From b396f633428cf3b9fb7cb103982127f4e24524c6 Mon Sep 17 00:00:00 2001 From: Yaro Kasear Date: Fri, 8 Aug 2025 09:06:17 -0500 Subject: [PATCH] Update graphics on easter egg. --- inventory/templates/coffee.html | 36 +++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/inventory/templates/coffee.html b/inventory/templates/coffee.html index f3b5ab2..f02c178 100644 --- a/inventory/templates/coffee.html +++ b/inventory/templates/coffee.html @@ -1,19 +1,19 @@ {% extends 'layout.html' %} {% block style %} -.clicked { - outline: 2px solid red; +.light { + transition: background-color .25s; } {% endblock %} {% block content %}
{% for x in range(level + 3) %} -
+
{% for y in range(level + 3) %} -
+
- +
{% endfor %} @@ -25,9 +25,33 @@ {% block script %} const gridSize = {{ level + 3 }}; + updateLights(); + + function updateLights() { + document.querySelectorAll('.light').forEach(light => { + const [x, y] = light.id.split('-').slice(1).map(Number); + const checkbox = document.querySelector(`#checkbox-${x}-${y}`); + + if(checkbox.checked) { + light.classList.add('bg-danger-subtle'); + } else { + light.classList.remove('bg-danger-subtle'); + } + }); + } + + document.querySelectorAll('.light').forEach(light => { + light.addEventListener('click', function() { + const [x, y] = this.id.split('-').slice(1).map(Number); + const checkbox = document.querySelector(`#checkbox-${x}-${y}`); + + checkbox.click(); + updateLights(); + }); + }); + document.querySelectorAll('.form-check-input').forEach(checkbox => { checkbox.addEventListener('change', function() { - checkbox.classList.toggle('clicked'); const [x, y] = this.id.split('-').slice(1).map(Number); const neighbors = [ [x - 1, y],