2013-10-23 22:11:41 +00:00
|
|
|
/*\
|
|
|
|
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) {
|
2014-04-03 19:49:16 +00:00
|
|
|
var results = [];
|
2021-09-20 07:25:53 +00:00
|
|
|
if(operator.operands.length >= 2) {
|
|
|
|
// Return the modules that have the module property specified in the first operand with the value in the second operand
|
|
|
|
source(function(tiddler,title) {
|
|
|
|
$tw.utils.each($tw.modules.types[title],function(moduleInfo,moduleName) {
|
|
|
|
if(require(moduleName)[operator.operands[0]] === operator.operands[1]) {
|
|
|
|
results.push(moduleName);
|
|
|
|
}
|
|
|
|
});
|
2013-10-23 22:11:41 +00:00
|
|
|
});
|
2021-09-20 07:25:53 +00:00
|
|
|
} else {
|
|
|
|
// Return all the module names without filtering
|
|
|
|
source(function(tiddler,title) {
|
|
|
|
$tw.utils.each($tw.modules.types[title],function(moduleInfo,moduleName) {
|
|
|
|
results.push(moduleName);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2013-10-23 22:11:41 +00:00
|
|
|
results.sort();
|
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|