diff options
author | Parabola <dev@list.parabolagnulinux.org> | 2011-05-21 05:41:26 +0000 |
---|---|---|
committer | Parabola <dev@list.parabolagnulinux.org> | 2011-05-21 05:41:26 +0000 |
commit | 62059d83aea71ac7bde8902b20221e52c86a810b (patch) | |
tree | 758bd028d43a30893ba6261f39b1ebdbebbbf6e3 /media/archweb.js | |
parent | 081223981aa520f792757a1776588756a4107fd4 (diff) | |
parent | fd9ecb6eb1c8ee56adfbb58640d7a98baa6cd62c (diff) |
Merge branch 'master' of /srv/git/projects/parabolaweb
Diffstat (limited to 'media/archweb.js')
-rw-r--r-- | media/archweb.js | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/media/archweb.js b/media/archweb.js index 52e817a4..49f2a319 100644 --- a/media/archweb.js +++ b/media/archweb.js @@ -67,20 +67,52 @@ if (typeof $.tablesorter !== 'undefined') { }, type: 'numeric' }); + $.tablesorter.addParser({ + id: 'filesize', + re: /^(\d+(?:\.\d+)?) (bytes?|KB|MB|GB|TB|PB)$/, + is: function(s) { + return this.re.test(s); + }, + format: function(s) { + var matches = this.re.exec(s); + if (!matches) return 0; + var size = parseFloat(matches[1]); + var suffix = matches[2]; + + switch(suffix) { + case 'byte': + case 'bytes': + return size; + case 'KB': + return size * 1024; + case 'MB': + return size * 1024 * 1024; + case 'GB': + return size * 1024 * 1024 * 1024; + case 'TB': + return size * 1024 * 1024 * 1024 * 1024; + case 'PB': + return size * 1024 * 1024 * 1024 * 1024 * 1024; + } + }, + type: 'numeric' + }); } /* news/add.html */ function enablePreview() { - $('#previewbtn').click(function(event) { + $('#news-preview-button').click(function(event) { event.preventDefault(); - $.post('/news/preview/', - { data: $('#id_content').val() }, + $.post('/news/preview/', { + data: $('#id_content').val(), + csrfmiddlewaretoken: $('#newsform input[name=csrfmiddlewaretoken]').val() + }, function(data) { - $('#previewdata').html(data); - $('.news-article').show(); + $('#news-preview-data').html(data); + $('#news-preview').show(); } ); - $('#previewtitle').html($('#id_title').val()); + $('#news-preview-title').html($('#id_title').val()); }); } |