1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
| $('body').mouseup(function(){ $('.output').height($('textarea').height()); $('.output').height($('textarea').height()); });
$.fn.selectRange = function(start, end){ if(!end) end = start; return this.each(function(){ if (this.setSelectionRange) { this.focus(); this.setSelectionRange(start, end); } else if (this.createTextRange) { var range = this.createTextRange(); range.collapse(true); range.moveEnd('character', end); range.moveStart('character', start); range.select(); } }); };
$('.bgs div').click(function(elem){ $('.output').css('background', $(elem.target).css('background')); $('.bgs div').css('border',0); $(elem.target).css('border', '3px #aaa solid'); });
var motd_raw = $('.editor textarea'); $('.tools button').click(function(e){ var caretPos = motd_raw[0].selectionStart; var textAreaTxt = motd_raw.val(); var txtToAdd = '&' + $(this).attr('data-color'); console.log(caretPos); motd_raw.val(textAreaTxt.substring(0, caretPos) + txtToAdd + textAreaTxt.substring(caretPos)).focus(); motd_raw.selectRange(caretPos + 2); colour(motd_raw.val()); });
function colour (text) { left = htmlEncode("<"); right = htmlEncode(">"); text = text.replace(/</gi, left); text = text.replace(/>/gi, right); text = text.replace(/\n/gi, "&r<br />");
text = text.replace(/&0/gi,'</span>&r<span class="c-1">'); text = text.replace(/&1/gi,'</span>&r<span class="c-2">'); text = text.replace(/&2/gi,'</span>&r<span class="c-3">'); text = text.replace(/&3/gi,'</span>&r<span class="c-4">'); text = text.replace(/&4/gi,'</span>&r<span class="c-5">'); text = text.replace(/&5/gi,'</span>&r<span class="c-6">'); text = text.replace(/&6/gi,'</span>&r<span class="c-7">'); text = text.replace(/&7/gi,'</span>&r<span class="c-8">'); text = text.replace(/&8/gi,'</span>&r<span class="c-9">'); text = text.replace(/&9/gi,'</span>&r<span class="c-10">'); text = text.replace(/&a/gi,'</span>&r<span class="c-11">'); text = text.replace(/&b/gi,'</span>&r<span class="c-12">'); text = text.replace(/&c/gi,'</span>&r<span class="c-13">'); text = text.replace(/&d/gi,'</span>&r<span class="c-14">'); text = text.replace(/&e/gi,'</span>&r<span class="c-15">'); text = text.replace(/&f/gi,'</span>&r<span class="c-16">');
text = text.replace(/&l/gi,"<span style='font-weight:900;'>");
text = text.replace(/&o/gi,"<span style='font-style:italic;'>");
text = text.replace(/&m/gi,"<span style='text-decoration:line-through'>");
text = text.replace(/&n/gi,"<span style='text-decoration:underline'>");
text = text.replace(/&k/gi,"<span class='obfuscated'>");
text = text.replace(/&r/gi, "</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>"); document.getElementById('output').innerHTML=text;
}
setInterval(function() { $('.obfuscated').text(randomizer($('.obfuscated').text())); }, 100);
function htmlEncode(value){ return $('<div/>').text(value).html(); }
function randomizer(rawr) { var length = rawr.length; var text = ''; var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0; i < length; i++ ) text += possible.charAt(Math.floor(Math.random() * possible.length));
return text; }
|