Commit d9b588d8 authored by Curtis Adam's avatar Curtis Adam

Restore .json import

parent 81f895ac
......@@ -19,26 +19,42 @@ Meteor.methods({
} else if (item.back === undefined || item.back === "") {
throw new Meteor.Error("entry number: " + i, "back missing");
}
if (item.subject === undefined) {
item.subject = "Kein Titel";
}
if (item.hint === undefined) {
item.hint = "";
}
if (item.difficulty === undefined) {
item.difficulty = Number(0);
}
}
for (let i = 0; i < data.length; i++) {
let item = data[i];
var front, back;
var subject, front, back, hint;
try {
// If the string is UTF-8, this will work and not throw an error.
subject = decodeURIComponent(encodeURIComponent(item.subject));
front = decodeURIComponent(encodeURIComponent(item.front));
back = decodeURIComponent(encodeURIComponent(item.back));
hint = decodeURIComponent(encodeURIComponent(item.hint));
} catch (e) {
// If it isn't, an error will be thrown, and we can assume that we have an ISO string.
subject = item.subject;
front = item.front;
back = item.back;
hint = item.hint;
}
if (item.front !== "") {
Cards.insert({
subject: subject,
difficulty: item.difficulty,
front: front,
back: back,
hint: hint,
cardset_id: cardset_id
});
Cardsets.update(cardset_id, {
......
......@@ -5,12 +5,12 @@
"start": "meteor run"
},
"dependencies": {
"babel-runtime": "^6.20.0",
"chart.js": "^2.4.0",
"babel-runtime": "^6.23.0",
"chart.js": "^2.5.0",
"ink-docstrap": "~1.3.0",
"meteor-node-stubs": "~0.2.0",
"react": "^15.0.2",
"ink-docstrap": "~1.3.0",
"web-push": "^3.2.1"
"web-push": "^3.2.2"
},
"version": "1.0.0",
"main": "index.js",
......
{
"front": "yourfirstcardfront",
"back": "yourfirstcardback"
},
{
"front": "yoursecondcardfront",
"back": "yoursecondcardback"
},
{
"front": "yourthirdcardfront",
"back": "yourthirdcardback"
"subject": "yourFirstCardSubject",
"difficulty": 1,
"hint": "yourFirstCardHint",
"front": "yourFirstCardFront",
"back": "yourFirstCardBack"
}, {
"subject": "yourSecondCardSubject",
"difficulty": 0,
"hint": "yourSecondCardHint",
"front": "yourSecondCardFront",
"back": "yourSecondCardBack"
}, {
"subject": "yourThirdCardSubject",
"difficulty": 1,
"hint": "yourThirdCardHint",
"front": "yourThirdCardFront",
"back": "yourThirdCardBack"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment