<commit_before>// Opening for events
const eventTitle = getElementByClassName('event-title', 0)
const eventSubtitle = getElementByClassName('event-subtitle', 0)
const eventDetails = getElementByClassName('event-details', 0)
// Fade in first slide
eventTitle.classList.add('fade-move')
eventSubtitle.classList.add('fade-move')
eventDetails.classList.add('fade-move')
// Email signup form
setTimeout(() => changeEmailContainerBackground(getElementByClassName('email-container-background', 0)), 600)

// Event listener for if reg form is closed
const regFormModalStatus = getElementByClassName('modal-status registration', 0)
const regFormModal = getElementByClassName('modal registration', 0)
const regFormModalWindow = getElementByClassName('modal-window registration', 0)
const regFormContainer = getElementByClassName('container reg-form', 0)
const regFormButtons = getElementsByClassName('button register')
for (let i = 0; i < regFormButtons.length; i++) {
	onClick(regFormButtons[i], () => {
		// Prepare for fade in
		regFormModal.style.opacity = '0'
		// Unhide modal
		setTimeout(() => showElement(regFormModalStatus), 100)
		// Fade in modal window
		setTimeout(() => regFormModal.style.opacity = '1.0', 200)
		setTimeout(() => {
			// Show reg form: browser error that doesn’t show opacity of children unless body is scrolled by 1 px and window opacity is set to 1 during scroll
			regFormContainer.scrollTop = 0
			window.scrollBy(0, 1)
			// Prevent background from scrolling
			document.body.style.overflow = 'hidden'
		}, 300)
	})
}

const regFormClose = getElementByClassName('reg-form-close', 0)
onClick(regFormClose, () => {
	document.body.style.overflow = 'visible'
	regFormModal.style.opacity = '0'
	setTimeout(() => hideElement(regFormModalStatus), 200)
})

// Event summary “Read more...” expansion
getElementByClassName('text read-more', 0).addEventListener('mouseover', () => {
	hideElement(getElementByClassName('text read-more'))
	hideElement(getElementByClassName('text summary'))
	getElementByClassName('text description').classList.add('display')
	setTimeout(() => getElementByClassName('text description display').classList.add('fade'), 100)
})

// Prevent accidental submission of form through 'enter' key
onKeyPress(document, e => {
	if (isInput(e.target) && e.which === 13) {
		e.preventDefault()
		return false
	}
})

let countries = [{value:'AF',label:'Afghanistan'},{value:'AX',label:'Åland Islands'},{value:'AL',label:'Albania'},{value:'DZ',label:'Algeria'},{value:'AS',label:'American Samoa'},{value:'AD',label:'Andorra'},{value:'AO',label:'Angola'},{value:'AI',label:'Anguilla'},{value:'AQ',label:'Antarctica'},{value:'AG',label:'Antigua and Barbuda'},{value:'AR',label:'Argentina'},{value:'AM',label:'Armenia'},{value:'AW',label:'Aruba'},{value:'AU',label:'Australia'},{value:'AT',label:'Austria'},{value:'AZ',label:'Azerbaijan'},{value:'BS',label:'Bahamas'},{value:'BH',label:'Bahrain'},{value:'BD',label:'Bangladesh'},{value:'BB',label:'Barbados'},{value:'BY',label:'Belarus'},{value:'BE',label:'Belgium'},{value:'BZ',label:'Belize'},{value:'BJ',label:'Benin'},{value:'BM',label:'Bermuda'},{value:'BT',label:'Bhutan'},{value:'BO',label:'Bolivia'},{value:'BA',label:'Bosnia and Herzegovina'},{value:'BW',label:'Botswana'},{value:'BV',label:'Bouvet Island'},{value:'BR',label:'Brazil'},{value:'IO',label:'British Indian Ocean Territory'},{value:'BN',label:'Brunei Darussalam'},{value:'BG',label:'Bulgaria'},{value:'BF',label:'Burkina Faso'},{value:'BI',label:'Burundi'},{value:'KH',label:'Cambodia'},{value:'CM',label:'Cameroon'},{value:'CA',label:'Canada'},{value:'CV',label:'Cape Verde'},{value:'KY',label:'Cayman Islands'},{value:'CF',label:'Central African Republic'},{value:'TD',label:'Chad'},{value:'CL',label:'Chile'},{value:'CN',label:'China, People’s Republic of'},{value:'CX',label:'Christmas Island'},{value:'CC',label:'Cocos (Keeling) Islands'},{value:'CO',label:'Colombia'},{value:'KM',label:'Comoros'},{value:'CG',label:'Congo'},{value:'CD',label:'Congo, The Democratic Republic of the'},{value:'CK',label:'Cook Islands'},{value:'CR',label:'Costa Rica'},{value:'CI',label:'Cote D’Ivoire'},{value:'HR',label:'Croatia'},{value:'CU',label:'Cuba'},{value:'CY',label:'Cyprus'},{value:'CZ',label:'Czech Republic'},{value:'DK',label:'Denmark'},{value:'DJ',label:'Djibouti'},{value:'DM',label:'Dominica'},{value:'DO',label:'Dominican Republic'},{value:'EC',label:'Ecuador'},{value:'EG',label:'Egypt'},{value:'SV',label:'El Salvador'},{value:'GQ',label:'Equatorial Guinea'},{value:'ER',label:'Eritrea'},{value:'EE',label:'Estonia'},{value:'ET',label:'Ethiopia'},{value:'FK',label:'Falkland Islands (Malvinas)'},{value:'FO',label:'Faroe Islands'},{value:'FJ',label:'Fiji'},{value:'FI',label:'Finland'},{value:'FR',label:'France'},{value:'GF',label:'French Guiana'},{value:'PF',label:'French Polynesia'},{value:'TF',label:'French Southern Territories'},{value:'GA',label:'Gabon'},{value:'GM',label:'Gambia'},{value:'GE',label:'Georgia'},{value:'DE',label:'Germany'},{value:'GH',label:'Ghana'},{value:'GI',label:'Gibraltar'},{value:'GR',label:'Greece'},{value:'GL',label:'Greenland'},{value:'GD',label:'Grenada'},{value:'GP',label:'Guadeloupe'},{value:'GU',label:'Guam'},{value:'GT',label:'Guatemala'},{value:'GG',label:'Guernsey'},{value:'GN',label:'Guinea'},{value:'GW',label:'Guinea-Bissau'},{value:'GY',label:'Guyana'},{value:'HT',label:'Haiti'},{value:'HM',label:'Heard Island and Mcdonald Islands'},{value:'VA',label:'Holy See (Vatican City State)'},{value:'HN',label:'Honduras'},{value:'HK',label:'Hong Kong'},{value:'HU',label:'Hungary'},{value:'IS',label:'Iceland'},{value:'IN',label:'India'},{value:'ID',label:'Indonesia'},{value:'IR',label:'Iran, Islamic Republic Of'},{value:'IQ',label:'Iraq'},{value:'IE',label:'Ireland'},{value:'IM',label:'Isle of Man'},{value:'IL',label:'Israel'},{value:'IT',label:'Italy'},{value:'JM',label:'Jamaica'},{value:'JP',label:'Japan'},{value:'JE',label:'Jersey'},{value:'JO',label:'Jordan'},{value:'KZ',label:'Kazakhstan'},{value:'KE',label:'Kenya'},{value:'KI',label:'Kiribati'},{value:'KP',label:'Democratic People’s Republic of Korea'},{value:'KR',label:'Korea, Republic of'},{value:'XK',label:'Kosovo'},{value:'KW',label:'Kuwait'},{value:'KG',label:'Kyrgyzstan'},{value:'LA',label:'Lao People’s Democratic Republic'},{value:'LV',label:'Latvia'},{value:'LB',label:'Lebanon'},{value:'LS',label:'Lesotho'},{value:'LR',label:'Liberia'},{value:'LY',label:'Libyan Arab Jamahiriya'},{value:'LI',label:'Liechtenstein'},{value:'LT',label:'Lithuania'},{value:'LU',label:'Luxembourg'},{value:'MO',label:'Macao'},{value:'MK',label:'Macedonia, The Former Yugoslav Republic of'},{value:'MG',label:'Madagascar'},{value:'MW',label:'Malawi'},{value:'MY',label:'Malaysia'},{value:'MV',label:'Maldives'},{value:'ML',label:'Mali'},{value:'MT',label:'Malta'},{value:'MH',label:'Marshall Islands'},{value:'MQ',label:'Martinique'},{value:'MR',label:'Mauritania'},{value:'MU',label:'Mauritius'},{value:'YT',label:'Mayotte'},{value:'MX',label:'Mexico'},{value:'FM',label:'Micronesia, Federated States of'},{value:'MD',label:'Moldova, Republic of'},{value:'MC',label:'Monaco'},{value:'MN',label:'Mongolia'},{value:'ME',label:'Montenegro'},{value:'MS',label:'Montserrat'},{value:'MA',label:'Morocco'},{value:'MZ',label:'Mozambique'},{value:'MM',label:'Myanmar'},{value:'NA',label:'Namibia'},{value:'NR',label:'Nauru'},{value:'NP',label:'Nepal'},{value:'NL',label:'Netherlands'},{value:'AN',label:'Netherlands Antilles'},{value:'NC',label:'New Caledonia'},{value:'NZ',label:'New Zealand'},{value:'NI',label:'Nicaragua'},{value:'NE',label:'Niger'},{value:'NG',label:'Nigeria'},{value:'NU',label:'Niue'},{value:'NF',label:'Norfolk Island'},{value:'MP',label:'Northern Mariana Islands'},{value:'NO',label:'Norway'},{value:'OM',label:'Oman'},{value:'PK',label:'Pakistan'},{value:'PW',label:'Palau'},{value:'PS',label:'Palestine, State of'},{value:'PA',label:'Panama'},{value:'PG',label:'Papua New Guinea'},{value:'PY',label:'Paraguay'},{value:'PE',label:'Peru'},{value:'PH',label:'Philippines'},{value:'PN',label:'Pitcairn'},{value:'PL',label:'Poland'},{value:'PT',label:'Portugal'},{value:'PR',label:'Puerto Rico'},{value:'QA',label:'Qatar'},{value:'RE',label:'Reunion'},{value:'RO',label:'Romania'},{value:'RU',label:'Russian Federation'},{value:'RW',label:'Rwanda'},{value:'SH',label:'Saint Helena'},{value:'KN',label:'Saint Kitts and Nevis'},{value:'LC',label:'Saint Lucia'},{value:'PM',label:'Saint Pierre and Miquelon'},{value:'VC',label:'Saint Vincent and the Grenadines'},{value:'WS',label:'Samoa'},{value:'SM',label:'San Marino'},{value:'ST',label:'Sao Tome and Principe'},{value:'SA',label:'Saudi Arabia'},{value:'SN',label:'Senegal'},{value:'RS',label:'Serbia'},{value:'SC',label:'Seychelles'},{value:'SL',label:'Sierra Leone'},{value:'SG',label:'Singapore'},{value:'SK',label:'Slovakia'},{value:'SI',label:'Slovenia'},{value:'SB',label:'Solomon Islands'},{value:'SO',label:'Somalia'},{value:'ZA',label:'South Africa'},{value:'GS',label:'South Georgia and the South Sandwich Islands'},{value:'ES',label:'Spain'},{value:'LK',label:'Sri Lanka'},{value:'SD',label:'Sudan'},{value:'SR',label:'Suriname'},{value:'SJ',label:'Svalbard and Jan Mayen'},{value:'SZ',label:'Swaziland'},{value:'SE',label:'Sweden'},{value:'CH',label:'Switzerland'},{value:'SY',label:'Syrian Arab Republic'},{value:'TW',label:'Taiwan, Republic of China'},{value:'TJ',label:'Tajikistan'},{value:'TZ',label:'Tanzania, United Republic of'},{value:'TH',label:'Thailand'},{value:'TL',label:'Timor-Leste'},{value:'TG',label:'Togo'},{value:'TK',label:'Tokelau'},{value:'TO',label:'Tonga'},{value:'TT',label:'Trinidad and Tobago'},{value:'TN',label:'Tunisia'},{value:'TR',label:'Turkey'},{value:'TM',label:'Turkmenistan'},{value:'TC',label:'Turks and Caicos Islands'},{value:'TV',label:'Tuvalu'},{value:'UG',label:'Uganda'},{value:'UA',label:'Ukraine'},{value:'AE',label:'United Arab Emirates'},{value:'GB',label:'United Kingdom'},{value:'US',label:'United States'},{value:'UM',label:'United States Minor Outlying Islands'},{value:'UY',label:'Uruguay'},{value:'UZ',label:'Uzbekistan'},{value:'VU',label:'Vanuatu'},{value:'VE',label:'Venezuela'},{value:'VN',label:'Viet Nam'},{value:'VG',label:'Virgin Islands, British'},{value:'VI',label:'Virgin Islands, U.S.'},{value:'WF',label:'Wallis and Futuna'},{value:'EH',label:'Western Sahara'},{value:'YE',label:'Yemen'},{value:'ZM',label:'Zambia'},{value:'ZW',label:'Zimbabwe'}]

