Rename string change option to more fitting name.

This commit is contained in:
Ajay Ramachandran
2020-02-08 21:42:15 -05:00
parent cfe91f6280
commit be6cd62fbe
3 changed files with 28 additions and 35 deletions

View File

@@ -76,7 +76,7 @@ body {
color: white;
}
.string-container {
.text-label-container {
font-size: 14px;
color: white;
}

View File

@@ -248,7 +248,7 @@
<br/>
<br/>
<div option-type="text-change" sync-option="userID" confirm-message="userIDChangeWarning">
<div option-type="private-text-change" sync-option="userID" confirm-message="userIDChangeWarning">
<div class="option-button trigger-button">
__MSG_changeUserID__
</div>
@@ -274,12 +274,14 @@
<br/>
<br/>
<div option-type="string-change" sync-option="serverAddress">
<label class="string-container">
<div option-type="text-change" sync-option="serverAddress">
<label class="text-label-container">
<div>__MSG_customServerAddress__</div>
<input class="option-text-box" type="text">
</label>
<div class="option-button custom-server-address-button inline">
<div class="option-button text-change-set inline">
__MSG_saveCustomServerAddress__
</div>

View File

@@ -55,27 +55,28 @@ async function init() {
});
break;
case "text-change":
let button = optionsElements[i].querySelector(".trigger-button");
button.addEventListener("click", () => activateTextChange(<HTMLElement> optionsElements[i]));
let textChangeOption = optionsElements[i].getAttribute("sync-option");
// See if anything extra must be done
switch (textChangeOption) {
case "invidiousInstances":
invidiousInstanceAddInit(<HTMLElement> optionsElements[i], textChangeOption);
}
let textInput = <HTMLInputElement> optionsElements[i].querySelector(".option-text-box");
let setButton = <HTMLElement> optionsElements[i].querySelector(".text-change-set");
textInput.value = Config.config[textChangeOption];
setButton.addEventListener("click", () => {
Config.config[textChangeOption] = textInput.value;
});
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");
case "private-text-change":
let button = optionsElements[i].querySelector(".trigger-button");
button.addEventListener("click", () => activatePrivateTextChange(<HTMLElement> optionsElements[i]));
stringInput.value = Config.config[stringChangeOption];
saveButton.addEventListener("click", () => {
setStringConfigOption(stringInput.value, stringChangeOption);
});
let privateTextChangeOption = optionsElements[i].getAttribute("sync-option");
// See if anything extra must be done
switch (privateTextChangeOption) {
case "invidiousInstances":
invidiousInstanceAddInit(<HTMLElement> optionsElements[i], privateTextChangeOption);
}
break;
case "keybind-change":
@@ -110,16 +111,6 @@ 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) {
Config.config[option] = value;
}
/**
* Called when the config is updated
*
@@ -305,7 +296,7 @@ function keybindKeyPressed(element: HTMLElement, e: KeyboardEvent) {
*
* @param element
*/
function activateTextChange(element: HTMLElement) {
function activatePrivateTextChange(element: HTMLElement) {
let button = element.querySelector(".trigger-button");
if (button.classList.contains("disabled")) return;