How to use PrimeVue File Upload component with Firebase?

I am trying to use the PrimeVue V3 File Upload component with Firebase.

I am also using VueFire to manage the Firebase upload. Only because it provides some convenient composables for managing Firebase Storage uploads. If we have to do away with this part then so be it.

The PrimeVue File Upload component is usually HTTP based, so to make it work with the Firebase client I am using custom-upload and @uploader="handleUpload" to manage the upload process. This part is working, the files are successfully uploaded to Firebase Storage.

My problem is that after upload the images immediately disappear from the File Upload UI. They are not supposed to disappear. They should still be visible with a “complete” tag instead of “pending” tag. I am not sure if this is a bug or something wrong with my custom upload process.

See a live stackblitz reproduction here.

<template>
  <div class="card">
    <FileUpload
      :max-file-size="1000000"
      :multiple="true"
      accept="image/*"
      custom-upload
      @uploader="handleUpload"
    >
      <template #empty>
        <p>Drag and drop files to here to upload.</p>
      </template>
    </FileUpload>
  </div>
</template>

<script setup>
import { ref as storageRef } from 'firebase/storage';
import { useStorageFile, useFirebaseStorage } from 'vuefire';

const storage = useFirebaseStorage();

const handleUpload = async (event) => {
  // Get the files from the event, if single file put it in an array
  const files = Array.isArray(event.files) ? event.files : [event.files];

  // Upload each file using the VueFire composable
  for (const file of files) {
    const fileRef = storageRef(storage, `uploads/${file.name}`);
    const { upload, url } = useStorageFile(fileRef);
    await upload(file);
  }
};
</script>

Arceus X APK 1.3.6 Descarga gratuita para Android Ultima versión

Descarga:Arceus X APK 1.3.6
¿Qué es Arceus X APK?
Arceus X es una aplicación revolucionaria diseñada para mejorar y optimizar el proceso de desarrollo de aplicaciones móviles. Proporciona a los desarrolladores una plataforma sólida que simplifica la creación, prueba e implementación de aplicaciones en múltiples sistemas operativos, incluidos iOS y Android. Arceus X se destaca por su interfaz fácil de usar y su completo conjunto de herramientas que se adaptan tanto a desarrolladores novatos como experimentados.

Beneficios de Arceus X APK nueva versión
El uso de Arceus X conlleva numerosos beneficios que agilizan el proceso de desarrollo y mejoran la calidad del producto final:

Compatibilidad multiplataforma: una de las ventajas más importantes de Arceus X es su capacidad para admitir el desarrollo tanto para iOS como para Android. Esto garantiza que las aplicaciones puedan llegar a una audiencia más amplia sin la necesidad de bases de código independientes.
Eficiencia y Velocidad: Arceus X está diseñado para acelerar el proceso de desarrollo. Con sus herramientas intuitivas y plantillas prediseñadas, los desarrolladores pueden crear prototipos funcionales y aplicaciones completas mucho más rápido que los métodos tradicionales.
Rentable: al reducir el tiempo y el esfuerzo necesarios para el desarrollo, Arceus X ayuda a reducir los costos. Esto es particularmente beneficioso para las nuevas empresas y las pequeñas empresas con presupuestos limitados.
Interfaz fácil de usar: la interfaz de la plataforma está diseñada para ser accesible, lo que permite a los desarrolladores de todos los niveles navegar y utilizar sus funciones de manera efectiva.
Actualizaciones periódicas: Arceus X evoluciona continuamente con actualizaciones periódicas que introducen nuevas funciones, corrigen errores y mejoran el rendimiento, lo que garantiza que los desarrolladores siempre tengan acceso a las herramientas más recientes.

Explore el menú de modificaciones definitivo de Roblox con Arceus X APK 2024: ¡desbloquee funciones avanzadas para una experiencia de juego mejorada

Visual studio code debug issue

Ive been using visual studio code to write HTML and some Java script. But I cant use the debug feature to run my code. I have to right click to “open with live server”.

Why does it not work to run the code with the debug feature? The error message just says: Cant access file ERR_FILE_NOT_FOUND. In visual studio code it says Unexpected 503 response from chrome-error://chromewebdata/neterror.rollup.js.map: Unsupported protocol “chrome-error:”

Can anyone please help?

Regards

I tried looking for solutions online but was unable to understand what causes the issue or how to resolve it

Aligning vertical scroll positions of related parts between main block and gutter

I am looking to find a less obtrusive way of rendering something like scriptural verse numbers. At the moment I have text something like this:

1 In the beginning God created the heaven and the earth.  2 And the earth
was without form, and void; and darkness was upon the face of the deep.
And the Spirit of God moved upon the face of the waters.

3 And God said, Let there be light: and there was light.  4 And God saw
the light, that it was good: and God divided the light from the darkness.
5 And God called the light Day, and the darkness he called Night. And the
evening and the morning were the
first day.

The verse numbers are hyperlinks, and I want those always available; I also want users to be able to distinguish the verses. But I would prefer a more subtle approach than throwing the numbers in the reader’s face. I also would prefer that the numbers don’t show up when the user copies text.

