2018-11-05 05:06:39 -05:00
|
|
|
/* eslint-disable
|
|
|
|
camelcase,
|
2018-11-13 08:35:50 -05:00
|
|
|
max-len
|
2018-11-05 05:06:39 -05:00
|
|
|
*/
|
2020-05-19 05:02:56 -04:00
|
|
|
import App from '../base'
|
2021-04-15 10:23:12 -04:00
|
|
|
import getMeta from '../utils/meta'
|
2021-04-14 09:17:21 -04:00
|
|
|
App.factory('MultiCurrencyPricing', function () {
|
2021-04-15 10:23:12 -04:00
|
|
|
const currencyCode = getMeta('ol-recomendedCurrency')
|
2020-05-19 05:02:56 -04:00
|
|
|
|
|
|
|
return {
|
|
|
|
currencyCode,
|
|
|
|
|
|
|
|
plans: {
|
|
|
|
USD: {
|
|
|
|
symbol: '$',
|
|
|
|
student: {
|
|
|
|
monthly: '$8',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$80',
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-10-13 08:32:57 -04:00
|
|
|
personal: {
|
|
|
|
monthly: '$10',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$120',
|
2020-10-13 08:32:57 -04:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
collaborator: {
|
|
|
|
monthly: '$15',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$180',
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
professional: {
|
|
|
|
monthly: '$30',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$360',
|
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2020-05-19 05:02:56 -04:00
|
|
|
EUR: {
|
|
|
|
symbol: '€',
|
|
|
|
student: {
|
|
|
|
monthly: '€7',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '€70',
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-10-13 08:32:57 -04:00
|
|
|
personal: {
|
|
|
|
monthly: '€9',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '€108',
|
2020-10-13 08:32:57 -04:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
collaborator: {
|
|
|
|
monthly: '€14',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '€168',
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '€28',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '€336',
|
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2020-05-19 05:02:56 -04:00
|
|
|
GBP: {
|
|
|
|
symbol: '£',
|
|
|
|
student: {
|
|
|
|
monthly: '£6',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '£60',
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-10-13 08:32:57 -04:00
|
|
|
personal: {
|
|
|
|
monthly: '£8',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '£96',
|
2020-10-13 08:32:57 -04:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
collaborator: {
|
|
|
|
monthly: '£12',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '£144',
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
professional: {
|
|
|
|
monthly: '£24',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '£288',
|
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2020-05-19 05:02:56 -04:00
|
|
|
SEK: {
|
|
|
|
symbol: 'kr',
|
|
|
|
student: {
|
|
|
|
monthly: '60 kr',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '600 kr',
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-10-13 08:32:57 -04:00
|
|
|
personal: {
|
|
|
|
monthly: '73 kr',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '876 kr',
|
2020-10-13 08:32:57 -04:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
collaborator: {
|
|
|
|
monthly: '110 kr',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '1320 kr',
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
professional: {
|
|
|
|
monthly: '220 kr',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '2640 kr',
|
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
|
|
|
CAD: {
|
|
|
|
symbol: '$',
|
|
|
|
student: {
|
|
|
|
monthly: '$9',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$90',
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-10-13 08:32:57 -04:00
|
|
|
personal: {
|
|
|
|
monthly: '$11',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$132',
|
2020-10-13 08:32:57 -04:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
collaborator: {
|
|
|
|
monthly: '$17',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$204',
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
professional: {
|
|
|
|
monthly: '$34',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$408',
|
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2020-05-19 05:02:56 -04:00
|
|
|
NOK: {
|
|
|
|
symbol: 'kr',
|
|
|
|
student: {
|
|
|
|
monthly: '60 kr',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '600 kr',
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-10-13 08:32:57 -04:00
|
|
|
personal: {
|
|
|
|
monthly: '73 kr',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '876 kr',
|
2020-10-13 08:32:57 -04:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
collaborator: {
|
|
|
|
monthly: '110 kr',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '1320 kr',
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '220 kr',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '2640 kr',
|
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
2020-05-07 09:17:23 -04:00
|
|
|
|
2020-05-19 05:02:56 -04:00
|
|
|
DKK: {
|
|
|
|
symbol: 'kr',
|
|
|
|
student: {
|
|
|
|
monthly: '50 kr',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '500 kr',
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
2020-10-13 08:32:57 -04:00
|
|
|
personal: {
|
|
|
|
monthly: '60 kr',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '720 kr',
|
2020-10-13 08:32:57 -04:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
collaborator: {
|
|
|
|
monthly: '90 kr',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '1080 kr',
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '180 kr',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '2160 kr',
|
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2020-05-19 05:02:56 -04:00
|
|
|
AUD: {
|
|
|
|
symbol: '$',
|
|
|
|
student: {
|
|
|
|
monthly: '$10',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$100',
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
2020-10-13 08:32:57 -04:00
|
|
|
personal: {
|
|
|
|
monthly: '$12',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$144',
|
2020-10-13 08:32:57 -04:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
collaborator: {
|
|
|
|
monthly: '$18',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$216',
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '$35',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$420',
|
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2020-05-19 05:02:56 -04:00
|
|
|
NZD: {
|
|
|
|
symbol: '$',
|
|
|
|
student: {
|
|
|
|
monthly: '$10',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$100',
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
2020-10-13 08:32:57 -04:00
|
|
|
personal: {
|
|
|
|
monthly: '$12',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$144',
|
2020-10-13 08:32:57 -04:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
collaborator: {
|
|
|
|
monthly: '$18',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$216',
|
2018-11-13 08:35:50 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
professional: {
|
|
|
|
monthly: '$35',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$420',
|
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
CHF: {
|
|
|
|
symbol: 'Fr',
|
|
|
|
student: {
|
|
|
|
monthly: 'Fr 8',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: 'Fr 80',
|
2018-11-13 08:35:50 -05:00
|
|
|
},
|
2020-10-13 08:32:57 -04:00
|
|
|
personal: {
|
|
|
|
monthly: 'Fr 10',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: 'Fr 120',
|
2020-10-13 08:32:57 -04:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
collaborator: {
|
|
|
|
monthly: 'Fr 15',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: 'Fr 180',
|
2018-11-13 08:35:50 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
professional: {
|
|
|
|
monthly: 'Fr 30',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: 'Fr 360',
|
|
|
|
},
|
2018-11-13 08:35:50 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
|
|
|
|
SGD: {
|
|
|
|
symbol: '$',
|
|
|
|
student: {
|
|
|
|
monthly: '$12',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$120',
|
2018-11-13 08:35:50 -05:00
|
|
|
},
|
2020-10-13 08:32:57 -04:00
|
|
|
personal: {
|
|
|
|
monthly: '$13',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$156',
|
2020-10-13 08:32:57 -04:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
collaborator: {
|
|
|
|
monthly: '$20',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$240',
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '$40',
|
2021-04-27 03:52:58 -04:00
|
|
|
annual: '$480',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
}
|
|
|
|
})
|
2018-11-13 08:35:50 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
App.controller(
|
|
|
|
'PlansController',
|
|
|
|
function (
|
|
|
|
$scope,
|
|
|
|
$modal,
|
|
|
|
eventTracking,
|
|
|
|
MultiCurrencyPricing,
|
|
|
|
$http,
|
|
|
|
$filter,
|
|
|
|
$location
|
|
|
|
) {
|
|
|
|
$scope.plans = MultiCurrencyPricing.plans
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.currencyCode = MultiCurrencyPricing.currencyCode
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.trial_len = 7
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.planQueryString = '_free_trial_7_days'
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.ui = { view: 'monthly' }
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.changeCurreny = function (e, newCurrency) {
|
|
|
|
e.preventDefault()
|
|
|
|
$scope.currencyCode = newCurrency
|
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
// because ternary logic in angular bindings is hard
|
|
|
|
$scope.getCollaboratorPlanCode = function () {
|
|
|
|
const { view } = $scope.ui
|
|
|
|
if (view === 'annual') {
|
|
|
|
return 'collaborator-annual'
|
|
|
|
} else {
|
|
|
|
return `collaborator${$scope.planQueryString}`
|
|
|
|
}
|
2018-11-13 08:35:50 -05:00
|
|
|
}
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.getPersonalPlanCode = function () {
|
|
|
|
const { view } = $scope.ui
|
|
|
|
if (view === 'annual') {
|
|
|
|
return 'paid-personal-annual'
|
|
|
|
} else {
|
|
|
|
return `paid-personal${$scope.planQueryString}`
|
|
|
|
}
|
2020-10-13 08:32:57 -04:00
|
|
|
}
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.signUpNowClicked = function (plan, location) {
|
|
|
|
if ($scope.ui.view === 'annual') {
|
|
|
|
plan = `${plan}_annual`
|
|
|
|
}
|
|
|
|
plan = eventLabel(plan, location)
|
|
|
|
eventTracking.sendMB('plans-page-start-trial')
|
|
|
|
eventTracking.send('subscription-funnel', 'sign_up_now_button', plan)
|
2018-11-13 08:35:50 -05:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.switchToMonthly = function (e, location) {
|
|
|
|
const uiView = 'monthly'
|
|
|
|
switchEvent(e, uiView + '-prices', location)
|
|
|
|
$scope.ui.view = uiView
|
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.switchToStudent = function (e, location) {
|
|
|
|
const uiView = 'student'
|
|
|
|
switchEvent(e, uiView + '-prices', location)
|
|
|
|
$scope.ui.view = uiView
|
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.switchToAnnual = function (e, location) {
|
|
|
|
const uiView = 'annual'
|
|
|
|
switchEvent(e, uiView + '-prices', location)
|
|
|
|
$scope.ui.view = uiView
|
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.openGroupPlanModal = function () {
|
|
|
|
const path = `${window.location.pathname}${window.location.search}`
|
|
|
|
history.replaceState(null, document.title, path + '#groups')
|
|
|
|
$modal
|
|
|
|
.open({
|
|
|
|
templateUrl: 'groupPlanModalPurchaseTemplate',
|
2021-04-27 03:52:58 -04:00
|
|
|
controller: 'GroupPlansModalPurchaseController',
|
2021-04-14 09:17:21 -04:00
|
|
|
})
|
|
|
|
.result.finally(() =>
|
|
|
|
history.replaceState(null, document.title, window.location.pathname)
|
|
|
|
)
|
|
|
|
eventTracking.send(
|
|
|
|
'subscription-funnel',
|
|
|
|
'plans-page',
|
|
|
|
'group-inquiry-potential'
|
2020-05-19 05:02:56 -04:00
|
|
|
)
|
2021-04-14 09:17:21 -04:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
if ($location.hash() === 'groups') {
|
|
|
|
$scope.openGroupPlanModal()
|
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
var eventLabel = (label, location) => label
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-05-05 09:05:04 -04:00
|
|
|
function switchEvent(e, label, location) {
|
2021-04-14 09:17:21 -04:00
|
|
|
e.preventDefault()
|
|
|
|
const gaLabel = eventLabel(label, location)
|
|
|
|
eventTracking.send('subscription-funnel', 'plans-page', gaLabel)
|
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
}
|
2021-04-14 09:17:21 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
App.controller(
|
|
|
|
'GroupPlansModalPurchaseController',
|
|
|
|
function ($scope, $modal, $location, $httpParamSerializer) {
|
|
|
|
$scope.options = {
|
|
|
|
plan_codes: [
|
|
|
|
{
|
|
|
|
display: 'Collaborator',
|
2021-04-27 03:52:58 -04:00
|
|
|
code: 'collaborator',
|
2021-04-14 09:17:21 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
display: 'Professional',
|
2021-04-27 03:52:58 -04:00
|
|
|
code: 'professional',
|
|
|
|
},
|
2021-04-14 09:17:21 -04:00
|
|
|
],
|
|
|
|
currencies: [
|
|
|
|
{
|
|
|
|
display: 'USD ($)',
|
2021-04-27 03:52:58 -04:00
|
|
|
code: 'USD',
|
2021-04-14 09:17:21 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
display: 'GBP (£)',
|
2021-04-27 03:52:58 -04:00
|
|
|
code: 'GBP',
|
2021-04-14 09:17:21 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
display: 'EUR (€)',
|
2021-04-27 03:52:58 -04:00
|
|
|
code: 'EUR',
|
|
|
|
},
|
2021-04-14 09:17:21 -04:00
|
|
|
],
|
|
|
|
currencySymbols: {
|
|
|
|
USD: '$',
|
|
|
|
EUR: '€',
|
2021-04-27 03:52:58 -04:00
|
|
|
GBP: '£',
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
2021-04-14 09:17:21 -04:00
|
|
|
sizes: [2, 3, 4, 5, 10, 20, 50],
|
|
|
|
usages: [
|
|
|
|
{
|
|
|
|
display: 'Enterprise',
|
2021-04-27 03:52:58 -04:00
|
|
|
code: 'enterprise',
|
2021-04-14 09:17:21 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
display: 'Educational',
|
2021-04-27 03:52:58 -04:00
|
|
|
code: 'educational',
|
|
|
|
},
|
|
|
|
],
|
2021-04-14 09:17:21 -04:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-15 10:23:12 -04:00
|
|
|
$scope.prices = getMeta('ol-groupPlans')
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
let currency = 'USD'
|
2021-04-15 10:23:12 -04:00
|
|
|
const recomendedCurrency = getMeta('ol-recomendedCurrency')
|
|
|
|
if (['USD', 'GBP', 'EUR'].includes(recomendedCurrency)) {
|
|
|
|
currency = recomendedCurrency
|
2019-03-27 06:08:45 -04:00
|
|
|
}
|
2021-04-14 09:17:21 -04:00
|
|
|
|
|
|
|
// default selected
|
|
|
|
$scope.selected = {
|
|
|
|
plan_code: 'collaborator',
|
|
|
|
currency,
|
|
|
|
size: '10',
|
2021-05-05 09:38:11 -04:00
|
|
|
usage: 'enterprise',
|
2018-11-13 08:35:50 -05:00
|
|
|
}
|
2021-04-14 09:17:21 -04:00
|
|
|
// selected via query
|
|
|
|
if ($location.search()) {
|
|
|
|
// usage
|
|
|
|
if ($location.search().usage) {
|
|
|
|
$scope.options.usages.forEach(usage => {
|
|
|
|
if (usage.code === $location.search().usage) {
|
|
|
|
$scope.selected.usage = usage.code
|
|
|
|
}
|
|
|
|
})
|
2020-05-19 05:02:56 -04:00
|
|
|
}
|
2021-04-14 09:17:21 -04:00
|
|
|
// plan
|
|
|
|
if ($location.search().plan) {
|
|
|
|
$scope.options.plan_codes.forEach(plan => {
|
|
|
|
if (plan.code === $location.search().plan) {
|
|
|
|
$scope.selected.plan_code = plan.code
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
// number
|
|
|
|
if ($location.search().number) {
|
|
|
|
// $location.search().number is a string,
|
|
|
|
// but $scope.options.sizes are numbers
|
|
|
|
// and $scope.selected.size is a string
|
|
|
|
const groupCount = parseInt($location.search().number, 10)
|
|
|
|
if ($scope.options.sizes.indexOf(groupCount) !== -1) {
|
|
|
|
$scope.selected.size = $location.search().number
|
2020-05-19 05:02:56 -04:00
|
|
|
}
|
2021-04-14 09:17:21 -04:00
|
|
|
}
|
|
|
|
// currency
|
|
|
|
if ($location.search().currency) {
|
|
|
|
$scope.options.currencies.forEach(currency => {
|
|
|
|
if (currency.code === $location.search().currency) {
|
|
|
|
$scope.selected.currency = currency.code
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2018-11-13 08:35:50 -05:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.recalculatePrice = function () {
|
2021-05-05 09:05:04 -04:00
|
|
|
const { usage, plan_code, currency, size } = $scope.selected
|
2021-04-14 09:17:21 -04:00
|
|
|
const price = $scope.prices[usage][plan_code][currency][size]
|
|
|
|
const currencySymbol = $scope.options.currencySymbols[currency]
|
|
|
|
$scope.displayPrice = `${currencySymbol}${price}`
|
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.$watch('selected', $scope.recalculatePrice, true)
|
|
|
|
$scope.recalculatePrice()
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.purchase = function () {
|
|
|
|
const { plan_code, size, usage, currency } = $scope.selected
|
|
|
|
const queryParams = {
|
|
|
|
planCode: `group_${plan_code}_${size}_${usage}`,
|
|
|
|
currency,
|
2021-04-27 03:52:58 -04:00
|
|
|
itm_campaign: 'groups',
|
2021-04-14 09:17:21 -04:00
|
|
|
}
|
|
|
|
if ($location.search().itm_content) {
|
|
|
|
queryParams.itm_content = $location.search().itm_content
|
|
|
|
}
|
|
|
|
window.location = `/user/subscription/new?${$httpParamSerializer(
|
|
|
|
queryParams
|
|
|
|
)}`
|
2020-06-11 11:24:38 -04:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
}
|
2021-04-14 09:17:21 -04:00
|
|
|
)
|