@osimatic/helpers-js 1.0.30 → 1.0.31
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/flash_message.js +0 -1
- package/location.js +21 -4
- package/media.js +43 -0
- package/network.js +8 -6
- package/package.json +1 -1
package/flash_message.js
CHANGED
|
@@ -33,7 +33,6 @@ class FlashMessage {
|
|
|
33
33
|
console.log('request failure. Status: ', status, ' Exception: ', exception);
|
|
34
34
|
this.display('danger', typeof labelErrorOccured != 'undefined' ? labelErrorOccured : "Une erreur s'est produite.", false, modal);
|
|
35
35
|
}
|
|
36
|
-
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
module.exports = { FlashMessage };
|
package/location.js
CHANGED
|
@@ -8,19 +8,19 @@ class Country {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
static fillCountrySelect(select, defaultValue) {
|
|
11
|
-
Object.entries(Country.
|
|
11
|
+
Object.entries(Country.getCountries()).forEach(([countryCode, countryName]) => select.append('<option value="'+countryCode+'">'+countryName+'</option>'));
|
|
12
12
|
if (typeof defaultValue != 'undefined') {
|
|
13
13
|
select.val(defaultValue);
|
|
14
14
|
}
|
|
15
15
|
select.selectpicker('refresh');
|
|
16
16
|
}
|
|
17
17
|
static getCountryName(countryCode) {
|
|
18
|
-
if (Country.
|
|
19
|
-
return Country.
|
|
18
|
+
if (Country.getCountries().hasOwnProperty(countryCode)) {
|
|
19
|
+
return Country.getCountries()[countryCode];
|
|
20
20
|
}
|
|
21
21
|
return countryCode;
|
|
22
22
|
}
|
|
23
|
-
static
|
|
23
|
+
static getCountries() {
|
|
24
24
|
return {
|
|
25
25
|
AF:'Afghanistan',
|
|
26
26
|
AX:'Åland Islands',
|
|
@@ -268,6 +268,23 @@ class Country {
|
|
|
268
268
|
ZW:'Zimbabwe',
|
|
269
269
|
};
|
|
270
270
|
}
|
|
271
|
+
|
|
272
|
+
static getContinents() {
|
|
273
|
+
return {
|
|
274
|
+
1: "Europe",
|
|
275
|
+
2: "Moyen-Orient",
|
|
276
|
+
3: "Afrique",
|
|
277
|
+
4: "Amérique du Nord",
|
|
278
|
+
5: "Amérique du Sud",
|
|
279
|
+
6: "Asie",
|
|
280
|
+
7: "Océanie",
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** @deprecated **/
|
|
285
|
+
static getCountryList() {
|
|
286
|
+
return Country.getCountries();
|
|
287
|
+
}
|
|
271
288
|
}
|
|
272
289
|
|
|
273
290
|
class PostalAddress {
|
package/media.js
CHANGED
|
@@ -72,6 +72,49 @@ class AudioMedia {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
static initAudioVisualization(canvas, audioStream) {
|
|
76
|
+
let canvasCtx = canvas.getContext("2d");
|
|
77
|
+
let canvasWidth = canvas.width;
|
|
78
|
+
let canvasHeight = canvas.height;
|
|
79
|
+
let audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
|
80
|
+
let analyser = audioCtx.createAnalyser();
|
|
81
|
+
|
|
82
|
+
let distortion = audioCtx.createWaveShaper();
|
|
83
|
+
let source = audioCtx.createMediaStreamSource(audioStream);
|
|
84
|
+
source.connect(analyser);
|
|
85
|
+
analyser.connect(distortion);
|
|
86
|
+
distortion.connect(audioCtx.destination);
|
|
87
|
+
|
|
88
|
+
analyser.fftSize = 256;
|
|
89
|
+
let bufferLength = analyser.frequencyBinCount;
|
|
90
|
+
console.log(bufferLength);
|
|
91
|
+
let dataArray = new Uint8Array(bufferLength);
|
|
92
|
+
|
|
93
|
+
canvasCtx.clearRect(0, 0, canvasWidth, canvasHeight);
|
|
94
|
+
|
|
95
|
+
function draw() {
|
|
96
|
+
let drawVisual = requestAnimationFrame(draw);
|
|
97
|
+
|
|
98
|
+
analyser.getByteFrequencyData(dataArray);
|
|
99
|
+
|
|
100
|
+
canvasCtx.fillStyle = 'rgb(0, 0, 0)';
|
|
101
|
+
canvasCtx.fillRect(0, 0, canvasWidth, canvasHeight);
|
|
102
|
+
|
|
103
|
+
let barWidth = (canvasWidth / bufferLength) * 2.5;
|
|
104
|
+
let barHeight;
|
|
105
|
+
let x = 0;
|
|
106
|
+
for (let i = 0; i < bufferLength; i++) {
|
|
107
|
+
barHeight = dataArray[i] / 2;
|
|
108
|
+
|
|
109
|
+
canvasCtx.fillStyle = 'rgb(' + (barHeight + 100) + ',50,50)';
|
|
110
|
+
canvasCtx.fillRect(x, canvasHeight - barHeight / 2, barWidth, barHeight);
|
|
111
|
+
|
|
112
|
+
x += barWidth + 1;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
draw();
|
|
117
|
+
}
|
|
75
118
|
}
|
|
76
119
|
|
|
77
120
|
//Source : https://www.npmjs.com/package/mic-check
|
package/network.js
CHANGED
|
@@ -238,7 +238,7 @@ class HTTPRequest {
|
|
|
238
238
|
jsonData = await response.json();
|
|
239
239
|
//console.log(url, jsonData);
|
|
240
240
|
|
|
241
|
-
if (response.status == 401 && (response.statusText === "Expired JWT Token" || (typeof jsonData['error'] != 'undefined' && jsonData['error'] === 'expired_token'))) {
|
|
241
|
+
if (response.status == 401 && url !== HTTPRequest.refreshTokenUrl && (response.statusText === "Expired JWT Token" || (typeof jsonData['error'] != 'undefined' && jsonData['error'] === 'expired_token'))) {
|
|
242
242
|
HTTPRequest.refreshToken(() => HTTPRequest.post(url, formData, successCallback, errorCallback, formErrorCallback));
|
|
243
243
|
return;
|
|
244
244
|
}
|
|
@@ -287,7 +287,7 @@ class HTTPRequest {
|
|
|
287
287
|
}
|
|
288
288
|
},
|
|
289
289
|
error: (jqxhr, status, errorThrown) => {
|
|
290
|
-
if (typeof jqxhr.responseJSON != 'undefined' && jqxhr.responseJSON.code == 401 && (jqxhr.responseJSON.message === "Expired JWT Token" || (typeof jqxhr.responseJSON['error'] != 'undefined' && jqxhr.responseJSON['error'] === 'expired_token' ))) {
|
|
290
|
+
if (typeof jqxhr.responseJSON != 'undefined' && jqxhr.responseJSON.code == 401 && url !== HTTPRequest.refreshTokenUrl && (jqxhr.responseJSON.message === "Expired JWT Token" || (typeof jqxhr.responseJSON['error'] != 'undefined' && jqxhr.responseJSON['error'] === 'expired_token' ))) {
|
|
291
291
|
HTTPRequest.refreshToken(() => HTTPRequest.post(url, formData, successCallback, errorCallback, formErrorCallback));
|
|
292
292
|
return;
|
|
293
293
|
}
|
|
@@ -324,8 +324,7 @@ class HTTPRequest {
|
|
|
324
324
|
JwtSession.setRefreshToken(data.refresh_token);
|
|
325
325
|
onCompleteCallback();
|
|
326
326
|
},
|
|
327
|
-
(
|
|
328
|
-
console.log(exception);
|
|
327
|
+
() => {
|
|
329
328
|
JwtSession.logout();
|
|
330
329
|
}
|
|
331
330
|
);
|
|
@@ -351,11 +350,12 @@ class HTTPRequest {
|
|
|
351
350
|
|
|
352
351
|
xhr.onreadystatechange = function () {
|
|
353
352
|
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
|
|
353
|
+
let data;
|
|
354
354
|
if (formatRetour == 'xml') {
|
|
355
|
-
|
|
355
|
+
data = xhr.responseXML;
|
|
356
356
|
}
|
|
357
357
|
else {
|
|
358
|
-
|
|
358
|
+
data = eval('(' + xhr.responseText + ')');
|
|
359
359
|
}
|
|
360
360
|
callback(data);
|
|
361
361
|
}
|
|
@@ -597,6 +597,7 @@ class UrlAndQueryString {
|
|
|
597
597
|
|
|
598
598
|
// deprecated
|
|
599
599
|
|
|
600
|
+
/** @deprecated **/
|
|
600
601
|
static parseQueryString(string) {
|
|
601
602
|
if (string === "" || string == null) return {};
|
|
602
603
|
if (string.charAt(0) === "?") string = string.slice(1);
|
|
@@ -636,6 +637,7 @@ class UrlAndQueryString {
|
|
|
636
637
|
return data0;
|
|
637
638
|
}
|
|
638
639
|
|
|
640
|
+
/** @deprecated **/
|
|
639
641
|
static getQuery(url) {
|
|
640
642
|
var str = url;
|
|
641
643
|
var strpos = str.indexOf('?');
|