wide/views/sign_up.html

165 lines
7.1 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>{{.i18n.wide}} - {{.i18n.sign_up}}</title>
2014-10-30 11:25:57 +03:00
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/base.css?{{.conf.StaticResourceVersion}}">
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/sign.css?{{.conf.StaticResourceVersion}}">
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
</head>
<body>
2014-10-30 11:25:57 +03:00
<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>
<li><button class="btn" onclick="window.open('/login')">{{.i18n.sign_up}}</button></li>
2014-10-30 11:25:57 +03:00
</ul>
</div>
</div>
<div class="content">
<div class="wrapper fn-clear">
<div class="fn-left">
<h2>Join Wide</h2>
<h3>Coding with Go on the Wide way.</h3>
</div>
<div class="form fn-right sign-up">
<div id="msg" class="fn-none"></div>
<div class="dir">
Workspace
2014-10-30 13:21:44 +03:00
<div id="dir" data-dir="{{.dir}}{{.pathSeparator}}">{{.dir}}{{.pathSeparator}}</div>
2014-10-30 11:25:57 +03:00
</div>
<input id="username" placeholder="Username"/><br/>
2014-12-08 09:02:39 +03:00
<input id="email" placeholder="Email"/><br/>
2014-10-30 11:25:57 +03:00
<input id="password" type="password" placeholder="Password"/><br/>
<input id="confirmPassword" type="password" placeholder="Confirm your password"/>
2014-12-19 10:44:49 +03:00
<button id="signUpBtn" class="btn">{{.i18n.sign_up}}</button>
2014-10-30 11:25:57 +03: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>
(function () {
var contentH = $(window).height() - $(".footer").height() - $(".header").height() - 18;
$(".content").height(contentH)
.css("padding-top", (contentH - $(".content .fn-left").height()) / 2 + "px");
var signUp = function () {
if ($.trim($("#username").val()) === ""
|| !/^\w+$/.test($("#username").val())
|| $.trim($("#username").val()).length > 16) {
$("#msg").text("{{.i18n.user_name_ruler}}").show();
$("#username").focus();
return false;
2014-12-08 09:02:39 +03:00
} else if (!/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test($("#email").val())) {
$("#msg").text("{{.i18n.invalid_email}}").show();
$("#email").focus();
return false;
2014-10-30 11:25:57 +03:00
} else if ($.trim($("#password").val()) === "") {
$("#msg").text("{{.i18n.sing_up_error}}").show();
$("#password").focus();
return false;
} else if ($("#confirmPassword").val() !== $("#password").val()) {
$("#msg").text("{{.i18n.password_no_match}}").show();
$("#confirmPassword").focus();
return false;
}
var request = {
username: $("#username").val(),
2014-12-08 09:02:39 +03:00
password: $("#password").val(),
email: $("#email").val()
2014-10-30 11:25:57 +03:00
};
$.ajax({
type: 'POST',
url: '/signup',
data: JSON.stringify(request),
dataType: "json",
success: function (data) {
if (!data.succ) {
$("#msg").text(data.msg).show();
return;
}
window.location.href = "/";
}
});
};
$("#username").keyup(function (event) {
if (event.which === 13) {
if ($.trim($(this).val()) === ""
|| !/^\w+$/.test($(this).val())
|| $.trim($(this).val()).length > 16) {
$("#msg").text("{{.i18n.user_name_ruler}}").show();
} else {
2014-12-08 09:02:39 +03:00
$("#email").focus();
2014-10-30 11:25:57 +03:00
$("#msg").hide();
}
} else {
if ($.trim($(this).val()) === ""
|| !/^\w+$/.test($(this).val())
|| $.trim($(this).val()).length > 16) {
$("#msg").text("{{.i18n.user_name_ruler}}").show();
} else {
$("#msg").hide();
}
$("#dir").html($("#dir").data('dir') + $(this).val());
}
}).focus();
2014-12-08 09:02:39 +03:00
$("#email").keydown(function (event) {
if (event.which === 13) {
if ($.trim($(this).val()) === "") {
$("#msg").text("{{.i18n.invalid_email}}").show();
} else {
$("#password").focus();
}
} else {
$("#msg").hide();
}
});
2014-10-30 11:25:57 +03:00
$("#password").keydown(function (event) {
if (event.which === 13) {
if ($.trim($(this).val()) === "") {
$("#msg").text("{{.i18n.sing_up_error}}").show();
} else {
$("#confirmPassword").focus();
}
} else {
$("#msg").hide();
}
});
$("#confirmPassword").keydown(function (event) {
if (event.which === 13) {
if ($(this).val() !== $("#password").val()) {
$("#msg").text("{{.i18n.password_no_match}}").show();
} else {
signUp();
}
} else {
$("#msg").hide();
}
});
2014-11-21 09:39:56 +03:00
$("#signUpBtn").click(function () {
signUp();
});
2014-10-30 11:25:57 +03:00
})();
</script>
</body>
</html>