| Conditions | 3 |
| Total Lines | 32 |
| Code Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { toggleBox } from '../core/state'; |
||
| 5 | |||
| 6 | export function createGrid(): void { |
||
| 7 | elements.grid.innerHTML = ''; |
||
| 8 | |||
| 9 | for (let i = 0; i < 12; i++) { |
||
| 10 | const box = document.createElement('button'); |
||
| 11 | box.className = 'box'; |
||
| 12 | box.dataset.index = i.toString(); |
||
| 13 | box.type = 'button'; |
||
| 14 | |||
| 15 | const bitValue = Math.pow(2, 11 - i); |
||
| 16 | box.setAttribute('aria-pressed', 'false'); |
||
| 17 | box.setAttribute('aria-label', `Bit ${i + 1}, value ${bitValue}`); |
||
| 18 | |||
| 19 | const label = document.createElement('span'); |
||
| 20 | label.className = 'bit-label'; |
||
| 21 | label.textContent = bitValue.toString(); |
||
| 22 | label.setAttribute('aria-hidden', 'true'); |
||
| 23 | box.appendChild(label); |
||
| 24 | |||
| 25 | box.addEventListener('click', () => { |
||
| 26 | if (box.dataset.isDisabled === 'true') { |
||
| 27 | showDisabledBoxToast(); |
||
| 28 | return; |
||
| 29 | } |
||
| 30 | toggleBox(i); |
||
| 31 | updateDisplay(); |
||
| 32 | }); |
||
| 33 | |||
| 34 | elements.grid.appendChild(box); |
||
| 35 | } |
||
| 36 | |||
| 37 | updateDisplay(); |
||
| 39 |