(function(){
var initColorIndex = Math.round(Math.random() * 255);
var colorStep = 8;
var minSize = 13;
var maxSize = 26;
var initSize = minSize + Math.round(Math.random() * (maxSize - minSize));
var sizeFlag = true;
function getColor(num) {
if (num > initColorIndex + 360) num = num - 360;
r = Math.round(255 * (1 + Math.sin((num + 0) / 180 * 3.14159265)) / 2);
g = Math.round(255 * (1 + Math.sin((num + 120) / 180 * 3.14159265)) / 2);
b = Math.round(255 * (1 + Math.sin((num + 240) / 180 * 3.14159265)) / 2);
return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
}
function getSize(num) {
if (initSize >= maxSize ) {sizeFlag = false; return initSize--;}
else if (initSize <= minSize) {sizeFlag = true; return initSize++;}
else if (sizeFlag) return initSize++;
else if (!sizeFlag) return initSize--;
}
function formatFont(txt) {
if (!txt) return '';
return txt.split('').map(function(item){return '[size='+ getSize(initSize) +'px][color='+ getColor(initColorIndex += colorStep) +']' + item + '[/color][/size]';}).join('');
}
$('#post_body').val(formatFont($('#post_body').val()));
})();
回复框写上要发的文字,f12进入console模式,粘贴代码进去,然后回车