summary refs log tree commit diff stats
path: root/web/wizard.js
diff options
context:
space:
mode:
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});