1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-01 01:33:16 +00:00
TiddlyWiki5/core/modules/filters/previous.js

33 lines
704 B
JavaScript
Raw Normal View History

2013-09-22 08:58:18 +00:00
/*\
title: $:/core/modules/filters/previous.js
type: application/javascript
module-type: filteroperator
Filter operator returning the tiddler whose title occurs immediately prior in the list supplied in the operand tiddler
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter function
*/
exports.previous = function(source,operator,options) {
var results = [],
list = options.wiki.getTiddlerList(operator.operand);
source(function(tiddler,title) {
2013-09-22 08:58:18 +00:00
var match = list.indexOf(title);
// increment match and then test if result is in range
2013-09-22 08:58:18 +00:00
match--;
if(match >= 0) {
2013-09-22 08:58:18 +00:00
results.push(list[match]);
}
});
2013-09-22 08:58:18 +00:00
return results;
};
})();