Update unlock page

This commit is contained in:
Alan Grainger
2024-11-01 12:18:13 +01:00
parent 356d9280d4
commit 77f8225c2f
3 changed files with 22 additions and 15 deletions
+11 -12
View File
@@ -41,20 +41,19 @@
</main>
<script src="/web.js"></script>
<script>
function submitForm (formElement) {
async function submitForm (formElement) {
const formData = new FormData(formElement)
fetch('/unlock', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(Object.fromEntries(formData.entries()))
})
.then(response => response.text())
.then(html => {
document.documentElement.innerHTML = html
initLightGallery() // from web.js
try {
const res = await fetch('/unlock', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(Object.fromEntries(formData.entries()))
})
.catch(error => console.error('Error:', error))
if (res.status === 200) {
document.documentElement.innerHTML = await res.text()
initLightGallery() // from web.js
}
} catch (e) { }
}
document.getElementById('unlock')