Vue.component('course-selector2',{ props: ['courses','value'], template: '', computed: { options: function() { var type = this.courses.type; var list = this.courses.list.map( function(obj){ //var label = type+' - '+obj.location+' - '+obj.start_date_formatted+' - '+obj.price; var label; if(obj.location.match(/Online/)){ label = obj.dates+' | '+obj.timezone+' | '+obj.location; } else { label = obj.dates+' | '+obj.location; } return {'value':obj.eventInternalid,'label':label}; } ); //list.push({'value':'-2','label':'I\'m not sure yet. Please have someone call me.'}); //list.push({'value':'-1','label':'Please notify me about future dates and/or locations.'}); return list; } }, data: function() { return { course: '' } }, watch: { course: function() { console.log(this.course); this.$emit('input',this.course); } } }); window.onload = function(){ ES6Promise.polyfill(); var app = new Vue({ el: '#app', data: { fun: [ ], course1: '', event_internal_id: '', event_name: '', accesscode: '', display_reg: true, display_reg_btn: true, display_call: false, display_notify: false, display_sold_out: false, display_call_header: false, display_notify_header: false, display_cart_text: false, load_count: 0, spinner: false, submit_text: "Add to Cart" }, methods: { onSubmit: function(e) { if(this.event_internal_id == ''){ alert('Please select a date and location'); e.preventDefault(); return false; } if(this.event_internal_id == -1){ this.display_reg = false; this.display_notify = false; this.display_call = true; this.display_call_header = true; e.preventDefault(); return false; } else if(this.event_internal_id == -2){ this.display_reg = false; this.display_call = false; this.display_notify = true; this.display_notify_header = true; e.preventDefault(); return false; } else { this.spinner = true; this.submit_text = "Please wait..."; document.getElementById('fun-form').submit(); } }, hideNotifyHeader: function() { //this.display_notify_header = false; this.load_count++; if(this.load_count > 2) this.display_reg = false; }, hideCallHeader: function() { //this.display_call_header = false; this.load_count++; if(this.load_count > 2) this.display_reg = false; } }, watch: { course1: function() { // FUN this.event_internal_id = this.course1; console.log('Selected '+this.event_internal_id); // find event in list this.event_name = ''; for(var i=0;i 0){ //document.getElementById('add-reg-btn').setAttribute('src','https://coactive.com/images/acton/add-cart.png'); this.display_cart_text = true; this.display_reg_btn = true; this.display_notify = false; this.display_call = false; this.display_sold_out = false; } else if(this.event_internal_id == -1){ this.display_cart_text = false; this.display_reg_btn = false; this.display_notify = false; this.display_call = true; this.display_sold_out = false; } else if(this.event_internal_id == -2){ this.display_cart_text = false; this.display_reg_btn = false; this.display_call = false; this.display_notify = true; this.display_sold_out = false; } else { //document.getElementById('add-reg-btn').setAttribute('src','https://coactive.com/images/acton/continue.png'); this.display_cart_text = false; this.display_reg_btn = true; this.display_notify = false; this.display_call = false; this.display_sold_out = false; } } }, template: '
' + //'

Register

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

You will be directed to an online cart to complete your purchase and confirm registration.

' + '
' + //'

Register

' + '
' + //'

Register

' + '
' + '

*SOLD OUT: Please call 1-800-691-6008 (Option 5) to be placed on the waitlist.

' + '
' }); // get the courses and populate the v-select getCourses(); function getCourses(){ var url = window.location.href; if(window.location.href.match(/accesscode=/)){ var captured = /accesscode=([^&]+)/.exec(url)[1]; app.accesscode = captured; } var guid = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); console.log(guid); axios.get('https://launchpad.coactive.com/data/cache/fun_events.json?guid='+guid) //axios.get('https://launchpad.coactive.com/data/registration-api.php') .then(function (response) { console.log(response); var events = response.data; events.sort(by_timestamp); console.log(events); app.fun = events.filter( function(e){ return e.fullCourse !== 'T' }); // only display available courses console.log(app.fun); }) .catch(function (error) { console.log(error); }); } } // end of window.onload() function by_timestamp(a,b){ if (a.startTimestamp > b.startTimestamp) return 1; if (b.startTimestamp > a.startTimestamp) return -1; return 0; }