unresponsive product image

I am having this issue that I have been trying to debugg for the last 24 hr. I made this shopping cart with HTML and css and JS. I first made the side list witch mounted correctly; its only css and html, but then when I made the item menu by running a function with a return statement, and template-litherals to embed the image with its border, it does not show up on the browser. I alredy debugged all my code from all the ovius mistakes that I made and the console is not reporting any errors, but for some reason I still cant load the image on my menu. I just dont know where my problem is!

Here lies my progress, as you can see its a pretty large “rabbit hole” it starts with the heading and then the item menu and finally the product menu. I have made the connection with the CSS which is “stats.css” and added the javaScript within the html with <script></script> tags.

<!DOCTYPE html>
<html lang="en">
 <head>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">
  <title>
   perfume
  </title>
  <link href="stats.css" rel="stylesheet">
 </head>
 <body>
  <div class="header">
   <p class="logo">
    Amazon, Spend less smile more
   </p>
   <div class="cart">
    <i class="bi bi-cart4">
    </i>
    <p id="count">
     0
    </p>
   </div>
  </div>
  <div class="grid">
   <div id="root">
   </div>
   <div class="sidebar">
    <div class="head">
     <p>
      My Stuff
     </p>
    </div>
    <div id="cartItem">
     Your cart is Empthy
    </div>
    <div class="foot">
     <h3>
      Total
     </h3>
     <h2 id="total">
      $ 0.00
     </h2>
    </div>
   </div>
  </div>
  <script type="text/javascript">
    const product = [
      {
        id: 0,
        image: "product/perfume.jpeg",
        title: "Victoria Secret Perfume",
        price: 50,
      },
    ];

    const categories = [
      ...new Set(
        product.map((item) => {
          return item;
        }),
      ),
    ];
    let i = 0;

    ///HERE is the return statement!
    document.getElementById("root").innerHTMl = categories
      .map((item) => {
        let { image, title, price } = item;
        return (
          `<div class= 'box'>
                        <div class= 'img-box'>
                                <img class='images' src=${image}></img>

                                </div>
                            <div class='bottom'>
                            <p>${title}</p>

                            <h2>$ ${price}.00  </h2>` +
          "<button onclick='addtocart(" +
          i++ +
          ")'>Add to cart</button>" +
          `</div>
                            </div>`
        );
      })
      .join("");

  </script>
 </body>
</html>

Here lies my CSS I targeted several parts of the html.

body {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.header {
  height: 4em;
  width: 70%;
  background: #3a3b3c;
  border-radius: 1em;
  margin: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2em;
}

.header .logo {
  font-size: 4em;
  font-weight: bold;
  color: #fff;
}

.cart {
  display: flex;
  background: #fff;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  border-radius: 3px;
  width: 80px;
}

.cart p {
  height: 22px;
  width: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  background-color: #3a3b3c;
  color: #fff;
}

.grid {
  display: flex;
  width: 70%;
  margin-bottom: 30px;
}

#root {
  width: 60%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-gap: 20px;
}

.sidebar {
  width: 40%;
  border-radius: 5px;
  background: #808080;
  margin-left: 5em;
  padding: 1em;
  text-align: center;
}

.head {
  background-color: #3a3b3c;
  border-radius: 1em;
  height: 2em;
  padding: 5px;
  margin-bottom: 1em;
  color: #fff;
  display: flex;
  align-items: center;
}

.foot {
  display: flex;
  justify-content: space-between;
  margin: 20px 0;
  padding: 10px 0;
  border-top: 1px solid #212329;
}

.box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #212329;
  border-radius: 5px;
  padding: 15px;
}

