From 801547bfa8bc1ae3949027e46045e4693454f65f Mon Sep 17 00:00:00 2001
From: Erich Eckner <erich.eckner.ext@bestsecret.com>
Date: Fri, 3 Feb 2023 12:36:32 +0100
Subject: remove duplicate key from keyboard ^^

---
 src/Wordle.vue | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 src/Wordle.vue

(limited to 'src/Wordle.vue')

diff --git a/src/Wordle.vue b/src/Wordle.vue
new file mode 100644
index 0000000..3ed7441
--- /dev/null
+++ b/src/Wordle.vue
@@ -0,0 +1,60 @@
+<template>
+  <h1>Wördle</h1>
+  <button @click="createPuzzle">new Puzzle</button>
+  <div>{{ current.trial }}</div>
+  <Keyboard
+    :add-letter="addLetter"
+    :navigate="navigate"
+    :remove-letter="removeLetter"
+  />
+</template>
+
+<script setup lang="ts">
+import Keyboard from "@/components/Keyboard.vue";
+import { reactive } from "vue";
+
+let riddle: string = "";
+let current = reactive({ trial: "" });
+let cursorPosition: number = 0;
+
+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) {
+  current.trial = current.trial + letter;
+  console.log("letter " + letter + " added");
+}
+
+function removeLetter() {
+  current.trial = current.trial.substring(0, -1);
+}
+
+function navigate(direction: "left" | "right" | "first" | "last") {
+  switch (direction) {
+    case "left":
+      cursorPosition -= 1;
+      break;
+    case "right":
+      cursorPosition += 1;
+      break;
+    case "first":
+      cursorPosition = 0;
+      break;
+    case "last":
+      cursorPosition = 4;
+      break;
+  }
+}
+</script>
+
+<style scoped></style>
-- 
cgit v1.2.3-70-g09d2

