diff --git a/htdocs/themes/stikkedizr/js/stikked.js b/htdocs/themes/stikkedizr/js/stikked.js index 5b9b317..7f26c92 100644 --- a/htdocs/themes/stikkedizr/js/stikked.js +++ b/htdocs/themes/stikkedizr/js/stikked.js @@ -1,47 +1,50 @@ var ST = window.ST || {} ST.show_embed = function() { - $embed_field = $('#embed_field'); + $embed_field = $('#embed_field'); var lang_showcode = $embed_field.data('lang-showcode'); - $embed_field.hide(); - $embed_field.after('' + lang_showcode + ''); - $('#show_code').live('click', - function() { - $(this).hide(); - $embed_field.show().select(); - return false; - }); + $embed_field.hide(); + $embed_field.after('' + lang_showcode + ''); + $('#show_code').live('click', + function() { + $(this).hide(); + $embed_field.show().select(); + return false; + }); }; ST.expand = function() { $('.expander').show(); - $('.expand').click(function() { - if ($('.paste').hasClass('full')) { - return false; - } - var window_width = $(window).width(); - var spacer = 20; - if (window_width < 900) { - window_width = 900; - spacer = 0; - } - var new_width = (window_width - (spacer * 3)); - $('.text_formatted').animate({ - 'width': new_width + 'px', - 'left': '-' + (((window_width - 900) / 2 - spacer)) + 'px' - }, - 200); - return false; - }); + $('.expand').click(function() { + if ($('.paste').hasClass('full')) { + return false; + } + var window_width = $(window).width(); + var spacer = 20; + if (window_width < 900) { + window_width = 900; + spacer = 0; + } + var new_width = (window_width - (spacer * 3)); + $('.text_formatted').animate({ + 'width': new_width + 'px', + 'left': '-' + (((window_width - 900) / 2 - spacer)) + 'px' + }, + 200); + return false; + }); }; ST.spamadmin = function() { - if ($('.content h1').text() == 'Spamadmin') { + if ($('.content h1').text() == 'Spamadmin') { $('.content .hidden').show(); $('.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() { + $.post(base_url + 'spamadmin/' + ip, { + 'confirm_remove': 'yes', + 'block_ip': 1 + }, function() { window.location.reload(); }); } @@ -56,7 +59,7 @@ ST.line_highlighter = function() { var second_line = false; $('.text_formatted').on('mousedown', function(ev) { - if(ev.which == 1){ // left mouse button has been clicked + if (ev.which == 1) { // left mouse button has been clicked window.getSelection().removeAllRanges(); } }); @@ -64,16 +67,16 @@ ST.line_highlighter = function() { $('.text_formatted').on('click', 'li', function(ev) { var $this = $(this); var li_num = ($this.index() + 1); - if(ev.shiftKey == 1){ + if (ev.shiftKey == 1) { second_line = li_num; } else { first_line = li_num; second_line = false; } - if(second_line){ + if (second_line) { // determine mark - if(first_line < second_line) { + if (first_line < second_line) { sel_start = first_line; sel_end = second_line; } else { @@ -92,20 +95,20 @@ ST.line_highlighter = function() { ST.highlight_lines = function() { var wloc = window.location.href; - if(wloc.indexOf('#') > -1) { + if (wloc.indexOf('#') > -1) { $('.text_formatted .container li').css('background', 'none'); var lines = wloc.split('#')[1]; - if(lines.indexOf('-') > -1) { + if (lines.indexOf('-') > -1) { var start_line = parseInt(lines.split('-')[0].replace('L', ''), 10); var end_line = parseInt(lines.split('-')[1].replace('L', ''), 10); - for(var i=start_line; i<=end_line; i++) { + for (var i = start_line; i <= end_line; i++) { $('.text_formatted .container li:nth-child(' + i + ')').css('background', '#F8EEC7'); } } else { var re = new RegExp('^L[0-9].*?$'); var r = lines.match(re); - if(r) { + if (r) { var marked_line = lines.replace('L', ''); $('.text_formatted .container li:nth-child(' + marked_line + ')').css('background', '#F8EEC7'); } @@ -129,31 +132,31 @@ 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(), - 'reply': $('input[name=reply]').val() - }, - function(redirect_url) { - if(redirect_url.indexOf('invalid') > -1) { - $('#create_encrypted').parent().html('
' + redirect_url + '#' + key + '
'); - } else { - window.location.href = base_url + redirect_url + '#' + key; - } - }); + 'name': $('#name').val(), + 'title': $('#title').val(), + 'code': encrypted, + 'lang': $('#lang').val(), + 'expire': $('#expire').val(), + 'reply': $('input[name=reply]').val() + }, + function(redirect_url) { + if (redirect_url.indexOf('invalid') > -1) { + $('#create_encrypted').parent().html('' + redirect_url + '#' + key + '
'); + } else { + window.location.href = base_url + redirect_url + '#' + key; + } + }); return false; }); // decryption routine w_href = window.location.href; - if(w_href.indexOf('#') > -1) { + if (w_href.indexOf('#') > -1) { key = w_href.split('#')[1]; var re = new RegExp('^L[0-9].*?$'); var r = key.match(re); - if(key.indexOf('-') > -1 || r) { + if (key.indexOf('-') > -1 || r) { // line highlighter } else { try { @@ -182,24 +185,24 @@ ST.crypto = function() { // kick out potential dangerous and unnecessary stuff $('.text_formatted').css('background', '#efe'); $('.replies').hide(); - for(var i=2; i<=7; i++) { + for (var i = 2; i <= 7; i++) { $('.meta .detail:nth-child(' + i + ')').hide(); } $('.meta .spacer:first').hide(); $('.qr').hide(); - } catch(e) {} + } catch (e) {} } } } // generate a random key ST.crypto_generate_key = function(len) { - var index = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; - var key = ''; - for(var i=0; i