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 | |
parent | f44d36b05e43cabde31aeaba5d25fded140345a1 (diff) |
Added WebAssembly for C++ implementation of Diff
Diffstat (limited to 'html')
-rw-r--r-- | html/index.html | 3 | ||||
-rw-r--r-- | html/whiteboard.js | 25 |
2 files changed, 23 insertions, 5 deletions
diff --git a/html/index.html b/html/index.html index 4d1fb2a..decc540 100644 --- a/html/index.html +++ b/html/index.html @@ -7,6 +7,7 @@ <title>Reichwein Whiteboard</title> <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/> <link rel="stylesheet" type="text/css" href="whiteboard.css"/> + <script src="libwhiteboard.js"></script> <script src="whiteboard.js"></script> </head> <body onload="init();"> @@ -20,7 +21,7 @@ <br/> <button class="button" onclick="on_new_page();">New page</button> <button class="button" onclick="on_qrcode_click();">QR code</button> - <span id="connecting">Connecting...</span> + <span id="status">Starting up...</span> <button class="buttonred" id="reconnect" onclick="on_reconnect_click();" hidden>Reconnect</button> <br/> <br/> 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(); }); |