enabled funbox only on test

This commit is contained in:
Saint 2021-04-05 00:47:51 -04:00
parent 17a9e0fb3b
commit 1d3512c79d
5 changed files with 32 additions and 16 deletions

View file

@ -126,9 +126,8 @@ let commandsFunbox = {
id: "changeFunboxNone",
display: "none",
exec: () => {
if (Funbox.activate("none", null)) {
TestLogic.restart();
}
Funbox.setFunbox("none", null);
TestLogic.restart();
},
},
],
@ -140,9 +139,8 @@ Misc.getFunboxList().then((funboxes) => {
id: "changeFunbox" + funbox.name,
display: funbox.name.replace(/_/g, " "),
exec: () => {
if (Funbox.activate(funbox.name, funbox.type)) {
TestLogic.restart();
}
Funbox.setFunbox(funbox.name, funbox.type);
TestLogic.restart();
},
});
});

View file

@ -616,7 +616,7 @@ $(".pageSettings .section.discordIntegration #unlinkDiscordButton").click(
$(document).on("click", ".pageSettings .section.funbox .button", (e) => {
let funbox = $(e.currentTarget).attr("funbox");
let type = $(e.currentTarget).attr("type");
Funbox.activate(funbox, type);
Funbox.setFunbox(funbox, type);
setActiveFunboxButton();
});

View file

@ -9,6 +9,8 @@ import * as Settings from "./settings";
export let active = "none";
let memoryTimer = null;
let memoryInterval = null;
let currentFunbox = "none";
let currentMode = null;
function showMemoryTimer() {
$("#typingTest #memoryTimer").stop(true, true).animate(
@ -71,12 +73,9 @@ export function toggleScript(...params) {
}
export async function activate(funbox, mode) {
if (TestLogic.active || TestUI.resultVisible) {
Notifications.add(
"You can only change the funbox before starting a test.",
0
);
return false;
if (funbox === undefined) {
funbox = currentFunbox;
mode = currentMode;
}
if (Misc.getCurrentLanguage().ligatures) {
if (funbox == "choo_choo" || funbox == "earthquake") {
@ -153,12 +152,16 @@ export async function activate(funbox, mode) {
active = funbox;
}
TestUI.updateModesNotice();
return true;
}
export function setFunbox(funbox, mode) {
currentFunbox = funbox;
currentMode = mode;
if (funbox !== "layoutfluid" || mode !== "script") {
if (Config.layout !== Config.savedLayout) {
UpdateConfig.setLayout(Config.savedLayout);
Settings.groups.layout.updateButton();
}
}
TestUI.updateModesNotice();
return true;
}

View file

@ -314,7 +314,6 @@ export function startTest() {
LiveAcc.show();
TimerProgress.update(TestTimer.time);
TestTimer.clear();
if (Funbox.active === "memory") {
Funbox.resetMemoryTimer();
$("#wordsWrapper").addClass("hidden");
@ -575,6 +574,13 @@ export async function init() {
// $("#wordsWrapper").css("height", "auto");
// } else {
TestUI.showWords();
// if($(".page.active").attr("class") === $(".page.pageTest")){
// Funbox.activate();
// }
if ($(".pageTest").hasClass("active")) {
Funbox.activate();
}
// }
}
@ -621,6 +627,7 @@ export function restart(withSameWordset = false, nosave = false, event) {
// incompleteTestSeconds += ;
TestStats.incrementIncompleteSeconds(testSeconds - afkseconds);
TestStats.incrementRestartCount();
// restartCount++;
}
@ -697,6 +704,7 @@ export function restart(withSameWordset = false, nosave = false, event) {
input.reset();
PaceCaret.init();
TestUI.showWords();
Funbox.activate();
}
if (Config.mode === "quote") {
setRepeated(false);
@ -924,6 +932,7 @@ export function finish(difficultyFailed = false) {
LiveAcc.hide();
TimerProgress.hide();
Keymap.hide();
Funbox.activate("none", null);
let stats = TestStats.calculateStats();
if (stats === undefined) {
stats = {

View file

@ -14,6 +14,7 @@ import * as ManualRestart from "./manual-restart-tracker";
import * as Settings from "./settings";
import * as Account from "./account";
import * as Leaderboards from "./leaderboards";
import * as Funbox from "./funbox";
export let pageTransition = false;
@ -136,6 +137,7 @@ export function changePage(page) {
TestStats.resetIncomplete();
ManualRestart.set();
TestLogic.restart();
Funbox.activate();
} else if (page == "about") {
setPageTransition(true);
TestLogic.restart();
@ -144,6 +146,7 @@ export function changePage(page) {
history.pushState("about", null, "about");
$(".page.pageAbout").addClass("active");
});
Funbox.activate("none", null);
TestConfig.hide();
SignOutButton.hide();
} else if (page == "settings") {
@ -154,6 +157,7 @@ export function changePage(page) {
history.pushState("settings", null, "settings");
$(".page.pageSettings").addClass("active");
});
Funbox.activate("none", null);
Settings.update();
TestConfig.hide();
SignOutButton.hide();
@ -176,6 +180,7 @@ export function changePage(page) {
SignOutButton.show();
}
);
Funbox.activate("none", null);
Account.update();
TestConfig.hide();
}
@ -190,6 +195,7 @@ export function changePage(page) {
history.pushState("login", null, "login");
$(".page.pageLogin").addClass("active");
});
Funbox.activate("none", null);
TestConfig.hide();
SignOutButton.hide();
}