From 464c6d561befe3496dda952efa5638ee478cc383 Mon Sep 17 00:00:00 2001 From: "Son A. Pham" Date: Sun, 12 Apr 2020 16:17:15 -0700 Subject: [PATCH] Add button to append a new section. ISSUE=#7 --- pug/index.pug | 3 +++ src/js/app.js | 4 +++- src/js/songchart.js | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pug/index.pug b/pug/index.pug index 524fa58..ff65941 100644 --- a/pug/index.pug +++ b/pug/index.pug @@ -61,3 +61,6 @@ html(lang='en') div.section(v-for='(section, index) in songChart.sections') div(v-bind:class='{ bold: index == songChart.curSectionIndex, hide: index < songChart.curSectionIndex }') | {{ index }}: {{ section.name }} ({{ section.length }}) + div + span(v-on:click='songChartAppendSection()') + | + Add section diff --git a/src/js/app.js b/src/js/app.js index ea098e1..d963c88 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -41,7 +41,9 @@ window.init = function() { metronomeTempoIncrement: (() => { metronome.tempoIncrement(); }), metronomeTempoIncrementBy5: (() => { metronome.tempoIncrementBy5(); }), metronomeTempoIncrementBy10: (() => { metronome.tempoIncrementBy10(); }), - metronomeTempoDouble: (() => { metronome.tempoDouble(); }) + metronomeTempoDouble: (() => { metronome.tempoDouble(); }), + + songChartAppendSection: (() => { songChart.appendSection(); }) } }); diff --git a/src/js/songchart.js b/src/js/songchart.js index 4f48a61..ffd7bbe 100644 --- a/src/js/songchart.js +++ b/src/js/songchart.js @@ -109,6 +109,13 @@ class SongChart { return this.uiData; } + appendSection() { + this.json.sections.push({ + "name": "Untitled", + "length": 8, + }); + } + /** * Fetches song chart from given url. * @param {string} url Url.