Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,11 @@ addItemsBtn.addEventListener('click', () => {
});
});

// Ensures the button is hidden on initial page load if the textarea is empty
if (pasteInput.value.trim() === "") {
clearBtn.style.display = 'none';
}

extractBtn.addEventListener('click', async () => {
const text = pasteInput.value;
if (!text.trim()) return;
Expand All @@ -1060,9 +1065,21 @@ extractBtn.addEventListener('click', async () => {
store.setExtracted(items);
});

// Wipes the text, clears the store, hides the button, and refocuses the cursor
clearBtn.addEventListener('click', () => {
pasteInput.value = '';
store.clearExtracted();
pasteInput.value = '';
store.clearExtracted();
clearBtn.style.display = 'none'; // Hides the clear button instantly
pasteInput.focus(); // Puts the typing cursor back in the box
});

// Listens to typing/pasting to show or hide the button dynamically
pasteInput.addEventListener('input', () => {
if (pasteInput.value.trim().length > 0) {
clearBtn.style.display = 'block';
} else {
clearBtn.style.display = 'none';
}
});

addItemsBtn.addEventListener('click', () => {
Expand Down