1
0
mirror of https://github.com/zumbiepig/MineXLauncher.git synced 2025-06-08 09:24:48 +00:00
This commit is contained in:
zumbiepig 2024-09-03 20:20:03 -07:00
parent 8d7d7a7c1c
commit 87e2cab85b
No known key found for this signature in database
GPG Key ID: 17C891BE28B953DE
3 changed files with 22 additions and 28 deletions

View File

@ -27,16 +27,7 @@
<input id="username-input" placeholder="Enter username" /> <input id="username-input" placeholder="Enter username" />
<label for="theme-select">Theme:</label> <label for="theme-select">Theme:</label>
<select id="theme-select"> <select id="theme-select">
<option selected value="default">Default</option> <option disabled selected hidden value=""></option>
<option value="light">Light</option>
<option value="hyperdark">Hyperdark</option>
<option value="overworld">Overworld</option>
<option value="nether">Nether</option>
<option value="the-end">The End</option>
<option value="cherry-blossom">Cherry Blossom</option>
<option value="retro">Retro</option>
<option value="starfall">Starfall</option>
<option value="campfire">Campfire</option>
</select> </select>
<!-- <label for="offline-checkbox">Enable offline use:</label> <!-- <label for="offline-checkbox">Enable offline use:</label>
<input type="checkbox" id="offline-checkbox" /> --> <input type="checkbox" id="offline-checkbox" /> -->

View File

@ -7,14 +7,9 @@ const theme = {
load: function (themeToLoad?: string) { load: function (themeToLoad?: string) {
const themeElement = document.getElementById('theme') as HTMLLinkElement; const themeElement = document.getElementById('theme') as HTMLLinkElement;
if (themeElement) { if (themeElement) {
if (themeToLoad) { document.documentElement.style.display = 'none';
themeElement.href = `/resources/styles/themes/${themeToLoad}.css`; themeElement.onload = () => (document.documentElement.style.display = '');
} else { themeElement.href = themeToLoad ? `/resources/styles/themes/${themeToLoad}.css` : `/resources/styles/themes/${storage.local.get('theme') ?? 'default'}.css`;
const savedTheme = storage.local.get('theme');
if (savedTheme) {
themeElement.href = `/resources/styles/themes/${savedTheme}.css`;
}
}
} }
}, },
set: function (newTheme: string) { set: function (newTheme: string) {
@ -349,8 +344,6 @@ const base64Gzip = {
}, },
}; };
theme.load();
if (detect.mobile()) { if (detect.mobile()) {
const link = document.createElement('link'); const link = document.createElement('link');
link.rel = 'stylesheet'; link.rel = 'stylesheet';
@ -366,11 +359,6 @@ if (window.location.pathname === '/') {
document.addEventListener('DOMContentLoaded', () => document.body.appendChild(iframe)); document.addEventListener('DOMContentLoaded', () => document.body.appendChild(iframe));
window.addEventListener('beforeinstallprompt', (event) => {
// @ts-expect-error
if (iframe.contentWindow) iframe.contentWindow.installPwaEvent = event;
});
/* document.addEventListener('load', () => { /* document.addEventListener('load', () => {
if (storage.local.get('offlineCache')) { if (storage.local.get('offlineCache')) {
sw.register('/sw-full.js'); sw.register('/sw-full.js');
@ -379,7 +367,21 @@ if (window.location.pathname === '/') {
} }
}); */ }); */
document.addEventListener('load', () => sw.register('/sw.js')); document.addEventListener('load', () => sw.register('/sw.js'));
window.addEventListener('beforeinstallprompt', (event) => {
// @ts-expect-error
if (iframe.contentWindow) iframe.contentWindow.installPwaEvent = event;
});
} else { } else {
document.addEventListener('DOMContentLoaded', () => {
const themeElement = document.getElementById('theme') as HTMLLinkElement;
if (themeElement) {
document.documentElement.style.display = 'none';
themeElement.onload = () => (document.documentElement.style.display = '');
themeElement.href = `/resources/styles/themes/${storage.local.get('theme') ?? 'default'}.css`;
}
});
document.addEventListener('DOMContentLoaded', async () => { document.addEventListener('DOMContentLoaded', async () => {
const profileName = document.getElementById('profile-name'); const profileName = document.getElementById('profile-name');
const titleBarText = document.getElementById('title-bar-text'); const titleBarText = document.getElementById('title-bar-text');
@ -449,7 +451,7 @@ if (window.location.pathname === '/settings/') {
if (profileName) profileName.textContent = username; if (profileName) profileName.textContent = username;
}); });
themeSelect.addEventListener('change', () => theme.set(themeSelect.value)); themeSelect.addEventListener('change', () => theme.set(themeSelect.value ?? 'default'));
/* offlineCheckbox.addEventListener('change', () => { /* offlineCheckbox.addEventListener('change', () => {
storage.local.set('offlineCache', offlineCheckbox.checked); storage.local.set('offlineCache', offlineCheckbox.checked);
@ -490,7 +492,7 @@ if (window.location.pathname === '/settings/') {
usernameInput.value = username; usernameInput.value = username;
}); });
themeSelect.addEventListener('change', () => theme.load(themeSelect.value)); themeSelect.addEventListener('change', () => theme.load(themeSelect.value ?? 'default'));
setupForm.addEventListener('submit', async (event) => { setupForm.addEventListener('submit', async (event) => {
event.preventDefault(); event.preventDefault();
@ -505,7 +507,7 @@ if (window.location.pathname === '/settings/') {
while (username.length < 3) username += '_'; while (username.length < 3) username += '_';
storage.local.set('username', username); storage.local.set('username', username);
storage.local.set('theme', themeSelect.value); storage.local.set('theme', themeSelect.value ?? 'default');
// storage.local.set('offlineCache', offlineCheckbox.checked); // storage.local.set('offlineCache', offlineCheckbox.checked);
storage.local.set('showAds', true); storage.local.set('showAds', true);
storage.local.set('mods', []); storage.local.set('mods', []);

View File

@ -7,6 +7,7 @@ const cacheAssets: string[] = [
'/resources/images/icons/favicon.webp', '/resources/images/icons/favicon.webp',
'/resources/scripts/google-tag.js', '/resources/scripts/google-tag.js',
'/resources/scripts/main.js', '/resources/scripts/main.js',
'/resources/styles/index.css',
'/resources/styles/mobile.css', '/resources/styles/mobile.css',
'/resources/styles/themes/default.css', '/resources/styles/themes/default.css',
'/resources/styles/themes/light.css', '/resources/styles/themes/light.css',