1// abc2svg - ABC to SVG translator 2// @source: https://chiselapp.com/user/moinejf/repository/abc2svg 3// Copyright (C) 2014-2020 Jean-Francois Moine - LGPL3+ 4//abc2svg-chordnames.js-change the names of the chord symbols 5abc2svg.chordnames={gch_build:function(of,s){var gch,i,ix,t,cfmt=this.cfmt() 6if(s.a_gch&&cfmt.chordnames){for(ix=0;ix<s.a_gch.length;ix++){gch=s.a_gch[ix] 7t=gch.text 8if(gch.type!='g') 9continue 10if(t=="N.C.") 11gch.text=cfmt.chordnames.Z 12else 13gch.text=t.replace(/[A-GZ]/g,function(c){return cfmt.chordnames[c]}) 14if(cfmt.chordnames.B=='H') 15gch.text=gch.text.replace(/Hb/g,'Bb')}} 16of(s)},set_fmt:function(of,cmd,parm){var i,cfmt=this.cfmt() 17if(cmd=="chordnames"){parm=parm.split(',') 18cfmt.chordnames={Z:"N.C."} 19for(i=0;i<parm.length;i++) 20cfmt.chordnames['CDEFGABZ'[i]]=parm[i] 21return} 22of(cmd,parm)},set_hooks:function(abc){abc.gch_build=abc2svg.chordnames.gch_build.bind(abc,abc.gch_build) 23abc.set_format=abc2svg.chordnames.set_fmt.bind(abc,abc.set_format)}} 24abc2svg.modules.hooks.push(abc2svg.chordnames.set_hooks) 25abc2svg.modules.chordnames.loaded=true 26