Skip to content

Commit 95947e2

Browse files
committed
add number system and rwd fretboard
Signed-off-by: Ca Chen <kiancaca@gmail.com>
1 parent b957b8b commit 95947e2

20 files changed

+204
-6
lines changed

public/js/lib/renderer/fretboard/css/i.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/lib/renderer/fretboard/fretboard.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}
2526
const 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

3335
export 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
})
Lines changed: 10 additions & 0 deletions
Loading
Lines changed: 10 additions & 0 deletions
Loading
Lines changed: 10 additions & 0 deletions
Loading
Lines changed: 10 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)