How would I position my elements as such on a website while maintaining its responsiveness?

I have been trying to create a website using HTML, and CSS that would not contain a more “linear” format and would instead have carousels that rotate items that would appear in seemingly random positions. I have constructed a wireframe below for further clarification.

Wireframe

I have tried this design before specifically with a grid method but either implemented wrong or had not used the proper tools with it. Currently right now I am trying to use flexbox to solve this issue.

If there are in fact any form of tutorials that aim to solve this issue could you please link it? Any help is appreciated, thank you!

(Please reach out if there was not as much information as needed this is my first question here)

How to fix CORS for front-end/client request using axios?

I made a simple video player and want to use different src files. None of the files are on the same server as the application.

The video code is like this:

<video preload="metadata" @play="onPlay" @pause="onPause" :src="https://xxx.s3.amazonaws.com/sample_960x400.mp4">
</video>

If I run the above code, it works fine without any CORS warning.

However if I perform a get of the file using axios:

await axios.get('https://xxx.s3.amazonaws.com/sample_960x400.mp4', {
          withCredentials: false,
          headers: {
            'Access-Control-Allow-Origin': '*',
            'Access-Control-Allow-Methods': 'GET, POST, PATCH, PUT, DELETE, OPTIONS',
            'Access-Control-Allow-Headers': 'Origin, Content-Type, X-Auth-Token',
            'Access-Control-Max-Age': 86400
          }
        })

Then it leads to this CORS error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading
the remote resource at
https://xxx.s3.amazonaws.com/sample_960x400.mp4. (Reason: CORS request
did not succeed). Status code: (null).

I am using Node.js with Express on the backend, but my files are not being served via my backend because they are hosted in the cloud.

My questions are:

  1. Why is there no CORS error when the video tag gets the file?
  2. Why does axios cause a CORS error?
  3. How do I fix this?

action.payload returns undefined even when i have provided values

In the getassignments i get the response from the server and the response is sent to the payload. But the action.payload in the extrareducers dosent contain any values it returns undefined.I cant even change the state. Why does it happen can anyone please tell me

import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";

const initialState = {
  assignments: [],
}

export const addAssignments = createAsyncThunk("addAssignments",async ({ c_id, formData }) => {
    try {
      const response = await fetch(
        `http://localhost:4000/addAssignments/${c_id}`,
        {
          method: "POST",
          body: formData,
          credentials: "include",
        }
      );
      const resdata = await response.json();
   
      return resdata;
    } catch (err) {
      console.log(err);
    }
  });

  export const getAssignments = createAsyncThunk("getAssignments", async (id) => {
    try {
      const response = await fetch(`http://localhost:4000/getAssignments/${id}`, {
        credentials: "include",
      });
      const res = await response.json();
      console.log(res);
      return res;
    } catch (err) {
      console.log(err);

    }
  });

export const AssignSlice = createSlice({
  name: "Assignment",
  initialState:initialState,
  reducers: {},
  extraReducers: (builder) => {
    builder.addCase(addAssignments.fulfilled, (action, state) => {
      state.assignments = action?.payload;
    });
    builder.addCase(addAssignments.rejected, (action, state) => {
      console.log("error", action?.payload);
    });
    builder.addCase(getAssignments.fulfilled, (action, state) => {
        state.assignments = action?.payload;
         console.log(action.payload)
    });
    builder.addCase(getAssignments.rejected, (action, state) => {
        console.log("error", action?.payload);
    });
  },
});
export default AssignSlice.reducer;

I have tried everything that i know. this code returns an empty array but in the redux developer tools the action has the value but the state is an empty array.

Play CSS animation on idle / user inactivity on webpage

I want to play CSS animation on multiple element with single CSS class when webpage idle or user inactivity for 3 seconds. I have tried javascript function.. its works fine for 1st element only.
I am just a beginner in JS. I have also tried querySelectorAll.. but got javascript error

html

    <p class="timertext"> 
        ANIMATION TEXT 1 
    </p> 
      
    <p class="timertext"> 
        Animation Text 2 
    </p> 

         <p class="timertext"> 
        Animation Text 3 
    </p>
     

JS

