diff --git a/contact.js b/contact.js index 9dd650d..5b5da85 100644 --- a/contact.js +++ b/contact.js @@ -1,10 +1,52 @@ const zoneMessage = document.getElementById("contacter"); const compteur = document.getElementById("restant"); +const motCaractere = document.getElementById("mot"); +const boutonEffacer = document.getElementById("effacer"); +const formulaire = document.querySelector("form"); +const badge = document.getElementById("statut_horaires"); +const heure = new Date().getHours(); const MAX = 500; -zoneMessage.addEventListener("input", function () { - const dejaTape = zoneMessage.value.length; - compteur.textContent = MAX - dejaTape; - compteur.style.color = MAX - dejaTape < 50 ? "red" : "black"; +if (heure >= 9 && heure < 18) { + badge.textContent = "✅ Nous sommes ouverts (9h–18h)"; + badge.style.color = "green"; +} else { + badge.textContent = "🔴 Fermé — écrivez-nous, on répond dès l'ouverture !"; + badge.style.color = "red"; +} + +function rafraichirCompteur() { + const restant = MAX - zoneMessage.value.length; + compteur.textContent = restant; + compteur.style.color = restant < 50 ? "red" : "black"; + motCaractere.textContent = restant <= 1 ? "caractère" : "caractères"; +} + +zoneMessage.addEventListener("input", rafraichirCompteur); + +boutonEffacer.addEventListener("click", function () { + zoneMessage.value = ""; + rafraichirCompteur(); }); + +formulaire.addEventListener("submit", function (evenement) { + if (zoneMessage.value.trim() === "") { + evenement.preventDefault(); + alert("Merci d'écrire un message avant d'envoyer !"); + } +}); + +function creerNavbar() { + return ` +
`; +} + +document.body.insertAdjacentHTML("afterbegin", creerNavbar()); diff --git a/pages/contact.css b/pages/contact.css index 0e96496..a9d25ac 100644 --- a/pages/contact.css +++ b/pages/contact.css @@ -130,7 +130,7 @@ td { .form { display: flex; width: 570px; - height: 320px; + height: 380px; border: 3px solid green; align-items: center; flex-direction: column; @@ -164,3 +164,6 @@ textarea { bottom: 0; width: 100%; } +#statut_horaires { + font-size: 15px; +} diff --git a/pages/contact.html b/pages/contact.html index df0f93b..840adfa 100644 --- a/pages/contact.html +++ b/pages/contact.html @@ -8,16 +8,6 @@ - - -Les développeurs de ce site
@@ -43,6 +33,7 @@Nous contacter
+