appendChild not working in tauri application?

I am new to tauri, I ran into a problem where appendChild in javascript will not work

js:

const { invoke } = window.__TAURI__.core;

let NoteInputEl;

async function ModNote(){
document.querySelector("#hd_1").textContent = "added";
var list = document.querySelector("#text_list");
let new_note = document.createElement("li");
new_note.textContent = await invoke("Note", {note: NoteInputEl.value});
list.appendChild(new_note);
} 


window.addEventListener("DOMContentLoaded", () => {
NoteInputEl = document.querySelector("#note-input");

document.querySelector("#note-form").addEventListener("submit", (e) => {
e.preventDefault();
ModNote();

NoteInputEl.value="";
});

});

index.html:

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="styles.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri App</title>
<script type="module" src="/main.js" defer></script>
</head>

 <body>
  <main class="container">
  <h1>Welcome to Tauri</h1>
 
  <form class="row" id="note-form">
    <input id="note-input" placeholder="Enter a note..." />
    <button type="submit">Add</button>
  </form>
  <ul id="text_list">
    
  </ul>
  <p id="hd_1"></p>
</main>
</body>
</html>

lib.rs:

use chrono::Local;

#[tauri::command]
fn note(note: &str) -> String {
let sys_time = Local::now(); // Get the current local time

format!("{} - Created at {}", note, sys_time.format("%Y-%m-%d"))
}


#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
    .plugin(tauri_plugin_opener::init())
    .invoke_handler(tauri::generate_handler![note])
    .run(tauri::generate_context!())
    .expect("error while running tauri application");
 }

There isn’t any error raised when I run it with tauri dev, the hd_1 is getting changed, is just that the appendChild is not updating the list with new entry when i press the button and submit the form, and when I went to test it by opening the index.html with google, the main.js wouldn’t get read, so i really have no idea what is the issue.

Nextjs automatically creates pages in ISR mode despite being client components

So i have been working on a Nextjs project recently, but there seems to be a problem with it while building. While trying to host it on vercel some of the pages are automatically generated in ISR mode despite being client components.

One potential cause i can infer for this is, as i am using react query for client side data fetching in my components. But i have not been able to find out any workaround to make this work.

Any help is deeply appreciated!

Below is the code of one of the pages being affected. All of these pages are also wrapped in a layout component. You can also view the code for it below.

"use client";
import { useEffect, useState } from "react";
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";

import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { useToast } from "@/hooks/use-toast";
import { Plus, Search, Loader2 } from "lucide-react";
import { Skeleton } from "@/components/ui/skeleton";
import { Club, User } from "@prisma/client";
import { ClubCard } from "@/components/clubs/ClubCard";
import { CreateClubDialog } from "@/components/clubs/CreateClubDialog";
import { EditClubSection } from "@/components/clubs/ClubDialog";


export default function ClubsPage() {
  const [search, setSearch] = useState("");
  const [dialogOpen, setDialogOpen] = useState(false);
  const [selectedClub, setSelectedClub] = useState<
    (Club & { clubLeads: string[] }) | undefined
  >();
  const { toast } = useToast();
  const queryClient = useQueryClient();

  // Fetch clubs
  const { data: clubs, isLoading: isLoadingClubs } = useQuery({
    queryKey: ["clubs", "all"],
    queryFn: async () => {
      const response = await fetch("/api/clubs/getAll");
      if (!response.ok) throw new Error("Failed to fetch clubs");
      const data = await response.json();
      console.log(data.clubs)
      return data.clubs;
    },
  });

  // Fetch users for leader selection
  const { data: users } = useQuery({
    queryKey: ["users"],
    queryFn: async () => {
      const response = await fetch("/api/user/getAll");
      if (!response.ok) throw new Error("Failed to fetch users");
      const dat = await response.json();
      return dat.users;
    },
  });

  const userOptions =
    users?.map((user: User) => ({
      value: user.userId,
      label: `${user.username} (${user.email})`,
    })) ?? [];

  useEffect(()=>{
    console.log(selectedClub)
  },[selectedClub])

  // Create/Update club mutation
  const clubMutation = useMutation({
    mutationFn: async (data: Partial<Club>) => {
      const response = await fetch(
        selectedClub ? `/api/clubs/${selectedClub.clubId}` : "/api/clubs",
        {
          method: selectedClub ? "PUT" : "POST",
          headers: { "Content-Type": "application/json" },
          body: JSON.stringify(data),
        }
      );
      if (!response.ok) throw new Error("Failed to save club");
      return response.json();
    },
    onSuccess: () => {
      toast({
        title: `Club ${selectedClub ? "updated" : "created"} successfully`,
      });
      setDialogOpen(false);
      setSelectedClub(undefined);
      queryClient.invalidateQueries({ queryKey: ["clubs"] });
    },
    onError: () => {
      toast({
        title: `Failed to ${selectedClub ? "update" : "create"} club`,
        variant: "destructive",
      });
    },
  });

  const filteredClubs = clubs?.filter((club: Club) =>
    club.clubName.toLowerCase().includes(search.toLowerCase())
  );

  return (
    <>
      <div className="container mx-auto py-8 px-8">
        <div className="flex justify-between items-center mb-8">
          <h1 className="text-3xl font-bold">Clubs Management</h1>
          <CreateClubDialog />
        </div>

        <div className="relative mb-6">
          <Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4" />
          <Input
            className="pl-10"
            placeholder="Search clubs..."
            value={search}
            onChange={(e) => setSearch(e.target.value)}
          />
        </div>

        {isLoadingClubs ? (
          <div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
            {[...Array(6)].map((_, i) => (
              <Skeleton key={i} className="h-[200px] rounded-lg" />
            ))}
          </div>
        ) : (
            <div className="flex flex-wrap gap-6">
            {filteredClubs?.map((club: Club & {clubLeads:string[]}) => (
              <ClubCard
              key={club.clubId}
              club={club}
              leaders={club.clubLeads} 
              onClick={() => {
                setSelectedClub({ ...club}); // Add actual clubLeads data
                setDialogOpen(true);
              }}
              />
            ))}
            </div>
        )}
      </div>

      {selectedClub && <EditClubSection
        club={selectedClub as Club & { clubLeads: string[] }}
        onClose={() => setSelectedClub(undefined)}
        userOptions={userOptions}
        isOpen={!!selectedClub}
      />}
    </>
  );
}

Layout.tsx

"use client";
import React, { Suspense, useEffect, useState } from "react";
import { useRouter } from "next/navigation";
import { signOut, useSession } from "next-auth/react";
import { useToast } from "@/hooks/use-toast";
import { useRecoilState, useSetRecoilState } from "recoil";
import { userAtom } from "@/states/userAtom";
import { teamAtom } from "@/states/teamAtom";
import { Bell, Menu } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet";
import { ModeToggle } from "@/components/theme-toggle";
import { NavigationLinks } from "@/components/layout/navigation-links";
import { TeamSelector } from "@/components/layout/team-selector";
import { UserMenu } from "@/components/layout/user-menu";
import { useQuery } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools/build/modern/production.js";
import { Team, User } from "@prisma/client";
import { permissionAtom } from "@/states/permissionAtom";
import { getDynamicPermissions } from "@/permissionManager/permissions";
import { NotificationPopover } from "@/components/notifications/NotificationPopOver";
import { notificationAtom } from "@/states/notificationAtom";


export default function DashboardLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  const session = useSession();
  const router = useRouter();
  const { toast } = useToast();
  const [teams, setTeams] = useState<Team[] | null>(null);
  const setUser = useSetRecoilState(userAtom);
  const [currentTeam, setCurrentTeam] = useRecoilState(teamAtom);
  const [isLoading, setIsLoading] = useState(false);
  const [permission, setPermissions] = useRecoilState(permissionAtom);
  const [notifications, setNotifications] = useRecoilState(notificationAtom)
 
  //also fetch the user and store the permissions in the permissionsAtom
  const fetchUser = async () => {
    try {
      const response = await fetch(
        `/api/user/get?userId=${session.data?.userId}`
      );
      const data: {
        user: { permissions: string[]; teams: Team[]; teamLeader: Team[] };
      } = await response.json();
      if (data.user) {
        console.log(data);
        const generatedPermissions = await getDynamicPermissions(
          data.user.teams,
          data.user.teamLeader
        );
        console.log("Generated Permissions: ", generatedPermissions);
        setPermissions([
          ...data.user.permissions,
          ...(generatedPermissions || []),
        ]);
        setTeams(data.user.teams);
        if (data.user.teams.length > 0) {
          setCurrentTeam(data.user.teams[0].teamId);
        }
        return data.user;
      }
    } catch (err) {
      console.log("Error Fetching User Profile!", err);
      toast({
        title: "Error Fetching User Profile",
        description: "Slow Internet Maybe!",
      });
    }
  };

  const fetchNotifications = async ()=>{
    try 
    {
      const response = await fetch(`/api/notification/getAll?userId=${session.data?.userId}`);
      const data = await response.json()
      setNotifications(data.notifications)
      return data.notifications
    }
    catch(err)
    {
      console.log(err)
      toast({
        title:"Error Fetching Notifications!",
        description:"Try Again!",
        variant:"destructive"
      })
    }
  }

  const userQuery = useQuery({
    queryKey: ["user", session.data?.userId],
    queryFn: fetchUser,
    staleTime: 1000 * 60 * 5,
    refetchInterval: 1000 * 60 * 5,
  });

  const notificationsQuery = useQuery({
    queryKey:['notifications', session.data?.userId],
    queryFn:fetchNotifications,
    staleTime: 5 * 60 * 1000,
    refetchInterval: 5 * 60 * 1000,
    
  })

  useEffect(() => {
    if (session.status === "unauthenticated") {
      router.push("/auth/signin");
      toast({
        title: "Please Login Again!",
        description: "Session Expired!",
      });
    }
  }, [session.status]);

  useEffect(() => {
    // @ts-ignore
    window.toggleDevtools = () => setShowDevtools((old) => !old);
  }, []);

  const handleLogOut = async () => {
    try {
      await signOut({ redirect: false });
      router.push("/auth/signin");
      toast({
        title: "Logged Out",
        description: "You have successfully logged out.",
      });
    } catch (error) {
      toast({
        title: "Logout Failed",
        description: "Something went wrong while logging out. Try Again!",
        variant: "destructive",
      });
    }
  };

  return (
    <>
      <div className="grid min-h-screen w-full md:grid-cols-[220px_1fr] lg:grid-cols-[280px_1fr]">
        {/* Sidebar */}
        <div className="hidden border-r bg-background md:block">
          <div className="flex h-full max-h-screen flex-col gap-2">
            <div className="flex h-14 items-center border-b px-4 lg:h-[60px] lg:px-6">
              {!userQuery.isError && (
                <TeamSelector
                  teams={teams || []}
                  currentTeam={currentTeam}
                  onTeamChange={setCurrentTeam}
                />
              )}
              {userQuery.isError && (
                <Button
                  variant={"outline"}
                  className="w-full mr-2"
                  onClick={() => {
                    userQuery.refetch();
                  }}
                >
                  Try Again!
                </Button>
              )}
              <div className="p-2">
                <NotificationPopover />
              </div>
            </div>
            <div className="flex-1 px-2 lg:px-4">
              <NavigationLinks />
            </div>
          </div>
        </div>

        {/* Main Content */}
        <div className="flex flex-col">
          <header className="flex h-14 items-center gap-4 border-b bg-background px-4 lg:h-[60px] lg:px-6">
            <Sheet>
              <SheetTrigger asChild>
                <Button
                  variant="outline"
                  size="icon"
                  className="shrink-0 md:hidden"
                >
                  <Menu className="h-5 w-5" />
                  <span className="sr-only">Toggle navigation menu</span>
                </Button>
              </SheetTrigger>
              <SheetContent side="left" className="flex flex-col bg-background">
                <div className="flex gap-2 items-center">
                  <TeamSelector
                    teams={teams || []}
                    currentTeam={currentTeam}
                    onTeamChange={setCurrentTeam}
                  />

                  <NotificationPopover />
                </div>
                <NavigationLinks className="mt-4" iconClassName="h-5 w-5" />
              </SheetContent>
            </Sheet>
            <div className="w-full flex-1">
              <ModeToggle />
            </div>
            <UserMenu onLogout={handleLogOut} />
          </header>
          <main className="flex flex-1 flex-col gap-4 p-4 lg:gap-6 lg:p-6 bg-background">
            <div className="flex flex-1 justify-center rounded-lg shadow-sm">
              {children}
            </div>
          </main>
        </div>
      </div>
      
        <ReactQueryDevtools initialIsOpen />
      
    </>
  );
}

Is there any way of getting an error message from the browsers XslProcessor object when using xsl:message terminate=true?

Here is what I am using:

<?xml version="1.0" encoding="utf-8"?>
<songList/>

xsl:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/">
    <out>ROOT found</out>   
    <xsl:message terminate="yes"><xsl:value-of select="'Test message - ZZZ'"/></xsl:message>
</xsl:template>
</xsl:stylesheet>

I have an html page that calls this and when the terminate=”no” (or I remove this line completely) the result is (as expected);

<out>ROOT found</out> 

The code is pretty much what is to be found in say MDN, eg

