summaryrefslogtreecommitdiffhomepage
path: root/html/whiteboard.js
diff options
context:
space:
mode:
Diffstat (limited to 'html/whiteboard.js')
-rw-r--r--html/whiteboard.js25
1 files changed, 21 insertions, 4 deletions
diff --git a/html/whiteboard.js b/html/whiteboard.js
index 83601b8..aef4391 100644
--- a/html/whiteboard.js
+++ b/html/whiteboard.js
@@ -8,6 +8,17 @@ var revision;
// helper for breaking feedback loop
var caretpos = 0;
+function set_status(message)
+{
+ if (message == "") {
+ document.getElementById("status").textContent = message;
+ document.getElementById("status").style.display = 'block';
+ } else {
+ document.getElementById("status").textContent = "";
+ document.getElementById("status").style.display = 'none';
+ }
+}
+
function showQRWindow()
{
document.getElementById("qrwindow").style.display = 'block';
@@ -103,7 +114,7 @@ function handleSelection() {
function connect_websocket() {
document.getElementById("reconnect").style.display = 'none';
- document.getElementById("connecting").style.display = 'block';
+ set_status("Connecting...");
var newlocation = location.origin + location.pathname;
newlocation = newlocation.replace(/^http/, 'ws');
if (newlocation.slice(-1) != "/")
@@ -123,7 +134,7 @@ function connect_websocket() {
websocket.send("<request><command>getversion</command></request>");
websocket.send("<request><command>getfile</command><id>" + get_id() + "</id></request>");
- document.getElementById("connecting").style.display = 'none';
+ set_status(""); // ok
};
websocket.onclose = function(e) {
@@ -135,15 +146,21 @@ function connect_websocket() {
alert("Error: Server connection closed.");
document.getElementById("reconnect").style.display = 'inline';
};
-
}
+// button in html
function on_reconnect_click() {
connect_websocket();
}
function init_board() {
- connect_websocket();
+ set_status("Loading...");
+ Module.onRuntimeInitialized = () => {
+ connect_websocket();
+ };
+ //Module.onRuntimeInitialized = () => { alert("DEBUG: " + Module._getnum(1) + " " + UTF8ToString(Module._getstring(allocateUTF8("abc"))));
+ //_free(allocateUTF8("abc"));
+ //};
var board = document.getElementById("board");
board.addEventListener("input", function() {on_input(); });