.img-box {
  width: 100%;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.images {
  max-width: ;
  max-height: ;
  object-fit: cover;
  object-position: center;
}

.bottom {
  margin-top: 20px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  height: 110px;
}

h2 {
  font-size: 20px;
  color: red;
}

button {
  width: 100%;
  border: none;
  border-radius: 5px;
  position: relative;
  padding: 7px 25px;
  color: #fff;
}

button:hover {
  background-color: #212329;
}

Node: DeprecationWarning: Buffer() is deprecated due to security and usability issues

I’m currently facing an issue when deploying my Node.js code to hosting. It’s showing the error “(node:85736) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. (Use node –trace-deprecation … to show where the warning was created).” I have checked my code thoroughly, and I’m not using the mentioned code anywhere. The Buffer only appears in the package.lock.json file. I have also updated Node.js and npm to the latest versions, but the issue persists.
enter image description here

Is there any way to fix this error?

Mapbox’s storytelling has the text boxes scrolling behind the map in Safari

When using firefox on web and android, everything looks fine. But when I use Safari the boxes often don’t scroll over the map. It looks like everything is working, except the boxes are scrolling behind the map, and are thus unseen. If I wait a bit and come back to the page, the boxes sometimes appear normal. But after refreshing, they disappear again. This is my code

I’ve tried a variety of browsers and OS, and this appears to only be a problem with Safari, but it’s a problem on both mobile and desktop. I have no idea how to even begin debugging a problem that occurs like this.

Javascript help PLEASE [closed]

OK I am lost.
Have a food site with a lot of recipes. Lost my computer and all that was on it week or so ago. Which included all coding.
My problem: On the site I had a Content/Recipe randomizer for the Recipe directories that changed whenever someone went to the website. Now I cannot find the code anymore to make this happen.

Example say I have Asian, Cajun, American for categories. It used to rotate them automatically to give viewers a different page every time they visited, and I liked it very much. I lost the code and am lost at how to redo it.

Can anyone help me?????

I have pulled hair out trying but cannot find nor duplicate what it was…

my SVG chess images are not changing their color

I am building a chess game in my js/css part of code when i try to change my svg images they’re not working idk why, I used fill in my css on that very element which is a child, but nothing is wrong

here is my code

const gameBoard = document.querySelector("#gameboard");

const playerDispaly = document.querySelector("#player");
const infoDisplay = document.querySelector("#info-display");
const width = 8;

const startPieces = [
  rook,
  knight,
  bishop,
  queen,
  king,
  bishop,
  knight,
  rook,
  pawn,
  pawn,
  pawn,
  pawn,
  pawn,
  pawn,
  pawn,
  pawn,
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  pawn,
  pawn,
  pawn,
  pawn,
  pawn,
  pawn,
  pawn,
  pawn,
  rook,
  knight,
  bishop,
  queen,
  king,
  bishop,
  knight,
  rook,
];

function createBoard() {
  startPieces.forEach((startPieces, i) => {
    const square = document.createElement("div");
    square.classList.add("square");
    //square.classList.add("beige")//
    const row = Math.floor((63 - i) / 8) + 1;
    if (row % 2 === 0) {
      square.classList.add(i % 2 === 0 ? "beige" : "brown");
    } else {
      square.classList.add(i % 2 === 0 ? "brown" : "beige");
    }

    /*if (i <= 15) {
      square.firstChild.firstChild.classList.add("black");
    }*/

    square.innerHTML = startPieces;
    square.setAttribute("sqaure-id", i);
    gameBoard.append(square);
  });
}

createBoard();
#gameboard {
  width: 320px;
  height: 320px;
  background-color: black;
  display: flex;
  flex-wrap: wrap;
}

.square {
  height: 40px;
  width: 40px;
}

.square svg {
  height: 30px;
  width: 30px;
  margin: 5px;
}

.beige {
  background-color: rgb(110, 110, 98);
}

.brown {
  background-color: rgb(169, 43, 43);
}

