diff options
author | Roland Reichwein <mail@reichwein.it> | 2023-01-28 15:07:14 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2023-01-28 15:07:14 +0100 |
commit | a61c702d91d7444ce0bb094ddccc70f72416500b (patch) | |
tree | 8d5a47c73666ee2b710a7a34c0c392b728bda45b /html/whiteboard.js | |
parent | f44d36b05e43cabde31aeaba5d25fded140345a1 (diff) |
Added WebAssembly for C++ implementation of Diff
Diffstat (limited to 'html/whiteboard.js')
-rw-r--r-- | html/whiteboard.js | 25 |
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(); }); |