//若使用者點擊back或forward按鈕,則重新載入網頁,以確保K線圖正常載入 if (performance.navigation.type == 2) { window.location.reload(true); } var oFloatScrollTool = { ParentObj:[], ReportObj:[], Header:[], ScrollBar:[] }; var oDynaDispElem = {}; var oAD = {}; var oDataTransfer = {}; var oStockPainterList = { StockPainterIDs:[], CanvasIDs:[] }; var oGlobalParm = {}; oGlobalParm.PageStart = Date.now()/86400000-GetTimezoneOffset()/1440+25569; const conSysNM = 'StockTW'; const conMobileMode = false; const conTestMode = false; const conIsLogin = false; const conRowMarkBGC = '#fff2cc'; const conAppPoolList = 'StockList,StockListAll,StockListMyFields,StockListFilter,StockListPick,StockListRank,StockDetail,StockDetail.cht,cht,data,user'; const conMidChtWidth = '520px'; const conFontSize08 = 8; const conFontSize09 = 9; const conFontSize10 = 10; const conFontSize11 = 11; const conFontSize12 = 12; const conFontSize13 = 13; const conFontSize14 = 14; const conFontSize16 = 16; const conFontSize18 = 18; const conLineHeight08 = 8; const conLineHeight09 = 9; const conLineHeight10 = 10; const conLineHeight12 = 12; const conLineHeight14 = 14; const conLineHeight15 = 15; const conLineHeight16 = 16; const conLineHeight17 = 17; const conLineHeight18 = 18; const conLineHeight20 = 20; const conLineHeight21 = 21; const conLineHeight22 = 22; const conLineHeight24 = 24; const conLineHeight28 = 28; //設定環境參數 setCookie('SCREEN_WIDTH', screen.width, 7, '/'); //Client's Screen width setCookie('SCREEN_HEIGHT', screen.height, 7, '/'); //Client's Screen height setCookie('IS_TOUCH_DEVICE', ('ontouchstart' in window?'T':'F'), 7, '/'); //Is touch device if (getCookie('AGREE_COOKIES_TW')=='T') { setCookie('AGREE_COOKIES_TW', 'T', 30, '/'); } if (getCookie('AGREE_COOKIES_CN')=='T') { setCookie('AGREE_COOKIES_CN', 'T', 30, '/'); } //讓AdSense可遞補ADX的空白廣告////////////////////////////////////////////////////////////////// try { window.googletag = window.googletag || {cmd: []}; googletag.cmd.push(function() { googletag.pubads().addEventListener('slotRenderEnded', function(event) { var id = event.slot.getSlotElementId(); if (Left(id,11) != 'div-gpt-ad-' || !(id in oAD)) { return; }; document.getElementById(id).parentElement.style.removeProperty('min-height'); if (event.isEmpty) { Adx2AdSense(id); }; }); }); } catch(e) {} //調整自動廣告的設定/////////////////////////////////////////////////////////////////////////////// const obsAutoAdx = new MutationObserver((mutations) => { mutations.forEach((mutation) => { var o = mutation.target; if (mutation.type === 'childList' && LCase(Left(o.id,11)) == 'ats-slider-') { while (o != null && !(LCase(Left(o.id,15)) == 'ats-slider-div-' && IsNumeric(Mid(o.id,16)))) { o = o.parentNode; } if (o != null) { o.style.zIndex = 100; } //調整浮動廣告的z-index } if (mutation.type === 'attributes' && o.id == 'ats-interstitial-root') { if (window.getComputedStyle(o).visibility == 'visible') { var arr = Split(NVL(getCookie('Anymind_Vignette'),'0|0'),'|'); if (Number(arr[0]) < Date.now() || Number(arr[1]) <= 0) { oGlobalParm['ats-interstitial-root'] = true; setCookie('Anymind_Vignette', String(Date.now()+300000)+'|30', 5/1440, '/'); console.log('set new cookie'); } else if (!oGlobalParm['ats-interstitial-root']) { o.style.visibility = 'hidden'; o?.remove(); console.log('remove:'+o.id); } } } }); }); // Initialize ////////////////////////////////////////////////////////////////////////////////////////////// function Initial() { if ('divInitCont' in window && InStr(window.location.search,'STEP=DATA_INIT',false) <= 0) { var s = AddUrlParam(window.location.href,'STEP=DATA_INIT'); ReloadReport(s, divInitCont, ('divInitContLoad' in window?divInitContLoad:undefined), null, ['Initial2']); } else { Initial2(); } } function Initial2() { var arr = Split(NVL(getCookie('Anymind_Vignette'),'0|0'),'|'); arr[1] = Number(arr[1])-1; setCookie('Anymind_Vignette', Join(arr,'|'), 5/1440, '/'); obsAutoAdx.observe(document.body, { childList:true, subtree:true, attributes:true, attributeFilter:['style'] }); setTimeout(function(){ obsAutoAdx.disconnect(); }, 10000); window.addEventListener('resize', (event) => { ResizeScreen(); }); window.addEventListener('scroll', (event) => { ScrollWindow(); }); window.addEventListener('pagehide', (event) => { UnloadPage(); }); if (conSysNM == "StockTW") { InitStockTW(); } if (conSysNM == "StockCN") { InitStockCN(); } var iSCROLL2Y = GetUrlParameter('SCROLL2Y'); if (IsNumeric(iSCROLL2Y)) { if (iSCROLL2Y > 0 && PageYOffset() == 0) { window.scrollTo({ top:iSCROLL2Y }); // window.scrollTo({ top:iSCROLL2Y, behavior:'smooth' }); } } ResizeReport(); PatchDataList('dlSTOCK_ID_NM'); ShowDynaDispElem(); ShowFloatScrollTool(); //放最後面 var arr = [1000,5000]; if (!conTestMode) { arr = [1000,1250,1500,1750,2000,2500,3000,3500,4000,5000]; } oGlobalParm['PageHeight'] = GetPageHeight(); for (var i of arr) { setTimeout(function(){ ShowDynaDispElem(); iPageHeight = GetPageHeight(); if (oGlobalParm['PageHeight'] != iPageHeight) { RepaintAllStockChart(); oGlobalParm['PageHeight'] = iPageHeight; } ShowFloatScrollTool(); }, i); } } 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 (sSTOCK_ID == '') return; if (sArea == 'TW' && 'garrTW_LIST_STOCK_ID' in window && garrTW_LIST_STOCK_ID.indexOf(sSTOCK_ID) >= 0 || sArea == 'CN' && 'garrCN_LIST_STOCK_ID' in window && garrCN_LIST_STOCK_ID.indexOf(sSTOCK_ID) >= 0) { 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); //前面加入新的 } //將清單維持在30個 arr = Split(s,"|"); s = ''; for (i=0; i < 30 && i < arr.length; i++) { s = s + (s==''?'':'|') + arr[i]; } setCookie(sCookieNM, s, 365, '/'); } } }