Created
June 5, 2011 03:42
-
-
Save websymphony/1008622 to your computer and use it in GitHub Desktop.
HeatMap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
var tracker_arr = new Array(); | |
$(window).bind('mousemove',function(e){ | |
var tracker_obj = {}; | |
tracker_obj['x'] = e.pageX; | |
tracker_obj['y'] = e.pageY; | |
tracker_arr.push(tracker_obj); | |
}); | |
$("#show").click(function(e){ | |
e.preventDefault(); | |
$("<div id='overlay'></div>").appendTo('body') | |
for (var i=0; i < tracker_arr.length; i++) { | |
show_marker(tracker_arr[i]); | |
}; | |
}); | |
function show_marker(pos_obj){ | |
$("<div class='mouse_position' style='margin-top:"+pos_obj['y']+"px;margin-left:"+pos_obj['x']+"px;'></div>").appendTo('#overlay'); | |
} | |
$('body').delegate("#overlay", "click", function(){ | |
$(this).remove(); | |
}); | |
//TODO | |
//Every few seconds need to make ajax call for each page and need to save | |
// ===>tracker_arr<=== in db | |
//Extract js out in JQuery plugin | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment