404 error when accessing react route in iis application

I’m having trouble accessing the routes of my application that is hosted on an IIS server. The route is opening and navigating through the screens. The redirection works, but if I just enter the route, or manually rewrite to a different endpoint, it returns the IIS 404 screen.

my environment is configured for a standard, in which a homologation system is differentiated by a route, for example:
homologacao_teste/application1
homologacao_teste/application2

in my real case, I am hosting on my 192.168…../vcn_web/ as a base route.

web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="React Routes" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="/vcn_web/index.html" />
        </rule>
      </rules>
    </rewrite>
    <staticContent>
      <mimeMap fileExtension=".js" mimeType="application/javascript" />
      <mimeMap fileExtension=".json" mimeType="application/json" />
      <mimeMap fileExtension=".css" mimeType="text/css" />
      <mimeMap fileExtension=".html" mimeType="text/html" />
    </staticContent>
  </system.webServer>
</configuration>

Router in app.js:

<Router basename="/vcn_web">

Homepage in package.json:

"homepage": "/vcn_web/",

Apparently everything is configured correctly, but I still get a 404 return, what should I adjust?

styling of pmtiles in openlayers

Im quite a newbie on OL.

First, I downloaded a osm/NatEarth pre-built tile Dataset at https://maps.protomaps.com/builds/

after that, i created my local ol Project.
I saw, that the pmtiles styling may be handled by a local json like

https://maps.protomaps.com/#map=0.41/0/0&theme=light&lang=en&tiles=https://demo-bucket.protomaps.com/v4.pmtiles

I tried the ol-mapbox-style Module, but also it was not quite clear to me, how to incldue the Json Style (and maybe additional ressources like Fonts and so on) into the project.

and here comes my question:
what modules do i require (other than ol-pmtiles, ol/layer/VectorTile)
to use such a json AND how do i include that into my OL Project? (e.g. main.js)
The Documentation is not quite clear to me..

Thanks in advance

Reading CSV File with JavaScript without manupulating encoding

I have a csv file that I can see with :

file -bi myCsv.txt

that the character-set is ‘iso-8859-1’.
Now I want to read this file using java-script from input tag and type ‘file’ without manipulating the encoding.

I tried several options with FileReader() with a method ‘readAsText()’ and ‘readAsArrayBuffer()’ or with a fetch API and ‘new Uint8Array(arrayBuffer)’, but every time I send the file (as string or byte[]) to the backend via ajax-post-request, I see UTF-8 and not ‘iso-8859-1’ anymore.

I thought that if I read just a bytes of this file, i would not manipulate the encoding.
But with FileReader() and fetch-API(URL) the encoding is changed every time.
How can i read text files without changing the encoding to check the encoding in the backend, which works fine.

How to defer inline CSS?

Is there any valid possibility to defer the <style></style> code?

Background:

I created a custom crawler, which loads a page with headless Chrome, with defined viewport settings. The crawler evaluates all existing CSS (links and inline), and creates two CSS parts, first as critical CSS, second as uncritical.

Now I have two CSS parts and want to defer the uncritical part as <style>.

I think about a way like it can be done with JS

<script>
    window.addEventListener('DOMContentLoaded', function()

Use keyboard shortcut to loop through options of a selectize dropdown

I have an RShiny a dropdow (a selectInput object) and I would like to be able to switch between options using a keyboard shortcut.

For my purposes the best option would be to have the key combination loop through the available options.

So far, I’ve managed to assign individual keys to individual options in the dropdow, using the selectize. This is the piece of code I am adding to the fluidPage:

tags$script(HTML("$(function(){ 
  $(document).keyup(function(e) {
      if(e.which == 49){
        var selectized = $('#selector_name').selectize();
        selectized[0].selectize.setValue(1);
        
      } 
    });
  })"))

What I was trying to do a switch statement inside the innermost if, like this:

if <current_value> = 1 {
   selectized[0].selectize.setValue(1);
} else if <current_value> = 2 {
    ...
}

However I don-t know how to access <current_value>.

In addition, the code above assigns a signle keystroke to the event, but I would really prefer using a combination of keys, such as SHIFT + D.

Replace silence in audio using ffmpeg.wasm

I have a use case where I have to shorten silences which are longer than 2 seconds and shrink them to 1 second in ffmpeg wasm

I can remove silences which are longer than 2 seconds but couldn’t shrink them.

const silenceDuration = 2;

    await ffmpeg.run(
      "-i",
      inputFileName,
      "-af",
      `silenceremove=stop_periods=-1:stop_duration=${silenceDuration}:stop_threshold=-30dB`,
      outputFileName,
    )

any idea how to achieve this in ffmpeg wasm?

Thank you

Uploading folders and files from a single input field in js/ts

I want to upload multiple files and folders from a single input, but unable to do so.

<input
  type="file"
  onChange={handleFileChange}
  className="hidden"
  id="file-input"
  multiple
  ref={fileInputRef}
/>

I was doing above code for uploading file and updated it to following

<input
  type="file"
  onChange={handleFileChange}
  className="hidden"
  id="file-input"
  multiple
  directory=""
  webkitdirectory=""
  mozdirectory=""
  ref={fileInputRef}
/>

But then I was only able to upload folders, not files

How to give a custom class name to the markNode of Lexical’s $wrapSelectionInMarkNode() using selection?

I’m working with Lexical and using the $wrapSelectionInMarkNode() function to wrap the current selection in a markNode. However, I need to add a custom class name to the markNode in order to apply unique styles.

Here’s the code I’m using:

import { $wrapSelectionInMarkNode } from 'lexical';
import { v4 as uuidv4 } from 'uuid';

editor.update(() => {
  if (!rangeSelection) return;

  const markNodeId = uuidv4();

  // Delete the current selection first
  rangeSelection.removeText();

  // Insert the new text
  rangeSelection.insertText(response as string);

  // Wrap the new text in a mark node
  $wrapSelectionInMarkNode(rangeSelection, rangeSelection.isBackward(), markNodeId);
})

I want to specify a custom class name for the markNode that wraps the selection so that I can apply unique styling. How can I achieve this? Do I need to modify the $wrapSelectionInMarkNode() function, or is there an easier way to pass the class name directly?

Any help would be greatly appreciated!

Fetching a app.js file before other files get loaded

I’m currently building my website using HTML, CSS and JS. I am trying to separate my header and footer from my index.html, but it doesn’t seem to be working as it would be if they were in the same file, index.html. Can someone please help me? I understand the problem might be because my app.js isn’t fetched before my header and footer pages are loaded. How does one fetch a app.js file?
This is how it is supposed to look like (this is what happens when I merge them all into index.html) Pic #1

This is how the webpage appears when I separate the header and footer from the index.html (the header no longer freezes at the top of the screen and animation for the footer stops working):Pic#2
Here is my HTML code:

<header class="header">
<div class="header-content">
    <div class="logo">RV</div>
    <div class="menu-icon" id="menu-icon">
        <div class="bar"></div>
        <div class="bar"></div>
        <div class="bar"></div>
    </div>
    <nav class="nav" id="navMenu">
        <ul class="nav-list"> 
            <li class="nav-link"> <a href="index.html">HOME</a></li>
            <li class="nav-link"> <a href="projects.html">PROJECTS</a></li>
            <li class="nav-link"> <a href="experience.html">EXPERIENCE</a></li>
            <li class="nav-link"> <a href="others.html">OTHERS</a></li>
        </ul>
    </nav>
</div>
</header>

This is my Footer.html

<div class="page-wrapper">
<div id="waterdrop"></div>
<footer>
  <div class="footer-top">
    <div class="footer-container">
        
        <div class="footer-icons">
            <a href="https://www.linkedin.com/in/rithvik-vaddadi-8469471a9/"> <img class="linkedin" src="Images/linkedin.png" alt="linkedin"></a>
            <a href="https://www.linkedin.com/in/rithvik-vaddadi-8469471a9/"> <img class="telegram" src="Images/telegram.png" alt="telegram"></a>
            <a href="https://www.instagram.com/rithvik_amars/"><img class="insta" src="Images/instagram.png" alt="instagram"></a>
          
        </div>
      
    </div>
  
    <div class="copyright">
      <p style="color: black;">
        2024 &copy by Rithvik Amar
      </p>
    </div>
  </div>
</footer>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" 
</script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="https://daniellaharel.com/raindrops/js/raindrops.js"></script>
<script> jQuery('#waterdrop').raindrops({color:'#989090',canvasHeight:150, density: 0.1, frequency: 10});</script>

This is my index.html code:

<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./styles.css"/>
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet'>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&family=Roboto:wght@400;500&display=swap" rel="stylesheet">
<title>HomePage</title>
<script>
    // Function to include an external file
    function includeHTML() {
        const elements = document.querySelectorAll("[data-include]");
  
        elements.forEach(el => {
            const file = el.getAttribute("data-include");
            if (file) {
                fetch(file)
                    .then(response => {
                        if (response.ok) return response.text();
                        throw new Error("Network response was not ok.");
                    })
                    .then(html => {
                        el.innerHTML = html;
                    })
                    .catch(err => console.error("There was a problem including the HTML file:", err));
            }
        });
    }
  
    document.addEventListener("DOMContentLoaded", includeHTML);
  </script>
</head>
<body>
<div class="page">
    <div data-include="header.html"></div>
    
    <div class="about">
        <div class="about-text">
            <h1 class="title">RITHVIK VADDADI</h1>
            <span class="Intro">Cyber Security Enthusiast | Toastmasters | Cardistry</span>
        </div>
        <div class="arrow-wrap">
            <div class="arrow-down arrow"></div>
            <div class="arrow-down arrow"></div>
        </div>
      </div>

      <div class="overview">
        <h2>About me</h2>
        <div class="OV">
            <img src="Images/My PFP.jpg" alt="Avatar" class="Avatar">
            <div class="text-buttons">
                <p class="description">Hello, I am Rithvik Vaddadi, a current NSF with a diploma in Cyber Security and Digital Forensics. Drawn to the world of computers, I aspire to make people's lives easier and protect them from cyber attacks with the help of technology around us. As a problem solver, I am known to use my creative and critical thinking skills when providing solutions in my past leadership roles and projects. When involved in projects, I tend to notice people's strengths and weaknesses and assign them to roles where their potential would be fully maximized in the project. When my mind is fixed on a goal, I dedicate my energy and focus to achieving the goal.</p>
                <div class="buttons">
                    <a href="https://docs.google.com/document/d/1ZjzHjOgWy2RH1Lz27aZAih7ZEqYFOU-0mNnstJ93LtU/edit?usp=sharing" target="_blank"></a>
                        <button>View My Resume</button>
                    </a>
                    <a href="https://www.linkedin.com/in/rithvik-vaddadi-8469471a9/" target="_blank">
                        <button>View My LinkedIn</button>
                    </a>
                </div>
            </div>
        </div>
        <section class="education-section">
          <h2>My Education Journey</h2>
          <div class="cards-container">
              <div class="card" id="army-card">
                  <div class="card-inner">
                      <div class="card-front">
                          <h3>Army</h3>
                      </div>
                      <div class="card-back">
                          <h3>SAF Singapore Armed Forces</h3>
                          <p>Vocation: 5SIR Infantry Soldier as a General Purpose Machine Gun (GPMG) Gunner and Platoon 2ic <br>
                            Rank: Corporal <br>
                            ORD Date: 2nd May 2025<br>
                            Overseas involvement: Brunei, Malaysia, Australia. <br>
                            Achievements: Due to my exceptional combat fitness and leadership, I was chosen to represent my battalion in a Joint Adventure Training (JAT) with the Malaysian Army Rangers. <br>
                            Skills: Proficient in handling GPMG, SAR21, and LMG. Trained in drone flying. (DJI Mavick Pro, Vesper, Cetus)
                          </p>
                          <div class="gallery-wrap">
                            <img src="Images/back.png" class="backBtn">
                            <div class="gallery">
                                <div>
                                    <span><img src="Images/Army1.jpg"></span>
                                    <span><img src="Images/Army2.jpg"></span>
                                    <span><img src="Images/Army4.jpg"></span>
                                </div>
                                <div>
                                    <span><img src="Images/Army3.jpg"></span>
                                    <span><img src="Images/Army5.jpg"></span>
                                    <span><img src="Images/My PFP.jpg"></span>
                                </div>
                            </div>
                            <img src="Images/front.png" class="nextBtn">
                          </div>
                          <span class="close-btn"><img src="Images/X.png" alt="close"></span>
                      </div>
                  </div>
              </div>
              <div class="card" id="poly-card">
                  <div class="card-inner">
                      <div class="card-front">
                          <h3>Polytechnic</h3>
                      </div>
                      <div class="card-back">
                          <h3>Ngee Ann Polytechnic</h3>
                          <p>Course: Cyber Security and Digital Forensics<br>
                            CCAs: Vice-President and Student Advisor of NP's Toastmasters Club, Head of Logistics for NP's ICTSociety, Tchoukball<br>
                            Achievements: I led a 2-hour group focus session with the Minister of Education, Mr Chan Chun Sing, about the future of Singapore's education, housing, etc. 
                            Showcased my capstone project at Singapore International Cyber Week X Govware (SICW 2022).
                            Spearheaded a YEP-GO overseas cross-cultural program with a school in Ladakh, India for a week.
                            </p>
                          <div class="gallery-wrap">
                            <img src="Images/back.png" class="backBtn">
                            <div class="gallery">
                                <div>
                                    <span><img src="Images/Dip2.jpg"></span>
                                    <span><img src="Images/Dip5.jpg"></span>
                                    <span><img src="Images/Dip6.jpg"></span>
                                </div>
                                <div>
                                    <span><img src="Images/Dip3.jpg"></span>
                                    <span><img src="Images/Dip1.jpg"></span>
                                    <span><img src="Images/Dip7.jpg"></span>
                                </div>
                            </div>
                            <img src="Images/front.png" class="nextBtn">
                          </div>
                          <span class="close-btn"><img src="Images/X.png" alt="close"></span>
                        </div>
                    </div>
              </div>
              <div class="card" id="school-card">
                  <div class="card-inner">
                      <div class="card-front">
                          <h3>Secondary School</h3>
                      </div>
                      <div class="card-back">
                        <h3>Bukit Batok Secondary School</h3>
                        <p>Stream: Express double science (Physics and Chemistry)<br>
                          O-Level L1R5: 10 L1R4: 7<br>
                          CCAs: Badminton (Vice-Captain), Student Council (Vice President), Lewis House Captain
                          Achievements: I attended a photoshoot with my school's principle for our school website and magazine. This event was a testament to the contributions and impact I made in the school's community. Involved in many volunteer programs such as donating rice, beach clean-ups, etc.

                        </p>
                        <div class="gallery-wrap">
                            <img src="Images/back.png" class="backBtn">
                            <div class="gallery">
                                <div>
                                    <span><img src="Images/Secondary1.jpg"></span>
                                    <span><img src="Images/Secondary2.jpg"></span>
                                    <span><img src="Images/Secondary3.jpg"></span>
                                </div>
                                <div>
                                    <span><img src="Images/Secondary4.jpg"></span>
                                    <span><img src="Images/Secondary5.jpg"></span>
                                    <span><img src="Images/Secondary6.jpg"></span>
                                </div>
                            </div>
                            <img src="Images/front.png" class="nextBtn">
                          </div>
                        <span class="close-btn"><img src="Images/X.png" alt="close"></span>
                      </div>
                  </div>
              </div>
          </div>
      </section>
      <div data-include="footer.html"></div>
      
</div>
<script src="app.js"></script>
</body>
</html>

This is my styles.CSS code:

 *{
margin: 0;
padding: 0;
box-sizing: border-box;
}

.page{
position: relative;
background: #e2e2e2;
height: 300vh;
}

.logo{
font-size: 22px;
}

.header{
color: white;
background: transparent;
position: sticky;
z-index: 2;
top: 0;
transition: 0.3s ease-in-out;
height: 80px;
}

.scrolled{
height: 50px;
background: black;
transition: .3s ease-in-out;

}

.header-content{
display: flex;
justify-content: space-between;
align-items: center;
max-width: 1100px;
margin: 0 auto;
height: 100%;
padding: 0 40px;
}

.nav{
display: flex;
width: 40%;
}

.nav-list{
list-style: none;
display: flex;
justify-content: space-between;
width: 100%;
flex-wrap: wrap;
gap: 20px;
}

.nav-link a{
color: white;
text-decoration: none;
border-bottom: 2px solid transparent;
transition: 0.3s;
}

.nav-link a:hover{
border-bottom: 2px solid white;
transition: 0.3s;
}

.menu-icon{
display: none;
flex-direction: column;
cursor: pointer;
}

.menu-icon .bar{
width: 25px;
height: 3px;
background-color: red;
margin: 4px 0;
transition: 0.4s;
}

@media (max-width:768px){
.nav{
    display: none;
    flex-direction: column;
    background-color: black;
    width: 100%;
    position: relative;
    top: 80px;
    left: 0;
    text-align: center;
    }
.nav-list{
    flex-direction: column;
    width: 100%;
}
.nav-link a{
    padding: 12px;
    border-bottom: 1px solid white;
    width: 100%;
    display: block;
}
.menu-icon{
    display: flex;
}
.nav.show{
    display:flex;
}
}


.about{
background-image: url(Images/CardistryBGD2.jpg);
background-size: cover;
height: 100vh;
position: relative;
top: -80px;
z-index: 1;
display: flex;
justify-content: center;
align-items:center;
flex-direction: column;
}

.about-text{
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
}

.title{
font-family:'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
color:white;
font-size: 9vw;
}

.Intro{
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
font-size: 1.5vw;
color: white;
margin-top: 10px;
}

.arrow-wrap {
position: absolute;
bottom: 30%;
left: 50%;
transform: translate(-50%, -25px);
-webkit-animation: arrow 0.5s 1s infinite ease-out alternate;
animation: arrow 0.5s 1s infinite ease-out alternate;
text-align: center;
}


.arrow {
position: relative;
padding: 15px;
border-left: solid 5px red;
border-bottom: solid 5px whitesmoke;
display: block;
}

.arrow-down {
transform: rotate(-45deg);
position: relative;
margin-top: -15px;
}

@keyframes arrow {
0% {
  bottom: 0px;
}
100% {
  bottom: 10px;
}
}

 /* Hover effect */
 .arrow-wrap:hover {
animation-play-state: paused;
}

/* Responsive styling for mobile screens */
@media (max-width: 768px) {
/* Place arrow differently on mobile */
.arrow-wrap {
    bottom: 30px;
}
}

h2{
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
color: white;
font-size: 3vw;
margin: 8px;
padding: 30px;
}

.Avatar{
vertical-align: middle;
width: 145px;
height: 140px;
border-radius: 50%;
margin-left: 15px;
}

.text-buttons{
display: flex;
flex-direction: column;
}

.overview{
background-image: url(Images/CardBG.jpg);
background-size: cover;
margin: -80px 0 0 0;
padding:0;
height: auto;
display: flex;
justify-content: center;
align-items:center;
flex-direction: column;
 

}

.OV{
display: flex;
align-items: flex-start;
max-width: 1150px;
color: white;
font-family: 'Montserrat';
text-align: left;
}

.description{
margin-left: 25px;
font-size: 1.2em;
}

.buttons{
display: flex;
gap: 20px;
margin-top: 20px;
}

button{
background: rgb(165, 1, 1);
color: #fff;
font-weight: 600;
border: none; 
border-radius: 12px;
/*     height: 50px;
width: 200px;  */
padding: 10px 20px;
font-size: 18px;
font-family: 'Montserrat';
margin-top: 20px;
box-shadow: 0px 4px 6px rgba(0,0,0,0.1);
transition: background-color 0.3s ease, transform 0.2s ease;
cursor: pointer;
}

button:hover{
background-color: #8a0000;
transform: translateY(-2px); 
box-shadow: 0px 6px 8px rgba(0,0,0,0.2);
}

@media (max-width: 768px) {
.overview {
    padding: 0px;
}

.OV {
    flex-direction: column;
    text-align: center;
    align-items: center;
}

.content{
    flex-direction: column;
}

.Avatar {
    margin-left: 0;
    margin-bottom: 20px;
    width: 120px;
    height: 120px;
}

.description {
    margin-left: 0;
    font-size: 4vw;
}

.buttons{
    flex-direction: column;
    align-items: center;
}

button{
    width: 150px;
    height: auto;
}
}

@media (max-width: 480px) {
.OV{
    align-items: center;
}

h2 {
    font-size: 6vw;
}

.description {
    font-size: 5vw;
}

.Avatar {
    margin: 0;
    width: 100px;
    height: 100px;
}

button{
    width: 100%;
    height: 16px;
    padding: 10px;
}
.buttons{
    align-items: center;
}
}


/* Section Styles */
.education-section {
padding: 20px 20px;
color: white;
text-align: center;
}

.cards-container {
display: flex;
justify-content: space-around;
flex-wrap: wrap;
margin-top: 20px;
margin-bottom: 0;
}

/* Card Styles */
.card {
width: 300px;
height: 400px;
perspective: 1000px; 
margin: 20px;
transition: transform 0.3s ease box-shadow 0.3s ease;
border-radius: 15px;
overflow: hidden;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
position: relative;

}

/* Hover Animation */
.card:hover {
transform: scale(1.05); /* Slight jump effect */
box-shadow: 0px 12px 24px rgba(255, 255, 255, 0.3);
}

/* Card Flip Animation */
.card-inner {
position: relative;
width: 100%;
height: 100%;
max-width: 1000px;
margin: 0 auto;
transform-style: preserve-3d;
transition: transform 0.8s ease;
cursor: pointer;
border-radius: 15px;
box-shadow: none;
font-family: Arial, sans-serif;
line-height: 1.6;
letter-spacing: 0.5px;
color: #f1f1f1;
}

.card-front, .card-back {
box-shadow: none;
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden; /* Hide the back while flipping */
border-radius: 10px;
background-color: #1e1e1e;
color: white;
display: flex;
align-items: center;
justify-content: center;
font-family: 'Roboto', sans-serif;
}


.card-front {
background: linear-gradient(135deg, #ac0101 0%, #941616 100%); /* Gradient */
color: white;
font-size: 1.5em;
font-weight: 600;
display: flex;
justify-content: center;
align-items: center;
text-align: center;

}
/* Back Card Design with Image Background */
.card-back {
background-image: url('your-image-back.jpg'); /* Replace with your image */
background-size: cover;
background-position: center;
transform: rotateY(180deg);
padding: 30px;
font-size: 1em;
color: #ddd;
backface-visibility: hidden;
display: flex;
flex-direction: column;
justify-content: flex-start; /* Align items from the top */
align-items: center; /* Center the items horizontally */
border-radius: 15px;
position: relative;
transition: background 0.5s ease;
}

.card-inner h1{
font-size: 24px;
font-weight: bold;
margin-bottom: 15px;
text-align: center;
}


/* Style for the h3 element (Title) */
.card-back h3 {
font-size: 1.8em;
color: #ffffff;
margin-bottom: 20px;
text-align: center;
width: 100%; /* Ensure it takes up full width */
position: absolute;
top: 30px; /* Adjust this value to control the top spacing */
left: 50%;
transform: translateX(-50%); /* Center horizontally */
}

/* Style for paragraph or other content */
.card-back p {
font-size: 1.2em;
text-align: left;
margin-top: 80px; /* Ensure it's below the h3 title */
z-index: 1;
width: 100%;
padding: 0 20px;
}

.card-inner.flip {
transform: rotateY(180deg);
}

/* Expand animation */
.card.expand {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 9999;
background-color: transparent;
transform: none;
transition: width 0.5s ease, height 0.5s ease;
box-shadow: none;
}



.card-back .close-btn {
position: absolute;
top: 15px;
right: 15px;
background-color: transparent;
border: none;
color: white;
font-size: 0.5em;
cursor: pointer;
font-weight: bold;
z-index: 1;
}

/* Media Queries for responsiveness */
@media (max-width: 768px) {
.cards-container {
    flex-direction: column;
    align-items: center;
}

.card {
    width: 80%;
    height: auto;
}
}

.gallery{
width:600px;
display:flex;
overflow-x: scroll;
}

.gallery div{
width: 100%;
display: grid;
grid-template-columns: auto auto auto;
grid-gap: 30px;
padding: 10px;
flex:none;
}

.gallery div img{
width:100%;
/* filter:grayscale(100%); */
transition: tranform 0.5s;
}

.gallery::-webkit-scrollbar{
display:none;
}

.gallery-wrap{
display:flex;
align-items:center;
justify-content: center;
margin: 2% auto;
}

.backBtn, .nextBtn{
width:50px;
cursor: pointer;
margin: 40px;
}

.gallery div img:hover{
transform: scale(1.1);
}

.footer-top {
text-align: center;
background-size: cover;
background-position: center;
padding: 30px 0px;
font-family: rubik;
margin-top: 0;

}
.page-wrapper
{
position: relative;
bottom: 0;
width: 100%;
z-index: 11111;

}

.footer-top, .footer-bottom {
background-color: #989090;

}

footer p, footer strong, footer b, footer {
color: #ffffff;
}

#waterdrop {
height: 80px;
}

#waterdrop canvas {
bottom: -70px !important;
}

.footer-site-info
{
padding-top: 10px;

}

footer {
text-align: center;
}

.footer-container {
justify-content: center;
display: flex;
align-items: center;
width: 100%;
}

.footer-container a {
padding: 0px 16px;
text-decoration: none;
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: medium;
}

.fa:hover {
color: #45405F;
}

.footer-icons {
display: flex;
justify-content: center;
gap:20px;
padding-bottom: 10px;
}

.copyright {
color:#f2f2f2;
overflow: hidden;
margin-bottom: -30px;
}

.telegram{
padding: 0px;
width: 30px;
text-decoration: none;
}

.telegram:hover{
opacity: 0.7;
}

.linkedin{
padding: 0px;
width: 30px;
text-decoration: none;
}

.linkedin:hover{
opacity: 0.7;
}

.insta{
padding: 0px;
width: 30px;
text-decoration: none;
}

.insta:hover{
opacity: 0.7;
}

This is my Javascript code:

const header = document.querySelector('.header');

window.addEventListener("scroll", () => {
if(window.scrollY >= 150){
    header.classList.add("scrolled");
} else if(window.scrollY <=100) {
    header.classList.remove("scrolled");
}
});

//Hamburger Toggle for mobile 
const menuIcon = document.getElementById('menu-icon');
const navMenu = document.getElementById('navMenu');

menuIcon.addEventListener('click', () => {
navMenu.classList.toggle('show');
});

window.addEventListener('load', function(){
this.document.querySelector('.arrow-wrap').computedStyleMap.display = 'block';
});

// Select all cards
const cards = document.querySelectorAll('.card');

// Add event listeners to each card
cards.forEach(card => {
const cardInner = card.querySelector('.card-inner');

// Only flip when you click the card front
const cardFront = card.querySelector('.card-front');
cardFront.addEventListener('click', function (e) {
    e.stopPropagation(); // Prevent the event from propagating to the document
    cardInner.classList.toggle('flip'); // Flip the card
    card.classList.toggle('expand'); // Expand the card
});

// Close button logic (for collapsing and un-flipping)
const closeButton = card.querySelector('.close-btn');
closeButton.addEventListener('click', function (e) {
    e.stopPropagation(); // Prevent clicking the card behind the button
    cardInner.classList.remove('flip'); // Remove the flip effect
    card.classList.remove('expand'); // Collapse the card
});
});



const nextButtons = document.querySelectorAll('.nextBtn');
const backButtons = document.querySelectorAll('.backBtn');
const galleries = document.querySelectorAll('.gallery');

// Function to scroll the gallery
function scrollGallery(direction, gallery) {
const scrollAmount = gallery.clientWidth;
gallery.scrollBy({ left: direction * scrollAmount, behavior: 'smooth' });
}

// Adding event listeners to each pair of buttons
nextButtons.forEach((btn, index) => {
btn.addEventListener('click', () => scrollGallery(1, galleries[index]));
});

backButtons.forEach((btn, index) => {
btn.addEventListener('click', () => scrollGallery(-1, galleries[index]));
});


window.addEventListener('scroll', function() {
const footer = document.querySelector('.footer');
const scrollable = document.documentElement.scrollHeight - window.innerHeight;
const scrolled = window.scrollY;

if (Math.ceil(scrolled) >= scrollable) {
    footer.classList.add('expanded'); // Expand footer when at the bottom
} else {
    footer.classList.remove('expanded'); // Hide footer when not at the bottom
}
});

I understand the problem might be because my app.js isn’t fetched before my header and footer pages are loaded. How does one fetch a app.js file?

Circle nicht gerade zu Text (Bulletpoint) [closed]

enter image description here

Wie auf dem Bild zu sehen ist, ist der Bulletpoint leicht höher als der Text dahinter. Ich habe schon viele Möglichkeiten getestet, alles ohne Erfolg. Habt ihr eine Idee? LG

.circle {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: #6FA5B7;
  transform: translate(-50%, 200px); /* 20px nach unten verschieben */
}


.container {
  display: flex; /* Macht den Container zu einem Flex-Container */
  align-items: center; /* Zentriert die Elemente vertikal */
  justify-content: center;
}
<div class="container">
  <div class="circle"></div> 
  Ganzheitliche, partnerschaftliche Gesundheitsförderung
</div>

Using Recoil, Why are other components also re-rendering when only 01 component is changing the state?

First of all, thank you for your time in going through my query and sharing your valuable tips and answers.

I have implemented an Amazon Checkout Page using React and Recoil.

Everything works as expected but the application is not behaving as expected by using Recoil.
That is, only that component should re-render that changes the state.

My Main focus while implementing this mini assignment, was on the Recoil Implementation, and did not use Routing so Layout was also not used (Header, Footer).

Flow:-
->Get data from the backend (array of cartItems) and store it in an atom
(I do not want to call ‘n’ calls to backend for ‘n’ items so get an array of todos)

What I did:-

->Use selectorFamily to retrieve/set a particular item.

->use selectorFamily to retrieve/set derived state of a particular item

Problem:-
->cartItem.jsx component is subscribing to the itemQuantity of the specific item by id
but why are all the other component are re-rendering when quantity is updated (Header,Footer,Other cartItem, and AmazonCheckout)

I know AmazonCheckout is dependent on cartItems array which is coming from the main atom but why is the other cartItem component re-rendered?

My Solution (Tentative):- Use React.memo in all the other components (Header,Footer, and cartItem.jsx) ???

Is there any other way to implement this Flow??

Github repo link:- https://github.com/pradeep652227/reactjs-cohort3.0/tree/main/02_assignment_amazonkart

cartItems-Atom.js:-

import { atom, selector, selectorFamily } from "recoil";

// Atom to store all todos as a dictionary
export const cartItemsAtom = atom({
    key: "cartItemsAtom",
    default: selector({
        key: "cartItemsSelector",
        get: async () => {
            const response = await getItemsFromBackend();
            // Transforming the array into an object by id
            return response.reduce((acc, todo) => {
                acc[todo.id] = todo;
                return acc;
            }, {});
        }   
    })
});

// SelectorFamily to retrieve a specific item by id
export const cartItemsSelectorFamily = selectorFamily({
    key: "cartItemsSelectorFamily",
    get: (id) => ({ get }) => {
        const items = get(cartItemsAtom);
        return items[id] || { id: '', title: '', price: '', quantity: 0, isInStock: false, img: '' };
    },
    set: (id) => ({ set, get }, newValue) => {
        const items = get(cartItemsAtom);
        set(cartItemsAtom, { ...items, [id]: newValue });
    }
});

// SelectorFamily to retrieve the in-stock status of an item
export const isInStockSelectorFamily = selectorFamily({
    key: "isInStockSelectorFamily",
    get: (id) => ({ get }) => {
        const item = get(cartItemsSelectorFamily(id));
        return item.isInStock || false;
    }
});

// SelectorFamily to manage the quantity of each item
export const itemQuantitySelectorFamily = selectorFamily({
    key: "itemQuantitySelectorFamily",
    get: (id) => ({ get }) => {
        const item = get(cartItemsSelectorFamily(id));
        return item?.quantity || 0;
    },
    set: (id) => ({ get, set }, newQuantity) => {
        const isInStock=get(isInStockSelectorFamily(id));
        if(!isInStock){
            alert('Item is Out Of Stock');
            return;
        }

        if(newQuantity>=0){
            const item = get(cartItemsSelectorFamily(id));
            // Ensure immutability by creating a new object
            const updatedItem = { ...item, quantity: newQuantity };
            set(cartItemsSelectorFamily(id), updatedItem);
        }
    }
});

export const deleteCartItemSelectorFamily = selectorFamily({
    key: "deleteCartItemSelectorFamily",
    set: (id) => ({ get, set }) => {
        const items = get(cartItemsAtom);
        if (items[id]) {
            //preserved immutability
            const newItems = { ...items };
            delete newItems[id];
            set(cartItemsAtom, newItems);
        }
    }
});

async function getItemsFromBackend() {
    return [
        {
            id: 1,
            title: "FUR JADEN 40L Weekender Travel Laptop Backpack with Anti Theft Pocket, Organizer, 15.6 Inch Padded Laptop Sleeve and Dual Hand",
            price: 369,
            quantity: 2,
            isInStock: true,
            img: ""
        },
        {
            id: 2,
            title: "Testing",
            price: 2069,
            quantity: 2,
            isInStock: false,
            img: ""
        }
    ]
}

AmazonCheckout.jsx

import { useRef,useMemo } from "react";
import { Header,Footer, Container, CartItem } from "../Components/imports-components";
import { nanoid } from "nanoid";
import { useRecoilValue } from "recoil";
import { cartItemsAtom } from "../store/imports-store";

export default function AmazonCheckout(){
    const checkoutIdRef=useRef(nanoid());
    const cartItems=useRecoilValue(cartItemsAtom);
    const cartItemsArray=useMemo(()=>Object.values(cartItems),[cartItems]);
    // const totalPrice=useMemo(()=>cartItemsArray.reduce((acc,item)=>acc+(parseFloat(item.price)*parseFloat(item.quantity)),0),
    //                         [cartItemsArray]);

    // const totalItems=useMemo(()=>cartItemsArray.reduce((acc,item)=>acc+parseInt(item.quantity),0),[cartItemsArray])
    
    //For test purpose, used hardCoded values
    const totalPrice=22222;
    const totalItems=4;

    console.log('Amazon Checkout Component');

    return(<>
            <Header/>
            <Container className="py-4 bg-slate-200 !max-w-full">
                <div id={`checkoutBox ${checkoutIdRef.current}`} className="flex flex-wrap md:flex-nowrap justify-between gap-4">
                    <div data-unique="checkout-leftPart" className="bg-white rounded-xl p-4">
                        <h1 className="text-2xl font-semibold mb-2">Shopping Cart</h1>
                        <div data-unique="items" className="space-y-4">
                            {
                                cartItemsArray.map(item=><CartItem key={item.id} id={item.id}
                                 />)
                            }
                        </div>
                    </div>
                    <div data-unique="checkout-rightPart" className="bg-white rounded-xl p-4 h-fit w-max">
                        <h1 className="text-2xl font-semibold">Order Summary</h1>
                        <div className="flex flex-wrap justify-between">
                            <span>Items ({totalItems})</span>
                            <span>TotalPrice: {totalPrice}</span>
                        </div>
                    </div>
                </div>
                </Container>
            <Footer />
        </>
    );
}

cart-item.jsx

import { useRef,useState } from 'react';
import { nanoid } from 'nanoid';
import {Button} from '../Reusables/imports-reusables';
import { useRecoilState, useSetRecoilState,useRecoilValue } from 'recoil';
import { deleteCartItemSelectorFamily, isInStockSelectorFamily, itemQuantitySelectorFamily,cartItemsSelectorFamily } from '../store/atoms/cartItems-Atom';

export default function CartItem({id}){
console.log('CartITem component');

const idRef=useRef(nanoid());
const {title,price}=useRecoilValue(cartItemsSelectorFamily(id));
const isInStock=useRecoilValue(isInStockSelectorFamily(id));
const [itemQuantity,setItemQuantity]=useRecoilState(itemQuantitySelectorFamily(id));
const setDeleteCartItem=useSetRecoilState(deleteCartItemSelectorFamily(id));

const quantityBtnClasses='bg-slate-300 rounded-md text-xl px-3 py-1';

    return(

        <div id={`cart-item ${idRef.current}`} className='flex flex-wrap md:flex-nowrap justify-between gap-4 px-4'>
        <div data-unique="cart-left-part" className='flex flex-wrap md:flex-nowrap space-x-2'>
            <div data-unique="cart-item-image" className="bg-slate-300" style={{"height":"90px",width:"90px"}}>
            </div>
            <div data-unique="cart-item-details">
                <span role="heading" data-unique="cart-item-heading" 
                className='text-xl font-semibold block'>
                    {title}
                </span>
                <span data-unique="cart-item-status" 
                className={`${isInStock?"text-green-500":"text-red-500"} block`}>
                    {isInStock?"In Stock":"Out Of Stock"}
                </span>
                <div data-unique="cart-item-incr-decr" className='space-x-2'>
                    <Button className={quantityBtnClasses} onClick={increaseQuantity}>+</Button>
                    <span data-unique="cart-item-quantity">{itemQuantity}</span>
                    <Button className={`${quantityBtnClasses}`} onClick={decreaseQuantity}>-</Button>
                    <Button className='bg-transparent 
                    text-blue-500 font-semibold hover:text-blue-700 duration-200'
                    onClick={()=>setDeleteCartItem()}
                    >Delete
                    </Button>
                </div>
            </div>
        </div>
        <span data-unique="cart-item-price" className=''>Rs. {price}</span>

    </div>
    
    )

    
function increaseQuantity(){
    setItemQuantity(q=>q+1);
}

function decreaseQuantity(){
    setItemQuantity(q=>q-1);
}

}

Printing HTML to Zebra Receipt printer is printing blank

I have a web app that is attempting to print this receipt to a Zebra GX430t thermal receipt printer:

this receipt

Unfortunately, it only prints whitespace.

When I print receipt to a normal printer, it prints fine. When I recreate the receipt in Word using the exact same fonts and print to receipt printer, it prints fine.

I have tried to make sure that what is being printed is not too large. The paper is 3.1 inches wide. My receipt is 250px, or 2.6 inches wide. I have tried using @media print in my CSS. This did not work.

I’ve included everything I can, HTML, CSS, JS. This isn’t the entire page, however.

I am working with LaserFiche Forms which injects all kind of crap into the page, (CSS etc.). I can’t see the whole thing. I’ve included just the stuff I’ve edited.

The reason for the !important splattered all over the CSS is because of the way their primary CSS is written, it’s been difficult to make my changes override theirs.

I just don’t understand why it’s showing up blank when it prints.

$(document).ready(function() {
  $('.Submit').hide();
  $(document).prop('title', 'Ticket');
  $('.hr').append('<hr>');
  $("#Field24").attr("id", "ticket-title");
  $("#Field6").attr("id", "ticket-barcode");

  $(document).on("onloadlookupfinished", function() {
    $('#Field26').val($('#Field26').val().split(" ")[0]);
    $('#Field19').val($('#Field19').val().split(" ")[0]);
    $('#Field18').val(new Date().toLocaleString());
    parent.postMessage("printme", "*");
  });

  $(document).on("lookupcomplete", function(e) {
    $('#ticket-title').val($('#Field1').val())
    var barcode_value = "*" + $('#Field1').val() + "*";
    $('#ticket-barcode').val(barcode_value);
  });
});
@import url('https://fonts.googleapis.com/css2?family=Libre+Barcode+128&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@500&display=swap');

