@osimatic/helpers-js 1.0.10 → 1.0.11
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.txt +1 -1
- package/duration.js +32 -28
- package/index.js +2 -2
- package/package.json +1 -1
- package/paging.js +3 -1
package/changelog.txt
CHANGED
|
@@ -16,7 +16,7 @@ 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(...)
|
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/index.js
CHANGED
|
@@ -21,7 +21,7 @@ const { chr, ord, trim, empty } = require('./php.min');
|
|
|
21
21
|
|
|
22
22
|
// exports plugins "maison"
|
|
23
23
|
const { DataTable } = require('./data_table');
|
|
24
|
-
const { Pagination,
|
|
24
|
+
const { Pagination, Navigation } = require('./paging');
|
|
25
25
|
const { FlashMessage } = require('./flash_message');
|
|
26
26
|
const { CountDown } = require('./count_down');
|
|
27
27
|
const { DetailsSubArray } = require('./details_sub_array');
|
|
@@ -41,7 +41,7 @@ const { NumberValue } = require('./number');
|
|
|
41
41
|
module.exports = {
|
|
42
42
|
Array, Object, Number, String,
|
|
43
43
|
HTTPRequest, Cookie, UrlAndQueryString, IBAN, AudioMedia, PersonName, Email, TelephoneNumber, DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, InputPeriod, Duration, File, CSV, Img, FormHelper, Country, PostalAddress, Location, SocialNetwork, NumberValue,
|
|
44
|
-
DataTable, Pagination, FlashMessage, CountDown, DetailsSubArray, ImportFromCsv, JwtToken, JwtSession, ListBox,
|
|
44
|
+
DataTable, Pagination, Navigation, FlashMessage, CountDown, DetailsSubArray, ImportFromCsv, JwtToken, JwtSession, ListBox,
|
|
45
45
|
sleep, refresh, chr, ord, trim, empty,
|
|
46
46
|
GoogleCharts, GoogleRecaptcha, GoogleMap, OpenStreetMap
|
|
47
47
|
};
|
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
|
/*
|