speaker-calibration 2.2.205 → 2.2.206

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speaker-calibration",
3
- "version": "2.2.205",
3
+ "version": "2.2.206",
4
4
  "description": "Speaker calibration library for auditory testing",
5
5
  "main": "dist/main.js",
6
6
  "directories": {
@@ -7,7 +7,7 @@ import {
7
7
  CalibrationTimedOutError,
8
8
  } from './peerErrors';
9
9
 
10
- import {phrases} from '../../dist/example/i18n';
10
+ //import {phrases} from '../../dist/example/i18n';
11
11
 
12
12
  /**
13
13
  * @class Handles the speaker's side of the connection. Responsible for initiating the connection,
@@ -43,6 +43,7 @@ class Speaker extends AudioPeer {
43
43
  this.isLoudspeakerCalibration = params?.isLoudspeakerCalibration ?? false;
44
44
  this.deviceId = params?.micrpohoneIdFromWebAudioApi ?? '';
45
45
  this.buttonsContainer = params?.buttonsContainer ?? document.createElement('div');
46
+ this.phrases = params?. phrases ?? {};
46
47
 
47
48
  /* Set up callbacks that handle any events related to our peer object. */
48
49
  }
@@ -208,6 +209,7 @@ class Speaker extends AudioPeer {
208
209
  params.calibrateSoundSamplingDesiredBits,
209
210
  params.language,
210
211
  params.loudspeakerModelName,
212
+ params.phrases,
211
213
  );
212
214
  speaker.#removeUIElems();
213
215
  resolve(speaker.result);
@@ -329,10 +331,10 @@ class Speaker extends AudioPeer {
329
331
  })
330
332
  .then(data => {
331
333
  explanation.innerHTML = formatLineBreak(
332
- phrases.RC_skipQR_ExplanationWithoutPreferNot[this.language]
334
+ this.phrases.RC_skipQR_ExplanationWithoutPreferNot[this.language]
333
335
  .replace('xxx', `<b style="user-select: text">${data.shortURL}</b>`)
334
336
  .replace('XXX', `<b style="user-select: text">${data.shortURL}</b>`),
335
- phrases.RC_checkInternetConnection[this.language]
337
+ this.phrases.RC_checkInternetConnection[this.language]
336
338
  );
337
339
  const checkConnection = document.createElement('a');
338
340
  checkConnection.id = 'check-connection';
@@ -342,7 +344,7 @@ class Speaker extends AudioPeer {
342
344
  checkConnection.addEventListener('click', function (event) {
343
345
  console.log('clicked');
344
346
  event.preventDefault(); // Prevent the default link action
345
- createAndShowPopup(lang);
347
+ createAndShowPopup(lang, this.phrases);
346
348
  });
347
349
  explanation.querySelector('a#check-connection').replaceWith(checkConnection);
348
350
  })
@@ -388,7 +390,7 @@ class Speaker extends AudioPeer {
388
390
  const proceedButton = document.createElement('button');
389
391
  proceedButton.setAttribute('id', 'calibrationProceedButton');
390
392
  proceedButton.setAttribute('class', 'btn btn-success');
391
- proceedButton.innerHTML = phrases.T_proceed[this.language];
393
+ proceedButton.innerHTML = this.phrases.T_proceed[this.language];
392
394
  proceedButton.onclick = () => {
393
395
  // open the link in a new tab
394
396
  window.open(this.uri, '_blank');
@@ -425,7 +427,7 @@ class Speaker extends AudioPeer {
425
427
  instructionDisplay.style.whiteSpace = 'nowrap';
426
428
  instructionDisplay.style.fontWeight = 'bold';
427
429
  instructionDisplay.style.width = 'fit-content';
428
- instructionDisplay.innerHTML = phrases.RC_soundRecording[this.language];
430
+ instructionDisplay.innerHTML = this.phrases.RC_soundRecording[this.language];
429
431
  let fontSize = 100;
430
432
  instructionDisplay.style.fontSize = fontSize + 'px';
431
433
  while (instructionDisplay.scrollWidth > background.scrollWidth * 0.9 && fontSize > 10) {
@@ -444,7 +446,7 @@ class Speaker extends AudioPeer {
444
446
 
445
447
  const timeToCalibrateDisplay = document.getElementById(this.timeToCalibrateDisplay);
446
448
  if (timeToCalibrateDisplay) {
447
- const timeToCalibrateText = phrases.RC_howLongToCalibrate[this.language];
449
+ const timeToCalibrateText = this.phrases.RC_howLongToCalibrate[this.language];
448
450
  timeToCalibrateDisplay.innerHTML = timeToCalibrateText.replace('111', this.timeToCalibrate);
449
451
  timeToCalibrateDisplay.style.fontWeight = 'normal';
450
452
  timeToCalibrateDisplay.style.fontSize = '1rem';
@@ -716,6 +718,7 @@ class Speaker extends AudioPeer {
716
718
  params.calibrateSoundSamplingDesiredBits,
717
719
  params.language,
718
720
  params.loudspeakerModelName,
721
+ params.phrases,
719
722
  );
720
723
  this.#removeUIElems();
721
724
  resolve(result);
@@ -32,7 +32,7 @@ import {
32
32
  where,
33
33
  Timestamp,
34
34
  } from 'firebase/firestore';
35
- import { phrases } from '../../../dist/example/i18n';
35
+ //import { phrases } from '../../../dist/example/i18n';
36
36
 
37
37
  /**
38
38
  *
@@ -312,7 +312,7 @@ class Combination extends AudioCalibrator {
312
312
  let systemSD = '';
313
313
  let flags = '';
314
314
  const reportWebAudioNames = `<strong>${this.webAudioDeviceNames.loudspeakerText} </strong> <strong>${this.webAudioDeviceNames.microphoneText} </strong>`;
315
- const samplingParamText = phrases.RC_SamplingHzBits[this.language].replace('111', this.sourceSamplingRate).replace('222',this.sinkSamplingRate).replace('333', this.calibrateSoundSamplingDesiredBits);
315
+ const samplingParamText = this.phrases.RC_SamplingHzBits[this.language].replace('111', this.sourceSamplingRate).replace('222',this.sinkSamplingRate).replace('333', this.calibrateSoundSamplingDesiredBits);
316
316
  const reportParameters = `${samplingParamText}`;
317
317
  if (this.flags) {
318
318
  flags = `<br> autoGainControl: ${this.flags.autoGainControl};
@@ -2735,6 +2735,7 @@ class Combination extends AudioCalibrator {
2735
2735
  calibrateSoundSamplingDesiredBits = 24,
2736
2736
  language,
2737
2737
  loudspeakerModelName='',
2738
+ phrases,
2738
2739
 
2739
2740
  ) => {
2740
2741
  this._calibrateSoundBurstPreSec = _calibrateSoundBurstPreSec;
@@ -2772,13 +2773,14 @@ class Combination extends AudioCalibrator {
2772
2773
  this._calibrateSoundBurstScalarDB = _calibrateSoundBurstScalarDB;
2773
2774
  this.webAudioDeviceNames = webAudioDeviceNames;
2774
2775
  this.calibrateSoundSamplingDesiredBits = calibrateSoundSamplingDesiredBits;
2776
+ this.phrases = phrases;
2775
2777
  if (isSmartPhone) {
2776
2778
  const leftQuote = "\u201C"; // “
2777
2779
  const rightQuote = "\u201D"; // ”
2778
2780
  this.webAudioDeviceNames.microphone = this.deviceInfo.microphoneFromAPI;
2779
2781
  const quotedWebAudioMic = leftQuote + this.webAudioDeviceNames.microphone + rightQuote;
2780
2782
  const combinedMicText = this.micModelName + " " + quotedWebAudioMic;
2781
- webAudioDeviceNames.microphoneText = phrases.RC_nameMicrophone[this.language]
2783
+ webAudioDeviceNames.microphoneText = this.phrases.RC_nameMicrophone[this.language]
2782
2784
  .replace("“xxx”", combinedMicText)
2783
2785
  .replace("“XXX”", combinedMicText);
2784
2786
  }
package/src/utils.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import Swal from "sweetalert2";
2
- import {phrases} from '../dist/example/i18n.js';
2
+ //import {phrases} from '../dist/example/i18n.js';
3
3
  /** .
4
4
  * .
5
5
  * .
@@ -147,7 +147,7 @@ export const formatLineBreak =(inputStr,checkInternetConnection) => {
147
147
 
148
148
 
149
149
 
150
- export const createAndShowPopup = (lang) => {
150
+ export const createAndShowPopup = (lang, phrases) => {
151
151
  console.log(`
152
152
  <div style="text-align: left;">
153
153
  ${convertAsterisksToList(phrases.RC_NeedInternetConnectedPhone[lang].replace(/\n/g, '<br>'))}