I would certainly entertain other approaches, but I was thinking about adding a gutter to the left of the text and putting the numbers in there, aligned as best possible, with the start of the verses, something like this line numbers in a code editor, like this:

1       In the beginning God created the heaven and the earth.  And the earth
2       was without form, and void; and darkness was upon the face of the deep.
         And the Spirit of God moved upon the face of the waters.

3       And God said, Let there be light: and there was light.  And God saw
4       the light, that it was good: and God divided the light from the darkness.
5       And God called the light Day, and the darkness he called Night. And the
         evening and the morning were the first day.

If the user hovers on a verse number, say, 4, then the corresponding verse itself is highlighted:

1       In the beginning God created the heaven and the earth.  And the earth
2       was without form, and void; and darkness was upon the face of the deep.
         And the Spirit of God moved upon the face of the waters.

3       And God said, Let there be light: and there was light.  And God saw
4     the light, that it was good: and God divided the light from the darkness.
5       And God called the light Day, and the darkness he called Night. And the
         evening and the morning were the first day.

But I don’t have a clue of how to go about that. (And I consider myself reasonably competent in Web technologies.) I have complete control of the HTML/CSS/JS, although I was hoping to do it without JS if that’s possible. There are plenty of techniques for doing this to add line numbers, but that’s fairly mechanical; I can’t see how to convert them to handle this.

Has anyone seen something like this before? Any suggestions for how to create it? Any alternative approaches you think worth considering?

Text renders once and then it disappears within div (textContent) in HTML

I am currently trying to spawn HTML, CSS, JS, and firebase code within dangerouselySetInnerHTML, and the text successfully renders within avatar-initials textContent (initials) for a millisecond, and then it disappears. This also applies to fullName and email, which are in the menu list (render for a millisecond and then disappear). The HTML, CSS, and JS code is rendered in Next JS. I tried to remove useEffect and put htmlCode outside of the function, remove return, but none of those methods worked. I also previously put in an if statement to check for if (document.getElementById('avatar-initials').textContent == "") then change otherwise don’t, but that also did not work. On the left is picture which spawns for a millisecond on the right is the picture that spawns afterward. If you need more information please let me know. Thank you in advance!

enter image description here
enter image description here

