From 4245a8c8db4589f179acff82f3e3ba10860710df Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 24 Nov 2019 15:48:54 +0100 Subject: burnonread fix for bootstrap & readd spamadmin functionality fixes #511 --- htdocs/themes/bootstrap/js/stikked.js | 114 +++++++++++++++++----------------- 1 file changed, 58 insertions(+), 56 deletions(-) diff --git a/htdocs/themes/bootstrap/js/stikked.js b/htdocs/themes/bootstrap/js/stikked.js index b89e601..19c57be 100644 --- a/htdocs/themes/bootstrap/js/stikked.js +++ b/htdocs/themes/bootstrap/js/stikked.js @@ -1,31 +1,31 @@ var ST = window.ST || {}; -ST.show_embed = function() { +ST.show_embed = function () { $embed_field = $('#embed_field'); var lang_showcode = $embed_field.data('lang-showcode'); $embed_field.hide(); $embed_field.after('' + lang_showcode + ''); - $('#show_code').on('click', function(e) { + $('#show_code').on('click', function (e) { e.preventDefault(); $(this).hide(); $embed_field.show().select(); }); - $embed_field.on("blur", function() { + $embed_field.on("blur", function () { $(this).hide(); $('#show_code').show(); }); }; -ST.spamadmin = function() { +ST.spamadmin = function () { if ($('.content h1').text() == 'Spamadmin') { $('.content .hidden').show(); - $('.content .quick_remove').live('click', function(ev) { + $('.content .quick_remove').live('click', function (ev) { var ip = $(ev.target).data('ip'); if (confirm('Delete all pastes belonging to ' + ip + '?')) { $.post(base_url + 'spamadmin/' + ip, { 'confirm_remove': 'yes', 'block_ip': 1 - }, function() { + }, function () { window.location.reload(); }); } @@ -34,42 +34,42 @@ ST.spamadmin = function() { } // needed by .selectable - $.fn.addBack = function(selector) { + $.fn.addBack = function (selector) { return this.add(selector == null ? this.prevObject : this.prevObject.filter(selector)); } - // $('.selectable>tbody').selectable({ - // filter: 'tr', - // cancel: 'a', - // stop: function() { - // var $deletestack = $(".paste_deletestack"); - // var $input = $("input[name=pastes_to_delete]"); - // $('.inv').show(); - // $deletestack.empty(); - // $input.empty(); - // var res = []; - // $(".ui-selected").each(function(i, el) { - // var id = $('a', el).attr('href').split('view/')[1]; - // res.push(id); - // }); - // $deletestack.text(res.join(' ')); - // $input.val(res.join(' ')); - // } - // }); + $('.selectable>tbody').selectable({ + filter: 'tr', + cancel: 'a', + stop: function () { + var $deletestack = $(".paste_deletestack"); + var $input = $("input[name=pastes_to_delete]"); + $('.inv').show(); + $deletestack.empty(); + $input.empty(); + var res = []; + $(".ui-selected").each(function (i, el) { + var id = $('a', el).attr('href').split('view/')[1]; + res.push(id); + }); + $deletestack.text(res.join(' ')); + $input.val(res.join(' ')); + } + }); }; -ST.line_highlighter = function() { +ST.line_highlighter = function () { var org_href = window.location.href.replace(/(.*?)#(.*)/, '$1'); var first_line = false; var second_line = false; - $('blockquote').on('mousedown', function(ev) { + $('blockquote').on('mousedown', function (ev) { if (ev.which == 1) { // left mouse button has been clicked window.getSelection().removeAllRanges(); } }); - $('blockquote').on('click', 'li', function(ev) { + $('blockquote').on('click', 'li', function (ev) { var $this = $(this); var li_num = ($this.index() + 1); if (ev.shiftKey == 1) { @@ -100,7 +100,7 @@ ST.line_highlighter = function() { } -ST.highlight_lines = function() { +ST.highlight_lines = function () { var wloc = window.location.href; if (wloc.indexOf('#') > -1) { $('.container .CodeMirror li').css('background', 'none'); @@ -123,9 +123,9 @@ ST.highlight_lines = function() { } } -ST.crypto = function() { +ST.crypto = function () { $('button[name=submit]').after('  '); - $('#create_encrypted').on('click', function() { + $('#create_encrypted').on('click', function () { var $code = $('#code'); // encrypt the paste @@ -139,20 +139,22 @@ ST.crypto = function() { // post request via JS $.post(base_url + 'post_encrypted', { - 'name': $('#name').val(), - 'title': $('#title').val(), - 'code': encrypted, - 'lang': $('#lang').val(), - 'expire': $('#expire').val(), - 'captcha': $('#captcha').val(), - 'reply': $('input[name=reply]').val() - }, - function(redirect_url) { + 'name': $('#name').val(), + 'title': $('#title').val(), + 'code': encrypted, + 'lang': $('#lang').val(), + 'expire': $('#expire').val(), + 'captcha': $('#captcha').val(), + 'reply': $('input[name=reply]').val() + }, + function (redirect_url) { if (redirect_url.indexOf('E_CAPTCHA') > -1) { $('.container .message').remove(); $('.container:eq(1)').prepend('
The captcha is incorrect.
'); } else if (redirect_url.indexOf('invalid') > -1) { - $('#create_encrypted').parent().html('

