Outlook plugin for website for view email

I have one site there client upload email for daily but when I view that email that email download. I want any plugin for outlook so when I view those email that are not download directly open throw that plugin.

I will try do this process directly to pc ya laptop system but there are some security issue that why that not happened.

Unexpected Jump in `movementX` and `movementY` Values in Chrome and Edge

I’m experiencing an unusual issue with mouse event handling in Chrome and Edge browsers (latest versions), which I don’t encounter in Firefox. The problem involves unexpected jumps in the values of movementX and movementY during mouse movement.

Background:
I am developing a web application that requires precise mouse movement tracking. I use requestPointerLock() to lock the mouse pointer for an immersive experience. The application heavily relies on the movementX and movementY properties of MouseEvent to track the mouse’s movement.

Issue:
When I move the mouse slowly, the values of movementX and movementY occasionally jump to a large number (e.g., from around 1 to 627), indicating a sudden, unrealistic change in the mouse position. This issue seems to occur only in Chrome and Edge, but not in Firefox.

Code Sample:

// Sample code demonstrating how I handle mouse events
document.addEventListener("mousemove", (event) => {
    let movementX = event.movementX;
    let movementY = event.movementY;

    // Process the movement
    // ...
});

Attempts to Resolve:

  • I have tried implementing a moving average filter to smooth out the values, but the issue persists.
  • Considering the possibility of a browser-specific issue, I have tested this on the latest versions of Chrome and Edge, as well as on Firefox where the issue does not occur.

Question:
Has anyone else encountered this kind of behavior in Chrome and Edge? Are there any known issues with how these browsers handle movementX and movementY in MouseEvent, especially when the pointer is locked? Any insights or suggestions on how to handle these unexpected jumps in mouse movement values would be greatly appreciated.

what will be the output of a variable which copies another object values

Predict the output of the below snippet and also specify the reason for the same

var a = {
x: 10,
y: ‘strOuter’,
z: {
val1: 20,
val2: ‘strInner’
}
};

var b = { …a };

b.x = 15 ;

b.y = ‘strOuter_append’ ;

b.z.val1 = 25;

b.z.val2 = ‘strInner_append’;

console.log(a);

I am guessing it to be as below thinking it works on the princple of pass by reference, kindly assist

{ x: 15, y: ‘strOuter_append’, z: { val1: 25, val2: ‘strInner_append’ } }

Using createRef inside useRef

I’m using createRef inside useRef. Do you think this is redundant? Should I have an audios array and a separate audioRefs array, especially since createRef is probably doing nothing because it only works in class components?

import { useRef, createRef, forwardRef, MutableRefObject } from 'react';
import Slider from 'rc-slider';
import 'rc-slider/assets/index.css';

const audios = [
  {
    src: 'https://onlinetestcase.com/wp-content/uploads/2023/06/100-KB-MP3.mp3',
  },
];

interface Props {
  src: string;
}

const Audio = forwardRef<HTMLAudioElement, Props>(
  (props: Props, ref: MutableRefObject<HTMLAudioElement>) => {
    const { src } = props;

    function handleVolumeChange(value) {
      ref.current.volume = value / 100;
    }

    return (
      <>
        <audio ref={ref} loop>
          <source src={src} type="audio/mpeg" /> Your browser does not support
          the audio element.
        </audio>
        <Slider
          min={0}
          max={100}
          step={1}
          value={ref.current?.volume}
          onChange={handleVolumeChange}
        />
      </>
    );
  }
);

export const App = ({ name }) => {
  const audioRefs = useRef(
    audios.map((audio) => ({
      ...audio,
      ref: createRef<HTMLAudioElement>(),
    }))
  );

  function playAudio() {
    audioRefs.current?.forEach((audioRef) => audioRef.ref.current.play());
  }

  return (
    <>
      {audioRefs.current?.map((audioRef, index) => (
        <>
          <Audio key={audioRef.src} {...audioRef} />
          <button onClick={playAudio}>Play Audio</button>
        </>
      ))}
    </>
  );
};

Live code at StackBlitz

Prisma + PostgreSQL — Connect or create many-to-many relationship

I’m trying to create a message threading system on my web app similar to iMessage. Every user has many threads they’re a part of, every thread has many messages, and each message has many recipients. I’ve handled creating the message and adding each recipient.

But where I keep getting lost is creating the thread. I want to query my database to try and find a thread with all of the recipients (including sender) of the message. If no thread exists with all those individuals, then create a new one. The reason I’m running into an error is that prisma won’t let me query by any field that’s not unique. Is there a simple work-around to get around this?

