-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeyboard.js
56 lines (53 loc) · 1.73 KB
/
keyboard.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* Uses DOM and loads the products with Javascript instead of HTML
*/
fetch("./data.json")
.then(response => response.json())
.then(prod => loadProducts(prod));
function loadProducts(prod)
{
for (var i = 0; i < prod.products.length; i++)
{
let name = prod.products[i].name;
let url = prod.products[i].url;
let desc = prod.products[i].description;
let prodImg = document.querySelectorAll("img");
// let prodImg = document.createElement("div");
// prodImg.innerHTML = `<img src=${url} alt=${name}></img>`;
let prodTxt = document.createElement("p");
prodTxt.innerHTML = `<p class="card-text">${desc}</p>`;
switch(prod.products[i].productId)
{
case "10":
prodTxt10.appendChild(prodTxt);
prodImg[0].src = url;
prodImg[0].alt = name;
break;
case "11":
prodTxt11.appendChild(prodTxt);
prodImg[1].src = url;
prodImg[1].alt = name;
break;
case "12":
prodTxt12.appendChild(prodTxt);
prodImg[2].src = url;
prodImg[2].alt = name;
break;
case "13":
prodTxt13.appendChild(prodTxt);
prodImg[3].src = url;
prodImg[3].alt = name;
break;
case "14":
prodTxt14.appendChild(prodTxt);
prodImg[4].src = url;
prodImg[4].alt = name;
break;
case "15":
prodTxt15.appendChild(prodTxt);
prodImg[5].src = url;
prodImg[5].alt = name;
break;
}
}
}