PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.20
Booking for Appointments and Events Calendar – Amelia v1.2.20
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / v3 / src / assets / js / common / formatting.js
ameliabooking / v3 / src / assets / js / common Last commit date
appointments.js 1 year ago attendees.js 1 year ago colorManipulation.js 3 years ago customer.js 1 year ago date.js 1 year ago defaultCustomize.js 1 year ago employee.js 1 year ago events.js 1 year ago formFieldsTemplates.js 3 years ago formatting.js 1 year ago helper.js 1 year ago image.js 1 year ago integrationApple.js 1 year ago integrationGoogle.js 1 year ago integrationOutlook.js 1 year ago integrationStripe.js 1 year ago integrationZoom.js 1 year ago licence.js 2 years ago objectAndArrayManipulation.js 3 years ago pricing.js 1 year ago recurring.js 1 year ago responsive.js 1 year ago scrollElements.js 4 years ago settings.js 1 year ago translationsElementPlus.js 1 year ago
formatting.js
94 lines
1 import {settings} from '../../../plugins/settings.js'
2
3 const thousandSeparatorMap = {
4 1: ',',
5 2: '.',
6 3: ' ',
7 4: ' '
8 }
9
10 const decimalSeparatorMap = {
11 1: '.',
12 2: ',',
13 3: '.',
14 4: ','
15 }
16
17
18 function getCurrencySymbol () {
19 return settings.payments.currency
20 }
21
22 function getPriceThousandSeparator () {
23 return thousandSeparatorMap[settings.payments.priceSeparator]
24 }
25
26 function getPriceDecimalSeparator () {
27 return decimalSeparatorMap[settings.payments.priceSeparator]
28 }
29
30 function getPriceNumberOfDecimalPlaces () {
31 return settings.payments.priceNumberOfDecimals
32 }
33
34 function getPricePrefix () {
35 if (settings.payments.priceSymbolPosition === 'after' || settings.payments.priceSymbolPosition === 'afterWithSpace') {
36 return ''
37 } else if (settings.payments.priceSymbolPosition === 'before') {
38 return getCurrencySymbol()
39 } else {
40 return getCurrencySymbol() + ' '
41 }
42 }
43
44 function getPriceSuffix () {
45 if (settings.payments.priceSymbolPosition === 'before' || settings.payments.priceSymbolPosition === 'beforeWithSpace') {
46 return ''
47 } else if (settings.payments.priceSymbolPosition === 'after') {
48 return getCurrencySymbol()
49 } else {
50 return ' ' + getCurrencySymbol()
51 }
52 }
53
54 function useFormattedPrice (price) {
55 let showCurrency = !settings.payments.hideCurrencySymbolFrontend
56 let decimalPlaces = getPriceNumberOfDecimalPlaces()
57 let thousandSeparator = getPriceThousandSeparator()
58 let decimalSeparator = getPriceDecimalSeparator()
59 let pricePrefix = getPricePrefix()
60 let priceSuffix = getPriceSuffix()
61
62 let i = parseInt(price = Math.abs(+price || 0).toFixed(decimalPlaces)) + ''
63 let j = i.length > 3 ? i.length % 3 : 0
64
65 return (showCurrency ? pricePrefix : '') + (j ? i.substr(0, j) + thousandSeparator : '') + i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + thousandSeparator) + (decimalPlaces ? decimalSeparator + Math.abs(price - i).toFixed(decimalPlaces).slice(2) : '') + (showCurrency ? priceSuffix : '')
66 }
67
68 function capitalizeFirstLetter (string) {
69 return string.charAt(0).toUpperCase() + string.slice(1)
70 }
71
72 function useRandomIntFromInterval (min, max) {
73 // min and max included
74 return Math.floor(Math.random() * (max - min + 1) + min)
75 }
76
77 function useCurrencyOptions () {
78 return {
79 thousands: getPriceThousandSeparator(),
80 decimal: getPriceDecimalSeparator(),
81 precision: getPriceNumberOfDecimalPlaces(),
82 suffix: getPriceSuffix(),
83 prefix: getPricePrefix(),
84 }
85 }
86
87 export {
88 useCurrencyOptions,
89 useFormattedPrice,
90 useRandomIntFromInterval,
91 capitalizeFirstLetter,
92 getCurrencySymbol,
93 }
94