const NavBar = () => {
  useEffect(() => {
    // Load Firebase SDK scripts
    const script = document.createElement('script');
    script.src = "https://www.gstatic.com/firebasejs/9.1.3/firebase-app-compat.js";
    script.async = true;
    document.body.appendChild(script);

const script2 = document.createElement('script');
script2.src = "https://www.gstatic.com/firebasejs/9.1.3/firebase-firestore-compat.js";
script2.async = true;
document.body.appendChild(script2);

script.onload = () => {
  script2.onload = () => {
    const scriptInit = document.createElement('script');
    scriptInit.innerHTML = `
      // Check if Firebase has already been initialized
      if (!firebase.apps.length) {
        // Your web app's Firebase configuration
        const firebaseConfig = {
          apiKey: "AIzaSyBJUBPWGwmNfPa127y42YfUSrYcv63Jh3A",
          authDomain: "innovatex-c12c6.firebaseapp.com",
          projectId: "innovatex-c12c6",
          storageBucket: "innovatex-c12c6.appspot.com",
          messagingSenderId: "837977074704",
          appId: "1:837977074704:web:ad488537707338cdae2e95",
          measurementId: "G-EP0JK2ETP7",
        };

        // Initialize Firebase
        firebase.initializeApp(firebaseConfig);
      }

      const db = firebase.firestore();

      // Fetch user data from Firestore
      db.collection("users").doc(localStorage.getItem("id")).get().then((val) => {
      const fullName = val.get("fullName");
      const email = val.get("email");
      const companyId = val.get("company");
      document.getElementById('full-name').innerText = fullName;
      document.getElementById('email').innerText = email;

      console.log(fullName)
      console.log(email)

      const initials = fullName.split(' ').map((name, index, arr) => {
        if (index === 0 || index === arr.length - 1) {
          return name.charAt(0);
        }
        return '';
      }).join('');
      document.getElementById('avatar-initials').textContent = initials;

      if (companyId) {
        db.collection('companies').doc(companyId).get().then((doc) => {
          if (doc.exists) {
            const employees = doc.data().activeEmployees || {};
            window.employees = employees;
          }
        });
      }
    });

      function navigateTo(url) {
        window.location.href = url;
      }

      function handleSearchQueryChange(event) {
        const searchQuery = event.target.value.toLowerCase();
        if (searchQuery) {
          const filteredEmployees = Object.keys(window.employees).filter((key) =>
            window.employees[key].fullName.toLowerCase().includes(searchQuery)
          );
          showDropdown(true, filteredEmployees);
        } else {
          showDropdown(false, []);
        }
      }

      function showDropdown(show, filteredEmployees) {
        const dropdown = document.getElementById('search-dropdown');
        if (show) {
          dropdown.style.display = 'flex';
          dropdown.innerHTML = filteredEmployees
            .map(
              (userId) => 
                `<button onclick="navigateTo('/c/view/' + '${userId}')">${window.employees[userId].fullName}</button>`
            )
            .join('');
        } else {
          dropdown.style.display = 'none';
        }
      }

      function toggleCalculatorPopover() {
        const popover = document.getElementById('calculator-popover');
        popover.style.display = popover.style.display === 'none' ? 'block' : 'none';
      }

      function toggleMenu() {
        const menuList = document.getElementById('menu-list');
        menuList.style.display = menuList.style.display === 'none' ? 'block' : 'none';
      }

      async function logout() {
        localStorage.removeItem('id');
        window.location.href = '/';
        alert('Logout Successful...');
        await firebase.auth().signOut()
      }

      // Calculator functionality
      let input = '';
      let result = '';

      function handleButtonClick(value) {
        input += value;
        document.getElementById('calculator-input').value = input;
      }

      function handleClear() {
        input = '';
        result = '';
        document.getElementById('calculator-input').value = '';
        document.getElementById('calculator-result').value = '';
      }

      function handleCalculate() {
        try {
          const evaluatedResult = evaluateExpression(input);
          result = evaluatedResult;
          document.getElementById('calculator-result').value = result;
        } catch (error) {
          document.getElementById('calculator-result').value = 'Error';
        }
      }

      function evaluateExpression(expr) {
        const sanitizedExpr = expr
          .replace(/\^/g, '**')
          .replace(/\|([^|]+)\|/g, 'Math.abs($1)');
        return Function(`'use strict'; return (${sanitizedExpr})`)();
      }

      function handleInputChange(event) {
        const value = event.target.value;
        const validChars = '0123456789+-*/^().|';
        let sanitizedValue = '';
        for (let i = 0; i < value.length; i++) {
          if (validChars.includes(value[i])) {
            sanitizedValue += value[i];
          }
        }
        input = sanitizedValue;
        event.target.value = sanitizedValue;
      }

      function handleKeyPress(event) {
        if (event.key === 'Enter') {
          handleCalculate();
        }
      }

      document.addEventListener('click', function(event) {
        const menuList = document.getElementById('menu-list');
        // const calculatorPopover = document.getElementById('calculator-popover');
        if (!event.target.closest('#menu-list') && !event.target.closest('#avatar-initials')) {
          menuList.style.display = 'none';
        }
        // if (!event.target.closest('#calculator-popover') && !event.target.closest('.calculator-button')) {
        //   calculatorPopover.style.display = 'none';
        // }
      });

      document.getElementById('calculator-input').addEventListener('keypress', handleKeyPress);
      
      document.getElementById('search-input').addEventListener('blur', function() {
        showDropdown(false, []);
      });

      document.getElementById('calculator-popover').addEventListener('blur', function() {
        this.style.display = 'none';
      });

    `;
    document.body.appendChild(scriptInit);
  };
};

return () => {
  document.body.removeChild(script);
  document.body.removeChild(script2);
};


}, []);



console.log('once')
  const htmlCode = `
    <style>
      .sidebar {
        display: flex;
        flex-direction: column;
        width: 80px;
        height: calc(100vh - 100px);
        background-color: #000000;
        align-items: center;
        padding: 5px;
        position: fixed;
        top: 85px;
        overflow-y: scroll;
        left: 8px;
        z-index: 1;
        box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        border-radius: 8px;
      }
      .hover-text {
        position: relative;
        display: inline-block;
      }
      .hover-text .hover-content {
        visibility: hidden;
        width: 70px;
        background-color: #555;
        color: #fff;
        text-align: center;
        border-radius: 6px;
        padding: 5px;
        position: absolute;
        z-index: 1;
        bottom: -50%;
        left: 100%;
        margin-left: -60px;
        opacity: 0;
        transition: opacity 0.3s;
        font-size: 9pt;
      }
      .hover-text:hover .hover-content {
        visibility: visible;
        opacity: 1;
      }
      .icon-button {
        margin-bottom: 10px;
        border-radius: 8px;
        border: none;
        cursor: pointer;
        padding: 10px;
        display: flex;
        justify-content: center;
        align-items: center;
        width: 50px;
        height: 50px;
      }
      .icon-button:hover {
        background-color: #a0a0a0;
      }
      .icon-button img {
        filter: brightness(0) invert(1);
      }
      .divider {
        margin-bottom: 14px;
        margin-top: 8px;
        border-color: #dcdcdc;
        width: 60%;
        height: 1px;
        background-color: #dcdcdc;
      }
      .navbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: calc(100% - 20px);
        border-radius: 8px;
        padding: 4px 5px;
        background-color: #000000;
        position: fixed;
        top: 3px;
        left: 8px;
        right: 0;
        z-index: 2;
        box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
      }
      .search-box {
        position: relative;
        width: 300px;
        margin: 0 auto;
      }
      .search-box input {
        width: 100%;
        padding: 10px 20px;
        border-radius: 50px;
        border: none;
        background-color: #ffffff;
        box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
        autocomplete: off;
      }
      .search-dropdown {
        display: flex;
        flex-direction: column;
        position: absolute;
        width: 300px;
        background-color: #ffffff;
        box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        border-radius: 8px;
        z-index: 3;
      }
      .search-dropdown button {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        border-top: 1px solid #e0e0e0;
        padding: 10px;
        background-color: #ffffff;
        border: none;
        cursor: pointer;
        width: 100%;
      }
      .search-dropdown button:hover {
        background-color: #f7f7f7;
      }
      .avatar-menu {
        display: flex;
        margin-top: 8px;
        direction: row;
        align-items: center;
        justify-content: center;
        gap: 3px;
      }
      .avatar-menu button {
        background-color: transparent;
        border: none;
        cursor: pointer;
      }
      .avatar-initials {
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: purple;
        color: white;
        border-radius: 50%;
        width: 45px;
        height: 45px;
        font-size: 14pt;
        font-weight: 600;
        border: 1.5px solid white;
      }
        .avatar-initials:hover {
          opacity:0.85;
        }
      .menu-list {
        display: flex;
        flex-direction: column;
        align-items: left;
        justify-content: center;
        padding: 10px;
        background-color: #ffffff;
        box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        border-radius: 8px;
        position: absolute;
        top: 60px;
        right: 10px;
        z-index: 3;
        width: 250px; /* Increased width */
      }
      .menu-item {
        display: flex;
        align-items: center;
        padding: 10px;
        cursor: pointer;
      }
      .menu-item:hover {
        background-color: #f7f7f7;
      }
      .popover-content {
        background-color: #ffffff;
        width: 500px;
        position: absolute;
        top: 75px;
        right: 10px;
        box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        border-radius: 8px;
        padding: 10px;
      }
      .popover-header {
        font-weight: 500;
        font-size: 16pt;
        color: #000000;
        margin-bottom: 10px;
      }
      .popover-close-button {
        position: absolute;
        top: 10px;
        right: 10px;
        cursor: pointer;
        background-color: transparent;
        border: none;
        padding-top: 3px;
        padding-bottom: 3px;
        padding-left: 8px;
        padding-right: 8px;
        border-radius: 5px;
      }
      .popover-close-button:hover {
        background-color: #dfdfdf;
      }
      .calculator-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
      }
      .calculator-input,
      .calculator-result {
        width: 100%;
        padding: 10px;
        margin-bottom: 10px;
        border-radius: 8px;
        border: 1px solid #ccc;
      }
      .calculator-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
      }
      .calculator-button {
        background-color: #b0b0b0;
        border: none;
        padding: 20px;
        border-radius: 8px;
        cursor: pointer;
      }
      .calculator-button:hover {
        background-color: #a0a0a0;
      }
      .calculator-clear {
        grid-column: span 4;
        background-color: red;
        color: white;
      }
      .calculator {
        width: 100%;
        max-width: 400px;
        border: 1px solid #2D3748;
        border-radius: 0.375rem;
        padding: 1.25rem;
        box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
        background-color: #2D3748;
      }
      .calculator input {
        width: 100%;
        padding: 0.75rem;
        margin-bottom: 0.75rem;
        border-radius: 0.375rem;
        background-color: #2A2F45;
        color: white;
        font-size: 1.25rem;
        text-align: right;
        border: none;
      }
      .calculator-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 0.75rem;
      }
      .calculator-button {
        padding: 0.75rem;
        font-size: 1.25rem;
        border-radius: 0.375rem;
        background-color: #319795;
        color: white;
        border: none;
        cursor: pointer;
      }
      .calculator-button-clear {
        grid-column: span 4;
        background-color: #E53E3E;
      }
    </style>
    <div>
      <div class="sidebar">
        <div class="hover-text">
          <button style="margin-top: 8px" class="icon-button" onclick="navigateTo('/c/main')">
            <img src="/home.png" width="25" height="25" />
          </button>
          <span class="hover-content">Home</span>
        </div>
        <div class="hover-text">
          <button class="icon-button" onclick="navigateTo('/c/todolist/overview')">
            <img src="/todolist.png" width="25" height="25" />
          </button>
          <span class="hover-content">To-Do List</span>
        </div>
        <div class="hover-text">
          <button class="icon-button" onclick="navigateTo('/c/applicantTracking/overall')">
            <img src="/ats.png" width="25" height="25" />
          </button>
          <span class="hover-content">ATS</span>
        </div>
        <div class="hover-text">
          <button class="icon-button" onclick="navigateTo('/c/forum/overall')">
            <img src="/forum.png" width="25" height="25" />
          </button>
          <span class="hover-content">Public Forum</span>
        </div>
        <div class="divider"></div>
        <div class="hover-text">
          <button class="icon-button" onclick="navigateTo('/c/timeTracker/overall')">
            <img src="/timeTracker.png" width="25" height="25" />
          </button>
          <span class="hover-content">Time Tracker</span>
        </div>
        <div class="hover-text">
          <button class="icon-button" onclick="navigateTo('/c/timeOff/overall')">
            <img src="/timeOff2.png" width="25" height="25" />
          </button>
          <span class="hover-content">Time Off</span>
        </div>
        <div class="hover-text">
          <button class="icon-button" onclick="navigateTo('/c/benefits/overall')">
            <img src="/benefits.png" width="25" height="25" />
          </button>
          <span class="hover-content">Benefits</span>
        </div>
        <div class="divider"></div>
        <div class="hover-text">
          <button class="icon-button" onclick="navigateTo('/c/payroll/overview')">
            <img src="/payroll.png" width="25" height="25" />
          </button>
          <span class="hover-content">Payroll</span>
        </div>
        <div class="hover-text">
          <button class="icon-button" onclick="navigateTo('/c/customize')">
            <img src="/customize.png" width="25" height="25" />
          </button>
          <span class="hover-content">Customize</span>
        </div>
      </div>

      <div class="navbar">
        <div style="display: flex; align-items: center; gap: 5px;">
          <button style="color: white; margin-left: 20px; margin-right: 20px; font-family: Montserrat; background-color: transparent; border: none; font-size: 30pt; font-weight: 800; cursor: pointer;" onclick="navigateTo('/c/main')">
            <i>I</i>
          </button>
          <div class="search-box">
            <input type="text" id="search-input" placeholder="Search for a co-worker" autocomplete="off" oninput="handleSearchQueryChange(event)" />
            <div id="search-dropdown" class="search-dropdown" style="display: none;">
              <!-- Dropdown content will be injected here -->
            </div>
          </div>
        </div>
        <div class="avatar-menu">
          <div class="hover-text">
            <button class="icon-button" onclick="navigateTo('/c/employees')">
              <img src="/people.png" width="25" height="25" />
            </button>
            <span class="hover-content">Employees</span>
          </div>
          <div class="hover-text">
            <button class="icon-button" onclick="navigateTo('/c/privateToDo')">
              <img src="/toDo.png" width="25" height="25" />
            </button>
            <span class="hover-content">Private To-Do List</span>
          </div>
          <div class="hover-text">
            <button class="icon-button" onclick="toggleCalculatorPopover()">
              <img src="/calculator.png" width="25" height="25" />
            </button>
            <span class="hover-content">Calculator</span>
          </div>
          <a href="/c/feedback" style="color: white; font-weight: 800; text-decoration: none; margin-bottom: 8px; margin-left: 5px;">FEEDBACK</a>
          <a href="/c/help" style="color: white; margin-bottom: 8px; margin-left: 5px; margin-right: 8px;"><img src="/info.png" width="25" height="25;" /></a>
          <div style="margin-left: 14px; margin-right: 22px;">
            <button onclick="toggleMenu()">
              <div id="avatar-initials" class="avatar-initials"></div>
            </button>
            <div id="menu-list" class="menu-list" style="display: none;">
              <div style="display: flex; flex-direction: column; align-items: left; justify-content: center; padding: 10px;">
                <span id="full-name" style="font-size: 12pt; font-weight: 700; color: #000000;"></span>
                <span id="email" style="font-size: 10pt; color: gray;"></span>
              </div>
              <div class="menu-item" onclick="logout()">
                <img src="/logout.png" width="25" height="25" />
                &nbsp;&nbsp;Log Out
              </div>
            </div>
          </div>
        </div>
      </div>

      <div id="calculator-popover" class="popover-content" style="display: none; z-index: 9999999;" tabindex="0">
        <button class="popover-close-button" onclick="toggleCalculatorPopover()" style="font-weight: 900; font-size: 16pt"><img style="width: 20px; height: 20px;" src="/close.png"></button>
        <div class="calculator" style="margin-top: 40px; margin-left: 40px">
          <input id="calculator-input" placeholder="0" oninput="handleInputChange(event)" onkeypress="handleKeyPress(event)">
          <input id="calculator-result" placeholder="Result" readonly>
          <div class="calculator-grid">
            ${["7", "8", "9", "/"].map(value => `
              <button class="calculator-button" onclick="handleButtonClick('${value}')">${value}</button>
            `).join('')}
            ${["4", "5", "6", "*"].map(value => `
              <button class="calculator-button" onclick="handleButtonClick('${value}')">${value}</button>
            `).join('')}
            ${["1", "2", "3", "-"].map(value => `
              <button class="calculator-button" onclick="handleButtonClick('${value}')">${value}</button>
            `).join('')}
            ${["0", ".", "(", ")"].map(value => `
              <button class="calculator-button" onclick="handleButtonClick('${value}')">${value}</button>
            `).join('')}
            ${["+", "="].map(value => `
              <button class="calculator-button" onclick="${value === '=' ? 'handleCalculate()' : `handleButtonClick('${value}')`}">${value}</button>
            `).join('')}
            <button class="calculator-button" onclick="handleButtonClick('^')">^</button>
            <button class="calculator-button" onclick="handleButtonClick('|')">|</button>
            <button class="calculator-button calculator-button-clear" onclick="handleClear()">Clear</button>
          </div>
        </div>
      </div>
    </div>
  `;

  return (
    <VStack spacing={4} align="center" marginBottom="5vh">
      {/* <Box width="100%" maxW="400px" borderWidth="1px" borderRadius="lg" p={5} boxShadow="lg" backgroundColor="gray.700"> */}
        <div dangerouslySetInnerHTML={{ __html: htmlCode }} />
      {/* </Box> */}
    </VStack>
  );
};

