From adb463333536de36944d0d3543250fc071c1c86c Mon Sep 17 00:00:00 2001 From: Jack Date: Tue, 11 Aug 2020 20:33:09 +0100 Subject: [PATCH] added funbox to the command line --- public/js/commandline.js | 38 ++++++++++++++++++++++++++++++++++++++ public/js/script.js | 8 ++++++++ 2 files changed, 46 insertions(+) diff --git a/public/js/commandline.js b/public/js/commandline.js index b2b26c791..851db87c0 100644 --- a/public/js/commandline.js +++ b/public/js/commandline.js @@ -237,6 +237,15 @@ let commands = { showCommandLine(); }, }, + { + id: "changeFunbox", + display: "Change funbox...", + subgroup: true, + exec: () => { + currentCommands.push(commandsFunbox); + showCommandLine(); + }, + }, { id: "changeLayout", display: "Change layout...", @@ -726,6 +735,35 @@ getFontsList().then((fonts) => { }); }); +let commandsFunbox = { + title: "Change funbox...", + list: [ + { + id: "changeFunboxNone", + display: "none", + exec: () => { + if (activateFunbox("none", null)) { + restartTest(); + } + }, + }, + ], +}; + +getFunboxList().then((funboxes) => { + funboxes.forEach((funbox) => { + commandsFunbox.list.push({ + id: "changeFunbox" + funbox.name, + display: funbox.name.replace(/_/g, " "), + exec: () => { + if (activateFunbox(funbox.name, funbox.type)) { + restartTest(); + } + }, + }); + }); +}); + let commandsThemes = { title: "Change theme...", list: [], diff --git a/public/js/script.js b/public/js/script.js index 92566941c..1bae61096 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -145,6 +145,13 @@ function copyResultToClipboard() { } function activateFunbox(funbox, mode) { + if (testActive || resultVisible) { + showNotification( + "You can only change the funbox before starting a test.", + 4000 + ); + return false; + } $("#funBoxTheme").attr("href", ``); if (funbox === "none") { activeFunBox = "none"; @@ -178,6 +185,7 @@ function activateFunbox(funbox, mode) { activeFunBox = funbox; } updateTestModesNotice(); + return true; } function toggleScriptFunbox(...params) {