mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-02 20:29:10 +00:00
commit
68930f333a
32
core/modules/filters/getindex.js
Normal file
32
core/modules/filters/getindex.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*\
|
||||||
|
title: $:/core/modules/filters/getindex.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: filteroperator
|
||||||
|
|
||||||
|
returns the value at a given index of datatiddlers
|
||||||
|
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Export our filter function
|
||||||
|
*/
|
||||||
|
exports.getIndex = function(source,operator,options) {
|
||||||
|
var data,title,results = [];
|
||||||
|
if(operator.operand){
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
title = tiddler ? tiddler.fields.title : title;
|
||||||
|
data = options.wiki.extractTiddlerDataItem(tiddler,operator.operand);
|
||||||
|
if(data) {
|
||||||
|
results.push(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
7
editions/tw5.com/tiddlers/filters/examples/getindex.tid
Normal file
7
editions/tw5.com/tiddlers/filters/examples/getindex.tid
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
created: 20150203140000000
|
||||||
|
modified: 20150203140000000
|
||||||
|
tags: [[getindex Operator]] [[Operator Examples]]
|
||||||
|
title: getindex Operator (Examples)
|
||||||
|
|
||||||
|
<<.operator-example 1 "[[$:/palettes/Vanilla]getindex[background]]" "returns the value at index ''background'' of the [[DataTiddler|DataTiddlers]] [[$:/palettes/Vanilla]]">>
|
||||||
|
<<.operator-example 2 "[tag[$:/tags/Palette]getindex[background]]" "returns all background colors defined in any of the ColourPalettes">>
|
17
editions/tw5.com/tiddlers/filters/getindex.tid
Normal file
17
editions/tw5.com/tiddlers/filters/getindex.tid
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
created: 20150203140000000
|
||||||
|
modified: 20150203140000000
|
||||||
|
tags: [[Filter Operators]] [[Field Operators]]
|
||||||
|
title: getindex Operator
|
||||||
|
caption: getindex
|
||||||
|
purpose: select all values of a data property in the input titles
|
||||||
|
|
||||||
|
<$macrocall $name=".operator-def"
|
||||||
|
input="a [[selection of titles|Title Selection]]"
|
||||||
|
parameter="the name of a [[property|DataTiddlers]]"
|
||||||
|
paramName="P"
|
||||||
|
output="the values of property <<.place P>> in each of the input titles"
|
||||||
|
/>
|
||||||
|
|
||||||
|
Each input title is processed in turn, and is ignored if it does not denote a [[data tiddler|DataTiddlers]]. If the tiddler contains property <<.place P>>, the value of that property is [[dominantly appended|Dominant Append]] to the output.
|
||||||
|
|
||||||
|
<<.operator-examples "getindex">>
|
Loading…
Reference in New Issue
Block a user