From 8b81f0dd97139af79f692c683d4ed8a06144a1bd Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 4 Nov 2024 12:47:51 -0500 Subject: Create static webapp --- web/wizard.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 web/wizard.js (limited to 'web/wizard.js') diff --git a/web/wizard.js b/web/wizard.js new file mode 100644 index 0000000..758ff22 --- /dev/null +++ b/web/wizard.js @@ -0,0 +1,20 @@ +$(document).ready(function() { + $("#send_request").on("click", function() { + var socket = new WebSocket("ws://localhost:9002"); + + socket.addEventListener("open", (event) => { + const msg = {"cmd": "generate", "text": $("#card_text").val()}; + socket.send(JSON.stringify(msg)); + }); + + socket.addEventListener("message", (event) => { + var msg = JSON.parse(event.data); + if (msg.hasOwnProperty("msg")) { + $("#status").html(msg["msg"]); + } + if (msg.hasOwnProperty("image")) { + $("#images").prepend("
  • "); + } + }); + }); +}); -- cgit 1.4.1