diff --git a/index.html b/index.html index 407114b..0e1ff5c 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ - 所见皆是 Minecraft + 所见皆是Minecraft @@ -42,15 +42,15 @@ - - - - - + + + + + - - + + diff --git a/scripts/init.js b/scripts/init.js index 1011ca4..7535502 100644 --- a/scripts/init.js +++ b/scripts/init.js @@ -1,4 +1,28 @@ -const init = ((file) => { +// 初始化全局变量 +let searchKeyword = '', searchableAbbr = ''; + +let notificationCount = ''; +let visibility = true; + +const downloadSVG = ''; +const downloadMirror = ((url) => `https://ghproxy.cn/${url}`); // 针对大陆地区 | for Chinese Mainland + + +// 国际化 (internationalization) +al.setLangPropPath('locales'); +al.setDefaultCountry({ + en: 'en', + zh: 'zh-CN' +}); +const i18n = ((callback = () => {}) => { + al.setLangProp(['zh-CN.yml','en.yml'], () => { + al.load(void 0, al.mode.HTML, callback); + }, {url: true, yaml: true}); +}); + + +// 读取 JSON5 文件 +const read = ((file) => { return JSON5.parse($.ajax({ url: `data/${file}.json5`, dataType: 'json', @@ -7,7 +31,7 @@ const init = ((file) => { }); // 启动器数据 -const launcherData = init('launcher'); +const launcherData = read('launcher'); // 各平台启动器数据 const AndroidLauncher = launcherData['AndroidLauncher']; const iOSLauncher = launcherData['iOSLauncher']; @@ -16,8 +40,20 @@ const macOSLauncher = launcherData['macOSLauncher']; const LinuxLauncher = launcherData['LinuxLauncher']; // 各类与搜索有关的站点数据 -const searchable = init('searchable'); +const searchable = read('searchable'); // 各类网站数据 -const utilityWebsite = init('utilityWebsite'); -const otherForum = init('otherForum'); +const utilityWebsite = read('utilityWebsite'); +const otherForum = read('otherForum'); + + +// 不记录历史滚动位置 +if (history.scrollRestoration) { + history.scrollRestoration = 'manual'; +}; + + +// 调试模式 (Debug Mode) +let debug = false; +const debugChange = (e = $('[visibleInDebugMode]')) => {for (const t of e) t.style.display = (debug ? 'block': 'none')}; +debugChange(); /* 监听变更我就先咕咕咕了 <(^-^)> --xs */ diff --git a/scripts/al.min.js b/scripts/lib/al.min.js similarity index 100% rename from scripts/al.min.js rename to scripts/lib/al.min.js diff --git a/scripts/browser.min.js b/scripts/lib/browser.min.js similarity index 100% rename from scripts/browser.min.js rename to scripts/lib/browser.min.js diff --git a/scripts/forums.js b/scripts/lib/forums.js similarity index 100% rename from scripts/forums.js rename to scripts/lib/forums.js diff --git a/scripts/jquery-3.7.1.min.js b/scripts/lib/jquery-3.7.1.min.js similarity index 100% rename from scripts/jquery-3.7.1.min.js rename to scripts/lib/jquery-3.7.1.min.js diff --git a/scripts/json5.min.js b/scripts/lib/json5.min.js similarity index 100% rename from scripts/json5.min.js rename to scripts/lib/json5.min.js diff --git a/scripts/mdui.global.js b/scripts/lib/mdui.global.js similarity index 100% rename from scripts/mdui.global.js rename to scripts/lib/mdui.global.js diff --git a/scripts/typeahead.jquery.min.js b/scripts/lib/typeahead.jquery.min.js similarity index 100% rename from scripts/typeahead.jquery.min.js rename to scripts/lib/typeahead.jquery.min.js diff --git a/scripts/main.js b/scripts/main.js index 5d986ca..1409c7b 100644 --- a/scripts/main.js +++ b/scripts/main.js @@ -1,11 +1,3 @@ -let searchKeyword = '', searchableAbbr = ''; - -let notificationCount = ''; -let visibility = true; - -const downloadSVG = ''; -const downloadMirror = ((url) => `https://ghproxy.cn/${url}`); // 针对大陆地区 | for Chinese Mainland - // 列出所有已支持的设备 const supportedDevices = [ // | 最早名称 | 显示名称 | @@ -18,26 +10,6 @@ const supportedDevices = [ DOMDeviceList.show(); -// 不记录历史滚动位置 -if (history.scrollRestoration) { - history.scrollRestoration = 'manual'; -}; - - -// 国际化 (internationalization) -al.setLangPropPath('locales'); -al.setDefaultCountry({ - en: 'en', - zh: 'zh-CN' -}); -const i18n = ((callback = () => {}) => { - al.setLangProp(['zh-CN.yml','en.yml'], () => { - al.load(void 0, al.mode.HTML, callback); - }, {url: true, yaml: true}); -}); - - - // 创建超文本标签(并点击) const createSuperLabel = ((url, id) => { const a = ``; @@ -84,7 +56,6 @@ const deleteUpdateLayer = function() { --updateLayerNumber; notificationCount = ''; if (updateLayerNumber) notificationCount = `(${updateLayerNumber})`; - i18n(); const number = Number($(this).attr('class').split('update-layer-')[1]); $(`.update-layer-${number}`).remove(); @@ -571,6 +542,7 @@ $(document).ready(() => { }; }; $('.update-layer').click(deleteUpdateLayer); + i18n(); }; // 默认值初始化 $('.Modrinth-projectType').val('mod'); @@ -603,8 +575,3 @@ $(document).on('visibilitychange', () => { visibility = true; }; }); - -// 调试模式 (Debug Mode) -let debug = false; -const debugChange = (e = $('[visibleInDebugMode]')) => {for (const t of e) t.style.display = (debug ? 'block': 'none')}; -debugChange(); /* 监听变更我就先咕咕咕了 <(^-^)> --xs */