var jst_music_album_all=new String('\
 <table class="g_t_left" cellpadding="0" cellspacing="0" border="0">\
 {var i = 0}\
 {for item in itemList}\
  {var i = i+1}\
  {if item_index%3==0}<tr>{/if}\
  <td><div class="itm g_htc_hvr">\
   <div class="left"><div class="p_ p2 g_c_hand" onclick="${objName}.showMusicAlbum(\'${item.id}\')"><img src="${item.coverPhSmallUrl|default:""|to_img:"http&#58//b.bst.126.net/style/common/musicbox/musicAlbum75.gif"}" title="${item.name|default:""|escape}" /></div><div class="nav c05 g_t_12">{if !isPrev}<span class="g_c_hand" onclick="${objName}.showMusicAlbum(\'${item.id}\')">管理歌曲</span>{if item.id != 0}<span class="bd1c"> | </span><span class="g_c_hand" onclick="${objName}.deleteMusicAlbum(\'${item.id}\')">删除</span>{/if}{/if}</div></div>\
   <div class="right"><div class="desc"><div id="$$_album_name_${item.id}" class="c07 g_t_14 g_t_bold g_t_hide i tile" style="line-height:120%; width:100%">${item.name|default:""|escape}</div>{if isPublishedAlbum(item)}<a class="rec g_c_hand" href="http://mp3.163.com/iting/album/?fromBlog&tab=48hour" target="_blank">&nbsp;</a>{/if}\
   <div class="c08 g_t_12">${item.musicCount|default:0}首歌曲{if item.id !=0} ${NetEase.DateTime.formatDate(item.createTime,"yyyy-MM-dd")}{/if}</div>\
     {if item.id !=0}<div id="r_album${item.id}">${showMusicRank(objName,item.id,\'r_album\',item.rank,item.voteRank,item.voteUserCount,isPrev)}</div>\
     <div class="c07 g_t_12 g_t_hide com"><span onclick="${objName}.showMusicAlbum(\'${item.id}\')">评论:${item.commentCount|default:0}</span><span class="sep bd1c">|</span>\
     <span onclick="${objName}.showMusicAlbum(\'${item.id}\')">人气:${item.popularity|default:0}</span></div>{/if}\
     <div class="c05 g_t_12 g_t_hide com"><span class="n_ k0_1 g_c_hand" onclick="${objName}.openMusicBox(\'${item.id}\')">&nbsp;</span><span class="g_c_hand udl" onclick="${objName}.openMusicBox(\'${item.id}\')">播放</span>{if isPrev && item.id !=0}<span class="sep bd1c">|</span><span class="g_c_hand udl" onclick="${objName}.collectMusicAlbum(\'${item.id}\',${item.userId})">收藏</span>{/if}</div>\
  <br class="g_p_clear" /></div></td>\
  {if item_index%3==2}</tr>{/if}\
 {forelse}\
  <tr><td><div class="c07 g_t_14 g_c_vmgin">暂无音乐专辑</div></td></tr>\
 {/for}\
 {if i > 0 && i%3 != 0}\
  <td colspan="${3-i%3}">&nbsp;</td></tr>\
 {/if}\
 </table>\
');
var jst_music_album_sort=new String('\
 {for item in itemList}\
  {if item.id !=0}\
  <div id="$$_album_${item.id}" class="item g_htc_selitm setDragOnlyClass"><div class="p_ p2"><img title="${item.name|default:""|escape}" src="${item.coverPhSmallUrl|default:""|to_img:"http&#58//b.bst.126.net/style/common/musicbox/musicAlbum75.gif"}" /></div>\
  <div class="i g_t_hide g_t_center">${item.name|default:""|escape}</div></div>\
  {/if}\
 {/for}\
 <br class="g_p_clear" />\
');
var jst_music_album_add=new String('\
    <form target="$$_musicPhotoUploadFrame" id="albumAddForm" method="post" action="${action}" enctype="multipart/form-data">\
    <div class="left" style="margin-top:15px;">\
      <div class="p_ p2 g_p_center"><img id="albumPhoto" title="专辑封面" src="http://b.bst.126.net/style/common/musicbox/musicAlbum75.gif"/></div>\
 </div>\
 <div class="right">\
  <div><label>名称:&nbsp;</label><input type="text" class="g_w_50 g_c_input g_h_ipt g_htc_focus" maxlength="50" name="Name"/><label>&nbsp;(必填)</label><input name="albumId" type="hidden" /></div>\
  <div><label>封面:&nbsp;</label><input type="file" class="g_w_80 g_h_ipt g_htc_focus" size="23" name="imageUrl" onchange="g_previewImg(this,\'albumPhoto\');"/></div>\
  <div><label>分类:&nbsp;</label><input type="hidden" id="album_add_tag" name="Tag" value=""/><span id="album_add_tag_show" class="g_t_12"></span>&nbsp;&nbsp;<a href="#" onclick="${objName}.editMusicAlbumTag();return false;">设置分类</a></div>\
  <div><label class="g_t_top">描述:&nbsp;</label><textarea class="g_w_80 g_h_85 g_htc_focus" rows="5" cols="30" name="Description"></textarea></div>\
  <div class="g_t_center g_c_mvdn" id="album_add_zone">\
   <input type="button" class="btncm btnok" value="确　定" onclick="${objName}.submitAddAlbum();" />\
   <span>&nbsp;&nbsp;&nbsp;&nbsp;</span>\
   <input type="button" class="btncm btncc" value="取　消" onclick="${objName}.cancelAddAlbum();" />\
  </div>\
 </div>\
 </form>\
');
var jst_musicalbum_tag_select=new String('\
 <div class="t">请为您的专辑选择分类，最多可选择3个。</div>\
 <div class="m" id="$$_album_tag_select_zone">\
  <div class="items">\
   {for key in keys}\
    {if parseInt(key) < 100}\
     <div class="item"><input type="checkbox" id="tag_${key}"/><label for="tag_${key}">${values[key_index]}</label></div>\
    {/if}\
   {/for}\
  </div>\
  <div class="items">\
   {for key in keys}\
    {if parseInt(key) >= 100}\
     <div class="item"><input type="checkbox" id="tag_${key}"/><label for="tag_${key}">${values[key_index]}</label></div>\
    {/if}\
   {/for}\
  </div>\
  <br class="g_p_clear"/>\
 </div>\
 <div class="btns">\
  <input class="ok" type="button" value="确  定" onclick="${objName}.addMusicAlbumTag()"/>\
 </div>\
');
var MusicConst={
DEFAULT_ALBUM:0
}
if(NetEase==undefined){
var NetEase={};
}
NetEase.MusicAlbumAbstract=Class.create();
NetEase.MusicAlbumAbstract.prototype={
initialize:function(objName,albumList){
this.objName=objName;
this.albumList=albumList||[];
this.switchTab(0);
},
switchTab:function(i){
this.selectedTab=i;
switch(i){
case 0:
$('$$_music_album_zone').className='g_mus_m_m';
if(!this._allZoneInited){
this._initMusicAlbumAll();
}
break;
case 1:
$('$$_music_album_zone').className='g_mus_m_s';
if(!this._isPrev()&&!this._sortZoneInited){
this._initSortZone();
}
break;
}
},
showMusicAlbum:function(id){
if(!this._isPrev())
window.location=UD.hostPath+'/music/entry/edit/'+id+'/';
else
window.location=UD.hostPath+'/music/entry/'+id+'/';
},
openMusicBox:function(aId){
window.open(UD.hostPath+"/m/?t=0&aid="+encodeURIComponent(aId),"_blank","resizable=no,scrollbars=no,status=yes,width=772px,height=595px");
},
collectMusicAlbum:function(aId,albumUserId){
if(UD.visitorId<=0){
showLoginDlg('blog.163.com');
return;
}
MusicBean.collectMusicAlbum(aId,albumUserId,function(s){
if(s==1){
dwrlog("收藏专辑成功!","ok");
}else if(s==-1){
dwrlog("收藏专辑个数超过最大限制!","info");
}else if(s==-2){
dwrlog("你已经收藏过该专辑!","info");
}else{
dwrlog("收藏专辑失败!","error");
}
}.bind(this));
},
voteMusicRank:function(id,type,rank){
if(UD.visitorRank<0){
showLoginDlg(UD.serverName);
return;
}
var album=this.albumList.detect(
function(e){
if(e.id==id)
return true;
return false;
});
if(!album)return;
if(type=='r_album'){
MusicBean.voteMusicAlbumRank(id,album.userId,rank,function(s){
if(s){
dwrlog('投票成功!','ok');
album.voteUserCount++;
album.voteRank+=rank;
$(type+id).innerHTML=showMusicRank(this.objName,id,type,rank,album.voteRank,album.voteUserCount,false);
}else{
dwrlog('投票失败!','error');
}
}.bind(this));
}
},
_initMusicAlbumAll:function(){
$('$$_music_album_all').innerHTML=this._renderTemplate(jst_music_album_all,{itemList:this.albumList});
if(!this._isPrev()){
this._initMusicAlbumEditAll();
}
},
_initMusicAlbumEditAll:Prototype.emptyFunction(),
_resetMusicAlbumAll:function(){
this._allZoneInited=false;
},
_resetSortZone:function(){
this._sortZoneInited=false;
},
_isPrev:function(){return true;},
_initSortZone:Prototype.emptyFunction(),
_renderTemplate:function(template,data){
if(template==null)return'';
data=data||{};
data.objName=this.objName;
data.isPrev=this._isPrev();
return template.processUseCache(data);
}
}
function showMusicRank(objName,id,type,rank,voteRank,voteUserCount,isPrev){
rank=(rank==null)?3:rank;
if(rank>5)rank=5;
voteRank=(voteRank==null)?0:voteRank;
voteUserCount=(voteUserCount==null)?0:voteUserCount;
var ss;
if(isPrev){
ss=['<div class="vote_star star_d'+rank+'" title="总计 '+voteUserCount+' 人投票，共 '+voteRank+' 分"><div class="default">&nbsp;</div>']
}else{
ss=['<div class="vote_star vote_star_d star_d'+rank+'" title="总计 '+voteUserCount+' 人投票，共 '+voteRank+' 分"><div class="default">&nbsp;</div>']
}
if(isPrev){
for(var i=1;i<=5;i++){
ss.push('<a class="star_'+i+'" href="#" onclick="'+objName+'.voteMusicRank(\''+id+'\',\''+type+'\','+i+');return false;">&nbsp;</a>');
}
}else{
for(var i=1;i<=5;i++){
ss.push('<a class="star_'+i+'" href="#">&nbsp;</a>');
}
}
ss.push('</div>');
return ss.join('');
}
var musicComment;
var musicCommentType;
var MusicCommentBean;
var musicCommentCallBack;
function loadComment(musicId,type,commentCount,mainCommentCount,commentList,commentRank,bean,callBack){
commentList=commentList||[];
for(var i=0;i<commentList.length;i++){
convertComment(commentList[i]);
}
musicCommentType=type;
Element.show('_$_comment_div');
$('$$_comment_count').innerHTML=commentCount+'';
var option={
bCanClose:true,bHasCancelBtn:true,bSupportDeleteComment:true,
bNeedCheckLogin:false,bNeedCheckRight:true,iAllowComment:commentRank,iPageSize:10,
iHostId:UD.hostId,sHostName:UD.hostName,iVisitorId:UD.visitorId,sVisitorName:UD.visitorName,
sVisitorNickname:UD.visitorNickname,sVisitorAvatar:UD.visitorAvatar,iVisitorRank:UD.visitorRank,sVisitorIP:UD.visitorIP,bShowSpaceUrl:true,
iInputWidth:460,iEditorHeight:90,fnOpenCommentEffect:null,iMainCommentCount:mainCommentCount,
fnAddComment:addNewComment,oAddCommentParams:{parentId:musicId,type:type},
fnDelComment:delComment,oDelCommentParams:{parentId:musicId,type:type},
fnMoreData:getCommentsByPage,
fnAfterAddComment:afterAddComment,oAfterAddCommentParams:{parentId:musicId,type:type},
fnAfterDelComment:afterDelComment,oAfterDelCommentParams:{parentId:musicId,type:type},fnReportBad:reportBad,
fnCloseComments:closeComments,sObjName:'musicComment',bDefaultPubClose:false,iEditorMaxLen:1000
};
musicComment=new NetEase.CommentPublish(commentList,musicId,mainCommentCount,'_$_comments','_$_comment_editor',option);
MusicCommentBean=bean;
musicCommentCallBack=callBack||Prototype.emptyFunction();
}
function convertComment(com){
com.publisherId=com.publishUserId;
com.publisherName=com.publishName;
com.publisherNickname=com.publishNickName;
com.publisherAvatar=com.publishAvatar;
com.publisherAvatarUrl=com.publishAvatar;
if(com.subComments!=null&&com.subComments.length>0){
for(var i=0;i<com.subComments.length;i++){
var scom=com.subComments[i];
scom.publisherId=scom.publishUserId;
scom.publisherName=scom.publishName;
scom.publisherNickname=scom.publishNickName;
scom.publisherAvatar=scom.publishAvatar;
scom.publisherAvatarUrl=scom.publishAvatar;
}
}
}
function addNewComment(newComment,params,postAddCommentFunc){
var com={};
com.musicId=params.parentId;
com.type=params.type
com.content=newComment.content;
com.publishUserId=newComment.publisherId;
com.publishName=newComment.publisherName;
com.publishNickName=newComment.publisherNickname;
com.publishAvatar=newComment.publisherAvatarUrl;
com.ip=newComment.ip;
com.replyToUserId=newComment.replyToUserId;
com.mainComId=newComment.mainComId;
com.replyComId=newComment.replyComId;
com.replyToUserName=newComment.replyToUserName;
com.replyToUserNick=newComment.replyToUserNick;
var filterType=0;
var valcodeelem=$("valcode"+params.valcodeid);
var valcode;
if(valcodeelem!=null)
valcode=valcodeelem.value;
else
valcode=-1;
if(UD.visitorRank<Const.Rank.Friend){
var match=checkOtherSiteUrl(newComment.content);
if(match){
alert(Local.Message.Blog[0]);
postAddCommentFunc(null);
return false;
}
}
MusicCommentBean.addMusicComment(com,com.type,params.valcodeid,valcode,{
callback:function(dataFromServer){
if(dataFromServer!=null)convertComment(dataFromServer);
postAddCommentFunc(dataFromServer);
},
errorHandler:function(errorString,ex){
if(captchaWarning(ex,"$$_comsubmithint"+params.valcodeid)){
postAddCommentFunc(null);
return false;
}
var filterType=filterWarning(ex);
if(filterType==-1){
postAddCommentFunc(null);
return false;
}
postAddCommentFunc(null);
}
});
}
function delComment(commentId,params,isMainComment,postDelCommentFunc){
MusicCommentBean.deleteComment(commentId,params.parentId,params.type,isMainComment,{
callback:function(dataFromServer){
postDelCommentFunc(dataFromServer,commentId,isMainComment);
}
});
}
function getCommentsByPage(musicId,limit,offset,postPageCommentFunc){
MusicCommentBean.getMusicCommentList(musicId,musicCommentType,offset,limit,{
callback:function(dataFromServer){
if(dataFromServer!=null){
for(var i=0;i<dataFromServer.length;i++){
convertComment(dataFromServer[i]);
}
}
postPageCommentFunc(dataFromServer);
}
});
}
function afterAddComment(){
updateTargetCount('$$_comment_count',1);
updateTargetCount('$$_comment_count_0',1);
musicCommentCallBack(1);
}
function afterDelComment(oParams){
var _count=0-oParams.iSuccCount;
updateTargetCount('$$_comment_count',_count);
updateTargetCount('$$_comment_count_0',_count);
musicCommentCallBack(_count);
}
function updateTargetCount(target,diff){
if($(target)){
$(target).innerHTML=parseInt($(target).innerHTML)+(diff)+'';
}
}
function reportBad(report,postReportFunc){
PreUserReportBean.addUserReport(report,postReportFunc);
}
function closeComments(){
$('_$_comments_zone').style.display=($('_$_comments_zone').style.display=='none')?'':'none';
}
function fillConstellation(target,value){
$(target).innerHTML=value>0?constellationArray[value][1]:'';
}
function fillfavoriteMusic(target,value,notBr){
var html=''
if(value!=null){
var ts=value.split('|')[0].split(',');
for(var i=0;i<ts.length;i++){
if(!musicArray[ts[i]])continue;
html+=musicArray[ts[i]][1]
if(i%2==0){
html+='&nbsp;&nbsp;';
}else{
html+=notBr?'&nbsp;&nbsp;':'<br/>';
}
}
html=html.replace(/,$/,"");
}
$(target).innerHTML=html;
}
function isPublishedAlbum(album){
return album!=null&&album.coverPhSmallId>0&&!isStrBlank(album.description)&&!isStrBlank(album.tagIds);
}
function isStrBlank(str){
return str==null||str.trim()=='';
}
var constellationArray=[
["0","星座"],
["1","水瓶座"],
["2","双鱼座"],
["3","白羊座"],
["4","金牛座"],
["5","双子座"],
["6","巨蟹座"],
["7","狮子座"],
["8","处女座"],
["9","天秤座"],
["10","天蝎座"],
["11","射手座"],
["12","摩羯座"]
];
var musicArray=[
["0","流行音乐"],
["1","摇滚/重金属"],
["2","爵士/蓝调"],
["3","Hip Hop"],
["4","古典音乐"],
["5","乡村/民谣"],
["6","民族音乐"],
["7","交响乐"],
["8","其他"]
];
var musicAlbumTagMap={
'0':'流行金曲',
'1':'经典怀旧',
'2':'动漫游戏',
'3':'影视音乐',
'4':'校园民谣',
'5':'戏剧类',
'6':'纯音乐',
'7':'原创作品',
'100':'伤感',
'101':'安静',
'102':'寂寞',
'103':'浪漫',
'104':'幸福',
'105':'失恋',
'106':'思念',
'107':'励志',
'108':'甜蜜',
'109':'深情',
'110':'激情',
'111':'其它'
}
