mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-08-20 14:45:59 +00:00
40 lines
868 B
JavaScript
40 lines
868 B
JavaScript
![]() |
/*\
|
||
|
title: $:/core/modules/filters/is.js
|
||
|
type: application/javascript
|
||
|
module-type: filteroperator
|
||
|
|
||
|
Filter operator for checking tiddler properties
|
||
|
|
||
|
\*/
|
||
|
(function(){
|
||
|
|
||
|
/*jslint node: true, browser: true */
|
||
|
/*global $tw: false */
|
||
|
"use strict";
|
||
|
|
||
|
var isFilterOperators;
|
||
|
|
||
|
function getIsFilterOperators() {
|
||
|
if(!isFilterOperators) {
|
||
|
isFilterOperators = {};
|
||
|
$tw.modules.applyMethods("isfilteroperator",isFilterOperators);
|
||
|
}
|
||
|
return isFilterOperators;
|
||
|
};
|
||
|
|
||
|
/*
|
||
|
Export our filter function
|
||
|
*/
|
||
|
exports.is = function(source,operator,options) {
|
||
|
// Dispatch to the correct isfilteroperator
|
||
|
var isFilterOperators = getIsFilterOperators();
|
||
|
var isFilterOperator = isFilterOperators[operator.operand];
|
||
|
if(isFilterOperator) {
|
||
|
return isFilterOperator(source,operator.prefix,options);
|
||
|
} else {
|
||
|
return ["Filter Error: Unknown operand for the 'is' filter operator"];
|
||
|
}
|
||
|
};
|
||
|
|
||
|
})();
|