Tried creating an array of ‘users’ and trying to findFirstOrThrow against my prisma database. Doesn’t work since this list may not be unique

Correct movement of rectangular blocks inside canvas in fabric.js library

It is necessary to make it so that blocks regardless of width and length do not overlap with each other and do not go beyond the borders of the canvas when moving and when resizing. Blocks can be either full width or full length, and with the side of the minimum cell.
If anyone has a solution or at least the direction in which to move I will be very happy

Here is my code. It does not work quite correctly, because in some cases it jumps to the wrong zones behind the canvas or inside another block.

const canvasSize = { width: 1923, height: 1083 }
const cellDimensions = { width: 120, height: 120 }
const borderStrokeWidth = 3
const objectTypes = {
    frame: 'frame',
    gridPoint: 'point',
    gridLine: 'line',
}

const initialFramesList = [
    {
        top: 120,
        left: 120,
        width: 240,
        height: 480,
    },
    {
        top: 120,
        left: 600,
        width: 480,
        height: 720,
    },
]

let drawingCanvas

initCanvas()
initFrames(initialFramesList)

function initCanvas(id = 'canvas') {
    let startX
    let startY
    let endX
    let endY
    let activeFrame

    drawingCanvas = new fabric.Canvas(id, {
        height: canvasSize.height + borderStrokeWidth,
        width: canvasSize.width + borderStrokeWidth,
        hoverCursor: 'default',
        backgroundColor: 'gray',
        selection: false,
    })

    const onClickPoint = (e) => {
        const isGridPoint = e.target?.type === objectTypes.gridPoint

        if (isGridPoint && !activeFrame) {
            const { top: y, left: x, width: d } = e.target
            const r = d / 2
            startX = x + r
            startY = y + r
            activeFrame = createFrame({ x: startX, y: startY })
            drawingCanvas.add(activeFrame)
        } else if (activeFrame) {
            startX = null
            startY = null
            endX = null
            endY = null
            activeFrame.setCoords()
            activeFrame = null
            drawingCanvas.renderAll()
        }
    }

    const widgetsLoop = (fn) => {
        const widgets = drawingCanvas.getObjects(objectTypes.frame)
        widgets.forEach((obj) => {
            fn(obj)
        })
    }

    const getAbsolutePosition = (el) => {
        return el.group
            ? { x: el.group.left, y: el.group.top }
            : { x: el.left, y: el.top }
    }

    const hasIntersection = (target, obj) => {
        const { x: targetLeft, y: targetTop } = getAbsolutePosition(target)
        const { x: objLeft, y: objTop } = getAbsolutePosition(obj)
        const {
            width: targetWidth,
            height: targetHeight,
            originX: targetOriginX,
            originY: targetOriginY,
        } = target
        const { width: objWidth, height: objHeight } = obj

        const rectLeftCorrect =
            targetOriginX === 'right'
                ? targetLeft - targetWidth - borderStrokeWidth
                : targetLeft
        const rectTopCorrect =
            targetOriginY === 'bottom'
                ? targetTop - targetHeight - borderStrokeWidth
                : targetTop

        const xIntersection =
            rectLeftCorrect + targetWidth > objLeft &&
            rectLeftCorrect < objLeft + objWidth
        const yIntersection =
            rectTopCorrect + targetHeight > objTop &&
            rectTopCorrect < objTop + objHeight

        return xIntersection && yIntersection
    }

    const limitFrameMoving = (target) => {
        const { width: screenW, height: screenH } = canvasSize
        const { x: rectLeft, y: rectTop } = getAbsolutePosition(target)
        const {
            originX: targetOriginX,
            originY: targetOriginY,
            width: targetW,
            height: targetH,
        } = target
        const rectLeftCorrect =
            targetOriginX === 'right'
                ? rectLeft - targetW - borderStrokeWidth
                : rectLeft
        const rectTopCorrect =
            targetOriginY === 'bottom'
                ? rectTop - targetH - borderStrokeWidth
                : rectTop

        if (rectLeftCorrect < 0) {
            target.set({ left: 0 })
        } else if (rectLeftCorrect + targetW > screenW) {
            target.set({ left: screenW - targetW })
        }

        if (rectTopCorrect < 0) {
            target.set({ top: 0 })
        } else if (rectTopCorrect + targetH > screenH) {
            target.set({ top: screenH - targetH })
        }
    }

    const setValidSize = (target) => {
        const { width: cellW, height: cellH } = cellDimensions

        widgetsLoop((obj) => {
            if (obj === target) {
                return
            }

            if (hasIntersection(target, obj)) {
                const { x: rectLeft, y: rectTop } = getAbsolutePosition(target)
                const { x: objLeft, y: objTop } = getAbsolutePosition(obj)
                const { originX: targetOriginX, originY: targetOriginY } =
                    target
                const { width: objWidth, height: objHeight } = obj

                const rectLeftCorrect =
                    targetOriginX === 'right'
                        ? rectLeft - objWidth - borderStrokeWidth
                        : rectLeft
                const rectTopCorrect =
                    targetOriginY === 'bottom'
                        ? rectTop - objHeight - borderStrokeWidth
                        : rectTop

                const dx = Math.abs(rectLeftCorrect - objLeft)
                const dy = Math.abs(rectTopCorrect - objTop)

                if (dx > dy && target.width > dx) {
                    target.set({ width: dx, cellY: dx / cellW })
                } else if (dx < dy && target.height > dy) {
                    target.set({ height: dy, cellY: dy / cellH })
                }
            }
        })
    }

    const setValidPosition = (target) => {
        widgetsLoop((obj) => {
            if (obj === target) {
                return
            }

            limitFrameMoving(target)

            if (hasIntersection(target, obj)) {
                const dx = Math.abs(target.left - obj.left)
                const dy = Math.abs(target.top - obj.top)
                if (dx > dy) {
                    target.set({ left: obj.left - target.width })
                    if (target.left < 0) {
                        target.set({ left: obj.left + obj.width })
                    }
                } else {
                    target.set({ top: obj.top - target.height })
                    if (target.top < 0) {
                        target.set({ top: obj.top + obj.height })
                    }
                }
            }
        })
        drawingCanvas.renderAll()
    }

    drawingCanvas.on('mouse:over', (e) => {
        if (e.target?.type === objectTypes.gridPoint) {
            drawingCanvas.bringToFront(e.target)
            e.target.set('opacity', 1)
            drawingCanvas.renderAll()
        }
    })

    drawingCanvas.on('mouse:out', (e) => {
        if (e.target?.type === objectTypes.gridPoint) {
            e.target.set('opacity', 0)
            drawingCanvas.renderAll()
        }
    })

    drawingCanvas.on('mouse:down', (e) => {
        onClickPoint(e)
    })

    drawingCanvas.on('mouse:move', (e) => {
        if (!activeFrame) {
            return
        }

        const { width: cellW, height: cellH } = cellDimensions
        const pointerX = Math.floor(e.pointer.x / cellW) * cellW
        const pointerY = Math.floor(e.pointer.y / cellH) * cellH

        const width = pointerX - startX + cellW
        const height = pointerY - startY + cellH

        if (pointerX >= startX) {
            activeFrame.set({ width, cellX: width / cellW })
        }

        if (pointerY >= startY) {
            activeFrame.set({ height, cellY: height / cellH })
        }

        setValidSize(activeFrame)

        drawingCanvas.renderAll()
    })

    drawingCanvas.on('object:scaling', (e) => {
        const target = e.target
        const { width: cellW, height: cellH } = cellDimensions
        const width = Math.round((target.width * target.scaleX) / cellW) * cellW
        const height =
            Math.round((target.height * target.scaleY) / cellH) * cellH
        const { originX, originY, corner } = e.transform
        const { y: top, x: left } = target.getPointByOrigin(originX, originY)

        target.set({
            originX,
            originY,
            left,
            top,
            scaleX: 1,
            scaleY: 1,
            width: width > cellW ? width : cellW,
            height: height > cellH ? height : cellH,
            cellX: width / cellW,
            cellY: height / cellH,
            lockScalingFlip: true,
        })

        setValidSize(target)
    })

    drawingCanvas.on('object:moving', (e) => {
        const target = e.target
        const { width: cellW, height: cellH } = cellDimensions
        const left = Math.floor(target.left / cellW) * cellW
        const top = Math.floor(target.top / cellH) * cellH
        target.set({
            left,
            top,
        })
        setValidPosition(target)
    })

    drawingCanvas.on('object:modified', (e) => {
        const obj = e.target
        const { y: top, x: left } = obj.getPointByOrigin('left', 'top')
        obj.set({ top, left, originX: 'left', originY: 'top' })
        drawingCanvas.renderAll()
    })

    drawGrid()
}

