close other menus when one is clicked

everything i keep trying breaks it.
Help me close the other menus when one is clicked.
https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_collapsible

the maxHeight is confusing me with the nextElementSibling

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

sry bout the lorem, it said my question was too short

Need a simple code for my perosnal task management app project [closed]

I have created 3 pages; register.html, authentication.html and account.html (for login). i need a simple code in which user will register by entering Call Name, email and 4 digit PIN (for login) in register.html page. by clicking register, email must sent with 4 digit OTP and redirecting to authentication.html page where user will enter verification OTP. if successful, redirect to account.html where user can enter its created PIN login and can access the dashboard.

creating a HTML app using Javascript.

more detail/code will be provided.

Should the HTML5 dialog tag be used for a toggleable responsive navigation menu?

Overview

It is common practice to have the primary website navigation always visible on larger devices (desktop and tablet) and shown/hidden with a toggle button (“hamburger menu”) on smaller devices (mobile). Is it best practice to use the HTML5 dialog element for this type of responsive navigation?

Dialog Pros

  1. dialog elements include a native keyboard trap. When a dialog is open, the tab index is isolated to the contents of the dialog, greatly improving the keyboard navigation experience.

  2. dialog elements include native functionality to close model with the escape button.

  3. dialog elements include native functionality to restore focus to the previously focused element when the modal is closed.

  4. dialog elements include native functionality for a backdrop behind the modal.

  5. dialog elements convey the intention of element to the browser allowing the browser to potentially render an element in the best possible way for the device. For example, select elements are rendered different on desktop browser than mobile browsers.

