exporting a spasfic rows from Database to .XSLX file

i need a web page that i can use it to export data from my database, i have a table in my SQL database called “sales”, i want to export all rows when Store_ID= “user input” input is int number and Date=” user input *input is selected from drop-down menu.
i see many questions, but i am new to web development i can’t understand it. Also, i see the SimpleXLSXGen but it seems not to achieve my goal.
also, i am working in an online web hosting if this could make a difference.

My DataBase

Is there a way to access slot in Svelte component created using Client-side component API?

I am creating a svelte component in use:action function and I need to get add dynamic content inside the component. Does svelte allow to replace slot during or after creation of a svelte component?

Example code

export default function (node: HTMLElement) {
  let component = new Component({
      props: {},
      target: node,
      // maybe this
      slot: anotherComponent,
  });

  // or this
  component.slot = anotherComponent;

  return {
    update() {},
    destroy() {
      component.$destroy();
    },
  };
}

Water not rendering in React Three Fiber

I’m trying to implement this Water Shader in my project but the water doesn’t show up. I get no errors in the console only a warning:

React Hook useMemo has a missing dependency: 'gl.encoding'. Either include it or remove the dependency array

I’ve tried removing it but no luck. I’m not exactly sure what this might mean, at first I thought the water wasn’t appearing because of the texture I was loading in but this doesn’t seem to be the case.

My code is here:

function Ocean() {
  const ref = useRef()
  const gl = useThree((state) => state.gl)
  const waterNormals = useLoader(THREE.TextureLoader, 'https://raw.githubusercontent.com/mrdoob/three.js/master/examples/textures/waternormals.jpg')
  waterNormals.wrapS = waterNormals.wrapT = THREE.RepeatWrapping
  const geom = useMemo(() => new THREE.PlaneGeometry(10000, 10000), [])
  const config = useMemo(
    () => ({
      textureWidth: 512,
      textureHeight: 512,
      waterNormals,
      sunDirection: new THREE.Vector3(),
      sunColor: 0xFFF05D,
      waterColor: 0x7F7F7F,
      distortionScale: 3.7,
      fog: false,
      format: gl.encoding
    }),
    [waterNormals]
  )
  useFrame((state, delta) => (ref.current.material.uniforms.time.value += delta))
  return <water ref={ref} args={[geom, config]} rotation-x={-Math.PI / 2} position={[0, 0, 0]} />
}

And the code when calling it:

export default function App() {
  return (
    <Canvas camera={{ position: [0, 5, 100], fov: 55, near: 1, far: 20000 }}>
      <pointLight position={[100, 100, 100]} />
      <pointLight position={[-100, -100, -100]} />
      <Suspense fallback={null}>
        <Ocean />
        <Box />
      </Suspense>
      <Sky scale={1000} sunPosition={[500, 150, -1000]} turbidity={0.1} />
      <OrbitControls />
    </Canvas>
  )
}

Material-ui DatePicker does not work and the form does not render

I created a component DateTimePicker (could be DatePicker), I made all the installation recommended in youtube videos, and also in this site. After one and half day of attempts, I need your help. I could not make it to work. So, bellow follows my codes, if you can make in a separated component to be used in others forms I will appreciate.
Thanks in advance.

// Bancos component (means Banks)
// if I don't comment the lines commented bellow, the form does not render and breaks the app.

import React, { useState } from 'react';
import { Container } from '@mui/material';
import { Typography } from '@mui/material';
import { Box } from '@mui/material';
import { TextField } from '@mui/material';
import { makeStyles } from '@mui/styles';
import { Button } from '@mui/material';
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
import Grid from '@mui/material/Grid';
import Select from '../components/Select';
// import Stack from '@mui/material/Stack';
// import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
// import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
// import { DatePicker } from '@mui/x-date-pickers/DateTimePicker';
// import MuiDatePicker from '../components/DatePicker';

const initialValues = {
    id: 0,
    fullName: '',
    address: '',
    local: '',
    city: '',
    CEP: '',
    phone: '',
    contact: '',
    email: '',
    numBank: '',
    branch: '',
    account: '',
    balance: '',
    date: '',
    stateId: '',
}

const initialSelectValues = { id: '', title: ''} 