function drawGrid() {
    const { width: colSize, height: rowSize } = cellDimensions

    const makePoint = (x, y) => {
        const r = 8
        const point = new fabric.Rect({
            top: y - r,
            left: x - r,
            width: r * 2,
            height: r * 2,
            rx: 1,
            ry: 1,
            fill: 'black',
            hasControls: false,
            hasBorders: false,
            selectable: false,
            opacity: 0,
            type: objectTypes.gridPoint,
            hoverCursor: 'pointer',
        })

        drawingCanvas.add(point)
    }

    const drawLine = (params) => {
        const line = new fabric.Line(params, {
            stroke: 'yellow',
            borderStrokeWidth: borderStrokeWidth,
            selectable: false,
            evented: false,
            type: objectTypes.gridLine,
        })
        drawingCanvas.add(line)
    }

    const makeRows = () => {
        const rowsCount = canvasSize.height / rowSize
        for (let i = 0; i < rowsCount; i++) {
            const y = i * rowSize
            drawLine([0, y, canvasSize.width, y])
        }
    }

    const makeCols = () => {
        const colsCount = canvasSize.width / colSize
        for (let i = 0; i < colsCount; i++) {
            const x = i * colSize
            drawLine([x, 0, x, canvasSize.height])
        }
    }

    const makePoints = () => {
        const rowsCount = canvasSize.height / rowSize
        const colsCount = canvasSize.width / colSize
        for (let i = 0; i < colsCount; i++) {
            const x = i * colSize
            for (let j = 0; j < rowsCount; j++) {
                const y = j * rowSize
                makePoint(x, y)
            }
        }
    }

    makeRows()
    makeCols()
    makePoints()
}