try{
    resultDoc = processor.transformToFragment(xmlDoc, document);
} catch (err) {
    console.log('err=' + err);
    return false;
}   

My issue is that whilst I am using FF and gecko, and the page here
https://developer.mozilla.org/en-US/docs/Web/XSLT/Element/message#gecko_support
seems to indicate xsl:message is supported, it only appears to be supported in the very loosest sense, ie it halts processing but it does not pass back the error/informational message so is of limited utility.
Am I doing something incorrectly?
When I set a breakpoint on the
console.log(‘err=’ + err); line it is totally unpopulated.
Yes, it does get hit but any error information is simply not present.

Why does this SVG filter not work in a canvas context using Chrome?

I have a SVG filter saved in a file hosted on the same website as the canvas. The canvas attempts to use that filter to draw a filtered image, but the original image is rendered instead, ignoring the filter.

The path to the SVG file is correct and the ID of the filter is correct. What am I doing wrong?

Here is the content of the “spherize.svg” file…

<svg>
    <defs>
        <filter id="sphereFilter">
            <feGaussianBlur in="SourceAlpha" stdDeviation="2" result="blur"/>
            <feOffset in="blur" dx="2" dy="2" result="offset"/>
            <feComposite in="SourceGraphic" operator="normal" in2="offset" result="final"/>
        </filter>
    </defs>
</svg>

And here is the call made in the canvas rendering function…

context.filter = "url(/resources/filters/spherize.svg#sphereFilter)";
context.drawImage(image, 0, 0, width, height);

I am using the most recent public version of Chrome (131.0.6778.205) on the most recent public version of macOS (15.1.1). Thanks for any insights.

Mail function in php not sending emails

Im trying to send an alert to an email depending on the value of a variable $alert. However, I can’t send any emails no matter what email address I use, but I do get the echo “Email enviado(sent)”, so I know the if structure is working properly! I don’t know if it is of any relevance, but I’m hosting my php file at IONOS. Any help please!

<?php
    date_default_timezone_set('America/Mexico_City');
    $hoy = getdate();
    $fecha = $hoy['hours'] . ":" . $hoy['minutes'] . ":" . $hoy['seconds'] . " " . $hoy['mday'] . "/" . $hoy['mon'] . "/" . $hoy['year'];

    $servername = "db5001424197.hosting-data.io";

    // REPLACE with your Database name
    $dbname = "dbs1200873";
    // REPLACE with Database user
    $username = "dbu300985";
    // REPLACE with Database user password
    $password = "Batman1998#";

    // Keep this API Key value to be compatible with the ESP32 code provided in the project page. If you change this value, the ESP32 sketch needs to match
    $api_key_value = "tPmAT5Ab3j7F9";

    $api_key = $ID = $porcentaje = "";

    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        $api_key = test_input($_POST["api_key"]);
        if($api_key == $api_key_value) {
            $ID = test_input($_POST["ID"]);
            $alarma = test_input($_POST["alarma"]);
            $pin = test_input($_POST["pin"]);

            if ($pin == 0 ){
                $pin = "none";
            }
            // Create connection
            $conn = new mysqli($servername, $username, $password, $dbname);
            // Check connection
            if ($conn->connect_error) {
                die("Connection failed: " . $conn->connect_error);
            } 
            //**********SISTEMA ANTERIOR**********//
            $sql = "UPDATE instituto SET ultCon = '$fecha' WHERE ID = '$ID'";
            $sql2 = "UPDATE instituto SET pin = '$pin' WHERE ID = '$ID'";
              
            $alter = $conn->query($sql);
            $alter2 = $conn->query($sql2);
            
            if ($alarma == 1){
                $email_from ="[email protected]";

                $email_subject = "Alarma encendida";

                $email_body = "Pin Activado: $pin.n".
                    "Botonera Activada: Si.n".
                    "Sirena Activada: Si.n";

                $to = "[email protected]";

                $headers = "From: $email_from rn";

                $headers .= "Reply-To: $email_from rn";

                mail($to,$email_subject,$email_body,$headers);

                echo "Email enviado";
            }


            echo "¡Conexión exitosa!";
        
            $conn->close();
        }
        else {
            echo "Wrong API Key provided.";
        }

    } else {
        echo "No data posted with HTTP POST.";
    }

    function test_input($data) {
        $data = trim($data);
        $data = stripslashes($data);
        $data = htmlspecialchars($data);
        return $data;
    }
    ?>

How to return blob in Joomla 5 API

