2014-03-13 17:40:53 +00:00
|
|
|
/*\
|
|
|
|
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 = [];
|
2014-04-03 19:49:16 +00:00
|
|
|
source(function(tiddler,title) {
|
2014-08-28 14:27:10 +00:00
|
|
|
if(title.substr(0,operator.operand.length) === operator.operand) {
|
2014-03-13 17:40:53 +00:00
|
|
|
results.push(title.substr(operator.operand.length));
|
|
|
|
}
|
2014-04-03 19:49:16 +00:00
|
|
|
});
|
2014-03-13 17:40:53 +00:00
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|