mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-07-05 19:42:51 +00:00
Fix filter output
This commit is contained in:
parent
8ff0cb8650
commit
ddeb4fd6e6
@ -27,20 +27,14 @@ exports.inspect = function(source,operator,options) {
|
|||||||
prefix: function(filterRunPrefixFunction,operationFunction,innerOptions) {
|
prefix: function(filterRunPrefixFunction,operationFunction,innerOptions) {
|
||||||
return function(results,innerSource,innerWidget) {
|
return function(results,innerSource,innerWidget) {
|
||||||
var details ={
|
var details ={
|
||||||
|
input: results.toArray(),
|
||||||
prefixName: innerOptions.prefixName,
|
prefixName: innerOptions.prefixName,
|
||||||
operators: []
|
operators: []
|
||||||
};
|
};
|
||||||
currentRun = details.operators;
|
currentRun = details.operators;
|
||||||
var innerResults = filterRunPrefixFunction.call(this,operationFunction,innerOptions),
|
var innerResults = filterRunPrefixFunction.call(null,operationFunction,innerOptions);
|
||||||
prefixOutput = new $tw.utils.LinkedList();
|
innerResults(results,innerSource,innerWidget);
|
||||||
innerResults(prefixOutput,innerSource,innerWidget);
|
|
||||||
var prefixOutputArray = prefixOutput.toArray();
|
|
||||||
details.output = prefixOutputArray;
|
|
||||||
output.runs.push(details);
|
output.runs.push(details);
|
||||||
results.clear();
|
|
||||||
$tw.utils.each(prefixOutputArray,function(title) {
|
|
||||||
results.push(title);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
operator: function(operatorFunction,innerSource,innerOperator,innerOptions) {
|
operator: function(operatorFunction,innerSource,innerOperator,innerOptions) {
|
||||||
@ -52,17 +46,17 @@ exports.inspect = function(source,operator,options) {
|
|||||||
suffixes: innerOperator.suffixes,
|
suffixes: innerOperator.suffixes,
|
||||||
regexp: innerOperator.regexp,
|
regexp: innerOperator.regexp,
|
||||||
input: []
|
input: []
|
||||||
},
|
};
|
||||||
innerResults = operatorFunction.apply(self,Array.prototype.slice.call(arguments,1));
|
|
||||||
innerSource(function(tiddler,title) {
|
innerSource(function(tiddler,title) {
|
||||||
details.input.push(title);
|
details.input.push(title);
|
||||||
});
|
});
|
||||||
currentRun.push(details);
|
currentRun.push(details);
|
||||||
|
var innerResults = operatorFunction.apply(null,Array.prototype.slice.call(arguments,1));
|
||||||
return innerResults;
|
return innerResults;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
output.output = compiledFilter.call(this,source,options.widget);
|
output.output = compiledFilter.call(options.wiki,source,options.widget);
|
||||||
var results = [];
|
var results = [];
|
||||||
results.push(JSON.stringify(output,null,4));
|
results.push(JSON.stringify(output,null,4));
|
||||||
return results;
|
return results;
|
||||||
|
@ -29,6 +29,7 @@ title: ExpectedResult
|
|||||||
],
|
],
|
||||||
"runs": [
|
"runs": [
|
||||||
{
|
{
|
||||||
|
"input": [],
|
||||||
"prefixName": "or",
|
"prefixName": "or",
|
||||||
"operators": [
|
"operators": [
|
||||||
{
|
{
|
||||||
@ -42,12 +43,12 @@ title: ExpectedResult
|
|||||||
"Output"
|
"Output"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"output": [
|
},
|
||||||
|
{
|
||||||
|
"input": [
|
||||||
"1"
|
"1"
|
||||||
]
|
],
|
||||||
},
|
|
||||||
{
|
|
||||||
"prefixName": "or",
|
"prefixName": "or",
|
||||||
"operators": [
|
"operators": [
|
||||||
{
|
{
|
||||||
@ -61,12 +62,13 @@ title: ExpectedResult
|
|||||||
"Output"
|
"Output"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
|
||||||
"output": [
|
|
||||||
"2"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"input": [
|
||||||
|
"1",
|
||||||
|
"2"
|
||||||
|
],
|
||||||
"prefixName": "or",
|
"prefixName": "or",
|
||||||
"operators": [
|
"operators": [
|
||||||
{
|
{
|
||||||
@ -80,13 +82,12 @@ title: ExpectedResult
|
|||||||
"Output"
|
"Output"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
|
||||||
"output": [
|
|
||||||
"3"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"output": [
|
"output": [
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
"3"
|
"3"
|
||||||
]
|
]
|
||||||
}</p>
|
}</p>
|
@ -18,9 +18,9 @@ The JSON object contains the following properties:
|
|||||||
* `output`: the output titles resulting from evaluating the filter
|
* `output`: the output titles resulting from evaluating the filter
|
||||||
* `runs`: an array of objects, each of which represents a single run of the filter. Each object contains the following properties:
|
* `runs`: an array of objects, each of which represents a single run of the filter. Each object contains the following properties:
|
||||||
** `prefixName`: the name of the prefix operator that was used in this run
|
** `prefixName`: the name of the prefix operator that was used in this run
|
||||||
|
** `input`: the input titles passed to the prefix operator
|
||||||
** `operators`: an array of objects, each of which represents a single operator that was used in this run. Each object contains the following properties:
|
** `operators`: an array of objects, each of which represents a single operator that was used in this run. Each object contains the following properties:
|
||||||
*** `operatorName`: the name of the operator
|
*** `operatorName`: the name of the operator
|
||||||
*** `operands`: an array of string operands passed to the operator
|
*** `operands`: an array of string operands passed to the operator
|
||||||
*** `input`: the input titles passed to the operator
|
*** `input`: the input titles passed to the operator
|
||||||
** `output`: the output titles resulting from evaluating this run
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user