npm ERR! Missing script: “eslint”. even after adding lint scrip [closed]

kept on getting the above error message in github workflow even after installing eslint package and adding lint script in package.json. If anyone has ever encountered this, what helped you? help me get unstuck. Thanks!
this is what it shows me on github
and here is what I have on package.json

I tried different variation of lint like “eslint .” or “esling.js” but that didn’t seem to change the issue

How to toggle a checkbox when clicking in a row?

I am trying to toggle the checked property of a checkbox when I click on a table row but so far with my solution I am unable to achieve it. This is how the HTML looks like:

<table id="chkContainer">
  <tr id="row-1">
    <td><input type="checkbox" value="1"></td>
    <td>1st Row</td>
    <td>Not clickable</td>
  </tr>
  <tr id="row-2">
    <td><input type="checkbox" value="2"></td>
    <td>2nd Row</td>
    <td>Not clickable</td>
  </tr>
  <tr id="row-3">
    <td><input type="checkbox" value="3"></td>
    <td>3rd Row</td>
    <td>Not clickable</td>
  </tr>
</table>

and here is the jQuery code I have built:

$(function() {
  $("#chkContainer tr > td").on("click", function() {
    const tr = $(this).closest('tr')
    const chk = tr.find('input:checkbox').prop("checked", true);

    tr.toggleClass('red', chk.checked);
  })
})

What is not working? I can check the checkbox when clicking the row for the first time but when I click the same row once again the checkbox remains checked. I am pretty sure my issue is this line: $(":checkbox[value=" + id + "]").prop("checked", true) since I am always setting it to true but I am not sure how to set it to false when the same row gets a new click.

How do I avoid this behavior from happening if I click in the last td which generally contains buttons or user actions?

I could not find any solution to this or I am very bad at searching on Google 😐

here is a Fiddle so you can play with it.

API pagination with perPage and page when there is no offset support

I have a requirement where I have to make an API request to fetch/load new items from client side for each button click.
Initial page load loads some items and new items fetched from clientside api call should offset those items. However the API doesnt support offset. How to achieve this using page and perPage.

For ex: Say I have 8 existing items on the page. new items on click of button should load 10 items every time (items 9-18, 19-28, 29-38 etc).
How do i make this work using page and perPage, without making multiple calls for each button click?

I made it work with multiple api requests for each button click but I’m trying to see if there is an effective way to do that using single api call for each button click.

Why FiveM script client callback does not receive the right variable type?

I am creating a FiveM script and I need to get the source citizenId and I am having a problem with what my client callback function receives from a server event. The server event return a string and I know it for a fact because I tried to print the variable and it’s type in the console and it was correct. But the second it goes to the function in which it got returned, it’s not a string anymore, it’s an “object”.

For minimal reproduction,

Here is the JS script that call my client callback on a button click (Working):
html/script.js

const createOrg = () =>{
    var orgName = document.getElementById("neworg-name-input").value;
    fetch(`https://${GetParentResourceName()}/orgcreateCb`, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json; charset=UTF-8',
        },
        body: JSON.stringify({
            organizationName: orgName,
        })
    }).then(resp => resp.json()).then(resp => console.log(resp));
    //console.log(orgName);
};

Here is the server event that return the string (Working):
server/main.lua

RegisterServerEvent('getPlayerCitizenId')
AddEventHandler('getPlayerCitizenId', function(cb)
    local currentCitizenId = QBCore.Functions.GetPlayer(source).PlayerData.citizenid
    cb(tostring(currentCitizenId))
end)

Here is the client callback that need what the server event returns (Not working):
client/main.lua

RegisterNUICallback("orgcreateCb", function(data, cb)
    TriggerServerEvent('getPlayerCitizenId', function(citizenId)
        print('Citizen ID:', citizenId)
    end)
end)

On the print I get -> “SCRIPT ERROR: error object is not a string”

How do reveal a hidden div onclick?

Hello all I have a square div with a hidden video file behind it. When the user clicks the square, the square gets removed and after

button.onclick = remove;

function remove(){
    this.remove();
    
}

let video = document.querySelector (".video");

function showHide(){
    video.classList.toggle("hide");
}
*{
    padding:0;
    margin:0;
}

