setInterval js

 $('#start_scan').on('click',function(){
         if(timer == undefined){
             timer = setInterval(scan,1000)
             starting = new Boolean(true)
             $('#start_scan').text("停止探测")
         }
         else{
            if(starting){
                  clearInterval(timer)
                  timer = undefined
                  starting = new Boolean(false)
                  $('#start_scan').text("开始探测")
              }
              else{
                  timer = setInterval(scan,1000)
                  starting = new Boolean(true)
                   $('#start_scan').text("停止探测")
              }
         }
              
          
      })


 var scan = function () {

            wifiscanner.scanByOneInf(wlan_interface,function(err, data){
	           console.log(data);
               var str = eval(data)
               var signal_level=undefined

              $.each(str,function(){
                 if(this.mac == arg.mac){
                    signal_level = this.signal_level
                 }
              })
              measure_data.rssis.push(signal_level)
              $('#scan_result_list').append(`${ signal_level }<br>`)
              return;
             });
         
      }

posted @ 2016-11-01 14:56  蚂蚁都督  阅读(119)  评论(0编辑  收藏  举报