mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-22 00:06:16 +08:00
Cleaned up code, made it *slightly* more efficient
This commit is contained in:
parent
4942cf5107
commit
fbf68a3c13
|
@ -143,7 +143,7 @@ Misc.getFunboxList().then((funboxes) => {
|
|||
id: "changeFunbox" + funbox.name,
|
||||
display: funbox.name.replace(/_/g, " "),
|
||||
exec: () => {
|
||||
if (Funbox.setFunbox(funbox.name)) {
|
||||
if (Funbox.setFunbox(funbox.name, funbox.type)) {
|
||||
TestLogic.restart();
|
||||
}
|
||||
},
|
||||
|
|
|
@ -695,7 +695,8 @@ $(".pageSettings .section.discordIntegration #unlinkDiscordButton").click(
|
|||
//funbox
|
||||
$(document).on("click", ".pageSettings .section.funbox .button", (e) => {
|
||||
let funbox = $(e.currentTarget).attr("funbox");
|
||||
Funbox.setFunbox(funbox);
|
||||
let type = $(e.currentTarget).attr("type");
|
||||
Funbox.setFunbox(funbox, type);
|
||||
setActiveFunboxButton();
|
||||
});
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import * as ManualRestart from "./manual-restart-tracker";
|
|||
import Config, * as UpdateConfig from "./config";
|
||||
import * as Settings from "./settings";
|
||||
|
||||
export let active = "none";
|
||||
let modeSaved = null;
|
||||
let memoryTimer = null;
|
||||
let memoryInterval = null;
|
||||
|
||||
|
@ -74,13 +74,13 @@ export function startMemoryTimer() {
|
|||
}
|
||||
|
||||
export function reset() {
|
||||
active = "none";
|
||||
resetMemoryTimer();
|
||||
}
|
||||
|
||||
export function toggleScript(...params) {
|
||||
if (active === "tts") {
|
||||
if (Config.funbox === "tts") {
|
||||
var msg = new SpeechSynthesisUtterance();
|
||||
console.log("Speaking");
|
||||
msg.text = params[0];
|
||||
msg.lang = "en-US";
|
||||
window.speechSynthesis.cancel();
|
||||
|
@ -88,7 +88,9 @@ export function toggleScript(...params) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function activate(funbox, mode) {
|
||||
export async function activate(funbox) {
|
||||
let mode = modeSaved;
|
||||
|
||||
if (funbox === undefined || funbox === null) {
|
||||
funbox = Config.funbox;
|
||||
}
|
||||
|
@ -122,10 +124,8 @@ export async function activate(funbox, mode) {
|
|||
|
||||
ManualRestart.set();
|
||||
if (mode === "style") {
|
||||
if (funbox != undefined) {
|
||||
if (funbox != undefined)
|
||||
$("#funBoxTheme").attr("href", `funbox/${funbox}.css`);
|
||||
active = funbox;
|
||||
}
|
||||
|
||||
if (funbox === "simon_says") {
|
||||
rememberSetting(
|
||||
|
@ -229,8 +229,9 @@ export async function activate(funbox, mode) {
|
|||
TestUI.updateModesNotice();
|
||||
return true;
|
||||
}
|
||||
export function setFunbox(funbox) {
|
||||
export function setFunbox(funbox, mode) {
|
||||
if (funbox === "none") loadMemory();
|
||||
modeSaved = mode;
|
||||
UpdateConfig.setFunbox(funbox);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue