Kumi
a3e50477b0
Introduced a "Delete all entries" link in the footer that clears local storage state upon confirmation from the user. Modified CSS to properly align new footer elements. This improvement enhances user control over stored data, ensuring an easy way to reset the application state.
30 lines
No EOL
938 B
JavaScript
30 lines
No EOL
938 B
JavaScript
document.addEventListener('DOMContentLoaded', () => {
|
|
window.kanblendar = new Kanblendar();
|
|
const createTaskBtn = document.getElementById('createTaskBtn');
|
|
createTaskBtn.addEventListener('click', () => window.kanblendar.openModal());
|
|
|
|
function saveState() {
|
|
const serializedState = kanblendar.serialize();
|
|
localStorage.setItem('kanblendarState', serializedState);
|
|
console.log('State saved!');
|
|
}
|
|
|
|
document.addEventListener('taskChanged', saveState);
|
|
|
|
const serializedState = localStorage.getItem('kanblendarState');
|
|
if (serializedState) {
|
|
kanblendar.deserialize(serializedState);
|
|
console.log('State loaded on page load!');
|
|
}
|
|
|
|
});
|
|
|
|
function clearState() {
|
|
if (!confirm('Are you sure you want to clear the state?')) {
|
|
return;
|
|
}
|
|
|
|
localStorage.removeItem('kanblendarState');
|
|
console.log('State cleared!');
|
|
document.location.reload();
|
|
} |