diff options
Diffstat (limited to 'templates/main/ws_test_rst.html')
-rw-r--r-- | templates/main/ws_test_rst.html | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/templates/main/ws_test_rst.html b/templates/main/ws_test_rst.html new file mode 100644 index 00000000..a0bae79b --- /dev/null +++ b/templates/main/ws_test_rst.html @@ -0,0 +1,39 @@ +{% extends "main/base.html" %} +{% block title %}WS Test{% endblock %} +{% block og_title %}WS Test{% endblock %} +{% block og_description %}A test page for our Websockets implementation{% endblock %} +{% block content %} + <div class="uk-container uk-section"> + <h1>Enter some text to test.</h1> + + <textarea title="RST Input" id="rst"></textarea> + <input type="button" value="Submit" id="submit-button" /> + + <br /> + + <div id="output"></div> + + <script type="application/javascript"> + let ws = new WebSocket("wss://api.{{ server_name }}/ws/rst"); + + ws.onopen = function(event) { + console.log("WS opened! Use send() to send a message."); + }; + + ws.onmessage = function (event) { + document.getElementById("output").innerHTML = event.data; + }; + + function send(text) { + console.log("-> " + text); + ws.send(text); + } + + document.getElementById("submit-button").onclick = function() { + send( + document.getElementById("rst").value + ); + } + </script> + </div> +{% endblock %} |