1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-28 11:00:27 +00:00

Text-slicer: Add list-children filter operator

Again, I needed this for the day job. @felixhayashi I think you
submitted a pull request for something similar, would this version meet
your needs?
This commit is contained in:
Jermolene 2016-02-05 18:46:01 +00:00
parent adf45b3468
commit 46800d790a

View File

@ -0,0 +1,38 @@
/*\
title: $:/core/modules/filters/list-children.js
type: application/javascript
module-type: filteroperator
Filter operator returning all the descendents of a tiddler listed in the "list" field
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter function
*/
exports["list-children"] = function(source,operator,options) {
var children = {},
processTiddler = function(title) {
var tiddler = options.wiki.getTiddler(title);
if(tiddler && !$tw.utils.hop(children,title)) {
children[title] = true;
var list = options.wiki.getTiddlerList(title,operator.operand);
list.forEach(function(listItem) {
if(!$tw.utils.hop(children,listItem)) {
processTiddler(listItem);
}
});
}
};
source(function(tiddler,title) {
processTiddler(title);
});
return Object.keys(children);
};
})();