Get a the contents of a span class of a website from js code

I am currently using the code:

   aboutTest = () => {
        const { username } = this.state;
        const proxyUrl = 'https://cors-anywhere.herokuapp.com/'; // Proxy URL to bypass CORS
        const targetUrl = `http://roblox.com/users/profile?username=${username}`; // Target URL
    
        fetch(proxyUrl + targetUrl, {
            method: 'GET',
            headers: {
                'Accept': 'text/html', // Accept HTML content
            }
        })
        .then(response => {
            if (!response.ok) {
                throw new Error('Network response was not ok');
            }
            return response.text(); // Parse response body as text
        })
        .then(htmlContent => {
            // Handle the HTML response data
            const parser = new DOMParser();
            const htmlDoc = parser.parseFromString(htmlContent, 'text/html');
            const elements = htmlDoc.querySelectorAll('span.profile-about-content-text');
            if (elements.length > 0) {
                console.log("Found elements with class 'profile-about-content-text':");
                elements.forEach(element => {
                    console.log(element.textContent.trim());
                });
            } else {
                console.log("No elements found with class 'profile-about-content-text'");
            }
        })
        .catch(error => {
            // Handle errors
            console.error('There was a problem with the fetch operation:', error);
        })
        .finally(() => {
            console.log("Function execution completed."); // Log completion of function execution
        });   
    }

yet when i try and run, no matter what i get the same response of no elements found in this class.

i have tried changing the const elements = htmlDoc.querySelectorAll('span.profile-about-content-text') removing the span, the dot and writing using the different names the image below could haveenter image description here

i am looking to call the in this case “beautiful dog rainbow dog car” but i think the problem may be that the url “https://roblox.com/users/profile?username=$%7Busername%7D” redirects to an url that looks like this: https://www.roblox.com/users/2630350688/profile (uses the user id) and i havent got the code to call from the redirected url but from the first url.

Does anyone have a fix – if so please write an answer

Binance Order Book – BUY and SELL Bars

This is a question regarding the order book on Binance’s trading page, like here: https://www.binance.com/en-GB/trade/SOL_USDT?_from=markets&type=spot

I am confused as to how the width of the bars in the order book are being calculated. I mean the red SELL bars and the green BUY bars at different price levels. If you check the HTML on the Binance trading page, I am specifically referring to the the ‘.progress-bar’ elements.

The width of the bars are obviously some calculation representing how big the order size is. However the width of the bars is NOT based on a comparative percentage with the largest order size in the book. You can tell this because several bars are more than 100% in width, so the calculation must be slightly more complex.

Does anyone know how the width of those bars are calculated?

Conection with JavaScript to rust

I have a question, so please, if you know how I can do this, tell me. I need to implement the following in Rust: Develop a graphical user interface application in the chosen programming language that simulates the operation of three stopwatches controlled by three threads, each performing incremental increases of one second, three seconds, and six seconds, respectively. Each stopwatch should feature four buttons (Start, Pause, Resume, Stop (kill the thread)), and a general button that pauses the progress of all three stopwatches for five seconds.

Here My codes: In this Order, HTML, JAVASCRIPT, RUST MAIN

