Created
October 7, 2018 22:09
-
-
Save mplewis/fbff4306cbe2d78cc61842a744783af6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @license | |
REI-Gearmail 0.1.0 2013-06-03 14:10 */ | |
'use strict'; | |
if ("undefined" == typeof console) { | |
window.console = { | |
log : function() { | |
}, | |
error : function() { | |
} | |
}; | |
} | |
var BrowserDetect = { | |
init : function() { | |
this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; | |
this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version"; | |
this.OS = this.searchString(this.dataOS) || "an unknown OS"; | |
}, | |
searchString : function(a) { | |
/** @type {number} */ | |
var i = 0; | |
for (; a.length > i; i++) { | |
var dataString = a[i].string; | |
var allProps = a[i].prop; | |
if (this.versionSearchString = a[i].versionSearch || a[i].identity, dataString) { | |
if (-1 != dataString.indexOf(a[i].subString)) { | |
return a[i].identity; | |
} | |
} else { | |
if (allProps) { | |
return a[i].identity; | |
} | |
} | |
} | |
}, | |
searchVersion : function(a) { | |
var index = a.indexOf(this.versionSearchString); | |
if (-1 != index) { | |
return parseFloat(a.substring(index + this.versionSearchString.length + 1)); | |
} | |
}, | |
dataBrowser : [{ | |
string : navigator.userAgent, | |
subString : "Chrome", | |
identity : "Chrome" | |
}, { | |
string : navigator.userAgent, | |
subString : "OmniWeb", | |
versionSearch : "OmniWeb/", | |
identity : "OmniWeb" | |
}, { | |
string : navigator.vendor, | |
subString : "Apple", | |
identity : "Safari", | |
versionSearch : "Version" | |
}, { | |
prop : window.opera, | |
identity : "Opera", | |
versionSearch : "Version" | |
}, { | |
string : navigator.vendor, | |
subString : "iCab", | |
identity : "iCab" | |
}, { | |
string : navigator.vendor, | |
subString : "KDE", | |
identity : "Konqueror" | |
}, { | |
string : navigator.userAgent, | |
subString : "Firefox", | |
identity : "Firefox" | |
}, { | |
string : navigator.vendor, | |
subString : "Camino", | |
identity : "Camino" | |
}, { | |
string : navigator.userAgent, | |
subString : "Netscape", | |
identity : "Netscape" | |
}, { | |
string : navigator.userAgent, | |
subString : "MSIE", | |
identity : "Explorer", | |
versionSearch : "MSIE" | |
}, { | |
string : navigator.userAgent, | |
subString : "Gecko", | |
identity : "Mozilla", | |
versionSearch : "rv" | |
}, { | |
string : navigator.userAgent, | |
subString : "Mozilla", | |
identity : "Netscape", | |
versionSearch : "Mozilla" | |
}], | |
dataOS : [{ | |
string : navigator.platform, | |
subString : "Win", | |
identity : "Windows" | |
}, { | |
string : navigator.platform, | |
subString : "Mac", | |
identity : "Mac" | |
}, { | |
string : navigator.userAgent, | |
subString : "iPhone", | |
identity : "iPhone/iPod" | |
}, { | |
string : navigator.platform, | |
subString : "Linux", | |
identity : "Linux" | |
}] | |
}; | |
if (BrowserDetect.init(), window.normalizeScroll = function() { | |
var doc = window.document; | |
if (!location.hash && window.addEventListener) { | |
window.scrollTo(0, 1); | |
/** @type {number} */ | |
var dimensions = 1; | |
/** | |
* @return {?} | |
*/ | |
var getViewport = function() { | |
return window.pageYOffset || "CSS1Compat" === doc.compatMode && doc.documentElement.scrollTop || doc.body.scrollTop || 0; | |
}; | |
/** @type {number} */ | |
var chat_retry = setInterval(function() { | |
if (doc.body) { | |
clearInterval(chat_retry); | |
dimensions = getViewport(); | |
window.scrollTo(0, 1 === dimensions ? 0 : 1); | |
} | |
}, 15); | |
window.addEventListener("load", function() { | |
setTimeout(function() { | |
if (20 > getViewport()) { | |
window.scrollTo(0, 1 === dimensions ? 0 : 1); | |
} | |
}, 0); | |
}, false); | |
} | |
}, function(w) { | |
/** | |
* @return {undefined} | |
*/ | |
function restoreZoom() { | |
content.setAttribute("content", c); | |
/** @type {boolean} */ | |
m = true; | |
} | |
/** | |
* @return {undefined} | |
*/ | |
function disableZoom() { | |
content.setAttribute("content", length); | |
/** @type {boolean} */ | |
m = false; | |
} | |
/** | |
* @param {?} e | |
* @return {undefined} | |
*/ | |
function checkTilt(e) { | |
aig = e.accelerationIncludingGravity; | |
/** @type {number} */ | |
n = Math.abs(aig.x); | |
/** @type {number} */ | |
videoBottom = Math.abs(aig.y); | |
/** @type {number} */ | |
videoTop = Math.abs(aig.z); | |
if (w.orientation && 180 !== w.orientation || !(n > 7 || (videoTop > 6 && 8 > videoBottom || 8 > videoTop && videoBottom > 6) && n > 5)) { | |
if (!m) { | |
restoreZoom(); | |
} | |
} else { | |
if (m) { | |
disableZoom(); | |
} | |
} | |
} | |
/** @type {string} */ | |
var ua = navigator.userAgent; | |
if (/iPhone|iPad|iPod/.test(navigator.platform) && /OS [1-5]_[0-9_]* like Mac OS X/i.test(ua) && ua.indexOf("AppleWebKit") > -1) { | |
/** @type {!HTMLDocument} */ | |
var doc = w.document; | |
if (doc.querySelector) { | |
var n; | |
var videoBottom; | |
var videoTop; | |
var aig; | |
/** @type {(Element|null)} */ | |
var content = doc.querySelector("meta[name=viewport]"); | |
/** @type {(null|string)} */ | |
var index = content && content.getAttribute("content"); | |
/** @type {string} */ | |
var length = index + ",maximum-scale=1"; | |
/** @type {string} */ | |
var c = index + ",maximum-scale=10"; | |
/** @type {boolean} */ | |
var m = true; | |
if (content) { | |
w.addEventListener("orientationchange", restoreZoom, false); | |
w.addEventListener("devicemotion", checkTilt, false); | |
} | |
} | |
} | |
}(this), window.PRIS !== void 0) { | |
throw 'Global variable "PRIS" already in use.'; | |
} | |
window.PRIS = function() { | |
/** | |
* @return {undefined} | |
*/ | |
function remove() { | |
var i; | |
/** @type {string} */ | |
var destination = "/"; | |
for (i in data) { | |
/** @type {string} */ | |
destination = destination + (i + "/" + data[i] + "/"); | |
} | |
/** @type {string} */ | |
location.hash = destination; | |
} | |
/** | |
* @return {undefined} | |
*/ | |
function set() { | |
if (location.hash.length) { | |
var i; | |
var length; | |
/** @type {string} */ | |
var a = window.location.hash; | |
if ("/" === a[a.length - 1]) { | |
/** @type {string} */ | |
a = a.slice(0, -1); | |
} | |
/** @type {!Array<string>} */ | |
a = a.split("/"); | |
/** @type {!Array<string>} */ | |
a = a.slice(1); | |
data = {}; | |
/** @type {number} */ | |
i = 0; | |
/** @type {number} */ | |
length = a.length; | |
for (; length > i; i = i + 2) { | |
/** @type {(boolean|number|string)} */ | |
data[a[i]] = isNaN(parseInt(a[i + 1], 10)) ? "true" === a[i + 1] || "false" === a[i + 1] ? "true" === a[i + 1] ? true : false : a[i + 1] : parseInt(a[i + 1], 10); | |
} | |
} | |
num_to_grab.databaseUpdated(); | |
} | |
/** | |
* @param {?} k | |
* @param {?} r | |
* @return {undefined} | |
*/ | |
function r(k, r) { | |
data[k] = r; | |
remove(); | |
} | |
/** | |
* @param {string} property | |
* @return {?} | |
*/ | |
function commonGetHandler(property) { | |
return data[property]; | |
} | |
/** | |
* @param {?} action | |
* @return {undefined} | |
*/ | |
function cb(action) { | |
delete data[action]; | |
remove(); | |
} | |
/** | |
* @param {!Object} handle | |
* @param {string} store | |
* @return {undefined} | |
*/ | |
function bind(handle, store) { | |
callbacks.push({ | |
callback : handle, | |
scope : store | |
}); | |
} | |
/** | |
* @return {undefined} | |
*/ | |
function unbindAll() { | |
/** @type {!Array} */ | |
callbacks = []; | |
} | |
/** | |
* @return {undefined} | |
*/ | |
function breakpointComplete() { | |
var i; | |
var l; | |
if (callbacks.length) { | |
/** @type {number} */ | |
i = 0; | |
l = callbacks.length; | |
for (; l > i; i++) { | |
callbacks[i].callback.call(callbacks[i].scope, data); | |
} | |
} | |
} | |
/** | |
* @return {undefined} | |
*/ | |
function options() { | |
/** @type {string} */ | |
location.hash = ""; | |
data = {}; | |
} | |
var num_to_grab; | |
var data = {}; | |
/** @type {!Array} */ | |
var callbacks = []; | |
/** @type {string} */ | |
var hash = window.location.hash; | |
return num_to_grab = { | |
databaseUpdated : function() { | |
breakpointComplete(); | |
} | |
}, set(), "object" == typeof window.onhashchange && "function" == typeof window.addEventListener ? window.addEventListener("hashchange", function() { | |
set(); | |
}) : setInterval(function() { | |
if (hash !== window.location.hash) { | |
set(); | |
} | |
/** @type {string} */ | |
hash = window.location.hash; | |
}, 100), { | |
set : r, | |
get : commonGetHandler, | |
remove : cb, | |
bind : bind, | |
unbindAll : unbindAll, | |
empty : options, | |
serializeHash : set | |
}; | |
}(); | |
REI = window.REI || {}, REI.Form = function(settings) { | |
var defaultOptions; | |
var self = this; | |
self.events.parent = self; | |
self.callbacks = {}; | |
defaultOptions = {}; | |
$.extend(defaultOptions, settings); | |
self.options = defaultOptions; | |
self.$component = $(REI.templates.form()); | |
self.inputs = {}; | |
self.inputs.$firstName = self.$component.find(".id-first"); | |
self.inputs.$lastName = self.$component.find(".id-last"); | |
self.inputs.$email = self.$component.find(".id-email"); | |
self.inputs.$phone = self.$component.find(".id-phone"); | |
self.inputs.$memberNumber = self.$component.find(".id-member"); | |
self.$submit = self.$component.find("button"); | |
self.$feedback = self.$component.filter(".feedback"); | |
self.$spinner = self.$component.find(".spinner"); | |
self.formValues = {}; | |
/** @type {boolean} */ | |
self.feedbackVisible = false; | |
if (!Modernizr.input.placeholder) { | |
self.polyfillPlaceholders(); | |
} | |
self.$submit.on("click", function() { | |
self.submitForm(); | |
}); | |
self.inputs.$memberNumber.on("keypress", function(event) { | |
if (13 === event.charCode) { | |
self.submitForm(); | |
} else { | |
if (0 === event.charCode) { | |
return; | |
} | |
if (!(event.charCode >= 48 && 58 >= event.charCode)) { | |
event.preventDefault(); | |
} | |
} | |
}); | |
self.$component.find("input").on("blur", function() { | |
if ($(this).val()) { | |
$(this).removeClass("missing"); | |
} | |
}); | |
}, REI.Form.prototype = { | |
events : { | |
validated : function(callback) { | |
var self = this.parent; | |
self.runCallbacks("validated", callback); | |
}, | |
validationFail : function(objectType) { | |
var self = this.parent; | |
self.$spinner.removeClass("on"); | |
self.showFeedback("We're not getting a match. Double check the info you provided."); | |
self.runCallbacks("validationFail", objectType); | |
} | |
}, | |
submitForm : function() { | |
var i; | |
var $scope = this; | |
if ($scope.validateFilled()) { | |
$scope.getInputValues(); | |
$scope.validateWithService(); | |
if ($scope.feedbackVisible) { | |
$scope.hideFeedback(); | |
} | |
for (i in $scope.inputs) { | |
$scope.inputs[i].removeClass("missing"); | |
} | |
} else { | |
$scope.showFeedback("Make sure the required fields have been filled out"); | |
for (i in $scope.inputs) { | |
if ($scope.inputs[i].val()) { | |
$scope.inputs[i].removeClass("missing"); | |
} else { | |
$scope.inputs[i].addClass("missing"); | |
} | |
} | |
} | |
}, | |
showFeedback : function(num) { | |
var that = this; | |
window.normalizeScroll(); | |
that.$feedback.find("p").text(num); | |
that.$feedback.addClass("on"); | |
/** @type {boolean} */ | |
that.feedbackVisible = true; | |
}, | |
hideFeedback : function() { | |
var that = this; | |
that.$feedback.removeClass("on"); | |
/** @type {boolean} */ | |
that.feedbackVisible = false; | |
}, | |
validateFilled : function() { | |
var name; | |
var object; | |
var blipnode = this; | |
/** @type {boolean} */ | |
var r = true; | |
object = { | |
firstName : blipnode.inputs.$firstName, | |
lastName : blipnode.inputs.$lastName | |
}; | |
for (name in object) { | |
if (!object[name].val()) { | |
/** @type {boolean} */ | |
r = false; | |
} | |
} | |
return blipnode.inputs.$email.val() || blipnode.inputs.$memberNumber.val() || (r = false), blipnode.inputs.$phone.val() || blipnode.inputs.$memberNumber.val() || (r = false), r; | |
}, | |
getInputValues : function() { | |
var name; | |
var current = this; | |
for (name in current.inputs) { | |
current.formValues[name.slice(1)] = current.inputs[name].val().trim(); | |
} | |
}, | |
validateWithService : function() { | |
var portalSelfUrl; | |
var self = this; | |
window.normalizeScroll(); | |
self.$spinner.addClass("on"); | |
if (self.formValues.phone) { | |
/** @type {string} */ | |
portalSelfUrl = "https://www.rei.com/rest/member.json?"; | |
/** @type {string} */ | |
portalSelfUrl = portalSelfUrl + ("firstName=" + encodeURIComponent(self.formValues.firstName)); | |
/** @type {string} */ | |
portalSelfUrl = portalSelfUrl + ("&lastName=" + encodeURIComponent(self.formValues.lastName)); | |
/** @type {string} */ | |
portalSelfUrl = portalSelfUrl + ("&email=" + encodeURIComponent(self.formValues.email)); | |
/** @type {string} */ | |
portalSelfUrl = portalSelfUrl + ("&phone=" + self.formValues.phone); | |
} else { | |
/** @type {string} */ | |
portalSelfUrl = "https://www.rei.com/rest/member/dividend.json?"; | |
/** @type {string} */ | |
portalSelfUrl = portalSelfUrl + ("firstName=" + encodeURIComponent(self.formValues.firstName)); | |
/** @type {string} */ | |
portalSelfUrl = portalSelfUrl + ("&lastName=" + encodeURIComponent(self.formValues.lastName)); | |
/** @type {string} */ | |
portalSelfUrl = portalSelfUrl + ("&memberNumber=" + self.formValues.memberNumber); | |
} | |
$.ajax({ | |
url : "http://rei-passbook.herokuapp.com/jsonp", | |
type : "GET", | |
dataType : "jsonp", | |
data : { | |
url : portalSelfUrl | |
}, | |
complete : function() { | |
console.log("complete"); | |
}, | |
success : function(e) { | |
console.log("success"); | |
console.log(e); | |
if (e.success) { | |
self.events.validated({ | |
memberName : (self.formValues.firstName + "+" + self.formValues.lastName).toLowerCase(), | |
memberNumber : e.memberNumber | |
}); | |
} else { | |
self.events.validationFail({}); | |
} | |
}, | |
error : function(e, a, f) { | |
console.log("error", e, a, f); | |
} | |
}); | |
}, | |
getPass : function(name, cb) { | |
/** @type {string} */ | |
var url = "http://rei-passbook.herokuapp.com/v1/membercard"; | |
/** @type {string} */ | |
url = url + ("?rei_member_name=" + encodeURI(name) + "&rei_member_number=" + cb); | |
location.replace(url); | |
}, | |
polyfillPlaceholders : function() { | |
var model = this; | |
console.log("polyfillPlaceholders"); | |
model.$component.find("input").each(function() { | |
var $search = $(this); | |
var placeholder = $search.attr("placeholder"); | |
$search.val(placeholder); | |
$search.on("focus", function() { | |
if ($search.val() === placeholder) { | |
$search.val(""); | |
} | |
}); | |
$search.on("blur", function() { | |
if ("" === $search.val()) { | |
$search.val(placeholder); | |
} | |
}); | |
}); | |
}, | |
bind : function(eventName, callback, method) { | |
var Event = this; | |
if (Event.callbacks[eventName] === void 0) { | |
/** @type {!Array} */ | |
Event.callbacks[eventName] = []; | |
} | |
Event.callbacks[eventName].push({ | |
callback : callback, | |
scope : method | |
}); | |
}, | |
unbind : function(key) { | |
var angular = this; | |
/** @type {!Array} */ | |
angular.callbacks[key] = []; | |
}, | |
runCallbacks : function(type, options) { | |
var i; | |
var countRep; | |
var t = this; | |
if (t.callbacks[type] !== void 0) { | |
/** @type {number} */ | |
i = 0; | |
countRep = t.callbacks[type].length; | |
for (; countRep > i; i++) { | |
t.callbacks[type][i].callback.call(t.callbacks[type][i].scope || t, options); | |
} | |
} | |
} | |
}, REI = window.REI || {}, REI.main = { | |
debug : { | |
debugOn : false, | |
noBlacklist : true | |
}, | |
config : { | |
iosApps : { | |
platform : "ios", | |
appURL : "https://itunes.apple.com/us/app/rei/id404849387?mt=8", | |
snowReportURL : "https://itunes.apple.com/us/app/rei-snow-report/id473215841?mt=8" | |
}, | |
androidApps : { | |
platform : "android", | |
appURL : "https://market.android.com/details?id=com.ubermind.rei", | |
snowReportURL : "https://market.android.com/details?id=com.rei.snowreport" | |
} | |
}, | |
init : function() { | |
var opts = this; | |
if (PRIS.get("debug") === true) { | |
/** @type {boolean} */ | |
opts.debug.debugOn = true; | |
} | |
REI.controllers = { | |
form : new REI.Form | |
}; | |
REI.views = { | |
form : { | |
$view : REI.controllers.form.$component, | |
title : "REI - Membership Confirmation" | |
}, | |
thankYou : { | |
$view : $(REI.templates.thankyou(opts.config.iosApps)), | |
title : "REI - All Done" | |
}, | |
sorryAndroid : { | |
$view : $(REI.templates["sorry-android"](opts.config.androidApps)), | |
title : "REI - Sorry" | |
}, | |
sorryIOS : { | |
$view : $(REI.templates["sorry-ios5"](opts.config.iosApps)), | |
title : "REI - Sorry" | |
}, | |
sorryOSX : { | |
$view : $(REI.templates["sorry-osx"](opts.config.iosApps)), | |
title : "REI - Sorry" | |
}, | |
sorryWP : { | |
$view : $(REI.templates["sorry-wp"]()), | |
title : "REI - Sorry" | |
} | |
}; | |
opts.filterClients(); | |
REI.controllers.form.bind("validated", function(expression) { | |
opts.showView("thankYou"); | |
REI.controllers.form.getPass(expression.memberName, expression.memberNumber); | |
}, opts); | |
}, | |
filterClients : function() { | |
/** | |
* @return {?} | |
*/ | |
function iOSversion() { | |
/** @type {(Array<string>|null)} */ | |
var sArrDayId = navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/); | |
return [parseInt(sArrDayId[1], 10), parseInt(sArrDayId[2], 10), parseInt(sArrDayId[3] || 0, 10)]; | |
} | |
var wait; | |
var node = this; | |
if (node.debug.debugOn && node.debug.noBlacklist) { | |
node.showView("form"); | |
} else { | |
if (navigator.userAgent.match("iPhone") || navigator.userAgent.match("iPad")) { | |
if (iOSversion()[0] >= 6 && navigator.userAgent.match("iPhone")) { | |
node.showView("form"); | |
} else { | |
node.showView("sorryIOS"); | |
node.logVisitorInfo("iOS5 or iPad"); | |
} | |
} else { | |
if (navigator.userAgent.match("Macintosh")) { | |
/** @type {number} */ | |
wait = parseInt(navigator.userAgent.match(/OS X 10.[0-9]/)[0].slice(-1), 10); | |
if (wait >= 8) { | |
node.showView("form"); | |
} else { | |
node.showView("sorryOSX"); | |
node.logVisitorInfo("OSX 10." + wait); | |
} | |
} else { | |
if (navigator.userAgent.match("Android")) { | |
node.showView("sorryAndroid"); | |
node.logVisitorInfo("Android"); | |
} else { | |
node.showView("sorryWP"); | |
node.logVisitorInfo("Other"); | |
setTimeout(function() { | |
location.replace("http://rei.com"); | |
}, 1E4); | |
} | |
} | |
} | |
} | |
}, | |
showView : function(name) { | |
if (REI.views[name]) { | |
window.normalizeScroll(); | |
$("body").empty().append(REI.views[name].$view); | |
$("body").attr("class", name); | |
$("title").text(REI.views[name].title); | |
} else { | |
console.error("Undefined view."); | |
} | |
}, | |
logVisitorInfo : function(name) { | |
$.ajax({ | |
url : "http://rei-passbook.herokuapp.com/gearmail_visitors", | |
type : "GET", | |
dataType : "jsonp", | |
data : { | |
operating_system : name, | |
email : PRIS.get("email") || "Missing" | |
}, | |
complete : function() { | |
}, | |
success : function() { | |
}, | |
error : function() { | |
} | |
}); | |
} | |
}, $(document).ready(function() { | |
REI.main.init(); | |
}), function() { | |
/** | |
* @param {?} val | |
* @return {?} | |
*/ | |
function nulls(val) { | |
return null != val; | |
} | |
var jade = {}; | |
if (!Array.isArray) { | |
/** | |
* @param {*} arr | |
* @return {boolean} | |
*/ | |
Array.isArray = function(arr) { | |
return "[object Array]" == Object.prototype.toString.call(arr); | |
}; | |
} | |
if (!Object.keys) { | |
/** | |
* @param {!Object} object | |
* @return {!Array<string>} | |
*/ | |
Object.keys = function(object) { | |
/** @type {!Array} */ | |
var objKeys = []; | |
var i; | |
for (i in object) { | |
if (object.hasOwnProperty(i)) { | |
objKeys.push(i); | |
} | |
} | |
return objKeys; | |
}; | |
} | |
/** | |
* @param {!Object} a | |
* @param {!Object} b | |
* @return {?} | |
*/ | |
jade.merge = function merge(a, b) { | |
var ac = a["class"]; | |
var bc = b["class"]; | |
if (ac || bc) { | |
ac = ac || []; | |
bc = bc || []; | |
if (!Array.isArray(ac)) { | |
/** @type {!Array} */ | |
ac = [ac]; | |
} | |
if (!Array.isArray(bc)) { | |
/** @type {!Array} */ | |
bc = [bc]; | |
} | |
ac = ac.filter(nulls); | |
bc = bc.filter(nulls); | |
a["class"] = ac.concat(bc).join(" "); | |
} | |
var prop; | |
for (prop in b) { | |
if ("class" != prop) { | |
a[prop] = b[prop]; | |
} | |
} | |
return a; | |
}; | |
/** | |
* @param {!Object} obj | |
* @param {string} state | |
* @return {?} | |
*/ | |
jade.attrs = function attrs(obj, state) { | |
/** @type {!Array} */ | |
var a = []; | |
var terse = obj.terse; | |
delete obj.terse; | |
/** @type {!Array<string>} */ | |
var element = Object.keys(obj); | |
/** @type {number} */ | |
var length = element.length; | |
if (length) { | |
a.push(""); | |
/** @type {number} */ | |
var i = 0; | |
for (; length > i; ++i) { | |
/** @type {string} */ | |
var key = element[i]; | |
var val = obj[key]; | |
if ("boolean" == typeof val || null == val) { | |
if (val) { | |
if (terse) { | |
a.push(key); | |
} else { | |
a.push(key + '="' + key + '"'); | |
} | |
} | |
} else { | |
if (0 == key.indexOf("data") && "string" != typeof val) { | |
a.push(key + "='" + JSON.stringify(val) + "'"); | |
} else { | |
if ("class" == key && Array.isArray(val)) { | |
a.push(key + '="' + jade.escape(val.join(" ")) + '"'); | |
} else { | |
if (state && state[key]) { | |
a.push(key + '="' + jade.escape(val) + '"'); | |
} else { | |
a.push(key + '="' + val + '"'); | |
} | |
} | |
} | |
} | |
} | |
} | |
return a.join(" "); | |
}; | |
/** | |
* @param {string} s | |
* @return {?} | |
*/ | |
jade.escape = function escape(s) { | |
return (s + "").replace(/&(?!(\w+|#\d+);)/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """); | |
}; | |
/** | |
* @param {!Object} err | |
* @param {string} filename | |
* @param {string} lineno | |
* @return {undefined} | |
*/ | |
jade.rethrow = function rethrow(err, filename, lineno) { | |
if (!filename) { | |
throw err; | |
} | |
/** @type {number} */ | |
var context = 3; | |
var csvdata = require("fs").readFileSync(filename, "utf8"); | |
var buffer = csvdata.split("\n"); | |
/** @type {number} */ | |
var index = Math.max(lineno - context, 0); | |
/** @type {number} */ | |
var num = Math.min(buffer.length, lineno + context); | |
context = buffer.slice(index, num).map(function(canCreateDiscussions, basemapLayerId) { | |
var curr = basemapLayerId + index + 1; | |
return (curr == lineno ? " > " : " ") + curr + "| " + canCreateDiscussions; | |
}).join("\n"); | |
throw err.path = filename, err.message = (filename || "Jade") + ":" + lineno + "\n" + context + "\n\n" + err.message, err; | |
}; | |
this.REI = this.REI || {}; | |
this.REI.templates = this.REI.templates || {}; | |
/** | |
* @param {?} locals | |
* @param {!Function} attrs | |
* @param {!Function} escape | |
* @param {!Function} rethrow | |
* @param {number} merge | |
* @return {?} | |
*/ | |
this.REI.templates.form = function anonymous(locals, attrs, escape, rethrow, merge) { | |
attrs = attrs || jade.attrs; | |
escape = escape || jade.escape; | |
rethrow = rethrow || jade.rethrow; | |
merge = merge || jade.merge; | |
/** @type {!Array} */ | |
var outChance = []; | |
with(locals || {}) { | |
outChance.push('<div class="feedback"><p>Feedback Message</p></div><div class="header"><img src="_fe/img/make-sure.png"/></div><ul class="inputList"><li><input placeholder="first" autocorrect="off" class="id-first"/></li><li><input placeholder="last" autocorrect="off" class="id-last"/></li><li><input placeholder="email" type="email" autocorrect="off" class="id-email"/></li></ul><ul class="inputList"><li><input placeholder="phone" type="tel" autocorrect="off" class="id-phone"/><p>OR</p></li><li><input placeholder="member number" type="number" autocorrect="off" class="id-member"/></li></ul><div class="formFooter"><button class="confirm">Confirm</button><div class="spinner"></div></div><div class="help"><p>Having trouble?</p><p>REI Member Support can help.</p><p><a href="tel:8004264840">(800) 426-4840</a></p></div>'); | |
} | |
return outChance.join(""); | |
}; | |
/** | |
* @param {?} locals | |
* @param {!Function} attrs | |
* @param {!Function} escape | |
* @param {!Function} rethrow | |
* @param {number} merge | |
* @return {?} | |
*/ | |
this.REI.templates["sorry-android"] = function anonymous(locals, attrs, escape, rethrow, merge) { | |
attrs = attrs || jade.attrs; | |
escape = escape || jade.escape; | |
rethrow = rethrow || jade.rethrow; | |
merge = merge || jade.merge; | |
/** @type {!Array} */ | |
var buf = []; | |
with(locals || {}) { | |
buf.push('<header><h1>Sorry.</h1><p class="subheader">Passbook only works with iPhones.</p></header><div'); | |
buf.push(attrs({ | |
"class" : "apps " + platform | |
}, { | |
"class" : true | |
})); | |
buf.push('><h2>Download these great apps from REI.</h2><ul><li><div class="wrapper"><div class="icon"><img src="_fe/img/app1.png"/></div><div class="meta"><h3>REI</h3><p>Recreational Equipment Inc.</p><div class="stars"><img src="_fe/img/stars.png"/><p>(418)</p></div><p>Free</p></div><a'); | |
buf.push(attrs({ | |
href : "" + appURL, | |
"class" : "button" | |
}, { | |
href : true | |
})); | |
buf.push('>Install</a></div></li><li><div class="wrapper"><div class="icon"><img src="_fe/img/app2.png"/></div><div class="meta"><h3>REI Snow Report</h3><p>Recreational Equipment Inc.</p><div class="stars"><img src="_fe/img/stars.png"/><p>(1512)</p></div><p>Free</p></div><a'); | |
buf.push(attrs({ | |
href : "" + snowReportURL, | |
"class" : "button" | |
}, { | |
href : true | |
})); | |
buf.push(">Install</a></div></li></ul></div>"); | |
} | |
return buf.join(""); | |
}; | |
/** | |
* @param {?} locals | |
* @param {!Function} attrs | |
* @param {!Function} escape | |
* @param {!Function} rethrow | |
* @param {number} merge | |
* @return {?} | |
*/ | |
this.REI.templates["sorry-ios5"] = function anonymous(locals, attrs, escape, rethrow, merge) { | |
attrs = attrs || jade.attrs; | |
escape = escape || jade.escape; | |
rethrow = rethrow || jade.rethrow; | |
merge = merge || jade.merge; | |
/** @type {!Array} */ | |
var buf = []; | |
with(locals || {}) { | |
buf.push('<header><h1>Sorry.</h1><p class="subheader">Passbook requires an iPhone with iOS 6 or higher.</p></header><div'); | |
buf.push(attrs({ | |
"class" : "apps " + platform | |
}, { | |
"class" : true | |
})); | |
buf.push('><h2>Download these great apps from REI.</h2><ul><li><div class="wrapper"><div class="icon"><img src="_fe/img/app1.png"/></div><div class="meta"><h3>REI</h3><p>Recreational Equipment Inc.</p><div class="stars"><img src="_fe/img/stars.png"/><p>(418)</p></div><p>Free</p></div><a'); | |
buf.push(attrs({ | |
href : "" + appURL, | |
"class" : "button" | |
}, { | |
href : true | |
})); | |
buf.push('>Install</a></div></li><li><div class="wrapper"><div class="icon"><img src="_fe/img/app2.png"/></div><div class="meta"><h3>REI Snow Report</h3><p>Recreational Equipment Inc.</p><div class="stars"><img src="_fe/img/stars.png"/><p>(1512)</p></div><p>Free</p></div><a'); | |
buf.push(attrs({ | |
href : "" + snowReportURL, | |
"class" : "button" | |
}, { | |
href : true | |
})); | |
buf.push(">Install</a></div></li></ul></div>"); | |
} | |
return buf.join(""); | |
}; | |
/** | |
* @param {?} locals | |
* @param {!Function} attrs | |
* @param {!Function} escape | |
* @param {!Function} rethrow | |
* @param {!Object} merge | |
* @return {?} | |
*/ | |
this.REI.templates["sorry-osx"] = function anonymous(locals, attrs, escape, rethrow, merge) { | |
attrs = attrs || jade.attrs; | |
escape = escape || jade.escape; | |
rethrow = rethrow || jade.rethrow; | |
merge = merge || jade.merge; | |
/** @type {!Array} */ | |
var buf = []; | |
with(locals || {}) { | |
buf.push('<header><h1>Sorry.</h1><p class="subheader">Passbook requires OSX 10.8 or higher.</p></header><div'); | |
buf.push(attrs({ | |
"class" : "apps " + platform | |
}, { | |
"class" : true | |
})); | |
buf.push('><h2>Download these great apps from REI.</h2><ul><li><div class="wrapper"><div class="icon"><img src="_fe/img/app1.png"/></div><div class="meta"><h3>REI</h3><p>Recreational Equipment Inc.</p><div class="stars"><img src="_fe/img/stars.png"/><p>(418)</p></div><p>Free</p></div><a'); | |
buf.push(attrs({ | |
href : "" + appURL, | |
"class" : "button" | |
}, { | |
href : true | |
})); | |
buf.push('>Install</a></div></li><li><div class="wrapper"><div class="icon"><img src="_fe/img/app2.png"/></div><div class="meta"><h3>REI Snow Report</h3><p>Recreational Equipment Inc.</p><div class="stars"><img src="_fe/img/stars.png"/><p>(1512)</p></div><p>Free</p></div><a'); | |
buf.push(attrs({ | |
href : "" + snowReportURL, | |
"class" : "button" | |
}, { | |
href : true | |
})); | |
buf.push(">Install</a></div></li></ul></div>"); | |
} | |
return buf.join(""); | |
}; | |
/** | |
* @param {?} locals | |
* @param {!Function} attrs | |
* @param {!Function} escape | |
* @param {!Function} rethrow | |
* @param {number} merge | |
* @return {?} | |
*/ | |
this.REI.templates["sorry-wp"] = function anonymous(locals, attrs, escape, rethrow, merge) { | |
attrs = attrs || jade.attrs; | |
escape = escape || jade.escape; | |
rethrow = rethrow || jade.rethrow; | |
merge = merge || jade.merge; | |
/** @type {!Array} */ | |
var outChance = []; | |
with(locals || {}) { | |
outChance.push('<header><h1>Sorry.</h1><p class="subheader">Passbook only works with iPhones.</p></header>'); | |
} | |
return outChance.join(""); | |
}; | |
/** | |
* @param {?} locals | |
* @param {!Function} attrs | |
* @param {!Function} escape | |
* @param {!Function} rethrow | |
* @param {!Function} merge | |
* @return {?} | |
*/ | |
this.REI.templates.thankyou = function anonymous(locals, attrs, escape, rethrow, merge) { | |
attrs = attrs || jade.attrs; | |
escape = escape || jade.escape; | |
rethrow = rethrow || jade.rethrow; | |
merge = merge || jade.merge; | |
/** @type {!Array} */ | |
var buf = []; | |
with(locals || {}) { | |
buf.push('<header><h1>All Done.</h1><p class="subheader">Your membership card has been added to Passbook.</p></header><div'); | |
buf.push(attrs({ | |
"class" : "apps " + platform | |
}, { | |
"class" : true | |
})); | |
buf.push('><h2>Download these great apps from REI.</h2><ul><li><div class="wrapper"><div class="icon"><img src="_fe/img/app1.png"/></div><div class="meta"><h3>REI</h3><p>Recreational Equipment Inc.</p><div class="stars"><img src="_fe/img/stars.png"/><p>(418)</p></div><p>Free</p></div><a'); | |
buf.push(attrs({ | |
href : "" + appURL, | |
"class" : "button" | |
}, { | |
href : true | |
})); | |
buf.push('>Install</a></div></li><li><div class="wrapper"><div class="icon"><img src="_fe/img/app2.png"/></div><div class="meta"><h3>REI Snow Report</h3><p>Recreational Equipment Inc.</p><div class="stars"><img src="_fe/img/stars.png"/><p>(1512)</p></div><p>Free</p></div><a'); | |
buf.push(attrs({ | |
href : "" + snowReportURL, | |
"class" : "button" | |
}, { | |
href : true | |
})); | |
buf.push(">Install</a></div></li></ul></div>"); | |
} | |
return buf.join(""); | |
}; | |
}.call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment