|
|
|
@ -16,7 +16,7 @@ function locomotive_Update(data) {
|
|
|
|
|
locomotives[i].name = data.name;
|
|
|
|
|
locomotives[i].ifname = data.ifname;
|
|
|
|
|
locomotives[i].addr = data.addr;
|
|
|
|
|
locomotives[i].steps = data.steps;
|
|
|
|
|
locomotives[i].stepcode = data.stepcode;
|
|
|
|
|
locomotives[i].speed = data.speed;
|
|
|
|
|
locomotives[i].vmin = data.vmin;
|
|
|
|
|
locomotives[i].vslow = data.vslow;
|
|
|
|
@ -24,6 +24,9 @@ function locomotive_Update(data) {
|
|
|
|
|
locomotives[i].vfast = data.vfast;
|
|
|
|
|
locomotives[i].vmax = data.vmax;
|
|
|
|
|
locomotives[i].flags = data.flags;
|
|
|
|
|
|
|
|
|
|
locodetail_setData(locomotives[i]);
|
|
|
|
|
lococtrl_setData(data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -123,7 +126,11 @@ function locodetail_show(loconame) {
|
|
|
|
|
<tr><td>Vmax:</td><td><input id=\"locodet_vmax\" style=\"width: 50\"></td><td><button id=\"locodet_btnvmax\" type=\"button\" value=\"vmax\">X</button> </td></tr> \
|
|
|
|
|
</table></td></fieldset> \
|
|
|
|
|
<td> \
|
|
|
|
|
Steps: <input id=\"locodet_steps\" style=\"width: 50\"><br> \
|
|
|
|
|
<fieldset><legend>Code</legend> \
|
|
|
|
|
<label><input type=\"radio\" id=\"locodet_DCC14\" name=\"STEPCODE\" value=\"1\">DCC14</label><br> \
|
|
|
|
|
<label><input type=\"radio\" id=\"locodet_DCC28\" name=\"STEPCODE\" value=\"2\">DCC28</label><br> \
|
|
|
|
|
<label><input type=\"radio\" id=\"locodet_DCC128\" name=\"STEPCODE\" value=\"3\">DCC128</label><br> \
|
|
|
|
|
</fieldset> \
|
|
|
|
|
Speed: <input id=\"locodet_speed\" style=\"width: 50\"><br> \
|
|
|
|
|
<label><input id=\"locodet_reverse\" type=\"checkbox\" value=\"\"> Reverse</label> \
|
|
|
|
|
</td></tr></table></div> <hr>\
|
|
|
|
@ -143,6 +150,10 @@ function locodetail_show(loconame) {
|
|
|
|
|
gAddEventListener("locodet_btnvmax", 'click', locodetail_cb_btnmove);
|
|
|
|
|
gAddEventListener("locodet_reverse", 'click', locodetail_cb_reverse);
|
|
|
|
|
|
|
|
|
|
// gAddEventListener("locodet_DCC14", 'click', locodetail_cb_stepcode);
|
|
|
|
|
// gAddEventListener("locodet_DCC28", 'click', locodetail_cb_stepcode);
|
|
|
|
|
// gAddEventListener("locodet_DCC128", 'click', locodetail_cb_stepcode);
|
|
|
|
|
|
|
|
|
|
gAddEventListener("locodet_CLOSE", 'click', locodetail_cb_close);
|
|
|
|
|
gAddEventListener("locodet_DELETE", 'click', locodetail_cb_delete);
|
|
|
|
|
gAddEventListener("locodet_SAVE", 'click', locodetail_cb_save);
|
|
|
|
@ -165,7 +176,6 @@ function locodetail_show(loconame) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// reverse selected, setup flags
|
|
|
|
|
function locodetail_cb_reverse () {
|
|
|
|
@ -182,8 +192,6 @@ function locodetail_cb_reverse () {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function locodetail_cb_btnmove () {
|
|
|
|
|
var win = document.getElementById("locodetail");
|
|
|
|
|
var loco_name = document.getElementById("locodet_name");
|
|
|
|
@ -217,6 +225,7 @@ function locodetail_cb_close () {
|
|
|
|
|
if (win) document.body.removeChild(win);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Callback: Delete Button
|
|
|
|
|
//
|
|
|
|
@ -296,7 +305,6 @@ function locodetail_setData(elm) {
|
|
|
|
|
var loco_addr = document.getElementById("locodet_addr");
|
|
|
|
|
var loco_speed = document.getElementById("locodet_speed");
|
|
|
|
|
var loco_flags = document.getElementById("locodet_flags");
|
|
|
|
|
var loco_steps = document.getElementById("locodet_steps");
|
|
|
|
|
var loco_vmin = document.getElementById("locodet_vmin");
|
|
|
|
|
var loco_vslow = document.getElementById("locodet_vslow");
|
|
|
|
|
var loco_vmid = document.getElementById("locodet_vmid");
|
|
|
|
@ -310,7 +318,6 @@ function locodetail_setData(elm) {
|
|
|
|
|
if (loco_flags) loco_flags.value = elm.flags;
|
|
|
|
|
if (loco_addr) loco_addr.value = elm.addr;
|
|
|
|
|
if (loco_speed) loco_speed.value = elm.speed;
|
|
|
|
|
if (loco_steps) loco_steps.value = elm.steps;
|
|
|
|
|
if (loco_vmin) loco_vmin.value = elm.vmin;
|
|
|
|
|
if (loco_vslow) loco_vslow.value = elm.vslow;
|
|
|
|
|
if (loco_vmid) loco_vmid.value = elm.vmid;
|
|
|
|
@ -322,6 +329,13 @@ function locodetail_setData(elm) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var codes = document.getElementsByName('STEPCODE');
|
|
|
|
|
for(var i = 0; i < codes.length; i++) {
|
|
|
|
|
// debug ("STEPCODE: elm.stepcode: " + elm.stepcode + " i:" + i + " codes[i].value: " + codes[i].value + " codes.id: " + codes[i].id);
|
|
|
|
|
if(elm.stepcode == codes[i].value) codes[i].checked = true;
|
|
|
|
|
else codes[i].checked = false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -330,31 +344,191 @@ function locodetail_setData(elm) {
|
|
|
|
|
// return all elements from the dialogbox
|
|
|
|
|
//
|
|
|
|
|
function locodetail_getData() {
|
|
|
|
|
var res = { name: "", ifname: "", addr: "", flags: 0, steps: "",
|
|
|
|
|
var res = { name: "", ifname: "", addr: "", flags: 0, stepcode:"0",
|
|
|
|
|
vmin: "20", vslow: "40", vmid:"60", vfast:"80", vmax:"100" };
|
|
|
|
|
|
|
|
|
|
var codes = document.getElementsByName('STEPCODE');
|
|
|
|
|
for(var i = 0; i < codes.length; i++){
|
|
|
|
|
if(codes[i].checked){
|
|
|
|
|
res.stepcode = codes[i].value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var loco_name = document.getElementById("locodet_name");
|
|
|
|
|
var loco_ifname = document.getElementById("locodet_ifname");
|
|
|
|
|
var loco_flags = document.getElementById("locodet_flags");
|
|
|
|
|
var loco_addr = document.getElementById("locodet_addr");
|
|
|
|
|
var loco_steps = document.getElementById("locodet_steps");
|
|
|
|
|
var loco_vmin = document.getElementById("locodet_vmin");
|
|
|
|
|
var loco_vslow = document.getElementById("locodet_vslow");
|
|
|
|
|
var loco_vmid = document.getElementById("locodet_vmid");
|
|
|
|
|
var loco_vfast = document.getElementById("locodet_vfast");
|
|
|
|
|
var loco_vmax = document.getElementById("locodet_vmax");
|
|
|
|
|
var loco_speed = document.getElementById("locodet_speed");
|
|
|
|
|
|
|
|
|
|
if (loco_name) res.name = loco_name.value;
|
|
|
|
|
if (loco_ifname) res.ifname = loco_ifname.value;
|
|
|
|
|
if (loco_flags) res.flags = loco_flags.value;
|
|
|
|
|
if (loco_addr) res.addr = loco_addr.value;
|
|
|
|
|
if (loco_steps) res.steps = loco_steps.value;
|
|
|
|
|
if (loco_vmin) res.vmin = loco_vmin.value;
|
|
|
|
|
if (loco_vslow) res.vslow = loco_vslow.value;
|
|
|
|
|
if (loco_vmid) res.vmid = loco_vmid.value;
|
|
|
|
|
if (loco_vfast) res.vfast = loco_vfast.value;
|
|
|
|
|
if (loco_vmax) res.vmax = loco_vmax.value;
|
|
|
|
|
if (loco_speed) res.speed = loco_speed.speed;
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***********************************************************************************************
|
|
|
|
|
// ***********************************************************************************************
|
|
|
|
|
// locolist: show a list of locomotives.
|
|
|
|
|
//
|
|
|
|
|
// ***********************************************************************************************
|
|
|
|
|
// ***********************************************************************************************
|
|
|
|
|
function locolist_show() {
|
|
|
|
|
var win = document.getElementById("locolist");
|
|
|
|
|
|
|
|
|
|
debug ("locolist_show");
|
|
|
|
|
|
|
|
|
|
if (!win) {
|
|
|
|
|
debug ("locolist_show create window");
|
|
|
|
|
win = gWindowCreate("locolist", "Locomotives", 400, 500, " \
|
|
|
|
|
<div id=\"locolist_listdiv\"> \
|
|
|
|
|
<ul id=\"locolist_elements\" style=\"list-style-type:none\"></ul> \
|
|
|
|
|
</div> \
|
|
|
|
|
<div align=right> \
|
|
|
|
|
<button id=\"locolist_CLOSE\" type=\"button\">Close</button> \
|
|
|
|
|
</div> \
|
|
|
|
|
\
|
|
|
|
|
");
|
|
|
|
|
|
|
|
|
|
gAddEventListener("locolist_CLOSE", 'click', locolist_cb_close);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ul = document.getElementById("locolist_elements");
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// clear list
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// append all locomotives
|
|
|
|
|
for (var i = 0; i < locomotives.length; i++) {
|
|
|
|
|
let li = document.createElement("li");
|
|
|
|
|
li.appendChild(document.createTextNode(locomotives[i].name));
|
|
|
|
|
li.setAttribute("id", "locol_elm_"+locomotives[i].name);
|
|
|
|
|
ul.appendChild(li);
|
|
|
|
|
|
|
|
|
|
gAddEventListener("locol_elm_"+locomotives[i].name, 'click', locolist_clicked);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function locolist_clicked() {
|
|
|
|
|
var i;
|
|
|
|
|
|
|
|
|
|
debug ("childnodes: " + this.childNodes[0].textContent);
|
|
|
|
|
lococtrl_show(this.childNodes[0].textContent);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function locolist_cb_close () {
|
|
|
|
|
var win = document.getElementById("locolist");
|
|
|
|
|
|
|
|
|
|
if (win) document.body.removeChild(win);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***********************************************************************************************
|
|
|
|
|
// ***********************************************************************************************
|
|
|
|
|
// locoshow: show controls for a loco loco_NAME
|
|
|
|
|
//
|
|
|
|
|
// ***********************************************************************************************
|
|
|
|
|
// ***********************************************************************************************
|
|
|
|
|
function lococtrl_show(name) {
|
|
|
|
|
var win = document.getElementById("lococtrl_"+name);
|
|
|
|
|
var i;
|
|
|
|
|
|
|
|
|
|
debug ("lococtrl_show:" + name);
|
|
|
|
|
|
|
|
|
|
if (!win) {
|
|
|
|
|
debug ("locolist_show create window");
|
|
|
|
|
win = gWindowCreate("lococtrl_"+name, "Loco:"+name, 200, 500, " \
|
|
|
|
|
<div> \
|
|
|
|
|
Speed: <div id=\"lococtrl_"+name+"_SPEED\"></div> \
|
|
|
|
|
<table><tr><td> \
|
|
|
|
|
<input id=\"lococtrl_"+name+"_RANGE\" name=\""+name+"\" type=\"range\" orient=\"vertical\" \
|
|
|
|
|
style=\"-webkit-appearance: slider-vertical; width: 10px; height: 100px;\"\
|
|
|
|
|
min=\"0\" value=\"0\" max=\"100\" > \
|
|
|
|
|
<br><button id=\"lococtrl_"+name+"_REVBTN\" type=\"button\">REV</button> \
|
|
|
|
|
</td><td> \
|
|
|
|
|
</td></tr></table></div> \
|
|
|
|
|
<div align=right> \
|
|
|
|
|
<button id=\"lococtrl_"+name+"_CLOSE\" type=\"button\" value=\""+name+"\">Close</button> \
|
|
|
|
|
</div> \
|
|
|
|
|
\
|
|
|
|
|
");
|
|
|
|
|
|
|
|
|
|
gAddEventListener("lococtrl_"+name+"_RANGE", 'click', lococtrl_speed);
|
|
|
|
|
gAddEventListener("lococtrl_"+name+"_REVBTN", 'click', lococtrl_reverse);
|
|
|
|
|
gAddEventListener("lococtrl_"+name+"_CLOSE", 'click', lococtrl_close);
|
|
|
|
|
}
|
|
|
|
|
for (var i = 0; i < locomotives.length; i++) {
|
|
|
|
|
if (name == locomotives[i].name) lococtrl_setData(locomotives[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function lococtrl_reverse() {
|
|
|
|
|
var name = getTextBetween(this.id, "lococtrl_", "_REVBTN");
|
|
|
|
|
var reverse;
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < locomotives.length; i++) {
|
|
|
|
|
if (name == locomotives[i].name) {
|
|
|
|
|
if (locomotives[i].flags & 1) reverse = 0;
|
|
|
|
|
else reverse = 1;
|
|
|
|
|
locomotive_server_Set ({name: name, reverse: reverse});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function lococtrl_speed() {
|
|
|
|
|
var name = getTextBetween(this.id, "lococtrl_", "_RANGE");
|
|
|
|
|
|
|
|
|
|
debug ("Speed Loco:'"+name+"' Speed:'"+this.value+"'");
|
|
|
|
|
for (var i = 0; i < locomotives.length; i++) {
|
|
|
|
|
if (name == locomotives[i].name) {
|
|
|
|
|
locomotive_server_Set ({name: name, speed: this.value});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function lococtrl_setData(data) {
|
|
|
|
|
var range = document.getElementById("lococtrl_"+data.name+"_RANGE");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (range) {
|
|
|
|
|
debug ("lococtrl: speed:" + data.speed);
|
|
|
|
|
range.min = 0;
|
|
|
|
|
range.max = data.vmax;
|
|
|
|
|
range.value = Math.abs(data.speed);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function lococtrl_close() {
|
|
|
|
|
debug ("LocoCtrl_close:" + this.value);
|
|
|
|
|
|
|
|
|
|
var win = document.getElementById("lococtrl_"+this.value);
|
|
|
|
|
if (win) document.body.removeChild(win);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|