2013-12-26 03:04:26 +00:00
doctype html
2013-12-12 20:48:23 +00:00
html(lang="en")
head
include head
2016-07-07 08:11:56 +00:00
+head()
2013-12-12 20:48:23 +00:00
body
#wrap
nav.navbar.navbar-inverse.navbar-fixed-top(role="navigation")
include nav
2016-07-07 08:11:56 +00:00
+navheader()
2013-12-12 20:48:23 +00:00
#nav-collapsible.collapse.navbar-collapse
ul.nav.navbar-nav
2016-07-07 08:11:56 +00:00
+navdefaultlinks("/register")
2013-12-12 20:48:23 +00:00
if loggedIn
2016-07-07 08:11:56 +00:00
+navlogoutform("/register")
2013-12-12 20:48:23 +00:00
section#mainpage.container
if loggedIn
.col-lg-6.col-lg-offset-3.col-md-6.col-md-offset-3
.alert.alert-danger.messagebox.center
strong Already logged in
p.
You are already logged in. If you intend to register a new account, please <a href="/logout?redirect=/register">Logout</a> first.
// TODO Link to My Account page
else if !registered
.col-lg-6.col-lg-offset-3.col-md-6.col-md-offset-3
if registerError
.alert.alert-danger.messagebox.center
strong Registration Failed
p= registerError
h2 Register
form(role="form", action="/register", method="post", onsubmit="return verify()")
2015-02-23 00:15:22 +00:00
input(type="hidden", name="_csrf", value=csrfToken)
2013-12-12 20:48:23 +00:00
.form-group
label.control-label(for="username") Username
2017-06-05 05:04:39 +00:00
input#username.form-control(type="text", name="name", onkeyup="checkUsername()", maxlength="20")
2013-12-12 20:48:23 +00:00
.form-group
label.control-label(for="password") Password
input#password.form-control(type="password", name="password", onkeyup="checkPasswords()")
.form-group
label.control-label(for="password_confirm") Confirm Password
input#password_confirm.form-control(type="password", onkeyup="checkPasswords()")
.form-group
label.control-label(for="email") Email (optional)
input#email.form-control(type="email", name="email")
2017-03-12 01:22:31 +00:00
p
| Providing an email address is optional and will allow you to recover your account via email if you forget your password.
strong If you do not provide an email address, you will not be able to recover a lost account!
2013-12-12 20:48:23 +00:00
button#registerbtn.btn.btn-success.btn-block(type="submit") Register
else
.col-lg-6.col-lg-offset-3.col-md-6.col-md-offset-3
.alert.alert-success.messagebox.center
strong Registration Successful
p Thanks for registering, #{registerName}! Now you can <a href="/login">Login</a> to use your account.
include footer
2016-07-07 08:11:56 +00:00
+footer()
2013-12-12 20:48:23 +00:00
script(src="/js/jquery.js")
script(type="text/javascript").
function verify() {
var valid = checkUsername();
valid = checkPasswords() && valid;
2017-03-12 01:22:31 +00:00
valid = checkEmail() && valid;
2013-12-12 20:48:23 +00:00
return valid;
}
function checkUsername() {
2017-06-05 05:04:39 +00:00
function createError(text, target){
target.parent()
.addClass("has-error")
.removeClass("has-success");
2013-12-12 20:48:23 +00:00
$("<p/>").addClass("text-danger")
.attr("id", "usernameerror")
2017-06-05 05:04:39 +00:00
.text(text)
.insertAfter(target);
}
var target = $("#username");
var name = target.val();
$("#usernameerror").remove();
if (name === "") {
createError('Username must not be empty', target)
2013-12-12 20:48:23 +00:00
return false;
} else if (!(/^[-\w\u00c0-\u00ff]{1,20}$/).test(name)) {
2017-06-05 05:04:39 +00:00
createError("Username must consist of 1-20 characters" +
" a-Z, A-Z, 0-9, -, or _.", target);
2013-12-12 20:48:23 +00:00
return false;
} else {
2017-06-05 05:04:39 +00:00
target.parent().removeClass("has-error")
2013-12-12 20:48:23 +00:00
.addClass("has-success");
}
}
function checkPasswords() {
2017-06-05 05:04:39 +00:00
function createError(text, target, id){
target.parent()
.addClass("has-error")
.removeClass("has-success");
$("<p/>").addClass("text-danger")
.attr("id", id)
.text(text)
.insertAfter(target);
}
var target = $("#password");
var target2 = $("#password_confirm");
var pw = target.val();
var pwc = target2.val();
2013-12-12 20:48:23 +00:00
$("#passwordempty").remove();
$("#passwordmismatch").remove();
if (pw === "") {
2017-06-05 05:04:39 +00:00
createError('Password must not be empty', target, 'passwordempty')
2013-12-12 20:48:23 +00:00
return false;
} else {
2017-06-05 05:04:39 +00:00
target.parent().removeClass("has-error")
2013-12-12 20:48:23 +00:00
.addClass("has-success");
if (pw !== pwc) {
2017-06-05 05:04:39 +00:00
createError('Passwords do not match', target2, 'passwordmismatch')
2013-12-12 20:48:23 +00:00
return false;
} else {
2017-06-05 05:04:39 +00:00
target2.parent()
.removeClass("has-error")
2013-12-12 20:48:23 +00:00
.addClass("has-success");
}
}
}
2017-03-12 01:22:31 +00:00
function checkEmail() {
var email = $("#email").val();
if (email.trim() === "") {
return confirm("Are you sure you want to register without setting a recovery email address? If you lose the password, or if your account is compromised, you WILL NOT be able to recover it.");
}
return true;
}