|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#16
|
||||
|
||||
|
CONGRATULATIONS
Dragon Rider and HAPPY BIRTHDAY!!! (this was created using this code: Code:
<html>
<head>
<title>Colorful Text Generator</title>
<script type="text/javascript">
function MakeRandom(objForm)
{
var strText=objForm.elements["text"].value;
var strRandom="";
for (var i=0; i<strText.length; i++)
{
strRandom += "[Color="+GetRandomColor()+"]"+strText.charAt(i)+"[/Color]";
}
objForm.elements["result"].value = strRandom;
PutPreview(strRandom);
return false;
}
function PutPreview(strText)
{
var strHtml=strText;
strHtml = strHtml.replace(/\[Color=/g, "<span style=\"color: ");
strHtml = strHtml.replace(/\[\/Color\]/g, "</span>");
strHtml = strHtml.replace(/\]/g, ";\">");
document.getElementById("Preview").innerHTML = strHtml;
}
function GetRandomColor()
{
var R=GetRandom(0, 256);
var G=GetRandom(0, 256);
var B=GetRandom(0, 256);
R = IntToHex(R);
G = IntToHex(G);
B = IntToHex(B);
return "#"+R+G+B;
}
function IntToHex(num)
{
if (num < 0)
return "-"+(-1*num);
if (num < 10)
return num;
switch (num)
{
case 10:
return "a";
case 11:
return "b";
case 12:
return "c";
case 13:
return "d";
case 14:
return "e";
case 15:
return "f";
}
return IntToHex(parseInt(num/16))+IntToHex(num % 16);
}
function GetRandom(min, max)
{
return parseInt(Math.random()*(max-min)+min);
}
</script>
</head>
<body>
<form onsubmit="return MakeRandom(this);">
Text: <input type="text" name="text" /><br />
Result: <input type="text" name="result" readonly="readonly" /> <span id="Preview" style="font-weight: bold;"></span><br />
<button type="submit">Put Colors!</button>
</form>
</body>
</html>
![]() ) |
|
#17
|
||||
|
||||
|
Quote:
whos mesie??? |
|
#18
|
||||
|
||||
|
Quote:
Do you prefer "senior"? ![]()
__________________
I'm smarter in my mother tongue.
|
|
#19
|
||||
|
||||
|
Quote:
wow that's lots of points for little script... feel free to use it yourself, everyone! ![]() |
|
#20
|
||||
|
||||
|
Quote:
Thanks Shadow, i have hosted it here to make it really easy for people ![]()
__________________
|
|
#21
|
||||
|
||||
|
nowwecanallhavecolourfulpoststhankstoshadow!!
|
|
#22
|
|||
|
|||
|
Froggie, can you make the background of that web page darker so that it's easier to read the text
that'd be Gr0o0o0o0o0o0o0ovy |
|
#23
|
||||
|
||||
|
Quote:
hmm... 1. blank space bug - the code also add color tags to blank spaces, it should not do that. 2. challenge: add code that auto-select all the text in the Result box once it get focus. easier to Copy and Paste this way.... ![]() 3. challenge2: add textbox to define the size... this will add [Size=x] tag around the whole Result. (12 points for each challenge) thanks for hosting! Last edited by Shadow Wizard : September 19th, 2005 at 07:13 PM. Reason: another challenge |
|
#24
|
||||
|
||||
|
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Colorful Text Generator</title> <script type="text/javascript"> function MakeRandom(objForm) { var strText=objForm.elements["text"].value; var strRandom=""; for (var i=0; i<strText.length; i++) { if (strText.charAt(i)==' '){strRandom +=' '} else {strRandom += "[Color="+GetRandomColor()+"]"+strText.charAt(i)+"[/Color]";} } objForm.elements["result"].value = '[size=' + objForm.elements["size"].value + ']' + strRandom + '[/size]'; PutPreview(strRandom); return false; } function PutPreview(strText) { var strHtml=strText; strHtml = strHtml.replace(/\[Color=/g, "<span style=\"color: "); strHtml = strHtml.replace(/\[\/Color\]/g, "</span>"); strHtml = strHtml.replace(/\]/g, ";\">"); document.getElementById("Preview").innerHTML = strHtml; } function GetRandomColor() { var R=GetRandom(0, 256); var G=GetRandom(0, 256); var B=GetRandom(0, 256); R = IntToHex(R); G = IntToHex(G); B = IntToHex(B); return "#"+R+G+B; } function IntToHex(num) { if (num < 0) return "-"+(-1*num); if (num < 10) return num; switch (num) { case 10: return "a"; case 11: return "b"; case 12: return "c"; case 13: return "d"; case 14: return "e"; case 15: return "f"; } return IntToHex(parseInt(num/16))+IntToHex(num % 16); } function GetRandom(min, max) { return parseInt(Math.random()*(max-min)+min); } </script> </head> <body> <form onsubmit="return MakeRandom(this);" action="."> <p> Text: <textarea name="text"></textarea><br /> Size: <input type="text" name="size" size="1" value="3" /><br /> Result: <textarea name="result" readonly="readonly" onfocus="this.select();"></textarea> <span id="Preview" style="font-weight: bold;"></span><br /> <button type="submit">Put Colors!</button> </p> </form> </body> </html> [edit]Highlighted changes[/edit] [edit again]Made into textareas for multiple-line copy and paste. Last edited by markisdee : September 19th, 2005 at 07:41 PM. |
|
#25
|
||||
|
||||
|
Quote:
hopefully there is not any text that colour i have tested it and there doesn't seem to be any!!RF |