Last active
April 16, 2018 12:37
-
-
Save earthday/4475d9807a03bfcaf22f to your computer and use it in GitHub Desktop.
上海长城宽带右下角广告代码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script language="javascript"> | |
<!-- | |
var ua = navigator.userAgent; | |
var $IE = (navigator.appName == "Microsoft Internet Explorer"); | |
var $IE5 = $IE && (ua.indexOf('MSIE 5') != -1); | |
var $IE5_0 = $IE && (ua.indexOf('MSIE 5.0') != -1); | |
var $Gecko = ua.indexOf('Gecko') != -1; | |
var $Safari = ua.indexOf('Safari') != -1; | |
var $Opera = ua.indexOf('Opera') != -1; | |
var $Mac = ua.indexOf('Mac') != -1; | |
var $NS7 = ua.indexOf('Netscape/7') != -1; | |
var $NS71 = ua.indexOf('Netscape/7.1') != -1; | |
if ($Opera) { | |
$IE = true; | |
$Gecko = false; | |
$Safari = false; | |
} | |
if ($IE5) { | |
$IE = true; | |
$Gecko = false; | |
$Safari = false; | |
} | |
function $_t(root,tag,id){ | |
var ar=root.getElementsByTagName(tag); | |
for (var i=0;i<ar.length;i++){ | |
if (ar[i].id==id) return ar[i]; | |
} | |
return null; | |
} | |
function $dele(o,fn,rv){ | |
var r = function (){ | |
var s=arguments.callee; | |
var args = []; | |
for (var i=0;i<s.length;i++) args[i]=s[i]; | |
var argStr = args.join(","); | |
if (argStr.length > 0) argStr=","+argStr; | |
var callStr="s.thiz[s.fn]("+argStr+")"; | |
var v=eval(callStr); | |
if (s.rv!=null) { | |
return s.rv; | |
} else { | |
return v; | |
} | |
} | |
r.thiz=o; | |
r.fn=fn; | |
r.rv=rv; | |
return r; | |
} | |
function $ge(e){ | |
if (e!=null) return e; | |
if ($IE) { | |
return window.event; | |
} else return e; | |
} | |
function $addEL(n,e,l,b){ | |
if ($IE){ | |
if (n["$__listener_"+e]==null){ | |
var lst=function (e){ | |
var f=arguments.callee; | |
var ar=f.fList; | |
e=$ge(e); | |
for (var i=0;i<ar.length;i++){ | |
ar[i](e); | |
} | |
} | |
lst.fList=[]; | |
n["$__listener_"+e]=lst; | |
n["on"+e]=n["$__listener_"+e]; | |
} | |
var fList=n["$__listener_"+e].fList; | |
fList[fList.length]=l; | |
} else { | |
n.addEventListener(e,l,b); | |
} | |
} | |
function $cancelEvent (e) { | |
if ($IE) { | |
e.returnValue = false; | |
e.cancelBubble = true; | |
} else | |
e.preventDefault(); | |
}; | |
function $openUrlBtn (e) { | |
var canopen=OpenAdUrl('http://www.gwbnsh.net.cn/RouletteActivity/Default.aspx',''); | |
}; | |
function $cpAttr(o,p){ | |
for (var i in p){ | |
var s=p[i]; | |
o[i]=s; | |
} | |
return o; | |
} | |
function $getValue(v,d){ | |
return v==null ? d : v; | |
} | |
var $gv=$getValue; | |
var $dom={ | |
parseInt : function(s) { | |
if (s == null || s == '' || typeof(s)=='undefined') | |
return 0; | |
return parseInt(s); | |
}, | |
getClientSize : function(n){ | |
if ($IE){ | |
var s= {x:n.clientLeft,y:n.clientTop}; | |
s.l=s.x; | |
s.t=s.y; | |
s.r=n.clientRight; | |
s.b=n.clientBottom; | |
s.w=n.clientWidth; | |
s.h=n.clientHeight; | |
return s; | |
} else { | |
var t=n.style; | |
if (t.borderLeftWidth.length==0 || t.borderTopWidth.length==0 || t.borderRightWidth.length==0 || t.borderBottomWidth.length==0){ | |
var l=n.offsetWidth; | |
t.borderLeftWidth="0px"; | |
l-=n.offsetWidth; | |
var r=n.offsetWidth; | |
t.borderRightWidth="0px"; | |
r-=n.offsetWidth; | |
var o=n.offsetHeight; | |
t.borderTopWidth="0px"; | |
o-=n.offsetHeight; | |
var b=n.offsetHeight; | |
t.borderBottomWidth="0px"; | |
b-=n.offsetHeight; | |
t.borderLeftWidth=l+"px"; | |
t.borderTopWidth=o+"px"; | |
t.borderRightWidth=r+"px"; | |
t.borderBottomWidth=b+"px"; | |
var s={l:l,r:r,t:o,b:b,x:l,y:o}; | |
return s; | |
} else { | |
var s= { | |
x: this.parseInt(n.style.borderLeftWidth), | |
y: this.parseInt(n.style.borderTopWidth), | |
r: this.parseInt(n.style.borderRightWidth), | |
b: this.parseInt(n.style.borderBottomWidth) | |
}; | |
s.l=s.x; | |
s.t=s.y; | |
return s; | |
} | |
} | |
}, | |
setSize : function(elmt,x,y,withMargin){ | |
if ($IE){ | |
if (withMargin){ | |
var m=this.getMargin(elmt); | |
x-=m.l+m.r; | |
y-=m.t+m.b; | |
} | |
elmt.style.width=x; | |
elmt.style.height=y; | |
} else { | |
var clientSize=this.getClientSize(elmt); | |
var dx=clientSize.l+clientSize.r; | |
var dy=clientSize.t+clientSize.b; | |
elmt.style.width=x-dx+"px"; | |
elmt.style.height=y-dy+"px"; | |
} | |
}, | |
setPosition : function (elmt,x,y,withMargin){ | |
if (withMargin){ | |
} | |
elmt.style.left=x+"px"; | |
elmt.style.top=y+"px"; | |
}, | |
setAlpha : function (n,a){ | |
return; | |
n.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+a*100+");"; | |
n.style.opacity = a; | |
n.style.MozOpacity = a; | |
} | |
} | |
var $motion={ | |
smooth : function (s, e, t){ | |
if (t>1) t=1; | |
return (e - s) * t + s; | |
} | |
} | |
function PopUp(id, config){ | |
this.id=id; | |
var c = this.config = config; | |
c.width = $gv(c.width,600); | |
c.height = $gv(c.height,300); | |
c.bottom = $gv(c.bottom,1); | |
c.right = $gv(c.right,1); | |
c.display = $gv(c.display,true); | |
c.contentUrl= $gv(c.contentUrl,"about:blank"); | |
c.motionFunc= $gv(c.motionFunc,$motion.smooth); | |
c.position = {x:0,y:0}; | |
var t=c.time; | |
t.slideIn = $gv(t.slideIn,1); | |
t.hold = $gv(t.hold,30); | |
t.slideOut = $gv(t.slideOut,1); | |
t.slideIn *= 1000; | |
t.hold *= 1000; | |
t.slideOut *= 1000; | |
this.container = document.body; | |
this.popup = null; | |
this.content = null; | |
this.switchButton = null; | |
this.moveTargetPosition = 0; | |
this.startMoveTime = null; | |
this.startPosition = null; | |
this.status = PopUp.STOP; | |
this.intervalHandle = null; | |
this.mm = "max"; | |
} | |
PopUp.STOP = 0; | |
PopUp.MOVE_DOWN = 1; | |
PopUp.MOVE_UP = 2; | |
PopUp.SWITCH_TO_MIN = PopUp.MOVE_DOWN | 4; | |
var __o={ | |
create : function (){ | |
var doc=document; | |
var c=this.config; | |
var p = this.popup = doc.createElement("div"); | |
this.container.appendChild(p); | |
p.id=this.id; | |
p.style.cssText="position:absolute;\ | |
z-index:9000;\ | |
overflow:hidden;\ | |
border:0px solid #f00;\ | |
"; | |
$dom.setSize(p, c.width, c.height); | |
var t = this.content = doc.createElement("div"); | |
p.appendChild(t); | |
t.id = this.id+"_content"; | |
t.style.cssText="position:absolute;\ | |
z-index:1;\ | |
overflow:hidden;"; | |
$dom.setSize(t, c.width, c.height); | |
$dom.setPosition(t,0,0); | |
c.position.y = c.height; | |
this.onresize(); | |
t.innerHTML = "<a id='closeButton' href='javascript:void(0)'></a>"+ | |
"<a id='switchButton' href='javascript:void(0)'></a>"+ | |
"<iframe id='"+this.id+"_content_iframe' src="+c.contentUrl+" frameborder=0 scrolling=no width='100%' height='100%'></iframe>"; | |
var sBtn = this.switchButton = $_t(t,'a',"switchButton"); | |
sBtn.style.cssText='position:absolute;\ | |
z-index:9992;\ | |
font-size:0px;\ | |
line-height:0px;\ | |
left:0px;\ | |
top:0px;\ | |
width:600px;\ | |
height:300px;\ | |
background-image:url("http://220.115.251.228/FeeFile/xfdzp.jpg");'; | |
$addEL(sBtn,"click",$dele(this,"hide"),true); | |
$addEL(sBtn,"click",$cancelEvent,true); | |
$addEL(sBtn,"click",$openUrlBtn,true); | |
var btn = $_t(t,'a',"closeButton"); | |
btn.style.cssText='position:absolute;\ | |
z-index:9993;\ | |
font-size:0px;\ | |
line-height:0px;\ | |
left:585px;\ | |
top:0px;\ | |
width:15px;\ | |
height:15px;\ | |
background-image:url("http://220.115.251.228/images/closeqq.gif");'; | |
$addEL(btn,"mouseover",function (e){ | |
$dom.setAlpha(this,0.4); | |
},true); | |
$addEL(btn,"mouseout",function (e){ | |
$dom.setAlpha(this,1); | |
},true); | |
$addEL(btn,"click",$dele(this,"hide"),true); | |
$addEL(btn,"click",$cancelEvent,true); | |
var container=$IE ? document.body : document.documentElement; | |
$addEL(document.body,"resize",$dele(this,"onresize"),true); | |
this.__hackTimer=window.setInterval("__popup.onresize()",50); | |
$addEL(container,"scroll",$dele(this,"onresize"),true); | |
this.onresize(); | |
}, | |
show : function (){ | |
if (!this.config.display) return; | |
this.moveTargetPosition = 0; | |
this.status = PopUp.MOVE_UP; | |
this.startMove(); | |
}, | |
hide : function (){ | |
this.moveTargetPosition = this.config.height; | |
this.status = PopUp.MOVE_DOWN; | |
this.startMove(); | |
}, | |
minimize : function (){ | |
this.mm = "min"; | |
this.moveTargetPosition = this.config.height - 20; | |
this.status = PopUp.SWITCH_TO_MIN; | |
this.startMove(); | |
var s = this.switchButton.style; | |
var bg = s.backgroundImage; | |
if (bg.indexOf(this.imgMin) > -1) { | |
bg = bg.replace(this.imgMin,this.imgMax); | |
s.backgroundImage = bg; | |
} | |
}, | |
delayHide : function (){ | |
window.setTimeout("__popup.hide()",this.config.time.hold); | |
}, | |
startMove : function (){ | |
this.stopMove(); | |
this.intervalHandle = window.setInterval("__popup.move()",100); | |
this.startMoveTime = new Date().getTime(); | |
this.startPosition = this.config.position.y; | |
}, | |
stopMove : function (){ | |
if (this.intervalHandle != null) window.clearInterval(this.intervalHandle); | |
this.intervalHandle = null; | |
}, | |
move : function (){ | |
var t = new Date().getTime(); | |
t = t - this.startMoveTime; | |
var total = this.status & PopUp.MOVE_UP ? | |
this.config.time.slideIn : | |
this.config.time.slideOut; | |
var y = this.config.motionFunc(this.startPosition, this.moveTargetPosition, t/total); | |
this.config.position.y = y; | |
this.onresize(); | |
if (t >= total){ | |
this.onFinishMove(); | |
} | |
}, | |
onFinishMove : function (){ | |
this.stopMove(); | |
if (this.status == PopUp.MOVE_UP && this.config.time.hold > 0 ){ | |
this.delayHide(); | |
} else { | |
if (this.__hackTimer!=null) window.clearInterval(this.__hackTimer); | |
} | |
this.status = PopUp.STOP; | |
}, | |
onresize : function (){ | |
var c=this.config; | |
var t=document.body; | |
var dx=t.clientWidth + t.scrollLeft; | |
var dy=t.clientHeight + t.scrollTop; | |
var x = dx - c.right - c.width ; | |
var y = dy - c.bottom - c.height + c.position.y; | |
$dom.setPosition(this.popup, x, y); | |
$dom.setSize(this.popup, c.width, c.height-c.position.y); | |
} | |
} | |
$cpAttr(PopUp.prototype,__o); | |
function job(){ | |
var cfg={ | |
width : 600, | |
height : 300, | |
bottom : 1, | |
right : 1, | |
display : true, | |
contentUrl : "about:blank", | |
time : { | |
slideIn : 1, | |
hold : 10, | |
slideOut : 1 | |
} | |
} | |
var displayTimeList = ["7+7"]; | |
var hours={}; | |
var delays=[]; | |
for (var i=0;i<displayTimeList.length;i++) { | |
var o = displayTimeList[i]; | |
var ar = o.split("+"); | |
var t = parseInt(ar[0]); | |
for (var m=0;m<ar.length-1;m++){ | |
ar[m]=ar[m+1]; | |
} | |
hours[t]=true; | |
for (var j=0;j<ar.length;j++){ | |
hours[t + parseInt(ar[j])]=true; | |
} | |
} | |
displayTimeList=[]; | |
for (var i in hours){ | |
var s = parseInt(i); | |
if (isNaN(s)) continue; | |
displayTimeList[displayTimeList.length]=s; | |
} | |
displayTimeList = displayTimeList.sort(); | |
var pp = new PopUp("xp", cfg); | |
window.__popup=pp; | |
pp.create(); | |
pp.show(); | |
} | |
function doit(){ | |
if (document.body == null) { | |
window.setTimeout(doit,500); | |
return; | |
} | |
job(); | |
} | |
doit(); | |
--> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment