mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-11 00:03:44 +08:00
Changed command line input to auto fill with current url for changing custom background.
This commit is contained in:
parent
d3ec8de8ea
commit
f17e25a9f7
3 changed files with 11 additions and 3 deletions
|
@ -1599,6 +1599,7 @@ export let defaultCommands = {
|
|||
{
|
||||
id: "changeCustomBackground",
|
||||
display: "Change custom background...",
|
||||
defaultValue: "",
|
||||
input: true,
|
||||
exec: (input) => {
|
||||
UpdateConfig.setCustomBackground(input);
|
||||
|
|
|
@ -7,15 +7,18 @@ import * as TestUI from "./test-ui";
|
|||
|
||||
let commandLineMouseMode = false;
|
||||
|
||||
function showInput(command, placeholder) {
|
||||
function showInput(command, placeholder, defaultValue = "") {
|
||||
$("#commandLineWrapper").removeClass("hidden");
|
||||
$("#commandLine").addClass("hidden");
|
||||
$("#commandInput").removeClass("hidden");
|
||||
$("#commandInput input").attr("placeholder", placeholder);
|
||||
$("#commandInput input").val("");
|
||||
$("#commandInput input").val(defaultValue);
|
||||
$("#commandInput input").focus();
|
||||
$("#commandInput input").attr("command", "");
|
||||
$("#commandInput input").attr("command", command);
|
||||
if (defaultValue != ""){
|
||||
$("#commandInput input").select();
|
||||
}
|
||||
}
|
||||
|
||||
function showFound() {
|
||||
|
@ -142,7 +145,7 @@ function trigger(command) {
|
|||
if (obj.id == command) {
|
||||
if (obj.input) {
|
||||
input = true;
|
||||
showInput(obj.id, obj.display);
|
||||
showInput(obj.id, obj.display, obj.defaultValue);
|
||||
} else {
|
||||
obj.exec();
|
||||
if (obj.subgroup !== null && obj.subgroup !== undefined) {
|
||||
|
|
|
@ -15,6 +15,7 @@ import * as LanguagePicker from "./language-picker";
|
|||
import * as TestLogic from "./test-logic";
|
||||
import * as PaceCaret from "./pace-caret";
|
||||
import * as UI from "./ui";
|
||||
import * as CommandlineLists from "./commandline-lists";
|
||||
|
||||
export let cookieConfig = null;
|
||||
export let dbConfigLoaded = false;
|
||||
|
@ -1352,6 +1353,9 @@ export function setCustomBackground(value, nosave) {
|
|||
value = value.trim();
|
||||
if( /(https|http):\/\/(www\.|).+\..+\/.+(\.png|\.gif|\.jpeg|\.jpg)/gi.test(value) || value == ""){
|
||||
config.customBackground = value;
|
||||
CommandlineLists.defaultCommands.list.filter( (command) =>
|
||||
command.id == "changeCustomBackground"
|
||||
)[0].defaultValue = value;
|
||||
ThemeController.applyCustomBackground();
|
||||
if (!nosave) saveToCookie();
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue