2022-05-06 14:01:17 +00:00
|
|
|
/*\
|
|
|
|
title: $:/core/modules/filters/unknown.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: filteroperator
|
|
|
|
|
2022-05-11 13:52:25 +00:00
|
|
|
Filter operator for handling unknown filter operators.
|
|
|
|
|
|
|
|
Not intended to be used directly by end users, hence the square brackets around the name.
|
2022-05-06 14:01:17 +00:00
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var fieldFilterOperatorFn = require("$:/core/modules/filters/field.js").field;
|
|
|
|
|
|
|
|
/*
|
|
|
|
Export our filter function
|
|
|
|
*/
|
2022-05-11 13:52:25 +00:00
|
|
|
exports["[unknown]"] = function(source,operator,options) {
|
2022-09-03 15:57:38 +00:00
|
|
|
// Check for a user defined filter operator
|
2022-05-23 15:40:21 +00:00
|
|
|
if(operator.operator.charAt(0) === ".") {
|
2023-01-21 22:07:34 +00:00
|
|
|
var variableInfo = options.widget && options.widget.getVariableInfo && options.widget.getVariableInfo(operator.operator);
|
|
|
|
if(variableInfo && variableInfo.srcVariable && variableInfo.srcVariable.isFunctionDefinition) {
|
|
|
|
var list = options.widget.evaluateVariable(operator.operator,{params: operator.operands, source: source});
|
2022-05-23 15:40:21 +00:00
|
|
|
if(operator.prefix === "!") {
|
|
|
|
var results = [];
|
|
|
|
source(function(tiddler,title) {
|
|
|
|
if(list.indexOf(title) === -1) {
|
|
|
|
results.push(title);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return results;
|
2022-05-09 17:00:09 +00:00
|
|
|
} else {
|
2022-05-23 15:40:21 +00:00
|
|
|
return list;
|
|
|
|
}
|
2022-05-06 14:01:17 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-03 15:57:38 +00:00
|
|
|
// Otherwise, use the "field" operator
|
2022-05-23 15:40:21 +00:00
|
|
|
return fieldFilterOperatorFn(source,operator,options);
|
2022-05-06 14:01:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
})();
|