no longer used - functionality has been moved to _scriptcraft.js
This commit is contained in:
parent
f2e35337f3
commit
5f930b8df3
1 changed files with 14 additions and 23 deletions
|
@ -1,4 +1,3 @@
|
||||||
var rootDir = __folder;
|
|
||||||
/*
|
/*
|
||||||
This module is responsible for managing commands which can be used by non-operator.
|
This module is responsible for managing commands which can be used by non-operator.
|
||||||
Since by default the /js command is op-only , there needs to be a way to expose javascript
|
Since by default the /js command is op-only , there needs to be a way to expose javascript
|
||||||
|
@ -15,34 +14,26 @@ var rootDir = __folder;
|
||||||
|
|
||||||
2. The non-operator can now change the time to day...
|
2. The non-operator can now change the time to day...
|
||||||
/jsp time_set 0
|
/jsp time_set 0
|
||||||
|
plugin("command", {
|
||||||
|
|
||||||
TODO: Figure out how to persist the 'command' module's configuration so it can be saved/restored
|
register: function(name, func){
|
||||||
on server shutdown/startup. THis should be done in a generic way so other modules can use it.
|
this.store[name] = func;
|
||||||
|
|
||||||
*/
|
|
||||||
var command = command || {
|
|
||||||
|
|
||||||
register: function(/* String */ namedFunction){
|
|
||||||
//
|
|
||||||
// namedFunction must be in the global namespace for this to work
|
|
||||||
// JSON cannot persist functions.
|
|
||||||
//
|
|
||||||
if (typeof namedFunction !== "string")
|
|
||||||
throw new Error("Usage: command.register(/* String */ namedFunction)");
|
|
||||||
|
|
||||||
command.data[namedFunction] = true;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
invoke: function(){
|
invoke: function(){
|
||||||
if (__cmdArgs.length === 0)
|
if (__cmdArgs.length === 0)
|
||||||
throw new Error("Usage: jsp command-name command-parameters");
|
throw new Error("Usage: jsp command-name command-parameters");
|
||||||
var cmdName = __cmdArgs[0];
|
var name = __cmdArgs[0];
|
||||||
if (typeof command.data[cmdName] === "undefined")
|
var func = this.store[name]
|
||||||
throw new Error("Command '" + cmdName + "' does not exist.");
|
if (typeof func === "undefined")
|
||||||
|
throw new Error("Command '" + name + "' does not exist.");
|
||||||
var params = [];
|
var params = [];
|
||||||
for (var i =1; i < __cmdArgs.length;i++){
|
for (var i =1; i < __cmdArgs.length;i++){
|
||||||
params.push("" + __cmdArgs[i]);
|
params.push("" + __cmdArgs[i]);
|
||||||
}
|
}
|
||||||
global[cmdName](params);
|
func(params);
|
||||||
},
|
}
|
||||||
data: {},
|
});
|
||||||
};
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
Reference in a new issue