Completed
Push — master ( 2e96ee...51b9e4 )
by Rain
01:37
created

plugins/piwik-analytics/js/include.js   A

Complexity

Total Complexity 8
Complexity/F 2.67

Size

Lines of Code 31
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 0
wmc 8
nc 8
mnd 2
bc 6
fnc 3
dl 0
loc 31
rs 10
bpm 2
cpm 2.6666
noi 0
c 0
b 0
f 0
1
2
$(function () {
3
4
	var
5
		sPiwikURL = '' + window.rl.pluginSettingsGet('piwik-analytics', 'piwik_url'),
6
		sSiteID = '' + window.rl.pluginSettingsGet('piwik-analytics', 'site_id')
7
	;
8
9
	if ('' !== sPiwikURL && '' !== sSiteID)
10
	{
11
		sPiwikURL = sPiwikURL.replace(/[\\\/\s]+$/, '') + '/';
12
		if (!/^https?:/i.test(sPiwikURL))
13
		{
14
			sPiwikURL = 'http://' + sPiwikURL;
15
		}
16
17
		window._paq = window._paq || [];
18
		(function(window){
19
			window._paq.push(['setSiteId', sSiteID]);
20
			window._paq.push(['setTrackerUrl', sPiwikURL + 'piwik.php']);
21
			window._paq.push(['trackPageView']);
22
			window.setInterval(function () {
23
				window._paq.push(['trackPageView']);
24
			}, 1000 * 60 * 2);
25
			var d = window.document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
26
			g.type = 'text/javascript'; g.defer = true; g.async = true; g.src = sPiwikURL + 'piwik.js';
27
			if (s && s.parentNode) {
28
				s.parentNode.insertBefore(g, s);
29
			}
30
		}(window));
31
	}
32
});