105 lines
4.0 KiB
HTML
105 lines
4.0 KiB
HTML
<!DOCTYPE>
|
|
<html>
|
|
<head>
|
|
<title>BookSystem 登录</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<link rel="stylesheet" href="jquery-ui.css">
|
|
<link rel="stylesheet" href="jquery-ui.structure.css">
|
|
<link rel="stylesheet" href="jquery-ui.theme.css">
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="jquery-ui.js"></script>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="login">
|
|
<div class="error"></div>
|
|
<p>BookSystem | Sign In </p>
|
|
<div id="js_login_info_panel">
|
|
<p id="js_login_info"></p>
|
|
</div>
|
|
<div id="login_panel" class="login_panel">
|
|
<label for="username">Username</label>
|
|
<input type="text" id="username" name="username" />
|
|
<label for="password">Password</label>
|
|
<input type="password" id="password" name="password" />
|
|
<button id="submit">Sign In</button>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
$("button").button();
|
|
|
|
/// Check Login
|
|
$.post("/cgi-bin/booksys/checkLogin",{},function(data){
|
|
console.log("CheckLogin Ajax Success");
|
|
if(data.success==1)
|
|
{
|
|
console.log("logged in. redirecting...");
|
|
location.href=data.next_url;
|
|
}
|
|
else
|
|
{
|
|
console.log("Check Failed, need login");
|
|
}
|
|
}).fail(function(err){
|
|
console.log("Failed to check login. err:",err);
|
|
});
|
|
|
|
//functions start
|
|
function createHighlight(obj){
|
|
obj.addClass('ui-state-highlight ui-corner-all');
|
|
obj.html('<p><span class="ui-icon ui-icon-alert" style="float: left; margin-right:.3em;"></span>'+obj.html()+'</p>');
|
|
}
|
|
|
|
function createError(obj){
|
|
obj.addClass('ui-state-error ui-corner-all');
|
|
obj.html('<p><span class="ui-icon ui-icon-alert" style="float: left; margin-right:.3em;"></span>'+obj.html()+'</p>');
|
|
}
|
|
|
|
$(".error").fadeTo(0,0).text("No Error");
|
|
createError($(".error"));
|
|
|
|
$("#submit").click(function(){
|
|
$("#submit").hide("");
|
|
$(".error").fadeTo(0,0).text("Submitting...");
|
|
createHighlight($(".error"));
|
|
$(".error").fadeTo(0,1);
|
|
|
|
console.log("Clicked");
|
|
console.log("Begin Post");
|
|
$.post("/cgi-bin/booksys/doLogin",
|
|
{
|
|
username:$("#username").val(),
|
|
password:$("#password").val()
|
|
},function(data){
|
|
console.log("Post Done!");
|
|
console.log(data);
|
|
if(data.success==1||data.success==2) {
|
|
// Success
|
|
location.href=data.next_url;
|
|
} else {
|
|
// Fail
|
|
console.log("Login Failure.");
|
|
$(".error").text("Login Failure.");
|
|
createError($(".error"));
|
|
$(".error").fadeTo(0,1).delay(500).fadeTo(500,0,function(){
|
|
$("#submit").show("");
|
|
});
|
|
}
|
|
},"json")
|
|
.fail(function(err){
|
|
console.log("Failed to post");
|
|
$(".error").text("Failed to Login");
|
|
createError($(".error"));
|
|
$(".error").fadeTo(0,1).delay(500).fadeTo(500,0,function(){
|
|
$("#submit").show("");
|
|
});
|
|
})
|
|
.always(function(){
|
|
console.log("Post Finished");
|
|
});
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html> |