diff options
| author | Arnaud Bailly <arnaud@pankzsoft.com> | 2025-11-05 14:23:03 +0100 |
|---|---|---|
| committer | Arnaud Bailly <arnaud@pankzsoft.com> | 2025-11-05 14:23:03 +0100 |
| commit | afcfa146122179dc80dd8055314b1381d152fb09 (patch) | |
| tree | 2aa2d930f89fa308d016c92c43395edaacbfcb99 /lambda-calcul/haskell | |
| parent | 71fa7dfdc873b014bf1b5b8ea648e803bff67724 (diff) | |
| download | lambda-nantes-afcfa146122179dc80dd8055314b1381d152fb09.tar.gz | |
provide session id to user so they can reconnect
Diffstat (limited to 'lambda-calcul/haskell')
| -rw-r--r-- | lambda-calcul/haskell/public/minilang.css | 6 | ||||
| -rw-r--r-- | lambda-calcul/haskell/public/repl.html | 1 | ||||
| -rw-r--r-- | lambda-calcul/haskell/public/repl.js | 6 |
3 files changed, 11 insertions, 2 deletions
diff --git a/lambda-calcul/haskell/public/minilang.css b/lambda-calcul/haskell/public/minilang.css index 0bfd397..801350d 100644 --- a/lambda-calcul/haskell/public/minilang.css +++ b/lambda-calcul/haskell/public/minilang.css @@ -168,3 +168,9 @@ code { padding: 1pt 2pt; font-family: Inconsolata, Courier; } + +div#session { + width: 80%; + margin: 0em 1em 0em 1em; + padding: .2em; +} diff --git a/lambda-calcul/haskell/public/repl.html b/lambda-calcul/haskell/public/repl.html index a6c5e78..4d95361 100644 --- a/lambda-calcul/haskell/public/repl.html +++ b/lambda-calcul/haskell/public/repl.html @@ -19,6 +19,7 @@ </div> </div> <div id="repl"> + <div id="session"></div> <div class="command"> <input id="command" class="disconnected" /> <img class="connect" id="connect" src="images/connect.png" /> diff --git a/lambda-calcul/haskell/public/repl.js b/lambda-calcul/haskell/public/repl.js index 22068f1..8f5d619 100644 --- a/lambda-calcul/haskell/public/repl.js +++ b/lambda-calcul/haskell/public/repl.js @@ -7,7 +7,7 @@ function generateRandomToken() { } function connect() { - websocket = (function() { + [websocket, token] = (function() { const host = window.location.host; const params = new URLSearchParams(window.location.search); let token = generateRandomToken(); @@ -17,7 +17,7 @@ function connect() { const protocol = window.location.protocol === "https:" ? "wss:" : "ws:"; const ws = new WebSocket(protocol + "//" + host + "/repl/" + token); ws.binaryType = "arraybuffer"; - return ws; + return [ws, token]; })(); websocket.onopen = function(e) { @@ -25,6 +25,7 @@ function connect() { document.getElementById("command").classList.add("connected"); document.getElementById("connect").src = "images/connected.png"; document.getElementById("connect").removeEventListener("click", connect); + document.getElementById("session").appendChild(document.createTextNode("Session: " + token)); }; websocket.onclose = function(e) { @@ -32,6 +33,7 @@ function connect() { document.getElementById("command").classList.add("disconnected"); document.getElementById("connect").src = "images/connect.png"; document.getElementById("connect").addEventListener("click", connect); + document.getElementById("session").children.each((node) => node.remove()); }; websocket.onmessage = function(e) { |
