/* For Coaches Training Institute By Thomas Beutel, 2018 */ /* Example: { "webinars" : [ { "title" : "CTI (US) : Webinar 8/30/18 Co-Active Experience (CLE)", "webinarid" : "E26576", "timezone" : "5", "type" : "179", "date" : "8/30/2018", "internaiid" : "572950", "status" : "3", "calltime" : "Thur 9:00 AM - 10:00 AM Pacific Time", "ukdate" : "30-08-2018" }, { "webinarid" : "E22451", "timezone" : "5", "title" : "CTI (US) : 12/31.Neuroscience Recording.Online", "date" : "12/30/2020", "internaiid" : "194459", "type" : "180", "ukdate" : "30-12-2020", "status" : "3", "calltime" : "" } ] } */ /* axios.post('/user', { firstName: 'Fred', lastName: 'Flintstone' }) .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }); */ function getUrlVars() { var vars = {}; var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { vars[key] = value; }); return vars; } function getUrlParam(parameter, defaultvalue){ var urlparameter = defaultvalue; if(window.location.href.indexOf(parameter) > -1){ urlparameter = getUrlVars()[parameter]; } return urlparameter; } Vue.component('course-selector2',{ props: ['courses','value'], template: '
', computed: { options: function() { var type = this.courses.type; var locations = { 'SEA':'Seattle, WA', 'ATL':'Atlanta, GA', 'DC':'Washington, DC', 'DVR':'Denver, CO', 'VAN':'Vancouver, BC', 'BOS':'Boston, MA', 'TOR':'Toronto, ON', 'SR':'San Rafael, CA', 'CGY':'Calgary, AB', 'CHI':'Chicago, IL', 'OC':'Orange County, CA', 'SF':'San Francisco, CA', 'Berkeley':'Berkeley, CA', 'Palo':'Palo Alto, CA', 'SG':'Singapore', 'Oslo':'Olso, Norway', 'NY':'New York, NY', 'SC':'Los Angeles, CA', 'LON':'London, UK' }; var list = this.courses.list.map( function(obj){ var event = new Date(Date.parse(obj.date)); var options = { year: 'numeric', month: 'short', day: 'numeric' }; var date = event.toLocaleDateString('en-US',options); // we are expecting something like this: CTI(US) : INTRO 1/10/19 NY-MARUIS // or this: CTI (US) : Webinar 2/20/19 Why Co-Active Coaching var title = obj.title; var label = title; var re = /[0-9][0-9] ([A-Za-z]+)/; var matches = re.exec(obj.title); if(matches){ if(matches[1] == 'Why' || matches[1] == 'Co'){ label = date+' at '+obj.calltime; } else if(matches[1] == 'Discovering') { label = title; } else { title = locations[matches[1]]; label = title+': '+date; } } if(obj.internaiid == 911132){ //label = date+' at '+obj.calltime; label = title; } return {'value':obj.internaiid,'label':label}; } ); //list.push({'value':'-1','label':'Please notify me about future dates and/or locations.'}); list.unshift({'value':'','label':'You have not made a selection'}); console.log('in options: '+this.courses.selected); if(this.courses.selected > 0){ for(i=0;i 0){ this.subsidiary = subsidiary_map[matches[1]]; } } } } console.log('Subsidiary is now '+this.subsidiary); if(this.country == 'United Kingdom'){ this.state = 'Avon'; // to get past bug in Netsuite suitelet } console.log('State is '+this.state); this.errors = []; if (!this.state && (this.country == 'United States' || this.country == 'Canada') ) { this.errors.push('State/Province required.'); } if (!this.first_name) { this.errors.push('First name required.'); } if (!this.last_name) { this.errors.push('Last name required.'); } if (!this.email) { this.errors.push('Email required.'); } if (!this.phone) { this.errors.push('Phone required.'); } if (!this.city) { this.errors.push('City required.'); } if (!this.errors.length) { console.log('submitted'); this.submit_state=1; return true; } e.preventDefault(); }, onSubmit: function(e) { /* Required fields, ids and types: Field: First Name ID: first_name Type: input Field: Last Name ID: last_name Type: input Field: Email ID: email Type: input Field: City ID: city Type: input Field: State ID: state Type: select Field: Country ID: country Type: select Field: Phone ID: phone Type: input Field: Webinar ID: webinar Type: select */ this.submit_state=1; console.log('submitted'); if(this.country == 'United Kingdom'){ this.state = 'Avon'; // to get past bug in Netsuite suitelet } var post_data = { // the data to post first_name: this.first_name, last_name: this.last_name, email: this.email, city: this.city, state: this.state, country: this.country, phone: this.phone, webinar: this.webinar }; console.log(post_data); axios({ method: 'post', /* url:'https://forms.netsuite.com/app/site/hosting/scriptlet.nl?script=452&deploy=1&compid=3958684_SB1&h=e01ea1bd7173e51c9f06', */ url:'https://forms.na1.netsuite.com/app/site/hosting/scriptlet.nl?script=492&deploy=1&compid=3958684&h=bbde7c179cf5d854fb66', data: post_data, headers: { 'Content-type': 'multipart/form-data' }, mode: 'no-cors' }) .then(function (response) { console.log(response); this.submit_state = 2; if(response.data.result == 'success'){ this.result_message = 'Success! Thank you for your registration.'; } else { this.result_message = response.data.details; } /* Result - Success: { "result" : "success", "details" : "The webinar registration record was successfully created. Registration ID: OR36533, Student Name: C135832 Tom Armbruster, Webinar Name: E26576 CTI (US) : Webinar 8/30/18 Co-Active Experience (CLE), Status: " } Error: { "result" : "error", "details" : "Last name is required\nEmail address is required\nCity is required\nWebinar selection is required" } */ }) .catch(function (error) { console.log(error); }); } }, watch: { country: function() { console.log('Country changed'); var country = this.country; if(country in this.country_states){ this.state_list_available = true; this.states = this.country_states[country]; console.log(this.state_list_available); console.log(this.states); } else { this.state_list_available = false; console.log(this.state_list_available); } } }, template: /* prod - webinar: https://forms.na1.netsuite.com/app/site/hosting/scriptlet.nl?script=519&deploy=1&compid=3958684&h=b90dfdc4de68af5b6bc1 prod - intros: https://forms.na1.netsuite.com/app/site/hosting/scriptlet.nl?script=518&deploy=1&compid=3958684&h=c8225407e94c94e6aefa sandbox: https://forms.netsuite.com/app/site/hosting/scriptlet.nl?script=452&deploy=1&compid=3958684_SB1&h=e01ea1bd7173e51c9f06 */ //'
' '' + '

' + 'Please correct the following error(s):' + '

' + '

' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
' + '' + '
' + '' + '
' + '' + '
' + '' + '
' + '' + '
' + '' + '' + '
' + '' + '' + '
' + '
' + '' + '' + '' //+ '

' + '

Processing registration

' //+ '

{{ result_message }}

' + '
' }); // get the courses and populate the v-select getCourses(); getStatesCountries(); function getCourses(){ axios.get('//launchpad.coactive.com/data/cache/webinars.json') .then(function (response) { console.log(response); if(app.webinar_filter == ''){ app.webinars = response.data.webinars; } else { var re = new RegExp(app.webinar_filter); var test_string = 'INTRO'; var webinar_type = 179; // regular webinars if(test_string.match(re)){ var webinar_type = 337; // we are looking for INTRO events } for(i=0;i 0){ // if .cap exists, use it to determine whether to show this webinar if(0 + parseInt(response.data.webinars[i].registered) + parseInt(response.data.webinars[i].waitlisted) < parseInt(response.data.webinars[i].cap) ){ app.webinars.push(response.data.webinars[i]); console.log('Pushed to array! registered:'+response.data.webinars[i].registered+' cap:'+response.data.webinars[i].cap); } else { console.log('Exceeded cap'); console.log('registered: '+response.data.webinars[i].registered); console.log('waitlisted: '+response.data.webinars[i].waitlisted); console.log('cap: '+response.data.webinars[i].cap); } } else { // .cap does not exist, so add the webinar regardless app.webinars.push(response.data.webinars[i]); console.log('Pushed to array! .cap does not exist'); } } else console.log('No match'); } // Exception: add webinar manually if(0 && webinar_type == 179){ var extra_webinar = { "cap" : "", "webinarid" : "E29175", "waitlisted" : 0, "registered" : 0, "attendees" : "", "timezone" : "5", "status" : "3", "date" : "8/2/2019", "ukdate" : "02-08-2019", "calltime" : "", "publish" : "T", "internaiid" : "1123180", "title" : "CTI (US) : Test Coaching Webinar 12 - 8/2/19", "type" : "179", "maxreg" : "" } app.webinars.push( extra_webinar ); } } }) .catch(function (error) { console.log(error); }); } function getStatesCountries(){ axios.get('//launchpad.coactive.com/data/cache/states_countries.json?v=2.0') .then(function (response) { console.log(response); app.country_states = response.data.states; app.countries = response.data.countries; app.states = app.country_states[app.country]; }) .catch(function (error) { console.log(error); }); } }); // end addOnloadEvent()