Gallery Page Buttons now get disabled (and look different) when you can't go any further

This commit is contained in:
ManInDark 2023-08-14 18:47:53 +02:00
parent 2dc8d8dd35
commit a3b97c2b47
No known key found for this signature in database
GPG Key ID: 72EC12A5B2D62779
2 changed files with 18 additions and 0 deletions

View File

@ -1899,6 +1899,9 @@ div#enlarge-buttons {
font-family: sans-serif;
}
*/
button:disabled {
background-color: var(--secondary-button-background);
}
#gallery-search {
display: flex;

View File

@ -3257,6 +3257,7 @@ function layoutGallery() {
}
function refreshGallery(newsearch = false) {
let BUTTONS = [...document.getElementById("gallery-search").children].filter(x => x.tagName === "BUTTON")
if (newsearch) {
document.getElementById("gallery-page").value = 0
}
@ -3294,6 +3295,20 @@ function refreshGallery(newsearch = false) {
layoutGallery()
})
})
fetch('/all_images?images_per_page=1&page=' + (parseInt(document.getElementById("gallery-page").value) + 1) * 50) // 50 has to be replaced if custom images per page is implemented
.then(response => response.json())
.then(json => {
if (json.length == 0) {
BUTTONS[2].disabled = true
} else {
BUTTONS[2].disabled = false
}
})
if (document.getElementById("gallery-page").value == 0) {
BUTTONS[0].disabled = true
} else {
BUTTONS[0].disabled = false
}
document.getElementById("gallery-refresh").innerText = "Refresh"
}