reijeo

rain mf2fm

Jul 16th, 2022
473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. <script type="text/javascript">
  2. // <![CDATA[
  3. var speed=33; // lower number for faster
  4. var drops=100; // number of 'drops'
  5. var colour="#999"; // colour of drops (generally grey!)
  6.  
  7. /***************************\
  8. * Rainy Afternoon Effect *
  9. *(c)2011-13 mf2fm web-design*
  10. * http://www.mf2fm.com/rv *
  11. * DON'T EDIT BELOW THIS BOX *
  12. \***************************/
  13.  
  14. var flks=new Array();
  15. var flkx=new Array();
  16. var flky=new Array();
  17. var fldy=new Array();
  18. var swide, shigh, boddie;
  19. var ie_version=(navigator.appVersion.indexOf("MSIE")!=-1)?parseFloat(navigator.appVersion.split("MSIE")[1]):false;
  20.  
  21. function addLoadEvent(funky) {
  22. var oldonload=window.onload;
  23. if (typeof(oldonload)!='function') window.onload=funky;
  24. else window.onload=function() {
  25. if (oldonload) oldonload();
  26. funky();
  27. }
  28. }
  29.  
  30. addLoadEvent(storm);
  31.  
  32. function storm() { if (document.getElementById) {
  33. var r1, r2;
  34. boddie=document.createElement("div");
  35. boddie.style.position="fixed";
  36. boddie.style.top="0px";
  37. boddie.style.left="0px";
  38. boddie.style.width="1px";
  39. boddie.style.height="1px";
  40. boddie.style.overflow="visible";
  41. boddie.style.backgroundColor="transparent";
  42. document.body.appendChild(boddie);
  43. set_width();
  44. for (var i=0; i<drops; i++) {
  45. flks[i]=createDiv(16, 2, "transparent");
  46. r1=createDiv(6, 2, colour);
  47. r1.style.top="10px";
  48. r1.style.left="0px";
  49. flks[i].appendChild(r1);
  50. r2=createDiv(10, 2, colour);
  51. r2.style.top="0px";
  52. r2.style.left="0px";
  53. if (ie_version && ie_version<10) r2.style.filter="alpha(opacity=25)";
  54. else r2.style.opacity=0.25;
  55. flks[i].appendChild(r2);
  56. flkx[i]=2*Math.floor(Math.random()*swide/2);
  57. flky[i]=Math.floor(Math.random()*shigh);
  58. fldy[i]=2+Math.floor(Math.random()*4);
  59. flks[i].style.left=flkx[i]+"px";
  60. flks[i].style.top=flky[i]+"px";
  61. boddie.appendChild(flks[i]);
  62. }
  63. setInterval("cats_and_dogs()", speed);
  64. }}
  65.  
  66. function createDiv(height, width, colour) {
  67. var div=document.createElement("div");
  68. div.style.position="absolute";
  69. div.style.height=height+"px";
  70. div.style.width=width+"px";
  71. div.style.overflow="hidden";
  72. div.style.backgroundColor=colour;
  73. return (div);
  74. }
  75.  
  76. window.onresize=set_width;
  77. function set_width() {
  78. var sw_min=999999;
  79. var sh_min=999999;
  80. if (document.documentElement && document.documentElement.clientWidth) {
  81. sw_min=document.documentElement.clientWidth;
  82. sh_min=document.documentElement.clientHeight;
  83. }
  84. if (typeof(self.innerWidth)!="undefined" && self.innerWidth) {
  85. if (self.innerWidth<sw_min) sw_min=self.innerWidth;
  86. if (self.innerHeight<sh_min) sh_min=self.innerHeight;
  87. }
  88. if (document.body.clientWidth) {
  89. if (document.body.clientWidth<sw_min) sw_min=document.body.clientWidth;
  90. if (document.body.clientHeight<sh_min) sh_min=document.body.clientHeight;
  91. }
  92. if (sw_min==999999 || sh_min==999999) {
  93. sw_min=800;
  94. sh_min=600;
  95. }
  96. swide=sw_min-2;
  97. shigh=sh_min;
  98. }
  99.  
  100. function cats_and_dogs(c) {
  101. var i, x, o=0;
  102. for (i=0; i<drops; i++) {
  103. flky[i]+=fldy[i];
  104. if (flky[i]>=shigh-16) {
  105. flky[i]=-16;
  106. fldy[i]=2+Math.floor(Math.random()*4);
  107. flkx[i]=2*Math.floor(Math.random()*swide/2);
  108. flks[i].style.left=flkx[i]+"px";
  109. }
  110. flks[i].style.top=flky[i]+"px";
  111. }
  112. }
  113. // ]]>
  114. </script>
Advertisement
Add Comment
Please, Sign In to add comment