const useStyles = makeStyles((theme) => {
    return{
        root: {
           
            display: "flex",
            flexwrap: "wrap",
            
            
        },
        textField: {
            margimLeft: theme.spacing(1),
            margimRight: theme.spacing(1),
            width: "2ch",
        },
        
        field: {
            spacing: 1,
            display: "block",
        }
    }
});

export default function Bancos(){
    const classes = useStyles()
    const [fullName, setFullName] = useState('');
    const [address, setAddress] = useState('');
    const [fullNameError, setFullNameError] = useState(false);
    const [addressError, setAddressError] = useState(false);
    const [numBank, setNumBank] = useState('');
    const [branch, setBranch] = useState('');
    const [account, setAccount] = useState('');
    const [numBankError, setNumBankError] = useState(false);
    const [branchError, setBranchError] = useState(false);
    const [accountError, setAccountError] = useState(false);
    const [ values, setValues ] = useState(initialValues);
    const [ value, setValue ] = useState(initialSelectValues)
    

    const handleInputChange = e => {
        const { name, value } = e.target
        setValues({ 
            ...values,
             [name]: value
         })
    
    }

    // const [dateValue, setDateValue] = useState<Date | null>(null);

    // const handleChange = (newValue) => {
    //   setDateValue(newValue);
    // };

    const handleSelectChange = (e) => {
        const { name, value } = e.target
        setValue({id: e.target.value})
        console.log(name, value);
      }

const handleSubmit = (e) => {
    e.preventDefault()
    setFullNameError(false)
    setAddressError(false)

    if(fullName == ''){
        setFullNameError(true)
    }

    if( address == ''){
        setAddressError(true)
    }
    if ( numBank == ''){
        setNumBankError(true)
    }
    if (branch == ''){
        setBranchError(true)
    }
    if (account == ''){
        setAccountError(true)
    }
}


    return(
        <Container>
            <form noValidate autoComplete="off" onSubmit={handleSubmit}>
        <Typography  variant="h6" color="textSecondary" align="center" gutterBottom
         className="titleBank">
            Cadastro de Bancos
        </Typography>

            <Grid container spacing={2}>
                <Box mt={3} mb={1}> {/* colocar margim top e bottom com box   */}
                <Grid item xs={6} md={6}>
                <TextField label="Nome do Banco" variant="outlined" color="secondary"
                sx={{width: "430px", ml: 2}} required className={classes.field} name="fullName"
                value={values.fullName}  error={ fullNameError }
                onChange={ handleInputChange }/>
                
                </Grid></Box>

                {/* <Box> // commented
                <LocalizationProvider dateAdapter={AdapterDateFns}>
                <Stack spacing={3}>
      
                <DatePicker
                    label="Date&Time picker"
                    value={dateValue}
                    onChange={handleChange}
                    renderInput={(params) => <TextField {...params} />}
                />
                </Stack>
                </LocalizationProvider>

                </Box> // commented  */}
                 <Box mt={1}>
                 <Grid item xs={6} md={10} style={{ display: "flex" }}>
                 <TextField label="Endereço" variant="outlined" color="secondary"
                 sx={{width: "650px", mr: 1, ml: 2}} required className={classes.field} name="address"
                 value={values.address}
                onChange={handleInputChange} error={addressError}/>
                <TextField label="Bairro"  className={classes.textField} name="local"
                 sx={{width: "350px" }}  value={ values.local }
                 onChange={ handleInputChange }  />
                </Grid></Box>
                <Grid item xs={6} md={10} style={{ display: "flex", margimLeft: 0}}>

                <TextField label="Cidade"  className={classes.field} name="city"
                sx={{width: "320px", mr: 1 }}  value={values.city}
                onChange={ handleInputChange } />

                 <TextField label="CEP"  className={classes.field} name="CEP"
                 sx={{width: "180px", mr: 1}} value={ values.CEP } 
                 onChange={ handleInputChange }/> 
               
                <TextField label="Contato" className={classes.field} name="contact"
                sx={{width: "350px", mr: 1 }} value={ values.contact} 
                onChange={ handleInputChange } />
                </Grid>

                <Grid item xs={6} md={10} style={{ display: "flex", margimLeft: 0}}>
                <TextField label="Telefone"  className={classes.field} name="phone"
                 sx={{width: "235px", mr: 1 }} value={ values.phone }
                 onChange={ handleInputChange } />
                 <TextField label="Celular"  className={classes.field} name="phone"
                 sx={{width: "235px", mr: 1 }} value={ values.phone }
                 onChange={ handleInputChange } />
                <TextField label="E-mail"  className={classes.field} name="email"
                 sx={{width: "350px", mr: 1 }} value={values.email} 
                 onChange={ handleInputChange } />
              
                 </Grid><br/>
                
                 <Grid item xs={6} md={10} style={{ display: "flex", margimLeft: 0}}>
                 
                 <Select   
                    name="state"
                    label="Estado"
                    value={value.id}
                    onChange={handleSelectChange}
                    options={Select.choices}
                    fullWidth
                 /> 
      
                 <TextField label="Nº do Banco" className={classes.field} required
                 sx={{width: "125px", mr: 1, ml: 1 }} name="numBank" value={values.numBank}
                 onChange={ handleInputChange } error={ numBankError } />   
                 <TextField label="Nº Agência" className={classes.field} name="branch"
                 sx={{width: "155px", mr: 1 }} value={ values.branch } required
                 onChange={ handleInputChange } error={ branchError } />
                <TextField label="Nº Conta Corrente" className={classes.field} name="account"
                 sx={{width: "200px", mr: 1 }}  value={ values.account } required 
                 onChange={ handleInputChange } error={ accountError } />
                 <TextField label="Saldo R$"  className={classes.field} name="balance"
                 sx={{width: "200px", mr: 1 }} value={ values.balance } 
                 disabled />
                 </Grid><br/>
                 <Grid item xs={6} md={8} style={{ display: "flex" }}> 
                <Box mt={4}> {/* colocar margim top e bottom com box   */}
                <Button type="submit" variant="contained" color="primary"
                 endIcon={<KeyboardArrowRightIcon />} 
                >
                 Salvar
                </Button>
                </Box>
                </Grid>
            </Grid>            
        
            </form>
        </Container>
        
    
    )
}
// DatePicker component
import React, {useState} from 'react';
import Stack from '@mui/material/Stack';
import TextField from '@mui/material/TextField';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';


