summaryrefslogtreecommitdiff
path: root/cmd/dolmetschctld/web-static/socket.html
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2019-02-13 18:10:54 +0100
committerChristian Pointner <equinox@spreadspace.org>2019-02-13 18:10:54 +0100
commit6fc90db16480abee1b6aa3ee4352793054f99714 (patch)
tree5f43b8018e33457b1f556097c16704930d12255c /cmd/dolmetschctld/web-static/socket.html
parentadded web handler for language (diff)
added basic web socket interface
Diffstat (limited to 'cmd/dolmetschctld/web-static/socket.html')
-rw-r--r--cmd/dolmetschctld/web-static/socket.html66
1 files changed, 66 insertions, 0 deletions
diff --git a/cmd/dolmetschctld/web-static/socket.html b/cmd/dolmetschctld/web-static/socket.html
new file mode 100644
index 0000000..d286cdc
--- /dev/null
+++ b/cmd/dolmetschctld/web-static/socket.html
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <title>dolmetschctl Websocket Testclient</title>
+ <meta charset="utf-8">
+ <style type="text/css">
+ body {
+ background-color: #555;
+ }
+
+ div.data {
+ background-color: white;
+ border: 1px solid;
+ padding: 1em;
+ font-family: monospace;
+ margin-top: 1em;
+ margin-bottom: 1em;
+ }
+
+ td {
+ text-align: right;
+ }
+ </style>
+ <script src="jquery.min.js"></script>
+ <script type="text/javascript">
+ function State(req) {
+ this.req = req
+ this.sock = new WebSocket("ws://localhost:8234/api/v1/socket");
+ this.sock_onmessage = function (event) {
+ $('#statemsg').text(event.data);
+ $('#buttonstate').removeAttr('disabled','disabled');
+ }
+ this.sock.onmessage = this.sock_onmessage.bind(this);
+
+ this.sock_onopen = function() {
+ this.sock.send(JSON.stringify(this.req));
+ $('#buttonstate').attr('disabled','disabled')
+ }
+ this.sock.onopen = this.sock_onopen.bind(this);
+ }
+
+ var s;
+
+ function state() {
+ req = { command: "state" };
+ s = new State(req);
+ }
+
+
+ function init() {
+ $('#buttonstate').removeAttr('disabled','disabled');
+ }
+
+ </script>
+ </head>
+ <body onload="init()">
+
+ <h1>dolmetschctl Websocket Testclient</h1>
+
+ <div>
+ <button id="buttonstate" onclick="state()">get state</button>
+ <div id="statemsg" class="data"></div>
+ </div>
+
+ </body>
+</html>