Skip to content

Commit 6af6e0b

Browse files
authored
Merge pull request #129 from DenisValeev/codex/add-clear-button-to-recall-app
Replace Total Recall defaults with clear action
2 parents 9cf65c7 + 0d2c8e8 commit 6af6e0b

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

apps/total-recall/app.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
const nextButton = document.querySelector('[data-next]');
77
const shuffleButton = document.querySelector('[data-shuffle]');
88
const saveButton = document.querySelector('[data-save]');
9-
const resetButton = document.querySelector('[data-reset]');
9+
const clearButton = document.querySelector('[data-clear]');
1010
const statusEl = document.querySelector('[data-status]');
1111

1212
if (
@@ -17,7 +17,7 @@
1717
!nextButton ||
1818
!shuffleButton ||
1919
!saveButton ||
20-
!resetButton ||
20+
!clearButton ||
2121
!statusEl
2222
) {
2323
return;
@@ -163,17 +163,22 @@
163163
}
164164
}
165165

166-
function handleReset() {
167-
notesInput.value = DEFAULT_NOTES;
168-
handleSave();
169-
setStatus('Restored the default joke deck.');
166+
function handleClear() {
167+
notesInput.value = '';
168+
try {
169+
localStorage.setItem(STORAGE_KEY, '');
170+
} catch (error) {
171+
console.error('Failed to clear notes in localStorage', error); // eslint-disable-line no-console
172+
}
173+
updateEntriesFrom('');
174+
setStatus('Cleared notes. Add new entries to continue.');
170175
}
171176

172177
prevButton.addEventListener('click', showPrev);
173178
nextButton.addEventListener('click', showNext);
174179
shuffleButton.addEventListener('click', reshuffleDeck);
175180
saveButton.addEventListener('click', handleSave);
176-
resetButton.addEventListener('click', handleReset);
181+
clearButton.addEventListener('click', handleClear);
177182

178183
document.addEventListener('keydown', (event) => {
179184
if (event.defaultPrevented) {

apps/total-recall/index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,6 @@
367367
</nav>
368368
<header class="app-header">
369369
<h1>Total Recall</h1>
370-
<p>Drop your raw notes here, split by blank lines, and train yourself with randomized memory cards.</p>
371370
</header>
372371
<article class="card" aria-live="polite">
373372
<div class="card__meta">
@@ -399,8 +398,8 @@ <h1>Total Recall</h1>
399398
<button class="control-button control-button--primary" type="button" data-save>
400399
Save notes
401400
</button>
402-
<button class="control-button control-button--secondary" type="button" data-reset>
403-
Restore defaults
401+
<button class="control-button control-button--secondary" type="button" data-clear>
402+
Clear notes
404403
</button>
405404
</div>
406405
<p class="editor__status" aria-live="polite" data-status></p>

0 commit comments

Comments
 (0)