Deprecated: Class Jetpack_Geo_Location is deprecated since version 14.3 with no alternative available. in /home/everyuseful/public_html/wp-includes/functions.php on line 6114
Javascript Archives - EveryUseful

Facing a hard time installing Gulp?

If you are trying to install Gulp and you always get errors related to node-sass, here is a small tip that could fix it for you

Simply uninstall node-sass and install dart-sass

npm uninstall gulp-sass
npm install gulp-dart-sass

Then, update your Gulpfile.js to use gulp-dart-sass instead of gulp-sass for compiling Sass.

By following these steps, you should be able to resolve the compatibility issue with Node Sass and successfully run gulp watch without encountering the “Node Sass does not yet support your current environment” error.

How to get the current date as yyyy-mm-dd in Javascript

If you want to get the current date in the format of yyyy-mm-dd using Javascript you can do:

new Date().toISOString().split('T')[0];

Where new Date() gets the date as :
Fri Mar 11 2022 11:04:44 GMT+0200 (Eastern European Standard Time) {}

.toISOString() convert it to: 2022-03-11T09:03:38.056Z

and as we need only the date, we split it and get the first part by: .split(‘T’)[0]

How to use “OR” while searching in datatables js

If you want to search for any of multiple strings in datatables , you can use the regex option, here is an example

 table.columns( 3 ).search('string A| String B', true, false).draw();

3 is the index of the column you want to search

String A, String B are the 2 strings you want to search any of them

true: to indicate that you want to use regex

false : tell datatables not to use smart search option as it uses regex and may conflict with the regex you are using

How to center google map to current location using javascript

To center google map to current user location using js api, you first have to make your website a HTTPS site

if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function (position) {
        var pos = {
            lat: position.coords.latitude,
            lng: position.coords.longitude
    };
    
    map.setCenter(pos);
    }, function () {
        console.log('error gis');
    });
}

more details here