blob: 758ff223d289b9d50aeeaea9702b5d6367858f75 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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("<li><img src=\"data:image/png;base64, " + msg["image"] + "\" /></li>");
}
});
});
});
|