@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/duration.js
CHANGED
|
@@ -1,199 +1,199 @@
|
|
|
1
|
-
|
|
2
|
-
class Duration {
|
|
3
|
-
|
|
4
|
-
// ---------- Nb jours ----------
|
|
5
|
-
|
|
6
|
-
static formatNbDays(nbDays, locale='fr-FR') {
|
|
7
|
-
return new Intl.NumberFormat(locale, {
|
|
8
|
-
minimumFractionDigits: 2,
|
|
9
|
-
maximumFractionDigits: 2
|
|
10
|
-
}).format(nbDays);
|
|
11
|
-
}
|
|
12
|
-
static formatNbDaysIfPositive(nbDays) {
|
|
13
|
-
return nbDays < 0 ? '-' : this.formatNbDays(nbDays);
|
|
14
|
-
}
|
|
15
|
-
static formatNbDaysWithColor(nbDays) {
|
|
16
|
-
return '<span class="text-'+(nbDays<0?'danger':'success')+'">'+this.formatNbDays(nbDays)+'</span>';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// ---------- Durée en seconde ----------
|
|
20
|
-
|
|
21
|
-
static convertInputTimeValueToDuration(inputTimeValue) {
|
|
22
|
-
if (null === inputTimeValue || -1 === inputTimeValue.indexOf(':')) {
|
|
23
|
-
return 0;
|
|
24
|
-
}
|
|
25
|
-
let arrayTime = inputTimeValue.split(':');
|
|
26
|
-
const nbHours = typeof arrayTime[0] != 'undefined' ? parseInt(arrayTime[0]) || 0 : 0;
|
|
27
|
-
const nbMinutes = typeof arrayTime[1] != 'undefined' ? parseInt(arrayTime[1]) || 0 : 0;
|
|
28
|
-
const nbSeconds = typeof arrayTime[2] != 'undefined' ? parseInt(arrayTime[2]) || 0 : 0;
|
|
29
|
-
return nbHours * 3600 + nbMinutes * 60 + nbSeconds;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
static convertToDurationAsInputTimeValue(durationInSeconds) {
|
|
33
|
-
return Duration.convertToDurationInHourChronoDisplay(Math.abs(durationInSeconds), 'input_time');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static convertToDurationInHourChronoDisplay(durationInSeconds, displayMode='chrono') {
|
|
37
|
-
durationInSeconds = Math.round(durationInSeconds);
|
|
38
|
-
|
|
39
|
-
let durationInSecondsOriginal = durationInSeconds;
|
|
40
|
-
durationInSeconds = Math.abs(durationInSeconds);
|
|
41
|
-
let seconds = ( durationInSeconds % 60 );
|
|
42
|
-
let remander = ( durationInSeconds % 3600 ) - seconds;
|
|
43
|
-
let minutes = ( remander / 60 );
|
|
44
|
-
remander = ( durationInSeconds ) - ( durationInSeconds % 3600 );
|
|
45
|
-
let hours = ( remander / 3600 );
|
|
46
|
-
if(hours.toString().length < 2) hours = '0'+hours;
|
|
47
|
-
if(hours.toString().charAt(0) === "-") hours[0] = '0';
|
|
48
|
-
if(minutes.toString().length < 2) minutes = '0'+minutes;
|
|
49
|
-
if(minutes.toString().charAt(0) === "-") minutes[0] = '0';
|
|
50
|
-
if(seconds.toString().length < 2) seconds = '0'+seconds;
|
|
51
|
-
return (durationInSecondsOriginal < 0 ? '- ' : '')+hours+':'+minutes+(displayMode==='input_time'?':':'.')+seconds;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
static convertToDurationInHourStringDisplay(durationInSeconds, withSecondes=true, withMinutes=true, withLibelleMinute=true, libelleEntier=false) {
|
|
55
|
-
durationInSeconds = Math.round(durationInSeconds);
|
|
56
|
-
|
|
57
|
-
// Heures
|
|
58
|
-
let strHeure = '';
|
|
59
|
-
let nbHeures = this.getNbHoursOfDurationInSeconds(durationInSeconds);
|
|
60
|
-
strHeure += nbHeures;
|
|
61
|
-
if (libelleEntier) {
|
|
62
|
-
strHeure += ' heure'+(nbHeures>1?'s':'');
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
strHeure += 'h';
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Minutes
|
|
69
|
-
let strMinute = '';
|
|
70
|
-
let nbMinutes = 0;
|
|
71
|
-
if (withMinutes) {
|
|
72
|
-
nbMinutes = this.getNbMinutesRemainingOfDurationInSeconds(durationInSeconds);
|
|
73
|
-
strMinute += ' ';
|
|
74
|
-
//strMinute += sprintf('%02d', nbMinutes);
|
|
75
|
-
strMinute += nbMinutes.toString().padStart(2, '0');
|
|
76
|
-
if (withLibelleMinute) {
|
|
77
|
-
if (libelleEntier) {
|
|
78
|
-
strMinute += ' minute'+(nbMinutes>1?'s':'');
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
strMinute += 'min';
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Secondes
|
|
87
|
-
let strSeconde = '';
|
|
88
|
-
if (withSecondes) {
|
|
89
|
-
let nbSecondes = this.getNbSecondsRemainingOfDurationInSeconds(durationInSeconds);
|
|
90
|
-
strSeconde += ' ';
|
|
91
|
-
//strSeconde += sprintf('%02d', nbSecondes);
|
|
92
|
-
strSeconde += nbSecondes.toString().padStart(2, '0');
|
|
93
|
-
if (libelleEntier) {
|
|
94
|
-
strSeconde += ' seconde'+(nbSecondes>1?'s':'');
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
strSeconde += 's';
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return (strHeure+strMinute+strSeconde).trim();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
static roundNbSeconds(durationInSeconds, roundPrecision, roundMode='close') {
|
|
105
|
-
let hours = Math.floor(durationInSeconds / 3600);
|
|
106
|
-
let minutes = Math.floor((durationInSeconds % 3600) / 60);
|
|
107
|
-
let seconds = durationInSeconds % 60;
|
|
108
|
-
|
|
109
|
-
let hoursRounded = hours;
|
|
110
|
-
let minutesRounded = minutes;
|
|
111
|
-
let secondsRounded = seconds;
|
|
112
|
-
|
|
113
|
-
if (roundPrecision > 0) {
|
|
114
|
-
let minutesRemaining = minutes % roundPrecision;
|
|
115
|
-
let minutesRemainingAndSecondsAsCentieme = minutesRemaining + seconds/60;
|
|
116
|
-
if (minutesRemainingAndSecondsAsCentieme === 0) {
|
|
117
|
-
// pas d'arrondissement
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
let halfRoundPrecision = roundPrecision / 2;
|
|
121
|
-
hoursRounded = hours;
|
|
122
|
-
secondsRounded = 0;
|
|
123
|
-
if (roundMode === 'up' || (roundMode === 'close' && minutesRemainingAndSecondsAsCentieme > halfRoundPrecision)) {
|
|
124
|
-
// Arrondissement au dessus
|
|
125
|
-
if (minutes > (60-roundPrecision)) {
|
|
126
|
-
minutesRounded = 0;
|
|
127
|
-
hoursRounded++;
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
minutesRounded = (minutes-minutesRemaining)+roundPrecision;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
// Arrondissement au dessous
|
|
135
|
-
minutesRounded = (minutes-minutesRemaining);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
// console.log(element.data('duration_default'), durationInSeconds, hours, minutes, seconds, '->', secondsTotalRounded, hoursRounded, minutesRounded, secondsRounded);
|
|
140
|
-
return hoursRounded * 3600 + minutesRounded * 60 + secondsRounded;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
static getNbDaysOfDurationInSeconds(durationInSeconds) {
|
|
144
|
-
return Math.floor(durationInSeconds / 86400);
|
|
145
|
-
}
|
|
146
|
-
static getNbHoursOfDurationInSeconds(durationInSeconds) {
|
|
147
|
-
return Math.floor(durationInSeconds / 3600);
|
|
148
|
-
}
|
|
149
|
-
static getNbMinutesOfDurationInSeconds(durationInSeconds) {
|
|
150
|
-
return Math.floor(durationInSeconds / 60);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/*static getNbMinutesRemaining(durationInSeconds) {
|
|
154
|
-
var remander = ( durationInSeconds % 3600 ) - ( durationInSeconds % 60 );
|
|
155
|
-
return ( remander / 60 );
|
|
156
|
-
}
|
|
157
|
-
static getNbHoursOfDurationInSeconds(durationInSeconds) {
|
|
158
|
-
// return (this.getNbDaysOfDurationInSeconds(durationInSeconds)*24)+this.getNbHoursRemainingOfDurationInSeconds(durationInSeconds);
|
|
159
|
-
return (durationInSeconds - (durationInSeconds % 3600)) / 3600;
|
|
160
|
-
}
|
|
161
|
-
static getNbMinutesOfDurationInSeconds(durationInSeconds) {
|
|
162
|
-
// return (this.getNbDaysOfDurationInSeconds(durationInSeconds)*24*60)+(this.getNbHoursRemainingOfDurationInSeconds(durationInSeconds)*60)+this.getNbMinutesRemainingOfDurationInSeconds(durationInSeconds);
|
|
163
|
-
return (durationInSeconds - (durationInSeconds % 60)) / 60;
|
|
164
|
-
}*/
|
|
165
|
-
|
|
166
|
-
static getNbHoursRemainingOfDurationInSeconds(durationInSeconds) {
|
|
167
|
-
return this.getNbHoursOfDurationInSeconds(durationInSeconds % 86400);
|
|
168
|
-
}
|
|
169
|
-
static getNbMinutesRemainingOfDurationInSeconds(durationInSeconds) {
|
|
170
|
-
return this.getNbMinutesOfDurationInSeconds(durationInSeconds % 3600);
|
|
171
|
-
}
|
|
172
|
-
static getNbSecondsRemainingOfDurationInSeconds(durationInSeconds) {
|
|
173
|
-
return durationInSeconds % 60;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// ---------- Durée en centième d'heure ----------
|
|
177
|
-
|
|
178
|
-
static convertToDurationAsHundredthOfAnHour(durationInSeconds) {
|
|
179
|
-
let hour = Math.floor(durationInSeconds / 3600);
|
|
180
|
-
let minutes = durationInSeconds % 3600;
|
|
181
|
-
minutes = Math.floor(minutes / 60);
|
|
182
|
-
// minutes = minutes - (minutes % 60);
|
|
183
|
-
let minCentieme = Math.round( (minutes / 60 ) * 100 );
|
|
184
|
-
return hour+(minCentieme/100);
|
|
185
|
-
//return parseFloat(hour+'.'+minCentieme);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
static getNbHoursOfHundredthOfAnHour(durationAsHundredthOfAnHour) {
|
|
189
|
-
return Math.trunc(durationAsHundredthOfAnHour);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
static getNbMinutesOfHundredthOfAnHour(durationAsHundredthOfAnHour) {
|
|
193
|
-
return Math.floor(Math.getDecimals(Number.roundDecimal(durationAsHundredthOfAnHour, 2)) / 100 * 60);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
|
|
1
|
+
|
|
2
|
+
class Duration {
|
|
3
|
+
|
|
4
|
+
// ---------- Nb jours ----------
|
|
5
|
+
|
|
6
|
+
static formatNbDays(nbDays, locale='fr-FR') {
|
|
7
|
+
return new Intl.NumberFormat(locale, {
|
|
8
|
+
minimumFractionDigits: 2,
|
|
9
|
+
maximumFractionDigits: 2
|
|
10
|
+
}).format(nbDays);
|
|
11
|
+
}
|
|
12
|
+
static formatNbDaysIfPositive(nbDays) {
|
|
13
|
+
return nbDays < 0 ? '-' : this.formatNbDays(nbDays);
|
|
14
|
+
}
|
|
15
|
+
static formatNbDaysWithColor(nbDays) {
|
|
16
|
+
return '<span class="text-'+(nbDays<0?'danger':'success')+'">'+this.formatNbDays(nbDays)+'</span>';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// ---------- Durée en seconde ----------
|
|
20
|
+
|
|
21
|
+
static convertInputTimeValueToDuration(inputTimeValue) {
|
|
22
|
+
if (null === inputTimeValue || -1 === inputTimeValue.indexOf(':')) {
|
|
23
|
+
return 0;
|
|
24
|
+
}
|
|
25
|
+
let arrayTime = inputTimeValue.split(':');
|
|
26
|
+
const nbHours = typeof arrayTime[0] != 'undefined' ? parseInt(arrayTime[0]) || 0 : 0;
|
|
27
|
+
const nbMinutes = typeof arrayTime[1] != 'undefined' ? parseInt(arrayTime[1]) || 0 : 0;
|
|
28
|
+
const nbSeconds = typeof arrayTime[2] != 'undefined' ? parseInt(arrayTime[2]) || 0 : 0;
|
|
29
|
+
return nbHours * 3600 + nbMinutes * 60 + nbSeconds;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static convertToDurationAsInputTimeValue(durationInSeconds) {
|
|
33
|
+
return Duration.convertToDurationInHourChronoDisplay(Math.abs(durationInSeconds), 'input_time');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static convertToDurationInHourChronoDisplay(durationInSeconds, displayMode='chrono') {
|
|
37
|
+
durationInSeconds = Math.round(durationInSeconds);
|
|
38
|
+
|
|
39
|
+
let durationInSecondsOriginal = durationInSeconds;
|
|
40
|
+
durationInSeconds = Math.abs(durationInSeconds);
|
|
41
|
+
let seconds = ( durationInSeconds % 60 );
|
|
42
|
+
let remander = ( durationInSeconds % 3600 ) - seconds;
|
|
43
|
+
let minutes = ( remander / 60 );
|
|
44
|
+
remander = ( durationInSeconds ) - ( durationInSeconds % 3600 );
|
|
45
|
+
let hours = ( remander / 3600 );
|
|
46
|
+
if(hours.toString().length < 2) hours = '0'+hours;
|
|
47
|
+
if(hours.toString().charAt(0) === "-") hours[0] = '0';
|
|
48
|
+
if(minutes.toString().length < 2) minutes = '0'+minutes;
|
|
49
|
+
if(minutes.toString().charAt(0) === "-") minutes[0] = '0';
|
|
50
|
+
if(seconds.toString().length < 2) seconds = '0'+seconds;
|
|
51
|
+
return (durationInSecondsOriginal < 0 ? '- ' : '')+hours+':'+minutes+(displayMode==='input_time'?':':'.')+seconds;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static convertToDurationInHourStringDisplay(durationInSeconds, withSecondes=true, withMinutes=true, withLibelleMinute=true, libelleEntier=false) {
|
|
55
|
+
durationInSeconds = Math.round(durationInSeconds);
|
|
56
|
+
|
|
57
|
+
// Heures
|
|
58
|
+
let strHeure = '';
|
|
59
|
+
let nbHeures = this.getNbHoursOfDurationInSeconds(durationInSeconds);
|
|
60
|
+
strHeure += nbHeures;
|
|
61
|
+
if (libelleEntier) {
|
|
62
|
+
strHeure += ' heure'+(nbHeures>1?'s':'');
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
strHeure += 'h';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Minutes
|
|
69
|
+
let strMinute = '';
|
|
70
|
+
let nbMinutes = 0;
|
|
71
|
+
if (withMinutes) {
|
|
72
|
+
nbMinutes = this.getNbMinutesRemainingOfDurationInSeconds(durationInSeconds);
|
|
73
|
+
strMinute += ' ';
|
|
74
|
+
//strMinute += sprintf('%02d', nbMinutes);
|
|
75
|
+
strMinute += nbMinutes.toString().padStart(2, '0');
|
|
76
|
+
if (withLibelleMinute) {
|
|
77
|
+
if (libelleEntier) {
|
|
78
|
+
strMinute += ' minute'+(nbMinutes>1?'s':'');
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
strMinute += 'min';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Secondes
|
|
87
|
+
let strSeconde = '';
|
|
88
|
+
if (withSecondes) {
|
|
89
|
+
let nbSecondes = this.getNbSecondsRemainingOfDurationInSeconds(durationInSeconds);
|
|
90
|
+
strSeconde += ' ';
|
|
91
|
+
//strSeconde += sprintf('%02d', nbSecondes);
|
|
92
|
+
strSeconde += nbSecondes.toString().padStart(2, '0');
|
|
93
|
+
if (libelleEntier) {
|
|
94
|
+
strSeconde += ' seconde'+(nbSecondes>1?'s':'');
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
strSeconde += 's';
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return (strHeure+strMinute+strSeconde).trim();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static roundNbSeconds(durationInSeconds, roundPrecision, roundMode='close') {
|
|
105
|
+
let hours = Math.floor(durationInSeconds / 3600);
|
|
106
|
+
let minutes = Math.floor((durationInSeconds % 3600) / 60);
|
|
107
|
+
let seconds = durationInSeconds % 60;
|
|
108
|
+
|
|
109
|
+
let hoursRounded = hours;
|
|
110
|
+
let minutesRounded = minutes;
|
|
111
|
+
let secondsRounded = seconds;
|
|
112
|
+
|
|
113
|
+
if (roundPrecision > 0) {
|
|
114
|
+
let minutesRemaining = minutes % roundPrecision;
|
|
115
|
+
let minutesRemainingAndSecondsAsCentieme = minutesRemaining + seconds/60;
|
|
116
|
+
if (minutesRemainingAndSecondsAsCentieme === 0) {
|
|
117
|
+
// pas d'arrondissement
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
let halfRoundPrecision = roundPrecision / 2;
|
|
121
|
+
hoursRounded = hours;
|
|
122
|
+
secondsRounded = 0;
|
|
123
|
+
if (roundMode === 'up' || (roundMode === 'close' && minutesRemainingAndSecondsAsCentieme > halfRoundPrecision)) {
|
|
124
|
+
// Arrondissement au dessus
|
|
125
|
+
if (minutes > (60-roundPrecision)) {
|
|
126
|
+
minutesRounded = 0;
|
|
127
|
+
hoursRounded++;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
minutesRounded = (minutes-minutesRemaining)+roundPrecision;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
// Arrondissement au dessous
|
|
135
|
+
minutesRounded = (minutes-minutesRemaining);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// console.log(element.data('duration_default'), durationInSeconds, hours, minutes, seconds, '->', secondsTotalRounded, hoursRounded, minutesRounded, secondsRounded);
|
|
140
|
+
return hoursRounded * 3600 + minutesRounded * 60 + secondsRounded;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static getNbDaysOfDurationInSeconds(durationInSeconds) {
|
|
144
|
+
return Math.floor(durationInSeconds / 86400);
|
|
145
|
+
}
|
|
146
|
+
static getNbHoursOfDurationInSeconds(durationInSeconds) {
|
|
147
|
+
return Math.floor(durationInSeconds / 3600);
|
|
148
|
+
}
|
|
149
|
+
static getNbMinutesOfDurationInSeconds(durationInSeconds) {
|
|
150
|
+
return Math.floor(durationInSeconds / 60);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/*static getNbMinutesRemaining(durationInSeconds) {
|
|
154
|
+
var remander = ( durationInSeconds % 3600 ) - ( durationInSeconds % 60 );
|
|
155
|
+
return ( remander / 60 );
|
|
156
|
+
}
|
|
157
|
+
static getNbHoursOfDurationInSeconds(durationInSeconds) {
|
|
158
|
+
// return (this.getNbDaysOfDurationInSeconds(durationInSeconds)*24)+this.getNbHoursRemainingOfDurationInSeconds(durationInSeconds);
|
|
159
|
+
return (durationInSeconds - (durationInSeconds % 3600)) / 3600;
|
|
160
|
+
}
|
|
161
|
+
static getNbMinutesOfDurationInSeconds(durationInSeconds) {
|
|
162
|
+
// return (this.getNbDaysOfDurationInSeconds(durationInSeconds)*24*60)+(this.getNbHoursRemainingOfDurationInSeconds(durationInSeconds)*60)+this.getNbMinutesRemainingOfDurationInSeconds(durationInSeconds);
|
|
163
|
+
return (durationInSeconds - (durationInSeconds % 60)) / 60;
|
|
164
|
+
}*/
|
|
165
|
+
|
|
166
|
+
static getNbHoursRemainingOfDurationInSeconds(durationInSeconds) {
|
|
167
|
+
return this.getNbHoursOfDurationInSeconds(durationInSeconds % 86400);
|
|
168
|
+
}
|
|
169
|
+
static getNbMinutesRemainingOfDurationInSeconds(durationInSeconds) {
|
|
170
|
+
return this.getNbMinutesOfDurationInSeconds(durationInSeconds % 3600);
|
|
171
|
+
}
|
|
172
|
+
static getNbSecondsRemainingOfDurationInSeconds(durationInSeconds) {
|
|
173
|
+
return durationInSeconds % 60;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// ---------- Durée en centième d'heure ----------
|
|
177
|
+
|
|
178
|
+
static convertToDurationAsHundredthOfAnHour(durationInSeconds) {
|
|
179
|
+
let hour = Math.floor(durationInSeconds / 3600);
|
|
180
|
+
let minutes = durationInSeconds % 3600;
|
|
181
|
+
minutes = Math.floor(minutes / 60);
|
|
182
|
+
// minutes = minutes - (minutes % 60);
|
|
183
|
+
let minCentieme = Math.round( (minutes / 60 ) * 100 );
|
|
184
|
+
return hour+(minCentieme/100);
|
|
185
|
+
//return parseFloat(hour+'.'+minCentieme);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
static getNbHoursOfHundredthOfAnHour(durationAsHundredthOfAnHour) {
|
|
189
|
+
return Math.trunc(durationAsHundredthOfAnHour);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
static getNbMinutesOfHundredthOfAnHour(durationAsHundredthOfAnHour) {
|
|
193
|
+
return Math.floor(Math.getDecimals(Number.roundDecimal(durationAsHundredthOfAnHour, 2)) / 100 * 60);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
}
|
|
198
|
+
|
|
199
199
|
module.exports = { Duration };
|
package/event_bus.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
class EventBus {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.events = {};
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
publish(name, data) {
|
|
7
|
-
var handlers = this.events[name];
|
|
8
|
-
|
|
9
|
-
if (!!handlers === false) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
handlers.forEach(function(handler) {
|
|
14
|
-
handler.call(this, data)
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
subscribe(name, handler) {
|
|
19
|
-
var handlers = this.events[name];
|
|
20
|
-
|
|
21
|
-
if (!!handlers === false) {
|
|
22
|
-
handlers = this.events[name] = [];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
handlers.push(handler);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
unsubscribe(name, handler) {
|
|
29
|
-
var handlers = this.events[name];
|
|
30
|
-
|
|
31
|
-
if (!!handlers === false) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
handlers.splice(handlers.indexOf(handler));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
1
|
+
class EventBus {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.events = {};
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
publish(name, data) {
|
|
7
|
+
var handlers = this.events[name];
|
|
8
|
+
|
|
9
|
+
if (!!handlers === false) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
handlers.forEach(function(handler) {
|
|
14
|
+
handler.call(this, data)
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
subscribe(name, handler) {
|
|
19
|
+
var handlers = this.events[name];
|
|
20
|
+
|
|
21
|
+
if (!!handlers === false) {
|
|
22
|
+
handlers = this.events[name] = [];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
handlers.push(handler);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
unsubscribe(name, handler) {
|
|
29
|
+
var handlers = this.events[name];
|
|
30
|
+
|
|
31
|
+
if (!!handlers === false) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
handlers.splice(handlers.indexOf(handler));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
39
|
module.exports = { EventBus };
|