speaker-calibration 2.2.177 → 2.2.179
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/dist/example/i18n.js +1936 -1637
- package/dist/main.js +14 -4
- package/package.json +2 -1
- package/src/peer-connection/speaker.js +37 -15
- package/src/utils.js +69 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "speaker-calibration",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.179",
|
|
4
4
|
"description": "Speaker calibration library for auditory testing",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"directories": {
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"peerjs": "^1.3.2",
|
|
41
41
|
"qrcode": "^1.4.4",
|
|
42
42
|
"socket.io-client": "^4.4.1",
|
|
43
|
+
"sweetalert2": "^11.14.0",
|
|
43
44
|
"uuid": "^8.3.2",
|
|
44
45
|
"xlsx": "^0.18.5"
|
|
45
46
|
},
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import QRCode from 'qrcode';
|
|
2
2
|
import AudioPeer from './audioPeer';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
sleep,
|
|
5
|
+
formatLineBreak,
|
|
6
|
+
createAndShowPopup
|
|
7
|
+
} from '../utils';
|
|
4
8
|
import {
|
|
5
9
|
UnsupportedDeviceError,
|
|
6
10
|
MissingSpeakerIdError,
|
|
@@ -289,24 +293,26 @@ class Speaker extends AudioPeer {
|
|
|
289
293
|
QRCode.toCanvas(qrCanvas, this.uri, error => {
|
|
290
294
|
if (error) console.error(error);
|
|
291
295
|
});
|
|
292
|
-
const explanation = document.createElement("
|
|
296
|
+
const explanation = document.createElement("h2");
|
|
293
297
|
explanation.id = "skipQRExplanation";
|
|
294
298
|
explanation.style = `
|
|
295
299
|
user-select: text;
|
|
300
|
+
margin-top: 9px;
|
|
301
|
+
font-size: 1.1rem;
|
|
296
302
|
`;
|
|
297
303
|
// Define the URL and options for the request
|
|
298
304
|
const url = 'https://api.short.io/links/public';
|
|
299
305
|
const options = {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
306
|
+
method: 'POST',
|
|
307
|
+
headers: {
|
|
308
|
+
'Accept': 'application/json',
|
|
309
|
+
'Content-Type': 'application/json',
|
|
310
|
+
'Authorization': 'pk_fysLKGj3legZz4XZ'
|
|
311
|
+
},
|
|
312
|
+
body: JSON.stringify({
|
|
313
|
+
domain: 'listeners.link', // Ensure this domain is valid for your account
|
|
314
|
+
originalURL: this.uri
|
|
315
|
+
})
|
|
310
316
|
};
|
|
311
317
|
|
|
312
318
|
// Make the request using fetch
|
|
@@ -318,14 +324,30 @@ await fetch(url, options)
|
|
|
318
324
|
return response.json(); // Parse the JSON response
|
|
319
325
|
})
|
|
320
326
|
.then(data => {
|
|
321
|
-
explanation.innerHTML =
|
|
327
|
+
explanation.innerHTML =formatLineBreak(
|
|
328
|
+
phrases.RC_skipQR_ExplanationWithoutPreferNot[this.language]
|
|
322
329
|
.replace("xxx", `<b style="user-select: text">${data.shortURL}</b>`)
|
|
323
|
-
.replace("XXX", `<b style="user-select: text">${data.shortURL}</b>`)
|
|
330
|
+
.replace("XXX", `<b style="user-select: text">${data.shortURL}</b>`),
|
|
331
|
+
phrases.RC_checkInternetConnection[this.language]
|
|
332
|
+
);
|
|
333
|
+
const checkConnection = document.createElement('a');
|
|
334
|
+
checkConnection.id = 'check-connection';
|
|
335
|
+
checkConnection.href = '#';
|
|
336
|
+
checkConnection.innerHTML = 'check the phone\'s internet connection';
|
|
337
|
+
const lang = this.language;
|
|
338
|
+
checkConnection.addEventListener('click', function(event,) {
|
|
339
|
+
console.log('clicked');
|
|
340
|
+
event.preventDefault(); // Prevent the default link action
|
|
341
|
+
createAndShowPopup(lang);
|
|
342
|
+
});
|
|
343
|
+
explanation.querySelector('a#check-connection').replaceWith(checkConnection);
|
|
324
344
|
})
|
|
325
345
|
.catch(error => {
|
|
326
346
|
console.error('Error:', error.message); // Handle errors
|
|
327
347
|
});
|
|
328
348
|
|
|
349
|
+
|
|
350
|
+
|
|
329
351
|
|
|
330
352
|
|
|
331
353
|
const qrImage = new Image(400, 400);
|
|
@@ -348,7 +370,7 @@ await fetch(url, options)
|
|
|
348
370
|
container.appendChild(qrImage);
|
|
349
371
|
container.appendChild(explanation);
|
|
350
372
|
container.appendChild(this.buttonsContainer);
|
|
351
|
-
const qrContainer = document.createElement("
|
|
373
|
+
const qrContainer = document.createElement("div");
|
|
352
374
|
qrContainer.appendChild(container);
|
|
353
375
|
|
|
354
376
|
document.getElementById(this.targetElement).appendChild(qrContainer);
|
package/src/utils.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import Swal from "sweetalert2";
|
|
2
|
+
import {phrases} from '../dist/example/i18n.js';
|
|
1
3
|
/** .
|
|
2
4
|
* .
|
|
3
5
|
* .
|
|
@@ -132,4 +134,71 @@ function interpolate(x, x0, x1, y0, y1) {
|
|
|
132
134
|
return y0 + (y1 - y0) * (x - x0) / (x1 - x0);
|
|
133
135
|
}
|
|
134
136
|
|
|
137
|
+
export const formatLineBreak =(inputStr,checkInternetConnection) => {
|
|
138
|
+
let finalStr = inputStr
|
|
139
|
+
.replace(/\n/g, '<br>')
|
|
140
|
+
.replace('LLL',
|
|
141
|
+
`<a href="#" id="check-connection">${checkInternetConnection}</a>`);
|
|
142
|
+
|
|
143
|
+
console.log(finalStr);
|
|
144
|
+
|
|
145
|
+
return finalStr;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
export const createAndShowPopup = (lang) => {
|
|
151
|
+
console.log(`
|
|
152
|
+
<div style="text-align: left;">
|
|
153
|
+
${convertAsterisksToList(phrases.RC_NeedInternetConnectedPhone[lang].replace(/\n/g, '<br>'))}
|
|
154
|
+
</div>
|
|
155
|
+
<div class="col-3" style="margin-top:10px;">
|
|
156
|
+
<button id="okaybtn" class="btn btn-lg btn-dark">
|
|
157
|
+
${phrases.EE_ok[lang]}
|
|
158
|
+
</button>
|
|
159
|
+
</div>`);
|
|
160
|
+
Swal.fire({
|
|
161
|
+
html: `
|
|
162
|
+
<div style="text-align: left;">
|
|
163
|
+
${convertAsterisksToList(phrases.RC_NeedInternetConnectedPhone[lang].replace(/\n/g, '<br>'))}
|
|
164
|
+
</div>
|
|
165
|
+
<div class="col-3" style="margin-top:10px;">
|
|
166
|
+
<button id="okaybtn" class="btn btn-lg btn-dark">
|
|
167
|
+
${phrases.EE_ok[lang]}
|
|
168
|
+
</button>
|
|
169
|
+
</div>`,
|
|
170
|
+
showConfirmButton: false,
|
|
171
|
+
position: 'bottom',
|
|
172
|
+
customClass: {
|
|
173
|
+
container:'no-background',
|
|
174
|
+
},
|
|
175
|
+
showClass: {
|
|
176
|
+
popup: "fade-in",
|
|
177
|
+
},
|
|
178
|
+
hideClass: {
|
|
179
|
+
popup: "",
|
|
180
|
+
},
|
|
181
|
+
didOpen: () => {
|
|
182
|
+
const okayBtn = document.getElementById("okaybtn");
|
|
183
|
+
okayBtn.style.display = "flex";
|
|
184
|
+
okayBtn.addEventListener('click', () => {
|
|
185
|
+
Swal.close(); // Close the Swal popup
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
export function convertAsterisksToList(content) {
|
|
192
|
+
// Replace * with <li> and convert line breaks to </li><li>
|
|
193
|
+
console.log(content);
|
|
194
|
+
let result = content
|
|
195
|
+
.replace(/\* (.*?)(<br>|$)/g, '<li>$1</li>')
|
|
196
|
+
.replace(/(<li>)(<\/li>)\s*$/, '') // Remove trailing </li>
|
|
197
|
+
.replace('<li>', '<ul style="padding-left:40px"> <br> <li>');
|
|
198
|
+
result = result.replace('</li>5', '</li></ul>5');
|
|
199
|
+
return result;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
135
204
|
export {sleep, saveToCSV, saveToJSON, csvToArray,findMinValue,findMaxValue, standardDeviation, interpolate};
|