2022-10-26 23:12:29 +02:00
|
|
|
document.querySelectorAll('body.users .ac_choice input[type=radio]')
|
|
|
|
.forEach(elt =>
|
|
|
|
elt.onchange = () => fetch(document.body.dataset.editUrl + '.choice', {
|
|
|
|
method: 'PUT',
|
|
|
|
body: new URLSearchParams(new FormData(elt.form))
|
|
|
|
})
|
2022-11-23 21:56:39 +01:00
|
|
|
.then(launchNotes)
|
2022-10-26 23:12:29 +02:00
|
|
|
.then(() => sleep(1))
|
2023-04-25 20:22:53 +02:00
|
|
|
.then(() => fetchResult())
|
2022-10-26 23:12:29 +02:00
|
|
|
.catch(error => console.error('Error sending answer', error)))
|
2023-04-25 20:22:53 +02:00
|
|
|
|
|
|
|
const fetchResult = () =>
|
|
|
|
fetch(document.body.dataset.editUrl + '.result')
|
|
|
|
.then(response => response.ok && response.text())
|
|
|
|
.then(result => result && window.location.assign('/users/' + window.location.pathname.split('/')[2] + result + '/'))
|
|
|
|
.then(() => sleep(1))
|
|
|
|
.then(() => fetchResult()) // Re-tries fetching result...
|
|
|
|
.catch(error => console.error('Error receiving result', error))
|