kopia lustrzana https://github.com/miklobit/TiddlyWiki5
Rename the operator portion after the colon to "suffix"
rodzic
42262a637c
commit
a76da88380
|
@ -44,7 +44,7 @@ function parseFilterOperation(operators,filterString,p) {
|
|||
// Any suffix?
|
||||
var colon = operator.operator.indexOf(':');
|
||||
if(colon > -1) {
|
||||
operator.field = operator.operator.substring(colon + 1);
|
||||
operator.suffix = operator.operator.substring(colon + 1);
|
||||
operator.operator = operator.operator.substring(0,colon) || "field";
|
||||
}
|
||||
// Empty operator means: title
|
||||
|
@ -186,7 +186,7 @@ exports.compileFilter = function(filterString) {
|
|||
operator: operator.operator,
|
||||
operand: operand,
|
||||
prefix: operator.prefix,
|
||||
field: operator.field,
|
||||
suffix: operator.suffix,
|
||||
regexp: operator.regexp
|
||||
},{
|
||||
wiki: self,
|
||||
|
|
|
@ -16,17 +16,17 @@ Filter operator for comparing fields for equality
|
|||
Export our filter function
|
||||
*/
|
||||
exports.field = function(source,operator,options) {
|
||||
var results = [];
|
||||
var results = [],
|
||||
fieldname = (operator.suffix || operator.operator).toLowerCase();
|
||||
// Function to check an individual title
|
||||
function checkTiddler(title) {
|
||||
var tiddler = options.wiki.getTiddler(title);
|
||||
if(tiddler) {
|
||||
var match,
|
||||
text = tiddler.getFieldString(operator.field);
|
||||
text = tiddler.getFieldString(fieldname);
|
||||
if(operator.regexp) {
|
||||
match = !! operator.regexp.exec(text);
|
||||
}
|
||||
else {
|
||||
match = !!operator.regexp.exec(text);
|
||||
} else {
|
||||
match = text === operator.operand;
|
||||
}
|
||||
if(operator.prefix === "!") {
|
||||
|
@ -38,10 +38,6 @@ exports.field = function(source,operator,options) {
|
|||
}
|
||||
}
|
||||
// Iterate through the source tiddlers
|
||||
if(!operator.field) {
|
||||
operator.field = operator.operator;
|
||||
}
|
||||
operator.field.toLowerCase();
|
||||
if($tw.utils.isArray(source)) {
|
||||
$tw.utils.each(source,function(title) {
|
||||
checkTiddler(title);
|
||||
|
|
Ładowanie…
Reference in New Issue