Why is red squiggly lines showing on valid javascript code in visual studio code?

I’m having an issue with these annoying red squiggly lines showing up under my import statement. It’s really bugging me because the code runs perfectly fine, and everything works as expected. The path I’m using in the require statement is correct and points to the right file in ‘.. > controllers > UserController’. I double-checked it, and there are no typos or mistakes. Despite this, the squiggly lines won’t go away. Has anyone else dealt with this before? Any tips on how to fix it or at least get rid of those distracting lines would be greatly appreciated!

enter image description here

Here is the error shown when hovering over the squiggly lines. The error occurred when I renamed my file.

enter image description here

How to check the checkbox without actually clicking it

I am working on a simple todo list, and I tried to link the todo, which is the task, with the checkbox, so when I click the task, the checkbox should be checked also.

But I don’t want to make a label and give it the attribute “for”, I want to make it by JavaScript, not by Html.

Is that possible?!!

I have tried to do as follows:

//JavaScript
let box = document.createElement("input")
box.setAttribute("type", "checkbox")
box.id = "box"

let label = document.createElement("label")
label.setAttribute("for", "box")

But it didn’t work with the rest of the code, because when i click on any label in the page, it checks only one checkbox.
Thanks For Helping

Equivalent of JS timedLoop in Swift

I have been programming in JavaScript for a while and have used the timedLoop command many times. Now I am transitioning to iOS app development and would like to do the same things I could in JS.

