cefSharp How to return value from JavaScript console.log(linksArray)

How to return value from this line console.log(linksArray); to cefSharp
As i know cefSharp does not return value from “console.log” is not it?
Is there any way to return value from console.log(linksArray);

var target = document.body;
const config = { 
    childList: true,
    attributes: true, 
    characterData: true, 
    subtree: true, 
    //attributeFilter: ["id"],
    attributeOldValue: true, 
    characterDataOldValue: true 
}

const callback = function(mutations)
{
    var linksArray = new Array();
    if(document.querySelector(".cdn_download_item"))
    {
    var elements = Array.from(document.querySelectorAll('.cdn_download_item span:first-child'));
    for (element of elements) {
        linksArray.push(element.innerText);
    }
    console.log(linksArray); //HERE!!!!!!!!!!!!!!!!!!!!!!!!!!
    }
}

const observer = new MutationObserver(callback);
observer.observe(target, config);
document.querySelector('#dle-content > div.section > ul > li:nth-child(3)').click();

Displaying the value from the second hidden table when clicking on the first open table

I have 2 tables in HTML output. One is hidden. I want to use JavaScript to make it so that when I select a row with a value with the mouse, a window opens and the value from the second hidden table is shown. How can I do that?

View of open table

ID   Week_1 Week_2 Week_3 Week_4
1    1             3
2    3      1             1
3           2       
4    1             5

View of hidden table

ID Week_number  Value
1      1        1050
1      3        3024
1      3        5623
1      3        4560
...
4      1        4563

The code I use to select a cell.

    function addRowHandlers() {
    var table = document.getElementById("duedate");
    var rows = table.getElementsByTagName("tr");
    for (i = 0; i < rows.length; i++) {
        var currentRow = table.rows[i];
        var createClickHandler = 
            function(row) 
            {
                return function() { 
                                        var cell = row.getElementsByTagName("td")[0];
                                        var id = cell.innerHTML;
                                        alert("id:" + id);
                                 };
            };

        currentRow.onclick = createClickHandler(currentRow);
    }
}

    window.onload = addRowHandlers();

How can I replace the selected id with other values from the hidden table?

My markers are not displayed React leaflet

the goal is to displayed marker on map.

I don’t understand why my markers are not displayed

I use react-leaflet

The response is okay but nothing is displayed

thanks you in advance
have a god day

response
my map

Import

import { MapContainer, TileLayer, Marker, ScaleControl } from 'react-leaflet';
import tileLayer from '../util/tileLayer';
import L from "leaflet";
import 'leaflet-fullscreen/dist/Leaflet.fullscreen.js';
import 'leaflet-fullscreen/dist/leaflet.fullscreen.css';
import { useEffect } from 'react';
import newMarker from "../data/asset/pin.png";
import axios from 'axios'

center of first view

const center = [46.227638, 2.213749];

Icon

const pointerIcon = new L.Icon({
  iconUrl: newMarker,
  iconSize: [50, 58], // size of the icon
  iconAnchor: [20, 58], // changed marker icon position
});

Markers

const MyMarkers = ({ data }) => {
  return data.map(({ lat, lng }, index) => (
    <Marker
      key={index}
      position={{ lat, lng }}
      icon={pointerIcon}
    >
    </Marker>
  ));
}

get data with useEffect, async await & axios

const MapWrapper = () => {

  useEffect( async () => {

    markers = (await componentDataMarkers()).data
    console.log(markers);
  }, [])
  const componentDataMarkers = async () => await axios.get(`http://localhost:5000/plane/latlong`)
  var markers = []

React Leaflet component

  return (
    <MapContainer
    fullscreenControl={true}
    center={center}
    zoom={13}
    scrollWheelZoom={true}
    >

      <TileLayer {...tileLayer} />

      <MyMarkers data={markers} />
      <ScaleControl imperial={false} />
    </MapContainer>
  )
}

export default MapWrapper;

how to create a Dynamic dropdown using semantic ui?

I want to create a dynamic dropdown in my form which will fetch values from a column in the table which is in my database.
Can some help regarding this issue, i have seen some examples here but none of them explain clearly how to do it. I am really stuck on this any help is appreciated.

And one more doubt do i have to write anything in back end for it or only in jsp is fine ??

please can some give any example or any rough idea how to do it with semantic ui ??

I’ll add what i have tried below it’s not much.

my dropdown


