How can I prevent trailing decimal point from displaying in number inputs after losing focus?

When using number inputs with the step attribute for decimal values, I noticed that when I type “1.2” and then delete the “2” to leave “1.”, the trailing decimal point remains visible in the input even after the input loses focus. The actual value is “1” (without the decimal), but the display still shows “1.”.

Here is a React example but it happens in plain HTML input as well. How can I fix this visual inconsistency?

function Example() {
  const [value, setValue] = React.useState('');
  const [focused, setFocused] = React.useState(false);
  
  return (
    <div>
      
      <label>
        Enter a decimal number <br/>(try typing "1.2" then delete the "2" and then lose focus):
       <br/><br/>
        <input
          type="number"
          step="0.01"
          value={value}
          onChange={(e) => {
            console.log("onChange value:", e.target.value);
            setValue(e.target.value);
          }}
          onFocus={() => setFocused(true)}
          onBlur={() => setFocused(false)}
          style={{padding: '5px', margin: '5px 0'}}
        />
      </label>
      
      <div style={{marginTop: '10px'}}>
        <p><strong>Input is currently:</strong> {focused ? 'Focused' : 'Blurred'}</p>
        <p><strong>Value in state:</strong> "{value}"</p>
      </div>
    </div>
  );
}

// Render it
ReactDOM.render(
  <Example />,
  document.getElementById('root')
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/18.3.1/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.3.1/umd/react-dom.production.min.js"></script>
<div id="root"></div>

Trying to draw on HTML canvas using precedence

<!DOCTYPE html>
<html lang="en">    
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <canvas id="myCanvas" width="300" height="200" style="border: 2px solid  salmon; background-color: lightblue;"></canvas>
<p id="letter"></p>
Width of the canvas is :
<p id=cw></p>
Height of the canvas is :
<p id=ch></p>
<br>
Dots position 
<br><br>
x =
<p id="x"></p>
y =
<p id="y"></p>
<script>
    var x = 0;
    var y = 0;
    var change = true;
const canvas = document.getElementById("myCanvas");
const ctx = canvas.getContext("2d");
  function main(){
if (change){
ctx.clearRect(0,0,canvas.width,canvas.height);
x = Math.floor(Math.random() * (canvas.width));
y = Math.floor(Math.random() * (canvas.height));
document.getElementById("x").innerHTML = x;
document.getElementById("y").innerHTML = y;
//ctx.fillStyle = "Purple";
//ctx.fillRect(0,0,canvas.width,canvas.height);
ctx.fillStyle = "Green";
ctx.arc(x, y, 10, 0, 2 * Math.PI);
ctx.fill;
document.getElementById("cw").innerHTML = canvas.width;
document.getElementById("ch").innerHTML = canvas.height;
document.getElementById("letter").innerHTML = "change = true";
    change = !change;
  } else {
document.getElementById("letter").innerHTML = "change = false";
//ctx.rect(0,0,canvas.width,canvas.height);
ctx.clearRect(0, 0, canvas.width, canvas.height);
//ctx.fillStyle = "yellow";
//ctx.fillRect(0, 0, canvas.width, canvas.height);
//ctx.fillStyle = "blue";
//ctx.arc(10,10,10,0,2 * Math.PI);
ctx.fill();
    change = !change;
  }
}
    setInterval(main, 1000);//calls the function
   </script>
</body>
</html>

I am trying to draw on this HTML canvas by clearing it and then drawing o circle on top so and then clearing the screen again and so it looks like the circle is flashing on for 1 second and off for 1 second.

I the commented lines in the code in case they were useful and so people can see what I’v been trying.

The x and y variables are just the coordinates of the centre of the circle.

The ‘change’ variable in a boolean. Which run the first or second part of the if loop depending on whether it is true or false.

The whole if loop is wrapped in a function called main. This called by setInterval every second on line 56, 4 from the bottom.

Any help would be greatly appreciated.

Thanks,

Shane

Argon2 always returns false

I create a user on the login page and hash this password with Argon2 but when I compare it, it does not match the password. The hashed password is shown in the database and I can also see the plain text. When I compare the two, it returns false. I have been trying for a day. I was using normal bcryptjs but when it did not work, I switched to argon2. I guess I was making the same mistake in both

exports.register = async (req, res) => {
  try {
    const { fullname, username, email, password } = req.body;
    const existingUser = await User.findOne({ email });
    if (existingUser)
      return res.status(400).json({ message: "User already exists!" });
    const trimmedPassword = password.trim();
    const hashedPassword = await argon2.hash(trimmedPassword);
    const newUser = new User({
      fullname,
      username,
      email,
      password: hashedPassword,
    });
    await newUser.save();
    console.log(newUser);
    res
      .status(201)
      .json({ message: "User created successfully. Welcome to InkSpace..." });
  } catch (error) {
    res.status(500).json({ message: "Error creating user", error });
  }
};
exports.login = async (req, res) => {
  try {
    const { email, password } = req.body;
    const plainPassword = password.trim();
    console.log("plain password",plainPassword);
    const user = await User.findOne({ email });
    const hashPassword = user.password;
    console.log(user);
    if (!user) {
      return res.status(400).json({ message: "Invalid email or password" });
    }
    console.log(hashPassword);
    const isMatch = await argon2.verify(hashPassword, plainPassword);
    console.log(isMatch)
    if (isMatch) {
      req.session.user = {
        userId: user._id,
        username: user.username,
      };
      console.log("Session data after login:", req.session.user);
      return res.status(200).json({ message: "Login successful" });
    } else {
      console.log("did not match")
      return res.status(400).json({ message: "Invalid email or password" });
    }
  } catch (error) {
    console.log("verify argon2 ", error);
    res.status(500).json({ message: "Error logging in", error });
  }
};

can’t get the gridextensions loaded in my module

I’m building a modern module that uses a grid in the admin part. (I use a Docker container as environment)
Can someone help me out as when I compile my index.js with “npm run build” it compiles the output, but doesn’t load in the gridextensions?!

I’m kind of newbie here as well as not a seasoned prestashop developer, so please bare with me 😉

enter image description here

My index.js for the gridextensions to be compiled with npm:

const { $ } = window

$(() => {

const grid = new window.prestashop.component.Grid(‘eventGrid’)

grid.addExtension(new window.prestashop.component.GridExtensions.SortingExtension());
grid.addExtension(new window.prestashop.component.GridExtensions.ReloadListActionExtension());
grid.addExtension(new window.prestashop.component.GridExtensions.LinkRowActionExtension());
grid.addExtension(new window.prestashop.component.GridExtensions.SubmitRowActionExtension());
grid.addExtension(new window.prestashop.component.GridExtensions.SubmitBulkExtension());
grid.addExtension(new window.prestashop.component.GridExtensions.SubmitGridExtension());
grid.addExtension(new window.prestashop.component.GridExtensions.PositionExtension());
grid.addExtension(new window.prestashop.component.GridExtensions.FiltersResetExtension());
grid.addExtension(new window.prestashop.component.GridExtensions.AsyncToggleColumnExtension());
grid.addExtension(new window.prestashop.component.GridExtensions.ColumnTogglingExtension());
grid.addExtension(new window.prestashop.component.GridExtensions.BulkActionCheckboxExtension());
grid.addExtension(new window.prestashop.component.GridExtensions.BulkActionDropdownExtension());
grid.addExtension(new window.prestashop.component.GridExtensions.BulkActionSubmitExtension());
grid.addExtension(new window.prestashop.component.GridExtensions.BulkActionResetExtension());
});

Get grid cells to expand to grid-item when the grid item resizes dynamically

I am having an auto-fill grid container. Initially when I add items, the grid cells automatically adjust to the grid-items width and height, however, if I try to dynamically change its size, the grid cells don’t expand to fit the content.

Here’s a demo:

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, auto));
    grid-template-rows: repeat(auto-fill, minmax(100px, auto));
    gap: 10px;
    border: 2px solid black;
    padding: 10px;
    width: fit-content;
}

  .grid-item {
      background-color: lightblue;
      display: flex;
      align-items: center;
      justify-content: center;
      border: 1px solid blue;
      padding: 10px;
      min-width: 100px;
      min-height: 100px;
      transition: width 0.3s ease, height 0.3s ease;
  }

