PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.6
Booking for Appointments and Events Calendar – Amelia v2.4.6
2.4.7 2.4.6 2.4.5 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 month ago attendees.js 1 month ago colorManipulation.js 1 month ago customer.js 1 month ago date.js 3 weeks ago defaultCustomize.js 3 weeks ago employee.js 5 days ago events.js 1 month ago formFieldsTemplates.js 1 month ago formatting.js 1 month ago helper.js 5 days ago image.js 1 month ago integrationApple.js 1 month ago integrationGoogle.js 1 month ago integrationOutlook.js 1 month ago integrationStripe.js 1 month ago integrationZoom.js 1 month ago licence.js 1 month ago liveAnnouncer.js 3 weeks ago phone.js 3 weeks ago pricing.js 1 month ago recurring.js 5 days ago responsive.js 1 month ago scrollElements.js 1 month ago settings.js 1 month ago translationsElementPlus.js 1 month ago utilHeaderHeight.js 1 month ago
formatting.js
110 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 function getCurrencySymbol() {
18 return settings.payments.currency
19 }
20
21 function getPriceThousandSeparator() {
22 return thousandSeparatorMap[settings.payments.priceSeparator]
23 }
24
25 function getPriceDecimalSeparator() {
26 return decimalSeparatorMap[settings.payments.priceSeparator]
27 }
28
29 function getPriceNumberOfDecimalPlaces() {
30 return settings.payments.priceNumberOfDecimals
31 }
32
33 function getPricePrefix() {
34 if (
35 settings.payments.priceSymbolPosition === 'after' ||
36 settings.payments.priceSymbolPosition === 'afterWithSpace'
37 ) {
38 return ''
39 } else if (settings.payments.priceSymbolPosition === 'before') {
40 return getCurrencySymbol()
41 } else {
42 return getCurrencySymbol() + ' '
43 }
44 }
45
46 function getPriceSuffix() {
47 if (
48 settings.payments.priceSymbolPosition === 'before' ||
49 settings.payments.priceSymbolPosition === 'beforeWithSpace'
50 ) {
51 return ''
52 } else if (settings.payments.priceSymbolPosition === 'after') {
53 return getCurrencySymbol()
54 } else {
55 return ' ' + getCurrencySymbol()
56 }
57 }
58
59 function useFormattedPrice(price) {
60 let showCurrency = !settings.payments.hideCurrencySymbolFrontend
61 let decimalPlaces = getPriceNumberOfDecimalPlaces()
62 let thousandSeparator = getPriceThousandSeparator()
63 let decimalSeparator = getPriceDecimalSeparator()
64 let pricePrefix = getPricePrefix()
65 let priceSuffix = getPriceSuffix()
66
67 let i = parseInt((price = Math.abs(+price || 0).toFixed(decimalPlaces))) + ''
68 let j = i.length > 3 ? i.length % 3 : 0
69
70 return (
71 (showCurrency ? pricePrefix : '') +
72 (j ? i.substr(0, j) + thousandSeparator : '') +
73 i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + thousandSeparator) +
74 (decimalPlaces
75 ? decimalSeparator +
76 Math.abs(price - i)
77 .toFixed(decimalPlaces)
78 .slice(2)
79 : '') +
80 (showCurrency ? priceSuffix : '')
81 )
82 }
83
84 function capitalizeFirstLetter(string) {
85 return string.charAt(0).toUpperCase() + string.slice(1)
86 }
87
88 function useRandomIntFromInterval(min, max) {
89 // min and max included
90 return Math.floor(Math.random() * (max - min + 1) + min)
91 }
92
93 function useCurrencyOptions() {
94 return {
95 thousands: getPriceThousandSeparator(),
96 decimal: getPriceDecimalSeparator(),
97 precision: getPriceNumberOfDecimalPlaces(),
98 suffix: getPriceSuffix(),
99 prefix: getPricePrefix(),
100 }
101 }
102
103 export {
104 useCurrencyOptions,
105 useFormattedPrice,
106 useRandomIntFromInterval,
107 capitalizeFirstLetter,
108 getCurrencySymbol,
109 }
110