summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShmuel83 <[email protected]>2016-06-21 13:26:54 +0200
committerShmuel83 <[email protected]>2016-06-21 13:26:54 +0200
commit62b4ceadd3ecd667d14873ee756fa7c8cb7a45d2 (patch)
treefb34b426f1f9fd70e1c028554fbbe8cb7598839c
parentbda0ef9f8f7596071483fbd7d6affd569ae73ca0 (diff)
downloadword-search-game-62b4ceadd3ecd667d14873ee756fa7c8cb7a45d2.tar.gz
word-search-game-62b4ceadd3ecd667d14873ee756fa7c8cb7a45d2.zip
Fix minor Bug
If user re-select a word always find, this.solved is increment. Now : To increment variable if the word of the list isn't <delete> I fix a bug for me : in list, First letter Upper, with CSS instead of javascript
-rw-r--r--css/style.css4
-rw-r--r--js/wordsearch.js15
2 files changed, 13 insertions, 6 deletions
diff --git a/css/style.css b/css/style.css
index 6c4a5ef..51304ed 100644
--- a/css/style.css
+++ b/css/style.css
@@ -51,4 +51,8 @@ body {
.ws-word {
margin-bottom: 4px;
+}
+
+.ws-words ::first-letter{
+ text-transform : capitalize;
} \ No newline at end of file
diff --git a/js/wordsearch.js b/js/wordsearch.js
index cac0ae1..8753ea9 100644
--- a/js/wordsearch.js
+++ b/js/wordsearch.js
@@ -64,7 +64,7 @@
for (var i = 0; i < this.settings.words.length; i++) {
// Convert all the letters to upper case
- this.settings.wordsList[i] = this.settings.words[i].charAt(0).toUpperCase() + this.settings.words[i].substring(1).toLowerCase();
+ this.settings.wordsList[i] = this.settings.words[i];
this.settings.words[i] = removeDiacritics(this.settings.wordsList[i].toUpperCase());
var word = this.settings.words[i];
@@ -341,14 +341,17 @@
var wordList = document.querySelector(".ws-words");
var wordListItems = wordList.getElementsByTagName("li");
for(var i=0; i<wordListItems.length; i++){
- if(words[0].toLowerCase() == wordListItems[i].innerHTML.toLowerCase()){
- wordListItems[i].innerHTML = "<del>"+wordListItems[i].innerHTML+"</del>";
+ if(words[0] == removeDiacritics(wordListItems[i].innerHTML.toUpperCase())){
+ if(wordListItems[i].innerHTML != "<del>"+wordListItems[i].innerHTML+"</del>") { //Check the word is never found
+ wordListItems[i].innerHTML = "<del>"+wordListItems[i].innerHTML+"</del>";
+ //Increment solved words.
+ this.solved++;
+ }
+
+
}
}
- //Increment solved words.
- this.solved++;
-
//Game over?
if(this.solved == this.settings.words.length){
this.gameOver();