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"
This commit is contained in:
Index 2024-02-22 22:33:36 -06:00
parent 7af0a628b0
commit 79f6b3a237
3 changed files with 40 additions and 12 deletions

View file

@ -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 {

View file

@ -546,7 +546,13 @@
<button id="Save" class="btn btn-primary w-50" disabled="true">Save</button>
<button id="ResetDefaults" class="btn btn-warning w-50">Reset to Default Settings</button>
</div>
<p class="text-center text-muted mt-2" style="font-size: 0.8rem;">made by Index</p>
<p id="footer-text" class="text-center text-muted mt-2" style="font-size: 0.8rem;">
<span></span>
|
<a id="check-for-updates"><b>Check for Updates</b></a>
<br>
made by Index with the help of several contributors <3
</p>
</div>
<script src="settings.js"></script>
</body>

View file

@ -315,4 +315,36 @@ function LoadFile(path, callback) {
xhr.onload = function () { return callback(this.responseText); }
xhr.open("GET", path, true);
xhr.send();
}
}
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 = '<b>No updates available</b>'
alert('No updates available')
} else {
const NumberOfUpdatesAvailable = Math.floor((data.version - Version) * 10)
CheckForUpdatesButton.innerHTML = '<b>'+NumberOfUpdatesAvailable+' update(s) available</b>'
alert(NumberOfUpdatesAvailable + ' updates available')
}
})
.catch(error => {console.log(error)});
}
CheckForUpdatesButton.addEventListener('click', CheckForUpdates)