From a3b97c2b475b9cd085478a3b97075ee2a906d708 Mon Sep 17 00:00:00 2001 From: ManInDark <61268856+ManInDark@users.noreply.github.com> Date: Mon, 14 Aug 2023 18:47:53 +0200 Subject: [PATCH] Gallery Page Buttons now get disabled (and look different) when you can't go any further --- ui/media/css/main.css | 3 +++ ui/media/js/main.js | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/ui/media/css/main.css b/ui/media/css/main.css index 44e238f6..e7f1f6e1 100644 --- a/ui/media/css/main.css +++ b/ui/media/css/main.css @@ -1899,6 +1899,9 @@ div#enlarge-buttons { font-family: sans-serif; } */ +button:disabled { + background-color: var(--secondary-button-background); +} #gallery-search { display: flex; diff --git a/ui/media/js/main.js b/ui/media/js/main.js index 3bba6a31..beb9a122 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -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" }