var scripts = document.getElementsByTagName('script'); var currentScript = scripts[scripts.length - 1].src; function getQueryString(name, url) { if(url == undefined){ url = window.location.search.substr(1); }else if(url.indexOf("?") != -1){ url = url.substr(url.indexOf("?") + 1) }else{ url = ""; } var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = url.match(reg); if (r != null){ return unescape(r[2]); } return ""; } function getId(){ var path = window.location.pathname; var channelId = 0; var infoId = 0; if(path.indexOf("/main/preview.do") != -1){ var url = window.location.href; channelId = getQueryString("channelId", url); infoId = getQueryString("infoId", url); }else{ var result = RegExp("/channel/(\\d*)/").exec(path); if(result != null){ channelId = result[1]// 鏍忕洰ID } result = RegExp("/detail-(\\d*)\\.").exec(path); if(result != null){ infoId = result[1]// 淇℃伅ID } } return new Array(channelId,infoId); } (function() { var domain = window.location.protocol + "//" + window.location.host; // 鑴氭湰瀵瑰簲鐨勮缁熻绔欑偣鍩熷悕 var url = domain + window.location.pathname; // 褰撳墠椤甸潰url var interfaceURL = currentScript.substring(0, currentScript.indexOf("/res/visit/")) + '/openapi/visit/visit.do';//缁熻鎺ュ彛 var D = document, L = D.location, R = D.referrer, W = window, E = encodeURIComponent; var VISIT = { client : {}, getUrl : function() {// 鍦板潃 this.client.url = url; }, getResolution : function() {// 鍒嗚鲸鐜 this.client.resolution = W.screen.width + "x" + W.screen.height; }, getColorDepth : function() {// 鑹叉繁 this.client.color = W.screen ? W.screen.colorDepth + "-bit" : ""; }, getRef : function() {// 鏉ユ簮椤甸潰 this.client.ref = R ? E(R) : ""; }, getCookieEnabled : function() {// 鏄惁鏀寔Cookie this.client.cookieEnabled = navigator.cookieEnabled ? "1" : "0"; }, getJavaEnabled : function() {// 鏄惁鏀寔Java this.client.javaEnabled = navigator.javaEnabled ? "1" : "0"; }, getFlash : function() {// Flash鐗堟湰 if (navigator.plugins && typeof navigator.plugins["Shockwave Flash"] == "object") { var a = navigator.plugins["Shockwave Flash"].description; if (a && (!navigator.mimeTypes || !navigator.mimeTypes["application/x-shockwave-flash"] || navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)) { this.client.flashVersion = a.replace(/^.*\s+(\S+)\s+\S+$/, "$1"); } } else { if (W.ActiveXObject) { try { if (a = new ActiveXObject( "ShockwaveFlash.ShockwaveFlash")) { (version = a.GetVariable("$version")) && (this.client.flashVersion = version.replace( /^.*\s+(\d+),(\d+).*$/, "$1.$2")); } } catch (b) { } } } }, getLanguage : function() {// 璇█ var a = navigator; this.client.language = (a.systemLanguage ? a.systemLanguage : a.browserLanguage ? a.browserLanguage : a.language ? a.language : a.userLanguage ? a.userLanguage : "-") .toLowerCase(); }, getId : function() { this.client.siteId = getQueryString("s", currentScript);// 绔欑偣ID var ids = getId(); this.client.channelId = ids[0]// 鏍忕洰ID this.client.infoId = ids[1]// 淇℃伅ID }, getTitle : function() {// 鏂囩珷鏍囬 this.client.title = E(document.title); }, getRnd : function() {// 浜х敓闅忓嵆鏁 this.client.rnd = Math.round(Math.random() * 4000000000); }, getUV : function() {// 鑾峰緱璁垮ID var uv = this.getCookie('VISIT_UV'); if (uv == '') { var rand1 = parseInt(Math.random() * 4000000000); var rand2 = parseInt(Math.random() * 4000000000); uv = String(rand1) + String(rand2); } var date = new Date(); date.setDate(date.getDate() + 1); date.setHours(0, 0, 0, 0); this.setCookie('VISIT_UV', uv, date, domain, '/'); this.client.uv = uv; }, getSession : function() {// 鑾峰彇Seesion ID var session = this.getCookie('VISIT_session'); if (session == '') { var rand1 = parseInt(Math.random() * 4000000000); var rand2 = parseInt(Math.random() * 4000000000); session = String(rand1) + String(rand2); } var date = new Date(); date.setMinutes(date.getMinutes() + 30); this.setCookie('VISIT_session', session, date, domain, '/'); this.client.sessionId = session; }, setCookie : function(name, value, expires, domain, path) {// 璁剧疆Cookie D.cookie = name + "=" + value + (expires == null ? "" : "; expires=" + expires.toGMTString()) + "; domain=" + domain + (path ? "; path=" + path : ""); }, getCookie : function(name) {// 鑾峰彇cookie if (name = RegExp("(^| )" + name + "=([^;]*)(;|$)").exec(D.cookie)) { return name[2] || ""; } return ""; }, postData : function() {// 鍙戦€佹暟鎹 var param = []; for ( var i in this.client) { var h = E(this.client[i]); if (h) param.push(i + '=' + h); } var a = new Image(1, 1); a.src = interfaceURL + '?' + param.join('&'); }, init : function() { this.getUrl(); this.getRnd(); this.getUV(); this.getSession(); this.getId(); this.getColorDepth(); this.getCookieEnabled(); this.getFlash(); this.getJavaEnabled(); this.getLanguage(); this.getRef(); this.getResolution(); this.getTitle(); //鍙戦€佹暟鎹埌鎺ュ彛 this.postData(); } }; VISIT.init(); })();