-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
54 lines (46 loc) · 1.88 KB
/
Copy pathscript.js
File metadata and controls
54 lines (46 loc) · 1.88 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// 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');
});
}
const workinprogresstext = "This is work in progress tool, and is not complete, check the status on the GH repo.";
/**
* Inizializza tutto quando il DOM è pronto
*/
document.addEventListener('DOMContentLoaded', function() {
initializeChecklist();
initializeWorkInProgress();
});
/**
* Inizializza il messaggio work in progress quando presente
* @param {Document|HTMLElement} root - contesto in cui cercare il messaggio
*/
function initializeWorkInProgress(root = document) {
const workinprogressElement = (root.getElementById ? root.getElementById('workinprogress') : null) || root.querySelector('#workinprogress');
if (workinprogressElement) {
workinprogressElement.innerText = workinprogresstext;
}
}
/**
* Espone le funzioni globalmente per poter essere chiamata dal spa-loader
* quando viene caricato nuovo contenuto dinamicamente
*/
window.initializeChecklist = initializeChecklist;
window.initializeWorkInProgress = initializeWorkInProgress;
function workinprogress() {
initializeWorkInProgress();
}