Skip to content

Commit

Permalink
Merge pull request #7 from boisvert42/deduper-clue-numbers
Browse files Browse the repository at this point in the history
Add clue numbers to de-duper
  • Loading branch information
crosswordnexus committed Sep 18, 2021
2 parents d4735da + 069a2c1 commit e395223
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions submission_checker/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
let contents = e.target.result;
var xw_constructor = new JSCrossword();
var xw = xw_constructor.fromData(contents);
console.log(xw);
document.getElementById('results').innerHTML = submission_check_html(xw);
};
})(f);
Expand Down
6 changes: 4 additions & 2 deletions submission_checker/submission_checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ function xwDupes(xw) {
Object.keys(entry_map).forEach(x => entries.add(entry_map[x]))

xw.clues.forEach(function(clueList) {
var thisCluesDirection = clueList.title;
clueList.clue.forEach(function (c) {
var clue = c.text;
var num = c.number;
// Loop through words in "clue"
var words = clue.split(/[ -]/);
words.forEach(function (word) {
Expand All @@ -64,7 +66,7 @@ function xwDupes(xw) {
if (word.length >= 4) {
entries.forEach(function (entry) {
if (entry.match(word)) {
dupes.push({'entry': entry, 'clue': clue});
dupes.push({'entry': entry, 'clue': clue, 'clueDirection': thisCluesDirection, 'clueNumber': num});
}
}); // end for entry
} // end if word length
Expand Down Expand Up @@ -109,7 +111,7 @@ function submission_check_html(xw) {
html += `<p style="color:${color};">`;
if (x.name == 'Dupes') {
x.value.forEach(function (d) {
html += `${d.entry} / ${d.clue}<br />\n`;
html += `${d.entry} / ${d.clue} [${d.clueNumber}-${d.clueDirection}]<br />\n`;
});
if (!x.value.length) {
html += 'No dupes found.';
Expand Down

0 comments on commit e395223

Please sign in to comment.