wide/views/login.html

119 lines
4.2 KiB
HTML
Raw Normal View History

2014-10-24 07:41:23 +04:00
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
2014-12-11 06:40:30 +03:00
<title>{{.i18n.wide}} - {{.i18n.wide_title}}</title>
2014-10-24 07:41:23 +04:00
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/base.css?{{.conf.StaticResourceVersion}}">
2014-10-30 11:25:57 +03:00
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/sign.css?{{.conf.StaticResourceVersion}}">
2014-10-24 07:41:23 +04:00
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
</head>
<body>
<div class="header">
<div class="wrapper fn-clear">
<a href="/login">
<img src="{{.conf.StaticServer}}/static/images/wide-logo.png"
class="logo"/></a>
<ul class="fn-right">
<li><a href="https://github.com/b3log/wide" target="_blank">GitHub</a></li>
<li><a href="https://www.gitbook.io/book/88250/wide-user-guide" target="_blank">{{.i18n.help}}</a></li>
<li><a href="https://github.com/b3log/wide/issues/new" target="_blank">{{.i18n.report_issues}}</a></li>
2014-12-19 10:44:49 +03:00
<li><button class="btn btn-red" onclick="window.open('http://b3log.org/services')">{{.i18n.pricing}}</button></li>
2014-12-19 12:44:50 +03:00
<li><button class="btn" onclick="window.location.href = '/signup'">{{.i18n.sign_up}}</button></li>
2014-10-24 07:41:23 +04:00
</ul>
</div>
</div>
<div class="content">
<div class="wrapper fn-clear">
<div class="fn-left">
<h2>Hello, 世界</h2>
<h3>Coding with Go on the Wide way.</h3>
</div>
<div class="form fn-right">
<div id="msg" class="fn-none"></div>
<input id="username" placeholder="Username"/><br/>
<input id="password" type="password" placeholder="Password"/><br/>
2014-12-19 10:44:49 +03:00
<button id="loginBtn" class="btn-white btn">{{.i18n.login}}</button>
2014-10-24 07:41:23 +04:00
</div>
</div>
</div>
<div class="footer">
<div class="wrapper">
Ver {{.ver}}, &copy; 2014 <a href="http://b3log.org" target="_blank">B3LOG.ORG</a>
</div>
</div>
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
(function () {
var contentH = $(window).height() - $(".footer").height() - $(".header").height() - 18;
$(".content").height(contentH)
.css("padding-top", (contentH - $(".content .fn-left").height()) / 2 + "px");
var login = function () {
2014-12-15 06:32:33 +03:00
var username = $.trim($("#username").val());
var password = $.trim($("#password").val());
if (username === "") {
2014-10-30 11:25:57 +03:00
$("#msg").text("{{.i18n.login_error}}").show();
$("#username").focus();
return false;
2014-12-15 06:32:33 +03:00
} else if (password === "") {
2014-10-30 11:25:57 +03:00
$("#msg").text("{{.i18n.login_error}}").show();
$("#password").focus();
return false;
}
2014-10-24 07:41:23 +04:00
var request = {
2014-12-15 06:32:33 +03:00
username: username,
password: password
2014-10-24 07:41:23 +04:00
};
2014-12-15 06:32:33 +03:00
2014-10-24 07:41:23 +04:00
$.ajax({
type: 'POST',
url: '/login',
data: JSON.stringify(request),
dataType: "json",
success: function (data) {
if (!data.succ) {
2014-10-27 18:58:10 +03:00
$("#msg").text('{{.i18n.login_error}}').show();
2014-10-24 07:41:23 +04:00
return;
}
window.location.href = "/";
}
});
};
$("#username").keydown(function (event) {
if (event.which === 13) {
if ($.trim($(this).val()) === "") {
2014-10-27 18:58:10 +03:00
$("#msg").text("{{.i18n.login_error}}").show();
2014-10-24 07:41:23 +04:00
} else {
$("#password").focus();
}
} else {
$("#msg").hide();
}
}).focus();
$("#password").keydown(function (event) {
if (event.which === 13) {
if ($.trim($(this).val()) === "") {
2014-10-27 18:58:10 +03:00
$("#msg").text("{{.i18n.login_error}}").show();
2014-10-24 07:41:23 +04:00
} else {
login();
}
} else {
$("#msg").hide();
}
});
2014-12-15 06:32:33 +03:00
$("#loginBtn").click(function () {
login();
});
2014-10-24 07:41:23 +04:00
})();
</script>
</body>
</html>