mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-11 08:14:11 +08:00
Completed Previous Commit
This commit is contained in:
parent
4c024887dc
commit
2a1711affc
1 changed files with 46 additions and 1 deletions
|
@ -470,7 +470,52 @@ async function initWords() {
|
|||
// if (config.language.split("_")[0] !== "code") {
|
||||
setLanguage(config.language.replace(/_\d*k$/g, ""), true);
|
||||
// }
|
||||
quotes = Misc.getquotes(config.language);
|
||||
showBackgroundLoader();
|
||||
$.ajax({
|
||||
url: `quotes/${config.language}.json`,
|
||||
async: false,
|
||||
success: function (data) {
|
||||
hideBackgroundLoader();
|
||||
try {
|
||||
if (data.quotes.length === 0) {
|
||||
throw new Error("No quotes");
|
||||
}
|
||||
quotes = data;
|
||||
quotes.groups.forEach((qg, i) => {
|
||||
let lower = qg[0];
|
||||
let upper = qg[1];
|
||||
quotes.groups[i] = quotes.quotes.filter((q) => {
|
||||
if (q.length >= lower && q.length <= upper) {
|
||||
q.group = i;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
quotes.quotes = [];
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
Notifications.add(
|
||||
`No ${config.language.replace(/_\d*k$/g, "")} quotes found`,
|
||||
0
|
||||
);
|
||||
testRestarting = false;
|
||||
return;
|
||||
}
|
||||
},
|
||||
error: (e) => {
|
||||
Notifications.add(
|
||||
`Error while loading ${config.language.replace(
|
||||
/_\d*k$/g,
|
||||
""
|
||||
)} quotes: ${e}`,
|
||||
-1
|
||||
);
|
||||
return;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (!language) {
|
||||
config.language = "english";
|
||||
|
|
Loading…
Reference in a new issue