Advertisement
dianakko

question mark cursor

Jul 14th, 2021
2,658
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.32 KB | None | 0 0
  1. <script type="text/javascript">
  2. // <![CDATA[
  3. var colours=new Array('#f00', '#f06', '#f0f', '#f6f', '#f39', '#f9c'); // colours of the hearts
  4. var minisize=16; // smallest size of hearts in pixels
  5. var maxisize=28; // biggest size of hearts in pixels
  6. var hearts=66; // maximum number of hearts on screen
  7. var over_or_under="over"; // set to "over" for hearts to always be on top, or "under" to allow them to float behind other objects
  8.  
  9. /*****************************
  10. *JavaScript Love Heart Cursor*
  11. * (c)2013+ mf2fm web-design *
  12. * http://www.mf2fm.com/rv *
  13. * DON'T EDIT BELOW THIS BOX *
  14. *****************************/
  15. var x=ox=400;
  16. var y=oy=300;
  17. var swide=800;
  18. var shigh=600;
  19. var sleft=sdown=0;
  20. var herz=new Array();
  21. var herzx=new Array();
  22. var herzy=new Array();
  23. var herzs=new Array();
  24. var kiss=false;
  25.  
  26. if (typeof('addRVLoadEvent')!='function') function addRVLoadEvent(funky) {
  27. var oldonload=window.onload;
  28. if (typeof(oldonload)!='function') window.onload=funky;
  29. else window.onload=function() {
  30. if (oldonload) oldonload();
  31. funky();
  32. }
  33. }
  34.  
  35. addRVLoadEvent(mwah);
  36.  
  37. function mwah() { if (document.getElementById) {
  38. var i, heart;
  39. for (i=0; i<hearts; i++) {
  40. heart=createDiv("auto", "auto");
  41. heart.style.visibility="hidden";
  42. heart.style.zIndex=(over_or_under=="over")?"1001":"0";
  43. heart.style.color=colours[i%colours.length];
  44. heart.style.pointerEvents="none";
  45. if (navigator.appName=="Microsoft Internet Explorer") heart.style.filter="alpha(opacity=75)";
  46. else heart.style.opacity=0.75;
  47. heart.appendChild(document.createTextNode(String.fromCharCode(9835)));
  48. document.body.appendChild(heart);
  49. herz[i]=heart;
  50. herzy[i]=false;
  51. }
  52. set_scroll();
  53. set_width();
  54. herzle();
  55. }}
  56.  
  57. function herzle() {
  58. var c;
  59. if (Math.abs(x-ox)>1 || Math.abs(y-oy)>1) {
  60. ox=x;
  61. oy=y;
  62. for (c=0; c<hearts; c++) if (herzy[c]===false) {
  63. herz[c].firstChild.nodeValue=String.fromCharCode(63);
  64. herz[c].style.left=(herzx[c]=x-minisize/2)+"px";
  65. herz[c].style.top=(herzy[c]=y-minisize)+"px";
  66. herz[c].style.fontSize=minisize+"px";
  67. herz[c].style.fontWeight='normal';
  68. herz[c].style.visibility='visible';
  69. herzs[c]=minisize;
  70. break;
  71. }
  72. }
  73. for (c=0; c<hearts; c++) if (herzy[c]!==false) blow_me_a_kiss(c);
  74. setTimeout("herzle()", 40);
  75. }
  76.  
  77. document.onmousedown=pucker;
  78. document.onmouseup=function(){clearTimeout(kiss);};
  79.  
  80. function pucker() {
  81. ox=-1;
  82. oy=-1;
  83. kiss=setTimeout('pucker()', 100);
  84. }
  85.  
  86. function blow_me_a_kiss(i) {
  87. herzy[i]-=herzs[i]/minisize+i%2;
  88. herzx[i]+=(i%5-2)/5;
  89. if (herzy[i]<sdown-herzs[i] || herzx[i]<sleft-herzs[i] || herzx[i]>sleft+swide-herzs[i]) {
  90. herz[i].style.visibility="hidden";
  91. herzy[i]=false;
  92. }
  93. else if (herzs[i]>minisize+2 && Math.random()<.5/hearts) break_my_heart(i);
  94. else {
  95. if (Math.random()<maxisize/herzy[i] && herzs[i]<maxisize) herz[i].style.fontSize=(++herzs[i])+"px";
  96. herz[i].style.top=herzy[i]+"px";
  97. herz[i].style.left=herzx[i]+"px";
  98. }
  99. }
  100.  
  101. function break_my_heart(i) {
  102. var t;
  103. herz[i].firstChild.nodeValue=String.fromCharCode(63);
  104. herz[i].style.fontWeight='bold';
  105. herzy[i]=false;
  106. for (t=herzs[i]; t<=maxisize; t++) setTimeout('herz['+i+'].style.fontSize="'+t+'px"', 60*(t-herzs[i]));
  107. setTimeout('herz['+i+'].style.visibility="hidden";', 60*(t-herzs[i]));
  108. }
  109.  
  110. document.onmousemove=mouse;
  111. function mouse(e) {
  112. if (e) {
  113. y=e.pageY;
  114. x=e.pageX;
  115. }
  116. else {
  117. set_scroll();
  118. y=event.y+sdown;
  119. x=event.x+sleft;
  120. }
  121. }
  122.  
  123. window.onresize=set_width;
  124. function set_width() {
  125. var sw_min=999999;
  126. var sh_min=999999;
  127. if (document.documentElement && document.documentElement.clientWidth) {
  128. if (document.documentElement.clientWidth>0) sw_min=document.documentElement.clientWidth;
  129. if (document.documentElement.clientHeight>0) sh_min=document.documentElement.clientHeight;
  130. }
  131. if (typeof(self.innerWidth)=='number' && self.innerWidth) {
  132. if (self.innerWidth>0 && self.innerWidth<sw_min) sw_min=self.innerWidth;
  133. if (self.innerHeight>0 && self.innerHeight<sh_min) sh_min=self.innerHeight;
  134. }
  135. if (document.body.clientWidth) {
  136. if (document.body.clientWidth>0 && document.body.clientWidth<sw_min) sw_min=document.body.clientWidth;
  137. if (document.body.clientHeight>0 && document.body.clientHeight<sh_min) sh_min=document.body.clientHeight;
  138. }
  139. if (sw_min==999999 || sh_min==999999) {
  140. sw_min=800;
  141. sh_min=600;
  142. }
  143. swide=sw_min;
  144. shigh=sh_min;
  145. }
  146.  
  147. window.onscroll=set_scroll;
  148. function set_scroll() {
  149. if (typeof(self.pageYOffset)=='number') {
  150. sdown=self.pageYOffset;
  151. sleft=self.pageXOffset;
  152. }
  153. else if (document.body && (document.body.scrollTop || document.body.scrollLeft)) {
  154. sdown=document.body.scrollTop;
  155. sleft=document.body.scrollLeft;
  156. }
  157. else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)) {
  158. sleft=document.documentElement.scrollLeft;
  159. sdown=document.documentElement.scrollTop;
  160. }
  161. else {
  162. sdown=0;
  163. sleft=0;
  164. }
  165. }
  166.  
  167. function createDiv(height, width) {
  168. var div=document.createElement("div");
  169. div.style.position="absolute";
  170. div.style.height=height;
  171. div.style.width=width;
  172. div.style.overflow="hidden";
  173. div.style.backgroundColor="transparent";
  174. return (div);
  175. }
  176. // ]]>
  177. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement