Tiptap BubbleMenu (tippy.js) issue – it appars even when `shouldShow` is false

I made a BubbleMenu for my link mark to show its href and a button to edit/delete mark.

The problem is that BubbleMenu is shown even when isActive("link") is false and hence href is null.

You could observe it in attached example when clicking outside bubble menu – the href disappears but the button is still visible. How can I fix that?

Interestingly, when I remove duration from bubble menu, the behaviour is opposite – the issue appears when showing BubbleMenu, no when closing it. Issue does not appear at all when clicking completely outside of editor.

DEMO: https://codesandbox.io/p/sandbox/bubblemenu-issue-d46rx5?file=%2Fsrc%2FApp.js%3A70%2C26

Active Directory Pass Through Authentication for Apache Intranet Web-Application (PHP, JS)

I’ve builded some Intranet Web-Applications, which run on an Docker Container (Ubuntu-Host) with Apache and PHP.

The current Authentication is based on the Active Directory (NOT Azure, On-Premise Domain Controller)
It’s a login-page where you insert your userPrincipalName and Password.
I’m using the PHP LDAP Module and the ldap_bind function for this.

But the user is already logged in with his Windows (or Active Directory) Account on the client-machine.
So I was wondering, if I could build an Single-Sign-On- (or more precise a Pass-Through-)Authentication.

For IIS-Server this is pretty simple …

I tried to find something, but I guess I’m not using the correct terminology.

You find a lot of stuff for configuring an Azure-AD, but as I said we don’t use Azure.
I tried “PHP AD Passthrough Authentication”, “PHP Kerberos”, “PHP NTLM”, “Webapplication Active Directory Passthrough” and similiar things for JS.
(Because you are logged in on your client-machine, you probably have to send some data from the client and use this on server-side)
But this doesn’t give me the results I need.

It seems than you can use the ldap_sasl_bind function (with the parameter “GSSAPI”), but I can’t figure out what exactly I got to do.

Has anyone expierience in this and can help me?

I wouldn’t mind if the Login-Page has an extra button “Login with Windows Credentials”, which would trigger the Pass-Through-Authentication. Full automation is nice to have, but I’d be happy if my users can login without entering “username” and password.

Thanks in Advance

Google Translate causing JavaScript errors

When a user uses Chrome’s Translate option, it is causing a JavaScript error. We believe it is conflicting with require.js that is used for the site. The Google translate code must now be making an anonymous define that it was not before.

Specifically it’s giving the following errors:

Uncaught (in promise) Error: Mismatched anonymous define() module: function

and
Uncaught TypeError: Cannot read properties of undefined (reading ‘gzip’)

This just started happening in December. Previously it was working fine. Hard to tell if the errors are related or not. We have yet to determine a fix for this issue.

Is it able to directly open a wallet using web3Modal 3?

current comp: open

The current open() func does have some useful options, while I want to realize a more direct way to open one wallet. For example:

open({
  specificWallet:'metamask'
})

or

//metamask
open({
  specificWalletId:'c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96'
}) 

Just without choosing which wallet to connect.

Is it possible? Or does it have a simple way to realize this?

I’ve tried using js’s document.getElement to call the current w3mButton to be “.click()”ed, while it seems no use.
I’ve also thought about compiling source code, exporting a simple or something, but I give it up when I saw how complicated is the w3m’s framework.

i am facing a issue while conditionally rendering two material-ui dialog in react js

i am conditionally rendering these dialogs , initial value of compareData is FALSE , and the compareData value is stored in redux Store . so when i change it to TRUE i can view the Dialog1 and if i again change it to FALSE i can view the Dialog2 but Dialog2 is re-rendering all the child components inside that again . so API calls also going again and fetching the same data . i want to avoid this unwanted API calls and re-render . additional info – i am using react-class-components .

{compareData ? (<Dialog1>
                <AccountDetails/>
                  <Dialog1>):
      (<Dialog2>
       <product/>
       <items/>
       <customers/>
       </Dialog2>
    )}

BlobURL for later usage [duplicate]

I got BlobURL by this:

cnv.toBlob(blob=>{
    var blobUrl = URL.createObjectURL(blob)
    localStorage.setItem("lorem",blobUrl)
})

Then I want to load it into canvas again on another time:

var blobUrl = localStorage.getItem("lorem")
fetch(blobUrl)
    .then(response => response.blob())
    .then(blob => {
        var img = new Image()
        img.onload = function() {
            cnv.ctx().drawImage(img, 0, 0)
        }
        img.src = URL.createObjectURL(blob)
    })
    .catch(error => console.error("Error:",error))

