$(document).ready(function(){
if ($("#qiuputable").length>0) {
$(".tag_selbtns li").click(function(){
$(this).addClass('tag_on').siblings().removeClass('tag_on');
$(this).parents('td').find("span").removeClass().addClass('ok_txt').html(" ");
$(this).parents('.qiutab-input-box').find("input").val($(this).attr('tag'));
});
$("#qiuway_selbtns li").click(function(){
var qiuway=$(this).attr('tag');
var qiutype=$('#type_txt').val();
if (qiuway==1) {
$('.price-input-group').show();
$('.maker-input-group').show();
$('.payway-input-group').show();
$('.price_selbtns li').hide();
$('.price_selbtns').find('.tagfor_'+qiutype).show();
$('.price_selbtns').find('.tagfor_'+qiutype).eq(0).click();
$('#ordsong_btn').html('提交付费求谱并去支付');
} else {
$('.price-input-group').hide();
$('.maker-input-group').hide();
$('.payway-input-group').hide();
$('#ordsong_btn').html('提交登记求谱');
}
});
$("#qiutype_selbtns li").click(function(){
var qiuway=$('#way_txt').val();
var qiutype=$(this).attr('tag');
if (qiuway==1) {
$('.price_selbtns li').hide();
$('.price_selbtns').find('.tagfor_'+qiutype).show();
$('.price_selbtns').find('.tagfor_'+qiutype).eq(0).click();
}
});
}
//谱列表hover事件
$('.tablist tr').hover(function(){
$(this).addClass('tablist_on');
$(this).find('.coltab').show();
}, function(){
$(this).removeClass('tablist_on');
$(this).find('.coltab').hide();
});
$('.saveasmytab,.colletalbum').hover(function(){
$(this).addClass('likeopt_on');
}, function(){
if (!$(this).hasClass('likeon')) {
$(this).removeClass('likeopt_on');
};
});
if ($('.muse-copyright-line').length>0) {
$('.muse-copyright-line').eq(0).siblings().hide();
};
$('#downmusetrans-img-close-btn').click(function(){
$('#down_pop').find('.close').click();
});
$('.lookmoresametab-btn').click(function(){
var act =$(this).attr('act');
if (act=='show') {
$(this).attr('act','hide');
$(this).parent().find('.tab_line_more').show();
$(this).find('span').html('︿');
} else {
$(this).attr('act','show');
$(this).parent().find('.tab_line_more').hide();
$(this).find('span').html('﹀');
};
});
$('#downmusetrans-img-btn').click(function(){
$('#down_pop').find('.close').click();
var that =this;
$(that).attr('disabled',true);
$.Pro('转图导出中
(长谱会耗时较长,请耐心等待)',{'Loading':true,'Showing':true,'Class':'muse-pro-prossing'});
$('').html('.muse-jitapuline .string-slash-up b::before {right: -7px; writing-mode: unset ; -webkit-writing-mode: unset; -ms-writing-mode: unset;} .muse-jitapuline .string-slash-down b::before { bottom: 1px; right: -7px; writing-mode: unset ; -webkit-writing-mode: unset; -ms-writing-mode: unset;}').appendTo($('head'));
var isWindows = function() {
return /windows|win32/i.test(navigator.userAgent);
};
if (isWindows) {
$('#tabbox3').addClass('musebox-window-preview-print');
} else {
$('#tabbox3').addClass('musebox-out-preview-print');
};
//$('#tabbox3').addClass('musebox-out-preview-print');
setTimeout(function() {
var musecannvastoimg = function(type,div,page){
html2canvas(div[0], {'scale':scale}).then(function (canvas) {
if (type==1) {
$('.muse-pro-prossing').find('p').text('导出成功');
$('#tabbox3 .muse-maker-info').hide();
} else {
$('.muse-pro-prossing').find('p').text('第'+page+'页导出成功');
isdone++;
if (isdone==$('.muse-printpage').length) {
$('.muse-printpage').remove();
$('#tabbox3').show();
};
}
if (isWindows) {
$('#tabbox3').removeClass('musebox-window-preview-print');
} else {
$('#tabbox3').removeClass('musebox-out-preview-print');
};
$('#imprtimgstype').remove();
if ($('.mpdownload-ikaopu-btn1').length>0) {
var image = canvas.toDataURL("image/png");
var pHtml = "";
$('#musebox').attr('hasexport','ok');
$('#musebox').html(pHtml);
$.Pro('转图完毕,长按谱子图片保存到手机',{Time:4});
//document.body.appendChild(canvas);
} else {
var file = dataURLtoBlob(canvas.toDataURL());
if('msSaveOrOpenBlob' in navigator){
// Microsoft Edge and Microsoft Internet Explorer 10-11
window.navigator.msSaveOrOpenBlob(file, savename);
}else{
$('#muse-img-download').attr("href", window.URL.createObjectURL(file)).attr("download", savename);
$('#muse-img-download')[0].click();
}
};
$('.muse-pro-prossing').fadeOut(1000,function(){
$('.muse-pro-prossing').remove();
$(that).attr('disabled',false);
});
});
}
var dataURLtoBlob = function (dataurl) {
var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
while(n--){
u8arr[n] = bstr.charCodeAt(n);
}
return new Blob([u8arr], {type:mime});
}
var savename ='music.52jianpu.com/guitar-'+$('#muse-topbar-fileinfo').find('h1').text()+'.png';
var scale = parseInt($('input:radio[name=muse-export-scale]:checked').val());
scale=scale<1?1:scale;
scale=scale>4?4:scale;
$('#tabbox3').addClass('muse-waterprint');
var printway=$("input:radio[name=muse-img-printway]:checked").val();
if (printway=='1') {
$('#tabbox3 .muse-maker-info').hide();
musecannvastoimg(1,$('#tabbox3'),1);
} else if (printway=='2') {
var musepage_makeinfo =$('#tabbox3 .muse-maker-info').clone();
var musepage_info =$('#tabbox3 .muse-info').clone();
var musepage_note =$('#tabbox3 .muse-notes').clone();
var musepage_line =$('#tabbox3 .muse-line').clone();
var musepage_lines=[];
for (var i = 0; i < musepage_line.length; i++) {
var linearry=[];
linearry['dom']=musepage_line.eq(i);
linearry['type']='line';
linearry['height']=$('#tabbox3').find('.muse-line').eq(i).outerHeight(true);
musepage_lines.push(linearry);
}
var notedata= [];
notedata['dom']=musepage_note;
notedata['type']='note';
notedata['height']=$('#tabbox3').find('.muse-notes').eq(0).outerHeight(true);
musepage_lines.push(notedata);
var musepage_width=$('#tabbox3').innerWidth();
var musepage_height=parseInt(musepage_width*1.449);
var musepage_h =$('#tabbox3').height();
var musepage_top_h=$('#tabbox3').find('.muse-info').outerHeight();
//var musepage_top_h=$('#tabbox3').find('.muse-maker-info').outerHeight(true)+$('#tabbox3').find('.muse-info').outerHeight();
var musepage_num =1;
var musepage_more=true;
$('#tabbox3').hide();
while (musepage_more){
$('#tabbox3').before('
'+string['finger']+'';
} else {
chordfinger ='';
}
chorddata['finger'][i]={'fred':string['fred'],'action':chordfinger};
//计算大横按
if (parseInt(string['fred'])>0 && parseInt(string['fred'])<2) {
newfred[i]=string;
}
}
maxfret=parseInt(maxfret)+1;
if(maxfret<4){maxfret=4;}
chorddata['maxfret']=maxfret;
newfred=$.grep(newfred,function(n,i){
return n;
},false);
if (hasx==false && newfred.length>1 && chorddata['fred']>0) {
if(!newfred[0]['finger']){newfred[0]['finger']='';}
chorddata['barre']=newfred[0]['finger'];
}
//console.log(chorddata);
//var chordhtml = template('muse-chord-box', {'chord':chorddata});
var chordhtml = window.BGMUSEJS.Localcode.getHtml('muse-chord-box', {'chord':chorddata});
//localStorage.setItem('chord-'+chordname, chordhtml);
chordbox.html(chordhtml);
//return chordbox;
};
BGMUSEJS.write.reprintTies = function() {
//重新排版,按行一行一行组装
var muselines =$('#muse-canvas').find('.muse-line');
if (muselines.length>0) {
$('.bar-repeat-atfirst').remove();
$('.bar-repeat-atlast').addClass('bar-repeat').removeClass('bar-repeat-atlast').find('span').show();
$('#muse-canvas').find('.muse-chord').removeClass('muse-empty-chordline');
$('#muse-canvas').find('.muse-line').removeClass('muse-empty-jianpuline');
$('#muse-canvas').find('.muse-lines').removeClass('hasfingerway');
$('#muse-canvas').find('.muse-print-margin').remove();
for (var i = 0; i < muselines.length; i++) {
$('#muse-canvas').append(muselines.eq(i).html());
muselines.eq(i).remove();
}
}
var newline=[];
var line=0;
newline[0]=[];
//var muselineoffset = $('.muse-bars:first').parent().offset().left;
var muselineoffset = $('#muse-canvas').offset().left;
var allbars =$('#muse-canvas').find('.muse-bars');
allbars.each(function(i){
//if (i!=0 && $(this).offset().left==parseInt($('#musebox-out').css('padding-left'))+$('.muse-sidebar').eq(0).width()) {
//if (i!=0 && $(this).offset().left==$(this).parent().offset().left) {
if (i!=0 && $(this).offset().left==muselineoffset) {
line++;
newline[line]=[];
}
newline[line].push($(this));
//console.log($(this).offset().left);
});
//$('#muse-canvas').html('');
for (var i = 0; i < newline.length; i++) {
//var nowline=$('#muse-canvas').find('.muse-line').eq(i);
$('#muse-canvas').append('');
//console.log($('#muse-canvas').find('.muse-line').eq(i));
//$('#muse-canvas').find('.muse-line').eq(i).append(newline[i]);
for (var j = 0; j < newline[i].length; j++) {
$('#muse-canvas').find('.muse-line').eq(i).append(newline[i][j]);
}
var ispreviewing =$('#muse-preview-inbox').find('.muse-line').length;
if (ispreviewing>0) {
var nowline =$('#muse-preview-inbox').find('.muse-line').eq(i);
var lineoflines =nowline.find('.muse-bars').eq(0).find('.muse-lines');
var lineofbars =nowline.find('.muse-bars').length;
for (var ii = 0; ii < lineoflines.length; ii++) {
if (lineofbars==nowline.find('.muse-lines-'+ii).find('.bar-placehoder').length || lineofbars==nowline.find('.muse-lines-'+ii).find('.muse-jianpuemptyline').length) {
//console.log('emptyline');
nowline.find('.muse-lines-'+ii).hide();
//还要把上面对应的和弦层也隐藏掉,如果有的话!muse-chord
} else {
nowline.find('.muse-lines-'+ii).show();
}
}
}
var nowline =$('#muse-canvas').find('.muse-line').eq(i);
var nowlinebar=nowline.find('.muse-bars').eq(0);
nowlinebar.find('.muse-chord').each(function(x){
//console.log(x);
if (nowline.find('.muse-chord-'+x).find('.chord').length==0) {
//$('#muse-canvas').find('.muse-line').eq(i).find('.muse-chord-'+x).css({'height':'30px'});
nowline.find('.muse-chord-'+x).addClass('muse-empty-chordline');
}
});
nowlinebar.find('.muse-lines').each(function(x){
var muse_lines_heiht_max=0;
var current_line=nowline.find('.muse-lines-'+x);
if (current_line.find('.chrod-subway').length>0) {
current_line.addClass('hasfingerway');
}
if (current_line.find('.muse-jpnote').length==0 && current_line.hasClass('muse-jianpu')) {
//$('#muse-canvas').find('.muse-line').eq(i).find('.muse-lines-'+x).css({'height':'10px'});
current_line.addClass('muse-empty-jianpuline');
}
if ((current_line.find('.muse-jitapuline').length==0) && current_line.hasClass('muse-jitapu')) {
//$('#muse-canvas').find('.muse-line').eq(i).find('.muse-lines-'+x).css({'height':'10px'});
current_line.addClass('muse-empty-jitapuline');
}
if (current_line.length>0 && current_line.hasClass('muse-jianpu')) {
current_line.each(function(){
if ($(this).height()>muse_lines_heiht_max) {
muse_lines_heiht_max =$(this).height();
}
});
current_line.height(muse_lines_heiht_max);
//$('#muse-canvas').find('.muse-line').eq(i).find('.muse-lines-'+x).height($('#muse-canvas').find('.muse-line').eq(i).find('.muse-lines-'+x).height());
}
});
var linelastbar=nowline.find('.muse-bars:last');
var repeatbars=linelastbar.find('.bar-repeat');
if (repeatbars.length>0) {
var linelastlines=linelastbar.find('.muse-lines');
var nextlinefirstbar =$('#muse-bars-'+(parseInt(linelastbar.attr('id').replace('muse-bars-',''))+1));
for (var m = 0; m < linelastlines.length; m++) {
var repeatbar =linelastlines.eq(m).find('.bar-repeat');
if (repeatbar.length>0) {
var newrepeatbar=repeatbar.clone();
newrepeatbar.addClass('bar-repeat-atfirst').removeAttr('mcode isbeat');
nextlinefirstbar.find('.muse-lines').eq(m).prepend(newrepeatbar);
repeatbar.addClass('bar-repeat-atlast').removeClass('bar-repeat').find('span').hide();
}
};
}
}
//console.log(newline);
var scale=$('#muse-topbar-icon-unzoom').attr('scale')?parseFloat($('#muse-topbar-icon-unzoom').attr('scale')).toFixed(1):1;
var scaleed = (1/scale).toFixed(2);
var boxright=parseInt(($('#muse-canvas').width()*scale)+$('#muse-canvas').offset().left);
var boxleft=$('#muse-canvas').offset().left;
allbars.find('.tritonetie').each(function(){
//console.log($(this).attr('pos'));
var tieboxW=parseInt($(this).width());
var tieleft=parseInt($(this).offset().left);
//var tieright=parseInt($('.tritonetie-end[pos="'+$(this).attr('pos')+'"]').offset().left);
var tritonetieend =$('#tritonetie-end'+$(this).attr('pos'));
//如果找不到闭合,则在自身后面30px后闭合
if (tritonetieend.html()!==null) {
var tieright=parseInt(tritonetieend.offset().left);
} else {
var tieright=tieboxW*parseInt($(this).attr('triplet'));
}
var tiewidth =tieright-tieleft;
tiewidth=tiewidth<=0?30:tiewidth;
var bili =tiewidth/tieboxW;
$(this).find('.jpnote-tritone-nums').width(tiewidth*scaleed);
var thistieline =$(this).find('.jpnote-tieline').eq(0);
var isgttieline =thistieline.hasClass('jtnote-tieline');
thistieline.css({"transform": "translateZ(0) "+((bili*scaleed)>1.5?" ":(isgttieline?" ":" translateY(4px) "))+" scale("+(bili*scaleed)+","+((bili*scaleed)>1.5?1:0.6)+")"});
});
allbars.find('.suffixtie').each(function(){
//console.log($(this).attr('pos'));
var iscross = $(this).attr('cross');
var tieboxW=parseInt($(this).width());
var tieleft=parseInt($(this).offset().left);
if (iscross=="cross") {
//var suffixtieend=$('.suffixtie-end[pos="'+$(this).attr('pos')+'"][cross="cross"]');
var suffixtieend=$('#suffixtie-end'+$(this).attr('pos')+'-cross');
} else {
//var suffixtieend=$('.suffixtie-end[pos="'+$(this).attr('pos')+'"][cross!="cross"]');
var suffixtieend=$('#suffixtie-end'+$(this).attr('pos'));
}
//如果找不到闭合,则在自身后面30px后闭合
if (suffixtieend.html()!==null) {
var tieright=parseInt(suffixtieend.offset().left);
} else {
var tieright=parseInt($(this).offset().left)+30;
}
var tiewidth =tieright-tieleft;
//tiewidth=tiewidth<=0?30:tiewidth;
if (tiewidth>0) {
var bili =tiewidth/tieboxW;
} else {
//var boxright=parseInt(($('#muse-canvas').width()*scale)+$('#muse-canvas').offset().left);
// if ($(this).hasClass('jtnote-tiebox')) {
// var boxright=parseInt($(this).parents('.muse-jitapu').find('.muse-bar').last().offset().right);
// } else {
// var boxright=parseInt($(this).parents('.muse-jianpu').find('.muse-bar').offset().left);
// };
var bili =(boxright-tieleft)/tieboxW;
}
if ($(this).find('.jtnote-skills').length>0) {
$(this).find('.jtnote-skills').eq(0).width(tiewidth>0?(tiewidth*scaleed):(boxright-tieleft)*scaleed);
}
suffixtieend.find('.jpnote-tieline').hide();
var thistieline =$(this).find('.jpnote-tieline').eq(0);
var isgttieline =thistieline.hasClass('jtnote-tieline');
thistieline.css({"transform": "translateZ(0) "+((bili*scaleed)>1.5?" ":(isgttieline?" ":" translateY(4px) "))+" scale("+(bili*scaleed)+","+((bili*scaleed)>1.5?1:0.6)+")"});
if (tiewidth<0) {
bili =parseInt(suffixtieend.offset().left-boxleft)/suffixtieend.width();
var thistieline =suffixtieend.find('.jpnote-tieline').eq(0);
var isgttieline =thistieline.hasClass('jtnote-tieline');
thistieline.css({"transform": "translateZ(0) "+((bili*scaleed)>1.5?" ":(isgttieline?" ":" translateY(4px) "))+" scale("+(bili*scaleed)+","+((bili*scaleed)>1.5?1:0.6)+")"}).show();
}
});
allbars.find('.prefixtie').each(function(){
//console.log($(this).attr('pos'));
var iscross = $(this).attr('cross');
var tieboxW=parseInt($(this).width());
var tieleft=parseInt($(this).offset().left);
if (iscross=="cross") {
//var prefixtieend=$('.prefixtie-end[pos="'+$(this).attr('pos')+'"][cross="cross"]');
var prefixtieend=$('#prefixtie-end'+$(this).attr('pos')+'-cross');
} else {
//var prefixtieend=$('.prefixtie-end[pos="'+$(this).attr('pos')+'"][cross!="cross"]');
var prefixtieend=$('#prefixtie-end'+$(this).attr('pos'));
}
//如果找不到闭合,则在自身后面30px后闭合
if (prefixtieend.html()!==null) {
var tieright=parseInt(prefixtieend.offset().left);
} else {
var tieright=parseInt($(this).offset().left)+30;
}
var tiewidth =tieright-tieleft;
if (tiewidth>0) {
var bili =tiewidth/tieboxW;
} else {
//var boxright=parseInt($(this).parents('.muse-jianpu').find('.muse-bar').offset().left);
//var boxright=parseInt(($('#muse-canvas').width()*scale)+$('#muse-canvas').offset().left);
var bili =(boxright-tieleft)/tieboxW;
}
//tiewidth=tiewidth<=0?30:tiewidth;
prefixtieend.find('.jpnote-tieline').hide();
var thistieline =$(this).find('.jpnote-tieline').eq(0);
var isgttieline =thistieline.hasClass('jtnote-tieline');
thistieline.css({"transform": "translateZ(0) "+((bili*scaleed)>1.5?" ":(isgttieline?" ":" translateY(4px) "))+" scale("+(bili*scaleed)+","+((bili*scaleed)>1.5?1:0.6)+")"});
if (tiewidth<0) {
bili =parseInt(prefixtieend.offset().left-boxleft)/prefixtieend.width();
var thistieline =prefixtieend.find('.jpnote-tieline').eq(0);
var isgttieline =thistieline.hasClass('jtnote-tieline');
thistieline.css({"transform": "translateZ(0) "+((bili*scaleed)>1.5?" ":(isgttieline?" ":" translateY(4px) "))+" scale("+(bili*scaleed)+","+((bili*scaleed)>1.5?1:0.6)+")"}).show();
}
});
allbars.find('.startslur').each(function(){
//console.log($(this).attr('pos'));
var tieboxW=parseInt($(this).width());
var tieleft=parseInt($(this).offset().left);
//var endslur=$('.endslur[pos="'+$(this).attr('pos')+'"]');
var endslur=$('#endslur'+$(this).attr('pos'));
//如果找不到闭合,则在自身后面30px后闭合
if (endslur.html()!==null) {
var tieright=parseInt(endslur.offset().left);
} else {
var tieright=parseInt($(this).offset().left)+30;
}
var tiewidth =tieright-tieleft;
//tiewidth=tiewidth<=0?30:tiewidth;
if (tiewidth>0) {
var bili =tiewidth/tieboxW;
} else {
//var boxright=parseInt(($('#muse-canvas').width()*scale)+$('#muse-canvas').offset().left);
//var boxright=parseInt($(this).parents('.muse-jianpu').find('.muse-bar').offset().left);
var bili =(boxright-tieleft)/tieboxW;
}
endslur.find('.jpnote-tieline').hide();
var endslurs=endslur.parent().find('.endslur');
var endties =endslur.parent().find('.jpnote-tieboxend');
if (endslurs.length>0 && endties.length>1) {
for (var i = 0; i < endslurs.length; i++) {
$('.startslur[pos='+endslurs.eq(i).attr('pos')+']').addClass('tiebox-'+(i+1));
}
}
var thistieline =$(this).find('.jpnote-tieline').eq(0);
var isgttieline =thistieline.hasClass('jtnote-tieline');
thistieline.css({"transform": "translateZ(0) "+((bili*scaleed)>1.5?" ":(isgttieline?" ":" translateY(4px) "))+" scale("+(bili*scaleed)+","+((bili*scaleed)>1.5?1:0.6)+")"});
if (tiewidth<0) {
bili =parseInt(endslur.offset().left-boxleft)/endslur.width();
var thistieline =endslur.find('.jpnote-tieline').eq(0)
var isgttieline =thistieline.hasClass('jtnote-tieline');
thistieline.css({"transform": "translateZ(0) "+((bili*scaleed)>1.5?" ":(isgttieline?" ":" translateY(4px) "))+" scale("+(bili*scaleed)+","+((bili*scaleed)>1.5?1:0.6)+")"}).show();
}
});
var xtuplets=$(".hasxtupletstart[class*='hasgrace'],.hasxtupletstart[class*='haschord']");
xtuplets.each(function(i){
var xlet=$(this);
var xlet_end=xlet.nextAll().filter('.hasxtupletsend').eq(0);
var xlet_width = (xlet_end.offset().left+(xlet_end.width()/2))-(xlet.offset().left+(xlet.width()/2))+1;
xlet.find('.xtuplet-line').eq(0).width(xlet_width).css({'left':'49%'});
});
$('.muse-pro-prossing').fadeOut();
//$('#musebox').css({'height':$('#muse-canvas').height()+'px'});
//$('#musebox').parent().height($('#musebox').height());
// var height=0;
// if ($('#muse-maker-info').length>0) {
// height=height+$('#muse-maker-info').height();
// }
// if ($('muse-infos').length>0) {
// height=height+$('#muse-infos').height();
// }
// height=(height+$('#muse-canvas').height()+200);
// $('#musebox').css({'height':height+'px'});
// if ($('#muse-notes').length>0) {
// height=height+$('#muse-notes').height();
// }
// $('#musebox').parent().height(height+180);
// if ($("#muse-canvas").css('visibility')=='hidden') {
// $("#muse-canvas").css('visibility','visible');
// };
// //如果是不换行定位坐标到最后
// if ($('#muse-canvas').hasClass('muse-canvas-nowap')) {
// $('#musebox-out').scrollLeft($('#musebox-out')[0].scrollWidth);
// };
};
(function($){
jQuery.Pro = jQuery.Pro || {};
jQuery.Pro = function(Html,Type) {
var Config = $.extend(true, {
Img:false,
Loading:false,
ImgWh:"100*100",
BoxBgopacity:0.8,
ZIndex:1000000,
Time:0.6,
StartOn:false,
EndOn:false,
Showing:false,
Class:'muse-propop',
},Type);
$Box=$("").css({
width:"100%",
"margin": "0",
"padding": "0",
}).html(Html);
$("body").append($Box.append($BoxHtml));
if(Config.Img){
$BoxImg=$("").attr({"src":Config.Img});
$Box.prepend($BoxImg);
}
if(Config.Loading){$Box.prepend('