2013-05-25 16:26:22 +00:00
|
|
|
/*\
|
|
|
|
title: $:/core/modules/filters/list.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: filteroperator
|
|
|
|
|
|
|
|
Filter operator returning the tiddlers whose title is listed in the operand tiddler
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/*
|
|
|
|
Export our filter function
|
|
|
|
*/
|
|
|
|
exports.list = function(source,operator,options) {
|
|
|
|
var results = [],
|
|
|
|
list = options.wiki.getTiddlerList(operator.operand);
|
|
|
|
function checkTiddler(title) {
|
|
|
|
var match = list.indexOf(title) !== -1;
|
|
|
|
if(operator.prefix === "!") {
|
|
|
|
match = !match;
|
|
|
|
}
|
|
|
|
if(match) {
|
|
|
|
results.push(title);
|
|
|
|
}
|
2013-07-05 21:37:55 +00:00
|
|
|
}
|
2013-05-25 16:26:22 +00:00
|
|
|
// Iterate through the source tiddlers
|
|
|
|
if($tw.utils.isArray(source)) {
|
|
|
|
$tw.utils.each(source,function(title) {
|
|
|
|
checkTiddler(title);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
if(operator.prefix !== "!") {
|
|
|
|
results = list;
|
|
|
|
} else {
|
|
|
|
$tw.utils.each(source,function(element,title) {
|
|
|
|
checkTiddler(title);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|