export default function MuiDatePicker() {
  const [dateValue, setDateValue] = useState<Date | null>(null);

  const handleChange = (newValue) => {
    setDateValue(newValue);
  };

  return (
    <LocalizationProvider dateAdapter={AdapterDateFns}>
      <Stack spacing={3}>
      
        <DateTimePicker
          label="Date&Time picker"
          value={dateValue}
          onChange={handleChange}
          renderInput={(params) => <TextField {...params} />}
        />
      </Stack>
    </LocalizationProvider>
  );
}

How can i use my worker like an endpoint with aws-sdk?

I’m build a script with node js and I’am using Bacblaze b2 + cloudflare.

I followed this tutorial:
https://www.backblaze.com/blog/use-a-cloudflare-worker-to-send-notifications-on-backblaze-b2-events/

And when i use backblaze postman api it works perfectly but when i configure my aws credential it doesn’t work.

My aws credential configuration:

AWS.config = new AWS.Config({
    accessKeyId: "...",
    secretAccessKey: "...",
    region: "us-west-000",
    endpoint: "cloudflare-b2-proxy.<api name omitted>.workers.dev"
});

But if i use my s3 endpoit it works but if i use this endpoint i’ll pay the bacblaze output ($0.01) but if i use my worker i don’t have to pay anything but with aws-sdk doesn’t work.

Error:

Error [XMLParserError]: Non-whitespace before first tag.

Line: 0

Column: 1

Char: e

React Calculator can’t find an algorithm to make calculations with different consecutive symbols

I have figured out an ‘algorithm’ to make consecutive calculations with the same symbol i.e. 2 + 3 + 5 = … or 1 * 2 * 4 = … However I’m stuck and can’t change it to work with different symbols, for example: 2 + 2 – 1 or 2 * 3 / 2 etc.

I tried to write it myself for the most part with occasional help from online sources. Is it reinventing the wheel or am I on the ‘more or less’ right path?

this part wroks with the same symbols:

localInput += value;

if(value === '+' || value === '-' || value === '*'|| value === '/' || value === '='){
  
  let x = localInput.slice(0, localInput.length - 1)
  parseFloat(x);
  
  if(!isNaN(x)){
    arr.push(parseFloat(x));
  }
  localInput = '';
  
}
if(arr.length === 2) {
  
  local_left = Calculate(arr[0], token, arr[1]);
       
  arr = [];
  
  arr[0] = local_left;
  
  
}
if(value === '='){
  result = local_left;
  
  setExpression(prevX => prevX + result);
  str = result;
}

Entire program below:

import './App.css';
import React, {useState} from 'react';


let token = '';
let first = 0;
let last = 0;
let result = 0;
let localInput = '';
let arr = [];
let str = '0';
let local_left = 0;

export default function App() {
  const [expression, setExpression] = useState('0');
  
  function Last_symbol(word) {
      return word.charAt(word.length - 1);
  }
  function Calculate(f, t, l) {
      let res = 0;
      if(t === '+'){
        res = parseFloat(f) + parseFloat(l);
      }
      else if(t === '-'){
        res = parseFloat(f) - parseFloat(l);
      }
      else if(t === '*'){
        res = parseFloat(f) * parseFloat(l);
      }
      else if(t === '/'){
        res = parseFloat(l) === 0 ? "Cannot divide by zero" : parseFloat(f) / parseFloat(l);
      }
      return res;
    }

  function Clear() {
    token = '';
    first = 0;
    last = 0;
    result = 0;
    localInput = 0;
    arr = [];
    local_left = 0;
    
    setExpression(prevX => prevX = '0');
    
    str = '0';
  }
  function GetInput(e){
    
    const {name, value} = e.target;
    if(str === '0'){
      str = value;
      
    }
    
    else if(value === '+' || value === '-' || value === '*' || value === '/'){
      str = value;
    }
    else{
      let x = ''
      str.includes('+') || str.includes('-') || str.includes('*') || str.includes('/') ? str = x += value: str += value;
    }
    
    
    
    setExpression(prevX => prevX === '0' ? prevX = value : prevX + value);
    
    
    
       
    
        

    if(value === '+'){
      token = '+';
      
    }else if(value === '-'){
      token = '-';
      
    }else if(value === '/'){
      token = '/';
      
    }else if(value === '*'){
      token = '*';
      
    }else if(value === '.'){
      
    }
    
    
    localInput += value;
    
    if(value === '+' || value === '-' || value === '*'|| value === '/' || value === '='){
      
      let x = localInput.slice(0, localInput.length - 1)
      parseFloat(x);
      
      if(!isNaN(x)){
        arr.push(parseFloat(x));
      }
      localInput = '';
      
    }
    if(arr.length === 2) {
      
      local_left = Calculate(arr[0], token, arr[1]);
           
      arr = [];
      
      arr[0] = local_left;
      
      
    }
    if(value === '='){
      result = local_left;
      
      setExpression(prevX => prevX + result);
      str = result;
    }

    
    
  }
  return (
      <div className='calc'>
        <div className='screen'>
          <p>{expression}</p>
          <h1>{str}</h1>
        </div>
        
        <div className='btn-section'>
          <button className='ac' onClick={Clear}>AC</button>
          <button className='sgn' value='/' onClick={GetInput}>/</button>
          <button className='sgn' value='*' onClick={GetInput}>*</button>
          <button value='7' onClick={GetInput}>7</button>
          <button value="8" onClick={GetInput}>8</button>
          <button value="9" onClick={GetInput}>9</button>
          <button className='sgn' value='-' onClick={GetInput}>-</button>
          <button value="4" onClick={GetInput}>4</button>
          <button value="5" onClick={GetInput}>5</button>
          <button value="6" onClick={GetInput}>6</button>
          <button className='sgn' value='+' onClick={GetInput}>+</button>
          <button value="1" onClick={GetInput}>1</button>
          <button value="2" onClick={GetInput}>2</button>
          <button value="3" onClick={GetInput}>3</button>
          <button className='equal-sgn' value='=' onClick={GetInput}>=</button>
          <button value="0" className='zero' onClick={GetInput}>0</button>
          <button className='sgn' value='.' onClick={GetInput}>.</button>
        </div>
        
  
      </div>
    );
}

change to a php variable in blade laravel doesn’t persist

