mirror of
https://github.com/cloudmaker97/DurstRechner.git
synced 2025-12-06 07:58:39 +00:00
Compare commits
No commits in common. "89f495c0fda113e237eea4edcd36024690d70bdd" and "c9796b8431e3b50fa104ec2a34f942730656d336" have entirely different histories.
89f495c0fd
...
c9796b8431
3 changed files with 8 additions and 55 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "Der Durstrechner",
|
"name": "Der Durstrechner",
|
||||||
"short_name": "Durstrechner",
|
"short_name": "Durstrechner",
|
||||||
"start_url": "/",
|
"start_url": "./",
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"background_color": "#ffffff",
|
"background_color": "#ffffff",
|
||||||
"theme_color": "#2196f3",
|
"theme_color": "#2196f3",
|
||||||
|
|
|
||||||
|
|
@ -57,14 +57,6 @@ class Element {
|
||||||
static getCartButton() {
|
static getCartButton() {
|
||||||
return document.querySelector('button.cart-value');
|
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) {
|
static imageResize(base64) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
|
|
@ -257,16 +244,6 @@ class ProductManager {
|
||||||
this.setExportFieldJsonValue();
|
this.setExportFieldJsonValue();
|
||||||
this.registerSettingsFormEvents();
|
this.registerSettingsFormEvents();
|
||||||
this.registerImportFormEvents();
|
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() {
|
registerCartResetEvent() {
|
||||||
Element.getCartButton().addEventListener('click', () => {
|
Element.getCartButton().addEventListener('click', () => {
|
||||||
CartHistoryManager.addToTotal(this.cartLines.reduce((acc, cartLine) => {
|
|
||||||
return acc + (cartLine.product.price * cartLine.quantity);
|
|
||||||
}, 0));
|
|
||||||
this.cartLines = [];
|
this.cartLines = [];
|
||||||
this.renderCart();
|
this.renderCart();
|
||||||
});
|
});
|
||||||
|
|
@ -521,12 +495,11 @@ class TabManager {
|
||||||
*/
|
*/
|
||||||
static toggleTab() {
|
static toggleTab() {
|
||||||
if(!TabManager.isSettingsTabActive) {
|
if(!TabManager.isSettingsTabActive) {
|
||||||
TabManager.isSettingsTabActive = true;
|
|
||||||
this.switchTab('settings');
|
this.switchTab('settings');
|
||||||
} else {
|
} else {
|
||||||
this.switchTab('products');
|
this.switchTab('products');
|
||||||
TabManager.isSettingsTabActive = false;
|
|
||||||
}
|
}
|
||||||
|
TabManager.isSettingsTabActive = !TabManager.isSettingsTabActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -534,9 +507,6 @@ class TabManager {
|
||||||
* @param tab {string} The tab to switch to
|
* @param tab {string} The tab to switch to
|
||||||
*/
|
*/
|
||||||
static switchTab(tab) {
|
static switchTab(tab) {
|
||||||
if(tab !== 'settings') {
|
|
||||||
TabManager.isSettingsTabActive = false;
|
|
||||||
}
|
|
||||||
const tabs = document.querySelectorAll('[data-tab]');
|
const tabs = document.querySelectorAll('[data-tab]');
|
||||||
tabs.forEach(e => {
|
tabs.forEach(e => {
|
||||||
e.classList.add('d-none');
|
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.
|
* Main function to initialize the application.
|
||||||
*/
|
*/
|
||||||
const cartManager = new CartManager();
|
const cartManager = new CartManager();
|
||||||
const productManager = new ProductManager();
|
const productManager = new ProductManager();
|
||||||
const tabManager = new TabManager();
|
const tabManager = new TabManager();
|
||||||
const themeManager = new ThemeManager();
|
const themeManager = new ThemeManager();
|
||||||
const cartHistoryManager = new CartHistoryManager();
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "durst-rechner",
|
"name": "durst-rechner",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"scripts": {},
|
"scripts": {
|
||||||
"keywords": ["calculator", "feuerwehr", "firefighter", "pos", "thirst"],
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
"author": "Dennis Heinrich",
|
"author": "Dennis Heinrich",
|
||||||
"license": "BSD-3-Clause",
|
"license": "proprietary",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bootstrap": "5.3.5",
|
"bootstrap": "5.3.5",
|
||||||
"bootstrap-icons": "^1.11.3"
|
"bootstrap-icons": "^1.11.3"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue