aumera-on-screen-widget 0.0.2 → 0.0.4

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.
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><path d="M18.3 5.71c-.39-.39-1.02-.39-1.41 0L12 10.59 7.11 5.7c-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.02 0 1.41L10.59 12 5.7 16.89c-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0L12 13.41l4.89 4.89c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><path fill="#FFFFFF" d="M18.3 5.71c-.39-.39-1.02-.39-1.41 0L12 10.59 7.11 5.7c-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.02 0 1.41L10.59 12 5.7 16.89c-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0L12 13.41l4.89 4.89c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4z"/></svg>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
2
+ <svg width="800px" height="800px" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
3
+ <path d="M44 20H28V4" stroke="#000000" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
4
+ <path d="M4 28H20V44" stroke="#000000" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
5
+ </svg>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+
3
+ <svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
4
+ <g id="Arrow / Expand">
5
+ <path id="Vector" d="M10 19H5V14M14 5H19V10" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
6
+ </g>
7
+ </svg>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="25px" height="32px" viewBox="0 0 25 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
4
+ <path d="M23.7932308,6.22276923 L13.5138462,0.290461538 C12.8492308,-0.0935384615 12.0221538,-0.0935384615 11.3575385,0.290461538 L1.07815385,6.22276923 C0.413538462,6.61169231 0.00492307692,7.32061538 0.00492307692,8.09353846 L0.00492307692,19.968 C0.00492307692,20.736 0.413538462,21.4449231 1.07815385,21.8338462 L6.22276923,24.8073846 L6.22276923,30.8676923 C6.22276923,31.2270769 6.51323077,31.5126154 6.87261538,31.5126154 C6.98584615,31.5126154 7.09415385,31.4830769 7.19261538,31.424 L23.808,21.8387692 C24.4726154,21.4547692 24.8861538,20.7458462 24.8813589,19.9729231 L24.8813589,8.09353846 C24.8763077,7.31569231 24.4627692,6.60676923 23.7932308,6.22276923 Z" fill="#000000" fill-rule="nonzero"></path>
5
+ </g>
6
+ </svg>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="25px" height="32px" viewBox="0 0 25 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
4
+ <path d="M23.7932308,6.22276923 L13.5138462,0.290461538 C12.8492308,-0.0935384615 12.0221538,-0.0935384615 11.3575385,0.290461538 L1.07815385,6.22276923 C0.413538462,6.61169231 0.00492307692,7.32061538 0.00492307692,8.09353846 L0.00492307692,19.968 C0.00492307692,20.736 0.413538462,21.4449231 1.07815385,21.8338462 L6.22276923,24.8073846 L6.22276923,30.8676923 C6.22276923,31.2270769 6.51323077,31.5126154 6.87261538,31.5126154 C6.98584615,31.5126154 7.09415385,31.4830769 7.19261538,31.424 L23.808,21.8387692 C24.4726154,21.4547692 24.8861538,20.7458462 24.8813589,19.9729231 L24.8813589,8.09353846 C24.8763077,7.31569231 24.4627692,6.60676923 23.7932308,6.22276923 Z" fill="#FFFFFF" fill-rule="nonzero"></path>
5
+ </g>
6
+ </svg>
package/df-btn.js CHANGED
@@ -216,8 +216,9 @@ if (!config.project) {
216
216
  }
217
217
 
218
218
  .df-btn-text:before {
219
- background-image: url('${config.logoDark || origin + "/assets/logo_dark.svg"
220
- }')
219
+ background-image: url('${
220
+ config.logoDark || origin + "/assets/logo_dark.svg"
221
+ }')
221
222
  }
222
223
 
