70 lines
1.7 KiB
JavaScript
70 lines
1.7 KiB
JavaScript
function Hint(element)
|
|
{
|
|
Module.call(this);
|
|
|
|
this.element = element;
|
|
|
|
this.update = function(module,cmd)
|
|
{
|
|
if(module){
|
|
this.element.innerHTML = this.message(module,cmd);
|
|
this.element.style.display = "block";
|
|
}
|
|
else if(commander && commander.element_input.value != ""){
|
|
this.element.innerHTML = commander.element_input.value;
|
|
this.element.style.display = "block";
|
|
}
|
|
else{
|
|
this.element.innerHTML = this.default();
|
|
this.element.style.display = "block";
|
|
}
|
|
}
|
|
|
|
this.message = function(module,cmd)
|
|
{
|
|
var s = this.pad(cmd.content.join(" "));
|
|
|
|
s += cmd.content.join(" ").length == 0 ? "<span class='module'>"+module.constructor.name+"</span>" : "";
|
|
|
|
// Params
|
|
|
|
var e = 0;
|
|
while(e < 10){
|
|
if(!module.parameters[e]){ break; }
|
|
var param_name = module.parameters[e].name;
|
|
s += cmd[param_name.toLowerCase()]() ? "" : "<span class='param'>"+param_name+"</span>";
|
|
e += 1;
|
|
}
|
|
|
|
// Variables
|
|
if(module.variables){
|
|
for (var key in module.variables){
|
|
if(cmd.variable(key)){continue;}
|
|
s += "<span class='variable_key'>"+key+"</span>=<span class='variable_value'>"+module.variables[key]+"</span> ";
|
|
}
|
|
}
|
|
|
|
return s;
|
|
}
|
|
|
|
this.pad = function(input)
|
|
{
|
|
var s = "";
|
|
for (i = 0; i < input.length+2; i++){
|
|
s += "_";
|
|
}
|
|
|
|
return "<span style='color:#000'>"+s+"</span>";
|
|
}
|
|
|
|
this.default = function()
|
|
{
|
|
var s = "<span class='module'>Modules</span>";
|
|
|
|
for (var key in ronin.modules){
|
|
s += "<span> <span class='value'>"+key+"</span> <span class='param'>"+ronin.modules[key].constructor.name.substr(0,2)+" ";
|
|
}
|
|
|
|
return s;
|
|
}
|
|
} |