<commit_before>// Opening for events
const eventTitle = getElementByClassName('event-title', 0)
const eventSubtitle = getElementByClassName('event-subtitle', 0)
const eventDetails = getElementByClassName('event-details', 0)
// Remove display classes on init for hero tabs
eventTitle.classList.remove('fade-move')
eventSubtitle.classList.remove('fade-move')
eventDetails.classList.remove('fade-move')
// Fade in first slide
setTimeout(() => {
	eventTitle.classList.add('display')
	eventSubtitle.classList.add('display')
	eventDetails.classList.add('display')
}, 100)
// 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 regFormButtons = getElementsByClassName('button register')
for (let i = 0; i < regFormButtons.length; i++) {
	onClick(regFormButtons[i], () => {
		// Prevent background from scrolling
		document.body.style.overflow = 'hidden'
		// Prepare for fade in
		regFormModal.style.opacity = '0'
		// Unhide modal
		setTimeout(() => regFormModalStatus.style.display = 'block', 100)
		// Fade in modal window
		setTimeout(() => regFormModal.style.opacity = '1.0', 200)
		// Show reg form: browser error that doesn’t show opacity of children unless scrolled to
		setTimeout(() => {
			onScroll(regFormModalWindow, () => {
				console.log('scrolling')
				regFormModalWindow.style.opacity = '1.0'
			})
		}, 300)
	})
}

