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 / helper.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
helper.js
190 lines
1 import { settings } from '../../../plugins/settings.js'
2
3 function useCurrentTimeZone() {
4 return Intl.DateTimeFormat().resolvedOptions().timeZone
5 }
6
7 function useRemoveUrlParameter(url, parameter) {
8 let urlParts = url.split('?')
9
10 if (urlParts.length >= 2) {
11 let prefix = encodeURIComponent(parameter) + '='
12 let pars = urlParts[1].split(/[&;]/g)
13
14 for (let i = pars.length; i-- > 0; ) {
15 if (pars[i].lastIndexOf(prefix, 0) !== -1) {
16 pars.splice(i, 1)
17 }
18 }
19
20 url = urlParts[0] + (pars.length > 0 ? '?' + pars.join('&') : '')
21 }
22
23 return url
24 }
25
26 function useUrlParams(params) {
27 if (!settings.activation.disableUrlParams) {
28 return params
29 }
30
31 let names = [
32 'categories',
33 'services',
34 'packages',
35 'employees',
36 'providers',
37 'providerIds',
38 'extras',
39 'locations',
40 'events',
41 'types',
42 'dates',
43 'customers',
44 'providers',
45 'services',
46 'locations',
47 'status',
48 ]
49
50 let convertedParams = JSON.parse(JSON.stringify(params))
51
52 names.forEach((name) => {
53 if (name === 'extras' && name in convertedParams && convertedParams['extras']) {
54 convertedParams['extras'] = JSON.parse(convertedParams['extras'])
55
56 let extras = []
57
58 convertedParams['extras'].forEach((item) => {
59 extras.push(item.id + '-' + item.quantity)
60 })
61
62 convertedParams['extras'] = extras.length ? extras : null
63 }
64
65 if (
66 name in convertedParams &&
67 Array.isArray(convertedParams[name]) &&
68 convertedParams[name].length
69 ) {
70 convertedParams[name] = convertedParams[name].join(',')
71 }
72 })
73
74 return convertedParams
75 }
76
77 function useSortedDateStrings(dates) {
78 return dates.sort((a, b) => new Date(a) - new Date(b))
79 }
80
81 function useSortedTimeStrings(times) {
82 return times.sort((a, b) => new Date(`2000-01-01T${a}`) - new Date(`2000-01-01T${b}`))
83 }
84
85 function useUrlQueryParams(url) {
86 let queryString =
87 url.indexOf('#') > 0 ? url.substring(0, url.indexOf('#')).split('?')[1] : url.split('?')[1]
88
89 if (queryString) {
90 let keyValuePairs = queryString.split('&')
91 let keyValue = []
92 let queryParams = {}
93
94 keyValuePairs.forEach(function (pair) {
95 keyValue = pair.split('=')
96 queryParams[keyValue[0]] = decodeURIComponent(keyValue[1]).replace(/\+/g, ' ')
97 })
98
99 return queryParams
100 }
101
102 // ! return null
103 return {}
104 }
105
106 function useUrlQueryParam(param) {
107 let queryParams = useUrlQueryParams(window.location.href)
108
109 return param in queryParams ? queryParams[param] : null
110 }
111
112 function useDescriptionVisibility(text) {
113 if (text && text.length) {
114 return (
115 !text.includes('<!-- Content -->') || (text.includes('<!-- Content -->') && text.length > 16)
116 )
117 }
118
119 return false
120 }
121 function mapAddressComponentsForXML(components) {
122 const result = {}
123
124 components.forEach((component) => {
125 const types = component.types
126
127 if (types.includes('street_number')) {
128 result.BuildingNumber = component.long_name
129 }
130
131 if (types.includes('route')) {
132 result.StreetName = component.long_name
133 }
134
135 if (types.includes('postal_code')) {
136 result.PostalZone = component.long_name
137 }
138
139 if (types.includes('locality')) {
140 result.CityName = component.long_name
141 }
142
143 if (types.includes('administrative_area_level_1')) {
144 result.CountrySubentity = component.long_name
145 }
146
147 if (types.includes('administrative_area_level_2') && !result.CountrySubentity) {
148 result.CountrySubentity = component.long_name
149 }
150
151 if (types.includes('country')) {
152 result.CountryCode = component.short_name
153 }
154
155 if (types.includes('premise')) {
156 result.Premise = component.long_name
157 }
158
159 if (types.includes('sublocality') || types.includes('neighborhood')) {
160 result.AdditionalStreetName = component.long_name
161 }
162 })
163
164 return result
165 }
166
167 function createFileUrlFromResponse(response, format = 'pdf') {
168 const byteCharacters = atob(response.data)
169 const byteNumbers = Array.from({ length: byteCharacters.length })
170 for (let i = 0; i < byteCharacters.length; i++) {
171 byteNumbers[i] = byteCharacters.charCodeAt(i)
172 }
173 const byteArray = new Uint8Array(byteNumbers)
174 const file = new Blob([byteArray], { type: `application/${format};base64` })
175 return URL.createObjectURL(file)
176 }
177
178 export {
179 useRemoveUrlParameter,
180 useSortedDateStrings,
181 useUrlParams,
182 useUrlQueryParams,
183 useUrlQueryParam,
184 useCurrentTimeZone,
185 useSortedTimeStrings,
186 useDescriptionVisibility,
187 createFileUrlFromResponse,
188 mapAddressComponentsForXML,
189 }
190