1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-23 15:36:52 +00:00

Add new modules and moduletypes filter operators

This commit is contained in:
Jeremy Ruston 2013-10-23 23:11:41 +01:00
parent 3241c2b76a
commit 3350510516
2 changed files with 66 additions and 0 deletions

View File

@ -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;
};
})();

View File

@ -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;
};
})();