Demo entry 3550685

a = "b"

   

Submitted by anonymous on Jan 22, 2016 at 19:01
Language: JavaScript. Code size: 5.3 kB.

var gcterm = gcterm || {};
/*1.1.0*/
gcterm.createTerminfo = function() {
	var ua = navigator.userAgent;

	// BrowserInfo
	var deviceId = "";
	var browserType = "";
	var browserVersion = "";
	var osType = "";
	var osVersion = "";
	var gpsSupport = "";

	// browser-version pattern
	var chromeReg = /(Chrome\/|CriOS\/)([-0-9_+.]+)/;
	var forefoxReg = /Firefox\/([-0-9_+.]+)/;
	var operaReg = /Opera[ |\/]([-0-9_+.]+)/;
	var dalvikReg = /Dalvik\/([-0-9_+.]+)/;
	var iemobileReg = /IEMobile\/([-0-9_+.]+)/;
	var ieReg = /MSIE ([-0-9_+.]+)/;
	var safariReg = /Safari\/([-0-9_+.]+)/;
	// os-version pattern
	var iOsReg = /\((iPhone|iPad|iPod).*CPU (iPhone )?OS ([-0-9_.]+)/;
	var androidReg = /Android[; ]([-a-z0-9_.]+)?/;
	var windowsPhoneReg = /Windows Phone (OS )?([-a-z0-9_.]+)?/;
	var blackBerryReg = /BlackBerry([0-9]+)?( |\/([-a-z0-9_.]+))/;
	// device-id pattern
	var safariChromeIdReg = /Linux;( U;)? Android ([-0-9a-zA-Z. _]+); ([-a-z; _]+)?([-0-9a-zA-Z \/+,_]+)( Build|;)/;
	var windowsPhoneId = /IEMobile\/[0-9.]+; [a-zA-Z0-9]+; ([-a-zA-Z0-9_.\/]+)/;
	var windowsMobileId = /Windows NT [0-9.]+;? ([-0-9a-zA-Z_.]+);?/;
	var blackBeryIdReg = /BlackBerry ?([0-9]+)/;

	var r = null;

	if((r = ua.match(chromeReg))) {
		// Chrome
		browserType = "chrome";
		browserVersion = r[2] ? r[2] : "";
	} else if((r = ua.match(dalvikReg))) {
		// Dalvik
		browserType = "dalvik";
		browserVersion = r[1] ? r[1] : "";
	} else if((r = ua.match(forefoxReg))) {
		// Firefox
		browserType = "firefox";
		browserVersion = r[1] ? r[1] : "";
	} else if((r = ua.match(operaReg))) {
		browserType = "opera";
		browserVersion = r[1] ? r[1] : "";
	} else if((r = ua.match(iemobileReg))) {
		browserType = "iemobile";
		browserVersion = r[1] ? r[1] : "";
	} else if((r = ua.match(ieReg))) {
		browserType = "ie";
		browserVersion = r[1] ? r[1] : "";
	} else if((r = ua.match(safariReg))) {
		browserType = "safari";
		browserVersion = r[1] ? r[1] : "";
	}

	r = null;
	if((r = ua.match(iOsReg))) {
		// iOS
		osType = "ios";
		osVersion = r[3] ? r[3] : "";
		deviceId = r[1] ? r[1] : "";
	} else if((r = ua.match(androidReg))) {
		// Android
		osType = "android";
		osVersion = r[1] ? r[1] : "";
		if((r = ua.match(safariChromeIdReg))) {
			deviceId = r[4] ? r[4] : "";
		}
	} else if((r = ua.match(windowsPhoneReg))) {
		// Windows Phone
		osType = "windowsphone";
		osVersion = r[2] ? r[2] : "";
		if((r = ua.match(windowsPhoneId))) {
			deviceId = r[1] ? r[1] : "";
		} else if((r = ua.match(windowsMobileId))) {
			deviceId = r[1] ? r[1] : "";
		}
	} else if((r = ua.match(blackBerryReg))) {
		// BlackBerry
		osType = "blackberry";
		osVersion = r[3] ? r[3] : "";
		if((r = ua.match(blackBeryIdReg))) {
			deviceId = r[1] ? r[1] : "";
		}
	}

	// width & height
	var browserWidth = "";
	var screenWidth = "";
	var browserHeight = "";
	var screenHeight = "";
	if(osType == "ios") {
		browserWidth  = screen.width;
		browserHeight = screen.height;
		screenWidth   = Math.floor(screen.width * window.devicePixelRatio);
		screenHeight  = Math.floor(screen.height * window.devicePixelRatio);
	} else if(osType == "android") {
		if(osVersion.charAt(0) == '2') {
			browserWidth  = screen.width;
			browserHeight = screen.height;
			screenWidth   = Math.floor(screen.width * window.devicePixelRatio);
			screenHeight  = Math.floor(screen.height * window.devicePixelRatio);
		} else {
			browserWidth  = Math.floor(screen.width/window.devicePixelRatio);
			browserHeight = Math.floor(screen.height/window.devicePixelRatio);
			screenWidth   = screen.width;
			screenHeight  = screen.height;
		}
	} else if(osType == "windowsphone") {
		var elem = document.getElementsByTagName("html")[0];
		browserWidth  = elem.scrollWidth;
		browserHeight = elem.scrollHeight;
		screenWidth   = screen.width;
		screenHeight  = screen.height;
	} else if(osType == "blackberry") {
		var elem = document.getElementsByTagName("html")[0];
		browserWidth  = elem.clientWidth;
		browserHeight = elem.clientHeight;
		screenWidth   = screen.width;
		screenHeight  = screen.height;
	}

	var gpsSupport = ("geolocation" in navigator) ? 1 : 0;
	var pixelRatio = window.devicePixelRatio ? window.devicePixelRatio : 1;

	var t = new Object();

	t['browserType'] = browserType;
	t['browserVersion'] = browserVersion;
	t['deviceId'] = deviceId;
	t['osType'] = osType;
	t['osVersion'] = osVersion;
	t['browserWidth'] = browserWidth;
	t['browserHeight'] = browserHeight;
	t['screenWidth'] = screenWidth;
	t['screenHeight'] = screenHeight;
	t['gpsSupport'] = gpsSupport;
	t['pixelRatio'] = pixelRatio;
	return t;
};
gcterm.setCookie = function() {
	if (gcterm.createTerminfo) {
		var str = "1.0|9ead84eb16ba|";
		var t = gcterm.createTerminfo();
		var terminfoKeys = ["deviceId","browserType","browserVersion","osType","osVersion","browserWidth","browserHeight","screenWidth","screenHeight","gpsSupport","pixelRatio"];
		for (var i = 0; i < terminfoKeys.length; i++) {
			var key = terminfoKeys[i];
			if (i > 0) {
				str += "|";
			}
			var value = "";
			if (t[key] !== undefined) {
				value = t[key];
			}
			str += value;
		}
		document.cookie = "gct=" + str + "; expires=Wed, 18 Nov 2015 02:56:19 GMT; path=/";
	}
};
window.addEventListener('resize', gcterm.setCookie, false);
window.addEventListener('load', gcterm.setCookie, false);

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).