📄 j.web.tips.js
字号:
var WebTips = new Object();
WebTips.Browser = {
ie: /msie/.test(window.navigator.userAgent.toLowerCase()),
moz: /gecko/.test(window.navigator.userAgent.toLowerCase()),
opera: /opera/.test(window.navigator.userAgent.toLowerCase())
};
WebTips.$ = function(s)
{
return (typeof s == 'object') ? s: document.getElementById(s);
};
WebTips.Element = {
remove: function()
{
for (var i=0; i<arguments.length; i++)
{
try
{
WebTips.$(arguments[i]).parentNode.removeChild(WebTips.$(arguments[i]));
}
catch (e)
{
}
}
}
};
WebTips.JsLoader = {
load: function(sUrl, fCallback)
{
WebTips.Element.remove(sUrl);
var _script = document.createElement('script');
_script.setAttribute('type', 'text/javascript');
_script.setAttribute('id', sUrl);
_script.setAttribute('src', sUrl);
_script.setAttribute('charset', "gb2312");
document.getElementsByTagName('head')[0].appendChild(_script);
if (WebTips.Browser.ie)
{
_script.onreadystatechange = function()
{
if (this.readyState=='loaded' || this.readyState=='complete')
{
fCallback();
WebTips.Element.remove(_script);
}
};
}
else if (WebTips.Browser.moz)
{
_script.onload = function()
{
fCallback();
WebTips.Element.remove(_script);
};
}
else
{
fCallback();
WebTips.Element.remove(_script);
}
}
};
WebTips.Cookie = {
setCookie: function(name, value, expires, path, domain, secure)
{
document.cookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "; path=/") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
},
getCookie: function(name)
{
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if (arr != null)
{
return unescape(arr[2]);
}
return "";
},
clearCookie: function(name, path, domain)
{
if (WebTips.Cookie.getCookie(name))
{
document.cookie = name + "=" +
((path) ? "; path=" + path : "; path=/") +
((domain) ? "; domain=" + domain : "") +
";expires=Fri, 02-Jan-1970 00:00:00 GMT";
}
}
};
WebTips.Page = {
getPageWidth: function()
{
return document.body.scrollWidth || document.documentElement.scrollWidth || 0;
},
getPageHeight: function()
{
return document.body.scrollHeight || document.documentElement.scrollHeight || 0;
},
getBodyWidth: function()
{
return document.documentElement.clientWidth || document.body.clientWidth || 0;
},
getBodyHeight: function()
{
return document.documentElement.clientHeight || document.body.clientHeight || 0;
},
getBodyLeft: function()
{
return document.body.scrollLeft || document.documentElement.scrollLeft || window.pageXOffset || 0;
},
getBodyTop: function()
{
return document.body.scrollTop || document.documentElement.scrollTop || window.pageYOffset || 0;
},
getBody: function()
{
return {
width : this.getBodyWidth(),
height : this.getBodyHeight(),
left : this.getBodyLeft(),
top : this.getBodyTop()
};
},
getScreenWidth: function()
{
return window.screen.width;
},
getScreenHeight: function()
{
return window.screen.height;
}
};
WebTips.Flags = {
"中国": "40.gif",
"美国": "196.gif",
"德国": "74.gif",
"意大利": "94.gif",
"日本": "98.gif",
"韩国": "103.gif",
"澳大利亚": "12.gif",
"法国": "66.gif",
"俄罗斯": "158.gif",
"英国": "70.gif",
"捷克共和国": "52.gif",
"乌克兰": "194.gif",
"格鲁吉亚": "72.gif",
"古巴": "50.gif",
"荷兰": "135.gif"
};
WebTips.hwd = null;
WebTips.nCheckInterval = 60000;
WebTips.IsNeedPush = function(sTimeStamp)
{
var year = parseInt(sTimeStamp.substr(0,4), 10);
var month = parseInt(sTimeStamp.substr(5,2), 10) - 1;
var day = parseInt(sTimeStamp.substr(8,2), 10);
var hours = parseInt(sTimeStamp.substr(11,2), 10);
var minutes = parseInt(sTimeStamp.substr(14,2), 10);
var seconds = parseInt(sTimeStamp.substr(17,2), 10);
var time1 = new Date(year, month, day, hours, minutes, seconds);
var time2 = new Date();
if((time2.getTime() - time1.getTime())/1000 < 600)
{
return true;
}
else
{
return false;
}
}
WebTips.check = function()
{
sWebTipsTimestamp = null;
WebTips.JsLoader.load("http://refresh.qq.com/immediately/1/tips_timestamp.json?cache="+parseInt(Math.random()*1500), function()
{
if (typeof sWebTipsTimestamp != "undefined")
{
if (sWebTipsTimestamp > WebTips.Cookie.getCookie("www_tips_timestamp_qqcom")
&& WebTips.IsNeedPush(sWebTipsTimestamp))
{
WebTips.push(sWebTipsTimestamp);
}
else
{
if (WebTips.hwd != 0)
{
WebTips.hwd = window.setTimeout(WebTips.check, WebTips.nCheckInterval);
}
}
}
else
{
if (WebTips.hwd != 0)
{
WebTips.hwd = window.setTimeout(WebTips.check, WebTips.nCheckInterval);
}
}
});
};
WebTips.push = function(_sWebTipsTimestamp)
{
insWebTipsInfo = null;
WebTips.JsLoader.load("http://refresh.qq.com/immediately/1/tips_info_v2.json?cache=" + parseInt(Math.random()*1500), function()
{
if (typeof insWebTipsInfo != "undefined")
{
if (insWebTipsInfo.title != WebTips.Cookie.getCookie("www_tips_title_qqcom"))
{
//flag==1 普通tips || flag==2 金牌tips
if (insWebTipsInfo.flag != "2")
{
var sUrl = insWebTipsInfo.url;
if(sUrl.indexOf("http://") == -1 && sUrl.indexOf("Http://") == -1)
{
sUrl = "http://" + sUrl;
}
try
{
WebTips.$("www_tips_title").innerHTML = '<a href="' + sUrl + '" class="title" target="_blank" onclick="WebTips.PGV(1, 2);">' + insWebTipsInfo.title + '</a>';
WebTips.$("www_tips_brief").innerHTML = insWebTipsInfo.brief.substr(0,35) + "...";
WebTips.$("www_tips_url").innerHTML = '<a href="' + sUrl + '" class="red" target="_blank" onclick="WebTips.PGV(1, 2);">详细>></a>';
}
catch (e)
{
}
WebTips.PopBox.enetgetMsg();
//曝光量统计
WebTips.Url = insWebTipsInfo.url.replace("http://2008.qq.com", "");
WebTips.PGV(1, 1);
}
else
{
//未登录QQ
if (WebTips.Browser.ie && IsInstallQQ() && !IsAnyQQActive())
{
try
{
insWebTipsInfo.title = insWebTipsInfo.newstitle;
WebTips.$('wintitle').innerHTML = insWebTipsInfo.wintitle;
WebTips.$('newstitle').innerHTML = insWebTipsInfo.newstitle;
WebTips.$('newstitleurl').href = insWebTipsInfo.newsurl;
WebTips.$('imglink').href = insWebTipsInfo.imglink;
WebTips.$('imgurl').src = insWebTipsInfo.imgurl;
WebTips.$('imgnote').innerHTML = insWebTipsInfo.imgnote;
WebTips.$('newsintro').innerHTML = insWebTipsInfo.newsinstor;
WebTips.$('newsurl').href = insWebTipsInfo.newsurl;
WebTips.$('newstitle').style.color = "#" + insWebTipsInfo.newstitlecolor;
WebTips.$('chinasum0').innerHTML = insWebTipsInfo.medal.split(",")[0];
WebTips.$('chinasum1').innerHTML = insWebTipsInfo.medal.split(",")[1];
WebTips.$('chinasum2').innerHTML = insWebTipsInfo.medal.split(",")[2];
if (insWebTipsInfo.ad_img_url!="" && insWebTipsInfo.ad_click_url!="")
{
WebTips.$('ad_img_url').src = insWebTipsInfo.ad_img_url;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -