mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-20 19:29:43 +00:00
44 lines
940 B
JavaScript
44 lines
940 B
JavaScript
|
/*\
|
||
|
title: $:/core/modules/filters/next.js
|
||
|
type: application/javascript
|
||
|
module-type: filteroperator
|
||
|
|
||
|
Filter operator returning the tiddler whose title occurs next in the list supplied in the operand tiddler
|
||
|
|
||
|
\*/
|
||
|
(function(){
|
||
|
|
||
|
/*jslint node: true, browser: true */
|
||
|
/*global $tw: false */
|
||
|
"use strict";
|
||
|
|
||
|
/*
|
||
|
Export our filter function
|
||
|
*/
|
||
|
exports.next = function(source,operator,options) {
|
||
|
var results = [],
|
||
|
list = options.wiki.getTiddlerList(operator.operand);
|
||
|
|
||
|
function checkTiddler(title) {
|
||
|
var match = list.indexOf(title);
|
||
|
// increment match and then test if result is in range
|
||
|
match++;
|
||
|
if(match > 0 && match < list.length) {
|
||
|
results.push(list[match]);
|
||
|
}
|
||
|
}
|
||
|
// 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;
|
||
|
};
|
||
|
|
||
|
})();
|