<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CRONOMETROS</title>
    <style>
        body, html {
            height: 100%;
            margin: 0;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .contenedor {
            width: 200px;
            height: 350px;
            background-color: #1B72E4 ;
            border: 2px solid #3777CB ;
            text-align: center;
            padding: 20px;
            margin-right: 40px;
            border-radius: 20px;
        
        }

        .resultado {
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
            background-color: white;
            border: 2px solid lightgrey;
            font-size: 35px;
            font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
            margin-bottom: 50px;
            width: 200px;
            height: 50px;
            border-radius: 20px;
            margin-top: 10px;

        }

        .botonInicio {
            width: 100%;
            padding: 10px 0;
            margin-top: 10px;
            background-color: #4CAF50;
            border: none;
            color: white;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
            font-size: 16px;
            cursor: pointer;
            border-radius: 5px;
            letter-spacing: 2px;

        }

        .botonPausar {
            width: 100%;
            padding: 10px 0;
            margin-top: 10px;
            background-color: #EE7E21;
            border: none;
            color: white;
            text-align: center;
            text-decoration: none;
            font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
            display: inline-block;
            font-size: 16px;
            cursor: pointer;
            border-radius: 5px;
            letter-spacing: 1px;


        }

        .botonReiniciar {
            width: 100%;
            padding: 10px 0;
            margin-top: 10px;
            background-color:#F2D30A  ;
            border: none;
            color: white;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 16px;
            cursor: pointer;
            font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
            border-radius: 5px;
            letter-spacing: 1px;


        }

        .botonDetener {
            width: 100%;
            padding: 10px 0;
            margin-top: 10px;
            background-color: #DD0A03  ;
            border: none;
            color: white;
            text-align: center;
            text-decoration: none;
            font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
            font-size: 15px;
            display: inline-block;
            font-size: 16px;
            cursor: pointer;
            border-radius: 5px;
            letter-spacing: 1px;
        }

        .botonDetenerTodos {
            position: fixed;
            width: 815px;
            height: 50px; 
            bottom: 45px; 
            font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
            font-size: 15px;
            left: 50%;
            transform: translateX(-53.1%);
            background-color: #DD0A03 ;
            text-align: center;
            color:white;
            letter-spacing: 2px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div  class="contenedor">
        <div id="crono1" class="resultado">5</div>
        <div>
          <button  class="botonInicio"   id="iniciar1" >INICIAR</button>
          <button  class="botonPausar"  id="pausar1" >PAUSAR</button>
          <button class="botonReiniciar"  id="reiniciar1">REINICIAR</button>
          <button  class="botonDetener"  id="detener1" >DETENER</button>
        </div>
    </div>
    <div class="contenedor">
        <div id="crono2" class="resultado">10</div>
        <div>
            <button  class="botonInicio"   id="iniciar2" >INICIAR</button>
            <button  class="botonPausar"  id="pausar2" >PAUSAR</button>
            <button class="botonReiniciar"  id="reiniciar2">REINICIAR</button>
            <button  class="botonDetener"  id="detener2" >DETENER</button>
        </div>
    </div>
    <div class="contenedor">
        <div id="crono3" class="resultado">5</div>
        <div>
            <button class="botonInicio" id="iniciar3">INICIAR</button>
            <button  class="botonPausar" id="pausar3">PAUSAR</button>
            <button  class="botonReiniciar" id="reiniciar3" >REINICIAR</button>
            <button  class="botonDetener" id="detener3" >DETENER</button>
        </div>
    </div>
    <div>
        <button class="botonDetenerTodos" id="DetenerTodos">DETENER TODOS LOS CRONOMETROS POR 5 SEGUNDOS</button>
    </div>
   <script src="./main.js"></script>
</body>

  
</html>

Java Script

const iniciar1 = document.querySelector('#iniciar1')
const iniciar2 = document.querySelector('#iniciar2')
const iniciar3 = document.querySelector('#iniciar3')

const pausar1 = document.querySelector('#pausar1')
const pausar2 = document.querySelector('#pausar2')
const pausar3 = document.querySelector('#pausar3')

const reiniciar1 = document.querySelector('#reiniciar1')
const reiniciar2 = document.querySelector('#reiniciar2')
const reiniciar3 = document.querySelector('#reiniciar3')

const detener1 = document.querySelector('#detener1')
const detener2 = document.querySelector('#detener2')
const detener3 = document.querySelector('#detener3')

const { invoke } = window.__TAURI__.tauri;

const detenerTodos = document.querySelector('#DetenerTodos')

iniciar1.addEventListener('click', () => {
  invoke('enviarAccion', { accion: 'detener1' })
});


iniciar2.addEventListener('click', () => {
  invoke('greet')
 })

iniciar3.addEventListener('click', () => {
  invoke('greet')
 })

pausar1.addEventListener('click', () => {
  invoke('greet')
})

pausar2.addEventListener('click', () => {
  invoke('greet')
})

pausar3.addEventListener('click', () => {
  invoke('greet')
})

reiniciar1.addEventListener('click', () => {
  invoke('greet')
})

reiniciar2.addEventListener('click', () => {
  invoke('greet')
})

reiniciar3.addEventListener('click', () => {
  invoke('greet')
})

detener1.addEventListener('click', () => {
  invoke('greet')
})

detener2.addEventListener('click', () => {
  invoke('greet')
})

detener3.addEventListener('click', () => {
  invoke('greet')
})

detenerTodos.addEventListener('click', () => {
  invoke('greet')
})




 



let greetInputEl;
let greetMsgEl;

async function greet() {
  // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
  greetMsgEl.textContent = await invoke("greet", { name: greetInputEl.value });
}

window.addEventListener("DOMContentLoaded", () => {
  greetInputEl = document.querySelector("#greet-input");
  greetMsgEl = document.querySelector("#greet-msg");
  document.querySelector("#greet-form").addEventListener("submit", (e) => {
    e.preventDefault();
    greet();
  });
});

RUST MAIN

use std::sync::mpsc;
use std::thread;
use std::time::Duration;

// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn iniciar(accion: String) -> String{
    println!("sirve:");
    format!("{}",accion).into()
}


fn main() {
    tauri::Builder::default()
        .invoke_handler(tauri::generate_handler![iniciar])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
    let (_in1, r1) = mpsc::channel();
    let mut activo_1 = false;
    let mut contador1 = 0;
    let mut mensaje1 = "";

    thread::spawn(move || {
        loop {
            while activo_1 {
                thread::sleep(Duration::new(1, 0));
                contador1 += 1;
                println!( "ads {}",contador1);
                mensaje1 = r1.recv().unwrap();
                if mensaje1 == "pausar" {
                    activo_1 = false;
                }
                if mensaje1 == "detener" {
                    activo_1 = false;
                }
                if mensaje1 == "reiniciar" {
                    contador1 = 0;
                    activo_1 = false;
                }
            }
            mensaje1 = r1.recv().unwrap();
            if mensaje1 == "iniciar" {
                activo_1 = true;
            }
            if mensaje1 == "detener" {
                break;
            }
        }
    });
    let (_in2, r3) = mpsc::channel();

    let mut activo_3 = false;
    let mut contador3 = 0;
    let mut mensaje = "";

    thread::spawn(move || {
        loop {
            while activo_3 {
                thread::sleep(Duration::new(3, 0));
                contador3 += 1;
                mensaje = r3.recv().unwrap();
                if mensaje == "pausar" {
                    activo_3 = false;
                }
                if mensaje == "detener" {
                    activo_3 = false;
                }
                if mensaje == "reiniciar" {
                    contador3 = 0;
                    activo_3 = false;
                }
            }
            mensaje = r3.recv().unwrap();
            if mensaje == "iniciar" {
                activo_3 = true;
            }
            if mensaje == "detener" {
                break;
            }
        }
    });
    let mut activo_6 = false;
    let mut contador6 = 0;
    let mut mensaje6 = "";

    let (_in3, r6) = mpsc::channel();
    thread::spawn(move || {
        loop {
            while activo_6 {
                thread::sleep(Duration::new(6, 0));
                contador6 += 1;
                mensaje6 = r6.recv().unwrap();
                if mensaje6 == "pausar" {
                    activo_6 = false;
                }
                if mensaje6 == "detener" {
                    activo_6 = false;
                }
                if mensaje6 == "reiniciar" {
                    contador6 = 0;
                    activo_6 = false;
                }
            }
            mensaje6 = r6.recv().unwrap();
            if mensaje6 == "iniciar" {
                activo_6 = true;
            }
            if mensaje6 == "detener" {
                break;
            }
        }
    });
}

However, I’ve been using Tauri, and I need to pass a parameter to my main function to execute the threads in my graphical user interface application. Could you please advise on the best approach to use my buttons to activate the stopwatches in the main function? Specifically, I’ll need the listener to pass a String to the main function when a button is clicked

how to correctly update the queue of audios to play? When the server first reloads, it takes two clicks for the onNext to work

After the second onNext click, everything functions as expected. However, when I select a song randomly instead of navigating through the list using the onNext and onPrevious buttons, I encounter a problem. I need to determine the current index of the song that is playing so that I can properly use the onNext and onPrevious functions based on this index. Could you help me rewrite or address this issue more effectively?

This is my hook:

import { useState, useEffect, useCallback } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useGlobalAudioPlayer } from "react-use-audio-player";
import { arraysEqual } from "../utils/helper";
import {
  getPlayerState,
  updateOnGoingAudio,
  updateOnGoingList,
} from "../../redux/Features/player_slice";

const useAudioPlayback = () => {
  const { onGoingList } = useSelector(getPlayerState);
  const dispatch = useDispatch();
  const [currentIndex, setCurrentIndex] = useState(-1);
  const [currentTime, setCurrentTime] = useState(0);

  const {
    load,
    play,
    pause,
    playing,
    stop,
    seek,
    duration,
    togglePlayPause,
    getPosition,
  } = useGlobalAudioPlayer();

  // Adjust how the song queue is updated
  const updateQueue = useCallback(
    (data, selectedSongId) => {
      const formattedList = data.map((item) => ({
        id: item.id,
        title: item.title,
        url: item.file,
        artwork: item.poster,
        artist: item.owner.name,
        genre: item.category,
      }));

      const selectedSongIndex = formattedList.findIndex(
        (song) => song.id === selectedSongId
      );
      dispatch(updateOnGoingList(formattedList));

      if (selectedSongIndex !== -1) {
        setCurrentIndex(selectedSongIndex);
        dispatch(updateOnGoingAudio(formattedList[selectedSongIndex]));
        load(formattedList[selectedSongIndex].url, { autoplay: true });
      }
    },
    [dispatch, load]
  );

  // Track position update in useEffect
  useEffect(() => {
    let interval = setInterval(() => {
      if (playing) {
        const position = getPosition();
        setCurrentTime(position);
      }
    }, 1000);
    return () => clearInterval(interval);
  }, [playing, getPosition]);

  // Load and play the song at currentIndex
  useEffect(() => {
    if (onGoingList.length > 0 && currentIndex !== -1) {
      load(onGoingList[currentIndex].url, {
        autoplay: true,
        onend: () => {
          if (currentIndex < onGoingList.length - 1) {
            setCurrentIndex((prevIndex) => prevIndex + 1);
          } else {
            stop();
          }
        },
      });
      dispatch(updateOnGoingAudio(onGoingList[currentIndex]));
    }
  }, [currentIndex, onGoingList, dispatch, load, stop]);

  // Navigation functions
  const onNext = useCallback(() => {
    setCurrentIndex((prevIndex) =>
      prevIndex < onGoingList.length - 1 ? prevIndex + 1 : prevIndex
    );
  }, [onGoingList.length]);

  const onPrevious = useCallback(() => {
    setCurrentIndex((prevIndex) => (prevIndex > 0 ? prevIndex - 1 : 0));
  }, []);

  const onAudioPress = useCallback(
    (item, data) => {
      const isNewQueue =
        onGoingList.length === 0 || !arraysEqual(onGoingList, data);
      if (isNewQueue) {
        updateQueue(data, item.id);
      } else {
        const selectedIndex = onGoingList.findIndex(
          (audio) => audio.id === item.id
        );
        if (selectedIndex !== currentIndex) {
          setCurrentIndex(selectedIndex);
          load(onGoingList[selectedIndex].url, { autoplay: true });
        } else {
          togglePlayPause();
        }
      }
    },
    [onGoingList, updateQueue, currentIndex, load, togglePlayPause]
  );

  return {
    onAudioPress,
    play,
    pause,
    playing,
    currentIndex,
    stop,
    seek,
    togglePlayPause,
    duration,
    currentTime,
    onNext,
    onPrevious,
  };
};