// Countries
if (getElementById('country')) {
	for(let i in countries) {
		let option = document.createElement('option')
		option.text = countries[i].label
		option.value = countries[i].value
		option.selected = countries[i] === 'United States'
			? true
			: false
		appendSelect(getElementById('country'), option)
	}
}

// Load reg form scripts
const baseScriptUrl = 'https://ecstaticliving.github.io/ecstaticliving.com/dev/events/'
const scripts = ['elements', 'functions', 'onchange', 'webflow', 'payment']
// Load scripts synchronously, one after another, to make sure hierarchy is respected.
const loadScript = index => {
	let js = document.createElement('script')
	js.src = baseScriptUrl + scripts[index] + '.js'
	js.onload = () => {
		// Once final script has loaded, initialise
		if (scripts[index] === 'payment' && (page() === 'Event' || page() === 'Update')) {
			resetForm()
			scriptsHaveBeenLoaded = true
		}
		else {
			loadScript(index + 1)
		}
	}
	document.head.appendChild(js)
}
loadScript(0)
<commit_msg>Reg form modal display.<commit_after>// Opening for events
const eventTitle = getElementByClassName('event-title', 0)
const eventSubtitle = getElementByClassName('event-subtitle', 0)
const eventDetails = getElementByClassName('event-details', 0)
// Fade in first slide
eventTitle.classList.add('fade-move')
eventSubtitle.classList.add('fade-move')
eventDetails.classList.add('fade-move')
// Email signup form
setTimeout(() => changeEmailContainerBackground(getElementByClassName('email-container-background', 0)), 600)

// Event listener for if reg form is closed
const regFormModalStatus = getElementByClassName('modal-status registration', 0)
const regFormModal = getElementByClassName('modal registration', 0)
const regFormModalWindow = getElementByClassName('modal-window registration', 0)
const regFormContainer = getElementByClassName('container reg-form', 0)
const regFormButtons = getElementsByClassName('button register')
for (let i = 0; i < regFormButtons.length; i++) {
	onClick(regFormButtons[i], () => {
		// Prepare for fade in
		regFormModal.style.opacity = '0'
		// Unhide modal
		setTimeout(() => showElement(regFormModalStatus), 100)
		// Fade in modal window
		setTimeout(() => regFormModal.style.opacity = '1.0', 200)
		setTimeout(() => {
			// Show reg form: browser error that doesn’t show opacity of children unless body is scrolled by 1 px and window opacity is set to 1 during scroll
			regFormContainer.scrollTop = 0
			window.scrollBy(0, 1)
		}, 300)
		// Prevent background from scrolling
		setTimeout(() => document.body.style.overflow = 'hidden', 500)
	})
}

const regFormClose = getElementByClassName('reg-form-close', 0)
onClick(regFormClose, () => {
	document.body.style.overflow = 'visible'
	regFormModal.style.opacity = '0'
	setTimeout(() => hideElement(regFormModalStatus), 200)
})

// Event summary “Read more...” expansion
getElementByClassName('text read-more', 0).addEventListener('mouseover', () => {
	hideElement(getElementByClassName('text read-more'))
	hideElement(getElementByClassName('text summary'))
	getElementByClassName('text description').classList.add('display')
	setTimeout(() => getElementByClassName('text description display').classList.add('fade'), 100)
})

// Prevent accidental submission of form through 'enter' key
onKeyPress(document, e => {
	if (isInput(e.target) && e.which === 13) {
		e.preventDefault()
		return false
	}
})

