typo correction
[KisSync.git] / templates / account-channels.pug
blob7b2a1dc8491d3f8003621e96c26c60d980333a67
1 extends layout.pug
3 block content
4   if !loggedIn
5     .col-lg-6.col-lg-offset-3.col-md-6.col-md-offset-3
6       .alert.alert-danger.messagebox.center
7         strong Authorization Required
8         p You must be <a href="/login">logged in</a> to view this page.
9   else
10     .col-lg-6.col-md-6
11       h3 My Channels
12       if deleteChannelError
13         .alert.alert-danger.center.messagebox
14           strong Channel Deletion Failed
15           p= deleteChannelError
16       if channels.length == 0
17         .center
18           strong You haven't registered any channels
19       else
20         table.table.table-bordered
21           thead
22             tr
23               th Channel
24           tbody
25             for c in channels
26               tr
27                 th
28                   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');")
29                     input(type="hidden", name="_csrf", value=csrfToken)
30                     input(type="hidden", name="action", value="delete_channel")
31                     input(type="hidden", name="name", value=c.name)
32                     button.btn.btn-xs.btn-danger(type="submit") Delete
33                       span.glyphicon.glyphicon-trash
34                   a(href=`/${channelPath}/${c.name}`, style="margin-left: 5px")= c.name
35     .col-lg-6.col-md-6
36       h3 Register a new channel
37       if newChannelError
38         .alert.alert-danger.messagebox.center
39           strong Channel Registration Failed
40           p= newChannelError
41       form(action="/account/channels", method="post")
42         input(type="hidden", name="_csrf", value=csrfToken)
43         input(type="hidden", name="action", value="new_channel")
44         .form-group
45           label.control-label(for="channelname") Channel URL
46           .input-group
47             span.input-group-addon #{baseUrl}/#{channelPath}/
48             input#channelname.form-control(type="text", name="name", maxlength="30", onkeyup="checkChannel()")
49           p#validate_channel.text-danger.pull-right
50         button#register.btn.btn-primary.btn-block(type="submit") Register
52 append footer
53   script(type='text/javascript').
54     function checkChannel(){
55         function nameIsInvalid(id){
56             if(/\s/.test(id)){
57                 return 'Channel URL may not contain spaces';
58             }
59             if(id === ''){
60                 return 'Channel URL must not be empty';
61             }
62             if(!/^[\w-]{1,30}$/.test(id)){
63                 return 'Channel URL may only consist of a-z, A-Z, 0-9, - and _';
64             }
65             return false;
66         }
68         var box = $("#channelname");
69         var value = box.val();
70         var lastkey = Date.now();
71         box.data("lastkey", lastkey);
73         setTimeout(function () {
74             if (box.data("lastkey") !== lastkey || box.val() !== value) {
75                 return;
76             }
77             if(nameIsInvalid(value)){
78                 $('#validate_channel').text(nameIsInvalid(value))
79                     .parent().addClass('has-error').removeClass('has-success');
80                 $('#register').addClass('disabled');
81             } else {
82                 $('#validate_channel').text('')
83                     .parent().addClass('has-success').removeClass('has-error');
84                 $('#register').removeClass('disabled');
85             }
86         }, 200);
88     }