diff --git a/core/modules/filters/is.js b/core/modules/filters/is.js index c1add6f61..b75943786 100644 --- a/core/modules/filters/is.js +++ b/core/modules/filters/is.js @@ -26,45 +26,23 @@ function getIsFilterOperators() { Export our filter function */ exports.is = function(source,operator,options) { - - var isFilterOperators = getIsFilterOperators(), - subops = operator.operand.split("+"), - num_of_subops = subops.length; - - //Make sure all the operands are defined. - for (var t = 0; t < num_of_subops; t++){ - if( !isFilterOperators[subops[t]] ) { + // Dispatch to the correct isfilteroperator + var isFilterOperators = getIsFilterOperators(); + if(operator.operand) { + var isFilterOperator = isFilterOperators[operator.operand]; + if(isFilterOperator) { + return isFilterOperator(source,operator.prefix,options); + } else { return [$tw.language.getString("Error/IsFilterOperator")]; } - } - - if(num_of_subops === 0) { // Return all tiddlers if the operand is missing + } else { + // Return all tiddlers if the operand is missing var results = []; source(function(tiddler,title) { results.push(title); }); - return results; - } else if(num_of_subops === 1) { // Shortcut the Single Operator - var operator = isFilterOperators[subops[0]]; - return operator(source,operator.prefix,options); - - } else { // Handle multiple operators - var filtered_results = {}, - results = []; - for(var t=0; t < num_of_subops; t++){ - var operator = isFilterOperators[subops[t]]; - operator(source,operator.prefix,options).forEach(function(element) { filtered_results[element] = "present"}); - } - - // Sort the output by the input (There may be a better way to do this) - source(function(tiddler,title) { - if(filtered_results[title] === "present") { - results.push(title); - } - }); - return results; } }; -})(); +})(); \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/filters/is.tid b/editions/tw5.com/tiddlers/filters/is.tid index 51725e19d..bd33d11a6 100644 --- a/editions/tw5.com/tiddlers/filters/is.tid +++ b/editions/tw5.com/tiddlers/filters/is.tid @@ -11,11 +11,7 @@ op-parameter-name: C op-output: those input tiddlers that belong to category <<.place C>> op-neg-output: those input tiddlers that do <<.em not>> belong to category <<.place C>> -The parameter <<.place C>> specifies zero or more fundamental categories using the following syntax: - -<$railroad text=""" -[{: ("current" | "missing" |: "orphan" | "shadow" | "system" | "tag" | "tiddler" | "image") +"+" }] -"""/> +The parameter <<.place C>> is one of the following fundamental categories: |!Category |!Matches any tiddler that... | |^`current` |is the [[current tiddler|Current Tiddler]] | @@ -35,4 +31,4 @@ When <<.op is[missing]>> is the first operator in a [[run|Filter Run]], its outp The <<.olink all>> operator is similar, but its scope is the whole wiki. -<<.operator-examples "is">> +<<.operator-examples "is">> \ No newline at end of file