Show Loading message/noscript
This commit is contained in:
parent
fd57189337
commit
0995fa63f0
1 changed files with 15 additions and 2 deletions
17
index.html
17
index.html
|
@ -52,8 +52,17 @@ body {
|
||||||
<h1>⛽<br>Fuel App</h1>
|
<h1>⛽<br>Fuel App</h1>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div id="app"></div>
|
<div id="app">
|
||||||
|
<noscript>JavaScript is required to use this calculator.</noscript>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
const el = document.getElementById('app');
|
||||||
|
if (el) {
|
||||||
|
const timer = setTimeout(function() { console.log('ran'); el.textContent = "Loading…" }, 500);
|
||||||
|
el.dataset.timer = timer;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import { reactive, html } from './arrow.min.mjs';
|
import { reactive, html } from './arrow.min.mjs';
|
||||||
|
|
||||||
|
@ -76,6 +85,10 @@ function updateValue(e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const app = document.getElementById('app');
|
||||||
|
clearTimeout(parseInt(app.dataset.timer, 10));
|
||||||
|
app.replaceChildren(); // Clear loading text
|
||||||
|
|
||||||
html`
|
html`
|
||||||
<form>
|
<form>
|
||||||
<label for="price">Price</label>
|
<label for="price">Price</label>
|
||||||
|
@ -94,7 +107,7 @@ html`
|
||||||
<p class="total">
|
<p class="total">
|
||||||
$${() => calculate().toFixed(2)}
|
$${() => calculate().toFixed(2)}
|
||||||
</p>
|
</p>
|
||||||
`(document.getElementById('app'))
|
`(app)
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue