| 522 | // ─── DNS Speed Test Logic ──────────────────────────────────────────────────── |
| 523 | |
| 524 | function setButtonState(state) { |
| 525 | const spinnerSVG = '<svg class="w-4 h-4 btn-spin" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"/><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"/></svg>'; |
| 526 | const playSVG = '<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M8 5v14l11-7z"/></svg>'; |
| 527 | |
| 528 | if (state === 'warmup') { |
| 529 | btnIcon.innerHTML = spinnerSVG; |
| 530 | btnText.textContent = 'Warming up...'; |
| 531 | checkButton.disabled = true; |
| 532 | } else if (state === 'testing') { |
| 533 | btnIcon.innerHTML = spinnerSVG; |
| 534 | // btnText updated per-server in performDNSTests |
| 535 | } else if (state === 'done') { |
| 536 | btnIcon.innerHTML = playSVG; |
| 537 | btnText.textContent = 'Run Again'; |
| 538 | checkButton.disabled = false; |
| 539 | } else { |
| 540 | btnIcon.innerHTML = playSVG; |
| 541 | btnText.textContent = 'Run Speed Test'; |
| 542 | checkButton.disabled = false; |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | checkButton.addEventListener('click', async function () { |
| 547 | if (testRunning) return; |