add GST
This commit is contained in:
parent
53827029a4
commit
ec86800151
26
gst.html
26
gst.html
@ -11,6 +11,7 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<nav class="navbar navbar-expand-sm bg-light navbar-light">
|
<nav class="navbar navbar-expand-sm bg-light navbar-light">
|
||||||
<div class="container-fluid h4">
|
<div class="container-fluid h4">
|
||||||
@ -41,5 +42,30 @@
|
|||||||
<!-- <div class="footer">
|
<!-- <div class="footer">
|
||||||
<a href="https://www.flaticon.com/free-icons/processor" title="processor icons">Processor icons created by kerismaker - Flaticon</a>
|
<a href="https://www.flaticon.com/free-icons/processor" title="processor icons">Processor icons created by kerismaker - Flaticon</a>
|
||||||
</div> -->
|
</div> -->
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col text-center mb-3">
|
||||||
|
<span class="h2">Guess the socket-type of the CPU</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row align-items-center">
|
||||||
|
<div class="col-6 offset-3 border text-center p-2">
|
||||||
|
<span class="h2" id="cpuName"></span>
|
||||||
|
<button class="btn btn-lg bg-info m-1">Desktop</button>
|
||||||
|
<br>
|
||||||
|
<button class="btn btn-lg bg-info m-1">Laptop</button>
|
||||||
|
<br>
|
||||||
|
<button class="btn btn-lg bg-info m-1">Mobile/Embedded</button>
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="module">
|
||||||
|
import {main, btnClick} from "./game.js"
|
||||||
|
window.btnHigherClick = btnHigherClick
|
||||||
|
window.btnLowerClick = btnLowerClick
|
||||||
|
main()
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
31
gst.js
31
gst.js
@ -1,17 +1,34 @@
|
|||||||
var cpuList;
|
var cpuList;
|
||||||
async function main() {
|
var currentCpu;
|
||||||
await fetch('./data.json')
|
|
||||||
.then((response) => response.json())
|
|
||||||
.then((json) => cpuList = json);
|
|
||||||
|
|
||||||
console.log(getRandomCpu().name)
|
var score;
|
||||||
|
var highScore;
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
// init cpu list
|
||||||
|
await (fetch('./data.json')
|
||||||
|
.then((response) => response.json())
|
||||||
|
.then((json) => cpuList = json));
|
||||||
|
|
||||||
|
nextRound();
|
||||||
|
}
|
||||||
|
|
||||||
|
function nextRound() {
|
||||||
|
currentCpu = getRandomCpu();
|
||||||
|
|
||||||
|
document.getElementById("cpuName").innerText = currentCpu.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRandomCpu() {
|
function getRandomCpu() {
|
||||||
let randomIndex = getRandomInt(0, cpuList.length)
|
let randomIndex;
|
||||||
|
do {
|
||||||
|
randomIndex = getRandomInt(0, cpuList.length)
|
||||||
|
} while (typeof(cpuList[randomIndex]["type"]) == null)
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: cpuList[randomIndex]["name"].split('@')[0],
|
name: cpuList[randomIndex]["name"].split('@')[0],
|
||||||
score: cpuList[randomIndex]["cpuScore"]
|
type: cpuList[randomIndex]["type"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user