Added tag search

This commit is contained in:
kkapsner 2024-04-08 00:09:37 +02:00
parent 54c625cd26
commit 56401048d1
2 changed files with 18 additions and 9 deletions

View File

@ -19,17 +19,26 @@
texts.push({text: text.toLowerCase(), content}); texts.push({text: text.toLowerCase(), content});
}; };
scope.search = function(search){ scope.search = function(search){
const resultSets = search.toLowerCase().split(/\s+/).filter(function(term){ const resultSets = search.split(/\s+/).filter(function(term){
return term.trim(); return term.trim();
}).map(function(term){
return new RegExp(term);
}).map(function(term){ }).map(function(term){
const matching = new Set(); const matching = new Set();
texts.forEach(function(text){ if (term.match(/^:[a-z]+$/i)){
if (term.test(text.text)){ const tag = term.substring(1);
matching.add(text.content); texts.forEach(function(text){
} if (text.content.querySelector(`.${tag}`)){
}); matching.add(text.content);
}
});
}
else {
term = new RegExp(term.toLowerCase());
texts.forEach(function(text){
if (term.test(text.text)){
matching.add(text.content);
}
});
}
return matching; return matching;
}); });
if (resultSets.length){ if (resultSets.length){

View File

@ -3,7 +3,7 @@ Version 1.10.1:
- -
new features: new features:
- - added tag search
fixes: fixes:
- lag and functionality loss on google sites - lag and functionality loss on google sites