diff options
-rw-r--r-- | deploy/index.html | 36 | ||||
-rw-r--r-- | src/client/views/Main.tsx | 7 |
2 files changed, 37 insertions, 6 deletions
diff --git a/deploy/index.html b/deploy/index.html index 4e0c2dfa4..f2eb5e2aa 100644 --- a/deploy/index.html +++ b/deploy/index.html @@ -7,6 +7,23 @@ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <script src="https://cdnjs.cloudflare.com/ajax/libs/typescript/3.3.1/typescript.min.js"></script> + + <script> + function getCookie(cname) { + var name = cname + "="; + var ca = document.cookie.split(';'); + for (var i = 0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0) == ' ') { + c = c.substring(1); + } + if (c.indexOf(name) == 0) { + return Number(c.substring(name.length, c.length)); + } + } + return 3000; + } + </script> <style> .dash-loader { display: flex; @@ -105,22 +122,29 @@ <div id="dash-progress" class="dash-progress"> </div> <script> + let load = getCookie("loadtime"); + document.startLoad = Date.now(); + console.log("Last Load = " + load); setTimeout(() => { document.getElementById("dash-progress").style.width = "10%" document.getElementById("dash-loader-text").innerHTML = "Loading Dash..." - }, 500); + }, load / 10); setTimeout(() => { - document.getElementById("dash-progress").style.width = "30%" + document.getElementById("dash-progress").style.width = "33%" document.getElementById("dash-loader-text").innerHTML = "Preparing dashboards..." - }, 1000); + }, load / 3); setTimeout(() => { document.getElementById("dash-progress").style.width = "50%" + document.getElementById("dash-loader-text").innerHTML = "Initializing scripts..." + }, load / 2); + setTimeout(() => { + document.getElementById("dash-progress").style.width = "75%" document.getElementById("dash-loader-text").innerHTML = "Fetching documents..." - }, 1500); + }, load / 4 * 3); setTimeout(() => { - document.getElementById("dash-progress").style.width = "70%" + document.getElementById("dash-progress").style.width = "100%" document.getElementById("dash-loader-text").innerHTML = "Finalising setup..." - }, 3000); + }, load); </script> </div> <div id="dash-loader-text" class="dash-loader-text"> diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index c256d2ebb..34bfa8e77 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -24,5 +24,12 @@ AssignAllExtensions(); event.preventDefault(); } }, true); + const startload = (document as any).startLoad; + const loading = Date.now() - (startload ? Number(startload) : (Date.now() - 3000)); + console.log("Load Time = " + loading); + var d = new Date(); + d.setTime(d.getTime() + (100 * 24 * 60 * 60 * 1000)); + var expires = "expires=" + d.toUTCString(); + document.cookie = `loadtime=${loading};${expires};path=/`; ReactDOM.render(<MainView />, document.getElementById('root')); })();
\ No newline at end of file |