mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-10 06:19:42 +00:00
![Jermolene](/assets/img/avatar_default.png)
There are still some warnings about making functions in a loop, but I’ll fix those as a separate pull request because the fixes are more than typographic errors.
40 lines
867 B
JavaScript
40 lines
867 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"];
|
|
}
|
|
};
|
|
|
|
})();
|