LightSlider Not Working on BigCartel.com Store

I am trying to add a LightSlider image carousel with thumbnails to my Big Cartel website (to display product images) but I can’t get it to work (even with example images)

I have tested it on Codepen & JSFiddle – works fine there, but on my bigcartel.com store, The photos show up stacked. No thumbnail gallery.

My Code (working): Codepen

    width:500px;
}
.ls-slider ul {
    list-style: none outside none;
    padding-left: 0;
    margin-bottom:0;
}
.ls-slider li {
    display: block;
    float: left;
    margin-right: 6px;
    cursor:pointer;
}
.ls-slider li img {
    display: block;
    height: auto;
    max-width: 100%;
}```

How do you code a hamburger menu to make your navbar appear?

So I am trying to make a responsive nav bar menu by adding a hamburger menu so mobile users could also use my website. I coded the navbar and the hamburger menu. But my problem is that I don’t know how to make my navbar appear when you click the hamburger menu icon. Can any of you guys tell me what the code for making my navbar appear onclick. My code is below. Resize your browser to a smaller width to see the hamburger menu if you can’t see it. Please ask me questions if you did not understand my question. Again my code is below.

@import url("https://fonts.googleapis.com/css2?family=Amatic+SC&display=swap");

* {
  font-family: "Amatic SC", cursive;
  padding: 0;
  margin: 0;
  text-decoration: none;
  list-style: none;
  box-sizing: border-box;
}

nav {
  background: #000;
  height: 80px;
  width: 100%;
}

label.logo {
  color: white;
  font-size: 35px;
  line-height: 80px;
  padding: 0 100px;
}

nav ul {
  float: right;
  margin-right: 20px;
}

nav ul li {
  display: inline-block;
  line-height: 80px;
  margin: 0 5px;
}

nav ul li a {
  color: white;
  font-size: 17px;
  text-transform: uppercase;
  padding: 1px 13px;
  border-radius: 3px;
}

a.active,
a:hover {
  background-image: linear-gradient(
    109.6deg,
    rgba(61, 245, 167, 1) 11.2%,
    rgba(9, 111, 224, 1) 91.1%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  transition: 0.5s;
}

.nav-icon-5 {
  width: 20px;
  height: 15px;
  position: relative;
  cursor: pointer;
  visibility: hidden;
}
.nav-icon-5 span {
  background-color: #fff;
  position: absolute;
  border-radius: 2px;
  transition: 0.3s cubic-bezier(0.8, 0.5, 0.2, 1.4);
  width: 100%;
  height: 2px;
  transition-duration: 500ms;
}
.nav-icon-5 span:nth-child(1) {
  top: 2px;
  left: 0px;
}
.nav-icon-5 span:nth-child(2) {
  top: 8px;
  left: 0px;
  opacity: 1;
}
.nav-icon-5 span:nth-child(3) {
  bottom: -1px;
  left: 0px;
}
.nav-icon-5:not(.open):hover span:nth-child(1) {
  transform: rotate(-3deg) scaleY(-0.5);
}
.nav-icon-5:not(.open):hover span:nth-child(2) {
  transform: rotate(3deg) scaleY(1.1);
}
.nav-icon-5:not(.open):hover span:nth-child(3) {
  transform: rotate(-4deg) scaleY(1.1);
}
.nav-icon-5.open span:nth-child(1) {
  transform: rotate(45deg);
  top: 6px;
}
.nav-icon-5.open span:nth-child(2) {
  opacity: 0;
}
.nav-icon-5.open span:nth-child(3) {
  transform: rotate(-45deg);
  bottom: 7px;
}

@media (max-width: 715px) {
  .nav {
    visibility: hidden;
  }

  .nav-icon-5 {
    bottom: 80px;
  }

  .nav-icon-5 span {
    visibility: visible;
    background-color: #fff;
  }
}

@media (max-width: 440px) {
  .nav-icon-5 span {
    visibility: visible !important;
    background-color: #fff;
  }
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>.WWW Home</title>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link
      rel="stylesheet"
      type="text/css"
      media="screen"
      href="Global/navbar.css"
    />
  </head>
  <body>
    <nav>
      <label class="logo">.WWW</label>
      <ul class="nav">
        <li><a href="#" class="active">The Domain</a></li>
        <li><a href="#">The News</a></li>
        <li><a href="#">Interesting Factoids</a></li>
        <li><a href="#">Sign Off</a></li>
        <li>
          <div class="icon nav-icon-5" onclick="Nav()">
            <span></span>
            <span></span>
            <span></span>
          </div>
        </li>
      </ul>
    </nav>
  </body>
  <script></script>
  <script href="main.js">
    const icons = document.querySelectorAll(".icon");
    icons.forEach((icon) => {
      icon.addEventListener("click", (event) => {
        icon.classList.toggle("open");
      });
    });
  </script>
</html>

Problem closing a child window using Javascript in web automation

I’m trying to automate a browser process using Selenium WebDriver.

The web site generates a series of downloadable files with a link button for each. Clicking on the link button opens up a new browser window in which the file is downloaded. But the new browser window is not coded to close.

I have located the JavaScript/jQuery function OpenWindowUrl in chrome’s web dev tool that opens up the new browser window, and the gist of the function is shown below.

As you can see, the function calls another function GetRootWin to open up the new browser window and download the file, then forces the new browser window into the foreground. I wish it had a few more lines to close it after 3 seconds or so.

Since the variable wnd which is the handle of the new browser window is scoped inside the function definition, I’m not able to use it in my automation to close the browser window like wnd.close();, because wnd is undefined outside of the function.

Although my automation process works fine without closing the child windows, potentially it will leave me over 200 child windows open, not a good idea.

Is there a way to override this OpenWindowUrl function such that my new OpenWindowUrl will be called by the website instead? If yes, I can run my new snippet for OpenWindowUrl using Selenium’s IJavaScriptExecutor before downloading the files. Or is there a way to inject wnd.close(); into the OpenWindowUrl function?

$.extend(Namespace('NS'), {
 OpenWindowUrl: function (url, winName, parameters) {
        ... ...
        var wnd = NS.GetRootWin().open(url, winName, parameters);
        // Force the window into the foreground
        setTimeout(function () {
            wnd.focus();
        }, 500);
    },
});

How to keep text box and not hide it when another button is clicked

I am building out a product page and I want to have a small “shopping cart” on the page. I’ve set it up where when you click on the 8oz radio button and the Green Tea, Chamomile, or Oolong buttons and the “Add to Cart” button, a text box appears on the shopping cart on the bottom of the page.

However the problem I am having is that every time a new set is clicked (8oz and Chamomile after clicking 8oz and Green Tea), the original text box disappears. They are all separate text boxes but they keep hiding when a new selection is “added to cart”. I would like them to just stack on top of one another.

Here is my Fiddle to see the code. Thanks in advance!

How do I print a key of an array of objects and the value, where every key has a different name, adding a text in between them? (javascript) [duplicate]

const obj = [{
    "aliceblue": [240, 248, 255, 1],
    "antiquewhite": [250, 235, 215, 1],
    "aqua": [0, 255, 255, 1],
    "aquamarine": [127, 255, 212, 1],
    "azure": [240, 255, 255, 1],
    "beige": [245, 245, 220, 1],
    "bisque": [255, 228, 196, 1],
    "black": [0, 0, 0, 1]
}]

I have this array of objects and I need to be able to print this:

aliceblue RGB: 240, 248, 255, 1

every line printed needs to have the name of the color, “RGB:” and the numbers.

I tried with:

obj.forEach(colorName => {

let color = Object.keys(colorName)
    
});

And the same for the “Object.values”, but I can’t put the two results together.
Any ideas about how to do this?

Thank you so much in advance, guys.

Unable to change react-select selected value color when menu is clicked

I am using react-select to select and search from a list. I need to change the text color of the selected text (that is visible in the search box) to gray when the user clicks on the search box and intends to search for a new option while letting it remain black when the user clicks out of the search box/has selected a new option.

I can change the color of the text by modifying the style for singleValue in the styles prop. But cannot change the color when the search menu is selected. Tried some other options too but the text color does not change when the search menu is in the selected state.

<Select
  components={{
    DropdownIndicator: () => null,
    IndicatorSeparator: () => null,
  }}
  placeholder="Search Names"
  onChange={selectName}
  options={namesList}
  styles={{
    singleValue: (styles, state) => {
      return {
        ...styles,
        color: state.isSelected ? "gray" : "black",
      };
    },
  }}
/>;

Any suggestions what I am doing wrong here?

Looking for solutions to enable non-blocking 60fps autosuggest UI for react

Problem description:
What are some good approaches for creating non-blocking UI for 60 fps rendering performance for filter operation on large [] of items? In this case, it would be an autosuggest box that contains 1,000,000 of items.

Sandbox example of slow suggest: https://codesandbox.io/s/bold-fermi-jfz1el

Source of discussion: https://dev.to/miketalbot/search-as-you-type-at-60fps-with-js-coroutines-35pc

MapboxGl Distinguishing Between “Move” and “Fly” Event

In MapboxGL JS, is it possible to watch a “flyTo” event triggered by the geolocate API, and not the user moving around the screen manually by dragging the map?

I’m trying to trigger an action in my application only when the user successfully enters a search into the Geolocation controller. The map has a movestart event that works for this, but it also captures the user’s movement of the screen via the cursor or their finger.

import Geocoder from "@mapbox/mapbox-gl-geocoder";
const geocoder = new Geocoder({
  countries: "us",
  accessToken: mapboxGl.accessToken,
  mapboxgl: mapboxGl,
  marker: false,
  render: function (item) {
    return `<span class='geocoder-dropdown-text'>${item.text}</span>`;
  },
});

map.on("movestart", (e) => {
  // The problem is this event is too broad...
});

Is it possible to only listen for the “flying” event when the Geolocation API fires, or specifically provide a callback to the Geocoder that will fire when the animation begins?

How to import JS modules in client sided JS files?

Sorry if the question wording is unclear. When I try to use the Ably module in my client-side js file, the object doesn’t exist. I thought that javascript files within the same HTML file all had access to each other, so my client-side JS file would have access to Ably because I specified them both, but it won’t function. If I type Ably in the JS file, which should let me access the methods of the Ably module, it does not recognize it and nothing happens(besides not found errors, of course)

Here is the HTML file

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./css/metronome.css">
    <title>whywontthiswork</title>
    <script lang="text/javascript" src="https://cdn.ably.com/lib/ably.min-1.js"></script>
    <script src="/public/app.js" type="module"></script>
</head>...

Here is the JS code segment that doesnt work because it won’t recognize Ably and thinks its random text.

const client = new Ably.Realtime({ 
    key: "(my key)" 
});

Here is my file structure

├── public/
│   ├── app.js
├── views/
│   ├── metronome.html

How to fix my onFormSubmit function with state?

There is part of my Component:

 const { id } = useParams();
  const [name, inputName] = useState("");
  const [email, inputEmail] = useState("");
  const [start, inputStart] = useState("");
  const [end, inputEnd] = useState("");

  const [errorNameEmpty, isErrorNameEmpty] = useState(false);
  const [errorEmailValid, iserrorEmailValid] = useState(false);
  const [errorStartEmpty, isErrorStartEmpty] = useState(false);
  const [errorEndEmpty, isErrorEndEmpty] = useState(false);
  const [errorDate, isErrorDate] = useState(false);
  const [sendData, setSendData] = useState(false);

  const validEmail = new RegExp(/^S+@S+.S+$/);

  const onFormSubmit = (e) => {
    e.preventDefault();
    let startDate = new Date(start).getTime();
    let endDate = new Date(end).getTime();

    if (startDate > endDate || startDate === endDate) {
      isErrorDate(true);
    } else {
      isErrorDate(false);
    }

    if (name === "") {
      isErrorNameEmpty(true);
    } else {
      isErrorNameEmpty(false);
    }

    if (email === "") {
      iserrorEmailValid(true);
    } else if (!validEmail.test(email)) {
      iserrorEmailValid(true);
    } else {
      iserrorEmailValid(false);
    }

    if (start === "") {
      isErrorStartEmpty(true);
    } else {
      isErrorStartEmpty(false);
    }

    if (end === "") {
      isErrorEndEmpty(true);
    } else {
      isErrorEndEmpty(false);
    }

    if (
      errorNameEmpty ||
      errorEmailValid ||
      errorStartEmpty ||
      errorEndEmpty ||
      errorDate ||
      sendData
    ) {
      setSendData(false);
      console.log("Net");
    } else {
      setSendData(true);
      console.log("Da");
    }

    let newIntern = {
      name: name,
      email: email,
      internshipStart: start + "T00:00+00Z",
      internshipEnd: end + "T00:00+00Z",
    };

    if (sendData) {
      const requestOptions = {
        method: "PUT",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(newIntern),
      };
      fetch(`http://localhost:3001/interns/${id}`, requestOptions).then(
        (response) => response.json()
      );
      console.log("Good");
    } else {
    }
  };

