mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-08-18 19:59:25 +00:00
![Jermolene](/assets/img/avatar_default.png)
I think it was a mistake for them to be case insensitive in the first place. https://groups.google.com/d/topic/tiddlywiki/dzpFsRCC5D8/discussion If case insensitivity is required then regexps can be used instead.
37 lines
713 B
JavaScript
37 lines
713 B
JavaScript
/*\
|
|
title: $:/core/modules/filters/suffix.js
|
|
type: application/javascript
|
|
module-type: filteroperator
|
|
|
|
Filter operator for checking if a title ends with a suffix
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
/*
|
|
Export our filter function
|
|
*/
|
|
exports.suffix = function(source,operator,options) {
|
|
var results = [];
|
|
if(operator.prefix === "!") {
|
|
source(function(tiddler,title) {
|
|
if(title.substr(-operator.operand.length) !== operator.operand) {
|
|
results.push(title);
|
|
}
|
|
});
|
|
} else {
|
|
source(function(tiddler,title) {
|
|
if(title.substr(-operator.operand.length) === operator.operand) {
|
|
results.push(title);
|
|
}
|
|
});
|
|
}
|
|
return results;
|
|
};
|
|
|
|
})();
|