Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorvipsoft <vipsoft@59fd770c-687e-43c8-a1e3-f5a4ff64c105>2009-10-23 08:28:55 +0400
committervipsoft <vipsoft@59fd770c-687e-43c8-a1e3-f5a4ff64c105>2009-10-23 08:28:55 +0400
commita9cfc465381f8dd5991122a4b124c291870e6d19 (patch)
treef25eb20a061f88bb86da6f5ff0473dae0a4da7cc /js
parent851b2e22b2fc004c4e006abfb84d267d9bfe0b29 (diff)
refs #708 - add setCustomUrl(url) to override document.location.href (default);
set action_name to document.title (default); add alias for window.location.hostname (for yuicompressor); rename private method, getWebBug(), to logPageView() for consistency; jslint 2009-10-04 ("The Good Parts")
Diffstat (limited to 'js')
-rw-r--r--js/piwik.js36
1 files changed, 25 insertions, 11 deletions
diff --git a/js/piwik.js b/js/piwik.js
index 26643558d3..74351d8bbf 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 */
+/*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().
@@ -39,6 +39,7 @@ if (!this.Piwik) {
navigatorAlias = navigator,
screenAlias = screen,
windowAlias = window,
+ hostnameAlias = windowAlias.location.hostname,
/* DOM Ready */
hasLoaded = false,
@@ -170,14 +171,17 @@ if (!this.Piwik) {
// Site ID
configTrackerSiteId = siteId || '',
+ // Document URL
+ configUrl = documentAlias.location.href,
+
// Document title
- configTitle = '',
+ configTitle = documentAlias.title,
// Extensions to be treated as download links
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 = [windowAlias.location.hostname],
+ configHostsAlias = [hostnameAlias],
// Anchor classes to not track
configIgnoreClasses = [],
@@ -390,7 +394,8 @@ if (!this.Piwik) {
*/
/*
- * Send image request to Piwik server using GET
+ * Send image request to Piwik server using GET.
+ * The infamous web bug is a transparent, single pixel (1x1) image
*/
function getImage(url, delay) {
var now = new Date(),
@@ -473,7 +478,7 @@ if (!this.Piwik) {
var i, now, request;
now = new Date();
request = 'idsite=' + configTrackerSiteId +
- '&url=' + escapeWrapper(documentAlias.location.href) +
+ '&url=' + escapeWrapper(configUrl) +
'&res=' + screenAlias.width + 'x' + screenAlias.height +
'&h=' + now.getHours() + '&m=' + now.getMinutes() + '&s=' + now.getSeconds() +
'&cookie=' + browserHasCookies +
@@ -489,9 +494,9 @@ if (!this.Piwik) {
}
/*
- * Get the web bug image (transparent single pixel, 1x1, image) to log visit in Piwik
+ * Log the page view / visit
*/
- function getWebBug() {
+ function logPageView() {
var request = getRequest();
request += '&action_name=' + escapeWrapper(configTitle); // refs #530;
@@ -816,10 +821,10 @@ if (!this.Piwik) {
setDomains: function (hostsAlias) {
if (typeof hostsAlias == 'object' && hostsAlias instanceof Array) {
configHostsAlias = hostsAlias;
- // configHostAlias.push(windowAlias.location.hostname); // array.push added in IE5.5
- configHostsAlias[configHostsAlias.length] = windowAlias.location.hostname;
+ // configHostAlias.push(hostnameAlias); // array.push added in IE5.5
+ configHostsAlias[configHostsAlias.length] = hostnameAlias;
} else if (typeof hostsAlias == 'string') {
- configHostsAlias = [hostsAlias, windowAlias.location.hostname];
+ configHostsAlias = [hostsAlias, hostnameAlias];
}
},
@@ -835,6 +840,15 @@ if (!this.Piwik) {
},
/*
+ * Override url
+ */
+ setCustomUrl: function (url) {
+ if (isDefined(url)) {
+ configUrl = url;
+ }
+ },
+
+ /*
* Override document.title
*/
setDocumentTitle: function (title) {
@@ -928,7 +942,7 @@ if (!this.Piwik) {
* Log visit to this page
*/
trackPageView: function () {
- getWebBug();
+ logPageView();
}
};
}