mirror of https://gitlab.com/openlp/web-remote.git
Tweaks here and there
This commit is contained in:
parent
f04941bf74
commit
76c56edfbf
|
@ -23,22 +23,20 @@ export class ChordProPipe implements PipeTransform {
|
|||
this.notesFlatNotation['german'] = ['C','Db','D','Eb','Fb','F','Gb','G','Ab','A','B','H'];
|
||||
this.notesSharpNotation['english'] = ['C','C#','D','D#','E','F','F#','G','G#','A','A#','B'];
|
||||
this.notesFlatNotation['english'] = ['C','Db','D','Eb','Fb','F','Gb','G','Ab','A','Bb','B'];
|
||||
this.notesSharpNotation['neo-latin'] = ['Do','Do#','Re','Re#','Mi','Fa','Fa#','Sol','Sol#','La','La#','Si'];
|
||||
this.notesFlatNotation['neo-latin'] = ['Do','Reb','Re','Mib','Fab','Fa','Solb','Sol','Lab','La','Sib','Si'];
|
||||
}
|
||||
|
||||
private keys = [
|
||||
{ name: 'Ab', value: 0 },
|
||||
{ name: 'A', value: 1 },
|
||||
{ name: 'A#', value: 2 },
|
||||
{ name: 'Bb', value: 2 },
|
||||
{ name: 'A#', value: 2 },
|
||||
{ name: 'B', value: 3 },
|
||||
{ name: 'C', value: 4 },
|
||||
{ name: 'C#', value: 5 },
|
||||
{ name: 'Db', value: 5 },
|
||||
{ name: 'D', value: 6 },
|
||||
{ name: 'D#', value: 7 },
|
||||
{ name: 'Eb', value: 7 },
|
||||
{ name: 'D#', value: 7 },
|
||||
{ name: 'E', value: 8 },
|
||||
{ name: 'F', value: 9 },
|
||||
{ name: 'F#', value: 10 },
|
||||
|
@ -49,6 +47,11 @@ export class ChordProPipe implements PipeTransform {
|
|||
notesSharpNotation = {};
|
||||
notesFlatNotation = {};
|
||||
|
||||
decodeHTML(value: string) {
|
||||
const tempElement = document.createElement("div")
|
||||
tempElement.innerHTML = value
|
||||
return tempElement.innerText
|
||||
}
|
||||
|
||||
/**
|
||||
* @var chordRegex Expression used to determine if given line contains a chord.
|
||||
|
@ -142,14 +145,16 @@ export class ChordProPipe implements PipeTransform {
|
|||
// we are currently receiving html, we need to replace that stuff,
|
||||
// becuase it gets messed up when a chord is placed on it..
|
||||
// shouldn't be relevant if we actually get chordpro format
|
||||
song = song.replace(/–/g, '-');
|
||||
console.log('parsing: ', song);
|
||||
song = this.decodeHTML(song);
|
||||
let comp = this;
|
||||
if (!song) {
|
||||
return '';
|
||||
}
|
||||
let chordText: string = '';
|
||||
let lastChord: string = '';
|
||||
if (!song.match(comp.chordRegex)) {
|
||||
return `<div class="no-chords">${song}</div>`;
|
||||
}
|
||||
song.split(comp.chordRegex).forEach((part, index) => {
|
||||
if (index % 2 == 0) {
|
||||
// text
|
||||
|
@ -163,12 +168,18 @@ export class ChordProPipe implements PipeTransform {
|
|||
// chord
|
||||
lastChord = part.replace(/[[]]/, '');
|
||||
if (nHalfSteps !== 0) {
|
||||
let chordRoot = comp.chordRoot(lastChord);
|
||||
let newRoot = comp.transposeChord(chordRoot, nHalfSteps);
|
||||
lastChord = newRoot + comp.restOfChord(lastChord);
|
||||
lastChord = lastChord.split('/').map(chord => {
|
||||
let chordRoot = comp.chordRoot(chord);
|
||||
let newRoot = comp.transposeChord(chordRoot, nHalfSteps);
|
||||
return newRoot + comp.restOfChord(chord);
|
||||
}).join('/');
|
||||
}
|
||||
|
||||
// use proper symbols
|
||||
lastChord = lastChord.replace(/b/g, '♭');
|
||||
lastChord = lastChord.replace(/#/g, '♯');
|
||||
}
|
||||
});
|
||||
return chordText;
|
||||
return `<div class="with-chords">${chordText}</div>`;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
.song {
|
||||
white-space: pre-wrap;
|
||||
line-height: 2;
|
||||
.with-chords {
|
||||
line-height: 2;
|
||||
}
|
||||
|
||||
span[data-chord]:before {
|
||||
position: relative;
|
||||
|
|
|
@ -12,6 +12,7 @@ export class State {
|
|||
blank: boolean;
|
||||
twelve: boolean;
|
||||
theme: boolean;
|
||||
chordNotation: string;
|
||||
|
||||
live = () => {return !(this.blank || this.display || this.theme);}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue