diff --git a/inventory/routes/index.py b/inventory/routes/index.py index b53b842..4e77693 100644 --- a/inventory/routes/index.py +++ b/inventory/routes/index.py @@ -1,5 +1,6 @@ from flask import render_template import pandas as pd +import random from . import main from .helpers import worklog_headers @@ -7,6 +8,11 @@ from .. import db from ..models import WorkLog, Inventory from ..utils.load import eager_load_worklog_relationships, eager_load_inventory_relationships +@main.route("/12648243") +def coffee(): + matrix = [[random.choice([True, False]) for _ in range(24)] for _ in range(24)] + return render_template("coffee.html", matrix=matrix) + @main.route("/") def index(): worklog_query = eager_load_worklog_relationships( diff --git a/inventory/templates/coffee.html b/inventory/templates/coffee.html new file mode 100644 index 0000000..574e124 --- /dev/null +++ b/inventory/templates/coffee.html @@ -0,0 +1,36 @@ +{% extends 'layout.html' %} + +{% block content %} +
+ {% for x in range(24) %} +
+ {% for y in range(24) %} +
+
+ +
+
+ {% endfor %} +
+ {% endfor %} +
+{% endblock %} + +{% block script %} + document.querySelectorAll('.form-check-input').forEach(checkbox => { + checkbox.addEventListener('change', function() { + const [x, y] = this.id.split('-').slice(1).map(Number); + const neighbors = [ + [x - 1, y], [x + 1, y], [x, y - 1], [x, y + 1], + [x - 1, y - 1], [x - 1, y + 1], [x + 1, y - 1], [x + 1, y + 1] + ]; + + neighbors.forEach(([nx, ny]) => { + if (nx < 0 || nx >= 24 || ny < 0 || ny >= 24) return; // Skip out of bounds + + const neighborCheckbox = document.querySelector(`#checkbox-${nx}-${ny}`); + neighborCheckbox.checked = !neighborCheckbox.checked; + }); + }); + }); +{% endblock %} \ No newline at end of file diff --git a/inventory/templates/layout.html b/inventory/templates/layout.html index 3bdf254..0505223 100644 --- a/inventory/templates/layout.html +++ b/inventory/templates/layout.html @@ -76,11 +76,11 @@ crossorigin="anonymous"> + -