const regFormClose = getElementByClassName('reg-form-close', 0)
onClick(regFormClose, () => {
	document.body.style.overflow = 'visible'
	regFormModal.style.opacity = '0'
	setTimeout(() => regFormModalStatus.style.display = 'none', 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 title.<commit_after>// Opening for events
const eventTitle = getElementByClassName('event-title', 0)
const eventSubtitle = getElementByClassName('event-subtitle', 0)
const eventDetails = getElementByClassName('event-details', 0)
// Remove display classes on init for hero tabs
eventTitle.classList.remove('fade-move')
eventSubtitle.classList.remove('fade-move')
eventDetails.classList.remove('fade-move')
// Fade in first slide
setTimeout(() => {
	eventTitle.classList.add('display')
	eventSubtitle.classList.add('display')
	eventDetails.classList.add('display')
}, 100)
// 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 regFormButtons = getElementsByClassName('button register')
for (let i = 0; i < regFormButtons.length; i++) {
	onClick(regFormButtons[i], () => {
		// Prevent background from scrolling
		document.body.style.overflow = 'hidden'
		// Prepare for fade in
		regFormModal.style.opacity = '0'
		// Unhide modal
		setTimeout(() => regFormModalStatus.style.display = 'block', 100)
		// Fade in modal window
		setTimeout(() => regFormModal.style.opacity = '1.0', 200)
		// Show reg form: browser error that doesn’t show opacity of children unless scrolled to
		setTimeout(() => {
			onScroll(regFormModalWindow, () => {
				console.log('scrolling')
				regFormModalWindow.style.width = '100%'
				regFormModalWindow.style.opacity = '1.0'
			})
		}, 300)
	})
}

const regFormClose = getElementByClassName('reg-form-close', 0)
onClick(regFormClose, () => {
	document.body.style.overflow = 'visible'
	regFormModal.style.opacity = '0'
	setTimeout(() => regFormModalStatus.style.display = 'none', 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><commit_msg>update file /application.js<commit_after><|endoftext|>


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

		$scope.sections = [{name: "Introduction", htmlText: "
This site is a guide to all developers wishing to contribute to or integrate with the inknote project.
"
								+ "
The aim of this project is to create a free, open source, browser based scoring program that will be both user and developer friendly.
"
		},
		{name: "Debugging", htmlText: "
Turn it on
"
			+ "
To turn debugging mode on, go to
"
			+ "
Developers → Log → On
"
			+ "
Change style
"
			+ "
To change debugging style, go to
"
			+ "
Developers → Log → UI/Console
"
			+ "
UI mode will use alertify logs to display the log, while console will print the logs to the console. Please be aware that when using UI logging, there is no record of the logs.
"
		},
		{name: "Adding plugins", htmlText: "
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;
		}

		$scope.to_trusted = function(html_code) {
		    return $sce.trustAsHtml(html_code);
		}

		$scope.getCurrentSectionIndex = function(){
			for(var i = 0; i < $scope.sections.length; i++){
				if($scope.sections[i] == $scope.currentSection){
					return i;
				}
			}
		}

		$scope.currentSectionIsFirst = function(){
			return $scope.getCurrentSectionIndex() == 0;
		}

		$scope.previousSection = function(){
			$scope.currentSection = $scope.sections[$scope.getCurrentSectionIndex - 1];
			$scope.$apply($scope.currentSection);
		}

		$scope.currentSectionIsLast = function(){
			return $scope.getCurrentSectionIndex() == $scope.sections.length - 1;
		}

		$scope.nextSection = function(){
			$scope.currentSection = $scope.sections[$scope.getCurrentSectionIndex - 1];
			$scope.$apply($scope.currentSection);
		}
	})
<commit_msg>Update guide.js<commit_after>developerKingdomModule.
	controller("guideCtrl", function guideCtrl($scope, $window, $sce){

		$scope.sections = [{name: "Introduction", htmlText: "
This site is a guide to all developers wishing to contribute to or integrate with the inknote project.
"
								+ "
The aim of this project is to create a free, open source, browser based scoring program that will be both user and developer friendly.
"
		},
		{name: "Debugging", htmlText: "
Turn it on
"
			+ "
To turn debugging mode on, go to
"
			+ "
Developers → Log → On
"
			+ "
Change style
"
			+ "
To change debugging style, go to
"
			+ "
Developers → Log → UI/Console
"
			+ "
UI mode will use alertify logs to display the log, while console will print the logs to the console. Please be aware that when using UI logging, there is no record of the logs.
"
		},
		{name: "Adding plugins", htmlText: "
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;
		}

		$scope.to_trusted = function(html_code) {
		    return $sce.trustAsHtml(html_code);
		}

		$scope.getCurrentSectionIndex = function(){
			for(var i = 0; i < $scope.sections.length; i++){
				if($scope.sections[i] == $scope.currentSection){
					return i;
				}
			}
		}

		$scope.currentSectionIsFirst = function(){
			return $scope.getCurrentSectionIndex() == 0;
		}

		$scope.previousSection = function(){
			$scope.currentSection = $scope.sections[$scope.getCurrentSectionIndex() - 1];
		}

		$scope.currentSectionIsLast = function(){
			return $scope.getCurrentSectionIndex() == $scope.sections.length - 1;
		}

		$scope.nextSection = function(){
			$scope.currentSection = $scope.sections[$scope.getCurrentSectionIndex() - 1];
		}
	})
<|endoftext|>


<commit_before>/**
 * Memory Usage sensor
 *
 * (c) 2014 James Hall
 */
'use strict'

const os = require('os-utils')
const _os = require('os')
const child = require('child_process')

const plugin = {
  /**
   * This appears in the title of the graph
   */
  title: 'Memory Usage',
  /**
   * The type of sensor
   * @type {String}
   */
  type: 'chart',
  /**
   * The default interval time in ms that this plugin should be polled.
   * More costly benchmarks should be polled less frequently.
   */
  interval: 200,

  initialized: false,

  currentValue: 0,

  isLinux: _os.platform().includes('linux'),

  isMac: _os.platform().includes('darwin'),

  /**
   * Grab the current value, from 0-100
   */
  poll () {
    const computeUsage = (used, total) => Math.round(100 * (used / total))

    if (plugin.isLinux) {
      child.exec('free -m', (err, stdout, stderr) => {
        if (err) {
          console.error(err)
        }
        const data = stdout.split('\n')[1].replace(/[\s\n\r]+/g, ' ').split(' ')
        const used = parseInt(data[2], 10)
        const total = parseInt(data[1], 10)
        plugin.currentValue = computeUsage(used, total)
      })
    } else if (plugin.isMac) {
      child.exec("ps -caxm -orss,comm", (err, stdout, stderr) => {
        let sp = stdout.split("\n")
        let total = 0; // kb
        for (var i = 0; i < sp.length; i++) {
          if (!isNaN(parseInt(sp[i].replace(/([a-zA-Z]).*/, "")))) {
            total += parseInt(sp[i].replace(/([a-zA-Z]).*/, ""))
          }
        }
        let usedmem = total / 1024 ^ 2
        let freemem = os.totalmem() - usedmem
        let per = freemem / os.totalmem()
        plugin.currentValue = Math.round((1 - per) * 100)
      })
    } else {
      plugin.currentValue = Math.round((1 - os.freememPercentage()) * 100)
    }

    plugin.initialized = true
  }
}

module.exports = exports = plugin
<commit_msg>Tidy code<commit_after>/**
 * Memory Usage sensor
 *
 * (c) 2014 James Hall
 */
'use strict'

const os = require('os-utils')
const _os = require('os')
const child = require('child_process')

const plugin = {
  /**
   * This appears in the title of the graph
   */
  title: 'Memory Usage',
  /**
   * The type of sensor
   * @type {String}
   */
  type: 'chart',
  /**
   * The default interval time in ms that this plugin should be polled.
   * More costly benchmarks should be polled less frequently.
   */
  interval: 200,

  initialized: false,

  currentValue: 0,

  isLinux: _os.platform().includes('linux'),

  isMac: _os.platform().includes('darwin'),

  /**
   * Grab the current value, from 0-100
   */
  poll () {
    const computeUsage = (used, total) => Math.round(100 * (used / total))

    if (plugin.isLinux) {
      child.exec('free -m', (err, stdout, stderr) => {
        if (err) {
          console.error(err)
        }
        const data = stdout.split('\n')[1].replace(/[\s\n\r]+/g, ' ').split(' ')
        const used = parseInt(data[2], 10)
        const total = parseInt(data[1], 10)
        plugin.currentValue = computeUsage(used, total)
      })
    } else if (plugin.isMac) {
      child.exec('ps -caxm -orss,comm', (err, stdout, stderr) => {
        if (err) {
          throw err
        }
        let sp = stdout.split('\n')
        let total = 0 // kb
        for (var i = 0; i < sp.length; i++) {
          if (!isNaN(parseInt(sp[i].replace(/([a-zA-Z]).*/, '')))) {
            total += parseInt(sp[i].replace(/([a-zA-Z]).*/, ''))
          }
        }
        let usedmem = total / 1024 ^ 2
        let freemem = os.totalmem() - usedmem
        let per = freemem / os.totalmem()
        plugin.currentValue = Math.round((1 - per) * 100)
      })
    } else {
      plugin.currentValue = Math.round((1 - os.freememPercentage()) * 100)
    }

    plugin.initialized = true
  }
}

module.exports = exports = plugin
<|endoftext|>


<commit_before>/**
 * @class
 * @classdesc: webpack2 快速开发网站项目模板入口
 * @extends
 * @example:
 * @author: maksim email:maksim.lin@foxmail.com
 * @copyright: Ds是累积平时项目工作的经验代码库，不属于职位任务与项目的内容。里面代码大部分理念来至曾经flash 前端时代，尽力减小类之间耦合，通过webpack按需request使用。Ds库里内容多来至网络与参考其他开源代码库。Ds库也开源开放，随意使用在所属的职位任务与项目中。
 * @constructor
 **/
_time = new Date().getTime();
//网址主模块
window.SiteModel = {
    // ShowProgress: 自动创建 通过SiteModel.LoadModel 实现
    // HitLoadPanel: 自动创建 通过SiteModel.LoadModel 实现
    Devicer:require('ds/gemo/Devicer'),//设备判断，依托于Ds.gemo.Devicer类
    AppModel:null,//这个单页面程序主逻辑模块  自动创建通过LoadSinglePageApplicationJS;
    LoadModel:require('app/LoadModel.js'),//设置加载loading的逻辑模块  [这个里如果是多页面可以根据自己页面Load的js来设置]
    Debug:false,//是否debug  会根据端口号进行判断
    LoadSinglePageApplicationJS:LoadSinglePageApplicationJS,//加载单页面应用逻辑代码
    SiteResizeModel:null,//网站自适应模块 自动创建
    LoadPanel:null,//加载界面 [Dom的loading 请在InitLoadPanel函数内进行实现   Createjs的loading，正常来说不需要修改，如果需要修改InitCreateJsLoadPanel函数内修改实现]
    CJSModel:null,//createjs项目模块  [设置IsCJSSiteModel=true 时候才会创建]
    AudioAutoPlayLister:null,//声音自动播放加载与控制器类对象  自动创建
    //对整个网站框架进行ReSize方法执行 重置执行强制resize计算
    ReSize:function(){SiteModel.SiteResizeModel.ReSize();},
    //==============以上参数不做修改，会根据下列配置进行生成===================
    ScreenType:'v',//网站自适应方式
    Screen:'#screen',//网站自适应容器
    HasCreateJs:false,//网站是否需要是否是用createjs    [设置开发网站的类型,true会使用vendors2.js false使用vendors1.js]
    IsCJSSiteModel:false,//是否是用createjs方式网站    [需要设置HasCreateJs 等于true]
    IsCJSLoadPanel:false,//是否用createjs的loading  [设置使用什么方式做loading]

    //声音自动播放加载与控制器类对象参数，不需要可以设置成null。
    AudioAutoPlayListerData:{
    //加载声音列表  list=null list=undefined list.length<=0没有这个列表不会执行
    list:[],//项格式 {src:'./media/BGM.mp3',id:'BGM',loop:true}
    //默认播放声音背景
    id:'BGM',
    //这个BMG 绑定的控制的按钮
    button:'#BGMBtn'
  },
};
//loading 方法
SiteModel.ShowProgress=SiteModel.LoadModel.ShowProgress;
SiteModel.HitLoadPanel=SiteModel.LoadModel.HitLoadPanel;
//基本的浏览器与设备的判断
SiteModel.IsWeixin=SiteModel.Devicer.IsWeixin;
SiteModel.IsIOS=SiteModel.Devicer.IsIOS;
SiteModel.IsMobile=SiteModel.Devicer.IsMobile;
//设置变量确保LoadSinglePageApplicationJS只能执行一次
var _LoadSinglePageApplicationEnd=false;
/**
 * 加载单页面应用的代码
 */
function LoadSinglePageApplicationJS(){
  if(_LoadSinglePageApplicationEnd)return;
  _LoadSinglePageApplicationEnd=true;
  require.ensure(
      ['app/AppMain.js'],
      function() {
          SiteModel.LoadModel.ShowProgress(20);
          _SinglePageApplication = require('app/AppMain.js');
          SiteModel.AppModel = _SinglePageApplication;
          SiteModel.AppModel.Init();
      },
      'AppMain'//单页面应用打包的js名称
  );
}
/*=================以下部分基本通用可以不需要修改===================*/
//进行判断是否进行debug的判断
if (location.href.indexOf(':800') != -1) SiteModel.Debug = true;
//屏蔽滑动页面
document.addEventListener('touchmove', function(e) {e.preventDefault();}, false);
/**
 * 构建createjs模块
 */
function InitCJSModel(){
  //构建createjs模块
  SiteModel.CJSModel = ccjs.CCJSModel.Create({
    appendTo:$('#cjsBox')[0],
      width: 640,
      height: 1140,
      fps: 30
  });
}
/**
 * 初始化网站自适应模块
 */
function InitSiteResizeModel(){
  //网站自适应模块
  window.SiteResizeModel = new Ds.SiteMoblieResizeModel({
    screen:SiteModel.Screen,
    screenType:SiteModel.ScreenType,
  });
  SiteModel.SiteResizeModel=SiteResizeModel;
  //进行提示浮动层显示
  if(SiteResizeModel.ScreenType!='auto')SiteResizeModel.InitOrientationTip();
  //监听场景自适应
  SiteResizeModel.on('resize', ReSize);
  //开始进行初始化场景自适应
  SiteResizeModel.InitResize();
  //解决loading页面缩放问题
  $(SiteModel.Screen).show();
}
/**
 * 自适应
 */
function ReSize(){
  //var _Width, _Height, _PageScale, _ActualH, _Horizontal = false,_IsInputState = false,_ScreenWidth, _DensityDpi;
  // if(SiteResizeModel.ScreenType=='auto'){}
}
/**
 * 加载基础库的
 */
function LoadBaseJS() {
    require.ensure(
        [
          'jquery',
          'eventdispatcher',
          'ds/gemo/QuickTrack',
          'ds/media/MobileAudioAutoPlayLister',
          'sitemoblieresizemodel',
        ],
        function() {
            require([
              'jquery',
              'eventdispatcher',
              'ds/gemo/QuickTrack',
              'ds/media/MobileAudioAutoPlayLister',
              'sitemoblieresizemodel',
            ],function(){
              console.log('LoadBaseJS:', new Date().getTime() - _time);
              if(SiteModel.AudioAutoPlayListerData){
                InitAudioAutoPlayLister();
              }
              InitSiteResizeModel();
              if(SiteModel.HasCreateJs)LoadCJSFrameWorkJS();
              else LoadFrameWorkJS();
            });
        },
        'base'
    );
}
/**
 * 初始化默认背景声音播放
 */
function InitAudioAutoPlayLister(){
  SiteModel.AudioAutoPlayLister=new Ds.media.MobileAudioAutoPlayLister();
  SiteModel.AudioAutoPlayLister.InitLoadAndSetBGM(SiteModel.AudioAutoPlayListerData);
}
/**
 * 加载项目需要支持的第三方库
 */
function LoadCJSFrameWorkJS(){
  require.ensure(
      [
          'createjs',//需要create
          'dscreatejs',//需要create 扩展
          'jstween',//需要运动引擎
          'touchjs',//需要touch事件
      ],
      function() {
          require([
              'createjs',
              'dscreatejs',
              'jstween',
              'touchjs',
          ],function(){
            console.log('LoadCJSFrameWorkJS:', new Date().getTime() - _time);
            //是否CJS类型网站
            if(SiteModel.IsCJSSiteModel) InitCJSModel();
            //使用什么模式的加载loading
            if(SiteModel.IsCJSLoadPanel) SiteModel.LoadModel.InitCreateJsLoadPanel();
            else  SiteModel.LoadModel.InitDomLoadPanel();
          });

      },
      'vendors2'
  );
}
/**
 * 加载项目需要支持的第三方库
 */
function LoadFrameWorkJS(){
  require.ensure(
      [
          'jstween',//需要运动引擎
          'touchjs',//需要touch事件
      ],
      function() {
          require([
              'jstween',
              'touchjs',
          ],function(){
            console.log('LoadFrameWorkJS:', new Date().getTime() - _time);
            InitLoadPanel();
          });

      },
      'vendors1'
  );
}
//开始加载代码
LoadBaseJS();
<commit_msg>update<commit_after>/**
 * @class
 * @classdesc: webpack2 快速开发网站项目模板入口
 * @extends
 * @example:
 * @author: maksim email:maksim.lin@foxmail.com
 * @copyright: Ds是累积平时项目工作的经验代码库，不属于职位任务与项目的内容。里面代码大部分理念来至曾经flash 前端时代，尽力减小类之间耦合，通过webpack按需request使用。Ds库里内容多来至网络与参考其他开源代码库。Ds库也开源开放，随意使用在所属的职位任务与项目中。
 * @constructor
 **/
_time = new Date().getTime();
//网址主模块
window.SiteModel = {
    // ShowProgress: 自动创建 通过SiteModel.LoadModel 实现
    // HitLoadPanel: 自动创建 通过SiteModel.LoadModel 实现
    Devicer:require('ds/gemo/Devicer'),//设备判断，依托于Ds.gemo.Devicer类
    AppModel:null,//这个单页面程序主逻辑模块  自动创建通过LoadSinglePageApplicationJS;
    LoadModel:require('app/LoadModel.js'),//设置加载loading的逻辑模块  [这个里如果是多页面可以根据自己页面Load的js来设置]
    Debug:false,//是否debug  会根据端口号进行判断
    LoadSinglePageApplicationJS:LoadSinglePageApplicationJS,//加载单页面应用逻辑代码
    SiteResizeModel:null,//网站自适应模块 自动创建
    LoadPanel:null,//加载界面 [Dom的loading 请在InitLoadPanel函数内进行实现   Createjs的loading，正常来说不需要修改，如果需要修改InitCreateJsLoadPanel函数内修改实现]
    CJSModel:null,//createjs项目模块  [设置IsCJSSiteModel=true 时候才会创建]
    AudioAutoPlayLister:null,//声音自动播放加载与控制器类对象  自动创建
    //对整个网站框架进行ReSize方法执行 重置执行强制resize计算
    ReSize:function(){SiteModel.SiteResizeModel.ReSize();},
    //==============以上参数不做修改，会根据下列配置进行生成===================
    ScreenType:'v',//网站自适应方式
    Screen:'#screen',//网站自适应容器
    HasCreateJs:false,//网站是否需要是否是用createjs    [设置开发网站的类型,true会使用vendors2.js false使用vendors1.js]
    IsCJSSiteModel:false,//是否是用createjs方式网站    [需要设置HasCreateJs 等于true]
    IsCJSLoadPanel:false,//是否用createjs的loading  [设置使用什么方式做loading]

    //声音自动播放加载与控制器类对象参数，不需要可以设置成null。
    AudioAutoPlayListerData:{
    //加载声音列表  list=null list=undefined list.length<=0没有这个列表不会执行
    list:[],//项格式 {src:'./media/BGM.mp3',id:'BGM',loop:true}
    //默认播放声音背景
    id:'BGM',
    //这个BMG 绑定的控制的按钮
    button:'#BGMBtn'
  },
};
//loading 方法
SiteModel.ShowProgress=SiteModel.LoadModel.ShowProgress;
SiteModel.HitLoadPanel=SiteModel.LoadModel.HitLoadPanel;
//基本的浏览器与设备的判断
SiteModel.IsWeixin=SiteModel.Devicer.IsWeixin;
SiteModel.IsIOS=SiteModel.Devicer.IsIOS;
SiteModel.IsMobile=SiteModel.Devicer.IsMobile;
//设置变量确保LoadSinglePageApplicationJS只能执行一次
var _LoadSinglePageApplicationEnd=false;
/**
 * 加载单页面应用的代码
 */
function LoadSinglePageApplicationJS(){
  if(_LoadSinglePageApplicationEnd)return;
  _LoadSinglePageApplicationEnd=true;
  require.ensure(
      ['app/AppMain.js'],
      function() {
          SiteModel.LoadModel.ShowProgress(20);
          _SinglePageApplication = require('app/AppMain.js');
          SiteModel.AppModel = _SinglePageApplication;
          SiteModel.AppModel.Init();
      },
      'AppMain'//单页面应用打包的js名称
  );
}
/*=================以下部分基本通用可以不需要修改===================*/
//进行判断是否进行debug的判断
if (location.href.indexOf(':800') != -1) SiteModel.Debug = true;
//屏蔽滑动页面
document.addEventListener('touchmove', function(e) {e.preventDefault();}, false);
/**
 * 构建createjs模块
 */
function InitCJSModel(){
  //构建createjs模块
  SiteModel.CJSModel = ccjs.CCJSModel.Create({
    appendTo:$('#cjsBox')[0],
      width: 640,
      height: 1140,
      fps: 30
  });
}
/**
 * 初始化网站自适应模块
 */
function InitSiteResizeModel(){
  //网站自适应模块
  window.SiteResizeModel = new Ds.SiteMoblieResizeModel({
    screen:SiteModel.Screen,
    screenType:SiteModel.ScreenType,
  });
  SiteModel.SiteResizeModel=SiteResizeModel;
  //进行提示浮动层显示
  if(SiteResizeModel.ScreenType!='auto')SiteResizeModel.InitOrientationTip();
  //监听场景自适应
  SiteResizeModel.on('resize', ReSize);
  //开始进行初始化场景自适应
  SiteResizeModel.InitResize();
  //解决loading页面缩放问题
  $(SiteModel.Screen).show();
}
/**
 * 自适应
 */
function ReSize(){
  //var _Width, _Height, _PageScale, _ActualH, _Horizontal = false,_IsInputState = false,_ScreenWidth, _DensityDpi;
  // if(SiteResizeModel.ScreenType=='auto'){}
}
/**
 * 加载基础库的
 */
function LoadBaseJS() {
    require.ensure(
        [
          'jquery',
          'eventdispatcher',
          'ds/gemo/QuickTrack',
          'ds/media/MobileAudioAutoPlayLister',
          'sitemoblieresizemodel',
        ],
        function() {
            require([
              'jquery',
              'eventdispatcher',
              'ds/gemo/QuickTrack',
              'ds/media/MobileAudioAutoPlayLister',
              'sitemoblieresizemodel',
            ],function(){
              console.log('LoadBaseJS:', new Date().getTime() - _time);
              if(SiteModel.AudioAutoPlayListerData){
                InitAudioAutoPlayLister();
              }
              InitSiteResizeModel();
              if(SiteModel.HasCreateJs)LoadCJSFrameWorkJS();
              else LoadFrameWorkJS();
            });
        },
        'base'
    );
}
/**
 * 初始化默认背景声音播放
 */
function InitAudioAutoPlayLister(){
  SiteModel.AudioAutoPlayLister=new Ds.media.MobileAudioAutoPlayLister();
  SiteModel.AudioAutoPlayLister.InitLoadAndSetBGM(SiteModel.AudioAutoPlayListerData);
}
/**
 * 加载项目需要支持的第三方库
 */
function LoadCJSFrameWorkJS(){
  require.ensure(
      [
          'createjs',//需要create
          'dscreatejs',//需要create 扩展
          'jstween',//需要运动引擎
          'touchjs',//需要touch事件
      ],
      function() {
          require([
              'createjs',
              'dscreatejs',
              'jstween',
              'touchjs',
          ],function(){
            console.log('LoadCJSFrameWorkJS:', new Date().getTime() - _time);
            //是否CJS类型网站
            if(SiteModel.IsCJSSiteModel) InitCJSModel();
            //使用什么模式的加载loading
            if(SiteModel.IsCJSLoadPanel) SiteModel.LoadModel.InitCreateJsLoadPanel();
            else  SiteModel.LoadModel.InitDomLoadPanel();
          });

      },
      'vendors2'
  );
}
/**
 * 加载项目需要支持的第三方库
 */
function LoadFrameWorkJS(){
  require.ensure(
      [
          'jstween',//需要运动引擎
          'touchjs',//需要touch事件
      ],
      function() {
          require([
              'jstween',
              'touchjs',
          ],function(){
            console.log('LoadFrameWorkJS:', new Date().getTime() - _time);
            SiteModel.LoadModel.InitDomLoadPanel();
          });

      },
      'vendors1'
  );
}
//开始加载代码
LoadBaseJS();
<|endoftext|>


<commit_before><commit_msg>Corrects anchor<commit_after><|endoftext|>


<commit_before>var Model=function(options){
	this.options=options;
};
Model.prototype.generateCode=function(){
	return this.generateLines().join("\n");
};
Model.prototype.generateLines=function(){
	var e=this.options.encode;
	var code=this.options.code;
	var data=code.data;
	var lines=[];

	function concatModelLines(data) {
		lines=lines.concat([this.comment('data.model')]);
		if (code.needProb) {
			lines=lines.concat(this.generateProbModelLines(data));
		} else {
			lines=lines.concat(this.generateClassModelLines(data));
		}
	}
	function concatPostModelLines(data,dataset) {
		if (code.needProb) {
			lines=lines.concat(
				[this.comment(dataset+'.prob')],
				this.generateProbLines(data),
				[this.comment(dataset+'.class')],
				this.generateClassFromProbLines(data)
			);
		} else {
			lines=lines.concat(
				[this.comment(dataset+'.class')],
				this.generateClassFromModelLines(data)
			);
		}
		lines=lines.concat(
			[this.comment(dataset+'.acc')],
			this.generateAccLines(data)
		);
		if (code.needProb) {
			lines=lines.concat(
				[this.comment(dataset+'.auc')],
				this.generateAucLines(data)
			);
		}
	}

	lines=lines.concat(this.listLibraries().map(function(lib){
		return "library("+lib+")";
	}),[
		"",
		this.comment('data'),
		e(data)+"=read.csv('"+e(code.filename)+"')",
	]);
	if (code.postprocess) {
		lines=lines.concat([
			this.comment('postprocess'),
			e(code.postprocess),
		]);
	}
	if (code.needSplit) {
		lines=lines.concat([
			this.comment('split'),
			"set.seed("+e(code.splitSeed)+")",
			"split=sample.split("+e(data)+"$"+e(code.y)+",SplitRatio="+e(code.splitRatio)+")",
			e(data.train)+"="+e(data)+"[split,]",
			e(data.test)+"="+e(data)+"[!split,]",
		]);
		concatModelLines.call(this,data.train);
		concatPostModelLines.call(this,data.train,'data.train');
		concatPostModelLines.call(this,data.test,'data.test');
	} else {
		concatModelLines.call(this,data);
		concatPostModelLines.call(this,data,'data');
	}
	return lines;
};
Model.prototype.generateClassFromProbLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data['class'])+"=+("+e(data.prob)+">="+e(code.threshold)+")",
	];
};
Model.prototype.generateAccLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.acc)+"=mean("+e(data)+"$"+e(code.y)+"=="+e(data['class'])+")",
	];
};
Model.prototype.generateAucLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.auc)+"=performance(",
		"\t"+"prediction("+e(data.prob)+","+e(data)+"$"+e(code.y)+"),'auc'",
		")@y.values[[1]]",
	];
};
Model.prototype.listLibraries=function(){
	libs=[
		'ROCR', // for AUC computation
	];
	if (this.options.code.needSplit) {
		libs.push('caTools');
	}
	return libs;
	// TODO require libs from code
}
Model.prototype.comment=function(id){
	return "# "+this.options.i18n('comment.'+id);
}