.black {
  fill: #ff0000;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Chess</title>
  <link rel="stylesheet" href="style.css" />
</head>

<body>
  <div id="gameboard"></div>
  <p>It is <span id="player"></span>go.</p>
  <p id="info-display"></p>

  <!-- actual assets missing here -->
  <script src="pieces.js"></script>
  <script src="app.js"></script>
</body>

</html>

the issue is with the svg fill property not working, or my css idk i tried different things like making my sqaure svg fill to inherit but didn’t work so idk

Optional chaining working not as expected

I’m learning JS from one of Udemy courses where optional chaining is explained. I think I get it yet there is a strange outcome I cannot figure out. I’m literally starying at it for 30minutes and cannot see what is the issue here.

There is a restaurant object with methods:

  order(starterIndex, mainIndex) {
    return [this.starterMenu[starterIndex], this.mainMenu[mainIndex]];
  },

  orderPizza(mainIngredient, ...otherIngredients) {
    console.log(`Ordered pizza with ${mainIngredient} and additional: ${otherIngredients}`)
  }

Then I use optional chaining on these methods :

console.log(restaurant.orderPizza?.('salami') ?? 'Method does not exist 1');
console.log(restaurant.order?.(0, 1) ?? 'Method does not exist 2');
console.log(restaurant.order?.(0, 1) ?? 'Method does not exist 3');
console.log(restaurant.orderRisotto?.(0, 1) ?? 'Method does not exist 4');

And as a result I got:

Ordered pizza with salami and additional: 
Method does not exist 1
(2) ['Focaccia', 'Pasta']
(2) ['Focaccia', 'Pasta']
Method does not exist 4

Why Method does not exist 1 is printed since method exists and is executed? There are no issues with .order() method tho, what am I missing here? Is it because of return and .orderPizza() is more like a void? But this concept does not apply to JavaScript right? At least it was not introduced to me so far.

How to handle an event of a child element, on a parent element?

I have a component that contains a Checkbox component from the @fluentui/react-components library, and I am using an onChange event on the Checkbox component.

const ContactText = ({ contact, contactKey, selectedContacts, setSelectedContacts }) => {

  return (
    <div>
      <img src={contactIcon} alt="Contact Icon" />
      <div>
        <Checkbox
          labelPosition="before"
          label={`${contact.firstname} ${contact.surname}`}
          checked={selectedContacts.filter((contact) => contact.key == contactKey).checked}
          //@ts-ignore - Ignore event parameter on onChange
          onChange={(event, data) => {
            setSelectedContacts((prevState: SelectedContactModel[]) =>
              data.checked
                ? [
                    ...prevState,
                    {
                      key: contactKey,
                      checked: data.checked,
                      companyKey: contact.companyKey,
                      companyName: contact.companyName,
                      individual: contact.individual,
                      title: contact.title,
                      firstname: contact.firstname,
                      surname: contact.surname,
                      telephone: contact.telephone,
                      mobile: contact.mobile,
                      retired: contact.retired,
                      address: contact.address,
                      postcode: contact.postcode,
                      email: contact.email,
                    },
                  ]
                : prevState.filter((contact) => contact.key !== contactKey)
            );
          }}
        />
        {contact.email != "" ? <SecondaryText text={contact.email} /> : <></>}
        {contact.telephone != "" ? <TertiaryText text={contact.telephone} /> : <></>}
        {contact.mobile != "" ? <TertiaryText text={contact.mobile} /> : <></>}
      </div>
    </div>
  );
};

I want to have the onChange to happen when I click the outermost div of the ContactText component. I have seen people using useRef although I am wondering if there are different ways of doing this.

Trigger multiple test using MOCHA

Context:

My test folder automationSuiteapiTestSuite has around 4 test files
userAPIValidation.js orderAPIValidation.js verifyAPIEndPoints.js verifyHealthEndPoints.js

And also I am using the mocha multi reporter to generate the Jnuit report file. As follows, from the snippet from package.json file

"scripts": {
    "test": "mocha automationSuite\apiTestSuite\verifyAPIEndPoints.js --reporter mocha-junit-reporter --reporter-options mochaFile=./autoTestResult/test-results.xml"
  },

And I want to add userAPIValidation.js & orderAPIValidation.js and generate the separate report for each

like mocha automationSuite\apiTestSuite\userAPIValidation.js & mocha automationSuite\apiTestSuite\orderAPIValidation.js (note this is just example to show my intention)

is there any way I can do it ?

Hours-related exercise in JavaScript

I have a function that receives an hours array (hoursArray) and a number variable (minutes).
hoursArray are the available hours of a barber schedule. Duration is de duration of the service that the client books (hair salon).

The current code returns another array with the hours of the hoursArray that are available according to the variable ‘minutes’, that is to say: If the array hoursArray is:

const hoursArray = [
    "09:00",
    "11:00",
    "11:30",
    "12:00",
    "13:00",
    "14:00",
    "14:30",
    "15:00",
    "15:30",
    "16:00",
];

And minutes is: minutes = 30

The function returns:

[ '09:00', '11:00', '11:30', '12:00', '13:00', '14:00', '14:30', '15:00', '15:30', '16:00' ]

Why?

The arrayHours in this case are intervals of 30 minutes. If the arrayHours starts with 09:00, 11:00 it means that 09:30, 10:00 and 10:30 are already reserved. So in the return array, this hours don’t appear, only 09:00 and 11:00. This is the logic for all of the array. The code that models this is:

function getAvailableHours(hours: string[], minutes: number): string[] {
    const availableHours: string[] = [];

    for (let i = 0; i < hours.length - 1; i++) {
        const currentHour = hours[i];
        const nextHour = hours[i + 1];

        const [hour1, minute1] = currentHour.split(":").map(Number);
        const [hour2, minute2] = nextHour.split(":").map(Number);

        const totalMinutes1 = hour1 * 60 + minute1;
        const totalMinutes2 = hour2 * 60 + minute2;
        const timeDifference = totalMinutes2 - totalMinutes1;

        if (minutes === 60) {
            if (timeDifference >= minutes) { } else {
                availableHours.push(currentHour);
            }
        }

        if (minutes === 30) {
            availableHours.push(currentHour);
        }
    }

    if (minutes === 30) {
        availableHours.push(hours[hours.length - 1]);
    }
    return availableHours;
}

But now, I need other functionality, I need that the function to do the same but with any interval of arrayHours (15mins, 30mins, 45min or 60mins) and the ‘minutes’ variable, also could be 15mins, 30mins, 45mins or 60mins.

I’ve been trying for months but I can’t get a good result.

iOS Audio Output Issue: Audio Coming from Front Speaker Instead of Main Speaker

Issue Description:

I am encountering an issue with audio output on iOS devices when using the YouTube embed feature alongside the user’s webcam and audio player on my website. The problem is specifically related to the audio output coming from the front speaker (earpiece) instead of the main speaker on iPhones, including iPhone 12 and 13.

Steps to Reproduce:

  1. Open the website on an iOS device (iPhone 12, 13, etc.).
  2. Start a workout.
  3. Observe the audio output location.

Expected Behavior:

The audio output should be directed to the main speaker of the device.

Actual Behavior:

The audio output is coming out of the front speaker (earpiece).

Additional Information:

  • This issue is reproducible on multiple iOS devices.
  • The website utilizes the YouTube embed feature.
  • We also use the user’s webcam and play audio during the interaction.

Environment:

  • iOS devices (iPhone 12, 13, etc.)
  • Website URL: Workout page
  • Browser: Safari & Chrome on iOS

Notes:

When playing a YouTube video on another page where there is no use of a webcam and a separate audio player on the same website, the audio is coming from the main speaker correctly, e.g., on this page: Videos page

Thank you for your assistance in addressing this matter.

Using NextJS <Link requires double tapping on mobile

When using the NextJS <Link tag, on mobile I have to double tap in order for the link to route.

Here is the code:

  <Link
          href="/methodology"
          passHref={true}
          target="_blank"
          rel="noopener noreferrer"
          className="w-auto text-right text-sm text-riskfactor-400 underline underline-offset-2 hover:text-riskfactor-300 md:w-[345px]"
          onClick={() =>
            handleLinkAnalytics(
              'How is Flood Calculated?',
              '/methodology',
            )
          }
        >
          How is Flood Calculated?
        </Link>

I passed in passHref but that didnt seem to solve the issue

Error: This part of the regular expression may cause exponential backtracking on strings starting with ‘ftp://’ and containing many repet of ‘0.0.’

/^(https?|ftp)://(((([a-z]|d|-|.||~|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])|(%[da-
f]{2})|[!$&'()*+,;=]|:)*@)?(((d|[1-9]d|1dd|2[0-4]d|25[0-5]).(d|[1-9]d|1dd|2[0- 4]d|25[0-5]).(d|[1-9]d|1dd|2[0-4]d|25[0-5]).(d|[1-9]d|1dd|2[0-4]d|25[0-
5]))|((([a-z]|d|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])|(([a-z]|d|[u00A0-uD7FFuF900-
uFDCFuFDF0-uFFEF])([a-z]|d|-|.|
|~|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])([a-
z]|d|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF]))).)+(([a-z]|[u00A0-uD7FFuF900- uFDCFuFDF0-uFFEF])|(([a-z]|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])([a-z]|d|-
|.|_|~|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])
([a-z]|[u00A0-uD7FFuF900-uFDCFuFDF0-
uFFEF]))).?)(:d*)?)(/((([a-z]|d|-|.||~|[u00A0-uD7FFuF900-uFDCFuFDF0-
uFFEF])|(%[da-f]{2})|[!$&'()*+,;=]|:|@)+(/(([a-z]|d|-|.|
|~|[u00A0-uD7FFuF900-
uFDCFuFDF0-uFFEF])|(%[da-f]{2})|[!$&'()*+,;=]|:|@)))?)?(?((([a-z]|d|-
|.||~|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])|(%[da-
f]{2})|[!$&'()*+,;=]|:|@)|[uE000-uF8FF]|/|?)*)?(#((([a-z]|d|-|.|
|~|[u00A0- uD7FFuF900-uFDCFuFDF0-uFFEF])|(%[da-f]{2})|[!$&'()*+,;=]|:|@)|/|?)*)?$/i

enter image description here

How do we find and resolve

enter image description here

Navigate dropdown using up and down arrow keys in jquery

I have input box with dropdown. We have implemented click event for input box for showing dropdown. for ada purpose, if user press arrow down and up need to show dropdown and navigate to option. Can anybody suggest how to implement in down arrow and up arrow to show dropdown and navigate to options. I know we need to use key up and key down event.

Thanks