$(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("
  • "+clist.cmdlist[i].replace(/\$/g,',')+"
  • "); } }); } 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()]); }); } }