"use strict"; // Datensammlung für Produkte var Aufgabe06; (function (Aufgabe06) { let shoppingPrice = 0; let shoppingCount = 0; communicate("http://127.0.0.1:5500/Aufgaben/Aufgabe_07_2020-06-10/myJSON.json"); async function communicate(_url) { let response = await fetch(_url); let jsonObj = await response.json(); console.log("Response", response); printProducts(100, jsonObj); /*console.log(jsonObj); console.log(jsonObj[0].products[2].price); console.log(jsonObj[1].products[3].title);*/ document.querySelector("#special_a").addEventListener("click", drawSpecial); function drawSpecial() { printProducts(0, jsonObj); } document.querySelector("#bunt_a").addEventListener("click", drawBunt); function drawBunt() { printProducts(1, jsonObj); } document.querySelector("#grün_a").addEventListener("click", drawGrün); function drawGrün() { printProducts(2, jsonObj); } document.querySelector("#all_a").addEventListener("click", drawAll); function drawAll() { printProducts(100, jsonObj); } } Aufgabe06.communicate = communicate; //printProducts(100); //console.log(jsonObj[1].products[3].title); //create Structure; function printProducts(_catNumber, _jsonObj) { clearProducts(_jsonObj); let catCheck = false; if (_catNumber != 100) catCheck = true; else _catNumber = 0; for (let nummer = _catNumber; nummer < _jsonObj.length; nummer++) { let heading = document.createElement("h1"); heading.setAttribute("id", _jsonObj[nummer].id); heading.innerHTML = `${_jsonObj[nummer].title}`; document.querySelector("#übersicht").appendChild(heading); let container = document.createElement("div"); container.classList.add("container"); document.querySelector("#übersicht").appendChild(container); for (let index = 0; index < _jsonObj[nummer].products.length; index++) { let product = document.createElement("div"); product.classList.add("product"); product.innerHTML = `
Size: ${_jsonObj[nummer].products[index].size}
${_jsonObj[nummer].products[index].description}
Size: 4m²
tag class contentIf you can't choose one color, go and catch them all!
tag content