From 6c7f991f5c65b608f50b9a3683e2b2a1229188a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Kotiuk?= Date: Sun, 14 Apr 2024 18:58:45 +0200 Subject: [PATCH] Allow changing name button --- layouts/partials/footer.html | 4 ++-- static/js/badge.js | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index c655ddb..c82b7bd 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -71,13 +71,13 @@

-
+

Warsztat 027

-
+
diff --git a/static/js/badge.js b/static/js/badge.js index 7b254c1..346c8d4 100644 --- a/static/js/badge.js +++ b/static/js/badge.js @@ -12,12 +12,18 @@ function handleError(error){ } function updateButtonState(button_element, hook_info){ - button_element.className='haczyk_right'; + const element_right = button_element.getElementsByClassName("haczyk_right")[0]; + const button_text = button_element.getElementsByClassName("haczyk_left_text")[0]; + element_right.className='haczyk_right'; const current_state = hook_info.state; if (classMap.hasOwnProperty(current_state)) { - button_element.classList.add(classMap[current_state]); + element_right.classList.add(classMap[current_state]); + let name = hook_info.place; + //replace first letter with upper case + name = name.charAt(0).toUpperCase() + name.slice(1); + button_text.textContent= name; } else { - button_element.classList.add("haczyk_key_error"); + element_right.classList.add("haczyk_key_error"); } }