From 9c7fcd1ec3c0880f3dc15a9600185fd7814db281 Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Wed, 30 Jun 2021 17:20:46 +0200 Subject: [PATCH] =?UTF-8?q?Opci=C3=B3n=20para=20ocultar=20los=20acordes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- res/static/sizes.js | 12 ----- res/static/{transpose.js => song.js} | 43 +++++++++++++++ res/templates/song.html | 81 ++++++++++++++++------------ 3 files changed, 90 insertions(+), 46 deletions(-) delete mode 100644 res/static/sizes.js rename res/static/{transpose.js => song.js} (52%) diff --git a/res/static/sizes.js b/res/static/sizes.js deleted file mode 100644 index b031f78..0000000 --- a/res/static/sizes.js +++ /dev/null @@ -1,12 +0,0 @@ -SIZE_STEPS = [30, 50, 67, 80, 90, 100, 110, 120, 133, 150, 170, 200, 240, 300]; - -currSize = SIZE_STEPS.indexOf(100) - -/** Changes the size of the lyrics and chords. */ -function size(steps) { - if (steps === 0) { - currSize = SIZE_STEPS.indexOf(100); - } - currSize += steps; - document.getElementById('wholeSongDiv').style.fontSize = SIZE_STEPS[currSize] + '%'; -} diff --git a/res/static/transpose.js b/res/static/song.js similarity index 52% rename from res/static/transpose.js rename to res/static/song.js index b694682..fc2efd7 100644 --- a/res/static/transpose.js +++ b/res/static/song.js @@ -1,3 +1,24 @@ +/* =========================================== + FONT SIZE + =========================================== */ +SIZE_STEPS = [30, 50, 67, 80, 90, 100, 110, 120, 133, 150, 170, 200, 240, 300]; + +currSize = SIZE_STEPS.indexOf(100) + +/** Changes the size of the lyrics and chords. */ +function size(steps) { + if (steps === 0) { + currSize = SIZE_STEPS.indexOf(100); + } + currSize += steps; + document.getElementById('wholeSongDiv').style.fontSize = SIZE_STEPS[currSize] + '%'; +} + +/* =========================================== + TRANSPOSE CHORDS + =========================================== */ + + ENG_INDEX = {'C': 0, 'C#': 1, 'Db': 1, 'D': 2, 'D#': 3, 'Eb': 3, 'E': 4, 'Fb': 4, 'F': 5, 'E#': 5, 'F#': 6, 'Gb': 6, 'G': 7, 'G#': 8, 'Ab': 8, 'A': 9, 'A#': 10, 'Bb': 10, 'B': 11, 'Cb': 11, 'B#': 0} LAT_INDEX = {'Do': 0, 'Do#': 1, 'Reb': 1, 'Re': 2, 'Re#': 3, 'Mib': 3, 'Mi': 4, 'Fab': 4, 'Fa': 5, 'Mi#': 5, 'Fa#': 6, 'Solb': 6, 'Sol': 7, 'Sol#': 8, 'Lab': 8, 'La': 9, 'La#': 10, 'Sib': 10, 'Si': 11, 'Dob': 11, 'Si#': 0} CHORDS_LAT = ['Do', 'Do#', 'Re', 'Re#', 'Mi', 'Fa', 'Fa#', 'Sol', 'Sol#', 'La', 'Sib', 'Si'] @@ -42,3 +63,25 @@ function setTransposeSelector(n) { function getTranspose() { return Number.parseInt(document.getElementById("transposeSelect").value) } + +/* =========================================== + HIDE CHORDS + =========================================== */ + +// Init +document.addEventListener("DOMContentLoaded", function () { + var show = localStorage.getItem("show_chords") == "true"; + showChords(show); + document.getElementById("showChords").checked = show; +}, false); + +function showChords(show) { + if (show || show == "true") { + document.getElementById("songLyrics").style.display = "none"; + document.getElementById("songChords").style.display = "block"; + } else { + document.getElementById("songLyrics").style.display = "block"; + document.getElementById("songChords").style.display = "none"; + } + localStorage.setItem("show_chords", show); +} \ No newline at end of file diff --git a/res/templates/song.html b/res/templates/song.html index 5907f50..fb84f73 100644 --- a/res/templates/song.html +++ b/res/templates/song.html @@ -3,8 +3,7 @@ {% include "head.html" with path=".." only %} - - + {% include "header.html" with path=".." %} @@ -26,6 +25,9 @@ {% if song.chorded %} +
+ +
@@ -58,40 +60,51 @@ {% endif %}

CanciĆ³n

- {% for verse in song.verses %} -
- {% for line in verse.lines %} - {% spaceless %} - {% for chord, lyric in line.zipped_arr %} - - - - - - - -
- {% if chord.class %} - - {% endif %} - {% for c in chord.chord.items %} - {% if c.chord %} - {{ c.text|safe }} - {% else %} - {{ c.text|safe }} - {% endif %} - {% endfor %} -
- {% if 'rowspan' not in chord %} - {{ lyric|safe }} - {% endif %} -
- {% endfor %} - {% if not forloop.last %}
{% endif %} - {% endspaceless %} + +
+ {% for verse in song.verses %} +
+ {% for line in verse.lines %} + {% spaceless %} + {% for chord, lyric in line.zipped_arr %} + + + + + + + +
+ {% if chord.class %} + + {% endif %} + {% for c in chord.chord.items %} + {% if c.chord %} + {{ c.text|safe }} + {% else %} + {{ c.text|safe }} + {% endif %} + {% endfor %} +
+ {% if 'rowspan' not in chord %} + {{ lyric|safe }} + {% endif %} +
+ {% endfor %} + {% if not forloop.last %}
{% endif %} + {% endspaceless %} + {% endfor %} +
{% endfor %}
- {% endfor %}
{% for audio in audios %} {% if forloop.first %}