How would I be able to run code every 1 second in Swift?

I have looked into this but can’t seem to find a clear answer.

Is there a way to make JavaScript vars non user editable for websites?

I have vars in my JavaScript script for a HTML website, and when I go into console on this website I can edit these vars. For example, I have a button which is collected from the HTML into the JavaScript which is disabled until a different var is true, but the user can just edit either the other var, or just do button.disabled = true in the console.

I’m presuming there is a way to fix this, seeing as you can’t do this on normal websites.

Package Manager: NPM, PNPM or YARN [closed]

I have been using NPM for quite some time, but the problem is the speed and the place that “node_modules” takes. I recently discovered, on YouTube videos, PNPM, which seems to me, at first (without having tested it), a quick tool that avoids downloading the same packages for projects with the same dependencies, which is convenient. I would like your opinion on the reliability of this tool and especially in a production environment.

On my production servers, I don’t, can’t put Node.js. Currently, I only copy files like “jquery.min.js” by hand, then modify their inclusion path, which is quite inconvenient. But I would still like to have a package manager like NPM; PNPM; YARN, to manage the packages easily and update them easily, at least for development and then, in one order, be able to have a portable production version.

how to solve this wordpress plugin problem

    <form method="post" action="" id="genpro-add-form">
        <h3>Adding New Products:</h3>
        <table>
            <tr valign="top">
                <th><input type="text" placeholder="Serial" name="genpro_serial" /></th>
                <th><input type="text" placeholder="Code" name="genpro_code" /></th>
                <th><input type="text" placeholder="Year of Manufacture" name="genpro_year_of_manufacture" /></th>
                <th>
                    <select id="genpro_product_id" name="genpro_product_id" style="width: 100%;">
                        <option value="">Select a product</option>
                        <?php foreach ($products as $product): ?>
                            <option value="<?php echo esc_attr($product->get_id()); ?>">
                                <?php echo esc_html($product->get_name()); ?>
                            </option>
                        <?php endforeach; ?>
                    </select>
                </th>
                <?php wp_nonce_field('nonce_submit_action', 'nonce_submit'); ?>
                <th><input type="submit" value="+"></th>
            </tr>
        </table>
    </form>

    <form method="post" action="" id="genpro-bulk-form">
        <h3>Generate Bulk Codes:</h3>
        <table>
            <tr valign="top">
                <th><input type="text" placeholder="Year of Manufacture" name="genpro_year_of_manufacture" required /></th>
                <th>
                    <select id="genpro_bulk_product_id" name="genpro_product_id" style="width: 100%;" required>
                        <option value="">Select a product</option>
                        <?php foreach ($products as $product): ?>
                            <option value="<?php echo esc_attr($product->get_id()); ?>">
                                <?php echo esc_html($product->get_name()); ?>
                            </option>
                        <?php endforeach; ?>
                    </select>
                </th>
                <th><input type="number" placeholder="Amount" name="genpro_amount" required /></th>
                <?php wp_nonce_field('nonce_submit_action', 'nonce_submit'); ?>
                <th><input type="submit" name="genpro_generate_bulk" value="Generate Bulk Codes"></th>
            </tr>
        </table>
    </form>

    <table id='genpro-prodTable'>
        <tr class='title-row'>
            <th>Serial</th>
            <th>Code</th>
            <th>Year of Manufacture</th>
            <th>Product ID</th>
            <th>Registration Date</th>
            <th>Status</th>
            <th></th>
        </tr>
        <?php foreach ($final_products as $final_product): ?>
            <tr class='data-row'>
                <td><?php echo esc_html($final_product->serial); ?></td>
                <td><?php echo esc_html($final_product->code); ?></td>
                <td><?php echo esc_html($final_product->year_of_manufacture); ?></td>
                <td><?php echo esc_html($final_product->product_id); ?></td>
                <td><?php echo esc_html($final_product->reg_date); ?></td>
                <td><?php echo $final_product->is_verified ? 'Verified on ' . esc_html($final_product->verified_at) : 'Not Verified'; ?></td>
                <td>
                    <form method="post" action="">
                        <input type="hidden" name="genpro_delete" value="<?php echo esc_attr($final_product->serial); ?>" />
                        <?php wp_nonce_field('nonce_submit_action', 'nonce_submit'); ?>
                        <input type="submit" value="Delete">
                    </form>
                </td>
            </tr>
        <?php endforeach; ?>
    </table>
