mirror of
https://github.com/ZetaKebab/japanese-conjugation-drill.git
synced 2025-01-14 22:08:44 +00:00
Used localstorage to store and load options chosen by user.
Co-authored-by: Maurice Ampt <mauriceampt@hotmail.com>
This commit is contained in:
parent
82fc46bcbf
commit
61ec40fb15
@ -4,6 +4,14 @@ var transformations = [];
|
|||||||
|
|
||||||
var log;
|
var log;
|
||||||
|
|
||||||
|
var options = ["plain", "polite", "negative", "past", "te-form",
|
||||||
|
"progressive", "potential", "imperative", "passive", "causative",
|
||||||
|
"godan", "ichidan", "iku", "kuru", "suru", "i-adjective", "na-adjective",
|
||||||
|
"ii", "desire", "volitional", "trick", "kana", "furigana_always",
|
||||||
|
"use_voice"];
|
||||||
|
|
||||||
|
var selects = ["questionFocus"];
|
||||||
|
|
||||||
Array.prototype.randomElement = function () {
|
Array.prototype.randomElement = function () {
|
||||||
return this[Math.floor(Math.random() * this.length)]
|
return this[Math.floor(Math.random() * this.length)]
|
||||||
}
|
}
|
||||||
@ -628,6 +636,7 @@ function showSplash() {
|
|||||||
function startQuiz() {
|
function startQuiz() {
|
||||||
|
|
||||||
var options = getOptions();
|
var options = getOptions();
|
||||||
|
localStorage.setItem('options', JSON.stringify(options));
|
||||||
|
|
||||||
const voiceSelectError = document.querySelector('#voiceSelectError');
|
const voiceSelectError = document.querySelector('#voiceSelectError');
|
||||||
|
|
||||||
@ -972,15 +981,6 @@ function explain() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getOptions() {
|
function getOptions() {
|
||||||
|
|
||||||
var options = ["plain", "polite", "negative", "past", "te-form",
|
|
||||||
"progressive", "potential", "imperative", "passive", "causative",
|
|
||||||
"godan", "ichidan", "iku", "kuru", "suru", "i-adjective", "na-adjective",
|
|
||||||
"ii", "desire", "volitional", "trick", "kana", "furigana_always",
|
|
||||||
"use_voice"];
|
|
||||||
|
|
||||||
var selects = ["questionFocus"];
|
|
||||||
|
|
||||||
var result = {};
|
var result = {};
|
||||||
|
|
||||||
options.forEach(function (option) {
|
options.forEach(function (option) {
|
||||||
@ -994,6 +994,18 @@ function getOptions() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadOptions() {
|
||||||
|
var storedOptions = JSON.parse(localStorage.getItem('options'));
|
||||||
|
|
||||||
|
options.forEach(function (option) {
|
||||||
|
($('#' + option)).checked = storedOptions[option];
|
||||||
|
});
|
||||||
|
|
||||||
|
selects.forEach(function (select) {
|
||||||
|
$('#' + select).value = storedOptions[select];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$('window').ready(function () {
|
$('window').ready(function () {
|
||||||
|
|
||||||
if (window.speechSynthesis) {
|
if (window.speechSynthesis) {
|
||||||
@ -1005,6 +1017,7 @@ $('window').ready(function () {
|
|||||||
|
|
||||||
calculateAllConjugations();
|
calculateAllConjugations();
|
||||||
calculateTransitions();
|
calculateTransitions();
|
||||||
|
loadOptions();
|
||||||
|
|
||||||
$('#go').click(startQuiz);
|
$('#go').click(startQuiz);
|
||||||
$('#backToStart').click(showSplash);
|
$('#backToStart').click(showSplash);
|
||||||
|
Loading…
Reference in New Issue
Block a user