fix: clear status after successful clipboard and constant actions
This commit is contained in:
@@ -110,6 +110,15 @@ function setStatus(message, isError = false, timeoutMs = 1400) {
|
|||||||
}, timeoutMs);
|
}, timeoutMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearStatus() {
|
||||||
|
clearTimeout(statusTimer);
|
||||||
|
statusTimer = null;
|
||||||
|
if (!statusLine) return;
|
||||||
|
statusLine.textContent = '';
|
||||||
|
statusLine.classList.remove('is-visible');
|
||||||
|
statusLine.classList.remove('is-error');
|
||||||
|
}
|
||||||
|
|
||||||
function normalizeStack() {
|
function normalizeStack() {
|
||||||
while (calc.stack.length > 4) {
|
while (calc.stack.length > 4) {
|
||||||
calc.stack.shift();
|
calc.stack.shift();
|
||||||
@@ -280,7 +289,7 @@ async function copyStackValue(label) {
|
|||||||
if (!value) return;
|
if (!value) return;
|
||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(value);
|
await navigator.clipboard.writeText(value);
|
||||||
setStatus(`Copied ${label}`);
|
clearStatus();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setStatus('Copy unavailable', true);
|
setStatus('Copy unavailable', true);
|
||||||
}
|
}
|
||||||
@@ -381,6 +390,7 @@ pasteButton.addEventListener('click', async () => {
|
|||||||
try {
|
try {
|
||||||
const text = await navigator.clipboard.readText();
|
const text = await navigator.clipboard.readText();
|
||||||
pasteTextIntoStack(text);
|
pasteTextIntoStack(text);
|
||||||
|
clearStatus();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setStatus('Paste unavailable', true);
|
setStatus('Paste unavailable', true);
|
||||||
}
|
}
|
||||||
@@ -427,7 +437,7 @@ function openConstMenu() {
|
|||||||
pushEditingValueIfNeeded();
|
pushEditingValueIfNeeded();
|
||||||
calc.push(constant.value);
|
calc.push(constant.value);
|
||||||
render();
|
render();
|
||||||
setStatus(`Inserted ${constant.label}`);
|
clearStatus();
|
||||||
closeConstMenu();
|
closeConstMenu();
|
||||||
focusInput();
|
focusInput();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user