I am writing a custom plugin API that should return PDF, I am using Joomla 5 but I see that it only supports JSON as a return via the View, not only that, but it also requires you to be working with Full MVC structure, is there a away to not do that? I want the flexibility to return a blob or text or whatever from inside the Controller.

class ProductsController extends ApiController
{
 protected $contentType = '';
 protected $default_view = '';

 public function displayList()
 {
 // I need to be able to return here a blob or whatever i want, right now if i return anything the content type in postmen is always "text/html; charset=UTF-8"
 }
}

And this is the view that I don’t really need, but it’s mandatory by Joomla:

class JsonapiView extends BaseApiView
{
        protected $fieldsToRenderList = [];

        protected $fieldsToRenderItem = [];
}

For reference, these are the docs: https://docs.joomla.org/J4.x:Adding_an_API_to_a_Joomla_Component/en

I did try to just return inside the displayList method but it’s not working.

XML Reader Not Found in cPANEL php v8.3

I am trying to use One Click Demo Import on WordPress which works fine on my local. When I moved to a fresh install on cpanel, I get this error.

PHP Fatal error:  Uncaught Error: Class "XMLReader" not found in....

Below is my phpinfo

enter image description here

enter image description here

Question: Why I am getting error in v8.3 on cpanel

Working Solution

I downgraded to version 8.2 and it worked

Laravel Defer on API requests

Is it possible to use defer functions on API requests? I can run defer on my website, but through API is not working at all.

Sample scenario:

// Endpoint accessible through browser https://mywebsite.com/something
public function index(Request $request): void
{
    Log::info('Before response sent');
    defer(function () {
        Log::info('Deferred task executed');
    });
    Log::info('After response sent');
}

// Endpoint accessible through API request https://mywebsite/api/something
public function search(Request $request): JsonResponse
{
    Log::info('Before response sent.');
    defer(function () {
        Log::info('Deferred task executed.');
    });
    Log::info('After response sent.');
    
    return response()->json(true);
}

This sample only works when acessing the endpoint through browser. With the API endpoint, by using either tests or Postman, the message Deferred task executed. is never written.

I tried to create a middleware, applied to the API endpoints, in order to make sure the app is terminated so the defer functions execute, but got no luck.

class EnforceDeferForApi
{
    public function handle(Request $request, Closure $next)
    {
        return $next($request);
    }

    public function terminate(Request $request, $response): void
    {
        app()->terminate();
    }
} 

Any solution?

The update and destroy parameters cannot be used in CRUD Laravel 11

I have a problem when editing my CRUD. When I click edit on my index.tsx page, I can’t display the data stored in the database for editing and can’t be deleted, how is the solution?

Here’s the route for my crud

Route::resource('galeri', GalleryController::class);

this is my index.tsx

import React from "react";
import { Link, usePage, router } from "@inertiajs/react";
import AuthenticatedLayout from "@/Layouts/AuthenticatedLayout";
import { PageProps } from "@/types";
import { route } from 'ziggy-js';


const createPostRoute = route('galeri.create');

// Define the type for a single post
interface Post {
    id: number;
    nama: string;
    deskripsi: string;
    image: string;
}

// Adjust the type to reflect the correct structure of posts
interface Posts {
    data: Post[];
}

