// Text Colorizer by David at stuffbydavid.com, 2011 // Really old code ahead! function cutHex(h) {return (h.charAt(0)=="#") ? h.substring(1,7):h} function hexToR(h) {return parseInt((cutHex(h)).substring(0,2),16)} function hexToG(h) {return parseInt((cutHex(h)).substring(2,4),16)} function hexToB(h) {return parseInt((cutHex(h)).substring(4,6),16)} function rgbToHex(R,G,B) {return toHex(R)+toHex(G)+toHex(B)} function toHex(n) { n = parseInt(n,10); if (isNaN(n)) return "00"; n = Math.max(0,Math.min(n,255)); return "0123456789ABCDEF".charAt((n-n%16)/16) + "0123456789ABCDEF".charAt(n%16); } input_effect="" input_color1="" input_color2="" input_color3="" input_color4="" input_color5="" input_color6="" input_color7="" input_color8="" input_text="" input_font="" input_size="" input_bold=0 input_italic=0 input_colorword=0 random_length=0; update=0 var random_char=new Array(); function randomize_colors() { var length=document.getElementById("input_text").value.length; var a; for (a=0; a'; str_bbcodeend=""+str_bbcodeend;} if (input_size!="0") { var str_size; str_size="" if (input_size=="1") str_size="10px" if (input_size=="2") str_size="12px" if (input_size=="3") str_size="15px" if (input_size=="4") str_size="17px" if (input_size=="5") str_size="22px" if (input_size=="25") str_size="27px" if (input_size=="35") str_size="35px" if (input_size=="8") str_size="60px" str_style+='font-size:'+str_size+';'; str_bbcode+=''; str_bbcodeend=""+str_bbcodeend; } if (str_style!="") str_html+=""; var a,r,g,b,rinc,ginc,binc,ccol; if (input_effect=="1") { r=hexToR(input_color1) g=hexToG(input_color1) b=hexToB(input_color1) rinc=(hexToR(input_color2)-r)/input_text.length ginc=(hexToG(input_color2)-g)/input_text.length binc=(hexToB(input_color2)-b)/input_text.length for (a=0; a"+input_text.charAt(a)+""; str_bbcode+=''+input_text.charAt(a)+""; } r+=rinc; g+=ginc; b+=binc; } } else if (input_effect=="2") { r=hexToR(input_color3) g=hexToG(input_color3) b=hexToB(input_color3) rinc=(hexToR(input_color4)-r)/Math.floor(input_text.length/2) ginc=(hexToG(input_color4)-g)/Math.floor(input_text.length/2) binc=(hexToB(input_color4)-b)/Math.floor(input_text.length/2) for (a=0; a"+input_text.charAt(a)+""; str_bbcode+=''+input_text.charAt(a)+""; } if (a"+input_text.charAt(a)+""; str_bbcode+=''+input_text.charAt(a)+""; } if (a"+input_text+"" str_bbcode+=''+input_text+""; } else if (input_effect=="5") { var i=0; for (a=0; a=random_length) { str_html+=input_text.charAt(a) str_bbcode+=input_text.charAt(a) } else { if (input_colorword==0) { if (input_text.charAt(a)==" ") { str_html+=" "; str_bbcode+=" "; } else { str_html+=""+input_text.charAt(a)+""; str_bbcode+=''+input_text.charAt(a)+""; } } else { if (a==0 || input_text.charAt(a-1)==" ") { str_html+=""+input_text.charAt(a); str_bbcode+=''+input_text.charAt(a); } else if (a==input_text.length-1 || input_text.charAt(a)==" ") { str_html+=input_text.charAt(a)+""; str_bbcode+=input_text.charAt(a)+''; } else { str_html+=input_text.charAt(a); str_bbcode+=input_text.charAt(a); } } } } } else if (input_effect=="6") { var i,s,p; for (a=0; a=s*0) ccol=rgbToHex(255,255*p,0); if (i>=s*1) ccol=rgbToHex(255*(1-p),255,0); if (i>=s*2) ccol=rgbToHex(0,255,255*p); if (i>=s*3) ccol=rgbToHex(0,255*(1-p),255); if (i>=s*4) ccol=rgbToHex(255*p,0,255); if (i>=s*5) ccol=rgbToHex(255,0,255*(1-p)); if (input_text.charAt(a)==" ") { str_html+=" "; str_bbcode+=" "; } else { str_html+=""+input_text.charAt(a)+""; str_bbcode+=''+input_text.charAt(a)+""; } } } if (str_style!="") {str_html+=""} document.getElementById("div_preview").innerHTML=""+str_html+""; document.getElementById("output_bbcode").value=str_bbcode+str_bbcodeend; document.getElementById("output_html").value=str_html; } setTimeout(textcolorizer_handle,50) }