1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-11 09:50:27 +00:00

Added "prefix" filter

It selects tiddlers whose title starts with a given string
This commit is contained in:
Jeremy Ruston 2012-05-29 22:01:07 +01:00
parent 2a1b0cec00
commit b91ccb064b

View File

@ -84,6 +84,16 @@ exports.operators = {
return "if(subResults.indexOf(\"" + $tw.utils.stringify(operator.operand) + "\") !== -1) {subResults = [\"" + $tw.utils.stringify(operator.operand) + "\"];} else {subResults = [];}";
}
},
"prefix": {
selector: function(operator) {
var op = operator.prefix === "!" ? "!" : "";
return "for(var title in source) {if(" + op + "title.substr(0,\"" + operator.operand.length + "\")===\"" + $tw.utils.stringify(operator.operand) + "\") {$tw.utils.pushTop(subResults,title);}}";
},
filter: function(operator) {
var op = operator.prefix === "!" ? "" : "!";
return "for(var r=subResults.length-1; r>=0; r--) {if(" + op + "title.substr(0,\"" + operator.operand.length + "\")===\"" + $tw.utils.stringify(operator.operand) + "\") {subResults.splice(r,1);}}";
}
},
"is": {
selector: function(operator) {
if(operator.operand === "tiddler") {