mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-09-20 00:30:43 +00:00
Refactoring module mechanism
Changed the data structure $tw.modules.types to make it possible to detect repeated registrations
This commit is contained in:
@@ -93,23 +93,17 @@ Commander.prototype.executeNextCommand = function() {
|
||||
};
|
||||
|
||||
Commander.initCommands = function(moduleType) {
|
||||
// Install the command modules
|
||||
moduleType = moduleType || "command";
|
||||
$tw.commands = {};
|
||||
var modules = $tw.modules.types[moduleType],
|
||||
n,m,f,c;
|
||||
if(modules) {
|
||||
for(n=0; n<modules.length; n++) {
|
||||
m = modules[n];
|
||||
$tw.commands[m.info.name] = {};
|
||||
c = $tw.commands[m.info.name];
|
||||
// Add the methods defined by the module
|
||||
for(f in m) {
|
||||
c[f] = m[f];
|
||||
$tw.modules.forEachModuleOfType(moduleType,function(title,module) {
|
||||
var c = $tw.commands[module.info.name] = {};
|
||||
// Add the methods defined by the module
|
||||
for(var f in module) {
|
||||
if($tw.utils.hop(module,f)) {
|
||||
c[f] = module[f];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
exports.Commander = Commander;
|
||||
|
||||
Reference in New Issue
Block a user