You are not recognized as the original poster of this topic.
// Event listener for the checkbox
document.getElementById('autoAddCheckbox').addEventListener('change', function() {
const isChecked = this.checked;
const inputTextArea = document.getElementById('inputText');
if (isChecked) {
// Listen for input events
inputTextArea.addEventListener('input', handleInput);
} else {
// Remove the input event listener
inputTextArea.removeEventListener('input', handleInput);
}
});
// Function to handle input events
function handleInput(event) {
// Get the input text area and its value
const inputTextArea = document.getElementById('inputText');
const inputText = inputTextArea.value.trim();
// Check if the input is not empty
if (inputText) {
// Retrieve existing items from localStorage
//let jsonArray = JSON.parse(localStorage.getItem('clipboardItems')) || [];
// Add the new input text to the array
jsonArray.push(inputText);
// Update localStorage with the new array
localStorage.setItem('clipboardItems', JSON.stringify(jsonArray));
// Clear the input
inputTextArea.value = '';
// Refresh the display to show the updated items
displayItems();
}
}