Samples Reappend

This commit is contained in:
luosheng
2023-02-13 19:58:15 +08:00
parent 4e70553bfc
commit eb4a7cffd6
471 changed files with 151790 additions and 6 deletions

View File

@@ -0,0 +1,59 @@
var colorArr = ["#f05f2a", "#DDFF00", "#01a252"],
liNodes = document.getElementsByClassName("light"),
index = 0,
index2 = 3;
$(document).ready(function () {
setInterval(readLamp, 1000);
});
function readLamp() {
var url = "/Home/GetLamp";
$.ajax({
type: "get",
async: true,
url: url,
timeout: 1000,
success: function (datas) {
[].forEach.call(liNodes, function (v) {
v.style.backgroundColor = "lightgray";
});
switch (datas.MainLamp) {
case "Red":
{
liNodes[index].style.backgroundColor = colorArr[index];
break;
}
case "Yellow":
{
liNodes[index + 1].style.backgroundColor = colorArr[index + 1];
break;
}
case "Green":
{
liNodes[index + 2].style.backgroundColor = colorArr[index + 2];
break;
}
}
switch (datas.SubLamp) {
case "Red":
{
liNodes[index2].style.backgroundColor = colorArr[index];
break;
}
case "Yellow":
{
liNodes[index2 + 1].style.backgroundColor = colorArr[index + 1];
break;
}
case "Green":
{
liNodes[index2 + 2].style.backgroundColor = colorArr[index + 2];
break;
}
}
},
error: function() {
}
});
}