✨
Your bucket list is empty
Add your first dream and start your journey together!
`;
printWindow.document.write(printHTML);
printWindow.document.close();
printWindow.focus();
// Wait for images to load before printing
setTimeout(() => {
printWindow.print();
}, 1000);
},importJSON(e) {
const file = e.target.files[0];
if (!file) return;const reader = new FileReader();
reader.onload = (event) => {
try {
const data = JSON.parse(event.target.result);
if (!data.bucketList || !Array.isArray(data.bucketList)) {
throw new Error('Invalid file format');
}if (confirm('This will replace your current bucket list. Are you sure?')) {
AppState.bucketList = data.bucketList;
Storage.save(AppState.bucketList);
BucketListManager.render();
BucketListManager.updateStats();
Utils.showNotification('Bucket list imported successfully!');
}
} catch (error) {
console.error('Import error:', error);
Utils.showNotification('Failed to import file. Please check the file format.', 'error');
}
};
reader.readAsText(file);
e.target.value = ''; // Reset file input
}
};// Initialize Application
function initApp() {
try {
BucketListManager.init();
FormManager.init();
ViewManager.init();
ExportImportManager.init();
// Check for storage quota warnings
if (navigator.storage && navigator.storage.estimate) {
navigator.storage.estimate().then(estimate => {
const usedPercentage = (estimate.usage / estimate.quota) * 100;
if (usedPercentage > 80) {
Utils.showNotification('Storage is getting full. Consider exporting your data.', 'warning');
}
});
}
console.log('Couple Bucket List App initialized successfully');
} catch (error) {
console.error('App initialization error:', error);
Utils.showNotification('Failed to initialize app. Please refresh the page.', 'error');
}
}// Start the application when DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initApp);
} else {
initApp();
}// Expose some functions for debugging (optional)
if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
window.CoupleBucketListApp = {
AppState,
BucketListManager,
Storage,
Utils
};
}
})();