Image will change when refresh the page and also every images will have an individual link

Image changes when the page refreshes and I am accomplishing this but I can’t add individual image links. how can I do it? Please have me out.. here is the code

<!DOCTYPE html>
<html lang="en">
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <style>
        #banner-images img{
            width: 172px;
            height: 215px ;
            border: 10px solid #fff ;
        }
    </style>
</head>
<body>
     <div id="banner-images"> </div>
<script> 
var images = ['1.jpg ', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg'];
 
$('<img class="fade-in" src="images/' + images[Math.floor(Math.random() * images.length)] + '">').appendTo('#banner-images');
</script>
</body>
</html>

How to close menu dropdown when click on body

I have a dropdown menu that works fine. The button allows me to open and close the menu, however, if I click on the body page the menu does not close, only clicking on the button can close it.
So I would like it to close even if I click on the body of the page or anything else that isn’t the button. Now I don’t know how to do it, I’m relatively new to all this, can someone help me by pointing me the right way?

I appreciate any response, thanks.

var usermenu = document.querySelector(".user_menu_button");
function userMenu() {
  var x = document.getElementById("mts_menu");
   if (x.classList.toggle ("show")) {
    usermenu.innerHTML = '<i class="icn_button fa-solid fa-xmark"></i><span class="txt_button">Account</span>';
}  else {
   usermenu.innerHTML = '<i class="icn_button fa-solid fa-bars"></i><span class="txt_button">Account</span>';
   }
}
/*Button Toggle Menu*/
.user_menu_button {
    display: flex;
    align-content: center;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 32px;
    background: #3D4350!important;
    border-radius: 4px;
    padding: 12px;
    font-size: 14px!important;
    line-height: 2;
}

.icn_button {
    margin: 0;
}

.icn_button:before, .icn_button:after {
    margin: 0;
}

.txt_button {
    margin-left: 10px;
    color: #fff;
    font-size: 14px;
    font-weight: 400;
}

/*Items menu*/
.user_menu {
    display: flex;
    flex-direction: column;
}

.user_menu.header {
  padding: 15px 15px;   
}

/*Menu header info*/
.display.name {
    font-size: 14px;
    font-weight: 500;
    color: #303238;
    line-height: 1.5;
}

.display.mail {
    font-size: 13px;
    color: #1E70EB;
    line-height: 1.5;
}

hr.divider-menu {
    border-top: 1px solid #e0e0e0;
}

/*Text Link css*/
.mnu_margin {
  margin: 7px 0;    
}

.user_menu.item > a {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 8px 15px; 
    color: #212629;
}

.user_menu.item:hover > a {
    color: #fff;
    background: #1E70EB;
    transition: all 0.2s;
}

.user_menu.item > a .link_text {
  font-size: 14px; 
  color: #212629;
}

.user_menu.item:hover > a .link_text {
  color: #fff;    
}


/*Icon Items Menu*/
.icn_menu:before, .icon_menu:after {
    margin: 0px;
    padding: 0px;
    font-size: 16px
}

.icn_menu {
    margin-right: 10px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
}

/* User Menu For header website */
.mts_menu_container {
    display: flex;
    flex-direction: column;
    align-content: flex-end;
    align-items: flex-end;
}

.dropdown_box {
    position: absolute;
    margin-top: 20px;
}

.mts_dropdown_content {
  background-color: #fff;
  min-width: 160px;
  width: 240px;
  border-radius: 6px;
  overflow-x: hidden;
  overflow-y: hidden;
  box-shadow: rgba(0, 0, 0, 0.15) 0px 5px 15px 0px;
  z-index: 999;
  position: relative;
  visibility: hidden;
  opacity: 0;
  top: 50px;
  height: 0;
  transition: visibility 0.2s, max-height 0.2s, opacity 0.2s, top 0.2s, height 0.2s;
}

.mts_dropdown_content.show {
   height: 100%;
   visibility: visible;
   opacity: 1;
   top: 0;
   transition: visibility 0.2s, max-height 0.2s, opacity 0.2s, top 0.2s, height 0.2s;
}
<button onclick="userMenu()" class="user_menu_button">
     <i class="icn_button fa-solid fa-bars"></i>
     <span class="txt_button">Account</span>
</button>

<div class="mts_menu_container">
  <div class="dropdown_box">
      
   <div id="mts_menu" class="mts_dropdown_content">
    <div class="user_menu header">
        <span class="display name">Ciao [display_name]</span>
        <span class="display mail">[display_email]</span>
    </div>   
      
     <hr class="divider-menu">  
     
    <div class="mnu_margin"> 
    <div class="user_menu item">
        <a href="/account">
         <i class="icn_menu fa-regular fa-user"></i>
         <span class="link_text">Dashboard</span>
        </a>
    </div>
    
     <div class="user_menu item">
        <a href="ordini">
         <i class="icn_menu fa-regular fa-basket-shopping"></i>
         <span class="link_text">I miei ordini</span>
        </a>
    </div>
    
    <div class="user_menu item">
        <a href="libreria">
         <i class="icn_menu fa-regular fa-cloud-arrow-down"></i>
         <span class="link_text">Downloads</span>
        </a>
    </div>
    
    <div class="user_menu item">
        <a href="impostazioni">
         <i class="icn_menu fa-regular fa-gear"></i>
         <span class="link_text">Impostazioni</span>
        </a>
    </div>
    
    <div class="user_menu item last">
        <a href="wp-login.php?action=logout">
         <i class="icn_menu fa-regular fa-arrow-right-from-bracket"></i>
         <span class="link_text">Logout</span>
        </a>
    </div>
    </div>
   
   </div> 
  </div>
</div>

Discord,js -> Reaction Roles

I am currently coding a discord bot reaction roles command.

Everything is running smoothly but I have one issue.

When I boot the bot and run the command to create the embed, everything works fine. The issue is when I react to the message it doesn’t give me the role.

The embed message works fine.
Applying the role doesn’t work and I have spent hours trying to find a solution. Please help me 🙂
Here is my code:

//Works
const { MessageEmbed } = require('discord.js');
module.exports = {
    name: "reactionrole",
    description: "Allows members to react to a messsage to get a role.",
    async execute(message, args, Discord, client){
        const channel = 'CHANNEL_ID';
        //Gets roles
        const annoucementRole = guild.roles.cache.find(role => role.name === "Announcements");
        const eventRole = guild.roles.cache.find(role => role.name === "Events");
        const sneakpeekRole = guild.roles.cache.find(role => role.name === "Sneak Peeks");
        const unrelatedstuffRole = guild.roles.cache.find(role => role.name === "Unrelated Stuff");
        const statusRole = guild.roles.cache.find(role => role.name === "Status");
        const pollRole = guild.roles.cache.find(role => role.name === "Polls");
        const updatesRole = guild.roles.cache.find(role => role.name === "Updates");
        //Role Emojis in message
        const annoucementRoleEmoji = '1️⃣';
        const eventRoleEmoji = '2️⃣';
        const sneakpeekRoleEmoji = '3️⃣';
        const unrelatedstuffRoleEmoji = '4️⃣';
        const statusRoleEmoji = '5️⃣';
        const pollRoleEmoji = '6️⃣';
        const updatesRoleEmoji = '7️⃣';
        //Embed Message - Works
        let reactionNotificationEmbed = new Discord.MessageEmbed()
        .setColor('#0099ff')
        .setTitle('Notification Roles')
        .setDescription('Below you will find the information on each reaction role.')
        .addFields(
            {name: 'Annoucement', value: '> 1️⃣ `-` Get notified each time an annoucement is made.'},
            {name: 'Events', value: '> 2️⃣ `-` Get notified when an event is made.'},
            {name: 'Sneak Peak', value: '> 3️⃣ `-` Get notified when a new YouTube video is posted from Pokemonboy Adventures.'},
            {name: 'Unrelated Stuff', value: '> 4️⃣ `-` Get notified when an annoucement from another server is made.'},
            {name: 'Status', value: '> 5️⃣ `-` Get notified when the Saphhire or PA_Admin bot has an outage.'},
            {name: 'Polls', value: '> 6️⃣ `-` Get notified when a poll is created.'},
            {name: 'Updates', value: '> 7️⃣ `-` Get notified when an update is made.'},
        )
        .setFooter('Created by PAdventures.');
        let sendEmbed = await message.reply({ embeds: [reactionNotificationEmbed] });
        sendEmbed.react(annoucementRoleEmoji);
        sendEmbed.react(eventRoleEmoji);
        sendEmbed.react(sneakpeekRoleEmoji);
        sendEmbed.react(unrelatedstuffRoleEmoji);
        sendEmbed.react(statusRoleEmoji);
        sendEmbed.react(pollRoleEmoji);
        sendEmbed.react(updatesRoleEmoji);
        //Apply the role - Doesn't work
        client.on('messageReactionAdd', async (reaction, user) => {
            if(reaction.message.partial) await message.reaction.fetch();
            if(reaction.partial) await message.fetch();
            if(user.bot) return;
            if(!reaction.message.guild) return;
            if(reaction.message.channel.id == channel) {
                const member = reaction.message.guild.members.cache.find((member) => member.id === user.id);
                if(reaction.emoji.name === annoucementRoleEmoji){
                    await reaction.message.member.roles.add(annoucementRole);
                }
                if(reaction.emoji.name === eventRoleEmoji){
                    await member.roles.add(eventRole);
                }
                if(reaction.emoji.name === sneakpeekRoleEmoji){
                    await member.roles.add(sneakpeekRole);
                }
                if(reaction.emoji.name === unrelatedstuffRoleEmoji){
                    await member.roles.add(unrelatedstuffRole);
                }
                if(reaction.emoji.name === statusRoleEmoji){
                    await member.roles.add(statusRole);
                }
                if(reaction.emoji.name === pollRoleEmoji){
                    await member.roles.add(pollRole);
                }
                if(reaction.emoji.name === updatesRoleEmoji){
                    await member.roles.add(updatesRole);
                }
            } else {
                return;
            }
        });
    }
}

i want to compare data from 2 tables either with php or javascript based on select option from form?

here are my table which i want to compare task_list and order_detail
what i’m looking for is that, when the user select an option from the below form WHITHPOUT PAGE REFRESH OR BUTTON CLICK should get the budget of that task name (value=”‘.$row[‘task_code’].'”) selected from task_list table and also get the SUM(total_price) from order_detail where task_code=value=”‘.$row[‘task_code’].'”…. i’m able to get budget but unable to get sum(total_price) from order_detail associated with task_code….
CREATE TABLE task_list (
id int(11) NOT NULL,
task_code varchar(255) NOT NULL,
project_id varchar(255) NOT NULL,
boq_id varchar(255) NOT NULL,
task_name varchar(200) NOT NULL,
task_desc text NOT NULL,
budget varchar(255) NOT NULL,
tstatus varchar(255) NOT NULL,
status_percent varchar(255) NOT NULL,
date_created datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE `order_detail` (
  `id` int(11) NOT NULL,
  `order_id` varchar(255) NOT NULL,
  `order_date` varchar(255) NOT NULL,
  `agent_name` varchar(255) NOT NULL,
  `proj_code` varchar(255) NOT NULL,
  `proj_name` varchar(255) NOT NULL,
  `supplier` varchar(255) DEFAULT NULL,
  `task_name` varchar(255) NOT NULL,
  `boq_id` varchar(255) NOT NULL,
  **`task_code` varchar(255) NOT NULL,**
  `total` varchar(255) DEFAULT NULL,
  `agent_state` varchar(255) NOT NULL,
  `account_state` varchar(255) NOT NULL,
  `admin_state` varchar(255) NOT NULL,
  `status` varchar(255) NOT NULL,
  `item_name` varchar(255) NOT NULL,
  `descr` text NOT NULL,
  `bill_ref` varchar(255) NOT NULL,
  `quantity` varchar(255) NOT NULL,
  `unit_price` varchar(255) DEFAULT NULL,
  `vat` varchar(255) DEFAULT NULL,
  `total_price` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


<form id="myform">
<br/>
 <div class="container">
 <br>
 <div class="row">
   <div  class="col-xs-5">
    <label id="lblSel" style="color:green">----</Label>
    
   </div>
  </div> 
  <br>
  <div class="row">
   <div class="col-xs-3">
    <select id="ddlEmployee" class="form-control">
    <option value="">-- Select --</option>
                    
                                  <?php         

                                      $select_query = "SELECT * FROM `task_list` WHERE project_id='".$_GET['pcode']."'";
                        
                                      $sql = mysqli_query($conn,$select_query) or die(mysqli_error());   
            
                                      while($row = mysqli_fetch_assoc($sql))
                                      {
                                       extract($row);

                                     echo '<option  value="'.$row['task_code'].'" data-budget="'.$row['budget'].'">'.$task_name.'</option>';
                                          
                            
                                       }
                                  ?>

  </select>
   </div>
  </div>
 </div>
</form>`enter code here`

How to loop a toggle classList infinitely through an array?

I’m trying to get a cycle/loop effect on 3 H1 elements, displaying a purple font color for each H1 for some seconds and then change to another H1 right below the first one.

I wanted this effect to be infinite and I thought about using for loop and setInterval but I’m getting anywhere.

setInterval(changeColorLoop(), 2000);

function changeColorLoop() {
  const titleArtArray = document.querySelectorAll(".art-text");

  for (var i = 0; i < titleArtArray.length; i++) {
    titleArtArray[i].classList.toggle = ".purple";
  }
}



  <div class="art-column">
                <h1 class="art-text">Think</h1>
                <h1 class="art-text">Design</h1>
                <h1 class="art-text">Code</h1>
              </div>


.purple {
  color: purple;
}

generate response time and save it in mongo

good morning, afternoon or evening. I want to save the response time (from the time a request is sent, until it returns) in mongo db, I am not an expert on the subject, and I would like you to please shake my hand on this topic.

  query: async (params = []) => {
    const startTime = new Date().getTime();
    let result = null;
    let error = null;
    try {
      result = await mongoose.query(params);
      const executionTime = (new Date().getTime() - startTime) / 1000;
      logger.info(`${executionTime} s`);
    } catch (err) {
      error = err;
      const executionTime = (new Date().getTime() - startTime) / 1000;
      logger.info(`${executionTime} s`);
    }

    if (result !== null) { return result; }
    throw error;
  }
}; ```
this is what it returns:
```(node:48160) UnhandledPromiseRejectionWarning: TypeError: mongoose.query is not a function

previously working with postgres and where it says query placed pol, it was more intuitive. I would appreciate any help. thanks in advance.

why is my tag activating as soon as i open my html file?

I basically have the href of my tag scroll to a certain part of my webpage. But every time I reload the webpage, it automatically scrolls to that part of the website without actually clicking it. Does anybody have any idea why this is?

html

<div class="arrow">
             <a href="#scroll-to"><span></span></a>
</div>

css

.arrow span{
    display: block;
    width: 30px;
    height: 30px;
    border-bottom: 5px solid black;
    border-right: 5px solid black;
    transform: rotate(45deg);
    margin: -10px;
    animation: scroll 2s infinite;}

@keyframes scroll {
0%{
    opacity: 1;
    transform: rotate(45deg) translate(-20px, -20px);
}
50%{
    opacity: 1;
}
100%{
    opacity: 0;
    transform: rotate(45deg) translate(20px, 20px);
}}

amcharts – change position of axis in heatmap

How can I move the time stamp to the bottom in this heatmap?

enter image description here

I was under the impression the bottomAxesContainer would do the trick, but it doesn:

var heatLegend = chart.bottomAxesContainer.children.push(am5.HeatLegend.new(root, {
  orientation: "horizontal",
  endColor: am5.color(0xfffb77),
  startColor: am5.color(0xfe131a)
}));

Laggy CSS animation with transform property

I have a pretty simple animation with only one element, but when I scroll, it turns out to be pretty laggy, though I use requestAnimationFrame() and transform property instead of top/left. What’s the problem with my code?

var floating = document.getElementsByClassName('floating');

function moveFloating(offset) {
    for (let i = 0; i < floating.length; i++) {
        floating[i].style.transform  = 'translate(0px, ' + offset +'px)';
    }
}

function loop() {
    let scrollOffset = window.scrollY;
    moveFloating(scrollOffset);
    requestAnimationFrame(loop);
}

requestAnimationFrame(loop);
html,
body {
    height: 100%;
    width: 100%;
    margin: 0 0;
    padding: 0;
    font-family: 'Courier New', Courier, monospace;
}

.frame {
    height: auto;
    width: 100%;
    position: relative;
    box-sizing: border-box;
    padding: 50px;
}

.static {
    width: 30%;
}

.floating {
    position: absolute;
    margin-left: auto;
    margin-right: auto;
    top: 50px;
    left: 0;
    right: 0;
    text-align: center;
}
<body>
    <div class="container">
        <div class="frame">
            <p class="static">
                Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse et volutpat tortor. Phasellus
                dignissim euismod ante, vel vulputate sapien vehicula dapibus. Phasellus sollicitudin est ac neque
                interdum, non vulputate augue efficitur. In feugiat convallis nunc. Etiam at luctus erat. Pellentesque
                in scelerisque tortor, vitae sodales lorem. Morbi vitae maximus massa. Donec aliquet dolor neque, porta
                tristique massa efficitur id. Ut ac odio justo. Maecenas accumsan justo id turpis lobortis vulputate.
                Aliquam ut sapien purus. Vestibulum vel sagittis purus. Quisque et gravida odio. Curabitur pretium
                lacinia nunc, nec dignissim lacus tristique sed. Vivamus ligula mi, interdum id hendrerit eget, posuere
                quis neque. Nulla eu eleifend arcu.
            </p>
            <h2 class="floating">Floating text</h2>
        </div>
    </div>
    <script src="script.js"></script>
</body>

How to stop Websocket request in network tab?

I am using websocket in react js. frontend connection code is


 useEffect(() => {
        const isHttps = process.env.REACT_APP_API_BACKENDURL
        setSocket(io(isHttps, {
    path: process.env.REACT_APP_PATH,
    withCredentials: true,
    auth: {
        token: localStorage.getItem("uuid")
    },
    transports: ["websocket"],
    autoConnect: true,
    reconnection: true,
    // reconnectionAttempts: "Infinity",
    // reconnectionDelay: 1000,
    // reconnectionDelayMax: 5000,
    // pingTimeout: 5000,
    // pingInterval: 5000,
}))
        socket?.on("connect_error", (err) => {
            console.log(err)
            console.log("connection error")
        })
    }, [])

what are the problem here so web socket automatically send request see network tab.

Web Socker request in network tab

handle async setState React

I’m new to React. I’m trying to understand useState and useEffect, so I implemented this simple code but I couldn’t handle setState of the state currentQuestion with this code I have to double click on the button (pre or next) to print the currentQuestion in h1

https://codesandbox.io/s/gifted-wilbur-lhnozg?file=/src/App.js

import { useEffect, useState } from "react";

function Survey() {
  let [currentQuestion, setCurrentQuestion] = useState(1);
  const [nextQuestion, setNextQuestion] = useState(0);
  const [preQuestion, setPreQuestion] = useState(0);
  const [disabledPre, setDisabledPre] = useState(false);
  const [disabledNext, setDisabledNext] = useState(false);

  useEffect(() => {
    console.log(
      "c = ",
      currentQuestion,
      "p = ",
      preQuestion,
      "n = ",
      nextQuestion
    );
  }, [currentQuestion, preQuestion, nextQuestion]);

  useEffect(() => {
    setPreQuestion(currentQuestion - 1);
    setNextQuestion(currentQuestion + 1);
  }, [currentQuestion]);

  const handlePre = () => {
    setDisabledNext(false);
    if (currentQuestion === 0) {
      setDisabledPre(true);
    } else {
      setCurrentQuestion(currentQuestion--);
    }
  };

  const handleNext = () => {
    setDisabledPre(false);
    if (currentQuestion === 10) {
      setDisabledNext(true);
    } else {
      setCurrentQuestion(currentQuestion++);
    }
  };

  return (
    <div>
      <h1>survey</h1>
      <nav>
        <h1>currentQuestion !: {currentQuestion}</h1>
        <button onClick={handlePre} disabled={disabledPre}>
          pre
        </button>
        <button onClick={handleNext} disabled={disabledNext}>
          next
        </button>
      </nav>
    </div>
  );
}
export default Survey;

i have a problem to show images from my cloudinary library in pug template

i got an error when i display the images in timeline which it come from my cloudinary and it consider like link “https://res.cloudinary……….” that not display , so can any one help me to find a solution for this problem i will be appreciate that , thanks a lot

timeline.pug
”’each post in posts

          .main-card.col-md-6.col-lg-4
            .right-content
              .card-container
                .card.left-card
                  .product-img
                    img.c-image(src= `${post.imageCover}` alt=`${post.name}`)'''

Axios get response gets printed in console but shows “object promise” on return

I am automating Whatsapp chat on glitch.
On some condition, I want to make a Get request to some URL to get some feed, that I want to send back to the user.
The response is being printed in the console, but actually showing as Object Promise when returned. How can I have the value of the response retuned in the body.
Appreciate your help on this. Thanks.

Here is the Get request:

async function readFeed(url){
   const resp = await axios.get(url).then(response => response.data)
   return resp
}

And here is how I am trying to call the Get function in order to send it back to the user in the chat: (Check in data > text > body)

app.post("/webhook", (req, res) => {
...
...

axios({
        method: "POST", // Required, HTTP method, a string, e.g. POST, GET
        url:
          "https://graph.facebook.com/v12.0/" +
          phone_number_id +
          "/messages?access_token=" +
          token,
        data: {
          messaging_product: "whatsapp",
          to: from,
          text: { body: readFeed("http://feed.something...").then((response) => { console.log(response); response })  },
        },
        headers: { "Content-Type": "application/json" },
      });

...
...

change output json on knex query

I would like to change my output on knex query. I have this output:

{
 restaurant_uuid: '123',
 name: 'Sea Bar',
 country_code: 'FR',
 locales: [ 'fr_FR' ]
}

I need to change it to:

{
 restaurant_uuid: '123',
 name: 'Sea Bar',
 country: {
  code: '123',
  locales: ['fr_FR']
 }
}

Could I do it on query? I know I do it at the end of flow on output with a “foreach” on array, but I would like to do it in a good way.