You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Website/src/email-client.js

51 lines
1.6 KiB
JavaScript

var ready = require('domready')
, check_email = require('valid-email')
process.nextTick(function() {
ready(function() {
var form = document.getElementById('signup-form')
, input_email = ''
, status_msg = document.getElementById('status-msg')
for (var n = 0, l = form.childNodes[1].childNodes.length; n < l; n++) {
var el = form.childNodes[1].childNodes[n]
if (el.nodeName === 'INPUT' && el.name === 'email')
input_email = el
}
document
.getElementById("signup-form")
.addEventListener("click", function(e) {
if (e.srcElement.nodeName === 'BUTTON') {
if (input_email && input_email.value) {
var is_valid = check_email(input_email.value)
if (is_valid) {
var progress = 0
, timerID = null
e.preventDefault()
status_msg.className = 'info'
status_msg.innerHTML = "Sending"
timerID = setInterval(function() {
if (++progress < 8) {
status_msg.innerHTML += "."
} else {
clearInterval(timerID)
form.submit()
}
}, 150)
} else {
e.preventDefault()
input_email.value = ''
status_msg.className = 'error'
status_msg.innerHTML = "that doesn't look like an email address,"
+ "<br />please try again..."
setTimeout(function() { status_msg.innerHTML = '&nbsp;' }, 2000)
}
}
}
})
})
})