From a61c702d91d7444ce0bb094ddccc70f72416500b Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 28 Jan 2023 15:07:14 +0100 Subject: Added WebAssembly for C++ implementation of Diff --- html/whiteboard.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'html/whiteboard.js') 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("getversion"); websocket.send("getfile" + get_id() + ""); - 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(); }); -- cgit v1.2.3