From 33505105161fe7d6d9f572bfded851291f07c5af Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Wed, 23 Oct 2013 23:11:41 +0100 Subject: [PATCH] Add new modules and moduletypes filter operators --- core/modules/filters/modules.js | 39 +++++++++++++++++++++++++++++ core/modules/widgets/moduletypes.js | 27 ++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 core/modules/filters/modules.js create mode 100644 core/modules/widgets/moduletypes.js diff --git a/core/modules/filters/modules.js b/core/modules/filters/modules.js new file mode 100644 index 000000000..bb9485876 --- /dev/null +++ b/core/modules/filters/modules.js @@ -0,0 +1,39 @@ +/*\ +title: $:/core/modules/filters/modules.js +type: application/javascript +module-type: filteroperator + +Filter operator for returning the titles of the modules of a given type in this wiki + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +/* +Export our filter function +*/ +exports.modules = function(source,operator,options) { + var results = [], + pushModules = function(type) { + $tw.utils.each($tw.modules.types[type],function(moduleInfo,moduleName) { + results.push(moduleName); + }); + }; + // Iterate through the source tiddlers + if($tw.utils.isArray(source)) { + $tw.utils.each(source,function(title) { + pushModules(title); + }); + } else { + $tw.utils.each(source,function(element,title) { + pushModules(title); + }); + } + results.sort(); + return results; +}; + +})(); diff --git a/core/modules/widgets/moduletypes.js b/core/modules/widgets/moduletypes.js new file mode 100644 index 000000000..67321caea --- /dev/null +++ b/core/modules/widgets/moduletypes.js @@ -0,0 +1,27 @@ +/*\ +title: $:/core/modules/filters/moduletypes.js +type: application/javascript +module-type: filteroperator + +Filter operator for returning the names of the module types in this wiki + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +/* +Export our filter function +*/ +exports.moduletypes = function(source,operator,options) { + var results = []; + $tw.utils.each($tw.modules.types,function(moduleInfo,type) { + results.push(type); + }); + results.sort(); + return results; +}; + +})();