mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-08-29 20:42:44 +00:00
54 lines
1.1 KiB
JavaScript
54 lines
1.1 KiB
JavaScript
![]() |
/*\
|
||
|
title: $:/core/modules/filters/match.js
|
||
|
type: application/javascript
|
||
|
module-type: filteroperator
|
||
|
|
||
|
Filter operator for checking if a title matches a string
|
||
|
|
||
|
\*/
|
||
|
(function(){
|
||
|
|
||
|
/*jslint node: true, browser: true */
|
||
|
/*global $tw: false */
|
||
|
"use strict";
|
||
|
|
||
|
/*
|
||
|
Export our filter function
|
||
|
*/
|
||
|
exports.match = function(source,operator,options) {
|
||
|
var results = [],
|
||
|
suffixes = (operator.suffixes || [])[0] || [];
|
||
|
if(suffixes.indexOf("caseinsensitive") !== -1) {
|
||
|
if(operator.prefix === "!") {
|
||
|
source(function(tiddler,title) {
|
||
|
if(title.toLowerCase() !== (operator.operand || "").toLowerCase()) {
|
||
|
results.push(title);
|
||
|
}
|
||
|
});
|
||
|
} else {
|
||
|
source(function(tiddler,title) {
|
||
|
if(title.toLowerCase() === (operator.operand || "").toLowerCase()) {
|
||
|
results.push(title);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
} else {
|
||
|
if(operator.prefix === "!") {
|
||
|
source(function(tiddler,title) {
|
||
|
if(title !== operator.operand) {
|
||
|
results.push(title);
|
||
|
}
|
||
|
});
|
||
|
} else {
|
||
|
source(function(tiddler,title) {
|
||
|
if(title === operator.operand) {
|
||
|
results.push(title);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
return results;
|
||
|
};
|
||
|
|
||
|
})();
|