Fix module import in html file
This commit is contained in:
parent
54b316d7b2
commit
78fb7fafb8
12
game.html
12
game.html
@ -51,9 +51,9 @@
|
|||||||
<span class="h3">cpu score:</span>
|
<span class="h3">cpu score:</span>
|
||||||
<span class="h3 counter-count" id="nextCpuScore">?</span>
|
<span class="h3 counter-count" id="nextCpuScore">?</span>
|
||||||
<br>
|
<br>
|
||||||
<button class="btn btn-lg bg-info m-3" id="btnHigher">Higher</button>
|
<button class="btn btn-lg bg-info m-3" onclick="btnHigherClick()" id="btnHigher">Higher</button>
|
||||||
<br>
|
<br>
|
||||||
<button class="btn btn-lg bg-info mb-3" id="btnLower">Lower</button>
|
<button class="btn btn-lg bg-info mb-3" onclick="btnLowerClick()" id="btnLower">Lower</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -62,10 +62,12 @@
|
|||||||
<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> -->
|
||||||
|
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import {btnHigherClick, btnLowerClick} from "./game.js"
|
import {main, btnHigherClick, btnLowerClick} from "./game.js"
|
||||||
document.getElementById("btnHigher").onclick = btnHigherClick
|
window.btnHigherClick = btnHigherClick
|
||||||
document.getElementById("btnLower").onclick = btnLowerClick
|
window.btnLowerClick = btnLowerClick
|
||||||
|
main()
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
4
game.js
4
game.js
@ -4,7 +4,7 @@ var cpuList;
|
|||||||
var currentCpu;
|
var currentCpu;
|
||||||
var nextCpu;
|
var nextCpu;
|
||||||
|
|
||||||
async function main() {
|
export async function main() {
|
||||||
await fetch('./data.json')
|
await fetch('./data.json')
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((json) => cpuList = json);
|
.then((json) => cpuList = json);
|
||||||
@ -66,5 +66,3 @@ function getRandomInt(min, max) {
|
|||||||
max = Math.floor(max);
|
max = Math.floor(max);
|
||||||
return Math.floor(Math.random() * (max - min) + min); // The maximum is exclusive and the minimum is inclusive
|
return Math.floor(Math.random() * (max - min) + min); // The maximum is exclusive and the minimum is inclusive
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
|
Loading…
Reference in New Issue
Block a user