how to replace items when using intersection observer

Pretty new to code so forgive me if I stumble around some wording here, but I’m trying to use IntersectObserver to show a specific image when its corresponding text is shown in a scroll menu. Right now the appropriate images appear when the text is shown in the scroll menu, however, they appear in a flexbox column type manner and I would like them to replace each other once the text is no longer intersecting with the scroll menu. Are there any ideas how I might be able to do this?

const observer = new IntersectionObserver(entries => {
  entries.forEach(elem => {
    if (elem.isIntersecting) {
      const append = $(elem.target).append()
      const text = $(elem.target).text()

      
      switch (append, text) {
        case 'ALEX':
          $('.image-content').append("<img class='img' src='images/ALEX.gif'/>")
          break
        case 'CHANEL':
          $('.image-content').append("<img class='img' src='images/CHANEL.gif'/>")
          break
        case 'LAURA':
          $('.image-content').append("<img class='img' src='images/LAURA.gif'/>")
          break
        case 'NATHAN':
          $('.image-content').append("<img class='img' src='images/NATHAN.gif'/>")
          break
        case 'RON':
          $('.image-content').append("<img class='img' src='images/RON.gif'/>")
          break
        case 'STACEY':
          $('.image-content').append("<img class='img' src='images/STACEY.gif'/>")
          break
        case 'VINCE':
          $('.image-content').append("<img class='img' src='images/VINCE.gif'/>")
          break
        default:
          $('.image-content').text(`Sorry, no more companions available ${text}.`)
      }
    }
  })
})

// Select all the options in the left
$('.companion-names').each(function () {
  // For each item we want to observe whether it is visible using the function above
  observer.observe(this)
})

Google Scatterchart doesn’t show any data

I was trying to create a ScatterChart in a div on a django project using JS but instead there is only a red square in the div. When I try to select the space where it should be, I can copy the data but it doesn’t show itself visually, even when I try to change its font color or width and height of div.

google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(() => { 
  google_carregado = true;
  atualizar_grafico();
  });

function atualizar_grafico() {
  if(!google_carregado) return;

  const dados = registros.map( e => [ e.ganho_anual, e.angle_anual ]);

  var data = google.visualization.arrayToDataTable([
    ['Angle', 'Custo'],
    ...dados
  ]);

  var options = {
    title: 'Angle vs. Custo',
    hAxis: {title: 'Angle', minValue: 0, maxValue: 50},
    vAxis: {title: 'Custo', minValue: 0, maxValue: 50},
    legend: 'none'
  };

  var chart = new google.visualization.ScatterChart(document.getElementById('chart_div'));
  chart.draw(data, options);
}

how to set display on countdown timer (javascript)

I used the snippet below to create a countdown timer.

<script>
  // Set the date we're counting down to
  var countDownDate = new Date("Jan 5, 2024 15:37:25").getTime();

  // Update the count down every 1 second
  var x = setInterval(function() {

    // Get today's date and time
    var now = new Date().getTime();

    // Find the distance between now and the count down date
    var distance = countDownDate - now;

    // Time calculations for days, hours, minutes and seconds
    var days = Math.floor(distance / (1000 * 60 * 60 * 24));
    var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
    var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
    var seconds = Math.floor((distance % (1000 * 60)) / 1000);

    // Output the result in an element with id="demo"
    document.getElementById("demo").innerHTML = days + "d " + hours + "h " +
      minutes + "m " + seconds + "s ";

    // If the count down is over, write some text 
    if (distance < 0) {
      clearInterval(x);
      document.getElementById("demo").innerHTML = "EXPIRED";
    }


  }, 1000);
</script>

How do I set the output (display) like so:

  1. If the remaining time is still above 1 month, then display only the month.

  2. If the remaining time is under 1 month, then display only days,

  3. If the remaining time is below 24 hours, display the hours and minutes

  4. If the remaining time is below 1 hour, display the minutes and seconds.

Thanks

How to create an N_sized Array with the size of N(x) and fill it with the numbers in a range from 0 to 100 randomly?

Hello StackOverflowCommunity! My name is Piet.

While investigating the beloved Javascript I got a bit stuck:

I´m not sure why I get 98 empty items pushed into my Array.

On Index[0] and Index[99] I get IntegerValues as expected.

Thank you for your answers! 🙂

// create an Array with the size of N(x) and 
// fill it with numbers in a range from 0 to 100 randomly.

createNSizedArray = (x) => {

    for(let i = 0; i < x; i++) {
        var arr = [];
        arr[i] = arr.push(Math.round(Math.random()*100));
        
    }
    return arr;
}

console.log(createNSizedArray(100)); 

// output -> [ 31, <98 empty items>, 1 ];

// Why are the other 98 items in the Array empty and how to change them into integer values?

Actually I inspected the Items[1-98] to find out their values and to check if they are really empty.

But:

console.log(arr[4]) for example return “undefined” to me. So they are not really empty.

Access denied for user ‘”root”;’@’localhost’ (using password: YES)

