@osimatic/helpers-js 1.0.9 → 1.0.12
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/README +1 -0
- package/bank.js +16 -1
- package/changelog.txt +5 -2
- package/duration.js +32 -28
- package/flash_message.js +1 -2
- package/form_helper.js +20 -0
- package/google_maps.js +1 -1
- package/index.js +24 -16
- package/{todos/multiple_action_in_table.js → multiple_action_in_table.js} +1 -5
- package/number.js +10 -0
- package/open_street_map.js +132 -0
- package/package.json +1 -1
- package/paging.js +3 -1
- package/{todos/select_all.js → select_all.js} +1 -16
- package/shopping_cart.js +32 -0
- package/string.js +7 -2
- package/util.js +1 -1
package/README
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npm install @osimatic/helpers-js
|
package/bank.js
CHANGED
|
@@ -4,4 +4,19 @@ class IBAN {
|
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
class BankCard {
|
|
8
|
+
static formatCardNumber(cardNumber) {
|
|
9
|
+
if (cardNumber.length === 16) {
|
|
10
|
+
cardNumber = cardNumber.substring(0, 4)+'-'+cardNumber.substring(4, 8)+'-'+cardNumber.substring(8, 12)+'-'+cardNumber.substring(12, 16);
|
|
11
|
+
cardNumber = cardNumber.replace(/(\*)/gi, 'X');
|
|
12
|
+
}
|
|
13
|
+
return cardNumber;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static formatExpirationDate(expirationDate) {
|
|
17
|
+
let locale = typeof locale != 'undefined' ? locale : 'fr-FR';
|
|
18
|
+
return SqlDateTime.getMonthName(expirationDate, locale)+' '+SqlDateTime.getYear(expirationDate);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = { IBAN, BankCard };
|
package/changelog.txt
CHANGED
|
@@ -4,7 +4,7 @@ copierTexte(str) -> str.copyToClipboard()
|
|
|
4
4
|
truncateString(str, ...) -> str.truncateString(...)
|
|
5
5
|
|
|
6
6
|
NumberValue.isNumeric(str) -> str.isNumeric()
|
|
7
|
-
NumberValue.format(number, nbDecimal, locale) -> number.format(nbDecimal, locale)
|
|
7
|
+
NumberValue.format(number, nbDecimal, locale) -> number.format(nbDecimal, locale) OU Number.format(number, nbDecimal, locale)
|
|
8
8
|
NumberValue.formatCurrency(montant, currency, nbDecimal, locale) -> montant.formatCurrency(currency, nbDecimal, locale)
|
|
9
9
|
NumberValue.formatPercent(number, nbDecimal, locale) -> number.formatPercent(nbDecimal, locale)
|
|
10
10
|
NumberValue.random(min, max) -> Number.random(min, max)
|
|
@@ -16,10 +16,13 @@ montant.formatAsCurrency(locale, currency, nbFractionDigits) -> montant.formatCu
|
|
|
16
16
|
number.formatAsPercent(locale, minimumFractionDigits) -> number.formatPercent(nbDecimal, locale)
|
|
17
17
|
|
|
18
18
|
constante COUNTRIES_LIST -> Country.getCountryList()
|
|
19
|
-
activateTab(...) ->
|
|
19
|
+
activateTab(...) -> Navigation.activateTab(...)
|
|
20
20
|
|
|
21
21
|
renameKeys(...) -> Object.renameKeys(...)
|
|
22
22
|
renameKeysByCallback(...) -> Object.renameKeysByCallback(...)
|
|
23
23
|
getValuesByKeyInArrayOfArrays(...) -> Array.getValuesByKeyInArrayOfArrays(...)
|
|
24
24
|
getValuesByKeyInArrayOfArrays(array, ...) -> array.getValuesByKeyInArrayOfArrays(...)
|
|
25
25
|
|
|
26
|
+
hasGetUserMedia() -> non remplacé
|
|
27
|
+
|
|
28
|
+
paginationAsList(...) -> Pagination.paginate(...)
|
package/duration.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
class Duration {
|
|
3
3
|
|
|
4
|
-
static formatNbDays(nbDays) {
|
|
5
|
-
|
|
4
|
+
static formatNbDays(nbDays, locale) {
|
|
5
|
+
locale = (typeof locale != 'undefined'?locale:'fr-FR');
|
|
6
|
+
return new Intl.NumberFormat(locale, {
|
|
7
|
+
minimumFractionDigits: 2,
|
|
8
|
+
maximumFractionDigits: 2
|
|
9
|
+
}).format(nbDays);
|
|
6
10
|
}
|
|
7
11
|
static formatNbDaysIfPositive(nbDays) {
|
|
8
12
|
return nbDays < 0 ? '-' : this.formatNbDays(nbDays);
|
|
@@ -12,11 +16,11 @@ class Duration {
|
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
static convertToDurationAsCentieme(durationInSeconds) {
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
let hour = Math.floor(durationInSeconds / 3600);
|
|
20
|
+
let minutes = durationInSeconds % 3600;
|
|
17
21
|
minutes = Math.floor(minutes / 60);
|
|
18
22
|
// minutes = minutes - (minutes % 60);
|
|
19
|
-
|
|
23
|
+
let minCentieme = Math.round( (minutes / 60 ) * 100 );
|
|
20
24
|
return parseFloat(hour+'.'+minCentieme);
|
|
21
25
|
}
|
|
22
26
|
|
|
@@ -27,17 +31,17 @@ class Duration {
|
|
|
27
31
|
static convertToDurationInHourChronoDisplay(durationInSeconds, displayMode) {
|
|
28
32
|
displayMode = typeof displayMode != 'undefined' ? displayMode : 'chrono';
|
|
29
33
|
|
|
30
|
-
|
|
34
|
+
let durationInSecondsOriginal = durationInSeconds;
|
|
31
35
|
durationInSeconds = Math.abs(durationInSeconds);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
let seconds = ( durationInSeconds % 60 );
|
|
37
|
+
let remander = ( durationInSeconds % 3600 ) - seconds;
|
|
38
|
+
let minutes = ( remander / 60 );
|
|
35
39
|
remander = ( durationInSeconds ) - ( durationInSeconds % 3600 );
|
|
36
|
-
|
|
40
|
+
let hours = ( remander / 3600 );
|
|
37
41
|
if(hours.toString().length < 2) hours = '0'+hours;
|
|
38
|
-
if(hours.toString().charAt(0)
|
|
42
|
+
if(hours.toString().charAt(0) === "-") hours[0] = '0';
|
|
39
43
|
if(minutes.toString().length < 2) minutes = '0'+minutes;
|
|
40
|
-
if(minutes.toString().charAt(0)
|
|
44
|
+
if(minutes.toString().charAt(0) === "-") minutes[0] = '0';
|
|
41
45
|
if(seconds.toString().length < 2) seconds = '0'+seconds;
|
|
42
46
|
return (durationInSecondsOriginal < 0 ? '- ' : '')+hours+':'+minutes+(displayMode==='input_time'?':':'.')+seconds;
|
|
43
47
|
}
|
|
@@ -49,8 +53,8 @@ class Duration {
|
|
|
49
53
|
if (libelleEntier == null) libelleEntier = false;
|
|
50
54
|
|
|
51
55
|
// Heures
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
let strHeure = '';
|
|
57
|
+
let nbHeures = this.getNbHoursOfDurationInSeconds(durationInSeconds);
|
|
54
58
|
strHeure += nbHeures;
|
|
55
59
|
if (libelleEntier) {
|
|
56
60
|
strHeure += ' heure'+(nbHeures>1?'s':'');
|
|
@@ -60,8 +64,8 @@ class Duration {
|
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
// Minutes
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
let strMinute = '';
|
|
68
|
+
let nbMinutes = 0;
|
|
65
69
|
if (withMinutes) {
|
|
66
70
|
nbMinutes = this.getNbMinutesRemainingOfDurationInSeconds(durationInSeconds);
|
|
67
71
|
strMinute += ' ';
|
|
@@ -78,9 +82,9 @@ class Duration {
|
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
// Secondes
|
|
81
|
-
|
|
85
|
+
let strSeconde = '';
|
|
82
86
|
if (withSecondes) {
|
|
83
|
-
|
|
87
|
+
let nbSecondes = this.getNbSecondsRemainingOfDurationInSeconds(durationInSeconds);
|
|
84
88
|
strSeconde += ' ';
|
|
85
89
|
//strSeconde += sprintf('%02d', nbSecondes);
|
|
86
90
|
strSeconde += nbSecondes.toString().padStart(2, '0');
|
|
@@ -96,25 +100,25 @@ class Duration {
|
|
|
96
100
|
}
|
|
97
101
|
|
|
98
102
|
static roundNbSeconds(durationInSeconds, roundPrecision, roundMode) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
let hours = Math.floor(durationInSeconds / 3600);
|
|
104
|
+
let minutes = Math.floor((durationInSeconds % 3600) / 60);
|
|
105
|
+
let seconds = durationInSeconds % 60;
|
|
102
106
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
let hoursRounded = hours;
|
|
108
|
+
let minutesRounded = minutes;
|
|
109
|
+
let secondsRounded = seconds;
|
|
106
110
|
|
|
107
111
|
if (roundPrecision > 0) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (minutesRemainingAndSecondsAsCentieme
|
|
112
|
+
let minutesRemaining = minutes % roundPrecision;
|
|
113
|
+
let minutesRemainingAndSecondsAsCentieme = minutesRemaining + seconds/60;
|
|
114
|
+
if (minutesRemainingAndSecondsAsCentieme === 0) {
|
|
111
115
|
// pas d'arrondissement
|
|
112
116
|
}
|
|
113
117
|
else {
|
|
114
118
|
var halfRoundPrecision = roundPrecision / 2;
|
|
115
119
|
hoursRounded = hours;
|
|
116
120
|
secondsRounded = 0;
|
|
117
|
-
if (roundMode
|
|
121
|
+
if (roundMode === 'up' || (roundMode === 'close' && minutesRemainingAndSecondsAsCentieme > halfRoundPrecision)) {
|
|
118
122
|
// Arrondissement au dessus
|
|
119
123
|
if (minutes > (60-roundPrecision)) {
|
|
120
124
|
minutesRounded = 0;
|
package/flash_message.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
class FlashMessage {
|
|
2
|
-
|
|
3
2
|
static displayRequestFailure(status, exception, modal) {
|
|
4
3
|
console.log('request failure. Status: ', status, ' Exception: ', exception);
|
|
5
|
-
this.display('danger', "Une erreur s'est produite.", false, modal);
|
|
4
|
+
this.display('danger', typeof labelErrorOccured != 'undefined' ? labelErrorOccured : "Une erreur s'est produite.", false, modal);
|
|
6
5
|
}
|
|
7
6
|
|
|
8
7
|
static displaySuccess(message, reload, modal) {
|
package/form_helper.js
CHANGED
|
@@ -161,6 +161,26 @@ class FormHelper {
|
|
|
161
161
|
// Messages
|
|
162
162
|
// ------------------------------------------------------------
|
|
163
163
|
|
|
164
|
+
static extractErrorKeyOfJson(json, onlyIfUniqueError) {
|
|
165
|
+
if (typeof json == 'undefined' || json == null) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (typeof json.error != 'undefined') {
|
|
170
|
+
return json.error;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (typeof onlyIfUniqueError != 'undefined' && onlyIfUniqueError && !json.length || json.length > 1) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (typeof json[0] != 'undefined' && typeof json[0].error != 'undefined') {
|
|
178
|
+
return json[0].error;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
|
|
164
184
|
static hideFormErrors(form) {
|
|
165
185
|
form.find('div.form_errors').remove();
|
|
166
186
|
return form;
|
package/google_maps.js
CHANGED
|
@@ -19,7 +19,7 @@ class GoogleMap {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
static getUrl(latitude, longitude) {
|
|
22
|
-
return '
|
|
22
|
+
return 'https://maps.google.com/?q='+latitude+','+longitude+'';
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
static getUrlFromCoordinates(locationCoordinates) {
|
package/index.js
CHANGED
|
@@ -7,36 +7,44 @@ require('./array');
|
|
|
7
7
|
|
|
8
8
|
// exports d'ojets non natif
|
|
9
9
|
const { HTTPRequest, Cookie, UrlAndQueryString } = require('./network');
|
|
10
|
-
const { IBAN } = require('./bank');
|
|
10
|
+
const { IBAN, BankCard } = require('./bank');
|
|
11
11
|
const { AudioMedia } = require('./media');
|
|
12
12
|
const { PersonName, Email, TelephoneNumber } = require('./contact_details');
|
|
13
|
-
const { CountDown } = require('./count_down');
|
|
14
|
-
const { DataTable } = require('./data_table');
|
|
15
13
|
const { DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, InputPeriod } = require('./date_time');
|
|
16
|
-
const { DetailsSubArray } = require('./details_sub_array');
|
|
17
14
|
const { Duration } = require('./duration');
|
|
18
15
|
const { File, CSV, Img } = require('./file');
|
|
19
|
-
const { FlashMessage } = require('./flash_message');
|
|
20
16
|
const { FormHelper } = require('./form_helper');
|
|
21
|
-
const { GoogleMap } = require('./google_maps');
|
|
22
|
-
const { ImportFromCsv } = require('./import_from_csv');
|
|
23
|
-
const { JwtToken, JwtSession } = require('./jwt');
|
|
24
|
-
const { ListBox } = require('./list_box');
|
|
25
17
|
const { Country, PostalAddress, Location } = require('./location');
|
|
26
18
|
const { SocialNetwork } = require('./social_network');
|
|
27
|
-
const { NumberValue } = require('./number');
|
|
28
19
|
const { sleep, refresh } = require('./util');
|
|
29
20
|
const { chr, ord, trim, empty } = require('./php.min');
|
|
30
|
-
|
|
21
|
+
|
|
22
|
+
// exports plugins "maison"
|
|
23
|
+
const { DataTable } = require('./data_table');
|
|
24
|
+
const { Pagination, Navigation } = require('./paging');
|
|
25
|
+
const { DetailsSubArray } = require('./details_sub_array');
|
|
26
|
+
const { SelectAll } = require('./select_all');
|
|
27
|
+
const { MultipleActionInTable } = require('./multiple_action_in_table');
|
|
28
|
+
const { ShoppingCart } = require('./shopping_cart');
|
|
29
|
+
const { FlashMessage } = require('./flash_message');
|
|
30
|
+
const { CountDown } = require('./count_down');
|
|
31
|
+
const { ImportFromCsv } = require('./import_from_csv');
|
|
32
|
+
const { JwtToken, JwtSession } = require('./jwt');
|
|
33
|
+
const { ListBox } = require('./list_box');
|
|
34
|
+
|
|
35
|
+
// exports surcouche lib externe
|
|
31
36
|
const { GoogleCharts } = require('./google_charts');
|
|
32
37
|
const { GoogleRecaptcha } = require('./google_recaptcha');
|
|
38
|
+
const { GoogleMap } = require('./google_maps');
|
|
39
|
+
const { OpenStreetMap } = require('./open_street_map');
|
|
40
|
+
|
|
41
|
+
// deprecated
|
|
42
|
+
const { NumberValue } = require('./number');
|
|
33
43
|
|
|
34
44
|
module.exports = {
|
|
35
45
|
Array, Object, Number, String,
|
|
36
|
-
HTTPRequest, Cookie, UrlAndQueryString, IBAN, AudioMedia, PersonName, Email, TelephoneNumber,
|
|
37
|
-
|
|
38
|
-
FlashMessage, FormHelper, GoogleMap, ImportFromCsv, JwtToken, JwtSession, ListBox, Country, PostalAddress,
|
|
39
|
-
Location, SocialNetwork, NumberValue, Pagination,
|
|
46
|
+
HTTPRequest, Cookie, UrlAndQueryString, IBAN, BankCard, AudioMedia, PersonName, Email, TelephoneNumber, DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, InputPeriod, Duration, File, CSV, Img, FormHelper, Country, PostalAddress, Location, SocialNetwork, NumberValue,
|
|
47
|
+
DataTable, Pagination, Navigation, DetailsSubArray, SelectAll, MultipleActionInTable, ShoppingCart, FlashMessage, CountDown, ImportFromCsv, JwtToken, JwtSession, ListBox,
|
|
40
48
|
sleep, refresh, chr, ord, trim, empty,
|
|
41
|
-
GoogleCharts, GoogleRecaptcha
|
|
49
|
+
GoogleCharts, GoogleRecaptcha, GoogleMap, OpenStreetMap
|
|
42
50
|
};
|
|
@@ -111,11 +111,7 @@ class MultipleActionInTable {
|
|
|
111
111
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
$('table.table-action_multiple').each(function(idx, table) {
|
|
116
|
-
MultipleActionInTable.init($(table));
|
|
117
|
-
});
|
|
118
|
-
});
|
|
114
|
+
module.exports = { MultipleActionInTable };
|
|
119
115
|
|
|
120
116
|
/*
|
|
121
117
|
// init checkbox
|
package/number.js
CHANGED
|
@@ -71,6 +71,16 @@ Number.prototype.format = Number.prototype.format || function(nbDecimal, locale)
|
|
|
71
71
|
}).format(this);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
if (!Number.format) {
|
|
75
|
+
Number.format = function(number, nbDecimal, locale) {
|
|
76
|
+
nbDecimal = (typeof nbDecimal != 'undefined'?nbDecimal:2);
|
|
77
|
+
return new Intl.NumberFormat(locale, {
|
|
78
|
+
minimumFractionDigits: nbDecimal,
|
|
79
|
+
maximumFractionDigits: nbDecimal
|
|
80
|
+
}).format(number);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
74
84
|
/**
|
|
75
85
|
* Number.prototype.format(n, x, s, c)
|
|
76
86
|
*
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://leafletjs.com/
|
|
3
|
+
* https://switch2osm.org/the-basics/
|
|
4
|
+
* https://www.openstreetmap.org/help
|
|
5
|
+
*/
|
|
6
|
+
class OpenStreetMap {
|
|
7
|
+
|
|
8
|
+
constructor(mapId, options) {
|
|
9
|
+
/*let [lat, lng] = button.data('coordinates').split(',');
|
|
10
|
+
let map = L.map('modal_map_canvas2').setView([lat, lng], 17);
|
|
11
|
+
|
|
12
|
+
L.marker([lat, lng], {
|
|
13
|
+
icon: L.icon({iconUrl: getIconOfMapMarker(button.data('type_marker'))}),
|
|
14
|
+
title: popoverContent.title
|
|
15
|
+
//popupopen: setTimeout(displayEmployeesAndCompaniesAndTasks, 250)
|
|
16
|
+
}).addTo(map)
|
|
17
|
+
.bindPopup(popoverContent.content)
|
|
18
|
+
//.openPopup()
|
|
19
|
+
;*/
|
|
20
|
+
|
|
21
|
+
this.markers = [];
|
|
22
|
+
this.locations = [];
|
|
23
|
+
this.mapId = mapId;
|
|
24
|
+
|
|
25
|
+
if (!$('#'+mapId).length) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
this.map = L.map(mapId, options || {});
|
|
30
|
+
|
|
31
|
+
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
32
|
+
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
|
33
|
+
}).addTo(this.map);
|
|
34
|
+
|
|
35
|
+
this.centerOnFrance();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static getUrl(latitude, longitude) {
|
|
39
|
+
return 'https://www.openstreetmap.org/?mlat='+latitude+'&mlon='+longitude+'#map=17/'+latitude+'/'+longitude+'&layers=N';
|
|
40
|
+
//return 'https://www.openstreetmap.org/#map=17/'+latitude+'/'+longitude+'';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static getUrlFromCoordinates(locationCoordinates) {
|
|
44
|
+
locationCoordinates = locationCoordinates.split(',');
|
|
45
|
+
return this.getUrl(parseFloat(locationCoordinates[0]), parseFloat(locationCoordinates[1]));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
setZoom(zoom) {
|
|
49
|
+
this.map.setZoom(zoom);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
deleteMarkers() {
|
|
53
|
+
this.locations = [];
|
|
54
|
+
|
|
55
|
+
//this.markers.forEach(marker => marker.setMap(null));
|
|
56
|
+
|
|
57
|
+
this.markers.length = 0;
|
|
58
|
+
this.markers = [];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
addMarkers(listLocations, icon) {
|
|
62
|
+
if (listLocations.length === 0) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
listLocations.forEach(location => this.addMarker(location, icon));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
addMarker(coordinates, options) {
|
|
70
|
+
let locationCoordinates = coordinates.split(',');
|
|
71
|
+
let latitude = parseFloat(locationCoordinates[0]);
|
|
72
|
+
let longitude = parseFloat(locationCoordinates[1]);
|
|
73
|
+
|
|
74
|
+
let marker = L.marker([latitude, longitude], {
|
|
75
|
+
icon: L.icon({
|
|
76
|
+
iconUrl: options['icon'],
|
|
77
|
+
iconSize: [22, 32],
|
|
78
|
+
}),
|
|
79
|
+
title: options['title'],
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
//marker.on('click', () => {
|
|
83
|
+
marker.on('popupopen', () => {
|
|
84
|
+
console.log('popupopen');
|
|
85
|
+
if (typeof options['on_click'] == 'function') {
|
|
86
|
+
options['on_click']();
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
});
|
|
90
|
+
marker.addTo(this.map);
|
|
91
|
+
marker.bindPopup(options['popup_content']);
|
|
92
|
+
|
|
93
|
+
this.markers.push(marker);
|
|
94
|
+
this.locations.push([latitude, longitude]);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
centerOnFrance() {
|
|
98
|
+
this.map.setView([46.52863469527167, 2.43896484375], 6);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
centerOnMarkers() {
|
|
102
|
+
this.map.invalidateSize(false);
|
|
103
|
+
|
|
104
|
+
if (this.locations.length === 0) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
this.map.fitBounds(new L.LatLngBounds(this.locations));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
connectMarkers() {
|
|
112
|
+
if (this.locations.length === 0) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
let prevLocation = null;
|
|
117
|
+
let listLineCoordinates = [];
|
|
118
|
+
this.locations.forEach(location => {
|
|
119
|
+
if (prevLocation != null) {
|
|
120
|
+
listLineCoordinates.push([prevLocation, location]);
|
|
121
|
+
}
|
|
122
|
+
prevLocation = location;
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
listLineCoordinates.forEach(line => {
|
|
126
|
+
L.polyline(line, {color: '#728bec'}).addTo(this.map);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
module.exports = { OpenStreetMap };
|
package/package.json
CHANGED
package/paging.js
CHANGED
|
@@ -95,7 +95,9 @@ class Pagination {
|
|
|
95
95
|
|
|
96
96
|
update();
|
|
97
97
|
}
|
|
98
|
+
}
|
|
98
99
|
|
|
100
|
+
class Navigation {
|
|
99
101
|
static activateTab(a) {
|
|
100
102
|
//console.log(a);
|
|
101
103
|
//a.click();
|
|
@@ -117,7 +119,7 @@ class Pagination {
|
|
|
117
119
|
}
|
|
118
120
|
}
|
|
119
121
|
|
|
120
|
-
module.exports = { Pagination };
|
|
122
|
+
module.exports = { Pagination, Navigation };
|
|
121
123
|
|
|
122
124
|
// deprecated
|
|
123
125
|
/*
|
|
@@ -114,19 +114,4 @@ class SelectAll {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
// Dans un form-group
|
|
119
|
-
$('a.check_all').each(function(idx, link) {
|
|
120
|
-
SelectAll.initLinkInFormGroup($(link));
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
// Dans tableau
|
|
124
|
-
$('table tr input.check_all').each(function(idx, inputCheckAll) {
|
|
125
|
-
SelectAll.initInTable($(inputCheckAll).closest('table'));
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
// Dans un div
|
|
129
|
-
$('div.checkbox_with_check_all').each(function(idx, div) {
|
|
130
|
-
SelectAll.initDiv($(div));
|
|
131
|
-
});
|
|
132
|
-
});
|
|
117
|
+
module.exports = { SelectAll };
|
package/shopping_cart.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
class ShoppingCart {
|
|
2
|
+
static addProduct(productId, quantity, data) {
|
|
3
|
+
let cart = this.getCart();
|
|
4
|
+
let item = cart.find(element => element.product_id == productId);
|
|
5
|
+
if (typeof item != 'undefined') {
|
|
6
|
+
cart.unsetVal(item);
|
|
7
|
+
quantity += item.quantity;
|
|
8
|
+
}
|
|
9
|
+
cart.push({product_id: productId, quantity: quantity, data: data});
|
|
10
|
+
localStorage.setItem('cart', JSON.stringify(cart));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static deleteProduct(productId) {
|
|
14
|
+
let cart = this.getCart();
|
|
15
|
+
cart.unsetVal(cart.find(element => element.product_id == productId));
|
|
16
|
+
localStorage.setItem('cart', JSON.stringify(cart));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static removeAllItems() {
|
|
20
|
+
localStorage.removeItem('cart');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static getCart() {
|
|
24
|
+
let cart = [];
|
|
25
|
+
if (localStorage.getItem('cart') != null) {
|
|
26
|
+
cart = JSON.parse(localStorage.getItem('cart'));
|
|
27
|
+
}
|
|
28
|
+
return cart;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = { ShoppingCart };
|
package/string.js
CHANGED
|
@@ -93,12 +93,17 @@ String.prototype.escapeHtml = String.prototype.escapeHtml || function() {
|
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
String.prototype.normalizeBreaks = String.prototype.normalizeBreaks || function(breaktype) {
|
|
96
|
-
|
|
96
|
+
// 20/01/2022 : modifié car ne fonctionnait pas pour les string en provenance de textarea, enregistrée en bd puis réaffiché depuis bd
|
|
97
|
+
//return this.replace(/$/mg, breaktype).replace(new RegExp('/'+breaktype.escapeRegExp()+'$/'), '');
|
|
98
|
+
return this.replace(/(?:\r\n|\r|\n)/g, breaktype);
|
|
99
|
+
//return this.replace('/(\r\n|\r|\n)/ms', breaktype);
|
|
97
100
|
//return this.replace('/(?:\r\n|\r|\n)/g', breaktype);
|
|
98
101
|
//console.log(breaktype);
|
|
99
102
|
//return this.replace(new RegExp('\r?\n','g'), breaktype);
|
|
100
103
|
};
|
|
101
|
-
|
|
104
|
+
String.prototype.escapeRegExp = String.prototype.escapeRegExp || function() {
|
|
105
|
+
return this.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
106
|
+
};
|
|
102
107
|
String.prototype.format = String.prototype.format || function() {
|
|
103
108
|
var args = arguments;
|
|
104
109
|
return this.replace(/{(\d+)}/g, (match, number) => (typeof args[number] != 'undefined' ? args[number] : match));
|
package/util.js
CHANGED