When I increment currentIndex whenever I click the next button, the value of currentIndex returns to its default value which is 1 here. So the update of currentIndex doesn’t persist. Does anyone have any idea why? And how can I solve this problem?

    let inputBoxNum = 3
    let currentIndex
    {{ $currentIndex = 1 }}
    updateButtons()
    $('.back-btn, .next-btn').on('click', function (e) {
        console.log({{$currentIndex}}) // returns 1 even if this function was called before
        let btnClicked = e.target.className.includes('next-btn') ? 'next' : 'back'
        if (btnClicked === 'next') {
            {{$currentIndex += 1}} // it increments to 2
            console.log({{$currentIndex}}) // returns 2
            $('#create-input-box').html(`@include('reservations.create-input-box-'.$currentIndex)`)
        } else {
            $('#create-input-box').html(`@include('reservations.create-input-box-'.$currentIndex)`)
        }
        updateButtons()
    })
    function updateButtons() {
        getCurrentIndex()
        if (currentIndex <= 1) {
            $('.back-btn').hide()
            $('.next-btn').show()
        } else if (currentIndex > 1 && currentIndex < inputBoxNum) {
            $('.back-btn').show()
            $('.next-btn').show()
        } else {
            $('.back-btn').show()
            $('.next-btn').hide()
        }
    }

    function getCurrentIndex() {
        currentIndex = parseInt($('#create-input-box')[0].children[0].className.split("-")[3])
    }

Append array to atribute of another array (javascript)

I’m learning Javascript and I’m stuck in a doubt with the joining of two arrays of objects through an ID, I can join the two, but the result is not what I expect.

So, I have these two object arrays:

"product": [
        {
            "id": "1000",
            "code": "f230fh0g3",
            "name": "Bamboo Watch",
            "description": "Product Description",
            "image": "bamboo-watch.jpg",
            "price": 65,
            "category": "Accessories",
            "quantity": 24,
         }
]

"orders": [            
       {                
            "id": "1000",             
            "productID": "f230fh0g3",           
            "date": "2020-09-13",
            "amount": 65,
            "quantity": 1,
       },
       {                
            "id": "1000",             
            "productID": "f230fh0g3",           
            "date": "2020-09-13",
            "amount": 65,
            "quantity": 1,
       },
]

and I want to join both by key (id) to get one array like this one:

"product": [
        {
            "id": "1000",
            "code": "f230fh0g3",
            "name": "Bamboo Watch",
            "description": "Product Description",
            "image": "bamboo-watch.jpg",
            "price": 65,
            "category": "Accessories",
            "quantity": 24,
            "orders": [
                {
                    "id": "1000",
                    "productCode": "f230fh0g3",
                    "date": "2020-09-13",
                    "amount": 65,
                    "quantity": 1,
                    "customer": "David James",
                    "status": "PENDING"
                },
                {
                    "id": "1001",
                    "productCode": "f230fh0g3",
                    "date": "2020-05-14",
                    "amount": 130,
                    "quantity": 2,
                    "customer": "Leon Rodrigues",
                    "status": "DELIVERED"
                },
              ]
    },
    {
         "id": "1001",
         "..."
         "orders": [
               {
                     "id": "1001",
                     "..."
               }
           ]
    }]

Is it possible to map these arrays in this way?
Thanks in advance

Appending / Modifying Text of Textarea via Javascript

I’m trying to make a browser extension that would be able to scrape specific HTML info from a website and properly output it into a textarea next to the button you would press to start it.

I’m very close to being done with it, but can’t seem to figure out how to append the data to the browser extension textarea instead of at the bottom of whatever page is currently open. (originally I was going to have the output be downloadable as a .txt file but found out quickly that you can’t do that with JS).

let downloadDeck = document.getElementById("downloadDeck");