Dialog Cons

  1. There could be SEO implications to placing the primary navigation in a dialog element. In an effort to circumvent possible consequences, the dialog element includes the open attribute.

  2. The dialog element is technically never opened on larger devices. Instead, the dialog element is set to display: block. If the dialog is opened (dialog.show()) when the browser width increases, it causes the focus to change. The `display:block; hack, circumvents the issue. This a typical implementation could cause issues on some devices.

Example

    const dialog = document.querySelector('header dialog');
    const header = document.querySelector('header');

    function resize() {
      if (!window.matchMedia('(max-width: 640px)').matches) {
        dialog.close();
      }
    }

    dialog.removeAttribute('open');
    window.addEventListener('resize', resize);
    resize();

    document.querySelector('.open').addEventListener('click', () => {
        dialog.showModal();
    });

    document.querySelector('.close').addEventListener('click', () => {
        dialog.close();
    });
body {
      margin: 0;
    }

    main {
      padding: 1rem;
    }

    dialog::backdrop {
      background-color: rgba(0, 0, 0, 0.75);
    }

    header dialog {
      width: auto;
      height: auto;     
      border: none;
      padding: 1rem;
      background-color: #333;
      color: #FFF;
    }

    header dialog a {
      color: #FFF;
    }
      
    header ul {
      list-style: none;
      margin: 0;
      padding: 0;
      display: flex;
      gap: 1rem;
    }
    
    @media (min-width: 641px) {
      header dialog {
        position: static;
        display: block; /* Force closed dialog to be visible on larger devices */
        margin: 0; /* Necessary to fix niche rending bug when going from narrow to wide with an open dialog */
      }
      
      header .close,
      header .open {
        display: none !important;
      }
    }
    
    @media (max-width: 640px) {
      header dialog {
        max-width: none;
        max-height: none;
        margin: 0;
        width: auto;
        padding: 1rem;
        text-align: center;
      }

      header ul {
        flex-direction: column;
        margin-bottom: 1rem;
      }
    }
<header>
  <dialog open> <!-- dialog is set to open in case search engines ignore closed dialogs -->
    <nav>
      <ul>
        <li><a href="#">Home</a></li>
        <li><a href="#">About</a></li>
        <li><a href="#">Contact</a></li>
      </ul>
    </nav>
    <button class="close">Close</button>  
  </dialog>
  <button class="open">Menu</button>
</header>

CSS Transformation lag [closed]

I am making a game where you follow the arrows by clicking on them. I am planning on placing them in the DOM through pure JS and I’m going to add a transformation to each one through the style attribute.

My question is, would it be to laggy to rotate each arrow with this method (there will be at most 80 arrows)? And if so, is there another solution in pure JS and CSS?

Form Submit event listener disabled by Google Password Manager

I am unable to copy/paste code in to here because of the policies of the place I work, but here is the scenario. We are having an issue where a basic “submit” event listener is not working when Google Password Manager autofills in the username and password. If the user just clicks “Sign On” the submit event does not work. But if they click in to the username or password field and then click “sign on” the event works. My actual function name is not “runCode”, but for demo purposes..

signonForm.addEventListener('submit', runCode);

function runCode() {
if (obj == undefined) return false
return obj.function()
}

I can put a breakpoint inside the function and watch it run in every other scenario, but like I said above… if the login fields are prefilled and the user does not click in to either field the function does not run at all. Any thoughts on this one?

Using Flask and Yolov2 to Detect event headers in olympic dataset of 2024 on floating headers and camera tracking with area pointers in uLong32

I am using Yolov2 with embedded CVSS for detecting Floating UI elements within any video object instance; in the example found be*low, I was having the AI watch the Olympics, and detect any floating header box upon execution. Using this system, how would I detect:

“LONG WANG”

on the attached photo? Please keep function calls to a minimum as it creates extra memory on my system because I am using the x86 assembly baseloader for my CPU model.

Here is my code thus far:

import cv2 import numpy as np

net = cv2.dnn.readNet("yolov2.weights", "yolov2.cfg") layer_names = net.getLayerNames() output_layers = [layer_names[i[0] - 1] for i in net.getUnconnectedOutLayers()]

with open("coco.names", "r") as f:
    classes = [line.strip() for line in f.readlines()]

def detect_ui_elements(frame):
    height, width, channels = frame.shape
    blob = cv2.dnn.blobFromImage(frame, 0.00392, (416, 416), (0, 0, 0), True, crop=False)
    net.setInput(blob)
    outs = net.forward(output_layers)
    class_ids = []
    confidences = []
    boxes = []
    for out in outs:
        for detection in out:
            scores = detection[5:]
            class_id = np.argmax(scores)
            confidence = scores[class_id]
            if confidence > 0.5:
                center_x = int(detection[0] * width)
                center_y = int(detection[1] * height)
                w = int(detection[2] * width)
                h = int(detection[3] * height)
                x = int(center_x - w / 2)
                y = int(center_y - h / 2)
                boxes.append([x, y, w, h])
                confidences.append(float(confidence))
                class_ids.append(class_id)
    indexes = cv2.dnn.NMSBoxes(boxes, confidences, 0.5, 0.4)
    for i in range(len(boxes)):
        if i in indexes:
            x, y, w, h = boxes[i]
            label = str(classes[class_ids[i]])
            confidence = confidences[i]
            color = (0, 255, 0)
            cv2.rectangle(frame, (x, y), (x + w, y + h), color, 2)
            cv2.putText(frame, f"{label} {confidence:.2f}", (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
    return frame



And the #assembly which is the problem:

section .data
    video_file db 'video.mp4', 0
    buffer_size equ 4096
    buffer times buffer_size db 0

section .bss
    fd resb 4
    nread resb 4

section .text
    extern fopen, fread, fclose, puts
    global _start

_start:
    ; Open the video file
    push video_file
    push dword 'r'
    call fopen
    add esp, 8
    mov [fd], eax

    ; Read from the file into the buffer
    mov eax, [fd]
    push dword buffer_size
    push buffer
    push eax
    call fread
    add esp, 12
    mov [nread], eax

    ; Display a message (simplified, no actual frame handling)
    push buffer
    call puts
    add esp, 4

    ; Close the file
    mov eax, [fd]
    push eax
    call fclose
    add esp, 4

    ; Exit the program
    mov eax, 1
    xor ebx, ebx
    int 0x80

Why doesn’t this work?

My computer doesn’t seem to load the yolov2 model.

enter image description here

TypeScript 5.5.4: tsc –extendedDiagnostics not showing JavaScript and TypeScript code lines

I have a problem with TypeScript 5.5.4. When running “tsc –extendedDiagnostics”, the output no longer shows the lines of JavaScript and TypeScript code. I have checked my tsconfig.json file and cannot find any configuration that might be causing this. Has anyone else experienced this issue?

When running tsc –extendedDiagnostics, I expect the report to return the following:

Lines of Definitions: 105992
Lines of TypeScript: 18361
Lines of JavaScript: 13154
Lines of JSON: 50974
Lines of Other: 0

Designing a MongoDB Database for a Spreadsheet-like Application with Mergeable Cells

I’m working on a project to create a web application similar to Excel, where users can edit cells in a spreadsheet. I need help designing the database schema using MongoDB to support the following features:

  1. Editable Cells: Users should be able to edit the content of individual cells.

  2. Merge/Unmerge Cells: Users should be able to merge multiple cells into one and later unmerge them.

  3. Persistent State: The state of the cells (including merged cells) should be saved so that users see the same configuration when they return to the page|

    How can I design a MongoDB schema to handle these requirements effectively? Any advice on best practices or potential pitfalls would be greatly appreciated.

I was thinking about a collection for the spreadsheets and another for the cells, but I’m not sure how to represent merged cells. Here’s a rough idea:

{
  "spreadsheets": [
    {
      "_id": "spreadsheet_id",
      "name": "Spreadsheet 1",
      "cells": [
        {
          "cell_id": "A1",
          "content": "Data",
          "merged_with": ["A2", "A3"]
        },
        {
          "cell_id": "A2",
          "content": "",
          "merged_with": ["A1", "A3"]
        },
        {
          "cell_id": "A3",
          "content": "",
          "merged_with": ["A1", "A2"]
        }
      ]
    }
  ]
}

How to embed a google extension into the browser itself?

Screenshot of example

Currently for my extension I’m developing, I have to inject HTML into the webpage directly but I see this extension Amino and some others are independent from reloading webpages and live inside of the web browser itself. Is there a link to how to accomplish this because I cannot find it no matter how much I have searched.

What exactly is it about my RedirectAttributes object after Object Mapper maps JSON to my Spring model causing things to return status code 400?

My whole HTML/JSP is pretty standard with JSTL tags to help with databinding while I send off JSON via JS. Submit the form data as JSOn via Fetch and off it goes to the controller with @RequestBody annotations and a RedirectAttributes redirect. Every part of my layers within the application is working as it needs to. DTO, Service, Exceptions and so on. Once I actually try to addFlashAttributes to redirect to another URL, I get status code 400.

I’m going to start with my HTML/JSP, JS for the form data, show the configuration I have so far in my Servlet config class, and the controller. Then show the result page and the JS script src.


<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<!DOCTYPE html>
    <html lang="en">
        <head>
            <title> Ken </title>
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0">
            <meta name="description" content="Kenneth's thingy">
            <meta name="author" content="Kenneth Steven Lee">
            <link rel="stylesheet" type="text/css" href="/untitled2/URLtoResources/css/stuff.css">
            <script type="text/javascript" src="/untitled2/URLtoResources/javascript/stuff.js" defered></script>
        </head>
        <body>
            
    <h2> Please post student here </h2>
    <form:form name="getForm" action="postStudent" modelAttribute="student_guy" id="studentForm" method="post" enctype="multipart/form-data
        <p> 
        <form:input path="id" type="number" autocomplete="off" id="first" /> <form:errors path="id" /> </p>
        <p> 
        <form:input path="name" type="text" autocomplete="off" id="second" /> <form:errors path="name" /></p>
        <p> 
        <form:input path="mobile" type="number" autocomplete="off" id="third" /> <form:errors path="mobile" /></p>
    <p> 
        <form:input path="country" type="text" autocomplete="off" id="fourth" /> <form:errors path="country" /></p>
    <input type="submit" value="submit" id="studentFormThing" />
    </form:form>
        </body>
    </html>
"use script"

window.addEventListener("load", () =>
{
    const form_Issue = document.forms["getForm"];
    
    
    async function postData(form_Issue)
    {
        try 
        {
            const formData = new FormData(form_Issue);
                
            const thing = Object.fromEntries(formData);
            console.log(JSON.stringify(thing));
            
            const response = await fetch("/untitled2/something/postStudent", {
                method: "POST",
                headers: {
                    "Content-Type": "application/json"
                },
                body: JSON.stringify(thing)
            });
            const result = response.json();
            console.log("the shit is going " + result);
        }
        catch (e)
        {
            console.error(e);
        }
    }
    
    form_Issue.addEventListener("submit", (event) => {
        postData(form_Issue);
    })
    
})
package org.ken;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.ken.Service.StudentServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.List;
import org.hibernate.validator.internal.util.stereotypes.Lazy;
import org.ken.Model.Student;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.validation.Validator;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

@Controller
@RequestMapping("/something")
public class WebController {
    @Autowired
    ObjectMapper objectmapper;
    
    @Autowired
    StudentServiceImpl student_service;
    
    @GetMapping("/studentpost")
    public String getStudent(@ModelAttribute("student_guy") Student student_guy, Model model)
    {
        model.addAttribute("student_guy", student_guy);
        return "index";
    }
    
    @PostMapping(value = "postStudent", consumes = {"application/json", "multipart/form-data"})
    public String postStudent(@RequestBody String student_guy_two, BindingResult error, RedirectAttributes redirect) throws JsonMappingException, JsonProcessingException
    {
        Student student_guy_three = objectmapper.readValue(student_guy_two, Student.class);
        
        if (error.hasErrors())
        {
            return "error";
        }
        
        student_service.insert(student_guy_three);
        
        redirect.addFlashAttribute(student_guy_three);
      
        return "redirect:/something/student";
    }
   
    @GetMapping(value = "/student")
    public String getList(@ModelAttribute("student_guy") Student student_guy, Model model)
    {
        List<Student> test_list = /**/student_service.getStudent();
        model.addAttribute("student", test_list);
        return "result";
    }
}

package org.ken;

import jakarta.servlet.ServletContext;

import jakarta.servlet.annotation.MultipartConfig;
import org.apache.commons.dbcp2.BasicDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.format.FormatterRegistry;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
import org.springframework.web.accept.ContentNegotiationManager;
import org.springframework.web.context.annotation.RequestScope;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.*;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.resource.VersionResourceResolver;
import org.springframework.web.servlet.view.ContentNegotiatingViewResolver;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

import org.springframework.web.multipart.support.StandardServletMultipartResolver;

import java.util.ArrayList;
import java.util.List;

import javax.sql.DataSource;

@Configuration
@EnableWebMvc
@EnableTransactionManagement(proxyTargetClass = true)
@ComponentScan("org.ken")
public class WebServletInit implements WebMvcConfigurer {
    
    @Override
    public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.defaultContentType(MediaType.APPLICATION_JSON);
    }
    
    @Bean MappingJackson2JsonView jsonView()
    {
        MappingJackson2JsonView js = new MappingJackson2JsonView();
        js.setPrettyPrint(true);
        return js;
    }
    
    @Bean
    public ViewResolver contentNegotiationViewResolver(ContentNegotiationManager manager)
    {
        ContentNegotiatingViewResolver viewresolver = new ContentNegotiatingViewResolver();
        viewresolver.setContentNegotiationManager(manager);
        List<View> views = new ArrayList<>();
        views.add(new MappingJackson2JsonView());
        viewresolver.setDefaultViews(views);
        return viewresolver;
    }
    
    @Bean
    @Primary
    public ObjectMapper objectMapper() {
        final ObjectMapper mapper = new ObjectMapper();
        return mapper;
      }
    
    @Bean
    public MappingJackson2HttpMessageConverter objectMapper1(){
        MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
        Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
        converter.setObjectMapper(builder.build());
        return converter;
    }
    
     @Override
     public void configureDefaultServletHandling(DefaultServletHandlerConfigurer config)
     {
        config.enable();
     }
     
     
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) 
    {
          VersionResourceResolver versionResolver = new VersionResourceResolver().addContentVersionStrategy("/**");
          
          
          ResourceHandlerRegistration resourceRegistration = registry.addResourceHandler("/URLtoResources/**").addResourceLocations("/resources/");
    }
   
    @Bean
    public MultipartResolver multipartResolver() {
        return new StandardServletMultipartResolver();
    }

    @Bean
    public InternalResourceViewResolver getInternalResourceViewResolver(){
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setPrefix("/WEB-INF/");
        viewResolver.setSuffix(".jsp");
        return viewResolver;
    }
    
    
    
    @Bean
    public DataSource dataSource()
    {
        BasicDataSource dataSource = new BasicDataSource();

        dataSource.setUsername("root");
        dataSource.setPassword("REVOLVEr10101!");
        dataSource.setUrl("jdbc:mysql://localhost:3306/school?allowPublicKeyRetrieval=true&useSSL=false");
        dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");

        return dataSource;
    }
    
    @Bean(name = "applicationJdbcTemplate")
    public JdbcTemplate applicationDataConnection(){
        return new JdbcTemplate(dataSource());
    }

    @Bean
    public TransactionManager transactionManager(DataSource dataSource)
    {
        return new DataSourceTransactionManager(dataSource);
    }
    
}

<!DOCTYPE html>
    <html lang="en">
        <head>
            <title> Ken </title>
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0">
            <meta name="description" content="Kenneth's thingy">
            <meta name="author" content="Kenneth Steven Lee">
            <script type="text/javascript" src="/untitled2/URLtoResources/javascript/stufftwo.js" defered></script>
        </head>
        <body>
            <h1> Big pimpin </h1>
            ${student}
            <br>
            <c:forEach var="guy" items="${student}">
                ${guy}
                <br>
            </c:forEach>
        </body>
    </html>

"use strict"

window.addEventListener("load", () =>
{
    
})

At this point, all I was expecting was just for JSON to data bind with Object Mapper and send off the instance of the class with redirection via addFlashAttribute(student_guy_three). I wanted everything added into the database with a clean redirection with all the list of java object. ALl I get back is status code 400.

React. How to set a column value that depends on another column

I’m new to development. I’m just studying the TS JS reaction. I can’t handle it. I get it from the employee’s database. Columns name, city of residence and city of employment. It is necessary not to display the city of employment if the city of the device coincides with the column of residence. I can’t pull out the data to put in variables for comparison.

I read the documentation, tried useState, useReducer and a lot of other things, but nothing…….

<div className={""}>
            <Table
                className={"settings-table"}
                columns={[{caption: Translate.NAME, accessorKey: 'name'},
                    {caption: Translate.CITYOFRESIDENCE, accessorKey: 'city_residence'},
                    {caption: Translate.CITYOFEMPLOYMENT, accessorKey: 'city_employment'},
                ]}
                data={this.state.clients.data}
                }}/>
</div>

page.click() not found – Puppeteer in Docker

I am working on automating a website. My script basically enters a website where you must log in to continue the process.

The problem is that apparently the “click” function does not work when it runs on docker (local and headless works), although it finds the selectors, when it is “clicked” it ends up exiting due to timeout. I have read that sometimes this causes problems. Any ideas??

I share some of the code and the versions of docker and puppeteer that I am using.

const selector = "#loginRegisterTabs > ul > li:nth-child(1)";
await page.waitForSelector(selector, { timeout: 30000 });
await page.focus(selector); // Opt
await page.click(selector);

FROM ghcr.io/puppeteer/puppeteer:22.14.0
> "puppeteer": "^22.14.0"

Thanks! Regards

I have already tried waiting for the selector, clicking directly, even focusing on it.
Locally works include headless mode

JavaScript and CSS: How to make a fixed navigation menu transparent when scrolling?

I’ve been researching how to make the navigation bar transparent but I can’t find which mistakes I’ve done. Currently the menu does not change at all could anyone please give me an example of the code I would need to use in order to make it transparent whenever I scroll down.

I am trying to create a fixed navigation menu that will become transparent when the user scrolls down the page. I used the following code:

I expected the menu to gradually become transparent as the user scrolls down, but it remains the original color. Also I tested my code in different browsers to ensure consistent behavior.
I’ve tried adding the following CSS:

.menu {
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 1000;
    background: linear-gradient(45deg, #f00,#00f);
    padding: 10px 0;
    margin-bottom: 40px;
}
.menu .transparent {
    background: linear-gradient(
        45deg,
        rgba(255,0,0,0.8),
        rgba(0,0,255,0.8)
    );
}

Together, this means that the following styles will only apply to elements within the menu when the transparent class is added to them

and here it is on JavaScript:

document.addEventListener('DOMContentLoaded', function () {
    const menu = document.querySelector('.menu');

    function toggleMenuTransparency() {
        if (window.scrollY > 0) {
           menu.classList.add('tranparent')
        }
        else {
            menu.classList.remove('transparent');
        }
    }
    window.addEventListener('scroll', toggleMenuTransparency);
});

How can I resolve an invalid token in js

I am trying to resolve the error. When I verify my touch it marks it as invalid and my req.user as defined

index.js(this is my file)

const express = require('express');
const mongoose = require('mongoose');
const bcrypt = require('bcrypt');
const jwt = require('jsonwebtoken');
const { expressjwt: expressJwt } = require('express-jwt');
const User = require('./user');

const jwtSecret = 'mi-string-secreto';

mongoose.connect('mongodb+srv://prprueba37:[email protected]/auth?retryWrites=true&w=majority&appName=Cluster0');

const app = express();
app.use(express.json());

// Middleware para validar el JWT
const validateJwt = expressJwt({
  secret: jwtSecret,
  algorithms: ['HS256']
});

// Función para firmar el token
const signToken = _id => jwt.sign({ _id }, jwtSecret, { algorithm: 'HS256' });

app.post('/register', async (req, res) => {
  const { email, password } = req.body;

  try {
    const isUser = await User.findOne({ email });
    if (isUser) {
      return res.status(403).send('Usuario existente');
    }
    const salt = await bcrypt.genSalt();
    const hashed = await bcrypt.hash(password, salt);
    const user = await User.create({ email, password: hashed, salt });
    const token = signToken(user._id);
    res.status(201).send({ token });
  } catch (err) {
    res.status(500).send(err.message);
  }
});

app.post('/login', async (req, res) => {
  const { email, password } = req.body;

  try {
    const user = await User.findOne({ email });
    if (!user) {
      return res.status(403).send('Usuario y/o contraseña inválida');
    }
    const isMatch = await bcrypt.compare(password, user.password);
    if (isMatch) {
      const token = signToken(user._id);
      res.status(200).send({ token });
    } else {
      res.status(403).send('Usuario y/o contraseña incorrecta');
    }
  } catch (err) {
    res.status(500).send(err.message);
  }
});

// Ruta protegida que requiere autenticación
app.get('/lele', validateJwt, (req, res) => {
  res.send('ok');
});

app.listen(3000, () => {
  console.log('Listening on port 3000');
});

user.js(this is my schematics file)

const mongoose = require('mongoose')

const User = mongoose.model('User', {
    email: {type: String, required: true},
    password: {type: String, required: true},
    salt: {type: String, required: true},
    
})

module.exports = User

I have tried several things but my token is still invalid,
I have the libraries installed but I get some warnings
npm WARN deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm WARN deprecated [email protected]: This package is no longer supported.
npm WARN deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
npm WARN deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm WARN deprecated [email protected]: This package is no longer supported.
npm WARN deprecated [email protected]: This package is no longer supported.