function initFrames(frames) {
    const { width: cellW, height: cellH } = cellDimensions
    frames.forEach(({ top, left, width, height }) => {
        const frame = createFrame(
            {
                x: left,
                y: top,
            },
            {
                width: width,
                height: height,
            }
        )
        frame.set({
            cellX: width / cellW,
            cellY: height / cellH,
            lockScalingFlip: true,
        })
        drawingCanvas.add(frame)
    })
}

function createFrame({ x, y }, { width, height } = { width: 0, height: 0 }) {
    const rect = new fabric.Rect({
        top: y,
        left: x,
        width,
        height,
        stroke: 'gray',
        borderStrokeWidth: borderStrokeWidth,
        fill: 'white',
        type: objectTypes.frame,
        strokeUniform: true,
        noScaleCache: false,
        objectCaching: false,
    })

    return rect
}
<canvas id="canvas"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/4.4.0/fabric.min.js"></script>

Everything I’ve tried is listed in my code. The element rotation will not be used, I will exclude it from the library later.

Spotify Web Api Bad Request When Pulling Playlists on Page Load Using Use Effect

Basically when I try to fetch playlist on page load using useEffect, i get these errors in the chrome console:

-GET https://api.spotify.com/v1/me/playlists 400 (Bad Request)

-Uncaught (in promise) Error: Failed to fetch playlists custom error
at DashboardPage.tsx:44:17

-GET https://api.spotify.com/v1/me/playlists 400 (Bad Request)

-Uncaught (in promise) Error: Failed to fetch playlists custom error
at DashboardPage.tsx:44:17

import { IconPlaylistAdd } from '@tabler/icons-react'
import { useEffect, useState } from 'react'
import { useDisclosure, useInputState } from '@mantine/hooks';
import { Modal, Button, TextInput, Image } from '@mantine/core';

export default function Dashboard() {
  const [playlistName, setPlaylistName] = useInputState('');
  const [playlistDescription, setPlaylistDescription] = useInputState('');
  const [playlists, setPlaylists] = useState([]);
  const userId = 'hidden for privacy'
  const [token, setToken] = useState('');

  useEffect(() => {
    const token = localStorage.getItem('token')
    setToken(`${token}`)
    fetchPlaylists()
    console.log(token)
  }, [])

  const [opened, { open, close }] = useDisclosure(false);

  const renderItem = (playlist: any, index: number) => {
    const imageUrl = playlist.images.length > 0 ? playlist.images[0].url : 'https://placekitten.com/300/300';
    return (
      <div key={index}>
        <Image radius='sm' src={imageUrl} w={150} h={150} />
        <div>{`${playlist.name}`}</div>
      </div>
    );
  };

  const fetchPlaylists = () => {
    fetch('https://api.spotify.com/v1/me/playlists', {
      headers: {
        'Authorization': `Bearer ${token}`
      }
    })
      .then((response) => {
        if (response.ok) {
          return response.json();
        } else {
          throw new Error('Failed to fetch playlists custom error');
        }
      })
      .then((data) => {
        setPlaylists(data.items)
        console.log(data.items)
      })
  }

  function handleSubmit() {
    fetch(`https://api.spotify.com/v1/users/${userId}/playlists`, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${token}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        'name': `${playlistName}`,
        'description': `${playlistDescription}`,
        'public': false
      })
    });
    setTimeout(fetchPlaylists, 500)
    close()
  }

  return (

    <div className="Container">
      <Modal opened={opened} onClose={close} title="Create Playlist">
        <TextInput value={playlistName} placeholder='Playlist name...' onChange={setPlaylistName} />
        <TextInput value={playlistDescription} placeholder='Playlist description...' onChange={setPlaylistDescription} />
        <Button type='submit' onClick={handleSubmit}>Submit</Button>
      </Modal>

      <IconPlaylistAdd onClick={open} size='150' />

      <div>{playlists.map((playlist, index) => renderItem(playlist, index))}</div>

    </div>
  );
}

Although, when i open the modal and press submit, it runs the exact same function but it works. The playlists show up.

I’ve tried setting a timer on the useEffect but I still get the same errors.

HTML pages not working, unable to go to other pages from homepage

I am on cs50’s week 8 pset, homepage, and I have to create a simple webpage to introduce myself. One of the requirements is to make multiple pages, and I have done that, however the links to go to other pages don’t work. I have included images and code below, but in short, when I click on the links to other pages, my website produces an error message that says “(link of page) cannot be found.”

<!DOCTYPE html>

<html lang="en">
    <head>
        <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
        <link href="styles.css" rel="stylesheet">
        <title>My Webpage</title>
    </head>
    <body>
        <main class = "container p-3">
            <h1>Hello, my name is <span id = "name">Kaley</span></h1>
            <h3>Get to know me in this webpage!</h3>
            <!--image here maybe-->
            <h3 class = "about">About Me</h3>
            <ul>
                <li>7987 years old</li>
                <li>Japanese/Korean</li>
                <li>Sadly allergic to some sushi</li>
            </ul>

            <h4 class = "about">These are the schools I've been to</h4>
            <table cellpadding="10">
                <tr>
                    <th>Country</th>
                    <th>School</th>
                </tr>
                <tr>
                    <td>Singapore</td>
                    <td>asdas</td>
                </tr>
                <tr>
                    <td>Japan</td>
                    <td>Iasdasd</td>
                    <td>asdasd</td>
                </tr>
                <tr>
                    <td>Korea</td>
                    <td>asasd</td>
                </tr>
            </table>

            <h5 class = "about">Click on one of these to get to know more about me!</h5>
            <a href = "index.html">Intro</a>
            <a href = "hobbies.html">Hobbies</a>
            <a href = "extracurriculars.html">Extracurriculars</a>
            <a href = "favourites.html">Favourites</a>

        </main>
    </body>
    <script src = "script.js"></script>
</html>

This is my code for index.html, I think I’m using the anchor link and href wrong, but I can’t figure it out.

<!DOCTYPE html>

<html lang="en">
    <head>
        <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
        <link href="styles.css" rel="stylesheet">
        <title>My Webpage</title>
    </head>
    <body>
        <main class = "container p-5">
            <h1>These are my hobbies!</h1>
            <h3 class = "hob">I love...</h3>
            <ul>
                <li>Watching movies and shows</li>
                <li>Reading</li>
                <li>Playing the piano</li>
                <li>Sleeping</li>
            </ul>

            <h5 class = "about">Click on one of these to get to know more about me!</h5>
            <a href = "index.html">Intro</a>
            <a href = "hobbies.html">Hobbies</a>
            <a href = "extracurriculars.html">Extracurriculars</a>
            <a href = "favourites.html">Favourites</a>
            
        </main>
    </body>
</html>

This is the code for one of my pages, hobbies.

This is the error message:
enter image description here

My initial page, the one where titles Index of / is had the links to visit all pages of my websites. When I click index.html, it takes me to my initial homepage, the first code I mentioned, but clicking on any other .html pages just downloads my that page. Ex, clicking on hobbies.html downloads hobbies.html, but doesn’t open it.

JavaScript Es6 vs Es7 – What Difference

Can anyone tell me Difference between these two versions and also tell any depreciation happened between them, New modules،new concepts.Any impact on JavaScript websites or create a bug that overnight your experience. All are need

Points that really matters are welcome

Retriving Point Location from a Scaled PIXI Container

anyone have experience in using PIXI JS?

The question is like this, im trying to code in an OOP style, and here is the main app.js
I set a default screen size as 1920, and scale the Stage() container relative to the client screen size

function startApplication() {
  const canvas = document.querySelector("canvas");

  const app = new PIXI.Application({
    width: canvas.width * window.devicePixelRatio,
    height: canvas.height * window.devicePixelRatio,
    background: "grey",
    resolution: window.devicePixelRatio,
    resizeTo: canvas,
    view: canvas,
  });

  const device_resolution = () =>
    (app.view.width / 1920) * window.devicePixelRatio;

  loadResource("./playerData.json")
    .then((data) => {
      let stageCode = 0;
      const stage = Stage(data, stageCode);
      app.stage.addChild(stage);
      stage.scale.set(device_resolution());

      window.addEventListener("resize", function () {
        stage.scale.set(device_resolution());
      });
    })
    .catch((err) => console.log(err));
}

Inside the Stage PIXI Container, all “stage” elements would be added. To simplify the question, I only added the Battlefield() to the Stage()

export default function Stage(playerData, stageCode) {
  let container = new PIXI.Container();
  loadResource("./stageData.json").then((stageData) => {
    //player name
    let playerAvatar = Avatar(playerData, false);
    let opponentAvatar = Avatar(stageData, true);

    let battleField = BattleField(playerData);

    
    playerAvatar.setWallHp(4300)
    opponentAvatar.setWallHp(1798);

    //battle field
    //unit bar
    
    container.addChild(
      // playerAvatar.getGraphic(),
      // opponentAvatar.getGraphic(),
      battleField.getGraphic()
    );
  });
  return container;
}

In the Battlefield(), I set up a event listener “logLocation” that I can retrieve the mouse position

export default function BattleField(playerData) {
  const container = new PIXI.Container();
  container.position = {
    x: 960,
    y: 120,
  };

  const logLocation = (e) => {
    console.log({
      eClient: e.client,
      eClientX: e.clientX,
      eClientDotX: e.client.x,
    });
  };
  container.on("click", logLocation);
  container.eventMode = "static";

//some codes here ...  

  return { getGraphic };
}

So the set up is like that, once I click that infantry sprite, it should log the mouse location in console

I tested the program in a 750 width x 966 height screen, placed the PIXI sprite in the middle of the screen, and here is the weird result.

{eClient: Point, eClientX: 402, eClientDotX: 402}
eClient: Point {x: 753, y: 339}
eClientX: 402
eClientDotX: 402
[[Prototype]]: Object

I bet the first result “e.client” is the point location relative to the 1920 screen size, which is the result I would like to get back to my program.

But once I dig in and try to retrieve the x and y coordinate’s respectively, the point seems to be mapped into the client screen size.

Base on the OOP principle, i dont wanna pass the scale parameter in the main app.js to this little subfunction. Anyone have a clue or experienced this question before?

In wix editor , How in html code to calculate target given date time according to my own current date time? getting error

I have this widget countdown with html code:

This code is working but I want to add some new feature that give me error.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        /* Disable pointer events for the countdown timer */
        .countdown-timer {
            pointer-events: none;
        }
    </style>
    <title>Countdown Timer</title>
</head>
<body>
    <script src="https://cdn.logwork.com/widget/countdown.js"></script>
    <a href="https://logwork.com/countdown-831z" class="countdown-timer" data-timezone="Asia/Jerusalem" data-date="2023-12-05 16:00">Countdown Tester</a>
</body>
</html>

the target future time to count to is “2023-12-05 16:00”

what I want to do now is that anyone who will browse the site to calculate automatically and convert the target time according to the user local date time.

so for me it will count down to “2023-12-05 16:00” but if someone in the usa will browse to this site and his time is et or pm, or am or pacific or any time then to automatically adjust the target date time counting to.

so each one that will browse to the site will a different count down target time. the init count time target will be the same for everyone but it will convert it and change the target time depending on the user local time.

so everyone target time will be “2023-12-05 16:00” but display the count time to that target depending on the user local time.

I tried this code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        /* Disable pointer events for the countdown timer */
        .countdown-timer {
            pointer-events: none;
        }
    </style>
    <title>Countdown Timer</title>
</head>
<body>
    <script src="https://cdn.logwork.com/widget/countdown.js"></script>
    <a href="https://logwork.com/countdown-831z" class="countdown-timer" data-timezone="auto" data-date="2023-12-05 16:00">Countdown Tester</a>

    <script>
        // Get the user's local time zone offset in minutes
        var userTimeZoneOffset = new Date().getTimezoneOffset();

        // Convert the target date to the user's local time
        var targetDate = new Date("2023-12-05T16:00:00");
        targetDate.setMinutes(targetDate.getMinutes() + userTimeZoneOffset);

        // Format the target date and time as YYYY-MM-DD HH:MM
        var formattedTargetDate = targetDate.toISOString().slice(0, 16).replace("T", " ");

        // Update the data-date attribute with the adjusted target date and time
        document.querySelector('.countdown-timer').setAttribute('data-date', formattedTargetDate);

        // Initialize the countdown timer with the adjusted target date
        logwork_countdown();
    </script>
</body>
</html>

but then this give me error: incorrect embedded code please , regenerate your countdown widget code

Supabase and NextJS Route API Handling Error: Only plain objects, and a few built-ins, can be passed to Client Components from Server Components

I am using NextJS and Supabase and this is the error that it shows:

⨯ Error: Only plain objects, and a few built-ins, can be passed to
Client Components from Server Components. Classes or null prototypes
are not supported.
at stringify () ⨯ Error: Only plain objects, and a few built-ins, can be passed to Client Components from Server Components.
Classes or null prototypes are not supported.
at stringify () digest: “1376061893”

app/api/Orders/route.ts

    import { createServerComponentClient } from "@supabase/auth-helpers-nextjs";
    import { NextApiRequest, NextApiResponse } from "next";
    import { cookies } from "next/headers";
    import { NextResponse } from "next/server";
    
    export async function GET (request: NextApiRequest) {
      const cookieStore = cookies()
      const supabase : any = createServerComponentClient({ cookies: () => cookieStore })
      const {data: {session }} = await supabase.auth.getSession();  
    
      const {data, error } = await supabase
      .from('orders')
      .select()
      .eq('id', session?.user.id)
    
    
       if (error == null) {
            return NextResponse.json({ data });
        }
        return NextResponse.json({ error: error.message });
    
    }

Calling it here: components/Orders/ViewOrders.tsx:

import OrderList from "./OrderList";

export default async function ViewOrdersByWaterStation({}) {
 

        try{
          const response = await fetch(`http://localhost:3000/api/Orders`,{
            method: 'GET',
            headers: {
              'Content-Type': 'application/json',
            },
          })

          const data = await response.json()
      
          return Response.json({ data })

        }catch(err){
          console.log(err)
        }
    return ( 
        <div>
         <OrderList orders={orders} />
        </div>
     );
}

how can i render an array of tasks when a project instance is clicked on?

I’m creating a todo list and i can not properly push a task into a project instance.

I tried creating a selectProject function that would target the project instance by a click which the user would then be able to add a and see it via the renderTasks function. Below is that javascript code that i’m having the issue with.

//class for single project
class Project {
    constructor(name) {
        this.name = name;
        this.tasksArr = [];
    }
    get nameOfProject() {
        return this.name;
    }
    get tasksArray() {
        return this.tasksArr;
    }
    isEmpty() {
        return this.tasksArr.length == 0;
    }
    addTasksToProject(name, dueDate) {
        let newTask = new Task(name, dueDate);
        this.tasksArr.push(newTask);
        return newTask
    }
}
//class for a group of projects 
class Projects {
    constructor() {
        this.listOfProjects = [new Project("Sample Project")];
    }
    addProjectToList(name) {
        let p = new Project(name);
        this.listOfProjects.push(p);
        return p
    }
    get allProjects() {
       return this.listOfProjects;
    }
    get numOfProjects() {
        return this.listOfProjects.length;
    }
}

class Task {
    constructor(name, dueDate) {
        this.name = name;
        this.dueDate = dueDate;
        this.completed = false;
    }
}

//global vars

let projects = new Projects();
let project = new Project();
let projArr = projects.allProjects;
let taskArr = project.tasksArray;
let projectId = 0;
let selectedProj = null;

function renderTasks(currentProj) {
    const taskList = document.getElementById("task-list");
    if (currentProj.isEmpty) {
        taskList.textContent = "this project currently has no task. Please add a task below";
    } else if (!currentProj.isEmpty) {
        taskList.textContent = "";
        taskArr.forEach(task => {
            const newTaskDiv = document.createElement("div");
            newTaskDiv.textContent = task.name;
            newTaskDiv.classList.add("task-item");
            taskList.appendChild(newTaskDiv);
        });
    }
}

function selectProject(e) {
    let currentProj = projArr[e.currentTarget.id];
    console.log(e.currentTarget);
    selectedProj = currentProj;
    renderTasks(selectedProj);
    console.log(taskArr);
    console.log(currentProj.name);
}

projArr.forEach(renderProjects);
function renderProjects(project) {
  const newProjectDiv = document.createElement("div");
  const dltBtn = document.createElement("button");
  const projectDom = document.getElementById("project-list");
    newProjectDiv.textContent = project.nameOfProject;
    dltBtn.textContent = "delete";
    newProjectDiv.classList.add("project-item");
    newProjectDiv.appendChild(dltBtn);
    projectDom.append(newProjectDiv);
    newProjectDiv.id = projectId;
    dltBtn.addEventListener("click", (index) => {
        if(projArr[index] === dltBtn[index]) {
            projArr.splice(projArr.indexOf(project), 1);
            newProjectDiv.remove();
            resetIds(Number(newProjectDiv.id));
            projectDom.listCounter.textContent = projects.numOfProjects;
            projectId -= 1;
        }
    });
    newProjectDiv.addEventListener("click", selectProject);
    projectId++;
    console.log(project.nameOfProject);
}

function resetIds(index) {
    for (let i = index; i < projArr.length; i++) {
        const element = document.getElementById(i+1);
        console.log(i+1)
        element.id = i;
    }
}

//eventListeners

const addBtn = document.getElementById("add");
const addTask = document.getElementById("addTask")
addBtn.addEventListener("click", addProjectBtn);
addTask.addEventListener("click", addTaskBtn)

function addProjectBtn() {
    let projName = prompt("name");
    let pushProj = projects.addProjectToList(projName);
    renderProjects(pushProj);
    console.log(projects.allProjects);
}

function addTaskBtn() {
    let taskName = prompt("task name");
    let pushTask = project.addTasksToProject(taskName);
    renderTasks(pushTask);
    console.log(project);
    console.log(renderTasks(pushTask))
}

How can I detect if datatable columns are currently being re-ordered

I am scraping products data from amazon, and I add a row each time a product is scraped.

But when I am re-ordering and at the same time a row is being added, I get a “column number is not the same” error, expected.

I am looking for something that will show me exactly when the table is being re-ordered.

I tried this:

  if (table.colReorder.order().length == 15) { // 15 is the number of columns
    $("table")
      .DataTable()
      .row.add($(productObjRowHtml(productObj)))
      .draw(); // add the product
  } else {
    setTimeout(addProduct, 1000, productObj, table); # wait and add it later
  }

But apparently while holding the column, the table.colReorder.order() is still giving me 15 items.

is there something I can use?

JavaScript not creating header inside div

function search() {
  var searchbar = document.getElementById("searchbar");
  if (searchbar.value != null) {
    var searchResult = document.createElement("h2");
    searchResult.value = "Search results for " + searchbar.value;
    document.getElementById("question-render").appendChild(searchResult);
  }
}
<!DOCTYPE html>
<html>

<head>
  <title>CodeGitOverflow</title>
  <link rel='stylesheet' href='css/navbar.css' />
  <script type='text/javascript' src='js/search.js'></script>
</head>

<body>

  <!-- Div for navbar -->
  <div class="navbar">
    <!-- Div for header -->
    <div class="header">
      <h1>Welcome to CodeGitOverflow</h1>
    </div>

    <!-- Div for search -->
    <div class="searchbar">
      <form action="javascript:search()">
        <input id="searchbar" type="search">
        <input type="submit" value="Search for question">
        <p>Search for a question</p>
        <noscript>This website won't work without JavaScript enabled.</noscript>
      </form>
    </div>

    <!-- Div for links -->
    <div class="links">
      <ul>
        <li><a onclick="javascript:this.style.display = 'none';" href="#home">Home</a></li>
        <li><a href="about.html">About</a></li>
        <li><a href="askQuestion.html">Ask a question</a></li>
        <li><a href="signup.html">Signup</a></li>
      </ul>
    </div>
  </div>

  <div class="question-render" id="question-render">

    <div class="questions-header">
      <h1>Questions Asked</h1>
    </div>
    <div class="questions-render-section" id="questions-render-section">
      <p>No questions asked yet.</p>
      <p>Have a question? <a href="askQuestion.html">Ask a question</a></p>
    </div>
  </div>
</body>

</html>

Inside the HTML code,

There is a div with the ID of ‘questions-render’ which is used to render the search result as an tag

Inside the JavaScript code,

  • I get the search bar by its identifier.
  • I checked if the value of the search bar’s value is not equal to null. If it isn’t I created an ‘h2’ with the variable name searchResult,
  • I set the value of the search result variable to ‘Search Results for’ + search Bar’s value
  • Then I append that to the question-render div