<?php
}


// Handle form submission via AJAX
add_action('wp_ajax_genpro_handle_form_submission', 'genpro_handle_form_submission');

function genpro_handle_form_submission() {
    check_ajax_referer('genpro_nonce', 'nonce');

    global $wpdb;
    $table_name = $wpdb->prefix . 'genpro_products';
    $response = array();

    if (isset($_POST['genpro_generate_bulk'])) {
        $year_of_manufacture = sanitize_text_field($_POST['genpro_year_of_manufacture']);
        $product_id = intval($_POST['genpro_product_id']);
        $amount = intval($_POST['genpro_amount']);
        
        genpro_generate_bulk_codes($year_of_manufacture, $product_id, $amount);

        $response['message'] = 'Bulk codes generated successfully!';
    } else {
        $genpro_serial = isset($_POST['genpro_serial']) ? sanitize_text_field($_POST['genpro_serial']) : '';
        $genpro_code = isset($_POST['genpro_code']) ? sanitize_text_field($_POST['genpro_code']) : '';
        $genpro_year_of_manufacture = isset($_POST['genpro_year_of_manufacture']) ? sanitize_text_field($_POST['genpro_year_of_manufacture']) : '';
        $genpro_product_id = isset($_POST['genpro_product_id']) ? intval($_POST['genpro_product_id']) : 0;

        if (!empty($genpro_serial) && !empty($genpro_code)) {
            $exist = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$table_name} WHERE serial = %s OR code = %s", $genpro_serial, $genpro_code));
            if (!$exist) {
                $wpdb->insert($table_name, [
                    'serial' => $genpro_serial,
                    'code' => $genpro_code,
                    'year_of_manufacture' => $genpro_year_of_manufacture,
                    'product_id' => $genpro_product_id,
                    'reg_date' => current_time('mysql')
                ]);
                $response['message'] = 'Product added successfully!';
            } else {
                wp_send_json_error(array('message' => 'Product already exists or invalid!'));
            }
        } else {
            wp_send_json_error(array('message' => 'Please fill all required fields!'));
        }
    }

    // Get updated products list
    $final_products = $wpdb->get_results("SELECT * FROM {$table_name}", OBJECT);
    ob_start();
    ?>
    <tr class='title-row'>
        <th>Serial</th>
        <th>Code</th>
        <th>Year of Manufacture</th>
        <th>Product ID</th>
        <th>Registration Date</th>
        <th>Status</th>
        <th></th>
    </tr>
    <?php foreach ($final_products as $final_product): ?>
        <tr class='data-row'>
            <td><?php echo esc_html($final_product->serial); ?></td>
            <td><?php echo esc_html($final_product->code); ?></td>
            <td><?php echo esc_html($final_product->year_of_manufacture); ?></td>
            <td><?php echo esc_html($final_product->product_id); ?></td>
            <td><?php echo esc_html($final_product->reg_date); ?></td>
            <td>
                <?php echo $final_product->is_verified ? 'Verified on ' . esc_html($final_product->verified_at) : 'Not Verified'; ?>
            </td>
            <td>
                <form method="post" action="">
                    <input type="hidden" name="genpro_delete" value="<?php echo esc_attr($final_product->serial); ?>" />
                    <?php wp_nonce_field('nonce_submit_action', 'nonce_submit'); ?>
                    <input type="submit" value="Delete">
                </form>
            </td>
        </tr>
    <?php endforeach; ?>
    <?php
    $response['table_html'] = ob_get_clean();

    wp_send_json_success($response);
}


