Skip to content

Commit

Permalink
An attempt at fixing #1081
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnSmith-LT committed May 3, 2022
1 parent 7f02e67 commit b981262
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Expand Up @@ -353,7 +353,7 @@ and (max-width :500px) {
caret-color: transparent;
}
/*gap fill: add ticks to correct answers*/
.x_gapFill_page #targetHolder input[readonly].correct+span:before, .x_gapFill_page #targetHolder input[correct]+span:before, .x_gapFill_page #targetHolder .target.correct+span:before,.x_gapFill_page #targetHolder select[disabled].correct+span:before{
.x_crossword_page .li-clue p.correct:after, .x_gapFill_page #targetHolder input[readonly].correct+span:before, .x_gapFill_page #targetHolder input[correct]+span:before, .x_gapFill_page #targetHolder .target.correct+span:before,.x_gapFill_page #targetHolder select[disabled].correct+span:before{
font-family: FontAwesome;
content: "\f00c";
color: green;
Expand All @@ -372,7 +372,7 @@ and (max-width :500px) {
padding:initial !important;
}
/*gap fill: show red crosses when incorrect and in tracking mode*/
.x_gapFill_page #targetHolder select[disabled]+span:before,.x_gapFill_page #targetHolder .target.incorrect+span:before, .x_gapFill_page #pageContents input[readonly]+span:before{
.x_crossword_page .li-clue p.incorrect:after, .x_gapFill_page #targetHolder select[disabled]+span:before,.x_gapFill_page #targetHolder .target.incorrect+span:before, .x_gapFill_page #pageContents input[readonly]+span:before{
font-family: FontAwesome;
content: "\f00d";
color: red;
Expand Down
Expand Up @@ -1283,6 +1283,7 @@
var coordinates = [];
var letters = [];
var coordinate = ""
var indices = [];
var table = document.getElementById('crossword-table');
var grid = cw.getSquareGrid(10);
for(var d = 0; d < grid.length; d++){
Expand All @@ -1291,10 +1292,12 @@
coordinate = d + "," + c;
coordinates.push(coordinate)
letters.push(grid[d][c].char)
indices.push(grid[d][c].across ? grid[d][c].across.index : grid[d][c].down.index);
}
}
}

var incorrectIndices = [];
for(var coor = 0; coor < coordinates.length; coor++){
var inputValue = document.getElementById(coordinates[coor]).value.toLowerCase()
if(letters[coor].toLowerCase() === inputValue){
Expand All @@ -1305,10 +1308,24 @@
//replace letter
document.getElementById(coordinates[coor]).value = document.getElementById(coordinates[coor]).value.replace(/[^\d,]/g,'')
document.getElementById(coordinates[coor]).value = letters[coor];
if (incorrectIndices.indexOf(indices[coor]) === -1) {
incorrectIndices.push(indices[coor]);
}
}

document.getElementById(coordinates[coor]).readOnly = true;
}
var incorrectWords = [];
incorrectIndices.forEach(function(index){ incorrectWords.push(words_in[index]);});console.log(incorrectWords);
$(".li-clue > p").each(function(index, element){
var word = $(element).text();
if (incorrectWords.indexOf(word) !== -1) {
$(element).addClass("incorrect");
}
else if (word.length>0) {
$(element).addClass("correct");
}
});

document.getElementById("show_button").disabled = true;

Expand Down

0 comments on commit b981262

Please sign in to comment.