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:
parent
e11282cc08
commit
737e9ae4cb
@ -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;
|
||||
}
|
||||
};
|
||||
|
@ -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]] |
|
||||
|
Loading…
Reference in New Issue
Block a user