JQuery is not working: Uncaught ReferenceError: JQuery is not defined | WordPress

I am looking to get an alert when click on submit button, but getting error when page loads: Uncaught ReferenceError: JQuery is not defined
I’m beginner at front-end development, trying to learn javascript and JQuery, can anyone help to fix? Also what went wrong?

html code:

<section>
  <div>
    <div class="row text-center">
      <div class="col-sm-12 text-center">
        <div class="row">
          <div class="col-sm-8 col-sm-offset-2">
            <div>
              <h2>CONTACT US</h2>
            </div>
            <form id="contactForm">
              <input type="hidden" data-form-email="true">
              <div class="form-group">
                <input type="text" class="form-control" name="name" required="" placeholder="Name*" data-form-field="Name">
              </div>
              <div class="form-group">
                <input type="email" class="form-control" name="email" required="" placeholder="Email*" data-form-field="Email">
              </div>
              <div>
                <input type="submit" id="submit" name="submit" class="btn btn-lg btn-danger">
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>

Script:

<script>
    JQuery('#contactForm').submit(function(){
    event.preventDefault();
    alert('Working');
    });
</script>

When I checked page source:

<script src='https://yourdevweb.com/testing/wp-includes/js/jquery/jquery.min.js?ver=3.6.0' id='jquery-core-js'></script>
<script src='https://yourdevweb.com/testing/wp-includes/js/jquery/jquery-migrate.min.js?ver=3.3.2' id='jquery-migrate-js'></script>

Node js – Node Path : How to find the Node Path on a windows machine

vscode settings for extension Ponicode

Hi,

Please see the attached picture for the settings of the extension Ponicode – used to automate unit tests

How do I find the Node Path for node js on my windows machine?

Node path for the test runner and tasks is required, and if absent node is looked up in PATH

However the default is not happening and I think I need to enter the Node path in the box myself

I have node V16.13 (LTS Support)
Node is working – I confirmed with using node to start a server on localhost as a test
I am not sure what “set the nodePath in your settings” means
I’ve uninstalled and re-installed Ponicode and rebooted my computer
I’ve contacted the Ponicode Team about this error too

Thanks,

Adding cookies to an existing site. (Asp.Net)

there is an active site available. I have added a cookie to this site. When the site opens, a button like accept appears and I can accept and close it. My question is how can I set the duration of this? Where are these cookie files? I see Js Document.cookie videos. They write to Script.js files. Where do they copy this file? I would be very happy if you answer.

The site is currently active.

I copied the ready-made script code from the site called Mosono and copied it to my default.aspx page. So what should I do next? How do I set the duration of this cookie? Where is this data stored? I couldn’t find it in AppData Local folder for Chrome. Or rather, is it a cookie? I am providing the link for you to view the site. I would be glad if you help.

http://www.kamerholding.com.tr

Why my custom css doesn’t apply for mapbox?

I have issue customizing my popup windows with mapboxgl.
No matter what i do in custom info_windows.scss it’s always display to default settings that are Inherited from mapbox-gl.css
I tried added a class to the popup element using the following code:
new mapboxgl.Popup({ className: ‘popups’ }) .setLngLat(coordinates) .setHTML(description) .addTo(map);
but still doesn’t pick up customize css code apply on .popups class eventhough my class popups applied on the element.
Any clue how to make this work?

_info_windows.scss

.popup {
  border-radius: 15px;
  border-color: orange;
  border-style: solid;
  overflow-y: auto;
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  margin-bottom: 60px;
  padding-bottom: 25px;
  border: 2px solid #0b5cb2;
  box-shadow: 1px 1px 3px 0px rgb(0 0 0 / 55%);
  width: 100%;
}


init_mapbox.js

const addMarkersToMap = (map, markers) => {
  markers.forEach((marker) => {
    const popup = new mapboxgl.Popup({ className: 'popup' }).setHTML(marker.info_window); // add this

    new mapboxgl.Marker()
      .setLngLat([marker.lng, marker.lat])
      .setPopup(popup)
      .addTo(map);
  });
};


application.html.erb

    <script src='https://api.mapbox.com/mapbox-gl-js/v2.6.0/mapbox-gl.js'></script>
    <link href='https://api.mapbox.com/mapbox-gl-js/v2.6.0/mapbox-gl.css' rel='stylesheet' />


[enter image description here][1]


  [1]: https://i.stack.imgur.com/YY6kS.png

tradingview library allow symbol change: false not working

Trading view widget is working fine except one parameter allow_symbol_change: false,. I tried this and its not working at all.

Code: –

