Author: KIZIL BULUT Language: javascript
Description: Not specified Timestamp: 2018-01-19 23:11:33 +0000
View raw paste Reply
  1. var smokeyness=100; // how much smoke is on the screen (more will slow the script down)
  2. var density=40; // how 'big' is the smoke
  3.  
  4. var swide=800;
  5. var shigh=600;
  6. var toke=new Array();
  7. var tokex=new Array();
  8. var tokedx=new Array();
  9. var tokey=new Array();
  10. var nicotine=new Array();
  11. var mousedown=false;
  12. var x=400;
  13. var y=300;
  14. var sleft=sdown=0;
  15. var ie_version=(navigator.appVersion.indexOf("MSIE")!=-1)?parseFloat(navigator.appVersion.split("MSIE")[1]):false;
  16.  
  17. function addLoadEvent(funky) {
  18.   var oldonload=window.onload;
  19.   if (typeof(oldonload)!='function') window.onload=funky;
  20.   else window.onload=function() {
  21.     if (oldonload) oldonload();
  22.     funky();
  23.   }
  24. }
  25.  
  26. addLoadEvent(puff);
  27.  
  28. function puff() { if (document.getElementById) {
  29.   var i, fag;
  30.   for (i=0; i<smokeyness; i++) {
  31.     fag=document.createElement("div");
  32.     toke[i]=fag.style;
  33.     toke[i].position="absolute";
  34.     toke[i].backgroundColor="transparent";
  35.     toke[i].font="bold "+density+"px Tahoma, Geneva, sans-serif";
  36.     toke[i].color="rgba(234,234,234,0.033)";
  37.     toke[i].zIndex="9999";
  38.     toke[i].pointerEvents="none";
  39.     toke[i].visibility="hidden";
  40.     fag.appendChild(document.createTextNode(String.fromCharCode('0x25CF')));
  41.  
  42.     document.body.appendChild(fag);
  43.     tokey[i]=false;
  44.   }
  45.   set_scroll();
  46.   set_width();
  47.   setInterval(drag, 50);
  48. }}
  49.  
  50. function drag() {
  51.   var c;
  52.   if (mousedown) for (c=0; c<smokeyness; c++) if (tokey[c]===false) {
  53.     toke[c].left=(tokex[c]=x-density/2)+"px";
  54.     toke[c].top=(tokey[c]=y-density)+"px";
  55.     toke[c].visibility="visible";
  56.     tokedx[c]=(c%2?1.5:-1.5)*Math.random();
  57.     nicotine[c]=80;
  58.     break;
  59.   }
  60.   for (c=0; c<smokeyness; c++) if (tokey[c]!==false) smoke_rising(c);
  61. }
  62.  
  63.  
  64. document.onmousedown=function(){set_scroll();if(ie_version)setTimeout('mousedown=true', 51);else mousedown=true;};
  65. document.onmouseup=function(){mousedown=false};
  66.  
  67. function smoke_rising(i) {
  68.   var cancer;
  69.   tokey[i]-=4+i%3;
  70.   tokex[i]+=tokedx[i]-0.5+Math.random();
  71.   if (tokey[i]>sdown-density*2 && tokex[i]>sleft && tokex[i]<sleft+swide-density && (nicotine[i]+=2)<256) {
  72.     cancer=nicotine[i].toString(16);
  73.     cancer="#"+cancer+cancer+cancer;
  74.     if (ie_version && ie_version<10) toke[i].filter="Glow(Color="+cancer+",Strength="+Math.floor(nicotine[i]/5)+")";
  75.     else if (ie_version) toke[i].textShadow='#000000 0px 0px '+Math.floor(nicotine[i]/5)+'px';
  76.     else toke[i].textShadow=cancer+' 0px 0px '+Math.floor(nicotine[i]/5)+'px';
  77.     toke[i].top=tokey[i]+"px";
  78.     toke[i].left=tokex[i]+"px";
  79.   }
  80.   else {
  81.     toke[i].visibility="hidden";
  82.     tokey[i]=false;
  83.   }
  84. }
  85.  
  86. document.onmousemove=mouse;
  87. function mouse(e) {
  88.   if (e) {
  89.     y=e.pageY;
  90.     x=e.pageX;
  91.   }
  92.   else {
  93.     set_scroll();
  94.     y=event.y+sdown;
  95.     x=event.x+sleft;
  96.   }
  97. }
  98.  
  99. window.onresize=set_width;
  100. function set_width() {
  101.   var sw_min=999999;
  102.   var sh_min=999999;
  103.   if (document.documentElement && document.documentElement.clientWidth) {
  104.     if (document.documentElement.clientWidth>0) sw_min=document.documentElement.clientWidth;
  105.     if (document.documentElement.clientHeight>0) sh_min=document.documentElement.clientHeight;
  106.   }
  107.   if (typeof(self.innerWidth)=='number' && self.innerWidth) {
  108.     if (self.innerWidth>0 && self.innerWidth<sw_min) sw_min=self.innerWidth;
  109.     if (self.innerHeight>0 && self.innerHeight<sh_min) sh_min=self.innerHeight;
  110.   }
  111.   if (document.body.clientWidth) {
  112.     if (document.body.clientWidth>0 && document.body.clientWidth<sw_min) sw_min=document.body.clientWidth;
  113.     if (document.body.clientHeight>0 && document.body.clientHeight<sh_min) sh_min=document.body.clientHeight;
  114.   }
  115.   if (sw_min==999999 || sh_min==999999) {
  116.     sw_min=800;
  117.     sh_min=600;
  118.   }
  119.   swide=sw_min;
  120.   shigh=sh_min;
  121. }
  122.  
  123. window.onscroll=set_scroll;
  124. function set_scroll() {
  125.   if (typeof(self.pageYOffset)=='number') {
  126.     sdown=self.pageYOffset;
  127.     sleft=self.pageXOffset;
  128.   }
  129.   else if (document.body && (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. }
View raw paste Reply