.parent{
    width:100vw;
    height:100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}


.video{
    border-radius: 20px;
    z-index: 1; 
}
.hide{
 display:none;
}
#button{
    width:200px;
    height:200px;
    position: absolute;
    background-color:orange; 
    border-radius: 20px;
    z-index: 2; 
    top:50%;
    left:50%;
    transform: translate(-50%,-50%);
    cursor: pointer;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>video reveal </title>
    <link rel="stylesheet" href="styles.css">

</head>
<body>
    <div class="parent">
        
            <iframe class="video hide" width="560" height="315" src="https://www.youtube.com/embed/q3WC-X7xDNo?si=E9MI_wcGtmrNyx3J" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

        <div id="button" onclick="this.remove();showHide();">
        </div>    
       
        
    </div>
    <script src="index.js"></script>
    
</body>
</html>

I want the video file to be revealed and autopay. I am currently using the toggle method to try to reveal the video but it is not working. Can anyone help?

how to authenticate that a user must be logged in before he can give a like or comment on a post

I have a protected route which i made where my reaction component contains likes, repost and comment, so i protect only be accessed by users who are logged in

this is my code below

I was expecting from that above that any one liking a post will have to be logged in or if not logged in will be asked to login first before his/her like will be counted.

side effect in the form of a black screen when switching video tag video

I want to download some videos from the network and play them in a circle. I need to pre-download them so that when I play, I do not see any delays

I have some not perfect component on which I test the video:

import video1 from './../../assets/videos/2s1.mp4';
import video2 from './../../assets/videos/2s2.mp4';
import video3 from './../../assets/videos/2s3.mp4';

const videos = [video1, video2, video3];

    const VideoPlayer = ({
                             videos = [],
                             disablePictureInPicture = true,
                             loop = false,
                             muted = true,
                             playsInline = true,
                             preload = 'auto',
                             autoPlay = true,
                             controls = true,
                             width = '100%',
                             ...props
                         }) => {
        const ref = useRef();
        const [currentVideoIndex, setCurrentVideoIndex] = useState(0);
    
    const handleVideoEnd = () => {
        setCurrentVideoIndex((currentVideoIndex + 1) % videos.length);
    };
    
    const handleSeeked = () => {
        ref.current?.play();
    };
    
    const onCanPlayThrough = () => {
        ref.current?.play();
    };
    
    return (
        <video
            ref={ref}
            src={videos[currentVideoIndex]}
            preload={preload}
            width={width}
            muted={muted}
            autoPlay={autoPlay}
            disablePictureInPicture={disablePictureInPicture}
            playsInline={playsInline}
            controls={controls}
            onEnded={() => {
                handleVideoEnd();
            }}
            controlsList="nofullscreen nodownload noremoteplayback noplaybackrate foobar"
        >
        
        </video>
    );

};

export default VideoPlayer;

between the videos I see a black screen. And this is not very noticeable in the browser of my laptop but it is very noticeable on mobile devices for which I develop an application

enter image description here

i tried to use the ready-made component of the player https://github.com/CookPete/react-player?tab=readme-ov-file but the problem is the same

for preload video I tried to download and cache it via tag link using helmet.

<HelmetProvider>
    <Helmet>
        <link rel="preload" href="https://file-examples.com/wp-content/storage/2017/04/file_example_MP4_480_1_5MG.mp4" as="video" type="video/mp4" />
    </Helmet>
</HelmetProvider>

but I don’t see downloading this video in the network tab

ApexCharts bars are too thin on rangeBar type

So, we rely on ApexCharts v3.37.2 to render list of workers currently assigned to various projects. We use the rangeBar type to represent the data.

The problem is when we add more than a dozen items to the Y axis, the bars on the main area get so thin that they don’t look easily detectable.

Is there any way that we can have a minimum thickness for bars without making them overlap or hide behind each other? We used stroke but were not happy with results due to overlapping bars. Some of them were completely hidden.

Also, is there a smart way of assigning proportionate height to each entry/item on the Y axis, so that if one project has more bars, it will get more space inside the viewport and vice-versa?

In short, how best to render a range bar that is over populated with bars across 1-6 months or so?

Here is an example of what we have, and thank you for your help.

chart

My websocket communication between backend and frontend in the nodejs server is not working