let countries = [{value:'AF',label:'Afghanistan'},{value:'AX',label:'Åland Islands'},{value:'AL',label:'Albania'},{value:'DZ',label:'Algeria'},{value:'AS',label:'American Samoa'},{value:'AD',label:'Andorra'},{value:'AO',label:'Angola'},{value:'AI',label:'Anguilla'},{value:'AQ',label:'Antarctica'},{value:'AG',label:'Antigua and Barbuda'},{value:'AR',label:'Argentina'},{value:'AM',label:'Armenia'},{value:'AW',label:'Aruba'},{value:'AU',label:'Australia'},{value:'AT',label:'Austria'},{value:'AZ',label:'Azerbaijan'},{value:'BS',label:'Bahamas'},{value:'BH',label:'Bahrain'},{value:'BD',label:'Bangladesh'},{value:'BB',label:'Barbados'},{value:'BY',label:'Belarus'},{value:'BE',label:'Belgium'},{value:'BZ',label:'Belize'},{value:'BJ',label:'Benin'},{value:'BM',label:'Bermuda'},{value:'BT',label:'Bhutan'},{value:'BO',label:'Bolivia'},{value:'BA',label:'Bosnia and Herzegovina'},{value:'BW',label:'Botswana'},{value:'BV',label:'Bouvet Island'},{value:'BR',label:'Brazil'},{value:'IO',label:'British Indian Ocean Territory'},{value:'BN',label:'Brunei Darussalam'},{value:'BG',label:'Bulgaria'},{value:'BF',label:'Burkina Faso'},{value:'BI',label:'Burundi'},{value:'KH',label:'Cambodia'},{value:'CM',label:'Cameroon'},{value:'CA',label:'Canada'},{value:'CV',label:'Cape Verde'},{value:'KY',label:'Cayman Islands'},{value:'CF',label:'Central African Republic'},{value:'TD',label:'Chad'},{value:'CL',label:'Chile'},{value:'CN',label:'China, People’s Republic of'},{value:'CX',label:'Christmas Island'},{value:'CC',label:'Cocos (Keeling) Islands'},{value:'CO',label:'Colombia'},{value:'KM',label:'Comoros'},{value:'CG',label:'Congo'},{value:'CD',label:'Congo, The Democratic Republic of the'},{value:'CK',label:'Cook Islands'},{value:'CR',label:'Costa Rica'},{value:'CI',label:'Cote D’Ivoire'},{value:'HR',label:'Croatia'},{value:'CU',label:'Cuba'},{value:'CY',label:'Cyprus'},{value:'CZ',label:'Czech Republic'},{value:'DK',label:'Denmark'},{value:'DJ',label:'Djibouti'},{value:'DM',label:'Dominica'},{value:'DO',label:'Dominican Republic'},{value:'EC',label:'Ecuador'},{value:'EG',label:'Egypt'},{value:'SV',label:'El Salvador'},{value:'GQ',label:'Equatorial Guinea'},{value:'ER',label:'Eritrea'},{value:'EE',label:'Estonia'},{value:'ET',label:'Ethiopia'},{value:'FK',label:'Falkland Islands (Malvinas)'},{value:'FO',label:'Faroe Islands'},{value:'FJ',label:'Fiji'},{value:'FI',label:'Finland'},{value:'FR',label:'France'},{value:'GF',label:'French Guiana'},{value:'PF',label:'French Polynesia'},{value:'TF',label:'French Southern Territories'},{value:'GA',label:'Gabon'},{value:'GM',label:'Gambia'},{value:'GE',label:'Georgia'},{value:'DE',label:'Germany'},{value:'GH',label:'Ghana'},{value:'GI',label:'Gibraltar'},{value:'GR',label:'Greece'},{value:'GL',label:'Greenland'},{value:'GD',label:'Grenada'},{value:'GP',label:'Guadeloupe'},{value:'GU',label:'Guam'},{value:'GT',label:'Guatemala'},{value:'GG',label:'Guernsey'},{value:'GN',label:'Guinea'},{value:'GW',label:'Guinea-Bissau'},{value:'GY',label:'Guyana'},{value:'HT',label:'Haiti'},{value:'HM',label:'Heard Island and Mcdonald Islands'},{value:'VA',label:'Holy See (Vatican City State)'},{value:'HN',label:'Honduras'},{value:'HK',label:'Hong Kong'},{value:'HU',label:'Hungary'},{value:'IS',label:'Iceland'},{value:'IN',label:'India'},{value:'ID',label:'Indonesia'},{value:'IR',label:'Iran, Islamic Republic Of'},{value:'IQ',label:'Iraq'},{value:'IE',label:'Ireland'},{value:'IM',label:'Isle of Man'},{value:'IL',label:'Israel'},{value:'IT',label:'Italy'},{value:'JM',label:'Jamaica'},{value:'JP',label:'Japan'},{value:'JE',label:'Jersey'},{value:'JO',label:'Jordan'},{value:'KZ',label:'Kazakhstan'},{value:'KE',label:'Kenya'},{value:'KI',label:'Kiribati'},{value:'KP',label:'Democratic People’s Republic of Korea'},{value:'KR',label:'Korea, Republic of'},{value:'XK',label:'Kosovo'},{value:'KW',label:'Kuwait'},{value:'KG',label:'Kyrgyzstan'},{value:'LA',label:'Lao People’s Democratic Republic'},{value:'LV',label:'Latvia'},{value:'LB',label:'Lebanon'},{value:'LS',label:'Lesotho'},{value:'LR',label:'Liberia'},{value:'LY',label:'Libyan Arab Jamahiriya'},{value:'LI',label:'Liechtenstein'},{value:'LT',label:'Lithuania'},{value:'LU',label:'Luxembourg'},{value:'MO',label:'Macao'},{value:'MK',label:'Macedonia, The Former Yugoslav Republic of'},{value:'MG',label:'Madagascar'},{value:'MW',label:'Malawi'},{value:'MY',label:'Malaysia'},{value:'MV',label:'Maldives'},{value:'ML',label:'Mali'},{value:'MT',label:'Malta'},{value:'MH',label:'Marshall Islands'},{value:'MQ',label:'Martinique'},{value:'MR',label:'Mauritania'},{value:'MU',label:'Mauritius'},{value:'YT',label:'Mayotte'},{value:'MX',label:'Mexico'},{value:'FM',label:'Micronesia, Federated States of'},{value:'MD',label:'Moldova, Republic of'},{value:'MC',label:'Monaco'},{value:'MN',label:'Mongolia'},{value:'ME',label:'Montenegro'},{value:'MS',label:'Montserrat'},{value:'MA',label:'Morocco'},{value:'MZ',label:'Mozambique'},{value:'MM',label:'Myanmar'},{value:'NA',label:'Namibia'},{value:'NR',label:'Nauru'},{value:'NP',label:'Nepal'},{value:'NL',label:'Netherlands'},{value:'AN',label:'Netherlands Antilles'},{value:'NC',label:'New Caledonia'},{value:'NZ',label:'New Zealand'},{value:'NI',label:'Nicaragua'},{value:'NE',label:'Niger'},{value:'NG',label:'Nigeria'},{value:'NU',label:'Niue'},{value:'NF',label:'Norfolk Island'},{value:'MP',label:'Northern Mariana Islands'},{value:'NO',label:'Norway'},{value:'OM',label:'Oman'},{value:'PK',label:'Pakistan'},{value:'PW',label:'Palau'},{value:'PS',label:'Palestine, State of'},{value:'PA',label:'Panama'},{value:'PG',label:'Papua New Guinea'},{value:'PY',label:'Paraguay'},{value:'PE',label:'Peru'},{value:'PH',label:'Philippines'},{value:'PN',label:'Pitcairn'},{value:'PL',label:'Poland'},{value:'PT',label:'Portugal'},{value:'PR',label:'Puerto Rico'},{value:'QA',label:'Qatar'},{value:'RE',label:'Reunion'},{value:'RO',label:'Romania'},{value:'RU',label:'Russian Federation'},{value:'RW',label:'Rwanda'},{value:'SH',label:'Saint Helena'},{value:'KN',label:'Saint Kitts and Nevis'},{value:'LC',label:'Saint Lucia'},{value:'PM',label:'Saint Pierre and Miquelon'},{value:'VC',label:'Saint Vincent and the Grenadines'},{value:'WS',label:'Samoa'},{value:'SM',label:'San Marino'},{value:'ST',label:'Sao Tome and Principe'},{value:'SA',label:'Saudi Arabia'},{value:'SN',label:'Senegal'},{value:'RS',label:'Serbia'},{value:'SC',label:'Seychelles'},{value:'SL',label:'Sierra Leone'},{value:'SG',label:'Singapore'},{value:'SK',label:'Slovakia'},{value:'SI',label:'Slovenia'},{value:'SB',label:'Solomon Islands'},{value:'SO',label:'Somalia'},{value:'ZA',label:'South Africa'},{value:'GS',label:'South Georgia and the South Sandwich Islands'},{value:'ES',label:'Spain'},{value:'LK',label:'Sri Lanka'},{value:'SD',label:'Sudan'},{value:'SR',label:'Suriname'},{value:'SJ',label:'Svalbard and Jan Mayen'},{value:'SZ',label:'Swaziland'},{value:'SE',label:'Sweden'},{value:'CH',label:'Switzerland'},{value:'SY',label:'Syrian Arab Republic'},{value:'TW',label:'Taiwan, Republic of China'},{value:'TJ',label:'Tajikistan'},{value:'TZ',label:'Tanzania, United Republic of'},{value:'TH',label:'Thailand'},{value:'TL',label:'Timor-Leste'},{value:'TG',label:'Togo'},{value:'TK',label:'Tokelau'},{value:'TO',label:'Tonga'},{value:'TT',label:'Trinidad and Tobago'},{value:'TN',label:'Tunisia'},{value:'TR',label:'Turkey'},{value:'TM',label:'Turkmenistan'},{value:'TC',label:'Turks and Caicos Islands'},{value:'TV',label:'Tuvalu'},{value:'UG',label:'Uganda'},{value:'UA',label:'Ukraine'},{value:'AE',label:'United Arab Emirates'},{value:'GB',label:'United Kingdom'},{value:'US',label:'United States'},{value:'UM',label:'United States Minor Outlying Islands'},{value:'UY',label:'Uruguay'},{value:'UZ',label:'Uzbekistan'},{value:'VU',label:'Vanuatu'},{value:'VE',label:'Venezuela'},{value:'VN',label:'Viet Nam'},{value:'VG',label:'Virgin Islands, British'},{value:'VI',label:'Virgin Islands, U.S.'},{value:'WF',label:'Wallis and Futuna'},{value:'EH',label:'Western Sahara'},{value:'YE',label:'Yemen'},{value:'ZM',label:'Zambia'},{value:'ZW',label:'Zimbabwe'}]

// Countries
if (getElementById('country')) {
	for(let i in countries) {
		let option = document.createElement('option')
		option.text = countries[i].label
		option.value = countries[i].value
		option.selected = countries[i] === 'United States'
			? true
			: false
		appendSelect(getElementById('country'), option)
	}
}

// Load reg form scripts
const baseScriptUrl = 'https://ecstaticliving.github.io/ecstaticliving.com/dev/events/'
const scripts = ['elements', 'functions', 'onchange', 'webflow', 'payment']
// Load scripts synchronously, one after another, to make sure hierarchy is respected.
const loadScript = index => {
	let js = document.createElement('script')
	js.src = baseScriptUrl + scripts[index] + '.js'
	js.onload = () => {
		// Once final script has loaded, initialise
		if (scripts[index] === 'payment' && (page() === 'Event' || page() === 'Update')) {
			resetForm()
			scriptsHaveBeenLoaded = true
		}
		else {
			loadScript(index + 1)
		}
	}
	document.head.appendChild(js)
}
loadScript(0)
<|endoftext|>


<commit_before>/**
 *  Authors: %Author Name%
*/
$(function() {

  if ($('html').hasClass('-device_desktop')) {

  }
});
$(window).resize(function() {

});
$(window).load(function() {

});<commit_msg>Prevent concat js from errors<commit_after>// Authors: %Author Name%

$(function() {

  if ($('html').hasClass('-device_desktop')) {

  }
});
$(window).resize(function() {

});
$(window).load(function() {

});
<|endoftext|>


<commit_before>developerKingdomModule.
	controller("guideCtrl", function guideCtrl($scope, $window){

		$scope.sections = [{name: "Introduction", html: "blah blah blah
Lololol
"},{name: "Adding plugins", html: "
Na na na na na nana heeeeeey jude

Hey judey judey jude
"}];

		$scope.currentSection = {};
		$scope.currentSectionOn = false;

		$scope.setSection = function(section){
			$scope.currentSection = section;
			$scope.currentSectionOn = true;
		}

		$scope.backToSections = function(){
			$scope.currentSectionOn = false;
		}
	})
<commit_msg>Update guide.js<commit_after>developerKingdomModule.
	controller("guideCtrl", function guideCtrl($scope, $window){

		$scope.sections = [{name: "Introduction", htmlText: "blah blah blah
Lololol
"},{name: "Adding plugins", html: "
Na na na na na nana heeeeeey jude

Hey judey judey jude
"}];

		$scope.currentSection = {};
		$scope.currentSectionOn = false;

		$scope.setSection = function(section){
			$scope.currentSection = section;
			$scope.currentSectionOn = true;
		}

		$scope.backToSections = function(){
			$scope.currentSectionOn = false;
		}
	})
<|endoftext|>


<commit_before>var DiffCamEngine = (function() {
	var stream;					// stream obtained from webcam
	var video;					// shows stream
	var captureCanvas;			// internal canvas for capturing full images from video
	var diffCanvas;				// internal canvas for diffing downscaled captures
	var motionCanvas;			// receives processed diff images

	var initSuccessCallback;	// called when init succeeds
	var initErrorCallback;		// called when init fails
	var startCompleteCallback;	// called when start is complete
	var captureCallback;		// called when an image has been captured and diffed

	var captureInterval;		// interval for continuous captures
	var captureIntervalTime;	// time between captures, in ms
	var captureWidth;			// full captured image width
	var captureHeight;			// full captured image height
	var diffWidth;				// downscaled width for diff/motion
	var diffHeight;				// downscaled height for diff/motion
	var isReadyToDiff;			// has a previous capture been made to diff against?
	var pixelDiffThreshold;		// min for a pixel to be considered significant

	function init(options) {
		// sanity check
		if (!options) {
			throw 'No options object provided';
		}

		// incoming options with defaults
		video = options.video || document.createElement('video');
		motionCanvas = options.motionCanvas || document.createElement('canvas');
		captureIntervalTime = options.captureIntervalTime || 100;
		captureWidth = options.captureWidth || 640;
		captureHeight = options.captureHeight || 480;
		diffWidth = options.diffWidth || 64;
		diffHeight = options.diffHeight || 48;
		pixelDiffThreshold = options.pixelDiffThreshold || 32;

		// callbacks
		initSuccessCallback = options.initSuccessCallback || function() {};
		initErrorCallback = options.initErrorCallback || function() {};
		startCompleteCallback = options.startCompleteCallback || function() {};
		captureCallback = options.captureCallback || function() {};

		// non-configurable
		captureCanvas = document.createElement('canvas');
		diffCanvas = document.createElement('canvas');
		isReadyToDiff = false;

		// prep capture canvas
		captureCanvas.width = captureWidth;
		captureCanvas.height = captureHeight;
		captureContext = captureCanvas.getContext('2d');

		// prep diff canvas
		diffCanvas.width = diffWidth;
		diffCanvas.height = diffHeight;
		diffContext = diffCanvas.getContext('2d');

		// prep motion canvas
		motionCanvas.width = diffWidth;
		motionCanvas.height = diffHeight;
		motionContext = motionCanvas.getContext('2d');

		requestWebcam();
	}

	function requestWebcam() {
		var constraints = {
			audio: false,
			video: { width: captureWidth, height: captureHeight }
		};

		navigator.mediaDevices.getUserMedia(constraints)
			.then(initSuccess)
			.catch(initError);
	}

	function initSuccess(requestedStream) {
		stream = requestedStream;
		initSuccessCallback();
	}

	function initError(error) {
		console.log(error);
		initErrorCallback();
	}

	function start() {
		if (!stream) {
			throw 'Cannot start after init fail';
		}

		// streaming takes a moment to start
		video.addEventListener('canplay', startComplete);
		video.srcObject = stream;
	}

	function startComplete() {
		video.removeEventListener('canplay', startComplete);
		captureInterval = setInterval(capture, captureIntervalTime);
		startCompleteCallback();
	}

	function stop() {
		clearInterval(captureInterval);
		video.src = '';
		motionContext.clearRect(0, 0, diffWidth, diffHeight);
		isReadyToDiff = false;
	}

	function capture() {
		// save a full-sized copy of capture
		captureContext.drawImage(video, 0, 0, captureWidth, captureHeight);
		captureImageData = captureContext.getImageData(0, 0, captureWidth, captureHeight);

		// diff current capture over previous capture, leftover from last time
		diffContext.globalCompositeOperation = 'difference';
		diffContext.drawImage(video, 0, 0, diffWidth, diffHeight);
		diffImageData = diffContext.getImageData(0, 0, diffWidth, diffHeight);

		if (isReadyToDiff) {
			var score = processDiff(diffImageData);
			motionContext.putImageData(diffImageData, 0, 0);
			captureCallback({
				imageData: captureImageData,
				score: score,
				getURL: getCaptureUrl.bind(null, captureImageData)
			});
		}

		// draw current capture normally over diff, ready for next time
		diffContext.globalCompositeOperation = 'source-over';
		diffContext.drawImage(video, 0, 0, diffWidth, diffHeight);
		isReadyToDiff = true;
	}

	function processDiff(diffImageData) {
		var rgba = diffImageData.data;

		// pixel adjustments are done by reference directly on diffImageData
		var score = 0;
		for (var i = 0; i < rgba.length; i += 4) {
			var pixelDiff = rgba[i] * 0.3 + rgba[i + 1] * 0.6 + rgba[i + 2] * 0.1;
			var normalized = Math.min(255, pixelDiff * (255 / pixelDiffThreshold));
			rgba[i] = 0;
			rgba[i + 1] = normalized;
			rgba[i + 2] = 0;

			if (pixelDiff >= pixelDiffThreshold) {
				score++;
			}
		}

		return score;
	}

	function getCaptureUrl(captureImageData) {
		// may as well borrow captureCanvas
		captureContext.putImageData(captureImageData, 0, 0);
		return captureCanvas.toDataURL();
	}

	function getPixelDiffThreshold() {
		return pixelDiffThreshold;
	}

	function setPixelDiffThreshold(val) {
		pixelDiffThreshold = val;
	}

	return {
		// public getters/setters
		getPixelDiffThreshold: getPixelDiffThreshold,
		setPixelDiffThreshold: setPixelDiffThreshold,

		// public functions
		init: init,
		start: start,
		stop: stop
	};
})();
<commit_msg>Video autoplay fix<commit_after>var DiffCamEngine = (function() {
	var stream;					// stream obtained from webcam
	var video;					// shows stream
	var captureCanvas;			// internal canvas for capturing full images from video
	var diffCanvas;				// internal canvas for diffing downscaled captures
	var motionCanvas;			// receives processed diff images

	var initSuccessCallback;	// called when init succeeds
	var initErrorCallback;		// called when init fails
	var startCompleteCallback;	// called when start is complete
	var captureCallback;		// called when an image has been captured and diffed

	var captureInterval;		// interval for continuous captures
	var captureIntervalTime;	// time between captures, in ms
	var captureWidth;			// full captured image width
	var captureHeight;			// full captured image height
	var diffWidth;				// downscaled width for diff/motion
	var diffHeight;				// downscaled height for diff/motion
	var isReadyToDiff;			// has a previous capture been made to diff against?
	var pixelDiffThreshold;		// min for a pixel to be considered significant

	function init(options) {
		// sanity check
		if (!options) {
			throw 'No options object provided';
		}

		// incoming options with defaults
		video = options.video || document.createElement('video');
		motionCanvas = options.motionCanvas || document.createElement('canvas');
		captureIntervalTime = options.captureIntervalTime || 100;
		captureWidth = options.captureWidth || 640;
		captureHeight = options.captureHeight || 480;
		diffWidth = options.diffWidth || 64;
		diffHeight = options.diffHeight || 48;
		pixelDiffThreshold = options.pixelDiffThreshold || 32;

		// callbacks
		initSuccessCallback = options.initSuccessCallback || function() {};
		initErrorCallback = options.initErrorCallback || function() {};
		startCompleteCallback = options.startCompleteCallback || function() {};
		captureCallback = options.captureCallback || function() {};

		// non-configurable
		captureCanvas = document.createElement('canvas');
		diffCanvas = document.createElement('canvas');
		isReadyToDiff = false;

		// prep video
		video.autoplay = true;

		// prep capture canvas
		captureCanvas.width = captureWidth;
		captureCanvas.height = captureHeight;
		captureContext = captureCanvas.getContext('2d');

		// prep diff canvas
		diffCanvas.width = diffWidth;
		diffCanvas.height = diffHeight;
		diffContext = diffCanvas.getContext('2d');

		// prep motion canvas
		motionCanvas.width = diffWidth;
		motionCanvas.height = diffHeight;
		motionContext = motionCanvas.getContext('2d');

		requestWebcam();
	}

	function requestWebcam() {
		var constraints = {
			audio: false,
			video: { width: captureWidth, height: captureHeight }
		};

		navigator.mediaDevices.getUserMedia(constraints)
			.then(initSuccess)
			.catch(initError);
	}

	function initSuccess(requestedStream) {
		stream = requestedStream;
		initSuccessCallback();
	}

	function initError(error) {
		console.log(error);
		initErrorCallback();
	}

	function start() {
		if (!stream) {
			throw 'Cannot start after init fail';
		}

		// streaming takes a moment to start
		video.addEventListener('canplay', startComplete);
		video.srcObject = stream;
	}

	function startComplete() {
		video.removeEventListener('canplay', startComplete);
		captureInterval = setInterval(capture, captureIntervalTime);
		startCompleteCallback();
	}

	function stop() {
		clearInterval(captureInterval);
		video.src = '';
		motionContext.clearRect(0, 0, diffWidth, diffHeight);
		isReadyToDiff = false;
	}

	function capture() {
		// save a full-sized copy of capture
		captureContext.drawImage(video, 0, 0, captureWidth, captureHeight);
		captureImageData = captureContext.getImageData(0, 0, captureWidth, captureHeight);

		// diff current capture over previous capture, leftover from last time
		diffContext.globalCompositeOperation = 'difference';
		diffContext.drawImage(video, 0, 0, diffWidth, diffHeight);
		diffImageData = diffContext.getImageData(0, 0, diffWidth, diffHeight);

		if (isReadyToDiff) {
			var score = processDiff(diffImageData);
			motionContext.putImageData(diffImageData, 0, 0);
			captureCallback({
				imageData: captureImageData,
				score: score,
				getURL: getCaptureUrl.bind(null, captureImageData)
			});
		}

		// draw current capture normally over diff, ready for next time
		diffContext.globalCompositeOperation = 'source-over';
		diffContext.drawImage(video, 0, 0, diffWidth, diffHeight);
		isReadyToDiff = true;
	}

	function processDiff(diffImageData) {
		var rgba = diffImageData.data;

		// pixel adjustments are done by reference directly on diffImageData
		var score = 0;
		for (var i = 0; i < rgba.length; i += 4) {
			var pixelDiff = rgba[i] * 0.3 + rgba[i + 1] * 0.6 + rgba[i + 2] * 0.1;
			var normalized = Math.min(255, pixelDiff * (255 / pixelDiffThreshold));
			rgba[i] = 0;
			rgba[i + 1] = normalized;
			rgba[i + 2] = 0;

			if (pixelDiff >= pixelDiffThreshold) {
				score++;
			}
		}

		return score;
	}

	function getCaptureUrl(captureImageData) {
		// may as well borrow captureCanvas
		captureContext.putImageData(captureImageData, 0, 0);
		return captureCanvas.toDataURL();
	}

	function getPixelDiffThreshold() {
		return pixelDiffThreshold;
	}

	function setPixelDiffThreshold(val) {
		pixelDiffThreshold = val;
	}

	return {
		// public getters/setters
		getPixelDiffThreshold: getPixelDiffThreshold,
		setPixelDiffThreshold: setPixelDiffThreshold,

		// public functions
		init: init,
		start: start,
		stop: stop
	};
})();
<|endoftext|>


<commit_before>// @flow

import pako from 'pako';
import untar from 'js-untar';
import {Buffer} from 'buffer/';
import LRU from 'lru-cache';

export type Credentials = {[key: string]: string};
export type Headers = {[key: string]: string};

export type LogFileHandle = {
  fileName: string;
  fileSize: number;
  taskName: string;
  fileTime: string;
  agentId: string;
  direct: ?string;
}

export type TarEntry = {
  name: string;
  buffer: ArrayBuffer;
}

export type IdName = {
  id: number;
  name: string;
}

export type NameOptionalId = {
  name: string;
  id: ?number;
};

export type UUID = string;

export type Workflow = {
  id: number;
  name: string;
  project: IdName;
  revision: string;
  config: Object;
};

export type Project = {
  id: number;
  name: string;
  revision: string;
  createdAt: string;
  updatedAt: string;
  archiveType: string;
  archiveMd5: string;
}

export type Task = {
  id: number;
  fullName: string;
  parentId: ?number;
  config: Object;
  upstreams: Array<number>;
  isGroup: boolean;
  state: string;
  exportParams: Object;
  storeParams: Object;
  stateParams: Object;
  updatedAt: string;
  retryAt: ?string;
};

export type Attempt = {
  id: number;
  project: IdName;
  workflow: NameOptionalId;
  sessionId: number;
  sessionUuid: UUID;
  sessionTime: string;
  retryAttemptName: ?string;
  done: boolean;
  success: boolean;
  cancelRequested: boolean;
  params: Object;
  createdAt: string;
  finishedAt: string;
};

export type Session = {
  id: number;
  project: IdName;
  workflow: NameOptionalId;
  sessionUuid: UUID;
  sessionTime: string;
  lastAttempt: ?{
    id: number;
    retryAttemptName: ?string;
    done: boolean;
    success: boolean;
    cancelRequested: boolean;
    params: Object;
    createdAt: string;
    finishedAt: string;
  };
};

export class ProjectArchive {
  files: Array<TarEntry>;
  fileMap: Map<string, TarEntry>;
  legacy: boolean;

  constructor(files: Array<TarEntry>) {
    this.files = files;
    this.fileMap = new Map();
    this.legacy = false;
    for (let file of files) {
      // If the archive has a digdag.yml (which is now just a normal file and no longer interpreted as a project definition) we assume that
      // the archive might stem from that legacy era and also contain <workflow>.yml files.
      if (file.name == 'digdag.yml') {
        this.legacy = true;
      }
      this.fileMap.set(file.name, file);
    }
  }

  getWorkflow(name: string): ?string {
    var buffer = this.getFileContents(`${name}.dig`);
    // Also look for <workflow>.yml if this archive might be a legacy archive.
    if (this.legacy && !buffer) {
      buffer = this.getFileContents(`${name}.yml`);
    }
    return buffer ? buffer.toString() : null;
  }

  getFileContents(name: string): ?Buffer {
    const file = this.fileMap.get(name);
    if (!file) {
      return null;
    }
    return new Buffer(file.buffer);
  }

  hasFile(name: string): boolean {
    return this.fileMap.has(name);
  }
}

export type HeadersProvider = (args: {credentials: Credentials}) => Headers;

export type ModelConfig = {
  url: string;
  credentials: Credentials;
  headers: HeadersProvider;
}

export class Model {
  config: ModelConfig;
  workflowCache: LRU;

  constructor(config: ModelConfig) {
    this.config = config;
    this.workflowCache = LRU({ max: 10000 });
  }

  fetchProjects(): Promise<Array<Project>> {
    return this.get(`projects/`);
  }

  fetchProject(projectId: number): Promise<Project> {
    return this.get(`projects/${projectId}`);
  }

  fetchWorkflow(workflowId: number): Promise<Workflow> {
    const id = workflowId.toString();
    let workflow = this.workflowCache.get(id);
    if (workflow) {
      return workflow;
    }
    workflow = this.get(`workflows/${id}`);
    this.workflowCache.set(id, workflow);
    workflow.catch(error => {
      this.workflowCache.delete(id);
    });
    return workflow;
  }

  fetchProjectWorkflows(projectId: number): Promise<Array<Workflow>> {
    return this.get(`projects/${projectId}/workflows`);
  }

  fetchProjectWorkflow(projectId: number, workflowName: string): Promise<Workflow> {
    return this.get(`projects/${projectId}/workflows/${encodeURIComponent(workflowName)}`);
  }

  fetchProjectWorkflowAttempts(projectName: string, workflowName: string): Promise<Array<Attempt>> {
    return this.get(`attempts?project=${encodeURIComponent(projectName)}&workflow=${encodeURIComponent(workflowName)}`);
  }

  fetchProjectWorkflowSessions(projectId: number, workflowName: string): Promise<Array<Session>> {
    return this.get(`projects/${projectId}/sessions?workflow=${encodeURIComponent(workflowName)}`);
  }

  fetchProjectSessions(projectId: number): Promise<Array<Session>> {
    return this.get(`projects/${projectId}/sessions`);
  }

  fetchProjectAttempts(projectName: string): Promise<Array<Attempt>> {
    return this.get(`attempts?project=${encodeURIComponent(projectName)}`);
  }

  fetchAttempts(): Promise<Array<Attempt>> {
    return this.get(`attempts`);
  }

  fetchSessions(): Promise<Array<Session>> {
    return this.get(`sessions`);
  }

  fetchAttempt(attemptId: number): Promise<Attempt> {
    return this.get(`attempts/${attemptId}`);
  }

  fetchSession(sessionId: number): Promise<Session> {
    return this.get(`sessions/${sessionId}`);
  }

  fetchSessionAttempts(sessionId: number): Promise<Array<Attempt>> {
    return this.get(`sessions/${sessionId}/attempts?include_retried=true`);
  }

  fetchAttemptTasks(attemptId: number): Promise<Array<Task>> {
    return this.get(`attempts/${attemptId}/tasks`);
  }

  fetchAttemptLogFileHandles(attemptId: number): Promise<Array<LogFileHandle>> {
    return this.get(`logs/${attemptId}/files`);
  }

  fetchAttemptTaskLogFileHandles(attemptId: number, taskName: string): Promise<Array<LogFileHandle>> {
    return this.get(`logs/${attemptId}/files?task=${encodeURIComponent(taskName)}`);
  }

  fetchLogFile(file: LogFileHandle) {
    if (!file.direct) {
      return new Promise((resolve, reject) => {
        reject(`Cannot fetch non-direct log file: ${file.fileName}`);
      });
    }
    return fetch(file.direct).then(response => {
      if (!response.ok) {
        throw new Error(response.statusText);
      }
      return response.arrayBuffer();
    });
  }

  fetchProjectArchiveLatest(projectId: number): Promise<ProjectArchive> {
    return fetch(this.config.url + `projects/${projectId}/archive`, {
      headers: this.headers(),
    }).then(response => {
      if (!response.ok) {
        throw new Error(response.statusText);
      }
      return response.arrayBuffer().then(data => {
        return untar(pako.inflate(data)).then(files => {
          return new ProjectArchive((files: Array<TarEntry>));
        });
      });
    });
  }

  fetchProjectArchiveWithRevision(projectId: number, revisionName: string): Promise<ProjectArchive> {
    return fetch(this.config.url + `projects/${projectId}/archive?revision=${encodeURIComponent(revisionName)}`, {
      headers: this.headers(),
    }).then(response => {
      if (!response.ok) {
        throw new Error(response.statusText);
      }
      return response.arrayBuffer().then(data => {
        return untar(pako.inflate(data).buffer);
      }).then(files => {
        return new ProjectArchive(files);
      });
    });
  }

  get(url: string): Promise {
    return fetch(this.config.url + url, {
      headers: this.headers(),
    }).then(response => {
      if (!response.ok) {
        throw new Error(response.statusText);
      }
      return response.json();
    });
  }

  headers(): Headers {
    return this.config.headers({credentials: this.config.credentials});
  }
}

var instance: ?Model = null;

export function setup(config: ModelConfig) {
  instance = new Model(config);
}

export function model(): Model {
  if (!instance) {
    throw new Error("Model not yet setup");
  }
  return instance;
}

<commit_msg>Add cookie pass thru to requests<commit_after>// @flow

import pako from 'pako';
import untar from 'js-untar';
import {Buffer} from 'buffer/';
import LRU from 'lru-cache';

export type Credentials = {[key: string]: string};
export type Headers = {[key: string]: string};

export type LogFileHandle = {
  fileName: string;
  fileSize: number;
  taskName: string;
  fileTime: string;
  agentId: string;
  direct: ?string;
}

export type TarEntry = {
  name: string;
  buffer: ArrayBuffer;
}

export type IdName = {
  id: number;
  name: string;
}

export type NameOptionalId = {
  name: string;
  id: ?number;
};

export type UUID = string;

export type Workflow = {
  id: number;
  name: string;
  project: IdName;
  revision: string;
  config: Object;
};

export type Project = {
  id: number;
  name: string;
  revision: string;
  createdAt: string;
  updatedAt: string;
  archiveType: string;
  archiveMd5: string;
}

export type Task = {
  id: number;
  fullName: string;
  parentId: ?number;
  config: Object;
  upstreams: Array<number>;
  isGroup: boolean;
  state: string;
  exportParams: Object;
  storeParams: Object;
  stateParams: Object;
  updatedAt: string;
  retryAt: ?string;
};

export type Attempt = {
  id: number;
  project: IdName;
  workflow: NameOptionalId;
  sessionId: number;
  sessionUuid: UUID;
  sessionTime: string;
  retryAttemptName: ?string;
  done: boolean;
  success: boolean;
  cancelRequested: boolean;
  params: Object;
  createdAt: string;
  finishedAt: string;
};

export type Session = {
  id: number;
  project: IdName;
  workflow: NameOptionalId;
  sessionUuid: UUID;
  sessionTime: string;
  lastAttempt: ?{
    id: number;
    retryAttemptName: ?string;
    done: boolean;
    success: boolean;
    cancelRequested: boolean;
    params: Object;
    createdAt: string;
    finishedAt: string;
  };
};

export class ProjectArchive {
  files: Array<TarEntry>;
  fileMap: Map<string, TarEntry>;
  legacy: boolean;

  constructor(files: Array<TarEntry>) {
    this.files = files;
    this.fileMap = new Map();
    this.legacy = false;
    for (let file of files) {
      // If the archive has a digdag.yml (which is now just a normal file and no longer interpreted as a project definition) we assume that
      // the archive might stem from that legacy era and also contain <workflow>.yml files.
      if (file.name == 'digdag.yml') {
        this.legacy = true;
      }
      this.fileMap.set(file.name, file);
    }
  }

  getWorkflow(name: string): ?string {
    var buffer = this.getFileContents(`${name}.dig`);
    // Also look for <workflow>.yml if this archive might be a legacy archive.
    if (this.legacy && !buffer) {
      buffer = this.getFileContents(`${name}.yml`);
    }
    return buffer ? buffer.toString() : null;
  }

  getFileContents(name: string): ?Buffer {
    const file = this.fileMap.get(name);
    if (!file) {
      return null;
    }
    return new Buffer(file.buffer);
  }

  hasFile(name: string): boolean {
    return this.fileMap.has(name);
  }
}

export type HeadersProvider = (args: {credentials: Credentials}) => Headers;

export type ModelConfig = {
  url: string;
  credentials: Credentials;
  headers: HeadersProvider;
}

export class Model {
  config: ModelConfig;
  workflowCache: LRU;

  constructor(config: ModelConfig) {
    this.config = config;
    this.workflowCache = LRU({ max: 10000 });
  }

  fetchProjects(): Promise<Array<Project>> {
    return this.get(`projects/`);
  }

  fetchProject(projectId: number): Promise<Project> {
    return this.get(`projects/${projectId}`);
  }

  fetchWorkflow(workflowId: number): Promise<Workflow> {
    const id = workflowId.toString();
    let workflow = this.workflowCache.get(id);
    if (workflow) {
      return workflow;
    }
    workflow = this.get(`workflows/${id}`);
    this.workflowCache.set(id, workflow);
    workflow.catch(error => {
      this.workflowCache.delete(id);
    });
    return workflow;
  }

  fetchProjectWorkflows(projectId: number): Promise<Array<Workflow>> {
    return this.get(`projects/${projectId}/workflows`);
  }

  fetchProjectWorkflow(projectId: number, workflowName: string): Promise<Workflow> {
    return this.get(`projects/${projectId}/workflows/${encodeURIComponent(workflowName)}`);
  }

  fetchProjectWorkflowAttempts(projectName: string, workflowName: string): Promise<Array<Attempt>> {
    return this.get(`attempts?project=${encodeURIComponent(projectName)}&workflow=${encodeURIComponent(workflowName)}`);
  }

  fetchProjectWorkflowSessions(projectId: number, workflowName: string): Promise<Array<Session>> {
    return this.get(`projects/${projectId}/sessions?workflow=${encodeURIComponent(workflowName)}`);
  }

  fetchProjectSessions(projectId: number): Promise<Array<Session>> {
    return this.get(`projects/${projectId}/sessions`);
  }

  fetchProjectAttempts(projectName: string): Promise<Array<Attempt>> {
    return this.get(`attempts?project=${encodeURIComponent(projectName)}`);
  }

  fetchAttempts(): Promise<Array<Attempt>> {
    return this.get(`attempts`);
  }

  fetchSessions(): Promise<Array<Session>> {
    return this.get(`sessions`);
  }

  fetchAttempt(attemptId: number): Promise<Attempt> {
    return this.get(`attempts/${attemptId}`);
  }

  fetchSession(sessionId: number): Promise<Session> {
    return this.get(`sessions/${sessionId}`);
  }

  fetchSessionAttempts(sessionId: number): Promise<Array<Attempt>> {
    return this.get(`sessions/${sessionId}/attempts?include_retried=true`);
  }

  fetchAttemptTasks(attemptId: number): Promise<Array<Task>> {
    return this.get(`attempts/${attemptId}/tasks`);
  }

  fetchAttemptLogFileHandles(attemptId: number): Promise<Array<LogFileHandle>> {
    return this.get(`logs/${attemptId}/files`);
  }

  fetchAttemptTaskLogFileHandles(attemptId: number, taskName: string): Promise<Array<LogFileHandle>> {
    return this.get(`logs/${attemptId}/files?task=${encodeURIComponent(taskName)}`);
  }

  fetchLogFile(file: LogFileHandle) {
    if (!file.direct) {
      return new Promise((resolve, reject) => {
        reject(`Cannot fetch non-direct log file: ${file.fileName}`);
      });
    }
    return fetch(file.direct).then(response => {
      if (!response.ok) {
        throw new Error(response.statusText);
      }
      return response.arrayBuffer();
    });
  }

  fetchProjectArchiveLatest(projectId: number): Promise<ProjectArchive> {
    return fetch(this.config.url + `projects/${projectId}/archive`, {
      headers: this.headers(),
    }).then(response => {
      if (!response.ok) {
        throw new Error(response.statusText);
      }
      return response.arrayBuffer().then(data => {
        return untar(pako.inflate(data)).then(files => {
          return new ProjectArchive((files: Array<TarEntry>));
        });
      });
    });
  }

  fetchProjectArchiveWithRevision(projectId: number, revisionName: string): Promise<ProjectArchive> {
    return fetch(this.config.url + `projects/${projectId}/archive?revision=${encodeURIComponent(revisionName)}`, {
      headers: this.headers(),
    }).then(response => {
      if (!response.ok) {
        throw new Error(response.statusText);
      }
      return response.arrayBuffer().then(data => {
        return untar(pako.inflate(data).buffer);
      }).then(files => {
        return new ProjectArchive(files);
      });
    });
  }

  get(url: string): Promise {
    return fetch(this.config.url + url, {
      credentials: 'include',
      headers: this.headers(),
    }).then(response => {
      if (!response.ok) {
        throw new Error(response.statusText);
      }
      return response.json();
    });
  }

  headers(): Headers {
    return this.config.headers({credentials: this.config.credentials});
  }
}

var instance: ?Model = null;

export function setup(config: ModelConfig) {
  instance = new Model(config);
}

export function model(): Model {
  if (!instance) {
    throw new Error("Model not yet setup");
  }
  return instance;
}

<|endoftext|>


<commit_before>var listOfDinos = require(__dirname + '/dinos.json');

exports.getDinos = function (options) {
  var paragraphs = [];
  var numberOfParagraphs = options.paragraphs || 10;
  var wordsPerParagraph  = options.words      || 30;

  for (var i = 0; i < numberOfParagraphs; i++) {
    paragraphs[i] = [];

    for (var j = 0; j < wordsPerParagraph; j++) {
      paragraphs[i].push(listOfDinos[~~(Math.random() * listOfDinos.length)]);
    }
  }

  return paragraphs.map(function (p) {
    return '
' + p.join(' ') + '
';
  }).join('');
};

<commit_msg>updated dinoipsum module<commit_after>var listOfDinos = require(__dirname + '/dinos.json');

/**
 * Generates a list of random dinosaur names.
 * @param  {Object} options
 *                   - paragraphs {Number} the number of paragraphs to generate (defaults to 10).
 *                   - words      {Number} the number of words per paragraph (defaults to 30).
 * @return {String}
 */
var generateListOfDinos = function generateListOfDinos(options) {
  var paragraphs = [];
  var numberOfParagraphs = options.paragraphs || 10;
  var wordsPerParagraph  = options.words      || 30;

  for (var i = 0; i < numberOfParagraphs; i++) {
    paragraphs[i] = [];

    for (var j = 0; j < wordsPerParagraph; j++) {
      paragraphs[i].push(listOfDinos[~~(Math.random() * listOfDinos.length)]);
    }
  }

  return paragraphs;
};

/**
 * Converts an array of paragraphs to an HTML string.
 * @param  {Array}  paragraphs an array of paragraphs.
 * @return {String}
 */
var toHTML = function toHTML(paragraphs) {
  return paragraphs.map(function (p) {
    return '
' + p.join(' ') + '
';
  }).join('');
};

/**
 * Converts an array of paragraphs to a stringified JSON object.
 * @param  {Array}  paragraphs an array of paragraphs.
 * @return {String}
 */
var toJSON = function toJSON(paragraphs) {
  return JSON.stringify(paragraphs);
};

/**
 * Converts an array of paragraphs to plain text.
 * @param  {Array}  paragraphs an array of paragraphs.
 * @return {String}
 */
var toPlainText = function toPlainText(paragraphs) {
  return paragraphs.map(function (p) {
    return p.join(' ') + '\n\n';
  }).join('');
};

/**
 * Get a list of dinosaurs.
 * @param  {Object} options
 *                   - paragraphs {Number} the number of paragraphs to generate (defaults to 10).
 *                   - words      {Number} the number of words per paragraph (defaults to 30).
 *                   - format     {String} the requested format response (defaults to ('html').
 * @return {String}
 */
exports.getDinos = function (options) {
  var format     = options.format || 'html';
  var paragraphs = generateListOfDinos(options);

  if (format === 'html' ) return toHTML(paragraphs);
  if (format === 'json' ) return toJSON(paragraphs);
  if (format === 'text')  return toPlainText(paragraphs);
};

<|endoftext|>


<commit_before>var devtoolsPort = [];
var notifId = '';
chrome.runtime.onConnect.addListener(function (port) {
	devtoolsPort.push(port);
});

var dsDebug = (chrome.runtime.id === 'ikbablmmjldhamhcldjjigniffkkjgpo' ? false : true);

function addBlocking() {
	removeBlocking();
	if (chrome.declarativeWebRequest)
		chrome.declarativeWebRequest.onRequest.addRules([{
			id: 'dataslayerBlocking',
			conditions: [
				new chrome.declarativeWebRequest.RequestMatcher({
					url: {
						hostSuffix: 'google-analytics.com',
						pathPrefix: '/collect',
						schemes: ['http', 'https']
					},
				}),
				new chrome.declarativeWebRequest.RequestMatcher({
					url: {
						hostSuffix: 'google-analytics.com',
						pathPrefix: '/__utm.gif',
						schemes: ['http', 'https']
					},
				}),
				new chrome.declarativeWebRequest.RequestMatcher({
					url: {
						hostSuffix: 'stats.g.doubleclick.net',
						pathPrefix: '/__utm.gif',
						schemes: ['http', 'https']
					},
				}),
				new chrome.declarativeWebRequest.RequestMatcher({
					url: {
						hostSuffix: 'doubleclick.net',
						pathPrefix: '/activity',
						schemes: ['http', 'https']
					},
				}),
				new chrome.declarativeWebRequest.RequestMatcher({
					url: {
						pathPrefix: '/b/ss',
						queryContains: 'AQB=1',
						schemes: ['http', 'https']
					},
				})
			],
			actions: [
				new chrome.declarativeWebRequest.RedirectToTransparentImage()
			]
		}]);
}

function removeBlocking() {
	if (chrome.declarativeWebRequest)
		chrome.declarativeWebRequest.onRequest.removeRules(['dataslayerBlocking']);
}

chrome.storage.sync.get(null, function (items) {
	if (items.hasOwnProperty('blockTags') && items.blockTags === true) addBlocking();
	else removeBlocking();
});

chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
	if (dsDebug) console.log(message);
	if (message.type === 'dataslayer_gtm_push' || message.type === 'dataslayer_gtm' || message.type === 'dataslayer_tlm' || message.type === 'dataslayer_tco' || message.type === 'dataslayer_var' || message.type === 'dataslayer_dtm') {
		message.tabID = sender.tab.id;
		devtoolsPort.forEach(function (v, i, x) {
			try {
				v.postMessage(message);
			} catch (e) {
				console.log(e);
			}
		});
	} else if (message.type === 'dataslayer_pageload' || message.type === 'dataslayer_opened') {
		chrome.tabs.executeScript(message.tabID, {
			file: 'content.js',
			runAt: 'document_idle',
			allFrames: true
		});
	} else if (message.type === 'dataslayer_refresh') {
		chrome.tabs.sendMessage(message.tabID, {
			ask: 'refresh'
		});
	} else if (message.type === 'dataslayer_unload')
		chrome.tabs.executeScript(message.tabID, {
			code: 'document.head.removeChild(document.getElementById(\'dataslayer_script\'));',
			runAt: "document_idle"
		});
	else if (message.type === 'dataslayer_loadsettings') {
		if (message.data.blockTags)
			addBlocking();
		else
			removeBlocking();
		devtoolsPort.forEach(function (v, i, x) {
			v.postMessage(message);
		});
	}
});

chrome.runtime.onInstalled.addListener(function (details) {
	if (details.reason === 'install')
		chrome.tabs.create({
			url: 'https://dataslayer.org/release-notes/',
			active: true
		});
	if ((details.reason === 'update') && (!dsDebug)) {
		chrome.notifications.create('', {
				type: 'basic',
				title: 'dataslayer' + (dsDebug ? ' beta' : ''),
				message: 'dataslayer' + (dsDebug ? ' beta' : '') + ' has been updated to version ' + chrome.runtime.getManifest().version + '.\n\nClick here to see what\'s new.',
				iconUrl: 'i128.png'
			},
			function (notificationId) {
				notifId = notificationId;
			}
		);
		chrome.notifications.onClicked.addListener(function (notificationId) {
			if (notificationId == notifId) chrome.tabs.create({
				url: 'https://dataslayer.org/release-notes/',
				active: true
			});
		});
	}
});<commit_msg>hopefully prevent unhandled chrome runtime errors #55<commit_after>var devtoolsPort = [];
var notifId = '';
chrome.runtime.onConnect.addListener(function (port) {
	devtoolsPort.push(port);
});

var dsDebug = (chrome.runtime.id === 'ikbablmmjldhamhcldjjigniffkkjgpo' ? false : true);

function addBlocking() {
	removeBlocking();
	if (chrome.declarativeWebRequest)
		chrome.declarativeWebRequest.onRequest.addRules([{
			id: 'dataslayerBlocking',
			conditions: [
				new chrome.declarativeWebRequest.RequestMatcher({
					url: {
						hostSuffix: 'google-analytics.com',
						pathPrefix: '/collect',
						schemes: ['http', 'https']
					},
				}),
				new chrome.declarativeWebRequest.RequestMatcher({
					url: {
						hostSuffix: 'google-analytics.com',
						pathPrefix: '/__utm.gif',
						schemes: ['http', 'https']
					},
				}),
				new chrome.declarativeWebRequest.RequestMatcher({
					url: {
						hostSuffix: 'stats.g.doubleclick.net',
						pathPrefix: '/__utm.gif',
						schemes: ['http', 'https']
					},
				}),
				new chrome.declarativeWebRequest.RequestMatcher({
					url: {
						hostSuffix: 'doubleclick.net',
						pathPrefix: '/activity',
						schemes: ['http', 'https']
					},
				}),
				new chrome.declarativeWebRequest.RequestMatcher({
					url: {
						pathPrefix: '/b/ss',
						queryContains: 'AQB=1',
						schemes: ['http', 'https']
					},
				})
			],
			actions: [
				new chrome.declarativeWebRequest.RedirectToTransparentImage()
			]
		}]);
}

function removeBlocking() {
	if (chrome.declarativeWebRequest)
		chrome.declarativeWebRequest.onRequest.removeRules(['dataslayerBlocking']);
}

chrome.storage.sync.get(null, function (items) {
	if (items.hasOwnProperty('blockTags') && items.blockTags === true) addBlocking();
	else removeBlocking();
});

chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
	if (dsDebug) console.log(message);
	if (message.type === 'dataslayer_gtm_push' || message.type === 'dataslayer_gtm' || message.type === 'dataslayer_tlm' || message.type === 'dataslayer_tco' || message.type === 'dataslayer_var' || message.type === 'dataslayer_dtm') {
		message.tabID = sender.tab.id;
		devtoolsPort.forEach(function (v, i, x) {
			try {
				v.postMessage(message);
			} catch (e) {
				console.log(e);
			}
		});
	} else if (message.type === 'dataslayer_pageload' || message.type === 'dataslayer_opened') {
		chrome.tabs.executeScript(message.tabID, {
			file: 'content.js',
			runAt: 'document_idle',
			allFrames: true
		});
	} else if (message.type === 'dataslayer_refresh') {
		chrome.tabs.sendMessage(message.tabID, {
			ask: 'refresh'
		});
	} else if (message.type === 'dataslayer_unload')
		chrome.tabs.executeScript(message.tabID, {
			code: 'document.head.removeChild(document.getElementById(\'dataslayer_script\'));',
			runAt: "document_idle"
		});
	else if (message.type === 'dataslayer_loadsettings') {
		if (message.data.blockTags)
			addBlocking();
		else
			removeBlocking();
		devtoolsPort.forEach(function (v, i, x) {
			v.postMessage(message);
		});
	} else {
		console.log(message);
		// prevent unhandled chrome runtime errors
		if (sendResponse) {
			sendResponse();
		}
	}
});

chrome.runtime.onInstalled.addListener(function (details) {
	if (details.reason === 'install')
		chrome.tabs.create({
			url: 'https://dataslayer.org/release-notes/',
			active: true
		});
	if ((details.reason === 'update') && (!dsDebug)) {
		chrome.notifications.create('', {
				type: 'basic',
				title: 'dataslayer' + (dsDebug ? ' beta' : ''),
				message: 'dataslayer' + (dsDebug ? ' beta' : '') + ' has been updated to version ' + chrome.runtime.getManifest().version + '.\n\nClick here to see what\'s new.',
				iconUrl: 'i128.png'
			},
			function (notificationId) {
				notifId = notificationId;
			}
		);
		chrome.notifications.onClicked.addListener(function (notificationId) {
			if (notificationId == notifId) chrome.tabs.create({
				url: 'https://dataslayer.org/release-notes/',
				active: true
			});
		});
	}
});<|endoftext|>


<commit_before>#!/usr/bin/env node
var prerender = require('./lib');
var config = require('config');
var logger = require('./lib/logger')('prerender');

var server = prerender({
    workers: config.phantom_cluster_num_workers,
    iterations: config.phantom_worker_iterations || 10,
    phantomBasePort: config.phantom_cluster_base_port || 12300,
    messageTimeout: config.phantom_cluster_message_timeout
});