.large {
    width: 200px !important;
    height: 200px !important;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Dynamic Grid Resizing</title>
    <style>
       
    </style>
</head>
<body>

    <button onclick="resizeItem()">Resize Item</button>

    <div class="grid-container">
        <div class="grid-item" id="resizable-item">Resize Me</div>
        <div class="grid-item">Item 2</div>
        <div class="grid-item">Item 3</div>
    </div>

    <script>
        function resizeItem() {
            const item = document.getElementById("resizable-item");
            item.classList.toggle("large");
        }
    </script>

</body>
</html>

As you can see when you press resize, it collapses onto each other.

I’ll be having more items, but above is the MRE. How can I get the grid cells to fit to grid items, even when resized dynamically?

Should I use defer or DOMContentLoaded for modifying image loading attributes?

I’m optimizing image loading for a grid layout (similar to YouTube thumbnails) by setting loading=”eager” for some images and loading=”lazy” for others based on screen size. I have placed the script tag in the head tag not the body to add loading attributes before images are in the DOM.

My goal is to:

  1. Run the script after the DOM is ready but before images load.

  2. Ensure optimal performance and avoid blocking rendering.

document.addEventListener("DOMContentLoaded", function(){
    let image = document.querySelectorAll(".image-container img");
    let eagerLoadLimit = 0

    if(window.innerWidth > 1024){
        eagerLoadLimit = 8 // desktop pc
    }
    else if(window.innerWidth >= 768 && window.innerWidth < 1024){
        eagerLoadLimit = 6 // tablets
    }
    else{
        eagerLoadLimit = 3; // mobile
    }
    image.forEach((img, index) =>{
        img.loading = index < eagerLoadLimit ? "eager" : "lazy";
    })
})

I was expecting better performance but I got worse performance in lighthouse

Stock Quantity Not Updating on Size Selection in Django Template with JavaScript

Problem Description:
I’m working on a Django project where a product can have multiple size variants, and each size has its own stock quantity. I want to display the stock information dynamically when a user selects a size using JavaScript.

However, the stock information is not updating as expected. It always shows undefined in stock or Only undefined left, even though I can see the correct stock data in the browser console.


Models:

class Size(models.Model):
    name = models.CharField(max_length=50)

class Product(models.Model):
    title = models.CharField(max_length=255)

class ProductStock(models.Model):
    product = models.ForeignKey(Product, on_delete=models.CASCADE, related_name="stocks")
    size = models.ForeignKey(Size, on_delete=models.CASCADE, blank=True, null=True)
    uploded_stock_quantity = models.PositiveIntegerField(default=0)
    stock_quantity = models.PositiveIntegerField(default=0)
    reserved_stock = models.PositiveIntegerField(default=0)

    def available_stock(self):
        return self.stock_quantity - self.reserved_stock

Views:

from django.shortcuts import render, get_object_or_404

def product_detail_view(request, pid):
    product = get_object_or_404(Product, pid=pid)
    sizes = product.size.filter(product=product)
    product_stocks = ProductStock.objects.filter(product=product)
    
    size_stock_data = {
        str(stock.size.id): {
            'stock_quantity': stock.stock_quantity,
            'uploaded_stock_quantity': stock.uploded_stock_quantity
        }
        for stock in product_stocks
    }

    return render(request, 'core/product_detail.html', {
        'product': product,
        'sizes': sizes,
        'size_stock_data': size_stock_data
    })

Template:

{{ size_stock_data|safe|json_script:"size-stock-data" }}

<div class="u-s-m-b-15">
  <div class="pd-detail__inline">
    <span class="pd-detail__stock" id="uploaded-stock">-</span>
    <span class="pd-detail__left" id="remaining-stock">-</span>
  </div>
</div>

{% if sizes %}
  <div class="u-s-m-b-15">
    <span class="pd-detail__label u-s-m-b-8">Size:</span>
    <div class="pd-detail__size">
      {% for s in sizes %}
      <div class="size__radio">
        <input type="radio" id="size_{{ s.id }}" name="size" value="{{ s.id }}" onclick="updateStock(this)" {% if forloop.first %}checked{% endif %}>
        <label class="size__radio-label" for="size_{{ s.id }}">{{ s.name }}</label>
      </div>
      {% endfor %}
    </div>
  </div>
{% endif %}

JavaScript:

function updateStock(element) {
  const sizeId = element.value;
  const stockDataElement = document.getElementById('size-stock-data');

  if (!stockDataElement) {
    console.error("Stock data not found!");
    return;
  }

  try {
    const stockData = JSON.parse(stockDataElement.textContent);
    console.log("Parsed Stock Data:", stockData);
    console.log("Selected Size ID:", sizeId);

    if (stockData[sizeId]) {
      const uploadedStock = stockData[sizeId].uploaded_stock_quantity;
      const stockQuantity = stockData[sizeId].stock_quantity;
      document.getElementById('uploaded-stock').innerText = `${uploadedStock} in stock`;
      document.getElementById('remaining-stock').innerText = `Only ${stockQuantity} left`;
    } else {
      console.error("No stock data available for size:", sizeId);
    }
  } catch (error) {
    console.error("Error parsing stock data:", error);
  }
}

// Trigger for initially selected size
document.addEventListener('DOMContentLoaded', function() {
  const checkedSize = document.querySelector('input[name="size"]:checked');
  if (checkedSize) {
    updateStock(checkedSize);
  }
});

Issue Faced:

  • undefined in stock or Only undefined left
  • The stock data is visible in the console using console.log, but the values are not reflected in the HTML.
  • No JavaScript errors in the console.

What I Tried:

  1. Confirmed size_stock_data is correctly passed to the template.
  2. Verified json_script using console.log(document.getElementById('size-stock-data').textContent).
  3. Confirmed HTML IDs are correct and not duplicated.
  4. Ensured the size IDs are properly rendered.

Expected Result:

  • When a size is selected, it should update the stock details with the correct values like 100 in stock and Only 98 left.

How can I fix this issue? Any suggestions are appreciated!

Add multiple select options to url paramter with Javascript | remove undefined

I want to create a url where I send select option values to the url.

I already saw that article, which helps a lot. Add multiple select options to url paramter with Javascript

The only thing with this code is, if I choose the second option and leave the first blank, I get a name=undefined in the url for the first value. But only for the first option value, the others are just not in the url if blank.

Can you please help to adjust the code, thank you. if there is no value selected, it should be not added to the url.

Another point is, if the option is preselected with html, it gets ignored and therefor an undefined.

<option value="2" selected>2</option>

thank you for your help.

Here is the code/answer from the other article:

<form action="" method="GET" id="myForm">
    <select name="channel" id="0" onChange="changeURL(0)">
            <option value="" selected disabled>Choose Channel</option>
            <option value="facebook-ads">Facebook ads</option>
            <option value="instagram-ads">Instagram ads</option>
    </select>
        <select name="brand" id="1" onChange="changeURL(1)">
            <option value="" selected disabled>Choose Brand</option>
            <option value="brand-1">brand 1</option>
            <option value="brand-2">brand 2</option>
            <option value="brand-3">brand 3</option>
        </select>
</form>
<p id="test"></p>
<script>

var filters = [,]; // create an array with empty values (only 2 in this case)

function changeURL(a) {
    var yourUrl = "https://yourdomain.com"; // your url
    filters[a] = document.getElementById(a).value; // set the value of the selected filter inside the array
    var preFilter = "?"; // blank url will need a "?" to start with your filters
    for(var i=0; i<filters.length; i++) {
        aName = document.getElementById(i).name; // get the name of the filter
        yourUrl += preFilter + aName + "=" + filters[i];
        preFilter = "&";  
    }
    document.getElementById("test").innerHTML = yourUrl; // test output of the new url
}
</script>

Is it possible to record current playing audio using web audio and play in different context?

I want to record current playing audio using Audio Worklet processer and web audio api and play in real time with possible lag of 100ms current audio sources, but the audio is distorted and not playing correctly so what is correct way to fix the following issues?

In following code a test.mp3 file selected, then played, after that the start processing button clicked to make current playing audio volume to 0.01 and and play the new processed audio in new context. The audio taken from Audio Worklet Processor.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Real-Time Audio Processing</title>
</head>
<body>
    <h1>Real-Time Audio Processing</h1>
    <audio id="audio" controls>
        <source src="test.mp3" type="audio/mpeg">
        Your browser does not support the audio tag.
    </audio>
    <button id="start">Start Processing</button>
    <button id="stop" disabled>Stop Processing</button>

    <script>
        let originalAudio, audioContext, newAudioContext, workletNode, mediaStreamSource;
        let bufferQueue = [];
        let isPlaying = false;
        let processorNode;
        let startTime = 0;
        let lastAudioTime = 0;

        document.getElementById('start').addEventListener('click', async () => {
            originalAudio = document.getElementById('audio');
            originalAudio.volume = 0.01; // Mute original audio to 0.01 but still play

            const stream = originalAudio.captureStream();

            audioContext = new AudioContext();
            newAudioContext = new AudioContext();

            // Register WorkletProcessor
            await audioContext.audioWorklet.addModule(URL.createObjectURL(new Blob([`
                class RecorderProcessor extends AudioWorkletProcessor {
                    constructor() {
                        super();
                        this.port.start();
                    }
                    process(inputs) {
                        const input = inputs[0];
                        if (input.length > 0) {
                            const outputBuffer = input[0]; // First channel data
                            this.port.postMessage(outputBuffer); // Send to main thread
                        }
                        return true;
                    }
                }
                registerProcessor("recorder-processor", RecorderProcessor);
            `], { type: "application/javascript" })));

            workletNode = new AudioWorkletNode(audioContext, "recorder-processor");

            workletNode.port.onmessage = (event) => {
                const data = event.data;
                bufferQueue.push(data);
                if (!isPlaying) {
                    playBufferedAudio();
                }
            };

            mediaStreamSource = audioContext.createMediaStreamSource(stream);
            mediaStreamSource.connect(workletNode);
            workletNode.connect(audioContext.destination);

            document.getElementById('start').disabled = true;
            document.getElementById('stop').disabled = false;
        });

        function playBufferedAudio() {
            if (bufferQueue.length === 0) {
                isPlaying = false;
                return;
            }

            isPlaying = true;

            const data = bufferQueue.shift();
            const buffer = newAudioContext.createBuffer(1, data.length, newAudioContext.sampleRate);
            buffer.copyToChannel(new Float32Array(data), 0);

            const source = newAudioContext.createBufferSource();
            source.buffer = buffer;
            source.connect(newAudioContext.destination);

            if (startTime === 0) {
                startTime = newAudioContext.currentTime + 0.02; // Add slight delay to sync
            } else {
                startTime = Math.max(newAudioContext.currentTime, lastAudioTime);
            }

            lastAudioTime = startTime + buffer.duration;
            source.start(startTime);

            source.onended = playBufferedAudio;
        }

        document.getElementById('stop').addEventListener('click', () => {
            audioContext.close();
            newAudioContext.close();
            bufferQueue = [];
            isPlaying = false;
            console.log("Stopped processing audio");
        });
    </script>
</body>
</html>

Is there a way to link this program? [closed]

I am going to need a lot of help with linking this program.

C:UsersuserDesktop>link /subsystem:console /entry:main malware.obj /RapeKernel32.lib
Microsoft (R) Incremental Linker Version 14.29.30159.0
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : warning LNK4044: unrecognized option '/RapeKernel32.lib'; ignored
malware.obj : error LNK2001: unresolved external symbol _GetStdHandle@4
malware.obj : error LNK2001: unresolved external symbol _WriteFile@20
malware.obj : error LNK2001: unresolved external symbol _ExitProcess@4

malware.exe : fatal error LNK1120: 3 unresolved externals

How to make the hover text in desktop to appear below the image?

I am building a website related to a branding agency and I am making its Our Team Section where I need to put a hover animation on the team members images to show their names, roles and linkedin profile button link as an overlay text. While I have successfully done that for the desktop view, I cannot seem to find a solution to do that in mobile view, I want to make the mobile view such that the description of the team member (name, role and linkedin) is fixed below each image in the smaller screens while keeping the layout similar to what the desktop is showing. Below is the code for the same

/* team container CSS start */
.team-container-outer {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100dvw;
    height: 150vh;
}

.team-container {
    display: flex;
    width: 80%;
    height: 90%;
    flex-direction: column;
    align-items: center;
}

@media (min-width:1450px) {
    .team-container-outer {
        width: 100dvw;
        height: 180vh;
    }

    .team-container {
        display: flex;
        width: 60%;
        height: 90%;

    }
}

.first-column,
.second-column,
.third-column {
    width: 100%;
    display: flex;
}

.first-column {
    flex: 2.5 1;
    flex-direction: row;
    justify-content: space-between;
    gap: 25px;
}

.second-column {
    flex: 1 1;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}

.third-column {
    flex: 3 1;
    justify-content: space-between;
    gap: 25px;
}

/* Base styles for all boxes */
.box {
    width: 30%;
    border-radius: 40px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

/* Remove hover from parent box6 */
.box6 {
    width: 30%;
    display: flex;
    flex-direction: column;
    height: 98%;
    gap: 3%;
    transform: none !important;
    transition: none !important;
}

/* Individual box styles */
.box1, .box2, .box3, .box4, .box5 {
    transition: transform 0.3s ease;
}

.box6-1, .box6-2 {
    width: 100%;
    flex: 1;
    border-radius: 40px;
    position: relative;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    transition: transform 0.3s ease;
}

/* Hover effects for individual boxes */
.box1:hover, .box2:hover, .box3:hover, .box4:hover, .box5:hover,
.box6-1:hover, .box6-2:hover {
    transform: scale(1.05);
}

/* Team member overlay styles */
.team-member-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

/* Show overlay only on hover of individual boxes */
.box1:hover .team-member-overlay,
.box2:hover .team-member-overlay,
.box3:hover .team-member-overlay,
.box4:hover .team-member-overlay,
.box5:hover .team-member-overlay,
.box6-1:hover .team-member-overlay,
.box6-2:hover .team-member-overlay {
    opacity: 1;
    visibility: visible;
}

.team-member-name {
    color: white;
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0;
}

.team-member-role {
    color: #4dd6f5;
    font-size: 1rem;
    margin: 0;
    font-weight: 500;
}

.linkedin-btn {
    background: #0077b5;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    border: none;
    margin-top: 5px;
}

.linkedin-btn:hover {
    background: #005885;
    transform: translateY(-2px);
}

/* Box background images */
.box1 {
    background: url(https://www.istockphoto.com/photos/full-length-person);
    background-size: cover;
    height: 70%;
}

.box2 {
    background: url(https://www.istockphoto.com/photos/full-length-person);
    background-size: cover;
    height: 70%;
    align-self: end;
}

.box3 {
    background: url(https://www.istockphoto.com/photos/full-length-person);
    background-size: cover;
    height: 70%;
}

.box4 {
    background: url(https://www.istockphoto.com/photos/full-length-person);
    background-size: cover;
    height: 95%;
    align-self: center;
}

.box5 {
    background: url(https://www.istockphoto.com/photos/full-length-person);
    background-size: cover;
    height: 80%;
    align-self: center;
}

.box6-1 {
    background: url(https://www.istockphoto.com/photos/full-length-person);
    background-size: cover;
}

.box6-2 {
    background: url(https://www.istockphoto.com/photos/full-length-person);
    background-size: cover;
}

/* Media queries */
@media (max-width: 768px) {
    .team-container-outer {
        height: 90vh;
    }

    .team-member-overlay {
        padding: 15px;
    }

    .team-member-name {
        font-size: 1.2rem;
    }

    .team-member-role {
        font-size: 0.9rem;
    }

    .linkedin-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .team-container-outer {
        height: 45vh;
    }

    .box, .box6-1, .box6-2 {
        border-radius: 25px;
    }

    .team-member-overlay {
        padding: 10px;
        opacity: 1;
        visibility: visible;
        background: rgba(0, 0, 0, 0.75);
    }

    .team-member-name {
        font-size: 1rem;
    }

    .team-member-role {
        font-size: 0.8rem;
    }

    .linkedin-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

@media screen and (max-width: 360px) {
    .team-member-name {
        font-size: 0.9rem;
    }

    .team-member-role {
        font-size: 0.75rem;
    }

    .linkedin-btn {
        padding: 5px 10px;
        font-size: 0.75rem;
    }
}
<section id="our-team" class="page6 hidden animate-on-scroll">
    <div class="team-container-outer">
      <div class="team-container">
        <div class="first-column">
          <div class="box box1">
            <div class="team-member-overlay">
              <h3 class="team-member-name">Aayush</h3>
              <p class="team-member-role">Frontend Developer</p>
              <a href="https://www.linkedin.com/in/aayush" target="_blank" rel="noopener" class="linkedin-btn">LinkedIn Profile</a>
            </div>
          </div>
          <div class="box box2">
            <div class="team-member-overlay">
              <h3 class="team-member-name">Lakshya</h3>
              <p class="team-member-role">Founder and UI/UX Designer</p>
              <a href="https://www.linkedin.com/in/lakshya" target="_blank" rel="noopener" class="linkedin-btn">LinkedIn Profile</a>
            </div>
          </div>
          <div class="box box3">
            <div class="team-member-overlay">
              <h3 class="team-member-name">Abhijeet</h3>
              <p class="team-member-role">Graphic Designer and Video Editor</p>
              <a href="https://www.linkedin.com/in/abhijeet" target="_blank" rel="noopener" class="linkedin-btn">LinkedIn Profile</a>
            </div>
          </div>
        </div>
        <div class="second-column">
          <h1>MEET OUR TEAM</h1>
          <p>We Explore, Create, Design, Develop only for your Growth</p>
        </div>
        <div class="third-column">
          <div class="box box4">
            <div class="team-member-overlay">
              <h3 class="team-member-name">Sumit</h3>
              <p class="team-member-role">Full Stack Developer</p>
              <a href="https://www.linkedin.com/in/sumit" target="_blank" rel="noopener" class="linkedin-btn">LinkedIn Profile</a>
            </div>
          </div>
          <div class="box box5">
            <div class="team-member-overlay">
              <h3 class="team-member-name">Aman</h3>
              <p class="team-member-role">LinkedIn Manager</p>
              <a href="https://www.linkedin.com/in/aman" target="_blank" rel="noopener" class="linkedin-btn">LinkedIn Profile</a>
            </div>
          </div>
          <div class="box box6">
            <div class="box box6-1">
              <div class="team-member-overlay">
                <h3 class="team-member-name">Avneesh</h3>
                <p class="team-member-role">Web Developer</p>
                <a href="https://www.linkedin.com/in/avneesh" target="_blank" rel="noopener" class="linkedin-btn">LinkedIn Profile</a>
              </div>
            </div>
            <div class="box box6-2">
              <div class="team-member-overlay">
                <h3 class="team-member-name">Divyanshu</h3>
                <p class="team-member-role">Web Developer</p>
                <a href="https://www.linkedin.com/in/divyanshu" target="_blank" rel="noopener" class="linkedin-btn">LinkedIn Profile</a>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>

Why does Promise.resolve().then() execute before process.nextTick() in my Node.js script?

I’m trying to understand the async operations of node.js, specifically process.nextTick() and Promise().

The process.nextTick() has the highest priority in async operations compared to all other operations.

process.nextTick(() => console.log("tick"));

Promise.resolve().then(() => console.log("promise"));

For above code the expected output should be:

tick
promise

But instead I got below output:

promise
tick

I could not able to understand why this strange behaviour happens, please give me proper reason and solution for this. Thanks for support.

How to maintain the selected state of radio button in slick slides as you navigate between slides

Steps to do.

  1. Select the radio button item 1.
  2. Click the slick next arrow until you reach again the item 1 and it is not selected. I want it selected because you select it previously.

I want to maintain the selected state of radio button in slick slides once it shown in the slick/viewport.

I tried using the slick Methods and Events like slickGoTo, afterChange ect.. but no to avail.

Here are my codes.

$('.my-slick-carousel').each(function() {
        let slider = $(this);
        slider.slick({
            slidesToShow: 2,
            slidesToScroll: 1,
            autoplay: false,
            dots: true,
            infinite: true,
            arrows: true,
            centerPadding: '0px',
            variableWidth: false,
            centerMode: false,
            touchThreshold: 100,
            rows: 0,
        });
    });
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick-theme.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.6.3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js"></script>
<style>
.items {
  background-color: gray;
  border-radius:2rem;
  text-align:center;
}
.slick-prev,
.slick-next {
  z-index:9;
}
.slick-next:before, .slick-prev:before {
  color: red;
}
.slick-prev {
  left: 0;
}
.slick-next {
  right: 0;
}
</style>

<div class="container">
  <h4 class="text-center">Maintain the selected radio button on slick slide and maintain the selected state as you navigate between slides.</h4>
  <div class="my-slick-carousel py-5 px-3">
    <div class="items mx-2 p-4"><input type="radio" name="addOnsRadio" value="item 1" id=""> item 1</div>
    <div class="items mx-2 p-4"><input type="radio" name="addOnsRadio" value="item 2" id=""> item 2</div>
    <div class="items mx-2 p-4"><input type="radio" name="addOnsRadio" value="item 3" id=""> item 3</div>
  </div>
</div>

Memory game code works but only if tiles are clicked slowly, if tiles are clicked too fast game breaks

HTML CODE

 <!DOCTYPE html>
<html>
    
    <body style="justify-self:center;">
        <h1 style="justify-self:center">Memory Game</h1>
        <div id="cont" style="width:px">
            <p class="stats" style="justify-self:center ;"></p>
            <div class='cardContainer' style="justify-self:center ;">
                <div class='card' id="1"></div>
                <div class='card' id="1"></div>
                <div class='card' id="2"></div>
                <div class='card' id="2"></div>
                <div class='card' id="3"></div>
                <div class='card' id="3"></div>
                <div class='card' id="4"></div>
                <div class='card' id="4"></div>
                <div class='card' id="5"></div>
                <div class='card' id="5"></div>
                <div class='card' id="6"></div>
                <div class='card' id="6"></div>
                <div class='card' id="7"></div>
                <div class='card' id="7"></div>
                <div class='card' id="8"></div>
                <div class='card' id="8"></div>
            </div>
        
            <div style="justify-self:center ;"><button id="reset" style="margin-top: 20px; ">Reset Game</button></div>
            <script src="mg.js"></script>
        </div>   
    </body>
    

</html> 

JS CODE

const cards = document.querySelectorAll('.card')
let clickCount = 0
let id = []
let matched = 0

function shuffle(){
    cards.forEach(card => {                                                  
        let pos = Math.floor(Math.random() * 12);
        card.style.order = pos
    })
}

shuffle()

function checkMatch(){
    if (id[0] == id[1]){
        return true
    }else{return false}
}


cards.forEach(card=>{
    card.addEventListener('click', ()=>{
        card.innerHTML = card.id
        id.push(card.id)
        card.setAttribute('open', 'true')
        clickCount += 1
        console.log(clickCount)
        if (clickCount == 2){
            let result = checkMatch()
            clickCount = 0
            if (result == false){
                id = []
                setTimeout(()=>{document.querySelectorAll('[open="true"]').forEach((card)=>{card.innerHTML='';card.removeAttribute('open', 'true')})},100)
            }else{
                console.log('matched')
                id = []
                document.querySelectorAll('[open="true"]').forEach((card)=>{card.removeAttribute('open', 'true');card.replaceWith(card.cloneNode(true))})
                matched += 2
            }
        }
        if (matched == 16){
            console.log('You win')
        }
    })
})

If i click the tiles slowly and play the game the game works properly. However if i were to try and randomly click tiles super fast, one of the clicked tiles declare itself as matched and stays open even thought it hasn’t matched. How do I fix this.
[1]: https://i.sstatic.net/65H9nyzB.png

Searching child elements of HTML DOM element?

const parent = document.getElementById('parent');
const paragraphs = parent.getElementsByTagName('p'); // Get all <p> tags
console.log(paragraphs); // HTMLCollection of <p> elements
<div id="parent">
    <p class="child">First Child</p>
    <p class="child">Second Child</p>
    <span class="child">A Span Child</span>
</div>

Code like this works, but I can’t find any documentation for using .getElementsByTagName – or any other JavaScript DOM search methods – as a method with HTMLelement, only with document, why is this?

See:
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
https://developer.mozilla.org/en-US/docs/Web/API/Document