(至顶按钮适配Edge。) |
(修正地址及页面命名问题。) |
||
Line 37: | Line 37: | ||
{ | { | ||
"menu": "Parts", | "menu": "Parts", | ||
− | + | "link": "https://2018.igem.org/Team:DLUT_China_B/Parts" | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
}, | }, | ||
{ | { | ||
Line 74: | Line 61: | ||
{ | { | ||
"name": "Applied Design", | "name": "Applied Design", | ||
− | "link": "https://2018.igem.org/Team:DLUT_China_B/ | + | "link": "https://2018.igem.org/Team:DLUT_China_B/Applied_Design" |
}, | }, | ||
{ | { | ||
Line 87: | Line 74: | ||
}, | }, | ||
{ | { | ||
− | "menu": "Human | + | "menu": "Human Practices", |
"subMenu": [ | "subMenu": [ | ||
{ | { | ||
− | "name": "Human | + | "name": "Human Practices", |
− | "link": "https://2018.igem.org/Team:DLUT_China_B/ | + | "link": "https://2018.igem.org/Team:DLUT_China_B/Human_Practices" |
}, | }, | ||
{ | { | ||
Line 111: | Line 98: | ||
}, | }, | ||
{ | { | ||
− | "name": " | + | "name": "Collaborations", |
− | "link": "https://2018.igem.org/Team:DLUT_China_B/ | + | "link": "https://2018.igem.org/Team:DLUT_China_B/Collaborations" |
} | } | ||
] | ] | ||
Line 119: | Line 106: | ||
let ul = document.createElement("ul"); | let ul = document.createElement("ul"); | ||
ul.setAttribute("class", "menu"); | ul.setAttribute("class", "menu"); | ||
− | + | for (let i = 0; i < navData.length; ++i) { | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | for (let i = | + | |
let menu = document.createElement("li"); | let menu = document.createElement("li"); | ||
let menuName = document.createElement("a"); | let menuName = document.createElement("a"); | ||
menuName.innerText = navData[i]["menu"]; | menuName.innerText = navData[i]["menu"]; | ||
− | let subMenu = document.createElement("ul"); | + | |
− | + | if(navData[i].hasOwnProperty("subMenu")) { | |
− | + | let subMenu = document.createElement("ul"); | |
− | + | subMenu.setAttribute("class", "subMenu"); | |
− | + | for (let j = 0; j < navData[i]["subMenu"].length; ++j) { | |
− | + | let subMenuName = document.createElement("li"); | |
− | + | let subMenuNameA = document.createElement("a"); | |
− | + | subMenuNameA.innerText = navData[i]["subMenu"][j]["name"]; | |
− | + | subMenuNameA.setAttribute("href", navData[i]["subMenu"][j]["link"]); | |
+ | subMenuName.appendChild(subMenuNameA); | ||
+ | subMenu.appendChild(subMenuName); | ||
+ | } | ||
+ | menu.appendChild(menuName); | ||
+ | menu.appendChild(subMenu); | ||
+ | } | ||
+ | else { | ||
+ | menuName.setAttribute("href", navData[i]["link"]); | ||
+ | menu.appendChild(menuName); | ||
} | } | ||
− | |||
− | |||
ul.appendChild(menu); | ul.appendChild(menu); | ||
} | } |
Revision as of 07:44, 11 October 2018
/*导航栏*/ let nav = document.getElementById("nav"); let navData = [
{ "menu": "Home", "link": "https://2018.igem.org/Team:DLUT_China_B" }, { "menu": "Project", "subMenu": [ { "name": "Description", "link": "https://2018.igem.org/Team:DLUT_China_B/Description" }, { "name": "Design", "link": "https://2018.igem.org/Team:DLUT_China_B/Design" }, { "name": "Demonstrate", "link": "https://2018.igem.org/Team:DLUT_China_B/Demonstrate" }, { "name": "Experiments", "link": "https://2018.igem.org/Team:DLUT_China_B/Experiments" }, { "name": "InterLab", "link": "https://2018.igem.org/Team:DLUT_China_B/InterLab" }, { "name": "Notebook", "link": "https://2018.igem.org/Team:DLUT_China_B/Notebook" } ] }, { "menu": "Parts", "link": "https://2018.igem.org/Team:DLUT_China_B/Parts" }, { "menu": "Model", "subMenu": [ { "name": "Condition Optimization", "link": "https://2018.igem.org/Team:DLUT_China_B/ConditionOptimization" }, { "name": "Standard Curve", "link": "https://2018.igem.org/Team:DLUT_China_B/StandardCurve" }, { "name": "Result", "link": "https://2018.igem.org/Team:DLUT_China_B/Result" } ] }, { "menu": "Awards", "subMenu": [ { "name": "Applied Design", "link": "https://2018.igem.org/Team:DLUT_China_B/Applied_Design" }, { "name": "Hardware", "link": "https://2018.igem.org/Team:DLUT_China_B/Hardware" }, { "name": "Software", "link": "https://2018.igem.org/Team:DLUT_China_B/Software" } ] }, { "menu": "Human Practices", "subMenu": [ { "name": "Human Practices", "link": "https://2018.igem.org/Team:DLUT_China_B/Human_Practices" }, { "name": "Education", "link": "https://2018.igem.org/Team:DLUT_China_B/Education" } ] }, { "menu": "Team", "subMenu": [ { "name": "Team Members", "link": "https://2018.igem.org/Team:DLUT_China_B/TeamMembers" }, { "name": "Attributions", "link": "https://2018.igem.org/Team:DLUT_China_B/Attributions" }, { "name": "Collaborations", "link": "https://2018.igem.org/Team:DLUT_China_B/Collaborations" } ] }
]; let ul = document.createElement("ul"); ul.setAttribute("class", "menu"); for (let i = 0; i < navData.length; ++i) {
let menu = document.createElement("li"); let menuName = document.createElement("a"); menuName.innerText = navData[i]["menu"];
if(navData[i].hasOwnProperty("subMenu")) { let subMenu = document.createElement("ul"); subMenu.setAttribute("class", "subMenu"); for (let j = 0; j < navData[i]["subMenu"].length; ++j) { let subMenuName = document.createElement("li"); let subMenuNameA = document.createElement("a"); subMenuNameA.innerText = navData[i]["subMenu"][j]["name"]; subMenuNameA.setAttribute("href", navData[i]["subMenu"][j]["link"]); subMenuName.appendChild(subMenuNameA); subMenu.appendChild(subMenuName); } menu.appendChild(menuName); menu.appendChild(subMenu); } else { menuName.setAttribute("href", navData[i]["link"]); menu.appendChild(menuName); } ul.appendChild(menu);
} document.getElementById('nav').appendChild(ul);
/*至顶按钮*/ $('#back').click(function () {
if(navigator.userAgent.indexOf("Edge")>-1) $('body').animate( {scrollTop: 0}, 500); else $('html').animate( {scrollTop: 0}, 500);
}); function topToggle() {
if($(window).scrollTop()>600) document.getElementById("back").style.display="block"; else document.getElementById("back").style.display="none";
}