var BaselineModel=function(options){
	Model.call(this,options);
};
BaselineModel.prototype=Object.create(Model.prototype);
BaselineModel.prototype.constructor=BaselineModel;
BaselineModel.prototype.name='Baseline method';
BaselineModel.prototype.generateProbModelLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.model)+"=mean("+e(data)+"$"+e(code.y)+")",
	];
}
BaselineModel.prototype.generateClassModelLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.model)+"=names(sort(-table("+e(data)+"$"+e(code.y)+")))[1]", // http://stackoverflow.com/a/2547551
	];
}
BaselineModel.prototype.generateProbLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.prob)+"=rep_len("+e(data.model)+",nrow("+e(data)+"))",
	];
};
BaselineModel.prototype.generateClassFromModelLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data['class'])+"=rep_len("+e(data.model)+",nrow("+e(data)+"))",
	];
};

var LogregModel=function(options){
	Model.call(this,options);
};
LogregModel.prototype=Object.create(Model.prototype);
LogregModel.prototype.constructor=LogregModel;
LogregModel.prototype.name='Logistic regression';
LogregModel.prototype.generateProbModelLines=
LogregModel.prototype.generateClassModelLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.model)+"=glm("+e(code.formula)+",data="+e(data)+",family=binomial)",
	];
};
LogregModel.prototype.generateProbLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.prob)+"=predict("+e(data.model)+",type='response')",
	];
};
LogregModel.prototype.generateClassFromModelLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		"# TODO",
	];
};

