Skip to content

Commit

Permalink
Never display chords in translation (#33)
Browse files Browse the repository at this point in the history
When there are chords in the translation (or in the song text and one uses the option to swap text and translation), then chords are not removed properly.
This fixes the issue by always parsing the chords, but then just ignoring them for the translation.
  • Loading branch information
aspettl authored Jan 31, 2024
1 parent c41c907 commit 0d0c837
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions WordsLive.Core/Resources/SongPresentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ SongPresentation.prototype.showSlide = function (slide) {
transLine = '';

inner.append($('<span>').append(this.parseLine(textLine, true)));
inner.append($('<span>').addClass('song-trans').append(this.parseLine(transLine, false)));
inner.append($('<span>').addClass('song-trans').append(this.parseLine(transLine, true, true)));
}
} else {
for (i = 0; i < lines.length; i++) {
Expand Down Expand Up @@ -281,7 +281,7 @@ SongPresentation.prototype.showSlide = function (slide) {
}

// parses chords in a line of the song text
SongPresentation.prototype.parseLine = function (line, parseChords) {
SongPresentation.prototype.parseLine = function (line, parseChords, ignoreChords = false) {
var result = new Array();
var index = 0; // current index in result array

Expand Down Expand Up @@ -315,7 +315,7 @@ SongPresentation.prototype.parseLine = function (line, parseChords) {
chordlen = end - (i + 1) + 2; // length of '[Chord]'

result[index++] = line.substring(start, pos); // append text to result
if (this.showChords) {
if (this.showChords && !ignoreChords) {
var chord = line.substring(pos + 1, pos + chordlen - 1);

// abusing the <b> tag for chords for brevity
Expand Down

0 comments on commit 0d0c837

Please sign in to comment.