forked from IntelliHome/Google-at-Home
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WebUI IntelliHome#7] Added a layout for login form
- Loading branch information
skullbocks
committed
Jul 13, 2014
1 parent
43bc101
commit a215a66
Showing
3 changed files
with
201 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
$(function(){ | ||
var userField = $("input[name=username]"); | ||
var passwordField = $("input[name=password]"); | ||
$('button[type="submit"]').click(function(e) { | ||
e.preventDefault(); | ||
if (userField.val() == "") { | ||
//remove success mesage replaced with error message | ||
$("#output").removeClass(' alert alert-success'); | ||
$("#output").addClass("alert alert-danger animated fadeInUp").html("Did you forget to enter username?"); | ||
} else if (passwordField.val() == "") { | ||
//remove success mesage replaced with error message | ||
$("#output").removeClass(' alert alert-success'); | ||
$("#output").addClass("alert alert-danger animated fadeInUp").html("Did you forget to enter password?"); | ||
} else { | ||
var loginRequest = $.ajax({ | ||
type: "POST", | ||
url : '/auth', | ||
data : {username : userField.val(), password : passwordField.val()}, | ||
dataType : 'json', //gives back a JSON object | ||
}); | ||
loginRequest.done(function( msg ) { | ||
//Display a message for login | ||
/* | ||
$("#output").addClass("alert alert-success animated fadeInUp").html("Welcome back " + "<span style='text-transform:uppercase'>" + userField.val() + "</span>"); | ||
$("#output").removeClass(' alert-danger'); | ||
$("input").css({ | ||
"height":"0", | ||
"padding":"0", | ||
"margin":"0", | ||
"opacity":"0" | ||
}); | ||
*/ | ||
//Change button | ||
/* | ||
$('button[type="submit"]').html("continue") | ||
.removeClass("btn-info") | ||
.addClass("btn-default").click(function(){ | ||
$("input").css({ | ||
"height":"auto", | ||
"padding":"10px", | ||
"opacity":"1" | ||
}).val(""); | ||
}); | ||
*/ | ||
|
||
//Display user avatar | ||
/* | ||
$(".avatar").css({ | ||
"background-image": "url('http://api.randomuser.me/0.3.2/portraits/women/35.jpg')" | ||
}); | ||
*/ | ||
}); | ||
loginRequest.fail(function() { | ||
//remove success mesage replaced with error message | ||
$("#output").removeClass(' alert alert-success'); | ||
$("#output").addClass("alert alert-danger animated fadeInUp").html("Server have some trouble!"); | ||
}); | ||
|
||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div class="container"> | ||
<div class="login-container"> | ||
<div id="output"></div> | ||
<div class="avatar"></div> | ||
<div class="form-box"> | ||
<form action="" method=""> | ||
%= text_field 'username', type => 'text', required => "true", class=> "form-control", placeholder=> "username" | ||
%= password_field 'password', required => "true", class=> "form-control" , placeholder=>"password" | ||
%= submit_button 'Login', class => 'btn btn-info btn-block login' | ||
</form> | ||
</div> | ||
</div> | ||
</div> |