Is there a way to automate inputting site dialog?

My friend has a website that they made, and (with their permission) I’d like to brute force it. The site uses a dialog box for the entering of the password (the one that goes “[website] says…”) and I would really like if there were some way to automatically enter passwords and reopen the dialog box.

I was thinking maybe something on my machine like a macro, but I’m not aware of any that would fit this need and be able to parse through a list of possible passwords. The passwords are all 4 digit numbers from 0-9.

Sorry if this is a stupid question, I haven’t much experience with building/exploiting websites.

Avoid “conflict” between javascript and php on submit contact form

I’m writing this question because I think it can help other people and maybe answer some questions about the “conflict” between javascript and php.

Let’s say I have created a contact form for my website. On this form, I added a client-side style to help users fill out the form as best they can and also for the site owner to retrieve the information.

As you can see in the snippet, I added different validations that are displayed when the user clicks on the “submit” button. If everything matches, I display a message. Nothing very complicated.

Here’s the problem/conflict, or maybe because I’m a beginner in php and server side programming and don’t really know.

One of the main purposes of a contact form is to be sent to the owner of the website and for him to answer or do what I want.
It’s not my business if the owner answers or does what he wants.

I created a php file to send the contact form to my email address.

<?php

  $mailto = "[email protected]"; //Send the email to this adress

  //All the inputs informations
  $mailfrom = $_POST['email'];
  $name = $_POST['name'];
  $subject = $_POST['subject'];
  //$message = "NAME: " .$name. "rnn". "Wrote the following Message:" ."rn". $_POST['message'];
  $message = $_POST['message'];
  $headers = "From: ". $mailfrom; 
  $sendMail = mail($mailto, $subject, $message, $headers); // Send mail to website owner

?>

Here is the conflict

Because javascript files and php files share the same logic: something happens when you click submit, it seems that one of these files is not working. Here, it’s my php function that doesn’t work when my javascript file is executed.

Is this a common thing between javascript and php or is it just me who doesn’t know anything about it?

I hope someone can help me and probably other people.

Cheers

const form = document.getElementById('formContact');
const nameContact = document.getElementById('name');
const emailContact = document.getElementById('email');
const messageContact = document.getElementById('message');
const headerContact = document.querySelector('.headerContact')
const thankYou = document.querySelector('.Thankyou');

