mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Add new "order" filter operator
This commit is contained in:
parent
a3dc3b4b98
commit
9a38642141
@ -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
|
||||
*/
|
||||
|
15
editions/tw5.com/tiddlers/filters/order_Operator.tid
Normal file
15
editions/tw5.com/tiddlers/filters/order_Operator.tid
Normal 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">>
|
Loading…
Reference in New Issue
Block a user