Started to migrate methods to the new systems
This commit is contained in:
@@ -30,7 +30,7 @@ function Commander()
|
||||
for(method_id in q.methods){
|
||||
var method_param = q.methods[method_id];
|
||||
if(!ronin.modules[q.module].methods[method_id]){ console.log("Missing method",method_id); return; }
|
||||
ronin.modules[q.module].methods[method_id](method_param);
|
||||
ronin.modules[q.module].methods[method_id].run(method_param);
|
||||
}
|
||||
|
||||
ronin.commander.input_el.value = "";
|
||||
|
||||
@@ -19,10 +19,14 @@ function Hint()
|
||||
}
|
||||
|
||||
var target_module = ronin.commander.query().module;
|
||||
var target_method = Object.keys(ronin.commander.query().methods).length > 0 ? Object.keys(ronin.commander.query().methods)[0] : null
|
||||
|
||||
if(ronin.commander.input_el.value == ""){
|
||||
this.el.innerHTML = html;
|
||||
}
|
||||
else if(ronin.modules[target_module] && ronin.modules[target_module].methods[target_method]){
|
||||
this.el.innerHTML = this.pad(ronin.commander.input_el.value)+ronin.modules[target_module].methods[target_method].docs();
|
||||
}
|
||||
else if(ronin.modules[target_module]){
|
||||
this.el.innerHTML = this.pad(ronin.commander.input_el.value)+ronin.modules[target_module].hint();
|
||||
}
|
||||
|
||||
18
sources/scripts/core/method.js
Normal file
18
sources/scripts/core/method.js
Normal file
@@ -0,0 +1,18 @@
|
||||
function Method(name,params,info = "Missing documentation")
|
||||
{
|
||||
this.name = name;
|
||||
this.params = params;
|
||||
this.info = info;
|
||||
|
||||
this.run = null;
|
||||
|
||||
this.hint = function()
|
||||
{
|
||||
return "<b>"+this.name+"</b>:"+this.params+" ";
|
||||
}
|
||||
|
||||
this.docs = function()
|
||||
{
|
||||
return "["+this.params+"] <i>"+this.info+"</i>";
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ function Module(name,docs = "Missing documentation.")
|
||||
|
||||
for(id in this.methods){
|
||||
var v = this.methods[id];
|
||||
html += id+": ";
|
||||
html += v.hint();
|
||||
}
|
||||
|
||||
for(setting_id in this.settings){
|
||||
@@ -26,6 +26,6 @@ function Module(name,docs = "Missing documentation.")
|
||||
html += route_id+"->"+route_val+" ";
|
||||
}
|
||||
|
||||
return html.trim() != "" ? "<b>"+this.name+"</b> "+html.trim() : "";
|
||||
return html.trim() != "" ? " "+html.trim() : "";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user