1// ç»ä¸å¯¼èªé¾æ¥æ¸²æåè½ 2// åªè´è´£æ¸²æå¯¼èªé¾æ¥é¨åï¼ä¸é´é¨åï¼ 3// æ ¹æ®éä¸ç游æç±»åï¼åªæ¸²æå¯¹åºæ¸¸æç导èªé¾æ¥ 4 5(function() { 6 'use strict'; 7 8 let currentPageId = null; 9 let currentGame = null; 10 11 // 渲æå¯¼èªé¾æ¥ï¼æ ¹æ®æ¸¸æç±»åï¼ 12 function renderNavLinks(game) { 13 // game 为 nullï¼æ¡é¢ç«¯ä¸æ¾ç¤ºä¸é´å¯¼èªï¼ç§»å¨ç«¯ä»æ¾ç¤ºååï¼POE1 | POE2ï¼å ¥å£ 14 if (game === null || game === undefined) { 15 var isMobileNav = false; 16 try { 17 isMobileNav = window.matchMedia && window.matchMedia('(max-width: 768px)').matches; 18 } catch (e1) { 19 isMobileNav = window.innerWidth <= 768; 20 } 21 if (isMobileNav && window.NavConfig) { 22 const navMenu = document.getElementById('mobile-nav-menu'); 23 if (navMenu) { 24 (async () => { 25 try { 26 await window.NavConfig.renderNavLinks('mobile-nav-menu', currentPageId, null); 27 currentGame = null; 28 const event = new CustomEvent('navLinksRendered', { detail: { currentPageId, game: null } }); 29 document.dispatchEvent(event); 30 } catch (err) { 31 console.error('渲æå¯¼èªé¾æ¥å¤±è´¥:', err); 32 } 33 })(); 34 } 35 return; 36 } 37 const navMenuEmpty = document.getElementById('mobile-nav-menu'); 38 if (navMenuEmpty) { 39 navMenuEmpty.innerHTML = ''; 40 } 41 currentGame = null; 42 return; 43 } 44 45 // æ£æ¥NavConfigæ¯å¦å·²å è½½ 46 if (!window.NavConfig) { 47 console.error('NavConfigæªå è½½ï¼è¯·ç¡®ä¿nav_config.jså¨nav_render.jsä¹åå è½½'); 48 // æå¤éè¯10次ï¼é¿å æ éå¾ªç¯ 49 if (!renderNavLinks.retryCount) { 50 renderNavLinks.retryCount = 0; 51 } 52 if (renderNavLinks.retryCount < 10) { 53 renderNavLinks.retryCount++; 54 setTimeout(() => renderNavLinks(game), 100); 55 } else { 56 console.error('NavConfigå 载失败ï¼å·²æ¾å¼éè¯'); 57 } 58 return; 59 } 60 renderNavLinks.retryCount = 0; // é置计æ°å¨ 61 62 // 渲æå¯¼èªé¾æ¥ 63 const navMenu = document.getElementById('mobile-nav-menu'); 64 if (navMenu) { 65 // åªæ¸²ææå®æ¸¸æç龿¥ï¼renderNavLinks ç°å¨æ¯å¼æ¥å½æ°ï¼ 66 (async () => { 67 try { 68 await window.NavConfig.renderNavLinks('mobile-nav-menu', currentPageId, game); 69 currentGame = game; 70 // 渲æå®æå触åèªå®ä¹äºä»¶ï¼åªå¨ééè¯æ¶è§¦åï¼é¿å 循ç¯ï¼ 71 if (!renderNavLinks.isRetrying) { 72 const event = new CustomEvent('navLinksRendered', { detail: { currentPageId, game } }); 73 document.dispatchEvent(event); 74 } 75 } catch (err) { 76 console.error('渲æå¯¼èªé¾æ¥å¤±è´¥:', err); 77 } 78 })(); 79 } else { 80 console.warn('æªæ¾å°å¯¼èªèåå®¹å¨ #mobile-nav-menu'); 81 // å»¶è¿éè¯ï¼æå¤éè¯5æ¬¡ï¼ 82 if (!renderNavLinks.menuRetryCount) { 83 renderNavLinks.menuRetryCount = 0; 84 } 85 if (renderNavLinks.menuRetryCount < 5) { 86 renderNavLinks.menuRetryCount++; 87 renderNavLinks.isRetrying = true; 88 setTimeout(() => { 89 renderNavLinks.isRetrying = false; 90 renderNavLinks(game); 91 }, 100); 92 } else { 93 console.error('导èªèå容卿ªæ¾å°ï¼å·²æ¾å¼éè¯'); 94 renderNavLinks.menuRetryCount = 0; 95 } 96 } 97 } 98 99 // åå§å导èªé¾æ¥ï¼å¨å¯¼èªæ 渲æå®æåè°ç¨ï¼ 100 function initNavLinks(pageId, defaultGame) { 101 currentPageId = pageId; 102 // çå¾ DOMå è½½å®æ 103 if (document.readyState === 'loading') { 104 document.addEventListener('DOMContentLoaded', function() { 105 renderNavLinks(defaultGame); 106 }); 107 } else { 108 renderNavLinks(defaultGame); 109 } 110 } 111 112 // åæ¢æ¸¸æç±»åï¼éæ°æ¸²æå¯¹åºæ¸¸æç龿¥ï¼ 113 function switchGame(game) { 114 console.log('switchNavGame被è°ç¨ï¼game:', game, 'currentPageId:', currentPageId); 115 // å³ä½¿ currentPageId 为 nullï¼å¦ privacy.html, about.html, terms.htmlï¼ï¼ä¹å¯ä»¥åæ¢æ¸¸æ 116 renderNavLinks(game); 117 } 118 119 // 导åºå°å ¨å± 120 window.initNavLinks = initNavLinks; 121 window.switchNavGame = switchGame; 122 123 // çå¬å¯¼èªæ 渲æå®æäºä»¶ 124 document.addEventListener('navBarRendered', function(e) { 125 // 妿æ¯ç¹æ®é¡µé¢ï¼isSpecial为trueï¼ï¼ä¼ énullè¡¨ç¤ºä¸æ¾ç¤ºåæ ç¾ 126 const game = e.detail.isSpecial ? null : e.detail.defaultGame; 127 initNavLinks(e.detail.currentPageId, game); 128 }); 129 130 // 横ç«å± / çªå£è·¨è¶ 768px æ¶éç»å¯¼èªï¼ç§»å¨ç«¯åå â æ¡é¢ååï¼ 131 var navResizeTimer = null; 132 window.addEventListener('resize', function() { 133 if (navResizeTimer) { 134 clearTimeout(navResizeTimer); 135 } 136 navResizeTimer = setTimeout(function() { 137 navResizeTimer = null; 138 renderNavLinks(currentGame); 139 }, 200); 140 }); 141})(); 142
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.