diff --git a/css/styles.css b/css/styles.css index cb3a976a208385b8fd2070a76d3034616a267e2b..bd5b154c9ebc4f80ccdd6c473e7b805cc7819d80 100644 --- a/css/styles.css +++ b/css/styles.css @@ -387,6 +387,18 @@ iframe { margin-top:1em; } +.pastille { + height: 15px; + width: 15px; + background-color: red; + border-radius: 50%; + position: absolute; + left: 210px; + bottom: 35px; + color: white; + font-size: 12.5px; +} + .search-button{ border-radius: 5px; border-width: 0px; diff --git a/html/chercherUnRepas.html b/html/chercherUnRepas.html index 8c2cc6ca1459714109e748d114af80e02b846bd1..8961a268c0f824827a44d34becf5665544719998 100644 --- a/html/chercherUnRepas.html +++ b/html/chercherUnRepas.html @@ -61,7 +61,16 @@ else { sessionStorage.setItem("panier", frigoIndex+"-"+repas); } + parentPastille(); } + function parentPastille() { + if(sessionStorage.getItem("panier") != null){ + console.log("slt") + var event = new CustomEvent('pastilleChanged') + window.parent.document.dispatchEvent(event) + } + console.log("allo") + } </script> </html> \ No newline at end of file diff --git a/html/membres.html b/html/membres.html index 2ff52a1033264a73fae9dad0e0f3136ab33b4c35..8836112aee702c8d35a0c2cee14d17cc5f028e1b 100644 --- a/html/membres.html +++ b/html/membres.html @@ -32,6 +32,7 @@ <span class="bold-btn">Mon profil</span> </button> <button class="tablinks" onclick="openTab(event, 'panier')"> + <div id="pastilleRouge" class="pastille hidden">0</div> <img src="../panier.png" class="icone-panier"> <span class="bold-btn">Mon panier</span> </button> @@ -47,10 +48,18 @@ </html> <script src="../scripts/tabsAndErrors.js"></script> <script> - /*var test = document.getElementById('test'); - - - for (var i = 1; i < 15 ; i++) { - test.innerHTML += "<div id=\"button_"+i+"\">" + i + "</div>"; - };*/ + managePastille(); + window.document.addEventListener('pastilleChanged', handleEvent, false) + function handleEvent(e) { + managePastille(); + } + function managePastille() { + if(sessionStorage.getItem("panier") != null){ + var count = 0; + var items = sessionStorage.getItem("panier").split(" "); + for (count; count < items.length; count++){} + document.getElementById("pastilleRouge").classList.remove("hidden"); + document.getElementById("pastilleRouge").innerHTML = count; + } + } </script> \ No newline at end of file