223
224
  .df-btn:not(.df-closed) > .df-btn-text:before {
@@ -227,29 +228,55 @@ if (!config.project) {
227
228
 
228
229
  @keyframes shake {
229
230
  0%, 100% { transform: translateX(0); }
230
- 10%, 30%, 50%, 70%, 90% { transform: translateX(-${config.shakeAmplitude
231
- }px); }
232
- 20%, 40%, 60%, 80% { transform: translateX(${config.shakeAmplitude
233
- }px); }
231
+ 10%, 30%, 50%, 70%, 90% { transform: translateX(-${
232
+ config.shakeAmplitude
233
+ }px); }
234
+ 20%, 40%, 60%, 80% { transform: translateX(${
235
+ config.shakeAmplitude
236
+ }px); }
234
237
  }
235
238
 
236
239
  .df-btn.shake {
237
- animation: shake ${config.shakeDuration / 1000
238
- }s cubic-bezier(.36,.07,.19,.97) both;
240
+ animation: shake ${
241
+ config.shakeDuration / 1000
242
+ }s cubic-bezier(.36,.07,.19,.97) both;
239
243
  }
240
244
  `;
241
245
 
242
246
  document.head.appendChild(style);
247
+
248
+ // Language detection function
249
+ function getLanguage() {
250
+ // Check HTML lang attribute first
251
+ let lang = document.documentElement.lang || "";
252
+
253
+ // Fallback to browser language
254
+ if (!lang) {
255
+ lang = navigator.language || navigator.languages?.[0] || "en";
256
+ }
257
+
258
+ // Extract language code (e.g., "en" from "en-US")
259
+ lang = lang.split("-")[0].toLowerCase();
260
+
261
+ // Validate against supported languages
262
+ const supportedLangs = ["en", "de", "it", "fr", "es"];
263
+ return supportedLangs.includes(lang) ? lang : "de";
264
+ }
265
+
266
+ // Get the detected language
267
+ const detectedLang = getLanguage();
268
+
243
269
  document.write(`
244
270
  <button class="df-btn df-closed" onclick="dfToggle()">
245
- ${config.showNotification
246
- ? '<div class="df-notification">Click to check messages</div>'
247
- : ""
248
- }
271
+ ${
272
+ config.showNotification
273
+ ? '<div class="df-notification">Click to check messages</div>'
274
+ : ""
275
+ }
249
276
  <div class="df-btn-header">
250
277
  <div class="df-btn-text">${config.openText || "Chat"}</div>
251
278
  </div>
252
- <iframe class="df-btn-content" src="https://chat.dev.aumera.ai?orgId=1" allow="microphone *"></iframe>
279
+ <iframe class="df-btn-content" src="https://chat.dev.aumera.ai/${detectedLang}/?orgId=1" allow="microphone *"></iframe>
253
280
  </button>
254
281
  `);
255
282
 
@@ -301,65 +328,69 @@ if (!config.project) {
301
328
 
302
329
  // Add close and maximize/minimize buttons dynamically when chat is open
303
330
  function updateHeaderButtons() {
304
- const header = document.querySelector('.df-btn-header');
331
+ const header = document.querySelector(".df-btn-header");
305
332
  if (!header) return;
306
333
  // Remove existing buttons if any
307
- const oldClose = header.querySelector('.close-btn');
334
+ const oldClose = header.querySelector(".close-btn");
308
335
  if (oldClose) header.removeChild(oldClose);
309
- const oldMax = header.querySelector('.maximize-minimize-btn');
336
+ const oldMax = header.querySelector(".maximize-minimize-btn");
310
337
  if (oldMax) header.removeChild(oldMax);
311
- const btnText = header.querySelector('.df-btn-text');
312
- const btn = document.querySelector('.df-btn');
338
+ const btnText = header.querySelector(".df-btn-text");
339
+ const btn = document.querySelector(".df-btn");
313
340
  if (!btn) return;
314
341
  // If open
315
- if (!btn.classList.contains('df-closed')) {
342
+ if (!btn.classList.contains("df-closed")) {
316
343
  // Set text to Close
317
- if (btnText) btnText.innerText = '';
344
+ if (btnText) btnText.innerText = "";
318
345
  // remove right padding from df-btn-text
319
- btnText.style.paddingRight = '0';
346
+ btnText.style.paddingRight = "0";
320
347
  // Add maximize/minimize button (right)
321
- const maxBtn = document.createElement('div');
322
- maxBtn.className = 'maximize-minimize-btn';
323
- const maximized = btn.classList.contains('df-maximized');
324
- maxBtn.innerHTML = `<img class="maximize-minimize-icon" src="${origin}/assets/${maximized ? 'collapse' : 'expand'}.svg" alt="${maximized ? 'Minimize' : 'Maximize'}" style="width:24px;height:24px;cursor:pointer;" />`;
348
+ const maxBtn = document.createElement("div");
349
+ maxBtn.className = "maximize-minimize-btn";
350
+ const maximized = btn.classList.contains("df-maximized");
351
+ maxBtn.innerHTML = `<img class="maximize-minimize-icon" src="${origin}/assets/${
352
+ maximized ? "collapse" : "expand"
353
+ }.svg" alt="${
354
+ maximized ? "Minimize" : "Maximize"
355
+ }" style="width:24px;height:24px;cursor:pointer;" />`;
325
356
  header.appendChild(maxBtn);
326
- maxBtn.addEventListener('click', (e) => {
357
+ maxBtn.addEventListener("click", (e) => {
327
358
  e.stopPropagation();
328
359
  maximizeMinimize();
329
360
  });
330
361
  // Add close button (left)
331
- const closeBtn = document.createElement('div');
332
- closeBtn.className = 'close-btn';
362
+ const closeBtn = document.createElement("div");
363
+ closeBtn.className = "close-btn";
333
364
  closeBtn.innerHTML = `<img src="${origin}/assets/close.svg" alt="Close" style="width:20px;height:20px;cursor:pointer;" />`;
334
365
  header.insertBefore(closeBtn, btnText);
335
- closeBtn.addEventListener('click', (e) => {
366
+ closeBtn.addEventListener("click", (e) => {
336
367
  e.stopPropagation();
337
368
  dfToggle();
338
369
  });
339
370
  } else {
340
371
  // Set text to openText
341
- if (btnText) btnText.innerText = config.openText || 'Chat';
372
+ if (btnText) btnText.innerText = config.openText || "Chat";
342
373
  // add right padding to df-btn-text only if screen size is greater than 720px
343
374
  if (window.innerWidth > 720) {
344
- btnText.style.paddingRight = '24px';
375
+ btnText.style.paddingRight = "24px";
345
376
  }
346
377
  }
347
378
  }
348
379
 
349
380
  function maximizeMinimize() {
350
- const btn = document.querySelector('.df-btn');
381
+ const btn = document.querySelector(".df-btn");
351
382
  if (!btn) return;
352
- btn.classList.toggle('df-maximized');
383
+ btn.classList.toggle("df-maximized");
353
384
  updateHeaderButtons();
354
385
  }
355
386
 
356
387
  function dfToggle() {
357
- const btn = document.querySelector('.df-btn');
388
+ const btn = document.querySelector(".df-btn");
358
389
  if (!btn) return;
359
- btn.classList.toggle('df-closed');
390
+ btn.classList.toggle("df-closed");
360
391
  // Always remove maximized state when closing
361
- if (btn.classList.contains('df-closed')) {
362
- btn.classList.remove('df-maximized');
392
+ if (btn.classList.contains("df-closed")) {
393
+ btn.classList.remove("df-maximized");
363
394
  }
364
395
  updateHeaderButtons();
365
396
  clearInactivityAndShake();
@@ -372,11 +403,11 @@ if (!config.project) {
372
403
  updateHeaderButtons();
373
404
 
374
405
  // Remove onclick from button, handle open/close in JS
375
- const btn = document.querySelector('.df-btn');
406
+ const btn = document.querySelector(".df-btn");
376
407
  btn.onclick = null;
377
- btn.addEventListener('click', (e) => {
408
+ btn.addEventListener("click", (e) => {
378
409
  // Only toggle if chat is closed (popover mode)
379
- if (btn.classList.contains('df-closed')) {
410
+ if (btn.classList.contains("df-closed")) {
380
411
  dfToggle();
381
412
  }
382
413
  // If open, do nothing (let header buttons handle maximize/minimize/close)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aumera-on-screen-widget",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "A lightweight, customizable chat widget for websites",
5
5
  "main": "df-btn.js",
6
6
  "scripts": {
@@ -26,6 +26,7 @@
26
26
  "files": [
27
27
  "df-btn.js",
28
28
  "README.md",
29
- "LICENSE"
29
+ "LICENSE",
30
+ "assets/"
30
31
  ]
31
32
  }