speaker-calibration 2.2.175 → 2.2.177

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.175",
3
+ "version": "2.2.177",
4
4
  "description": "Speaker calibration library for auditory testing",
5
5
  "main": "dist/main.js",
6
6
  "directories": {
@@ -270,7 +270,7 @@ class Speaker extends AudioPeer {
270
270
  * @example
271
271
  */
272
272
 
273
- #showQRCode = () => {
273
+ #showQRCode = async () => {
274
274
  // Get query string, the URL parameters to specify a Listener
275
275
  const queryStringParameters = {
276
276
  speakerPeerId: this.peer.id,
@@ -282,6 +282,7 @@ class Speaker extends AudioPeer {
282
282
  const queryString = this.queryStringFromObject(queryStringParameters);
283
283
  this.uri = this.siteUrl + queryString;
284
284
  if (this.isSmartPhone) {
285
+ // if (true) { // test smartphone QR
285
286
  // Display QR code for the participant to scan
286
287
  const qrCanvas = document.createElement('canvas');
287
288
  qrCanvas.setAttribute('id', 'qrCanvas');
@@ -293,38 +294,37 @@ class Speaker extends AudioPeer {
293
294
  explanation.style = `
294
295
  user-select: text;
295
296
  `;
296
-
297
297
  // Define the URL and options for the request
298
- const url = 'https://api.short.io/links';
299
- const options = {
300
- method: 'POST',
301
- headers: {
302
- 'Accept': 'application/json',
303
- 'Content-Type': 'application/json',
304
- 'Authorization': 'sk_7Y58e7P68nyqOQ0J'
305
- },
306
- body: JSON.stringify({
307
- domain: 'listeners.link', // Ensure this domain is valid for your account
308
- originalURL: this.uri
309
- })
298
+ const url = 'https://api.short.io/links/public';
299
+ const options = {
300
+ method: 'POST',
301
+ headers: {
302
+ 'Accept': 'application/json',
303
+ 'Content-Type': 'application/json',
304
+ 'Authorization': 'pk_fysLKGj3legZz4XZ'
305
+ },
306
+ body: JSON.stringify({
307
+ domain: 'listeners.link', // Ensure this domain is valid for your account
308
+ originalURL: this.uri
309
+ })
310
310
  };
311
311
 
312
312
  // Make the request using fetch
313
- fetch(url, options)
314
- .then(response => {
315
- if (!response.ok) {
316
- throw new Error(`HTTP error! Status: ${response.status}`);
317
- }
318
- return response.json(); // Parse the JSON response
319
- })
320
- .then(data => {
321
- explanation.innerHTML = phrases.RC_skipQR_ExplanationWithoutPreferNot[this.language]
322
- .replace("xxx", `<b style="user-select: text">${data.shortURL}</b>`)
323
- .replace("XXX", `<b style="user-select: text">${data.shortURL}</b>`);
324
- })
325
- .catch(error => {
326
- console.error('Error:', error.message); // Handle errors
327
- });
313
+ await fetch(url, options)
314
+ .then(response => {
315
+ if (!response.ok) {
316
+ throw new Error(`HTTP error! Status: ${response.status}`);
317
+ }
318
+ return response.json(); // Parse the JSON response
319
+ })
320
+ .then(data => {
321
+ explanation.innerHTML = phrases.RC_skipQR_ExplanationWithoutPreferNot[this.language]
322
+ .replace("xxx", `<b style="user-select: text">${data.shortURL}</b>`)
323
+ .replace("XXX", `<b style="user-select: text">${data.shortURL}</b>`);
324
+ })
325
+ .catch(error => {
326
+ console.error('Error:', error.message); // Handle errors
327
+ });
328
328
 
329
329
 
330
330
 
@@ -343,13 +343,13 @@ fetch(url, options)
343
343
  const container = document.createElement("div");
344
344
  container.style.display = "flex";
345
345
  container.style.justifyContent = "space-between";
346
- container.style.alignItems = "center";
346
+ container.style.alignItems = "top";
347
347
  container.id = "skipQRContainer";
348
348
  container.appendChild(qrImage);
349
349
  container.appendChild(explanation);
350
- const qrContainer = document.createElement("div");
350
+ container.appendChild(this.buttonsContainer);
351
+ const qrContainer = document.createElement("h2");
351
352
  qrContainer.appendChild(container);
352
- qrContainer.appendChild(this.buttonsContainer);
353
353
 
354
354
  document.getElementById(this.targetElement).appendChild(qrContainer);
355
355
  } else {
@@ -171,6 +171,36 @@ class PythonServerAPI {
171
171
  return res.data[task];
172
172
  };
173
173
 
174
+ getShortURL = async (originalURL) => {
175
+ const task = 'url';
176
+ let res = null;
177
+ console.log(originalURL);
178
+ const data = JSON.stringify({
179
+ 'URL': originalURL
180
+ });
181
+
182
+ console.log(data);
183
+
184
+ await axios({
185
+ method: 'post',
186
+ baseURL: PythonServerAPI.PYTHON_SERVER_URL,
187
+ url: `/task/${task}`,
188
+ headers: {
189
+ 'Content-Type': 'application/json',
190
+ },
191
+ data,
192
+ })
193
+ .then(response => {
194
+ res = response;
195
+ console.log(res.data[task]);
196
+ })
197
+ .catch(error => {
198
+ throw error;
199
+ });
200
+
201
+ return res.data[task];
202
+ };
203
+
174
204
  getMemory = async () => {
175
205
  let res;
176
206
  await axios({