blob: d3de991a7cfc5aaa5345465ae9053174115c1cfd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
<!DOCTYPE html>
<html>
<body>
<h1>wordle</h1>
<table id="the_table">
</table>
<p id="debug"></p>
<script>
let table = document.getElementById("the_table");
let row_count = 0;
let cursor_column = 1;
let puzzle = '';
createPuzzle = function() {
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
puzzle = JSON.parse(request.responseText).riddle;
}
}
request.open( "GET", "https://wordle-backend.eckner.net/create", true );
request.send();
}
addNewRow = function() {
row_count++;
the_table.innerHTML += "<tr id=\"row_" + row_count + "\"></td>";
for (let i = 1; i <= 5; i++) {
the_table
.querySelector("#row_" + row_count)
.innerHTML += "<td id=\"column_" + i + "\"></td>";
}
};
onKeyDown = function(event){
let to_print = '';
let cursor_increment = 1;
if (event.keyCode >= 65 && event.keyCode < 91) {
to_print = String.fromCharCode(event.keyCode);
} else if (event.keyCode == 59) {
to_print = 'Ö';
} else if (event.keyCode == 63) {
to_print = 'ß';
} else if (event.keyCode == 219) {
to_print = 'Ü';
} else if (event.keyCode == 222) {
to_print = 'Ä';
} else if (event.keyCode == 8 ) {
if (cursor_column > 1) {
cursor_column--;
}
to_print = ' ';
cursor_increment = 0;
} else if (event.keyCode == 46 ) {
to_print = ' ';
cursor_increment = 0;
} else if (event.keyCode == 37 ) {
cursor_increment = -1;
} else if (event.keyCode == 39 ) {
cursor_increment = 1;
} else if (event.keyCode == 13 ) {
trial = 'abcdef';
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById('debug').innerHTML = xmlHttp.responseText;
}
}
xmlHttp.open( "GET", "https://wordle-backend.eckner.net/try/" + trial + '?riddle=' + puzzle, true );
xmlHttp.send( null );
cursor_increment = 0;
} else {
to_print = event.keyCode;
cursor_increment = 0;
};
if (to_print !== '') {
table
.querySelector("#row_" + row_count)
.querySelector("#column_" + cursor_column)
.innerHTML = to_print;
}
cursor_column = Math.min(5,Math.max(0,cursor_column + cursor_increment));
};
addNewRow();
createPuzzle();
document.body.addEventListener("keydown", onKeyDown);
</script>
</body>
</html>
|