I always got “net::ERR_FILE_NOT_FOUND” error, why? How to re-use Blob later?

Prevent unwanted characters in the file name field when loading with fileLoad.click( )

In my JavaScript project, reading in data using a single button works perfectly.

However, I also have to read in data when I click on an object with the mouse in an area “ContainerB” while holding down a key such as s for “shape”. This works fine in itself, the problem is that when the “Upload file” window opens, there are already quite a number of “s” letters in the active “File name” input field. If you don’t get your finger off the s very quickly, there are a lot of characters.

This is very unpleasant. How can you prevent this?
It should be empty or contain a default value like “shape.txt”?

My structure:

    <input type="file" id="shapeFileLoad" style="display: none;">
    function onWindowKeyDown( event ) {
        if ( event.keyCode === 83 )  key = 'shape';     //  load a shape file 
    }
    function onWindowKeyUp( event ) {
        key = ''; // reset keyCode  
    }   
    function onContainerBpointerDown( event ) {
      if ( key === 'shape' ) {
        shapeFileLoad.click( );
        shapeFileLoad.addEventListener( 'change', e => {
            const f = shapeFileLoad.files[ 0 ];
            reader.readAsText( f );
            reader.onload = e => { processLoadedShape ( ); } // process data
        }
      }
    }

Embed HTML widget into angular 7+ component

Problem

I am trying to embed an HTML in an angular component. (I am using Angular 7 at the moment, but plan to upgrade in the near future)

The documentation says I need to have the following HTML on my page

<div widget1 sandbox='true' 
    pc-account='aba123212312' 
    payment-method='0' widget-method='2' return-method="2" currency='AUD' amount='45.00' 
    reference='ME123456789' return-action='pcReturn'  
    hash='bb16dfsdfsdfwefwec640dfd722' 
    time-stamp='20220306095214'></div>

and to include an js file as well.

<script src="https://sandbox.pc.com.au/scripts/js/widget11.min.js"></script>

The solution I have tried so far is to
Create an pc.component.html which has

 <div widget1 sandbox='true' 
        pc-account='aba123212312' 
        payment-method='0' widget-method='2' return-method="2" currency='AUD' amount='45.00' 
        reference='ME123456789' return-action='pcReturn'  
        hash='bb16dfsdfsdfwefwec640dfd722' 
        time-stamp='20220306095214'></div>

and I’ve included the script in the HEAD of the index.html file.

However, I’m not sure where to go next. What would I put into pc.component.ts ?

However, the widget never shows up.

how to get the value of data-id in an html when clicked using javascript forloop and return the value

this is my html

       <ul class="conversations">
            {% if t_ques %}
                <li class="grouping">Today</li>
                {% for item in t_ques %}
                    <li class="active">
                        <a id="convers" class="conversation-button text-[#E8F5FC] my-2" href="{% url 'assistant:continuechat' item.pk %}" data-pk="{{item.pk}}">
                            <i class="fa fa-message fa-regular"></i> {{item.title| truncatewords:04 }}
                        </a>
                        <div class="fade"></div>
                        <div class="edit-buttons">
                            <button><i class="fa fa-edit"></i></button>
                            <button class="trash" data-id = "{{item.pk}}"><i class="fa fa-trash"></i></button>
                        </div>
                    </li>
                {% endfor %}
            {% endif %}
            {% if y_ques %}
                <li class="grouping">Yesterday</li>
                {% for item in y_ques %}
                    <li>
                        <a id="convers" class="conversation-button text-[#E8F5FC] my-2" href="{% url 'assistant:continuechat' item.pk %}" data-pk="{{item.pk}}">
                            <i class="fa fa-message fa-regular"></i>  {{item.title| truncatewords:04 }}
                        </a>
                        <div class="fade"></div>
                        <div class="edit-buttons">
                            <button><i class="fa fa-edit"></i></button>
                            <button class="trash" data-id = "{{item.pk}}"><i class="fa fa-trash"></i></button>
                        </div>
                    </li>
                {% endfor %}
            {% endif %}
            {% if s_ques %}
                <li class="grouping">Previous 7 days</li>
                {% for item in s_ques %}
                    <li>
                        <a id="convers" class="conversation-button text-[#E8F5FC] my-2" href="{% url 'assistant:continuechat' item.pk %}" data-pk="{{item.pk}}">
                            <i class="fa fa-message fa-regular"></i>  {{item.title| truncatewords:04 }}
                        </a>
                        <div class="fade"></div>
                        <div class="edit-buttons">
                            <button><i class="fa fa-edit"></i></button>
                            <button class="trash" data-id = "{{item.pk}}"><i class="fa fa-trash"></i></button>
                        </div>
                    </li>
                {% endfor %}
            {% endif %}
            {% if more_s_ques %}
                <li class="grouping">Previous 30 days</li>
                {% for item in more_s_ques %}
                    <li>
                        <a id="convers" class="conversation-button text-[#E8F5FC] my-2" href="{% url 'assistant:continuechat' item.pk %}" data-pk="{{item.pk}}">
                            <i class="fa fa-message fa-regular"></i>  {{item.title| truncatewords:04 }}
                        </a>
                        <div class="fade"></div>
                        <div class="edit-buttons">
                            <button><i class="fa fa-edit"></i></button>
                            <button class="trash" data-id = "{{item.pk}}"><i class="fa fa-trash"></i></button>
                        </div>
                    </li>
                {% endfor %}
            {% endif %}
        </ul>
   </div>

i’ve been trying to get the value of any data-pk when being clicked on using javascript but can’t seem to achieve that. This kept saying currentTarget not defined and when i replaced it with target, it says the same thing. then if i replace it it with document.querySelector(“#convers”), it just give the first value, regardless of which is clicked on

this is my javascript

    const conversationButtons = document.querySelectorAll("#convers");
    conversationButtons.forEach(button => {
        button.addEventListener("click", getId);
    });

    function getId(e){
        var idValue = e.currentTarget.getAttribute('data-pk');
        console.log(idValue); //output corresponding target-id

        if(!chat_id){
            url = `/chat-previous/${idValue}/`
        }else{
            url = 'initiate-chat/'
        }

        return url;
    }

    $.ajax({
        type: 'POST',
        url: getId(),
        data: {
            message: usermsg,
            chatId: chat_id,
            // itemId: item_id,
            csrfmiddlewaretoken: $('input[name=csrfmiddlewaretoken]').val(),
            action: 'post'
        },
        success: function(json){
            const res = json['chats']
            setTimeout(() => {
                hideTyping();
                body.appendChild(mgses(res, "assistant"));
                scrollToBottomOfResults();
            }, 1000);
            console.log(json)
        },
        error: function(rs, e){
            setTimeout(() => {
                hideTyping();
                body.appendChild(setBotResponse("bot"));
                scrollToBottomOfResults();
            }, 600);
            console.log(rs.error);
        },
    });

i used other methods like

    const getId = () => {
        console.log(document.querySelector(".conversation-button").getAttribute('data-pk'))
         if(!chat_id){
             url = `/chat-previous/${document.querySelector(".conversation-button").getAttribute('data-pk')}/`

      
         }else{
             url = 'initiate-chat/'
    
         }
    
        return url;
    }

    conversationButtons.forEach(button => {
       button.addEventListener("click", getId);
        console.log(button.getAttribute('data-pk'));
    });

still couldn’t get what i really want. is there a way i can achieve this?

The disabled input doesnt enable

startbtn.addEventListener("click",() =>{
    if (startbtnclicked === false) {

        time[0] = inputhours.value
        time[1] = inputmins.value
        temp = inputtemp.value
        if (valid(100,temp,time)) {
        inputmins.setAttribute("disabled", true)
        inputtemp.setAttribute("disabled", true) 
        inputhours.setAttribute("disabled", true)
            console.log("allclear");
            clockdisplay.innerText = `${time[0]}:${time[1]}:00`
            tempdisplay.innerText = ` ${temp}°C`
            countdown(time,clockdisplay)
            startbtnclicked = true
        } else {
            console.log("fuck off");

        }
    }else{   
        console.log("for fucks sake")
            inputmins.setAttribute("disabled", false)
            inputtemp.setAttribute("disabled", false) 
            inputhours.setAttribute("disabled", false)
        startbtnclicked = false
    }
})

this code will disable the inputs but when it comes to enabling it back it doesnt work (the console shows the log but this doesnt work)

Documenting destructured function argument with rest parameter

Is it possible to correctly document something like this using JSDoc?

/**
 * CartFooter component
 *
 * @type {React.FunctionComponent}
 *
 * @param {Object} footerProps          props
 * @param {Object} footerProps.classes  classes injected from the parent
 * @param {Object} footerProps.events   events for the component
 * @param {Object} footerProps.children events for the component
 * @param {Object} footerProps.props
 * @param {React.Ref<Object>} ref
 * @returns {JSX.Element}
 * @constructor
 */
const CartFooter = ({ classes: parentClasses, events, children, ...props }, ref) => { /* ... */ }

I don’t understand how to document the rest param ...props correctly in this case:

If I hover over ...props, VSCode describes it as

(parameter) props: {
    props: any;
}

Which is incorrect, if I do

const { a, b, ...options } = props
const { c, d } = options

Inside the function body, a, b, c and d have red lines, with the error Property 'q' does not exist on type '{ props: any; }'.ts(2339)

I don’t understand why the type of ...props is { props: any; }. If I change

 * @param {Object} footerProps.props

to

 * @param {...any} footerProps.props

I get the error A rest parameter must be last in a parameter list.ts(1014).

I’d appreciate any help on this. Thanks

React Router: Data not displaying on the first visit to ParentNotificationsPage component, appears only after returning

I’m facing an issue with React Router in my React application where the ParentNotificationsPage component doesn’t display data on the first visit. The data only appears when I navigate back to the component. Here’s a breakdown of my setup:

Problem:
I have a React application using React Router, and in the ParentNotificationsPage component, I fetch data and render it in a list. The data fetching occurs in the useEffect hook on the initial render. However, on the first visit to the component, the page is empty, and the data only appears when I navigate away and then return to the component.

Code:
Here’s the relevant part of my code:

ParentNotificationPage.js:

import React, { useEffect, useState } from 'react';
import getNotifications from '../services/GetNotifications';
import { Link } from 'react-router-dom';

const ParentNotificationsPage = () => {
    const [notifications, setNotifications] = useState([]);

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

    const fetchNotifications = () => {
        getNotifications()
            .then((data) => {
                setNotifications(data);
            })
            .catch((error) => {
                console.error('Error fetching notifications:', error);
            });
    };

    return (
        <div>
            <h2>Notifications for Parent User</h2>
            <ul>
                {notifications.map((notification) => (
                    <li key={notification.id}>
                        {notification.message}
                    </li>
                ))}
            </ul>
            <Link to="/addNotifications">
                <button>Add Notification</button>
            </Link>
        </div>
    );
};

export default ParentNotificationsPage;

App.js

import React from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import AuthPage from './pages/AuthPage';
import ParentNotificationsPage from './components/ParentPage';
import AddNotificationForm from './services/AddNotifications';

const App = () => {
  return (
    <Router>
      <Switch>
        <Route exact path="/" component={AuthPage} />
        <Route
          path="/ParentPage"
          render={(props) => (
            <ParentNotificationsPage {...props} />
          )}
        />
        <Route
          path="/addNotifications"
          component={AddNotificationForm}
        />
      </Switch>
    </Router>
  );
};

export default App;

What I’ve Tried:
1.Checked if the data is properly fetched before rendering the ParentNotificationsPage component.
2. Verified that the useEffect hook is triggered on the initial render.
3. Confirmed that the data is present in the state after the initial fetch.
Expected Behavior:
I expect the ParentNotificationsPage component to display data on the first visit without having to navigate away and return.

Question:
What could be causing the data not to display on the first visit to the ParentNotificationsPage component, and how can I ensure that the data is shown immediately upon entering the page?

Even after the module is presented, it is showing an ERR_MODULE_NOT_FOUND error

The file is there in the path.

abcd@abcd-dell-123D-80:~/Projects/test$ find ~/Projects/test -name 'dayApiSlice.js'
/home/abcd/Projects/test/src/features/day/dayApiSlice.js

You added “type”: “module” to package.json.

abcd@abcd-dell-123D-80:~/Projects/test$ git diff package
fatal: ambiguous argument 'package': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
abcd@abcd-dell-123D-80:~/Projects/test$ git diff package.json
diff --git a/package.json b/package.json
index 21fd3ecb..76a9d990 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,7 @@
 {
   "name": "test",
   "version": "0.1.0",
+  "type": "module",
   "private": true,
   "dependencies": {
     "@casl/ability": "^6.5.0",

still getting below error

abcd@abcd-dell-123D-80:~/Projects/test$ node customer-report.js
node:internal/process/esm_loader:40
      internalBinding('errors').triggerUncaughtException(
                                ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/abcd/Projects/test/src/features/day/dayApiSlice' imported from /home/abcd/Projects/test/customer-report.js
Did you mean to import ../src/features/day/dayApiSlice.js?
Node.js v20.10.0

below import is giving error

import { useGetUserQuery } from "./src/features/day/dayApiSlice.js";

Can anyone help me solve this problem?

I have tried different import methods; none of them worked.

Webgl-plot gives me error when trying to plot data

I have created a Flask proyect to show in real time some metrics from the computer. First I used chart.js and everything works fine.
Here is what I achived with using chart.js:
chart.js

This library is not as fast as I need, so after investigating i found that I could use either uPlot or WebGL-plot.

I’m trying using webgl-plot.

This is what I’ve done so far. First of all this is the stucture that my proyect has:

-FLASK_WEBGL/
   - .venv/
   - static/
      - css/
         - base.css
         - index.css
      - scripts/
         - webgl_scripts/
            - All the scripts that appeare in the github repo under dist/
         - script_cpu.js
         - script_drive.js
         - script_ram.js
         - script_temp.js
   - templates/
      - base.html
      - index.html
   - app.py

My app.py, here I obtain all the data I need and save it in a json file:

import psutil, json, wmi

from flask import Flask, render_template

app = Flask(__name__, static_url_path='/static')


def get_cpu_temperature():
    # Code to get cpu temperature
   return temp

@app.route("/")
def index():
    return render_template("index.html")

@app.route("/get_data")
def get_data():
    temperature = get_cpu_temperature()
    data = {
        'temp_cpu': temperature if temperature is not None else 'N/A',
        'cpu_percent': psutil.cpu_percent(),
        'ram_percent': psutil.virtual_memory().percent,
        'drive_percent': psutil.disk_usage('/').percent
    }
    return json.dumps(data)

In case it’s needed, this is what i get in 127.0.0.1/get_data:

{"temp_cpu": 53.8, "cpu_percent": 0.0, "ram_percent": 43.3, "drive_percent": 85.7}

This is th base.html and the index.html:

Base
Here I load the webplot.js.

<!DOCTYPE html>
<html lang="es">

<head>
    <meta charset="UTF-8">
    <title>{% block title %}{% endblock %}</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/base.css') }}">
    <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>

    <script type="module" src="{{ url_for('static', filename='scripts/webgl_scripts/webglplot.js') }}"></script>

</head>

<body>
    {% block content %}{% endblock %}
</body>

</html>

Index
For the example I’m only showing one of the elements to plot.

{% extends "base.html" %}

{% block title %} Metrics {% endblock %}

{% block content %}
    <head>
        <link rel="stylesheet" href="{{ url_for('static', filename='css/index.css') }}">
    </head>

    <header>
        <h1> Computer real time metrics </h1>
    </header>

    <main>
        <div class="ram-container">
            <div class="container-title"> <h2> RAM </h2> </div>
            <div class="container-chart">
                <canvas class="canvas" id="ram-chart"> </canvas>                
                <script type="module" src="{{ url_for('static', filename='scripts/script_ram.js') }}"></script>
            </div> 
        </div> 
    </main>
{% endblock %}

Finally this is the script I’ve written, script_ram.js:

  • First of all I create the plot where the data will be printed.
  • Second I create the function updateRAMData() where I parse th data from the json and save it in an array called ramData.
  • At the end I set an interval so that every 2 seconds I can get the data and graph it.
var ramData = [];

function generatePlotInstance() {
    const plot = new WebGLPlot();
    plot.setData(ramData);
    plot.setTitle("Gráfico de Uso de RAM");
    plot.renderTo("ram-chart");
}

function updateRAMData() {
    $.get('/get_data', function (data) {
        try {
            const parseData = JSON.parse(data);
            const ramPercent = parseData.ram_percent;
            const timestamp = Date.now();
            
            ramData.push([timestamp, ramPercent]);

            if (ramData.length > 450) { ramData.shift(); }

            generatePlotInstance();
        } catch (error) {
            console.log('Error RAM', error);
        }        
    });
}

setInterval(updateRAMData, 2000);

The problem I have is that in the console log of the navigator I get this error:


Error RAM ReferenceError: WebGLPlot is not defined
    generatePlotInstance http://127.0.0.1:5000/static/scripts/script_ram.js:4
    updateRAMData http://127.0.0.1:5000/static/scripts/script_ram.js:21
    jQuery 7
        c
        fireWith
        l
        o
        send
        ajax
        i
    updateRAMData http://127.0.0.1:5000/static/scripts/script_ram.js:11
    setInterval handler* http://127.0.0.1:5000/static/scripts/script_ram.js:29
script_ram.js:23:21

And I do not know how to solve it so I can see if the code I`ve written works.