<div class="required field">
    <label align = " left "  > Main Category </label>
        <select name = "home_main_category" class = "ui dropdown"  id = "home_main_cat_dropdown_id" >   
            <option> Select a main category </option>   
        </select>
</div>      

what i have tried


    $('#home_main_cat_dropdown_id').dropdown
    ({
        apiSettings:
        {
            url : 'ControllerServlet.listMainCategory',
            method : 'GET',
            cache: false,
            
            onSuccess : function(data)
            {
                var aa = { success: true, results: [] };
            }
    
            $.each(data, function(key, value)
            {
                {
                    $('#home_main_cat_dropdown_id').append('<option value="' + value.id + '">' + value.main_category + '</option>')
                }
            });
        },
    });

Event Calendar is not showing up on clicking radio button

I’m trying to show full calendar event upon clicking the radio button. It is shown in collapsed way while loading and when I click the “Month” tab calendar is viewing correctly. My working url is [https://sampledemos.online/training-maker/create-training-program.html]. In this under the action tab, when I click the group plus icon, it opens a modal. In the popup modal, when I click the radio button, calendar is displaying as collapsed way. When I click the “Month” tab again it is showing correctly.
In my onclick radio button am the function – myFunction(),

<input type="radio" id="css" name="trainerstype" value="Trainer 1" onclick="myFunction()">

and my script is

function myFunction() {
  var x = document.getElementById("menu1");
  x.addEventListener('show.bs.modal', function (event) {
 $("#menu1").show();
})}

and am using the calendar view inside div element as

<div id="menu1" style="display:none;">
///here goes the full calendar codings
</div>

Let me know is there any wrong in my scripts…

how to filter only specific objects from an array

I need to filter objects with certain criteria from an array of objects.

Data:

const system = [
    {
        "Name": "Ben.",
        "TypeID": "STRONG",
        "CatID": "BEN",
        "GENDER": "MALE"
    },
    {
        "Name": "Jack.",
        "TypeID": "SOUND",
        "CatID": "JACK",
        "GENDER": "MALE"
    },
    {
        "Name": "DAVE.",
        "TypeID": "STRONG",
        "CatID": "DAVE",
        "GENDER": "MALE"
    },    
    {
        "Name": "ALICE.",
        "TypeID": "MIND",
        "CatID": "ALICE",
        "GENDER": "FEMALE"
    },
    {
        "Name": "LISA.",
        "TypeID": "MIND",
        "CatID": "LISA",
        "GENDER": "FEMALE"
    },
    {
        "Name": "GROW.",
        "TypeID": "TALL",
        "CatID": "GROW",
        "GENDER": "MALE"
    },
    {
        "Name": "PINK.",
        "TypeID": "SPEED",
        "CatID": "PINK",
        "GENDER": "FEMALE"
    },
]



const building = [
    {
        "Name": "B1",
        "TypeID": "SPEED"
    },
    {
        "Name": "B2",
        "TypeID": "MIND"
    },
    {
        "Name": "B3",
        "TypeID": "STRONG"
    },
]

Code:

const custom = system.filter((c) => {
    return c.GENDER === "FEMALE"
})
const filtered = system.filter((z) => {
        return building.some((c) => {
          return c.TypeID === z.TypeID && z.GENDER === "MALE";
        });
      });
const newArr = filtered.concat(custom)
      
console.log(newArr)

Output:

[ { Name: 'Ben.', TypeID: 'STRONG', CatID: 'BEN', GENDER: 'MALE' },
  { Name: 'DAVE.', TypeID: 'STRONG', CatID: 'DAVE', GENDER: 'MALE' },
  { Name: 'ALICE.',
    TypeID: 'MIND',
    CatID: 'ALICE',
    GENDER: 'FEMALE' },
  { Name: 'LISA.', TypeID: 'MIND', CatID: 'LISA', GENDER: 'FEMALE' },
  { Name: 'PINK.',
    TypeID: 'SPEED',
    CatID: 'PINK',
    GENDER: 'FEMALE' } ]

I need to filter out objects that have same ‘GENDER’ in system array and building array.
But, need to filter only GENDER with ‘male’ as value, and show all the objects with GENDER ‘female’.
I above output is correct. But is there any better way to do ?

Props are not passing from parent to child components in React Functional component

Hi developers I’m just a beginner in React.js. I tried to print props by passing from parent to child.

This is app.js file

    import React from "react";
    import Hooks from "./components/ReactHooks1";
    import Hooks2 from "./components/ReactHooks2";
    
    const App = () => {
        return (
            <div>
            <h1>
                Welcome to React App
            </h1>
            <Hooks2 title2={"Welcome"}/>
            </div>
    
        )
    }
    
    export default App

This is child component file

import React from 'react';


const Hooks2 = (props) => {
    console.log(props);
}


export default Hooks2;

I just try to print props.title but it shows an empty object. what am I doing wrong please help me on this

JSON.stringify on Arrays adding numeric keys for each array value

I am trying to convert an array to object .

Below is the array value which I am trying to transform into an object.

kbInfo : [{ "questionId": "1", "customQuestion": "What is your first car make and model", "answer": "Ford Pinto" },{ "questionId": "14", "customQuestion": "Your favorite sports", "answer": "Sleeping" } ]

This gives a result like below after doing a JSON.stringify(kbaInfo)

{"0":{ "questionId": "1", "customQuestion": "What is your first car make and model", "answer": "Ford Pinto" },"1":{ "questionId": "14", "customQuestion": "Your favorite sports", "answer": "Sleeping" }}

I want to create the result in this form.

{ "SQA": [{ "questionId": "1", "customQuestion": "What is your first car make and model", "answer": "Ford Pinto" }, { "questionId": "14", "customQuestion": "Your favorite sports", "answer": "Sleeping" } ]}

I am not able to figure out how I can create on object result like above. I am using a Rhino 1.7 engine. Is there a way I can achieve this form?

How to identify whether website is accessed from same hosted server or different client machine

We have a website hosted in local intranet environment using Python webserver.
In that website particular button should only be visible if user is accessing this website on the machineserver on which site is hosted.

If website is getting accessed from any other system of the network then that button should be hidden.

So is there robust way to find whether site is accessed from same server or different machine

Change OpenLayers map style

I am trying to create a map in OpenLayers. I have no problem with other APIs, but the map style is old. Also, there is another application named Snap (it’s using OSM) that has a prettier style:

Left image is Snap, Right image is my map

How can I change OpenLayers map style?

Why doesn’t my promise then work, but no errors? [duplicate]

Inside function googleSearch a promise, and i need to wait, when the googleSearch resolved, but .then(()=>{…}) not working. Help pls :(;

client.on("messageCreate",(msg)=>{
  if (msg.author.bot) return;
  if (!msg.content.trim().startsWith(config.prefix)) return;
  var msgCont = msg.content.trim().split(" ");
  if (msgCont[1]=="ping"){
    msg.channel.send("pong")
  }
  if (msgCont[1]=="search"){
    var req = msgCont.slice(2,msgCont.length).join(" ");
    if (req.length==0) return;
    var promise = new Promise(()=>{
    for(let base in ansBase){
      googleSearch(req,ansBase[base])
    }
    })
    promise.then(()=>{
    msg.channel.send({ embeds:  })
    embed.fields=[]
    }
   )
  }
})

Clicking a text is not expanding table

I am having problem in my JS code. I tried much but was unable to solve it. The problem is that i have a dashboard which have multiple pages. We can switch from one page to another without reloading the page.
Code of switching the pages without refresh

  $(sidebar_a).click(function (e) {
        // load another page without reloading

    if ($(sidebar_a).hasClass("active")) {
      $(sidebar_a).removeClass("active");
    }

    e.preventDefault();
    $(this).addClass("active");
    setTimeout(() => {
      let url = $(this).attr("data-href");
      // show page content and change the url
      $(".recent-orders").load(url + " .recent-orders", function () {
        window.history.replaceState(null, null, url);
      });
    }, 500);
    $(".recent-orders").load("./inc/preloader.html");
  });

I have multiple pages which includes dashboard orders customers etc. Each page has table which loads when we switch from one page to another. I have limited the tbody with 4 customers. If user wants to see all the customers he have to press show all button As shown in picture See Here

Table doesnot expand on pressing show all button if we switch between pages . If we switch to another page we have to reload the page than show-all button works well. And after reloading if we switch to another page as I told without reloading and come back to previous it doesnot work neither on previous page nor on next page.Each page contain table as shown above in picture with show-all button. Each time I have to reload page if I switch from one page to another. I want to solve it and make it work without reloading page.
Here is My Both Pages code between which I am switching.
1st Page

<div class="recent-orders">
    <h2>Recent Orders</h2>
    <table id="recent-orders-table">
        <thead>
            <tr>
                <th>Product Name</th>
                <th>Product Number</th>
                <th>Payment</th>
                <th>Status</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>iPhone 12</td>
                <td>0002</td>
                <td>Due</td>
                <td class="warning">Pending</td>

                <!-- Classes available for status text color warning,success,danger,primary -->
                <a href="./index?detail_customer=">
                    <td class="primary"> <a href="./index?detail_customer="> Details </a> </td>
                </a>

            </tr>
            <tr>
                <td>iPhone 12</td>
                <td>0003</td>
                <td>Due</td>
                <td class="warning">Pending</td>

                <!-- Classes available for status text color warning,success,danger,primary -->
                <a href="./index?detail_customer=">
                    <td class="primary"> <a href="./index?detail_customer="> Details </a> </td>
                </a>

            </tr>
            <tr>
                <td>Apple Tab</td>
                <td>0004</td>
                <td>Due</td>
                <td class="warning">Pending</td>

                <!-- Classes available for status text color warning,success,danger,primary -->
                <a href="./index?detail_customer=">
                    <td class="primary"> <a href="./index?detail_customer="> Details </a> </td>
                </a>

            </tr>
            <tr>
                <td>iPhone 12</td>
                <td>0001</td>
                <td>Due</td>
                <td class="warning">Pending</td>

                <!-- Classes available for status text color warning,success,danger,primary -->
                <a href="./index?detail_customer=">
                    <td class="primary"> <a href="./index?detail_customer="> Details </a> </td>
                </a>

            </tr>
        </tbody>
        <tbody class="hidetbody">
            <tr>
                <td>iPhone 2</td>
                <td>0003</td>
                <td>Due</td>
                <td class="warning">Pending</td>

                <!-- Classes available for status text color warning,success,danger,primary -->
                <a href="./index?detail_customer=">
                    <td class="primary"> <a href="./index?detail_customer="> Details </a> </td>
                </a>

            </tr>
            <tr>
                <td>iPhone 12</td>
                <td>0003</td>
                <td>Due</td>
                <td class="warning">Pending</td>

                <!-- Classes available for status text color warning,success,danger,primary -->
                <a href="./index?detail_customer=">
                    <td class="primary"> <a href="./index?detail_customer="> Details </a> </td>
                </a>

            </tr>
            <tr>
                <td>Apple Tab</td>
                <td>0004</td>
                <td>Due</td>
                <td class="warning">Pending</td>

                <!-- Classes available for status text color warning,success,danger,primary -->
                <a href="./index?detail_customer=">
                    <td class="primary"> <a href="./index?detail_customer="> Details </a> </td>
                </a>

            </tr>
            <tr>
                <td>iPhone 12</td>
                <td>0001</td>
                <td>Due</td>
                <td class="warning">Pending</td>

                <!-- Classes available for status text color warning,success,danger,primary -->
                <a href="./index?detail_customer=">
                    <td class="primary"> <a href="./index?detail_customer="> Details </a> </td>
                </a>

            </tr>
        </tbody>
    </table>
    <a href="javascript:void(0);" class="show-all-text">Show All</a>
</div>

2nd Page

<div class="recent-orders">
    <h2>Customers</h2>
    <table id="recent-orders-table">
        <thead>
            <tr>
                <th>Customer Id</th>
                <th>Customer Name</th>
                <th>City</th>
                <th>Contact</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>1</td>
                <td>UZAIR</td>
                <td>Lahore</td>
                <td class="success">03233337187</td>

                <!-- Classes available for status text color warning,success,danger,primary -->

                <td class="primary"> <a class="detail_c_each" href="./index?detail_customer=31"> Details </a> </td>


            </tr>
            <tr>
                <td>2</td>
                <td>UZAIR</td>
                <td>Lahore</td>
                <td class="success">03233337187</td>

                <!-- Classes available for status text color warning,success,danger,primary -->
                <td class="primary"> <a class="detail_c_each" href="./index?detail_customer=31"> Details </a> </td>

            </tr>
            <tr>
                <td>3</td>
                <td>UZAIR</td>
                <td>Lahore</td>
                <td class="success">03233337187</td>

                <!-- Classes available for status text color warning,success,danger,primary -->
                <td class="primary"> <a class="detail_c_each" href="./index?detail_customer=32"> Details </a> </td>

            </tr>

        </tbody>
        <tbody class="hidetbody">
            <tr>
                <td>1</td>
                <td>UZAIR</td>
                <td>Lahore</td>
                <td class="success">03233337187</td>

                <!-- Classes available for status text color warning,success,danger,primary -->

                <td class="primary"> <a class="detail_c_each" href="./index?detail_customer=31"> Details </a> </td>


            </tr>
            <tr>
                <td>2</td>
                <td>UZAIR</td>
                <td>Lahore</td>
                <td class="success">03233337187</td>

                <!-- Classes available for status text color warning,success,danger,primary -->
                <td class="primary"> <a class="detail_c_each" href="./index?detail_customer=31"> Details </a> </td>

            </tr>
            <tr>
                <td>3</td>
                <td>UZAIR</td>
                <td>Lahore</td>
                <td class="success">03233337187</td>

                <!-- Classes available for status text color warning,success,danger,primary -->
                <td class="primary"> <a class="detail_c_each" href="./index?detail_customer=32"> Details </a> </td>

            </tr>

        </tbody>
    </table>
    <a href="javascript:void(0);" class="show-all-text">Show All</a>
</div>

My All JS Code

$(document).ready(function () {
  let sideMenu = document.querySelector("aside");
  let menuBtn = document.querySelector("#menu-btn");
  let closeBtn = document.querySelector("#close-btn");
  let themeToggler = document.querySelector(".theme-toggler");
  let detailCustomerEach = document.querySelectorAll(".detail_c_each");
  let sidebar_a = document.querySelectorAll(".sidebar_a");
  let alerts = document.querySelectorAll(".alert");

  // hide  alerts
  $(".alert-success").hide();
  $(".alert-danger").hide();

  $(".hidetbody").hide();

  // show .hidetr when click on show-all

  $(".show-all-text").click(function () {
    $(".hidetbody").show();

    // toggle the text of #show-all
    $(".show-all-text").text(function (i, text) {
      return text === "Show All" ? "Hide" : "Show All";
    });

    // toggle class of .hidetr
    $(".hidetbody").toggleClass("show-all");
    // if tbody has class show-all than show all tr
    if ($("tbody").hasClass("show-all")) {
      $(".hidetbody").show();
    } else {
      $(".hidetbody").hide();
    }
  });

  // slide the menu for mobile
  $(menuBtn).click(function () {
    sideMenu.style.display = "block";
    $(sideMenu).removeClass("animate__animated animate__slideOutLeft");
    $(sideMenu).addClass("animate__animated animate__slideInLeft");
  });

  $(sidebar_a).click(function (e) {
    // load another page without reloading

    if ($(sidebar_a).hasClass("active")) {
      $(sidebar_a).removeClass("active");
    }

    e.preventDefault();
    $(this).addClass("active");
    setTimeout(() => {
      let url = $(this).attr("data-href");
      // show page content and change the url
      $(".recent-orders").load(url + " .recent-orders", function () {
        window.history.replaceState(null, null, url);
      });
    }, 500);
    $(".recent-orders").load("./inc/preloader.html");
  });

  $("form").on("submit", function (e) {
    e.preventDefault();
    var form = $(this);
    var formData = form.serialize();

    $.ajax({
      type: "POST",
      url: form.attr("action"),
      data: formData,
      success: function (data) {
        $(".alert-success").show();
        // hide alerts after 3 seconds

        $(".alert-success").fadeOut(3000);
      },
      error: function (data) {
        $(".alert-danger").show();
      },
    });
  });

  // close the menu for mobile
  $(closeBtn).click(function () {
    // sideMenu.style.display = "none";
    $(sideMenu).removeClass("animate__animated animate__slideInLeft");
    $(sideMenu).addClass("animate__animated animate__slideOutLeft");
  });

  $(".add-product").click(function () {
    window.open("./index", "_self");
  });

  // change theme
  $(themeToggler).click(function () {
    document.body.classList.toggle("dark-theme-variables");
    themeToggler.querySelector("span:nth-child(1)").classList.toggle("active");
    themeToggler.querySelector("span:nth-child(2)").classList.toggle("active");
  });
});

Update Parent State from Child Component and send back response to child

I have two components,

Component A –

const handleLike(id) {
.....
handle the logic for the button and setting the state
}

<ComponentB handleLike={handleLike}/>

Component B –

return(
    <>
        <button onclick={props.handleLike("123")}/>
    </>
)

<ComponentB handleLike={handleLike}/>

This code works, but it changes the state in the Component A and the state is not updated in the Component B

How can this be solved?