Closed SinghGauravKumar closed 1 year ago
This is already supported. An "Exolve" event is fired upon completion, and you just have to add a few lines of JavaScript to listen for this event and show a message upon receiving it.
See the documentation in https://github.com/viresh-ratnakar/exolve#completion-event and see https://github.com/viresh-ratnakar/exolve/blob/master/test-completion-notice.html for an example.
@viresh-ratnakar I saw that. But I am hosting several crosswords on the same page of my website using embeds. The Alert message shows up for the whole page, while I was looking for a message at that particular crossword itself.
You don't have to show a page-wide alert()
upon completion—that's just an example. You can insert a congratulatory message anywhere, instead. For example, this code will insert a message in the puzzle preamble:
document.addEventListener('exolve', function (e) {
let msg = 'You have completed the puzzle.';
msg += '.';
if (e.detail.knownCorrect) msg += ' Your solution is correct!';
if (e.detail.knownIncorrect) msg += ' Your solution has mistakes.';
const puz = exolvePuzzles[e.detail.id];
document.getElementById(puz.prefix + '-preamble').innerHTML = msg;
});
I don't know what's best, but anything which says "Woohoo, you have done it"