const Index = ({ auth }: PageProps) => {
    const { posts } = usePage<{ posts: Posts; auth: PageProps["auth"] }>().props;
    const data: Post[] = posts.data; 

    console.log(data); 

    // Function to handle delete action
    const handleDelete = (id: number) => {
        if (confirm("Are you sure you want to delete this post?")) {
            router.delete(route("galeri.destroy", id));
        }
    };
    

    return (
        <AuthenticatedLayout
            header={<h2 className="font-semibold text-xl text-gray-800 leading-tight">Dashboard</h2>}
        >
            <div className="container mx-auto max-w-7xl mt-4">
                <h1 className="mb-8 text-4xl font-bold text-center">Posts Index</h1>
                <div className="flex items-center justify-between mb-6">
                    <Link
                        className="px-3 py-1.5 text-white bg-blue-500 rounded-md focus:outline-none"
                        href={route("galeri.create")}
                    >
                        Create Post
                    </Link>
                </div>

                <div className="overflow-x-auto">
                    <table className="min-w-full bg-white">
                        <thead>
                            <tr>
                                <th className="px-4 py-2 bg-gray-200 text-gray-600 border-b border-gray-300 text-left text-sm uppercase font-semibold">
                                    #
                                </th>
                                <th className="px-4 py-2 bg-gray-200 text-gray-600 border-b border-gray-300 text-left text-sm uppercase font-semibold">
                                    Nama
                                </th>
                                <th className="px-4 py-2 bg-gray-200 text-gray-600 border-b border-gray-300 text-left text-sm uppercase font-semibold">
                                    deskripsi
                                </th>
                                <th className="px-4 py-2 bg-gray-200 text-gray-600 border-b border-gray-300 text-left text-sm uppercase font-semibold">
                                    image
                                </th>
                                <th className="px-4 py-2 bg-gray-200 text-gray-600 border-b border-gray-300 text-left text-sm uppercase font-semibold">
                                    Actions
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            {data && data.length > 0 ? (
                                data.map(({ id, nama, deskripsi, image }) => (
                                    <tr key={id}>
                                        <td className="px-4 py-2 border-b border-gray-300">{id}</td>
                                        <td className="px-4 py-2 border-b border-gray-300">{nama}</td>
                                        <td className="px-4 py-2 border-b border-gray-300">{deskripsi}</td>
                                        <td className="px-4 py-2 border-b border-gray-300">
                                            
                                            <img 
                                                src={`/storage/${image}`} 
                                                alt={nama} 
                                                className="h-20 w-20 object-cover rounded"
                                            />
                                        </td>
                                        <td className="px-4 py-2 border-b border-gray-300">
                                            <Link
                                                className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-1 px-2 rounded text-xs mr-1"
                                                href={route("galeri.edit", id)}
                                            >
                                                Edit
                                            </Link>
                                            <button
                                                className="bg-red-500 hover:bg-red-700 text-white font-bold py-1 px-2 rounded text-xs"
                                                onClick={() => handleDelete(id)}
                                            >
                                                Delete
                                            </button>
                                        </td>
                                    </tr>
                                ))
                            ) : (
                                <tr>
                                    <td className="px-4 py-2 border-b border-gray-300" colSpan={5}>
                                        No posts found.
                                    </td>
                                </tr>
                            )}
                        </tbody>

                    </table>
                </div>
            </div>
        </AuthenticatedLayout>
    );
};

export default Index;

this is my controller

<?php

namespace AppHttpControllers;

use AppHttpRequestsStoreGalleryRequest;
use AppModelsGallery;
use IlluminateSupportFacadesAuth;
use IlluminateHttpRequest;
use IlluminateSupportFacadesRedirect;
use InertiaInertia;

class GalleryController extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index()
{
    $postgaleris = Gallery::all();

    return Inertia::render('Gallery/index', [
        'auth' => [
            'user' => [
                'name' => Auth::user()->name,
                'email' => Auth::user()->email,
            ],
        ],
        'posts' => ['data' => $postgaleris],
    ]);
}


    /**
     * Show the form for creating a new resource.
     */
    public function create()
    {
        return Inertia::render('Gallery/post');
    }

    /**
     * Store a newly created resource in storage.
     */
    public function store(StoreGalleryRequest $request)
    {

        $data = $request->validated();


        if ($request->hasFile('image')) {
            $imagePath = $request->file('image')->store('gallery_fotos', 'public');
            $data['image'] = $imagePath;
        } else {
            $data['image'] = null;
        }

        Gallery::create($data);

        return Redirect::route('galeri.index');
    }


    /**
     * Display the specified resource.
     */
    public function show(Gallery $gallery)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     */
    public function edit(Gallery $gallery)
{
    return Inertia::render('Gallery/edit', [
        'post' => [
            'id' => $gallery->id,
            'nama' => $gallery->nama,
            'deskripsi' => $gallery->deskripsi,
            'image' => $gallery->image ? asset('storage/' . $gallery->image) : null,
        ],
    ]);
}


    /**
     * Update the specified resource in storage.
     */
    public function update(StoreGalleryRequest $request, Gallery $gallery)
    {
        $data = $request->validated();

        if ($request->hasFile('image')) {
            if ($gallery->image && Storage::disk('public')->exists($gallery->image)) {
                Storage::disk('public')->delete($gallery->image);
            }
            $data['image'] = $request->file('image')->store('gallery_fotos', 'public');
        }

        $gallery->update($data);

        return Redirect::route('galeri.index');
    }



    /**
     * Remove the specified resource from storage.
     */
    public function destroy(Gallery $gallery)
    {
        $gallery->delete();

        return Redirect::route('galeri.index');
    }

}

I’ve tried to find the problem, but I don’t know where it is because there is no error message for the destroy and update functions

Three Contenteditable Divs that connect as one larger text box with maxChars of 274