export default useAudioPlayback;

I tried debugging and seeing how current index is setup but could not figure out

ckeditor5 DropdownField label does not update

Within a drupal module, a custom plugin has been created. I am using the advanced plugin walkthru from ck5 docs to implement a contextual balloon.

Objective: Have a dropdown populate its button label so that a user can see the selection made.

The contextual balloon has a dropdown like so…

  1. has my attempt at binding to the label within that field but does nothing after clicking an option
  2. WORKS but is now permanently set for any future balloons a user might insert.

How can i achieve this basic task so that users can see a field get updated after clicking?

view.js

const styleOptions = [
  ['defaultTable', 'Default'],
  ['tableScrollable', 'Scrollable (horizontal)'],//
  ['tableVerticalScrollable', 'Scrollable (vertical)'],
  ['tableCompactScrollable', 'Compact Scrollable (horizontal)'],
  ['tableSortable', 'Sortable'],
  ['tableWithSearch', 'Scrollable with search'],
  ['tableStacked', 'Responsive stacked'],
];
export default class FormView extends View {
  constructor(locale) {
   this.headerRowsView = this._createDropdown('Headers', headerOptions);
   this.headerRowsView.items = headerOptions;
    
    // 1. my attempt at trying to bind
    this.headerRowsView.fieldView.buttonView.bind('label').to(this, 'styleOption', value => {
       return value ? value : 'defaultTable'
    });
   
   this.headerRowsView.fieldView.on('execute', evt => {
      const { id, label } = evt.source;
      this.headerRowsViewValue = id;
      /// 2. This works almost but its permanent for all balloons appearing
      //this.headerRowsView.fieldView.buttonView.label = label;
      //this.headerRowsView.fieldView.class = 'ck-dropdown-selected';
    });
    this.childViews = this.createCollection([
      this.headerRowsView,
    ]);
    this._focusCycler = new FocusCycler({ ... });
    this.setTemplate({ ... });
  }
  _createDropdown(label, options) {
    const dropdown = new LabeledFieldView(this.locale, createLabeledDropdown);
    const bind = this.bindTemplate;
    dropdown.set({
      label: label,
      class: 'ck-table-form__style-options'
    });
    dropdown.fieldView.buttonView.set({
      isOn: true,
      withText: true,
    });

    // **** It would be nice to bind the label here to return the value

    const opts_collection = this._createDropdownItems(options);
    addListToDropdown(dropdown.fieldView, opts_collection, {
      role: 'menu',
      tooltip: 'Options'
    });
    return dropdown;
  }
   _createDropdownItems(options) {
     const items = new Collection();
     options.forEach(opt => {
      items.add({
        type: 'button',
        model: new Model({
          withText: true,
          label: opt[1],
          id: opt[0],
        }),
      });
    });
    return items;
  }
}

User Manager does not send a correct request

<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>User Form</title>
</head>
<body>
<h1>User Form</h1>
<form id="userForm">
    <label for="firstname">First Name:</label>
    <input type="text" id="firstname" name="firstname" required><br><br>

    <label for="lastname">Last Name:</label>
    <input type="text" id="lastname" name="lastname" required><br><br>

    <label for="mail">Email:</label>
    <input type="email" id="mail" name="mail" required><br><br>

    <label for="password">Password:</label>
    <input type="password" id="password" name="password" required><br><br>

    <button type="button" onclick="addUser()">Hinzufügen</button>
</form>

<div id="userData"></div>

