spanish-quizzer

An app to quiz you on Spanish vocabulary and verb conjugations
git clone https://git.ashermorgan.net/spanish-quizzer/
Log | Files | Refs | README

commit da409182a3d8961b353ee5fdf2212a6b006117a6
parent 8263947a923772d1691f04f373366a0ef5e25681
Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com>
Date:   Sat, 28 Nov 2020 14:41:23 -0800

Implement "All Sets" filter in reference tables.

Diffstat:
Mjs/reference.js | 21+++++++++++++++++++--
Mreference.html | 1+
2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/js/reference.js b/js/reference.js @@ -12,7 +12,7 @@ function loadVue() { data: { set: "Choose a vocab set", - sets: {"Choose a vocab set":[]}, + sets: {"Choose a vocab set":[], "All Sets":[["English", "Spanish", "Type"]]}, query: "" } }); @@ -48,8 +48,25 @@ function Load() { Papa.parse(`vocab/${setName}.csv`, { download: true, complete: function(results) { - // Set verbs + // Add Set app.sets[setName] = results.data; + + // Add data to "All Sets" + if (setName === "Verbs") { + for (let row of results.data.slice(1)) { + app.sets["All Sets"].push([row[0], row[1], "Verb"]); + } + } + else { + app.sets["All Sets"].push(...results.data.slice(1)); + } + + // Sort "All Sets" + app.sets["All Sets"].sort(function(a, b) { + if (a[0] === "English") return false; // Header row should be at the top + else if (b[0] === "English") return true; // Header row should be at the top + else return a[0] > b[0]; // Sort other rows by 1st item + }) } }); } diff --git a/reference.html b/reference.html @@ -33,6 +33,7 @@ <div id="controls" hidden> <select aria-label="Vocab Set" v-model="set"> <option>Choose a vocab set</option> + <option>All Sets</option> <optgroup label="Common Words"> <option>Adjectives</option> <option>Adverbs</option>