Skip to content

Commit

Permalink
refactor: tidy files
Browse files Browse the repository at this point in the history
  • Loading branch information
teaSummer committed Aug 3, 2024
1 parent 38e889e commit 5f1ca38
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 47 deletions.
16 changes: 8 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.9, minimum-scale=0.9">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title al="head.title">所见皆是 Minecraft</title>
<title al="head.title">所见皆是Minecraft</title>
<!-- pwa: manifest -->
<link rel="manifest" href="manifest.json">
<!-- [start] pwa: backward support -->
Expand Down Expand Up @@ -42,15 +42,15 @@
<link rel="stylesheet" href="assets/mdui.css">
<link rel="stylesheet" href="assets/typeahead.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"/>
<script src="scripts/mdui.global.js"></script>
<script src="scripts/jquery-3.7.1.min.js"></script>
<script src="scripts/json5.min.js"></script>
<script src="scripts/al.min.js"></script>
<script src="scripts/browser.min.js"></script>
<script src="scripts/lib/mdui.global.js"></script>
<script src="scripts/lib/jquery-3.7.1.min.js"></script>
<script src="scripts/lib/json5.min.js"></script>
<script src="scripts/lib/al.min.js"></script>
<script src="scripts/lib/browser.min.js"></script>
<script src="scripts/init.js"></script>
<script src="scripts/DOMConstructor.js"></script>
<script src="scripts/typeahead.jquery.min.js"></script>
<script src="scripts/forums.js"></script>
<script src="scripts/lib/typeahead.jquery.min.js"></script>
<script src="scripts/lib/forums.js"></script>
</head>

<body class="page-body">
Expand Down
46 changes: 41 additions & 5 deletions scripts/init.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
const init = ((file) => {
// 初始化全局变量
let searchKeyword = '', searchableAbbr = '';

let notificationCount = '';
let visibility = true;

const downloadSVG = '<span class="svg right"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M320 336h76c55 0 100-21.21 100-75.6s-53-73.47-96-75.6C391.11 99.74 329 48 256 48c-69 0-113.44 45.79-128 91.2-60 5.7-112 35.88-112 98.4S70 336 136 336h56M192 400.1l64 63.9 64-63.9M256 224v224.03" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="56"></path></svg></span>';
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',
Expand All @@ -7,7 +31,7 @@ const init = ((file) => {
});

// 启动器数据
const launcherData = init('launcher');
const launcherData = read('launcher');
// 各平台启动器数据
const AndroidLauncher = launcherData['AndroidLauncher'];
const iOSLauncher = launcherData['iOSLauncher'];
Expand All @@ -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 */
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
35 changes: 1 addition & 34 deletions scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
let searchKeyword = '', searchableAbbr = '';

let notificationCount = '';
let visibility = true;

const downloadSVG = '<span class="svg right"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M320 336h76c55 0 100-21.21 100-75.6s-53-73.47-96-75.6C391.11 99.74 329 48 256 48c-69 0-113.44 45.79-128 91.2-60 5.7-112 35.88-112 98.4S70 336 136 336h56M192 400.1l64 63.9 64-63.9M256 224v224.03" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="56"></path></svg></span>';
const downloadMirror = ((url) => `https://ghproxy.cn/${url}`); // 针对大陆地区 | for Chinese Mainland

// 列出所有已支持的设备
const supportedDevices = [
// | 最早名称 | 显示名称 |
Expand All @@ -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 = `<a href="" target="_blank" id="${id}">`;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -571,6 +542,7 @@ $(document).ready(() => {
};
};
$('.update-layer').click(deleteUpdateLayer);
i18n();
};
// 默认值初始化
$('.Modrinth-projectType').val('mod');
Expand Down Expand Up @@ -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 */

0 comments on commit 5f1ca38

Please sign in to comment.