/*I have tried it both with and without this @media print thingy. */

@media print {
  .cf-section-block {
    white-space: nowrap !important;
    overflow: hidden !important;
  }
  .cf-label {
    /*Notice that the font family is turned off here*/
    /*font-family: "Montserrat", sans-serif !important;*/
    font-size: 12px !important;
    width: 100px !important;
    padding: 0px !important;
  }
  .cf-table {
    /*font-family: "Montserrat", sans-serif !important;*/
    font-size: 12px !important;
    margin-bottom: 10px !important;
  }
  .cf-table input {
    /*font-family: "Montserrat", sans-serif !important;*/
    font-size: 12px !important;
    border-width: 0px !important;
  }
  .cf-medium,
  .cf-field {
    /*font-family: "Montserrat", sans-serif !important;*/
    font-size: 12px !important;
    width: 150px !important;
    padding: 0px !important;
    border-width: 0px !important;
    height: 20px !important;
  }
  #ticket-title {
    /*font-family: "Montserrat", sans-serif !important;*/
    font-weight: 500 !important;
    padding: 0px !important;
    font-size: 20px !important;
    width: 250px !important;
    background-color: #FFF !important;
    border-width: 0px !important;
    text-align: center !important;
  }
  #ticket-barcode {
    font-family: "Libre Barcode 128", system-ui !important;
    font-weight: 400 !important;
    font-style: normal !important;
    font-size: 45px !important;
    height: 30px !important;
    background-color: #FFF !important;
    border-width: 0px !important;
    width: 250px !important;
    text-align: center !important;
  }
  ul li.form-q {
    padding: 0px 0px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    margin: 0px !important;
  }
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<!DOCTYPE html>

<html>

<head>
  <title></title>
</head>

