From b23e01e2cf1088778923ce67a47c171ae8299fa2 Mon Sep 17 00:00:00 2001 From: afonsosousah Date: Thu, 25 Jan 2024 23:41:18 +0000 Subject: [PATCH] moved versioning information to a separate file --- index.html | 1 + scripts/stations.js | 36 +----------------------------------- scripts/user.js | 2 +- scripts/version.js | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 36 deletions(-) create mode 100644 scripts/version.js diff --git a/index.html b/index.html index f1fd84d..26b2e98 100644 --- a/index.html +++ b/index.html @@ -57,6 +57,7 @@ + diff --git a/scripts/stations.js b/scripts/stations.js index 6bfafd7..364bea0 100644 --- a/scripts/stations.js +++ b/scripts/stations.js @@ -75,41 +75,7 @@ async function getStations() { getUserInformation(); // Check if update info should be shown - setTimeout(() => { - // Set the cookie expiry to 1 year after today. - const expiryDate = new Date(); - expiryDate.setFullYear(expiryDate.getFullYear() + 1); - - // Check version to show update notes - const tempVersion = getCookie("version"); - if (tempVersion) { - if (tempVersion !== "0.0.3") { - alert(` - Nova versão 0.0.3!
- - `); - document.cookie = "version=0.0.3" + "; expires=" + expiryDate.toGMTString(); - } - } else { - alert(` - Nova versão 0.0.3!
- - `); - document.cookie = "version=0.0.3" + "; expires=" + expiryDate.toGMTString(); - } - }, 2000); + showUpdateInfoIfNeeded(); return response.data.getStations; } else { diff --git a/scripts/user.js b/scripts/user.js index 0ae1532..c739312 100644 --- a/scripts/user.js +++ b/scripts/user.js @@ -217,7 +217,7 @@ async function openUserSettings() {
-
0.0.3
+
${currentVersion}
Sair
`.trim(); diff --git a/scripts/version.js b/scripts/version.js new file mode 100644 index 0000000..57c7f7a --- /dev/null +++ b/scripts/version.js @@ -0,0 +1,37 @@ + + +// Current version number +const currentVersion = "0.0.3"; + +// Changelog HTML +const changelogHTML = ` +Nova versão 0.0.3!
+ +`; + + +function showUpdateInfoIfNeeded() { + setTimeout(() => { + // Set the cookie expiry to 1 year after today. + const expiryDate = new Date(); + expiryDate.setFullYear(expiryDate.getFullYear() + 1); + + // Check version to show update notes + const userVersion = getCookie("version"); + if (userVersion) { + if (userVersion !== "0.0.3") { + alert(changelogHTML); + document.cookie = "version=" + currentVersion + "; expires=" + expiryDate.toGMTString(); + } + } else { + alert(changelogHTML); + document.cookie = "version=" + currentVersion + "; expires=" + expiryDate.toGMTString(); + } + }, 1500); +} \ No newline at end of file