var CartModel=function(options){
	Model.call(this,options);
};
CartModel.prototype=Object.create(Model.prototype);
CartModel.prototype.constructor=CartModel;
CartModel.prototype.name='Regression tree';
CartModel.prototype.generateProbModelLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.model)+"=rpart("+e(code.formula)+",data="+e(data)+")",
	];
};
CartModel.prototype.generateClassModelLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.model)+"=rpart("+e(code.formula)+",data="+e(data)+",method='class')",
	];
};
CartModel.prototype.generateProbLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.prob)+"=predict("+e(data.model)+")",
	];
};
CartModel.prototype.generateClassFromModelLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		"# TODO",
	];
};
CartModel.prototype.listLibraries=function(){
	return Model.prototype.listLibraries.call(this).concat([
		'rpart',
	]);
};
<commit_msg>ProbModel/ClassModel for all models<commit_after>var Model=function(options){
	this.options=options;
};
Model.prototype.generateCode=function(){
	return this.generateLines().join("\n");
};
Model.prototype.generateLines=function(){
	var e=this.options.encode;
	var code=this.options.code;
	var data=code.data;
	var lines=[];

	function concatModelLines(data) {
		lines=lines.concat([this.comment('data.model')]);
		if (code.needProb) {
			lines=lines.concat(this.generateProbModelLines(data));
		} else {
			lines=lines.concat(this.generateClassModelLines(data));
		}
	}
	function concatPostModelLines(data,dataset) {
		if (code.needProb) {
			lines=lines.concat(
				[this.comment(dataset+'.prob')],
				this.generateProbLines(data),
				[this.comment(dataset+'.class')],
				this.generateClassFromProbLines(data)
			);
		} else {
			lines=lines.concat(
				[this.comment(dataset+'.class')],
				this.generateClassFromModelLines(data)
			);
		}
		lines=lines.concat(
			[this.comment(dataset+'.acc')],
			this.generateAccLines(data)
		);
		if (code.needProb) {
			lines=lines.concat(
				[this.comment(dataset+'.auc')],
				this.generateAucLines(data)
			);
		}
	}

	lines=lines.concat(this.listLibraries().map(function(lib){
		return "library("+lib+")";
	}),[
		"",
		this.comment('data'),
		e(data)+"=read.csv('"+e(code.filename)+"')",
	]);
	if (code.postprocess) {
		lines=lines.concat([
			this.comment('postprocess'),
			e(code.postprocess),
		]);
	}
	if (code.needSplit) {
		lines=lines.concat([
			this.comment('split'),
			"set.seed("+e(code.splitSeed)+")",
			"split=sample.split("+e(data)+"$"+e(code.y)+",SplitRatio="+e(code.splitRatio)+")",
			e(data.train)+"="+e(data)+"[split,]",
			e(data.test)+"="+e(data)+"[!split,]",
		]);
		concatModelLines.call(this,data.train);
		concatPostModelLines.call(this,data.train,'data.train');
		concatPostModelLines.call(this,data.test,'data.test');
	} else {
		concatModelLines.call(this,data);
		concatPostModelLines.call(this,data,'data');
	}
	return lines;
};
Model.prototype.generateClassFromProbLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data['class'])+"=+("+e(data.prob)+">="+e(code.threshold)+")",
	];
};
Model.prototype.generateAccLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.acc)+"=mean("+e(data)+"$"+e(code.y)+"=="+e(data['class'])+")",
	];
};
Model.prototype.generateAucLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.auc)+"=performance(",
		"\t"+"prediction("+e(data.prob)+","+e(data)+"$"+e(code.y)+"),'auc'",
		")@y.values[[1]]",
	];
};
Model.prototype.listLibraries=function(){
	libs=[
		'ROCR', // for AUC computation
	];
	if (this.options.code.needSplit) {
		libs.push('caTools');
	}
	return libs;
	// TODO require libs from code
}
Model.prototype.comment=function(id){
	return "# "+this.options.i18n('comment.'+id);
}

