/* * To change this template, choose Tools | Templates * and open the template in the editor. */ function displaymenu() { //On créer les images var img1 = document.createElement("img"); var img2 = document.createElement("img"); var img3 = document.createElement("img"); var img4 =document.createElement("img"); var img5 =document.createElement("img"); var img6 =document.createElement("img"); //Mise en place des attributs img1.setAttribute("src", "../../img/burger_top.png"); img2.setAttribute("src", "../../img/burger_salade.png"); img3.setAttribute("src", "../../img/burger_tomate.png"); img4.setAttribute("src", "../../img/burger_oignon.png"); img5.setAttribute("src", "../../img/burger_steak.png"); img6.setAttribute("src", "../../img/burger_bottom.png"); img1.setAttribute("alt", "img"); img2.setAttribute("alt", "img") img3.setAttribute("alt", "img") img4.setAttribute("alt", "img") img5.setAttribute("alt", "img") img6.setAttribute("alt", "img") img1.setAttribute("class", "sub_menu_img"); img2.setAttribute("class", "sub_menu_img"); img3.setAttribute("class", "sub_menu_img"); img4.setAttribute("class", "sub_menu_img"); img5.setAttribute("class", "sub_menu_img"); img6.setAttribute("class", "sub_menu_img"); //Creation des liens var link1 = document.createElement("a"); var link2 = document.createElement("a"); var link3 = document.createElement("a"); var link4 = document.createElement("a"); var link5 = document.createElement("a"); var link6 = document.createElement("a"); link1.setAttribute("href", "index.php"); link2.setAttribute("href", "index.php?page=game"); link3.setAttribute("href", "index.php?page=signup"); link4.setAttribute("href", "index.php?page=account"); link5.setAttribute("href", "index.php?page=rank"); link6.setAttribute("href", "index.php?page=logout"); link1.appendChild(document.createTextNode("Accueil")); link2.appendChild(document.createTextNode("Jouer")); link3.appendChild(document.createTextNode("Inscription")); link4.appendChild(document.createTextNode("Compte")); link5.appendChild(document.createTextNode("Classement")); link6.appendChild(document.createTextNode("Déconnexion")); //Creation des conteneurs var cnt1 = document.createElement("li"); var cnt2 = document.createElement("li"); var cnt3 = document.createElement("li"); var cnt4 = document.createElement("li"); var cnt5 = document.createElement("li"); var cnt6 = document.createElement("li"); //Ajout des élements aux containers cnt1.appendChild(img1); cnt1.appendChild(link1); cnt2.appendChild(img2); cnt2.appendChild(link2); cnt3.appendChild(img3); cnt3.appendChild(link3); cnt3.appendChild(document.createElement("br")); cnt3.appendChild(document.createElement("br")); cnt3.appendChild(link4); cnt4.appendChild(img4); cnt4.appendChild(link5); cnt5.appendChild(img5); cnt5.appendChild(link6); cnt6.appendChild(img6); //Avant la mise en place on supprime les anciens élements menu = document.getElementById("menu_ul"); while(menu.firstChild) { menu.removeChild(menu.firstChild); } //On ajoute les éléments menu.appendChild(cnt1); menu.appendChild(cnt2); menu.appendChild(cnt3); menu.appendChild(cnt4); menu.appendChild(cnt5); menu.appendChild(cnt6); } function hidemenu() { //On supprime tous les noeud var ul = document.getElementById("menu_ul"); while(ul.firstChild) { ul.removeChild(ul.firstChild); } //On met en place l'image de départ var img = document.createElement("img"); img.setAttribute("alt", "img"); img.setAttribute("id", "menu_img"); img.setAttribute("src", "../../img/burger_menu.png"); //On met en place le conteneur var cnt = document.createElement("li"); cnt.appendChild(img); //On met en place l'image ul.appendChild(cnt); } function init() { var core = document.getElementById("core"); // core.setAttribute("onmouseover", "javascript:hidemenu()") }