diff --git a/www/index.html b/www/index.html index a3674d6..bf1a99e 100644 --- a/www/index.html +++ b/www/index.html @@ -22,7 +22,6 @@
-

diff --git a/www/room.js b/www/room.js index a95a1b0..5e3f9d1 100644 --- a/www/room.js +++ b/www/room.js @@ -10,7 +10,7 @@ function Room(domElem, lib) { var playersList = domElem.getElementsByClassName('players')[0]; domElem.addEventListener('submit', function(e) { e.preventDefault(); - lib.send({tag: "Invitation", to: parseInt(domElem.guest.value)}) + lib.send({tag: "Invitation", to: session.selected}) }); return { @@ -63,6 +63,8 @@ function Room(domElem, lib) { var player = players[key]; if(key == session.key) { off(); + } else if(key == session.selected) { + reset(); } if(player != undefined) { playersList.removeChild(player.dom); @@ -85,25 +87,29 @@ function Room(domElem, lib) { function off() { domElem.className = "off"; session.loggedIn = false; + reset(); } function select(key) { - if(key == domElem.guest.value) { - unselect(players[key].dom); + if(key === session.selected) { + unselect(key); } else { - if(session.selected) { - unselect(session.selected); - } + reset(); players[key].dom.className = "selected"; - session.selected = players[key].dom; - domElem.guest.value = key; + session.selected = key; domElem.invite.disabled = false; } } - function unselect(dom) { - dom.className = ""; - domElem.guest.value = ""; + function reset() { + if(session.selected) { + unselect(session.selected); + } + } + + function unselect(key) { + players[key].dom.className = ""; + session.selected = null; domElem.invite.disabled = true; } }