`;
container.appendChild(product);
}
if (catCheck)
break;
}
addShoppingFunction();
}
function clearProducts() {
for (let nummer = 0; nummer < jsonObj.length; nummer++) {
let alles = document.querySelector("#übersicht");
alles.innerHTML = "";
}
}
function money(_event) {
let target = _event.target;
//let price: number = parseFloat(target.getAttribute("productPrice")!);
let price = jsonObj[parseInt(target.getAttribute("categoryNumber"))].products[parseInt(target.getAttribute("productIndex"))].price;
console.log("Artikel-Preis: " + price + " ¥");
shoppingPrice += price;
console.log("Shopping-Cart-Preis: " + shoppingPrice + " ¥");
shoppingCount++;
document.querySelector("#shoppingCartNumber").innerHTML = shoppingCount.toLocaleString();
}
function addLocal(_event) {
if (localStorage.shoppingCount) {
localStorage.shoppingCount = Number(localStorage.shoppingCount) + 1;
}
else {
localStorage.shoppingCount = 1;
}
let target = _event.target;
let shoppingProduct = jsonObj[parseInt(target.getAttribute("categoryNumber"))].products[parseInt(target.getAttribute("productIndex"))];
localStorage.setItem(`${shoppingProduct.title}`, JSON.stringify(shoppingProduct));
}
function addShoppingFunction() {
const buttons = document.getElementsByClassName("addProduct");
for (const button of buttons) {
button.addEventListener("click", money);
button.addEventListener("click", addLocal);
}
}
})(Aufgabe07 || (Aufgabe07 = {}));
// Folgender auskommentierter Code dient mir als Archiv für Gedankenansätze oder Verläufe.
// Wenn dies nicht gerne gesehen ist, gebt mir kurz Bescheid und ich werde es entfernen
/*
function zeichnen(tagArray: Tag[]): void {
for (let i: number = 0; i < tagArray.length ; i++){
let title: HTMLElement = document.createElement(tagArray[i].tag);
title.innerHTML = "I bims title";
title.classList.add("title");
if (tagArray[i].image) {
title.setAttribute("src", "value");
title.setAttribute("alt", "value");
}
document.body.appendChild(title);
}
}
*/
/*
console.log("Hello Console");
let theName: String = "Justin" + "Dretvic" + 20;
console.log(theName);
*/
/*
# Template für ein Produkt in HTML
tag class
Color: Rainbow
tag class content
tag class
3279,99 ¥ tag class content
tag content
tag content
tag attribute1 attribute2
Size: 4m²
tag class content
tag class
If you can't choose one color, go and catch them all!