1/* 2 * @Author: iowen 3 * @Author URI: https://www.iowen.cn/ 4 * @Date: 2023-02-01 00:01:43 5 * @LastEditors: iowen 6 * @LastEditTime: 2026-08-03 18:35:41 7 * @FilePath: /onenav/assets/js/require.js 8 * @Description: 模åå è½½å¨ 9 */ 10 11(function (global) { 12 var loadedScripts = {}; 13 var config = { 14 baseUrl: '', 15 urlArgs: '', 16 paths: {} 17 }; 18 19 // åå§å require 模å 20 var require = { 21 config: function (options) { 22 config = Object.assign(config, options); 23 }, 24 25 // æ£æ¥æ¯å¦æ¯ç»å¯¹ URL 26 isAbsoluteUrl: function (url) { 27 return /^(https?:)?\/\//.test(url); 28 }, 29 30 loadScript: function (url, callback) { 31 if (loadedScripts[url]) { 32 callback(true); 33 return; 34 } 35 36 var script = document.createElement('script'); 37 script.src = url; 38 script.onload = function () { 39 loadedScripts[url] = true; 40 callback(true); 41 }; 42 script.onerror = function () { 43 callback(false); 44 console.error('Error loading script:', url); 45 }; 46 document.head.appendChild(script); 47 }, 48 49 // å è½½å个æå¤ä¸ª URLï¼æ°ç»æ åµ 50 loadScriptsArray: function (urls, callback, errorCallback) { 51 var index = 0; 52 53 function tryLoadNext() { 54 if (index >= urls.length) { 55 callback(); 56 return; 57 } 58 59 require.loadScript(urls[index], function (success) { 60 if (!success) { 61 errorCallback && errorCallback(urls[index]); 62 } else { 63 index++; 64 tryLoadNext(); 65 } 66 }); 67 } 68 69 tryLoadNext(); 70 }, 71 72 load: function (deps, callback) { 73 if (typeof deps === 'string') { 74 deps = [deps]; 75 } 76 77 var loadedCount = 0; 78 var totalDeps = deps.length; 79 80 function onLoad() { 81 loadedCount++; 82 if (loadedCount === totalDeps && typeof callback === 'function') { 83 callback(); 84 } 85 } 86 87 deps.forEach(function (dep) { 88 var path = config.paths[dep] ? config.paths[dep] : dep; 89 var urls; 90 91 if (Array.isArray(path)) { 92 urls = path; 93 } else { 94 urls = [path]; 95 } 96 97 urls = urls.map(function (url) { 98 if (!require.isAbsoluteUrl(url)) { 99 url = [config.baseUrl + '/' + url + '.js']; // æ¼æ¥ baseUrl 100 } 101 if (config.urlArgs) { 102 return url + (url.indexOf('?') === -1 ? '?' : '&') + config.urlArgs; 103 } 104 return url; 105 }); 106 107 require.loadScriptsArray(urls, onLoad, function (failedUrl) { 108 console.error('Failed to load dependency:', dep, 'URL:', failedUrl); // è¾åºè¯¦ç»éè¯¯ä¿¡æ¯ 109 }); 110 }); 111 } 112 }; 113 114 global.ioRequire = function (deps, callback) { 115 require.load(deps, callback); 116 }; 117 118 global.ioRequire.config = require.config; 119 120})(window); 121 122// 示ä¾é ç½® 123ioRequire.config({ 124 baseUrl: IO.uri + '/assets/js', 125 urlArgs: 'ver=' + IO.version, 126 paths: { 127 'main': 'main' + IO.minAssets, 128 'lazyload': 'lazyload.min', 129 'captcha': 'captcha', 130 'comments': [IO.homeUrl + '/wp-includes/js/comment-reply.min.js', 'comments-ajax'], 131 'sticky-sidebar': 'theia-sticky-sidebar.min', 132 'slidercaptcha': 'longbow.slidercaptcha' + IO.minAssets, 133 'color-thief': 'color-thief.umd', 134 'fancybox': 'jquery.fancybox.min', 135 'echarts': ['echarts.min', 'sites-chart'], 136 'pay': IO.uri + '/iopay/assets/js/pay.js', 137 'new-post': ['new-post'], 138 'weather': '//widget.seniverse.com/widget/chameleon.js', 139 'weather-v2': '//cdn.sencdn.com/widget2/static/js/bundle.js?t=' + parseInt((new Date().getTime() / 100000000).toString(), 10), 140 'swiper': 'swiper-bundle.min', 141 } 142}); 143 144document.querySelectorAll(".panel-body.single img").forEach(function(img) { 145 // 妿å¾ç䏿¯ wp-smiley 并䏿²¡æè¢«å è£¹å¨ <a> ä¸ 146 if (!img.classList.contains('unfancybox') && 147 !img.classList.contains('wp-smiley') && 148 !img.parentElement.matches('a')) { 149 150 var imgSrc = IO.lazyload ? img.dataset.src : img.src; 151 var caption = img.alt || ''; 152 imgSrc = imgSrc || img.src; 153 154 var link = document.createElement('a'); 155 link.className = 'js'; 156 link.href = imgSrc; 157 link.setAttribute('data-fancybox', 'images'); 158 link.setAttribute('data-caption', caption); 159 160 img.parentNode.insertBefore(link, img); 161 link.appendChild(img); 162 } 163 164 if (IO.lazyload && img.dataset.src && !img.classList.contains('lazy')) { 165 img.classList.add('lazy'); 166 } 167}); 168 169 170//ioRequire(['lazyload','main']); 171//ioRequire('main'); 172ioRequire('lazyload', function () { 173 ioRequire('main'); 174});
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.