v1.0 beta init
This commit is contained in:
@@ -1,4 +1,13 @@
|
||||
{{template "home/header_box.html" .}}
|
||||
|
||||
<!-- 验证码 -->
|
||||
<script type="text/x-jsrender" id="tCaptcha">
|
||||
<div class="form-group">
|
||||
<label class="control-label">{{rawMsg . "captcha"}}</label>
|
||||
<input type="text" class="form-control" id="captcha" name="captcha">
|
||||
<a id="reloadCaptcha" title="{{msg . "reloadCaptcha"}}" onclick="$('#captchaImage').attr('src', '/captcha/get?' + ((new Date()).getTime()))"><img src="/captcha/get" id="captchaImage"/></a>
|
||||
</div>
|
||||
</script>
|
||||
<section id="box" class="animated fadeInUp">
|
||||
<!--
|
||||
<div>
|
||||
@@ -11,7 +20,8 @@
|
||||
<div id="boxHeader">{{msg . "login"}}</div>
|
||||
<form>
|
||||
<div class="alert alert-danger" id="loginMsg"></div>
|
||||
<div class="form-group">
|
||||
<input id="from" type="hidden" value="{{.from}}" />
|
||||
<div class="form-group">
|
||||
<label class="control-label">{{msg . "usernameOrEmail"}}</label>
|
||||
<input type="text" class="form-control" id="email" name="email" value="{{.email}}">
|
||||
</div>
|
||||
@@ -19,6 +29,11 @@
|
||||
<label class="control-label">{{msg . "password"}}</label>
|
||||
<input type="password" class="form-control" id="pwd" name="pwd">
|
||||
</div>
|
||||
|
||||
<div id="captchaContainer">
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix">
|
||||
<a href="/findPassword" class="pull-right m-t-xs"><small>{{msg . "forgetPassword"}}</small></a>
|
||||
<button id="loginBtn" class="btn btn-success">{{msg . "login"}}</button>
|
||||
@@ -57,6 +72,12 @@
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
var needCaptcha = {{.needCaptcha}};
|
||||
|
||||
if(needCaptcha){
|
||||
$("#captchaContainer").html($("#tCaptcha").html());
|
||||
}
|
||||
|
||||
$("#email").focus();
|
||||
if($("#email").val()) {
|
||||
$("#pwd").focus();
|
||||
@@ -74,6 +95,7 @@ $(function() {
|
||||
e.preventDefault();
|
||||
var email = $("#email").val();
|
||||
var pwd = $("#pwd").val();
|
||||
var captcha = $("#captcha").val()
|
||||
if(!email) {
|
||||
showMsg("{{msg . "inputUsername"}}", "email");
|
||||
return;
|
||||
@@ -87,17 +109,27 @@ $(function() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(needCaptcha && !captcha) {
|
||||
showMsg("{{msg . "inputCaptcha"}}", "captcha");
|
||||
return;
|
||||
}
|
||||
|
||||
$("#loginBtn").html("{{msg . "logining"}}...").addClass("disabled");
|
||||
// hideMsg();
|
||||
|
||||
$.post("/doLogin", {email: email, pwd: pwd}, function(e) {
|
||||
$.post("/doLogin", {email: email, pwd: pwd, captcha: $("#captcha").val()}, function(e) {
|
||||
$("#loginBtn").html("{{msg . "login"}}").removeClass("disabled");
|
||||
if(e.Ok) {
|
||||
$("#loginBtn").html("{{msg . "loginSuccess"}}...");
|
||||
location.href = '/note';
|
||||
var from = $("#from").val() || "{{.noteUrl}}" || "/note";
|
||||
location.href = from;
|
||||
} else {
|
||||
showMsg(e.Msg, "pwd");
|
||||
if(e.Item && $.trim($("#captchaContainer").text()) == "") {
|
||||
$("#captchaContainer").html($("#tCaptcha").html());
|
||||
needCaptcha = true
|
||||
}
|
||||
|
||||
showMsg(e.Msg);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user