@osimatic/helpers-js 1.0.710 → 1.1.1

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/number.js CHANGED
@@ -22,7 +22,7 @@ if (!Number.format) {
22
22
  * @param integer x: length of sections
23
23
  */
24
24
  Number.prototype.formatForDisplay = Number.prototype.formatForDisplay || function(n, s, c, x) {
25
- var re = '\\d(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\D' : '$') + ')',
25
+ let re = '\\d(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\D' : '$') + ')',
26
26
  num = this.toFixed(Math.max(0, ~~n));
27
27
  return (c ? num.replace('.', c) : num).replace(new RegExp(re, 'g'), '$&' + (s || ','));
28
28
  };
@@ -81,7 +81,7 @@ class OpenStreetMap {
81
81
 
82
82
  //marker.on('click', () => {
83
83
  marker.on('popupopen', () => {
84
- console.log('popupopen');
84
+ //console.log('popupopen');
85
85
  if (typeof options['on_click'] == 'function') {
86
86
  options['on_click']();
87
87
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.0.710",
4
- "main": "index.js",
3
+ "version": "1.1.1",
4
+ "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
7
7
  },
package/string.js CHANGED
@@ -4,7 +4,7 @@ String.prototype.copyToClipboard = String.prototype.copyToClipboard || function(
4
4
  window.clipboardData.setData('Text', this);
5
5
  }
6
6
  else if (document.body.createTextRange) {
7
- var textRange = document.body.createTextRange();
7
+ let textRange = document.body.createTextRange();
8
8
  textRange.moveToElementText(this);
9
9
  textRange.execCommand("Copy");
10
10
  }
@@ -18,7 +18,7 @@ String.prototype.copyToClipboard = String.prototype.copyToClipboard || function(
18
18
  alert("Impossible d'accéder au presse-papier.");
19
19
  }
20
20
  // Initialisation du composant fournit par Mozilla.
21
- var gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper);
21
+ let gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper);
22
22
  // Copie du texte dans le presse papier.
23
23
  gClipboardHelper.copyString(this);
24
24
  }
@@ -33,14 +33,14 @@ String.prototype.truncateOnWord = String.prototype.truncateOnWord || function(li
33
33
  if (fromLeft) {
34
34
  return this.reverseString(this.truncateOnWord(this.reverseString(), limit));
35
35
  }
36
- var TRIM_CHARS = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u2028\u2029\u3000\uFEFF';
37
- var words = this.split(RegExp('(?=['+TRIM_CHARS+'])'));
38
- var count = 0;
36
+ let TRIM_CHARS = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u2028\u2029\u3000\uFEFF';
37
+ let words = this.split(RegExp('(?=['+TRIM_CHARS+'])'));
38
+ let count = 0;
39
39
 
40
40
  function filter(arr, fn) {
41
- var result = [];
42
- for (var i = 0, len = arr.length; i < len; i++) {
43
- var el = arr[i];
41
+ let result = [];
42
+ for (let i = 0, len = arr.length; i < len; i++) {
43
+ let el = arr[i];
44
44
  if (i in arr && fn(el, i)) {
45
45
  result.push(el);
46
46
  }
@@ -105,7 +105,7 @@ String.prototype.escapeRegExp = String.prototype.escapeRegExp || function() {
105
105
  return this.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
106
106
  };
107
107
  String.prototype.format = String.prototype.format || function() {
108
- var args = arguments;
108
+ let args = arguments;
109
109
  return this.replace(/{(\d+)}/g, (match, number) => (typeof args[number] != 'undefined' ? args[number] : match));
110
110
  };
111
111
 
@@ -136,7 +136,7 @@ String.prototype.isNumeric = String.prototype.isNumeric || function() {
136
136
  // s'utilise : "ma chaine {0} de caracteres"
137
137
  if (!String.format) {
138
138
  String.format = function(format) {
139
- var args = Array.prototype.slice.call(arguments, 1);
139
+ let args = Array.prototype.slice.call(arguments, 1);
140
140
  return format.replace(/{(\d+)}/g, (match, number) => (typeof args[number] != 'undefined' ? args[number] : match));
141
141
  };
142
142
  }
package/visitor.js CHANGED
@@ -12,6 +12,7 @@ class Browser {
12
12
  return !!window.chrome && !!window.chrome.webstore;
13
13
  }
14
14
  static isIE() {
15
+ //return window.navigator.userAgent.indexOf("MSIE ") > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./);
15
16
  return /*@cc_on!@*/false || !!document.documentMode;
16
17
  }
17
18
  static isEdge() {
@@ -19,4 +20,59 @@ class Browser {
19
20
  }
20
21
  }
21
22
 
22
- module.exports = { Browser };
23
+ class UserAgent {
24
+ static getOsDisplay(osName) {
25
+ let str = '';
26
+ if (osName === 'Windows') {
27
+ str += '<i class="fab fa-windows"></i>';
28
+ }
29
+ if (osName === 'Linux') {
30
+ str += '<i class="fab fa-linux"></i>';
31
+ }
32
+ if (osName === 'macOS' || osName === 'iOS') {
33
+ str += '<i class="fab fa-apple"></i>';
34
+ }
35
+ if (osName === 'Android') {
36
+ str += '<i class="fab fa-android"></i>';
37
+ }
38
+ str += ' '+osName;
39
+ return str.trim();
40
+ }
41
+
42
+ static getBrowserDisplay(browserName) {
43
+ let str = '';
44
+ if (browserName === 'Chrome') {
45
+ str += '<i class="fab fa-chrome"></i>';
46
+ }
47
+ if (browserName === 'Firefox') {
48
+ str += '<i class="fab fa-firefox"></i>';
49
+ }
50
+ if (browserName === 'Edge') {
51
+ str += '<i class="fab fa-edge"></i>';
52
+ }
53
+ if (browserName === 'Safari') {
54
+ str += '<i class="fab fa-safari"></i>';
55
+ }
56
+ if (browserName === 'Opera') {
57
+ str += '<i class="fab fa-opera"></i>';
58
+ }
59
+ str += ' '+browserName;
60
+ return str.trim();
61
+ }
62
+
63
+ static getDeviceDisplay(device) {
64
+ let str = '';
65
+ if (device['type'] === 'desktop') {
66
+ str += '<i class="fas fa-desktop"></i> Ordinateur';
67
+ }
68
+ else {
69
+ if (device['is_mobile']) {
70
+ str += '<i class="fas fa-mobile-alt"></i> '+(null == device['manufacturer'] && null == device['model'] ? 'Mobile' : '');
71
+ }
72
+ str += device['manufacturer']+' '+device['model'];
73
+ }
74
+ return str.trim();
75
+ }
76
+ }
77
+
78
+ module.exports = { Browser, UserAgent };