Drag&drop ChartJS charts make them disappear

I have different div in my HTML body (some of them with charts) and I want to be able to drag&drop these div to re-organise them. I found Dragula which work pretty well but when I drag&drop div with a chart inside, the chart disappear.

I only found plugins to drag&drop data inside the charts when I searched for this on google.

Here’s a code sample but the whole file have 10divs : 4 with chartJS charts, 3 with gaugeJS gauges (which work well when drag&drop) and 2 with basic HTML element (h3 and h4) without any problem neither.

let graphItop2 = new Chart(document.getElementById("ticket"), {
            type: "pie",
            data: {labels: ["Blue", "Purple"],
                datasets: [{
                    data: [1, 1],
                    backgroundColor: ["blue", "purple"],
                }]
            },
        });

dragula([document.querySelector("body")])
/* This comes from dragula's github */

.gu-mirror {
    position: fixed !important;
    margin: 0 !important;
    z-index: 9999 !important;
    opacity: .8
}

.gu-hide {
    display: none !important
}

.gu-unselectable {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important
}

.gu-transit {
    opacity: .2
}

/* This is mine */

body {
    color: #000;
    background-color: #f0f0f0;
    display: flex;
    align-content: stretch;
    flex-wrap: wrap;
    margin: 18px;
    
    grid-gap : 10px
}

.case {
    position: relative;
    padding: 10px;
    text-align: center;
    border-radius: 10px;
    background-color: #fff;
}

h2 {
    margin: 0;
    padding: 10px 20px;
    border-radius: 10px;
    background-color: lightgray
}
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dragula/3.6.6/dragula.min.js"></script>

<div class="case ticket">
    <h2>Tickets</h2>
    <canvas height="200" id="ticket" width="200"></canvas>
</div>

<div class="case random">
    <h2>Random</h2>
    <p>This is random text</p>
</div>

Why browser is not setting the cookie sent from my node js backend?

I’m trying to set a cookie from the backend server running at “api.mydomain.com” like this to the frontend running at “mydomain.com”.

res.cookie('auth', token, {
  domain: 'mydomain.com',
  httpOnly: true,
  signed: true,
  secure: true,
  sameSite:'none',
});
res.json({
  //response object
});

In the response header of the request, the “Set-Cookie” header is visible, but when I am checking the cookie storage for the frontend running on “mydomain.com” I cannot find the cookie.

Set-Cookie: auth=<...>; Domain=mydomain.com; Path=/; HttpOnly; Secure; SameSite=None

My backend server is running Node.js and the frontend is in React.

How to close a div on click in vue js?

I have added a close button to a div in Calendly popup in VueJS and I want to close this div when click on the close button. How can I do this?

This is my Calendly Code:

<TransitionRoot as="template" :show="openTimes">
<Dialog
  as="div"
  class="fixed inset-0 overflow-y-auto"
  @close="closeModal"
  :open="openTimes"
  :initialFocus="closeModalTimesRef"
>

And this is the button I have added

<button type="button" class="close" 
@click="$emit('close')"> X 
 </button>

I am new to vue js. Please help me !!!

Mousedown event not added

I’m adding an event listener but listener didn’t added and i have no errors.

    thisalphabet.addEventListener("mousedown",function(event){
        lastwordchoosed += event.target.innerHTML;
        document.getElementById("wordchoosed").innerHTML = lastwordchoosed;
    });

thisalphabet : a div that when it clicks it adds the character to the field.
lastwordchoosed : the word that must be write to the field.
What should i do?

get InputName of div element using js, no jquery please

I have a variable that consists of an HTML tag as below:

let customDiv = '<div class="MuiAutocomplete-root" name="ApplyTo">Hello</div>';

I want to fetch the “name” which outputs –> “ApplyTo”… from the above customDiv variable. I don’t want to use jquery. Wanted to implement it with vanilla javascript. Thanks.

Google pay option is not coming in stripe

backend

    @app.route('/create-payment-intent', methods=['POST'])
    def create_payment():
        try:
            data = json.loads(request.data)
            # Create a PaymentIntent with the order amount and currency
            intent = stripe.PaymentIntent.create(
                amount=calculate_order_amount(data['items']),
                currency='usd',
                automatic_payment_methods={
                    'enabled': True,
                },
            )
            return jsonify({
                'clientSecret': intent['client_secret']
            })
        except Exception as e:
            return jsonify(error=str(e)), 403

frontend

    export default function App() {
    const [clientSecret, setClientSecret] = useState("");

    useEffect(() => {
        // Create PaymentIntent as soon as the page loads
        fetch("/create-payment-intent", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ items: [{ id: "xl-tshirt" }] }),
        })
        .then((res) => res.json())
        .then((data) => setClientSecret(data.clientSecret));
    }, []);

    const appearance = {
        theme: "stripe",
    };
    const options = {
        clientSecret,
        appearance,
    };

    return (
        <div className="App">
        {clientSecret && (
            <Elements options={options} stripe={stripePromise}>
            <CheckoutForm />
            </Elements>
        )}
        </div>
    );
    }

here is my stripe code where i am expecting google pay to come but it is not coming in my localhost. I am using live stripe acccount for testing .
Is google pay btn not coming because of localhost ?

Please check the screenshot how it is coming .
enter image description here

Not sure what this mean in there doc
enter image description here

React-Router: Force reload in browser

We have a monolithic react SPA deployed with AWS Cloudfront. We are trying out microsite architecture where each route/path in the react app will be built and deployed as a standalone app. To achieve this we have configured path-based behaviors in Cloudfront to route the request to the respective origin which works fine.

Due to its SPA nature, all the routes defined in the monolithic react app tries to load pages without sending a request to the server. This is causing issues because we want a few routes to be loaded from the server so that CloudFront can route the requests properly.

How can we force react-router to load a specific route from the server?

<Route exact path="/example" render={()=>console.log("load from server?");} />

Extract individual PDF from a portfolio of multiple PDF documents

I have a web application builded with PHP and JS.
In this app i make different operations with certain files and i encounter the next problem:

The user needs to upload in my app a PDF file wich is a portfolio/package of multiple PDF documents. So the problem is that i don’t know how to individually extract each PDF document from the portfolio (i want to read each PDF file separate, otherwise i can’t).
This is where i get stuck and i don’t know how destructure this collection of PDF’s.
The solution can be in either PHP or JS, it doesn’t really matter.

Example with the PDF portfolio/collection (in the left side are the PDF documents that i need to extract them separately in my app):
PDF portfolio example

Google Oauth popup cancellation callback

When using Google Identity Services (GSI) I can display a popup to ask users to connect with their Google account.
This is pretty well documented and it works well with this code:

const client = window.google.accounts.oauth2.initCodeClient({
  client_id: 'CLIENT_ID',
  scope: 'SCOPE',
  ux_mode: 'popup',
  callback: async (response) => {
    console.log('Response Google', response);
  },
});
client.requestCode();

However, I wish to do something if the user close the popup. I can’t find anything in the documentation and in examples online. I tried intermediate_iframe_close_callback and native_callback, but neither are called when closing the popup.

So, is it possible ? How can I do it ?

Thanks

Can we run a javascript file located in a Github repo, on the console of a website in our browser?

So for example I have a Github repo that has a javascript file with the contents of:

console.log("Hello World")
console.log("I'm alive!")

lets say the file name is alive.js

Now I want to run this code inside my browser console on a website. Instead of copy pasting the whole code, which “leaks” the contents of the code, can we just use a single lined code, that runs the js file from the github repo? Thanks!

Querying MarkLogic merged collection

I’m trying to write a query to get the unique values of an attribute from the final merged collection(sm-Survey-merged). Something like:

select distinct(participantID) from sm-Survey-merged;

I get a tree-cache error with the below equivalent JS query. Can someone help me with a better query?

[...new Set (fn.collection("sm-Survey-merged").toArray().map(doc => doc.root.participantID.valueOf()).sort(),  "unfiltered")]