CyTube/templates/account-channels.pug

104 lines
4.2 KiB
Plaintext
Raw Normal View History

2013-12-26 03:04:26 +00:00
doctype html
html(lang="en")
head
include head
+head()
body
#wrap
nav.navbar.navbar-inverse.navbar-fixed-top(role="navigation")
include nav
+navheader()
#nav-collapsible.collapse.navbar-collapse
ul.nav.navbar-nav
+navdefaultlinks("/account/channels")
+navloginlogout("/account/channels")
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 Authorization Required
p You must be <a href="/login">logged in</a> to view this page.
else
.col-lg-6.col-md-6
h3 My Channels
if deleteChannelError
.alert.alert-danger.center.messagebox
strong Channel Deletion Failed
p= deleteChannelError
if channels.length == 0
.center
strong You haven't registered any channels
else
table.table.table-bordered
thead
tr
th Channel
tbody
for c in channels
tr
th
form.form-inline.pull-right(action="/account/channels", method="post", onsubmit="return confirm('Are you sure you want to delete " +c.name+ "? This cannot be undone');")
2015-02-23 00:15:22 +00:00
input(type="hidden", name="_csrf", value=csrfToken)
input(type="hidden", name="action", value="delete_channel")
input(type="hidden", name="name", value=c.name)
button.btn.btn-xs.btn-danger(type="submit") Delete
span.glyphicon.glyphicon-trash
a(href=`/${channelPath}/${c.name}`, style="margin-left: 5px")= c.name
.col-lg-6.col-md-6
h3 Register a new channel
if newChannelError
.alert.alert-danger.messagebox.center
strong Channel Registration Failed
p= newChannelError
form(action="/account/channels", method="post")
2015-02-23 00:15:22 +00:00
input(type="hidden", name="_csrf", value=csrfToken)
input(type="hidden", name="action", value="new_channel")
.form-group
label.control-label(for="channelname") Channel URL
.input-group
span.input-group-addon #{baseUrl}/#{channelPath}/
2017-06-05 05:16:40 +00:00
input#channelname.form-control(type="text", name="name", maxlength="30", onkeyup="checkChannel()")
2017-06-05 06:44:46 +00:00
p#validate_channel.text-danger.pull-right
button#register.btn.btn-primary.btn-block(type="submit") Register
include footer
+footer()
script( type='text/javascript').
2017-06-05 06:44:46 +00:00
function checkChannel(){
function nameIsInvalid(id){
if(/\s/.test(id)){
return 'Channel URL may not contain spaces';
}
if(id === ''){
return 'Channel URL must not be empty';
}
if(!/^[\w-]{1,30}$/.test(id)){
return 'Channel URL may only consist of a-z, A-Z, 0-9, - and _';
}
return false;
}
2017-06-05 05:16:40 +00:00
var box = $("#channelname");
var value = box.val();
var lastkey = Date.now();
box.data("lastkey", lastkey);
setTimeout(function () {
if (box.data("lastkey") !== lastkey || box.val() !== value) {
return;
}
if(nameIsInvalid(value)){
2017-06-05 06:44:46 +00:00
$('#validate_channel').text(nameIsInvalid(value))
2017-06-05 05:16:40 +00:00
.parent().addClass('has-error').removeClass('has-success');
$('#register').addClass('disabled');
} else {
2017-06-05 06:44:46 +00:00
$('#validate_channel').text('')
2017-06-05 05:16:40 +00:00
.parent().addClass('has-success').removeClass('has-error');
$('#register').removeClass('disabled');
}
}, 200);
2017-06-05 05:16:40 +00:00
}