var BaselineModel=function(options){
	Model.call(this,options);
};
BaselineModel.prototype=Object.create(Model.prototype);
BaselineModel.prototype.constructor=BaselineModel;
BaselineModel.prototype.name='Baseline method';
BaselineModel.prototype.generateProbModelLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.model)+"=mean("+e(data)+"$"+e(code.y)+")",
	];
}
BaselineModel.prototype.generateClassModelLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.model)+"=names(sort(-table("+e(data)+"$"+e(code.y)+")))[1]", // http://stackoverflow.com/a/2547551
	];
}
BaselineModel.prototype.generateProbLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.prob)+"=rep_len("+e(data.model)+",nrow("+e(data)+"))",
	];
};
BaselineModel.prototype.generateClassFromModelLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data['class'])+"=rep_len("+e(data.model)+",nrow("+e(data)+"))",
	];
};

var LogregModel=function(options){
	Model.call(this,options);
};
LogregModel.prototype=Object.create(Model.prototype);
LogregModel.prototype.constructor=LogregModel;
LogregModel.prototype.name='Logistic regression';
LogregModel.prototype.generateProbModelLines=
LogregModel.prototype.generateClassModelLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.model)+"=glm("+e(code.formula)+",data="+e(data)+",family=binomial)",
	];
};
LogregModel.prototype.generateProbLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.prob)+"=predict("+e(data.model)+",newdata="+e(data)+",type='response')",
	];
};
LogregModel.prototype.generateClassFromModelLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data['class'])+"=+(predict("+e(data.model)+",newdata="+e(data)+",type='response')>0.5)",
	];
};

var CartModel=function(options){
	Model.call(this,options);
};
CartModel.prototype=Object.create(Model.prototype);
CartModel.prototype.constructor=CartModel;
CartModel.prototype.name='Regression tree';
CartModel.prototype.generateProbModelLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.model)+"=rpart("+e(code.formula)+",data="+e(data)+")",
	];
};
CartModel.prototype.generateClassModelLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.model)+"=rpart("+e(code.formula)+",data="+e(data)+",method='class')",
	];
};
CartModel.prototype.generateProbLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data.prob)+"=predict("+e(data.model)+",newdata="+e(data)+")",
	];
};
CartModel.prototype.generateClassFromModelLines=function(data){
	var e=this.options.encode;
	var code=this.options.code;
	return [
		e(data['class'])+"=predict("+e(data.model)+",newdata="+e(data)+",type='class')",
	];
};
CartModel.prototype.listLibraries=function(){
	return Model.prototype.listLibraries.call(this).concat([
		'rpart',
	]);
};
<|endoftext|>


<commit_before>import Rx from 'rx';
import token from './transforms/token';

function initializeToken() {
  return {
    // TODO
    settings: null,
    token: {
      value: ''
    }
  };
}

function indexOf(issues, issue) {
  const indexes = issues
  .map((i, index) => [i, index])
  .filter(([i, _]) => i.url === issue.url)
  .map(([_, index]) => index);
  return indexes.length > 0 ? indexes[0] : -1;
}

function merge(issues, issue) {
  const index = indexOf(issues, issue);
  if (index >= 0) {
    issues[index] = issue;
  } else {
    issues.push(issue);
  }
  return addChildren(addParent(issues));
}

function addParent(issues) {
  return issues.map(issue => {
    const m = (issue.body || '').match(/^(?:([^\/]+)\/([^#]+))?#(\d+)/);
    if (!m) return Object.assign({}, issue, { parent: null });
    const [_, u, r, n] = m;
    return Object.assign({}, issue, {
      parent: {
        user: u || issue.user,
        repo: r || issue.repo,
        number: parseInt(n, 10)
      }
    });
  });
}

function addChildren(issues) {
  return issues.map(issue => {
    const { user, repo, number } = issue;
    const children = issues.filter(i => {
      const p = i.parent;
      return p && p.user === user && p.repo === repo && p.number === number;
    });
    return Object.assign({}, issue, { children });
  });
}

export default function(actions) {
  const {
    loadSettings$,
    addRepo$,
    fetchIssues$,
    updateIssue$,
    updateRepo$,
    updateUser$
  } = actions;
  const state = {
    issues: [],
    repos: [],
    requests: [],
    repo: null,
    user: null,
    ...initializeToken()
  };
  const reposMaxLength = 10;
  const actions$ = Rx.Observable.merge(
    loadSettings$
    .map(storage => state => {
      state.settings = storage;
      return state;
    }),
    fetchIssues$
    .map((_, i) => state => {
      const newRequests = state.repos.map(({ user, repo }, j) => {
        const id = i * reposMaxLength + j;
        const url = `https://api.github.com/repos/${user}/${repo}/issues`;
        const headers = { 'User-Agent': 'gh-tree' };
        return { id, method: 'GET', url, headers };
      });
      state.requests = state.requests.concat(newRequests);
      return state;
    }),
    addRepo$
    .map(repo => state => {
      const { user, repo } = state;
      if (state.repos.length > reposMaxLength) return state;
      const duplicated = state.repos.filter(i => {
        return i.user === user && i.repo === repo;
      }).length > 0;
      if (duplicated) return state;
      state.repos.push({ user, repo });
      return state;
    }),
    token(actions),
    updateIssue$
    .map(issue => state => {
      state.issues = merge(state.issues, issue);
      return state;
    }),
    updateRepo$
    .map(repo => state => {
      state.repo = repo;
      return state;
    }),
    updateUser$
    .map(user => state => {
      state.user = user;
      return state;
    })
  );
  const state$ = Rx.Observable.just(state)
    .merge(actions$)
    .scan((state, action) => action(state))
    .shareReplay(1);
  return state$;
}
<commit_msg>add token support<commit_after>import Rx from 'rx';
import token from './transforms/token';

function initializeToken() {
  return {
    // TODO
    settings: null,
    token: {
      value: ''
    }
  };
}

function indexOf(issues, issue) {
  const indexes = issues
  .map((i, index) => [i, index])
  .filter(([i, _]) => i.url === issue.url)
  .map(([_, index]) => index);
  return indexes.length > 0 ? indexes[0] : -1;
}

function merge(issues, issue) {
  const index = indexOf(issues, issue);
  if (index >= 0) {
    issues[index] = issue;
  } else {
    issues.push(issue);
  }
  return addChildren(addParent(issues));
}

function addParent(issues) {
  return issues.map(issue => {
    const m = (issue.body || '').match(/^(?:([^\/]+)\/([^#]+))?#(\d+)/);
    if (!m) return Object.assign({}, issue, { parent: null });
    const [_, u, r, n] = m;
    return Object.assign({}, issue, {
      parent: {
        user: u || issue.user,
        repo: r || issue.repo,
        number: parseInt(n, 10)
      }
    });
  });
}

function addChildren(issues) {
  return issues.map(issue => {
    const { user, repo, number } = issue;
    const children = issues.filter(i => {
      const p = i.parent;
      return p && p.user === user && p.repo === repo && p.number === number;
    });
    return Object.assign({}, issue, { children });
  });
}

export default function(actions) {
  const {
    loadSettings$,
    addRepo$,
    fetchIssues$,
    updateIssue$,
    updateRepo$,
    updateUser$
  } = actions;
  const state = {
    issues: [],
    repos: [],
    requests: [],
    repo: null,
    user: null,
    ...initializeToken()
  };
  const reposMaxLength = 10;
  const actions$ = Rx.Observable.merge(
    loadSettings$
    .map(storage => state => {
      state.settings = storage;
      return state;
    }),
    fetchIssues$
    .map((_, i) => state => {
      const { settings } = state;
      const newRequests = state.repos.map(({ user, repo }, j) => {
        const id = i * reposMaxLength + j;
        const url = `https://api.github.com/repos/${user}/${repo}/issues`;
        const ua = { 'User-Agent': 'gh-tree' };
        const auth = settings.token ? {
          'Authorization': `token ${settings.token}`
        } : {};
        const headers = Object.assign({}, ua, auth);
        return { id, method: 'GET', url, headers };
      });
      state.requests = state.requests.concat(newRequests);
      return state;
    }),
    addRepo$
    .map(repo => state => {
      const { user, repo } = state;
      if (state.repos.length > reposMaxLength) return state;
      const duplicated = state.repos.filter(i => {
        return i.user === user && i.repo === repo;
      }).length > 0;
      if (duplicated) return state;
      state.repos.push({ user, repo });
      return state;
    }),
    token(actions),
    updateIssue$
    .map(issue => state => {
      state.issues = merge(state.issues, issue);
      return state;
    }),
    updateRepo$
    .map(repo => state => {
      state.repo = repo;
      return state;
    }),
    updateUser$
    .map(user => state => {
      state.user = user;
      return state;
    })
  );
  const state$ = Rx.Observable.just(state)
    .merge(actions$)
    .scan((state, action) => action(state))
    .shareReplay(1);
  return state$;
}
<|endoftext|>


<commit_before>'use strict';

var express = require('express');
var mongoose = require('mongoose');
var morgan = require('morgan');
var compress = require('compression');
var methodOverride = require('method-override');
var bodyParser = require('body-parser');
var serveStatic = require('serve-static');
var errorHandler = require('errorhandler');
var helmet = require('helmet');
var config = require('./config/config');
var fs = require('fs');
var path = require('path');
var app = module.exports = express();

mongoose.connect(config.db);

requireModels(fs);

securityHeaders(app, helmet);

app.set('port', process.env.PORT || 3000);
app.use(morgan('dev'));
app.use(compress());
app.use(methodOverride());
app.use(bodyParser());
app.use(serveStatic(path.join(__dirname, '../../' + config.public)));

// bootstrap routes
require('./config/routes')(app);

if (process.env.NODE_ENV === 'development') {
    app.use(errorHandler({ dumpExceptions: true, showStack: true }));
}
if (process.env.NODE_ENV === 'production') {
    app.use(errorHandler());
}

function requireModels(fs) {
    fs.readdirSync(path.join(__dirname, './models')).forEach(function (file) {
        require('./models/' + file);
    });
}

function securityHeaders(app, helmet) {
    app.use(helmet.xframe());
    app.use(helmet.csp(config.csp));
    app.use(helmet.iexss());
    app.use(helmet.hidePoweredBy());
}
<commit_msg>Use bodyParser json<commit_after>'use strict';

var express = require('express');
var mongoose = require('mongoose');
var morgan = require('morgan');
var compress = require('compression');
var methodOverride = require('method-override');
var bodyParser = require('body-parser');
var serveStatic = require('serve-static');
var errorHandler = require('errorhandler');
var helmet = require('helmet');
var config = require('./config/config');
var fs = require('fs');
var path = require('path');
var app = module.exports = express();

mongoose.connect(config.db);

requireModels(fs);

securityHeaders(app, helmet);

app.set('port', process.env.PORT || 3000);
app.use(morgan('dev'));
app.use(compress());
app.use(methodOverride());
app.use(bodyParser.json());
app.use(serveStatic(path.join(__dirname, '../../' + config.public)));

// bootstrap routes
require('./config/routes')(app);

if (process.env.NODE_ENV === 'development') {
    app.use(errorHandler({ dumpExceptions: true, showStack: true }));
}
if (process.env.NODE_ENV === 'production') {
    app.use(errorHandler());
}

function requireModels(fs) {
    fs.readdirSync(path.join(__dirname, './models')).forEach(function (file) {
        require('./models/' + file);
    });
}

function securityHeaders(app, helmet) {
    app.use(helmet.xframe());
    app.use(helmet.csp(config.csp));
    app.use(helmet.iexss());
    app.use(helmet.hidePoweredBy());
}
<|endoftext|>


<commit_before>#!/usr/bin/env node

/**
 * Module dependencies.
 */

const app = require('../app')
const debug = require('debug')('app:server')
const http = require('http')
const helpers = require('../../config/helpers')
const config = require(helpers('config/project.config'))

/**
 * Get port from environment and store in Express.
 */

const port = normalizePort(config.port)
app.set('port', port)

/**
 * Create HTTP server.
 */

const server = http.createServer(app)

/**
 * Listen on provided port, on all network interfaces.
 */

server.listen(port)
server.on('error', onError)
server.on('listening', onListening)

/**
 * Normalize a port into a number, string, or false.
 */

function normalizePort(val) {
  const port = parseInt(val, 10)

  if (isNaN(port)) {
    // named pipe
    return val
  }

  if (port >= 0) {
    // port number
    return port
  }

  return false
}

/**
 * Event listener for HTTP server "error" event.
 */

function onError(error) {
  if (error.syscall !== 'listen') {
    throw error
  }

  const bind = typeof port === 'string'
    ? 'Pipe ' + port
    : 'Port ' + port

  // handle specific listen errors with friendly messages
  switch (error.code) {
    case 'EACCES':
      console.error(bind + ' requires elevated privileges')
      process.exit(1)
      break
    case 'EADDRINUSE':
      console.error(bind + ' is already in use')
      process.exit(1)
      break
    default:
      throw error
  }
}

/**
 * Event listener for HTTP server "listening" event.
 */

function onListening() {
  const addr = server.address()
  const bind = typeof addr === 'string'
    ? 'pipe ' + addr
    : 'port ' + addr.port
  debug('Listening on ' + bind)
}
<commit_msg>config port<commit_after>#!/usr/bin/env node

/**
 * Module dependencies.
 */

const app = require('../app')
const debug = require('debug')('app:server')
const http = require('http')
const config = require('../../config/project.config')

/**
 * Get port from environment and store in Express.
 */

const port = normalizePort(config.port)
app.set('port', port)

/**
 * Create HTTP server.
 */

const server = http.createServer(app)

/**
 * Listen on provided port, on all network interfaces.
 */

server.listen(port)
server.on('error', onError)
server.on('listening', onListening)

/**
 * Normalize a port into a number, string, or false.
 */

function normalizePort(val) {
  const port = parseInt(val, 10)

  if (isNaN(port)) {
    // named pipe
    return val
  }

  if (port >= 0) {
    // port number
    return port
  }

  return false
}

/**
 * Event listener for HTTP server "error" event.
 */

function onError(error) {
  if (error.syscall !== 'listen') {
    throw error
  }

  const bind = typeof port === 'string'
    ? 'Pipe ' + port
    : 'Port ' + port

  // handle specific listen errors with friendly messages
  switch (error.code) {
    case 'EACCES':
      console.error(bind + ' requires elevated privileges')
      process.exit(1)
      break
    case 'EADDRINUSE':
      console.error(bind + ' is already in use')
      process.exit(1)
      break
    default:
      throw error
  }
}

/**
 * Event listener for HTTP server "listening" event.
 */

function onListening() {
  const addr = server.address()
  const bind = typeof addr === 'string'
    ? 'pipe ' + addr
    : 'port ' + addr.port
  debug('Listening on ' + bind)
}
<|endoftext|>


<commit_before>

function initMainCat(){
  var baseurl=$("#base_url").val();
    $('.main-category').off("change");
    $('.main-category').on("change",function () {
        var maincatId = $(this).find('option:selected').val();
        $.ajax({
            url: baseurl+"seller/maicatAjax",
            type: "POST",
            data: "maincatId="+maincatId,
            success: function (response) {
               $(".parent-category").html(response);
                $('select').material_select();
            },
        });
    });
}

function initParentCat(){
  var baseurl=$("#base_url").val();
   /* Parent Category*/
   $('.parent-category').off("change");
    $('.parent-category').on("change",function () {
        var parentcatId = $(this).find('option:selected').val();
        $.ajax({
            url: baseurl+"seller/parentcatAjax",
            type: "POST",
            data: "parentcatId="+parentcatId,
            success: function (response) {
               $(".child-category").html(response);
                $('select').material_select();
            },
        });
    });

     /*End*/
}

function initChildCat(){
  var baseurl=$("#base_url").val();
   /* Child Category*/
        $('.child-category').off("change");
        $('.child-category').on("change",function () {
        var childcatId = $(this).find('option:selected').val();
        $.ajax({
            url: baseurl+"seller/childcatAjax",
            type: "POST",
            data: "childcatId="+childcatId,
            success: function (response) {
               $(".sub-category").html(response);
                $('select').material_select();
            },
        });
    });
}

  $(function() {
    var baseurl=$("#base_url").val();
    initMainCat();
    initParentCat();
    initChildCat();
     /*End*/
    $('.modal').modal();

  $(document).ready(function() {
    $('select').material_select();
  });
  var Accordion = function(el, multiple) {
    this.el = el || {};
    // more then one submenu open?
    this.multiple = multiple || false;

    var dropdownlink = this.el.find('.dropdownlink');
    dropdownlink.on('click',
                    { el: this.el, multiple: this.multiple },
                    this.dropdown);
  };

  Accordion.prototype.dropdown = function(e) {
    var $el = e.data.el,
        $this = $(this),
        //this is the ul.submenuItems
        $next = $this.next();

    $next.slideToggle();
    $this.parent().toggleClass('open');

    if(!e.data.multiple) {
      //show only one menu at the same time
      $el.find('.submenuItems').not($next).slideUp().parent().removeClass('open');
    }
  }

  var accordion = new Accordion($('.accordion-menu'), false);

  $(".product-thumbnail").on("click",function(){
    var imageSrc = $(this).attr("src");
    $("#mainProductImage").attr("src",imageSrc);
    $('#zoom1').zoom();
  });

  /* Seller add/edit/delete Products*/
  /* Add Products*/

  $("#addProductBtn").on("click",function(){
       $("#addModal").modal('open');
  });
  $("#sendProductData").on('click',function(){
    var productData=new FormData($("#addProductForm")[0]);
    $.ajax({
          url:baseurl+"product/addProduct",
          type:'POST',
          processData:false,
          contentType:false,
          data:productData,
          success:function(res){
            alert("Inserted successfully");
            window.location.relode();
          }

    });

  });
  /* Delete Products*/
  $(".product_delete_btn").on("click",function(){
    var proID=$(this).data("proid");
    if(confirm("Do You Want to Delete this Product")){
    $.post(baseurl+"product/deleteProduct/"+proID,function(data){
      $("tr[data-proid="+proID+"]").remove();
    });
  }

  });
 /* Update Products*/
  $("#updateBtn").on("click",function(){
    var productData=new FormData($("#updateForm")[0]);
    $.ajax({
        url:baseurl+"product/updateProduct/",
        type: 'POST',
        processData: false,
        contentType: false,
        data: productData,
        success: function(res){
          alert('Updated succesfully');
          window.locatio.relode();
        }
    });

  });
  $(".product-edit-btn").on("click",function(){
    $("#editModal .modal-content").html("");
    $("#editModal").modal('open');
    var proID=$(this).data("proid");
    $.post(baseurl+"product/getProduct/"+proID,function(data){
      $("#editModal .modal-content").html(data);
      Materialize.updateTextFields();$('select').material_select();
       initMainCat();
      initParentCat();
      initChildCat();
    });

  });

});
<commit_msg>admin changes<commit_after>function initMainCat(){
  var baseurl=$("#base_url").val();
    $('.main-category').off("change");
    $('.main-category').on("change",function () {
        var maincatId = $(this).find('option:selected').val();
        $.ajax({
            url: baseurl+"seller/maicatAjax",
            type: "POST",
            data: "maincatId="+maincatId,
            success: function (response) {
               $(".parent-category").html(response);
                $('select').material_select();
            },
        });
    });
}

function initParentCat(){
  var baseurl=$("#base_url").val();
   /* Parent Category*/
   $('.parent-category').off("change");
    $('.parent-category').on("change",function () {
        var parentcatId = $(this).find('option:selected').val();
        $.ajax({
            url: baseurl+"seller/parentcatAjax",
            type: "POST",
            data: "parentcatId="+parentcatId,
            success: function (response) {
               $(".child-category").html(response);
                $('select').material_select();
            },
        });
    });

     /*End*/
}

function initChildCat(){
  var baseurl=$("#base_url").val();
   /* Child Category*/
        $('.child-category').off("change");
        $('.child-category').on("change",function () {
        var childcatId = $(this).find('option:selected').val();
        $.ajax({
            url: baseurl+"seller/childcatAjax",
            type: "POST",
            data: "childcatId="+childcatId,
            success: function (response) {
               $(".sub-category").html(response);
                $('select').material_select();
            },
        });
    });
}

  $(function() {
    var baseurl=$("#base_url").val();
    initMainCat();
    initParentCat();
    initChildCat();
     /*End*/
    $('.modal').modal();

  $(document).ready(function() {
    $('select').material_select();
  });
  var Accordion = function(el, multiple) {
    this.el = el || {};
    // more then one submenu open?
    this.multiple = multiple || false;

    var dropdownlink = this.el.find('.dropdownlink');
    dropdownlink.on('click',
                    { el: this.el, multiple: this.multiple },
                    this.dropdown);
  };

  Accordion.prototype.dropdown = function(e) {
    var $el = e.data.el,
        $this = $(this),
        //this is the ul.submenuItems
        $next = $this.next();

    $next.slideToggle();
    $this.parent().toggleClass('open');

    if(!e.data.multiple) {
      //show only one menu at the same time
      $el.find('.submenuItems').not($next).slideUp().parent().removeClass('open');
    }
  }

  var accordion = new Accordion($('.accordion-menu'), false);

  $(".product-thumbnail").on("click",function(){
    var imageSrc = $(this).attr("src");
    $("#mainProductImage").attr("src",imageSrc);
    $('#zoom1').zoom();
  });

  /* Seller add/edit/delete Products*/
  /* Add Products*/

  $("#addProductBtn").on("click",function(){
       $("#addModal").modal('open');
  });
  $("#sendProductData").on('click',function(){
    var productData=new FormData($("#addProductForm")[0]);
    $.ajax({
          url:baseurl+"product/addProduct",
          type:'POST',
          processData:false,
          contentType:false,
          data:productData,
          success:function(res){
            alert("Inserted successfully");
            window.location.relode();
          }

    });

  });
  /* Delete Products*/
  $(".product_delete_btn").on("click",function(){
    var proID=$(this).data("proid");
    if(confirm("Do You Want to Delete this Product")){
    $.post(baseurl+"product/deleteProduct/"+proID,function(data){
      $("tr[data-proid="+proID+"]").remove();
    });
  }

  });
 /* Update Products*/
  $("#updateBtn").on("click",function(){
    var productData=new FormData($("#updateForm")[0]);
    $.ajax({
        url:baseurl+"product/updateProduct/",
        type: 'POST',
        processData: false,
        contentType: false,
        data: productData,
        success: function(res){
          alert('Updated succesfully');
          window.locatio.relode();
        }
    });

  });
  $(".product-edit-btn").on("click",function(){
    $("#editModal .modal-content").html("");
    $("#editModal").modal('open');
    var proID=$(this).data("proid");
    $.post(baseurl+"product/getProduct/"+proID,function(data){
      $("#editModal .modal-content").html(data);
      Materialize.updateTextFields();$('select').material_select();
       initMainCat();
      initParentCat();
      initChildCat();
    });

  });

});
<|endoftext|>