-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added version check in GUI * Rename JS function --------- Co-authored-by: Josef Haupt <[email protected]>
- Loading branch information
1 parent
b84ef12
commit 0e1f552
Showing
3 changed files
with
99 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.d-block .wrap { | ||
display: block !important; | ||
} | ||
|
||
.mh-200 { | ||
max-height: 300px; | ||
overflow-y: auto !important; | ||
} | ||
|
||
footer { | ||
display: none !important; | ||
} | ||
|
||
#single_file_audio, | ||
#single_file_audio * { | ||
max-height: 81.6px; | ||
min-height: 0; | ||
} | ||
|
||
#update-notification { | ||
background: green; | ||
border-radius: 50%; | ||
width: 1rem; | ||
height: 1rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
function checkForNewerVersion() { | ||
function sendGetRequest(url) { | ||
return new Promise((resolve, reject) => { | ||
const xhr = new XMLHttpRequest(); | ||
xhr.open("GET", url); | ||
xhr.onload = () => { | ||
if (xhr.status === 200) { | ||
resolve(xhr.responseText); | ||
} else { | ||
reject(new Error(`Request failed with status ${xhr.status}`)); | ||
} | ||
}; | ||
xhr.onerror = () => { | ||
reject(new Error("Request failed")); | ||
}; | ||
xhr.send(); | ||
}); | ||
} | ||
|
||
const apiUrl = "https://api.github.com/repos/kahst/BirdNET-Analyzer/releases/latest"; | ||
|
||
sendGetRequest(apiUrl) | ||
.then(response => { | ||
const current_version = "v" + document.getElementById("current-version").textContent; | ||
const response_object = JSON.parse(response); | ||
const latest_version = response_object.tag_name; | ||
|
||
if (current_version !== latest_version) { | ||
const updateNotification = document.getElementById("update-available"); | ||
|
||
updateNotification.style.display = "block"; | ||
updateNotification.getElementsByTagName("a")[0].href = response_object.html_url; | ||
} | ||
}) | ||
.catch(error => { | ||
console.error(error); | ||
}); | ||
} |