Started to migrate methods to the new systems

This commit is contained in:
Devine Lu Linvega
2017-11-07 16:51:01 +13:00
parent 1c261cf166
commit 021f2fc048
10 changed files with 60 additions and 42 deletions

View File

@@ -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 = "";

View File

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

View 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>";
}
}

View File

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