let timer, currSeconds = 0; 
          
        function resetTimer() { 
          
            /* Hide the timer text */ 
            document.querySelector(".timertext") 
                .style.animation = 'none'; 
          
            /* Clear the previous interval */ 
            clearInterval(timer); 
          
            /* Reset the seconds of the timer */ 
            currSeconds = 0; 
          
            /* Set a new interval */ 
            timer = 
                setInterval(startIdleTimer, 3000); 
        } 
          
        // Define the events that 
        // would reset the timer 
        window.onload = resetTimer; 
        window.onmousemove = resetTimer; 
        window.onmousedown = resetTimer; 
        window.ontouchstart = resetTimer; 
        window.onclick = resetTimer; 
        window.onkeypress = resetTimer; 
          
        function startIdleTimer() { 
              
            document.querySelector(".timertext") 
               .style.animation = 'shift 4s ease-in-out infinite'; 
       

        } 

Anime JS Timeline Issue

anime
  .timeline()
  .add({
    targets: ".ml5 .letters-left",
    opacity: [0, 1],
    translateX: ["-100%", 0],
    easing: "easeOutExpo",
    duration: 600,
    offset: "-=60",
  })
  .add({
    targets: ".ml5 .letters-right",
    opacity: [0, 1],
    translateX: ["100%", 0],
    easing: "easeOutExpo",
    duration: 600,
    offset: "-=60",
  });

I am facing issue due to which letters-left and letters-right are coming one after other (first left then right) they are not coming together & I want them to come together.

I’ve tried changing offset of both of them to different values but still the issue persists.

Cannot make the POST request with my Google Chrome Extension

I have a Google Chrome Extension (GCE) which will request to my server (Nginx – Backend Golang)

I already configured CORS on my backend side, I can easily make any HTTP Methods to my server with Postman or execute CURL in my terminal without getting a CORS issue
The response header will be included in the CORS header below
enter image description here

But for my GCE, I only can make the GET request successfully. For the POST request, I got the issue
enter image description here

Here is my mainfest.json file

{
  "manifest_version": 3,
  "name": "Extension Name",
  "version": "1.0",
  "description": "Description",
  "permissions": [
    "activeTab",
    "storage"
  ],
  "host_permissions": [
    "https://example.com/*"
  ],
  "action": {
    "default_popup": "popup.html"
  }
}

my POST function

submitButtonProductCfg.addEventListener('click', () => {
    const productName = document.getElementById("product-cfg-name").value;
    const link = backendURL + "/api/extension/v1/products/configs"; 

    chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) {
        // Prepare data for POST request (modify as needed)
        const data = {
            "name": productName,
        };

        // Create XHR object
        const xhr = new XMLHttpRequest();

        // Set up the request
        xhr.open('POST', link);
        xhr.setRequestHeader("Content-Type", "application/json; charset = UTF-8");

        // Set up event listeners
        xhr.onload = function() {
            if (xhr.status >= 200 && xhr.status < 300) {
                alert("Success");
            } else {
                console.log(xhr.status);
                alert("Err");
            }
        };

        xhr.onerror = function() {
            console.log(xhr.status);
            alert("Err");
        };

        // Send the request
        try {
            xhr.send(JSON.stringify(data));
        } catch (e) {
            console.log("errr ", e);
        }
    

});
});

I tried Fetch lib also

Please help me!

How to add entire graphql schema to another schema using Pothos GraphQL?

I have two GraphQL schema. I need to add all the types (including Query and Mutation type) from one schema to another schema, ultimately resulting in a single GraphQL schema for end users. To achieve this, I am using @pothos/plugin-add-graphql plugin.

This plugins works very well and copies Objects, Interfaces, Enums, Unions but it doesn’t copy Query and Mutation fields defined on first schema.

Both schemas are defined using Pothos.

Is there any way to achieve this via some other means?

Cannot set headers after they are sent to the client Express.js

I’m using Express to handle a POST request from an EJS file, where I pass the contents of req.body to a Python script. This Python script takes a few minutes to execute, and during this time, I want to temporarily redirect the user to another page. Once the Python script finishes, I want to render the EJS file again. However, I’m encountering the error “Cannot set headers after they are sent to the client”.

