bug fix + add multiple correct anwsers

This commit is contained in:
Florian Schmid 2023-04-14 00:02:35 +02:00
parent 7d01dcda30
commit 8833deaace

31
gst.js
View File

@ -25,7 +25,7 @@ function getRandomCpu() {
let randomIndex; let randomIndex;
do { do {
randomIndex = getRandomInt(0, cpuList.length) randomIndex = getRandomInt(0, cpuList.length)
} while (typeof(cpuList[randomIndex]["type"]) == null) } while (typeof(cpuList[randomIndex]["type"]) == null || cpuList[randomIndex]["type"] == "null" || cpuList[randomIndex]["type"] == null);
return { return {
@ -51,6 +51,10 @@ export async function btnClick(typ) {
let btns = [btnDesktop, btnLaptop, btnMobile, btnServer]; let btns = [btnDesktop, btnLaptop, btnMobile, btnServer];
btns.forEach((el) => {
el.setAttribute("disabled", "");
})
switch (typ) { switch (typ) {
case 0: case 0:
btnDesktop.style.backgroundColor = "#FF4444"; btnDesktop.style.backgroundColor = "#FF4444";
@ -66,25 +70,24 @@ export async function btnClick(typ) {
break; break;
} }
switch (currentCpu.type) { if(currentCpu.type.includes("Desktop")) {
case "Desktop": btnDesktop.style.backgroundColor = "lightgreen";
btnDesktop.style.backgroundColor = "lightgreen"; }
break; if(currentCpu.type.includes("Laptop")) {
case "Laptop": btnLaptop.style.backgroundColor = "lightgreen";
btnLaptop.style.backgroundColor = "lightgreen"; }
break; if(currentCpu.type.includes("Mobile/Embedded")) {
case "Mobile/Embedded": btnMobile.style.backgroundColor = "lightgreen";
btnMobile.style.backgroundColor = "lightgreen"; }
break; if(currentCpu.type.includes("Server")) {
case "Server": btnServer.style.backgroundColor = "lightgreen";
btnServer.style.backgroundColor = "lightgreen";
break;
} }
await delay(2000); await delay(2000);
btns.forEach( (el) => { btns.forEach( (el) => {
el.style.backgroundColor = "#3CC3FA"; el.style.backgroundColor = "#3CC3FA";
el.removeAttribute("disabled");
}) })
nextRound(); nextRound();