admin: show loading progress
Massimo Melina committed
Feb 19, 2025 at 19:00 UTC
688374597d4f3a87c9a067739fc5e3c70074ec48
1 file changed
+13
-1
admin/index.html
+13
-1
@@ -11,7 +11,19 @@
11
</head>
12
<body>
13
<style class="removeAtBoot">@media (prefers-color-scheme: dark) { html { background-color: #000; color: #888; } }</style>
14
- <div id="root"></div>
14
+ <div id="root">Loading... <span id="loadingPerc"/></div>
15
<script nomodule>document.getElementById('root').innerText = "Please use a newer browser"</script>
16
+ <script>
17
+ (function(){ // legacy way to not pollute global scope
18
+ const total = 2600*1000 // no need to be precise, but stay on the abundant side
19
+ const t = setInterval(function() {
20
+ const e = document.getElementById('loadingPerc')
21
+ if (!e) // when load is complete the element will be removed
22
+ return clearInterval(t)
23
+ const v = performance.getEntriesByType('resource').reduce((acc, res) => acc + (res.transferSize || 0), 0)
24
+ e.innerText = Math.min(100, Math.round(v / total * 100)) + '%'
25
+ }, 200)
26
+ })()
27
+ </script>
28
</body>
29
</html>