mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-19 02:39:42 +00:00
f48701544e
Now the $:/ part of the name is rendered in grey, making the main part of the title more prominent. @tobibeer suggested this a long time ago; good idea!
41 lines
956 B
JavaScript
41 lines
956 B
JavaScript
/*\
|
|
title: $:/core/modules/filters/removeprefix.js
|
|
type: application/javascript
|
|
module-type: filteroperator
|
|
|
|
Filter operator for removing a prefix from each title in the list. Titles that do not start with the prefix are removed.
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
/*
|
|
Export our filter function
|
|
*/
|
|
exports.removeprefix = function(source,operator,options) {
|
|
var results = [];
|
|
// Function to check an individual title
|
|
function checkTiddler(title) {
|
|
var match = title.substr(0,operator.operand.length).toLowerCase() === operator.operand.toLowerCase();
|
|
if(match) {
|
|
results.push(title.substr(operator.operand.length));
|
|
}
|
|
}
|
|
// Iterate through the source tiddlers
|
|
if($tw.utils.isArray(source)) {
|
|
$tw.utils.each(source,function(title) {
|
|
checkTiddler(title);
|
|
});
|
|
} else {
|
|
$tw.utils.each(source,function(element,title) {
|
|
checkTiddler(title);
|
|
});
|
|
}
|
|
return results;
|
|
};
|
|
|
|
})();
|