enter image description here
ok , there are some problems with this code , when i want to generate bulk code , even when i entered the year and amount and product , it says Please fill all required fields! there are two ways of making serial for a product , one manual and one bulk .
help me Guys!

i’m a newbie in php

Javascript message box pop up

hoping someone can help! I am running the below js code to check for a value over $10.00 and display a pop up box if this is true (in a power app model app- OnChange event). The code works and the pop up appears but it appears if the user enters in any amount. I need this pop up to display only if the value is over $10.00.

function Logic2(executionContext)
{
  var formContext = executionContext.getFormContext();
  if(formContext.getAttribute("cr166_moneyseized").value>=10)
  {
  var messageBox = 
    {
    confirmButtonLabel:"MG",
    text:"Message box",
    title:"Hello"
    }
  var messageBoxOptions =
    height:300,
    width:400
  }

  Xrm.Navigation.openAlertDialog(messageBox,messageBoxOptions).then
    (
    function(success){},
    function(error){ console.log("Error...") }
    )
}
}

Tried the above code but it’s not working right

How to Detect the Uploaded Image Face that Matches Faces in Local Images

I have developed an Angular application that use face-api.js for face recognition. The application processes a set of local images to identify faces and generates corresponding face descriptors. When a new image is uploaded, the application detects and extracts the face descriptor from the uploaded image, then compares it against the descriptors of the local images to find and return all images containing matching faces

 selectedFile: any;
  localImages = ['assets/photo/face1.png', 'assets/photo/face2.png', 'assets/photo/faces.jpg']; // Add paths to your local images
  faceDescriptors: faceapi.LabeledFaceDescriptors[] = [];
  images: string[] = [];

  async ngOnInit() {
    await this.loadModels();
    await this.loadLocalImages();
  }

  async loadModels() {
    try {
      await faceapi.nets.ssdMobilenetv1.loadFromUri('/assets/models');
      await faceapi.nets.faceLandmark68Net.loadFromUri('/assets/models');
      await faceapi.nets.faceRecognitionNet.loadFromUri('/assets/models');
      console.log('Models loaded successfully');
    } catch (error) {
      console.error('Error loading models:', error);
    }
  }

  async loadLocalImages() {
    try {
      for (const imagePath of this.localImages) {
        const img = await faceapi.fetchImage(imagePath);
        const detections = await faceapi.detectSingleFace(img).withFaceLandmarks().withFaceDescriptor();
        if (detections) {
          const label = imagePath; // Use image file path as label
          this.faceDescriptors.push(new faceapi.LabeledFaceDescriptors(label, [detections.descriptor]));
          console.log(`Loaded descriptor for ${label}:`, detections.descriptor);
        } else {
          console.log(`No face detected in ${imagePath}`);
        }
      }
      console.log('Local images loaded and processed:', this.faceDescriptors);
    } catch (error) {
      console.error('Error loading local images:', error);
    }
  }

  onFileSelected(event: any) {
    this.selectedFile = event.target.files[0];
    console.log('File selected:', this.selectedFile);
  }

  async onUpload() {
    if (this.selectedFile) {
      const reader = new FileReader();
      reader.onload = async () => {
        try {
          const imageBlob = this.dataURLToBlob(reader.result as string);
          if (imageBlob) {
            const img = await faceapi.bufferToImage(imageBlob);
            const detection = await faceapi.detectSingleFace(img).withFaceLandmarks().withFaceDescriptor();
            if (detection) {
              console.log('Uploaded image descriptor:', detection.descriptor);
              const faceMatcher = new faceapi.FaceMatcher(this.faceDescriptors);
              const threshold = 0.6; // Adjust this value as needed

              // Find matches based on the threshold
              const matchedImageURLs = this.faceDescriptors
                .filter(descriptor => faceMatcher.findBestMatch(detection.descriptor).distance < threshold)
                .map(descriptor => descriptor.label);

              if (matchedImageURLs.length > 0) {
                console.log('Matched image URLs:', matchedImageURLs);
                this.images = matchedImageURLs;
              } else {
                this.images = [];
                console.log('No exact matches found.');
              }
            } else {
              this.images = [];
              console.log('No face detected in the uploaded image.');
            }
          } else {
            this.images = [];
            console.error('Failed to convert Data URL to Blob.');
          }
        } catch (error) {
          console.error('Error processing uploaded image:', error);
        }
      };
      reader.readAsDataURL(this.selectedFile);
    }
  }


