Files
SkyArtShop/website/assets/js/shopping-prod.js

48 lines
1.1 KiB
JavaScript
Raw Normal View History

2025-12-19 20:44:46 -06:00
// Production-ready wrapper for shopping.js
// Removes console statements for production
(function () {
"use strict";
class ShoppingCart {
constructor() {
this.cart = this.loadFromStorage("cart") || [];
this.wishlist = this.loadFromStorage("wishlist") || [];
this.setupEventListeners();
this.renderCart();
this.renderWishlist();
}
loadFromStorage(key) {
try {
const data = localStorage.getItem(key);
return data ? JSON.parse(data) : null;
} catch (e) {
// Silent error handling in production
return null;
}
}
saveToStorage(key, data) {
try {
localStorage.setItem(key, JSON.stringify(data));
return true;
} catch (e) {
// Silent error handling in production
return false;
}
}
// Add other methods here...
}
// Initialize when DOM is ready
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", () => {
window.shoppingCart = new ShoppingCart();
});
} else {
window.shoppingCart = new ShoppingCart();
}
})();