Sign in / Sign out links

This commit is contained in:
Mattias Erming 2014-06-15 23:45:16 +02:00
parent 0757450859
commit d805e1edb9
2 changed files with 12 additions and 4 deletions

View File

@ -19,7 +19,10 @@
<aside id="sidebar"> <aside id="sidebar">
<section> <section>
<h1>Shout</h1> <h1>Shout</h1>
<a href="#sign-in">Sign in</a> <% if (password) { %>
<a id="login" href="#sign-in">Sign in</a>
<a id="logout" href="" style="display: none;">Sign out</a>
<% } %>
</section> </section>
<div id="networks"> <div id="networks">
</div> </div>
@ -32,7 +35,7 @@
<h2>You need to sign in to continue.</h2> <h2>You need to sign in to continue.</h2>
<form id="sign-in-form" method="post"> <form id="sign-in-form" method="post">
<h3>Password:</h3> <h3>Password:</h3>
<input type="password" id="sign-in-input"> <input id="sign-in-input" type="password" autofocus>
<button type="submit" class="btn"> <button type="submit" class="btn">
Sign in Sign in
</button> </button>

View File

@ -65,8 +65,8 @@ $(function() {
function event(e, data) { function event(e, data) {
switch (e) { switch (e) {
case "auth": case "auth":
chat.add($("#networks")).empty(); $("#networks").add(chat).empty();
$("#sign-in").addClass("active").find("#sign-in-input").focus(); $("#login").trigger("click");
break; break;
case "debug": case "debug":
@ -120,6 +120,11 @@ $(function() {
.find(".chat") .find(".chat")
.sticky(); .sticky();
$("#login").hide();
$("#logout").show().on("click", function(e) {
e.stopPropagation();
});
var networks = $("#networks") var networks = $("#networks")
.html(render("networks", {networks: data.networks})) .html(render("networks", {networks: data.networks}))
.find("a") .find("a")