This commit is contained in:
Xaekai 2017-06-04 22:16:40 -07:00
parent 668477d711
commit d42de93d74
2 changed files with 14 additions and 13 deletions

View File

@ -202,6 +202,7 @@ function handleAccountChannelPage(req, res) {
db.channels.listUserChannels(req.user.name, function (err, channels) { db.channels.listUserChannels(req.user.name, function (err, channels) {
sendPug(res, "account-channels", { sendPug(res, "account-channels", {
domain: req.host,
channels: channels channels: channels
}); });
}); });

View File

@ -56,10 +56,10 @@ html(lang="en")
input(type="hidden", name="action", value="new_channel") input(type="hidden", name="action", value="new_channel")
.form-group .form-group
label.control-label(for="channelname") Channel URL label.control-label(for="channelname") Channel URL
span#validation.pull-right span#validation.text-danger.pull-right
.input-group .input-group
span.input-group-addon #{baseUrl}/r/ span.input-group-addon #{domain}/r/
input#channelname.form-control(type="text", name="name") input#channelname.form-control(type="text", name="name", maxlength="30", onkeyup="checkChannel()")
button#register.btn.btn-primary.btn-block(type="submit") Register button#register.btn.btn-primary.btn-block(type="submit") Register
include footer include footer
@ -69,11 +69,8 @@ html(lang="en")
if(/\s/.test(id)){ if(/\s/.test(id)){
return 'Channel URLs may not contain spaces'; return 'Channel URLs may not contain spaces';
} }
if(id.length > 30){ if(id === ''){
return 'Channel URLs may not be longer than 30 characters'; return 'Channel URLs must not be empty';
}
if(id.length < 1){
return 'Channel URLs must be at least one character';
} }
if(!/^[\w-]{1,30}$/.test(id)){ if(!/^[\w-]{1,30}$/.test(id)){
return 'Channel URLs may only consist of a-z, A-Z, 0-9, - and _'; return 'Channel URLs may only consist of a-z, A-Z, 0-9, - and _';
@ -81,8 +78,8 @@ html(lang="en")
return false; return false;
} }
$("#channelname").keyup(function () { function checkChannel(){
var box = $(this); var box = $("#channelname");
var value = box.val(); var value = box.val();
var lastkey = Date.now(); var lastkey = Date.now();
box.data("lastkey", lastkey); box.data("lastkey", lastkey);
@ -92,12 +89,15 @@ html(lang="en")
return; return;
} }
if(nameIsInvalid(value)){ if(nameIsInvalid(value)){
$('#validation').text(nameIsInvalid(value)); $('#validation').text(nameIsInvalid(value))
.parent().addClass('has-error').removeClass('has-success');
$('#register').addClass('disabled'); $('#register').addClass('disabled');
} else { } else {
$('#validation').text(''); $('#validation').text('')
.parent().addClass('has-success').removeClass('has-error');
$('#register').removeClass('disabled'); $('#register').removeClass('disabled');
} }
}, 200); }, 200);
});
}