Skip to content

Commit

Permalink
Add link to invite friends to room
Browse files Browse the repository at this point in the history
  • Loading branch information
duxovni authored and cryslith committed Sep 13, 2019
1 parent 2e547c0 commit 3cba6e4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ window.onload = function() {
socket.onmessage = receiveServer_raw;
socket.onclose = socketClosed;
keepalive_intervalID = setInterval(sendKeepalive, 10000);
document.forms["signin"]["room"].value = location.hash.substring(1);
rsa.generateKeyPair({bits: TUNNEL_BITS, e: PUBLIC_EXPONENT, workers: -1},
function(e, kp) {
hide("keygen");
Expand Down Expand Up @@ -62,11 +63,13 @@ function receiveServer(data) {
} else if (data["room"] !== room) {
console.log("server tried to assign us unrequested room: " + data["room"]);
} else {
location.hash = room;
name = data["name"];
newUser(name, keypair.publicKey.n, true);
hide("signin");
showMessage("room", room, msgcolors.INFO);
showMessage("name", "Signed in as " + name, msgcolors.INFO);
showInvite();
show("users");
}
break;
Expand Down Expand Up @@ -664,6 +667,17 @@ function disable(id) {
document.getElementById(id).disabled = true;
}

function showInvite() {
if (location.protocol == "file:") {
return;
}

var link = document.getElementById("inviteLink");
link.href = location.href;
link.textContent = location.href;
show("invite");
}


// Crypto wrappers

Expand Down
3 changes: 3 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
<h3 class="six columns" id="room" style="display:none;"></h3>
<h3 class="six columns" id="name" style="display:none;"></h3>
</div>
<div id="invite" style="display:none;">
To invite friends, send them this link: <a href="" id="inviteLink"></a>
</div>
<div id="users" style="display:none;">
<h5>Users Online</h5>
<form name="selections" onsubmit="sendSelections()" action="javascript:void(0);">
Expand Down

0 comments on commit 3cba6e4

Please sign in to comment.