Replaced msg with alerts on clientside
parent
858f4dd564
commit
285e2b2345
|
@ -9,14 +9,11 @@
|
|||
|
||||
<p><button id="send-button" class="h-captcha" data-sitekey="<YOUR HCAPTCHA SITE KEY>" data-callback="sendClicked">Send</button></p>
|
||||
|
||||
<p id="msg"></p>
|
||||
|
||||
<p>This page is protected by <a href="https://www.hcaptcha.com/">hCaptcha</a> so its <a href="https://hcaptcha.com/privacy">Privacy Policy</a> and <a href="https://hcaptcha.com/terms">Terms of Service</a> apply.</p>
|
||||
|
||||
<script src="https://js.hcaptcha.com/1/api.js" async defer></script>
|
||||
<script src="/PATH/TO/LOCAL/COPY/OF/openpgp.min.js"></script>
|
||||
<script>/* global openpgp fetch */
|
||||
let msg = document.getElementById('msg')
|
||||
let send = document.getElementById('send-button')
|
||||
let name = document.getElementById('name-input')
|
||||
let email = document.getElementById('email-input')
|
||||
|
@ -28,7 +25,7 @@
|
|||
async function sendClicked (captchaToken) {
|
||||
if (captchaToken) {
|
||||
send.disabled = true
|
||||
msg.innerHTML = `Sending... `
|
||||
send.innerHTML = `Sending... `
|
||||
let res; try {
|
||||
res = await fetch(API_URL, {
|
||||
method: 'POST',
|
||||
|
@ -58,19 +55,19 @@ lk6lY0ktTb+vRnndyN3m+XW1mYdv3xUZMjQwMBtgdZbfY43pq8+N55tSTycF
|
|||
} catch (err) {
|
||||
send.disabled = false
|
||||
console.error(err)
|
||||
msg.innerHTML = `Failed to connect to the network. Are you online?`
|
||||
alert('Failed to connect to the network. Are you online?')
|
||||
}
|
||||
console.log(res.json())
|
||||
send.disabled = false
|
||||
|
||||
if (res.status===200) {
|
||||
text.value = ''; subj.value = ''; name.value = ''; email.value = ''
|
||||
msg.innerHTML = `Sent!`
|
||||
alert(Sent!')
|
||||
} else if (res.status===403)
|
||||
msg.innerHTML = `hCaptcha failed! Please try again.`
|
||||
alert('hCaptcha failed! Please try again.')
|
||||
else if (res.status===500)
|
||||
msg.innerHTML = `Backend failed! Please try again. If the problem persists, please email hostmaster@[this domain].`
|
||||
else msg.innerHTML = `Unknown error! Please try again. If the problem persists, please email hostmaster@[this domain].`
|
||||
alert('Backend failed! Please try again. If the problem persists, please email hostmaster@[this domain].')
|
||||
else alert('Unknown error! Please try again. If the problem persists, please email hostmaster@[this domain].')
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue