Revert multiple suboperator functionality from the "is" operator

See the discussion here: https://github.com/Jermolene/TiddlyWiki5/pull/3240#issuecomment-388035466
This commit is contained in:
Jermolene 2018-05-10 13:15:49 +01:00
parent e11282cc08
commit 737e9ae4cb
2 changed files with 12 additions and 38 deletions

View File

@ -26,45 +26,23 @@ function getIsFilterOperators() {
Export our filter function Export our filter function
*/ */
exports.is = function(source,operator,options) { exports.is = function(source,operator,options) {
// Dispatch to the correct isfilteroperator
var isFilterOperators = getIsFilterOperators(), var isFilterOperators = getIsFilterOperators();
subops = operator.operand.split("+"), if(operator.operand) {
num_of_subops = subops.length; var isFilterOperator = isFilterOperators[operator.operand];
if(isFilterOperator) {
//Make sure all the operands are defined. return isFilterOperator(source,operator.prefix,options);
for (var t = 0; t < num_of_subops; t++){ } else {
if( !isFilterOperators[subops[t]] ) {
return [$tw.language.getString("Error/IsFilterOperator")]; return [$tw.language.getString("Error/IsFilterOperator")];
} }
} } else {
// Return all tiddlers if the operand is missing
if(num_of_subops === 0) { // Return all tiddlers if the operand is missing
var results = []; var results = [];
source(function(tiddler,title) { source(function(tiddler,title) {
results.push(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; return results;
} }
}; };
})(); })();

View File

@ -11,11 +11,7 @@ op-parameter-name: C
op-output: those input tiddlers that belong to category <<.place 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>> 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: The parameter <<.place C>> is one of the following fundamental categories:
<$railroad text="""
[{: ("current" | "missing" |: "orphan" | "shadow" | "system" | "tag" | "tiddler" | "image") +"+" }]
"""/>
|!Category |!Matches any tiddler that... | |!Category |!Matches any tiddler that... |
|^`current` |is the [[current tiddler|Current Tiddler]] | |^`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. The <<.olink all>> operator is similar, but its scope is the whole wiki.
<<.operator-examples "is">> <<.operator-examples "is">>