mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-08-18 19:59:25 +00:00
![Jeremy Ruston](/assets/img/avatar_default.png)
Long overdue rewrite to make it simpler, and break the filter operators out into individual modules.
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"];
|
|
}
|
|
};
|
|
|
|
})();
|