mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-20 19:29:43 +00:00
5faae2547d
Fixes #4130
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;
|
|
};
|
|
|
|
})();
|