diff --git a/index.html b/index.html index 7cd72ae..0571437 100644 --- a/index.html +++ b/index.html @@ -1,111 +1,112 @@ - - - - - Document - - - - - -
WORDLE INSA
+ + + + + WORDLE MAIS L'INSA + + + + + + +
WORDLE INSA
-
+
+

+
+
+

+

+

+

+

+
+
+

+

+

+

+

+
+
+

+

+

+

+

+
+
+

+

+

+

+

+
+
+

+

+

+

+

+
+
+

+

+

+

+

+
-
-
-

-

-

-

-

-
-
-

-

-

-

-

-
-
-

-

-

-

-

-
-
-

-

-

-

-

-
-
-

-

-

-

-

-
-
-

-

-

-

-

-
+
-
+ - - -
+
- + \ No newline at end of file diff --git a/script.js b/script.js index 6abbeb6..1a93b83 100644 --- a/script.js +++ b/script.js @@ -9,6 +9,7 @@ let arrWords; readTextFile("words.txt"); aleatoire(); +setMyKeyDownListener(); function change_color_good_letter(coord){ coord = "case".concat(coord) @@ -31,6 +32,27 @@ function change_color_mid_letter(coord){ case_div.style.backgroundColor = mid_letter_color; } +function key_color_good_letter(coord){ + coord = "case".concat(coord) + console.log(coord) + var case_div = document.getElementById(coord); + case_div.style.backgroundColor = good_letter_color; +} + +function key_color_bad_letter(coord){ + coord = "case".concat(coord) + console.log(coord) + var case_div = document.getElementById(coord); + case_div.style.backgroundColor = bad_letter_color; +} + +function key_color_mid_letter(coord){ + coord = "case".concat(coord) + console.log(coord) + var case_div = document.getElementById(coord); + case_div.style.backgroundColor = mid_letter_color; +} + function update(x) { if (free_box[1]==6) { } @@ -44,6 +66,7 @@ function update(x) { } function Supprimer() { + document.getElementById("info").innerHTML=""; word = word.slice(0,-1); if (free_box[1]==1) { } @@ -145,16 +168,35 @@ function verifWord() { let exist = false; if (word.length == 5){ for(let i = 0; i< arrWords.length;i++){ - if(arrWords[i]==word){ + if(arrWords[i]==word){ exist = true; } + else { + document.getElementById("info").innerHTML="NOT A WORD"; + } } } return exist; -} +} function aleatoire() { let rand = Math.floor(Math.random() * arrWords.length); reponse = arrWords[rand]; console.log(reponse); -} \ No newline at end of file +} + +function setMyKeyDownListener() { + window.addEventListener("keydown", + function(event){ + console.log(event.key) + if (event.key == "Enter"){ + Enter(); + } + else if (event.key == "Backspace") { + Supprimer(); + } + else if (event.key != "Control" & event.key != "Fn" & event.key != "Alt" & event.key != "Tab" & event.key != "CapsLock"){ + update(event.key); + } + }); +} diff --git a/styles.css b/styles.css index aaa3d33..53eb4d2 100644 --- a/styles.css +++ b/styles.css @@ -17,7 +17,10 @@ section{ /* Alignement du tableau de jeu */ padding-top: 5%; align-items: center; } - +.info{ /* Alignement du tableau de jeu */ + text-align: center; + height: 15px; +} .grille_haut { /* Alignement du tableau de jeu */ display: flex; align-items: center;