diff options
author | mattab <matthieu.aubry@gmail.com> | 2015-03-03 05:37:24 +0300 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2015-03-03 05:37:24 +0300 |
commit | f8588272259a9de43ce48abb38bab7272888308e (patch) | |
tree | 77202405454104ef764c1fe27d4c58aa50bfb705 /js | |
parent | b30dd2ffb27409ca52a7781df64e8a29b1d4debb (diff) |
Refs #7290 Fix tests and JSlint
Diffstat (limited to 'js')
-rw-r--r-- | js/piwik.js | 73 |
1 files changed, 39 insertions, 34 deletions
diff --git a/js/piwik.js b/js/piwik.js index bfc77ffc37..27413028ff 100644 --- a/js/piwik.js +++ b/js/piwik.js @@ -410,7 +410,7 @@ if (typeof JSON2 !== 'object') { exec, res, width, height, devicePixelRatio, pdf, qt, realp, wma, dir, fla, java, gears, ag, - hook, getHook, getVisitorId, getVisitorInfo, setUserId, getUserId, setSiteId, setTrackerUrl, appendToTrackingUrl, getRequest, addPlugin, + hook, getHook, getVisitorId, getVisitorInfo, setUserId, getUserId, setSiteId, getSiteId, setTrackerUrl, getTrackerUrl, appendToTrackingUrl, getRequest, addPlugin, getAttributionInfo, getAttributionCampaignName, getAttributionCampaignKeyword, getAttributionReferrerTimestamp, getAttributionReferrerUrl, setCustomData, getCustomData, @@ -426,7 +426,7 @@ if (typeof JSON2 !== 'object') { setVisitorCookieTimeout, setSessionCookieTimeout, setReferralCookieTimeout, setConversionAttributionFirstReferrer, disablePerformanceTracking, setGenerationTimeMs, - doNotTrack, setDoNotTrack, msDoNotTrack, + doNotTrack, setDoNotTrack, msDoNotTrack, getValuesFromVisitorIdCookie, addListener, enableLinkTracking, enableJSErrorTracking, setLinkTrackingTimer, setHeartBeatTimer, killFrame, redirectFile, setCountPreRendered, trackGoal, trackLink, trackPageView, trackSiteSearch, trackEvent, @@ -457,7 +457,9 @@ if (typeof JSON2 !== 'object') { trackVisibleContentImpressions, isTrackOnlyVisibleContentEnabled, port, isUrlToCurrentDomain, isNodeAuthorizedToTriggerInteraction, replaceHrefIfInternalLink, getConfigDownloadExtensions, disableLinkTracking, substr, setAnyAttribute, wasContentTargetAttrReplaced, max, abs, childNodes, compareDocumentPosition, body, - getConfigVisitorCookieTimeout, getRemainingVisitorCookieTimeout + getConfigVisitorCookieTimeout, getRemainingVisitorCookieTimeout, + newVisitor, uuid, createTs, visitCount, currentVisitTs, lastVisitTs, lastEcommerceOrderTs + */ /*global _paq:true */ /*members push */ @@ -2686,6 +2688,38 @@ if (typeof Piwik !== 'object') { return cookieValue; } + + /** + * Loads the Visitor ID cookie and returns a named array of values + */ + function getValuesFromVisitorIdCookie() { + var cookieVisitorIdValue = loadVisitorIdCookie(), + newVisitor = cookieVisitorIdValue[0], + uuid = cookieVisitorIdValue[1], + createTs = cookieVisitorIdValue[2], + visitCount = cookieVisitorIdValue[3], + currentVisitTs = cookieVisitorIdValue[4], + lastVisitTs = cookieVisitorIdValue[5]; + + // case migrating from pre-1.5 cookies + if (!isDefined(cookieVisitorIdValue[6])) { + cookieVisitorIdValue[6] = ""; + } + + var lastEcommerceOrderTs = cookieVisitorIdValue[6]; + + return { + newVisitor: newVisitor, + uuid: uuid, + createTs: createTs, + visitCount: visitCount, + currentVisitTs: currentVisitTs, + lastVisitTs: lastVisitTs, + lastEcommerceOrderTs: lastEcommerceOrderTs + }; + } + + function getRemainingVisitorCookieTimeout() { var now = new Date(), nowTs = now.getTime(), @@ -2809,36 +2843,6 @@ if (typeof Piwik !== 'object') { } /** - * Loads the Visitor ID cookie and returns a named array of values - */ - function getValuesFromVisitorIdCookie() { - var cookieVisitorIdValue = loadVisitorIdCookie(); - var newVisitor = cookieVisitorIdValue[0]; - var uuid = cookieVisitorIdValue[1]; - var createTs = cookieVisitorIdValue[2]; - var visitCount = cookieVisitorIdValue[3]; // Updated below - var currentVisitTs = cookieVisitorIdValue[4]; - var lastVisitTs = cookieVisitorIdValue[5]; // Updated below - - // case migrating from pre-1.5 cookies - if (!isDefined(cookieVisitorIdValue[6])) { - cookieVisitorIdValue[6] = ""; - } - - var lastEcommerceOrderTs = cookieVisitorIdValue[6]; - - return { - newVisitor: newVisitor, - uuid: uuid, - createTs: createTs, - visitCount: visitCount, - currentVisitTs: currentVisitTs, - lastVisitTs: lastVisitTs, - lastEcommerceOrderTs: lastEcommerceOrderTs - }; - } - - /** * Returns the URL to call piwik.php, * with the standard parameters (plugins, resolution, url, referrer, etc.). * Sends the pageview and browser settings with every request in case of race conditions. @@ -4141,7 +4145,8 @@ if (typeof Piwik !== 'object') { * @return array */ getVisitorInfo: function () { - // @todo: in a new method, we could return also return getValuesFromVisitorIdCookie() which has named parameters rather than returning int indexed array + // Note: in a new method, we could return also return getValuesFromVisitorIdCookie() + // which returns named parameters rather than returning integer indexed array return loadVisitorIdCookie(); }, |