I’m building a tool to help me with multi-part tweets when I need to separate the character limitations into separate tweets. I want it built so that if I copy a large body of text or freely type into the first div (Tweet1), it will split it up as needed.

I’ve attempted some script using AI but I believe that is not allowed on this page so I did not share it below. After countless attempts and tweaks, I cannot get this to flow very well.

When I use my current code, the backspace acts all wonky and adds more lines of spaces below instead of deleting it. The first div will only allow one character at a time when I type before moving down a row. If I paste the text into the first div, it will overflow below, but it adds large blank lines. If I try to delete or edit, it adds more lines or deletes the end of that div instead of where the carrot is

Style:

    .Tweet {
    height: 25%;
    padding: 10px;
    font-size: 14px;
    overflow: auto;
    word-wrap: break-word;
    white-space: pre-wrap;
    border: 1px solid black;
    margin: 10px;
    }

Code:

    Tweet 1
    <div id='Tweet1' class='Tweet BlueBorder' contenteditable="true" oninput="countText1()"></div>
    Tweet 2
    <div id='Tweet2' class='Tweet BlueBorder' contenteditable="true" oninput="countText2()"></div>
    Tweet 3
    <div id='Tweet3' class='Tweet BlueBorder' contenteditable="true" oninput="countText3()"></div>

Script:

<script>
const Tweet1 = document.getElementById("Tweet1");
const Tweet2 = document.getElementById("Tweet2");
const Tweet3 = document.getElementById("Tweet3");
const maxChars = 274;
const urlCharCount = 23;

const tweets = [Tweet1, Tweet2, Tweet3];

tweets.forEach((div, index) => {
  div.addEventListener("input", () => handleInput(index));
  div.addEventListener("keydown", (e) => handleBackspace(e, index));
  div.addEventListener("paste", handlePaste);
});

function handleInput(index) {
  redistributeText();
}

function handleBackspace(event, index) {
  const currentDiv = tweets[index];
  if (event.key === "Backspace" && currentDiv.innerText.trim() === "" && index > 0) {
    event.preventDefault();
    const previousDiv = tweets[index - 1];
    previousDiv.focus();
    moveCaretToEnd(previousDiv);
    redistributeText();
  }
}

function handlePaste(event) {
  event.preventDefault();
  const text = (event.clipboardData || window.clipboardData).getData("text/plain");
  const targetDiv = event.target;

  // Insert pasted text and redistribute
  const selection = window.getSelection();
  if (selection.rangeCount) {
    const range = selection.getRangeAt(0);
    range.deleteContents();
    range.insertNode(document.createTextNode(text));
    redistributeText();
  }
}

function redistributeText() {
  const allText = tweets.map(div => div.innerText).join("n");
  const words = splitTextIntoWordsAndNewLines(allText);
  let remainingWords = [...words];

  tweets.forEach((div, index) => {
    if (index < tweets.length - 1) {
      const [visibleWords, remaining] = fitWordsWithUrlHandling(remainingWords, maxChars);
      div.innerText = visibleWords.join("");
      remainingWords = remaining;
    } else {
      div.innerText = remainingWords.join("");
    }
  });

  // Restore caret position if redistribution affected typing
  restoreCaret();
}

function splitTextIntoWordsAndNewLines(text) {
  const wordsAndLines = text.match(/([^sn]+|s+|n)/g) || [];
  return wordsAndLines;
}

function fitWordsWithUrlHandling(words, limit) {
  let visibleWords = [];
  let charCount = 0;

  for (const word of words) {
    const isUrl = isValidUrl(word.trim());
    const wordLength = word.trim() === "n" ? 1 : isUrl ? urlCharCount : word.length;

    if (charCount + wordLength <= limit) {
      visibleWords.push(word);
      charCount += wordLength;
    } else {
      break;
    }
  }

  const remainingWords = words.slice(visibleWords.length);
  return [visibleWords, remainingWords];
}

