oda-framework
Version:
61 lines (54 loc) • 1.67 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>loader</title>
</head>
<style>
*{
font-size: 150%;
}
</style>
<body style="background-color: gray;">
<div style="height: 50%;" class="vertical">
<input id="input" type="number" value="1000">
<button id="btn">run</button>
<div style="height: 100px;"></div>
</div>
<script type="module">
import '../../../oda.js';
import { getLoader } from './loader.js';
if(window.top === window){
const frame = document.createElement('iframe');
frame.style.setProperty('height', '50%');
frame.src = './index.html';
document.body.appendChild(frame);
}
const loader = await getLoader();
btn.onclick = async () => {
if (btn.hasAttribute('disabled')) return;
setRun()
const count = Number(input.value);
const task = loader.addTask();
setTimeout(() => {
for (let i = 0; i < count; i++) {
for (let j = 0; j < count; j++) {
let x = i ** j;
}
}
loader.removeTask(task);
setStop()
}, 100);
}
function setRun(){
btn.setAttribute('disabled', '');
input.setAttribute('disabled', '');
}
function setStop(){
btn.removeAttribute('disabled');
input.removeAttribute('disabled');
}
</script>
</body>
</html>