<script>
    async function addUser() {
        const form = document.getElementById('userForm');
        const formData = new FormData(form);
        const userData = {
            firstname: formData.get('firstname'),
            lastname: formData.get('lastname'),
            mail: formData.get('mail'),
            password: formData.get('password')
        };

        const response = await fetch('https://userman.thuermer.red/api/users/', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify(userData)
        });

        if (response.ok) {
            await displayUserData();
        } else {
            alert('Failed to add user.');
        }
    }

    async function displayUserData() {
        const userDataDiv = document.getElementById('userData');
        userDataDiv.innerHTML = '';

        const response = await fetch('https://userman.thuermer.red/api/users/', {
            method: 'GET',
            headers: {
                'Content-Type': 'application/json'
            }
        });

        if (!response.ok) {
            alert('Failed to fetch user data.');
            return;
        }

        const userDataList = await response.json();

        userDataList.forEach(user => {
            const userDiv = document.createElement('div');
            userDiv.innerHTML = `
                    <p>First Name: ${user.firstname}</p>
                    <p>Last Name: ${user.lastname}</p>
                    <p>Email: ${user.mail}</p>
                    <p>Password: ${user.password}</p>
                    <hr>
                `;
            userDataDiv.appendChild(userDiv);
        });
    }

    // Display user data on initial page load
    displayUserData();
</script>
</body>
</html>

It is supposed to be a CRUD user manager but posting and retrieving does not seem to work properly. When posting, there is simply no POST to the server and when loading only the default 0 entry appears. What have I overlooked?

It has already been checked that the server assignment is correct without success. The rendering was checked without success.

Execute after ajax is complete — without accessing the ajax function?

I need to perform a JS function after an ajax function is complete (filtering posts in WordPress). However, the ajax filter tool is created by a WordPress plugin that I can’t edit. How can I detect that a particular ajax call has finished when I didn’t create the ajax function?

For example (I know this isn’t correct, but trying to show what I want to do):

  $(document).on("AJAX HAS FINISHED", function(){
        console.log("ajax complete");
        activatePopup();
  });

Can this be done?

Read query parameters of a script tag source link inserted using JavaScript

My website has a library that loads external JavaScript sources like this.

const script = document.createElement('script');
script.src = 'https://example.com/file.js?test=123';
script.async = true;
document.body.appendChild(script);

How to programmatically detect whenever a script is added to the site using this method and further how to read the src parameter to access the query parameters (?test=123 in this case)?

I can do this for sendBeacon and XHR requests but what about scripts loaded as seen above?

Capturing data from AJAX-loaded modals using jQuery and JavaScript, encountering issues with capturing data from previous modals when opening new ones

I have a modal where I use AJAX with jQuery and JavaScript to make a GET request and display some data. Within this modal, there’s a button that, when clicked, captures some data. I’ve added a console.log to verify if the data is being captured, and indeed it is. However, when I close this modal, open another one, and repeat the same steps, clicking the button shows in the console.log that it has captured data from previous modals along with the current one. I need it to only capture data from the current modal.

