diff --git a/app.py b/app.py index d675f5d..59bd97e 100644 --- a/app.py +++ b/app.py @@ -34,6 +34,7 @@ def index(): if request.method == 'POST': set_num = request.form.get('set_num') + index = request.form.get('index') minif = request.form.get('minif') scheck = request.form.get('scheck') scol = request.form.get('scol') @@ -41,12 +42,12 @@ def index(): with open('./info/'+set_num+'.json') as info: json_file = json.loads(info.read()) if minif != None: - json_file['Minifigs Collected'] = minif + json_file['unit'][int(index)]['Minifigs Collected'] = minif if scheck != None: - json_file['Set Checked'] = scheck + json_file['unit'][int(index)]['Set Checked'] = scheck if scol != None: - json_file['Set Collected'] = scol - + json_file['unit'][int(index)]['Set Collected'] = scol + with open('./info/'+set_num+'.json', 'w') as dump_file: json.dump(json_file,dump_file) return ('', 204) diff --git a/templates/frontpage.html b/templates/frontpage.html index 57bcf36..31037c2 100644 --- a/templates/frontpage.html +++ b/templates/frontpage.html @@ -33,15 +33,14 @@ body { .grid-container { display: grid; - grid-template-columns: repeat(auto-fit, minmax(20%, 32%)); /* Between 33% and 50% width */ + grid-template-columns: repeat(auto-fit, minmax(10%, 48%)); /* Between 33% and 50% width */ /* grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); */ gap: 10px; padding: 10px; } .grid-item { - height: 300px; - display: flex; + height:auto; } .card { @@ -49,7 +48,7 @@ body { border: 1px solid #ccc; padding: 10px; box-sizing: border-box; - padding-bottom:40px; /* Height of the footer */ + padding-bottom:30px; /* Height of the footer */ } /* Adjust height for smaller screens */ @@ -68,7 +67,6 @@ body { .grid-item img { max-width: 100%; - height: auto; display: block; } @@ -79,7 +77,7 @@ body { position:absolute; bottom:0; width:90%; - height:40px; /* Height of the footer */ + height:30px; /* Height of the footer */ } .button { @@ -107,6 +105,7 @@ body { + @@ -114,49 +113,50 @@ body {
+
-
-
+
- {% for i in set_list %} + {% for i in set_list %} + {% if json_file[i['set_num']]['count'] == 1 %} +
+
+ {% else %} +
+
+ {% endif %} -
-
-
-
- - {{ i['set_num'] }} {{ i['name'] }} - -
-
-
- Parts: - {{ i['num_parts'] }} +
+
+ + {{ i['set_num'] }} {{ i['name'] }} + +
+
+
+ Parts: + {{ i['num_parts'] }} +
-
-
-
-
- - Image - -
-

- {{ i['theme_id'] }} ({{ i['year'] }}) -

-
+
+
+
+ + Image + +
+
- {% for j in json_file[i['set_num']]['unit'] %} -
-

- {{ j }} -

-
+ {% for j in json_file[i['set_num']]['unit'] %} +
+

Set #{{ loop.index }}

+
- - +
+ +
+ +
+
-
- +
{% endfor %} - +
-
{% endfor %}
-
- + // Initialize visibility based on isHidden + updateVisibility(); + + toggleButton.addEventListener('click', function() { + // Toggle visibility and update grid items + isHidden = !isHidden; + updateVisibility(); + }); + + function updateVisibility() { + // Get all grid items + const gridItems = document.querySelectorAll('.grid-item'); + + // Iterate over each grid item + gridItems.forEach(function(item) { + // Check if the corresponding checkbox is checked + const checkbox = item.querySelector('.s_com'); + if (isHidden || (checkbox && checkbox.checked)) { + // Show the grid item if it's hidden or the checkbox is checked + item.style.display = 'block'; + } else { + // Hide the grid item if the checkbox is not checked + item.style.display = 'none'; + } + }); + } + }); + +