1: <%@ Control Language="C#" AutoEventWireup="true" CodeFile="HeatMapCollector.ascx.cs" Inherits="HeatMapCollector" %>
2:
3: <script type="text/javascript" language="javascript">
4:
5:
6: ///////////////////////////////////////////////////
7: // Internal Variables
8: ///////////////////////////////////////////////////
9: var IE = document.all ? true : false
10: if (!IE) document.captureEvents(Event.MOUSEUP)
11:
12: document.onmouseup = GetMouseXY;
13:
14: var sTime = Date();
15:
16: ///////////////////////////////////////////////////
17: // Capture MouseUP Events
18: ///////////////////////////////////////////////////
19: function GetMouseXY(e)
20: {
21: var posx = 0;
22: var posy = 0;
23:
24: if (!e) var e = window.event;
25: if (e.pageX || e.pageY)
26: {
27: posx = e.pageX;
28: posy = e.pageY;
29: }
30: else if (e.clientX || e.clientY)
31: {
32: posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
33: posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
34: }
35:
36:
37: // Get the current page name, or user supplied page name
38: var sPage;
39: sPage = HMC_DefaultPageName;
40:
41: if(HMC_PageName == "") // No user supplied pagename, attempt to parse page name from URL
42: {
43: var sPath = window.location.pathname;
44: sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
45:
46: // There's a possibility that sPage will be NULL due to the default page of a site or virtual site
47: // If that's the case, alert user
48: // i.e http:///www.somewhere.com/
49: if ((sPage == '') || (sPage == null))
50: {
51: if ((HMC_DefaultPageName == '') || (HMC_DefaultPageName == null))
52: {
53: alert("No Default PageName parameter or URL 'page name' available to save mouse click.");
54: }
55: else
56: sPage = HMC_DefaultPageName;
57: }
58: else if (sPage.toLowerCase() == HMC_DefaultPageName.toLowerCase())
59: {
60: sPage = HMC_DefaultPageName;
61: }
62: }
63: else
64: sPage = HMC_PageName; // Use user supplied name
65:
66:
67: $j.ajax({
68: type: "POST",
69: url: getRootURL() + "/themes/13sides/HeatMapService.svc/SaveClick",
70: data: '{ "coordX":"' + posx + '", "coordY":"' + posy + '", "page":"' + sPage + '" }',
71: contentType: "application/json; charset=utf-8",
72: dataType: "json",
73: success: function(msg) { },
74: error: function(xhr, msg, e) { }
75: });
76:
77:
78: // Let the mouse event continue normally
79: return true;
80: }
81: function getRootURL()
82: {
83: var baseURL = location.href;
84: var rootURL = baseURL.substring(0, baseURL.indexOf('/', 14));
85:
86: // if the root url is localhost, don't add the directory as cassani doesn't use it
87: if (baseURL.indexOf('localhost') != -1)
88: {
89: return rootURL + "/BlogEngine.Web/";
90: }
91: else
92: {
93: return rootURL + "/";
94: }
95: }
96: ///////////////////////////////////////////////////
97: </script>