const isValidEmail = (email) => {
  const re = /^(([^<>()[]\.,;:s@"]+(.[^<>()[]\.,;:s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/;
  return re.test(String(email).toLowerCase());
};


let isValid = true;

function checkInputs(){

  //get the values from the inputs or textarea

  const nameValue = nameContact.value.trim();
  const emailValue = emailContact.value.trim();
  const messageValue = messageContact.value.trim();

  if (nameValue === ''){
    //show error
    //add error class
    setErrorFor(nameContact, 'Name cannot be blank');
  } else{
    //add success class
    setSuccesFor(nameContact);
  }

  if (emailValue === ''){
    //show error
    //add error class
    setErrorFor(emailContact, 'Email cannot be blank');
  } else if(!isValidEmail(emailValue)){
    setErrorFor(emailContact, 'Please add a valid email adress');
  } else{
    setSuccesFor(emailContact);
  }

  if (messageValue === ''){
    //show error
    //add error class
    setErrorFor(messageContact, 'Message cannot be blank');
  } else if (messageValue.length < 20){
    setErrorFor(messageContact, 'Message need to be at least 20 characters');
  }
  else{
    //add success class
    setSuccesFor(messageContact);
  }

}

function setErrorFor(input, message){
  isValid=false;
  const formControl = input.parentElement; 
  const errorContactMessage = formControl.querySelector('#Error');

  //add error message inside the span
  errorContactMessage.innerText = message;

  //add error class
  formControl.className = 'form-control error';

}

function setSuccesFor(input){
  isValid=true;
  const formControl = input.parentElement; 
  const errorContactMessage = formControl.querySelector('#Error');
  //remove message inside the span
  errorContactMessage.innerText='';

  //add success class
  formControl.className = 'form-control success';

}

let nameThk = "";
nameContact.addEventListener('input', (e) =>{
  nameThk = e.target.value;
});

form.addEventListener('submit', (e) =>{
  e.preventDefault();
  checkInputs();
  if(isValid){
    form.remove();
    headerContact.classList.add('hide');
    thankYou.classList.remove('hide');
    document.querySelector('#merci').innerHTML = `<h3>Dear ${nameThk}, thank you for reaching out ! </h3>`;
    
  }

});
.containerContact {
  background-color: #F8F8F8;
  width: 100%;
  max-width: 100%;
  padding: 0.5rem;
  display: block;
}

.containerContact h2 {
  margin-bottom: 0.5rem;
}

.form-control {
  margin-bottom: 0.25rem;
  position: relative;
}

.form-control input {
  display: block;
  width: 100%;
  height: 2rem;
  padding-left: 0.5rem;
  background: transparent;
  border: 0.025rem solid #000000;
  outline: none;
  font-size: 0.8125rem;
  color: #000000;
}

.form-control input::-webkit-input-placeholder {
  color: #000000;
}

.form-control input:-ms-input-placeholder {
  color: #000000;
}

.form-control input::-ms-input-placeholder {
  color: #000000;
}

.form-control input::placeholder {
  color: #000000;
}

.form-control textarea {
  width: 100%;
  height: 10rem;
  background: transparent;
  border: 0.025rem solid #000000;
  outline: none;
  font-family: Arial, Helvetica, sans-serif;
  padding: 0.5rem;
  font-size: 0.8125rem;
  color: #000000;
  resize: none;
}

.form-control textarea::-webkit-input-placeholder {
  color: #000000;
}

.form-control textarea:-ms-input-placeholder {
  color: #000000;
}

.form-control textarea::-ms-input-placeholder {
  color: #000000;
}

.form-control textarea::placeholder {
  color: #000000;
}

.form-control i {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  visibility: hidden;
}

.form-control #textareaChecks {
  position: absolute;
  top: 8.5rem;
  right: 0.5rem;
}

.form-control.success input {
  border-color: green;
}

.form-control.success i.fa-check-circle {
  visibility: visible;
  color: green;
}

.form-control.error input {
  border-color: red;
}

.form-control.error i.fa-exclamation-circle {
  visibility: visible;
  color: red;
}

.form-control.success textarea {
  border-color: green;
}

.form-control.success i.fa-check-circle {
  visibility: visible;
  color: green;
}

.form-control.error textarea {
  border-color: red;
}

.form-control.error i.fa-exclamation-circle {
  visibility: visible;
  color: red;
}

#Error {
  font-weight: 500;
  font-size: 0.75rem;
  font-style: italic;
  color: red;
  margin: 0;
  padding: 0;
}

#ContactSubmit {
  width: 100%;
  height: 2rem;
  background: #1e1e1e;
  outline: none;
  border: 0.025rem solid #000000;
  color: #FFFFFF;
}

.containerThank {
  height: 300px;
  display: -ms-grid;
  display: grid;
}

.containerThank h3 {
  margin: 0;
  text-align: center;
  -ms-flex-item-align: end;
      align-self: flex-end;
  font-size: 18px;
  font-weight: bold;
}

.containerThank p {
  -ms-flex-item-align: start;
      align-self: flex-start;
  text-align: center;
  font-size: 13px;
  padding-top: 0.5rem;
}

.hide {
  display: none;
}
 <section class="Contact">
        <div class="containerContact">
          <div class="headerContact">
            <h2>Contact</h2>
          </div>
          <form action="/php/contactMail.php" method="POST" class="formContact" id="formContact" novalidate>
            <div class="form-control">
              <input type="text" name="name" id="name" placeholder="First and Last name">
              <i class="fas fa-check-circle"></i>
              <i class="fas fa-exclamation-circle"></i>
              <span id="Error"></span>
            </div>

            <div class="form-control">
              <input type="email"  name="email" id="email" placeholder="Please enter your email">
              <i class="fas fa-check-circle"></i>
              <i class="fas fa-exclamation-circle"></i>
              <span id="Error"></span>
            </div>

            <div class="form-control">
              <input type="text"  name="subject" id="subject" placeholder="Subject">
              <i class="fas fa-check-circle"></i>
              <i class="fas fa-exclamation-circle"></i>
              <span id="Error"></span>
            </div>

            <div class="form-control">
                <textarea id="message" name="message" type="text" placeholder="Message"></textarea>
                <i id="textareaChecks" class="fas fa-check-circle"></i>
                <i id="textareaChecks" class="fas fa-exclamation-circle"></i>
                <span id="Error"></span>                
              </div>
              <button id="ContactSubmit" name="submit">Submit</button>
          </form>
          <div class="Thankyou hide">
            <div class="containerThank">
            <h3 id="merci"></h3>
            <p>Our team is going to get back to you as soon as possible</p>
            </div>
          </div>
        </div>
      </div>
    </section>
  </div>

