Compare commits

..

No commits in common. "89f495c0fda113e237eea4edcd36024690d70bdd" and "c9796b8431e3b50fa104ec2a34f942730656d336" have entirely different histories.

3 changed files with 8 additions and 55 deletions

View file

@ -1,7 +1,7 @@
{
"name": "Der Durstrechner",
"short_name": "Durstrechner",
"start_url": "/",
"start_url": "./",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#2196f3",

View file

@ -57,14 +57,6 @@ class Element {
static getCartButton() {
return document.querySelector('button.cart-value');
}
/**
* Get the navbar brand element
* @returns {Element}
*/
static getNavbarBrand() {
return document.querySelector('nav a.navbar-brand');
}
}
/**
@ -208,11 +200,6 @@ class Base64Image {
});
}
/**
* Resize an image from a base64 string to a smaller size
* @param base64
* @returns {Promise<unknown>}
*/
static imageResize(base64) {
return new Promise((resolve, reject) => {
const img = new Image();
@ -257,16 +244,6 @@ class ProductManager {
this.setExportFieldJsonValue();
this.registerSettingsFormEvents();
this.registerImportFormEvents();
this.registerNavbarBrandToProductEvent();
}
/**
* Register the event for the navbar brand to switch to the products tab when clicked.
*/
registerNavbarBrandToProductEvent() {
Element.getNavbarBrand().addEventListener('click', () => {
TabManager.switchTab('products');
})
}
/**
@ -399,9 +376,6 @@ class CartManager {
*/
registerCartResetEvent() {
Element.getCartButton().addEventListener('click', () => {
CartHistoryManager.addToTotal(this.cartLines.reduce((acc, cartLine) => {
return acc + (cartLine.product.price * cartLine.quantity);
}, 0));
this.cartLines = [];
this.renderCart();
});
@ -521,12 +495,11 @@ class TabManager {
*/
static toggleTab() {
if(!TabManager.isSettingsTabActive) {
TabManager.isSettingsTabActive = true;
this.switchTab('settings');
} else {
this.switchTab('products');
TabManager.isSettingsTabActive = false;
}
TabManager.isSettingsTabActive = !TabManager.isSettingsTabActive;
}
/**
@ -534,9 +507,6 @@ class TabManager {
* @param tab {string} The tab to switch to
*/
static switchTab(tab) {
if(tab !== 'settings') {
TabManager.isSettingsTabActive = false;
}
const tabs = document.querySelectorAll('[data-tab]');
tabs.forEach(e => {
e.classList.add('d-none');
@ -577,29 +547,10 @@ class ThemeManager {
}
}
/**
* Define the CartHistoryManager class to manage the cart history.
*/
class CartHistoryManager {
static getTotal() {
return localStorage.getItem('cart-total-value') || 0;
}
static setTotal(value) {
localStorage.setItem('cart-total-value', value);
}
static addToTotal(value) {
const total = parseFloat(CartHistoryManager.getTotal()) + value;
CartHistoryManager.setTotal(total);
}
}
/**
* Main function to initialize the application.
*/
const cartManager = new CartManager();
const productManager = new ProductManager();
const tabManager = new TabManager();
const themeManager = new ThemeManager();
const cartHistoryManager = new CartHistoryManager();
const themeManager = new ThemeManager();

View file

@ -1,10 +1,12 @@
{
"name": "durst-rechner",
"version": "1.0.0",
"scripts": {},
"keywords": ["calculator", "feuerwehr", "firefighter", "pos", "thirst"],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "Dennis Heinrich",
"license": "BSD-3-Clause",
"license": "proprietary",
"dependencies": {
"bootstrap": "5.3.5",
"bootstrap-icons": "^1.11.3"