add custom server address

This commit is contained in:
Joe Dowd
2020-02-07 00:40:01 +00:00
parent feda7fd1a0
commit dd08ff1507
6 changed files with 70 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
import Config from "./config";
import * as CompileConfig from "../config.json";
import Utils from "./utils";
var utils = new Utils();
@@ -65,6 +66,23 @@ async function init() {
invidiousInstanceAddInit(<HTMLElement> optionsElements[i], textChangeOption);
}
break;
case "string-change":
let stringChangeOption = optionsElements[i].getAttribute("sync-option");
let stringInput = <HTMLInputElement> optionsElements[i].querySelector(".string-container").querySelector(".option-text-box");
let saveButton = <HTMLElement> optionsElements[i].querySelector(".option-button");
stringInput.value = Config.config[stringChangeOption];
// Devs can use config.json to set server address
if (stringChangeOption === "customServerAddress") {
stringInput.value = (Config.config.customServerAddress) ? Config.config.customServerAddress : CompileConfig.serverAddress;
}
saveButton.addEventListener("click", () => {
setStringConfigOption(stringInput.value, stringChangeOption);
});
break;
case "keybind-change":
let keybindButton = optionsElements[i].querySelector(".trigger-button");
@@ -80,6 +98,18 @@ async function init() {
optionsContainer.classList.add("animated");
}
/**
* Set the value in the string input the the defined config option
*
* @param element
* @param option
*/
function setStringConfigOption(value: string, option: string) {
console.log(value);
console.log(option);
Config.config[option] = value;
}
/**
* Called when the config is updated
*