Looping through a javascript array to check each item for certain children elements

I am trying to loop through a webpage and change certain styles depending on the number of children with the class ‘award-winner’ within elements with the class ‘award-winner-wrapper’. Currently, I have been able to check the webpage for the parent elements using this.

<div class="award-winner-wrapper">
    <h2>Heading></h2>
    <p>Paragraph content</p>
    <p>Paragraph content</p>
    <div class="award-winner'></div>
</div>

<div class="award-winner-wrapper">
    <h2>Heading></h2>
    <p>Paragraph content</p>
    <p>Paragraph content</p>
    <div class="award-winner'></div>
</div>

<div class="award-winner-wrapper">
    <h2>Heading></h2>
    <p>Paragraph content</p>
    <p>Paragraph content</p>
    <div class="award-winner'></div>
    <div class="award-winner'></div>
</div>

let parents = document.querySelectorAll('.award-winner-wrapper');
let pArray = Array.from(parents)

The problem I having is using a foreach loop to check each array item for the ‘award-winner’ class and if there are 2 or more elements with that class change some styles.

Hide/Show Div code not working for dropdown box choices

I know that this question is asked many times and I actually got the answer from another post, however now I have written the code to suit my needs it is not showing the div at all when clicking on the specific dropdown choice.
I really liked this method as the code made more sense to me but am not sure what I am doing wrong.
I am setting up a form and want to have a few questions where the user will choose an option and then a specific question will then show below asking one or more specific questions. I did this with Yes/No radio buttons elsewhere which is working, but I need to do this with three options that will lead to three separate inquiries to get more information, and another choice where they have the option to just leave it as is and not answer.

The code for the javascript is as follows:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>">
    <script>

function landaccessfunction(){
                        getValue = document.getElementById("access").value;
                        if(getValue == "road"){
                            document.getElementById("roaddetails").style.display = "block";
                            document.getElementById("easementdetails").style.display = "none";
                            document.getElementById("noaccessdetails").style.display = "none";
                        }
                        if(getValue == "easement"){
                            document.getElementById("roaddetails").style.display = "none";
                            document.getElementById("easementdetails").style.display = "block";
                            document.getElementById("noaccessdetails").style.display = "none";
                        }
                        if(getValue == "noaccess"){
                            document.getElementById("roaddetails").style.display = "none";
                            document.getElementById("easementdetails").style.display = "none";
                            document.getElementById("noaccessdetails").style.display = "block";
                        }
                        if(getValue == "selectaccess"){
                            document.getElementById("roaddetails").style.display = "block";
                            document.getElementById("easementdetails").style.display = "block";
                            document.getElementById("noaccessdetails").style.display = "block";
                        }
                    }
                </script>

Then this is the part of the code which is placed within the body tags and the form itself:

How is the land accessed?
<select style="height:24px;font-size:12pt; name="access" id="access" onchange="landaccessfunction" class="form-control" form="landform">
                <option value="selectaccess">Select One</option>
                <option value="road">Direct road access</option>
                <option value="easement">A legally deeded easement</option>
                <option value="noaccess">No legal access</option>
                          </select> 


<div class=text" id="roaddetails" style="display:none;">                
Who owns the road?<br><input style="height:20px;font-size:12pt; name="roadowner" type="text" id="roadowner" form="landform" size="50">
</div>

<div class=text" id="easementdetails" style="display:none;">                
Describe easement<br><input style="height:20px;font-size:12pt; name="easedescr" type="text" id="easedescr" form="landform" size="50">
</div>

<div class=text" id="noaccessdetails" style="display:none;">                
How do you access the land at this time?<br><input style="height:20px;font-size:12pt; name="howaccess" type="text" id="howaccess" form="landform" size="50">
</div>

My apologies if it is something stupid that I am not seeing. Also note that the questions that show up may include text boxes or other form field types but for now I have just put simple short entry fields.

Thank you so much.

How to find elephant with the lowest value in object

Hello I have a question how can I find elephant with the lowest value from object? I need to find elephant with the value of “minimum” variable. I mean I want to get the whole object.

let startOrder = [1, 4, 5, 3, 6, 2];


  

    const elephantObject = [];
      startOrder.forEach((order, i) => {
        elephantObject.push({ [order]: massOfElephants[i] });
      });
    
    for (let i = 0; i < numberOfElephants; i++) {
        for (let j = 0; j < numberOfElephants; j++) {
        
            const [value] = Object.values(elephantObject[i]);
            const [valueOfStarter] = Object.values(elephantObject[startOrder[i]]);
            const minimum = Math.min(
              elephantAtGivenCorrectIndex[itemAtGivenOrder],
              value
            );

How do I map data with nested dictionaries?

I use KO JS and had an issue with displaying keys of the root keys. I asked a question about it and did have some progress but still, problem is not solved.
LINK TO PREVIOUS QUESTION

I figured that my data needed mapping. Data that I get from back-end looks like this :
enter image description here

I’m thinking about recreating data like this :
from :

2020-21 :
{
    Tbilisi: {PriceHeaders: Array(9), Comment: 'TBi', Pricings: Array(1)}
}

To :

Year : 2020-21 
Cities : {
    Tbilisi: {PriceHeaders: Array(9), Comment: 'TBi', Pricings: Array(1)}
}

After that, I can run a simple foreach and get Values of Year and Any key from Cities.

I came up with something like this

Object.entries(data).map(([year, cities]) =>
(
    {
     "year": year,
     "cities": Object.entries(cities).map(([name, cities]) =>
      (
          {
              name,
              ...cities
          }
      ))
     }
 ))

Problem is, I can not make use of this code in data bind

        <div data-bind="data : THIS FUNCTION HERE , as 'result'"></div>

Photshop: Saving pngs on randomizing function not working

i’m trying to run a script on PS 2021 version to randomize the creation of PNG artworks. I’ve set up four groups with different layers on it. It randomizes the visibility of layers in a certain way. However, when it comes to saving the image as PNG it prompts the file explorer to save the file in PSD format.

This is the code am using right now:

function Visible() {
    var Grps = app.activeDocument.layerSets;

    //alert("total groups: "+ Grps.length);
    for (var i = 0; i < Grps.length; i++) {
        // Get the amount of layers in a set
        var tmp = app.activeDocument.layerSets[i].layers.length;

        // set the whole group visible
        app.activeDocument.layerSets[i].visible = true;

        var groupChildArr = app.activeDocument.layerSets[i].layers;

        var randLays = Math.floor(Math.random() * tmp);

        groupChildArr[randLays].visible = true;

        Save();

    }
    Revert();
}
function Save() {
    var outFolder = app.activeDocument;

    var outPath = outFolder.path;

    var fName = "PNG";

    var f = new Folder(outPath + "/" + fName);
    if (!f.exists) {
        f.create()
    }
    //alert("before path config");
    var saveFile = new File(outPath + "/" + fName + "/" + "TREE_" + num + ".png");
    pngSaveOptions = new PNGSaveOptions();
    pngSaveOptions.interlaced = false;

    //alert("before save")
    app.activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);
    //alert("after save")
}
function Revert() { 
    var idRvrt = charIDToTypeID("Rvrt"); 
    executeAction(idRvrt, undefined, DialogModes.NO); 
}
var count = prompt("How many versions you want", ""); 
for (var x = 0; x < count; x++) { 
    var num = x + 1; 
    Visible(); 
}

This is how it works, it asks for the number of pieces to generate:

enter image description here

And then it just prompts the explorer on each iteration:
enter image description here

Any help would be greatly appreciated!

Simple vanilla javascript accordion – problem when click on active item

I have a problem with my accordion script.

Can someone explain me – why after clicking on the active item, the animation is not performed like when clicking on the next item?

It seems to me that the problem is at the beginning of the if condition:

if (this.nextElementSibling.style.maxHeight) {

when I click on accordionItemHead

 let accordions = document.querySelectorAll('.js-accordions');

    accordions.forEach(function (accordion) {

        let singleAccordionItems = accordion.querySelectorAll('.js-accordions-item');

        singleAccordionItems.forEach(function (accordionItem) {

            let accordionItemHead = accordionItem.querySelector('.js-accordions-head');
            let accordionItemContent = accordionItem.querySelector('.js-accordions-content');

            accordionItemHead.addEventListener("click", function() {

                if (this.nextElementSibling.style.maxHeight) {
                    this.nextElementSibling.style.maxHeight = null;

                } else {

                    singleAccordionItems.forEach(function (item) {

                        item.querySelector('.js-accordions-content').style.maxHeight = null;
                        item.classList.remove('is-active');

                    });
                }

                accordionItemContent.style.maxHeight = accordionItemContent.scrollHeight + "px";
                accordionItem.classList.toggle('is-active');
                
            });
            
        
        });
        
    });
.c-accordion {
     box-shadow: 2px 2px 24px rgba(0, 0, 0, 0.05);
}
 .c-accordion__item {
     padding-left: 20px;
}
 .c-accordion__header {
     position: relative;
     cursor: pointer;
     padding: 26px 0 22px;
}
 .c-accordion__header::before {
     content: '';
     position: absolute;
     top: 0;
     left: 0;
     right: 0;
     height: 1px;
     background-color: blue;
}
 .c-accordion__item:first-child .c-accordion__header::before {
     content: none;
}
 .c-accordion__header h4 {
     padding-right: 60px;
     font-size: 18px;
     font-weight: 500;
     line-height: 1.2;
}
 .c-accordion__text {
     max-height: 0;
     overflow: hidden;
     visibility: hidden;
     transition-duration: 400ms;
     transition-property: max-height, visibility;
     transition-delay: 0, 400ms;
}
 .is-active .c-accordion__text {
     visibility: visible;
     transition-duration: 400ms;
     transition-property: max-height, visibility;
     transition-delay: 400ms, 0;
}
 .c-accordion__text p {
     margin-top: 0;
     margin-bottom: 25px;
}
 .c-accordion__text-inner {
     display: flex;
     flex-direction: column;
}
 .c-accordion__icon {
     position: absolute;
     top: 50%;
     margin-top: -9px;
     right: 25px;
     font-size: 18px;
     color: red;
}
 .c-accordion__icon::after {
     position: absolute;
     top: 50%;
     margin-top: -1px;
     left: 0;
     content: '';
     width: 19px;
     height: 2px;
     background-color: blue;
     transform: scalex(0);
     transition: transform 0.4s;
}
 .is-active .c-accordion__icon::after {
     transform: scaleX(1);
}
 .c-accordion__icon::before {
     display: inline-block;
     transition: transform 0.3s, opacity 0.5s;
}
 .is-active .c-accordion__icon::before {
     transform: rotate(90deg);
     opacity: 0;
}
 
<div class="c-accordion js-accordions">
                                                    <div class="c-accordion__item js-accordions-item">

                                <div class="c-accordion__header js-accordions-head">
                                                                            <h4>Długie pytanie w dwóch linijkach</h4>
                                        <span class="c-accordion__icon icon icon-plus"></span>
                                                                    </div>

                                <div class="c-accordion__text js-accordions-content" style="">
                                   <div class="c-accordion__text-inner">
                                                                                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vulputate libero et velit interdum, ac aliquet odio mattis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Consectetur adipiscing elit. Nunc vulputate libero et velit interdum, ac aliquet odio mattis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. 2</p>
                                                                           </div>
                                </div>
                                
                            </div>

                                                                                <div class="c-accordion__item js-accordions-item">

                                <div class="c-accordion__header js-accordions-head">
                                                                            <h4>Długie pytanie w dwóch linijkach</h4>
                                        <span class="c-accordion__icon icon icon-plus"></span>
                                                                    </div>

                                <div class="c-accordion__text js-accordions-content">
                                   <div class="c-accordion__text-inner">
                                                                                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vulputate libero et velit interdum, ac aliquet odio mattis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Consectetur adipiscing elit. Nunc vulputate libero et velit interdum, ac aliquet odio mattis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.</p>
                                                                           </div>
                                </div>
                                
                            </div>

                                                                                <div class="c-accordion__item js-accordions-item">

                                <div class="c-accordion__header js-accordions-head">
                                                                            <h4>Długie pytanie w dwóch linijkach</h4>
                                        <span class="c-accordion__icon icon icon-plus"></span>
                                                                    </div>

                                <div class="c-accordion__text js-accordions-content">
                                   <div class="c-accordion__text-inner">
                                                                                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vulputate libero et velit interdum, ac aliquet odio mattis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Consectetur adipiscing elit. Nunc vulputate libero et velit interdum, ac aliquet odio mattis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.</p>
                                                                           </div>
                                </div>
                                
                            </div>

                                                                                <div class="c-accordion__item js-accordions-item">

                                <div class="c-accordion__header js-accordions-head">
                                                                            <h4>Długie pytanie w dwóch linijkach</h4>
                                        <span class="c-accordion__icon icon icon-plus"></span>
                                                                    </div>

                                <div class="c-accordion__text js-accordions-content">
                                   <div class="c-accordion__text-inner">
                                                                                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vulputate libero et velit interdum, ac aliquet odio mattis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Consectetur adipiscing elit. Nunc vulputate libero et velit interdum, ac aliquet odio mattis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.</p>
                                                                           </div>
                                </div>
                                
                            </div>

                                                                            
                    </div>

Update Leaflet map and markers everytime active Bootstrap tab changes

I have Bootstrap tabs element and separate Leaflet map aside it. Each tab lists different elements with “marker” class and data-attributes for coordinates. Markers are created on map from these attributes. My goal is to update markers when the active tab changes. Only markers inside the active tab should be displayed.

So far, I’ve been able to create a map and add markers to it from first active tab. Also, the map and markers are zoomed that they can fit inside boundaries. When switching the tab, markers are not updated. Each tab buttons and tab panes have their unique element IDs. I’m stuck, how could I achieve the goal?

Here’s a jQuery part of the code.

jQuery(document).ready(function () {

    var map = L.map('map').setView([64.794444, 25.359444], 5);

    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
        attribution: ' &copy; <a href="https://www.openstreetmap.org/" target="_blank">OpenStreetMap</a> contributors',
        maxZoom: 19,
    }).addTo(map);

    var markers = [];

    jQuery.each(jQuery('.tab-pane.active.show .marker'), function () {
        var marker = [];
        var lat = jQuery(this).attr('data-lat');
        var lng = jQuery(this).attr('data-lng');
        var name = jQuery(this).attr('data-title');
        marker = [name, lat, lng];
        markers.push( marker );
        
    });

    let markerArray = [];

    for (var i = 0; i < markers.length; i++) {
        marker = new L.marker([markers[i][1], markers[i][2]],{alt: markers[i][0]}).bindTooltip(markers[i][0], {permanent: true}).addTo(map);
        markerArray.push([markers[i][1], markers[i][2]]);
    }
    
    var bounds = new L.LatLngBounds(markerArray);
    map.fitBounds(bounds);

});

