|
17 | 17 | const toggleBtn = document.querySelector('#toggle'); |
18 | 18 | const globalStatus = document.querySelector('#global-status'); |
19 | 19 | const globalControls = document.querySelector('.global-controls'); |
| 20 | + const scheduleNotice = document.querySelector('#schedule-notice'); |
20 | 21 | const siteControls = document.querySelector('#site-controls'); |
21 | 22 | const siteHostLabel = document.querySelector('#site-host'); |
22 | 23 | const siteStatus = document.querySelector('#site-status'); |
|
121 | 122 | } |
122 | 123 | } |
123 | 124 |
|
| 125 | + function setScheduleLock(enabled) { |
| 126 | + const isLocked = Boolean(enabled); |
| 127 | + const ariaValue = String(isLocked); |
| 128 | + const noticeId = scheduleNotice && scheduleNotice.id ? scheduleNotice.id : null; |
| 129 | + |
| 130 | + if (slider) { |
| 131 | + slider.disabled = isLocked; |
| 132 | + slider.setAttribute('aria-disabled', ariaValue); |
| 133 | + if (isLocked && noticeId) { |
| 134 | + slider.setAttribute('aria-describedby', noticeId); |
| 135 | + } else { |
| 136 | + slider.removeAttribute('aria-describedby'); |
| 137 | + } |
| 138 | + } |
| 139 | + |
| 140 | + if (toggleBtn) { |
| 141 | + toggleBtn.disabled = isLocked; |
| 142 | + toggleBtn.setAttribute('aria-disabled', ariaValue); |
| 143 | + if (isLocked && noticeId) { |
| 144 | + toggleBtn.setAttribute('aria-describedby', noticeId); |
| 145 | + } else { |
| 146 | + toggleBtn.removeAttribute('aria-describedby'); |
| 147 | + } |
| 148 | + } |
| 149 | + |
| 150 | + if (globalControls) { |
| 151 | + globalControls.classList.toggle('schedule-locked', isLocked); |
| 152 | + } |
| 153 | + |
| 154 | + if (scheduleNotice) { |
| 155 | + if (isLocked) { |
| 156 | + scheduleNotice.hidden = false; |
| 157 | + scheduleNotice.textContent = getMessage('popupScheduleLockNotice'); |
| 158 | + } else { |
| 159 | + scheduleNotice.hidden = true; |
| 160 | + scheduleNotice.textContent = ''; |
| 161 | + } |
| 162 | + } |
| 163 | + } |
| 164 | + |
124 | 165 | function updateManageSummary(levels) { |
125 | 166 | if (!manageBtn) return; |
126 | 167 | const entries = levels && typeof levels === 'object' |
|
321 | 362 | updateGlobal, |
322 | 363 | renderSite, |
323 | 364 | setSiteToggleDisabled, |
| 365 | + setScheduleLock, |
324 | 366 | updateManageSummary, |
325 | 367 | renderManager, |
326 | 368 | setManagerVisible, |
|
0 commit comments