mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-08-31 05:22:43 +00:00
32 lines
607 B
JavaScript
32 lines
607 B
JavaScript
![]() |
/*\
|
||
|
title: $:/core/modules/filters/before.js
|
||
|
type: application/javascript
|
||
|
module-type: filteroperator
|
||
|
|
||
|
Filter operator returning the tiddler from the current list that is before the tiddler named in the operand.
|
||
|
|
||
|
\*/
|
||
|
(function(){
|
||
|
|
||
|
/*jslint node: true, browser: true */
|
||
|
/*global $tw: false */
|
||
|
"use strict";
|
||
|
|
||
|
/*
|
||
|
Export our filter function
|
||
|
*/
|
||
|
exports.before = function(source,operator,options) {
|
||
|
var results = [];
|
||
|
source(function(tiddler,title) {
|
||
|
results.push(title);
|
||
|
});
|
||
|
var index = results.indexOf(operator.operand);
|
||
|
if(index <= 0) {
|
||
|
return [];
|
||
|
} else {
|
||
|
return [results[index - 1]];
|
||
|
}
|
||
|
};
|
||
|
|
||
|
})();
|