diff --git a/samples/calc-02/index.js b/samples/calc-02/index.js index 3c0e082..d5fb2d3 100644 --- a/samples/calc-02/index.js +++ b/samples/calc-02/index.js @@ -110,6 +110,15 @@ function setStatus(message, isError = false, timeoutMs = 1400) { }, timeoutMs); } +function clearStatus() { + clearTimeout(statusTimer); + statusTimer = null; + if (!statusLine) return; + statusLine.textContent = ''; + statusLine.classList.remove('is-visible'); + statusLine.classList.remove('is-error'); +} + function normalizeStack() { while (calc.stack.length > 4) { calc.stack.shift(); @@ -280,7 +289,7 @@ async function copyStackValue(label) { if (!value) return; try { await navigator.clipboard.writeText(value); - setStatus(`Copied ${label}`); + clearStatus(); } catch (error) { setStatus('Copy unavailable', true); } @@ -381,6 +390,7 @@ pasteButton.addEventListener('click', async () => { try { const text = await navigator.clipboard.readText(); pasteTextIntoStack(text); + clearStatus(); } catch (error) { setStatus('Paste unavailable', true); } @@ -427,7 +437,7 @@ function openConstMenu() { pushEditingValueIfNeeded(); calc.push(constant.value); render(); - setStatus(`Inserted ${constant.label}`); + clearStatus(); closeConstMenu(); focusInput(); });