rb___hexChars = "0123456789ABCDEF"; rb___lastColor = "000000"; function Dec2Hex (Dec) { var a = Dec % 16; var b = (Dec - a) / 16; hex = "" + rb___hexChars.charAt(b) + rb___hexChars.charAt(a); return hex; } function colorize(rbFlag, csFlag, cmFlag, startColor, endColor, colorShift, colorModify, smoothFlag, colorKill, text) { var name = 'RainbowText dynamic HTML parser and font colorizer'; var version = 'v1.52 (28 JUL 04)'; UnknownTours_com_textStream = ''; if ( rbFlag == 99 ) { alert('RainbowText javascript licensed for use by www.UnknownTours.com. \n\n' + 'LICENSEE: UnknownTours.COM\n\n' + 'DATE ISSUED: not listed\n\n' + 'EXPIRY: none') }; if ( rbFlag == 98 ) { alert(name + ', ' + version) }; ///////////////////////////////////////// // rbFlag: when 1 then text is rainbow colorized, randomly, while respecting // the primary and secondary colors specified // when 2 then text is blended from the primary color to the secondary // color (no rainbow effect) // when 3 then text is blended from the secondary color to the primary // color (no rainbow effect) // when 4 then text is rainbow colorized regardless of colors specified // (classic rainbow effect, red-grn-blu) // when 5 then text is rainbow colorized regardless of colors specified // (classic rainbow effect, blu-grn-red) // when 6 then text is rainbow colorized regardless of colors specified // (classic rainbow effect, red-blu-grn) // when 7 then text is rainbow colorized regardless of colors specified // (classic rainbow effect, grn-blu-red) // when 8 then text is rainbow colorized regardless of colors specified // (classic rainbow effect, blu-red-grn) // when 9 then text is rainbow colorized regardless of colors specified // (classic rainbow effect, grn-red-blu) // when 10 then text is rainbow colorized regardless of colors specified // (dynamic rainbow effect, initially purple-yellow-red -- red-blue-green) // 11 (internal use) // when 12 then text is rainbow colorized regardless of colors specified // (dynamic rainbow effect, initially yellow-blue-green -- green-blue-red) // 13 (internal use) // when 14 then text is rainbow colorized regardless of colors specified // (dynamic rainbow effect, initially blue-purple-green) // 15 (internal use) // // csFlag: when 1 then text is altered by randomly adjusting the endpoint // of the fade using the colorShift value as a range while // respecting the primary and secondary colors specified // (if colorShift < 1 no effect) // when 2 then text is altered by randomly adjusting the endpoint // of the fade using the full length of text sample as a range // (colorShift n/a) // // cmFlag: when 1 then text is altered by randomly adjusting the second color // using the colorModify value as a range (if colorModify < 1 no effect) // var textSample = ""; var fadeFromColor = startColor; var fadeToColor = endColor; var startPos = 0; var endPos = Math.round(text.length / 2) + colorShift; var rrr; var amper_test = ""; var creditLine = "This website uses www.RainbowText.com - you should too!"; var writeCreditLine = 0; if ( text == creditLine ) { writeCreditLine = 1; rbFlag = Math.round( Math.random()*4 ) + 5; // 4-9 csFlag = 0; cmFlag = 0; colorShift = 0; colorModify = 0; smoothFlag = 1; colorKill = Math.round( Math.random()*3 ); // 0-3 //alert(colorKill); document.write('You are '); document.write(''); text = "viewing a RainbowText website because color on the Internet is a&/xa"; }; //if (rbFlag == 0) { // var pre_format = ""; // var post_format = ""; // document.write(pre_format + text + post_format); // } else { if (csFlag == 1) { rrr = (Math.floor(Math.random() * 100) + 1); if (rrr > 50 ) { endPos = Math.round(text.length / 2) + (Math.floor(Math.random() * colorShift) + 1) } else { endPos = Math.round(text.length / 2) - (Math.floor(Math.random() * colorShift) + 1) }; }; if (csFlag == 2) { rrr = (Math.floor(Math.random() * 100) + 1); if (rrr > 50 ) { endPos = Math.round(text.length / 2) + (Math.floor(Math.random() * Math.round(text.length / 2.5) ) + 1) } else { endPos = Math.round(text.length / 2) - (Math.floor(Math.random() * Math.round(text.length / 2.5) ) + 1) }; }; // ensure we don't start on the semi-colon of a prior control sequence if (text.substring(endPos, endPos + 1) == ";" ) { endPos ++; //alert('starting with ;'); }; // ensure we do not end on an ampersand (or chop a control sequence) for(var i = 0; i < 6; i++) { amper_test = text.substring(endPos - i,endPos) if (amper_test.substring(0,1) == "&") { endPos = endPos - i; }; }; // enforce bounds if (endPos <= startPos) { endPos = startPos + 1 }; if (endPos > text.length) { endPos = text.length }; colorMod = colorModify; if (cmFlag == 1) { colorMod = Math.floor(Math.random() * colorModify) + 1 }; if (rbFlag == 2) { ////// simple fade from one color to another endPos = text.length; // fade from first color to second textSample = text.substring(startPos, endPos); fadeMeister(rbFlag, fadeFromColor, fadeToColor, colorMod, colorKill, textSample); } else if (rbFlag == 3) { ////// simple fade from one color to another endPos = text.length; // fade from second color to first textSample = text.substring(startPos, endPos); fadeMeister(rbFlag, fadeToColor, fadeFromColor, colorMod, colorKill, textSample); } else if (rbFlag == 20) { ////// red-white-blue fade (stark) textSample = text.substring(startPos, endPos); fadeMeister(rbFlag, "ff0000", "ffffff", colorMod, colorKill, textSample); // fade back from last color used to first color //fadeFromColor = rb___lastColor; //fadeToColor = startColor; startPos = endPos; endPos = text.length; textSample = text.substring(startPos, endPos); fadeMeister(rbFlag, "ffffff", "0000ff", colorMod, colorKill, textSample); } else if (rbFlag == 21) { ////// red-white-blue fade (softened) textSample = text.substring(startPos, endPos); fadeMeister(rbFlag, "ff6868", "ffffff", colorMod, colorKill, textSample); // fade back from last color used to first color //fadeFromColor = rb___lastColor; //fadeToColor = startColor; startPos = endPos; endPos = text.length; textSample = text.substring(startPos, endPos); fadeMeister(rbFlag, "ffffff", "6868ff", colorMod, colorKill, textSample); } else { ////// process bi-fading rainbow effect // fade from first color to second textSample = text.substring(startPos, endPos); //alert(textSample); fadeMeister(rbFlag, fadeFromColor, fadeToColor, colorMod, colorKill, textSample); // fade back from last color used to first color fadeFromColor = rb___lastColor; fadeToColor = startColor; startPos = endPos; endPos = text.length; // do smooth fades if (smoothFlag == 1) { switch ( rbFlag ) { case 4: rbFlag = 5; colorKill--; break; case 5: rbFlag = 4; colorKill--; break; case 6: rbFlag = 7; colorKill--; break; case 7: rbFlag = 6; colorKill--; break; case 8: rbFlag = 9; colorKill--; break; case 9: rbFlag = 8; colorKill--; break; case 10: rbFlag = 11; colorKill--; break; case 11: rbFlag = 10; colorKill--; break; case 12: rbFlag = 13; colorKill--; break; case 13: rbFlag = 12; colorKill--; break; case 14: rbFlag = 15; colorKill--; break; case 15: rbFlag = 14; colorKill--; break; }; } textSample = text.substring(startPos, endPos); //startColoralert(textSample); fadeMeister(rbFlag, fadeFromColor, fadeToColor, colorMod, colorKill, textSample); } if ( writeCreditLine ) { RainbowText_com_textStream = RainbowText_com_textStream + " good thing." }; } //} function fadeMeister (rbFlag, startColor, endColor, modifyFade, colorKill, textIn) { // The fadeMeister function is adapted from a script by Jenny Lam, // if anyone else should be credited insert your name [here] // // The functions colorize and fadeMeister are created by the MothMan // exclusively for RainbowText.com -- don't try these at home alone // // The parser respects the codes for quotes, non-breaking spaces, and other // assorted goodies // var steps = textIn.length; var shift = modifyFade; var flagtext = ""; var forwardAdjust = 0; var pre_fix = ""; var colorZero = colorKill; //if (rbFlag == 2) { alert(steps) }; redA = startColor.charAt(0) + startColor.charAt(1); red_valA = parseInt(redA,'16'); redB = endColor.charAt(0) + endColor.charAt(1); red_valB = parseInt(redB,'16'); red_int = ((red_valB - red_valA) / (steps + shift)) * -1; grnA = startColor.charAt(2) + startColor.charAt(3); grn_valA = parseInt(grnA,'16'); grnB = endColor.charAt(2) + endColor.charAt(3); grn_valB = parseInt(grnB,'16'); grn_int = ((grn_valB - grn_valA) / (steps + shift)) * -1; grn_int = grn_int + 0; bluA = startColor.charAt(4) + startColor.charAt(5); blu_valA = parseInt(bluA,'16'); bluB = endColor.charAt(4) + endColor.charAt(5); blu_valB = parseInt(bluB,'16'); blu_int = ((blu_valB - blu_valA) / (steps + shift)) * -1; blu_int = blu_int - 0; red = red_valA; grn = grn_valA; blu = blu_valA; rbt_base = (Math.floor(Math.random() * 255) + 1); rbt_mod1 = 0; for(var i = 0; i < steps; i++) { outputChar = textIn.substring(i,i + 1); pre_fix = ""; if (outputChar == "&") { flagText = textIn.substring(i + 1,i + 4); switch ( flagText.toUpperCase() ) { case "QSR": outputChar = "’"; forwardAdjust = 6; break; case "RSQ": outputChar = "’"; // assumes "’" forwardAdjust = 6; break; // // case "QDR": outputChar = "”"; forwardAdjust = 6; break; case "RDQ": outputChar = "”"; // assumes "”" forwardAdjust = 6; break; // // case "QSL": outputChar = "‘"; forwardAdjust = 6; break; case "LSQ": outputChar = "‘"; // assumes "‘" forwardAdjust = 6; break; // // case "QDL": outputChar = "“"; forwardAdjust = 6; break; case "LDQ": outputChar = "“"; // assumes "“" forwardAdjust = 6; break; // // case "NBS": outputChar = " "; // assumes " " forwardAdjust = 5; break; // // case "MDA": outputChar = "—"; // assumes "—" forwardAdjust = 6; break; // // case "/B1": outputChar = ""; // Note: the output is chopped like this so the page will properly // validate at http://www.htmlhelp.com/tools/validator/ // otherwise the validator gets confused seeing the tags // and not realizing these are variables (stuuu-pid validator) forwardAdjust = 3; break; // // case "/B0": outputChar = ""; forwardAdjust = 3; break; // // case "/I1": outputChar = ""; forwardAdjust = 3; break; // // case "/I0": outputChar = ""; forwardAdjust = 3; break; // // case "/Y1": outputChar = ""; forwardAdjust = 3; break; // // case "/Y0": outputChar = ""; forwardAdjust = 3; break; // // case "/Z1": outputChar = ""; forwardAdjust = 3; break; // // case "/Z0": outputChar = ""; forwardAdjust = 3; break; // // case "/CR": outputChar = "
"; forwardAdjust = 3; pre_fix = ""; break; // // case "/S1": outputChar = "¹"; // Superscript 1 forwardAdjust = 3; pre_fix = ""; break; // // case "/S2": outputChar = "²"; // Superscript 2 forwardAdjust = 3; pre_fix = ""; break; // // case "/S3": outputChar = "³"; // Superscript 3 forwardAdjust = 3; pre_fix = ""; break; // // case "/S4": outputChar = "•"; // Middle dot forwardAdjust = 3; pre_fix = ""; break; // // case "DEG": outputChar = "°"; // assumes ° // Degree symbol forwardAdjust = 4; pre_fix = ""; break; // // case "/XA": outputChar = "
"; // assumes close anchor; forwardAdjust = 3; pre_fix = ""; rbFlag = 0; break; // // default: forwardAdjust = 0; }; i = i + forwardAdjust; } rbt_text = rbt_base * Math.sin(i / (steps / 3)); // red color red-= red_int; if (rbFlag == 4 || rbFlag == 6) { j = steps - i; if (j < 0) { j = 0 }; red = (255 / steps ) * j; }; //first if (rbFlag == 5 || rbFlag == 7) { red = (255 / steps) * i }; //end if (rbFlag == 8 || rbFlag == 9) { red = 255 * Math.sin(i / (steps / 3)) }; //mid if (rbFlag == 10) { red = 255 }; if (rbFlag == 14) { red = (255 / steps) * i }; //if (rbFlag == 21) { red = 0 }; if (rbFlag == 8 || rbFlag == 9) { if (colorZero == 1 || colorZero == 3) { red = 0 }; }; red_round = Math.round(red); red_hex = Dec2Hex(red); //green color grn-= grn_int; if (rbFlag == 1) { grn = rbt_text }; if (rbFlag == 4 || rbFlag == 5) { grn = 255 * Math.sin(i / (steps / 3)) }; //mid if (rbFlag == 6 || rbFlag == 8) { grn = (255 / steps) * i }; //end if (rbFlag == 7 || rbFlag == 9) { j = steps - i; if (j < 0) { j = 0 }; grn = (255 / steps ) * j; }; //first if (rbFlag == 10) { grn = 255 * Math.sin(i / (steps / 3)) }; if (rbFlag == 12) { grn = 255 }; if (rbFlag == 14) { grn = 255 * Math.sin(i / (steps / 3)) }; if (rbFlag == 15) { grn = (255 / steps) * i }; //if (rbFlag == 20) ( grn = 0 ); //if (rbFlag == 21) ( grn = 0 ); if (rbFlag == 4 || rbFlag == 5) { if (colorZero == 1 || colorZero == 3) { grn = 0 }; }; grn_round = Math.round(grn); grn_hex = Dec2Hex(grn); // blue color blu-= blu_int; if (rbFlag == 4 || rbFlag == 9) { blu = (255 / steps) * i }; //end if (rbFlag == 6 || rbFlag == 7) { blu = 255 * Math.sin(i / (steps / 3)) }; //mid if (rbFlag == 5 || rbFlag == 8) { j = steps - i; if (j < 0) { j = 0 }; blu = (255 / steps ) * j; }; //first if (rbFlag == 10) { blu = 255 * Math.cos(i / (steps / 3)) }; if (rbFlag == 11) { blu = 255 * Math.sin(i / (steps / 3)) }; if (rbFlag == 12) { blu = 255 * Math.sin(i / (steps / 3)) }; if (rbFlag == 13) { blu = 255 * Math.sin(i / (steps / 3)) }; if (rbFlag == 14) { blu = 255 }; //if (rbFlag == 20) { blu = 0 }; //if (rbFlag == 21) { blu = 255 }; if (rbFlag == 6 || rbFlag == 7) { if (colorZero == 1 || colorZero == 3) { blu = 0 }; }; blu_round = Math.round(blu); blu_hex = Dec2Hex(blu); hex_Color = red_hex + grn_hex + blu_hex; rb___lastColor = hex_Color; font_Color = "#" + hex_Color; var pre_format = pre_fix + ""; var post_format = ""; //document.write(pre_format + outputChar + post_format); //eval(writeLicensee = writeLicensee + pre_format + outputChar + post_format + ';'); UnknownTours_com_textStream = UnknownTours_com_textStream + pre_format + outputChar + post_format; } }