14 lines
579 B
JavaScript
14 lines
579 B
JavaScript
const resultUrl = '/users/' + window.location.pathname.split('/')[2]
|
|
|
|
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))
|
|
})
|
|
.then(() => sleep(1))
|
|
.then(() => fetch(document.body.dataset.editUrl + '.result'))
|
|
.then(response => response.text())
|
|
.then(result => window.location.assign(resultUrl + result))
|
|
.catch(error => console.error('Error sending answer', error)))
|