summary refs log tree commit diff stats
path: root/web/wizard.js
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-11-04 12:47:51 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2024-11-04 12:47:51 -0500
commit8b81f0dd97139af79f692c683d4ed8a06144a1bd (patch)
tree86fb0de42baa6e3a29236a95de815f8790e4c17a /web/wizard.js
parent8375f92802d3aa7667bfc6f22f6d2a72361c9808 (diff)
downloadwizard-8b81f0dd97139af79f692c683d4ed8a06144a1bd.tar.gz
wizard-8b81f0dd97139af79f692c683d4ed8a06144a1bd.tar.bz2
wizard-8b81f0dd97139af79f692c683d4ed8a06144a1bd.zip
Create static webapp
Diffstat (limited to 'web/wizard.js')
-rw-r--r--web/wizard.js20
1 files changed, 20 insertions, 0 deletions
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 @@
1$(document).ready(function() {
2 $("#send_request").on("click", function() {
3 var socket = new WebSocket("ws://localhost:9002");
4
5 socket.addEventListener("open", (event) => {
6 const msg = {"cmd": "generate", "text": $("#card_text").val()};
7 socket.send(JSON.stringify(msg));
8 });
9
10 socket.addEventListener("message", (event) => {
11 var msg = JSON.parse(event.data);
12 if (msg.hasOwnProperty("msg")) {
13 $("#status").html(msg["msg"]);
14 }
15 if (msg.hasOwnProperty("image")) {
16 $("#images").prepend("<li><img src=\"data:image/png;base64, " + msg["image"] + "\" /></li>");
17 }
18 });
19 });
20});