fork download
  1.  
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>devbanban.com</title>
  6. <script type="text/javascript">
  7. // <![CDATA[
  8. var bits=80; // how many bits
  9. var speed=33; // how fast - smaller is faster
  10. var bangs=20; // how many can be launched simultaneously (note that using too many can slow the script down)
  11. var colours=new Array("#03f", "#f03", "#0e0", "#93f", "#0cf", "#f93", "#f0c");
  12. // blue red green purple cyan orange pink
  13.  
  14. var bangheight=new Array();
  15. var intensity=new Array();
  16. var colour=new Array();
  17. var Xpos=new Array();
  18. var Ypos=new Array();
  19. var dX=new Array();
  20. var dY=new Array();
  21. var stars=new Array();
  22. var decay=new Array();
  23. var swide=800;
  24. var shigh=600;
  25. var boddie;
  26.  
  27. if (typeof('addRVLoadEvent')!='function') function addRVLoadEvent(funky) {
  28. var oldonload=window.onload;
  29. if (typeof(oldonload)!='function') window.onload=funky;
  30. else window.onload=function() {
  31. if (oldonload) oldonload();
  32. funky();
  33. }
  34. }
  35.  
  36. addRVLoadEvent(light_blue_touchpaper);
  37.  
  38. function light_blue_touchpaper() { if (document.getElementById) {
  39. var i;
  40. boddie=document.createElement("div");
  41. boddie.style.position="fixed";
  42. boddie.style.top="0px";
  43. boddie.style.left="0px";
  44. boddie.style.overflow="visible";
  45. boddie.style.width="1px";
  46. boddie.style.height="1px";
  47. boddie.style.backgroundColor="transparent";
  48. document.body.appendChild(boddie);
  49. set_width();
  50. for (i=0; i<bangs; i++) {
  51. write_fire(i);
  52. launch(i);
  53. setInterval('stepthrough('+i+')', speed);
  54. }
  55. }}
  56.  
  57. function write_fire(N) {
  58. var i, rlef, rdow;
  59. stars[N+'r']=createDiv('|', 12);
  60. boddie.appendChild(stars[N+'r']);
  61. for (i=bits*N; i<bits+bits*N; i++) {
  62. stars[i]=createDiv('*', 13);
  63. boddie.appendChild(stars[i]);
  64. }
  65. }
  66.  
  67. function createDiv(char, size) {
  68. var div=document.createElement("div");
  69. div.style.font=size+"px monospace";
  70. div.style.position="absolute";
  71. div.style.backgroundColor="transparent";
  72. div.appendChild(document.createTextNode(char));
  73. return (div);
  74. }
  75.  
  76. function launch(N) {
  77. colour[N]=Math.floor(Math.random()*colours.length);
  78. Xpos[N+"r"]=swide*0.5;
  79. Ypos[N+"r"]=shigh-5;
  80. bangheight[N]=Math.round((0.5+Math.random())*shigh*0.4);
  81. dX[N+"r"]=(Math.random()-0.5)*swide/bangheight[N];
  82. if (dX[N+"r"]>1.25) stars[N+"r"].firstChild.nodeValue="/";
  83. else if (dX[N+"r"]<-1.25) stars[N+"r"].firstChild.nodeValue="\\";
  84. else stars[N+"r"].firstChild.nodeValue="|";
  85. stars[N+"r"].style.color=colours[colour[N]];
  86. }
  87.  
  88. function bang(N) {
  89. var i, Z, A=0;
  90. for (i=bits*N; i<bits+bits*N; i++) {
  91. Z=stars[i].style;
  92. Z.left=Xpos[i]+"px";
  93. Z.top=Ypos[i]+"px";
  94. if (decay[i]) decay[i]--;
  95. else A++;
  96. if (decay[i]==15) Z.fontSize="7px";
  97. else if (decay[i]==7) Z.fontSize="2px";
  98. else if (decay[i]==1) Z.visibility="hidden";
  99. if (decay[i]>1 && Math.random()<.1) {
  100. Z.visibility="hidden";
  101. setTimeout('stars['+i+'].style.visibility="visible"', speed-1);
  102. }
  103. Xpos[i]+=dX[i];
  104. Ypos[i]+=(dY[i]+=1.25/intensity[N]);
  105.  
  106. }
  107. if (A!=bits) setTimeout("bang("+N+")", speed);
  108. }
  109.  
  110. function stepthrough(N) {
  111. var i, M, Z;
  112. var oldx=Xpos[N+"r"];
  113. var oldy=Ypos[N+"r"];
  114. Xpos[N+"r"]+=dX[N+"r"];
  115. Ypos[N+"r"]-=4;
  116. if (Ypos[N+"r"]<bangheight[N]) {
  117. M=Math.floor(Math.random()*3*colours.length);
  118. intensity[N]=5+Math.random()*4;
  119. for (i=N*bits; i<bits+bits*N; i++) {
  120. Xpos[i]=Xpos[N+"r"];
  121. Ypos[i]=Ypos[N+"r"];
  122. dY[i]=(Math.random()-0.5)*intensity[N];
  123. dX[i]=(Math.random()-0.5)*(intensity[N]-Math.abs(dY[i]))*1.25;
  124. decay[i]=16+Math.floor(Math.random()*16);
  125. Z=stars[i];
  126. if (M<colours.length) Z.style.color=colours[i%2?colour[N]:M];
  127. else if (M<2*colours.length) Z.style.color=colours[colour[N]];
  128. else Z.style.color=colours[i%colours.length];
  129. Z.style.fontSize="13px";
  130. Z.style.visibility="visible";
  131. }
  132. bang(N);
  133. launch(N);
  134. }
  135. stars[N+"r"].style.left=oldx+"px";
  136. stars[N+"r"].style.top=oldy+"px";
  137. }
  138.  
  139. window.onresize=set_width;
  140. function set_width() {
  141. var sw_min=999999;
  142. var sh_min=999999;
  143. if (document.documentElement && document.documentElement.clientWidth) {
  144. if (document.documentElement.clientWidth>0) sw_min=document.documentElement.clientWidth;
  145. if (document.documentElement.clientHeight>0) sh_min=document.documentElement.clientHeight;
  146. }
  147. if (typeof(self.innerWidth)!="undefined" && self.innerWidth) {
  148. if (self.innerWidth>0 && self.innerWidth<sw_min) sw_min=self.innerWidth;
  149. if (self.innerHeight>0 && self.innerHeight<sh_min) sh_min=self.innerHeight;
  150. }
  151. if (document.body.clientWidth) {
  152. if (document.body.clientWidth>0 && document.body.clientWidth<sw_min) sw_min=document.body.clientWidth;
  153. if (document.body.clientHeight>0 && document.body.clientHeight<sh_min) sh_min=document.body.clientHeight;
  154. }
  155. if (sw_min==999999 || sh_min==999999) {
  156. sw_min=800;
  157. sh_min=600;
  158. }
  159. swide=sw_min;
  160. shigh=sh_min;
  161. }
  162. // ]]>
  163. </script>
  164. </head>
  165. <body>
  166. <h1> Fireworks Animation </h1>
  167. </body>
  168. </html>
  169.  