// server.use(prerender.basicAuth());
// server.use(prerender.whitelist());
server.use(prerender.blacklist());
server.use(prerender.logger());
server.use(prerender.removeScriptTags());
server.use(prerender.httpHeaders());

if (process.env.NODE_ENV !== 'development') {
  logger.info('Setting up s3HtmlCache'.green);
  server.use(prerender.s3HtmlCache());
}

if (config.aws) {
  server.use(prerender.snsNotify());
}

server.start();

process.on('uncaughtException', function (err) {
  console.log('uncaughtException: ', err);
  logger.error(err);
  logger.error(err.stack);
  process.exit(1);
});
<commit_msg>commenting out s3 cache until I can fix phantom<commit_after>#!/usr/bin/env node
var prerender = require('./lib');
var config = require('config');
var logger = require('./lib/logger')('prerender');

var server = prerender({
    workers: config.phantom_cluster_num_workers,
    iterations: config.phantom_worker_iterations || 10,
    phantomBasePort: config.phantom_cluster_base_port || 12300,
    messageTimeout: config.phantom_cluster_message_timeout
});

// server.use(prerender.basicAuth());
// server.use(prerender.whitelist());
server.use(prerender.blacklist());
server.use(prerender.logger());
server.use(prerender.removeScriptTags());
server.use(prerender.httpHeaders());

