-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Completed 'Determing and saving the environment' section
- Loading branch information
Showing
2 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,59 @@ | ||
(function($) { | ||
|
||
var doc = $(document), | ||
// General storage container for session | ||
clickStats = { | ||
url: document.location.href, | ||
clicks: [] | ||
}, | ||
// Store objects representing each layout for the document | ||
layouts = []; | ||
|
||
// Set AJAX options | ||
$.ajaxSetup({ | ||
type: 'POST', | ||
contentType: 'application/json', | ||
dataType: 'json' | ||
}); | ||
|
||
// Parse any stylesheet attached to document via <link/> elements | ||
// x = index | ||
// ss = current stylesheet object | ||
$.each(doc[0].styleSheets, function(x, ss) { | ||
// Iterate through rules of stylesheet | ||
// y = index | ||
// rule = current rule | ||
$.each(ss.rules, function(y, rule) { | ||
// Is this a valid `CSSMediaRule` rule? | ||
if (rule.media && rule.media.length) { | ||
// We have a media query! | ||
|
||
var jq = $, | ||
// store the media query definition | ||
current = rule.media[0], | ||
// store the breakpoints of said media query | ||
mq = { | ||
min: (current.indexOf('min') !== -1) ? jq.trim(current.split('min-width:')[1].split('px')[0]) : 0, | ||
max: (current.indexOf('max') !== -1) ? jq.trim(current.split('max-width:')[1].split('px')[0]) : 'none' | ||
}; | ||
|
||
// Save whatcha got | ||
layouts.push(mq); | ||
} | ||
}); | ||
}); | ||
|
||
// Sort in ascending order | ||
// Makes breakpoint detection much more efficient | ||
layouts.sort(function(a, b) { | ||
return a.min - b.min; | ||
}); | ||
|
||
// Send to server so it can be saved | ||
$.ajax({ | ||
url: 'heat-map.asmx/saveLayouts', | ||
data: JSON.stringify({ | ||
url: url, | ||
layouts: layouts | ||
}); | ||
}) | ||
})(jQuery); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%@ WebService Language="C#" CodeBehind="~/App_Code/heat-map.cs" Class="heat_map" %> |