1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +00:00

Add new "order" filter operator

This commit is contained in:
Jermolene 2016-11-28 19:16:08 +00:00
parent a3dc3b4b98
commit 9a38642141
2 changed files with 32 additions and 0 deletions

View File

@ -12,6 +12,23 @@ Filter operators for manipulating the current selection list
/*global $tw: false */
"use strict";
/*
Order a list
*/
exports.order = function(source,operator,options) {
var results = [];
if(operator.operand.toLowerCase() === "reverse") {
source(function(tiddler,title) {
results.unshift(title);
});
} else {
source(function(tiddler,title) {
results.push(title);
});
}
return results;
};
/*
Reverse list
*/

View File

@ -0,0 +1,15 @@
caption: order
created: 20161128185907280
modified: 20161128191251557
op-input: a [[selection of titles|Title Selection]]
op-output: the input, with the order reversed if <<.field F>> is the special value `reverse`
op-parameter: Either the string `reverse` or another value
op-parameter-name: F
op-purpose: selectively reverse the input list
tags: [[Filter Operators]] [[Common Operators]] [[Field Operators]] [[Order Operators]]
title: order Operator
type: text/vnd.tiddlywiki
Either reverses or preserves the order of the input list according to whether the parameter is the special value `reverse`.
<<.operator-examples "order">>