diff --git a/index.html b/index.html index 0571437..5a3ced5 100644 --- a/index.html +++ b/index.html @@ -71,37 +71,37 @@
- - - - - - - - - - + + + + + + + + + +
- - - - - - - - - + + + + + + + + +
- - - - - - - + + + + + + +
diff --git a/script.js b/script.js index 9047931..e841ad6 100644 --- a/script.js +++ b/script.js @@ -43,25 +43,22 @@ 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_good_letter(key){ + console.log(key) + var key_div = document.getElementById(key); + key_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_bad_letter(key){ + console.log(key) + var key_div = document.getElementById(key); + key_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 key_color_mid_letter(key){ + console.log(key) + var key_div = document.getElementById(key); + key_div.style.backgroundColor = mid_letter_color; } function update(x) { @@ -108,10 +105,15 @@ function verifLettres() { for(let i=0 ; i<5; i++){ if(word[i]==reponse[i]){ verif[i]=2; + key_color_good_letter(word[i].toUpperCase()); } else{ if(reponse.includes(word[i])){ verif[i]=1; + key_color_mid_letter(word[i].toUpperCase()); + } + else { + key_color_bad_letter(word[i].toUpperCase()); } } } @@ -177,13 +179,11 @@ function readTextFile(file) { //Merci StackOverflow function verifWord() { let exist = false; if (word.length == 5){ - for(let i = 0; i< arrWords.length;i++){ - if(arrWords[i]==word){ - exist = true; - } - else { - document.getElementById("info").innerHTML="NOT A WORD"; - } + if(arrWords.includes(word)){ + exist = true; + } + else { + document.getElementById("info").innerHTML="NOT A WORD"; } } return exist; @@ -205,8 +205,8 @@ function setMyKeyDownListener() { 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); + else if (["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m"].includes(event.key)){ + update(event.key.toUpperCase()); } }); }