origin
steffen 5 years ago
parent db2196b709
commit 7d66e1a77e

@ -39,7 +39,7 @@
<a href="#" onclick="intdetail_show(this);">Interfaces</a>
<a href="#" onclick="turndetail_show(this);">Turnouts</a>
<a href="#" onclick="locodetail_show(this);">Locomotives</a>
<a href="#" onclick="sensordetail_show(this);">Sensors</a>
<a href="#" onclick="sensorlist_show(this);">Sensors</a>
<a href="#" onclick="blockdetail_show(this);">Block</a>
</div>
</div>

@ -246,3 +246,67 @@ function sensordetail_getData() {
return res;
};
// ***********************************************************************************************
// ***********************************************************************************************
// sensorlist: show a list of sensors.
//
// ***********************************************************************************************
// ***********************************************************************************************
function sensorlist_show() {
var win = document.getElementById("sensorlist");
debug ("sensorlist_show");
if (!win) {
debug ("sensorlist_show create window");
win = gWindowCreate("sensorlist", "Sensors", 400, 500, " \
<div id=\"sensorlist_listdiv\"> \
<ul id=\"sensorlist_elements\" style=\"list-style-type:none\"></ul> \
</div> \
<div align=right> \
<button id=\"sensorlist_CLOSE\" type=\"button\">Close</button> \
</div> \
\
");
gAddEventListener("sensorlist_CLOSE", 'click', sensorlist_cb_close);
}
var ul = document.getElementById("sensorlist_elements");
//
// clear list
//
// append all sensors
for (var i = 0; i < sensors.length; i++) {
let li = document.createElement("li");
li.appendChild(document.createTextNode(sensors[i].name));
li.setAttribute("id", "sensor_elm_"+sensors[i].name);
ul.appendChild(li);
gAddEventListener("sensor_elm_"+sensors[i].name, 'click', sensorlist_clicked);
}
};
function sensorlist_clicked() {
var i;
debug ("childnodes: " + this.childNodes[0].textContent);
sensordetail_show(this.childNodes[0].textContent);
};
function sensorlist_cb_close () {
var win = document.getElementById("sensorlist");
if (win) document.body.removeChild(win);
};

Loading…
Cancel
Save