/* Evento que abre o modal dinamicamente */
        $(document).ready(function() {
            $('.btnBatchModal').click(function() {
                var cd_regiao = $(this).data("cd-regiao");
                var nr_grupo = $(this).data("nr-grupo");
                var cd_lote = $(this).data("cd-lote");
                var ano_base = $(this).data("ano-base");
                var urlBatch = 'show/' + cd_regiao + '/' + nr_grupo + '/' + cd_lote + '/' + ano_base;

                $.ajax({
                    url: urlBatch,
                    method: "get",
                    success: function(data) {
                        var batch = JSON.parse(data);
                        var formData = null;

                        $('#tableAssoc').empty();

                        $('#showBatchHeader h1.modal-title').html('Lote ' + batch.showBatches[0].cd_capa_de_lote +
                            ' - ' + 'Grupo ' + batch.showBatches[0].nr_grupo + '/' + batch.showBatches[0].cd_regiao);

                        var count = 0;

                        batch.showBatches.forEach(function(item) {

                            if (item.nr_cpf == null) {
                                item.nr_cpf = ' - ';
                            }

                            //ABA ASSOCIADOS
                            var htmlAssoc =
                                `   <hr class="border border-dark border-2">
                                    <div class="col-2" id="nr_cpf_${count}">
                                        <p>${item.nr_cpf}</p>
                                    </div>
                                    <div class="col-2" id="nr_registro_${count}">
                                        <p>${item.nr_registro}</p>
                                    </div>
                                    <div class="col-4" id="nm_associado_${count}">
                                        <p>${item.nm_associado}</p>
                                    </div>
                                    <div class="col-2" id="dt_validade_${count}">
                                        <p>${moment(item.dt_validade).format('DD/MM/YYYY')}</p>
                                    </div>
                                    <div class="col-2" id="fl_ativo_${count}">
                                        <p>${item.fl_ativo}</p>
                                    </div>`;

                            $('#tableAssoc').append(htmlAssoc);
                            count++;
                        });

                        //ABA INFORMACOES REGISTRO
                        $('#qt_inclusao').html(batch.showBatches[0].qt_inclusao);
                        $('#qt_renovacao').html(batch.showBatches[0].qt_renovacao);
                        $('#qt_retorno').html(batch.showBatches[0].qt_retorno);
                        $('#qt_transferido').html(batch.showBatches[0].qt_transferido);
                        $('#qt_segunda_via').html(batch.showBatches[0].qt_segunda_via);
                        $('#qt_credencial_pai_responsavel').html(batch.showBatches[0].qt_credencial_pai_responsavel);
                        $('#qt_credencial_mae').html(batch.showBatches[0].qt_credencial_mae);
                        //$('#qt_credencial_impressa').html(batch.showBatches[0].qt_credencial_impressa);

                        //ABA VALORES
                        $('#vl_desconto').html('R$ ' + batch.showBatches[0].vl_desconto);
                        $('#vl_cota_registro').html('R$ ' + batch.showBatches[0].vl_cota_registro);
                        $('#qt_distintivo_anual').html(batch.showBatches[0].qt_distintivo_anual);
                        $('#vl_distintivo_anual').html('R$ ' + batch.showBatches[0].vl_distintivo_anual);

                        //METODO DE PAGAMENTO
                        if (batch.showBatches[0].nr_boleto == null && batch.showBatches[0].dt_confirmacao_cartao == null) {
                            $('#accordionMtdPagamento').hide();

                        } else {
                            $('#accordionMtdPagamento').show();
                        }

                        if (batch.showBatches[0].nr_boleto) {
                            $('#nr_boleto').html(batch.showBatches[0].nr_boleto);
                            $('#vl_boleto').html('R$ ' + batch.showBatches[0].vl_boleto);
                            $('#dt_vencimento').html(moment(batch.showBatches[0].dt_vencimento).format('DD/MM/YYYY'));
                            $('#dt_pagamento').html(moment(batch.showBatches[0].dt_pagamento).format('DD/MM/YYYY'));

                            if (batch.showBatches[0].nr_parcelas == null) {
                                $('#nr_parcelas').html(' - ');
                            } else {
                                $('#nr_parcelas').html(batch.showBatches[0].nr_parcelas);
                            }

                            $('#rowBoleto').show();
                            $('#rowBoleto1').show();
                        } else {
                            $('#rowBoleto').hide();
                            $('#rowBoleto1').hide();
                        }

                        if (batch.showBatches[0].dt_confirmacao_cartao) {
                            $('#vl_cartao').html('R$ ' + batch.showBatches[0].vl_cartao);
                            $('#dt_confirmacao_cartao').html(moment(batch.showBatches[0].dt_confirmacao_cartao).format('DD/MM/YYYY'));
                            $('#rowCartao').show();
                        } else {
                            $('#rowCartao').hide();
                        }

                        if (batch.showBatches[0].ds_observacao_descontos) {
                            $('#ds_observacao_descontos').html(batch.showBatches[0].ds_observacao_descontos);
                            $('#accordionObs').show();
                        } else {
                            $('#accordionObs').hide();
                        }

                        $('#showBatchModal').modal("show"); //abrir modal


                        /* Evento que libera os lotes pelo botão */
                        $('#btnBatchUnlock').click(function(e) {
                            e.preventDefault();
                            formData = {
                                'cd_capa_de_lote': batch.showBatches[0].cd_capa_de_lote,
                                'nr_grupo': batch.showBatches[0].nr_grupo,
                                'cd_regiao': batch.showBatches[0].cd_regiao,
                                'dt_base_calculo': batch.showBatches[0].dt_base_calculo,
                            }
                            var urlBatchUnlock;

                            // $.ajax({
                            //     url: urlBatchUnlock,
                            //     method: "post",
                            //     success: function(data) {}
                            // });
                            
                            
                        });

                        console.log(formData);

                        $("#showBatchModal").on("hidden.bs.modal", function() {
                            formData = null;
                        });

                        /* Fim evento que libera os lotes pelo botão */
                    },
                });
            });
        });
        /* Fim evento modal */

I’ve tried modifying the code several times, including clearing the array when the modal opens or closes, but nothing seems to work.I need it to capture ONLY the data from the current modal. I’ve tried several attempts to clear the array, but it seems like it doesn’t recognize that.

DigitalPersona 4500 – Fingerprint Hash to WEB

I was doin’ some research but I haven’t really found anything but scrambled information and lack of needed resources…

I wanted to enroll patients on a web app, php/js… has anyone done it? is it possible?
I just need to get the ‘hash’ provided by the device, but I cant seem to find how to ‘print’ that hash onto an input

I was reading a guide but it needed:

<script src="es6-shim.js"></script>
<script src=" websdk.client.bundle.min.js"></script>
<script src=" fingerprint.sdk.min.js"></script>

The last two I couldnt find anywhere, so its like they don’t exist…

To find anything, but no info or useful guides are found.

React typescript with SVG element

I’m keep getting a error for my component with a icon Map for the icon elements, error message below for my code. and I try SVGProps<SVGSVGElement> | Element; define the type by search around, I still getting red underscore SvgIconProps of the type error message.

Type '({ icon, width, height, fill, className, }: SvgIconProps) => string | Element | JSX.Element | SVGProps<SVGSVGElement>' is not assignable to type 'FC<SvgIconProps>'.
  Type 'string | Element | JSX.Element | SVGProps<SVGSVGElement>' is not assignable to type 'ReactNode'.
    Type 'Element' is not assignable to type 'ReactNode'.
      Type 'Element' is missing the following properties from type 'ReactPortal': type, props, key

