mirror of
https://github.com/claudehohl/Stikked.git
synced 2025-04-25 20:41:20 -05:00
codeformat
This commit is contained in:
parent
50fd78d85e
commit
a0a0d6dbbc
@ -1,21 +1,21 @@
|
|||||||
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').live('click',
|
$('#show_code').live('click',
|
||||||
function() {
|
function () {
|
||||||
$(this).hide();
|
$(this).hide();
|
||||||
$embed_field.show().select();
|
$embed_field.show().select();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
ST.expand = function() {
|
ST.expand = function () {
|
||||||
$('.expander').show();
|
$('.expander').show();
|
||||||
$('.expand').click(function() {
|
$('.expand').click(function () {
|
||||||
if ($('.paste').hasClass('full')) {
|
if ($('.paste').hasClass('full')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -27,24 +27,24 @@ ST.expand = function() {
|
|||||||
}
|
}
|
||||||
var new_width = (window_width - (spacer * 3));
|
var new_width = (window_width - (spacer * 3));
|
||||||
$('.text_formatted').animate({
|
$('.text_formatted').animate({
|
||||||
'width': new_width + 'px',
|
'width': new_width + 'px',
|
||||||
'left': '-' + (((window_width - 900) / 2 - spacer)) + 'px'
|
'left': '-' + (((window_width - 900) / 2 - spacer)) + 'px'
|
||||||
},
|
},
|
||||||
200);
|
200);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
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();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -53,9 +53,9 @@ ST.spamadmin = function() {
|
|||||||
|
|
||||||
$(document).tooltip({
|
$(document).tooltip({
|
||||||
items: "td.first a",
|
items: "td.first a",
|
||||||
content: function(done) {
|
content: function (done) {
|
||||||
var pid = $(this).attr('href').split('view/')[1];
|
var pid = $(this).attr('href').split('view/')[1];
|
||||||
$.get(base_url + 'view/raw/' + pid + '?preview', function(data) {
|
$.get(base_url + 'view/raw/' + pid + '?preview', function (data) {
|
||||||
done(data);
|
done(data);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -65,21 +65,21 @@ 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);
|
||||||
});
|
});
|
||||||
@ -89,18 +89,18 @@ ST.spamadmin = function() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
$('.text_formatted').on('mousedown', function(ev) {
|
$('.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();
|
window.getSelection().removeAllRanges();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.text_formatted').on('click', 'li', function(ev) {
|
$('.text_formatted').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) {
|
||||||
@ -129,7 +129,7 @@ ST.line_highlighter = function() {
|
|||||||
ST.highlight_lines();
|
ST.highlight_lines();
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
$('.text_formatted .container li').css('background', 'none');
|
$('.text_formatted .container li').css('background', 'none');
|
||||||
@ -152,9 +152,9 @@ ST.highlight_lines = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ST.crypto = function() {
|
ST.crypto = function () {
|
||||||
$('button[name=submit]').after('<button id="create_encrypted">Create encrypted</button>');
|
$('button[name=submit]').after('<button id="create_encrypted">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
|
||||||
@ -168,15 +168,15 @@ 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) {
|
||||||
$('.content .container .message').remove();
|
$('.content .container .message').remove();
|
||||||
$('.content .container').prepend('<div class="message error"><div class="container">The captcha is incorrect.</div></div>');
|
$('.content .container').prepend('<div class="message error"><div class="container">The captcha is incorrect.</div></div>');
|
||||||
@ -230,13 +230,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++) {
|
||||||
@ -245,7 +245,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",
|
||||||
@ -264,7 +264,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);
|
||||||
@ -279,7 +279,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');
|
||||||
|
|
||||||
@ -304,16 +304,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 {
|
||||||
@ -327,12 +327,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') {
|
||||||
@ -344,12 +344,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 {
|
||||||
@ -359,11 +359,11 @@ ST.codemirror_setlang = function() {
|
|||||||
'script');
|
'script');
|
||||||
}
|
}
|
||||||
|
|
||||||
ST.clickable_urls = function() {
|
ST.clickable_urls = function () {
|
||||||
$('.paste .container').linkify();
|
$('.paste .container').linkify();
|
||||||
}
|
}
|
||||||
|
|
||||||
ST.init = function() {
|
ST.init = function () {
|
||||||
ST.expand();
|
ST.expand();
|
||||||
ST.show_embed();
|
ST.show_embed();
|
||||||
ST.spamadmin();
|
ST.spamadmin();
|
||||||
@ -375,6 +375,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