2024-07-30 08:52:03 +00:00
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
2024-07-30 12:09:38 +00:00
|
|
|
window.kanblendar = new Kanblendar();
|
2024-07-30 11:48:35 +00:00
|
|
|
const createTaskBtn = document.getElementById('createTaskBtn');
|
2024-07-30 12:09:38 +00:00
|
|
|
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!');
|
|
|
|
}
|
|
|
|
|
2024-07-30 13:13:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
function clearState() {
|
|
|
|
if (!confirm('Are you sure you want to clear the state?')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
localStorage.removeItem('kanblendarState');
|
|
|
|
console.log('State cleared!');
|
|
|
|
document.location.reload();
|
|
|
|
}
|