Code here in the below and code sandbox here:https://codesandbox.io/p/sandbox/svg-43x2gz?file=%2Fsrc%2FApp.tsx%3A38%2C16

import React, { SVGProps } from "react";

type iconListType = {
  [key: string]: string | SVGProps<SVGSVGElement> | Element;
};

export const iconList: iconListType = {
  fillOn:
    "M8 2H16C17.6569 2 19 3.34315 19 5V19C19 20.6569 17.6569 22 16 22H8C6.34315 22 5 20.6569 5 19V5C5 3.34315 6.34315 2 8 2ZM16 20.5C16.8284 20.5 17.5 19.8284 17.5 19V5C17.5 4.17157 16.8284 3.5 16 3.5H8C7.17157 3.5 6.5 4.17157 6.5 5V19C6.5 19.8284 7.17157 20.5 8 20.5H16ZM12.5 5H8V10H12.5V5ZM9.51 8.5H11V6.5H9.51V8.5ZM8 14.5H16V16H8V14.5ZM16 17.5H8V19H16V17.5ZM16 10H14V8.51H16V10ZM16 11.5H8V13H16V11.5Z",
  ,
  ads: (
    <svg
      width="16"
      height="16"
      viewBox="0 0 24 24"
      fill="none"
      className="pr-1"
      xmlns="http://www.w3.org/2000/svg"
    >
      <path
        d="M10.75 15.4999C11.1642 15.4999 11.5 15.1641 11.5 14.7499C11.5 14.3356 11.1642 13.9999 10.75 13.9999C10.3358 13.9999 10 14.3356 10 14.7499C10 15.1641 10.3358 15.4999 10.75 15.4999Z"
        fill="#F6F6F9"
      />
      <path
        d="M19.27 8.99985L14.16 5.99985C13.9906 5.90762 13.7922 5.88421 13.6059 5.9345C13.4197 5.98478 13.26 6.10488 13.16 6.26985C13.0652 6.43872 13.0404 6.63801 13.0909 6.82497C13.1414 7.01192 13.2631 7.17164 13.43 7.26985L18.54 10.2699C18.8478 10.4443 19.1038 10.6972 19.282 11.0029C19.4601 11.3086 19.5539 11.6561 19.5539 12.0099C19.5539 12.3636 19.4601 12.7111 19.282 13.0168C19.1038 13.3225 18.8478 13.5754 18.54 13.7499L7.54003 20.2299C7.23599 20.4054 6.8911 20.4978 6.54003 20.4978C6.18895 20.4978 5.84406 20.4054 5.54003 20.2299C5.23482 20.0536 4.98159 19.7999 4.80598 19.4944C4.63037 19.1888 4.53863 18.8423 4.54003 18.4899V5.48985C4.53863 5.13743 4.63037 4.7909 4.80598 4.48534C4.98159 4.17979 5.23482 3.92606 5.54003 3.74985C5.84406 3.57431 6.18895 3.4819 6.54003 3.4819C6.8911 3.4819 7.23599 3.57431 7.54003 3.74985L10 5.24985V11.9999C10 12.1988 10.079 12.3895 10.2197 12.5302C10.3603 12.6708 10.5511 12.7499 10.75 12.7499C10.9489 12.7499 11.1397 12.6708 11.2804 12.5302C11.421 12.3895 11.5 12.1988 11.5 11.9999V4.81985C11.4996 4.6888 11.4653 4.56008 11.4005 4.44619C11.3357 4.33229 11.2425 4.2371 11.13 4.16985L8.26003 2.48985C7.73118 2.17856 7.12869 2.0144 6.51503 2.0144C5.90136 2.0144 5.29887 2.17856 4.77003 2.48985C4.23518 2.79278 3.78983 3.23159 3.47902 3.76189C3.16821 4.2922 3.00297 4.89518 3.00003 5.50985V18.5099C2.99767 19.1296 3.16039 19.7388 3.47147 20.2748C3.78255 20.8109 4.23076 21.2544 4.77003 21.5599C5.29887 21.8711 5.90136 22.0353 6.51503 22.0353C7.12869 22.0353 7.73118 21.8711 8.26003 21.5599L19.26 15.0799C19.7866 14.7685 20.2229 14.3254 20.526 13.794C20.8291 13.2627 20.9885 12.6616 20.9885 12.0499C20.9885 11.4381 20.8291 10.837 20.526 10.3057C20.2229 9.77435 19.7866 9.33118 19.26 9.01985L19.27 8.99985Z"
        fill="#F6F6F9"
      />
    </svg>
  ),
};

interface SvgIconProps {
  icon: string;
  fill?: string;
  className: string;
  width?: number;
  height?: number;
}

