1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-24 17:10:29 +00:00

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,43 +26,21 @@ 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;
}
};

View File

@ -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]] |