Skip to content

Commit

Permalink
refs #3747 refactoring logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mattab committed Mar 11, 2013
1 parent 0775c8c commit dc18d7b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 31 deletions.
24 changes: 11 additions & 13 deletions js/piwik.js
Expand Up @@ -954,6 +954,13 @@ var
* Page Overlay
************************************************************/

function getTrackerUrlForOverlay(trackerUrl) {
if (trackerUrl.slice(-9) === 'piwik.php') {
trackerUrl = trackerUrl.slice(0, trackerUrl.length - 9);
}
return trackerUrl;
}

/*
* Check whether this is a page overlay session
*
Expand All @@ -964,12 +971,7 @@ var
function isOverlaySession(configTrackerUrl, configTrackerSiteId) {
var windowName = 'Piwik_Overlay',
referrer = documentAlias.referrer,
testReferrer = configTrackerUrl;

// remove piwik.php from referrer if present
if (testReferrer.slice(-9) === 'piwik.php') {
testReferrer = testReferrer.slice(0, testReferrer.length - 9);
}
testReferrer = getTrackerUrlForOverlay(configTrackerUrl);

// remove protocol
testReferrer.slice(testReferrer.slice(0, 7) === 'http://' ? 7 : 8, testReferrer.length);
Expand Down Expand Up @@ -1015,16 +1017,12 @@ var
var windowNameParts = windowAlias.name.split('###'),
period = windowNameParts[1],
date = windowNameParts[2],
root = configTrackerUrl;

if (root.slice(-9) === 'piwik.php') {
root = root.slice(0, root.length - 9); // remove piwik.php if present
}
trackerUrl = getTrackerUrlForOverlay(configTrackerUrl);

loadScript(
root + 'plugins/Overlay/client/client.js?v=1',
trackerUrl + 'plugins/Overlay/client/client.js?v=1',
function () {
Piwik_Overlay_Client.initialize(root, configTrackerSiteId, period, date);
Piwik_Overlay_Client.initialize(trackerUrl, configTrackerSiteId, period, date);
}
);
}
Expand Down

0 comments on commit dc18d7b

Please sign in to comment.