Skip to content

Commit

Permalink
Add force update check
Browse files Browse the repository at this point in the history
  • Loading branch information
Marlamin committed Sep 10, 2023
1 parent 034c4ed commit 8043bcc
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions wwwroot/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ $(function() {
checkForUpdates();
});

async function checkForUpdates() {
if (document.cookie) {
async function checkForUpdates(force = false) {
if (document.cookie && !force) {
newUpdateAvailable(JSON.parse(document.cookie).updateAvailable);
return;
}
Expand Down Expand Up @@ -73,13 +73,19 @@ function newUpdateAvailable(isUpdateAvailable) {
var updateDiv = document.createElement("div");
updateDiv.id = 'updateDiv';
if (isUpdateAvailable) {
updateDiv.innerHTML = "<i class='fa fa-exclamation-circle' style='color: red'></i> <a href='https://github.com/marlamin/wow.tools.local/releases' target='_BLANK'>An update to version " + JSON.parse(document.cookie).latestVersion + " is available!</a>";
updateDiv.innerHTML = "<i class='fa fa-exclamation-circle' style='color: red'></i> <a href='https://github.com/marlamin/wow.tools.local/releases' target='_BLANK'>An update to version " + JSON.parse(document.cookie).latestVersion + " is available!</a> <a href='#' onClick='forceUpdateCheck()'><i class='fa fa-refresh'></i></a>";
} else {
updateDiv.innerHTML = "<i class='fa fa-check-circle' style='color: green'></i> Up to date.";
updateDiv.innerHTML = "<i class='fa fa-check-circle' style='color: green'></i> Up to date. <a href='#' onClick='forceUpdateCheck()'><i class='fa fa-refresh'></i></a>";
}
navBar[0].appendChild(updateDiv);
}

function forceUpdateCheck() {
var element = document.getElementById("updateDiv");
element.parentNode.removeChild(element);
checkForUpdates(true);
}

function renderBLPToIMGElement(url, elementID){
fetch(url).then(function(response) {
return response.arrayBuffer();
Expand Down

0 comments on commit 8043bcc

Please sign in to comment.