export const SvgIcon: React.FC<SvgIconProps> = ({
  icon = "",
  width = 16,
  height = 16,
  fill,
  className,
}) => {
  const iconCheck = typeof iconList[icon] === "string";
  return icon && iconCheck ? (
    <svg
      width={width}
      height={height}
      fill={fill}
      viewBox="0 0 24 24"
      className={className}
      xmlns="http://www.w3.org/2000/svg"
    >
      <path
        fill-rule="evenodd"
        clip-rule="evenodd"
        d={iconList[icon]}
        fill={fill}
      />
    </svg>
  ) : (
    iconList[icon]
  );
};

Thanks in advance!

website changing on different computers and zoom sizes

check here for the website
the heading is meant to be centred but when you zoom out or in or even go on a different computer it changes where it is. Why Is This? how Do I fix it

I tried to use percentages instead to make it look the same on smaller devices but its just a mess with the layout I want it to look the same on all devices

I have tried To Search This Up Before But Couldn’t figure it out based on other peoples code because theirs is different code to mine (website kinda inspired of github)

Apply script when hovering over any element with a specific class

I am a Javascript novice and have been working on a script and it works! It is a simple typewriter effect. I want to apply it to all elements with the .type-me class attached. Using querySelector, I got it to work on the first element but I’m not sure how to amend the script so that it works on any element that has the .type-me class attached. Any assistance would be greatly appreciated.

<script>
   var i = 0;
   var txt = document.querySelector('.type-me').textContent;
   document.querySelector('.type-me').textContent = '';
   document.querySelector('.type-me').removeAttribute('style');
   var speed = 500;
   type();
   function type() {
     if (i < txt.length) {
       document.querySelector('.type-me').textContent += txt.charAt(i);
       i++;
       setTimeout(type, speed);
     }
   }
</script>

I’ve tried using a combination of document.getElementsbyClassName and document.querySelectorAll but I have a feeling a loop is needed and I’m not great at writing loops just yet.

How to iterate through object with array values and then iterate through the arrays?

How can I iterate through an object of key values where value is an array?
I would like it to be:

groupA
mike - Paris
nino - new yoek

groupB
jenn - lisbon
lisa - dublin

const object1 = {
  ["groupA"]: [{name: "mike", city: "paris"}, {name: "nino", city: "new york"}],
  b["groupA"] [{name: "jenn", city: "lisbon"}, {name: "lisa", city: "dublin"}],
};

const func = () => {
for (const [key, value] of Object.entries(object1)) {
//here without return nothing gets rendered, but with return only the first property will be returned, ignoring the others
    Object.values(value).map((item) => { 
    //group should only be rendered once
    return <h1>}{item.name} - {item.city}</h1>
  })
}
}
func()

Canvas Red Dot Resets the image to ‘img1’

I am trying to place a red dot in a canvas where it has a background image, this canvas changes images to image 1, 2 or 3 but if I am for example in image 2 and I add the red dot the canvas resets to image 1 but the only thing that works is that the red dot stays in the position that I click. I want it to stay in the image where I put the red dot.

Here is the code:

window.onload = function () {
    var canvas = document.getElementById('myCanvas');
    var context = canvas.getContext('2d');
    var damagepositions = [];

    var imageObj = new Image();
    imageObj.onload = function () {
        context.drawImage(imageObj, 0, 0);
    };
    imageObj.src = './assets/img/img1.jpg';

    canvas.addEventListener('click', function (event) {
    
        //remove red dots
        context.clearRect(0, 0, canvas.width, canvas.height);
        context.drawImage(imageObj, 0, 0);

        var rect = canvas.getBoundingClientRect();
        var x = event.clientX - rect.left;
        var y = event.clientY - rect.top;
        var z = 1; // Asume un valor de z

        // Draw dot
        context.beginPath();
        context.arc(x, y, 8, 0, 2 * Math.PI, false);
        context.fillStyle = 'red';
        context.fill();

        // Save dot position
        damagepositions = [{
            x: x,
            y: y,
            z: z
        }];
    });
};

var damagepositions = [];
var count = 2;

function changeView() {
    if (count == 1) {
        canvas = document.getElementById('myCanvas');
        context = canvas.getContext('2d');
        imageObj = new Image();
        imageObj.onload = function () {
            context.drawImage(imageObj, 0, 0);
        };
        imageObj.src = './assets/img/img1.jpg';
    }else if(count == 2){
        canvas = document.getElementById('myCanvas');
        context = canvas.getContext('2d');
        imageObj = new Image();
        imageObj.onload = function () {
            context.drawImage(imageObj, 0, 0);
        };
        imageObj.src = './assets/img/img2.jpg';
    }else{
        canvas = document.getElementById('myCanvas');
        context = canvas.getContext('2d');
        imageObj = new Image();
        imageObj.onload = function () {
            context.drawImage(imageObj, 0, 0);
        };
        imageObj.src = './assets/img/img3.jpg';
    }
    count++;
    if(count >= 4){
        count = 1;
    }
}

function clearCanvas(){
    canvas = document.getElementById('myCanvas');
    context = canvas.getContext('2d');
    context.clearRect(0, 0, canvas.width, canvas.height);
    context.drawImage(imageObj, 0, 0);
    damagepositions = [];
}