const widgetOptions: ChartingLibraryWidgetOptions = {
  symbol: this.props.symbol as string,
  allow_symbol_change: false,
  datafeed: Datafeed,
  interval: this.props.interval as ChartingLibraryWidgetOptions['interval'],
  container: this.props.container as ChartingLibraryWidgetOptions['container'],
  library_path: this.props.libraryPath as string,
  locale: getLanguageFromURL() || 'en',
  disabled_features: ['use_localstorage_for_settings'],
  enabled_features: ['study_templates'],
  charts_storage_url: this.props.chartsStorageUrl,
  charts_storage_api_version: this.props.chartsStorageApiVersion,
  client_id: this.props.clientId,
  user_id: this.props.userId,
  fullscreen: this.props.fullscreen,
  autosize: this.props.autosize,
  theme: 'Dark',
  studies_overrides: this.props.studiesOverrides,
  timeframe: '1w',
}

Is ther any other method for this also like disable_feature

Node js Child process event emitter vs callbacks

Is there any difference between attaching callbacks or event listeners for child process in nodejs. like –

const execute = require('child-process').exec;
const process = execute('ping -n 1 www.google.com'); // or ping -c 1 www.google.com for mac

process.stdout.on('data', data => {
    console.log(data)
})  

In the above code i am using event listener for the output and i am getting stdout data in windows but can’t get the output in macos. But if i use callback like –

const execute = require('child-process').exec;

execute('ping -c 1 www.google.com', (error, stdout, stderr) => {
   console.log(stdout);
})

I am getting the output data in both windows and mac.. Is there any difference using callback or event listeners(both are asynchronous)?

How to place widgets next to each other for photography website

I am using a site to create before and after slider widgets, I than want to use the widget for my website. The code is:

<script src="https://apps.elfsight.com/p/platform.js" defer></script>
<div class="elfsight-app-738dcbf9-2e16-40e0-8b87-d21a5fa6a201"></div>

This results in the two widgets being in a vertical line, how do
I make it so the widgets are next to each other in horizontal line?

Converting geoJson to shapfile as batch using GDAL ogr2ogr in Node JS

I want to convert all the geojsons in a file to shapefiles in a single batch using ogr2ogr library in NodeJS. I know it can be done directly from the terminal using the gdal cli, but I want do know how to do it in Node. Thanks alot!

**I have this code to convert a single file:

// Using CommonJS modules
const ogr2ogr = require('ogr2ogr').default;
const fs = require('fs') ;

// Promise API
(async() => {

   

  // Convert path to GeoJSON.
  let {data} = await ogr2ogr('/Users/MihaiB/Desktop/test_josm/test22.geojson' );
  console.log(data);

  
 
  let {stream} = await ogr2ogr( data, {format: 'ESRI Shapefile'}, {destination:'/Users/MihaiB/Desktop/shapefile2.shx'});
    console.log(stream)

   
        
  
})()





Leaflet Center Marker Numbers

Does anyone have an idea how to center numbers inside markers? This is the current situation.

Marker with Number

Creating a Marker

    return L.divIcon({
  className: "green-icon",
  iconSize: [25, 41],
  iconAnchor: [10, 44],
  popupAnchor: [3, -40],
  html: markerNumber,
});

CSS

.green-icon {
 background-image: url("../GreenIcon.png");
 background-repeat: no-repeat;
 margin: 0 auto;
 text-align: center;
 color: white;
 font-weight: bold;
 }

How to sort an array of object given multiple conditions?

Given an array of objects as such –

item= [
{
 "id": "1",
 "name": "Book",
 "price": "100",
 "status" : "Disabled"
},
{
 "id": "2",
 "name": "Pen",
 "price": "0",
 "status" : "Enabled"
},
{
 "id": "3",
 "name": "Pencil",
 "price": "20",
 "status" : "Enabled"
},
{
 "id": "4",
 "name": "Tape",
 "price": "50",
 "status" : null
},
{
 "id": "5",
 "name": "Paper",
 "price": "10",
 "status" : "Enabled"
},
...
];
if (item.price == '0' || item.status!= 'Enabled'): the item is greyed out. 

How can the item be sorted such that the non greyed items are shown first and then the greyed out items

array.sort() works for prices but don’t seem to work for status

How to connect two components in a same component created on click of add button

I am creating multiple counters on click and I want to connect the two counters, When I increase the value in the first counter it should automatically decrease in the second counter. Can you suggest any solution where I can communicate with multiple counters as I can generate multiple counters on click?

import React from "react";
import ReactDOM from "react-dom";

const Counter = ({ value, onIncrement, onDecrement, hideIncrement }) => {
  return (
    <div>
      <span>{value}</span>
      {value > 0 && (
        <button
          onClick={() => {
            onDecrement();
          }}
        >
          -
        </button>
      )}
      {hideIncrement === false && value < 10 && (
        <button
          onClick={() => {
            onIncrement();
          }}
        >
          +
        </button>
      )}
    </div>
  );
};

