ronin/scripts/modules/terminal.widget.js
Devine Lu Linvega d9677f0fea Misc
2017-04-21 10:08:28 -10:00

57 lines
1.3 KiB
JavaScript

function Widget(rune)
{
Module.call(this,rune);
this.element = document.createElement("div");
this.element.setAttribute("id","widget");
this.install = function()
{
ronin.terminal.element.appendChild(this.element);
}
this.update = function()
{
var s = "";
s += ronin.terminal.file_name+" ";
s += "Cursor: "+ronin.cursor.widget();
this.element.innerHTML = s;
}
// this.widget = function()
// {
// if(!this.active_layer){ return ""; }
// return this.rune+" "+this.settings["size"].render();
// }
// // Widget
this.update_widget = function()
{
if(!this.active_layer){ return; }
var s = "";
s += "<span class='module'>";
for (var key in ronin.modules){
s += ronin.modules[key].widget() ? ronin.modules[key].widget()+" " : "";
}
s += "</span>";
s += "<span class='cursor'>"+ronin.cursor.mode.mouse_mode()+"</span>";
var keys = Object.keys(ronin.frame.layers);
var loc = keys.indexOf(this.active_layer.name);
if(keys.length > 1){
s += "<span class='layer'>"+ronin.frame.active_layer.widget()+"("+(loc+1)+"/"+keys.length+")</span>";
}
else{
s += "<span class='layer'>"+ronin.frame.active_layer.widget()+"</span>";
}
this.widget_element.innerHTML = s;
}
}