diff --git a/avocat/index.html b/avocat/index.html index 78cb40b..5098c16 100644 --- a/avocat/index.html +++ b/avocat/index.html @@ -1 +1,24 @@ -

Avocat

\ No newline at end of file + + + + + Avocat | Saoul Bonmonsieur + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/droits/affaire.html b/droits/affaire.html index 5a621a5..f60c860 100644 --- a/droits/affaire.html +++ b/droits/affaire.html @@ -1 +1,24 @@ -

Affaire

\ No newline at end of file + + + + + Droit des Affaires | Saoul Bonmonsieur + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/droits/penal.html b/droits/penal.html index 0da48ca..820d9fc 100644 --- a/droits/penal.html +++ b/droits/penal.html @@ -1 +1,24 @@ -

Penal

\ No newline at end of file + + + + + Droit pénal | Saoul Bonmonsieur + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/index.html b/index.html index b861c44..adb1cad 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ - + diff --git a/join/contact.html b/join/contact.html index c8d307e..caa7c92 100644 --- a/join/contact.html +++ b/join/contact.html @@ -1 +1,24 @@ -

Contact

\ No newline at end of file + + + + + Contact | Saoul Bonmonsieur + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/join/coordonees.html b/join/coordonees.html index d74d57f..d73ea61 100644 --- a/join/coordonees.html +++ b/join/coordonees.html @@ -1 +1,24 @@ -

Coordonées

\ No newline at end of file + + + + + Coordonées | Saoul Bonmonsieur + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/js/componentloader.js b/js/base.js similarity index 66% rename from js/componentloader.js rename to js/base.js index 5de7fc9..4f7a117 100644 --- a/js/componentloader.js +++ b/js/base.js @@ -46,10 +46,40 @@ function ready(callback) { }); } +/** + * Parse each character of the given string. + * @param {string} string + * @returns number of '/' in the string + */ +function getSlashNum(string) { + var returnValue = 0; + for (char of string) { + if (char == "/") { + returnValue++; + } + } + return returnValue; +} + +/** + * Will contenate a string of slash (num of parent dir) onto a given path + * @param {Int, number of slashes} slashNum + * @param {Concat String} basePath + * @returns the concatened string + */ +function concatPath(slashNum, basePath) +{ + var slashString = ""; + for (let i = 0; i < slashNum; i++) { + slashString += "../"; + } + return slashString+basePath; +} + /****************************************/ /* main */ /****************************************/ window.addEventListener('load', function () { - load("../components/navbar.html", document.getElementsByTagName("Navbar")[0],"js/navbar.js", this.document.getElementsByTagName("head")[0]); + load("../components/navbar.html", document.getElementsByTagName("Navbar")[0], concatPath(getSlashNum(window.location.pathname)-1,"js/navbar.js"), this.document.getElementsByTagName("head")[0]); }) \ No newline at end of file diff --git a/js/navbar.js b/js/navbar.js index 7081684..1dd3419 100644 --- a/js/navbar.js +++ b/js/navbar.js @@ -10,6 +10,12 @@ var dropdownList = document.getElementById("navbar_text-container").children[0]. var aTagList = getNavbarTextContainer(); //a list var dropdownStatus = Array(aTagList.length).fill(false); +//list of dropdown links +var dropdownLinks = ["droits/penal.html","droits/affaire.html","join/contact.html","join/coordonees.html"]; +//list of container links +var containerLinks = ["avocat"]; +//navbarDropdown Element +var navbarDropdown = document.getElementsByClassName("navbar_dropdown"); /****************************************/ /* animjs */ @@ -69,7 +75,7 @@ function getNavbarTextContainer() { */ function resetNavbar() { //For each dropdown found with the given classname, will set the display to none - for (dropdownClass of document.getElementsByClassName("navbar_dropdown")) { + for (dropdownClass of navbarDropdown) { dropdownClass.style.display = "none"; } } @@ -78,6 +84,28 @@ function resetNavbar() { /* main */ /****************************************/ +//Setting the href links for in directory links +var dropdownCount = 0; +for(var dropdown of navbarDropdown) +{ + for(var aTagDropdown of dropdown.children) + { + aTagDropdown.href = concatPath(getSlashNum(window.location.pathname)-1,dropdownLinks[dropdownCount]); + dropdownCount++; + } +} +dropdownCount = 0; +for(var aTag of aTagList) +{ + console.log(aTag); + if(!(aTag.href.includes("#0"))) + { + console.log(aTag); + aTag.href = concatPath(getSlashNum(window.location.pathname)-1,containerLinks[dropdownCount]); + dropdownCount++; + } +} + //Mouse enter for the logo document.getElementById("navbar_logo-container").addEventListener("mouseenter", function () { //enterAnimation is now true (see update in logoRotate) @@ -125,7 +153,7 @@ for (var dropdownElement of dropdownList) { window.addEventListener('click', function (e) { //clickState is set to 1 if the click is done outside any dropdownElement or the dropdown itself var clickState = false; - for (dropdownClass of document.getElementsByClassName("navbar_dropdown")) { + for (dropdownClass of navbarDropdown) { clickState |= dropdownClass.contains(e.target); } for (aTag of aTagList) {