-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
35 lines (30 loc) · 1.16 KB
/
script.js
File metadata and controls
35 lines (30 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Script principale per il sito
/**
* Inizializza le checkbox della checklist dinamicamente
* @param {Document|HTMLElement} root - contesto in cui cercare le checkbox
*/
function initializeChecklist(root = document) {
const completedCheckboxes = root.querySelectorAll('input[type="checkbox"].completed-checkbox');
const uncompletedCheckboxes = root.querySelectorAll('input[type="checkbox"].uncompleted-checkbox');
completedCheckboxes.forEach(checkbox => {
checkbox.checked = true;
checkbox.disabled = true;
checkbox.closest('.checklist-item')?.classList.add('completed');
});
uncompletedCheckboxes.forEach(checkbox => {
checkbox.checked = false;
checkbox.disabled = true;
checkbox.closest('.checklist-item')?.classList.remove('completed');
});
}
/**
* Inizializza tutto quando il DOM è pronto
*/
document.addEventListener('DOMContentLoaded', function() {
initializeChecklist();
});
/**
* Espone la funzione globalmente per poter essere chiamata dal spa-loader
* quando viene caricato nuovo contenuto dinamicamente
*/
window.initializeChecklist = initializeChecklist;