diff options
Diffstat (limited to 'src/renderer/gameserver/serverView/preferences.ts')
-rw-r--r-- | src/renderer/gameserver/serverView/preferences.ts | 95 |
1 files changed, 51 insertions, 44 deletions
diff --git a/src/renderer/gameserver/serverView/preferences.ts b/src/renderer/gameserver/serverView/preferences.ts index 4697efe..b7a5255 100644 --- a/src/renderer/gameserver/serverView/preferences.ts +++ b/src/renderer/gameserver/serverView/preferences.ts @@ -2,58 +2,65 @@ import GameServerProfile from "../profile"; import { GameServerPage } from "./serverPage"; export class ServerPreferencesPage extends GameServerPage { + getPage(): HTMLElement { + const content = document.createElement("div"); + content.classList.add("preferencesServerPage"); - getPage(): HTMLElement { - const content = document.createElement('div'); - content.classList.add("preferencesServerPage"); + const title = document.createElement("h2"); + title.innerText = `Preferences for ${this.server.name}`; + content.appendChild(title); - const title = document.createElement('h2'); - title.innerText = `Preferences for ${this.server.name}`; - content.appendChild(title); + const loginSection = document.createElement("div"); + loginSection.classList.add("loginSection"); + content.appendChild(loginSection); - const loginSection = document.createElement('div'); - loginSection.classList.add("loginSection"); - content.appendChild(loginSection); + const loginUsernameLabel = document.createElement("label"); + loginUsernameLabel.innerText = "Username"; + const loginUsername = document.createElement("input") as HTMLInputElement; + loginUsername.value = localStorage.getItem( + "2_username_" + this.server.profile.address + ); + loginUsernameLabel.appendChild(loginUsername); - const loginUsernameLabel = document.createElement('label'); - loginUsernameLabel.innerText = "Username"; - const loginUsername = document.createElement('input') as HTMLInputElement; - loginUsername.value = localStorage.getItem("2_username_" + this.server.profile.address); - loginUsernameLabel.appendChild(loginUsername); + const loginPinLabel = document.createElement("label"); + loginPinLabel.innerText = "Password"; + const loginPin = document.createElement("input") as HTMLInputElement; + loginPin.type = "password"; + loginPin.value = localStorage.getItem( + "2_pin_" + this.server.profile.address + ); + loginPinLabel.appendChild(loginPin); - const loginPinLabel = document.createElement('label'); - loginPinLabel.innerText = "Password"; - const loginPin = document.createElement('input') as HTMLInputElement; - loginPin.type = "password"; - loginPin.value = localStorage.getItem("2_pin_" + this.server.profile.address); - loginPinLabel.appendChild(loginPin); + const saveBtn = document.createElement("button") as HTMLButtonElement; + saveBtn.innerText = "save"; - const saveBtn = document.createElement('button') as HTMLButtonElement; - saveBtn.innerText = "save"; + saveBtn.addEventListener("click", () => { + localStorage.setItem( + "2_username_" + this.server.profile.address, + loginUsername.value + ); + localStorage.setItem( + "2_pin_" + this.server.profile.address, + loginPin.value + ); + updateLoginTextElement(this.server.profile.address); + }); - saveBtn.addEventListener('click', () => { - localStorage.setItem("2_username_" + this.server.profile.address, loginUsername.value); - localStorage.setItem("2_pin_" + this.server.profile.address, loginPin.value); - updateLoginTextElement(this.server.profile.address); - }); - - - loginSection.appendChild(loginUsernameLabel); - loginSection.appendChild(loginPinLabel); - loginSection.appendChild(saveBtn); - - return content; - } + loginSection.appendChild(loginUsernameLabel); + loginSection.appendChild(loginPinLabel); + loginSection.appendChild(saveBtn); + return content; + } } export function updateLoginTextElement(serverAddress: string): void { - const account = localStorage.getItem("2_username_" + serverAddress); - const pin = localStorage.getItem("2_pin_" + serverAddress); - const element = document.getElementById('LoginText'); - if (account && pin) { - element.innerHTML = `Logged in as <b>${account}</b>`; - } else { - element.innerHTML = "Automatic login not set up"; - } -}
\ No newline at end of file + const account = localStorage.getItem("2_username_" + serverAddress); + const pin = localStorage.getItem("2_pin_" + serverAddress); + const element = document.getElementById("LoginText"); + if (account && pin) { + element.innerHTML = `Logged in as <b>${account}</b>`; + } else { + element.innerHTML = "Automatic login not set up"; + } +} |