How to hide a whole component on selecting a radio button

I am working on html file. I have two two labels(say L1 and L2). Each label has two radio buttons. I want to hide L2 and it’s radio buttons if a user selects any radio button from L1.

I know this can be done using java script but how to capture the selection of radio buttons on which i can execute my java script.

how to fix org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in class path

i am new to Spring boot application. i have been getting this error every time I try running the codes. i use intellij IDEA as my eidtor.and I have tried the multiple solutions online but I couldn’t fix it. here are the errors

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-12-02 12:36:19.105 ERROR 14880 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Could not determine type for: Server.accessingdata.Secondhand, at table: reserve, for columns: [org.hibernate.mapping.Column(secondhand)]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.12.jar:5.3.12]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.12.jar:5.3.12]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.12.jar:5.3.12]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.5.6.jar:2.5.6]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) [spring-boot-2.5.6.jar:2.5.6]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) [spring-boot-2.5.6.jar:2.5.6]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) [spring-boot-2.5.6.jar:2.5.6]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) [spring-boot-2.5.6.jar:2.5.6]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) [spring-boot-2.5.6.jar:2.5.6]
    at Server.Application.main(Application.java:21) [classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_281]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_281]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_281]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_281]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.5.6.jar:2.5.6]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Could not determine type for: Server.accessingdata.Secondhand, at table: reserve, for columns: [org.hibernate.mapping.Column(secondhand)]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:421) ~[spring-orm-5.3.12.jar:5.3.12]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-5.3.12.jar:5.3.12]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.12.jar:5.3.12]
    ... 21 common frames omitted
Caused by: org.hibernate.MappingException: Could not determine type for: Server.accessingdata.Secondhand, at table: reserve, for columns: [org.hibernate.mapping.Column(secondhand)]
    at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:512) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
    at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:479) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
    at org.hibernate.mapping.Property.isValid(Property.java:231) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
    at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:627) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
    at org.hibernate.mapping.RootClass.validate(RootClass.java:267) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
    at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:359) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:307) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:471) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1498) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) ~[spring-orm-5.3.12.jar:5.3.12]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.3.12.jar:5.3.12]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-5.3.12.jar:5.3.12]
    ... 25 common frames omitted
Process finished with exit code 0

this is my application.properties

    spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/4sshop?allowPublicKeyRetrieval=true&useSSL=false
spring.datasource.username=root
spring.datasource.password=12345
spring.datasource.driver-class-name =com.mysql.jdbc.Driver
spring.jpa.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.show-sql: true

this is my application class

package Server;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
;



@SpringBootApplication(scanBasePackages={"Server.repository"})
@EnableJpaRepositories(basePackages = "Server.repository")


public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}

this is my entity class

package Server.accessingdata;


import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="user")
public class User{
    @Id

    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name="userID")
    private String userID;
    @Column(name="userName")
    private String userName;
    @Column(name="password")
    private String password;
    @Column(name="Level")
    private Integer Level;

    public User() {}
    public User(String userID, String userName, String password, Integer Level) {
        this.userID=userID;
        this.userName=userName;
        this.password=password;
        this.Level=Level;

    }

    public String getuserid() {
        return userID;
    }
    public void setuserID(String userID) {
        this.userID = userID;
    }

    public String getusername() {
        return userName;
    }
    public void setusername(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public Integer getlevel() {
        return Level;
    }
    public void setlevel(Integer Level) {
        this.Level = Level;
    }
    @Override
    public String toString() {
        return "User[userID="+ userID +", userName="+ userName +", password="+ password +", Level="+ Level +"]";
    }
}

this is my repository class

package Server.repository;
import java.util.List;
import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;
import Server.accessingdata.User;

public interface UserRepo extends JpaRepository<User,Long>  {
    Optional<User>  findByUsername(String userName);
    List<User>  findByuserID(String userID);
    List<User>  findByPassword(String password);
    List<User>  findBylevel(Integer Level);
}

and this is my controller class

package Server.controller;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import Server.accessingdata.User;
import Server.repository.UserRepo;

@CrossOrigin(origins="http://localhost:8081")
@RestController
@RequestMapping("/api")

public class UserControl {
    @Autowired

    UserRepo userRepo;

    @GetMapping("/users")
    public ResponseEntity<List<User>>getAllUsers(@RequestParam(required=false) String userID){
        try {
            List<User> users= new ArrayList<User>();
            if(userID==null)
                userRepo.findAll().forEach(users::add);
            else
                userRepo.findByuserID(userID).forEach(users::add);
            if(users.isEmpty()) {
                return new ResponseEntity<>(HttpStatus.NO_CONTENT);
            }
            return new ResponseEntity<>(users, HttpStatus.OK);
        }catch (Exception e) {
            return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }
    @GetMapping("/users/{userName}")
    public ResponseEntity<User>getUserByUsername(@PathVariable("userName")String userName){
        Optional<User> UserData= userRepo.findByUsername(userName);
        if(UserData.isPresent()) {
            return new ResponseEntity<>(UserData.get(), HttpStatus.OK);
        }else {
            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
        }
    }
    @PostMapping("/users")
    public ResponseEntity<User> createUser(@RequestBody User user){
        try {
            User _user= userRepo.save(new User(user.getuserid(), user.getusername(), user.getPassword(), user.getlevel()));
            return new ResponseEntity<>(_user, HttpStatus.CREATED);
        }catch(Exception e) {
            return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }
    @PutMapping("/users{userName}")
    public ResponseEntity<User> updateUser(@PathVariable("userName") String userName, @RequestBody User user){
        Optional<User> UserData= userRepo.findByUsername(userName);
        if(UserData.isPresent()) {
            User _user= UserData.get();
            _user.setusername(user.getusername());
            _user.setuserID(user.getuserid());
            _user.setPassword(user.getPassword());
            _user.setlevel(user.getlevel());
            return new ResponseEntity<>(userRepo.save(_user), HttpStatus.OK);
        }else {
            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
        }
    }
    @DeleteMapping("/users")
    public ResponseEntity<HttpStatus> deleteAllUsers(){
        try {
            userRepo.deleteAll();
            return new ResponseEntity<>(HttpStatus.NO_CONTENT);
        }catch(Exception e) {
            return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }
    @GetMapping("/users/Level")
    public ResponseEntity<List<User>> findByLevel(){
        try{
            List<User> users= userRepo.findBylevel(null);
            if(users.isEmpty()) {
                return new ResponseEntity<>(HttpStatus.NO_CONTENT);
            }return new ResponseEntity<>(users, HttpStatus.OK);
        }catch(Exception e) {
            return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }

}

And also I have added my pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.6</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>Server</groupId>
    <artifactId>carServer</artifactId>  <version>0.0.1-SNAPSHOT</version>
    <name>4sserver</name>
    <description>server for 4sshop</description>
    <properties>
            
            <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.6.1.Final</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

How do I load my HTML and CSS file with my NODEJS server?

I am running a nodejs server file, code below. Currently the code you see does not have the HTML or CSS referenced because I don’t know how to do it.

const http = require('http');

// Create an instance of the http server to handle HTTP requests
let app = http.createServer((req, res) => {
    // Set a response type of plain text for the response
    res.writeHead(200, {'Content-Type': 'text/plain'});

    // Send back a response and end the connection
    res.end('Hello World!n');
});

// Start the server on port 3000
app.listen(3000, '127.0.0.1');
console.log('Node server running on port 3000');

In a folder that looks like this

I have already searched online for hours, looked at previous stackoverflow posts, and I still haven’t found the answer. I got the HTML file to load at one point, but I was not able to get the CSS file to load.

Trying connection with PagSeguro API and i have cors Problem

I’m trying conect my website with PagSeguro API. In Insomnia the request works, but in my website, the cors is the problem.

Problem:
x

Access to XMLHttpRequest at 'https://sandbox.api.pagseguro.com/charges' from origin 'https://mobile-andre-luis.web.app' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

buyCartela.js:107 POST https://sandbox.api.pagseguro.com/charges net::ERR_FAILED

Code Section:

const request = new XMLHttpRequest();
const body = {
        "reference_id": ``,
        "description": ``,
        "amount": {
            "value": 200,
            "currency": "BRL"
        },
        "payment_method": {
            "type": "CREDIT_CARD",
            "installments": 1,
            "capture": true,
            "soft_descriptor": "Cartela do Bode da Sorte",
            "card": {
                "number": ``,
                "exp_month": ``,
                "exp_year": ``,
                "security_code": ``,
                "holder": {
                    "name": ``
                }
            }
        },
        "notification_urls": [
            "http://127.0.0.1:5500/form/buyVerify.html"
        ],
        "metadata": {
            "idVendedor": "Papai Noel",
            "idCartela": ``,
            "nameComprador": ``,
            "phoneComprador": ``,

        }
    };


    const url = `https://sandbox.api.pagseguro.com/charges`;
    request.open("POST", url, true);
    request.setRequestHeader("Access-Control-Allow-Origin","*");
    request.setRequestHeader("Content-type","application/json");
    request.setRequestHeader("Authorization","x");
    request.setRequestHeader("x-api-version","4.0");
    request.send(body);

    console.log(request.response)

xhttp.send works once but fails the 2nd time

I have the following javascript that works happily the 1st time but fails the second time..

    xhttp = new XMLHttpRequest();               
    xhttp.open("POST","FINDMOVES",false);
    xhttp.send(text);       

This send is actually being received by the server and a respone is written by the server. The server is my own and written in assembler.
The java console reports:-

POST http://localhost:1024/FINDMOVES net::ERR_EMPTY_RESPONSE
Uncaught DOMException: Failed to execute ‘send’ on ‘XMLHttpRequest’: Failed to load ‘http://localhost:1024/FINDMOVES’.

This code works happily where it is used in other programs.

I am aware that:- “[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience” but it is not java’s decision as to what my end user experience is like. It is mine.

Anyone got any clues ??

Is there a reason to prefer Symbol.keyFor() over Symbol.prototype.description?

In JavaScript, I can create Symbol -primitives like this:

const ex1 = Symbol('example1');
const ex2 = Symbol.for('example2');

And I can get the original string that was used to create the Symbol by accessing the Symbol.prototype.description, or by calling the Symbol.keyFor() -method like so:

ex1.description; // 'example1'
ex2.description; // 'example2'
// OR
Symbol.keyFor(ex1); // undefined
Symbol.keyFor(ex2); // 'example2'

My questions are;

  • Is there any difference between the two methods, other than Symbol.keyFor not working for Symbols that are not in the global registry (i.e. created from Symbol.for())? It seems to me they are otherwise used to achieve the exact same thing.
  • Is there a reason to ever prefer using Symbol.keyFor() instead of Symbol.prototype.description? Since the description works for all Symbols, while keyFor works only for ones in the global registry.

Why does bind() work so inconsistently in Vue template event handlers?

When experimenting with a bit of fancy syntax in my templates today I came across a confusing behaviour of the bind() function in Vue event handlers.

Ignoring any possibly bad practices and the fact that the bind is completely pointless here, please look at the following 2 code samples.

1.

<template>
  <button @click="(() => console.log('this gets logged')).bind()"></button>
</template>

<script>
export default {
  computed: {
    console: () => console,
  },
}
</script>
<template>
  <button @click="myFunc.bind()"></button>
</template>

<script>
export default {
  methods: {
    myFunc () { console.log("this doesn't get logged") }
  }
}
</script>

Code sample 1 properly logs an output to the console when clicking the button, but for some reason sample 2 doesn’t log anything. Why?

Why’s my response coming back correctly the first log but later on it changes to a 1?

I’m facing a very weird issue where my response comes back correctly during the first log but later on it changes to a 1 when the console.log(data); logs data to the console.

The screenshot shows the pattern:

enter image description here

If you expand the very first array underneath where it says data below from userEffect inside Gallery.js , the data shows up as intended

Then there’s the response array from App.js which also appears as intended.

Lastly, the response magically gets converted to a 1 from inside Gallery.js and I’m not sure how. I’ve ran out of options on how to troubleshoot this and resolve it where it doesn’t get converted to a 1.

What am I doing wrong? I’m open to any code improvements and any other suggestions for better practice :).

Here’s App.js:

import { useEffect, useState } from 'react';
import { BrowserRouter as Router, Switch, Route, useHistory} from 'react-router-dom';
import ReactDOM from 'react-dom';
import '../../sass/HomePage/homePage.scss';
import LoginRegister from "./LoginRegister/LoginRegister";
import Gallery from "./Gallery/Gallery";
import Cookies from 'js-cookie';

const App = () => {
    const [uploadsData, setUploadsData] = useState([]);
    let { push } = useHistory();
    let authToken = Cookies.get('token');

    useEffect(() => {
        getUploads();
    },[])

    function getUploads() {
        const headers = {
            "Accept": 'application/json',
            "Authorization": `Bearer ${authToken}`
        }

        axios.get('http://localhost:8005/api/get-uploads', {headers})
            .then(resp => {
                let uData = uploadsData.push(resp)
                setUploadsData(uData);
                console.log(uploadsData);
                if (authToken !== null) {
                    push('/gallery');
                } else {
                    console.log("User's NOT authenticated, returning to login view");
                    push('/');
                }
            }).catch(error => {
            console.log(error);
        })
    }

    return (
        <>
            <Switch>
                <Route exact path="/" component={LoginRegister} />
                <Route component={() => <Gallery data={uploadsData}/>} />
            </Switch>
        </>
    );
}

export default App;

if (document.getElementById('example')) {
    ReactDOM.render(<Router><App/></Router>, document.getElementById('example'));
}

Here’s Gallery.js:

import React, {useEffect} from 'react';

const Gallery = ( {data} ) => {
    useEffect(() => {
        console.log("FROM App.js INSIDE Gallery.js");
        console.log(data);
    }, []);

    return (
        <>
            <h1>test</h1>
        </>
    );
}

export default Gallery;

Javascript remove style using giving it a id or a class

so I have this HTML code where I hide the body of the website using

    <style>
        body{
          display: none;
        }
    </style>

    <body>
    <p>Something..</p>
    </body>

but now I want to remove this using Javascript without giving the body an ID or a class. As a solution I’ve tried the following but it is not working.

document.getElementsByTagName("body")[0].removeAttribute("style");

Any help is appreciated. Thanks.

How to scroll to top on route change with react router dom v6?

How to scroll to top on route change with react router dom v6?

I have tried this, react-router scroll to top on every transition, which was my solution to make my page scroll to top on route change when I use react-router-dom v5. Now, I am using react-router-dom v6 and this solution does not work.

I tried React-router v6 window.scrollTo does not work and does not work for me.

I tried https://github.com/remix-run/react-router/issues/7365, which is to use the preload prop to trigger the scrollTo(0,0), also does not work for me.

TinyMCE droping html element not allowed with Chrome and Edge

I’ve an issue with Chrome and Edge, about dropping. I have on the right side of my html page, html elements I can drop. On the left side, the tinymce editor. Everything about the editor is set correctly, I have look up for a lot of solutions to resolve my issue, but without success.

The aim is to drag an element from the right, and to drop it on the editor. If i have some text on the editor, it has to be dropped at the caret position of the editor where the mouse with the dragging element is. With firefox, it works well, I have no problems.

Issues with Chrome and Edge:

  • When I have dragged the element, and I start to go in the editor, the css cursor is ‘not-allowed’
  • I added the parameter auto_focus : 'tinyid' at the initialization of the editor (no need to do it on Firefox), where tinyid is the id of the textarea containing the tinymce editor.
  • The solution I had, was to click at a caret position in the editor where I want to drop my element, to start dragging my element, but to not go in the editor, and to drop it after dragging it. It will appear at the caret position i clicked on before.

About solutions I tried:

To set the focus

  • tinyMCE.activeEditor.focus();
  • tinymce.execCommand("mceFocus", false, "tinyid");
  • tinyMCE.get('tinyid').focus();

To get the selection and the caret position with:

  • var objSelection = tinyMCE.activeEditor.selection.getSel();
  • var intCaretPosition = objSelection.anchorOffset;

But all of this is not working. I repeat it works on Firefox. To drag and drop, I use this:

$('.blocUndragged') 
.bind('dragstart', function(event, ui){
    // start
    tinymce.execCommand("mceFocus", false, "tinyid");
    })
.bind('drag', function(event, ui){
    // while 
    tinymce.execCommand("mceFocus", false, "tinyid");
    })
.bind('dragend',   function(event, ui){
    // end
    tinymce.execCommand("mceFocus", false, "tinyid");
    moveElementDraggedIntoEditor(event);});

The function moveElementDraggedIntoEditor(event), is a function where I reworked the html element I dropped, to reformate it.

If you need more precisions, I will try to add some codes.

Thank you for trying to find a solution about my issue.