Calculator test (non-gem pages)

var initCalculator; $(function() { var providers = { regfox: { name: 'RegFox', calculate: function(f,y,m){ var fee = 0.99; if(m){ fee += f*0.0299; } return fee; }, pricing: function(f,y){ return '$0.99'; }, merchant: function(f,y){ return '2.99%'; }, blurb: [ 'No contracts, no setup fees, no cancelation fees' ], monthly: 0.00 }, redpodium: { name: 'RedPodium', calculate: function(f,y,m){ var fee = 0.99; if(m){ fee += f*0.0299; } return fee; }, pricing: function(f,y){ return '$0.99'; }, merchant: function(f,y){ return '2.99%'; }, blurb: [ 'No contracts, no setup fees, no cancelation fees' ], monthly: 0.00 }, ticketspice: { name: 'TicketSpice', calculate: function(f,y,m){ var fee = 0.99; if(f <= 5){ fee = 0.49; } if(m){ fee += f*0.0299; } return fee; }, pricing: function(f,y){ return '$0.99'; }, merchant: function(f,y){ return '2.99%'; }, blurb: [ 'No contracts, no setup fees, no cancelation fees' ], monthly: 0.00 }, 'active': { name: 'Active', calculate: function(f,y,m){ var fee = 0; switch(this.scale(f)){ case 1: fee += 3.25; break; case 2: fee += (f*0.0675) + 1.25; break; case 3: fee += (f*0.0375) + 5.75; break; case 4: fee += (f*0.0275) + 10.75; break; } return fee; }, pricing: function(f,y){ switch(this.scale(f)){ case 1: return '$3.25'; case 2: return '6.75% + $1.25'; case 3: return '3.75% + $5.75'; case 4: return '2.75% + $10.75'; } }, merchant: function(f,y){ return ''; }, scale: function(f){ var fee = (f*0.0675) + 1.25; if(fee < 3.25){ return 1; }else if(f < 150){ return 2; }else if(f >= 150 && f < 500){ return 3; }else if(f >= 500){ return 4; } }, blurb: [ 'Lots of contract and fees' ], monthly: 0.00 }, 'eventbrite': { name: 'EventBrite Essentials', calculate: function(f,y,m){ var fee = (f*0.01) + 0.99; fee = fee > 19.95 ? 19.95 : fee; if(m){ fee += f*0.03; } return fee; }, pricing: function(f,y){ return '$0.99 + 1%, capped at $19.95'; }, merchant: function(f,y){ return '3%'; }, blurb: [ 'Source: https://www.eventbrite.com/fees as of October 2016. Pricing is subject to change.' ], monthly: 0.00 }, 'eventbritepro': { name: 'EventBrite Professional', calculate: function(f,y,m){ var fee = (f*0.025) + 1.99; fee = fee > 24.95 ? 24.95 : fee; if(m){ fee += f*0.03; } return fee; }, pricing: function(f,y){ return '$1.99 + 2.5%, capped at $24.95'; }, merchant: function(f,y){ return '3%'; }, blurb: [ 'Source: https://www.eventbrite.com/fees as of October 2016. Pricing is subject to change.' ], monthly: 0.00 }, 'cvent': { name: 'Cvent', calculate: function(f,y,m){ var fee = f*0.025; switch(this.scale(y)){ case 1: fee += 0.50; break; case 2: fee += 1.50; break; } if(m){ fee += f*0.03; } return fee; }, pricing: function(f,y){ switch(this.scale(y)){ case 1: return '$0.50 + 2.5%'; case 2: return '$1.50 + 2.5%'; } }, merchant: function(f,y){ return '3%'; }, scale: function(y){ if(y < 3000){ return 1; }else{ return 2; } }, blurb: [ ], monthly: 0.00 }, 'regonline': { name: 'RegOnline', calculate: function(f,y,m){ var fee = (f*0.0475) + 3.85; return fee; }, pricing: function(f,y){ return '$3.85 + 4.75%'; }, merchant: function(f,y){ return ''; }, blurb: [ ], monthly: 0.00 }, 'eventscom': { name: 'Events.com', calculate: function(f,y,m){ var fee = 0; switch(this.scale(f)){ case 1: fee += 1.95; break; case 2: fee += 2.95; break; case 3: fee += 3.95; break; case 4: fee += 4.95; break; case 5: fee += 5.95; break; case 6: fee += 6.95; break; case 7: fee += 7.95; break; case 8: fee += 8.95; break; } if(m){ fee += f*0.03; } return fee; }, pricing: function(f,y){ switch(this.scale(f)){ case 1: return '$1.95'; case 2: return '$2.95'; case 3: return '$3.95'; case 4: return '$4.95'; case 5: return '$5.95'; case 6: return '$6.95'; case 7: return '$7.95'; case 8: return '$8.95'; } }, merchant: function(f,y){ return '3.00%'; }, scale: function(f){ if(f <= 35){ return 1; }else if(f >= 36 && f <= 50){ return 2; }else if(f >= 51 && f <= 100){ return 3; }else if(f >= 101 && f <= 125){ return 4; }else if(f >= 126 && f <= 175){ return 5; }else if(f >= 176 && f <= 200){ return 6; }else if(f >= 201 && f <= 300){ return 7; }else if(f >= 301){ return 8; } }, blurb: [ ], monthly: 0.00 }, 'eply': { name: 'Eply', calculate: function(f,y,m){ var fee = (f*0.01) + 4.00; if(m){ fee += f*0.03; } return fee; }, pricing: function(f,y){ return '$4.00 + 1%'; }, merchant: function(f){ return '3%'; }, blurb: [ ], monthly: 0.00 }, 'runsignup': { name: 'RunSignUp', calculate: function(f,y,m){ var fee = 0; switch(this.scale(f)){ case 1: fee += 0.00; break; case 2: fee += 2.00; break; case 3: fee += 2.50; break; case 4: fee += 3.00; break; case 5: fee += f * 0.06; break; case 6: fee += f * 0.05; break; case 7: fee += f * 0.04; break; } if(m){ fee += f*0.03; } return fee; }, pricing: function(f,y){ switch(this.scale(f)){ case 1: return "Free"; case 2: return "$2.00"; case 3: return "$2.50"; case 4: return "$3.00"; case 5: return "6%"; case 6: return "5%"; case 7: return "4%"; } }, merchant: function(f){ return '3%'; }, scale: function(f){ if(f == 0){ return 1; }else if(f > 0 && f < 10){ return 2; }else if(f >= 10 && f < 30){ return 3; }else if(f >= 30 && f < 50){ return 4; }else if(f >= 50 && f < 250){ return 5; }else if(f >= 250 && f < 1000){ return 6; }else if(f >= 1000){ return 7; } }, blurb: [ '4-4.8% fee on donations' ], monthly: 0.00 }, 'raceit': { name: 'RaceIt', calculate: function(f,y,m){ var fee = 0; switch(this.scale(f)){ case 1: fee += (f*0.06) + 1.25; break; case 2: fee += (f*0.05) + 1.25; break; case 3: fee += (f*0.035) + 5.25; break; case 4: fee += (f*0.03) + 7.25; break; } if(m){ fee += f*0.03; } return fee; }, pricing: function(f,y){ switch(this.scale(f)){ case 1: return "$1.25 + 6%"; case 2: return "$1.25 + 5%"; case 3: return "$5.25 + 3.5%"; case 4: return "$7.25 + 3%"; } }, merchant: function(f){ return '3%'; }, scale: function(f){ if(f <= 50){ return 1; }else if(f > 50 && f < 200){ return 2; }else if(f >= 200 && f < 500){ return 3; }else if(f >= 500){ return 4; } }, blurb: [ '6% fee on donations and merchandise' ], monthly: 0.00 }, 'raceroster': { name: 'RaceRoster', calculate: function(f,y,m){ var fee = 0; switch(this.scale(f)){ case 1: fee += 0.00; break; case 2: fee += 0.75; break; case 3: fee += 1.75; break; case 4: fee += 2.50; break; case 5: fee += 2.95; break; case 6: fee += 3.50; break; case 7: fee += 3.95; break; case 8: fee += 4.50; break; case 9: fee += 4.95; break; case 10: fee += 5.50; break; case 11: fee += 5.95; break; case 12: fee += 6.50; break; case 13: fee += f*0.065; break; case 14: fee += (f*0.04) + 10.00; break; } if(m){ fee += f*0.03; } return fee; }, pricing: function(f,y){ switch(this.scale(f)){ case 1: return "Free"; case 2: return "$0.75"; case 3: return "$1.75"; case 4: return "$2.50"; case 5: return "$2.95"; case 6: return "$3.50"; case 7: return "$3.95"; case 8: return "$4.50"; case 9: return "$4.95"; case 10: return "$5.50"; case 11: return "$5.95"; case 12: return "$6.50"; case 13: return "6.5%"; case 14: return "$10.00 + 4%"; } }, merchant: function(f){ return '3%'; }, scale: function(f){ if(f == 0){ return 1; }else if(f > 0 && f <= 5){ return 2; }else if(f > 5 && f <= 10){ return 3; }else if(f > 10 && f <= 20){ return 4; }else if(f > 20 && f <= 30){ return 5; }else if(f > 30 && f <= 40){ return 6; }else if(f > 40 && f <= 50){ return 7; }else if(f > 50 && f <= 60){ return 8; }else if(f > 60 && f <= 70){ return 9; }else if(f > 70 && f <= 80){ return 10; }else if(f > 80 && f <= 90){ return 11; }else if(f > 90 && f <= 100){ return 12; }else if(f > 100 && f <= 500){ return 13; }else if(f > 500){ return 14; } }, blurb: [ ], monthly: 0.00 }, 'imathlete': { name: 'ImAthlete', calculate: function(f,y,m){ var fee = 0; switch(this.scale(f)){ case 1: fee += f*0.13; break; case 2: fee += f*0.09; break; } if(m){ fee += f*0.03; } return fee; }, pricing: function(f,y){ switch(this.scale(f)){ case 1: return "13%"; case 2: return "9%"; } }, merchant: function(f){ return '3%'; }, scale: function(f){ if(f < 20){ return 1; }else if(f >= 20){ return 2; } }, blurb: [ ], monthly: 0.00 }, ticketleap: { name: 'TicketLeap', calculate: function(f,y,m){ var fee = 1; if(f > 5){ fee += (f * 0.02) }else{ fee = 0.25; } fee = fee > 10 ? 10 : fee; if(m){ fee += (f * 0.03); } return fee; }, pricing: function(f,y){ return '$1 + 2%, capped at $10.00'; }, merchant: function(f,y){ return '3%'; }, blurb: [ 'No contracts, no setup fees, no cancelation fees' ], monthly: 0.00 }, 'showclix': { name: 'ShowClix', calculate: function(f,y,m){ var fee = 0; switch(this.scale(f)){ case 1: fee += (f * 0.03) + 3.75; break; case 2: fee += (f * 0.08); break; } if(m){ fee += f*0.03; } return fee; }, pricing: function(f,y){ switch(this.scale(f)){ case 1: return "$3.75 + 3%"; case 2: return "8%"; } }, merchant: function(f){ return '3%'; }, scale: function(f){ if(f < 50){ return 1; }else if(f >= 50){ return 2; } }, blurb: [ ], monthly: 0.00 } } var data = { product: '', comparing: [], term: 'registrant', init: function(product,comparing,term){ this.product = product; this.comparing = comparing; this.term = term ? term : this.term; $('#product-name').html(providers[this.product].name); $('#product-term').html(this.term); this.update(); }, setValue: function(key,value,init){ this[key] = value; $output = $('#'+key+' output'); $output.html(value); $input = $('#'+key+' input[type="range"]'); $input.val(value).change(); $input2 = $('#'+key+' .slider-input input');; $input2.val(value); if(!init){ this.update(); } }, update: function(){ var entryfee = this.entryfee; var attendees = this.attendees; var events = this.events; var yearlyAttendees = attendees*events; var mfees = $('#toggle-card').is(':checked'); if(this.comparing.length == 1){ $container = $('.compare-one'); $list = $container.find('ul'); $list.html(''); var template = '
  • Pricing is per '+data.term+'
  • '; var templatec = '
    Average credit card fees are
    '; var product = providers[this.product]; var competitor = providers[this.comparing[0]]; var $pelement = $(template); $pelement.find('.provider-name').html(product.name); $pelement.find('.provider-pricing').html(product.pricing(entryfee, yearlyAttendees)); if(product.merchant(entryfee)){ $melement = $(templatec); $melement.find('.provider-merch-fee').html(product.merchant(entryfee, yearlyAttendees)); $pelement.append($melement); } for(var i in product.blurb){ $pelement.append($('
    '+product.blurb[i]+'
    ')); } $list.append($pelement); var $celement = $(template); $celement.find('.provider-name').html(competitor.name); $celement.find('.provider-pricing').html(competitor.pricing(entryfee, yearlyAttendees)); if(competitor.merchant(entryfee)){ $melement = $(templatec); $melement.find('.provider-merch-fee').html(competitor.merchant(entryfee, yearlyAttendees)); $celement.append($melement); } for(var i in competitor.blurb){ $celement.append($('
    '+competitor.blurb[i]+'
    ')); } $list.append($celement); var productFee = product.calculate(entryfee, yearlyAttendees, mfees); var competitorFee = competitor.calculate(entryfee, yearlyAttendees, mfees); var productTotalFees = (productFee * yearlyAttendees) + (12 * product.monthly); var competitorTotalFees = (competitorFee * yearlyAttendees) + (12 * competitor.monthly); var yearlySavings = competitorTotalFees - productTotalFees; var percentSavings = ((competitorTotalFees / productTotalFees) - 1) * 100; $('#total-1').html(formatCurrency(yearlySavings)); $('#total-5').html(formatCurrency(yearlySavings*5)); $('.competitor-fees').html(formatCurrency(competitorTotalFees)); $('.product-fees').html(formatCurrency(productTotalFees)); $('#percent').html(percentSavings.toFixed(0)+'%'); $('#header-competitor-name').html(competitor.name); $('#header-product-name').html(product.name); $container.find('.product-name').html(product.name); $container.find('.competitor-name').html(competitor.name); $container.show(); }else if(this.comparing.length > 1){ $container = $('.compare-all'); $list = $container.find('ul'); $list.html(''); var template = '
  • vs
    savings per year
  • '; var product = providers[this.product]; var allYearlySavings = []; for(var i in this.comparing){ var competitor = providers[this.comparing[i]]; var productFee = product.calculate(entryfee, yearlyAttendees, mfees); var competitorFee = competitor.calculate(entryfee, yearlyAttendees, mfees); var productTotalFees = (productFee * yearlyAttendees) + (12 * product.monthly); var competitorTotalFees = (competitorFee * yearlyAttendees) + (12 * competitor.monthly); var yearlySavings = competitorTotalFees - productTotalFees; allYearlySavings.push(yearlySavings); $element = $(template); $element.find('.product-name').html(product.name); $element.find('.competitor-name').html(competitor.name); $element.find('.total-price').html(formatCurrency(yearlySavings)); $list.append($element); } allYearlySavings.sort(function(a,b){return a - b;}); lowestYearlySavings = allYearlySavings[0]; highestYearlySavings = allYearlySavings[allYearlySavings.length-1]; $container.find('.product-name').html(product.name); $('#total-1').html(formatCurrency(lowestYearlySavings) + ' - ' + formatCurrency(highestYearlySavings)); $('#total-5').html(formatCurrency(lowestYearlySavings*5) + ' - ' + formatCurrency(highestYearlySavings*5)); $('#header-competitor-name').html('the Rest'); $('#header-product-name').html(product.name); $container.show(); } } } initCalculator = function(product,comparing,term){ data.init(product,comparing,term); } function formatCurrency(x) { return '$'+x.toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ","); } $('.slider-output').on('click', function(e){ var key = $(this).parent().parent().attr('id'); var $input = $('#'+key+' .slider-input input'); $input.val(data[key]); $('#'+key+' .slider-output').hide(); $('#'+key+' .slider-input').show(); $input.focus().select(); }); $('.slider-input input').on('blur', function(e){ var key = $(this).parent().parent().parent().attr('id'); var $input = $('#'+key+' .slider-input input'); var value = $input.val(); $('#'+key+' .slider-input').hide(); $('#'+key+' .slider-output').show(); if(!isNaN(value) && value > 0){ data.setValue(key,value); } }); $('#toggle-card').on('click', function(e){ data.update(); }); // Basic rangeslider initialization $('[data-rangeslider]').rangeslider({ // Deactivate the feature detection polyfill: false, // Callback function onInit: function() {}, // Callback function onSlide: function(position, value) { var key = this.$element.parent().attr('id'); data.setValue(key,value); }, // Callback function onSlideEnd: function(position, value) { var key = this.$element.parent().attr('id'); data.setValue(key,value); } }); data.setValue('entryfee',100,true); data.setValue('attendees',300,true); data.setValue('events',12,true); data.update(); });