// if (process.env.NODE_ENV !== 'development') {
//   logger.info('Setting up s3HtmlCache'.green);
//   server.use(prerender.s3HtmlCache());
// }

if (config.aws) {
  server.use(prerender.snsNotify());
}

server.start();

process.on('uncaughtException', function (err) {
  console.log('uncaughtException: ', err);
  logger.error(err);
  logger.error(err.stack);
  process.exit(1);
});
<|endoftext|>


<commit_before>(function($) {
    "use strict";

    var rideCountupStarted = false,
        originalCount = 0;

    $('body').scrollspy({
        target: '.navbar-fixed-top',
        offset: 60
    });

    $('#topNav').affix({
        offset: {
            top: 200
        }
    });

    new WOW().init();

    var isScrolledIntoView = function (elem) {
        var docViewTop = $(window).scrollTop();
        var docViewBottom = docViewTop + $(window).height();

        var elemTop = $(elem).offset().top;
        var elemBottom = elemTop + $(elem).height();

        return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
    };

    var startRideCountup = function () {
        console.log('starting ride countup');
        var counter = $('#ride-count');
        var count = parseInt(counter.text());

        if(originalCount <= count) {
            return;
        }

        counter.removeClass();
        counter.text(count + 1);
        counter.addClass('fadeInUp');

        setTimeout(startRideCountup, 1);
    };

    $('a.page-scroll').bind('click', function(event) {
        var $ele = $(this);
        $('html, body').stop().animate({
            scrollTop: ($($ele.attr('href')).offset().top - 60)
        }, 1450, 'easeInOutExpo');
        event.preventDefault();
    });

    $('.navbar-collapse ul li a').click(function() {
        /* always close responsive nav after click */
        $('.navbar-toggle:visible').click();
    });

    $('#galleryModal').on('show.bs.modal', function (e) {
       $('#galleryImage').attr("src",$(e.relatedTarget).data("src"));
    });

    $(window).scroll(function () {
        var counter = $('#ride-count');
        if(isScrolledIntoView(counter) && !rideCountupStarted) {
            rideCountupStarted = true;
            startRideCountup();
        }
    });;

    var counter = $('#ride-count');
    originalCount = parseInt(counter.text());
    counter.text("0");

})(jQuery);<commit_msg>Added an event to resize the iframes on mobile.<commit_after>window.isMobileBrowser = function() {
    var check = false;
    (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera);
    return check;
  };

