Skip to content

Commit

Permalink
moved versioning information to a separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
afonsosousah committed Jan 25, 2024
1 parent 6f24799 commit b23e01e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 36 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<script src="scripts/extras.js"></script>
<script src="scripts/swipe.js"></script>
<script src="scripts/fulltilt.js"></script>
<script src="scripts/version.js"></script>
<script src="https://cdn.jsdelivr.net/npm/ol@v8.1.0/dist/ol.js"></script>
<script src="https://unpkg.com/ol-mapbox-style@9.4.0/dist/olms.js"></script>
<script type="module" src="https://unpkg.com/openrouteservice-js@0.3.2/dist/ors-js-client.js"></script>
Expand Down
36 changes: 1 addition & 35 deletions scripts/stations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!<br>
<ul>
<li>Mudança da UI</li>
<li>Suporte para botão voltar atrás nativo (obrigado DanielAgostinho)</li>
<li>Pedidos e error handling melhorados (obrigado rodrigoleitao)</li>
<li>Proxy já não é utilizado no login na API da EMEL (obrigado j0dd)</li>
<li>Melhorias no sistema de navegação (já não utiliza a bússola do dispositivo)</li>
</ul>
`);
document.cookie = "version=0.0.3" + "; expires=" + expiryDate.toGMTString();
}
} else {
alert(`
Nova versão 0.0.3!<br>
<ul>
<li>Mudança da UI</li>
<li>Suporte para botão voltar atrás nativo (obrigado DanielAgostinho)</li>
<li>Pedidos e error handling melhorados (obrigado rodrigoleitao)</li>
<li>Proxy já não é utilizado no login na API da EMEL (obrigado j0dd)</li>
<li>Melhorias no sistema de navegação (já não utiliza a bússola do dispositivo)</li>
</ul>
`);
document.cookie = "version=0.0.3" + "; expires=" + expiryDate.toGMTString();
}
}, 2000);
showUpdateInfoIfNeeded();

return response.data.getStations;
} else {
Expand Down
2 changes: 1 addition & 1 deletion scripts/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ async function openUserSettings() {
</div>
</div>
<div id="bottom">
<div id="versionNumber">0.0.3</div>
<div id="versionNumber">${currentVersion}</div>
<div id="logoutButton" onclick="openLoginMenu()">Sair</div>
</div>
`.trim();
Expand Down
37 changes: 37 additions & 0 deletions scripts/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@


// Current version number
const currentVersion = "0.0.3";

// Changelog HTML
const changelogHTML = `
Nova versão 0.0.3!<br>
<ul>
<li>Mudança da UI</li>
<li>Suporte para botão voltar atrás nativo (obrigado DanielAgostinho)</li>
<li>Pedidos e error handling melhorados (obrigado rodrigoleitao)</li>
<li>Proxy já não é utilizado no login na API da EMEL (obrigado j0dd)</li>
<li>Melhorias no sistema de navegação (já não utiliza a bússola do dispositivo)</li>
</ul>
`;


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);
}

0 comments on commit b23e01e

Please sign in to comment.