1/** 2 * PJAX åå§åä¸é¡µé¢åæ¢éç»å®èæ¬ 3 * ä¾èµï¼jQuery, jquery.pjax.min.js 4 * å 载顺åºï¼å¨ jquery.pjax.min.js ä¹åï¼body æ«å°¾ 5 */ 6 7(function ($) { 8 // ========== 常é ========== 9 var CONTAINER = '#pjax-container'; 10 var PJAX_OPTS = { 11 container: CONTAINER, 12 fragment: CONTAINER, 13 timeout: 5000, 14 scrollTo: false 15 }; 16 17 // ========== åç»ä»¶éåå§å ========== 18 19 /** Google Analytics 页颿µè§äºä»¶ */ 20 function trackPageView() { 21 if (typeof gtag === 'function') { 22 gtag('config', window._gaId || '', { page_path: window.location.pathname }); 23 } 24 } 25 26 /** Live2D éåå§å */ 27 var _live2dSelectors = ['.post-link', '#search-input']; 28 var _live2dDelegateBound = false; 29 30 function reinitLive2d() { 31 if (!window._live2d) return; 32 var pathname = window.location.pathname; 33 34 // æ´æ°"æ³é®è¿ç¯æç« "ç¸å ³ç¶æï¼ä» çæ£çæç« 页æ¾ç¤ºï¼ 35 $('#post_id').val(pathname); 36 if ($(CONTAINER + ' #gitalk-container').length > 0) { 37 $('.live_talk_input_name_body').show(); 38 } else { 39 $('.live_talk_input_name_body').hide(); 40 $('#load_this').prop('checked', false); 41 } 42 43 // é³ä¹æé®ï¼æ ¹æ®å½å页颿¯å¦æ BGM è¾å ¥æ¥æ¾ç¤º/éè 44 if (typeof window._live2d.initBGM === 'function') { 45 window._live2d.initBGM(); 46 } 47 48 // äºä»¶å§æç»å®ï¼åªæ§è¡ä¸æ¬¡ï¼ 49 if (!_live2dDelegateBound && typeof String.prototype.renderTip === 'function') { 50 var selector = CONTAINER + ' ' + _live2dSelectors.join(', ' + CONTAINER + ' '); 51 $(document).on('mouseover._live2d_pjax', selector, function (e) { 52 var $el = $(e.currentTarget || e.target); 53 if ($el.is('.post-link')) { 54 window._live2d.showMessage('è¦çç ' + $el.text() + ' ä¹ï¼', 3000); 55 } else if ($el.is('#search-input')) { 56 window._live2d.showMessage('卿¾ä»ä¹ä¸è¥¿å¢ï¼éè¦å¸®å¿åï¼', 3000); 57 } 58 }); 59 $(document).on('mouseout._live2d_pjax', selector, function () { 60 if (window._live2d.showHitokoto) window._live2d.showHitokoto(); 61 }); 62 _live2dDelegateBound = true; 63 } 64 65 // 欢è¿è¯ 66 if (typeof window._live2d.showMessage === 'function') { 67 window._live2d.showMessage(getWelcomeText(pathname), 6000); 68 } 69 } 70 71 // ========== PJAX å¯¼èª ========== 72 73 /** PJAX 宿åçç»ä¸å¤ç */ 74 function doPjaxComplete() { 75 $('body').removeClass('pjax-loading'); 76 // æ¸ çå¯è½æ®ççæµ®å±ï¼å¦æ¨èæç« tooltipï¼hover åç¹å»è·³è½¬æ¶ mouseleave æ¥ä¸å触åï¼ 77 $('.content-tooltip').remove(); 78 onPjaxComplete(); 79 } 80
81 /** æ´é²ç»æ¨¡æ¿å onclick/onchange è°ç¨ç导èªå½æ° */ 82 window.go = function (url) { 83 $.pjax($.extend({ url: url }, PJAX_OPTS)); 84 }; 85 86 // ========== åå§å ========== 87 88 /** pjax 宿忻å¨å°ç®æ ä½ç½®ï¼æéç¹åå®ä½éç¹ï¼å¦ååå°é¡¶é¨ */ 89 function scrollToAnchor() { 90 var hash = window.location.hash; 91 if (hash) { 92 // 䏿çé ASCII åç¬¦å¨ URL ä¸ä¼è¢«ç¼ç ï¼éå è§£ç åå¹é å ç´ id 93 var id = hash.slice(1); 94 try { id = decodeURIComponent(id); } catch (e) { /* ä¿æåå¼ */ } 95 var target = document.getElementById(id) || 96 document.querySelector('a[name="' + id + '"]'); 97 if (target) { 98 target.scrollIntoView({ behavior: 'smooth', block: 'start' }); 99 return; 100 } 101 } 102 window.scrollTo(0, 0); 103 } 104 105 /** æ¯æ¬¡ pjax å®æåæ§è¡ææéåå§å */ 106 function onPjaxComplete() { 107 initVisitors(); 108 initCopyButtons(); 109 highlightKeyword(); 110 reinitLive2d(); 111 trackPageView(); 112 scrollToAnchor(); 113 } 114 115 $(document).ready(function () { 116 // æé¤å表ï¼å¤é¾ãéç¹ãéæèµæºãLive2D ç®å½ 117 var exclude = ':not([target="_blank"]):not([href^="http"]):not([href^="//"])' + 118 ':not([href^="mailto"]):not([href^="#"])' + 119 ':not([href$=".xml"]):not([href$=".json"]):not([href$=".7z"]):not([href$=".zip"])' + 120 ':not([href^="/Live2dHistoire"])'; 121 $(document).pjax('a' + exclude, PJAX_OPTS.container, PJAX_OPTS); 122 $(document).on('submit', 'form#search-input-all', function (e) { 123 $.pjax.submit(e, PJAX_OPTS.container, PJAX_OPTS); 124 }); 125 $(document).on('pjax:send', function () { 126 $('body').addClass('pjax-loading'); 127 }); 128 $(document).on('pjax:complete', doPjaxComplete); 129 $(document).on('pjax:end', function (event, xhr, options) { 130 var $container = $(options.container || PJAX_OPTS.container); 131 132 $container.find('script[type="module"]').each(function () { 133 var oldScript = this; 134 var newScript = document.createElement('script'); 135 newScript.type = 'module'; 136 137 // 妿æ¯å¤é¾èæ¬ (<script src="..."></script>) 138 if (oldScript.src) { 139 newScript.src = oldScript.src; 140 } else { 141 // 妿æ¯è¡å èæ¬ (<script>...code...</script>) 142 newScript.textContent = oldScript.textContent; 143 } 144 // æå ¥å° body ä¸è§¦åæµè§å¨æ§è¡ 145 document.body.appendChild(newScript); 146 147 // è¿è¡å®å建议移é¤ï¼é²æ¢ DOM å徿··ä¹±ï¼ä¸å½±åæ¨¡åæ§è¡ï¼ 148 newScript.remove(); 149 }); 150 }); 151 }); 152 153})(jQuery);
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.