瀏覽代碼

Merge branch 'feature-loading-messages'

n1474335 8 年之前
父節點
當前提交
a6317212d9
共有 3 個文件被更改,包括 46 次插入1 次删除
  1. 3 0
      src/web/App.js
  2. 25 0
      src/web/html/index.html
  3. 18 1
      src/web/stylesheets/preloader.css

+ 3 - 0
src/web/App.js

@@ -70,6 +70,9 @@ App.prototype.loaded = function() {
         document.getElementById("loader-wrapper").remove();
         document.body.classList.remove("loaded");
     }, 1000);
+
+    // Clear the loading message interval
+    clearInterval(window.loadingMsgInt);
 };
 
 

+ 25 - 0
src/web/html/index.html

@@ -34,12 +34,37 @@
         <script type="application/javascript">
             // Load theme before the preloader is shown
             document.querySelector(":root").className = JSON.parse(localStorage.getItem("options")).theme;
+
+            // Cycle loading messages
+            const loadingMsgs = [
+                "Proving P = NP...",
+                "Computing 6 x 9...",
+                "Mining bitcoin...",
+                "Dividing by 0...",
+                "Initialising Skynet...",
+                "[REDACTED]",
+                "Downloading more RAM...",
+                "Loading more loading messages...",
+                "Ordering 1s and 0s...",
+                "Navigating neural network...",
+                "Importing machine learning..."
+            ];
+            function changeLoadingMsg() {
+                try {
+                    const el = document.getElementById("preloader-msg");
+                    el.className = "loading"; // Causes CSS transition on first message
+                    el.innerHTML = loadingMsgs[Math.floor(Math.random()*loadingMsgs.length)];
+                } catch (err) {}
+            }
+            changeLoadingMsg();
+            window.loadingMsgsInt = setInterval(changeLoadingMsg, (Math.random()*500) + 500);
         </script>
     </head>
     <body>
         <!-- Preloader overlay -->
         <div id="loader-wrapper">
             <div id="preloader"></div>
+            <div id="preloader-msg"></div>
         </div>
         <!-- End preloader overlay -->
         <span id="edit-favourites" class="btn btn-default btn-sm"><img aria-hidden="true" src="<%- require('../static/images/favourite-16x16.png') %>" alt="Star Icon"/> Edit</span>

+ 18 - 1
src/web/stylesheets/preloader.css

@@ -55,9 +55,26 @@
     animation: spin 1.5s linear infinite;
 }
 
+#preloader-msg {
+    display: block;
+    position: relative;
+    width: 300px;
+    left: calc(50% - 150px);
+    top: calc(50% + 50px);
+    text-align: center;
+    margin-top: 50px;
+    opacity: 0;
+}
+
+#preloader-msg.loading {
+    opacity: 1;
+    transition: all 0.1s ease-in;
+}
+
 
 /* Loaded */
-.loaded #preloader {
+.loaded #preloader,
+.loaded #preloader-msg {
     opacity: 0;
     transition: all 0.3s ease-out;
 }