summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <erich.eckner.ext@bestsecret.com>2023-02-03 11:25:12 +0100
committerErich Eckner <erich.eckner.ext@bestsecret.com>2023-02-03 11:25:12 +0100
commit8ce00c5f3acbcde05581c0c60f2e7ed63beed264 (patch)
treee03dceedfe897cc3deaf89d51d5d47a79cef872c
parent2188e12f4edfcc1bbb2f7fa56616bef798dff89f (diff)
downloadwordle-frontend-8ce00c5f3acbcde05581c0c60f2e7ed63beed264.tar.xz
make trial reactive
-rw-r--r--src/App.vue11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/App.vue b/src/App.vue
index 28f621a..3ed7441 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,7 +1,7 @@
<template>
<h1>Wördle</h1>
<button @click="createPuzzle">new Puzzle</button>
- <div>{{ trial }}</div>
+ <div>{{ current.trial }}</div>
<Keyboard
:add-letter="addLetter"
:navigate="navigate"
@@ -11,9 +11,10 @@
<script setup lang="ts">
import Keyboard from "@/components/Keyboard.vue";
+import { reactive } from "vue";
let riddle: string = "";
-let trial: string = "";
+let current = reactive({ trial: "" });
let cursorPosition: number = 0;
function createPuzzle() {
@@ -21,7 +22,7 @@ function createPuzzle() {
request.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
riddle = JSON.parse(request.responseText).riddle;
- trial = "";
+ current.trial = "";
cursorPosition = 0;
}
};
@@ -30,12 +31,12 @@ function createPuzzle() {
}
function addLetter(letter: string) {
- trial = trial + letter;
+ current.trial = current.trial + letter;
console.log("letter " + letter + " added");
}
function removeLetter() {
- trial = trial.substring(0, -1);
+ current.trial = current.trial.substring(0, -1);
}
function navigate(direction: "left" | "right" | "first" | "last") {