<body>
  <div class="cf-page active" id="q0">
    <div id="q2" class="cf-section-block hidden lf-container-hidden" readonlysection="false" aria-hidden="true">
      <ul>
        <li attr="TicketID" attrtype="text" name="q4" id="q4" class="form-q label-left">
          <label class="cf-label" id="FieldLabel4" for="Field4"><span><span>TicketID</span></span><span class="screen-reader-legend">field type single line</span></label>
          <div class="cf-field">
            <input type="text" id="Field4" name="Field4" aria-labelledby="FieldLabel4" class="singleline cf-medium lf-no-validate" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="u" disabled user-preset="620" aria-invalid="false">
          </div>
        </li>

        <li attr="TicketTypeID" attrtype="text" name="q5" id="q5" class="form-q label-left">
          <label class="cf-label" id="FieldLabel5" for="Field5"><span><span>TicketTypeID</span></span><span class="screen-reader-legend">field type single line</span></label>
          <div class="cf-field awesomplete">
            <input type="text" id="Field5" name="Field5" aria-labelledby="FieldLabel5" class="singleline cf-medium lf-no-validate awesomplete" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="e" disabled aria-invalid="false" autocomplete="off"
              aria-autocomplete="list" awesomelast="" lookupalt="true">
          </div>
        </li>

        <li attr="TicketNumber" attrtype="text" name="q1" id="q1" class="montserrat-title form-q label-left">
          <label class="cf-label" id="FieldLabel1" for="Field1"><span><span>Ticket Number:</span></span><span class="screen-reader-legend">field type single line</span></label>

          <div class="cf-field awesomplete">
            <input type="text" id="Field1" name="Field1" aria-labelledby="FieldLabel1" class="singleline cf-medium lf-no-validate awesomplete" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="e" disabled aria-invalid="false" autocomplete="off"
              aria-autocomplete="list" awesomelast="" lookupalt="true">
          </div>
        </li>
      </ul>
    </div>

    <div id="q3" class="cf-section-block" readonlysection="false">
      <ul>
        <li attr="TicketNumberTitle" attrtype="text" name="q24" id="q24" class="form-q label-left">
          <label class="cf-label" id="FieldLabel24" for="Field24"><span><span>Ticket Number:</span></span><span class="screen-reader-legend">field type single line</span></label>

          <div class="cf-field">
            <input type="text" id="ticket-title" name="Field24" aria-labelledby="FieldLabel24" class="singleline cf-medium" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="e" aria-invalid="false">
          </div>
        </li>

        <li attr="TicketNumber_Barcode" attrtype="text" name="q6" id="q6" class="barcode form-q label-left">
          <label class="cf-label" id="FieldLabel6" for="Field6"><span><span>Barcode:</span></span><span class="screen-reader-legend">field type single line</span></label>

          <div class="cf-field">
            <input type="text" id="ticket-barcode" name="Field6" aria-labelledby="FieldLabel6" class="singleline cf-medium" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="e" aria-invalid="false">
          </div>
        </li>

        <li attr="" attrtype="custom" name="q22" id="q22" class="form-q label-left">
          <div class="cf-custom" id="Field22">
            <p class="hr"></p>
            <hr>
          </div>
        </li>

        <li attr="Operator_" attrtype="text" name="q7" id="q7" class="form-q label-left form-focused">
          <label class="cf-label" id="FieldLabel7" for="Field7"><span><span>Operator:</span></span><span class="screen-reader-legend">field type single line</span></label>

          <div class="cf-field awesomplete">
            <input type="text" id="Field7" name="Field7" aria-labelledby="FieldLabel7" class="singleline cf-medium awesomplete parsley-success" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="e" autocomplete="off" aria-autocomplete="list"
              awesomelast="Sammy Marks" lookupalt="true" data-parsley-id="15">
            <ul class="awesomplete-child cf-medium" hidden="">
              <li aria-selected="false" class="ellipsis" title="Sammy Marks">
                <mark>Sammy Marks</mark>
              </li>
            </ul>
          </div>
        </li>

        <li attr="Department_" attrtype="text" name="q8" id="q8" class="form-q label-left">
          <label class="cf-label" id="FieldLabel8" for="Field8"><span><span>Department:</span></span><span class="screen-reader-legend">field type single line</span></label>

          <div class="cf-field awesomplete">
            <input type="text" id="Field8" name="Field8" aria-labelledby="FieldLabel8" class="singleline cf-medium awesomplete" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="e" aria-invalid="false" autocomplete="off" aria-autocomplete="list"
              awesomelast="" lookupalt="true">
          </div>
        </li>

        <li attr="Mach__Name" attrtype="text" name="q9" id="q9" class="form-q label-left">
          <label class="cf-label" id="FieldLabel9" for="Field9"><span><span>Mach. Name:</span></span><span class="screen-reader-legend">field type single line</span></label>

          <div class="cf-field awesomplete">
            <input type="text" id="Field9" name="Field9" aria-labelledby="FieldLabel9" class="singleline cf-medium awesomplete" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="e" aria-invalid="false" autocomplete="off" aria-autocomplete="list"
              awesomelast="" lookupalt="true">
          </div>
        </li>

        <li attr="Mach__Grp" attrtype="text" name="q10" id="q10" class="form-q label-left">
          <label class="cf-label" id="FieldLabel10" for="Field10"><span><span>Mach. Grp:</span></span><span class="screen-reader-legend">field type single line</span></label>

          <div class="cf-field awesomplete">
            <input type="text" id="Field10" name="Field10" aria-labelledby="FieldLabel10" class="singleline cf-medium awesomplete" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="e" aria-invalid="false" autocomplete="off" aria-autocomplete="list"
              awesomelast="" lookupalt="true">
          </div>
        </li>

        <li attr="Cell_Leader_" attrtype="text" name="q11" id="q11" class="form-q label-left">
          <label class="cf-label" id="FieldLabel11" for="Field11"><span><span>Cell Leader:</span></span><span class="screen-reader-legend">field type single line</span></label>

          <div class="cf-field awesomplete">
            <input type="text" id="Field11" name="Field11" aria-labelledby="FieldLabel11" class="singleline cf-medium awesomplete" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="e" aria-invalid="false" autocomplete="off" aria-autocomplete="list"
              awesomelast="" lookupalt="true">

            <p class="screen-reader-legend">Input blocked. Maximum character limit of 4000 characters reached.</p>

            <ul hidden="" class="awesomplete-child cf-medium"></ul>
          </div>
        </li>

        <li attr="Part_Number_" attrtype="text" name="q25" id="q25" class="form-q label-left">
          <label class="cf-label" id="FieldLabel25" for="Field25"><span><span>Part Number:</span></span><span class="screen-reader-legend">field type single line</span></label>

          <div class="cf-field awesomplete">
            <input type="text" id="Field25" name="Field25" aria-labelledby="FieldLabel25" class="singleline cf-medium awesomplete" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="e" aria-invalid="false" autocomplete="off" aria-autocomplete="list"
              awesomelast="" lookupalt="true">
          </div>
        </li>

        <li attr="Job_Lot_" attrtype="text" name="q12" id="q12" class="form-q label-left">
          <label class="cf-label" id="FieldLabel12" for="Field12"><span><span>Job/Lot:</span></span><span class="screen-reader-legend">field type single line</span></label>

          <div class="cf-field awesomplete">
            <input type="text" id="Field12" name="Field12" aria-labelledby="FieldLabel12" class="singleline cf-medium awesomplete" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="e" aria-invalid="false" autocomplete="off" aria-autocomplete="list"
              awesomelast="" lookupalt="true">
          </div>
        </li>

        <li attr="" attrtype="custom" name="q23" id="q23" class="form-q label-left">
          <div class="cf-custom" id="Field23">
            <p class="hr"></p>
            <hr>
          </div>
        </li>

        <li attr="Pins" attrtype="table" name="q16" id="q16" class="form-q label-left cf-table-block label-left">
          <div class="cf-section-header">
            <h2>Pins</h2>
          </div>

          <div class="cf-table_parent">
            <table summary="Pins" class="cf-table">
              <thead>
                <tr>
                  <th class="hideRowLabel" style="display:none"></th>

                  <th width="0%" id="q13" class="form-q"><label class="cf-col-label" id="FieldLabel13(1)" for="Field13(1)">Diam.<span class="screen-reader-legend">field type single line</span></label></th>

                  <th width="0%" id="q14" class="form-q"><label class="cf-col-label" id="FieldLabel14(1)" for="Field14(1)"># Pins<span class="screen-reader-legend">field type single line</span></label></th>

                  <th width="0%" id="q17" class="form-q"><label class="cf-col-label" id="FieldLabel17(1)" for="Field17(1)">Type<span class="screen-reader-legend">field type single line</span></label></th>

                  <th></th>
                </tr>
              </thead>

              <tbody repeatrowlabel="Row {n}" backendrowcount="{&quot;13&quot;:5,&quot;14&quot;:5,&quot;17&quot;:5}" class="kx-repeatable">
                <tr style="">
                  <td data-col="q13" data-title="Diam.">
                    <label class="cf-col-label" id="FieldLabel13(1)" for="Field13(1)">Diam.<span class="screen-reader-legend">field type single line</span></label>

                    <div class="cf-field">
                      <input type="text" id="Field13(1)" name="Field13(1)" aria-labelledby="FieldLabel13(1)" class="singleline cf-xlarge" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="k" list="datalist13" lookupalt="true">
                      <input type="hidden" name="PopulatedField13(1)" value="0" id="PopulatedField13(1)">
                    </div>
                  </td>

                  <td data-col="q14" data-title="# Pins">
                    <label class="cf-col-label" id="FieldLabel14(1)" for="Field14(1)"># Pins<span class="screen-reader-legend">field type single line</span></label>

                    <div class="cf-field">
                      <input type="text" id="Field14(1)" name="Field14(1)" aria-labelledby="FieldLabel14(1)" class="singleline cf-xlarge" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="k" list="datalist14" lookupalt="true">
                      <input type="hidden" name="PopulatedField14(1)" value="0" id="PopulatedField14(1)">
                    </div>
                  </td>

                  <td data-col="q17" data-title="Type">
                    <label class="cf-col-label" id="FieldLabel17(1)" for="Field17(1)">Type<span class="screen-reader-legend">field type single line</span></label>

                    <div class="cf-field">
                      <input type="text" id="Field17(1)" name="Field17(1)" aria-labelledby="FieldLabel17(1)" class="singleline cf-xlarge" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="k" list="datalist17" lookupalt="true">
                      <input type="hidden" name="PopulatedField17(1)" value="0" id="PopulatedField17(1)">

                    </div>
                  </td>

                </tr>

                <tr style="">
                  <td data-col="q13" data-title="Diam.">
                    <label class="cf-col-label" id="FieldLabel13(2)" for="Field13(2)">Diam.<span class="screen-reader-legend">field type single line</span></label>

                    <div class="cf-field">
                      <input type="text" id="Field13(2)" name="Field13(2)" aria-labelledby="FieldLabel13(2)" class="singleline cf-xlarge" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="k" list="datalist13" lookupalt="true">
                      <input type="hidden" name="PopulatedField13(2)" value="1" id="PopulatedField13(2)">
                    </div>
                  </td>

                  <td data-col="q14" data-title="# Pins">
                    <label class="cf-col-label" id="FieldLabel14(2)" for="Field14(2)"># Pins<span class="screen-reader-legend">field type single line</span></label>

                    <div class="cf-field">
                      <input type="text" id="Field14(2)" name="Field14(2)" aria-labelledby="FieldLabel14(2)" class="singleline cf-xlarge" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="k" list="datalist14" lookupalt="true">
                      <input type="hidden" name="PopulatedField14(2)" value="1" id="PopulatedField14(2)">
                    </div>
                  </td>

                  <td data-col="q17" data-title="Type">
                    <label class="cf-col-label" id="FieldLabel17(2)" for="Field17(2)">Type<span class="screen-reader-legend">field type single line</span></label>

                    <div class="cf-field">
                      <input type="text" id="Field17(2)" name="Field17(2)" aria-labelledby="FieldLabel17(2)" class="singleline cf-xlarge" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="k" list="datalist17" lookupalt="true">
                      <input type="hidden" name="PopulatedField17(2)" value="1" id="PopulatedField17(2)">
                    </div>
                  </td>

                </tr>

                <tr style="">
                  <td data-col="q13" data-title="Diam.">
                    <label class="cf-col-label" id="FieldLabel13(3)" for="Field13(3)">Diam.<span class="screen-reader-legend">field type single line</span></label>

                    <div class="cf-field">
                      <input type="text" id="Field13(3)" name="Field13(3)" aria-labelledby="FieldLabel13(3)" class="singleline cf-xlarge" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="k" list="datalist13" lookupalt="true">
                      <input type="hidden" name="PopulatedField13(3)" value="2" id="PopulatedField13(3)">
                    </div>
                  </td>

                  <td data-col="q14" data-title="# Pins">
                    <label class="cf-col-label" id="FieldLabel14(3)" for="Field14(3)"># Pins<span class="screen-reader-legend">field type single line</span></label>

                    <div class="cf-field">
                      <input type="text" id="Field14(3)" name="Field14(3)" aria-labelledby="FieldLabel14(3)" class="singleline cf-xlarge" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="k" list="datalist14" lookupalt="true">
                      <input type="hidden" name="PopulatedField14(3)" value="2" id="PopulatedField14(3)">
                    </div>
                  </td>

                  <td data-col="q17" data-title="Type">
                    <label class="cf-col-label" id="FieldLabel17(3)" for="Field17(3)">Type<span class="screen-reader-legend">field type single line</span></label>

                    <div class="cf-field">
                      <input type="text" id="Field17(3)" name="Field17(3)" aria-labelledby="FieldLabel17(3)" class="singleline cf-xlarge" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="k" list="datalist17" lookupalt="true">
                      <input type="hidden" name="PopulatedField17(3)" value="2" id="PopulatedField17(3)">
                    </div>
                  </td>

                </tr>

                <tr style="">

                  <td data-col="q13" data-title="Diam.">
                    <label class="cf-col-label" id="FieldLabel13(4)" for="Field13(4)">Diam.<span class="screen-reader-legend">field type single line</span></label>

                    <div class="cf-field">
                      <input type="text" id="Field13(4)" name="Field13(4)" aria-labelledby="FieldLabel13(4)" class="singleline cf-xlarge" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="k" list="datalist13" lookupalt="true">
                      <input type="hidden" name="PopulatedField13(4)" value="3" id="PopulatedField13(4)">
                    </div>
                  </td>

                  <td data-col="q14" data-title="# Pins">
                    <label class="cf-col-label" id="FieldLabel14(4)" for="Field14(4)"># Pins<span class="screen-reader-legend">field type single line</span></label>

                    <div class="cf-field">
                      <input type="text" id="Field14(4)" name="Field14(4)" aria-labelledby="FieldLabel14(4)" class="singleline cf-xlarge" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="k" list="datalist14" lookupalt="true">
                      <input type="hidden" name="PopulatedField14(4)" value="3" id="PopulatedField14(4)">
                    </div>
                  </td>

                  <td data-col="q17" data-title="Type">
                    <label class="cf-col-label" id="FieldLabel17(4)" for="Field17(4)">Type<span class="screen-reader-legend">field type single line</span></label>

                    <div class="cf-field">
                      <input type="text" id="Field17(4)" name="Field17(4)" aria-labelledby="FieldLabel17(4)" class="singleline cf-xlarge" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="k" list="datalist17" lookupalt="true">
                      <input type="hidden" name="PopulatedField17(4)" value="3" id="PopulatedField17(4)">
                    </div>
                  </td>

                </tr>

                <tr style="">
                  <td data-col="q13" data-title="Diam.">
                    <label class="cf-col-label" id="FieldLabel13(5)" for="Field13(5)">Diam.<span class="screen-reader-legend">field type single line</span></label>
                    <div class="cf-field">
                      <input type="text" id="Field13(5)" name="Field13(5)" aria-labelledby="FieldLabel13(5)" class="singleline cf-xlarge" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="k" list="datalist13" lookupalt="true">
                      <input type="hidden" name="PopulatedField13(5)" value="4" id="PopulatedField13(5)">
                    </div>
                  </td>

                  <td data-col="q14" data-title="# Pins">
                    <label class="cf-col-label" id="FieldLabel14(5)" for="Field14(5)"># Pins<span class="screen-reader-legend">field type single line</span></label>

                    <div class="cf-field">
                      <input type="text" id="Field14(5)" name="Field14(5)" aria-labelledby="FieldLabel14(5)" class="singleline cf-xlarge" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="k" list="datalist14" lookupalt="true">
                      <input type="hidden" name="PopulatedField14(5)" value="4" id="PopulatedField14(5)">
                    </div>
                  </td>

                  <td data-col="q17" data-title="Type">
                    <label class="cf-col-label" id="FieldLabel17(5)" for="Field17(5)">Type<span class="screen-reader-legend">field type single line</span></label>

                    <div class="cf-field">
                      <input type="text" id="Field17(5)" name="Field17(5)" aria-labelledby="FieldLabel17(5)" class="singleline cf-xlarge" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="k" list="datalist17" lookupalt="true">
                      <input type="hidden" name="PopulatedField17(5)" value="4" id="PopulatedField17(5)">
                    </div>
                  </td>

                </tr>
              </tbody>
            </table>
          </div>
        </li>

        <li attr="" attrtype="custom" name="q21" id="q21" class="form-q label-left">
          <div class="cf-custom" id="Field21">
            <p class="hr"></p>
            <hr>
          </div>
        </li>

        <li attr="Date_Printed" attrtype="text" name="q18" id="q18" class="form-q label-left">
          <label class="cf-label" id="FieldLabel18" for="Field18"><span><span>Printed:</span></span><span class="screen-reader-legend">field type single line</span></label>

          <div class="cf-field">
            <input type="text" id="Field18" name="Field18" aria-labelledby="FieldLabel18" class="singleline cf-medium" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="e" aria-invalid="false">
          </div>
        </li>

        <li attr="Last_Cal_Date_" attrtype="text" name="q26" id="q26" class="form-q label-left">
          <label class="cf-label" id="FieldLabel26" for="Field26"><span><span>Last Cal Date:</span></span><span class="screen-reader-legend">field type single line</span></label>

          <div class="cf-field awesomplete">
            <input type="text" id="Field26" name="Field26" aria-labelledby="FieldLabel26" class="singleline cf-medium awesomplete" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="e" aria-invalid="false" autocomplete="off" aria-autocomplete="list"
              awesomelast="" lookupalt="true">
          </div>
        </li>

        <li attr="Cal_Due_Date_" attrtype="text" name="q19" id="q19" class="form-q label-left">
          <label class="cf-label" id="FieldLabel19" for="Field19"><span><span>Cal Due Date:</span></span><span class="screen-reader-legend">field type single line</span></label>

          <div class="cf-field awesomplete">
            <input type="text" id="Field19" name="Field19" aria-labelledby="FieldLabel19" class="singleline cf-medium awesomplete" maxlength="4000" data-list-focus="true" data-parsley-legal-character="True" vo="e" aria-invalid="false" autocomplete="off" aria-autocomplete="list"
              awesomelast="" lookupalt="true">
          </div>
        </li>
      </ul>
    </div>
  </div>
