mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-03 17:52:30 +02:00
version alert
This commit is contained in:
parent
4249da5595
commit
585562b363
@ -60,6 +60,49 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script th:inline="javascript">
|
||||||
|
function compareVersions(version1, version2) {
|
||||||
|
const v1 = version1.split('.');
|
||||||
|
const v2 = version2.split('.');
|
||||||
|
|
||||||
|
for (let i = 0; i < v1.length || i < v2.length; i++) {
|
||||||
|
const n1 = parseInt(v1[i]) || 0;
|
||||||
|
const n2 = parseInt(v2[i]) || 0;
|
||||||
|
|
||||||
|
if (n1 > n2) {
|
||||||
|
return 1;
|
||||||
|
} else if (n1 < n2) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getLatestReleaseVersion() {
|
||||||
|
const url = "https://api.github.com/repos/Frooodle/Stirling-PDF/releases/latest";
|
||||||
|
const response = await fetch(url);
|
||||||
|
const data = await response.json();
|
||||||
|
return data.tag_name.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentVersion = /*[[${@appVersion}]]*/ ''; // Replace with your current version number
|
||||||
|
|
||||||
|
async function checkForUpdate() {
|
||||||
|
const latestVersion = await getLatestReleaseVersion();
|
||||||
|
console.log("latestVersion=" + latestVersion)
|
||||||
|
console.log("currentVersion=" + currentVersion)
|
||||||
|
console.log("compareVersions(latestVersion, currentVersion) > 0)=" + compareVersions(latestVersion, currentVersion))
|
||||||
|
if (latestVersion != null && latestVersion != "" && compareVersions(currentVersion, latestVersion) > 0) {
|
||||||
|
document.getElementById("update-btn").style.display = "block";
|
||||||
|
} else {
|
||||||
|
document.getElementById("update-btn").style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
checkForUpdate();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
<div class="container ">
|
<div class="container ">
|
||||||
@ -133,7 +176,13 @@
|
|||||||
|
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<button type="button" class="btn btn-outline-primary" id="update-btn">Update available</button>
|
<button type="button" class="btn btn-outline-primary" id="update-btn">Update available</button>
|
||||||
</li>
|
|
||||||
|
<li class="nav-item">
|
||||||
|
<!-- Settings Button -->
|
||||||
|
<button type="button" class="btn btn-secondary float-right" data-toggle="modal" data-target="#settingsModal">
|
||||||
|
<span class="glyphicon glyphicon-cog"></span> Settings/About
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
@ -168,10 +217,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Settings Button -->
|
|
||||||
<button type="button" class="btn btn-secondary float-right" data-toggle="modal" data-target="#settingsModal">
|
|
||||||
<span class="glyphicon glyphicon-cog"></span> Settings/About
|
|
||||||
</button>
|
|
||||||
<script>
|
<script>
|
||||||
// Get the download option from local storage, or set it to 'sameWindow' if it doesn't exist
|
// Get the download option from local storage, or set it to 'sameWindow' if it doesn't exist
|
||||||
var downloadOption = localStorage.getItem('downloadOption')
|
var downloadOption = localStorage.getItem('downloadOption')
|
||||||
|
Loading…
Reference in New Issue
Block a user