(function($) {
    "use strict";

    if(isMobileBrowser()) {
        // Change all images to small images?
        // Reduce the size of the iframes
        $('iframe').each(function(iframeEl){
            iframeEl.width = 320;
        });
    }

    var rideCountupStarted = false,
        originalCount = 0;

    $('body').scrollspy({
        target: '.navbar-fixed-top',
        offset: 60
    });

    $('#topNav').affix({
        offset: {
            top: 200
        }
    });

    new WOW().init();

    var isScrolledIntoView = function (elem) {
        var docViewTop = $(window).scrollTop();
        var docViewBottom = docViewTop + $(window).height();

        var elemTop = $(elem).offset().top;
        var elemBottom = elemTop + $(elem).height();

        return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
    };

    var startRideCountup = function () {
        console.log('starting ride countup');
        var counter = $('#ride-count');
        var count = parseInt(counter.text());

        if(originalCount <= count) {
            return;
        }

        counter.removeClass();
        counter.text(count + 1);
        counter.addClass('fadeInUp');

        setTimeout(startRideCountup, 1);
    };

    $('a.page-scroll').bind('click', function(event) {
        var $ele = $(this);
        $('html, body').stop().animate({
            scrollTop: ($($ele.attr('href')).offset().top - 60)
        }, 1450, 'easeInOutExpo');
        event.preventDefault();
    });

    $('.navbar-collapse ul li a').click(function() {
        /* always close responsive nav after click */
        $('.navbar-toggle:visible').click();
    });

    $('#galleryModal').on('show.bs.modal', function (e) {
       $('#galleryImage').attr("src",$(e.relatedTarget).data("src"));
    });

    $(window).scroll(function () {
        var counter = $('#ride-count');
        if(isScrolledIntoView(counter) && !rideCountupStarted) {
            rideCountupStarted = true;
            startRideCountup();
        }
    });;

    var counter = $('#ride-count');
    originalCount = parseInt(counter.text());
    counter.text("0");

})(jQuery);<|endoftext|>