📄 ednad.js
字号:
///<reference path="JQuery.Intellisense.js"/>
var GlobalTimeOut = 0;
var keyword;
var artbody = '';
var re;
$(function() {
if (typeof (HTMLElement) != "undefined") {
HTMLElement.prototype.contains = function(Node) {// 是否包含某节点
do if (Node == this) return true;
while (Node = Node.parentNode);
return false;
}
}
if (window.Event) {// 修正Event的DOM
Event.prototype.__defineGetter__("toElement", function() {// 返回鼠标移入的源节点
var node;
if (this.type == "mouseout") {
node = this.relatedTarget;
}
else if (this.type == "mouseover") {
node = this.target;
}
if (!node) return;
while (node.nodeType != 1) node = node.parentNode;
return node;
});
}
$.getJSON(
"http://article.ednchina.com/js/keyjson.ashx?jsoncallback=?",
function(msg) {
if (document.getElementById("ArticleContent") != null) {
artbody = $("#ArticleContent").html();
}
if (document.getElementById("bbsContent") != null) {
artbody = $("#bbsContent").html();
}
if (document.getElementById("groupContent") != null) {
artbody = $("#groupContent").html();
}
if (artbody.length == 0) {
return;
}
var k = 0;
for (var i = 0; i < msg.length; i++) {
if (k < 10) {
var NewClass = {
ID: msg[i].id,
KeyID: msg[i].keyid,
Type: msg[i].type,
Url: msg[i].url,
Key: msg[i].adkey,
Body: msg[i].txt
};
var engre = new RegExp('[a-zA-Z]');
re = new RegExp('(>[^<]*?)(' + NewClass.Key + ')([^<]*?<)', 'i');
//NewClass.Type 有0 ,1 ,2 三种广告形式
if (NewClass.Type < 2) {
if (artbody.search(re) > -1) {
var NewKey = "<nobr id='nobr" + NewClass.ID + "'" +
" onmouseout=\"GlobalHide('" + NewClass.ID + "',null)\"" +
" onclick=\"CompanyInsert('" + NewClass.ID + "','false','" + NewClass.Url + "');\"" +
" onmousemove=\"GetAsync('" + NewClass.ID + "','" + NewClass.Type + "','" + NewClass.Url + "');\" \>" +
NewClass.Key +
"</nobr>";
GetArtBody(engre, NewClass, NewKey);
k = k + 1;
CompanyInsert(NewClass.ID, null, null);
}
}
else {
if (artbody.search(re) > -1) {
var NewKey = "<font color='blue'>" + NewClass.Key + "</font>(<nobr id='span" + NewClass.ID + "'" +
" onclick=\"CompanyInsert('" + NewClass.ID + "','false','" + NewClass.Url + "');\">" +
NewClass.Body + "</nobr>)";
GetArtBody(engre, NewClass, NewKey);
k = k + 1;
CompanyInsert(NewClass.ID, null, null);
}
}
}
}
if (document.getElementById("ArticleContent") != null) {
$("#ArticleContent").html(artbody);
}
if (document.getElementById("bbsContent") != null) {
$("#bbsContent").html(artbody);
}
if (document.getElementById("groupContent") != null) {
$("#groupContent").html(artbody);
}
$("nobr").css("border-bottom", "1px dotted rgb(102,0,255)")
.css("text-decoration", "underline")
.css("color", "#CB4BFC")
.css("background-color", "transparent")
.css("cursor", "pointer");
}
);
})
function GetArtBody(engre, NewClass, newkey) {
artbody = artbody.replace(re, '$1' + newkey + '$3');
}
function CompanyInsert(companyid, isshow, url) {
if (isshow == null) {
$.getJSON(
"http://article.ednchina.com/js/CompanyAdInsert.ashx?id=" + companyid + "&jsoncallback=?",
function(msg) { }
);
//$.get("http://ariticle.mycode.com/js/CompanyAdInsert.ashx",{ id: companyid })
}
else {
$.getJSON(
"http://article.ednchina.com/js/CompanyAdInsert.ashx?jsoncallback=?",
{ id: companyid, show: isshow },
function(msg) { }
);
//$.get("http://ariticle.mycode.com/js/CompanyAdInsert.ashx", { id: companyid, show: isshow })
}
if (url == null || url == 'null') {
}
else {
window.open(url, 'ad', '', '');
}
}
function GlobalHide(id, url) {
GlobalTimeOut = window.setTimeout("Hide('" + id + "','" + url + "')", 100);
}
function Hide(id, url) {
document.getElementById("nobrDisplay" + id).style.display = "none";
CompanyInsert(id, "true", url);
}
function GetAsync(id, type, url) {
var nobrDisply = $("#nobrDisply" + id);
if (document.getElementById("nobrDisplay" + id) == null) {
var TempClass = {
Id: id,
Type: type,
Url: url
};
$("body").append("<div id='nobrDisplay" + TempClass.Id + "'></div>");
nobrDisply = $("#nobrDisplay" + TempClass.Id);
if (TempClass.Type == '0') {
nobrDisply.addClass("keywords");
}
else {
nobrDisply.addClass("keywords2");
}
var location = $("#nobr" + TempClass.Id).offset();
nobrDisply.css("position", "absolute");
nobrDisply.css("left", location.left + 5 + "px");
nobrDisply.css("top", location.top + 20 + "px");
nobrDisply.prepend("<img src=\"/Images/bbsLoad.gif\" alt=\"Loading...\" />请等待.....");
nobrDisply.click(function() {
CompanyInsert(TempClass.Id, "false", TempClass.Url);
}).mousemove(function(event) {
if (GlobalTimeOut != 0) {
window.clearTimeout(GlobalTimeOut);
}
$(this).show();
})
.mouseout(function(event) {
if (!this.contains(event.toElement)) {
Hide(TempClass.Id, null)
}
});
$.getJSON("http://article.ednchina.com/js/companyad.ashx?jsoncallback=?",
{ id: TempClass.Id },
function(response) {
if (response.length > 0) {
nobrDisply.empty();
nobrDisply.prepend(response[0].AdTxt);
}
}
);
}
else {
document.getElementById("nobrDisplay" + id).style.display = "block";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -