diff --git a/src/js/account.js b/src/js/account.js
index e7a0a1750..12af2af92 100644
--- a/src/js/account.js
+++ b/src/js/account.js
@@ -1,52 +1,3 @@
-$(".pageLogin .register input").keyup((e) => {
- if ($(".pageLogin .register .button").hasClass("disabled")) return;
- if (e.key == "Enter") {
- signUp();
- }
-});
-
-$(".pageLogin .register .button").click((e) => {
- if ($(".pageLogin .register .button").hasClass("disabled")) return;
- signUp();
-});
-
-$(".pageLogin .login input").keyup((e) => {
- if (e.key == "Enter") {
- configChangedBeforeDb = false;
- signIn();
- }
-});
-
-$(".pageLogin .login .button").click((e) => {
- configChangedBeforeDb = false;
- signIn();
-});
-
-$(".signOut").click((e) => {
- signOut();
-});
-
-$(".pageAccount .loadMoreButton").click((e) => {
- loadMoreLines();
-});
-
-$(".pageLogin #forgotPasswordButton").click((e) => {
- let email = prompt("Email address");
- if (email) {
- firebase
- .auth()
- .sendPasswordResetEmail(email)
- .then(function () {
- // Email sent.
- Misc.showNotification("Email sent", 2000);
- })
- .catch(function (error) {
- // An error happened.
- Misc.showNotification(error.message, 5000);
- });
- }
-});
-
function showSignOutButton() {
$(".signOut").removeClass("hidden").css("opacity", 1);
}
@@ -2434,3 +2385,52 @@ $("#resultEditTagsPanel .confirmButton").click((f) => {
function updateLbMemory(mode, mode2, type, value) {
db_getSnapshot().lbMemory[mode + mode2][type] = value;
}
+$(".pageLogin .register input").keyup((e) => {
+ if ($(".pageLogin .register .button").hasClass("disabled")) return;
+ if (e.key == "Enter") {
+ signUp();
+ }
+});
+
+$(".pageLogin .register .button").click((e) => {
+ if ($(".pageLogin .register .button").hasClass("disabled")) return;
+ signUp();
+});
+
+$(".pageLogin .login input").keyup((e) => {
+ if (e.key == "Enter") {
+ configChangedBeforeDb = false;
+ signIn();
+ }
+});
+
+$(".pageLogin .login .button").click((e) => {
+ configChangedBeforeDb = false;
+ signIn();
+});
+
+$(".signOut").click((e) => {
+ signOut();
+});
+
+$(".pageAccount .loadMoreButton").click((e) => {
+ loadMoreLines();
+});
+
+$(".pageLogin #forgotPasswordButton").click((e) => {
+ let email = prompt("Email address");
+ if (email) {
+ firebase
+ .auth()
+ .sendPasswordResetEmail(email)
+ .then(function () {
+ // Email sent.
+ Misc.showNotification("Email sent", 2000);
+ })
+ .catch(function (error) {
+ // An error happened.
+ Misc.showNotification(error.message, 5000);
+ });
+ }
+});
+
diff --git a/src/js/db.js b/src/js/db.js
index 1ec40c3d5..aa8a37dc3 100644
--- a/src/js/db.js
+++ b/src/js/db.js
@@ -273,8 +273,7 @@ export async function db_getLocalTagPB(tagId) {
}
let retval;
- if (dbSnapshot == null) {
- } else {
+ if (dbSnapshot != null) {
retval = cont();
}
return retval;
@@ -289,8 +288,7 @@ export async function db_saveLocalTagPB(tagId, wpm) {
});
}
- if (dbSnapshot == null) {
- } else {
+ if (dbSnapshot != null) {
cont();
}
}
diff --git a/src/js/monkey.js b/src/js/monkey.js
index 777ec24bc..a49182dd7 100644
--- a/src/js/monkey.js
+++ b/src/js/monkey.js
@@ -10,6 +10,19 @@ let last = "right";
// 0 up
// 1 down
+function update() {
+ if (!document.querySelector("#monkey").classList.contains("hidden")) {
+ Object.keys(elements).forEach((key) => {
+ elements[key].classList.add("hidden");
+ });
+
+ let id = left ? "1" : "0";
+ id += right ? "1" : "0";
+
+ elements[id].classList.remove("hidden");
+ }
+}
+
export function type() {
if (!left && last == "right") {
left = true;
@@ -30,15 +43,3 @@ export function stop() {
update();
}
-function update() {
- if (!document.querySelector("#monkey").classList.contains("hidden")) {
- Object.keys(elements).forEach((key) => {
- elements[key].classList.add("hidden");
- });
-
- let id = left ? "1" : "0";
- id += right ? "1" : "0";
-
- elements[id].classList.remove("hidden");
- }
-}
diff --git a/src/js/userconfig.js b/src/js/userconfig.js
index 6b2a00ab9..1ab1a36c7 100644
--- a/src/js/userconfig.js
+++ b/src/js/userconfig.js
@@ -150,142 +150,6 @@ function loadConfigFromCookie() {
restartTest(false, true);
}
-function applyConfig(configObj) {
- if (configObj == null || configObj == undefined) {
- Misc.showNotification("Could not apply config", 1000);
- console.error("configobj is null or undefined");
- return;
- }
- Object.keys(defaultConfig).forEach((configKey) => {
- if (configObj[configKey] === undefined) {
- configObj[configKey] = defaultConfig[configKey];
- }
- });
- if (configObj && configObj != null && configObj != "null") {
- setTheme(configObj.theme, true);
- setCustomTheme(configObj.customTheme, true);
- setCustomThemeColors(configObj.customThemeColors, true);
- setQuickTabMode(configObj.quickTab, true);
- setKeyTips(configObj.showKeyTips, true);
- setTimeConfig(configObj.time, true);
- setQuoteLength(configObj.quoteLength, true);
- setWordCount(configObj.words, true);
- setLanguage(configObj.language, true);
- setCapsLockBackspace(configObj.capsLockBackspace, true);
- setSavedLayout(configObj.savedLayout, true);
- setFontSize(configObj.fontSize, true);
- setFreedomMode(configObj.freedomMode, true);
- setCaretStyle(configObj.caretStyle, true);
- setPaceCaretStyle(configObj.paceCaretStyle, true);
- setDifficulty(configObj.difficulty, true);
- setBlindMode(configObj.blindMode, true);
- setQuickEnd(configObj.quickEnd, true);
- setFlipTestColors(configObj.flipTestColors, true);
- setColorfulMode(configObj.colorfulMode, true);
- setConfidenceMode(configObj.confidenceMode, true);
- setIndicateTypos(configObj.indicateTypos, true);
- setTimerStyle(configObj.timerStyle, true);
- setTimerColor(configObj.timerColor, true);
- setTimerOpacity(configObj.timerOpacity, true);
- setKeymapMode(configObj.keymapMode, true);
- setKeymapStyle(configObj.keymapStyle, true);
- setKeymapLayout(configObj.keymapLayout, true);
- setFontFamily(configObj.fontFamily, true);
- setSmoothCaret(configObj.smoothCaret, true);
- setSmoothLineScroll(configObj.smoothLineScroll, true);
- setShowLiveWpm(configObj.showLiveWpm, true);
- setShowLiveAcc(configObj.showLiveAcc, true);
- setShowTimerProgress(configObj.showTimerProgress, true);
- setAlwaysShowDecimalPlaces(configObj.alwaysShowDecimalPlaces, true);
- setAlwaysShowWordsHistory(configObj.alwaysShowWordsHistory, true);
- setSingleListCommandLine(configObj.singleListCommandLine, true);
- setPlaySoundOnError(configObj.playSoundOnError, true);
- setPlaySoundOnClick(configObj.playSoundOnClick, true);
- setStopOnError(configObj.stopOnError, true);
- setFavThemes(configObj.favThemes, true);
- setRandomTheme(configObj.randomTheme, true);
- setShowAllLines(configObj.showAllLines, true);
- setSwapEscAndTab(configObj.swapEscAndTab, true);
- setShowOutOfFocusWarning(configObj.showOutOfFocusWarning, true);
- setPaceCaret(configObj.paceCaret, true);
- setPaceCaretCustomSpeed(configObj.paceCaretCustomSpeed, true);
- setPageWidth(configObj.pageWidth, true);
- setChartAccuracy(configObj.chartAccuracy, true);
- setChartStyle(configObj.chartStyle, true);
- setMinWpm(configObj.minWpm, true);
- setMinWpmCustomSpeed(configObj.minWpmCustomSpeed, true);
- setMinAcc(configObj.minAcc, true);
- setMinAccCustom(configObj.minAccCustom, true);
- setNumbers(configObj.numbers, true);
- setPunctuation(configObj.punctuation, true);
- setHighlightMode(configObj.highlightMode, true);
- setAlwaysShowCPM(configObj.alwaysShowCPM, true);
- setHideExtraLetters(configObj.hideExtraLetters, true);
- setStartGraphsAtZero(configObj.startGraphsAtZero, true);
- setStrictSpace(configObj.strictSpace, true);
- setMode(configObj.mode, true);
-
- try {
- setEnableAds(configObj.enableAds, true);
- if (config.enableAds === "on") {
- $("#ad1").removeClass("hidden");
- $("#ad1")
- .html(`
-
- `);
- const adsbygoogle = window.adsbygoogle || [];
- adsbygoogle.push({});
- } else if (config.enableAds === "max") {
- $("#ad1").removeClass("hidden");
- $("#ad2").removeClass("hidden");
- $("#ad3").removeClass("hidden");
- $("#ad1").html(`
-
- `);
- $("#ad2")
- .html(`
-
- `);
- $("#ad3")
- .html(`
-
- `);
- const adsbygoogle = window.adsbygoogle || [];
- adsbygoogle.push({});
- adsbygoogle.push({});
- adsbygoogle.push({});
- } else {
- $("#ad1").remove();
- $("#ad2").remove();
- $("#ad3").remove();
- }
- } catch (e) {
- console.log("error initialising ads " + e.message);
- $("#ad1").remove();
- $("#ad2").remove();
- $("#ad3").remove();
- }
- }
- updateTestModesNotice();
-}
-
function saveActiveTagsToCookie() {
let tags = [];
@@ -1615,3 +1479,140 @@ function setFontSize(fontSize, nosave) {
}
if (!nosave) saveConfigToCookie();
}
+
+function applyConfig(configObj) {
+ if (configObj == null || configObj == undefined) {
+ Misc.showNotification("Could not apply config", 1000);
+ console.error("configobj is null or undefined");
+ return;
+ }
+ Object.keys(defaultConfig).forEach((configKey) => {
+ if (configObj[configKey] === undefined) {
+ configObj[configKey] = defaultConfig[configKey];
+ }
+ });
+ if (configObj && configObj != null && configObj != "null") {
+ setTheme(configObj.theme, true);
+ setCustomTheme(configObj.customTheme, true);
+ setCustomThemeColors(configObj.customThemeColors, true);
+ setQuickTabMode(configObj.quickTab, true);
+ setKeyTips(configObj.showKeyTips, true);
+ setTimeConfig(configObj.time, true);
+ setQuoteLength(configObj.quoteLength, true);
+ setWordCount(configObj.words, true);
+ setLanguage(configObj.language, true);
+ setCapsLockBackspace(configObj.capsLockBackspace, true);
+ setSavedLayout(configObj.savedLayout, true);
+ setFontSize(configObj.fontSize, true);
+ setFreedomMode(configObj.freedomMode, true);
+ setCaretStyle(configObj.caretStyle, true);
+ setPaceCaretStyle(configObj.paceCaretStyle, true);
+ setDifficulty(configObj.difficulty, true);
+ setBlindMode(configObj.blindMode, true);
+ setQuickEnd(configObj.quickEnd, true);
+ setFlipTestColors(configObj.flipTestColors, true);
+ setColorfulMode(configObj.colorfulMode, true);
+ setConfidenceMode(configObj.confidenceMode, true);
+ setIndicateTypos(configObj.indicateTypos, true);
+ setTimerStyle(configObj.timerStyle, true);
+ setTimerColor(configObj.timerColor, true);
+ setTimerOpacity(configObj.timerOpacity, true);
+ setKeymapMode(configObj.keymapMode, true);
+ setKeymapStyle(configObj.keymapStyle, true);
+ setKeymapLayout(configObj.keymapLayout, true);
+ setFontFamily(configObj.fontFamily, true);
+ setSmoothCaret(configObj.smoothCaret, true);
+ setSmoothLineScroll(configObj.smoothLineScroll, true);
+ setShowLiveWpm(configObj.showLiveWpm, true);
+ setShowLiveAcc(configObj.showLiveAcc, true);
+ setShowTimerProgress(configObj.showTimerProgress, true);
+ setAlwaysShowDecimalPlaces(configObj.alwaysShowDecimalPlaces, true);
+ setAlwaysShowWordsHistory(configObj.alwaysShowWordsHistory, true);
+ setSingleListCommandLine(configObj.singleListCommandLine, true);
+ setPlaySoundOnError(configObj.playSoundOnError, true);
+ setPlaySoundOnClick(configObj.playSoundOnClick, true);
+ setStopOnError(configObj.stopOnError, true);
+ setFavThemes(configObj.favThemes, true);
+ setRandomTheme(configObj.randomTheme, true);
+ setShowAllLines(configObj.showAllLines, true);
+ setSwapEscAndTab(configObj.swapEscAndTab, true);
+ setShowOutOfFocusWarning(configObj.showOutOfFocusWarning, true);
+ setPaceCaret(configObj.paceCaret, true);
+ setPaceCaretCustomSpeed(configObj.paceCaretCustomSpeed, true);
+ setPageWidth(configObj.pageWidth, true);
+ setChartAccuracy(configObj.chartAccuracy, true);
+ setChartStyle(configObj.chartStyle, true);
+ setMinWpm(configObj.minWpm, true);
+ setMinWpmCustomSpeed(configObj.minWpmCustomSpeed, true);
+ setMinAcc(configObj.minAcc, true);
+ setMinAccCustom(configObj.minAccCustom, true);
+ setNumbers(configObj.numbers, true);
+ setPunctuation(configObj.punctuation, true);
+ setHighlightMode(configObj.highlightMode, true);
+ setAlwaysShowCPM(configObj.alwaysShowCPM, true);
+ setHideExtraLetters(configObj.hideExtraLetters, true);
+ setStartGraphsAtZero(configObj.startGraphsAtZero, true);
+ setStrictSpace(configObj.strictSpace, true);
+ setMode(configObj.mode, true);
+
+ try {
+ setEnableAds(configObj.enableAds, true);
+ if (config.enableAds === "on") {
+ $("#ad1").removeClass("hidden");
+ $("#ad1")
+ .html(`
+
+ `);
+ const adsbygoogle = window.adsbygoogle || [];
+ adsbygoogle.push({});
+ } else if (config.enableAds === "max") {
+ $("#ad1").removeClass("hidden");
+ $("#ad2").removeClass("hidden");
+ $("#ad3").removeClass("hidden");
+ $("#ad1").html(`
+
+ `);
+ $("#ad2")
+ .html(`
+
+ `);
+ $("#ad3")
+ .html(`
+
+ `);
+ const adsbygoogle = window.adsbygoogle || [];
+ adsbygoogle.push({});
+ adsbygoogle.push({});
+ adsbygoogle.push({});
+ } else {
+ $("#ad1").remove();
+ $("#ad2").remove();
+ $("#ad3").remove();
+ }
+ } catch (e) {
+ console.log("error initialising ads " + e.message);
+ $("#ad1").remove();
+ $("#ad2").remove();
+ $("#ad3").remove();
+ }
+ }
+ updateTestModesNotice();
+}
+