mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 12:50:36 +01:00
Added tag search
This commit is contained in:
parent
54c625cd26
commit
56401048d1
@ -19,17 +19,26 @@
|
||||
texts.push({text: text.toLowerCase(), content});
|
||||
};
|
||||
scope.search = function(search){
|
||||
const resultSets = search.toLowerCase().split(/\s+/).filter(function(term){
|
||||
const resultSets = search.split(/\s+/).filter(function(term){
|
||||
return term.trim();
|
||||
}).map(function(term){
|
||||
return new RegExp(term);
|
||||
}).map(function(term){
|
||||
const matching = new Set();
|
||||
texts.forEach(function(text){
|
||||
if (term.test(text.text)){
|
||||
matching.add(text.content);
|
||||
}
|
||||
});
|
||||
if (term.match(/^:[a-z]+$/i)){
|
||||
const tag = term.substring(1);
|
||||
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;
|
||||
});
|
||||
if (resultSets.length){
|
||||
|
@ -3,7 +3,7 @@ Version 1.10.1:
|
||||
-
|
||||
|
||||
new features:
|
||||
-
|
||||
- added tag search
|
||||
|
||||
fixes:
|
||||
- lag and functionality loss on google sites
|
||||
|
Loading…
x
Reference in New Issue
Block a user