Skip to content

fix: display error message (again) when regular expression contains errors #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions _layouts/tutorial.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
<title>{{ page.title | escape }} - {{ site.data.localization.title[page.lang] }}</title>
<script type="text/javascript">
var current_page_id = "page-" + {{ page.path | jsonify }};

var errorMessage = "{{ site.data.localization.error.message[page.lang] }}";
var errorReferenceWrong = "{{ site.data.localization.error.reference[page.lang] }}";
</script>
<style>
.clicked .toggle-hint:before {
Expand Down
9 changes: 6 additions & 3 deletions js/playfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
var playfieldsLoaded = false;

function translateErrorMessage(message) {
var translation = (errorMessages[message] || PLEASE_TRANSLATE);
return ERROR_MESSAGE + ": \"" + message + "\": " + translation;
return errorMessage + ": \"" + message + "\"";
}

function translateReferenceWrongErrorMessage(message) {
return errorReferenceWrong + ": \"" + message + "\"";
}

function matchTextElement(string) {
Expand Down Expand Up @@ -59,7 +62,7 @@ function watchExpression(playfield, examples, regex, message) {
try {
return RegExp(reference);
} catch (err) {
message.innerHTML = translateErrorMessage(err.message) + errorReferenceWrong;
message.innerHTML = translateReferenceWrongErrorMessage(err.message);
return null;
}
}
Expand Down