机房环境监测服务端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.4 KiB

$(function(){
var clock = '';
clock = setInterval(flushcmd, 5000);
});
function flushcmd(){
//alert('clock exec');
$.get("http://172.18.17.136:8000/env/cmdqueue/", function(result){
$("#cmdul").empty();
var clist = jQuery.parseJSON(result);
for(i in clist.cmdlist){
$("#cmdul").append("<li class=\"lst\">"+clist.cmdlist[i].replace(/\$/g,',')+"</li>");
}
});
}
function change_spot(value) {
$("#spotval").val(value);
$('#spotbtn').html($("#sptlist"+value).html());
$("#sptname").val($("#sptlist"+value).html());
}
function change_cmd(value) {
$("#cmdval").val(value);
$('#cmdbtn').html($("#cmdlist"+value).html());
$("#cmdname").val($("#cmdlist"+value).html());
$("#cmdval").change();
}
function isInteger(obj){
if(isFinite(obj) && obj%1===0){
return true;
}
else{
return false;
}
}
function check_form() {
if(!$("#spotval").val()||!$("#cmdval").val()){
alert('请选择设备和命令!');
return false;
}
if($("#cmdval").val()!='REBOOT'){
var reg = new RegExp("^[0-9]+\.?[0-9]*$");
if(!reg.test($("#paramval").val())){
alert('请输入正确的数值!');
return false;
}
}
if($("#cmdval").val()=='TIMESPAN'&&!isInteger($("#paramval").val())){
alert('时间间隔应为整数!');
return false;
}
else if($("#cmdval").val()=='A_FIRE'&&(parseInt($("#paramval").val())<8000||parseInt($("#paramval").val())>50000)){
alert('烟雾报警参数取值:[8000,50000]!');
return false;
}
else if($("#cmdval").val()=='A_TEMP'&&($("#paramval").val()<5||$("#paramval").val()>50)){
alert('温度报警参数取值:[5.0, 50.0]!');
return false;
}
else if($("#cmdval").val()=='A_HUM'&&($("#paramval").val()<30||$("#paramval").val()>95)){
alert('湿度报警参数取值:[30.0, 95.0]!');
return false;
}
return true;
}
function get_device(){
if($("#spotval").val()){
// alert($("#cmdval").val());
$.get("http://172.18.17.136:8000/env/deviceinfo/?spot="+$("#spotval").val(), function(result){
// alert(jQuery.parseJSON(result));
$("#paramval").val(jQuery.parseJSON(result)[$("#cmdval").val()]);
});
}
}