@osimatic/helpers-js 1.4.24 → 1.4.26
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/.claude/settings.local.json +2 -1
- package/chartjs.js +1 -1
- package/date_time.js +25 -16
- package/draw.js +3 -2
- package/duration.js +176 -130
- package/event_bus.js +2 -2
- package/file.js +20 -5
- package/form_helper.js +1 -1
- package/google_charts.js +2 -1
- package/http_client.js +2 -0
- package/jwt.js +18 -6
- package/location.js +5 -1
- package/media.js +7 -7
- package/multi_files_input.js +3 -1
- package/number.js +2 -3
- package/package.json +4 -2
- package/paging.js +2 -2
- package/social_network.js +5 -0
- package/string.js +11 -2
- package/tests/__mocks__/socket.io-client.js +13 -0
- package/tests/chartjs.test.js +273 -0
- package/tests/count_down.test.js +580 -0
- package/tests/date_time/DatePeriod.test.js +179 -0
- package/tests/date_time/DateTime.test.js +492 -0
- package/tests/date_time/SqlDate.test.js +205 -0
- package/tests/date_time/SqlDateTime.test.js +326 -0
- package/tests/date_time/SqlTime.test.js +162 -0
- package/tests/date_time/TimestampUnix.test.js +262 -0
- package/tests/details_sub_array.test.js +367 -0
- package/tests/draw.test.js +271 -0
- package/tests/duration.test.js +365 -0
- package/tests/event_bus.test.js +268 -0
- package/tests/file.test.js +568 -0
- package/tests/flash_message.test.js +297 -0
- package/tests/form_date.test.js +1559 -0
- package/tests/form_helper.test.js +1065 -0
- package/tests/google_charts.test.js +768 -0
- package/tests/google_maps.test.js +655 -0
- package/tests/google_recaptcha.test.js +441 -0
- package/tests/http_client.test.js +570 -0
- package/tests/import_from_csv.test.js +797 -0
- package/tests/jwt.test.js +804 -0
- package/tests/list_box.test.js +255 -0
- package/tests/location.test.js +86 -0
- package/tests/media.test.js +473 -0
- package/tests/multi_files_input.test.js +1015 -0
- package/tests/multiple_action_in_table.test.js +477 -0
- package/tests/network.test.js +489 -0
- package/tests/number.test.js +448 -0
- package/tests/open_street_map.test.js +388 -0
- package/tests/paging.test.js +646 -0
- package/tests/select_all.test.js +360 -0
- package/tests/shopping_cart.test.js +355 -0
- package/tests/social_network.test.js +333 -0
- package/tests/sortable_list.test.js +602 -0
- package/tests/string.test.js +489 -0
- package/tests/user.test.js +204 -0
- package/tests/util.test.js +99 -0
- package/tests/visitor.test.js +508 -0
- package/tests/web_rtc.test.js +458 -0
- package/tests/web_socket.test.js +538 -0
- package/visitor.js +2 -2
- package/tmpclaude-0fa4-cwd +0 -1
- package/tmpclaude-104f-cwd +0 -1
- package/tmpclaude-1468-cwd +0 -1
- package/tmpclaude-324b-cwd +0 -1
- package/tmpclaude-35d3-cwd +0 -1
- package/tmpclaude-4aa8-cwd +0 -1
package/chartjs.js
CHANGED
|
@@ -298,7 +298,7 @@ class Chartjs {
|
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
static getAutoGranularity(data) {
|
|
301
|
-
const dates = Object.keys(data);
|
|
301
|
+
const dates = Object.keys(data).sort();
|
|
302
302
|
const days = (new Date(dates[dates.length - 1]) - new Date(dates[0])) / (1000 * 60 * 60 * 24);
|
|
303
303
|
if (days > 90) return 'month';
|
|
304
304
|
if (days > 30) return 'week';
|
package/date_time.js
CHANGED
|
@@ -206,9 +206,7 @@ class DateTime {
|
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
static getLastDayOfYear(date) {
|
|
209
|
-
date.
|
|
210
|
-
date.setUTCMonth(11);
|
|
211
|
-
return new Date(date);
|
|
209
|
+
return new Date(Date.UTC(date.getUTCFullYear(), 11, 31));
|
|
212
210
|
}
|
|
213
211
|
|
|
214
212
|
static getFirstDayOfWeekAndYear(year, week) {
|
|
@@ -308,7 +306,7 @@ class DatePeriod {
|
|
|
308
306
|
return partOfDay === DatePeriod.PART_OF_DAY_MORNING || partOfDay === DatePeriod.PART_OF_DAY_AFTERNOON;
|
|
309
307
|
}
|
|
310
308
|
|
|
311
|
-
static getNbDayBetweenTwo(jsDate1, jsDate2,
|
|
309
|
+
static getNbDayBetweenTwo(jsDate1, jsDate2, considerTime=false, timeZone="Europe/Paris", returnDecimal=false) {
|
|
312
310
|
//jsDate1.set
|
|
313
311
|
if (jsDate1 == null || jsDate2 == null) {
|
|
314
312
|
return 0;
|
|
@@ -317,7 +315,7 @@ class DatePeriod {
|
|
|
317
315
|
let timestamp1 = jsDate1.getTime() / 1000;
|
|
318
316
|
let timestamp2 = jsDate2.getTime() / 1000;
|
|
319
317
|
|
|
320
|
-
if (!
|
|
318
|
+
if (!considerTime) {
|
|
321
319
|
let jsMidnightDate1 = new Date(jsDate1.toLocaleDateString('en-US', {timeZone: timeZone})+' 00:00:00');
|
|
322
320
|
let jsMidnightDate2 = new Date(jsDate2.toLocaleDateString('en-US', {timeZone: timeZone})+' 00:00:00');
|
|
323
321
|
timestamp1 = jsMidnightDate1.getTime() / 1000;
|
|
@@ -327,7 +325,9 @@ class DatePeriod {
|
|
|
327
325
|
//jsDate1.setUTCHours(0, 0, 0);
|
|
328
326
|
//jsDate2.setUTCHours(0, 0, 0);
|
|
329
327
|
}
|
|
330
|
-
|
|
328
|
+
|
|
329
|
+
const daysDiff = (timestamp2-timestamp1)/86400;
|
|
330
|
+
return returnDecimal ? daysDiff : parseInt(Math.round(daysDiff));
|
|
331
331
|
}
|
|
332
332
|
|
|
333
333
|
static getPeriodLabels(data, period, locale = 'fr-FR', timeZone = 'Europe/Paris') {
|
|
@@ -392,23 +392,32 @@ class TimestampUnix {
|
|
|
392
392
|
}
|
|
393
393
|
|
|
394
394
|
static getYear(timestamp, timeZone="Europe/Paris") {
|
|
395
|
-
|
|
395
|
+
//const sqlDate = this.getSqlDate(timestamp, timeZone);
|
|
396
|
+
//return parseInt(sqlDate.substring(0, 4));
|
|
397
|
+
return parseInt(this.parse(timestamp).toLocaleDateString('fr-FR', {year: 'numeric', timeZone: timeZone}));
|
|
396
398
|
}
|
|
397
399
|
static getMonth(timestamp, timeZone="Europe/Paris") {
|
|
398
|
-
|
|
400
|
+
//const sqlDate = this.getSqlDate(timestamp, timeZone);
|
|
401
|
+
//return parseInt(sqlDate.substring(5, 7));
|
|
402
|
+
return parseInt(this.parse(timestamp).toLocaleDateString('fr-FR', {month: 'numeric', timeZone: timeZone}));
|
|
399
403
|
}
|
|
400
404
|
static getDayOfMonth(timestamp, timeZone="Europe/Paris") {
|
|
401
|
-
|
|
405
|
+
//const sqlDate = this.getSqlDate(timestamp, timeZone);
|
|
406
|
+
//return parseInt(sqlDate.substring(8, 10));
|
|
407
|
+
return parseInt(this.parse(timestamp).toLocaleDateString('fr-FR', {day: 'numeric', timeZone: timeZone}));
|
|
402
408
|
}
|
|
403
409
|
|
|
404
410
|
static getHour(timestamp, timeZone="Europe/Paris") {
|
|
405
|
-
|
|
411
|
+
const sqlTime = this.getSqlTime(timestamp, timeZone);
|
|
412
|
+
return parseInt(sqlTime.substring(0, 2));
|
|
406
413
|
}
|
|
407
414
|
static getMinute(timestamp, timeZone="Europe/Paris") {
|
|
408
|
-
|
|
415
|
+
const sqlTime = this.getSqlTime(timestamp, timeZone);
|
|
416
|
+
return parseInt(sqlTime.substring(3, 5));
|
|
409
417
|
}
|
|
410
418
|
static getSecond(timestamp, timeZone="Europe/Paris") {
|
|
411
|
-
|
|
419
|
+
const sqlTime = this.getSqlTime(timestamp, timeZone);
|
|
420
|
+
return parseInt(sqlTime.substring(6, 8));
|
|
412
421
|
}
|
|
413
422
|
|
|
414
423
|
static getSqlDateTime(timestamp, timeZone="Europe/Paris") {
|
|
@@ -556,18 +565,18 @@ class SqlDateTime {
|
|
|
556
565
|
return DateTime.getSqlDateTime(new Date());
|
|
557
566
|
}
|
|
558
567
|
|
|
559
|
-
static getSqlDate(sqlDateTime) {
|
|
568
|
+
static getSqlDate(sqlDateTime, timeZone="UTC") {
|
|
560
569
|
if (sqlDateTime == null) {
|
|
561
570
|
return null;
|
|
562
571
|
}
|
|
563
|
-
return DateTime.getSqlDate(this.parse(sqlDateTime));
|
|
572
|
+
return DateTime.getSqlDate(this.parse(sqlDateTime), timeZone);
|
|
564
573
|
}
|
|
565
574
|
|
|
566
|
-
static getSqlTime(sqlDateTime) {
|
|
575
|
+
static getSqlTime(sqlDateTime, timeZone="UTC") {
|
|
567
576
|
if (sqlDateTime == null) {
|
|
568
577
|
return null;
|
|
569
578
|
}
|
|
570
|
-
return DateTime.getSqlTime(this.parse(sqlDateTime));
|
|
579
|
+
return DateTime.getSqlTime(this.parse(sqlDateTime), timeZone);
|
|
571
580
|
}
|
|
572
581
|
|
|
573
582
|
static parse(sqlDateTime) {
|
package/draw.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
class HexColor {
|
|
2
2
|
static check(hexColor) {
|
|
3
|
-
|
|
3
|
+
const match = hexColor.match(/^[0-9a-fA-F]{6}$/);
|
|
4
|
+
return match ? match.length > 0 : false;
|
|
4
5
|
}
|
|
5
6
|
|
|
6
7
|
static convertToRgb(hexColor) {
|
|
@@ -9,7 +10,7 @@ class HexColor {
|
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
if (hexColor.length === 3) {
|
|
12
|
-
hexColor = hexColor+hexColor;
|
|
13
|
+
hexColor = hexColor[0]+hexColor[0]+hexColor[1]+hexColor[1]+hexColor[2]+hexColor[2];
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
if (!HexColor.check(hexColor)) {
|
package/duration.js
CHANGED
|
@@ -1,199 +1,245 @@
|
|
|
1
1
|
|
|
2
2
|
class Duration {
|
|
3
3
|
|
|
4
|
-
//
|
|
4
|
+
// -------------------------------------------------------------------------
|
|
5
|
+
// Days formatting
|
|
6
|
+
// -------------------------------------------------------------------------
|
|
5
7
|
|
|
6
|
-
static
|
|
8
|
+
static formatDays(days, locale = 'fr-FR') {
|
|
7
9
|
return new Intl.NumberFormat(locale, {
|
|
8
10
|
minimumFractionDigits: 2,
|
|
9
11
|
maximumFractionDigits: 2
|
|
10
|
-
}).format(
|
|
12
|
+
}).format(days);
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
|
|
15
|
+
static formatDaysIfPositive(days) {
|
|
16
|
+
return days < 0 ? '-' : this.formatDays(days);
|
|
14
17
|
}
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
|
|
19
|
+
static formatDaysWithColor(days) {
|
|
20
|
+
return '<span class="text-' + (days < 0 ? 'danger' : 'success') + '">' + this.formatDays(days) + '</span>';
|
|
17
21
|
}
|
|
18
22
|
|
|
19
|
-
//
|
|
23
|
+
// -------------------------------------------------------------------------
|
|
24
|
+
// Seconds — conversion
|
|
25
|
+
// -------------------------------------------------------------------------
|
|
20
26
|
|
|
21
|
-
static
|
|
22
|
-
if (null ===
|
|
27
|
+
static parseTimeInputToSeconds(timeInput) {
|
|
28
|
+
if (null === timeInput || -1 === timeInput.indexOf(':')) {
|
|
23
29
|
return 0;
|
|
24
30
|
}
|
|
25
|
-
let arrayTime =
|
|
26
|
-
const nbHours
|
|
31
|
+
let arrayTime = timeInput.split(':');
|
|
32
|
+
const nbHours = typeof arrayTime[0] != 'undefined' ? parseInt(arrayTime[0]) || 0 : 0;
|
|
27
33
|
const nbMinutes = typeof arrayTime[1] != 'undefined' ? parseInt(arrayTime[1]) || 0 : 0;
|
|
28
34
|
const nbSeconds = typeof arrayTime[2] != 'undefined' ? parseInt(arrayTime[2]) || 0 : 0;
|
|
29
35
|
return nbHours * 3600 + nbMinutes * 60 + nbSeconds;
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
// -------------------------------------------------------------------------
|
|
39
|
+
// Seconds — formatting
|
|
40
|
+
// -------------------------------------------------------------------------
|
|
41
|
+
|
|
42
|
+
static formatSecondsAsTimeInput(seconds) {
|
|
43
|
+
return Duration.formatSecondsAsChrono(Math.abs(seconds), 'input_time');
|
|
34
44
|
}
|
|
35
45
|
|
|
36
|
-
static
|
|
37
|
-
|
|
46
|
+
static formatSecondsAsChrono(seconds, displayMode = 'chrono', withSeconds = true) {
|
|
47
|
+
seconds = Math.round(seconds);
|
|
48
|
+
const absoluteSeconds = Math.abs(seconds);
|
|
49
|
+
|
|
50
|
+
let secs = absoluteSeconds % 60;
|
|
51
|
+
let remainder = (absoluteSeconds % 3600) - secs;
|
|
52
|
+
let minutes = remainder / 60;
|
|
53
|
+
remainder = absoluteSeconds - (absoluteSeconds % 3600);
|
|
54
|
+
let hours = remainder / 3600;
|
|
55
|
+
|
|
56
|
+
hours = hours.toString().length < 2 ? '0' + hours : hours;
|
|
57
|
+
minutes = minutes.toString().length < 2 ? '0' + minutes : minutes;
|
|
38
58
|
|
|
39
|
-
let
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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;
|
|
59
|
+
let result = (seconds < 0 ? '- ' : '') + hours + ':' + minutes;
|
|
60
|
+
if (withSeconds) {
|
|
61
|
+
secs = secs.toString().length < 2 ? '0' + secs : secs;
|
|
62
|
+
result += (displayMode === 'input_time' ? ':' : '.') + secs;
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
52
65
|
}
|
|
53
66
|
|
|
54
|
-
static
|
|
55
|
-
|
|
67
|
+
static formatSecondsAsString(seconds, withSeconds = true, withMinutes = true, withMinuteLabel = true, fullLabel = false, hideHourIfZero = false) {
|
|
68
|
+
seconds = Math.round(seconds);
|
|
56
69
|
|
|
57
|
-
//
|
|
58
|
-
let
|
|
59
|
-
let
|
|
60
|
-
if (!
|
|
61
|
-
|
|
70
|
+
// Hours
|
|
71
|
+
let strHours = '';
|
|
72
|
+
let nbHours = this.totalHours(seconds);
|
|
73
|
+
if (!hideHourIfZero || nbHours > 0) {
|
|
74
|
+
strHours += nbHours;
|
|
62
75
|
if (fullLabel) {
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
strHeure += 'h';
|
|
76
|
+
strHours += ' heure' + (nbHours > 1 ? 's' : '');
|
|
77
|
+
} else {
|
|
78
|
+
strHours += 'h';
|
|
67
79
|
}
|
|
68
80
|
}
|
|
69
|
-
|
|
81
|
+
|
|
70
82
|
// Minutes
|
|
71
|
-
let
|
|
83
|
+
let strMinutes = '';
|
|
72
84
|
if (withMinutes) {
|
|
73
|
-
let nbMinutes = this.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
strMinute += ' minute'+(nbMinutes>1?'s':'');
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
strMinute += 'min';
|
|
83
|
-
}
|
|
85
|
+
let nbMinutes = this.remainingMinutes(seconds);
|
|
86
|
+
strMinutes += ' ';
|
|
87
|
+
if (fullLabel) {
|
|
88
|
+
strMinutes += nbMinutes.toString() + (withMinuteLabel ? ' minute' + (nbMinutes > 1 ? 's' : '') : '');
|
|
89
|
+
} else {
|
|
90
|
+
strMinutes += nbMinutes.toString().padStart(2, '0') + (withMinuteLabel ? 'min' : '');
|
|
84
91
|
}
|
|
85
92
|
}
|
|
86
|
-
|
|
87
|
-
//
|
|
88
|
-
let
|
|
93
|
+
|
|
94
|
+
// Seconds
|
|
95
|
+
let strSeconds = '';
|
|
89
96
|
if (withSeconds) {
|
|
90
|
-
let
|
|
91
|
-
|
|
92
|
-
//strSeconde += sprintf('%02d', nbSecondes);
|
|
93
|
-
strSeconde += nbSecondes.toString().padStart(2, '0');
|
|
97
|
+
let nbSeconds = this.remainingSeconds(seconds);
|
|
98
|
+
strSeconds += ' ';
|
|
94
99
|
if (fullLabel) {
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
strSeconde += 's';
|
|
100
|
+
strSeconds += nbSeconds.toString() + ' seconde' + (nbSeconds > 1 ? 's' : '');
|
|
101
|
+
} else {
|
|
102
|
+
strSeconds += nbSeconds.toString().padStart(2, '0') + 's';
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
|
-
|
|
102
|
-
return (
|
|
105
|
+
|
|
106
|
+
return (strHours + strMinutes + strSeconds).trim();
|
|
103
107
|
}
|
|
104
108
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
let seconds = durationInSeconds % 60;
|
|
109
|
+
// -------------------------------------------------------------------------
|
|
110
|
+
// Seconds — rounding
|
|
111
|
+
// -------------------------------------------------------------------------
|
|
109
112
|
|
|
110
|
-
|
|
111
|
-
let
|
|
112
|
-
let
|
|
113
|
+
static roundSeconds(seconds, precision, roundMode = 'close') {
|
|
114
|
+
let hours = Math.floor(seconds / 3600);
|
|
115
|
+
let minutes = Math.floor((seconds % 3600) / 60);
|
|
116
|
+
let secs = seconds % 60;
|
|
113
117
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
let hoursRounded = hours;
|
|
119
|
+
let minutesRounded = minutes;
|
|
120
|
+
let secondsRounded = secs;
|
|
121
|
+
|
|
122
|
+
if (precision > 0) {
|
|
123
|
+
let minutesRemaining = minutes % precision;
|
|
124
|
+
let minutesRemainingAndSecondsAsFraction = minutesRemaining + secs / 60;
|
|
125
|
+
if (minutesRemainingAndSecondsAsFraction === 0) {
|
|
126
|
+
// already aligned, no rounding needed
|
|
127
|
+
} else {
|
|
128
|
+
let halfPrecision = precision / 2;
|
|
129
|
+
hoursRounded = hours;
|
|
123
130
|
secondsRounded = 0;
|
|
124
|
-
if (roundMode === 'up' || (roundMode === 'close' &&
|
|
125
|
-
//
|
|
126
|
-
if (minutes > (60-
|
|
131
|
+
if (roundMode === 'up' || (roundMode === 'close' && minutesRemainingAndSecondsAsFraction > halfPrecision)) {
|
|
132
|
+
// Round up
|
|
133
|
+
if (minutes > (60 - precision)) {
|
|
127
134
|
minutesRounded = 0;
|
|
128
135
|
hoursRounded++;
|
|
136
|
+
} else {
|
|
137
|
+
minutesRounded = (minutes - minutesRemaining) + precision;
|
|
129
138
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
// Arrondissement au dessous
|
|
136
|
-
minutesRounded = (minutes-minutesRemaining);
|
|
139
|
+
} else {
|
|
140
|
+
// Round down
|
|
141
|
+
minutesRounded = minutes - minutesRemaining;
|
|
137
142
|
}
|
|
138
143
|
}
|
|
139
144
|
}
|
|
140
|
-
|
|
145
|
+
|
|
141
146
|
return hoursRounded * 3600 + minutesRounded * 60 + secondsRounded;
|
|
142
147
|
}
|
|
143
148
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
static getNbMinutesOfDurationInSeconds(durationInSeconds) {
|
|
151
|
-
return Math.floor(durationInSeconds / 60);
|
|
149
|
+
// -------------------------------------------------------------------------
|
|
150
|
+
// Seconds — total extraction
|
|
151
|
+
// -------------------------------------------------------------------------
|
|
152
|
+
|
|
153
|
+
static totalDays(seconds) {
|
|
154
|
+
return Math.floor(seconds / 86400);
|
|
152
155
|
}
|
|
153
156
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return ( remander / 60 );
|
|
157
|
+
static totalHours(seconds) {
|
|
158
|
+
return Math.floor(seconds / 3600);
|
|
157
159
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return (
|
|
160
|
+
|
|
161
|
+
static totalMinutes(seconds) {
|
|
162
|
+
return Math.floor(seconds / 60);
|
|
161
163
|
}
|
|
162
|
-
static getNbMinutesOfDurationInSeconds(durationInSeconds) {
|
|
163
|
-
// return (this.getNbDaysOfDurationInSeconds(durationInSeconds)*24*60)+(this.getNbHoursRemainingOfDurationInSeconds(durationInSeconds)*60)+this.getNbMinutesRemainingOfDurationInSeconds(durationInSeconds);
|
|
164
|
-
return (durationInSeconds - (durationInSeconds % 60)) / 60;
|
|
165
|
-
}*/
|
|
166
164
|
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
// -------------------------------------------------------------------------
|
|
166
|
+
// Seconds — remaining extraction
|
|
167
|
+
// -------------------------------------------------------------------------
|
|
168
|
+
|
|
169
|
+
static remainingHours(seconds) {
|
|
170
|
+
return this.totalHours(seconds % 86400);
|
|
169
171
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
+
|
|
173
|
+
static remainingMinutes(seconds) {
|
|
174
|
+
return this.totalMinutes(seconds % 3600);
|
|
172
175
|
}
|
|
173
|
-
|
|
174
|
-
|
|
176
|
+
|
|
177
|
+
static remainingSeconds(seconds) {
|
|
178
|
+
return seconds % 60;
|
|
175
179
|
}
|
|
176
180
|
|
|
177
|
-
//
|
|
181
|
+
// -------------------------------------------------------------------------
|
|
182
|
+
// Decimal hours (hundredth of an hour)
|
|
183
|
+
// -------------------------------------------------------------------------
|
|
178
184
|
|
|
179
|
-
static
|
|
180
|
-
let hour
|
|
181
|
-
let minutes =
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
let minCentieme = Math.round( (minutes / 60 ) * 100 );
|
|
185
|
-
return hour+(minCentieme/100);
|
|
186
|
-
//return parseFloat(hour+'.'+minCentieme);
|
|
185
|
+
static toDecimalHours(seconds) {
|
|
186
|
+
let hour = Math.floor(seconds / 3600);
|
|
187
|
+
let minutes = Math.floor((seconds % 3600) / 60);
|
|
188
|
+
let centieme = Math.round((minutes / 60) * 100);
|
|
189
|
+
return hour + (centieme / 100);
|
|
187
190
|
}
|
|
188
191
|
|
|
189
|
-
static
|
|
190
|
-
return Math.trunc(
|
|
192
|
+
static getHoursFromDecimal(decimalHours) {
|
|
193
|
+
return Math.trunc(decimalHours);
|
|
191
194
|
}
|
|
192
195
|
|
|
193
|
-
static
|
|
194
|
-
|
|
196
|
+
static getMinutesFromDecimal(decimalHours) {
|
|
197
|
+
const decimal = decimalHours - Math.floor(decimalHours);
|
|
198
|
+
return Math.floor(decimal * 60);
|
|
195
199
|
}
|
|
196
200
|
|
|
201
|
+
// -------------------------------------------------------------------------
|
|
202
|
+
// Deprecated aliases — kept for backwards compatibility
|
|
203
|
+
// -------------------------------------------------------------------------
|
|
204
|
+
|
|
205
|
+
/** @deprecated Use {@link formatDays} instead */
|
|
206
|
+
static formatNbDays(nbDays, locale = 'fr-FR') { return this.formatDays(nbDays, locale); }
|
|
207
|
+
/** @deprecated Use {@link formatDaysIfPositive} instead */
|
|
208
|
+
static formatNbDaysIfPositive(nbDays) { return this.formatDaysIfPositive(nbDays); }
|
|
209
|
+
/** @deprecated Use {@link formatDaysWithColor} instead */
|
|
210
|
+
static formatNbDaysWithColor(nbDays) { return this.formatDaysWithColor(nbDays); }
|
|
211
|
+
|
|
212
|
+
/** @deprecated Use {@link parseTimeInputToSeconds} instead */
|
|
213
|
+
static convertInputTimeValueToDuration(inputTimeValue) { return this.parseTimeInputToSeconds(inputTimeValue); }
|
|
214
|
+
/** @deprecated Use {@link formatSecondsAsTimeInput} instead */
|
|
215
|
+
static convertToDurationAsInputTimeValue(durationInSeconds) { return this.formatSecondsAsTimeInput(durationInSeconds); }
|
|
216
|
+
/** @deprecated Use {@link formatSecondsAsChrono} instead */
|
|
217
|
+
static convertToDurationInHourChronoDisplay(durationInSeconds, displayMode = 'chrono') { return this.formatSecondsAsChrono(durationInSeconds, displayMode); }
|
|
218
|
+
/** @deprecated Use {@link formatSecondsAsString} instead */
|
|
219
|
+
static convertToDurationInHourStringDisplay(durationInSeconds, withSeconds = true, withMinutes = true, withMinuteLabel = true, fullLabel = false, hideHourIfZeroHour = false) { return this.formatSecondsAsString(durationInSeconds, withSeconds, withMinutes, withMinuteLabel, fullLabel, hideHourIfZeroHour); }
|
|
220
|
+
/** @deprecated Use {@link roundSeconds} instead */
|
|
221
|
+
static roundNbSeconds(durationInSeconds, roundPrecision, roundMode = 'close') { return this.roundSeconds(durationInSeconds, roundPrecision, roundMode); }
|
|
222
|
+
|
|
223
|
+
/** @deprecated Use {@link totalDays} instead */
|
|
224
|
+
static getNbDaysOfDurationInSeconds(durationInSeconds) { return this.totalDays(durationInSeconds); }
|
|
225
|
+
/** @deprecated Use {@link totalHours} instead */
|
|
226
|
+
static getNbHoursOfDurationInSeconds(durationInSeconds) { return this.totalHours(durationInSeconds); }
|
|
227
|
+
/** @deprecated Use {@link totalMinutes} instead */
|
|
228
|
+
static getNbMinutesOfDurationInSeconds(durationInSeconds) { return this.totalMinutes(durationInSeconds); }
|
|
229
|
+
|
|
230
|
+
/** @deprecated Use {@link remainingHours} instead */
|
|
231
|
+
static getNbHoursRemainingOfDurationInSeconds(durationInSeconds) { return this.remainingHours(durationInSeconds); }
|
|
232
|
+
/** @deprecated Use {@link remainingMinutes} instead */
|
|
233
|
+
static getNbMinutesRemainingOfDurationInSeconds(durationInSeconds) { return this.remainingMinutes(durationInSeconds); }
|
|
234
|
+
/** @deprecated Use {@link remainingSeconds} instead */
|
|
235
|
+
static getNbSecondsRemainingOfDurationInSeconds(durationInSeconds) { return this.remainingSeconds(durationInSeconds); }
|
|
236
|
+
|
|
237
|
+
/** @deprecated Use {@link toDecimalHours} instead */
|
|
238
|
+
static convertToDurationAsHundredthOfAnHour(durationInSeconds) { return this.toDecimalHours(durationInSeconds); }
|
|
239
|
+
/** @deprecated Use {@link getHoursFromDecimal} instead */
|
|
240
|
+
static getNbHoursOfHundredthOfAnHour(durationAsHundredthOfAnHour) { return this.getHoursFromDecimal(durationAsHundredthOfAnHour); }
|
|
241
|
+
/** @deprecated Use {@link getMinutesFromDecimal} instead */
|
|
242
|
+
static getNbMinutesOfHundredthOfAnHour(durationAsHundredthOfAnHour) { return this.getMinutesFromDecimal(durationAsHundredthOfAnHour); }
|
|
197
243
|
|
|
198
244
|
}
|
|
199
245
|
|
package/event_bus.js
CHANGED
package/file.js
CHANGED
|
@@ -52,7 +52,7 @@ class File {
|
|
|
52
52
|
fileSizeInBytes = fileSizeInBytes / 1024;
|
|
53
53
|
i++;
|
|
54
54
|
}
|
|
55
|
-
while (fileSizeInBytes
|
|
55
|
+
while (fileSizeInBytes >= 1024);
|
|
56
56
|
//var size = Math.max(fileSizeInBytes, 0.1).toFixed(fractionDigits);
|
|
57
57
|
let size = Math.max(fileSizeInBytes, 0.1);
|
|
58
58
|
return (new Intl.NumberFormat(locale, {
|
|
@@ -124,10 +124,25 @@ class Img {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
static setBlobToImg(img, blob) {
|
|
127
|
-
//
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
// Validation de l'élément img
|
|
128
|
+
if (!img || !img.length) {
|
|
129
|
+
console.error('Invalid img element provided to setBlobToImg');
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Validation du blob
|
|
134
|
+
if (!blob || !(blob instanceof Blob) || blob.size === 0) {
|
|
135
|
+
console.error('Invalid blob provided to setBlobToImg', blob);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
try {
|
|
140
|
+
let urlCreator = window.URL || window.webkitURL;
|
|
141
|
+
let objectURL = urlCreator.createObjectURL(blob);
|
|
142
|
+
img.attr('src', objectURL);
|
|
143
|
+
} catch (error) {
|
|
144
|
+
console.error('Error creating object URL from blob:', error);
|
|
145
|
+
}
|
|
131
146
|
}
|
|
132
147
|
|
|
133
148
|
static async getBase64FromUrl(url) {
|
package/form_helper.js
CHANGED
|
@@ -294,7 +294,7 @@ class FormHelper {
|
|
|
294
294
|
if (typeof errors[property] == 'function') {
|
|
295
295
|
continue;
|
|
296
296
|
}
|
|
297
|
-
if (typeof errors[property]['error_description'] !== 'undefined') {
|
|
297
|
+
if (errors[property] != null && typeof errors[property]['error_description'] !== 'undefined') {
|
|
298
298
|
errorLabels.push(errors[property]['error_description']);
|
|
299
299
|
continue;
|
|
300
300
|
}
|
package/google_charts.js
CHANGED
|
@@ -77,6 +77,7 @@ class GoogleCharts {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
let data = null;
|
|
80
|
+
let nbCells = 0;
|
|
80
81
|
if (typeGraph === 'pie_chart') {
|
|
81
82
|
//data = google.visualization.arrayToDataTable(tabDataAbsParam);
|
|
82
83
|
|
|
@@ -101,7 +102,7 @@ class GoogleCharts {
|
|
|
101
102
|
});
|
|
102
103
|
|
|
103
104
|
// Remplissage des données
|
|
104
|
-
|
|
105
|
+
nbCells = 0;
|
|
105
106
|
let numRow = 0;
|
|
106
107
|
$.each(tabDataAbsParam, function(idx, dataAbs) {
|
|
107
108
|
// dataOrd = tabDataOrd[idx];
|