总状态灯的判断
1.lightStatus=[],创建总状态灯判断的依据;
2.将所有群组的状态传入总状态灯数组;
3.判断lightStatus是否全部"正常运行",并返回布尔值;
4.$("#sStatus").removeClass().addClass("alert2"),更换样式;
if (data1) { var secHtml = ""; var lightStatus=[]; for (var i = 0; i < data1.length; i++) { //状态的新数组; lightStatus[i] =data1[i].status; //文本信息; secHtml += "<li><span>" + (i + 1) + "</span><span>" + limitWords(data1[i].device, 9) + "</span><span>" + data1[i].datetime + "</span><span class=" + getStColor(data1[i].status) + "></span><span>" + getStatus(data1[i].status) + "</span></li>"; } //console.log(lightStatus); //状态灯; var result = lightStatus.every(item => item === "正常运行"); if (result === true) { $("#sStatus").removeClass().addClass("alert2"); } if (result === false){ $("#sStatus").removeClass().addClass("alert1"); }
lockdatav Done!