' + redirect_url + '#' + key + '

'); + // burn on read + redirect_url = redirect_url.replace('" />', '#' + key + '" />') + $('#create_encrypted').parent().html('

' + redirect_url + '

'); } else { window.location.href = base_url + redirect_url + '#' + key; } @@ -201,13 +203,13 @@ ST.crypto = function() { } $('.meta .spacer:first').hide(); $('.qr').hide(); - } catch (e) {} + } catch (e) { } } } } // generate a random key -ST.crypto_generate_key = function(len) { +ST.crypto_generate_key = function (len) { var index = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; var key = ''; for (var i = 0; i < len; i++) { @@ -216,7 +218,7 @@ ST.crypto_generate_key = function(len) { return key; } -ST.dragdrop = function() { +ST.dragdrop = function () { $("#code").fileReaderJS({ // CSS Class to add to the drop element when a drag is active dragClass: "drag", @@ -235,7 +237,7 @@ ST.dragdrop = function() { // How to read any files not specified by readAsMap readAsDefault: 'DataURL', on: { - loadend: function(e, file) { + loadend: function (e, file) { try { var words = CryptoJS.enc.Base64.parse(e.target.result.split(',')[1]); var utf8 = CryptoJS.enc.Utf8.stringify(words); @@ -250,7 +252,7 @@ ST.dragdrop = function() { }); } -ST.ace_init = function() { +ST.ace_init = function () { // prepare the editor, needs to be a div var $code = $('#code'); @@ -275,16 +277,16 @@ ST.ace_init = function() { ST.ace_editor = ace.edit("editor"); ST.ace_editor.setTheme("ace/theme/clouds"); ST.ace_editor.getSession().setValue($code.val()); - ST.ace_editor.getSession().on('change', function(e) { + ST.ace_editor.getSession().on('change', function (e) { $code.val(ST.ace_editor.getValue()); }); ST.ace_setlang(); - $('#lang').change(function() { + $('#lang').change(function () { ST.ace_setlang(); }); } -ST.ace_setlang = function() { +ST.ace_setlang = function () { var lang = $('#lang').val(); var mode = ''; try { @@ -298,12 +300,12 @@ ST.ace_setlang = function() { ST.ace_editor.getSession().setMode("ace/mode/" + mode); } -ST.codemirror_init = function() { +ST.codemirror_init = function () { if (typeof CodeMirror == 'undefined') { return false; } ST.cm_modes = $.parseJSON($('#codemirror_modes').text()); - $('#lang').change(function() { + $('#lang').change(function () { ST.codemirror_setlang(); }); if (typeof ST.cm_editor == 'undefined') { @@ -317,12 +319,12 @@ ST.codemirror_init = function() { ST.codemirror_setlang(); } -ST.codemirror_setlang = function() { +ST.codemirror_setlang = function () { var lang = $('#lang').val(); var mode = ST.cm_modes[lang]; $.get(base_url + 'main/get_cm_js/' + lang, - function(data) { + function (data) { if (data != '') { ST.cm_editor.setOption('mode', mode); } else { @@ -332,11 +334,11 @@ ST.codemirror_setlang = function() { 'script'); } -ST.clickable_urls = function() { +ST.clickable_urls = function () { $('.container .row .span12').linkify(); } -ST.init = function() { +ST.init = function () { ST.show_embed(); ST.spamadmin(); ST.line_highlighter(); @@ -347,6 +349,6 @@ ST.init = function() { ST.ace_init(); }; -$(document).ready(function() { +$(document).ready(function () { ST.init(); }); -- cgit v1.2.3