The current issue with this code is that it does not return the matching face images.

trying to call my api dynamically but all my categories are returning undefined

I am building a mock movie website using an api and I am trying to dynamically call the api to show specific details for the movie that was clicked on by the user, but all of my categories are returning undefined. not entirely sure what to do next.

this is the code for the current component i am working on

import React from "react";
import Nav from "../ui/Nav";
import axios from "axios";

const MovieCard = ({ movie: {Released, Actors, Genre, Director, Writer, Language, Plot } })

const API_URL = "http://www.omdbapi.com/?apikey=cca6a59";

async function moveDesc(imdbID) {
    const { movie } = await axios.get(`${API_URL}&i=${imdbID}`);
}

function Moviecard() {
  return (
    <>
      <Nav />
      <div className="movie__img--wrapper">
        <h1>${movie.Title}</h1>
        <img src={`${movie.Poster}`} alt="" />
      </div>
      <div className="movie__info--wrapper" key={imdbID}>
        <h3>
          <span className="red">Released: </span>${movie.Released}
        </h3>
        <h3>
          <span className="red">Actors: </span>${movie.Actors}
        </h3>
        <h3>
          <span className="red">Genre: </span>${movie.Genre}
        </h3>
        <h3>
          <span className="red">Director: </span>${movie.Director}
        </h3>
        <h3>
          <span className="red">Writer: </span>${movie.Writer}
        </h3>
        <h3>
          <span className="red">Language: </span>${movie.Language}
        </h3>
        <h3>
          <span className="red">Plot: </span>${movie.Plot}
        </h3>
      </div>
    </>
  );
}

export default Moviecard;