Skip to content

Commit 3ce5f6f

Browse files
committed
Pressing enter loads next page
When you press enter you will be redirected to the next step in the tutorial. See #20
1 parent fd703d4 commit 3ce5f6f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

js/playfield.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function matchExample(match, example) {
2626
var textBefore = text.slice(0, start);
2727
var textMatch = text.slice(start, stop);
2828
var textAfter = text.slice(stop, text.length);
29-
29+
3030
example.innerHTML = "";
3131
example.appendChild(nomatchTextElement(textBefore));
3232
example.appendChild(matchTextElement(textMatch));
@@ -105,7 +105,7 @@ function watchExpression(playfield, examples, regex, message) {
105105
}
106106
}
107107
regex.onkeyup = check;
108-
108+
109109
var experiments = playfield.getElementsByClassName("experiment");
110110
if (experiments.length == 1) {
111111
var experiment = experiments[0];
@@ -158,7 +158,7 @@ window.addEventListener("load", function(){
158158
var regex = getPlayfieldElement(playfield, i, "regex");
159159
var examples = getPlayfieldElement(playfield, i, "examples");
160160
var message = getPlayfieldElement(playfield, i, "message");
161-
161+
162162
watchExpression(playfield, examples, regex, message);
163163
if (i == 0) {
164164
regex.focus();
@@ -167,4 +167,9 @@ window.addEventListener("load", function(){
167167
playfieldsLoaded = true;
168168
});
169169

170-
170+
window.addEventListener("keypress", function(){
171+
var next = document.getElementsByClassName("next-page").href;
172+
if (!(!next | next.length === 0)) {
173+
window.location.href = next;
174+
}
175+
});

0 commit comments

Comments
 (0)