Fix module import in html file

This commit is contained in:
Marcel Schwarz 2023-04-12 12:51:10 +02:00
parent 54b316d7b2
commit 78fb7fafb8
2 changed files with 9 additions and 9 deletions

View File

@ -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>

View File

@ -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();
}