showing peer selector on login, minor login improvements

This commit is contained in:
mrfry 2023-04-27 08:07:16 +02:00
parent 9220466561
commit 2ee9731fdf

View file

@ -198,6 +198,7 @@
donate: 'Donate', donate: 'Donate',
retry: 'Újra', retry: 'Újra',
invalidPW: 'Hibás jelszó: ', invalidPW: 'Hibás jelszó: ',
loggingIn: 'Belépés ...',
connecting: 'Csatlakozás: ', connecting: 'Csatlakozás: ',
connect: 'Csatlakozás', connect: 'Csatlakozás',
login: 'Belépés', login: 'Belépés',
@ -1653,6 +1654,9 @@
} }
function Auth(pw) { function Auth(pw) {
SafeGetElementById('infoMainDiv', (elem) => {
elem.innerText = texts.loggingIn
})
post('login', { pw: pw, script: true }).then((res) => { post('login', { pw: pw, script: true }).then((res) => {
if (res.result === 'success') { if (res.result === 'success') {
infoExpireTime = -1 infoExpireTime = -1
@ -1844,6 +1848,9 @@
SafeGetElementById('loginDiv', (elem) => { SafeGetElementById('loginDiv', (elem) => {
elem.style.display = 'flex' elem.style.display = 'flex'
}) })
SafeGetElementById('peerSelector', (elem) => {
elem.style.display = ''
})
} }
function addNewHost() { function addNewHost() {
@ -2734,6 +2741,36 @@
textAlign: 'center', textAlign: 'center',
}, },
}, },
loginContainer: {
id: 'loginDiv',
style: {
display: 'none',
},
children: {
loginInput: {
customElem: () => {
const loginInput = document.createElement('input')
loginInput.setAttribute('id', 'pwInput')
loginInput.type = 'text'
loginInput.placeholder = texts.pwHere
SetStyle(loginInput, {
width: '100%',
textAlign: 'center',
})
return loginInput
},
},
loginButton: {
innerText: texts.login,
style: buttonStyle,
onClick: () => {
SafeGetElementById('pwInput', (elem) => {
Auth(elem.value.trim())
})
},
},
},
},
peerSelector: { peerSelector: {
customElem: () => { customElem: () => {
try { try {
@ -2782,36 +2819,6 @@
} }
}, },
}, },
loginContainer: {
id: 'loginDiv',
style: {
display: 'none',
},
children: {
loginInput: {
customElem: () => {
const loginInput = document.createElement('input')
loginInput.setAttribute('id', 'pwInput')
loginInput.type = 'text'
loginInput.placeholder = texts.pwHere
SetStyle(loginInput, {
width: '100%',
textAlign: 'center',
})
return loginInput
},
},
loginButton: {
innerText: texts.login,
style: buttonStyle,
onClick: () => {
SafeGetElementById('pwInput', (elem) => {
Auth(elem.value)
})
},
},
},
},
hostInputContainer: { hostInputContainer: {
id: 'hostInputContainer', id: 'hostInputContainer',
style: { style: {