daily pastebin goal
12%
SHARE
TWEET

Untitled

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