Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function($) {
- // I'll put this here Script Ajax
- var startTime = new Date(); //Start the clock!
- window.onbeforeunload = function() //When the user leaves the page(closes the window/tab, clicks a link)...
- {
- var endTime = new Date(); //Get the current time.
- var timeSpent = (endTime - startTime); //Find out how long it's been.
- var xmlhttp; //Make a variable for a new ajax request.
- if (window.XMLHttpRequest) //If it's a decent browser...
- {
- // code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp = new XMLHttpRequest(); //Open a new ajax request.
- }
- else //If it's a bad browser...
- {
- // code for IE6, IE5
- xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); //Open a different type of ajax call.
- }
- var url = "timer.php?time="+timeSpent; //Send the time on the page to a php script of your choosing.
- 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.
- xmlhttp.send(null); //Send the request and don't wait for a response.
- };
- // There it is
- // The Script JQuery
- $.fn.saveClicks = function() {
- $(this).bind('mousedown.clickmap', function(evt) {
- $.post('clickmap.php', {
- x:evt.pageX,
- y:evt.pageY,
- l:escape(document.location.pathname)
- });
- });
- };
- /* Limite */
- $.fn.stopSaveClicks = function() {
- $(this).unbind('mousedown.clickmap');
- };
- $.displayClicks = function(settings) {
- $('<div id="clickmap-overlay"></div>').appendTo('body');
- $('<div id="clickmap-loading"></div>').appendTo('body');
- $.get('clickmap.php', { l:escape( document.location.pathname) },
- function(html) {
- $(html).appendTo('body');
- $('#clickmap-loading').remove();
- }
- );
- };
- $.removeClicks = function() {
- $('#clickmap-overlay').remove();
- $('#clickmap-container').remove();
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement