@osimatic/helpers-js 1.1.76 → 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/array.js CHANGED
@@ -42,6 +42,9 @@ Array.prototype.filterUnique = function() {
42
42
  return this.filter((v, i, a) => a.indexOf(v) === i);
43
43
  };
44
44
 
45
+ Array.generate = ({from = 0, to, step = 1, length = Math.ceil((to - from) / step)}) =>
46
+ Array.from({length}, (_, i) => from + i * step);
47
+
45
48
  Array.getValuesByKeyInArrayOfArrays = function(array, key) {
46
49
  let listeValues = [];
47
50
  for (let i in array) {
@@ -1,4 +1,8 @@
1
1
  class GoogleRecaptcha {
2
+ static setConfig(config) {
3
+ this.config = config;
4
+ }
5
+
2
6
  static onLoad() {
3
7
  console.log('GoogleRecaptcha.onLoad');
4
8
  if (typeof grecaptcha == 'undefined' || typeof grecaptcha.render != 'function') {
@@ -24,14 +28,10 @@ class GoogleRecaptcha {
24
28
  });*/
25
29
  }
26
30
 
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();
31
+ static render(id) {
32
+ GoogleRecaptcha.addRenderCallback(() => {
33
+ GoogleRecaptcha.reset(id);
34
+ });
35
35
  }
36
36
 
37
37
  static reset(id) {
@@ -46,7 +46,7 @@ class GoogleRecaptcha {
46
46
 
47
47
  if (typeof GoogleRecaptcha.grecaptchaWidgets[id] == 'undefined') {
48
48
  try {
49
- GoogleRecaptcha.grecaptchaWidgets[id] = grecaptcha.render(id, googleReCaptchaDatas);
49
+ GoogleRecaptcha.grecaptchaWidgets[id] = grecaptcha.render(id, this.config);
50
50
  }
51
51
  catch (e) {
52
52
  console.error('Exception during grecaptcha.render', e);
@@ -56,6 +56,16 @@ class GoogleRecaptcha {
56
56
  grecaptcha.reset(GoogleRecaptcha.grecaptchaWidgets[id]);
57
57
  }
58
58
  }
59
+
60
+ static addRenderCallback(callback) {
61
+ if (typeof GoogleRecaptcha.googleCaptchaRendersCallback == 'undefined') {
62
+ GoogleRecaptcha.googleCaptchaRendersCallback = [];
63
+ }
64
+
65
+ GoogleRecaptcha.googleCaptchaRendersCallback.push(callback);
66
+ console.log('GoogleRecaptcha.addRenderCallback');
67
+ GoogleRecaptcha.onLoad();
68
+ }
59
69
  }
60
70
 
61
71
  module.exports = { GoogleRecaptcha };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.1.76",
3
+ "version": "1.1.78",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"