And the element with “marker” class with data-attributes.

<div class="marker" data-lat="' . $station['lat'] . '" data-lng="' . $station['lng'] . '" data-title="' . $term->name . '"></div>

As you can see, I have tried to achieve this by using “.tab-pane.active.show .marker” selector in jQuery. However, this doesn’t work.

I wish somebody can help me with this issue. Thank you very much!

How to compare to json and change the key name?

const headerObject = [
    { label: 'Code', field_key: 'code' },
    { label: 'Worked Accounts', field_key: 'workedAccounts' },
    { label: 'Contactable Accounts', field_key: 'contactableAccounts' },
    { label: 'Taken By', field_key: 'takenBy' },
];

const dataObj = [
    {
        "code": "ABCD",
        "takenBy": "",
        "workedAccounts": 4,
        "contactableAccounts": 3,
    },
    {
        "takenBy": "Ram",
        "workedAccounts": 2,
        "contactableAccounts": 1,
    },
    {
        "takenBy": "krish",
        "workedAccounts": 2,
        "contactableAccounts": 2,
    },
    {
        "code": "XYZ",
        "takenBy": "",
        "workedAccounts": 9,
        "contactableAccounts": 4,
    },
    {
        "Taken By": "Jack",
        "workedAccounts": 5,
        "contactableAccounts": 0,
    },
    {
        "Taken By": "krish",
        "workedAccounts": 4,
        "contactableAccounts": 4,
    }
];

