mirror of
https://github.com/Gerald-Ha/HodlEye-Crypto-Price-Tracker.git
synced 2025-06-25 09:11:45 +00:00
- Responsive design addet - Crypto News Auto Update without Browser Refresh every 3 minutes - Crypto Price Refresh Reduce from 5 Second to 1 Second - Docker command updated to saved alarms and registered cryptocurrencies that are still there after a Docker image update --> docker run -p 3099:3099 -p 5001:5001 -v hodleye_data:/app/data --name hodleye-container hodleye-crypto-tracker - Bugfix "Edit List" works now - Addet Update Notification every 5 Days - re-Design from Crypto-box - improving the logic of the price display for small cryptocurrencies
83 lines
2.7 KiB
JavaScript
83 lines
2.7 KiB
JavaScript
const CURRENT_VERSION = "1.0.6";
|
|
|
|
function getUpdateUrl() {
|
|
return "/api/update?t=" + new Date().getTime();
|
|
}
|
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
document.getElementById("currentVersion").textContent = `Version ${CURRENT_VERSION}`;
|
|
checkForUpdates();
|
|
|
|
setInterval(checkForUpdates, 432000000);
|
|
});
|
|
|
|
function checkForUpdates() {
|
|
fetch(getUpdateUrl())
|
|
.then((response) => response.json())
|
|
.then((data) => {
|
|
let skippedVersion = localStorage.getItem("skippedVersion") || null;
|
|
|
|
if (skippedVersion && data.version !== skippedVersion) {
|
|
localStorage.removeItem("skippedVersion");
|
|
skippedVersion = null;
|
|
}
|
|
|
|
if (compareVersions(data.version, CURRENT_VERSION) > 0) {
|
|
const updateAvailableEl = document.getElementById("updateAvailable");
|
|
updateAvailableEl.style.display = "inline";
|
|
|
|
updateAvailableEl.onclick = () => {
|
|
fetch(getUpdateUrl())
|
|
.then((response) => response.json())
|
|
.then((data) => {
|
|
let skippedVersion = localStorage.getItem("skippedVersion") || null;
|
|
if (skippedVersion && data.version !== skippedVersion) {
|
|
localStorage.removeItem("skippedVersion");
|
|
skippedVersion = null;
|
|
}
|
|
openUpdateModal(data);
|
|
})
|
|
.catch((error) => console.error("Fehler beim erneuten Abrufen des Updates:", error));
|
|
};
|
|
}
|
|
})
|
|
.catch((error) => console.error("Fehler beim Abrufen des Updates:", error));
|
|
}
|
|
|
|
function compareVersions(v1, v2) {
|
|
const v1parts = v1.split(".").map(Number);
|
|
const v2parts = v2.split(".").map(Number);
|
|
for (let i = 0; i < Math.max(v1parts.length, v2parts.length); i++) {
|
|
const num1 = v1parts[i] || 0;
|
|
const num2 = v2parts[i] || 0;
|
|
if (num1 > num2) return 1;
|
|
if (num1 < num2) return -1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
function openUpdateModal(data) {
|
|
document.getElementById("updateVersion").textContent = data.version;
|
|
document.getElementById("updateChanges").textContent = data.changelog || "Kein Changelog vorhanden.";
|
|
|
|
window._updateData = data;
|
|
|
|
document.getElementById("updateModal").style.display = "block";
|
|
}
|
|
|
|
function closeUpdateModal() {
|
|
document.getElementById("updateModal").style.display = "none";
|
|
}
|
|
|
|
function performUpdate() {
|
|
window.open("https://github.com/Gerald-Ha/HodlEye-Crypto-Price-Tracker", "_blank");
|
|
closeUpdateModal();
|
|
}
|
|
|
|
function skipUpdate() {
|
|
if (window._updateData && window._updateData.version) {
|
|
localStorage.setItem("skippedVersion", window._updateData.version);
|
|
}
|
|
closeUpdateModal();
|
|
}
|