1
0
mirror of https://github.com/zumbiepig/MineXLauncher.git synced 2025-06-26 10:05:10 +00:00

remove offline, uses too much bandwidth

This commit is contained in:
zumbiepig
2024-08-20 20:42:41 -07:00
parent 64c5c5b179
commit 9bedbf18f1
6 changed files with 41 additions and 39 deletions

View File

@@ -284,19 +284,43 @@ const serviceworker = {
};
if (window.location.pathname === '/') {
const lastPage = storage.session.get('lastPage');
const isMobile = detect.mobile();
const iframe = document.createElement('iframe');
iframe.id = 'main_frame';
iframe.style.display = 'none';
iframe.addEventListener('load', () => {
iframe.style.display = '';
});
if (storage.local.get('lastVersion') === null) {
iframe.src = '/welcome/';
} else if (lastPage !== null) {
iframe.src = lastPage;
} else if (isMobile) {
iframe.src = '/mobile/';
} else {
iframe.src = '/home/game/';
}
document.addEventListener('DOMContentLoaded', () => {
document.body.appendChild(iframe);
});
window.addEventListener('beforeinstallprompt', (event) => {
const mainFrame = document.getElementById('main_frame') as HTMLIFrameElement;
if (mainFrame.contentWindow) {
if (iframe.contentWindow) {
// @ts-expect-error
mainFrame.contentWindow.installPwaEvent = event;
iframe.contentWindow.installPwaEvent = event;
}
});
if (storage.local.get('offlineCache') === true) {
/* if (storage.local.get('offlineCache') === true) {
serviceworker.register('/sw-full.js');
} else {
serviceworker.register('/sw.js');
}
} */
serviceworker.register('/sw.js');
} else {
document.addEventListener('DOMContentLoaded', () => {
const profileName = document.getElementById('profile-name');
@@ -311,7 +335,6 @@ if (window.location.pathname === '/') {
alert(`MineXLauncher has been updated to v${launcherVersion}!
Changes in v${launcherVersion}:
- The launcher can now be downloaded for offline use
- You can now install the launcher as a PWA web app`);
storage.local.set('lastVersion', launcherVersion);
}

View File

@@ -3,11 +3,11 @@ if (window.location.pathname === '/settings/') {
const profileName = document.getElementById('profile-name');
const usernameInput = document.getElementById('username-input') as HTMLInputElement;
const themeSelect = document.getElementById('theme-select') as HTMLSelectElement;
const offlineCheckbox = document.getElementById('offline-checkbox') as HTMLInputElement;
// const offlineCheckbox = document.getElementById('offline-checkbox') as HTMLInputElement;
usernameInput.placeholder = storage.local.get('username') ?? '';
themeSelect.value = storage.local.get('theme') ?? '';
offlineCheckbox.checked = storage.local.get('offlineCache') ?? false;
// offlineCheckbox.checked = storage.local.get('offlineCache') ?? false;
usernameInput.addEventListener('input', () => {
let username = usernameInput.value.replace(/[^A-Za-z0-9]/g, '_').substring(0, 16);
@@ -25,7 +25,7 @@ if (window.location.pathname === '/settings/') {
theme.set(themeSelect.value);
});
offlineCheckbox.addEventListener('change', () => {
/* offlineCheckbox.addEventListener('change', () => {
storage.local.set('offlineCache', offlineCheckbox.checked);
if (offlineCheckbox.checked) {
serviceworker.register('/sw-full.js');
@@ -36,7 +36,7 @@ if (window.location.pathname === '/settings/') {
serviceworker.register('/sw.js');
alert('Offline cache has been deleted.');
}
});
}); */
});
}
@@ -45,7 +45,7 @@ if (window.location.pathname === '/welcome/') {
const setupForm = document.getElementById('setup-form') as HTMLFormElement;
const usernameInput = document.getElementById('username-input') as HTMLInputElement;
const themeSelect = document.getElementById('theme-select') as HTMLSelectElement;
const offlineCheckbox = document.getElementById('offline-checkbox') as HTMLInputElement;
// const offlineCheckbox = document.getElementById('offline-checkbox') as HTMLInputElement;
usernameInput.addEventListener('input', () => {
const username = usernameInput.value.replace(/[^A-Za-z0-9]/g, '_').substring(0, 16);
@@ -72,10 +72,10 @@ if (window.location.pathname === '/welcome/') {
storage.local.set('username', username);
storage.local.set('theme', themeSelect.value);
storage.local.set('offlineCache', offlineCheckbox.checked);
// storage.local.set('offlineCache', offlineCheckbox.checked);
storage.local.set('lastVersion', launcherVersion);
if (offlineCheckbox.checked) {
/* if (offlineCheckbox.checked) {
serviceworker.register('/sw-full.js');
alert(
'Offline cache is now downloading.\nThe download size is about 1GB, so it may take a while.\n\nPlease do not leave this page while the download is in progress.\nYou will be notified when the download is complete.'
@@ -88,7 +88,7 @@ if (window.location.pathname === '/welcome/') {
}
} else {
serviceworker.register('/sw.js');
}
} */
// @ts-expect-error
window.top.location.href = '/';