GitHub Repo
Everything is currently located on the develop branch.

PS C:Userstylerdesktopbootcampe-commerce> npm run seed

> [email protected] seed
> node seeds/index.js

node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^

AccessDeniedError [SequelizeAccessDeniedError]: Access denied for user '"root";'@'localhost' (using password: YES)
    at C:Userstylerdesktopbootcampe-commercenode_modulessequelizelibdialectsmysqlconnection-manager.js:125:19
    at tryCatcher (C:Userstylerdesktopbootcampe-commercenode_modulesbluebirdjsreleaseutil.js:16:23)
    at Promise._settlePromiseFromHandler (C:Userstylerdesktopbootcampe-commercenode_modulesbluebirdjsreleasepromise.js:547:31)
    at Promise._settlePromise (C:Userstylerdesktopbootcampe-commercenode_modulesbluebirdjsreleasepromise.js:604:18)
    at Promise._settlePromise0 (C:Userstylerdesktopbootcampe-commercenode_modulesbluebirdjsreleasepromise.js:649:10)
    at Promise._settlePromises (C:Userstylerdesktopbootcampe-commercenode_modulesbluebirdjsreleasepromise.js:725:18)
    at _drainQueueStep (C:Userstylerdesktopbootcampe-commercenode_modulesbluebirdjsreleaseasync.js:93:12)
    at _drainQueue (C:Userstylerdesktopbootcampe-commercenode_modulesbluebirdjsreleaseasync.js:86:9)
    at Async._drainQueues (C:Userstylerdesktopbootcampe-commercenode_modulesbluebirdjsreleaseasync.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (C:Userstylerdesktopbootcampe-commercenode_modulesbluebirdjsreleaseasync.js:15:14)
    at processImmediate (node:internal/timers:466:21) {
  parent: Error: Access denied for user '"root";'@'localhost' (using password: YES)
      at Packet.asError (C:Userstylerdesktopbootcampe-commercenode_modulesmysql2libpacketspacket.js:728:17)
      at ClientHandshake.execute (C:Userstylerdesktopbootcampe-commercenode_modulesmysql2libcommandscommand.js:29:26)
      at Connection.handlePacket (C:Userstylerdesktopbootcampe-commercenode_modulesmysql2libconnection.js:456:32)
      at PacketParser.onPacket (C:Userstylerdesktopbootcampe-commercenode_modulesmysql2libconnection.js:85:12)
      at PacketParser.executeStart (C:Userstylerdesktopbootcampe-commercenode_modulesmysql2libpacket_parser.js:75:16)
      at Socket.<anonymous> (C:Userstylerdesktopbootcampe-commercenode_modulesmysql2libconnection.js:92:25)
      at Socket.emit (node:events:526:28)
      at addChunk (node:internal/streams/readable:315:12)
      at readableAddChunk (node:internal/streams/readable:289:9)
      at Socket.Readable.push (node:internal/streams/readable:228:10)
      at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
    code: 'ER_ACCESS_DENIED_ERROR',
    errno: 1045,
    sqlState: '28000',
    sqlMessage: `Access denied for user '"root";'@'localhost' (using password: YES)`,
    sql: undefined
  },
  original: Error: Access denied for user '"root";'@'localhost' (using password: YES)
      at Packet.asError (C:Userstylerdesktopbootcampe-commercenode_modulesmysql2libpacketspacket.js:728:17)
      at ClientHandshake.execute (C:Userstylerdesktopbootcampe-commercenode_modulesmysql2libcommandscommand.js:29:26)
      at Connection.handlePacket (C:Userstylerdesktopbootcampe-commercenode_modulesmysql2libconnection.js:456:32)
      at PacketParser.onPacket (C:Userstylerdesktopbootcampe-commercenode_modulesmysql2libconnection.js:85:12)
      at PacketParser.executeStart (C:Userstylerdesktopbootcampe-commercenode_modulesmysql2libpacket_parser.js:75:16)
      at Socket.<anonymous> (C:Userstylerdesktopbootcampe-commercenode_modulesmysql2libconnection.js:92:25)
      at Socket.emit (node:events:526:28)
      at addChunk (node:internal/streams/readable:315:12)
      at readableAddChunk (node:internal/streams/readable:289:9)
      at Socket.Readable.push (node:internal/streams/readable:228:10)
      at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
    code: 'ER_ACCESS_DENIED_ERROR',
    errno: 1045,
    sqlState: '28000',
    sqlMessage: `Access denied for user '"root";'@'localhost' (using password: YES)`,
    sql: undefined
  }
}

Hello, I am fairly new to coding and Node, I have been having this issue all day and have not been able to solve it, I am receiving the error “Access denied for user ‘”root”;’@’localhost’ (using password: YES)” when I try to npm run seed or npm run start my server. I am able to login to mysql cli just fine on root and using my password.

I feel like I have done nearly every solution I have found online, I have tried changing privileges for the root user, changed password, made new user. I have updated Node, all my NPM packages, and MYSQL. I have made a bunch of changes to my .env file, thinking something could be wrong there, but still no success.

