blob: 395c3adbfc9dafa551b540cc408f67147943d0e9 (
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
|
<template>
<h1>Wördle</h1>
<button @click="createPuzzle">new Puzzle</button>
<Trials :length="length" :currentTrial="current.trial" />
<Keyboard
:add-letter="addLetter"
:remove-letter="removeLetter"
:submit="submit"
/>
</template>
<script setup lang="ts">
import Keyboard from "@/components/Keyboard.vue";
import { reactive } from "vue";
import Trials from "@/components/Trials.vue";
let riddle: string = "";
let current = reactive({ trial: "" });
let cursorPosition: number = 0;
let props = defineProps<{ length: number }>();
function createPuzzle() {
const request = new XMLHttpRequest();
request.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
riddle = JSON.parse(request.responseText).riddle;
current.trial = "";
cursorPosition = 0;
}
};
request.open("GET", "http://127.0.0.1:8889/create", true);
request.send();
}
function addLetter(letter: string) {
if (current.trial.length < props.length) {
current.trial = current.trial + letter;
}
}
function removeLetter() {
current.trial = current.trial.substring(0, current.trial.length - 1);
}
function submit() {
if (current.trial.length === props.length) {
/* var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
response = JSON.parse(xmlHttp.responseText);
// document.getElementById('debug').innerHTML = xmlHttp.responseText;
if (!response.is_in_dictionary) {
table.setAttribute('bgcolor', '#ff8080');
cursor_column = 1;
updateCursorDisplay();
return;
}
if (response.is_solved) {
document.body.setAttribute('bgcolor', '#40ff40');
cursor_column = 1;
updateCursorDisplay();
return;
}
for (i = 1; i <= 5; i++) {
table
.querySelector("#row_" + row_count)
.querySelector("#column_" + i)
.className = colors[response.colors[i - 1]];
}
colorizeKeyboard();
addNewRow();
}
}
xmlHttp.open("GET", "https://wordle-backend.eckner.net/try/" + trial + '?riddle=' + puzzle, true);
xmlHttp.send(null); */
}
}
</script>
<style scoped></style>
|