Add reset confirmation

This commit is contained in:
dwrz
2026-05-28 01:00:12 +00:00
parent 9ea4005e96
commit 07377abff6
2 changed files with 45 additions and 2 deletions

View File

@@ -446,6 +446,20 @@ body {
border-color: var(--color-red); border-color: var(--color-red);
} }
.footer__toolbar-btn--pending {
background: var(--color-yellow);
color: var(--color-black);
border-color: var(--color-yellow);
}
@media (hover: hover) {
.footer__toolbar-btn--pending:hover {
background: var(--color-yellow);
color: var(--color-black);
border-color: var(--color-yellow);
}
}
@media (hover: hover) { @media (hover: hover) {
.footer__toolbar-btn--muted:hover { .footer__toolbar-btn--muted:hover {
color: var(--color-red); color: var(--color-red);

View File

@@ -28,6 +28,7 @@ class Odidere {
this.isProcessing = false; this.isProcessing = false;
this.isRecording = false; this.isRecording = false;
this.isMuted = false; this.isMuted = false;
this.isResetPending = false;
this.mediaRecorder = null; this.mediaRecorder = null;
// DOM Elements // DOM Elements
@@ -143,8 +144,9 @@ class Odidere {
// Send button // Send button
this.$send.addEventListener('click', () => this.#submitText()); this.$send.addEventListener('click', () => this.#submitText());
// Reset button // Reset button: two-press safety
this.$reset.addEventListener('click', () => this.reset()); this.$reset.addEventListener('click', () => this.#handleResetClick());
this.document.addEventListener('click', (e) => this.#handleResetCancel(e));
// File attachment // File attachment
this.$attach.addEventListener('click', () => this.$fileInput.click()); this.$attach.addEventListener('click', () => this.$fileInput.click());
@@ -327,6 +329,33 @@ class Odidere {
this.$fileInput.value = ''; this.$fileInput.value = '';
} }
/**
* #handleResetClick toggles the pending state on first press,
* executes the reset on second press.
*/
#handleResetClick() {
if (this.isResetPending) {
this.isResetPending = false;
this.$reset.classList.remove('footer__toolbar-btn--pending');
this.reset();
} else {
this.isResetPending = true;
this.$reset.classList.add('footer__toolbar-btn--pending');
}
}
/**
* #handleResetCancel clears the pending reset state when the user
* clicks anywhere outside the reset button.
* @param {MouseEvent} event
*/
#handleResetCancel(event) {
if (!this.isResetPending) return;
if (this.$reset.contains(event.target)) return;
this.isResetPending = false;
this.$reset.classList.remove('footer__toolbar-btn--pending');
}
// ==================== // ====================
// AUDIO RECORDING // AUDIO RECORDING
// ==================== // ====================