var oFloatScrollTool = { ParentObj:[], ReportObj:[], Header:[], ScrollBar:[] }; var oDynaDispElem = {}; var oAD = {}; var oDataTransfer = {}; var oStockPainterList = { StockPainterIDs:[], CanvasIDs:[] }; var oGlobalParm = {}; const conSysNM = 'StockTW'; const conMobileMode = false; const conTestMode = false; const conIsLogin = false; const conRowMarkBGC = '#fff2cc'; const conFontSize06 = 6; const conFontSize07 = 7; const conFontSize08 = 8; const conFontSize09 = 9; const conFontSize10 = 10; const conFontSize11 = 11; const conFontSize12 = 12; const conFontSize13 = 13; const conFontSize14 = 14; const conFontSize15 = 15; const conFontSize16 = 16; const conFontSize17 = 17; const conFontSize18 = 18; const conFontSize19 = 19; const conFontSize20 = 20; const conFontSize21 = 21; const conFontSize22 = 22; const conFontSize23 = 23; const conFontSize24 = 24; const conLineHeight08 = 8; const conLineHeight09 = 9; const conLineHeight10 = 10; const conLineHeight11 = 11; const conLineHeight12 = 12; const conLineHeight13 = 13; const conLineHeight14 = 14; const conLineHeight15 = 15; const conLineHeight16 = 16; const conLineHeight17 = 17; const conLineHeight18 = 18; const conLineHeight19 = 19; const conLineHeight20 = 20; const conLineHeight21 = 21; const conLineHeight22 = 22; const conLineHeight23 = 23; const conLineHeight24 = 24; const conLineHeight25 = 25; const conLineHeight26 = 26; const conLineHeight27 = 27; const conLineHeight28 = 28; //若使用者點擊back或forward按鈕,則重新載入網頁,以確保K線圖正常載入 if (performance.navigation.type == 2) { window.location.reload(true); } //如果瀏覽器不支援JSON則載入json2.js (一定要放最前面) ////////////////////////////////////////////////////////// /* 停用2024/7/10 if (typeof (JSON) == 'undefined') { var script = document.createElement('script'); script.type = 'text/javascript'; script.src = '/Library/js/JSON-js-master/json2.js'; document.getElementsByTagName('head')[0].appendChild(script); } */ ///////////////////////////////////////////////////////////////////////////////////////////////////////////// // Initialize ////////////////////////////////////////////////////////////////////////////////////////////// function Initial(oParm) { oGlobalParm['PageHeight'] = GetPageHeight(); if (oParm == undefined) { oParm = {}; } oParm.SCROLL2Y = null; if (conSysNM == "StockTW") { InitStockTW(); } if (conSysNM == "StockCN") { InitStockCN(); } if (IsNumeric(oParm.SCROLL2Y)) { if (oParm.SCROLL2Y > 0 && PageYOffset() == 0) { window.scrollTo({ top:oParm.SCROLL2Y }); // window.scrollTo({ top:oParm.SCROLL2Y, behavior:'smooth' }); } } ShowDynaDispElem(); ShowFloatScrollTool(); //放最後面 for (var i=(conTestMode?9:0); i<10; i=i+(conTestMode?100:1)) { setTimeout(function(){ FixAtsSliderDivZIndex(); RemoveAbnormalAD(); FixTriggerEvent() iPageHeight = GetPageHeight(); if (oGlobalParm['PageHeight'] != iPageHeight) { RepaintAllStockChart(); } oGlobalParm['PageHeight'] = iPageHeight; }, i*500); } } function InitStockTW() { AddStockBrowseList('TW'); } function InitStockCN() { AddStockBrowseList('CN'); } function AddStockBrowseList(sArea) { var s, arr, i //將目前瀏覽的STOCK_ID加入Cookie var sSTOCK_ID = Trim(UCase(getUrlParameter('STOCK_ID'))); if (sArea == 'TW' && Len(sSTOCK_ID) >= 4 && IsNumeric(Left(sSTOCK_ID,4)) || sArea == 'CN' && Len(sSTOCK_ID) == 8 && IsNumeric(Mid(sSTOCK_ID,3) && (Left(sSTOCK_ID,2) == 'SH' || Left(sSTOCK_ID,2) == 'SZ'))) { var sCookieNM = sArea + '_STOCK_BROWSE_LIST'; if (sCookieNM != '') { //將新的STOCK_ID加入字串中 var s = '|' + NVL(getCookie(sCookieNM)) + '|'; if (s == '||') { s = sSTOCK_ID; } else { s = Replace(s, '|' + sSTOCK_ID + '|', '|'); //清掉舊的 s = sSTOCK_ID + Left(s,Len(s)-1); //前面加入新的 } //將清單維持在20個 arr = Split(s,"|"); s = ''; for (i=0; i < 20 && i < arr.length; i++) { s = s + (s==''?'':'|') + arr[i]; } setCookie(sCookieNM, s, 365, '/'); } } } //調整浮動廣告的z-index function FixAtsSliderDivZIndex() { var oDivs = document.getElementsByTagName("div"); for (var i=0; i < oDivs.length; i++) { if (LCase(Left(oDivs[i].id,15)) == 'ats-slider-div-' && IsNumeric(Mid(oDivs[i].id,16))) { if (oDivs[i].style.zIndex != 100) { oDivs[i].style.zIndex = 100; } } } var o = [{ id:'ats-overlay-bottom-wrapper-rendered', zIndex:2147483646 }, { id:'ats-interstitial-root', zIndex:2147483647 }]; for (var v of o) { if (v.id in window) { document.getElementById(v.id).style.zIndex = v.zIndex; } } } //確保全頁式廣告每十分鐘只顯示一次 function RemoveAbnormalAD() { if (oGlobalParm['ANYMIND_SAS_SHOW']) { return; } var oDivs = document.getElementsByTagName("div"); for (var i=oDivs.length-1; i>=0 ; i--) { var sID = LCase(oDivs[i].id); if (sID == '') { continue; } if (Left(sID,4) == 'sas_' && IsNumeric(Mid(sID,5)) || Left(sID,15) == 'sas-background-' && IsNumeric(Mid(sID,16)) || Left(sID,17) == 'sas-video-holder-' && IsNumeric(Mid(sID,17)) || Left(sID,10) == 'sas-video-' && IsNumeric(Mid(sID,11))) { if (Date.now() - NumVL(getCookie('ANYMIND_SAS_LAST_SHOW'),0) > 86400000*10/1440) { setCookie('ANYMIND_SAS_LAST_SHOW', Date.now(), 10/1440, '/'); oGlobalParm['ANYMIND_SAS_SHOW'] = true; return; } else { /* try { oDivs[i].remove(); } catch(err) {} try { document.body.style.removeProperty('overflow'); } catch(err) {} try { document.documentElement.removeAttribute('style'); } catch(err) {} try { document.body.removeEventListener('touchmove', preventDefault, { passive: !0 }); } catch(err) {} */ } } } } //修正event被廣告改寫的問題 function FixTriggerEvent() { if (InStr(document.body.onresize,'ResizeScreen();',false) <= 0) { var func_onresize_org = window.onresize; if (func_onresize_org == null || func_onresize_org == undefined) { window.onresize = function(e) { ResizeScreen(); } } else { window.onresize = function(e) { func_onresize_org.apply(this, arguments); ResizeScreen(); } } } if (InStr(document.body.onscroll,'ScrollWindow();',false) <= 0) { var func_onscroll_org = window.onscroll; if (func_onscroll_org == null || func_onscroll_org == undefined) { window.onscroll = function(e) { ScrollWindow(); } } else { window.onscroll = function(e) { func_onscroll_org.apply(this, arguments); ScrollWindow(); } } } }