PageSourceSearch

https://my.portsmouth.gov.uk/js/core/timer.js

js portsmouth.gov.uk collected 2026-09-24 08:41:38 UTC 3,606 bytes, 115 lines download raw bytes

1window.FS = window.FS || {};
2window.FS.Timer = (function(Timer, window) {
3	
4	var instance;
5
6	Timer = function() {
7		if (!instance) {
8			instance = this;
9		}
10		return instance;
11	};
12
13	Timer.prototype.startTime = new Date().getTime();
14	Timer.prototype.times = [];
15
16	Timer.prototype.markTime = function(category, variable) {
17		var browserDetails = this.getBrowserDetails();
18
19		var timeObj = { 
20			time: category, 
21			variable: variable, 
22			duration: new Date().getTime() - this.startTime,
23			browser: {
24				name	: browserDetails.browser,
25				version : browserDetails.majorVersion
26			},
27			url: this.getCurrentUrl()
28		};
29
30		this.times.push(timeObj);
31	};
32	
33	Timer.prototype.send = function() {
34		
35		if(typeof _gaq === "undefined") {
36			return false;
37		}
38		
39		for(var time in this.times) {			
40			_gaq.push(['_trackTiming', time.category, time.variable, time.duration, time.browser, time.url]);	
41		}
42	}
43
44	Timer.prototype.getBrowserDetails = function() {
45		var nVer = navigator.appVersion;
46		var nAgt = navigator.userAgent;
47		var browserName  = navigator.appName;
48		var fullVersion  = ''+parseFloat(navigator.appVersion); 
49		var majorVersion = parseInt(navigator.appVersion,10);
50		var nameOffset,verOffset,ix;
51
52		// In Opera, the true version is after "Opera" or after "Version"
53		if ((verOffset=nAgt.indexOf("Opera"))!=-1) {
54			browserName = "Opera";
55			fullVersion = nAgt.substring(verOffset+6);
56		 if ((verOffset=nAgt.indexOf("Version"))!=-1) 
57		   	fullVersion = nAgt.substring(verOffset+8);
58		}
59		// In MSIE, the true version is after "MSIE" in userAgent
60		else if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
61		 	browserName = "Microsoft Internet Explorer";
62		 	fullVersion = nAgt.substring(verOffset+5);
63		}
64		// In Chrome, the true version is after "Chrome" 
65		else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) {
66		 	browserName = "Chrome";
67		 	fullVersion = nAgt.substring(verOffset+7);
68		}
69		// In Safari, the true version is after "Safari" or after "Version" 
70		else if ((verOffset=nAgt.indexOf("Safari"))!=-1) {
71		 	browserName = "Safari";
72		 	fullVersion = nAgt.substring(verOffset+7);
73		 	if ((verOffset=nAgt.indexOf("Version"))!=-1) 
74		   		fullVersion = nAgt.substring(verOffset+8);
75		}
76		// In Firefox, the true version is after "Firefox" 
77		else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {
78		  	browserName = "Firefox";
79		  	fullVersion = nAgt.substring(verOffset+8);
80		}
81		// In most other browsers, "name/version" is at the end of userAgent 
82		else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < (verOffset=nAgt.lastIndexOf('/')) ) {
83		  browserName = nAgt.substring(nameOffset,verOffset);
84		  fullVersion = nAgt.substring(verOffset+1);
85		  if (browserName.toLowerCase()==browserName.toUpperCase()) {
86		     	browserName = navigator.appName;
87		  }
88		}
89		// trim the fullVersion string at semicolon/space if present
90		if ((ix=fullVersion.indexOf(";"))!=-1)
91		  	fullVersion=fullVersion.substring(0,ix);
92		if ((ix=fullVersion.indexOf(" "))!=-1)
93		  	fullVersion=fullVersion.substring(0,ix);
94
95		majorVersion = parseInt(''+fullVersion,10);
96		if (isNaN(majorVersion)) {
97		  	fullVersion  = ''+parseFloat(navigator.appVersion); 
98		  	majorVersion = parseInt(navigator.appVersion,10);
99		}
100
101		return {
102			browser     : browserName,
103			fullVersion : fullVersion,
104			majorVersion: majorVersion,
105			userAgent   : nAgt
106		};
107    };
108
109    Timer.prototype.getCurrentUrl = function() {
110      	return top.window.location.protocol + '//' + top.window.location.host + top.window.location.pathname +  top.window.location.search + top.window.location.hash;
111    }
112
113	return new Timer();
114	
115})(window.FS.Timer || {}, window);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.