(function () {
var req, UID, ot;
var expDays = 30;
var exp = new Date();
var isRefresh;
exp.setTime(exp.getTime() + (expDays * 24 * 60 * 60 * 1000));
init();
function init(a) {
setUp();//启动cookies
if (!window.remote_ip_info) {
var s = document.createElement('script');
s.onload = pullRequest;
//加载新浪IP库
s.type = 'text/javascript';
s.src = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js';
document.body.appendChild(s);
s = null;
}
//检查脚本是否加载成功,否则重载
ot = setInterval(function () {
!!window.remote_ip_info ? clearInterval(ot) : init()
}, 1500);
}
/*后台处理
function pullRequest() {
// 后台处理的文件地址
var url = "http://t1.tuancity.com/analysis/rev.php";
// 获取当前的网址
var link = window.location.href;
// 获取上页地址
var oldlink = document.referrer;
// 获取当前访问页的标题
var titleName = document.title;
// 屏幕分辨率
var screen = window.screen.width + "*" + window.screen.height;
// 异步请求发送
$.ajax(
{
url: url + "?id=" + escape(link) + "&oldlink=" + escape(oldlink) + "&title=" + escape(titleName) + "&s=" + screen + "&p=" + remote_ip_info.province + "&c=" + remote_ip_info.city + "&guid=" + TY.storage.getCookie('GUID') + "&wwc=" + TY.storage.getCookie('WWHCount') + "&wwh=" + TY.storage.getCookie('WWhenH') + "&uv=" + TY.storage.getCookie('UVCount'),
type: 'post',
//data: { id: escape(link), oldlink: escape(oldlink), title: escape(titleName), s: screen, p: remote_ip_info.province, c: remote_ip_info.city,guid:TY.storage.getCookie('GUID'),wwc:TY.storage.getCookie('WWHCount'),wwh: TY.storage.getCookie('WWhenH'),uv: TY.storage.getCookie('UVCount')},
success: function (data) {
}
});
}
// Cookies
function setUp() {
TY.storage.setCookie('GUID', Who(), false, exp);
Count();
CountUv();
When();
}
function Who() {
var GUID = TY.storage.getCookie('GUID');
if (GUID == null||!GUID) {
GUID = function () {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
}).toUpperCase();
};
return GUID()
}
return GUID;
}
//访问时间
function When() {
var rightNow = new Date();
var WWHTime = 0;
WWHTime = TY.storage.getCookie('WWhenH');
WWHTime = WWHTime * 1
var lastHereFormatting = new Date(WWHTime);
// 访问时间记录
var intLastVisit = (lastHereFormatting.getYear() * 10000) + (lastHereFormatting.getMonth() * 100) + lastHereFormatting.getDate();
var lastHereInDateFormat = "" + lastHereFormatting;
var dayOfWeek = lastHereInDateFormat.substring(0, 3);
var dateMonth = lastHereInDateFormat.substring(4, 11);
var timeOfDay = lastHereInDateFormat.substring(11, 16);
var year = lastHereInDateFormat.substring(23, 25);
var WWHText = dayOfWeek + ", " + dateMonth + " at " + timeOfDay;
TY.storage.setCookie("WWhenH", rightNow.getTime(), false, exp);
return WWHText;
}
// 访问次数统计pv
function Count() {
var WWHCount = TY.storage.getCookie('WWHCount')
if (WWHCount == null) {
WWHCount = 1;
}else {
WWHCount++;
}
TY.storage.setCookie('WWHCount', WWHCount, false, exp);
return WWHCount;
}
//访问uv次数。
function CountUv() {
var UVCount = TY.storage.getCookie('UVCount');
var oldtime = TY.storage.getCookie('WWhenH');
var newtime = new Date();
var olddateMax = (parseInt(oldtime / 1000 / 60 / 60/24)+1)*24 * 3600 * 1000;
if (UVCount == null) {
UVCount = 1;
}else {
if (newtime>olddateMax)
UVCount++;
}
TY.storage.setCookie('UVCount', UVCount,false, exp);
return UVCount;
}
}());