Skip to content

Commit

Permalink
Fix cell creation
Browse files Browse the repository at this point in the history
  • Loading branch information
otacke committed Sep 12, 2024
1 parent 755bbb2 commit 59527f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/scripts/components/h5p-crossword-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ export default class CrosswordContent {
this.clueAnnouncer = new CrosswordClueAnnouncer();
tableWrapper.appendChild(this.clueAnnouncer.getDOM());

this.crosswordLayout.result = this.crosswordLayout.result.map((word, index) => {
word.clue = this.params.words[index].clue;
word.answer = this.params.words[index].answer;
word.extraClue = this.params.words[index].extraClue;
this.crosswordLayout.result = this.crosswordLayout.result.map((word) => {
word.clue = this.params.words[word.index].clue;
word.answer = this.params.words[word.index].answer;
word.extraClue = this.params.words[word.index].extraClue;

return word;
});
Expand Down
12 changes: 7 additions & 5 deletions src/scripts/services/h5p-crossword-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -697,31 +697,33 @@ export default class CrosswordGenerator {
continue;
}

if (cell.down && cell.down.isStartOfWord) {
if (cell.down?.isStartOfWord) {
result.push({
clue: this.getWordElement(cell.down.index, 'clue'),
answer: this.getWordElement(cell.down.index, 'answer'),
extraClue: this.getWordElement(cell.down.index, 'extraClue'),
startx: c + 1,
starty: r + 1,
orientation: 'down',
clueId: nextClueId
clueId: nextClueId,
index: cell.down.index
});
}

if (cell.across && cell.across.isStartOfWord) {
if (cell.across?.isStartOfWord) {
result.push({
clue: this.getWordElement(cell.across.index, 'clue'),
answer: this.getWordElement(cell.across.index, 'answer'),
extraClue: this.getWordElement(cell.across.index, 'extraClue'),
startx: c + 1,
starty: r + 1,
orientation: 'across',
clueId: nextClueId
clueId: nextClueId,
index: cell.across.index
});
}

if (cell.down && cell.down.isStartOfWord || cell.across && cell.across.isStartOfWord) {
if (cell.down?.isStartOfWord || cell.across?.isStartOfWord) {
nextClueId++;
}
}
Expand Down

0 comments on commit 59527f4

Please sign in to comment.