@osimatic/helpers-js 1.4.19 → 1.4.21

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.
@@ -77,7 +77,7 @@ class OpenStreetMap {
77
77
  listLocations.forEach(location => this.addMarker(location, icon));
78
78
  }
79
79
 
80
- addMarker(geoJson, options) {
80
+ addMarker(coordinates, options) {
81
81
  let locationCoordinates = coordinates.split(',');
82
82
  let latitude = parseFloat(locationCoordinates[0]);
83
83
  let longitude = parseFloat(locationCoordinates[1]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.4.19",
3
+ "version": "1.4.21",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/string.js CHANGED
@@ -136,6 +136,21 @@ String.prototype.isNumeric = String.prototype.isNumeric || function() {
136
136
  return IsNumber;
137
137
  }
138
138
 
139
+ String.prototype.isBase64 = String.prototype.isBase64 || function() {
140
+ // Vérifie les caractères autorisés par le base64
141
+ if (!/^[A-Za-z0-9+/=]+$/.test(this)) return false;
142
+
143
+ // Longueur multiple de 4
144
+ if (this.length % 4 !== 0) return false;
145
+
146
+ try {
147
+ atob(this); // Tentative de décodage
148
+ return true; // OK → c’est du base64
149
+ } catch (e) {
150
+ return false; // Erreur → pas du base64
151
+ }
152
+ }
153
+
139
154
  // s'utilise : "ma chaine {0} de caracteres"
140
155
  if (!String.format) {
141
156
  String.format = function(format) {
@@ -144,6 +159,20 @@ if (!String.format) {
144
159
  };
145
160
  }
146
161
 
162
+ if (!JSON.encodeJsonForDataAttr) {
163
+ JSON.encodeJsonForDataAttr = function(obj) {
164
+ const json = JSON.stringify(obj);
165
+ return btoa(encodeURIComponent(json));
166
+ }
167
+ }
168
+
169
+ if (!JSON.decodeJsonFromDataAttr) {
170
+ JSON.decodeJsonFromDataAttr = function(str) {
171
+ const json = decodeURIComponent(atob(str));
172
+ return JSON.parse(json);
173
+ }
174
+ }
175
+
147
176
  /*
148
177
  function selectionnerContenuNode(node) {
149
178
  if (window.getSelection) {