From dcb6e3eabb358b83015eb0db3441948a4375dfcd Mon Sep 17 00:00:00 2001 From: hdw <hdw@192.168.7.112> Date: 星期四, 03 一月 2019 10:02:11 +0800 Subject: [PATCH] 不访问自动关闭首页和top.jsp的计时器 --- gx_tieta/WebRoot/index.jsp | 56 ++++++++++++++++-- gx_tieta/WebRoot/Top.jsp | 90 +++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+), 9 deletions(-) diff --git a/gx_tieta/WebRoot/Top.jsp b/gx_tieta/WebRoot/Top.jsp index d0863f8..172f767 100644 --- a/gx_tieta/WebRoot/Top.jsp +++ b/gx_tieta/WebRoot/Top.jsp @@ -196,6 +196,35 @@ </div> </div> </body> + <script type="text/javascript"> + // 妫�娴嬮〉闈㈡槸鍚﹁璁块棶 + var pageIsVisit = false; + ;(function($) { + // 闅愯棌鐨勫師鍨� + var hiddenProperty = 'hidden' in document ? 'hidden' : + 'webkitHidden' in document ? 'webkitHidden' : + 'mozHidden' in document ? 'mozHidden' : + null; + + // 椤甸潰鍒濆鍖� + if (!document[hiddenProperty]) { + pageIsVisit = true; + }else{ + pageIsVisit = false; + } + + + var visibilityChangeEvent = hiddenProperty.replace(/hidden/i, 'visibilitychange'); + var onVisibilityChange = function(){ + if (!document[hiddenProperty]) { + pageIsVisit = true; + }else{ + pageIsVisit = false; + } + } + document.addEventListener(visibilityChangeEvent, onVisibilityChange); + })(jQuery); + </script> <script src="pages/js/base.js"></script> <script src="pages/js/common.js"></script> <script src="js/dev.js"></script> @@ -243,6 +272,13 @@ //鏌ヨ钀藉悗鍗曚綋鎬绘暟 function searchlowmon(){ + + // 鍒ゆ柇椤甸潰鏄惁琚闂� + if(!pageIsVisit) { + setTimeout(searchlowmon, 5000); + return; + } + $.ajax({ type: "post", url: "BadBatt_monAction!searchNums", @@ -263,6 +299,12 @@ //鏌ヨ鏈烘埧鍋滅數鎬绘暟 function searchpoweroffOld(){ + // 鍒ゆ柇椤甸潰鏄惁琚闂� + if(!pageIsVisit) { + setTimeout(searchpoweroffOld, 5000); + return; + } + $.ajax({ type: "post", url: "BattPower_offAction!serchPowerOff", @@ -283,6 +325,11 @@ //鏌ヨ鏈烘埧鍋滅數鎬绘暟 function searchpoweroff(){ + // 鍒ゆ柇椤甸潰鏄惁琚闂� + if(!pageIsVisit) { + setTimeout(searchpoweroff, 5000); + return; + } $.ajax({ type: "post", url: "Bts_station_stateAction_action_serchByState", @@ -303,6 +350,11 @@ //鏌ヨ璁惧鍛婅鎬绘暟 function searchdevalarm(){ + // 鍒ゆ柇椤甸潰鏄惁琚闂� + if(!pageIsVisit) { + setTimeout(searchdevalarm, 5000); + return; + } $.ajax({ type: "post", url: "Batt_devalarm_dataAction!searchNums", @@ -323,6 +375,11 @@ //鏌ヨ鏀剧數璁″垝寤惰繜鎬绘暟 function searchnotcomplan(){ + // 鍒ゆ柇椤甸潰鏄惁琚闂� + if(!pageIsVisit) { + setTimeout(searchnotcomplan, 5000); + return; + } $.ajax({ type: "post", url: "BattDischarge_planAction!searchNums", @@ -343,6 +400,11 @@ // 鏈烘埧缁埅涓嶈冻涓暟 function searchWeakHome() { + // 鍒ゆ柇椤甸潰鏄惁琚闂� + if(!pageIsVisit) { + setTimeout(searchWeakHome, 5000); + return; + } $.ajax({ type: 'post' ,async: true @@ -361,6 +423,11 @@ // 鏌ヨ鎵�鏈夌殑璁惧鏁� searchAllDevNum(); function searchAllDevNum() { + // 鍒ゆ柇椤甸潰鏄惁琚闂� + if(!pageIsVisit) { + setTimeout(searchAllDevNum, 5000); + return; + } $.ajax({ type: 'post' ,async: true @@ -384,6 +451,11 @@ // 鏌ヨ鎵�鏈夌殑鐢垫睜缁勬暟 searchAllEleGroupNum(); function searchAllEleGroupNum() { + // 鍒ゆ柇椤甸潰鏄惁琚闂� + if(!pageIsVisit) { + setTimeout(searchAllEleGroupNum, 5000); + return; + } $.ajax({ type: 'post' ,async: true @@ -554,6 +626,11 @@ * 瀹炴椂鏌ヨ鍛婅淇℃伅 */ function searchBattAndDevAlarm(){ + // 鍒ゆ柇椤甸潰鏄惁琚闂� + if(!pageIsVisit) { + setTimeout(searchBattAndDevAlarm, 3000); + return; + } $.ajax({ type:"post", url: "Battalarm_dataAction!serchTopAlmTen", @@ -597,7 +674,12 @@ seachServerTime(); //鑾峰彇鏈嶅姟鍣ㄤ笂鐨勬椂闂� - function seachServerTime(){ + function seachServerTime(){ + // 鍒ゆ柇椤甸潰鏄惁琚闂� + if(!pageIsVisit) { + setTimeout(seachServerTime, 1000); + return; + } $.ajax({ type:"post", url: "User_infAction!searchServerTime", @@ -716,6 +798,11 @@ //鏌ヨ鏈�杩�30鍐呯殑璁惧鍜岀數姹犲憡璀﹀苟鎾姤璇煶 function searchRecentlyAlarm(){ + // 鍒ゆ柇椤甸潰鏄惁琚闂� + if(!pageIsVisit) { + setTimeout(searchRecentlyAlarm, 5000); + return; + } $.ajax({ type: "post", url: "Battalarm_dataAction!serchIn30", @@ -1005,6 +1092,5 @@ }); } })(jQuery); - </script> </html> diff --git a/gx_tieta/WebRoot/index.jsp b/gx_tieta/WebRoot/index.jsp index 6fcf891..45bb7c7 100644 --- a/gx_tieta/WebRoot/index.jsp +++ b/gx_tieta/WebRoot/index.jsp @@ -801,12 +801,14 @@ } //闇�瑕佸疄鏃舵煡璇㈢殑鏂规硶 - function Repeatoperation(){ - searchBattmaintrecords(); - searchUserTask(); - searchAnnounceall(); - searchTestsCale(); - + function Repeatoperation(){ + // 鍒ゆ柇椤甸潰鏄惁姝e湪琚闂� + if(pageIsVisit) { + searchBattmaintrecords(); + searchUserTask(); + searchAnnounceall(); + searchTestsCale(); + } setTimeout(Repeatoperation,10000); } @@ -940,6 +942,13 @@ if($('#content .warn-pie').length==0){ return; } + + // 鍒ゆ柇椤甸潰鏄惁琚闂� + if(!pageIsVisit) { + setTimeout(searchalarm_data, 10000); + return; + } + //鐢熸垚鐢垫睜鍛婅鐜囬ゼ鐘跺浘 var $warn=$('#content .pie-con .warn-pie'); //鑾峰彇鍛婅瀹瑰櫒鐨刯query瀵硅薄 if($warn.length!=0){ @@ -1051,6 +1060,12 @@ return; } + // 鍒ゆ柇椤甸潰鏄惁琚闂� + if(!pageIsVisit) { + setTimeout(searchmaintByMap, 10000); + return; + } + // 鍒ゆ柇鏄惁涓篍charts瀵硅薄 var isEcharts = isObject(brdnPie)?true:false; @@ -1123,6 +1138,13 @@ if($('#content .repair-pie').length==0){ return; } + + // 鍒ゆ柇椤甸潰鏄惁琚闂� + if(!pageIsVisit) { + setTimeout(searchBatt_maint_inf, 10000); + return; + } + // 鍒ゆ柇鏄惁涓篍charts瀵硅薄 var isEcharts = isObject(repairPie)?true:false; if(!isEcharts) { @@ -1178,6 +1200,13 @@ if($('#content .health-pie').length==0){ return; } + + // 鍒ゆ柇椤甸潰鏄惁琚闂� + if(!pageIsVisit) { + setTimeout(searchGood, 10000); + return; + } + //鐢熸垚鐢垫睜鍋ュ悍鐜� var $health=$('#content .pie-con .health-pie'); //鑾峰彇鏁呴殰瀹瑰櫒鐨刯query瀵硅薄 if($health.length!=0){ @@ -1228,6 +1257,12 @@ var endurPie; function searchEndurHome() { if($('#content .endur-pie').length==0){ + return; + } + + // 鍒ゆ柇椤甸潰鏄惁琚闂� + if(!pageIsVisit) { + setTimeout(searchEndurHome, 10000); return; } @@ -1840,7 +1875,7 @@ var powercut = mapImgDesc.find('.badge-powercut'); // 鍋滅數鏈烘埧 var normal = mapImgDesc.find('.badge-normal'); // 姝e父鏈烘埧 var weak = mapImgDesc.find('.badge-xuhang'); // 缁埅涓嶈冻3灏忔椂鏈烘埧 - console.log(warn.length); + // console.log(warn.length); // 璇锋眰鍚庡彴鏁版嵁 $.ajax({ type: 'post' @@ -2632,6 +2667,13 @@ var bmap = GLOBAL.BMap; // BMap鐨勫懡鍚嶇┖闂� var updateStationData = []; + // 鍒ゆ柇鏄惁琚闂� + if(!pageIsVisit) { + // 鍏抽棴骞舵坊鍔犲欢鏃舵墽琛� + clearInterval(updateTimeout); + updateTimeout = setTimeout(updateStation, 4000); + } + if(isLoad) { updateLoad = layer.load(1); } -- Gitblit v1.9.1