var _cwa = _cwa || []; (function () { var _customdata=[]; if(_cwa.length>0) { for(var q in _cwa) { console.log(_cwa[q][0]) if(_cwa[q][0]=="_setCustom") { _customdata.push(_cwa[q]); } } } _cwa=[]; function cwa() { this.siteid = 1001; this.host = "sichuan.iischool.com" this.ischooluid = "iischool_uid"; this.uuid = "CWA_Uid" + this.siteid; this.cwauid = "CWA_UserID" + this.siteid; this.cwauidtemp = "CWA_UserIDt" + this.siteid; this.lasttime = "CWA_lasttime" + this.siteid; this.rtime = "CWA_rtime" + this.siteid; this.repeat = "CWA_repeat" + this.siteid; this.ucode = "CWA_ucode" + this.siteid; this.isshowsitedisplay = false; this.init() }; var d = document, w = window, f = encodeURIComponent, l = decodeURIComponent, u = unescape; cwa.prototype = { init:function() { this.eventpush(); }, log:function(name,message) { var c = []; c.push("siteid="+this.siteid); c.push("name=" + f(a.name)); c.push("msg=" + f(a.message)); c.push("r=" + f(d.referrer)); c.push("page=" + f(d.location.href)); c.push("agent=" + f(w.navigator.userAgent)); console.log(c.join("&")); }, createscript: function (url) { try { ////if (b = b || "utf-8", "1" === this.v) { // var c = d.createElement("script"); // c.type = "text/javascript"; // c.async = true; // c.charset = "utf-8"; // c.src = url; // d.body.appendChild(c); ////} else d.write(u("%3Cscript src='" + url + "' charset='utf-8' type='text/javascript'%3E%3C/script%3E")) } catch (e) { this.log(e, "cAS failed") } }, createimg: function (arr) { for (var b = arr.length, c = null, d = 0; d < b; d++) { arr[d] && (c = "cwaimg_" + Math.floor(2147483648 * Math.random()), w[c] = new Image, w[c].W = c, w[c].onload = w[c].onerror = w[c].onabort = function () { try { this.onload = this.onerror = this.onabort = null, w[this.W] = null } catch (a) { } }, w[c].src = arr[d] + "&rnd=" + Math.floor(2147483648 * Math.random())) } }, event:function(arr) { if ("[object Array]" === {}.toString.call(arr)) { switch (arr[0]) { case "_trackPageview": break; case "_setCustom": if(arr.length==3) { this.cookieset(arr[1],arr[2],2); } conosle.log(arr[1]); break; case "_trackEvent": var c = []; arr[1] && arr[2]&& arr[3] &&(c.push(f(arr[1])),c.push(f(arr[2])),c.push(f(arr[3])),c.push(arr[4] ? f(arr[4]) : ""), arr[5] = parseFloat(arr[5]), c.push(isNaN(arr[5]) ? 0 : arr[5]), c.push(arr[6] ? f(arr[6]) : ""),this.ev=c.join("|"),this.eventpost(),delete this.ev); break; } } }, eventpush:function() { try { var a = this; w._cwa = { push: function () { return a.event.apply(a, arguments) } } } catch (e) { this.log(e, "push error") } }, eventpost:function() { var uid = this.cookieget(this.uuid); var userid = this.cookieget(this.cwauid); var data = this.basicdata(); "[object String]" === {}.toString.call(this.ev) && data.push("ev=" + f(this.ev)); var c = data.join("&"); "[object String]" === {}.toString.call(this.ev) && this.createimg(["http://" + this.host + "/home/event?" + c]); }, cookieget: function (name) { var arr = d.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)")); if (arr != null) return u(arr[2]); return -1; }, cookieset: function (name, val, cotp) { var date = new Date(); var year = date.getFullYear(); var hour = date.getHours(); var ck = ""; if (cotp == 0) { var datey = new Date((date.getFullYear() + 5), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()); ck = name + "=" + val + ";expires=" + datey.toGMTString() + ";"; } else if (cotp == 1) { ck = name + "=" + val + ";expires=" + new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 1, 0, 0, 0).toGMTString() + ";"; } else if (cotp == 2) { ck = name + "=" + val + ";expires=" + CWA.UTC.tm() + ";"; } ck += "path=/;"; //console.log(ck); d.cookie = ck; }, screen:function(){ var width = screen.width; var height = screen.height; var _screen = screen.width + "x" + screen.height; return _screen; }, basicdata: function () { var data = []; data.push("siteID=" + this.siteid); data.push("uid=" + this.cookieget(this.uuid)); data.push("userid=" + this.cookieget(this.cwauid)); data.push("url=" + f(d.URL)); data.push("screen=" + f(this.screen())); return data; }, track: function () { var page = d.URL; var referrer = d.referrer; var language = navigator.systemLanguage; var nowtime = parseInt(new Date().getTime()); var lastime = parseInt(this.cookieget(this.lasttime)); var rtime = parseInt(this.cookieget(this.rtime)); var repeat = this.cookieget(this.repeat); var repeattime = parseInt((nowtime - lastime) / 1000); var uid = this.cookieget(this.uuid); var unionCode = this.cookieget(this.ucode); var userid = this.cookieget(this.ischooluid); if (unionCode == -1) { unionCode = ""; } var newUv = 0; if (uid == -1) { var rand1 = parseInt(Math.random() * 4000000000); var rand2 = parseInt(Math.random() * 4000000000); uid = String(rand1) + String(rand2); this.cookieset(this.uuid, uid, 0); newUv = 1; repeat = -1; } if (userid != -1) { var _userid = this.cookieget(this.cwauid); this.cookieset(this.cwauid, userid, 0); var _tempuserid = this.cookieget(this.cwauidtemp); if (_tempuserid == -1) _tempuserid = ""; if (_tempuserid.indexOf(_userid) == -1) { repeat = -1; newUv = 0; this.cookieset(this.cwauidtemp, _tempuserid + "," + userid, 1); } } else { userid = this.cookieget(this.cwauid); } if (repeat == -1) { repeat = 1; } else { repeat = parseInt(repeat) + 1; } if (lastime < 1000000) { rtime = 0; lastime = 0; } if (rtime < 1) rtime = 0; if (((nowtime - lastime) > 500 * 86400) && (lastime > 0)) rtime++; var data = []; data.push("siteID=" + this.siteid); data.push("uid=" + uid); data.push("userid=" + userid); data.push("lg=" + f(language)); data.push("lastime=" + lastime); data.push("rpcount=" + repeat); data.push("rtime=" + rtime); data.push("rptime=" + repeattime); data.push("rf=" + f(referrer)); data.push("isnewUv=" + newUv ); data.push("screen=" + f(this.screen())); data.push("url=" + f(d.URL)); data.push("unionCode=" + unionCode); data.push("pageTitle=" + document.title); for(var q in _customdata) { data.push(_customdata[q][1]+"="+f(_customdata[q][2])); } this.cookieset(this.repeat, repeat, 1); this.cookieset(this.lasttime, nowtime, 1); this.cookieset(this.rtime, rtime, 1); var url = "http://"+this.host+"/home/analytics?" + data.join("&"); this.createimg([url]); }, show: function () { var url = "http://" + this.host + "/home/online?" + this.basicdata().join("&"); this.createscript(url); } } try { var o = new cwa; o.track(); o.isshowsitedisplay==true&&o.show(); } catch (e) { //this.log(e,"") } })()