Browse Source

Tidying codebase

n1474335 8 years ago
parent
commit
6abd10f9e2
4 changed files with 10 additions and 118 deletions
  1. 4 1
      Gruntfile.js
  2. 6 6
      src/web/ControlsWaiter.js
  3. 0 108
      src/web/SeasonalWaiter.js
  4. 0 3
      src/web/spiderImages.json

+ 4 - 1
Gruntfile.js

@@ -237,7 +237,10 @@ module.exports = function (grunt) {
                         compileTime: compileTime
                     })
                 ],
-                watch: true
+                watch: true,
+                stats: {
+                    warningsFilter: /source-map/
+                }
             },
             webProd: {
                 target: "web",

+ 6 - 6
src/web/ControlsWaiter.js

@@ -168,17 +168,17 @@ ControlsWaiter.prototype.generateStateUrl = function(includeRecipe, includeInput
     recipeConfig = recipeConfig || this.app.getRecipeConfig();
 
     const link = baseURL || window.location.protocol + "//" +
-                window.location.host +
-                window.location.pathname;
+        window.location.host +
+        window.location.pathname;
     const recipeStr = JSON.stringify(recipeConfig);
     const inputStr = Utils.toBase64(this.app.getInput(), "A-Za-z0-9+/"); // B64 alphabet with no padding
 
-    const myIncludeRecipe = includeRecipe && (recipeConfig.length > 0);
-    const myIncludeInput = includeInput && (inputStr.length > 0) && (inputStr.length < 8000);
+    includeRecipe = includeRecipe && (recipeConfig.length > 0);
+    includeInput = includeInput && (inputStr.length > 0) && (inputStr.length < 8000);
 
     const params = [
-        myIncludeRecipe ? ["recipe", recipeStr] : undefined,
-        myIncludeInput ? ["input", inputStr] : undefined,
+        includeRecipe ? ["recipe", recipeStr] : undefined,
+        includeInput ? ["input", inputStr] : undefined,
     ];
 
     const query = params

+ 0 - 108
src/web/SeasonalWaiter.js

@@ -1,8 +1,3 @@
-import spiderImages from "./spiderImages.json";
-
-
-const { spider16, spider32, spider64 } = spiderImages;
-
 /**
  * Waiter to handle seasonal events and easter eggs.
  *
@@ -24,66 +19,12 @@ const SeasonalWaiter = function(app, manager) {
  * Loads all relevant items depending on the current date.
  */
 SeasonalWaiter.prototype.load = function() {
-    //var now = new Date();
-
-    // SpiderChef
-    // if (now.getMonth() === 3 && now.getDate() === 1) { // Apr 1
-        // this.insertSpiderIcons();
-        // this.insertSpiderText();
-    // }
-
     // Konami code
     this.kkeys = [];
     window.addEventListener("keydown", this.konamiCodeListener.bind(this));
 };
 
 
-/**
- * Replaces chef icons with spider icons.
- * #spiderchef
- */
-SeasonalWaiter.prototype.insertSpiderIcons = function() {
-
-    // Favicon
-    document.querySelector("link[rel=icon]").setAttribute("href", "data:image/png;base64," + spider16);
-
-    // Bake button
-    document.querySelector("#bake img").setAttribute("src", "data:image/png;base64," + spider32);
-
-    // About box
-    document.querySelector(".about-img-left").setAttribute("src", "data:image/png;base64," + spider64);
-};
-
-
-/**
- * Replaces all instances of the word "cyber" with "spider".
- * #spiderchef
- */
-SeasonalWaiter.prototype.insertSpiderText = function() {
-    // Title
-    document.title = document.title.replace(/Cyber/g, "Spider");
-
-    // Body
-    SeasonalWaiter.treeWalk(document.body, function(node) {
-        // process only text nodes
-        if (node.nodeType === 3) {
-            node.nodeValue = node.nodeValue.replace(/Cyber/g, "Spider");
-        }
-    }, true);
-
-    // Bake button
-    SeasonalWaiter.treeWalk(document.getElementById("bake-group"), function(node) {
-        // process only text nodes
-        if (node.nodeType === 3) {
-            node.nodeValue = node.nodeValue.replace(/Bake/g, "Spin");
-        }
-    }, true);
-
-    // Recipe title
-    document.querySelector("#recipe .title").innerHTML = "Web";
-};
-
-
 /**
  * Listen for the Konami code sequence of keys. Turn the page upside down if they are all heard in
  * sequence.
@@ -104,53 +45,4 @@ SeasonalWaiter.prototype.konamiCodeListener = function(e) {
     }
 };
 
-
-/**
- * Walks through the entire DOM starting at the specified element and operates on each node.
- *
- * @static
- * @param {element} parent - The DOM node to start from
- * @param {Function} fn - The callback function to operate on each node
- * @param {booleam} allNodes - Whether to operate on every node or not
- */
-SeasonalWaiter.treeWalk = (function() {
-    // Create closure for constants
-    const skipTags = {
-        "SCRIPT": true, "IFRAME": true, "OBJECT": true,
-        "EMBED": true, "STYLE": true, "LINK": true, "META": true
-    };
-
-    return function(parent, fn, allNodes) {
-        let node = parent.firstChild;
-
-        while (node && node !== parent) {
-            if (allNodes || node.nodeType === 1) {
-                if (fn(node) === false) {
-                    return false;
-                }
-            }
-            // If it's an element &&
-            //    has children &&
-            //    has a tagname && is not in the skipTags list
-            // then, we can enumerate children
-            if (node.nodeType === 1 &&
-                node.firstChild &&
-                !(node.tagName && skipTags[node.tagName])) {
-                node = node.firstChild;
-            } else if (node.nextSibling) {
-                node = node.nextSibling;
-            } else {
-                // No child and no nextsibling
-                // Find parent that has a nextSibling
-                while ((node = node.parentNode) !== parent) {
-                    if (node.nextSibling) {
-                        node = node.nextSibling;
-                        break;
-                    }
-                }
-            }
-        }
-    };
-})();
-
 export default SeasonalWaiter;

File diff suppressed because it is too large
+ 0 - 3
src/web/spiderImages.json


Some files were not shown because too many files changed in this diff