code on server:

exports.getConnect = (req, res, next) => {
...

    Sensor.findById(senId)
        .then(sensor => {
            if (!sensor) {
                return next(new Error('Sensor not found.'));
            }
            if (sensor.userId.toString() !== clientId.toString()) {
                return res.status(403).send('Unauthorized');
            }

            const { addresIp, port, name } = sensor;
            const topic = name;

            const brokerUrl = `tcp://${addresIp}:${port}`;
            const client = mqtt.connect(brokerUrl);

            // Tworzenie serwera WebSocket

            const PORT = 8080;

            const webSocketServer = new WebSocket.Server({ port: PORT });

            webSocketServer.on('connection', function connection(ws) {
                ws.clientId = clientId; // Przypisanie identyfikatora klienta do sesji WebSocket
                console.log(`WebSocket client connected with ID: ${ws.clientId}`);
            });

            client.on('connect', () => {
                console.log('Connected to MQTT broker');

                
                client.subscribe(topic, (err) => {
                    if (err) {
                        console.error('Error subscribing to topic:', err);
                    } else {
                        console.log('Subscribed to topic:', topic);
                    }
                });
            });

            res.redirect('/');

            client.on('message', (receivedTopic, message) => {
                
                console.log('Received message:', message.toString());
            
                
                webSocketServer.clients.forEach(function each(client) {
                    if (client.readyState === WebSocket.OPEN && client.clientId.toString() === clientId.toString()) {
                        console.log('Client ID AUUUU:', client.clientId);
                        const dataToSend = {
                            sensorId: senId, // Identyfikator czujnika
                            msg: {
                                date: new Date().toISOString(), 
                                value: parseFloat(message.toString()) 
                            }
                        };
                        client.send(JSON.stringify(dataToSend));
                    }
                });
            });
...
};

In general, the server side works and I displayed how far the code is executed and reaches the send function but I cannot read the message at all, this function is in the controller and the recipient, i.e. the frontend, is in views

JS frontend code in html:

    const socket = new WebSocket("ws://localhost:8080");
    
    socket.addEventListener("open", () =>{
        console.log("We are connected");
    });
      
    socket.onmessage = function(event) {
        console.log("Message from server ", event.data);
    };

nothing is displayed on the client side as if the communication is not working and I know that the code is working up to the sending line

NextAuth – Unexpected token < in JSON at position 0

Hi I’m trying to make a login system for my application. When I use the login function the application gives an error. I couldn’t find a solution yet hope this way we can fix it.

I’ve checked the NEXTAUTH_URL and NEXTAUTH_SECRET but they seem to be okay.

NEXTAUTH_URL=http://localhost:3000/api/auth
NEXTAUTH_SECRET=myApp

My [...nextauth] route is in the correct location /src/app/api/auth/[...nextauth]/route.js. Ive used the default credentials example.

import NextAuth from "next-auth/next";
import CredentialsProvider from "next-auth/providers/credentials";

const handler = NextAuth({
    providers:[
      CredentialsProvider({
        // The name to display on the sign in form (e.g. 'Sign in with...')
        name: 'Credentials',
        // The credentials is used to generate a suitable form on the sign in page.
        // You can specify whatever fields you are expecting to be submitted.
        // e.g. domain, username, password, 2FA token, etc.
        // You can pass any HTML attribute to the <input> tag through the object.
        credentials: {
          username: { label: "Username", type: "text", placeholder: "jsmith" },
          password: { label: "Password", type: "password" }
        },
        async authorize(credentials, req) {
          // You need to provide your own logic here that takes the credentials
          // submitted and returns either a object representing a user or value
          // that is false/null if the credentials are invalid.
          // e.g. return { id: 1, name: 'J Smith', email: '[email protected]' }
          // You can also use the `req` object to obtain additional parameters
          // (i.e., the request IP address)
          const res = await fetch("http://localhost:3000/api/login", {
              method: 'POST',
              body: JSON.stringify(credentials),
              headers: { "Content-Type": "application/json" }
          })
          const user = await res.json()

          // If no error and we have user data, return it
          if (res.ok && user) {
              return user
          }
          // Return null if user data could not be retrieved
          return null
        }
      })
    ]
});

export { handler as GET, handler as POST }

And this is the button I use to call the login page. It’s just the default login page that comes with next-auth.

<Button color="primary" variant="flat" className="text-base" onClick={() => signIn()}>
          SignIn
</Button>

Anybody who had a similar issue or can help me fix this?

Regex match Greek words ignoring diacritics

I was wondering how to check if two greek words match ignoring the diacritic mark (‘). For example I want the words Μήλο and Μηλο to match.

Right now I have created this regex (?![^<>]*>)exampleWord that I use to find inside a string if a word is matching the exampleWord along with some more rules. How can I extend this regex to also match the above rule?

Undefined phrases from annyang in callback result

I am using annyang library to my microphone, but I get undefined in my audio:

I think the user said: undefined
But then again, it could be any of the following: undefined

<script src="https://cdnjs.cloudflare.com/ajax/libs/annyang/2.6.1/annyang.min.js"></script>

This is my code:

if (annyang) {
            
    annyang.addCallback('result', function(phrases) {
        console.log("I think the user said: ", phrases);
        console.log("But then again, it could be any of the following: ", phrases);
    });

    annyang.start({ autoRestart: true});
            
}

Can someone explain this to me? I’ve been stuck on this code for a couple of hours now

So basically im following Jonas’s course on JS, and ive stumbled upon this challenge.
I cant get my mind around it. Can someone help me?
Basically a textbox where we put values like underscore_caSe or HellO_WORld etc.
and we need it to be in camelCase when we press a button.Here is the code!

This code works i just need someone to explain it to me.
Im pretty new to coding, i just started 3 months ago!

Get input data into Database

I want to get data from my 2 inputs when I click the button NEXT into my SQL Server database. I tried looking online for a solution but nothing works for me for some reason. I have already set up my database to accept remote connections. I have done same thing with C# web forms but its my first time leaning this deep into JavaScript and NodeJS. If someone can link me to a video or just explain what should I would really appreciate it.

Here is my HTML (you can just copy paste HTML and CSS to see how my website looks like but I don’t think it matters too much).

<!DOCTYPE html>
<html lang="en">
    <html xmlns="http://www.w3.org/1999/xhtml"></html>
<head>
    <script src="script3.js"></script>
    <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel="stylesheet">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Page</title>
    <link rel="stylesheet" href="style2.css">
</head>
<body>

<div class="background-image"></div>

<div class="login-box">
    <div class="class">
        <div class="image">
            <img src='img/Google_2015_logo.svg.png'>
        </div>
        <h1 style="margin: 0px; font-size: 25px;">Sign in</h1>
        <x1> Use your Google Account</x1>
        
            <div class="inputs">
                <input type="text" id="Email" name="Email" placeholder="Email or phone">
                <input type="password" id="Password" class="pass" name="Password" placeholder="Password">
                <input type="submit">
                <x2 style="color: blue; margin-bottom: 5px;">Forgot email?</x2>
            </div>
        </form>
       
      
        <small>Not your computer? Use a private browsing window to sign<br> in.<span style="color: blue;"> Learn more<span></small>
        <div class="floater">
            <x3> Create Account</x3>
            <button type="text" id="nextButton" onclick="DataBase()"> Next </button> <!-- Added an ID to the button -->
        </div>
        
    </div>
</div>
<!-- You can include script.js at the end of the body -->
<script src="script.js"></script>
</body>
</html>

Here is css

  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  margin-top: 10%;
}
.image {
  width: 90px;
  height: 30px;
}
img {
  width: 100%;
  height: 100%;
}
.class {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
  border: 1px solid rgb(214, 211, 211);
  border-radius: 10px;
  padding: 30px;
}
.inputs {
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding-right: 20px;
  padding-left: 20px;
}
h1,
x1,
x3,
x2,
small {
  font-family: "Roboto", sans-serif;
  font-weight: 400;
  font-style: normal;
}
.floater {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
button {
  width: 90px;
  height: 35px;
  background-color: rgb(18, 76, 202);
  border: 0px;
  border-radius: 5px;
}
input {
  background-color: white;
  border: 1px solid rgb(214, 211, 211);
  height: 50px;
  width: 350px;
  padding-left: 10px;
  font-size: 15px;
}