日期:2014-05-16 浏览次数:20448 次
<javascript>
$(function()){
function hello(){
alert('123');
}
……省略好多function……
</javascript>
parent.window.hello();
var MusicBox=function(){
this.prevCache=-1;
this.index=0;
this.currentIndex=this.index;
this.data;//在init中初始化时赋值
this.len=0;//在init中初始化时赋值
this.show=function(cIndex,pIndex){
$("#player").attr("src","player.php?u="+this.data.eq(cIndex).attr("title")+'&ms='+this.data.eq(cIndex).attr("target"));
$("#now_playing").html(this.data.eq(cIndex).attr("target"));
$(document).attr("title", this.data.eq(cIndex).attr("target"));
this.currentIndex=cIndex;
if(pIndex!==undefined){
$(".playerpanel-prev-song-video img").attr("src",this.data.eq(pIndex).attr("href"));
$(".tooltip a").html(" "+this.data.eq(pIndex).attr("target")+" ");
$("#playerpanel-prev-song").fadeIn(200).animate({left:"0"},2000);
}else{
$("#playerpanel-prev-song").animate({left:"153px"},2000).fadeOut(200);
}
};
this.prevsong=function(){
if(this.prevCache==-1){return}
this.show(this.prevCache);
this.prevCache=-1;
};
this.nextsong=function(){
this.prevCache=this.currentIndex;
this.index++;
this.index%=this.len;
this.show(this.index,this.prevCache);
};
this.init=function(){
this.data=$("#playlist a");
this.len=this.data.size();
$("#playerpanel-prev-song").hover(
function (){
$(".playerpanel-prev-song-overlay").fadeIn(300);
$(".tooltip").css("display","block");
},
function (){
$(".playerpanel-prev-song-overlay").fadeOut(300);
$(".tooltip").css("display","none");
}
);
this.show(this.index);
var _that=this;
$("#prevsong").click(function(){_that.prevsong()});
$("#nextsong").click(function(){_that.nextsong()});
$("#playerpanel-prev-song").click(function(){_that.prevsong()});
}
}
var myBox=new MusicBox();//顺序不能乱,这个必须在匿名函数的外部
$(function(){
myBox.init();//初始化时必须在匿名函数的内容部
})