diff --git a/gst.js b/gst.js index 3b23197..7029e2e 100644 --- a/gst.js +++ b/gst.js @@ -25,7 +25,7 @@ function getRandomCpu() { let randomIndex; do { 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 { @@ -51,6 +51,10 @@ export async function btnClick(typ) { let btns = [btnDesktop, btnLaptop, btnMobile, btnServer]; + btns.forEach((el) => { + el.setAttribute("disabled", ""); + }) + switch (typ) { case 0: btnDesktop.style.backgroundColor = "#FF4444"; @@ -66,25 +70,24 @@ export async function btnClick(typ) { break; } - switch (currentCpu.type) { - case "Desktop": - btnDesktop.style.backgroundColor = "lightgreen"; - break; - case "Laptop": - btnLaptop.style.backgroundColor = "lightgreen"; - break; - case "Mobile/Embedded": - btnMobile.style.backgroundColor = "lightgreen"; - break; - case "Server": - btnServer.style.backgroundColor = "lightgreen"; - break; + if(currentCpu.type.includes("Desktop")) { + btnDesktop.style.backgroundColor = "lightgreen"; + } + if(currentCpu.type.includes("Laptop")) { + btnLaptop.style.backgroundColor = "lightgreen"; + } + if(currentCpu.type.includes("Mobile/Embedded")) { + btnMobile.style.backgroundColor = "lightgreen"; + } + if(currentCpu.type.includes("Server")) { + btnServer.style.backgroundColor = "lightgreen"; } await delay(2000); btns.forEach( (el) => { el.style.backgroundColor = "#3CC3FA"; + el.removeAttribute("disabled"); }) nextRound();