Here’s a snippet of my code:

app.post("/submit", (req, res) => {
    res.render("index.ejs", { flag1: "true", flag2: "false", flag3: "false" });
    const form_link = req.body.form_link;
    const pythonProcess = spawn("python", ["./py_scripts/script.py", form_link]);
    pythonProcess.on("exit", () => {
        console.log(`Python script finished`);
        res.render('index.ejs', { flag1: "false", flag2: "true", flag3: "true" });
    });
    res.render('index.ejs', { flag1: "true", flag2: "false", flag3: "false" });
});

i tried asking chatgpt ,claude.ai ,gemini but none of their solutions seem to work

How to Retrieve System Information (IP Address, OS, Battery, Storage) in ReactJS?

‘I’m working on a ReactJS project and need to retrieve various system information such as the IP address, operating system details, battery status, and storage information. I’ve researched different approaches but haven’t found a solution that fits my requirements.

I tried javascript method console.log(window) and console.log(navigator) but unable to get valid information. Even I tried one npm it’s called systeminformation but i can’t get valid information

  1. I’m unsure how to access the IP address and OS information within a ReactJS application.
  2. I’m not sure which libraries or APIs are suitable for retrieving battery and storage information in a web application context.

It’s must applicable for all over the environment like (windows, linux, mac).

Could someone please provide guidance on how to achieve these tasks in ReactJS? Any help or pointers in the right direction would be greatly appreciated. Thank you!

How to handle sessions after Chrome’s planned cross-site cookie changes?

I have a web app that runs React on the frontend, like the title suggests, it has a login/authentication feature which is powered by session cookies, however, due to the frontend and backend being hosted on seperate domains, the session cookie the backend sets can only be used by the frontend using the SameSite option set to none, sending credentials back and forth.

This works fine, however, Chrome is now stating that it is planning to deprecate cross-site cookies, which will break the auth system for various sites.

What is the recommended alternative for legacy sites?

Can’t delete by id from mongoDB in nextjs app

0

I’m making an app in nextjs to practice, and I am having a hard time getting single data to delete from the database using the findByIdAndDelete function.

CastError: Cast to ObjectId failed for value “undefined” (type string) at path “_id” for model “Appointment”

./page.jsx


import AddAppointment from "./addAppointment";
import DeleteAppointment from "./deleteAppointment";
import UpdateAppointment from "./updateAppointment";

async function getAppointment() {
  const res = await fetch("http://localhost:3000/api/appointment", {
    method: "GET",
    cache: "no-store",
  });
  // const data = await res.json();
  return res.json();
}

async function Appointment() {
  const { appointment } = await getAppointment();

  return (

    <div className="py-10 px-10">
      <div className="py-2">
        <AddAppointment />
      </div>
      <table className="table w-full">
        <thead>
          <tr>
            <th>#</th>
            <th>Nama</th>
            <th>Tanggal</th>
            <th>No Telp.</th>
            <th>Terapis</th>
            <th>Status</th>
            <th>Action</th>
          </tr>
        </thead>
        <tbody>
          {appointment.map((row, i) => (
            <tr key={row._id}>
              <td>{i + 1}</td>
              <td>{row.name}</td>
              <td>{row.date}</td>
              <td>{row.phone}</td>
              <td>{row.terapist}</td>
              <td>{row.statust || "unknown"}</td>
              <td className="flex">
                <UpdateAppointment {...appointment} />
                <DeleteAppointment {...appointment} />
              </td>
            </tr>
          ))}
        </tbody>
      </table>
    </div>
  );
}

export default Appointment;

./deleteAppointment.jsx

"use client";
import { useState } from "react";
import { useRouter } from "next/navigation";