const Counters = () => {
  const [counters, setCounters] = React.useState([4, 0, 0, 5]);

  const sum = counters.reduce((acc, item) => acc + item, 0);

  return (
    <div>
      <p>Sum: {sum}</p>
      <button
        onClick={() => {
          setCounters([...counters, 0]);
        }}
      >
        Add counter
      </button>
      <br />
      <div>
        {counters.map((value, index) => (
          <Counter
            value={value}
            hideIncrement={sum >= 20}
            onIncrement={() => {
              const countersCopy = [...counters];
              countersCopy[index] += 1;
              setCounters(countersCopy);
            }}
            onDecrement={() => {
              const countersCopy = [...counters];
              countersCopy[index] -= 1;
              setCounters(countersCopy);
            }}
          />
        ))}
      </div>
    </div>
  );
};

const rootElement = document.getElementById("root");
ReactDOM.render(<Counters />, rootElement);

“user validation failed: passsword: Path `passsword` is required.”

Here is my Mongoose model:

    const mongoose=require('mongoose')

const userSchema=new mongoose.Schema({
    firstName:{
        type:String,
        required:true
    },
    middleName:{
        type:String,
    },
  
    lastName:{
        type:String,
        required:true,
    },
    passsword:{
        type: String,
        required: true,
    },
    email:{
        type:String,
        unique:true,
        sparse:true
    },
    phoneNumber:{
        type:Number
    },
    address:{
        permanentAddress:String,
        temporaryAddress:[String]
    },
    gender:{
        type:String,
        enum:['male','female','others']
    },
    dob:{
        type:Date
    },
    country:{
        type:String,
        default:'Nepal'
    },
    image:{
        type:[String]
    },
    role:{
        type:Number,
        default:2
    },
    isArchived:{
        type:Boolean,
        default:false
    },
    status:{
        type:String,
        enum:['active','inactive','frequent'],
        default:'active'
    },
    passwordResetTOken:String,
    passwordResetTokenExpiry:String
})


const userModel=mongoose.model('user',userSchema)
module.exports=userModel

The controller is:

    function insert(data){
    return new Promise(function(resolve,reject){
        const newUser=new userModel
        newUser.password = passwordHash.generate(data.password)
        newUser.firstName=data.firstName
        newUser.lastName=data.lastName
        newUser.dob=data.dob
        console.log("new user is",newUser.password)
        console.log("mapped user is",newUser)
        newUser.save(function(err,done){
             if(err){
                 return reject(err)
             }
             console.log("user is",done)
             resolve(done)
         }) 
    })

}

I am getting error:


                    "name": "ValidatorError",
                "message": "Path `passsword` is required.",

But req.body has:

     {
  firstName: 'rajiv',
  lastName: 'dahal',
  password: 'admin',
  dob: '2021/03/03'
}

What is my mistake?

Shoutcast artwork image

I am trying to create a custom artwork image using shoutcast server information and api services, that updates itself automatically about the title and artwork of the current streaming audio/artwork.

I would like to put the artwork on my website in circle 150x150px with blue border of 7px and with small cube 50x50px into cube png/jpg image for radio channel.

I would like visitors to see the current streaming audio information: singer name – song title and artwork from singer.

Shoutcast does have an API but in some case i was using already some php codes and plugins but most of them didn’t recronize the artwork image only some players like luna player recronize all images but in my case i dont need player. I searched around internet and most of the answes for the shoutcast code etc i found on this site.

Also i try to find does anyone asking for the same solution like mine on this site but i didnt found any solution and thats why im asking for help/solution and how can i make that.

I know there are some PHP solution, but since I do not know the language I could not find out their solution how to do that.

Most of the people which i try to get help from other sites like freel**cer they first time listen for shoutcast server, most of them ask me does shoutcast has php asp or zlib extentions, most of them think that shoutcast is some php server.
Thats why i registered here and i hope guys you can help me.

Could please provide some examples or hints about how to get the current track title, artwork, even possibly the artwork image from some api service, and if artimage was not found to be shown by default radio logo?

Im showing example how I would like to make it.

Thanks in advance.

Uncaught TypeError: Cannot read properties of undefined (reading ‘items’)

I’m testing the call but I keep getting the error uncaught type Error. it says the error is when i call data.tracks.items.

It says the error is at Object.success, at i, at Object.fireWith, at z, at XMLHttpRequest

  console.log('hello world');

  $('form').submit(function(event) {
    event.preventDefault();
    
    let query = $('input').val();
    let context = $('input[name="context"]:checked').val();
    
    $.get('/search?' + $.param({context: context, query: query}), function(data) {
      $('#results').empty();
      $('input[type="text"]').val('');
      $('input').focus();
      
      data.tracks.items.forEach(function(track, index) {
        let trackSearch = "https://open.spotify.com/track/";
        let newElement = $('<a onClick="getFeatures(&apos;' + track.id + '&apos;)" target="_blank"></a><br>').text(track.name + '   |   ' + track.artists[0].name).attr('href', trackSearch + track.id);
        $('#results').append(newElement);
      });
    });
  });
}); ```