Advertisement
EmilyTozerr

Raining Nutella

Jun 27th, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. <script type="text/javascript">
  2.  
  3. /******************************************
  4. * raining nutella by inspir1ng
  5. * enjoy !
  6. ******************************************/
  7.  
  8. //Change below to change url for the nutella
  9. var snowsrc="http://i991.photobucket.com/albums/af37/mstrawberry24/tumblr_lpw66doDXw1ql1l0v.gif"
  10. // change below to change number of nutella to fall
  11. var no = 20;
  12. // change whether nutella should disappear after x seconds (0=never):
  13. var hidesnowtime = 0;
  14. // change how many nutellas should drop down before fading ("windowheight" or "pageheight")
  15. var snowdistance = "pageheight";
  16.  
  17. ///////////Stop Config//////////////////////////////////
  18.  
  19. var ie4up = (document.all) ? 1 : 0;
  20. var ns6up = (document.getElementById&&!document.all) ? 1 : 0;
  21.  
  22. function iecompattest(){
  23. return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
  24. }
  25.  
  26. var dx, xp, yp; // coordinate and position variables
  27. var am, stx, sty; // amplitude and step variables
  28. var i, doc_width = 800, doc_height = 600;
  29.  
  30. if (ns6up) {
  31. doc_width = self.innerWidth;
  32. doc_height = self.innerHeight;
  33. } else if (ie4up) {
  34. doc_width = iecompattest().clientWidth;
  35. doc_height = iecompattest().clientHeight;
  36. }
  37.  
  38. dx = new Array();
  39. xp = new Array();
  40. yp = new Array();
  41. am = new Array();
  42. stx = new Array();
  43. sty = new Array();
  44. snowsrc=(snowsrc.indexOf("dynamicdrive.com")!=-1)? "snow.gif" : snowsrc
  45. for (i = 0; i < no; ++ i) {
  46. dx[i] = 0; // set coordinate variables
  47. xp[i] = Math.random()*(doc_width-50); // set position variables
  48. yp[i] = Math.random()*doc_height;
  49. am[i] = Math.random()*20; // set amplitude variables
  50. stx[i] = 0.02 + Math.random()/10; // set step variables
  51. sty[i] = 0.7 + Math.random(); // set step variables
  52. if (ie4up||ns6up) {
  53. if (i == 0) {
  54. document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><a href=\"http://www.snazzyspace.com\"><img src='"+snowsrc+"' border=\"0\"><\/a><\/div>");
  55. } else {
  56. document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+snowsrc+"' border=\"0\"><\/div>");
  57. }
  58. }
  59. }
  60. /******************************************
  61. * do not edit
  62. ******************************************/
  63. function snowIE_NS6() { // IE and NS6 main animation function
  64. doc_width = ns6up?window.innerWidth-10 : iecompattest().clientWidth-10;
  65. doc_height=(window.innerHeight && snowdistance=="windowheight")? window.innerHeight : (ie4up && snowdistance=="windowheight")? iecompattest().clientHeight : (ie4up && !window.opera && snowdistance=="pageheight")? iecompattest().scrollHeight : iecompattest().offsetHeight;
  66. for (i = 0; i < no; ++ i) { // iterate for every dot
  67. yp[i] += sty[i];
  68. if (yp[i] > doc_height-50) {
  69. xp[i] = Math.random()*(doc_width-am[i]-30);
  70. yp[i] = 0;
  71. stx[i] = 0.02 + Math.random()/10;
  72. sty[i] = 0.7 + Math.random();
  73. }
  74. dx[i] += stx[i];
  75. document.getElementById("dot"+i).style.top=yp[i]+"px";
  76. document.getElementById("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i])+"px";
  77. }
  78. snowtimer=setTimeout("snowIE_NS6()", 10);
  79. }
  80.  
  81. function hidesnow(){
  82. if (window.snowtimer) clearTimeout(snowtimer)
  83. for (i=0; i<no; i++) document.getElementById("dot"+i).style.visibility="hidden"
  84. }
  85.  
  86.  
  87. if (ie4up||ns6up){
  88. snowIE_NS6();
  89. if (hidesnowtime>0)
  90. setTimeout("hidesnow()", hidesnowtime*1000)
  91. }
  92.  
  93. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement