Passport JS + React application internal 500 errro

I am creating a general chat application with react, and am stuck while trying to authenticate a user. The axios post request raises a 500 error that I cannot track anywhere. When I put in correct authentication for a user, it says that the password was correct (aka, the user and password was found in the database), but then I believe the serialization/deserialization of the user is messing up somewhere but again, I can’t figure it out.

I’ve tried debugging and logging, it fetches the user properly, un-hashes the password correctly. heres a link to a github repo,
https://github.com/Macpickle/Chatroom-REACT

any help is appreciated, i feel it is something small but again stumping me. thanks.

Checkbox returns true when unchecked in Google Tag Manager

When testing in tag assistant the below variable returns true whether it’s checked or unchecked.

`function checked() {
    var check = jQuery('#marketing').attr("checked");
    if(check === "checked") {
   return true;
    } else {
    return false;
    }
}`

Tried return true.toString(); and return false.toString(); and it’s still returning true either way. Any advice would be appreciated.

<input type="checkbox" name="marketing" id="marketing" style="padding:0;margin:0;" value="1" checked="checked" aria-require="true">

Above is the code for the checkbox.

Why my javascript function detected as not function on callback?

recently I try to jump into coding again after stopping for almost 7 years long.
What I’m troubled now is a simple case where function became “not” function on callback.

Here is where it happens:

function xhrcall() {
   let xhr = new XMLHttpRequest();
   xhr.responseType = "json";
   xhr.open("POST", "/api", true);
   xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   xhr.send("token=xxxxxxx");
   xhr.onload = () => {
      let x = xhr.status == 200 ? xhr.response : false;     //console.log(x) gives proper response
      return x;
   }
}

When I try to declare it in variable or use it as callback it gives me Uncaught Error.

For example if I declare it like this

let fn = xhrcall()
console.log(fn)        //will gives me undefined result
window.callback = xhrcall()
callback()             //will gives uncaught error not a function

As I recalled, this should be fine and working yet it not.

This could be duplicate questions but I hope someone could explain what is actually wrong here. Did I miss the function scope? or is it the problem with return x?

Thank you.

Find a specific ID from the array javascript dynamoDB(local)

This is Array
response:

  {
      "sk": "srName",
      "Name" : "John",
      "pk": "srName:6666ad97-53bf-4557-8b19-a552a75edd39"
    },
    {
      "sk": "srName",
      "Name": "Brian",
      "pk": "srName:7f3569b2-62aa-4ac3-a2e8-10255fdb0769"
    }
  ]

I’m trying to write code in javascript to GET specific item from above array

GET http://localhost:3000/6666ad97-53bf-4557-8b19-a552a75edd39

response should be:

[
    {
        "eventId": "6666ad97-53bf-4557-8b19-a552a75edd39",
        "Name" : 'Brian'
       
    }
]

Await in next js causing infinite loading with no error

I’m trying to query a db with drizzle and show the results but when I await the function querying the db my app starts reloading and never stops until i remove the await. When i remove the await I get a promise and I even tried using .then but the promise won’t resolve

"use server"

import { db } from "@/server"

export default async function getPosts(){
  const posts = await db.query.PostsTable.findMany()
  if (!posts){
    return {error: "No posts found"}
  } else {
    return {success: posts}
  }
}

get-posts.ts

import Image from "next/image";
import "dotenv/config"
import getPosts from "@/server/actions/get-posts";


export default async function Home() {
  const data = await getPosts()
  console.log(data) 

  return (
    <main className="flex min-h-screen flex-col items-center justify-between p-24">
      <h1>Hello</h1>
    </main>
  );
}

page.tsx

JS not opening a button as intended

I’m working on a header section in HTML and decided to learn JavaScript in this project. I’m also using TailwindCSS, with a few specifics I included in a different .css file.

I got the JS code from w3schools and adapted it to fit my current setup.

I don’t really understand why the menu isnt opening when I click the button.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="output.css">
    <link rel="stylesheet" href="alt.css">
</head>
<body style="background-color: #171614;">

<script>
function menudd() {
    document.getElementById(menu-main).classList.toggle("show");
}

window.onclick = function(event) {
    if (!event.target.matches('.menub')) {
        var dropdowns = document.getElementsByClassName("ddcontent");
        var i;
        for (i = 0; i < dropdowns.length; i++) {
            var openDropdown = dropdowns[i];
            if (openDropdown.classList.contains('show')) {
                openDropdown.classList.remove('show');
            }
        }
    }
}
</script>


    <div class="flex bg-prim py-1">
        <button onclick="menudd()" class="menub p-2 ml-2"><img src="./content/logowhite.png" width="50" height="50"></button>
        <div id="menu-main" class="ddcontent absolute bg-sec-orange mx-5 min-w-40 z-1">
            <ul>
                <li class="px-12 py-2 block text-center nav-button cursor-pointer">a</li>
                <li class="px-12 py-2 block text-center nav-button cursor-pointer">b</li>
                <li class="px-12 py-2 block text-center nav-button cursor-pointer">c</li>
            </ul>
        </div>
        <div class="relative hidden lg:flex items-center ml-auto pr-6">
            <nav class="text-sm leading-6 font-semibold text-bone">
                <ul class="ddcontent flex space-x-8">
                    <li><a class="bg-sec-orange rounded-full p-3 hover:cursor-pointer nav-button">Artists</a></li>
                    <li><a class="bg-sec-orange rounded-full p-3 hover:cursor-pointer nav-button">Contact Us</a></li>
                </ul>
            </nav>
        </div>    
    </div>
</body>
</html>

And here’s alt.css

.bg-prim {
    background-color: #7a1d00;
}

.bg-sec-orange {
    background-color: #ba3f1d;
}

.bg-sec-grey {
    background-color: #545f71;
}

.text-bone {
    color: #ece2d0;
}

.nav-button:hover {background-color: #7A1D00; transition: background-color 100ms ease-in-out;}

#menu-main {
    display: none;
}

.show {display: block;}

I tried many different things, such as playing around with Tailwind and even entering my own lines of CSS, however I’m not really sure what I’m supposed to get this working as intended.

PHP echo out an href that contains javascript and php variables

Consider the following href:

<a href="javascript:loadRightMain('director_u.mv?func=1215&sub1=0&SRVID=<?php echo $srvs['id']; ?>&CLIENTID=<?php echo $CLIENTID; ?>');">$</a>

I would like to echo the entire href inside php tags more like:

<?php

echo "<a href="javascript:loadRightMain('director_u.mv?func=1215&sub1=0&SRVID=".$srvs['id']."&CLIENTID=".$CLIENTID."');">$</a>";

?>

Of course the issue is with all the conflicting single and/or double quotes.
Is there a way to do this? Or am I approaching the whole idea wrong?

Calculating the area of packaging dieline from DXF file using JavaScript

Here my dxd file dieline image dxd file dieline image

I want to calculate the area of dieline in dxd file

Heres my dxd file:

https://drive.google.com/file/d/1crCl0uiSOHN4idBfQVTUIu6BJ0ZdhS5-/view?usp=sharing

Here my Next js code:

 

import Head from "next/head";
import React, { useRef, useState } from "react";
import DxfParser from 'dxf-parser';
import { parse as parsePath } from 'svg-path';

export default function Home() {
  const fileInput = useRef(null);
  const [area, setArea] = useState(0);
  const [areaOfObjectInSvg, setAreaOfObjectInSvg] = useState(0);
  const [dimensions, setDimensions] = useState({});
  const [svgContent, setSvgContent] = useState('');

  const handleFileChange = (event) => {
    const file = event.target.files[0];
    const reader = new FileReader();
    reader.onload = () => {
      const dxfString = reader.result;
      try {
        const drawing = new DxfParser().parseSync(dxfString);
        const { width, height, calculatedArea } = calculateDimensions(drawing);
        setDimensions({ width, height, drawing });
        setArea(calculatedArea);

        const svgData = renderDXFToSVG(drawing);
        setSvgContent(svgData);

        // Calculate area of SVG content
        const svgArea = calculateAreaOfSVG(svgData);
        setAreaOfObjectInSvg(svgArea);

      } catch (err) {
        console.error('Error parsing DXF:', err);
      }
    };
    reader.readAsText(file);
  };

  const calculateDimensions = (dxf) => {
    let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
    let totalArea = 0;
    dxf.entities.forEach(entity => {
      if (entity.type === 'LINE') {
        entity.vertices.forEach(vertex => {
          if (vertex.x < minX) minX = vertex.x;
          if (vertex.y < minY) minY = vertex.y;
          if (vertex.x > maxX) maxX = vertex.x;
          if (vertex.y > maxY) maxY = vertex.y;
        });
      } else if (entity.type === 'LWPOLYLINE') {
        const area = calculatePolygonArea(entity.vertices);
        totalArea += area;
      }
    });

    const width = maxX !== -Infinity && minX !== Infinity ? maxX - minX : 0;
    const height = maxY !== -Infinity && minY !== Infinity ? maxY - minY : 0;

    return { width, height, calculatedArea: totalArea };
  };

  const calculatePolygonArea = (coords) => {
    let area = 0;
    const numPoints = coords.length;
    for (let i = 0; i < numPoints; i++) {
      const j = (i + 1) % numPoints;
      area += coords[i].x * coords[j].y;
      area -= coords[j].x * coords[i].y;
    }
    area = Math.abs(area) / 2;
    return area;
  };

  const renderDXFToSVG = (dxf) => {
    const width = dimensions.width;
    const height = dimensions.height;
    let svgElements = `<svg xmlns="http://www.w3.org/2000/svg">`;

    dxf.entities.forEach(entity => {
        if (entity.type === 'LINE') {
          svgElements += `
            <line 
              x1="${entity.vertices[0].x}" 
              y1="${entity.vertices[0].y}" 
              x2="${entity.vertices[1].x}" 
              y2="${entity.vertices[1].y}" 
              stroke="black" 
              stroke-width="2" />
          `;
        } 
        else if (entity.type === 'ARC') {
          const { center, radius, startAngle, endAngle } = entity;
          const startX = center.x + radius * Math.cos(startAngle);
          const startY = center.y + radius * Math.sin(startAngle);
          const endX = center.x + radius * Math.cos(endAngle);
          const endY = center.y + radius * Math.sin(endAngle);
  
          const largeArcFlag = (Math.abs(endAngle - startAngle) > Math.PI) ? 1 : 0;
          const sweepFlag = 1;
  
          const pathData = `
            M ${startX} ${startY}
            A ${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${endX} ${endY}
          `;
  
          svgElements += `
            <path 
              d="${pathData}" 
              stroke="black" 
              stroke-width="2" 
              fill="none" />
          `;
        } else if (entity.type === 'LWPOLYLINE') {
          const points = entity.vertices.map(v => `${v.x},${v.y}`).join(' ');
          svgElements += `
            <polygon 
              points="${points}" 
              stroke="black" 
              stroke-width="2" 
              fill="none" />
          `;
        }
    });

    svgElements += `</svg>`;
    return svgElements;
  };

  const calculateAreaOfSVG = (svgContent) => {
    const parser = new DOMParser();
    const svgDoc = parser.parseFromString(svgContent, 'image/svg+xml');
    const svg = svgDoc.documentElement;

    let totalArea = 0;

    svg.querySelectorAll('path').forEach(shape => {
      const pathData = shape.getAttribute('d');
      const parsedPath = parsePath(pathData);
      const pathArea = calculatePathArea(parsedPath);
      totalArea += pathArea;
    });

    svg.querySelectorAll('polygon').forEach(shape => {
      const points = shape.getAttribute('points').trim().split(/s+/);
      const coords = points.map(point => point.split(',').map(Number));
      const polygonArea = calculatePolygonArea(coords);
      totalArea += polygonArea;
    });

    return totalArea;
  };

  const calculatePathArea = (path) => {
    const points = [];
    path.forEach(segment => {
      if (segment.command === 'M') {
        points.push([segment.x, segment.y]);
      } else if (segment.command === 'L') {
        points.push([segment.x, segment.y]);
      } else if (segment.command === 'Z') {
        points.push(points[0]);
      }
    });
    return calculatePolygonArea(points);
  };


  function extractPoints(segments) {
    let points = [];

    segments.forEach(segment => {
      if (segment.type === 'LINE') {
        points.push(segment.vertices[0]);
        points.push(segment.vertices[1]);
      } else if (segment.type === 'ARC') {
      }
    });

    return points;
  }

  function isShapeClosed(vertices) {
    const tolerance = 0.0001; // Tolerance for floating-point comparison

    // Extract points from the shape segments
    const points = extractPoints(vertices);

    // Check if the first and last points are approximately equal
    if (points.length < 2) {
      return false;
    }

    const firstPoint = points[0];
    const lastPoint = points[points.length - 1];

    return Math.abs(firstPoint.x - lastPoint.x) < tolerance &&
      Math.abs(firstPoint.y - lastPoint.y) < tolerance;
  }

  return (
    <>
      <Head>
        <title>DXF PARSER</title>
        <meta name="description" content="DXF PARSER BY HAMMAD" />
      </Head>
      <main>
        <input type="file" ref={fileInput} onChange={handleFileChange} />

        <div className="flex gap-[30px] mt-[30px]">
          <div>
            <p>Width: {dimensions?.width?.toFixed(3)} mm</p>
            <p>Height: {dimensions?.height?.toFixed(3)} mm</p>
          </div>

          <div>
            <p>Width: {(dimensions?.width * 0.0393701).toFixed(3)} inches</p>
            <p>Height: {(dimensions?.height * 0.0393701).toFixed(3)} inches</p>
          </div>

          <h2>Total Area: {((dimensions?.width *  dimensions?.height) / 100).toFixed(3)} cm2</h2>
          <div>Area of SVG Object: {areaOfObjectInSvg.toFixed(3)} cm2</div>
        </div>
        <br />
        <div className="main_svg_class" dangerouslySetInnerHTML={{ __html: svgContent }} />
      </main>
    </>
  );
}

Need Corrected Code to Calculate the accurate dieline area through the dxf file

Get Transformed Box Coordinates in Javascript (getBoxQuads)

I’ve created a polyfill for the getBoxQuads API (https://hacks.mozilla.org/2014/03/introducing-the-getboxquads-api/), but it does not work if I use transform in css with perspective in it. (see my sample app here: https://jogibear9988.github.io/getBoxQuadsPolyfill/), the overlay for these 2 boxes is wrong:
enter image description here

source is here: https://github.com/jogibear9988/getBoxQuadsPolyfill

What did I do in the polyfill? I combine all the transform applied to an element, I apply a translateTransform for it’s offset position and multiply with a the parent transforms.

But somehow this only works for 2D.

The resulting Point has a “z” value where the overlay is wrong, but I don’t know how to convert back to 2D.

HTML form not populating correctly, What am I doing wrong?

I have a javascript application where I need to save the user selections in a HTML form that I need to retrun to the form when the user returns to the page with the form. I have implemented solutions that I have found here on stackoverflow, in fact the code below that I am using comes from this link

Here are two versions of that code

function dataLoad() 
        {
            if (typeof(Storage)!== "undefined")
            {
                if (localStorage.getItem('settingsObject') !== null) 
                {
                    console.log("in dataLoad");
                    var inputParse = JSON.parse(localStorage.getItem('settingsObject'));
                    console.log(inputParse);
                    $.each(inputParse, function (key, value) {
                        var field = document.getElementById(key);
                        if(field.type == 'radio' || field.type == 'checkbox'){
                            field.checked = value;
                        }else{
                            field.value = value;
                        }
                    });
                }
            }
            else
            {
                document.getElementById("result").innerHTML = "Sorry, your browser does not support Web Storage...";
            }
            
        }
                    
        function dataLoad() 
        {
            if (typeof(Storage) !== "undefined")
            {
                if (localStorage.getItem('settingsObject') !== null) 
                {
                    alert("in dataLoad");
                    var inputParse = JSON.parse(localStorage.getItem('settingsObject'));
                    console.log(inputParse);
                    $.each(inputParse, function(key, value) {
                      var field = document.querySelector("[name=" + key + "]");
                      if (field.type == 'radio' || field.type == 'checkbox') {
                        field.checked = field.value == value;
                      } else {
                        field.value = value;
                      }
                    });
                }
                
            }
            else 
            {
              document.getElementById("result").innerHTML = "Sorry, your browser does not support Web Storage...";
            }

        }

Here is my form

<form id="settingsInput" class="dropdown contents" autocomplete="on" target="hiddeniFrame">
                
                <fieldset class="locfield">
                    <legend>Location<br></legend>
                    <input type="radio" name="location" value="auto" id="autoloc" checked><label for="autoloc"> Auto</label><br><hr class="settingsDivider">
                    <input type="radio" name="location" value="city" id="cityloc"><label for="cityloc"> City</label><br>
                    Select City:<br>
                    <select name="cities" class="locinput" style="width:6em">
                        <option value="0" selected>U.S. Cities</option>
                        <option value="1">Albuquerque, NM</option>
                        <option value="2">Anchorage, AK</option>
                        <option value="3">Atlanta, GA</option>
                        <option value="4">Austin, TX</option>
                    </select><br>
                    <span><label for="Citydst" style="font-size:15px">Daylight Saving?</label></span><br>
                    <input type="checkbox" name="CityDST" value="DST" id="Citydst"><br>
                    <hr class="settingsDivider">
                    
                    <input type="radio" name="location" value="manual" id="manualloc"><label for="manualloc"> Manual</label><br>
                    
                    Latitude:<br> <input type="number" name="latitude" maxlength="10" class="locinput" style="width:6em"><br>
                    <input type="radio" name="NS" value="north" id="North"><label for="North"> North</label><br>
                    <input type="radio" name="NS" value="south" id="South"><label for="South"> South</label><br>
                    Longitude:<br> <input type="number" name="longitude" class="locinput" style="width:6em"><br>
                    <input type="radio" name="EW" value="east" id="East"><label for="East"> East</label><br>
                    <input type="radio" name="EW" value="west" id="West"><label for="West"> West</label><br>
                    Elevation:<br> <input type="number" name="landelev" class="locinput" style="width:6em"><br>
                    <input type="radio" name="elevunits" value="feet" id="feet"><label for="feet"> Feet</label><br>
                    <input type="radio" name="elevunits" value="meters" id="meters"><label for="meters"> Meters</label><br>
                    Time Zone:<br> <select name="timezones">
                        <option value="-12">UTC-12</option>
                        <option value="-11">UTC-11</option>
                        <option value="-10">UTC-10</option>
                        <option value="-9">UTC-9</option>
                        <option value="-8">UTC-8</option>
                        <option value="-7">UTC-7</option>
                        <option value="-6">UTC-6</option>
                        <option value="-5">UTC-5</option>
                        <option value="-4">UTC-4</option>
                        <option value="-3">UTC-3</option>
                        <option value="-2">UTC-2</option>
                        <option value="-1">UTC-1</option>
                        <option value="0">UTC+0</option>
                        <option value="1">UTC+1</option>
                        <option value="2">UTC+2</option>
                        <option value="3">UTC+3</option>
                        <option value="4">UTC+4</option>
                        <option value="5">UTC+5</option>
                        <option value="6">UTC+6</option>
                        <option value="7">UTC+7</option>
                        <option value="8">UTC+8</option>
                        <option value="9">UTC+9</option>
                        <option value="10">UTC+10</option>
                        <option value="11">UTC+11</option>
                        <option value="12">UTC+12</option>
                    </select><br>
                    <span><label for="Manualdst" style="font-size:15px">Daylight Saving?</label></span><br>
                    <input type="checkbox" name="ManualDST" value="DST" id="Manualdst">
                </fieldset>
                <fieldset class="datefield">
                    <legend>Date</legend>
                    <input type="radio" name="dateMode" value="auto" id="autodate" checked><label for="autodate"> Auto</label><br><hr class="settingsDivider">
                    <input type="radio" name="dateMode" value="manual" id="manualdate"><label for="manualdate"> Manual</label><br>
                    Select Date:<br>
                    <input type="date" name="dateInput" class="dateinput" style="width:6em"><br><hr class="settingsDivider">
                    <!--<label for="dst" style="font-size:15px">Daylight Saving?</label></span><br>
                    <input type="checkbox" name="DST" value="DST" id="dst"><span style="font-size: 13px">-->
                </fieldset>
                <fieldset class="prayerfield">
                    <legend>Prayers</legend>
                    <!--<span style="text-decoration: underline">Subh Cond:</span><br>-->
                    <span>Subh Cond:</span><br>
                    <input type="radio" name="subhMode" value="12" id="subhurban" checked><span><label for="subhurban"> Urban</label></span><br>
                    <input type="radio" name="subhMode" value="15" id="subhwild"><span style="font-size: 17px"><label for="subhwild"> Wilderness</label></span><br><hr class="settingsDivider">
                    <span class="dhuhurtext">Dhuhur Shadow:</span><br>
                    <input type="radio" name="dhuhurMode" value="42" id="dhuhursandal"><span style="font-size: 15px"><label for="dhuhursandal"> Sandal Strap</label></span><br>
                    <input type="radio" name="dhuhurMode" value="21" id="dhuhurhand" checked><span style="font-size: 17px"><label for="dhuhurhand"> Hand Span</label></span><br>
                    <input type="radio" name="dhuhurMode" value="7" id="dhuhurfoot"><span style="font-size: 17px"><label for="dhuhurfoot"> Foot Span</label></span><br><hr class="settingsDivider">
                    <!--<span style="text-decoration: underline">Asr Shadow:</span><br>-->
                    <span>Asr Shadow:</span><br>
                    <input type="radio" name="asrMode" value="1" id="asrmajority" checked><span style="font-size: 20px"><label for="asrmajority"> Majority</label></span><br>
                    <input type="radio" name="asrMode" value="2" id="asrhanafi"><span><label for="asrhanafi"> Hanafi</label></span><br><hr class="settingsDivider">
                    <!--<span style="text-decoration: underline">Isha Cond:</span><br>-->
                    <span>Isha Cond:</span><br>
                    <input type="radio" name="ishaMode" value="12" id="ishaurban"><span><label for="ishaurban"> Urban</label></span><br>
                    <input type="radio" name="ishaMode" value="15" id="ishawild" checked><span style="font-size: 17px"><label for="ishawild"> Wilderness</label></span><br>
                </fieldset>
                <div class="set-section">
                    <button type="button" name="prayertimes" value=" Save " onclick="chooseMethod(this.form)">Save</button>
                </div>
                <div class="update-section">
                    <button type="button" name="updateprayertimes" value=" Update " onclick="chooseMethod(this.form)">Update</button>
                </div>
                <div class="reset-section">
                    <button type="reset" value=" Reset ">Reset</button>
                </div>
                <script>
                    document.getElementById("settingsInput").addEventListener("submit", function(e) {
                        e.preventDefault();
                    });
                    //Rest of your js code here...
                </script>
            </form>

I have had more success with the bottom version than the top version. Actually the top version does not seem to repopulate any of the elements, while the bottom version does a better job, but fails to populate the radio buttons named “location” and the radio buttons named “auto”, “cities”, and “manual”, as well as the radio buttons named “NS” and “EW”. Sometimes the radio button for “dateMode” doe not get repopulated. The funny thing is that the radio buttons named “subhMode”, “dhuhurMode”, “asrMode”, and “ishaMode” always get repopulated.

What am I doing wrong?

How to decode compiledInstructions with js- Solana

I am trying to decode the ‘compiledInstructions’
How to go from this:

compiledInstructions: [
    {
      programIdIndex: 6,
      accountKeyIndexes: [],
      data: <Buffer 02 f0 49 02 00>
    },
    {
      programIdIndex: 6,
      accountKeyIndexes: [],
      data: <Buffer 03 55 81 f2 07 00 00 00 00>
    },
    {
      programIdIndex: 7,
      accountKeyIndexes: [Array],
      data: <Buffer 52 e1 77 e7 4e 1d 2d 46 cf e5 99 66 00 00 00 00 00 67 04 76 00 00 00 00 d0 ed 77 b5 6d 0b 00 00 00 2d 31 01 00 00 00 00>
    },
    {
      programIdIndex: 12,
      accountKeyIndexes: [Array],
      data: <Buffer 02 00 00 00 c0 e1 e4 00 00 00 00 00>
    }
  ],
  addressTableLookups: [
    {
      accountKey: [PublicKey [PublicKey(4QHABYqrbhcj3EtknQ3dYewAmjuqU9Pstuo7kcCcz3FM)]],
      readonlyIndexes: [Array],
      writableIndexes: [Array]
    }
  ]

to this: solscan
I know there are 4 transactions involved, but only the third one seems to have useful information, I need just the token bought and for how much.

I read the Solana official transactions and instructions docs but found nothing useful.

Error ”Cannot read properties of undefined (reading ‘canvas’)” while creating a pixi.js app

I am getting the error Cannot read properties of undefined (reading 'canvas') while trying to run a pixi.js app. Here is my code :

 <script src = 'js/pixi.min.js'></script>
 <script>

       let app;
       window.onload = function() {
       app = new PIXI.Application(
          {
              width: 800,
              height: 600,
              backgroundColor: 0xAAAAAA
          }
          );
       document.body.appendChild(app.view);
    }; 

</script>

I am using pixi.js version 8. This error specifically comes from app.view. Why am I getting this error?

It seems to have worked for other people so I don’t why it isn’t for me.

How can I avoid cursor to jump to invalid fields

I have code like this:

    <div class="form-wrapper">
        <div class="form-input">
            <span class="form-name">Date des faits</span>
            <input id="date-faits" type="text" pattern="(?:(?:31(/|-|.)(?:0?[13578]|1[02]))1|(?:(?:29|30)(/|-|.)(?:0?[13-9]|1[0-2])2))(?:(?:1[6-9]|[2-9]d)?d{2})$|^(?:29(/|-|.)0?23(?:(?:(?:1[6-9]|[2-9]d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1d|2[0-8])(/|-|.)(?:(?:0?[1-9])|(?:1[0-2]))4(?:(?:1[6-9]|[2-9]d)?d{2})" autofocus="false" />
        </div>
        <div class="form-input">
            <span class="form-name">Lieu des faits</span>
            <input id="lieu-faits" type="text" autofocus="false" />
        </div>
...

I didn’t tried on chrome but on firefox when writing to the non required field my text cursor jumps automatically to invalid required field.

I also have a javascript validation class but I don’t use focus method or programatically jump to any inputs.

How can I avoid that?

note: I use reportValidity() in my validation class