console.log("Popup Script Ready to Run!");
// When the button is clicked, inject downloadDeck into current page
downloadDeck.addEventListener("click", async () => {
  let [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
    chrome.scripting.executeScript({
      target: { tabId: tab.id },
      function: scrapePageforDeck,
    });
  });
  
  function scrapePageforDeck() {
    console.log('Deck Scraper Started! ');
    page = document.getElementById("maincontentfull");
    //console.log(page);
    // id = maincontentfull -> a class_ = "subdeck-group__card" -> span class: subdeck-group__card-name
    subdeckCard = document.querySelectorAll('.subdeck-group__card');
    //console.log(subdeckCard);
    let actualCard = "";
    let cardList = "";
    for(i=0; i < subdeckCard.length; i++) {
        subdeckCardQuantity = subdeckCard[i].querySelector('.subdeck-group__card-qty').innerHTML;
        subdeckCardName = subdeckCard[i].querySelector('.subdeck-group__card-name').innerHTML; 
        actualCard += subdeckCardQuantity + " " + subdeckCardName;
        //console.log("Card #:" + i + " " + actualCard);  
        cardList += actualCard + "n";
        actualCard = "";
    }
    console.log(cardList);

    let cardTextArea = document.createElement('textarea');
    cardTextArea.id = "deckList";
    let text = document.createTextNode(cardList);
    cardTextArea.appendChild(text); 
    document.body.appendChild(cardTextArea);
  }

The Browser Extension HTML is very simple, but I figured knowing the layout may be helpful to know as well

<html>
    <head>
        <link rel="stylesheet" href="popup.css"/>
    </head>
    <body>
        <button id="downloadDeck">Download Deck!</button>
        <textarea id="deckBox">
        </textarea>
    </body>
    <script src="popup.js"></script>
</html>

Cannot Append A HTML Element Inside A Function

I was trying to create something like a terminal, and i decided to make a init function for creating the “terminal”, but it gave me a error:

Uncaught TypeError: terminal.appendChild is not a function
at initTerminal

here’s my code:

function initTerminal(terminal, initText, prefix) {

    let textInput = document.createElement("textarea")
    let console = document.createElement("p")

    textInput.addEventListener("keypress", (e) => {

        if (e.key === "Enter") {
            e.preventDefault()
    
            let savedText = textInput.value
    
            document.querySelector(".out").innerHTML += "<br>" + `<span>${prefix} </span>` +savedText
    
            textInput.value = ""
        }
    })

    console.className = "out"

    terminal.appendChild(console)
    terminal.appendChild(textInput)
    console.innerHTML = initText
}

initTerminal("terminal", "Isaacpar Terminal 1.0 | Type 'help' to get a list of avaliable commands", "$")

Best way to make MYSQL queries after the page is loaded?

I have an app where after the user inserts a word in an input field, the app needs to do a MYSLQ query and display information from a database related to that query on a modal, on the same page, and without reloading the page behind the modal.
Before this I have only used PHP to manage MYSQL queries without any problem, but since PHP only works before the page loads, it isn’t helpful here. I would like to know what most developers do in this situation. Thanks in advance.

Separating array into 3 parts with near the same sum in Javascript

I’m trying to separate the given array into 3 arrays that have almost the same sum. I managed to separate the array, but I’m unsure how to take the sum into considiration.

Example: Input array:[8, 1, 5, 2, 4, 1, 9, 8]
Output:

 [9, 2, 1, 1] // 13
 [8, 4] // 12,
 [8, 5] // 13

Code I have now:

 const items = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 
    
    const n = 3
    const result = [[], [], []]
    
    const x= Math.ceil(items.length / 3)
    
    for (let line = 0; line < n; line++) {
      for (let i = 0; i < x; i++) {
        const value = items[i + line * x]
        if (!value) continue 
        result[line].push(value)
      }
    }
    
    console.log(result);

How would I be able to show the informaiton associated with the api I integrated with the picture if clicked?

I am extremely new to JS and API, nevertheless, I believe I get the overall process of API integration. I am struggling to figure out exactly what I did wrong here when trying to get the information to show up when you click the picture.

When I click the picture, the information shows up in my console, but it doesn’t show up with my picture. Am I missing a step? Or Should I post somewhere? Please attach any good resources I could refer to because I haven’t been successful in my own google search trying to understand what I am missing here. Maybe I am not searching the correct question.
This is my main.js

// Declarations for the Artwork
let art;
let showArtInfo;

//  The Art Institute of Chicago request - No user login needed because it's 
free... I think...


// Function to get Art Info when image figure is clicked
/**
 * @param art_index
 * @param info_index
 * 
 * The function gets art information from The Art Institute of Chicago using 
 the art_index of our gallery.
 * Then finds the correct info_index inside of the JSON response data from 
 The Art Institute
 * of Chicago which will produce a description that will be shown when you 
 click the art.
 */

async function clickedEvent(art_index, info_index) {
    //  Get Art Id
    let id = document.getElementsByTagName('img')[art_index].attributes[2].value;

   let headers = new Headers([
    ['Content-Type', 'application/json'],
    ['Accept', 'application/json']
]);

let request = new Request(`https://api.artic.edu/api/v1/artworks/${id}? 
    fields=id,title,artist_display,date_display,main_reference_number`, {
    method: 'GET',
    headers: headers
});
let result = await fetch(request);
let response = await result.json();
console.log(response)

if (showArtInfo){
    stopShow();
}
}


 /**
  * @param id
  * @param event
  * 
  * id = image id for gallery image
  * event = Mouse event given by the action from our user
  * 
  * Function produces art information from the clickedEvent based 
  * on index of image.
  */

 function getArt(id, event){
        switch(id){
    case 'blackmirror' : {
        event.stopPropagation();
        clickedEvent(0,0)
        break;
    }
    case 'manymansions' : {
        event.stopPropagation();
        clickedEvent(1,0)
        break;
    }
    case 'nightlife' : {
        event.stopPropagation();
        clickedEvent(2,0)
        break;
    }
    case 'room' : {
        event.stopPropagation();
        clickedEvent(3,0)
        break;
    }
    case 'opo' : {
        event.stopPropagation();
        clickedEvent(4,0)
        break;
    } 
    case 'weaving' : {
        event.stopPropagation();
        clickedEvent(5,0)
        break;
    }
  }
 }

This is my index.html

<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="Description" content="Enter your description here"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<link rel="stylesheet" href="main.css">
<script src="main.js"></script>
<title>Art</title>
</head>
<body>
    <!-- Navbar Section -->
    <nav class="navbar navbar-expand-lg bg-dark navbar-dark py-3 fixed-top shadow-lg">
        <div class="container">
            <a href="#" class="navbar-brand">For the love of Art</a>
            <button 
                class="navbar-toggler" 
                type="button" 
                data-bs-toggle="collapse" 
                data-bs-target="#navmenu"
            ><span class="navbar-toggler-icon"></span></button>
            <div class="collapse navbar-collapse" id="navmenu">
                <ul class="navbar-nav ms-auto">
                    <li class="nav-item">
                        <a href="#126414" class="nav-link">Espejo Negro</a>
                    </li>
                    <li class="nav-item">
                        <a href="#137125" class="nav-link">Many Mansions</a>
                    </li>
                    <li class="nav-item">
                        <a href="#117266" class="nav-link">Nightlife</a>
                    </li>
                    <li class="nav-item">
                        <a href="#191556" class="nav-link">The Room No. VI</a>
                    </li>
                    <li class="nav-item">
                        <a href="#102611" class="nav-link">Veranda Post</a>
                    </li>
                    <li class="nav-item">
                        <a href="#151363" class="nav-link">Weaving</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>
    <br>
    <!--Start of Container For Artwork-->
    <div class="container">
        <div class="gallery">
            <br>
            <figure class="gallery__item gallery__item--1" id="blackmirror" onclick="event.stopPropagation(); getArt(this.id, event)">
                <img class="gallery__img shadow-lg" src="images/black-mirror.jpeg" alt="126414">
            </figure>
                <br>
            <figure class="gallery__item gallery__item--2" id="manymansions" onclick="event.stopPropagation(); getArt(this.id, event)" >
                <img class="gallery__img shadow-lg" src="/images/many-mansions.jpeg" alt="137125">
            </figure>
                <br>
            <figure class="gallery__item gallery__item--3" id="nightlife" onclick="event.stopPropagation(); getArt(this.id, event)">
                <img class="gallery__img shadow-lg" src="images/nightlife.jpeg" alt="117266">
            </figure>
                <br>
            <figure class="gallery__item gallery__item--4" id="room" onclick="event.stopPropagation(); getArt(this.id, event)">
                <img class="gallery__img shadow-lg" src="images/the-room-no-vi.jpeg" alt="191556">
            </figure>
                <br>
            <figure class="gallery__item gallery__item--5" id="opo" onclick="event.stopPropagation(); getArt(this.id, event)">
                <img class="gallery__img shadow-lg" src="images/veranda-post-opo-ogoga.jpeg" alt="102611">
            </figure>
                <br>
            <figure class="gallery__item gallery__item--6" id="weaving" onclick="event.stopPropagation(); getArt(this.id, event)">
                <img class="gallery__img shadow-lg" src="images/weaving.jpeg" alt="151363">
            </figure>
        </div>
    </div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.9.2/umd/popper.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.0/js/bootstrap.min.js"></script>
</body>
</html>```