diff options
Diffstat (limited to 'js/piwik.js')
-rw-r--r-- | js/piwik.js | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/js/piwik.js b/js/piwik.js index 8c4527be4e..e14b91c8cd 100644 --- a/js/piwik.js +++ b/js/piwik.js @@ -6,7 +6,7 @@ * @version $Id$ */ -/*jslint browser:true, forin:true, plusplus:false, onevar:false, eqeqeq:false, strict:false */ +/*jslint browser:true, forin:true, plusplus:false, onevar:false, eqeqeq:false; strict:false */ /*global window escape unescape ActiveXObject */ // Note: YUICompressor 2.4.2 won't compress piwik_log() because of the the "evil" eval(). @@ -18,8 +18,6 @@ * * This version of piwik.js is known to not work with: * - IE4 (and below) - try..catch and for..in not introduced until IE5 - * - * @todo Move to minimum EMCAScript v3 (IE5.5). */ // Guard against loading the script twice @@ -95,11 +93,11 @@ if (!this.Piwik) { * Delay/pause (blocks UI) */ if (isDefined(expireDateTime)) { - var now; + var now = new Date(); - do { + while (now.getTime() < expireDateTime) { now = new Date(); - } while (now.getTime() < expireDateTime); + } } executePluginMethod('unload'); @@ -124,24 +122,19 @@ if (!this.Piwik) { */ function addReadyListener() { if (documentAlias.addEventListener) { -// addEventListener(documentAlias, "DOMContentLoaded", function ready() { // named functions added in IE 5.5 addEventListener(documentAlias, "DOMContentLoaded", function () { -// documentAlias.removeEventListener("DOMContentLoaded", ready, false); documentAlias.removeEventListener("DOMContentLoaded", arguments.callee, false); loadHandler(); }); } else if (documentAlias.attachEvent) { -// documentAlias.attachEvent("onreadystatechange", function ready() { - documentAlias.attachEvent("onreadystatechange", function () { // named functions added in IE 5.5 + documentAlias.attachEvent("onreadystatechange", function () { if (documentAlias.readyState === "complete") { -// documentAlias.detachEvent("onreadystatechange", ready); documentAlias.detachEvent("onreadystatechange", arguments.callee); loadHandler(); } }); if (documentAlias.documentElement.doScroll && windowAlias == windowAlias.top) { -// (function ready() { // named functions added in IE 5.5 (function () { if (hasLoaded) { return; @@ -149,7 +142,6 @@ if (!this.Piwik) { try { documentAlias.documentElement.doScroll("left"); } catch (error) { -// setTimeout(ready, 0); setTimeout(arguments.callee, 0); return; } @@ -180,13 +172,13 @@ if (!this.Piwik) { configTrackerSiteId = siteId || '', // Document URL - configCustomUrl, + configUrl = documentAlias.location.href, // Document title configTitle = documentAlias.title, // Extensions to be treated as download links - configDownloadExtensions = '7z|aac|arc|arj|asf|asx|avi|bin|csv|deb|dmg|doc|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt|qtm?|ra(m|r)?|rpm|sea|sit|tar|t?bz2?|tgz|torrent|txt|wav|wma|wmv|wpd||xls|xml|z|zip', + configDownloadExtensions = '7z|aac|arc|arj|asf|asx|avi|bin|csv|doc|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt|qtm?|ra(m|r)?|sea|sit|tar|t?bz2?|tgz|torrent|txt|wav|wma|wmv|wpd||xls|xml|z|zip', // Hosts or alias(es) to not treat as outlinks configHostsAlias = [hostnameAlias], @@ -304,7 +296,7 @@ if (!this.Piwik) { // the remote chance that this gets fixed someday. return String(value); - case 'object': + case 'object': // Make an array to hold the partial results of stringifying this object value. partial = []; @@ -486,8 +478,7 @@ if (!this.Piwik) { var i, now, request; now = new Date(); request = 'idsite=' + configTrackerSiteId + - '&rec=1' + - '&url=' + escapeWrapper(isDefined(configCustomUrl) ? configCustomUrl : documentAlias.location.href) + + '&url=' + escapeWrapper(configUrl) + '&res=' + screenAlias.width + 'x' + screenAlias.height + '&h=' + now.getHours() + '&m=' + now.getMinutes() + '&s=' + now.getSeconds() + '&cookie=' + browserHasCookies + @@ -505,9 +496,9 @@ if (!this.Piwik) { /* * Log the page view / visit */ - function logPageView(customTitle) { + function logPageView() { var request = getRequest(); - request += '&action_name=' + escapeWrapper(isDefined(customTitle) ? customTitle : configTitle); // refs #530; + request += '&action_name=' + escapeWrapper(configTitle); // refs #530; // encode custom data if (isDefined(configCustomData)) { @@ -543,12 +534,11 @@ if (!this.Piwik) { } /* - * Log the link or click with the server + * Log the click with the server */ - function logLink(url, linkType, customData) { + function logClick(url, linkType, customData) { var request; request = 'idsite=' + configTrackerSiteId + - '&rec=1' + '&' + linkType + '=' + escapeWrapper(url) + '&rand=' + Math.random() + '&redirect=0'; @@ -599,7 +589,7 @@ if (!this.Piwik) { * Construct regular expression of classes */ function getClassesRegExp(configClasses, defaultClass) { - var i, classesRegExp = '(^| )(piwik[_-]' + defaultClass; + var i, classesRegExp = '(^| )(piwik_' + defaultClass; if (isDefined(configClasses)) { for (i = 0; i < configClasses.length; i++) { @@ -686,7 +676,7 @@ if (!this.Piwik) { // track outlinks and all downloads linkType = getLinkType(sourceElement.className, sourceHref, isSiteHostName(sourceHostName)); if (linkType) { - logLink(sourceHref, linkType); + logClick(sourceHref, linkType); } } } @@ -854,7 +844,7 @@ if (!this.Piwik) { */ setCustomUrl: function (url) { if (isDefined(url)) { - configCustomUrl = url; + configUrl = url; } }, @@ -945,14 +935,14 @@ if (!this.Piwik) { * Manually log a click from your own code */ trackLink: function (sourceUrl, linkType, customData) { - logLink(sourceUrl, linkType, customData); + logClick(sourceUrl, linkType, customData); }, /* * Log visit to this page */ - trackPageView: function (customTitle) { - logPageView(customTitle); + trackPageView: function () { + logPageView(); } }; } |