added Makefile to build subpages; added fake resume; finished basic page design/structure
[jkinsey.net.git] / js / script.js
index c5f2c7a4167db351e8af42da240d9cb2ea965c72..6528aa3fffbec092eaebfd9b1da621006b290d08 100644 (file)
@@ -1,27 +1,37 @@
 window.addEventListener('load', function() {
     var links = document.getElementById("links").children[0].children;
     var home = document.getElementsByClassName("home");
-    var directions = [];
-    for(var i = 0; i < links.length - 1; i++) {
-        directions.push(links[i]);
-    }
-    for(var i = 0; i < home.length; i++) {
-        directions.push(home[i]);
-    }
     var menu = document.getElementById("menu");
+    var content = document.getElementById("content");
     var menuLoc = parseInt(getComputedStyle(menu).getPropertyValue("top"));
 
-    for(var i = 0; i < directions.length; i++) {
-        directions[i].children[0].onclick = function(event) { 
-            event.preventDefault();
-            var node = event.currentTarget;
-            if(menuLoc != 10) {
-                menuLoc = 0;
-                menu.setAttribute("class", "top");
-                window.history.pushState("object or string", "Title", node.href);
-            } else {
-                window.history.pushState("object or string", "Title", node.href);
-            }
+    function menuOperator(position, token="") {
+        event.preventDefault();
+        var node = event.currentTarget;
+        menu.setAttribute("class", position);
+        for(var i = 0; i < links.length; i++) {
+            links[i].children[0].removeAttribute("class");
+        }
+        node.setAttribute("class", "selected " + token);
+        for(var i = 0; i < content.children.length; i++) {
+            content.children[i].setAttribute("class", "hidden")
+        }
+        var name = node.getAttribute("data-name");
+        if(name) {
+            var article = document.getElementById(name);
+            article.setAttribute("class", "selected");
+        }
+        window.history.pushState("object or string", "Title", node.href);
+    }
+
+    for(var i = 0; i < links.length - 1; i++) {
+        links[i].children[0].onclick = function(event) { 
+            menuOperator("top");
         };
     }
+    for(var i = 0; i < home.length; i++) {
+        home[i].onclick = function(event) {
+            menuOperator("middle", "home");
+        }
+    }
 }, false);