bozza di checkLogin
This commit is contained in:
parent
fff408bd24
commit
d0b372bcef
1 changed files with 14 additions and 0 deletions
|
@ -1,3 +1,13 @@
|
|||
async function checkLogin() {
|
||||
let resp = await fetch('../whoami', {
|
||||
method: 'POST',
|
||||
})
|
||||
console.log('ok', resp)
|
||||
data = await resp.json()
|
||||
console.log('got', data)
|
||||
// try... catch?
|
||||
}
|
||||
|
||||
async function onGenerate(evt) {
|
||||
let resp = await fetch('../generate', {
|
||||
method: 'POST',
|
||||
|
@ -8,6 +18,7 @@ async function onGenerate(evt) {
|
|||
document.getElementById("generate-label").value = data.password
|
||||
document.getElementById("accept-btn").removeAttribute('disabled')
|
||||
}
|
||||
|
||||
async function onAccept(evt) {
|
||||
document.getElementById("generate-btn").setAttribute('disabled', 'disabled')
|
||||
let resp = await fetch('../change', {
|
||||
|
@ -25,11 +36,14 @@ async function onAccept(evt) {
|
|||
document.getElementById("accept-btn").setAttribute('disabled', 'disabled')
|
||||
}
|
||||
}
|
||||
|
||||
function initChange() {
|
||||
checkLogin()
|
||||
document.getElementById("generate-label").value = ""
|
||||
document.getElementById("accept-btn").setAttribute('disabled', 'disabled')
|
||||
document.getElementById("generate-btn").addEventListener('click', onGenerate, false)
|
||||
document.getElementById("accept-btn").addEventListener('click', onAccept, false)
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', initChange)
|
||||
|
||||
|
|
Loading…
Reference in a new issue