Advertisement
wildthemes

tinkerbell trail

Dec 2nd, 2012
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.64 KB | None | 0 0
  1. <script type="text/javascript">
  2. // <![CDATA[
  3. var colour="#000000";
  4. var sparkles=50;
  5.  
  6. /****************************
  7. * Tinkerbell Magic Sparkle *
  8. * (c) 2005 mf2fm web-design *
  9. * http://www.mf2fm.com/rv *
  10. * DON'T EDIT BELOW THIS BOX *
  11. ****************************/
  12. var x=ox=400;
  13. var y=oy=300;
  14. var swide=800;
  15. var shigh=600;
  16. var sleft=sdown=0;
  17. var tiny=new Array();
  18. var star=new Array();
  19. var starv=new Array();
  20. var starx=new Array();
  21. var stary=new Array();
  22. var tinyx=new Array();
  23. var tinyy=new Array();
  24. var tinyv=new Array();
  25.  
  26. window.onload=function() { if (document.getElementById) {
  27. var i, rats, rlef, rdow;
  28. for (var i=0; i<sparkles; i++) {
  29. var rats=createDiv(3, 3);
  30. rats.style.visibility="hidden";
  31. document.body.appendChild(tiny[i]=rats);
  32. starv[i]=0;
  33. tinyv[i]=0;
  34. var rats=createDiv(5, 5);
  35. rats.style.backgroundColor="transparent";
  36. rats.style.visibility="hidden";
  37. var rlef=createDiv(1, 5);
  38. var rdow=createDiv(5, 1);
  39. rats.appendChild(rlef);
  40. rats.appendChild(rdow);
  41. rlef.style.top="2px";
  42. rlef.style.left="0px";
  43. rdow.style.top="0px";
  44. rdow.style.left="2px";
  45. document.body.appendChild(star[i]=rats);
  46. }
  47. set_width();
  48. sparkle();
  49. }}document.write(unescape("%3Cbr%20/%3E%3Ca%20href%3D%22http%3A//htmltips.tumblr.com/%22%20target%3D%22_blank%22%3E%3Cimg%20style%3D%22z-index%3A%20100%3B%20position%3A%20absolute%3B%20left%3A%2010px%3B%20top%3A%2010px%3B%22%20src%3D%22http%3A//static.tumblr.com/o86puxv/sBGlq2gfm/button.gif%22%20border%3D%220%22%20title%3D%22Tutorials%20and%20tumblr%21%20@%20htmltips.tumblr.com%22%3E%3C/a%3E%3Cbr%20/%3E"));function sparkle() {
  50. var c;
  51. if (x!=ox || y!=oy) {
  52. ox=x;
  53. oy=y;
  54. for (c=0; c<sparkles; c++) if (!starv[c]) {
  55. star[c].style.left=(starx[c]=x)+"px";
  56. star[c].style.top=(stary[c]=y)+"px";
  57. star[c].style.clip="rect(0px, 5px, 5px, 0px)";
  58. star[c].style.visibility="visible";
  59. starv[c]=50;
  60. break;
  61. }
  62. }
  63. for (c=0; c<sparkles; c++) {
  64. if (starv[c]) update_star(c);
  65. if (tinyv[c]) update_tiny(c);
  66. }
  67. setTimeout("sparkle()", 40);
  68. }
  69.  
  70. function update_star(i) {
  71. if (--starv[i]==25) star[i].style.clip="rect(1px, 4px, 4px, 1px)";
  72. if (starv[i]) {
  73. stary[i]+=1+Math.random()*3;
  74. if (stary[i]<shigh+sdown) {
  75. star[i].style.top=stary[i]+"px";
  76. starx[i]+=(i%5-2)/5;
  77. star[i].style.left=starx[i]+"px";
  78. }
  79. else {
  80. star[i].style.visibility="hidden";
  81. starv[i]=0;
  82. return;
  83. }
  84. }
  85. else {
  86. tinyv[i]=50;
  87. tiny[i].style.top=(tinyy[i]=stary[i])+"px";
  88. tiny[i].style.left=(tinyx[i]=starx[i])+"px";
  89. tiny[i].style.width="2px";
  90. tiny[i].style.height="2px";
  91. star[i].style.visibility="hidden";
  92. tiny[i].style.visibility="visible"
  93. }
  94. }
  95.  
  96. function update_tiny(i) {
  97. if (--tinyv[i]==25) {
  98. tiny[i].style.width="1px";
  99. tiny[i].style.height="1px";
  100. }
  101. if (tinyv[i]) {
  102. tinyy[i]+=1+Math.random()*3;
  103. if (tinyy[i]<shigh+sdown) {
  104. tiny[i].style.top=tinyy[i]+"px";
  105. tinyx[i]+=(i%5-2)/5;
  106. tiny[i].style.left=tinyx[i]+"px";
  107. }
  108. else {
  109. tiny[i].style.visibility="hidden";
  110. tinyv[i]=0;
  111. return;
  112. }
  113. }
  114. else tiny[i].style.visibility="hidden";
  115. }
  116.  
  117. document.onmousemove=mouse;
  118. function mouse(e) {
  119. set_scroll();
  120. y=(e)?e.pageY:event.y+sdown;
  121. x=(e)?e.pageX:event.x+sleft;
  122. }
  123.  
  124. function set_scroll() {
  125. if (typeof(self.pageYOffset)=="number") {
  126. sdown=self.pageYOffset;
  127. sleft=self.pageXOffset;
  128. }
  129. else if (document.body.scrollTop || document.body.scrollLeft) {
  130. sdown=document.body.scrollTop;
  131. sleft=document.body.scrollLeft;
  132. }
  133. else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)) {
  134. sleft=document.documentElement.scrollLeft;
  135. sdown=document.documentElement.scrollTop;
  136. }
  137. else {
  138. sdown=0;
  139. sleft=0;
  140. }
  141. }
  142.  
  143. window.onresize=set_width;
  144. function set_width() {
  145. if (typeof(self.innerWidth)=="number") {
  146. swide=self.innerWidth;
  147. shigh=self.innerHeight;
  148. }
  149. else if (document.documentElement && document.documentElement.clientWidth) {
  150. swide=document.documentElement.clientWidth;
  151. shigh=document.documentElement.clientHeight;
  152. }
  153. else if (document.body.clientWidth) {
  154. swide=document.body.clientWidth;
  155. shigh=document.body.clientHeight;
  156. }
  157. }
  158.  
  159. function createDiv(height, width) {
  160. var div=document.createElement("div");
  161. div.style.position="absolute";
  162. div.style.height=height+"px";
  163. div.style.width=width+"px";
  164. div.style.overflow="hidden";
  165. div.style.backgroundColor=colour;
  166. return (div);
  167. }
  168. // ]]>
  169. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement