commit 18d830c4eb3aed968b2b262c31885cfbb2ab12ab
parent 90817ebd8a5535ca0660b2f99970ea7ab3a3469d
Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com>
Date: Tue, 28 Jul 2020 12:16:49 -0700
Refactor CSV loading.
Diffstat:
| M | Scripts/Home.js | | | 138 | +++++++------------------------------------------------------------------------ |
1 file changed, 12 insertions(+), 126 deletions(-)
diff --git a/Scripts/Home.js b/Scripts/Home.js
@@ -52,132 +52,18 @@ function Load() {
// Load CSVs
Sets = [];
- Papa.parse("Vocab/Verbs.csv", {
- download: true,
- complete: function(results) {
- // Set verbs
- Sets["Verbs"] = results.data;
- }
- });
- Papa.parse("Vocab/Adjectives.csv", {
- download: true,
- complete: function(results) {
- // Set verbs
- Sets["Adjectives"] = results.data;
- }
- });
- Papa.parse("Vocab/Adverbs.csv", {
- download: true,
- complete: function(results) {
- // Set verbs
- Sets["Adverbs"] = results.data;
- }
- });
- Papa.parse("Vocab/Prepositions.csv", {
- download: true,
- complete: function(results) {
- // Set verbs
- Sets["Prepositions"] = results.data;
- }
- });
- Papa.parse("Vocab/Transitions.csv", {
- download: true,
- complete: function(results) {
- // Set verbs
- Sets["Transitions"] = results.data;
- }
- });
- Papa.parse("Vocab/Colors.csv", {
- download: true,
- complete: function(results) {
- // Set verbs
- Sets["Colors"] = results.data;
- }
- });
- Papa.parse("Vocab/Days.csv", {
- download: true,
- complete: function(results) {
- // Set verbs
- Sets["Days"] = results.data;
- }
- });
- Papa.parse("Vocab/Months.csv", {
- download: true,
- complete: function(results) {
- // Set verbs
- Sets["Months"] = results.data;
- }
- });
- Papa.parse("Vocab/Questions.csv", {
- download: true,
- complete: function(results) {
- // Set verbs
- Sets["Questions"] = results.data;
- }
- });
- Papa.parse("Vocab/Weather.csv", {
- download: true,
- complete: function(results) {
- // Set verbs
- Sets["Weather"] = results.data;
- }
- });
- Papa.parse("Vocab/Family.csv", {
- download: true,
- complete: function(results) {
- // Set verbs
- Sets["Family"] = results.data;
- }
- });
- Papa.parse("Vocab/Clothes.csv", {
- download: true,
- complete: function(results) {
- // Set verbs
- Sets["Clothes"] = results.data;
- }
- });
- Papa.parse("Vocab/Nature.csv", {
- download: true,
- complete: function(results) {
- // Set verbs
- Sets["Nature"] = results.data;
- }
- });
- Papa.parse("Vocab/House.csv", {
- download: true,
- complete: function(results) {
- // Set verbs
- Sets["House"] = results.data;
- }
- });
- Papa.parse("Vocab/Vacation.csv", {
- download: true,
- complete: function(results) {
- // Set verbs
- Sets["Vacation"] = results.data;
- }
- });
- Papa.parse("Vocab/Childhood.csv", {
- download: true,
- complete: function(results) {
- // Set verbs
- Sets["Childhood"] = results.data;
- }
- });
- Papa.parse("Vocab/Professions.csv", {
- download: true,
- complete: function(results) {
- // Set verbs
- Sets["Professions"] = results.data;
- }
- });
- Papa.parse("Vocab/Health.csv", {
- download: true,
- complete: function(results) {
- // Set verbs
- Sets["Health"] = results.data;
- }
- });
+ let setNames = ["Verbs", "Adjectives", "Adverbs", "Prepositions", "Transitions",
+ "Colors", "Days", "Months", "Questions", "Weather", "Family", "Clothes",
+ "Nature", "House", "Vacation", "Childhood", "Professions", "Health"];
+ for (let setName of setNames) {
+ Papa.parse(`Vocab/${setName}.csv`, {
+ download: true,
+ complete: function(results) {
+ // Set verbs
+ Sets[setName] = results.data;
+ }
+ });
+ }
}