Merge pull request #1178 from Smithster/master

command line input autofill
This commit is contained in:
Jack 2021-04-04 22:10:43 +01:00 committed by GitHub
commit db950750c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View file

@ -1599,6 +1599,7 @@ export let defaultCommands = {
{
id: "changeCustomBackground",
display: "Change custom background...",
defaultValue: "",
input: true,
exec: (input) => {
UpdateConfig.setCustomBackground(input);

View file

@ -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) {

View file

@ -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;
@ -1361,6 +1362,9 @@ export function setCustomBackground(value, nosave) {
value == ""
) {
config.customBackground = value;
CommandlineLists.defaultCommands.list.filter( (command) =>
command.id == "changeCustomBackground"
)[0].defaultValue = value;
ThemeController.applyCustomBackground();
if (!nosave) saveToCookie();
} else {