function isValidUrl(word) {
  const urlRegex = /^(https?://)?([a-zA-Z0-9.-]+.[a-zA-Z]{2,})(/[^s]*)?$/;
  return urlRegex.test(word);
}

function moveCaretToEnd(element) {
  const range = document.createRange();
  const selection = window.getSelection();
  range.selectNodeContents(element);
  range.collapse(false);
  selection.removeAllRanges();
  selection.addRange(range);
}

function restoreCaret() {
  const selection = window.getSelection();
  if (!selection.rangeCount) return;

  const focusNode = selection.focusNode;
  const focusOffset = selection.focusOffset;

  tweets.forEach(div => {
    const range = document.createRange();
    range.selectNodeContents(div);
    range.setStart(focusNode, focusOffset);
    range.collapse(false);
    selection.removeAllRanges();
    selection.addRange(range);
  });
}

// Initialize divs
tweets.forEach(div => {
  div.innerText = "";
});
</script>


Screenshot of layout

I can either paste a large paragraph into or free-type text into and split the text into three separate Contenteditable Divs so that Tweet1 and Tweet2 will not allow any more than 274 characters before spilling down to the next div below. I want it so that it won’t cut off words either so it uses a break-word to keep it moving down. I want it so that the three divs flow seamlessly between them so if I delete or add more text to any of the three sections it pushes or pulls text in or out of another div as needed.

Unable to locate tests within a folder

i’m trying to run all my Cypress tests by importing them in a all.cy.js file but i’m not getting the desired results.

import "./folder1/test1.cy.js";
import "./folder2/test2.cy.js";
import "./folder3/test3.cy.js";
import "./test4.cy.js";

but Cypress is only reading/testing test4.cy.js
Folder structure: e2e > folder1, folder2, folder3, all.cy.js, test4.js

How to play HLS live-stream from the end with Bitmovin player

I want to play live streams from “live-edge” instead of playing from the start (first segment of manifest) with Bitmovin player.

With some HLS streams, the playback starts from the beginning of the live event. The user must manually click the “Live” button to jump to the current part of the stream. While this behavior is acceptable for VODs, it is not appropriate for live streams.

My config is as follow:

{key: '-', playback: {live: { edgeThreshold: 5 }, autoplay: true, muted: true}}

Also, with desktop browser element inject document.getElementById("#bmpui-id-185").click(); does work, but that’s nasty and doesn’t work on mobile.

Why Does Putting a Custom HTML Element Inside Another Leaves the Second Hidden?

TL;DR: When one custom element is inside of another, the second fails to render. Why is this and how is it fixed?

Explanation

I created three custom HTML elements and two templates using JS (seen below).

const baseTemplate = document.createElement("template");
baseTemplate.innerHTML = `
<slot name="left-pane">Warning: left-pane not included</slot>
<slot name="right-pane">Warning: right-pane not included</slot>
`;

const paneTemplate = document.createElement("template");
paneTemplate.innerHTML = `<slot name="content">Warning: no content included</slot>`;

class PageBase extends HTMLElement {
    constructor() {
        super();

        const shadow = this.attachShadow({ mode: "closed" });

        let clone = baseTemplate.content.cloneNode(true);
        shadow.append(clone);
    }
}

class LeftPane extends HTMLElement {
    constructor() {
        super();

        const shadow = this.attachShadow({ mode: "closed" });

        let clone = paneTemplate.cloneNode(true);
        shadow.append(clone);
    }
}

class RightPane extends HTMLElement {
    constructor() {
        super();

        const shadow = this.attachShadow({ mode: "closed" });

        let clone = paneTemplate.cloneNode(true);
        shadow.append(clone);
    }
}

customElements.define("page-base", PageBase);
customElements.define("left-pane", LeftPane);
customElements.define("right-pane", RightPane);

In the HTML document (seen below), when right-pane or left-pane is put inside another custom element (in this case page-base), it is not rendered in the browser.

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

<head>
    [...]
    <script src="js/layout.js" type="module"></script>   <!---This is the JS file seen above--->
</head>

<body>
    <page-base>
        <div slot="left-pane">
            <p>Thing 1</p>
        </div>
        <div slot="right-pane">
            <right-pane>
                <p slot="content">Thing 3</p>
            </right-pane>
            <p>Thing 2</p>
        </div>
    </page-base>
</body>

</html>

Question: Thing 1 and Thing 2 are rendered, but not Thing 3. Why is this and how do I fix it?

I’ve tried using each custom element on their own, and they work fine putting header or paragraph tags inside, but not for the custom elements.

filter out object in array if object key value is null

I need to filter out objects in array if specific key value is null.

const getPlayerData = async () => {
  const allPlayers = await fetchData("https://api.sleeper.app/v1/players/nfl");
  const players = Object.keys(allPlayers).map(function(key) {
    return allPlayers[key]
  })

  const activePlayers = await Promise.all(players?.filter(async(player: any) => {player.search_rank !== null}
).sort((a, b) => a.search_rank - b.search_rank));
  
  console.log(activePlayers)
  return activePlayers;
}

it filters if {player.active = true} but i need to filter if player.search_rank is null aswell