From a2a5a3a96b407e62607c45771bc9a0a06131c35c Mon Sep 17 00:00:00 2001 From: Blavignac Leonardo Date: Mon, 12 Dec 2022 09:10:18 +0100 Subject: [PATCH 1/3] asdfsad --- script.js | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/script.js b/script.js index 02bf86a..33e3a85 100644 --- a/script.js +++ b/script.js @@ -31,25 +31,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; + 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; + console.log(key) + var key_div = document.getElementById(key); + key_div.style.backgroundColor = mid_letter_color; } function update(x) { @@ -135,13 +132,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(word in arrWords){ + exist = true; + } + else { + document.getElementById("info").innerHTML="NOT A WORD"; } } return exist; @@ -163,8 +158,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 (event.key in ["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"]){ + update(event.key.toUpperCase()); } }); } From a4152b4529665f91a6e81dfaa832287b474bb227 Mon Sep 17 00:00:00 2001 From: Blavignac Leonardo Date: Mon, 12 Dec 2022 09:25:07 +0100 Subject: [PATCH 2/3] asdfsadf --- script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script.js b/script.js index 33e3a85..d85aa91 100644 --- a/script.js +++ b/script.js @@ -132,7 +132,7 @@ function readTextFile(file) { //Merci StackOverflow function verifWord() { let exist = false; if (word.length == 5){ - if(word in arrWords){ + if(arrWords.includes(word)){ exist = true; } else { @@ -158,7 +158,7 @@ function setMyKeyDownListener() { else if (event.key == "Backspace") { Supprimer(); } - else if (event.key in ["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"]){ + 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()); } }); From c0d19b44145822b3ff8f89e687bb81d9c864ec00 Mon Sep 17 00:00:00 2001 From: Blavignac Leonardo Date: Mon, 12 Dec 2022 09:33:12 +0100 Subject: [PATCH 3/3] asdfsad --- index.html | 52 ++++++++++++++++++++++++++-------------------------- script.js | 9 +++++++-- 2 files changed, 33 insertions(+), 28 deletions(-) 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 d85aa91..2ec0e0a 100644 --- a/script.js +++ b/script.js @@ -37,13 +37,13 @@ function key_color_good_letter(key){ key_div.style.backgroundColor = good_letter_color; } -function key_color_bad_letter(coord){ +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){ +function key_color_mid_letter(key){ console.log(key) var key_div = document.getElementById(key); key_div.style.backgroundColor = mid_letter_color; @@ -86,10 +86,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()); } } }