Success #stdin #stdout 0.02s 26060KB
stdin
Standard input is empty
stdout
<html>
<head>
	<meta charset="utf-8">
	<title>devbanban.com</title>
	<script type="text/javascript">
// <![CDATA[
var bits=80; // how many bits
var speed=33; // how fast - smaller is faster
var bangs=20; // how many can be launched simultaneously (note that using too many can slow the script down)
var colours=new Array("#03f", "#f03", "#0e0", "#93f", "#0cf", "#f93", "#f0c"); 
//                     blue    red     green   purple  cyan    orange  pink
 
var bangheight=new Array();
var intensity=new Array();
var colour=new Array();
var Xpos=new Array();
var Ypos=new Array();
var dX=new Array();
var dY=new Array();
var stars=new Array();
var decay=new Array();
var swide=800;
var shigh=600;
var boddie;
 
if (typeof('addRVLoadEvent')!='function') function addRVLoadEvent(funky) {
  var oldonload=window.onload;
  if (typeof(oldonload)!='function') window.onload=funky;
  else window.onload=function() {
    if (oldonload) oldonload();
    funky();
  }
}
 
addRVLoadEvent(light_blue_touchpaper);
 
function light_blue_touchpaper() { if (document.getElementById) {
  var i;
  boddie=document.createElement("div");
  boddie.style.position="fixed";
  boddie.style.top="0px";
  boddie.style.left="0px";
  boddie.style.overflow="visible";
  boddie.style.width="1px";
  boddie.style.height="1px";
  boddie.style.backgroundColor="transparent";
  document.body.appendChild(boddie);
  set_width();
  for (i=0; i<bangs; i++) {
    write_fire(i);
    launch(i);
    setInterval('stepthrough('+i+')', speed);
  }
}}
 
