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

View File

@ -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);
@ -65,6 +65,4 @@ function getRandomInt(min, max) {
min = Math.ceil(min); min = Math.ceil(min);
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();