2014-09-21 16:31:36 +04:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<title>{{.i18n.wide}} - {{.i18n.login}}</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<input id="username" placeholder="{{.i18n.username}}"/>
|
2014-09-21 17:49:13 +04:00
|
|
|
<input id="password" type="password" placeholder="{{.i18n.password}}..."/>
|
2014-09-21 16:31:36 +04:00
|
|
|
<button onclick="login()">{{.i18n.login}}</button>
|
|
|
|
<div id="msg"></div>
|
2014-09-21 17:49:13 +04:00
|
|
|
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/jquery-2.1.1.min.js"></script>
|
2014-09-21 16:31:36 +04:00
|
|
|
<script type="text/javascript">
|
2014-09-21 17:49:13 +04:00
|
|
|
(function () {
|
|
|
|
$("#username").keydown(function (event) {
|
|
|
|
if (event.which === 13) {
|
|
|
|
if ($.trim($(this).val()) === "") {
|
|
|
|
$("#msg").text("{{.i18n.login_failed}}");
|
|
|
|
} else {
|
|
|
|
$("#password").focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#msg").text('');
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$("#password").keydown(function (event) {
|
|
|
|
if (event.which === 13) {
|
|
|
|
if ($.trim($(this).val()) === "") {
|
|
|
|
$("#msg").text("{{.i18n.login_failed}}");
|
|
|
|
} else {
|
|
|
|
login();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#msg").text('');
|
|
|
|
});
|
|
|
|
})();
|
|
|
|
|
|
|
|
var login = function () {
|
2014-09-21 16:31:36 +04:00
|
|
|
var request = {
|
|
|
|
username: $("#username").val(),
|
2014-09-21 17:49:13 +04:00
|
|
|
password: $("#password").val()
|
2014-09-21 16:31:36 +04:00
|
|
|
};
|
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url: '/login',
|
|
|
|
data: JSON.stringify(request),
|
|
|
|
dataType: "json",
|
|
|
|
success: function (data) {
|
2014-09-21 17:49:13 +04:00
|
|
|
if (!data.succ) {
|
|
|
|
$("#msg").text('{{.i18n.login_failed}}');
|
2014-09-21 16:31:36 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
window.location.href = "/";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|