()
| 210 | |
| 211 | // Function to update the fetch button's state and countdown |
| 212 | function updateFetchButtonState() { |
| 213 | const nextAllowTime = parseInt(localStorage.getItem(CHICKEN_LEG_NEXT_ALLOW_KEY) || '0'); |
| 214 | const now = Date.now(); |
| 215 | |
| 216 | if (now < nextAllowTime) { |
| 217 | fetchRangeBtn.disabled = true; |
| 218 | let remainingSeconds = Math.ceil((nextAllowTime - now) / 1000); |
| 219 | fetchRangeStatus.textContent = `请等待 ${remainingSeconds} 秒后再次拉取`; |
| 220 | // Set a timeout to update the countdown |
| 221 | if (chickenLegTimeoutId) clearTimeout(chickenLegTimeoutId); // Clear previous timeout |
| 222 | chickenLegTimeoutId = setTimeout(updateFetchButtonState, 1000); // Update every second |
| 223 | } else { |
| 224 | fetchRangeBtn.disabled = false; |
| 225 | fetchRangeStatus.textContent = ''; |
| 226 | if (chickenLegTimeoutId) { |
| 227 | clearTimeout(chickenLegTimeoutId); |
| 228 | chickenLegTimeoutId = null; |
| 229 | } |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | // Initial update when the dialog opens |
| 234 | updateFetchButtonState(); |
no outgoing calls
no test coverage detected