onFormSubmit is a function that fires when the button is clicked.
I want that if there are no errors (that is, when all states that store error states = false) my fetch will work, and in the case when at least one state has an error = true then fetch will not be performed.
Now after the first click, when I deliberately make a mistake in my form, the function works fine (fetch does not work), but immediately changes sendData = true. and if you click again, then fetch will work. I don’t understand why sendData is set to true after the first call of the function.

Cannot read properties of undefined at XMLHttpRequest

I am trying to make requests to my API from XMLHttpRequest, but the data I request is not sent correctly. My API:

router.get("/dashboard/cd/:id", async (req, res) => {
    if (!req.params.id) return;
    let cooldowns = await pool.query(`SELECT * FROM cooldowns WHERE user_id = '${req.params.id}';`);
    let { cooldown } = cooldowns[0];
    
    console.log(req.params.id, cooldowns, cooldown)

    return res.send({ time: cooldown });
});

I know that the requested value exists thanks to the Console output:

54 
[
   RowDataPacket {
      user_id: '54',
      cooldown: 1651378259630
   }
]
1651378259630

The Script with which I send the request is as follows:

<script>
    var cd = document.getElementById("cd");
    var userId = "54";

    setInterval(() => {
        var request = new XMLHttpRequest()
        request.addEventListener("load", () => {
            var cool = this.response.time
            console.log(cool)
            if(parseInt(cool) > Date.now()) {
                var coold = moment.duration(Math.floor(parseInt(cool)-Date.now()), "").format("HH:mm:ss")
                cd.innerHTML = "Another dig in " + coold
            } else {
                cd.innerHTML = "Please refresh."
            }

        })
        request.open("GET", "/dashboard/cd/"+userId)
        request.send()
    }, 1001)