export default function DeleteAppointment() {
  const [modal, setModal] = useState(false);

  const router = useRouter();

  async function handleDelete({ id }) {
    await fetch(`http://localhost:3000/api/appointment?id=${id}`, {
      method: "DELETE",
    });

    router.refresh();
    setModal(false);
  }

  function handleChange() {
    setModal(!modal);
  }

  return (
    <div>
      <button className="btn btn-error btn-sm" onClick={handleChange}>
        Delete
      </button>

      <input
        type="checkbox"
        checked={modal}
        onChange={handleChange}
        className="modal-toggle"
      />

      <div className="modal">
        <div className="modal-box">
          <h3 className="font-bold text-lg">
            Anda yakin untuk menghapus data ""?
          </h3>

          <div className="modal-action">
            <button type="button" className="btn" onClick={handleChange}>
              Close
            </button>
            <button type="button" onClick={handleDelete} className="btn">
              Delete
            </button>
          </div>
        </div>
      </div>
    </div>
  );
}

api route

import { connectMongoDB } from "@/lib/mongodb";
import Appointment from "@/models/appointment";
import { NextResponse } from "next/server";

export async function DELETE(req) {

  const id = req.nextUrl.searchParams.get("id");
  await connectMongoDB();
  await Appointment.findByIdAndDelete(id);
  return NextResponse.json({ message: "Appointment deleted" }, { status: 200 });
}

Model

import mongoose, { Schema, models } from "mongoose";

const appointmentSchema = new Schema(
  {
    name: {
      type: String,
      required: true,
    },
    date: {
      type: String,
      required: true,
    },
    phone: {
      type: String,
      required: true,
    },
    terapist: {
      type: String,
      required: true,
    },
    statust: {
      type: String,
      required: true,
    },
  },
  { timestamps: true }
);

const Appointment =
  models.Appointment || mongoose.model("Appointment", appointmentSchema);
export default Appointment;

CastError: Cast to ObjectId failed for value “undefined” (type string) at path “_id” for model “Appointment”

having hard time to figure how to passing id and difference between id and _id

setHeader(‘Set-Cookie’) not saving the cookie in the browser cookie storage

I try to build a registration route for my app and when sending the cookie to the client the cookie is not being saved in the browser cookie atorage – application/cookies on chrome or data/cookies on firefox. In network tab in Response Headers section i can see the entry

Set-Cookie: cc=bkdbjvsdvs; Path=/; Max-Age=3600; SameSite=None; Secure

and in Network tab in cookies i can see my cookie, its just not being saved to the cookies in application tab for some reason, I have tried the set all properties to all possible values and nothing seems to be working, I don’t have any plugins running no ad blocker I have no idea whhy is it like that i’ve been struggling with this for days. If anyone have an idea why it may be happening please tell me. For contenxt the backend is trpc, but i don’t think it matters since i can see the cookie in response headers than it’s on the browsers side, i tried chrome and firefox in incognito mode and in normal mode.

How to create this line animation on OpenAI’s site with pure CSS?

I’m trying to create this line animation on OpenAI site but cannot figure out how this is implemented. The inspect shows it uses some figure and figcaption tag with an image moving nested inside a div.

Can someone kindly guide me towards how to implement this?

Animation here

Thank you.

I tried to animate using the available image but there were no properties found at inspect level that could hint at what kind of animation it was using.

How to check if every array is filled?

I’m writing a code for rock paper scissor.
I need a function to run everytime I click on a button, to check if every array inside of array is filled. If every arrray is filled with player markers (without anyone winning), i need it to return false and make the game end on a draw.

let arrayOne = [
                [],[],[],
                [],[],[],
                [],[],[],
];

function isBoardFilled() {
    for (let i = 0; i < arrayOne.length; i++) {
        const row = arrayOne[i];
        for (let j = 0; j < row.length; j++) {
            if (row[j].length === 0) {
                return false;
            }
        }
    }
    return true; 
}


 if (isBoardFilled()) {
        \the game goes on.
    } else {
        \the game end with a draw.
    }

When i try to run the code, it just iterates over the first array and just ends the game on a draw.

I hope you understand what I mean.

Thank you all in advance.

How to set this form field as optional?

<div class="col-xxl-4 col-xl-4 col-lg-4 col-md-6 col-sm-12 col-12">
    <div class="mb-3">
        <label  class="form-label form_label_custom">KYC 3 (Optional)</label>
        [file* KYCOfProposerBackAddharUpload filetypes:png|jpg|pdf|jpeg class:form-control class:custom_control placeholder "KYC 3 (Optional)"]
    </div>
</div>

How I can do this form field as an optional that anyone can avoid this field.