const result = [
    {
        "Code": "ABCD",
        "Taken By": "",
        "Worked Accounts": 4,
        "Contactable Accounts": 3,
    },
    {
        "Taken By": "Ram",
        "Worked Accounts": 2,
        "Contactable Accounts": 1,
    },
    {
        "Taken By": "krish",
        "Worked Accounts": 2,
        "Contactable Accounts": 2,
    },
    {
        "Code": "XYZ",
        "Taken By": "",
        "Worked Accounts": 9,
        "Contactable Accounts": 4,
    },
    {
        "Taken By": "Jack",
        "Worked Accounts": 5,
        "Contactable Accounts": 0,
    },
    {
        "Taken By": "krish",
        "Worked Accounts": 4,
        "Contactable Accounts": 4,
    }
];

result = filter(headerObj, el => Object.keys(dataObj)?.filter(ele => ele === el.field_key && {[el.field.key]: ele[field.key));

How do I add user inputs on click?

Self taught coder. Hopefully I can explain this adequately. Users create recipe cooking guides by inputing values like dish name, food category, cover img, etc. The steps array only has 1 step at the moment. I want a button that users can click that would add another “step” and “gif” to the steps array. Can anyone help with this?

  const handleAddGuide = async (e) => {
    e.preventDefault();
    const newId = uuidv4();

    await setDoc(doc(db, "guides", newId), {
      author: e.target.author.value,
      categoryId: "100",
      categoryName: e.target.categoryName.value,
      coverImg: data.img,
      id: newId,
      name: e.target.name.value,
      tags: e.target.tags.value,
      steps: [ <----- Need a button that adds another step and gif into this array
        {
          step: e.target.step.value,
          img: data.img,
        },
      ],
    });
  };

This is what the jsx looks like. I basically need this code blow to “duplicate” itself when a button is clicked so users can add as many steps at they want to the recipe.

<div className="upload__inputs">
            <label className="upload__label">Step 1</label>
            <input
              className="upload__input upload__input--large"
              name="step"
            ></input>
          </div>
          <div className="upload__inputs">
            <div>
              <img src={file ? URL.createObjectURL(file) : ""}></img>
            </div>
            <label
              htmlFor="file"
              style={{ cursor: "pointer" }}
              className="upload__add"
            >
              + GIF
            </label>
            <input
              id="file"
              onChange={(e) => setFile(e.target.files[0])}
              style={{ display: "none" }}
              type="file"
            ></input>
          </div>

Please let me know if I’m missing any key information. Any advice is appreciated. Thank you.

Having an issue with randomization in Discord JS

so i’ve been trying to make it so that every time the user sends a message there’s a 50/50 chance that the bot reacts with an emoji, however the number is only picked every time i restart the bot. any ideas on how i can make it pick the number every time the command is triggered?

i tried to use setInterval but that didn’t work so idk

here code;

const userID = "user id"
let random = Math.floor(Math.random()*2)

client.on('messageCreate', (message) => {
  if(random === 1) {
    if(message.author.id === userID) {
      message.react('emoji');
    }
  }
});

How to position node absolutely using vis.js

I’m trying to position four nodes absolutely using Vis.js, meaning I set the physical coordinates and they do not move in relation with the other nodes. I’ve set physics to false, and fixed.x and fixed.y to true, but the nodes are still moving in relation to each other and I’m not sure why.