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