mirror of
https://github.com/claudehohl/Stikked.git
synced 2025-04-25 20:41:20 -05:00
burnonread fix for bootstrap & readd spamadmin functionality
fixes #511
This commit is contained in:
parent
8d61ba5c60
commit
4245a8c8db
@ -1,31 +1,31 @@
|
|||||||
var ST = window.ST || {};
|
var ST = window.ST || {};
|
||||||
|
|
||||||
ST.show_embed = function() {
|
ST.show_embed = function () {
|
||||||
$embed_field = $('#embed_field');
|
$embed_field = $('#embed_field');
|
||||||
var lang_showcode = $embed_field.data('lang-showcode');
|
var lang_showcode = $embed_field.data('lang-showcode');
|
||||||
$embed_field.hide();
|
$embed_field.hide();
|
||||||
$embed_field.after('<a id="show_code" href="#">' + lang_showcode + '</a>');
|
$embed_field.after('<a id="show_code" href="#">' + lang_showcode + '</a>');
|
||||||
$('#show_code').on('click', function(e) {
|
$('#show_code').on('click', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$(this).hide();
|
$(this).hide();
|
||||||
$embed_field.show().select();
|
$embed_field.show().select();
|
||||||
});
|
});
|
||||||
$embed_field.on("blur", function() {
|
$embed_field.on("blur", function () {
|
||||||
$(this).hide();
|
$(this).hide();
|
||||||
$('#show_code').show();
|
$('#show_code').show();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
ST.spamadmin = function() {
|
ST.spamadmin = function () {
|
||||||
if ($('.content h1').text() == 'Spamadmin') {
|
if ($('.content h1').text() == 'Spamadmin') {
|
||||||
$('.content .hidden').show();
|
$('.content .hidden').show();
|
||||||
$('.content .quick_remove').live('click', function(ev) {
|
$('.content .quick_remove').live('click', function (ev) {
|
||||||
var ip = $(ev.target).data('ip');
|
var ip = $(ev.target).data('ip');
|
||||||
if (confirm('Delete all pastes belonging to ' + ip + '?')) {
|
if (confirm('Delete all pastes belonging to ' + ip + '?')) {
|
||||||
$.post(base_url + 'spamadmin/' + ip, {
|
$.post(base_url + 'spamadmin/' + ip, {
|
||||||
'confirm_remove': 'yes',
|
'confirm_remove': 'yes',
|
||||||
'block_ip': 1
|
'block_ip': 1
|
||||||
}, function() {
|
}, function () {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -34,42 +34,42 @@ ST.spamadmin = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// needed by .selectable
|
// needed by .selectable
|
||||||
$.fn.addBack = function(selector) {
|
$.fn.addBack = function (selector) {
|
||||||
return this.add(selector == null ? this.prevObject : this.prevObject.filter(selector));
|
return this.add(selector == null ? this.prevObject : this.prevObject.filter(selector));
|
||||||
}
|
}
|
||||||
|
|
||||||
// $('.selectable>tbody').selectable({
|
$('.selectable>tbody').selectable({
|
||||||
// filter: 'tr',
|
filter: 'tr',
|
||||||
// cancel: 'a',
|
cancel: 'a',
|
||||||
// stop: function() {
|
stop: function () {
|
||||||
// var $deletestack = $(".paste_deletestack");
|
var $deletestack = $(".paste_deletestack");
|
||||||
// var $input = $("input[name=pastes_to_delete]");
|
var $input = $("input[name=pastes_to_delete]");
|
||||||
// $('.inv').show();
|
$('.inv').show();
|
||||||
// $deletestack.empty();
|
$deletestack.empty();
|
||||||
// $input.empty();
|
$input.empty();
|
||||||
// var res = [];
|
var res = [];
|
||||||
// $(".ui-selected").each(function(i, el) {
|
$(".ui-selected").each(function (i, el) {
|
||||||
// var id = $('a', el).attr('href').split('view/')[1];
|
var id = $('a', el).attr('href').split('view/')[1];
|
||||||
// res.push(id);
|
res.push(id);
|
||||||
// });
|
});
|
||||||
// $deletestack.text(res.join(' '));
|
$deletestack.text(res.join(' '));
|
||||||
// $input.val(res.join(' '));
|
$input.val(res.join(' '));
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
ST.line_highlighter = function() {
|
ST.line_highlighter = function () {
|
||||||
var org_href = window.location.href.replace(/(.*?)#(.*)/, '$1');
|
var org_href = window.location.href.replace(/(.*?)#(.*)/, '$1');
|
||||||
var first_line = false;
|
var first_line = false;
|
||||||
var second_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
|
if (ev.which == 1) { // left mouse button has been clicked
|
||||||
window.getSelection().removeAllRanges();
|
window.getSelection().removeAllRanges();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('blockquote').on('click', 'li', function(ev) {
|
$('blockquote').on('click', 'li', function (ev) {
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var li_num = ($this.index() + 1);
|
var li_num = ($this.index() + 1);
|
||||||
if (ev.shiftKey == 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;
|
var wloc = window.location.href;
|
||||||
if (wloc.indexOf('#') > -1) {
|
if (wloc.indexOf('#') > -1) {
|
||||||
$('.container .CodeMirror li').css('background', 'none');
|
$('.container .CodeMirror li').css('background', 'none');
|
||||||
@ -123,9 +123,9 @@ ST.highlight_lines = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ST.crypto = function() {
|
ST.crypto = function () {
|
||||||
$('button[name=submit]').after(' <button type="submit" id="create_encrypted" class="btn-large btn-success"> <i class="icon-lock icon-white"></i> Create encrypted</button>');
|
$('button[name=submit]').after(' <button type="submit" id="create_encrypted" class="btn-large btn-success"> <i class="icon-lock icon-white"></i> Create encrypted</button>');
|
||||||
$('#create_encrypted').on('click', function() {
|
$('#create_encrypted').on('click', function () {
|
||||||
var $code = $('#code');
|
var $code = $('#code');
|
||||||
|
|
||||||
// encrypt the paste
|
// encrypt the paste
|
||||||
@ -139,20 +139,22 @@ ST.crypto = function() {
|
|||||||
|
|
||||||
// post request via JS
|
// post request via JS
|
||||||
$.post(base_url + 'post_encrypted', {
|
$.post(base_url + 'post_encrypted', {
|
||||||
'name': $('#name').val(),
|
'name': $('#name').val(),
|
||||||
'title': $('#title').val(),
|
'title': $('#title').val(),
|
||||||
'code': encrypted,
|
'code': encrypted,
|
||||||
'lang': $('#lang').val(),
|
'lang': $('#lang').val(),
|
||||||
'expire': $('#expire').val(),
|
'expire': $('#expire').val(),
|
||||||
'captcha': $('#captcha').val(),
|
'captcha': $('#captcha').val(),
|
||||||
'reply': $('input[name=reply]').val()
|
'reply': $('input[name=reply]').val()
|
||||||
},
|
},
|
||||||
function(redirect_url) {
|
function (redirect_url) {
|
||||||
if (redirect_url.indexOf('E_CAPTCHA') > -1) {
|
if (redirect_url.indexOf('E_CAPTCHA') > -1) {
|
||||||
$('.container .message').remove();
|
$('.container .message').remove();
|
||||||
$('.container:eq(1)').prepend('<div class="message error"><div class="container">The captcha is incorrect.</div></div>');
|
$('.container:eq(1)').prepend('<div class="message error"><div class="container">The captcha is incorrect.</div></div>');
|
||||||
} else if (redirect_url.indexOf('invalid') > -1) {
|
} else if (redirect_url.indexOf('invalid') > -1) {
|
||||||
$('#create_encrypted').parent().html('<p>' + redirect_url + '#' + key + '</p>');
|
// burn on read
|
||||||
|
redirect_url = redirect_url.replace('" /><!-- behind you -->', '#' + key + '" />')
|
||||||
|
$('#create_encrypted').parent().html('<p>' + redirect_url + '</p>');
|
||||||
} else {
|
} else {
|
||||||
window.location.href = base_url + redirect_url + '#' + key;
|
window.location.href = base_url + redirect_url + '#' + key;
|
||||||
}
|
}
|
||||||
@ -201,13 +203,13 @@ ST.crypto = function() {
|
|||||||
}
|
}
|
||||||
$('.meta .spacer:first').hide();
|
$('.meta .spacer:first').hide();
|
||||||
$('.qr').hide();
|
$('.qr').hide();
|
||||||
} catch (e) {}
|
} catch (e) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate a random key
|
// generate a random key
|
||||||
ST.crypto_generate_key = function(len) {
|
ST.crypto_generate_key = function (len) {
|
||||||
var index = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
var index = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||||
var key = '';
|
var key = '';
|
||||||
for (var i = 0; i < len; i++) {
|
for (var i = 0; i < len; i++) {
|
||||||
@ -216,7 +218,7 @@ ST.crypto_generate_key = function(len) {
|
|||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
ST.dragdrop = function() {
|
ST.dragdrop = function () {
|
||||||
$("#code").fileReaderJS({
|
$("#code").fileReaderJS({
|
||||||
// CSS Class to add to the drop element when a drag is active
|
// CSS Class to add to the drop element when a drag is active
|
||||||
dragClass: "drag",
|
dragClass: "drag",
|
||||||
@ -235,7 +237,7 @@ ST.dragdrop = function() {
|
|||||||
// How to read any files not specified by readAsMap
|
// How to read any files not specified by readAsMap
|
||||||
readAsDefault: 'DataURL',
|
readAsDefault: 'DataURL',
|
||||||
on: {
|
on: {
|
||||||
loadend: function(e, file) {
|
loadend: function (e, file) {
|
||||||
try {
|
try {
|
||||||
var words = CryptoJS.enc.Base64.parse(e.target.result.split(',')[1]);
|
var words = CryptoJS.enc.Base64.parse(e.target.result.split(',')[1]);
|
||||||
var utf8 = CryptoJS.enc.Utf8.stringify(words);
|
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
|
// prepare the editor, needs to be a div
|
||||||
var $code = $('#code');
|
var $code = $('#code');
|
||||||
|
|
||||||
@ -275,16 +277,16 @@ ST.ace_init = function() {
|
|||||||
ST.ace_editor = ace.edit("editor");
|
ST.ace_editor = ace.edit("editor");
|
||||||
ST.ace_editor.setTheme("ace/theme/clouds");
|
ST.ace_editor.setTheme("ace/theme/clouds");
|
||||||
ST.ace_editor.getSession().setValue($code.val());
|
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());
|
$code.val(ST.ace_editor.getValue());
|
||||||
});
|
});
|
||||||
ST.ace_setlang();
|
ST.ace_setlang();
|
||||||
$('#lang').change(function() {
|
$('#lang').change(function () {
|
||||||
ST.ace_setlang();
|
ST.ace_setlang();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ST.ace_setlang = function() {
|
ST.ace_setlang = function () {
|
||||||
var lang = $('#lang').val();
|
var lang = $('#lang').val();
|
||||||
var mode = '';
|
var mode = '';
|
||||||
try {
|
try {
|
||||||
@ -298,12 +300,12 @@ ST.ace_setlang = function() {
|
|||||||
ST.ace_editor.getSession().setMode("ace/mode/" + mode);
|
ST.ace_editor.getSession().setMode("ace/mode/" + mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
ST.codemirror_init = function() {
|
ST.codemirror_init = function () {
|
||||||
if (typeof CodeMirror == 'undefined') {
|
if (typeof CodeMirror == 'undefined') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ST.cm_modes = $.parseJSON($('#codemirror_modes').text());
|
ST.cm_modes = $.parseJSON($('#codemirror_modes').text());
|
||||||
$('#lang').change(function() {
|
$('#lang').change(function () {
|
||||||
ST.codemirror_setlang();
|
ST.codemirror_setlang();
|
||||||
});
|
});
|
||||||
if (typeof ST.cm_editor == 'undefined') {
|
if (typeof ST.cm_editor == 'undefined') {
|
||||||
@ -317,12 +319,12 @@ ST.codemirror_init = function() {
|
|||||||
ST.codemirror_setlang();
|
ST.codemirror_setlang();
|
||||||
}
|
}
|
||||||
|
|
||||||
ST.codemirror_setlang = function() {
|
ST.codemirror_setlang = function () {
|
||||||
var lang = $('#lang').val();
|
var lang = $('#lang').val();
|
||||||
var mode = ST.cm_modes[lang];
|
var mode = ST.cm_modes[lang];
|
||||||
|
|
||||||
$.get(base_url + 'main/get_cm_js/' + lang,
|
$.get(base_url + 'main/get_cm_js/' + lang,
|
||||||
function(data) {
|
function (data) {
|
||||||
if (data != '') {
|
if (data != '') {
|
||||||
ST.cm_editor.setOption('mode', mode);
|
ST.cm_editor.setOption('mode', mode);
|
||||||
} else {
|
} else {
|
||||||
@ -332,11 +334,11 @@ ST.codemirror_setlang = function() {
|
|||||||
'script');
|
'script');
|
||||||
}
|
}
|
||||||
|
|
||||||
ST.clickable_urls = function() {
|
ST.clickable_urls = function () {
|
||||||
$('.container .row .span12').linkify();
|
$('.container .row .span12').linkify();
|
||||||
}
|
}
|
||||||
|
|
||||||
ST.init = function() {
|
ST.init = function () {
|
||||||
ST.show_embed();
|
ST.show_embed();
|
||||||
ST.spamadmin();
|
ST.spamadmin();
|
||||||
ST.line_highlighter();
|
ST.line_highlighter();
|
||||||
@ -347,6 +349,6 @@ ST.init = function() {
|
|||||||
ST.ace_init();
|
ST.ace_init();
|
||||||
};
|
};
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function () {
|
||||||
ST.init();
|
ST.init();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user