70 lines
2.2 KiB
JavaScript
70 lines
2.2 KiB
JavaScript
define(function(require, exports, module) {
|
|
|
|
var hiido = {
|
|
domain: "ylog.hiido.com",
|
|
|
|
ips: ['218.61.196.187', '218.61.196.188', '14.17.112.232', '14.17.112.233', '183.232.137.31', '183.232.137.32', '117.144.234.35','117.144.234.36'],
|
|
getServerUrl: function(host) {
|
|
host = host || this.domain;
|
|
var ptl = location.protocol;
|
|
var path = "j.gif?";
|
|
return ptl + "//" + host + "/" + path;
|
|
},
|
|
randomIp: function() {
|
|
var Rand = Math.random();
|
|
var index = Math.round(Rand * (this.ips.length - 1));
|
|
var suff = this.ips[index];
|
|
return suff;
|
|
},
|
|
getParam: function(opt) {
|
|
var obj = opt;
|
|
var param = ['act=webvipfront']; // act放在第一个参数的位置
|
|
param[1] = ['time=' + parseInt( 1 * new Date()/1000) ];
|
|
param[2] = ['uid=' + this.getCookie("yyuid") ];
|
|
//obj.time =parseInt( 1 * new Date()/1000);
|
|
//obj.uid=this.getCookie("yyuid");
|
|
|
|
for (h in obj) {
|
|
if (obj.hasOwnProperty(h)) {
|
|
param.push(h + "=" + (obj[h] === undefined || obj[h] === null ? "" :
|
|
obj[h]))
|
|
}
|
|
}
|
|
return param.join("&");
|
|
},
|
|
send: function(url, backurl, times) {
|
|
var reties = times || 0;
|
|
var img = new Image();
|
|
var self = this;
|
|
img.onerror = function() {
|
|
if (reties <= 1) {
|
|
self.send(url, backurl, ++reties);
|
|
}
|
|
else if (reties == 2) {
|
|
self.send(backurl, backurl, ++reties);
|
|
}
|
|
}
|
|
img.src = url;
|
|
},
|
|
getCookie:function(name){
|
|
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
|
|
if(arr=document.cookie.match(reg)) {
|
|
return unescape(arr[2]);
|
|
}else{
|
|
return null
|
|
};
|
|
}
|
|
};
|
|
|
|
function hiddoStat(opt){
|
|
var svr = hiido.getServerUrl();
|
|
var param = hiido.getParam(opt);
|
|
var url = svr + param;
|
|
|
|
var backurl = hiido.getServerUrl(hiido.randomIp()) + param;
|
|
hiido.send(url, backurl);
|
|
}
|
|
|
|
exports.hiddoStat = hiddoStat;
|
|
});
|