function write_fire(N) {
  var i, rlef, rdow;
  stars[N+'r']=createDiv('|', 12);
  boddie.appendChild(stars[N+'r']);
  for (i=bits*N; i<bits+bits*N; i++) {
    stars[i]=createDiv('*', 13);
    boddie.appendChild(stars[i]);
  }
}
 
function createDiv(char, size) {
  var div=document.createElement("div");
  div.style.font=size+"px monospace";
  div.style.position="absolute";
  div.style.backgroundColor="transparent";
  div.appendChild(document.createTextNode(char));
  return (div);
}
 
function launch(N) {
  colour[N]=Math.floor(Math.random()*colours.length);
  Xpos[N+"r"]=swide*0.5;
  Ypos[N+"r"]=shigh-5;
  bangheight[N]=Math.round((0.5+Math.random())*shigh*0.4);
  dX[N+"r"]=(Math.random()-0.5)*swide/bangheight[N];
  if (dX[N+"r"]>1.25) stars[N+"r"].firstChild.nodeValue="/";
  else if (dX[N+"r"]<-1.25) stars[N+"r"].firstChild.nodeValue="\\";
  else stars[N+"r"].firstChild.nodeValue="|";
  stars[N+"r"].style.color=colours[colour[N]];
}
 
function bang(N) {
  var i, Z, A=0;
  for (i=bits*N; i<bits+bits*N; i++) { 
    Z=stars[i].style;
    Z.left=Xpos[i]+"px";
    Z.top=Ypos[i]+"px";
    if (decay[i]) decay[i]--;
    else A++;
    if (decay[i]==15) Z.fontSize="7px";
    else if (decay[i]==7) Z.fontSize="2px";
    else if (decay[i]==1) Z.visibility="hidden";
 if (decay[i]>1 && Math.random()<.1) {
    Z.visibility="hidden";
    setTimeout('stars['+i+'].style.visibility="visible"', speed-1);
 }
    Xpos[i]+=dX[i];
    Ypos[i]+=(dY[i]+=1.25/intensity[N]);
 
  }
  if (A!=bits) setTimeout("bang("+N+")", speed);
}
 
function stepthrough(N) { 
  var i, M, Z;
  var oldx=Xpos[N+"r"];
  var oldy=Ypos[N+"r"];
  Xpos[N+"r"]+=dX[N+"r"];
  Ypos[N+"r"]-=4;
  if (Ypos[N+"r"]<bangheight[N]) {
    M=Math.floor(Math.random()*3*colours.length);
    intensity[N]=5+Math.random()*4;
    for (i=N*bits; i<bits+bits*N; i++) {
      Xpos[i]=Xpos[N+"r"];
      Ypos[i]=Ypos[N+"r"];
      dY[i]=(Math.random()-0.5)*intensity[N];
      dX[i]=(Math.random()-0.5)*(intensity[N]-Math.abs(dY[i]))*1.25;
      decay[i]=16+Math.floor(Math.random()*16);
      Z=stars[i];
      if (M<colours.length) Z.style.color=colours[i%2?colour[N]:M];
      else if (M<2*colours.length) Z.style.color=colours[colour[N]];
      else Z.style.color=colours[i%colours.length];
      Z.style.fontSize="13px";
      Z.style.visibility="visible";
    }
    bang(N);
    launch(N);
  }
  stars[N+"r"].style.left=oldx+"px";
  stars[N+"r"].style.top=oldy+"px";
} 
 
window.onresize=set_width;
function set_width() {
  var sw_min=999999;
  var sh_min=999999;
  if (document.documentElement && document.documentElement.clientWidth) {
    if (document.documentElement.clientWidth>0) sw_min=document.documentElement.clientWidth;
    if (document.documentElement.clientHeight>0) sh_min=document.documentElement.clientHeight;
  }
  if (typeof(self.innerWidth)!="undefined" && self.innerWidth) {
    if (self.innerWidth>0 && self.innerWidth<sw_min) sw_min=self.innerWidth;
    if (self.innerHeight>0 && self.innerHeight<sh_min) sh_min=self.innerHeight;
  }
  if (document.body.clientWidth) {
    if (document.body.clientWidth>0 && document.body.clientWidth<sw_min) sw_min=document.body.clientWidth;
    if (document.body.clientHeight>0 && document.body.clientHeight<sh_min) sh_min=document.body.clientHeight;
  }
  if (sw_min==999999 || sh_min==999999) {
    sw_min=800;
    sh_min=600;
  }
  swide=sw_min;
  shigh=sh_min;
}
// ]]>
</script>
</head>
<body>
<h1> Fireworks Animation </h1>
</body>
</html>