</script>

And the error I get is this:

Uncaught TypeError: Cannot read properties of undefined (reading 'time')
    at XMLHttpRequest.<anonymous> ((index):243:38)

Handling of overlapping events

Have an interactive list of inputs and want to add, remove or insert rows.
I use two different change and keydown events causing different behaviors which sometimes overlap when they are allowed and sometimes not.

For example the keydown-event when enter is pressed should always regulate where the next focus with .focus() goes, the change-event never. But if the input value has changed and the input is left with enter I want the same validation-function for the input running but only once.
But the entering trigger the onchange-listener, event.preventDefault() blocks any user input and there is no ordering of events?! All messed up.

How can I handle multiple events with one listener once? What should be the general code design?

My general structure:

class InteractiveList{
    createRow(...args){
        //some stuff, tThis and tInput references on list and current input
        tInput.addEventListener("change", function(event){
            tThis.updateAt(this);
            return false;
        });
        tInput.addEventListener("keydown", function(event){
            if(this.value.trim().length > 0 && event.key == "Enter"){
                tThis.moveTheEmptyRowNextTo(this);
                //tThis.updateAt(this);
                return false;
            }
        });
    }

    updateAt(nInput){
        if(nInput.value.length == 0){
            //if was already empty not, not nessecary to check if only caused by change
            //if entered with keydown focus on previous row
        }
        else{
            //if should validate input
                //if was empty add new empty row (give focus if entered kewdown)
                //else moveTheEmptyRowNextTo (give focus if entered by kewdown)
            //if should add multiple rows
                //add rows
                //if was empty add new empty row (give focus if entered kewdown)
                //else moveTheEmptyRowNextTo (give focus if entered by kewdown)
        }
    }
}