diff --git a/templates/index.html b/templates/index.html index 28f9fe2..18efaf2 100644 --- a/templates/index.html +++ b/templates/index.html @@ -14,6 +14,47 @@ background-size: 20px 20px; font-family: 'Google Sans', sans-serif; } + + .grid-cell { + border: 2px solid #e5e7eb; /* Tailwind gray-200 */ + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + border-radius: 0.5rem; /* Rounded corners */ + transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease; /* Smooth transition */ + padding-top: 25%; /* More compact rectangular shape */ + position: relative; + overflow: hidden; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); /* Subtle shadow for modern look */ + } + + .grid-cell span { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-weight: 500; /* Semi-bold text */ + } + + .grid-cell.selected { + background-color: #1f2937; /* Tailwind gray-800 */ + color: white; + border-color: #1f2937; /* Match border color with background */ + } + + .grid-cell:hover { + background-color: #9ca3af; /* Tailwind gray-400 for hover effect */ + color: white; + border-color: #9ca3af; /* Match border color with hover effect */ + } + + .grid-container { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); + gap: 8px; /* Adjust gap between cells */ + margin-top: 1rem; + } @@ -59,8 +100,8 @@
- +
+
@@ -87,8 +128,8 @@
- +
+
@@ -138,6 +179,8 @@ if (element.tagName === 'IMG') element.src = ''; } }); + + updateGrid(service); } function initializeForm() { @@ -181,11 +224,49 @@ } } + function updateGrid(service) { + const gridSize = parseInt(document.getElementById('grid_size_' + service).value); + const gridContainer = document.getElementById('gridContainer_' + service); + gridContainer.innerHTML = ''; + gridContainer.style.gridTemplateColumns = `repeat(${gridSize}, minmax(0, 1fr))`; + const wantedCellsInput = document.getElementById('wanted_cells_' + service); + const selectedCells = wantedCellsInput.value ? wantedCellsInput.value.split(',').map(Number) : []; + + for (let i = 0; i < gridSize * gridSize; i++) { + const cell = document.createElement('div'); + cell.classList.add('grid-cell'); + + const cellSpan = document.createElement('span'); + cellSpan.textContent = i + 1; + cell.appendChild(cellSpan); + + if (selectedCells.includes(i + 1)) cell.classList.add('selected'); + cell.addEventListener('click', () => { + cell.classList.toggle('selected'); + updateWantedCells(service); + }); + gridContainer.appendChild(cell); + } + } + + function updateWantedCells(service) { + const gridContainer = document.getElementById('gridContainer_' + service); + const selectedCells = []; + gridContainer.querySelectorAll('.grid-cell.selected').forEach(cell => { + selectedCells.push(cell.textContent); + }); + document.getElementById('wanted_cells_' + service).value = selectedCells.join(','); + } + $(document).ready(function () { initializeForm(); toggleLogo(); window.matchMedia("(prefers-color-scheme: dark)").addEventListener('change', toggleLogo); + $('#grid_size_alpr, #grid_size_alpr_grid_debug').on('input', function () { + updateGrid(document.getElementById('service').value); + }); + $('#serviceForm').on('submit', function (e) { e.preventDefault(); const service = $('#service').val();