daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Jan 22nd, 2016 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // My script Ajax **************************************************************************************
  2.  
  3.  
  4.  var startTime = new Date();        //Start the clock!
  5.             window.onbeforeunload = function()        //When the user leaves the page(closes the window/tab, clicks a link)...
  6.             {
  7.                 var endTime = new Date();        //Get the current time.
  8.                 var timeSpent = (endTime - startTime);        //Find out how long it's been.
  9.                 var xmlhttp;        //Make a variable for a new ajax request.
  10.                 if (window.XMLHttpRequest)        //If it's a decent browser...
  11.                 {
  12.                     // code for IE7+, Firefox, Chrome, Opera, Safari
  13.                     xmlhttp = new XMLHttpRequest();        //Open a new ajax request.
  14.                 }
  15.                 else        //If it's a bad browser...
  16.                 {
  17.                     // code for IE6, IE5
  18.                     xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");        //Open a different type of ajax call.
  19.                 }
  20.                 var url = "timer.php?time="+timeSpent;        //Send the time on the page to a php script of your choosing.
  21.                 xmlhttp.open("GET",url,false);        //The false at the end tells ajax to use a synchronous call which wont be severed by the user leaving.
  22.                 xmlhttp.send(null);        //Send the request and don't wait for a response.
  23.             }
  24.  
  25.  
  26.  
  27.  
  28.  
  29. // My script Jquery *****************************************************************************************
  30.  
  31. (function($) {
  32.  
  33. $.fn.saveClicks = function() {
  34.     $(this).bind('mousedown.clickmap', function(evt) {
  35.         $.post('clickmap.php', {  
  36.             x:evt.pageX,  
  37.             y:evt.pageY,
  38.             l:escape(document.location.pathname)
  39.         });
  40.     });
  41. };
  42.  /*   Limite    */
  43.  
  44. $.fn.stopSaveClicks = function() {
  45.      $(this).unbind('mousedown.clickmap');
  46. };
  47.  
  48. $.displayClicks = function(settings) {
  49.     $('<div id="clickmap-overlay"></div>').appendTo('body');
  50.  
  51.     $('<div id="clickmap-loading"></div>').appendTo('body');
  52.  
  53.     $.get('clickmap.php', { l:escape( document.location.pathname) },  
  54.         function(html) {
  55.             $(html).appendTo('body');    
  56.             $('#clickmap-loading').remove();
  57.         }
  58.     );
  59. };
  60.  
  61. $.removeClicks = function() {
  62.     $('#clickmap-overlay').remove();
  63.     $('#clickmap-container').remove();
  64. };
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72. /*     Limite     */        
  73. })(jQuery);
RAW Paste Data
Top