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.
51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
10 years ago
|
var ready = require('domready')
|
||
10 years ago
|
, check_email = require('valid-email')
|
||
10 years ago
|
|
||
|
process.nextTick(function() {
|
||
|
ready(function() {
|
||
|
|
||
10 years ago
|
var form = document.getElementById('signup-form')
|
||
|
, input_email = ''
|
||
10 years ago
|
, status_msg = document.getElementById('status-msg')
|
||
10 years ago
|
|
||
10 years ago
|
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")
|
||
10 years ago
|
.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) {
|
||
10 years ago
|
var progress = 0
|
||
|
, timerID = null
|
||
|
e.preventDefault()
|
||
10 years ago
|
status_msg.className = 'info'
|
||
10 years ago
|
status_msg.innerHTML = "Sending"
|
||
|
timerID = setInterval(function() {
|
||
|
if (++progress < 8) {
|
||
|
status_msg.innerHTML += "."
|
||
|
} else {
|
||
|
clearInterval(timerID)
|
||
|
form.submit()
|
||
|
}
|
||
|
}, 150)
|
||
10 years ago
|
} else {
|
||
10 years ago
|
e.preventDefault()
|
||
10 years ago
|
input_email.value = ''
|
||
10 years ago
|
status_msg.className = 'error'
|
||
|
status_msg.innerHTML = "that doesn't look like an email address,"
|
||
|
+ "<br />please try again..."
|
||
|
setTimeout(function() { status_msg.innerHTML = ' ' }, 2000)
|
||
10 years ago
|
}
|
||
10 years ago
|
}
|
||
|
}
|
||
|
})
|
||
10 years ago
|
})
|
||
|
})
|
||
|
|