@osimatic/helpers-js 1.1.77 → 1.1.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG +76 -76
- package/array.js +93 -90
- package/bank.js +20 -20
- package/contact_details.js +194 -194
- package/count_down.js +102 -102
- package/data_table.js +416 -416
- package/date_time.js +592 -592
- package/details_sub_array.js +123 -123
- package/draw.js +52 -52
- package/duration.js +198 -198
- package/event_bus.js +38 -38
- package/file.js +146 -146
- package/flash_message.js +35 -35
- package/form_date.js +610 -610
- package/form_helper.js +410 -410
- package/google_charts.js +347 -347
- package/google_maps.js +169 -169
- package/google_recaptcha.js +87 -87
- package/http_client.js +469 -469
- package/import_from_csv.js +273 -273
- package/index.js +55 -55
- package/jwt.js +288 -288
- package/list_box.js +112 -112
- package/location.js +431 -431
- package/media.js +218 -218
- package/multiple_action_in_table.js +336 -336
- package/network.js +756 -756
- package/number.js +99 -99
- package/open_street_map.js +142 -142
- package/package.json +15 -15
- package/paging.js +278 -278
- package/php.min.js +5 -5
- package/revolut.js +22 -22
- package/select_all.js +121 -121
- package/shopping_cart.js +31 -31
- package/social_network.js +109 -109
- package/sortable_list.js +37 -37
- package/string.js +162 -162
- package/util.js +16 -16
- package/visitor.js +77 -77
- package/web_rtc.js +114 -114
- package/web_socket.js +97 -97
package/location.js
CHANGED
|
@@ -1,432 +1,432 @@
|
|
|
1
|
-
|
|
2
|
-
class Country {
|
|
3
|
-
static getFlagPath(countryCode) {
|
|
4
|
-
return flagsPath+countryCode.toLowerCase()+'.png';
|
|
5
|
-
}
|
|
6
|
-
static getFlagImg(countryCode) {
|
|
7
|
-
return '<span><img src="'+Country.getFlagPath(countryCode)+'" alt="" title="'+Country.getCountryName(countryCode)+'" class="flag" /></span>'
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
static fillCountrySelect(select, defaultValue=null, countriesList=null, addNoneValue=false, noneLabel='- Aucun -') {
|
|
11
|
-
if (select.children().length === 0) {
|
|
12
|
-
if (addNoneValue) {
|
|
13
|
-
select.append('<option value="">'+noneLabel+'</option>');
|
|
14
|
-
}
|
|
15
|
-
Object.entries(null != countriesList ? countriesList : Country.getCountries()).forEach(([countryCode, countryName]) => select.append('<option value="' + countryCode + '">' + countryName + '</option>'));
|
|
16
|
-
}
|
|
17
|
-
if (null != defaultValue) {
|
|
18
|
-
select.val(defaultValue);
|
|
19
|
-
}
|
|
20
|
-
if (typeof select.selectpicker != 'undefined') {
|
|
21
|
-
select.selectpicker('refresh');
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
static getCountryName(countryCode) {
|
|
25
|
-
if (Country.getCountries().hasOwnProperty(countryCode)) {
|
|
26
|
-
return Country.getCountries()[countryCode];
|
|
27
|
-
}
|
|
28
|
-
return countryCode;
|
|
29
|
-
}
|
|
30
|
-
static getCountries() {
|
|
31
|
-
return {
|
|
32
|
-
AF:'Afghanistan',
|
|
33
|
-
AX:'Åland Islands',
|
|
34
|
-
AL:'Albania',
|
|
35
|
-
DZ:'Algeria',
|
|
36
|
-
AS:'American Samoa',
|
|
37
|
-
AD:'Andorra',
|
|
38
|
-
AO:'Angola',
|
|
39
|
-
AI:'Anguilla',
|
|
40
|
-
AQ:'Antarctica',
|
|
41
|
-
AG:'Antigua and Barbuda',
|
|
42
|
-
AR:'Argentina',
|
|
43
|
-
AM:'Armenia',
|
|
44
|
-
AW:'Aruba',
|
|
45
|
-
AU:'Australia',
|
|
46
|
-
AT:'Austria',
|
|
47
|
-
AZ:'Azerbaijan',
|
|
48
|
-
BS:'Bahamas',
|
|
49
|
-
BH:'Bahrain',
|
|
50
|
-
BD:'Bangladesh',
|
|
51
|
-
BB:'Barbados',
|
|
52
|
-
BY:'Belarus',
|
|
53
|
-
BE:'Belgium',
|
|
54
|
-
BZ:'Belize',
|
|
55
|
-
BJ:'Benin',
|
|
56
|
-
BM:'Bermuda',
|
|
57
|
-
BT:'Bhutan',
|
|
58
|
-
BO:'Bolivia',
|
|
59
|
-
BA:'Bosnia and Herzegovina',
|
|
60
|
-
BW:'Botswana',
|
|
61
|
-
BV:'Bouvet Island',
|
|
62
|
-
BR:'Brazil',
|
|
63
|
-
IO:'British Indian Ocean Territory',
|
|
64
|
-
BN:'Brunei Darussalam',
|
|
65
|
-
BG:'Bulgaria',
|
|
66
|
-
BF:'Burkina Faso',
|
|
67
|
-
BI:'Burundi',
|
|
68
|
-
KH:'Cambodia',
|
|
69
|
-
CM:'Cameroon',
|
|
70
|
-
CA:'Canada',
|
|
71
|
-
CV:'Cape Verde',
|
|
72
|
-
KY:'Cayman Islands',
|
|
73
|
-
CF:'Central African Republic',
|
|
74
|
-
TD:'Chad',
|
|
75
|
-
CL:'Chile',
|
|
76
|
-
CN:'China',
|
|
77
|
-
CX:'Christmas Island',
|
|
78
|
-
CC:'Cocos (Keeling) Islands',
|
|
79
|
-
CO:'Colombia',
|
|
80
|
-
KM:'Comoros',
|
|
81
|
-
CG:'Congo',
|
|
82
|
-
CD:'Congo, The Democratic Republic of The',
|
|
83
|
-
CK:'Cook Islands',
|
|
84
|
-
CR:'Costa Rica',
|
|
85
|
-
CI:'Cote d’Ivoire',
|
|
86
|
-
HR:'Croatia',
|
|
87
|
-
CU:'Cuba',
|
|
88
|
-
CY:'Cyprus',
|
|
89
|
-
CZ:'Czechia',
|
|
90
|
-
DK:'Denmark',
|
|
91
|
-
DJ:'Djibouti',
|
|
92
|
-
DM:'Dominica',
|
|
93
|
-
DO:'Dominican Republic',
|
|
94
|
-
EC:'Ecuador',
|
|
95
|
-
EG:'Egypt',
|
|
96
|
-
SV:'El Salvador',
|
|
97
|
-
GQ:'Equatorial Guinea',
|
|
98
|
-
ER:'Eritrea',
|
|
99
|
-
EE:'Estonia',
|
|
100
|
-
ET:'Ethiopia',
|
|
101
|
-
FK:'Falkland Islands (Malvinas)',
|
|
102
|
-
FO:'Faroe Islands',
|
|
103
|
-
FJ:'Fiji',
|
|
104
|
-
FI:'Finland',
|
|
105
|
-
FR:'France',
|
|
106
|
-
GF:'French Guiana',
|
|
107
|
-
PF:'French Polynesia',
|
|
108
|
-
TF:'French Southern Territories',
|
|
109
|
-
GA:'Gabon',
|
|
110
|
-
GM:'Gambia',
|
|
111
|
-
GE:'Georgia',
|
|
112
|
-
DE:'Germany',
|
|
113
|
-
GH:'Ghana',
|
|
114
|
-
GI:'Gibraltar',
|
|
115
|
-
GR:'Greece',
|
|
116
|
-
GL:'Greenland',
|
|
117
|
-
GD:'Grenada',
|
|
118
|
-
GP:'Guadeloupe',
|
|
119
|
-
GU:'Guam',
|
|
120
|
-
GT:'Guatemala',
|
|
121
|
-
GG:'Guernsey',
|
|
122
|
-
GN:'Guinea',
|
|
123
|
-
GW:'Guinea-bissau',
|
|
124
|
-
GY:'Guyana',
|
|
125
|
-
HT:'Haiti',
|
|
126
|
-
HM:'Heard Island and Mcdonald Islands',
|
|
127
|
-
VA:'Holy See (Vatican City State)',
|
|
128
|
-
HN:'Honduras',
|
|
129
|
-
HK:'Hong Kong',
|
|
130
|
-
HU:'Hungary',
|
|
131
|
-
IS:'Iceland',
|
|
132
|
-
IN:'India',
|
|
133
|
-
ID:'Indonesia',
|
|
134
|
-
IR:'Iran, Islamic Republic of',
|
|
135
|
-
IQ:'Iraq',
|
|
136
|
-
IE:'Ireland',
|
|
137
|
-
IM:'Isle of Man',
|
|
138
|
-
IL:'Israel',
|
|
139
|
-
IT:'Italy',
|
|
140
|
-
JM:'Jamaica',
|
|
141
|
-
JP:'Japan',
|
|
142
|
-
JE:'Jersey',
|
|
143
|
-
JO:'Jordan',
|
|
144
|
-
KZ:'Kazakhstan',
|
|
145
|
-
KE:'Kenya',
|
|
146
|
-
KI:'Kiribati',
|
|
147
|
-
KP:'Korea, Democratic People’s Republic of',
|
|
148
|
-
KR:'Korea, Republic of',
|
|
149
|
-
KW:'Kuwait',
|
|
150
|
-
KG:'Kyrgyzstan',
|
|
151
|
-
LA:'Lao People’s Democratic Republic',
|
|
152
|
-
LV:'Latvia',
|
|
153
|
-
LB:'Lebanon',
|
|
154
|
-
LS:'Lesotho',
|
|
155
|
-
LR:'Liberia',
|
|
156
|
-
LY:'Libyan Arab Jamahiriya',
|
|
157
|
-
LI:'Liechtenstein',
|
|
158
|
-
LT:'Lithuania',
|
|
159
|
-
LU:'Luxembourg',
|
|
160
|
-
MO:'Macao',
|
|
161
|
-
MK:'Macedonia, The Former Yugoslav Republic of',
|
|
162
|
-
MG:'Madagascar',
|
|
163
|
-
MW:'Malawi',
|
|
164
|
-
MY:'Malaysia',
|
|
165
|
-
MV:'Maldives',
|
|
166
|
-
ML:'Mali',
|
|
167
|
-
MT:'Malta',
|
|
168
|
-
MH:'Marshall Islands',
|
|
169
|
-
MQ:'Martinique',
|
|
170
|
-
MR:'Mauritania',
|
|
171
|
-
MU:'Mauritius',
|
|
172
|
-
YT:'Mayotte',
|
|
173
|
-
MX:'Mexico',
|
|
174
|
-
FM:'Micronesia, Federated States of',
|
|
175
|
-
MD:'Moldova, Republic of',
|
|
176
|
-
MC:'Monaco',
|
|
177
|
-
MN:'Mongolia',
|
|
178
|
-
ME:'Montenegro',
|
|
179
|
-
MS:'Montserrat',
|
|
180
|
-
MA:'Morocco',
|
|
181
|
-
MZ:'Mozambique',
|
|
182
|
-
MM:'Myanmar',
|
|
183
|
-
NA:'Namibia',
|
|
184
|
-
NR:'Nauru',
|
|
185
|
-
NP:'Nepal',
|
|
186
|
-
NL:'Netherlands',
|
|
187
|
-
AN:'Netherlands Antilles',
|
|
188
|
-
NC:'New Caledonia',
|
|
189
|
-
NZ:'New Zealand',
|
|
190
|
-
NI:'Nicaragua',
|
|
191
|
-
NE:'Niger',
|
|
192
|
-
NG:'Nigeria',
|
|
193
|
-
NU:'Niue',
|
|
194
|
-
NF:'Norfolk Island',
|
|
195
|
-
MP:'Northern Mariana Islands',
|
|
196
|
-
NO:'Norway',
|
|
197
|
-
OM:'Oman',
|
|
198
|
-
PK:'Pakistan',
|
|
199
|
-
PW:'Palau',
|
|
200
|
-
PS:'Palestinian Territory, Occupied',
|
|
201
|
-
PA:'Panama',
|
|
202
|
-
PG:'Papua New Guinea',
|
|
203
|
-
PY:'Paraguay',
|
|
204
|
-
PE:'Peru',
|
|
205
|
-
PH:'Philippines',
|
|
206
|
-
PN:'Pitcairn',
|
|
207
|
-
PL:'Poland',
|
|
208
|
-
PT:'Portugal',
|
|
209
|
-
PR:'Puerto Rico',
|
|
210
|
-
QA:'Qatar',
|
|
211
|
-
RE:'Reunion',
|
|
212
|
-
RO:'Romania',
|
|
213
|
-
RU:'Russian Federation',
|
|
214
|
-
RW:'Rwanda',
|
|
215
|
-
SH:'Saint Helena',
|
|
216
|
-
KN:'Saint Kitts and Nevis',
|
|
217
|
-
LC:'Saint Lucia',
|
|
218
|
-
PM:'Saint Pierre and Miquelon',
|
|
219
|
-
VC:'Saint Vincent and The Grenadines',
|
|
220
|
-
WS:'Samoa',
|
|
221
|
-
SM:'San Marino',
|
|
222
|
-
ST:'Sao Tome and Principe',
|
|
223
|
-
SA:'Saudi Arabia',
|
|
224
|
-
SN:'Senegal',
|
|
225
|
-
RS:'Serbia',
|
|
226
|
-
SC:'Seychelles',
|
|
227
|
-
SL:'Sierra Leone',
|
|
228
|
-
SG:'Singapore',
|
|
229
|
-
SK:'Slovakia',
|
|
230
|
-
SI:'Slovenia',
|
|
231
|
-
SB:'Solomon Islands',
|
|
232
|
-
SO:'Somalia',
|
|
233
|
-
ZA:'South Africa',
|
|
234
|
-
GS:'South Georgia and The South Sandwich Islands',
|
|
235
|
-
ES:'Spain',
|
|
236
|
-
LK:'Sri Lanka',
|
|
237
|
-
SD:'Sudan',
|
|
238
|
-
SR:'Suriname',
|
|
239
|
-
SJ:'Svalbard and Jan Mayen',
|
|
240
|
-
SZ:'Swaziland',
|
|
241
|
-
SE:'Sweden',
|
|
242
|
-
CH:'Switzerland',
|
|
243
|
-
SY:'Syrian Arab Republic',
|
|
244
|
-
TW:'Taiwan, Province of China',
|
|
245
|
-
TJ:'Tajikistan',
|
|
246
|
-
TZ:'Tanzania, United Republic of',
|
|
247
|
-
TH:'Thailand',
|
|
248
|
-
TL:'Timor-leste',
|
|
249
|
-
TG:'Togo',
|
|
250
|
-
TK:'Tokelau',
|
|
251
|
-
TO:'Tonga',
|
|
252
|
-
TT:'Trinidad and Tobago',
|
|
253
|
-
TN:'Tunisia',
|
|
254
|
-
TR:'Turkey',
|
|
255
|
-
TM:'Turkmenistan',
|
|
256
|
-
TC:'Turks and Caicos Islands',
|
|
257
|
-
TV:'Tuvalu',
|
|
258
|
-
UG:'Uganda',
|
|
259
|
-
UA:'Ukraine',
|
|
260
|
-
AE:'United Arab Emirates',
|
|
261
|
-
GB:'United Kingdom',
|
|
262
|
-
US:'United States',
|
|
263
|
-
UM:'United States Minor Outlying Islands',
|
|
264
|
-
UY:'Uruguay',
|
|
265
|
-
UZ:'Uzbekistan',
|
|
266
|
-
VU:'Vanuatu',
|
|
267
|
-
VE:'Venezuela',
|
|
268
|
-
VN:'Viet Nam',
|
|
269
|
-
VG:'Virgin Islands, British',
|
|
270
|
-
VI:'Virgin Islands, U.S.',
|
|
271
|
-
WF:'Wallis and Futuna',
|
|
272
|
-
EH:'Western Sahara',
|
|
273
|
-
YE:'Yemen',
|
|
274
|
-
ZM:'Zambia',
|
|
275
|
-
ZW:'Zimbabwe',
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
static getContinents() {
|
|
280
|
-
return {
|
|
281
|
-
1: "Europe",
|
|
282
|
-
2: "Moyen-Orient",
|
|
283
|
-
3: "Afrique",
|
|
284
|
-
4: "Amérique du Nord",
|
|
285
|
-
5: "Amérique du Sud",
|
|
286
|
-
6: "Asie",
|
|
287
|
-
7: "Océanie",
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/** @deprecated **/
|
|
292
|
-
static getCountryList() {
|
|
293
|
-
return Country.getCountries();
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
class PostalAddress {
|
|
298
|
-
static setAutocomplete(input, onPlaceChanged) {
|
|
299
|
-
let autocomplete = new google.maps.places.Autocomplete(
|
|
300
|
-
input[0],
|
|
301
|
-
{types: ['geocode']}
|
|
302
|
-
);
|
|
303
|
-
//console.log(autocomplete);
|
|
304
|
-
|
|
305
|
-
// When the user selects an address from the dropdown, populate the address fields in the form.
|
|
306
|
-
autocomplete.addListener('place_changed', function() {
|
|
307
|
-
let place = autocomplete.getPlace();
|
|
308
|
-
input.val('');
|
|
309
|
-
if (typeof onPlaceChanged == 'function') {
|
|
310
|
-
onPlaceChanged(place['formatted_address']);
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
static format(addressData, separator='<br/>') {
|
|
316
|
-
function empty(value) {
|
|
317
|
-
return typeof value == 'undefined' || value == null || value === '';
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
/*
|
|
321
|
-
var address = new Address({
|
|
322
|
-
country: "USA",
|
|
323
|
-
countryCode: "US",
|
|
324
|
-
postalCode: "95054",
|
|
325
|
-
region: "CA",
|
|
326
|
-
locality: "Santa Clara",
|
|
327
|
-
streetAddress: "LG Silicon Valley Lab, 5150 Great America Pkwy"
|
|
328
|
-
});
|
|
329
|
-
var af = new AddressFmt();
|
|
330
|
-
var formatted = af.format(address);
|
|
331
|
-
console.log(formatted);
|
|
332
|
-
*/
|
|
333
|
-
|
|
334
|
-
addressData['countryCode'] = !empty(addressData['countryCode'])?addressData['countryCode']:null;
|
|
335
|
-
|
|
336
|
-
let addressDataForPluging = {
|
|
337
|
-
streetAddress: (!empty(addressData['streetAddress'])?addressData['streetAddress']:'')+(!empty(addressData['additionalAddress'])?"\n"+addressData['additionalAddress']:''),
|
|
338
|
-
postalCode: !empty(addressData['postalCode'])?addressData['postalCode']:null,
|
|
339
|
-
locality: !empty(addressData['locality'])?addressData['locality']:null,
|
|
340
|
-
region: !empty(addressData['state'])?addressData['state']:null,
|
|
341
|
-
countryCode: addressData['countryCode'],
|
|
342
|
-
country: Country.getCountryName(addressData['countryCode']),
|
|
343
|
-
};
|
|
344
|
-
if (addressDataForPluging['locality'] == null && !empty(addressData['suburb'])) {
|
|
345
|
-
addressDataForPluging['locality'] = addressData['suburb'];
|
|
346
|
-
}
|
|
347
|
-
if (addressDataForPluging['locality'] == null && !empty(addressData['stateDistrict'])) {
|
|
348
|
-
addressDataForPluging['locality'] = addressData['stateDistrict'];
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
//var Address = require("ilib/js/lib/Address");
|
|
352
|
-
//var AddressFmt = require("ilib/lib/AddressFmt");
|
|
353
|
-
|
|
354
|
-
let af = new AddressFmt();
|
|
355
|
-
let formattedAddress = af.format(new Address(addressDataForPluging));
|
|
356
|
-
return formattedAddress.replace(/\n+/g, separator);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
static getComponentsFromGoogleApi(googleApiResult) {
|
|
360
|
-
/*
|
|
361
|
-
var addressData = {
|
|
362
|
-
streetAddress: address.street,
|
|
363
|
-
additionalAddress: null,
|
|
364
|
-
postalCode: address.zipCode,
|
|
365
|
-
locality: address.city,
|
|
366
|
-
stateDistrict: null,
|
|
367
|
-
state: null,
|
|
368
|
-
countryCode: address.country,
|
|
369
|
-
};
|
|
370
|
-
*/
|
|
371
|
-
|
|
372
|
-
var streetNumber = null;
|
|
373
|
-
var route = null;
|
|
374
|
-
var shortRoute = null;
|
|
375
|
-
|
|
376
|
-
var addressData = {};
|
|
377
|
-
googleApiResult.address_components.forEach(function(resultAddressComponent) {
|
|
378
|
-
if (resultAddressComponent.types.indexOf('street_number') !== -1) {
|
|
379
|
-
streetNumber = resultAddressComponent.long_name;
|
|
380
|
-
}
|
|
381
|
-
if (resultAddressComponent.types.indexOf('route') !== -1) {
|
|
382
|
-
route = resultAddressComponent.long_name;
|
|
383
|
-
shortRoute = resultAddressComponent.long_name;
|
|
384
|
-
}
|
|
385
|
-
if (resultAddressComponent.types.indexOf('sublocality_level_1') !== -1) {
|
|
386
|
-
addressData.suburb = resultAddressComponent.long_name;
|
|
387
|
-
}
|
|
388
|
-
if (resultAddressComponent.types.indexOf('locality') !== -1) {
|
|
389
|
-
addressData.locality = resultAddressComponent.long_name;
|
|
390
|
-
}
|
|
391
|
-
if (resultAddressComponent.types.indexOf('postal_town') !== -1) {
|
|
392
|
-
addressData.locality = resultAddressComponent.long_name;
|
|
393
|
-
}
|
|
394
|
-
if (resultAddressComponent.types.indexOf('postal_code') !== -1) {
|
|
395
|
-
addressData.postalCode = resultAddressComponent.long_name;
|
|
396
|
-
}
|
|
397
|
-
if (resultAddressComponent.types.indexOf('administrative_area_level_3') !== -1) {
|
|
398
|
-
addressData.locality = resultAddressComponent.long_name;
|
|
399
|
-
}
|
|
400
|
-
if (resultAddressComponent.types.indexOf('administrative_area_level_2') !== -1) {
|
|
401
|
-
addressData.stateDistrict = resultAddressComponent.long_name;
|
|
402
|
-
}
|
|
403
|
-
if (resultAddressComponent.types.indexOf('administrative_area_level_1') !== -1) {
|
|
404
|
-
addressData.state = resultAddressComponent.long_name;
|
|
405
|
-
}
|
|
406
|
-
if (resultAddressComponent.types.indexOf('country') !== -1) {
|
|
407
|
-
addressData.countryCode = resultAddressComponent.short_name;
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
|
-
var htmlAddress = $(googleApiResult.adr_address);
|
|
411
|
-
// console.log(googleApiResult.adr_address);
|
|
412
|
-
// console.log(htmlAddress);
|
|
413
|
-
// console.log(htmlAddress.find('span.street-address'));
|
|
414
|
-
//console.log($(htmlAddress[0]).text());
|
|
415
|
-
if (htmlAddress.length && $(htmlAddress[0]).length) {
|
|
416
|
-
addressData.streetAddress = $(htmlAddress[0]).text();
|
|
417
|
-
}
|
|
418
|
-
else {
|
|
419
|
-
addressData.streetAddress = streetNumber+' '+route;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
return addressData;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
class GeographicCoordinates {
|
|
427
|
-
static check(str) {
|
|
428
|
-
return /^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$/.test(str);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
|
|
1
|
+
|
|
2
|
+
class Country {
|
|
3
|
+
static getFlagPath(countryCode) {
|
|
4
|
+
return flagsPath+countryCode.toLowerCase()+'.png';
|
|
5
|
+
}
|
|
6
|
+
static getFlagImg(countryCode) {
|
|
7
|
+
return '<span><img src="'+Country.getFlagPath(countryCode)+'" alt="" title="'+Country.getCountryName(countryCode)+'" class="flag" /></span>'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static fillCountrySelect(select, defaultValue=null, countriesList=null, addNoneValue=false, noneLabel='- Aucun -') {
|
|
11
|
+
if (select.children().length === 0) {
|
|
12
|
+
if (addNoneValue) {
|
|
13
|
+
select.append('<option value="">'+noneLabel+'</option>');
|
|
14
|
+
}
|
|
15
|
+
Object.entries(null != countriesList ? countriesList : Country.getCountries()).forEach(([countryCode, countryName]) => select.append('<option value="' + countryCode + '">' + countryName + '</option>'));
|
|
16
|
+
}
|
|
17
|
+
if (null != defaultValue) {
|
|
18
|
+
select.val(defaultValue);
|
|
19
|
+
}
|
|
20
|
+
if (typeof select.selectpicker != 'undefined') {
|
|
21
|
+
select.selectpicker('refresh');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
static getCountryName(countryCode) {
|
|
25
|
+
if (Country.getCountries().hasOwnProperty(countryCode)) {
|
|
26
|
+
return Country.getCountries()[countryCode];
|
|
27
|
+
}
|
|
28
|
+
return countryCode;
|
|
29
|
+
}
|
|
30
|
+
static getCountries() {
|
|
31
|
+
return {
|
|
32
|
+
AF:'Afghanistan',
|
|
33
|
+
AX:'Åland Islands',
|
|
34
|
+
AL:'Albania',
|
|
35
|
+
DZ:'Algeria',
|
|
36
|
+
AS:'American Samoa',
|
|
37
|
+
AD:'Andorra',
|
|
38
|
+
AO:'Angola',
|
|
39
|
+
AI:'Anguilla',
|
|
40
|
+
AQ:'Antarctica',
|
|
41
|
+
AG:'Antigua and Barbuda',
|
|
42
|
+
AR:'Argentina',
|
|
43
|
+
AM:'Armenia',
|
|
44
|
+
AW:'Aruba',
|
|
45
|
+
AU:'Australia',
|
|
46
|
+
AT:'Austria',
|
|
47
|
+
AZ:'Azerbaijan',
|
|
48
|
+
BS:'Bahamas',
|
|
49
|
+
BH:'Bahrain',
|
|
50
|
+
BD:'Bangladesh',
|
|
51
|
+
BB:'Barbados',
|
|
52
|
+
BY:'Belarus',
|
|
53
|
+
BE:'Belgium',
|
|
54
|
+
BZ:'Belize',
|
|
55
|
+
BJ:'Benin',
|
|
56
|
+
BM:'Bermuda',
|
|
57
|
+
BT:'Bhutan',
|
|
58
|
+
BO:'Bolivia',
|
|
59
|
+
BA:'Bosnia and Herzegovina',
|
|
60
|
+
BW:'Botswana',
|
|
61
|
+
BV:'Bouvet Island',
|
|
62
|
+
BR:'Brazil',
|
|
63
|
+
IO:'British Indian Ocean Territory',
|
|
64
|
+
BN:'Brunei Darussalam',
|
|
65
|
+
BG:'Bulgaria',
|
|
66
|
+
BF:'Burkina Faso',
|
|
67
|
+
BI:'Burundi',
|
|
68
|
+
KH:'Cambodia',
|
|
69
|
+
CM:'Cameroon',
|
|
70
|
+
CA:'Canada',
|
|
71
|
+
CV:'Cape Verde',
|
|
72
|
+
KY:'Cayman Islands',
|
|
73
|
+
CF:'Central African Republic',
|
|
74
|
+
TD:'Chad',
|
|
75
|
+
CL:'Chile',
|
|
76
|
+
CN:'China',
|
|
77
|
+
CX:'Christmas Island',
|
|
78
|
+
CC:'Cocos (Keeling) Islands',
|
|
79
|
+
CO:'Colombia',
|
|
80
|
+
KM:'Comoros',
|
|
81
|
+
CG:'Congo',
|
|
82
|
+
CD:'Congo, The Democratic Republic of The',
|
|
83
|
+
CK:'Cook Islands',
|
|
84
|
+
CR:'Costa Rica',
|
|
85
|
+
CI:'Cote d’Ivoire',
|
|
86
|
+
HR:'Croatia',
|
|
87
|
+
CU:'Cuba',
|
|
88
|
+
CY:'Cyprus',
|
|
89
|
+
CZ:'Czechia',
|
|
90
|
+
DK:'Denmark',
|
|
91
|
+
DJ:'Djibouti',
|
|
92
|
+
DM:'Dominica',
|
|
93
|
+
DO:'Dominican Republic',
|
|
94
|
+
EC:'Ecuador',
|
|
95
|
+
EG:'Egypt',
|
|
96
|
+
SV:'El Salvador',
|
|
97
|
+
GQ:'Equatorial Guinea',
|
|
98
|
+
ER:'Eritrea',
|
|
99
|
+
EE:'Estonia',
|
|
100
|
+
ET:'Ethiopia',
|
|
101
|
+
FK:'Falkland Islands (Malvinas)',
|
|
102
|
+
FO:'Faroe Islands',
|
|
103
|
+
FJ:'Fiji',
|
|
104
|
+
FI:'Finland',
|
|
105
|
+
FR:'France',
|
|
106
|
+
GF:'French Guiana',
|
|
107
|
+
PF:'French Polynesia',
|
|
108
|
+
TF:'French Southern Territories',
|
|
109
|
+
GA:'Gabon',
|
|
110
|
+
GM:'Gambia',
|
|
111
|
+
GE:'Georgia',
|
|
112
|
+
DE:'Germany',
|
|
113
|
+
GH:'Ghana',
|
|
114
|
+
GI:'Gibraltar',
|
|
115
|
+
GR:'Greece',
|
|
116
|
+
GL:'Greenland',
|
|
117
|
+
GD:'Grenada',
|
|
118
|
+
GP:'Guadeloupe',
|
|
119
|
+
GU:'Guam',
|
|
120
|
+
GT:'Guatemala',
|
|
121
|
+
GG:'Guernsey',
|
|
122
|
+
GN:'Guinea',
|
|
123
|
+
GW:'Guinea-bissau',
|
|
124
|
+
GY:'Guyana',
|
|
125
|
+
HT:'Haiti',
|
|
126
|
+
HM:'Heard Island and Mcdonald Islands',
|
|
127
|
+
VA:'Holy See (Vatican City State)',
|
|
128
|
+
HN:'Honduras',
|
|
129
|
+
HK:'Hong Kong',
|
|
130
|
+
HU:'Hungary',
|
|
131
|
+
IS:'Iceland',
|
|
132
|
+
IN:'India',
|
|
133
|
+
ID:'Indonesia',
|
|
134
|
+
IR:'Iran, Islamic Republic of',
|
|
135
|
+
IQ:'Iraq',
|
|
136
|
+
IE:'Ireland',
|
|
137
|
+
IM:'Isle of Man',
|
|
138
|
+
IL:'Israel',
|
|
139
|
+
IT:'Italy',
|
|
140
|
+
JM:'Jamaica',
|
|
141
|
+
JP:'Japan',
|
|
142
|
+
JE:'Jersey',
|
|
143
|
+
JO:'Jordan',
|
|
144
|
+
KZ:'Kazakhstan',
|
|
145
|
+
KE:'Kenya',
|
|
146
|
+
KI:'Kiribati',
|
|
147
|
+
KP:'Korea, Democratic People’s Republic of',
|
|
148
|
+
KR:'Korea, Republic of',
|
|
149
|
+
KW:'Kuwait',
|
|
150
|
+
KG:'Kyrgyzstan',
|
|
151
|
+
LA:'Lao People’s Democratic Republic',
|
|
152
|
+
LV:'Latvia',
|
|
153
|
+
LB:'Lebanon',
|
|
154
|
+
LS:'Lesotho',
|
|
155
|
+
LR:'Liberia',
|
|
156
|
+
LY:'Libyan Arab Jamahiriya',
|
|
157
|
+
LI:'Liechtenstein',
|
|
158
|
+
LT:'Lithuania',
|
|
159
|
+
LU:'Luxembourg',
|
|
160
|
+
MO:'Macao',
|
|
161
|
+
MK:'Macedonia, The Former Yugoslav Republic of',
|
|
162
|
+
MG:'Madagascar',
|
|
163
|
+
MW:'Malawi',
|
|
164
|
+
MY:'Malaysia',
|
|
165
|
+
MV:'Maldives',
|
|
166
|
+
ML:'Mali',
|
|
167
|
+
MT:'Malta',
|
|
168
|
+
MH:'Marshall Islands',
|
|
169
|
+
MQ:'Martinique',
|
|
170
|
+
MR:'Mauritania',
|
|
171
|
+
MU:'Mauritius',
|
|
172
|
+
YT:'Mayotte',
|
|
173
|
+
MX:'Mexico',
|
|
174
|
+
FM:'Micronesia, Federated States of',
|
|
175
|
+
MD:'Moldova, Republic of',
|
|
176
|
+
MC:'Monaco',
|
|
177
|
+
MN:'Mongolia',
|
|
178
|
+
ME:'Montenegro',
|
|
179
|
+
MS:'Montserrat',
|
|
180
|
+
MA:'Morocco',
|
|
181
|
+
MZ:'Mozambique',
|
|
182
|
+
MM:'Myanmar',
|
|
183
|
+
NA:'Namibia',
|
|
184
|
+
NR:'Nauru',
|
|
185
|
+
NP:'Nepal',
|
|
186
|
+
NL:'Netherlands',
|
|
187
|
+
AN:'Netherlands Antilles',
|
|
188
|
+
NC:'New Caledonia',
|
|
189
|
+
NZ:'New Zealand',
|
|
190
|
+
NI:'Nicaragua',
|
|
191
|
+
NE:'Niger',
|
|
192
|
+
NG:'Nigeria',
|
|
193
|
+
NU:'Niue',
|
|
194
|
+
NF:'Norfolk Island',
|
|
195
|
+
MP:'Northern Mariana Islands',
|
|
196
|
+
NO:'Norway',
|
|
197
|
+
OM:'Oman',
|
|
198
|
+
PK:'Pakistan',
|
|
199
|
+
PW:'Palau',
|
|
200
|
+
PS:'Palestinian Territory, Occupied',
|
|
201
|
+
PA:'Panama',
|
|
202
|
+
PG:'Papua New Guinea',
|
|
203
|
+
PY:'Paraguay',
|
|
204
|
+
PE:'Peru',
|
|
205
|
+
PH:'Philippines',
|
|
206
|
+
PN:'Pitcairn',
|
|
207
|
+
PL:'Poland',
|
|
208
|
+
PT:'Portugal',
|
|
209
|
+
PR:'Puerto Rico',
|
|
210
|
+
QA:'Qatar',
|
|
211
|
+
RE:'Reunion',
|
|
212
|
+
RO:'Romania',
|
|
213
|
+
RU:'Russian Federation',
|
|
214
|
+
RW:'Rwanda',
|
|
215
|
+
SH:'Saint Helena',
|
|
216
|
+
KN:'Saint Kitts and Nevis',
|
|
217
|
+
LC:'Saint Lucia',
|
|
218
|
+
PM:'Saint Pierre and Miquelon',
|
|
219
|
+
VC:'Saint Vincent and The Grenadines',
|
|
220
|
+
WS:'Samoa',
|
|
221
|
+
SM:'San Marino',
|
|
222
|
+
ST:'Sao Tome and Principe',
|
|
223
|
+
SA:'Saudi Arabia',
|
|
224
|
+
SN:'Senegal',
|
|
225
|
+
RS:'Serbia',
|
|
226
|
+
SC:'Seychelles',
|
|
227
|
+
SL:'Sierra Leone',
|
|
228
|
+
SG:'Singapore',
|
|
229
|
+
SK:'Slovakia',
|
|
230
|
+
SI:'Slovenia',
|
|
231
|
+
SB:'Solomon Islands',
|
|
232
|
+
SO:'Somalia',
|
|
233
|
+
ZA:'South Africa',
|
|
234
|
+
GS:'South Georgia and The South Sandwich Islands',
|
|
235
|
+
ES:'Spain',
|
|
236
|
+
LK:'Sri Lanka',
|
|
237
|
+
SD:'Sudan',
|
|
238
|
+
SR:'Suriname',
|
|
239
|
+
SJ:'Svalbard and Jan Mayen',
|
|
240
|
+
SZ:'Swaziland',
|
|
241
|
+
SE:'Sweden',
|
|
242
|
+
CH:'Switzerland',
|
|
243
|
+
SY:'Syrian Arab Republic',
|
|
244
|
+
TW:'Taiwan, Province of China',
|
|
245
|
+
TJ:'Tajikistan',
|
|
246
|
+
TZ:'Tanzania, United Republic of',
|
|
247
|
+
TH:'Thailand',
|
|
248
|
+
TL:'Timor-leste',
|
|
249
|
+
TG:'Togo',
|
|
250
|
+
TK:'Tokelau',
|
|
251
|
+
TO:'Tonga',
|
|
252
|
+
TT:'Trinidad and Tobago',
|
|
253
|
+
TN:'Tunisia',
|
|
254
|
+
TR:'Turkey',
|
|
255
|
+
TM:'Turkmenistan',
|
|
256
|
+
TC:'Turks and Caicos Islands',
|
|
257
|
+
TV:'Tuvalu',
|
|
258
|
+
UG:'Uganda',
|
|
259
|
+
UA:'Ukraine',
|
|
260
|
+
AE:'United Arab Emirates',
|
|
261
|
+
GB:'United Kingdom',
|
|
262
|
+
US:'United States',
|
|
263
|
+
UM:'United States Minor Outlying Islands',
|
|
264
|
+
UY:'Uruguay',
|
|
265
|
+
UZ:'Uzbekistan',
|
|
266
|
+
VU:'Vanuatu',
|
|
267
|
+
VE:'Venezuela',
|
|
268
|
+
VN:'Viet Nam',
|
|
269
|
+
VG:'Virgin Islands, British',
|
|
270
|
+
VI:'Virgin Islands, U.S.',
|
|
271
|
+
WF:'Wallis and Futuna',
|
|
272
|
+
EH:'Western Sahara',
|
|
273
|
+
YE:'Yemen',
|
|
274
|
+
ZM:'Zambia',
|
|
275
|
+
ZW:'Zimbabwe',
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
static getContinents() {
|
|
280
|
+
return {
|
|
281
|
+
1: "Europe",
|
|
282
|
+
2: "Moyen-Orient",
|
|
283
|
+
3: "Afrique",
|
|
284
|
+
4: "Amérique du Nord",
|
|
285
|
+
5: "Amérique du Sud",
|
|
286
|
+
6: "Asie",
|
|
287
|
+
7: "Océanie",
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** @deprecated **/
|
|
292
|
+
static getCountryList() {
|
|
293
|
+
return Country.getCountries();
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
class PostalAddress {
|
|
298
|
+
static setAutocomplete(input, onPlaceChanged) {
|
|
299
|
+
let autocomplete = new google.maps.places.Autocomplete(
|
|
300
|
+
input[0],
|
|
301
|
+
{types: ['geocode']}
|
|
302
|
+
);
|
|
303
|
+
//console.log(autocomplete);
|
|
304
|
+
|
|
305
|
+
// When the user selects an address from the dropdown, populate the address fields in the form.
|
|
306
|
+
autocomplete.addListener('place_changed', function() {
|
|
307
|
+
let place = autocomplete.getPlace();
|
|
308
|
+
input.val('');
|
|
309
|
+
if (typeof onPlaceChanged == 'function') {
|
|
310
|
+
onPlaceChanged(place['formatted_address']);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
static format(addressData, separator='<br/>') {
|
|
316
|
+
function empty(value) {
|
|
317
|
+
return typeof value == 'undefined' || value == null || value === '';
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/*
|
|
321
|
+
var address = new Address({
|
|
322
|
+
country: "USA",
|
|
323
|
+
countryCode: "US",
|
|
324
|
+
postalCode: "95054",
|
|
325
|
+
region: "CA",
|
|
326
|
+
locality: "Santa Clara",
|
|
327
|
+
streetAddress: "LG Silicon Valley Lab, 5150 Great America Pkwy"
|
|
328
|
+
});
|
|
329
|
+
var af = new AddressFmt();
|
|
330
|
+
var formatted = af.format(address);
|
|
331
|
+
console.log(formatted);
|
|
332
|
+
*/
|
|
333
|
+
|
|
334
|
+
addressData['countryCode'] = !empty(addressData['countryCode'])?addressData['countryCode']:null;
|
|
335
|
+
|
|
336
|
+
let addressDataForPluging = {
|
|
337
|
+
streetAddress: (!empty(addressData['streetAddress'])?addressData['streetAddress']:'')+(!empty(addressData['additionalAddress'])?"\n"+addressData['additionalAddress']:''),
|
|
338
|
+
postalCode: !empty(addressData['postalCode'])?addressData['postalCode']:null,
|
|
339
|
+
locality: !empty(addressData['locality'])?addressData['locality']:null,
|
|
340
|
+
region: !empty(addressData['state'])?addressData['state']:null,
|
|
341
|
+
countryCode: addressData['countryCode'],
|
|
342
|
+
country: Country.getCountryName(addressData['countryCode']),
|
|
343
|
+
};
|
|
344
|
+
if (addressDataForPluging['locality'] == null && !empty(addressData['suburb'])) {
|
|
345
|
+
addressDataForPluging['locality'] = addressData['suburb'];
|
|
346
|
+
}
|
|
347
|
+
if (addressDataForPluging['locality'] == null && !empty(addressData['stateDistrict'])) {
|
|
348
|
+
addressDataForPluging['locality'] = addressData['stateDistrict'];
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
//var Address = require("ilib/js/lib/Address");
|
|
352
|
+
//var AddressFmt = require("ilib/lib/AddressFmt");
|
|
353
|
+
|
|
354
|
+
let af = new AddressFmt();
|
|
355
|
+
let formattedAddress = af.format(new Address(addressDataForPluging));
|
|
356
|
+
return formattedAddress.replace(/\n+/g, separator);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
static getComponentsFromGoogleApi(googleApiResult) {
|
|
360
|
+
/*
|
|
361
|
+
var addressData = {
|
|
362
|
+
streetAddress: address.street,
|
|
363
|
+
additionalAddress: null,
|
|
364
|
+
postalCode: address.zipCode,
|
|
365
|
+
locality: address.city,
|
|
366
|
+
stateDistrict: null,
|
|
367
|
+
state: null,
|
|
368
|
+
countryCode: address.country,
|
|
369
|
+
};
|
|
370
|
+
*/
|
|
371
|
+
|
|
372
|
+
var streetNumber = null;
|
|
373
|
+
var route = null;
|
|
374
|
+
var shortRoute = null;
|
|
375
|
+
|
|
376
|
+
var addressData = {};
|
|
377
|
+
googleApiResult.address_components.forEach(function(resultAddressComponent) {
|
|
378
|
+
if (resultAddressComponent.types.indexOf('street_number') !== -1) {
|
|
379
|
+
streetNumber = resultAddressComponent.long_name;
|
|
380
|
+
}
|
|
381
|
+
if (resultAddressComponent.types.indexOf('route') !== -1) {
|
|
382
|
+
route = resultAddressComponent.long_name;
|
|
383
|
+
shortRoute = resultAddressComponent.long_name;
|
|
384
|
+
}
|
|
385
|
+
if (resultAddressComponent.types.indexOf('sublocality_level_1') !== -1) {
|
|
386
|
+
addressData.suburb = resultAddressComponent.long_name;
|
|
387
|
+
}
|
|
388
|
+
if (resultAddressComponent.types.indexOf('locality') !== -1) {
|
|
389
|
+
addressData.locality = resultAddressComponent.long_name;
|
|
390
|
+
}
|
|
391
|
+
if (resultAddressComponent.types.indexOf('postal_town') !== -1) {
|
|
392
|
+
addressData.locality = resultAddressComponent.long_name;
|
|
393
|
+
}
|
|
394
|
+
if (resultAddressComponent.types.indexOf('postal_code') !== -1) {
|
|
395
|
+
addressData.postalCode = resultAddressComponent.long_name;
|
|
396
|
+
}
|
|
397
|
+
if (resultAddressComponent.types.indexOf('administrative_area_level_3') !== -1) {
|
|
398
|
+
addressData.locality = resultAddressComponent.long_name;
|
|
399
|
+
}
|
|
400
|
+
if (resultAddressComponent.types.indexOf('administrative_area_level_2') !== -1) {
|
|
401
|
+
addressData.stateDistrict = resultAddressComponent.long_name;
|
|
402
|
+
}
|
|
403
|
+
if (resultAddressComponent.types.indexOf('administrative_area_level_1') !== -1) {
|
|
404
|
+
addressData.state = resultAddressComponent.long_name;
|
|
405
|
+
}
|
|
406
|
+
if (resultAddressComponent.types.indexOf('country') !== -1) {
|
|
407
|
+
addressData.countryCode = resultAddressComponent.short_name;
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
var htmlAddress = $(googleApiResult.adr_address);
|
|
411
|
+
// console.log(googleApiResult.adr_address);
|
|
412
|
+
// console.log(htmlAddress);
|
|
413
|
+
// console.log(htmlAddress.find('span.street-address'));
|
|
414
|
+
//console.log($(htmlAddress[0]).text());
|
|
415
|
+
if (htmlAddress.length && $(htmlAddress[0]).length) {
|
|
416
|
+
addressData.streetAddress = $(htmlAddress[0]).text();
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
addressData.streetAddress = streetNumber+' '+route;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
return addressData;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
class GeographicCoordinates {
|
|
427
|
+
static check(str) {
|
|
428
|
+
return /^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$/.test(str);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
432
|
module.exports = { Country, PostalAddress, GeographicCoordinates };
|