function AsProgress() { var h = "50vh"; var w = "50vw"; var loading = document.createElement("IMG"); loading.id = "AsimgLoading" loading.alt = "資料處理中" loading.src = "Images/AsLoading.png" var brTag = document.createElement("br"); var fontTag = document.createElement("font"); fontTag.color = "#1B3563"; fontTag.size = "2"; fontTag.innerHTML = "資料處理中"; var progress = document.createElement("div"); progress.id = "AsdivProgress" progress.style.textAlign = "center"; progress.appendChild(loading); progress.appendChild(brTag); progress.appendChild(fontTag); progress.style.position = "fixed"; progress.style.top = h; progress.style.left = w ; // progress.style.top = (h / 2) - (progress.style.height / 2); // progress.style.left = (w / 2) - (progress.style.width / 2); progress.style.zIndex = "99999"; progress.style.display = ''; //document.body.appendChild(progress); //debugger; if (self.frameElement && self.frameElement.tagName == "IFRAME") { var oprogress = window.top.document.getElementById("AsdivProgress"); if (oprogress == null || typeof (oprogress) == "undefind") { window.top.document.body.appendChild(progress); } } else { document.body.appendChild(progress); } } function AsMaskFrame() { var h = "100vh"; var w = "100vw"; var mask = document.createElement("div"); mask.id = "AsdivMaskFrame" mask.style.position = "fixed"; mask.style.top = "0px"; mask.style.left = "0px"; mask.style.height = h; mask.style.width = w; mask.style.backgroundColor = "#000000"; mask.style.opacity = "0.3"; mask.style.zIndex = "99998"; mask.style.display = ''; if (self.frameElement && self.frameElement.tagName == "IFRAME") { var omask = window.top.document.getElementById("AsdivMaskFrame"); if (omask == null || typeof (omask) == "undefind") { window.top.document.body.appendChild(mask); } } else { document.body.appendChild(mask); } } function ShowAsloader() { AsMaskFrame(); AsProgress(); $(document).keydown(function (event) { if (event.keyCode == "9") { event.preventDefault(); } if (event.keyCode == "13") { event.preventDefault(); } }); } function HiddenAsloader() { var asprogress = document.getElementById('AsdivProgress'); if (asprogress) { document.body.removeChild(asprogress); }; asprogress = window.top.document.getElementById('AsdivProgress'); if (asprogress) { window.top.document.body.removeChild(asprogress); }; var asmask = document.getElementById('AsdivMaskFrame'); if (asmask) { document.body.removeChild(asmask); }; asmask = window.top.document.getElementById('AsdivMaskFrame'); if (asmask) { window.top.document.body.removeChild(asmask);}; $(document).off("keydown"); } function rptcheck() { //debugger; if (document.readyState == 'complete') { HiddenAsloader(); } else { setTimeout('rptcheck()', 1000); } } function inactivityTime() { var ast; var aspostback = new Date(); //window.onload = resetTimer; // DOM Events window.onmousemove = resetTimer; window.onkeypress = resetTimer; //window.onmousedown = resetTimer; // catches touchscreen presses //window.onclick = resetTimer; // catches touchpad clicks //window.onscroll = resetTimer; // catches scrolling with arrow keys resetTimer; function logout() { //alert("閒置時間過久,請重新登入"); //window.location = "Login.aspx"; var pagename = "Login.aspx"; var arrPath = location.pathname.split('/'); if (arrPath.length > 0) { if (arrPath[arrPath.length - 1].toLowerCase().indexOf('.aspx') > -1) { pagename = arrPath[arrPath.length - 1].toLowerCase(); } } if (pagename.toUpperCase() != "LOGIN.ASPX") { alert("閒置時間過久,請重新登入"); //if (top !== self) { // window.location = "../Login.aspx"; //} //else { var path = location.pathname; var path = path.replace(/\/{1}[\w]+.aspx/g, ''); window.top.location = path + "/Login.aspx"; //} } } function resetTimer() { console.log("resetTimer"); window.top.clearTimeout(ast); var sessionTimeoutWarning = 20; //min var sTimeout = parseInt(sessionTimeoutWarning) * 60 * 1000; ast = window.top.setTimeout(logout, sTimeout); var current = new Date(); if (((current.getTime() - aspostback.getTime())/60000)>15) { try { var astimerclient = getXmlHttpRequestObject(); astimerclient.open("GET", encodeURI("AsCheck.ashx"), false); astimerclient.send(); } catch (e) { } aspostback = new Date(); console.log("AsCheck"); } // 1000 milisec = 1 sec } }; // kathy 修改pop的height function resizeTime() { var asresizetime; var asresizetimeout = false; var asresizechg = 300; //$(window).resize(function () { $(window).on('resize', function () { asresizetime = new Date(); if (asresizetimeout === false) { asresizetimeout = true; setTimeout(resizeend, asresizechg); } }); function resizeend() { if (new Date() - asresizetime < asresizechg) { setTimeout(resizeend, asresizechg); } else { asresizetimeout = false; rePopSize(); console.log("window resizeend"); } } function rePopSize() { var poplarges = document.getElementsByClassName('popLarge'); if(poplarges.length == 0){ var asiframecontent=document.getElementById('iframecontent'); if(asiframecontent){ //asiframecontent.style.height= (parseInt(document.documentElement.clientHeight)-60).toString() + "px"; } } for (var ipl = 0; ipl < poplarges.length; ipl++) { if (poplarges[ipl] != null || typeof (poplarges[ipl]) != undefined) { //var viewHeight = document.documentElement.clientHeight; var viewWidth = document.documentElement.clientWidth; //iframe大小也要改 var ifr = window.frameElement; if(ifr!= null && typeof (ifr) != undefined){ //ifr.style.height= (parseInt(ifr.parentElement.clientHeight)).toString() + "px"; } //poplarges[ipl].style.width = (parseInt(viewWidth) - 50).toString() + "px"; if (window.innerWidth > 780) { poplarges[ipl].style.width = (parseInt(viewWidth) - 50).toString() + "px"; } else { poplarges[ipl].style.width = (parseInt(viewWidth)).toString() + "px"; } //poplarges[ipl].style.height = (parseInt(viewHeight)).toString() + "px"; } } var zbrowserpop = document.getElementsByClassName('zBrowsePop'); if(zbrowserpop.length == 0){ var asiframecontent=document.getElementById('iframecontent'); if(asiframecontent){ //asiframecontent.style.height= (parseInt(document.documentElement.clientHeight)-60).toString() + "px"; } } for (var ibp = 0; ibp < zbrowserpop.length; ibp++) { if (zbrowserpop[ibp] != null || typeof (zbrowserpop[ibp]) != undefined) { //var viewHeight = document.documentElement.clientHeight; var viewWidth = document.documentElement.clientWidth; //iframe大小也要改 var ifr = window.frameElement; if(ifr!= null && typeof (ifr) != undefined){ //ifr.style.height= (parseInt(ifr.parentElement.clientHeight)).toString() + "px"; } //zbrowserpop[ibp].style.width = (parseInt(viewWidth) - 50).toString() + "px"; if (window.innerWidth > 780) { zbrowserpop[ibp].style.width = (parseInt(viewWidth) - 50).toString() + "px"; } else { zbrowserpop[ibp].style.width = (parseInt(viewWidth)).toString() + "px"; } //zbrowserpop[ibp].style.height = (parseInt(viewHeight)).toString() + "px"; } } //新增判斷function上存不存在有則跑 if (window.setFreezeGrid) { setFreezeGrid(); } //新增判斷特殊字視窗 var divWord = document.getElementById('divSpecialWord'); if (divWord) { resizeSpecicalWord(); } }; } resizeTime(); //20210809_依平_scrollbar保持位置 function getFileName() { var url = this.location.href; var pos = url.lastIndexOf("/"); if(pos == -1) { pos = url.lastIndexOf("\\"); } var los = url.lastIndexOf(".aspx"); var filename = url.substr(pos+1,los-pos-1); return filename; } function getMainName() { var url = this.location.href; if(self.parent.frameElement){ url = this.parent.location.href; } var pos = url.lastIndexOf("/"); if(pos == -1) { pos = url.lastIndexOf("\\"); } var los = url.lastIndexOf(".aspx"); var filename = url.substr(pos+1,los-pos-1); return filename.substring(0,5); } localData = { hname:location.hostname?location.hostname:'localStatus', isLocalStorage:window.localStorage?true:false, dataDom:null, initDom:function(){ //初始化userData if(!this.dataDom){ try{ this.dataDom = document.createElement('input'); this.dataDom.type = 'hidden'; this.dataDom.style.display = "none"; this.dataDom.addBehavior('#default#userData'); document.body.appendChild(this.dataDom); var exDate = new Date(); exDate = exDate.getDate()+30; this.dataDom.expires = exDate.toUTCString(); }catch(ex){ return false; } } return true; }, set:function(key,value){ if(this.isLocalStorage){ window.localStorage.setItem(key,value); }else{ if(this.initDom()){ this.dataDom.load(this.hname); this.dataDom.setAttribute(key,value); this.dataDom.save(this.hname); } } }, get:function(key){ if(this.isLocalStorage){ return window.localStorage.getItem(key); }else{ if(this.initDom()){ this.dataDom.load(this.hname); return this.dataDom.getAttribute(key); } } }, remove:function(key){ if(this.isLocalStorage){ localStorage.removeItem(key); }else{ if(this.initDom()){ this.dataDom.load(this.hname); this.dataDom.removeAttribute(key); this.dataDom.save(this.hname); } } }, clear:function(){ if(this.isLocalStorage){ localStorage.clear(); }else{ if(this.initDom()){ this.dataDom.load(this.hname); for (var i=0; i -1){ boolSet = false; } } if(boolSet == false > 0&&localData.get(getMainName()) == '0'){ return; } } //html localData.set(getFileName()+"_html",window.document.firstElementChild.scrollTop) //body localData.set(getFileName()+"_body",window.document.body.scrollTop) //gridview var lsttblFreeze = document.getElementsByClassName("tblFreeze"); if (lsttblFreeze.length > 0) { for (var lst = 0; lst < lsttblFreeze.length; lst++) { localData.set(getFileName()+"_"+lsttblFreeze[lst].id,lsttblFreeze[lst].scrollTop); } } } function setScroll() { //if(localData.get(getFileName().substring(0,5)) == null){ // localData.clear(); //} //抓close按鈕self.frameElement.contentDocument.getElementsByClassName('webClose') //判斷是外還是pop if(self.parent.frameElement){ //是pop localData.set(getMainName(),'1') //window.document.body.scrollTop=localData.get(getFileName()+"_body"); window.document.firstElementChild.scrollTop=localData.get(getFileName()+"_html"); var lsttblFreeze = document.getElementsByClassName("tblFreeze"); if (lsttblFreeze.length > 0) { for (var lst = 0; lst < lsttblFreeze.length; lst++) { lsttblFreeze[lst].scrollTop=localData.get(getFileName()+"_"+lsttblFreeze[lst].id); } } } else { //是外層 if(localData.get(getMainName()) == '1'){ window.document.body.scrollTop=localData.get(getFileName()+"_body"); var lsttblFreeze = document.getElementsByClassName("tblFreeze"); if (lsttblFreeze.length > 0) { for (var lst = 0; lst < lsttblFreeze.length; lst++) { lsttblFreeze[lst].scrollTop=localData.get(getFileName()+"_"+lsttblFreeze[lst].id); } } //只保留外層的紀錄 localData.clear(); //body localData.set(getFileName()+"_body",window.document.body.scrollTop) //gridview var lsttblFreeze = document.getElementsByClassName("tblFreeze"); if (lsttblFreeze.length > 0) { for (var lst = 0; lst < lsttblFreeze.length; lst++) { localData.set(getFileName()+"_"+lsttblFreeze[lst].id,lsttblFreeze[lst].scrollTop); } } } else{ if(localData.get(getMainName()) != null){ localData.clear(); } } localData.set(getMainName(),'0') } //window.document.body.scrollTop=localData.get(getFileName()+"_body"); window.document.body.setAttribute("onscroll","saveScroll()"); var lsttblFreeze = document.getElementsByClassName("tblFreeze"); if (lsttblFreeze.length > 0) { for (var lst = 0; lst < lsttblFreeze.length; lst++) { //lsttblFreeze[lst].scrollTop=localData.get(getFileName()+"_"+lsttblFreeze[lst].id); lsttblFreeze[lst].setAttribute("onscroll","saveScroll()"); } } //clearScroll(); } function clearScroll() { if(LastPage!=getFileName()){ //body localData.remove(getFileName()+"_body") //gridview var lsttblFreeze = document.getElementsByClassName("tblFreeze"); if (lsttblFreeze.length > 0) { for (var lst = 0; lst < lsttblFreeze.length; lst++) { localData.remove(getFileName()+"_"+lsttblFreeze[lst].id); } } } } window.addEventListener("load", function() { //20210917_依平_比較目前頁面跟之前紀錄的是否為同一頁面,不同的話不設定scroll if(localData.get('page') != getMainName()){ localData.set(getMainName(),'0'); } setScroll(); }); //20210917_依平_增加離開頁面時判斷postback的參數,設定旗標 window.addEventListener("beforeunload", function() { var theForm; var theFormlist = document.getElementsByTagName('form'); for(var f = 0; f < theFormlist.length; f++){ if(theFormlist[f].id.toLowerCase() == ('form_' + getFileName()).toLowerCase()){ theForm = theFormlist[f]; } } if(!theForm){ theForm = document.form1; } if(theForm){ var asevent = theForm.__EVENTTARGET; if(asevent){ //20210924_依平_上下一頁跟搜尋要回到最上面,其他保留原位置 if( asevent.value.endsWith('_btnLast') || asevent.value.endsWith('_btnNext') || asevent.value.endsWith('_btnBefore') || asevent.value.endsWith('_btnFirst') || asevent.value.endsWith('_btnsearch')) { localData.set(getMainName(),'0'); } else { localData.set(getMainName(),'1'); } } } //紀錄目前頁面 localData.set('page',getMainName()); });