@@ -20,19 +20,22 @@ const switchListV = {
2020 '^' : `<div class='cell'>${ stringO } </div>` ,
2121 x : `<div class='cell'>${ stringX } </div>` ,
2222 '|' : `<div class='cell empty'>${ dotEmpty } </div>` ,
23- ' ' : `<div class='cell empty'>${ dotEmpty } </div>`
23+ ' ' : `<div class='cell empty'>${ dotEmpty } </div>` ,
24+ '\n' : `<div class='cell empty'>${ dotEmpty } </div>`
2425}
2526const switchListH = {
2627 o : `<div class='cell dot'>${ dotH } </div>` ,
2728 '*' : `<div class='cell dot faded'>${ dotH } </div>` ,
2829 O : `<div class='cell dot root'>${ dotH } </div>` ,
2930 '-' : `<div class='cell empty'>${ dotEmptyH } </div>` ,
30- ' ' : `<div class='cell empty'>${ dotEmptyH } </div>`
31+ ' ' : `<div class='cell empty'>${ dotEmptyH } </div>` ,
32+ '\n' : `<div class='cell empty'>${ dotEmptyH } </div><div class='cell empty'>${ dotEmptyH } </div>`
3133}
3234
3335export const renderFretBoard = ( content , { title : fretTitle , type } ) => {
34- const fretboardHTML = $ ( '<div class="fretboard_instance"></div>' )
3536 const fretType = type . split ( ' ' )
37+ const containerClass = fretType && fretType [ 0 ] . startsWith ( 'h' ) ? 'fretContainer_h' : 'fretContainer'
38+ const fretboardHTML = $ ( `<div class="${ containerClass } "></div>` )
3639
3740 $ ( fretboardHTML ) . append ( $ ( `<div class="fretTitle">${ fretTitle } </div>` ) )
3841
@@ -47,11 +50,26 @@ export const renderFretBoard = (content, { title: fretTitle, type }) => {
4750
4851 // create cells HTML
4952 const cellsHTML = $ ( '<div class="cells"></div>' )
50- const switchList = fretbOrientation && fretbOrientation === 'vert' ? switchListV : switchListH
53+ let switchList = ''
54+ if ( fretbOrientation && fretbOrientation === 'vert' ) {
55+ switchList = switchListV
56+ } else {
57+ // calculate position
58+ const emptyFill = new Array ( Number ( fretbLen ) + 3 ) . fill ( ' ' ) . join ( '' )
59+ content = `${ emptyFill } ${ content } `
60+
61+ switchList = switchListH
62+ }
63+
5164 const contentCell = content && content . split ( '' )
5265 // Go through each ASCII character...
66+ const numArray = [ ...Array ( 10 ) . keys ( ) ] . slice ( 1 )
5367 contentCell && contentCell . forEach ( char => {
54- if ( switchList [ char ] !== undefined ) {
68+ if ( numArray . toString ( ) . indexOf ( char ) !== - 1 ) {
69+ const numType = fretType && fretType [ 0 ] . startsWith ( 'h' ) ? '_h' : ''
70+ const numSvg = require ( `./svg/number${ char } ${ numType } .svg` )
71+ cellsHTML . append ( $ ( `<div class='cell empty'>${ numSvg } </div>` ) )
72+ } else if ( switchList [ char ] !== undefined ) {
5573 cellsHTML . append ( $ ( switchList [ char ] ) )
5674 }
5775 } )
0 commit comments