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 counter-count" id="nextCpuScore">?</span>
|
||||
<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>
|
||||
<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>
|
||||
@ -62,10 +62,12 @@
|
||||
<a href="https://www.flaticon.com/free-icons/processor" title="processor icons">Processor icons created by kerismaker - Flaticon</a>
|
||||
</div> -->
|
||||
|
||||
|
||||
<script type="module">
|
||||
import {btnHigherClick, btnLowerClick} from "./game.js"
|
||||
document.getElementById("btnHigher").onclick = btnHigherClick
|
||||
document.getElementById("btnLower").onclick = btnLowerClick
|
||||
import {main, btnHigherClick, btnLowerClick} from "./game.js"
|
||||
window.btnHigherClick = btnHigherClick
|
||||
window.btnLowerClick = btnLowerClick
|
||||
main()
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
6
game.js
6
game.js
@ -4,7 +4,7 @@ var cpuList;
|
||||
var currentCpu;
|
||||
var nextCpu;
|
||||
|
||||
async function main() {
|
||||
export async function main() {
|
||||
await fetch('./data.json')
|
||||
.then((response) => response.json())
|
||||
.then((json) => cpuList = json);
|
||||
@ -65,6 +65,4 @@ function getRandomInt(min, max) {
|
||||
min = Math.ceil(min);
|
||||
max = Math.floor(max);
|
||||
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