@osimatic/helpers-js 1.0.6 → 1.0.9
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/.idea/helpers-js.iml +8 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/array.js +4 -6
- package/changelog.txt +25 -0
- package/{todos/google_charts.js → google_charts.js} +11 -8
- package/google_recaptcha.js +78 -0
- package/index.js +14 -7
- package/location.js +249 -251
- package/network.js +2 -0
- package/number.js +59 -7
- package/package.json +1 -1
- package/paging.js +21 -20
- package/string.js +85 -50
- package/util.js +0 -8
- package/todos/google_charts_mytime.js +0 -295
- package/todos/google_recaptcha.js +0 -15
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$" />
|
|
5
|
+
<orderEntry type="inheritedJdk" />
|
|
6
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
|
+
</component>
|
|
8
|
+
</module>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/helpers-js.iml" filepath="$PROJECT_DIR$/.idea/helpers-js.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/.idea/vcs.xml
ADDED
package/array.js
CHANGED
|
@@ -42,7 +42,7 @@ Array.prototype.filterUnique = function() {
|
|
|
42
42
|
return this.filter((v, i, a) => a.indexOf(v) === i);
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
function
|
|
45
|
+
Array.getValuesByKeyInArrayOfArrays = function(array, key) {
|
|
46
46
|
let listeValues = [];
|
|
47
47
|
for (let i in array) {
|
|
48
48
|
let subArray = array[i];
|
|
@@ -63,7 +63,7 @@ Object.filter = (obj, predicate) => {
|
|
|
63
63
|
.reduce( (res, key) => (res[key] = obj[key], res), {} );
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
function
|
|
66
|
+
Object.renameKeys = function(obj, keysMap) {
|
|
67
67
|
return Object.keys(obj).reduce(
|
|
68
68
|
(acc, key) => ({
|
|
69
69
|
...acc,
|
|
@@ -71,9 +71,9 @@ function renameKeys(obj, keysMap) {
|
|
|
71
71
|
}),
|
|
72
72
|
{}
|
|
73
73
|
);
|
|
74
|
-
}
|
|
74
|
+
};
|
|
75
75
|
|
|
76
|
-
function
|
|
76
|
+
Object.renameKeysByCallback = function(obj, callback) {
|
|
77
77
|
return Object.keys(obj).reduce(
|
|
78
78
|
(acc, key) => ({
|
|
79
79
|
...acc,
|
|
@@ -82,5 +82,3 @@ function renameKeysByCallback(obj, callback) {
|
|
|
82
82
|
{}
|
|
83
83
|
);
|
|
84
84
|
}
|
|
85
|
-
|
|
86
|
-
module.exports = { getValuesByKeyInArrayOfArrays, renameKeys, renameKeysByCallback };
|
package/changelog.txt
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
1.0.9 :
|
|
3
|
+
copierTexte(str) -> str.copyToClipboard()
|
|
4
|
+
truncateString(str, ...) -> str.truncateString(...)
|
|
5
|
+
|
|
6
|
+
NumberValue.isNumeric(str) -> str.isNumeric()
|
|
7
|
+
NumberValue.format(number, nbDecimal, locale) -> number.format(nbDecimal, locale)
|
|
8
|
+
NumberValue.formatCurrency(montant, currency, nbDecimal, locale) -> montant.formatCurrency(currency, nbDecimal, locale)
|
|
9
|
+
NumberValue.formatPercent(number, nbDecimal, locale) -> number.formatPercent(nbDecimal, locale)
|
|
10
|
+
NumberValue.random(min, max) -> Number.random(min, max)
|
|
11
|
+
NumberValue.padLeft2(n) -> n.padLeft2()
|
|
12
|
+
NumberValue.roundDecimal(nombre, precision) -> nombre.roundDecimal(precision)
|
|
13
|
+
|
|
14
|
+
nombre.formatAsString(locale, minimumFractionDigits) -> nombre.format(nbDecimal, locale)
|
|
15
|
+
montant.formatAsCurrency(locale, currency, nbFractionDigits) -> montant.formatCurrency(currency, nbDecimal, locale)
|
|
16
|
+
number.formatAsPercent(locale, minimumFractionDigits) -> number.formatPercent(nbDecimal, locale)
|
|
17
|
+
|
|
18
|
+
constante COUNTRIES_LIST -> Country.getCountryList()
|
|
19
|
+
activateTab(...) -> Pagination.activateTab(...)
|
|
20
|
+
|
|
21
|
+
renameKeys(...) -> Object.renameKeys(...)
|
|
22
|
+
renameKeysByCallback(...) -> Object.renameKeysByCallback(...)
|
|
23
|
+
getValuesByKeyInArrayOfArrays(...) -> Array.getValuesByKeyInArrayOfArrays(...)
|
|
24
|
+
getValuesByKeyInArrayOfArrays(array, ...) -> array.getValuesByKeyInArrayOfArrays(...)
|
|
25
|
+
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
class GoogleCharts {
|
|
2
|
+
static init(onLoadCallback) {
|
|
3
|
+
// google.load("visualization", "1", {packages:["corechart"]});
|
|
4
|
+
google.charts.load('current', {'packages':['bar','line','corechart']});
|
|
5
|
+
// google.charts.load('current', {packages:['corechart']});
|
|
6
|
+
|
|
7
|
+
if (onLoadCallback !== 'undefined') {
|
|
8
|
+
google.charts.setOnLoadCallback(onLoadCallback);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
1
11
|
|
|
2
|
-
// google.load("visualization", "1", {packages:["corechart"]});
|
|
3
|
-
google.charts.load('current', {'packages':['bar','line','corechart']});
|
|
4
|
-
// google.charts.load('current', {packages:['corechart']});
|
|
5
|
-
|
|
6
|
-
google.charts.setOnLoadCallback(drawAllCharts);
|
|
7
|
-
|
|
8
|
-
class GoogleCharts
|
|
9
|
-
{
|
|
10
12
|
static drawCharts(chartsList, onComplete) {
|
|
11
13
|
// on supprime du tableau la liste des graphiques dont l'id div n'a pas été trouvé (le graphique ne pourra pas être généré)
|
|
12
14
|
chartsList = chartsList.filter(chartData => typeof chartData.div_id != 'undefined' && $('#'+chartData.div_id).length);
|
|
@@ -342,3 +344,4 @@ class GoogleCharts
|
|
|
342
344
|
|
|
343
345
|
}
|
|
344
346
|
|
|
347
|
+
module.exports = { GoogleCharts };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
class GoogleRecaptcha {
|
|
2
|
+
static onLoad() {
|
|
3
|
+
console.log('GoogleRecaptcha.onLoad');
|
|
4
|
+
if (typeof grecaptcha == 'undefined' || typeof grecaptcha.render != 'function') {
|
|
5
|
+
console.log('var grecaptcha undefined');
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (typeof GoogleRecaptcha.googleCaptchaRendersCallback == 'undefined') {
|
|
10
|
+
GoogleRecaptcha.googleCaptchaRendersCallback = [];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
GoogleRecaptcha.googleCaptchaRendersCallback.forEach(callback => callback());
|
|
14
|
+
GoogleRecaptcha.googleCaptchaRendersCallback = [];
|
|
15
|
+
|
|
16
|
+
/*document.querySelectorAll('.grecaptcha').forEach(element => {
|
|
17
|
+
try {
|
|
18
|
+
console.log(element.id);
|
|
19
|
+
//grecaptchaWidgets[element.id] = grecaptcha.render(element.id, googleReCaptchaDatas);
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
console.log('Exception during grecaptcha.render', e);
|
|
23
|
+
}
|
|
24
|
+
});*/
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static addRenderCallback(callback) {
|
|
28
|
+
if (typeof GoogleRecaptcha.googleCaptchaRendersCallback == 'undefined') {
|
|
29
|
+
GoogleRecaptcha.googleCaptchaRendersCallback = [];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
GoogleRecaptcha.googleCaptchaRendersCallback.push(callback);
|
|
33
|
+
console.log('GoogleRecaptcha.addRenderCallback');
|
|
34
|
+
GoogleRecaptcha.onLoad();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static reset(id) {
|
|
38
|
+
if (typeof grecaptcha == 'undefined' || typeof grecaptcha.render != 'function') {
|
|
39
|
+
console.log('var grecaptcha.render undefined');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (typeof GoogleRecaptcha.grecaptchaWidgets == 'undefined') {
|
|
44
|
+
GoogleRecaptcha.grecaptchaWidgets = [];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (typeof GoogleRecaptcha.grecaptchaWidgets[id] == 'undefined') {
|
|
48
|
+
try {
|
|
49
|
+
GoogleRecaptcha.grecaptchaWidgets[id] = grecaptcha.render(id, googleReCaptchaDatas);
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
console.log('Exception during grecaptcha.render', e);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
grecaptcha.reset(GoogleRecaptcha.grecaptchaWidgets[id]);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = { GoogleRecaptcha };
|
|
62
|
+
|
|
63
|
+
/*
|
|
64
|
+
var grecaptchaWidgets = [];
|
|
65
|
+
|
|
66
|
+
function grecaptchaOnload () {
|
|
67
|
+
if (typeof grecaptcha == 'undefined') {
|
|
68
|
+
console.log('var grecaptcha undefined');
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
document.querySelectorAll('.grecaptcha').forEach(element => {
|
|
72
|
+
grecaptchaWidgets[element.id] = grecaptcha.render(element.id, googleReCaptchaDatas);
|
|
73
|
+
});
|
|
74
|
+
//$('.grecaptcha').each(function(idx, el) {
|
|
75
|
+
// grecaptchaWidgets[$(el).attr('id')] = grecaptcha.render($(el).attr('id'), googleReCaptchaDatas);
|
|
76
|
+
//});
|
|
77
|
+
}
|
|
78
|
+
*/
|
package/index.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
//A noter : les réécritures de prototypes définies dans certains fichiers n'ont pas besoin d'être exportés depuis le module en question (exemple Array / Object dans array.js).
|
|
2
2
|
//Il faut uniquement appeler require() (sans récupérer le retour) et ajouter la/les classe(s) concernée(s) dans l'export ci-dessous (l'appel de require() applique l'extension).
|
|
3
3
|
|
|
4
|
+
// rien à exporter (que des extensions d'objet natif)
|
|
5
|
+
require('./string');
|
|
6
|
+
require('./array');
|
|
7
|
+
|
|
8
|
+
// exports d'ojets non natif
|
|
4
9
|
const { HTTPRequest, Cookie, UrlAndQueryString } = require('./network');
|
|
5
10
|
const { IBAN } = require('./bank');
|
|
6
11
|
const { AudioMedia } = require('./media');
|
|
@@ -17,19 +22,21 @@ const { GoogleMap } = require('./google_maps');
|
|
|
17
22
|
const { ImportFromCsv } = require('./import_from_csv');
|
|
18
23
|
const { JwtToken, JwtSession } = require('./jwt');
|
|
19
24
|
const { ListBox } = require('./list_box');
|
|
20
|
-
const {
|
|
25
|
+
const { Country, PostalAddress, Location } = require('./location');
|
|
21
26
|
const { SocialNetwork } = require('./social_network');
|
|
22
|
-
const { getValuesByKeyInArrayOfArrays, renameKeys, renameKeysByCallback } = require('./array');
|
|
23
27
|
const { NumberValue } = require('./number');
|
|
24
|
-
const {
|
|
25
|
-
const { addBookmark, sleep, refresh } = require('./util');
|
|
28
|
+
const { sleep, refresh } = require('./util');
|
|
26
29
|
const { chr, ord, trim, empty } = require('./php.min');
|
|
27
30
|
const { Pagination, activateTab } = require('./paging');
|
|
31
|
+
const { GoogleCharts } = require('./google_charts');
|
|
32
|
+
const { GoogleRecaptcha } = require('./google_recaptcha');
|
|
28
33
|
|
|
29
34
|
module.exports = {
|
|
35
|
+
Array, Object, Number, String,
|
|
30
36
|
HTTPRequest, Cookie, UrlAndQueryString, IBAN, AudioMedia, PersonName, Email, TelephoneNumber, CountDown, DataTable,
|
|
31
37
|
DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, InputPeriod, DetailsSubArray, Duration, File, CSV, Img,
|
|
32
|
-
FlashMessage, FormHelper, GoogleMap, ImportFromCsv, JwtToken, JwtSession, ListBox,
|
|
33
|
-
Location, SocialNetwork,
|
|
34
|
-
|
|
38
|
+
FlashMessage, FormHelper, GoogleMap, ImportFromCsv, JwtToken, JwtSession, ListBox, Country, PostalAddress,
|
|
39
|
+
Location, SocialNetwork, NumberValue, Pagination,
|
|
40
|
+
sleep, refresh, chr, ord, trim, empty,
|
|
41
|
+
GoogleCharts, GoogleRecaptcha
|
|
35
42
|
};
|