@osimatic/helpers-js 1.1.77 → 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/CHANGELOG +76 -76
- package/array.js +93 -90
- package/bank.js +20 -20
- package/contact_details.js +194 -194
- package/count_down.js +102 -102
- package/data_table.js +416 -416
- package/date_time.js +592 -592
- package/details_sub_array.js +123 -123
- package/draw.js +52 -52
- package/duration.js +198 -198
- package/event_bus.js +38 -38
- package/file.js +146 -146
- package/flash_message.js +35 -35
- package/form_date.js +610 -610
- package/form_helper.js +410 -410
- package/google_charts.js +347 -347
- package/google_maps.js +169 -169
- package/google_recaptcha.js +87 -87
- package/http_client.js +469 -469
- package/import_from_csv.js +273 -273
- package/index.js +55 -55
- package/jwt.js +288 -288
- package/list_box.js +112 -112
- package/location.js +431 -431
- package/media.js +218 -218
- package/multiple_action_in_table.js +336 -336
- package/network.js +756 -756
- package/number.js +99 -99
- package/open_street_map.js +142 -142
- package/package.json +15 -15
- package/paging.js +278 -278
- package/php.min.js +5 -5
- package/revolut.js +22 -22
- package/select_all.js +121 -121
- package/shopping_cart.js +31 -31
- package/social_network.js +109 -109
- package/sortable_list.js +37 -37
- package/string.js +162 -162
- package/util.js +16 -16
- package/visitor.js +77 -77
- package/web_rtc.js +114 -114
- package/web_socket.js +97 -97
package/string.js
CHANGED
|
@@ -1,163 +1,163 @@
|
|
|
1
|
-
|
|
2
|
-
String.prototype.copyToClipboard = String.prototype.copyToClipboard || function() {
|
|
3
|
-
if (window.clipboardData && clipboardData.setData) {
|
|
4
|
-
window.clipboardData.setData('Text', this);
|
|
5
|
-
}
|
|
6
|
-
else if (document.body.createTextRange) {
|
|
7
|
-
let textRange = document.body.createTextRange();
|
|
8
|
-
textRange.moveToElementText(this);
|
|
9
|
-
textRange.execCommand("Copy");
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
try {
|
|
13
|
-
// On test si la configuration permet l'accès au presse-papier.
|
|
14
|
-
netscape.security.PrivilegeManager
|
|
15
|
-
.enablePrivilege("UniversalXPConnect");
|
|
16
|
-
}
|
|
17
|
-
catch (e) {
|
|
18
|
-
alert("Impossible d'accéder au presse-papier.");
|
|
19
|
-
}
|
|
20
|
-
// Initialisation du composant fournit par Mozilla.
|
|
21
|
-
let gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper);
|
|
22
|
-
// Copie du texte dans le presse papier.
|
|
23
|
-
gClipboardHelper.copyString(this);
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
String.prototype.reverseString = String.prototype.reverseString || function() {
|
|
29
|
-
return this.split('').reverse().join('');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
String.prototype.truncateOnWord = String.prototype.truncateOnWord || function(limit, fromLeft) {
|
|
33
|
-
if (fromLeft) {
|
|
34
|
-
return this.reverseString(this.truncateOnWord(this.reverseString(), limit));
|
|
35
|
-
}
|
|
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
|
-
|
|
40
|
-
function filter(arr, fn) {
|
|
41
|
-
let result = [];
|
|
42
|
-
for (let i = 0, len = arr.length; i < len; i++) {
|
|
43
|
-
let el = arr[i];
|
|
44
|
-
if (i in arr && fn(el, i)) {
|
|
45
|
-
result.push(el);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return result;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return filter(words, function(word) {
|
|
52
|
-
count += word.length;
|
|
53
|
-
return count <= limit;
|
|
54
|
-
}).join('');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
String.prototype.truncateString = String.prototype.truncateString || function(length, from, ellipsis='…', split=false) {
|
|
58
|
-
let str1, str2, len1, len2;
|
|
59
|
-
if (this.length <= length) {
|
|
60
|
-
return this.toString();
|
|
61
|
-
}
|
|
62
|
-
switch(from) {
|
|
63
|
-
case 'left':
|
|
64
|
-
str2 = split ? this.truncateOnWord(length, true) : this.slice(this.length - length);
|
|
65
|
-
return ellipsis + str2;
|
|
66
|
-
case 'middle':
|
|
67
|
-
len1 = Math.ceil(length / 2);
|
|
68
|
-
len2 = Math.floor(length / 2);
|
|
69
|
-
str1 = split ? this.truncateOnWord(len1) : this.slice(0, len1);
|
|
70
|
-
str2 = split ? this.truncateOnWord(len2, true) : this.slice(this.length - len2);
|
|
71
|
-
return str1 + ellipsis + str2;
|
|
72
|
-
default:
|
|
73
|
-
str1 = split ? this.truncateOnWord(length) : this.slice(0, length);
|
|
74
|
-
return str1 + ellipsis;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
String.prototype.htmlentities = String.prototype.htmlentities || function() {
|
|
79
|
-
return this.replace(/[\u00A0-\u9999<>\&]/gim, (i) => '&#'+i.charCodeAt(0)+';');
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
String.prototype.escapeHtml = String.prototype.escapeHtml || function() {
|
|
83
|
-
let entityMap = {
|
|
84
|
-
"&": "&",
|
|
85
|
-
"<": "<",
|
|
86
|
-
">": ">",
|
|
87
|
-
'"': '"',
|
|
88
|
-
"'": ''',
|
|
89
|
-
"/": '/'
|
|
90
|
-
};
|
|
91
|
-
return this.replace(/[&<>"'\/]/g, (s) => entityMap[s]);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
String.prototype.normalizeBreaks = String.prototype.normalizeBreaks || function(breaktype) {
|
|
95
|
-
// 20/01/2022 : modifié car ne fonctionnait pas pour les string en provenance de textarea, enregistrée en bd puis réaffiché depuis bd
|
|
96
|
-
//return this.replace(/$/mg, breaktype).replace(new RegExp('/'+breaktype.escapeRegExp()+'$/'), '');
|
|
97
|
-
return this.replace(/(?:\r\n|\r|\n)/g, breaktype);
|
|
98
|
-
//return this.replace('/(\r\n|\r|\n)/ms', breaktype);
|
|
99
|
-
//return this.replace('/(?:\r\n|\r|\n)/g', breaktype);
|
|
100
|
-
//console.log(breaktype);
|
|
101
|
-
//return this.replace(new RegExp('\r?\n','g'), breaktype);
|
|
102
|
-
};
|
|
103
|
-
String.prototype.escapeRegExp = String.prototype.escapeRegExp || function() {
|
|
104
|
-
return this.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
105
|
-
};
|
|
106
|
-
String.prototype.format = String.prototype.format || function() {
|
|
107
|
-
let args = arguments;
|
|
108
|
-
return this.replace(/{(\d+)}/g, (match, number) => (typeof args[number] != 'undefined' ? args[number] : match));
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
String.prototype.ucwords = String.prototype.ucwords || function() {
|
|
112
|
-
return this.toLowerCase().replace(/(^([a-zA-Z\p{M}]))|([ -][a-zA-Z\p{M}])/g, ($1) => $1.toUpperCase());
|
|
113
|
-
};
|
|
114
|
-
String.prototype.capitalize = String.prototype.capitalize || function() {
|
|
115
|
-
return this.charAt(0).toUpperCase() + this.slice(1);
|
|
116
|
-
}
|
|
117
|
-
String.prototype.acronym = String.prototype.acronym || function() {
|
|
118
|
-
return this.split(' ').map(word => word.charAt(0)).join('');
|
|
119
|
-
//return this.match(/\b(\w)/g).join('');
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
String.prototype.encodeForHtmlDataAttribute = String.prototype.encodeForHtmlDataAttribute || function() {
|
|
123
|
-
return this.replace(/\"/g, "'");
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
String.prototype.isNumeric = String.prototype.isNumeric || function() {
|
|
127
|
-
let ValidChars = "0123456789.";
|
|
128
|
-
let IsNumber = true;
|
|
129
|
-
let Char;
|
|
130
|
-
for (let i = 0; i < this.length && IsNumber === true; i++){
|
|
131
|
-
Char = this.charAt(i);
|
|
132
|
-
if (ValidChars.indexOf(Char) === -1) {
|
|
133
|
-
IsNumber = false;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return IsNumber;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// s'utilise : "ma chaine {0} de caracteres"
|
|
140
|
-
if (!String.format) {
|
|
141
|
-
String.format = function(format) {
|
|
142
|
-
let args = Array.prototype.slice.call(arguments, 1);
|
|
143
|
-
return format.replace(/{(\d+)}/g, (match, number) => (typeof args[number] != 'undefined' ? args[number] : match));
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/*
|
|
148
|
-
function selectionnerContenuNode(node) {
|
|
149
|
-
if (window.getSelection) {
|
|
150
|
-
var selection = window.getSelection();
|
|
151
|
-
var intervalle = document.createRange();
|
|
152
|
-
intervalle.selectNodeContents(node);
|
|
153
|
-
selection.removeAllRanges();
|
|
154
|
-
selection.addRange(intervalle);
|
|
155
|
-
}
|
|
156
|
-
else if (document.body.createTextRange) {
|
|
157
|
-
var intervalle = document.body.createTextRange();
|
|
158
|
-
intervalle.moveToElementText(node);
|
|
159
|
-
intervalle.select();
|
|
160
|
-
}
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
1
|
+
|
|
2
|
+
String.prototype.copyToClipboard = String.prototype.copyToClipboard || function() {
|
|
3
|
+
if (window.clipboardData && clipboardData.setData) {
|
|
4
|
+
window.clipboardData.setData('Text', this);
|
|
5
|
+
}
|
|
6
|
+
else if (document.body.createTextRange) {
|
|
7
|
+
let textRange = document.body.createTextRange();
|
|
8
|
+
textRange.moveToElementText(this);
|
|
9
|
+
textRange.execCommand("Copy");
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
try {
|
|
13
|
+
// On test si la configuration permet l'accès au presse-papier.
|
|
14
|
+
netscape.security.PrivilegeManager
|
|
15
|
+
.enablePrivilege("UniversalXPConnect");
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
alert("Impossible d'accéder au presse-papier.");
|
|
19
|
+
}
|
|
20
|
+
// Initialisation du composant fournit par Mozilla.
|
|
21
|
+
let gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper);
|
|
22
|
+
// Copie du texte dans le presse papier.
|
|
23
|
+
gClipboardHelper.copyString(this);
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
String.prototype.reverseString = String.prototype.reverseString || function() {
|
|
29
|
+
return this.split('').reverse().join('');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
String.prototype.truncateOnWord = String.prototype.truncateOnWord || function(limit, fromLeft) {
|
|
33
|
+
if (fromLeft) {
|
|
34
|
+
return this.reverseString(this.truncateOnWord(this.reverseString(), limit));
|
|
35
|
+
}
|
|
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
|
+
|
|
40
|
+
function filter(arr, fn) {
|
|
41
|
+
let result = [];
|
|
42
|
+
for (let i = 0, len = arr.length; i < len; i++) {
|
|
43
|
+
let el = arr[i];
|
|
44
|
+
if (i in arr && fn(el, i)) {
|
|
45
|
+
result.push(el);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return filter(words, function(word) {
|
|
52
|
+
count += word.length;
|
|
53
|
+
return count <= limit;
|
|
54
|
+
}).join('');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
String.prototype.truncateString = String.prototype.truncateString || function(length, from, ellipsis='…', split=false) {
|
|
58
|
+
let str1, str2, len1, len2;
|
|
59
|
+
if (this.length <= length) {
|
|
60
|
+
return this.toString();
|
|
61
|
+
}
|
|
62
|
+
switch(from) {
|
|
63
|
+
case 'left':
|
|
64
|
+
str2 = split ? this.truncateOnWord(length, true) : this.slice(this.length - length);
|
|
65
|
+
return ellipsis + str2;
|
|
66
|
+
case 'middle':
|
|
67
|
+
len1 = Math.ceil(length / 2);
|
|
68
|
+
len2 = Math.floor(length / 2);
|
|
69
|
+
str1 = split ? this.truncateOnWord(len1) : this.slice(0, len1);
|
|
70
|
+
str2 = split ? this.truncateOnWord(len2, true) : this.slice(this.length - len2);
|
|
71
|
+
return str1 + ellipsis + str2;
|
|
72
|
+
default:
|
|
73
|
+
str1 = split ? this.truncateOnWord(length) : this.slice(0, length);
|
|
74
|
+
return str1 + ellipsis;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
String.prototype.htmlentities = String.prototype.htmlentities || function() {
|
|
79
|
+
return this.replace(/[\u00A0-\u9999<>\&]/gim, (i) => '&#'+i.charCodeAt(0)+';');
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
String.prototype.escapeHtml = String.prototype.escapeHtml || function() {
|
|
83
|
+
let entityMap = {
|
|
84
|
+
"&": "&",
|
|
85
|
+
"<": "<",
|
|
86
|
+
">": ">",
|
|
87
|
+
'"': '"',
|
|
88
|
+
"'": ''',
|
|
89
|
+
"/": '/'
|
|
90
|
+
};
|
|
91
|
+
return this.replace(/[&<>"'\/]/g, (s) => entityMap[s]);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
String.prototype.normalizeBreaks = String.prototype.normalizeBreaks || function(breaktype) {
|
|
95
|
+
// 20/01/2022 : modifié car ne fonctionnait pas pour les string en provenance de textarea, enregistrée en bd puis réaffiché depuis bd
|
|
96
|
+
//return this.replace(/$/mg, breaktype).replace(new RegExp('/'+breaktype.escapeRegExp()+'$/'), '');
|
|
97
|
+
return this.replace(/(?:\r\n|\r|\n)/g, breaktype);
|
|
98
|
+
//return this.replace('/(\r\n|\r|\n)/ms', breaktype);
|
|
99
|
+
//return this.replace('/(?:\r\n|\r|\n)/g', breaktype);
|
|
100
|
+
//console.log(breaktype);
|
|
101
|
+
//return this.replace(new RegExp('\r?\n','g'), breaktype);
|
|
102
|
+
};
|
|
103
|
+
String.prototype.escapeRegExp = String.prototype.escapeRegExp || function() {
|
|
104
|
+
return this.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
105
|
+
};
|
|
106
|
+
String.prototype.format = String.prototype.format || function() {
|
|
107
|
+
let args = arguments;
|
|
108
|
+
return this.replace(/{(\d+)}/g, (match, number) => (typeof args[number] != 'undefined' ? args[number] : match));
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
String.prototype.ucwords = String.prototype.ucwords || function() {
|
|
112
|
+
return this.toLowerCase().replace(/(^([a-zA-Z\p{M}]))|([ -][a-zA-Z\p{M}])/g, ($1) => $1.toUpperCase());
|
|
113
|
+
};
|
|
114
|
+
String.prototype.capitalize = String.prototype.capitalize || function() {
|
|
115
|
+
return this.charAt(0).toUpperCase() + this.slice(1);
|
|
116
|
+
}
|
|
117
|
+
String.prototype.acronym = String.prototype.acronym || function() {
|
|
118
|
+
return this.split(' ').map(word => word.charAt(0)).join('');
|
|
119
|
+
//return this.match(/\b(\w)/g).join('');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
String.prototype.encodeForHtmlDataAttribute = String.prototype.encodeForHtmlDataAttribute || function() {
|
|
123
|
+
return this.replace(/\"/g, "'");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
String.prototype.isNumeric = String.prototype.isNumeric || function() {
|
|
127
|
+
let ValidChars = "0123456789.";
|
|
128
|
+
let IsNumber = true;
|
|
129
|
+
let Char;
|
|
130
|
+
for (let i = 0; i < this.length && IsNumber === true; i++){
|
|
131
|
+
Char = this.charAt(i);
|
|
132
|
+
if (ValidChars.indexOf(Char) === -1) {
|
|
133
|
+
IsNumber = false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return IsNumber;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// s'utilise : "ma chaine {0} de caracteres"
|
|
140
|
+
if (!String.format) {
|
|
141
|
+
String.format = function(format) {
|
|
142
|
+
let args = Array.prototype.slice.call(arguments, 1);
|
|
143
|
+
return format.replace(/{(\d+)}/g, (match, number) => (typeof args[number] != 'undefined' ? args[number] : match));
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/*
|
|
148
|
+
function selectionnerContenuNode(node) {
|
|
149
|
+
if (window.getSelection) {
|
|
150
|
+
var selection = window.getSelection();
|
|
151
|
+
var intervalle = document.createRange();
|
|
152
|
+
intervalle.selectNodeContents(node);
|
|
153
|
+
selection.removeAllRanges();
|
|
154
|
+
selection.addRange(intervalle);
|
|
155
|
+
}
|
|
156
|
+
else if (document.body.createTextRange) {
|
|
157
|
+
var intervalle = document.body.createTextRange();
|
|
158
|
+
intervalle.moveToElementText(node);
|
|
159
|
+
intervalle.select();
|
|
160
|
+
}
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
163
|
*/
|
package/util.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
function sleep(milliseconds) {
|
|
3
|
-
var start = new Date().getTime();
|
|
4
|
-
for (var i = 0; i < 1e7; i++) {
|
|
5
|
-
if ((new Date().getTime() - start) > milliseconds){
|
|
6
|
-
break;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function refresh() {
|
|
12
|
-
// console.log('Refresh page');
|
|
13
|
-
// history.go(0);
|
|
14
|
-
window.location.reload(true);
|
|
15
|
-
}
|
|
16
|
-
|
|
1
|
+
|
|
2
|
+
function sleep(milliseconds) {
|
|
3
|
+
var start = new Date().getTime();
|
|
4
|
+
for (var i = 0; i < 1e7; i++) {
|
|
5
|
+
if ((new Date().getTime() - start) > milliseconds){
|
|
6
|
+
break;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function refresh() {
|
|
12
|
+
// console.log('Refresh page');
|
|
13
|
+
// history.go(0);
|
|
14
|
+
window.location.reload(true);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
17
|
module.exports = { sleep, refresh };
|
package/visitor.js
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
class Browser {
|
|
2
|
-
static isOpera() {
|
|
3
|
-
return (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
|
|
4
|
-
}
|
|
5
|
-
static isFirefox() {
|
|
6
|
-
return typeof InstallTrigger !== 'undefined';
|
|
7
|
-
}
|
|
8
|
-
static isSafari() {
|
|
9
|
-
return Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
|
|
10
|
-
}
|
|
11
|
-
static isChrome() {
|
|
12
|
-
return !!window.chrome && !!window.chrome.webstore;
|
|
13
|
-
}
|
|
14
|
-
static isIE() {
|
|
15
|
-
//return window.navigator.userAgent.indexOf("MSIE ") > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./);
|
|
16
|
-
return /*@cc_on!@*/false || !!document.documentMode;
|
|
17
|
-
}
|
|
18
|
-
static isEdge() {
|
|
19
|
-
return !isIE && !!window.StyleMedia;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
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
|
-
|
|
1
|
+
class Browser {
|
|
2
|
+
static isOpera() {
|
|
3
|
+
return (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
|
|
4
|
+
}
|
|
5
|
+
static isFirefox() {
|
|
6
|
+
return typeof InstallTrigger !== 'undefined';
|
|
7
|
+
}
|
|
8
|
+
static isSafari() {
|
|
9
|
+
return Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
|
|
10
|
+
}
|
|
11
|
+
static isChrome() {
|
|
12
|
+
return !!window.chrome && !!window.chrome.webstore;
|
|
13
|
+
}
|
|
14
|
+
static isIE() {
|
|
15
|
+
//return window.navigator.userAgent.indexOf("MSIE ") > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./);
|
|
16
|
+
return /*@cc_on!@*/false || !!document.documentMode;
|
|
17
|
+
}
|
|
18
|
+
static isEdge() {
|
|
19
|
+
return !isIE && !!window.StyleMedia;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
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
78
|
module.exports = { Browser, UserAgent };
|