1
0
mirror of https://github.com/zumbiepig/MineXLauncher.git synced 2025-06-08 09:24:48 +00:00

remove offline, uses too much bandwidth

This commit is contained in:
zumbiepig 2024-08-20 20:42:41 -07:00
parent acd410f575
commit 9b731c71ce
No known key found for this signature in database
GPG Key ID: 17C891BE28B953DE
6 changed files with 41 additions and 39 deletions

View File

@ -22,25 +22,5 @@
<meta property="og:locale" content="en-US" />
<script src="/resources/scripts/google-tag.js"></script>
<script src="/resources/scripts/main.js"></script>
<script>
const lastPage = storage.session.get('lastPage');
const isMobile = detect.mobile();
const iframe = document.createElement('iframe');
iframe.id = 'main_frame'
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', function () {
document.body.appendChild(iframe);
});
</script>
</head>
</html>

View File

@ -70,10 +70,10 @@
<option value="campfire">Campfire</option>
</select>
</div>
<div class="settings-section">
<!-- <div class="settings-section">
<label for="offline-checkbox">Enable offline use:</label>
<input type="checkbox" id="offline-checkbox" />
</div>
</div> -->
</div>
</div>
</div>

View File

@ -51,7 +51,6 @@
<div class="news-item">
<!-- Don't forget to update launcherVersion and the changelog in main.js as well -->
<strong>MineXLauncher 1.5</strong>
<li>The launcher can now be downloaded for offline use</li>
<li>You can now install the launcher as a PWA web app</li>
<br />
<strong>MineXLauncher 1.4</strong>

View File

@ -39,8 +39,8 @@
<option value="starfall">Starfall</option>
<option value="campfire">Campfire</option>
</select>
<label for="offline-checkbox">Enable offline use:</label>
<input type="checkbox" id="offline-checkbox" />
<!-- <label for="offline-checkbox">Enable offline use:</label>
<input type="checkbox" id="offline-checkbox" /> -->
<button type="submit" class="setup-submit">Submit</button>
</form>
</div>

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 = '/';