How can I pretty print keys and values of a JavaScript object on web page

I have a JavaScript object that contains terms and definitions. I want to create a function that displays/prints the key, value pairs on a webpage.

For example:

let dict = {
    term1: "definition",
    term2: "definition",
    term3: "definition",
    term4: "definition"
}

Ideal output:

term1: definition**
term2:** definition**
term3:** definition**
term4:** definition

I am currently using this code:

function viewAll()
{
var json = JSON.stringify(dict,null,3);
document.getElementById("output").innerText = json;
}

which outputs:

{
term1: "definition",
term2: "definition",
term3: "definition",
term4: "definition"
}

This is okay, but I’d like to remove the special characters ({",)

My json data wont show in javascript but its correctly programmed to do so

Im making a cryptocurrency using python,html,and javascript. I have everything working but a balance checker. Im using the same method for the balance checker that i used for every other service in my app. I dont know why this happens but it gets the data that works but then it just displays nothing. Code for getting data(javascript):

function getbal(){
        var address=document.getElementById("address").value;
        let xhr = new XMLHttpRequest();
        xhr.open('GET', '/wallet/getbalance?address='+address);
        xhr.send();
        raw=xhr.responseText;
        data=raw;
        alert(data)
        return data;
      };

GET url response is 200 and it shows 1.0
enter image description here
I dont know why this is happening!

I am trying to get the wallet balance and im expecting a str value.

When clicking on my label, would like the url background to show instead of a bg color

var links = [{label: 'Montreal', document.body.style.backgroundImage = "url('https://unsplash.com/photos/qzgN45hseN0')|none|initial|inherit"}, 
             {label: 'Toronto', bg: '#16a085'}, 
             {label: 'Ottawa', bg: '#8e44ad'}, 
             {label: 'Gatineau', bg: '#27ae60'}, 
             {label: 'Vancouver', bg: '#f39c12'}, 
             {label: 'Winnipeg', bg: '#2980b9'},
             {label: 'Saint-John', bg: '#f39c12'},
             {label: 'Quebec', bg: '#f39c12'},
             {label: 'Edmonton', bg: '#c0392b'}, 
             {label: 'Halifax', bg: '#16a085'}, 
             {label: 'Victoria', bg: '#8e44ad'}, 
             {label: 'Hamilton', bg: '#27ae60'}, 
             {label: 'Saskatoon', bg: '#f39c12'}, 
             {label: 'Regina', bg: '#2980b9'},
             {label: 'Mississauga', bg: '#f39c12'},
             {label: 'Thunderbay', bg: '#f39c12'},];
var windowHeight = window.innerHeight;
if(windowHeight === 0) windowHeight = 238;
var radius = windowHeight*0.2,
    circle = document.createElement('div'),
    borderSize = radius*0.011;
    totalArea = 98, 
    increment = totalArea/(links.length-10),
    startPoint = 0-(totalArea/2),
    fontSize = radius*0.30,
    linkSize = radius*0.25;

styleCircle();
addCircle();
addLinks();
styleLinks();

function styleCircle() {
  circle.style.width = radius*2+'px';
  circle.style.height = radius*2+'px';
  circle.style.borderRadius = radius+'px';
  circle.style.position = 'absolute';
  circle.style.top = '-'+radius*0.2+'px';
  circle.style.left = radius*-1+'px';
}

function addCircle() {
  document.body.appendChild(circle);
}

function addLinks() {
  for (var i=0, l=links.length; i<l; i++) {
    link = document.createElement('a'),
    hover = document.createElement('span');
    link.href = "#";
    link.dataset.color = links[i].bg;
    link.style.display = 'inline-block';
    link.style.textDecoration = 'none';
    link.style.color = '#fff';
    link.style.position = 'absolute';
    link.style.zIndex = 100;
    link.innerHTML = links[i].label;
    hover.style.position = 'absolute';
    hover.style.display = 'inline-block';
    hover.style.zIndex = 50;
    hover.style.opacity = 0;
    document.body.appendChild(link);
    document.body.appendChild(hover);
    link.addEventListener('mouseover', linkOver);
    link.addEventListener('mouseout', linkOut);
    links[i].elem = link;
    links[i].hover = hover;
  }
}

function styleLinks() {
  for (var i=0, l=links.length; i<l; i++) {
    var link = links[i].elem, hover = links[i].hover, deg = startPoint+(i*increment);  
    link.style.paddingLeft = radius*1.2+'px';
    link.style.fontSize = fontSize+'px';
    link.style.height = linkSize+'px';
    link.style.lineHeight = linkSize+'px';
    setTransformOrigin(link, '0px '+linkSize*0.5+'px');
    setTransition(link, 'all 0.2s ease-out');
    setTransform(link, 'rotate('+deg+'deg)');
    link.style.left = borderSize+'px';
    link.style.top = (windowHeight/2) - (windowHeight*0.1)+borderSize+'px';

    hover.style.left = borderSize+'px';
    setTransformOrigin(hover, '0px '+linkSize*0.5+'px');
    setTransition(hover, 'all 0.2s ease-out');
    setTransform(hover, 'rotate('+deg+'deg)');
    hover.style.top = (windowHeight*0.4)+borderSize +'px';
    hover.style.width = radius+(borderSize/2)+'px';
    hover.style.height = linkSize+'px';
    hover.style.borderRight = borderSize*2+'px solid #fff';
  
  }
}

window.onresize = function() {
  windowHeight = window.innerHeight;
  radius = windowHeight*0.6,
  borderSize = radius*0.021;  
  fontSize = radius*0.12,
  linkSize = radius*0.25;
  styleCircle();
  styleLinks();
}

function linkOver(e) {
  var thisLink = e.target, thisHover = thisLink.nextSibling;
  thisLink.style.paddingLeft = radius*1.25+'px';
  thisHover.style.opacity = 1;
  document.body.style.backgroundColor = thisLink.dataset.color;
}

function linkOut(e) {
  var thisLink = e.target, thisHover = thisLink.nextSibling;
  thisLink.style.paddingLeft = radius*1.2+'px';
  thisHover.style.opacity = 0;
}

function setTransform(element, string) {
  element.style.webkitTransform = string;
  element.style.MozTransform = string;
  element.style.msTransform = string;
  element.style.OTransform = string;
  element.style.transform = string;
}

function setTransformOrigin(element, string) {
  element.style.webkitTransformOrigin = string;
  element.style.MozTransformOrigin = string;
  element.style.msTransformOrigin = string;
  element.style.OTransformOrigin = string;
  element.style.transformOrigin = string;
}

function setTransition(element, string) {
  element.style.webkitTransition = string;
  element.style.MozTransition = string;
  element.style.msTransition = string;
  element.style.OTransition = string;
  element.style.transition = string;
}

I tried replacing the bg by url pointing toward the image instead but nothing happens, also checked if it was maybe a syntax error and tried with (‘https://unsplash.com/photos/qzgN45hseN0’).
Also tried [{label: ‘Montreal’, document.body.style.backgroundImage = “url(‘https://unsplash.com/photos/qzgN45hseN0’)|none|initial|inherit”},

Send the information of the form and the generated image to an email

I want that when the png image is generated, another button appears to validate that the information is correct and send it to an email, together with the information put in the form.

What I investigated is the option to send it through php or an asp. I don’t know much about php.

I also want the image to be converted from png to jpg when uploaded.

Code

<!DOCTYPE html>
<html>

<head>
  <title>ESQUELAS | GR</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />

  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
  <meta name="viewport" content="initial-scale=1">

  <!-- CACHE -->
  <meta http-equiv="Expires" content="0">
  <meta http-equiv="Last-Modified" content="0">
  <meta http-equiv="Cache-Control" content="no-cache, mustrevalidate">
  <meta http-equiv="Pragma" content="no-cache">

  <link rel="stylesheet" href="css/estilos.css" type="text/css" />
  <!-- Google Fonts -->
  <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Oswald:400,300,700" />

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="js/html2canvas.js"></script>
  <script type="text/javascript">
    function showCross(text) {
      document.getElementById('cross').innerHTML = text;
    }

    function showCross(text) {
      document.getElementById('lazo').innerHTML = text;
    }

    function showEvento(text) {
      document.getElementById('evento').innerHTML = text;
    }

    function showDifunto(text) {
      document.getElementById('difunto').innerHTML = text;
    }

    function showEdad(text) {
      document.getElementById('edad').innerHTML = text;
    }

    function showParr1(text) {
      document.getElementById('parrafo1').innerHTML = text;
    }

    function showParr2(text) {
      document.getElementById('parrafo2').innerHTML = text;
    }

    function showLugar(text) {
      document.getElementById('lugar').innerHTML = text;
    }

    function showFecha(text) {
      document.getElementById('fecha').innerHTML = text;
    }


    function showCross() {
      // Get the checkbox
      var checkBox = document.getElementById("txtCross");
      // Get the output text
      var text = document.getElementById("cross");
      // If the checkbox is checked, display the output text
      if (checkBox.checked == true) {
        text.style.display = "block";
      } else {
        text.style.display = "none";
      }
    }

    function showLazo() {
      // Get the checkbox
      var checkBox = document.getElementById("txtLazo");
      // Get the output text
      var text = document.getElementById("lazo");
      // If the checkbox is checked, display the output text
      if (checkBox.checked == true) {
        text.style.display = "block";
      } else {
        text.style.display = "none";
      }
    }

    function showLogo() {
      // Get the checkbox
      var checkBox = document.getElementById("txtLogo");
      // Get the output text
      var text = document.getElementById("logo");
      // If the checkbox is checked, display the output text
      if (checkBox.checked == true) {
        text.style.display = "block";
      } else {
        text.style.display = "none";
      }
    }


    function showDeceso(text) {
      document.getElementById('deceso').innerHTML = text;
    }
  </script>

</head>

<body>

  <div style="visibility:hidden" id="previewImage"></div>
  <div id="shadow" onClick="closeImg();">
  </div>

  <div class="header">
    <div class="logo">
      <img src="img/logoElNorte.png" border="0" height="20" onClick="location.href='http://www.elnorte.com/'" style="cursor:pointer;"> <a href="default.asp">&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;ESQUELAS</a>
    </div>

  </div>


  <div id="all" class="all">
    <form method="post" action="enviamail.asp" id="form1">
      <div class="content">
        <div class="subtit">
          <div>Contenido de la Esquela</div><br>
          <hr>
        </div>

        <table class="infoMensaje">
          <!--<tr>
                <td>Logotipo:</td>
                <td><input type="text" name="logo" style="width:145px;"> <div class="btnxtra">ADJUNTAR</div></td>
            </tr>-->
          <tr>
            <td></td>
            <td>
              <label class="checkgr">
                <input type="checkbox" id="txtCross" onChange="showCross();">
                <span class="checkmark"></span>
                <img src="img/op_cruz.gif" class="ics" width="10%">
              </label>
              &nbsp;
              <label class="checkgr">
                <input type="checkbox" id="txtLazo" onChange="showLazo();">
                <span class="checkmark"></span>
                <img src="img/op_lazo.gif" class="ics" width="10%">
              </label>
              &nbsp;

              <!-- <label class="checkgr">
                  <input type="checkbox">
                  <span class="checkmark"></span>
                  SIN IMAGEN
                </label>-->

            </td>
          </tr>

          <tr>
            <td></td>
            <td>
              <textarea rows="1" name="txtCustomWord" type="text" maxlength="80" id="txtEvento" placeholder="r" onkeyup="showEvento(this.value);" style="width:80%;">Este 00 de septiembre a las 00:00 horas falleció la Sr/Sra/Md.  </textarea>
            </td>
          </tr>
          <tr>
            <td></td>
            <td><input name="txtCustomWord" type="text" maxlength="60" id="txtDifunto" placeholder="Nombre del difunto" onkeyup="showDifunto(this.value);" style="width:80%;"></td>
          </tr>
          <tr>
            <td></td>
            <td><input name="txtCustomWord" type="text" maxlength="55" id="txtEdad" onkeyup="showEdad(this.value);" style="width:80%;" value="a la edad de 00 años"></td>
          </tr>
          <tr>
            <td>
              <!--Mensaje:<br>-->
            </td>
            <td><textarea rows="3" name="txtCustomWord" type="text" maxlength="200" id="txtParr1" placeholder="Mensaje" onkeyup="showParr1(this.value);"
                style="width:80%;">Habiendo vivido siempre en el seno de la Iglesia Católica, Apostólica y Romana, confortada su alma con los Santos Sacramentos.</textarea></td>
          </tr>
          <tr>
            <td>
              <!--Mensaje:<br>-->
            </td>
            <td><textarea rows="3" name="txtCustomWord" type="text" maxlength="250" id="txtParr2" placeholder="Mensaje" onkeyup="showParr2(this.value);"
                style="width:80%;">Su esposa: xxxxxx xxxxxx xxxxxx (+), Hijos: xxxxxxxx xxxxx y xxxxxx xxxxxx y demás familiares lo participan con profundo dolor y ruegan eleve a Dios Nuestro Señor sus oraciones por el eterno descanso de su alma.</textarea>
            </td>
          </tr>
          <tr>
            <td></td>
            <td>
              <textarea rows="3" name="txtCustomWord" type="text" maxlength="245" id="txtLugar" placeholder="" onkeyup="showLugar(this.value);"
                style="width:80%;">El duelo se recibirá a partir de las 09:00 horas en las Capillas de Funerales Dolores Lincoln (Av. Lincoln #4628, Col. Valle de las Mitras), posteriormente el cortejo se despidirá en el Crematorio del Panteón Dolores.</textarea>
            </td>
          </tr>
          <tr>
            <td></td>
            <td>
              <textarea rows="1" name="txtCustomWord" type="text" maxlength="80" id="txtFecha" placeholder="r" onkeyup="showFecha(this.value);" style="width:80%;">Monterrey, Nuevo León, a 00 de junio de 2022 </textarea>
            </td>
          </tr>

          <tr>
            <td></td>
            <td>
              <label class="checkgr">
                <input type="checkbox" checked id="txtLogo" onChange="showLogo();">
                <span class="checkmark"></span>
                <img src="img/logo_benitoflores.jpg" class="ics" width="27%">
              </label>
            </td>
          </tr>
        </table>

        <div class="botonero">
          <!--<button class="btnEnd" type="submit" id="btnSave" onClick="document.info.submit();">GENERAR Y ENVIAR</button>-->
          <div class="btnEnd" id="btnSave" onClick="document.info.submit();">GENERAR IMAGEN</div>
        </div>

        <!--<div class="aster"><h3>*</h3> datos obligatorio para la publicación</div>-->

      </div>

      <div class="preview" id="widget">



        <div class="border">

          <div class="prePicto" id="cross">
            <img src="img/op_cruz.gif">
          </div>
          <div class="prePicto" id="lazo">
            <img src="img/op_lazo.gif">
          </div>

          <div class="preEvent" id="evento">
            <span class="red">
              Este 00 de septiembre a las 00:00 horas falleció la Sr/Sra/Md.
            </span>
          </div>
          <div class="preDeceased" id="difunto">
            <span class="red">
              NOMBRE DEL DIFUNTO
            </span>
          </div>
          <div class="preAge" id="edad">
            <span class="red">
              a la edad de 00 años
            </span>
          </div>
          <div class="preOneMessage" id="parrafo1">
            Habiendo vivido siempre en el seno de la Iglesia Católica, Apostólica y Romana, confortada su alma con los Santos Sacramentos.
          </div>
          <div class="preTwoMessage" id="parrafo2">
            <span class="red">
              Su esposa: xxxxxx xxxxxx xxxxxx (+), Hijos: xxxxxxxx xxxxx y xxxxxx xxxxxx y demás familiares lo participan con profundo dolor y ruegan eleve a Dios Nuestro Señor sus oraciones por el eterno descanso de su alma.
            </span>
          </div>
          <div class="prePlace" id="lugar">
            <span class="red">
              El duelo se recibirá a partir de las 09:00 horas en las Capillas de Funerales Dolores Lincoln
              (Av. Lincoln #4628, Col. Valle de las Mitras), posteriormente el cortejo se despidirá en el Crematorio del Panteón Dolores.
            </span>
          </div>
          <div class="preDate" id="fecha">
            <span class="red">
              Monterrey, Nuevo León, a 00 de junio de 2022
            </span>
          </div>
          <div class="preLogo" id="logo">
            <img src="img/logo_benitoflores.jpg">
          </div>

        </div>
      </div>
      <div id="btnSend">
        <div class="btnEnd" id="btnSave" action="mail.php">ENVIAR</div>
      </div>
    </form>
  </div>

  <!-- <div class="footer">
        si necesitas ayuda comunicate al 8150 • 8333 o 8150 • 8344 o escríbenos a <a href="mailto:[email protected]">[email protected]</a>.
    </div>-->

  <script>
    $(function() {
      $("#btnSave").click(function() {
        html2canvas($("#widget"), {
          onrendered: function(canvas) {
            theCanvas = canvas;
            document.body.appendChild(canvas);
            $("#shadow").fadeIn(500);
            // Convert and download as image

            Canvas2Image.saveAsPNG(canvas);
            $("#img-out").append(canvas);
            // Clean up
            //document.body.removeChild(canvas);
          }
        });
      });
    });

    function closeImg() {
      $("canvas").attr("id", "render");
      $("#shadow").fadeOut(500);
      $("#render").remove();
      $("#all").fadeIn(500);
    }
  </script>

</body>

</html>

React Multiple Button Filter

I have been able to map JSON wine data to a table and filter the table of wine data by color. When I click Red, the table filters to red wines, and the same for the White button.

Goal: Filter JSON data with multiple buttons. I would like to add taste buttons (Sweet, Dry, Semi-Sweet) that filter by taste and a body button that will filter wines by body How can I accomplish this?

Here, I created an object that defines wines and their properties:

    var wineData = {
    
      redWines : [
        {name: "Pinot Noir", body: "Light", taste:"Dry"},
        {name: "Cabernet Sauvignon", body: "Full", taste:"Dry"},
        {name: "Malbec", body: "Full", taste:"Dry"},
        {name:"Zinfadel",body:"Medium",taste:""},
        {name: "Montepulciano", body: "Medium", taste:"Dry"},
        {name: "Merlot", body: "Medium", taste:"Dry"},
      ],
    
    whiteWines : [
      {name: "Chardonnay", body: "Full", taste:"Dry"},
      {name: "Pinot Grigio", body: "Light", taste:"Dry"},
      {name: "Moscato", body: "Light", taste:"Semi-Sweet"},
      {name:"Sauvignon Blanc",body:"Light",taste:"Dry"},
      {name: "Riesling", body: "Light", taste:"Semi-Sweet"},
      {name: "White Zinfadel", body: "", taste:"Sweet"},
    ]
    
    }
const wine_names = {
  red: wineData.redWines.map(({ name }) => name.toLowerCase()),
  white: wineData.whiteWines.map(({ name }) => name.toLowerCase()),
  sweet: wineData.redWines.map(({taste})=> taste.toLowerCase()),
  sweet: wineData.whiteWines.map(({taste})=> taste.toLowerCase())

};

filterData algo that filters wines by its color property (matching with wineData data)

const filterData = (wines,color)=>{
  if(!taste) return wines;
  if(!color) return wines;
  return wines.filter(
    (wine) => wine_names[color].some(
      (name) => wine.field2.toLowerCase().includes(name),
      ) ) 
    }

Button and Form components

const Form = ({ handleColorChange,handleTasteChange,color,taste}) => {


  const handleClick = (e) =>{
    const {color}=e.target.dataset
    handleColorChange(color);
    handleTasteChange(taste);
    console.log(color);
   }
  

  return (
<div>
    {/* <input type="text" value={filteredData} onChange={(e)=>setFilteredData(e.target.value)}></input> */}

    <form onSubmit={(e)=> e.preventDefault()}>

            <Button
            buttonText="Red"
            color="red"
            handleClick={handleClick}
           />
              
            <Button
            buttonText="White"
            color="white"
            handleClick={handleClick}

            
           />
           
           


           <Button
           buttonText="reset"
           color=""
           handleClick={handleClick}
          
           />
          

    </form>
   </div>
  )
}

export default Form

const Button = ({buttonText, color, handleClick, taste, handleColorClick,handleTasteClick}) => {
  return (
    <button
        data-color={color}
        data-taste={taste}
        onClick={handleClick}
      

        
        // onClick={handleTasteClick}
        
    >
        {buttonText}
    </button>
    )
}

export default Button

A line from my wine JSON file looks like this:

{"key":"38843316","field2":"Robert Mondavi Winery Napa Merlot","field3":"Robert Mondavi Winery Napa Valley Merlot Red Wine showcases glorious richness and mouthwatering fruit flavors. Deeply intense Bing cherry and blackberry flavors layer with warm oak spices and a fresh, earthy complexity on the palate. Firm, velvety tannins are balanced by refreshing acidity and long finish. The unique geography and climate of Napa Valley produce delicious grapes that give this Robert Mondavi red wine its distinctive character and intense fruit flavor." ,"field4":"Robert Mondavi","field5":"31.99","field6":"Robert Mondavi","field7":"750","field8":"ml","field9":"California"}

Identifier expected error with multi line string

enter image description here

I’m working with node , trying to build jupyter notebooks programatically. I’m trying to create a function that will build a notebook ‘code’ type cell. After working in the repl I have:

function codeCell(arr =>  
  `{
  cell_type: 'code',
  execution_count: null,
  metadata: { tags: [] },
  outputs: [],
  source: [${arr}]
}`
);

As you can see in the screenshot I’m getting an identifier expected error. What am I doing wrong?

Need Help W/ My Comment Section Not Staying Within Container using JS HTML & CSS

this is my first post on stack overflow! This problem pertains to Vanilla JS, HTML, & CSS

I’m working on a practice project I have coined “Social Media Daily Quotes.” I have created a comment section and the functionality works, however I believe my JS/HTML/CSS are out of balance. The comment section starts out working fine, then after 3-4 comments it doesn’t expand the container it is in, but passes through the container and my comment form…

My goal is for the comments to stay within that comment-container and for the comment form to stay below the comments, I’ve tried a few things but I honestly don’t know due to my newness in the space.

Also, for some reason I keep throwing an error when I use postForm.reset() It worked before and stopped working somewhere along the way of me writing code. It returns an error saying that is not a function, which I understand what it means, but I don’t understand why…

Can somebody please help out, share some feedback, pointers or help me find a solution to fix this problem?

Thanks, in advance.

Go easy on the criticism, I know my code is pretty ugly, I’m new haha

Photo of the problem I am having

   const postForm = document.querySelector('#post-container')
    const commentList = document.querySelector('#comment-list')
    const commentContainer = document.querySelector('#comment-container')
    postForm.addEventListener('submit', newCommentAndlikes)


    function newCommentAndlikes (e, likes) {
        e.preventDefault();
        const div = document.createElement('div')
        div.id = "commentsAndLikes-container"

        let li = document.createElement('li')
        li.textContent = e.target.addComment.value

        const commentLikesNum = document.createElement('h3')
        commentLikesNum.textContent = "0"

        const likesBttn = document.createElement("button")
        likesBttn.className = 'like-bttn'
        likesBttn.textContent = "♥"

        likesBttn.addEventListener('click', () => increaseLikes(commentLikesNum))


        li.appendChild(commentLikesNum)
        li.appendChild(likesBttn)
        commentList.append(li)
        commentContainer.appendChild(commentList)
        // postForm.reset();
    }

    function increaseLikes(commentLikesNum){
        // inside here incrememnt character number of likes
        ++commentLikesNum.textContent
      }
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body{
    padding-top: 15px;
    display: flex;
    justify-content: center;
    text-align: center;
    height: 110vh;
    background-color: lavender;
    font-family: Lucida Handwriting, cursive;
}

img {
    border: 5px solid rgb(194, 191, 201);
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
    transition: 0.3s;
}

#quote{
    font-size: 40px;
}

#dropdown-container{
    margin-top: 15px;
    font-size: 25px;
}

#quote-dropdown {
  /* height: 30px */
  position: absolute;
  background-color: #f9f9f9;

  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  padding: 12px 12px;


}



#comment-list{
    list-style: none;
}

li {
    background-color: white;
    border-radius: 5px;
    border: 1px solid black;
    padding: 20px;
    margin-bottom: 20px;
  }

#comment-container{
    width: 600px;
    height: 350px;
    border: 2px solid #333;
    margin: auto;
    margin-top: 40px;
    padding: 15px 35px;
    background-color: whitesmoke;
}


#post-container{
    margin-top: 30px;
}

.container{
    width: 600px;
    border: 2px solid #333;
    margin: auto;
    padding: 15px 35px;
    background-color: whitesmoke;
}

.container h2{
    text-align: center;
    margin-bottom: 25px
}

textarea{
    height: 20px;
    width: 100%;
    border: none;
    border-bottom: 2px solid #aaa;
    background-color: transparent;
    margin-bottom: 10px;
    resize: none;
    outline: none;
    transition: .5s
}

input[type="submit"] {
    padding: 10px 15px;
    border: none;
    outline: none;
    border-radius: 5px;
    text-transform: uppercase;
    font-weight: bold;
    cursor: pointer;
}

input[type="submit"]{
    color: black;
    background-color: whitesmoke;
}

button{
    padding: 3px 8px;
    border-radius: 5px;
    color: #fff;
    background-color: black;
}

.btn{
    display: block;
}
<!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="styles.css">
    <script src="index.js"></script>
    <title>Document</title>
</head>
<body>



    <div id="main-content">

        <h1><strong><em>Social Media Daily Quotes</em> </strong></h1>

        <div id="imageHere">
            <img class="beach-image" src="https://source.unsplash.com/1600x900/?beach" alt="beach image" width="850" height="300"/>
        </div>
                <!-- <img src="https://random.imagecdn.app/500/150"> -->


        <div id="quote-container">
                <div id="quote">
                <h2> </h2>
                </div>
        </div>


        <div id="dropdown-container">
        <label for="select-quote">Find other quotes: </label>
        <select id="quote-dropdown" name="select-quote">
            <option value = "x">Quote of The Day!</option>
            <option value="a">Tosie's Favourite Quote ~</option>
            <option value="b">Jacob's Favourite Quote </option>
            <option value="c">Taulant's Favourite Quote </option>
        </select>
        </div>


        <div id="quote-container">


        <div id="comment-container">
        <h3> Comments: </h3>
            <ul id="comment-list">


            </ul>
        </div>


        <div id="post-container"class="container">
         <h2>Leave Them a Comment</h2>

            <form>
            <textarea id="addComment" placeholder='Add Your Comment Here'></textarea>

            <div class="btn">
                <input type="submit" value='Comment'>
                <button id='clear'>Cancel</button>
            </div>
            </form>
        </div>
        </hr>

    </div>


</body>
</html>

2: Whats Happening: https://i.stack.imgur.com/0v8h1.png

how to code a custom rich presence i tried doing one but gives error

const client = require("../index");

client.on("ready", () =>
    console.log(`${client.user.tag} is up and ready to go!`)
);
client.user.setPresence({
    status: "online",  // You can show online, idle... Do not disturb is dnd
    game: {
        name: "p!help • poketwo.net",  // The message shown
        type: "PLAYING" // PLAYING, WATCHING, LISTENING, STREAMING,
    }
});

that is the code for my rich presence but but i get a error as below

F:akashcodep22222eventsready.js:6
client.user.setPresence({
            ^

TypeError: Cannot read properties of null (reading 'setPresence')
    at Object.<anonymous> (F:akashcodep22222eventsready.js:6:13)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at F:akashcodep22222handlerindex.js:27:31
    at Array.map (<anonymous>)
    at module.exports (F:akashcodep22222handlerindex.js:27:16)

i dont know how to fix pls let me know what to do

How mapping specific property from arraylist

I m looking a way to get all email property from my postList list to filtering max chars authorized, the problme is i don’t know really how mapping email property from postList…

const postList = [
 {"postId": 1, "id": 1, "email": "[email protected]"},
 {"postId": 1, "id": 2, "email": "[email protected]"},
 {"postId": 1, "id": 3, "email": "[email protected]"},
 {"postId": 1, "id": 4, "email": "[email protected]"},
]

const onlyEmailValid = []

for (let i = 0; i < postList.length; i++) {
   if(postList.email.value.length > max_chars) {
     console.log("email : " + postList.email + " has too long");
       continue
     }
      
     onlyEmailValid.push(postList[i]);
}
console.log(clearJobList);

How to inject JavaScript into Vue script

I have a block of code that needs to be reused in multiple components. What is the best way to do this in Vue 3 with the composition API and script setup? I’ve looked into composables, but I can’t get it to work for my use case. My code is a bit like this

const popupEnabled = ref(false);

function currentPopupState() {
    return store.getters.getPopupState;
}

onMounted(() => {
    watch(currentPopupState, (value) => {
        if (value) {
            popupEnabled.value = true;
            setTimeout(() => {
                store.commit("changeCurrentPopupState", false);
                popupEnabled.value = false;
            }, 1800);
        }
    });
});

It watches an external value, then runs a timed function if the value is changed. I just want to inject this block of code into my Vue script, how do I do this?