</body>

</html>

How to dynamically render a Laravel Blade component with JavaScript variables?

I am trying to dynamically render a Laravel Blade component using JavaScript variables. Specifically, I am passing the label and color properties from JavaScript into a Blade component like this:

<x-badge label="${customer.status.label}" color="${customer.status.color}" />

However, this approach doesn’t work as expected. The component itself is working fine, and the label property renders as expected. However, the color property is not being rendered correctly.

I confirmed that the ${customer.status.color} variable contains the correct value.

I expected the color to dynamically apply the correct badge class based on the JavaScript variable, but only the label shows up, while the color is setting the default that i defined.

Property ‘x’ does not exist on type ‘number’ [closed]

It seems that when I’m using .on('click', function (event, d)), d is no longer complete object but it’s a number:

svg
      .selectAll('circle')
      .data(nodes)
      .enter()
      .append('circle')
      .attr('cx', (d) => d.x)
      .attr('cy', (d) => d.y)
      .attr('r', 20)
      .attr('fill', 'white')
      .attr('stroke', (d) => (d.id === selectedNodeId ? 'blue' : 'red'))
      .attr('stroke-width', (d) => (d.id === selectedNodeId ? 4 : 2))
      .on('click', function (event, d) {
        setSelectedNodeId(d.id);
        notifications.toasts.addSuccess(`Nodo ${d.id} selezionato`);
      });

I cannot access the id field of object d, I tried to force d to type any but it didn’t work for me

“Cannot access file” in ES module, that I could with CommonJS module (Electron JS app)

I’m building a desktop app using ElectronJS, which reads content of pre-existing XLSX files. I first created the app as a CommonJS module with dependencies:

const { app, BrowserWindow, ipcMain } = require('electron');
const path = require('node:path');
const xlsx = require('xlsx');
const cp = require('child_process')
const os = require('os')

In the actual app, I build the filename path from dirPath and filename which are pre-determined and then attempt to access it.

workbook = xlsx.readFile(path.join(dirPath, filename));

This works.

But for other reasons, I needed to convert this module to an ES module. I now have the following dependencies:

import { app, BrowserWindow, ipcMain } from 'electron';
import { join } from 'node:path';
import * as xlsx from 'xlsx';
import { execSync } from 'child_process';
import { hostname } from 'os';

and the code I’m trying to execute is:

workbook = xlsx.readFile(join(dirPath, filename);

This throws an error Error occurred in handler for 'initialise': Error: Cannot access file. If relevant, the path and file names have spaces in them, and I can’t eliminate them.