From 79f6b3a237b952b29d1a767310edf7ab9efd1603 Mon Sep 17 00:00:00 2001 From: Index Date: Thu, 22 Feb 2024 22:33:36 -0600 Subject: [PATCH] Improved Settings Page Footer You are now able to see the version number, build type (stable or pre-release), and quickly check for updates The text has been changed to say "made by Index with the help of several contributors" instead of just "made by Index" --- js/debug.js | 10 ---------- settings.html | 8 +++++++- settings.js | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/js/debug.js b/js/debug.js index c308903..4a04499 100644 --- a/js/debug.js +++ b/js/debug.js @@ -79,16 +79,6 @@ function CheckForUpdates() { return response.json() }) .then(data => { - /* - const Result = document.createElement('span') - if (data.version === Version || Math.floor((data.version - Version) * 10) === 0) { - Result.innerText = 'No updates available' - } else { - Result.innerText = Math.floor((data.version - Version) * 10) + ' updates available' - } - CheckForUpdatesButton.parentElement.insertBefore(Result, CheckForUpdatesButton) - CheckForUpdatesButton.remove() - */ if (data.version === Version || Math.floor((data.version - Version) * 10) === 0) { CheckForUpdatesButton.innerText = 'No updates available' } else { diff --git a/settings.html b/settings.html index e5f16fb..7b9565f 100755 --- a/settings.html +++ b/settings.html @@ -546,7 +546,13 @@ -

made by Index

+ diff --git a/settings.js b/settings.js index 7b820e8..41eafba 100755 --- a/settings.js +++ b/settings.js @@ -315,4 +315,36 @@ function LoadFile(path, callback) { xhr.onload = function () { return callback(this.responseText); } xhr.open("GET", path, true); xhr.send(); -} \ No newline at end of file +} + +const Manifest = chrome.runtime.getManifest() +let BuildType = "Stable" +if (Manifest.version_name !== undefined) {BuildType = "Pre-Release"} + +const FooterText = document.getElementById('footer-text') +FooterText.children[0].innerHTML = `Version: v${Manifest.version} | Build Type: ${BuildType}` + +const CheckForUpdatesButton = document.getElementById('check-for-updates') +function CheckForUpdates() { + CheckForUpdatesButton.removeEventListener('click', CheckForUpdates) + CheckForUpdatesButton.disabled = true + fetch('https://polyplus.vercel.app/data/version.json') + .then(response => { + if (!response.ok) { + throw new Error('Network not ok') + } + return response.json() + }) + .then(data => { + if (data.version === Manifest.version || Math.floor((data.version - Manifest.version) * 10) === 0) { + CheckForUpdatesButton.innerHTML = 'No updates available' + alert('No updates available') + } else { + const NumberOfUpdatesAvailable = Math.floor((data.version - Version) * 10) + CheckForUpdatesButton.innerHTML = ''+NumberOfUpdatesAvailable+' update(s) available' + alert(NumberOfUpdatesAvailable + ' updates available') + } + }) + .catch(error => {console.log(error)}); +} +CheckForUpdatesButton.addEventListener('click', CheckForUpdates) \ No newline at end of file