| 1 | window.addEventListener('load', function() { |
| 2 | var links = document.getElementById("links").children[0].children; |
| 3 | var home = document.getElementsByClassName("home"); |
| 4 | var directions = []; |
| 5 | for(var i = 0; i < links.length - 1; i++) { |
| 6 | directions.push(links[i]); |
| 7 | } |
| 8 | for(var i = 0; i < home.length; i++) { |
| 9 | directions.push(home[i]); |
| 10 | } |
| 11 | var menu = document.getElementById("menu"); |
| 12 | var menuLoc = parseInt(getComputedStyle(menu).getPropertyValue("top")); |
| 13 | |
| 14 | for(var i = 0; i < directions.length; i++) { |
| 15 | directions[i].children[0].onclick = function(event) { |
| 16 | event.preventDefault(); |
| 17 | var node = event.currentTarget; |
| 18 | if(menuLoc != 10) { |
| 19 | menuLoc = 0; |
| 20 | menu.setAttribute("class", "top"); |
| 21 | window.history.pushState("object or string", "Title", node.href); |
| 22 | } else { |
| 23 | window.history.pushState("object or string", "Title", node.href); |
| 24 | } |
| 25 | }; |
| 26 | } |
| 27 | }, false); |