Added background color changing
[jkinsey.net.git] / js / script.js
index 6528aa3fffbec092eaebfd9b1da621006b290d08..e7ab2b64e94d2eccb94dcc67cfc36770def73e79 100644 (file)
@@ -3,6 +3,7 @@ window.addEventListener('load', function() {
     var home = document.getElementsByClassName("home");
     var menu = document.getElementById("menu");
     var content = document.getElementById("content");
+    var body = document.getElementsByTagName("body")[0];
     var menuLoc = parseInt(getComputedStyle(menu).getPropertyValue("top"));
 
     function menuOperator(position, token="") {
@@ -21,6 +22,10 @@ window.addEventListener('load', function() {
             var article = document.getElementById(name);
             article.setAttribute("class", "selected");
         }
+        var color = node.getAttribute("data-color");
+        if(color) {
+            body.setAttribute("class", color);
+        }
         window.history.pushState("object or string", "Title", node.href);
     }