1
0
Fork 0
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/public/assets/js/email.js

543 lines
18 KiB
JavaScript

(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"/Users/jloi/code/Squatconf/website/node_modules/domready/ready.js":[function(require,module,exports){
/*!
* domready (c) Dustin Diaz 2014 - License MIT
*/
!function (name, definition) {
if (typeof module != 'undefined') module.exports = definition()
else if (typeof define == 'function' && typeof define.amd == 'object') define(definition)
else this[name] = definition()
}('domready', function () {
var fns = [], listener
, doc = document
, hack = doc.documentElement.doScroll
, domContentLoaded = 'DOMContentLoaded'
, loaded = (hack ? /^loaded|^c/ : /^loaded|^i|^c/).test(doc.readyState)
if (!loaded)
doc.addEventListener(domContentLoaded, listener = function () {
doc.removeEventListener(domContentLoaded, listener)
loaded = 1
while (listener = fns.shift()) listener()
})
return function (fn) {
loaded ? fn() : fns.push(fn)
}
});
},{}],"/Users/jloi/code/Squatconf/website/node_modules/load-svg/index.js":[function(require,module,exports){
var xhr = require('xhr');
module.exports = function (opts, cb) {
if (typeof opts === 'string') opts = { uri: opts };
xhr(opts, function (err, res, body) {
if (err) return cb(err);
if (!/^2/.test(res.statusCode)) {
return cb(new Error('http status code: ' + res.statusCode));
}
var div = document.createElement('div');
div.innerHTML = body;
var svg = div.querySelector('svg');
if (!svg) return cb(new Error('svg not present in resource'));
cb(null, svg);
});
};
},{"xhr":"/Users/jloi/code/Squatconf/website/node_modules/load-svg/node_modules/xhr/index.js"}],"/Users/jloi/code/Squatconf/website/node_modules/load-svg/node_modules/xhr/index.js":[function(require,module,exports){
var window = require("global/window")
var once = require("once")
var parseHeaders = require('parse-headers')
var messages = {
"0": "Internal XMLHttpRequest Error",
"4": "4xx Client Error",
"5": "5xx Server Error"
}
var XHR = window.XMLHttpRequest || noop
var XDR = "withCredentials" in (new XHR()) ? XHR : window.XDomainRequest
module.exports = createXHR
function createXHR(options, callback) {
if (typeof options === "string") {
options = { uri: options }
}
options = options || {}
callback = once(callback)
var xhr = options.xhr || null
if (!xhr) {
if (options.cors || options.useXDR) {
xhr = new XDR()
}else{
xhr = new XHR()
}
}
var uri = xhr.url = options.uri || options.url
var method = xhr.method = options.method || "GET"
var body = options.body || options.data
var headers = xhr.headers = options.headers || {}
var sync = !!options.sync
var isJson = false
var key
var load = options.response ? loadResponse : loadXhr
if ("json" in options) {
isJson = true
headers["Accept"] = "application/json"
if (method !== "GET" && method !== "HEAD") {
headers["Content-Type"] = "application/json"
body = JSON.stringify(options.json)
}
}
xhr.onreadystatechange = readystatechange
xhr.onload = load
xhr.onerror = error
// IE9 must have onprogress be set to a unique function.
xhr.onprogress = function () {
// IE must die
}
// hate IE
xhr.ontimeout = noop
xhr.open(method, uri, !sync)
//backward compatibility
if (options.withCredentials || (options.cors && options.withCredentials !== false)) {
xhr.withCredentials = true
}
// Cannot set timeout with sync request
if (!sync) {
xhr.timeout = "timeout" in options ? options.timeout : 5000
}
if (xhr.setRequestHeader) {
for(key in headers){
if(headers.hasOwnProperty(key)){
xhr.setRequestHeader(key, headers[key])
}
}
} else if (options.headers) {
throw new Error("Headers cannot be set on an XDomainRequest object")
}
if ("responseType" in options) {
xhr.responseType = options.responseType
}
if ("beforeSend" in options &&
typeof options.beforeSend === "function"
) {
options.beforeSend(xhr)
}
xhr.send(body)
return xhr
function readystatechange() {
if (xhr.readyState === 4) {
load()
}
}
function getBody() {
// Chrome with requestType=blob throws errors arround when even testing access to responseText
var body = null
if (xhr.response) {
body = xhr.response
} else if (xhr.responseType === 'text' || !xhr.responseType) {
body = xhr.responseText || xhr.responseXML
}
if (isJson) {
try {
body = JSON.parse(body)
} catch (e) {}
}
return body
}
function getStatusCode() {
return xhr.status === 1223 ? 204 : xhr.status
}
// if we're getting a none-ok statusCode, build & return an error
function errorFromStatusCode(status) {
var error = null
if (status === 0 || (status >= 400 && status < 600)) {
var message = (typeof body === "string" ? body : false) ||
messages[String(status).charAt(0)]
error = new Error(message)
error.statusCode = status
}
return error
}
// will load the data & process the response in a special response object
function loadResponse() {
var status = getStatusCode()
var error = errorFromStatusCode(status)
var response = {
body: getBody(),
statusCode: status,
statusText: xhr.statusText,
raw: xhr
}
if(xhr.getAllResponseHeaders){ //remember xhr can in fact be XDR for CORS in IE
response.headers = parseHeaders(xhr.getAllResponseHeaders())
} else {
response.headers = {}
}
callback(error, response, response.body)
}
// will load the data and add some response properties to the source xhr
// and then respond with that
function loadXhr() {
var status = getStatusCode()
var error = errorFromStatusCode(status)
xhr.status = xhr.statusCode = status
xhr.body = getBody()
xhr.headers = parseHeaders(xhr.getAllResponseHeaders())
callback(error, xhr, xhr.body)
}
function error(evt) {
callback(evt, xhr)
}
}
function noop() {}
},{"global/window":"/Users/jloi/code/Squatconf/website/node_modules/load-svg/node_modules/xhr/node_modules/global/window.js","once":"/Users/jloi/code/Squatconf/website/node_modules/load-svg/node_modules/xhr/node_modules/once/once.js","parse-headers":"/Users/jloi/code/Squatconf/website/node_modules/load-svg/node_modules/xhr/node_modules/parse-headers/parse-headers.js"}],"/Users/jloi/code/Squatconf/website/node_modules/load-svg/node_modules/xhr/node_modules/global/window.js":[function(require,module,exports){
(function (global){
if (typeof window !== "undefined") {
module.exports = window;
} else if (typeof global !== "undefined") {
module.exports = global;
} else {
module.exports = {};
}
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],"/Users/jloi/code/Squatconf/website/node_modules/load-svg/node_modules/xhr/node_modules/once/once.js":[function(require,module,exports){
module.exports = once
once.proto = once(function () {
Object.defineProperty(Function.prototype, 'once', {
value: function () {
return once(this)
},
configurable: true
})
})
function once (fn) {
var called = false
return function () {
if (called) return
called = true
return fn.apply(this, arguments)
}
}
},{}],"/Users/jloi/code/Squatconf/website/node_modules/load-svg/node_modules/xhr/node_modules/parse-headers/node_modules/for-each/index.js":[function(require,module,exports){
var isFunction = require('is-function')
module.exports = forEach
var toString = Object.prototype.toString
var hasOwnProperty = Object.prototype.hasOwnProperty
function forEach(list, iterator, context) {
if (!isFunction(iterator)) {
throw new TypeError('iterator must be a function')
}
if (arguments.length < 3) {
context = this
}
if (toString.call(list) === '[object Array]')
forEachArray(list, iterator, context)
else if (typeof list === 'string')
forEachString(list, iterator, context)
else
forEachObject(list, iterator, context)
}
function forEachArray(array, iterator, context) {
for (var i = 0, len = array.length; i < len; i++) {
if (hasOwnProperty.call(array, i)) {
iterator.call(context, array[i], i, array)
}
}
}
function forEachString(string, iterator, context) {
for (var i = 0, len = string.length; i < len; i++) {
// no such thing as a sparse string.
iterator.call(context, string.charAt(i), i, string)
}
}
function forEachObject(object, iterator, context) {
for (var k in object) {
if (hasOwnProperty.call(object, k)) {
iterator.call(context, object[k], k, object)
}
}
}
},{"is-function":"/Users/jloi/code/Squatconf/website/node_modules/load-svg/node_modules/xhr/node_modules/parse-headers/node_modules/for-each/node_modules/is-function/index.js"}],"/Users/jloi/code/Squatconf/website/node_modules/load-svg/node_modules/xhr/node_modules/parse-headers/node_modules/for-each/node_modules/is-function/index.js":[function(require,module,exports){
module.exports = isFunction
var toString = Object.prototype.toString
function isFunction (fn) {
var string = toString.call(fn)
return string === '[object Function]' ||
(typeof fn === 'function' && string !== '[object RegExp]') ||
(typeof window !== 'undefined' &&
// IE8 and below
(fn === window.setTimeout ||
fn === window.alert ||
fn === window.confirm ||
fn === window.prompt))
};
},{}],"/Users/jloi/code/Squatconf/website/node_modules/load-svg/node_modules/xhr/node_modules/parse-headers/node_modules/trim/index.js":[function(require,module,exports){
exports = module.exports = trim;
function trim(str){
return str.replace(/^\s*|\s*$/g, '');
}
exports.left = function(str){
return str.replace(/^\s*/, '');
};
exports.right = function(str){
return str.replace(/\s*$/, '');
};
},{}],"/Users/jloi/code/Squatconf/website/node_modules/load-svg/node_modules/xhr/node_modules/parse-headers/parse-headers.js":[function(require,module,exports){
var trim = require('trim')
, forEach = require('for-each')
, isArray = function(arg) {
return Object.prototype.toString.call(arg) === '[object Array]';
}
module.exports = function (headers) {
if (!headers)
return {}
var result = {}
forEach(
trim(headers).split('\n')
, function (row) {
var index = row.indexOf(':')
, key = trim(row.slice(0, index)).toLowerCase()
, value = trim(row.slice(index + 1))
if (typeof(result[key]) === 'undefined') {
result[key] = value
} else if (isArray(result[key])) {
result[key].push(value)
} else {
result[key] = [ result[key], value ]
}
}
)
return result
}
},{"for-each":"/Users/jloi/code/Squatconf/website/node_modules/load-svg/node_modules/xhr/node_modules/parse-headers/node_modules/for-each/index.js","trim":"/Users/jloi/code/Squatconf/website/node_modules/load-svg/node_modules/xhr/node_modules/parse-headers/node_modules/trim/index.js"}],"/Users/jloi/code/Squatconf/website/node_modules/valid-email/index.js":[function(require,module,exports){
module.exports = require('./lib/valid-email');
},{"./lib/valid-email":"/Users/jloi/code/Squatconf/website/node_modules/valid-email/lib/valid-email.js"}],"/Users/jloi/code/Squatconf/website/node_modules/valid-email/lib/valid-email.js":[function(require,module,exports){
/*!
* Valid Email
* Copyright(c) 2013 John Henry
* MIT Licensed
*/
/**
* Valid-Email:
*
* An alternative to using a regular expression to validate email.
* Inspired by:
* http://stackoverflow.com/questions/997078/email-regular-expression
* http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address
*
* Examples:
* console.log(require('valid-email')('john@iamjohnhenry.com'))//#true
* console.log(require('valid-email')('iamjohnhenry.com'))//#false
*
* @param {String} email
* // potential email address
* @return {Boolean}
* @api public
*/
module.exports = function valid(email){
var at = email.search("@");
if (at <0) return false;
var user = email.substr(0, at);
var domain = email.substr(at+1);
var userLen = user.length;
var domainLen = domain.length;
if (userLen < 1 || userLen > 64) return false;// user part length exceeded
if (domainLen < 1 || domainLen > 255) return false;// domain part length exceeded
if (user.charAt(0) === '.' || user.charAt(userLen-1) === '.') return false;// user part starts or ends with '.'
if (user.match(/\.\./)) return false;// user part has two consecutive dots
if (!domain.match(/^[A-Za-z0-9.-]+$/)) return false;// character not valid in domain part
if (domain.match( /\\.\\./)) return false;// domain part has two consecutive dots
if (!user.replace("\\\\","").match(/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/)) if (!user.replace("\\\\","").match(/^"(\\\\"|[^"])+"$/)) return false
return true;
}
},{}],"/Users/jloi/code/Squatconf/website/src/email-client.js":[function(require,module,exports){
(function (process){
var ready = require('domready')
, check_email = require('valid-email')
, loadsvg = require('load-svg')
process.nextTick(function() {
ready(function() {
var form = document.getElementById('signup-form')
, input_email = ''
, status_msg = document.getElementById('status-msg')
, logoCont = document.getElementById('logoCont')
loadsvg('/assets/img/squatconf_baguette.svg', function (err, svg) {
logoCont.appendChild(svg);
});
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)
}
}
}
})
})
})
}).call(this,require('_process'))
},{"_process":"/usr/local/lib/node_modules/watchify/node_modules/browserify/node_modules/process/browser.js","domready":"/Users/jloi/code/Squatconf/website/node_modules/domready/ready.js","load-svg":"/Users/jloi/code/Squatconf/website/node_modules/load-svg/index.js","valid-email":"/Users/jloi/code/Squatconf/website/node_modules/valid-email/index.js"}],"/usr/local/lib/node_modules/watchify/node_modules/browserify/node_modules/process/browser.js":[function(require,module,exports){
// shim for using process in browser
var process = module.exports = {};
process.nextTick = (function () {
var canSetImmediate = typeof window !== 'undefined'
&& window.setImmediate;
var canPost = typeof window !== 'undefined'
&& window.postMessage && window.addEventListener
;
if (canSetImmediate) {
return function (f) { return window.setImmediate(f) };
}
if (canPost) {
var queue = [];
window.addEventListener('message', function (ev) {
var source = ev.source;
if ((source === window || source === null) && ev.data === 'process-tick') {
ev.stopPropagation();
if (queue.length > 0) {
var fn = queue.shift();
fn();
}
}
}, true);
return function nextTick(fn) {
queue.push(fn);
window.postMessage('process-tick', '*');
};
}
return function nextTick(fn) {
setTimeout(fn, 0);
};
})();
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.binding = function (name) {
throw new Error('process.binding is not supported');
}
// TODO(shtylman)
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
},{}]},{},["/Users/jloi/code/Squatconf/website/src/email-client.js"]);