/** * @author hechen/var GS = {/** get screen width **/screenwidth:function () {return window.screen.width;
/*** Get screen height **/screenheight:function () {return window.screen.height;
/** gets the browser ***/browse:function () {var browser = {};
var useragent = Navigator.userAgent.toLowerCase ();
var s; (s = Useragent.match (/msie) ([\d.] +)/)) ? browser.ie = S[1]: (s = Useragent.match (/firefox\/([\d.] +)/)) ? Browser.firefox = S[1]: (s = Useragent.match (/chrome\/([\d.] +)/)) ? Browser.chrome = S[1]: (s = Useragent.match (/opera. ( [\d.] +)/)) ? Browser.opera = S[1]: (s = Useragent.match (/version\/([\d.] +). *safari/)?
Browser.safari = S[1]: 0;
var version = "";
if (browser.ie) {version = ' ie ' + browser.ie;
else {if (browser.firefox) {version = ' Firefox ' + Browser.firefox;
else {if (browser.chrome) {version = ' chrome ' + browser.chrome; } else {if (browser.operA) {version = ' opera ' + Browser.opera;
else {if (Browser.safari) {version = ' safari ' + Browser.safari;
else {version = ' unknown browser ';
}}} return version;
/** obtains the operating system ***/clientos:function () {var suseragent = navigator.useragent; var Iswin = (Navigator.platform = = "Win32") | |
(Navigator.platform = = "Windows"); var Ismac = (Navigator.platform = = "mac68k") | | (Navigator.platform = = "MacPPC") | | (Navigator.platform = "Macintosh") | |
(Navigator.platform = = "Macintel");
if (ISMAC) return "Mac";
var Isunix = (Navigator.platform = = "X11") &&!iswin &&!ismac;
if (Isunix) return "Unix";
var islinux = (String (navigator.platform). IndexOf ("Linux") >-1);
if (islinux) return "Linux"; if (Iswin) {var iswin2k = Suseragent.indexof ("Windows NT 5.0") >-1 | | suserAgent.indexof ("Windows C") >-1;
if (iswin2k) return "Win2000"; var iswinxp = Suseragent.indexof ("Windows NT 5.1") >-1 | |
Suseragent.indexof ("Windows XP") >-1;
if (ISWINXP) return "WinXP"; var isWin2003 = Suseragent.indexof ("Windows NT 5.2") >-1 | |
Suseragent.indexof ("Windows 2003") >-1;
if (isWin2003) return "Win2003"; var Iswinvista = Suseragent.indexof ("Windows NT 6.0") >-1 | |
Suseragent.indexof ("Windows Vista") >-1;
if (Iswinvista) return "WinVista"; var isWin7 = Suseragent.indexof ("Windows NT 6.1") >-1 | |
Suseragent.indexof ("Windows 7") >-1;
if (isWin7) return "Win7";
Return to "other";
/**** obtains client id****/clientid:function (name) {var cookies = Document.cookie.split (";");
var value = "";
for (var i = 0; i < cookies.length i++) {var temp = cookies[i].split ("="); var tempvalue = temp[0].replace (/(^\s*) | ( \s*$)/g, "");
if (Tempvalue = = name) {value = Unescape (temp[1]);
Break
} return value;
/**** obtains the product id****/searchgid:function () {var url = window.location.href;
var value = ""; if (url!= undefined && url!= "") {Url.replace (/-\d+-/, function (A, B, c) {if (a!= undefined &A
mp;& a!= "" && a.length > 2) {value = a.substring (1, a.length-1);
}
});
return value;
/**** get the site search keyword ****/searchkey:function () {var url = window.location.href;
var value = ""; if (url!= undefined && url!= "") {Url.replace (/[=].*/, function (A, B, c) {if (a!= undefined &A
mp;& a!= "" && a.length > 1) {value = a.substring (1);
}
});
return value;
/** Gets the product category search number **/searchcategory:function () {var url = window.location.href;
var value = ""; if (url!= undefined &&Amp URL!= "") {Url.replace (/-\d+/, function (A, B, c) {if (a!= undefined && a!= "" && A.len
Gth > 1) {value = a.substring (1);
}
});
return value;
/**** outside the site search Google Baidu *****/searchsite:function (type) {var referrer = Document.referrer; if (referrer!= undefined && referrer!= "") {if ("Google" = type) {url.replace (New RegExp (?: ^| /?| &) q= ([^&]*) (?: &|$)), function (A, B, c) {if (this._ch!= undefined && a!= undefined &
& a.length > 0) {a = A.substring (A.indexof ("=") + 1, a.length-1);
return A;
}
}); else if ("baidu" = = Type) {url.replace (RegExp: ^| /?| &) wd= ([^&]*) (?: &|$)), function (A, B, c) {if (this._ch!= undefined && a!= undefined
;& a.length > 0) {a = A.substring (A.indexof ("=") + 1, a.length-1); return A;
}
}); else if ("sogou" = = Type) {url.replace (?: ^| /?| &) query= ([^&]*) (?: &|$)), function (A, B, c) {if (this._ch!= undefined && a!= undefined &
amp;& a.length > 0) {a = A.substring (A.indexof ("=") + 1, a.length-1);
return A;
}
}); else if ("bing" = = type) {url.replace (RegExp: ^| /?| &) q= ([^&]*) (?: &|$)), function (A, B, c) {if (this._ch!= undefined && a!= undefined &
& a.length > 0) {a = A.substring (A.indexof ("=") + 1, a.length-1);
return A;
}
});
} return ""; /****** inserts a value into the array *********/pushvalue:function (key, value) {if (this._ch!= undefined) {This._ch[key] =
Value
/*** the custom parameter **/param:function (value) {if (this._ch!= undefined) {this._ch["_ps"] = value; }
},
/*Submit data to the background **********/postdata:function () {$.ajax ({url: "http://localhost:28482/Ajax/StatActions.aspx?t=
"+ math.random (), type:" Post ", Data:this._ch, Success:function (data) {}});
},/*** initializes **/init:function () {if (this._ch!= undefined) {this._ch = undefined;
} this._ch = {};
if (this._reg!= undefined) {this._reg = undefined;
///Initialize regular expression matching URL This._reg = new Array ();
This._reg[0] = "http://www.google.com.hk (. *)";
THIS._REG[1] = "http://www.baidu.com (. *)";
THIS._REG[2] = "http://www.sogou.com (. *)";
THIS._REG[3] = "http://cn.bing.com (. *)";
Parse URL parameter var hosturl = window.location.href; if (hosturl!= undefined && hosturl!= "") {if (new RegExp (this._reg[4)). Test (Hosturl)) {This._c h["_gid"] = this.
Searchgid ();
else if ((New RegExp (this._reg[7)). Test (Hosturl)) {} else if ((New RegExp (this._reg[5)). Test (Hosturl)) { this._ch["_cid"] = this.
Searchcategory (); else if ((New RegExp (this._reg[6)). Test (Hosturl)) {this._ch["_key"] = this.
Searchkey ();
} this._ch["_tu"] = Hosturl;
var referrer = Document.referrer; if (referrer!= undefined && referrer!= "") {if (new RegExp (this._reg[0)). Test (referrer)) {This . _ch["_key"] = this.
SearchSite ("Google"); else if ((New RegExp (this._reg[1)). Test (referrer)) {this._ch["_key"] = this.
SearchSite ("Baidu"); else if ((New RegExp (this._reg[2)). Test (referrer)) {this._ch["_key"] = this.
SearchSite ("Sogou"); else if ((New RegExp (this._reg[3)). Test (referrer)) {this._ch["_key"] = this.
SearchSite ("Bing");
} this._ch["_su"] = referrer; //Get client-related information this._ch["_SW"] = this.
ScreenWidth (); this._ch["_sh"] = this.
ScreenHeight (); this._ch["_BW"] = this.
Browse (); this._ch["_cs"] = this.
Clientos (); this._ch["_mid"] = thIs.
ClientID ("From_channelid"); this._ch["_ctid"] = this.
ClientID ("Clientkey"); }, _ch:undefined, _reg:undefined
This is the entire article, learn more about JavaScript syntax, you can see: "JavaScript Reference Tutorial," JavaScript Code style guide, and also hope that you support the cloud-Habitat community.