vis.js timeline element set content same size as outer element

in vis.js timeline you can set the own elements to overflow the item box like in this example.
Is there also an way that my custom element is exactly the same size as the VISIBLE item box on the screen?
By default it is the same size which is good until the item leaves the visible page on the left/right. After that a translateX() gets added to the own content which moves my progressbar out of the container.
enter image description here
enter image description here
enter image description here

What I want:

enter image description here

Is there a way to achieve this without doing hacky things? I calculate the negative translate(X) on every event and with an interval right now which is just bad.

Thank you very much 🙂

Authentication Cookie Not Sent with Axios Request in Browser

I’m having trouble with cookie-based authentication in my Django + React app. I’ve set the cookie on the backend, but it’s not being sent with subsequent requests from the frontend React (Using Vite) app running on Google Chrome.

I’m trying to implement authentication using cookies in a Django backend using Simple JWT. After a successful login, I set an authentication cookie (“CAT”) in Django. Here’s the code I use to set the cookie:

final_response.set_cookie(
    "CAT",
    combined_token,
    httponly=True,
    secure=False,
    samesite="None",
    max_age=86400,
    path="/",
)
return final_response

Setting.py at the Django server:

CORS_ALLOW_ALL_ORIGINS = False
CORS_ALLOWED_ORIGINS = ["http://localhost:5173/"]
CORS_ALLOW_CREDENTIALS = True
SECURE_CROSS_ORIGIN_OPENER_POLICY = "same-origin"

I can see the cookie stored in Chrome after logging in:
enter image description here

However, when my React app makes subsequent requests, the browser doesn’t seem to include the cookie, and I get an authentication failure (“Cookie not found”). Here’s my Axios request setup in the React app:

try {
  const auth_response = await axios.get(
    "http://my-django-server/api/auth/auth-checker",
    {
      headers: {
        "Content-Type": "application/json",
      },
      withCredentials: true,
      timeout: 5000,
    }
  );
  console.log(auth_response?.data);
  if (auth_response?.status === 200) {
    navigate("/profile");
  } else {
    console.error("Unauthorized access. Please try again.");
  }
} catch (error) {
  console.error("An error occurred. Please try again.", error);
}

Manual authentication works:
Interestingly, when I manually set the cookie in an Axios request from the terminal, the request works as expected and I get an authenticated response. However, in the browser, it fails.

getRegularHeader(port: string): Record<string, string> {
    return {
      "Content-Type": "application/json",
      Origin: `http://localhost:${port}`,
    };
  }

const token = readlineSync.question("Enter CAT token: ");
        try {
          const response = await axios.get(url, {
            headers: { ...this.getRegularHeader(port), Cookie: `CAT=${token}` },
            withCredentials: true,
            timeout: 5000,
          });
          return response;
        } catch (error) {
          console.error(`Failed to authenticate: ${error}`);
          return null;
        }

There is also a message from Google Chrome:
enter image description here

What I’ve Tried:

  • Checked in both Chrome and Edge with the same result.
  • Verified that withCredentials: true is set in the Axios request.
  • Attempted different cookie settings (e.g., SameSite=None, Secure=False).

Questions:

  • Why are the browsers not sending the cookie with my requests?
  • Are there any specific settings or configurations I might be missing in either Django or React?

Axios invalid URL but url is correct

I just can’t send request
This code perfectly works:

    const data = new FormData()
    data.append('file', event.target!.files![0])

    const xhr = new XMLHttpRequest()

    xhr.addEventListener('readystatechange', function () {
      if (this.readyState === 4) {
        console.log(this.responseText)
      }
    })

    xhr.open('POST', 'http://localhost:9095/upload')

    xhr.send(data)

but this do not, I executed both in the same project during the same event:

    const formData = new FormData()
    formData.append('file', event.target!.files![0])
    const response = await axios({
      method: 'post',
      url: 'http://localhost:9095/upload',
      data: formData,
      headers: {
        'Content-Type': 'multipart/form-data',
      },
    })
    console.log(response.data)

ERROR:

ncaught (in promise) SyntaxError: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL
    at dispatchXhrRequest (axios.js?v=cf8614a3:1572:13)
    at new Promise (<anonymous>)
    at xhr (axios.js?v=cf8614a3:1557:10)
    at Axios.dispatchRequest (axios.js?v=cf8614a3:2012:10)
    at async Axios.request (axios.js?v=cf8614a3:2118:14)
    at async handleFileUpload (fileButton.tsx:18:22)
    at Axios.request (axios.js?v=cf8614a3:2122:41)
    at async handleFileUpload (fileButton.tsx:18:22)

P.S. I use react ts + axios 1.7.3

Unable to control a React Aria component

I’m trying to build a custom Accordion component with (Adobe) React Aria. I’m building it on top of the Disclosure and DisclosureGroup components.

import { tv } from "tailwind-variants";
import { motion } from "framer-motion";
import {
  UNSTABLE_Disclosure as DisclosureItem,
  UNSTABLE_DisclosureGroup as Disclosure,
  UNSTABLE_DisclosurePanel as DisclosurePanel,
  DisclosureGroupProps as DisclosureProps,
  DisclosureProps as DisclosureItemProps
} from "react-aria-components";
import ChevronLeft from "@spectrum-icons/workflow/ChevronLeft";
import { useButton, AriaButtonOptions, ButtonAria } from "@react-aria/button";

export const accordion = tv({
  slots: {
    accordion: "p-2",
    item: "",
    header: "flex flex-row"
  },
  variants: {
    colorMode: {
      dark: { accordion: "bg-slate-900 text-white" },
      light: { accordion: "text-slate-800" }
    }
  }
});

export type AccordionProps = Omit<DisclosureProps, "id" | "style" | "isDisabled" | "className"> & Options;

export const Accordion = forwardRef(
  (
    {
      children,
      allowsMultipleExpanded,
      expandedKeys,
      defaultExpandedKeys,
      onExpandedChange,
      className,
      id,
      isVisible,
      borderRadius,
      isLoading,
      error,
      isDisabled
    }: AccordionProps,
    ref: React.LegacyRef<HTMLDivElement>
  ) => {
    return (
      <Disclosure
        ref={ref}
        allowsMultipleExpanded={allowsMultipleExpanded}
        expandedKeys={expandedKeys}
        defaultExpandedKeys={defaultExpandedKeys}
        onExpandedChange={onExpandedChange}
        className={accordion().accordion({ colorMode: "light", class: className })}
        id={id}
        isDisabled={isDisabled}
      >
        {children}
      </Disclosure>
    );
  }
);

export type AccordionItemProps = Omit<DisclosureItemProps, "id" | "style" | "isDisabled" | "className"> & Options;

export const AccordionItem = forwardRef(
  (
    {
      children,
      onExpandedChange,
      className,
      isExpanded,
      defaultExpanded,
      slot,
      id,
      isVisible,
      borderRadius,
      isLoading,
      error,
      isDisabled
    }: AccordionItemProps,
    ref: React.LegacyRef<HTMLDivElement>
  ) => {
    return (
      <DisclosureItem
        ref={ref}
        onExpandedChange={onExpandedChange}
        className={accordion().item({ class: className })}
        isExpanded={isExpanded}
        defaultExpanded={defaultExpanded}
        slot={slot}
        id={id}
        isDisabled={isDisabled}
      >
        {children}
      </DisclosureItem>
    );
  }
);

export type AccordionHeaderProps<T extends ElementType> = {
  children: React.ReactNode;
  iconProps?: AriaButtonOptions<T>;
} & Options;

export const AccordionHeader = forwardRef(
  (
    {
      children,
      iconProps,
      id,
      className,
      isVisible,
      borderRadius,
      isLoading,
      error,
      isDisabled
    }: AccordionHeaderProps<"button">,
    ref
  ) => {
    const { buttonProps } = useButton(iconProps || { elementType: "button" }, ref as RefObject<HTMLButtonElement>);

    // @ts-ignore
    // Type conversion for framer-motion is nessecary so defination is removed
    const ariaButtonProps: Omit<ButtonAria<HTMLAttributes<unknown>>, "defination"> & { defination: undefined } = {
      defination: undefined,
      onAnimationStart: undefined,
      ...buttonProps
    };
    return (
      <div className={accordion().header({ class: className })}>
        <div>{children}</div>
        <motion.button {...ariaButtonProps} disabled={isDisabled} className="ml-auto">
          <ChevronLeft width={25} />
        </motion.button>
      </div>
    );
  }
);

export const AccordionContent = forwardRef(({ children }: { children: React.ReactNode }, ref) => {
  return <DisclosurePanel>{children}</DisclosurePanel>;
});

Please note that I have rearranged the names of the Disclosure from React Aria to better fit my use cases:

  • Disclosure is now DisclosureItem
  • DisclosureGroup is now Disclosure
  • DisclosurePanel is now DisclosureProps

This new accordion component is used like so:

<Accordion>
      <AccordionItem isExpanded>
        <AccordionHeader>
          test
        </AccordionHeader>
        <AccordionContent>
          Hello, World
        </AccordionContent>
      </AccordionItem>
</Accordion>

As you can see I am trying to control one of the AccordionItems however when I preview the component all it is not expanded:

Current

Current

Expected

Expected

I look at the DOM shows that even when isExpanded is true hidden is still applied to the AccordionContent div:

<div class="p-2 text-slate-800" data-rac="">
  <div class="react-aria-Disclosure" data-rac="">
    <div class="flex flex-row">
      <div>test</div>
      <button type="button" class="ml-auto">
        <svg
          viewBox="0 0 36 36"
          class="wBx8DG_spectrum-Icon wBx8DG_spectrum-Icon--sizeM"
          focusable="false"
          aria-hidden="true"
          role="img"
          style="width: 25px"
        >
          <path
            fill-rule="evenodd"
            d="M12,18v0a1.988,1.988,0,0,0,.585,1.409l7.983,7.98a2,2,0,1,0,2.871-2.772l-.049-.049L16.819,18l6.572-6.57a2,2,0,0,0-2.773-2.87l-.049.049-7.983,7.98A1.988,1.988,0,0,0,12,18Z"
          ></path>
        </svg>
      </button>
    </div>
   <!-- Here ⬇️ -->
    <div
      id="react-aria3890111277-:r2:"
      role="group"
      aria-labelledby="react-aria3890111277-:r1:"
      hidden=""
      class="react-aria-DisclosurePanel"
      data-rac=""
    >
      Hello, World
    </div>
  </div>
</div>

Removing hidden shows the element. So my question is how do I do this with RA?

bundle unused functions in vite js

hi I’m using vite for bundle my javascript codes and moudules in vanilla js

it’s ok when i run in dev mode
but when i build the code there is two problems

first
i have some functions that aren’t called directly in code and when i build the code they aren’t export to final js file

this is how i call my function in a loob

eval(routes[routesKey]+'(fn(currentRoute))')

and the secound problem is i have some html files and i use them by a fetch in my code and after build the html files are not in dist directory

export function home(pathData){
document.querySelector('title').innerText = "Home"
fetch("/pages/home.html").then(response => {return response.text()} ).then(text =>{
    document.getElementById('main').innerHTML = text
})

}

why does my marker appear in the layerswitcher under a number

I receive the list of layers to use in a json.
To add them, I browse the json and add the layers in the overlaylayers.
Then, I want to materialize the coordinates passed to the page with a marker.
It is displayed correctly but instead of finding the name of the marker “Position” in the layerSwitcher, there is a number.
Below is the code to use.
Any idea?

jsonData.Layers.forEach(layer => {
    console.log("2 "+layer.Layer.nom);  // Affiche le nom de chaque layer

    index = index + 1;
    const layerKey = `lyr${index}`; // Créer une clé dynamique
    let [unLayer,unNom,unVisible]=createLayer(layer.Layer);
    theLayers[index]=unLayer;
    theLayersSwitcher[index]= {layer : unLayer, config : {title : unNom,description : unNom,visibility : unVisible}};

    theLayersNom[index]=unNom;
    theLayersVisible[index]=unVisible;

    if (layer.Layer.inUse==1)
    {
        overlayLayers[layer.Layer.nom] = unLayer; // Stocker la couche dans l'objet}
        unLayer.addTo(map);
    }
    else
    {
        overlayLayers[layer.Layer.nom] = unLayer; // Stocker la couche dans l'objet
    }
});
let PositionMarker = L.marker([<?php echo $_REQUEST["LATITUDE"]?>, <?php echo $_REQUEST["LONGITUDE"]?>], {
    title: "La position"
}).addTo(map);

let reversedLayersSwitcher = {};
let keys = Object.keys(theLayersSwitcher).reverse();
index = 0;

for (let i = 0; i < keys.length; i++) {
    index += 1;
    reversedLayersSwitcher[index] = theLayersSwitcher[keys[i]];
}

let layerSwitcher = L.geoportalControl.LayerSwitcher({ layers: reversedLayersSwitcher });
map.addControl(layerSwitcher);

Products Not Filtering Correctly with AJAX in Django

I’m working on an e-commerce website using Django and jQuery to filter products based on selected criteria (price range, categories, and vendors). While the AJAX request seems to be sent correctly and I receive a response, all products are still displayed on the page, regardless of the selected filters.
What I’ve Implemented:
JavaScript (AJAX) Code:

$(document).ready(function() {
    function filterProducts() {
        let filter_object = {};

        // Get price range values
        let min_price = $("#price-min").val() || 0;
        let max_price = $("#price-max").val() || 9999999;

        filter_object.min_price = min_price;
        filter_object.max_price = max_price;

        // Get selected categories and vendors
        $(".filter-checkbox").each(function() {
            let filter_key = $(this).data("filter");
            filter_object[filter_key] = Array.from(
                document.querySelectorAll('input[data-filter=' + filter_key + ']:checked')
            ).map(function(element) {
                return element.value;
            });
        });

        // Send AJAX request to filter products
        $.ajax({
            url: '/filter-product',
            data: filter_object,
            dataType: 'json',
            beforeSend: function() {
                console.log("Filtering products...");
            },
            success: function(response) {
                console.log("Products filtered successfully.");
                $(".showcase").html(response.data);
            },
            error: function(xhr, status, error) {
                console.error("Error filtering products:", error);
            }
        });
    }

    // Event listener for checkbox and filter button
    $(".filter-checkbox, #filter-btn").on("click", filterProducts);
});

HTML Structure:

<div class="u-s-m-b-30">
    <div class="shop-w">
        <div class="shop-w__intro-wrap">
            <h1 class="shop-w__h">PRICE</h1>
            <span class="fas fa-minus shop-w__toggle" data-target="#s-price" data-toggle="collapse"></span>
        </div>
        <div class="shop-w__wrap collapse show" id="s-price">
            <form class="shop-w__form-p">
                <div class="shop-w__form-p-wrap">
                    <div>
                        <label for="price-min"></label>
                        <input class="input-text input-text--primary-style" type="text" id="price-min" placeholder="Min">
                    </div>
                    <div>
                        <label for="price-max"></label>
                        <input class="input-text input-text--primary-style" type="text" id="price-max" placeholder="Max">
                    </div>
                    <div>
                        <button class="btn btn--icon fas fa-angle-right btn--e-transparent-platinum-b-2" id="filter-btn" type="button"></button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<div class="u-s-m-b-30">
    <div class="shop-w">
        <div class="shop-w__intro-wrap">
            <h1 class="shop-w__h">MANUFACTURER</h1>
            <span class="fas fa-minus shop-w__toggle" data-target="#s-manufacturer" data-toggle="collapse"></span>
        </div>
        <div class="shop-w__wrap collapse show" id="s-manufacturer">
            <ul class="shop-w__list-2">
                {% for v in vendors %}
                <li>
                    <div class="list__content">
                        <input type="checkbox" name="vendor" data-filter="vendor" class="filter-checkbox" value="{{v.id}}">
                        <span>{{v.title}}</span>
                    </div>
                </li>
                {% endfor %}
            </ul>
        </div>
    </div>
</div>

Django Product Model:

class Product(models.Model):
    # Product fields...
    price = models.DecimalField(max_digits=10, decimal_places=2, default=1.99)
    # Other fields...

Django View to Handle Filtering:

def filter_product(request):
    categories = request.GET.getlist("category[]")
    vendors = request.GET.getlist("vendor[]")

    min_price = request.GET.get('min_price', 0)
    max_price = request.GET.get('max_price', 9999999)

    products = Product.objects.filter(product_status="published").order_by("-id").distinct()

    products = products.filter(price__gte=min_price)
    products = products.filter(price__lte=max_price)

    if categories:
        products = products.filter(category__id__in=categories).distinct()

    if vendors:
        products = products.filter(vendor__id__in=vendors).distinct()

    context = {
        "products": products
    }
    data = render_to_string("core/async/product-list.html", context)

    return JsonResponse({"data": data})

Current Issue:

  1. Despite receiving the AJAX response with Products filtered successfully., all products are still displayed on the page regardless of the applied filters.

What I’ve Tried:

  1. Verified that the AJAX request is sending the correct filter parameters.
  2. Ensured that the Django view logic correctly applies the filters.
  3. Confirmed that the filtered product HTML is rendered correctly in the response.

Questions:

  1. What could be the reason for all products being displayed despite the filters?
  2. Are there any debugging tips or common pitfalls I should look out for in my implementation?

Thank you for your help!

Svg fill animation from left to right

Here’s the attached svg image for my initial svg(which has a light grey fill) and my final svg(which has a linear gradient fill).

I want to achieve a animation so that it fills the linear gradient in that light grey svg from left to the right. Kindof like a progress bar.Initial state of svg

Final State of svg

I tried doing that using css mask-clip but unfortunately i am unable to achieve the desired result

TypeScript SetIterator.toArray() Method Not Recognized

Description:

I’m encountering an issue when attempting to use the toArray() method on a SetIterator object in TypeScript. While the method is available in JavaScript, TypeScript is flagging an error indicating that the method does not exist on the SetIterator type.

  const str1 = "abcd"
  const set1 = new Set([...str1]);

  let keys: SetIterator<string> = set1.keys();

  return keys.toArray().join("");
// get error Property 'toArray' does not exist on type 'SetIterator<string>'.ts(2339)

why typescript cant reconize toArray() method?

TypeScript version: ^5.7.0-dev.20241013
VScode: 1.94.2
vite: “^5.0.8”

I’ve tried using explicit type assertions, but they haven’t resolved the issue.
I’ve verified that my TypeScript setup is up-to-date.
I’ve consulted relevant documentation and community forums without finding a solution.
i know about Array.from()

Sending array of texts to Django, via POST, cannot get as array, getting string

I’m sending this data to Django, these texts are from multiple CKEditors

chk_vals = ["Some text","Other text"];
const data = new URLSearchParams();
data.append("csrfmiddlewaretoken", "{{csrf_token}}");
data.append("tmplData", JSON.stringify(chk_vals));

fetch(uri, {
        method: 'post',
        body: data,
    })
    .then(response => response.json())
    .then(data => {

It’s from Chrome’s network:
tmplData: [“Some text”,”Other text”]

Now Django:

data = request.POST
templateArr = data.getlist('tmplData')
templateList = list(templateArr)

And the length of the templateList is 1, it is getting it as one string and I cannot split it with ‘,’ because these texts can contain ‘,’ too.

I also tried
templateArr = data.getlist(‘tmplData[]’)

and sending without JSON.stringify, but nothing works

data = request.POST
templateArr = data.getlist('tmplData[]')
templateList = list(templateArr)

and this variable templateArr is empty

Value is undefined when accessing data variable inside a loop from other data variable in Vue.js Options API [duplicate]

Here’s my script, using Vue.js Options API:

<div id="app">
    <button @click="readArrays">Read Arrays</button>
</div>

<script>
    
    const { createApp } = Vue
      const app = createApp({
        data() {
          return {
            array1 : [1, 2, 3],
            array2 : [4, 5, 6, 7]
          }
        },
        methods: {
          readArrays() {
            this.array1.forEach(function (a) {
              console.log(a)
              this.array2.forEach(function (b) {
                console.log(b)
              })
            })
          }
        }
    })
    app.mount('#app')

</script>

It gives the message: this.array2 is undefined. How to fix this? I need to access or modify the values from the second array, but inside the forEach loop in the first array.

Why is the Javascript file not loaded?

I am writing a simple log-in website with Javascript and HTML. The first page is “index.html”. Here the user can log in with username and password. I just designed it.

<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login-Seite</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #f0f0f0;
            margin: 0;
        }
        .container {
            text-align: center;
            background-color: #fff;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        input {
            width: 100%;
            padding: 10px;
            margin: 10px 0;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
        button {
            width: 48%;
            padding: 10px;
            margin: 10px 1%;
            border: none;
            border-radius: 5px;
            background-color: #4CAF50;
            color: white;
            cursor: pointer;
            font-size: 16px;
        }
        button:hover {
            background-color: #45a049;
        }
    </style>
</head>
<body>
    <div class="container">
        <h2>Login</h2>
        <input type="text" id="username" placeholder="User name" required>
        <input type="password" id="password" placeholder="Password" required>
        <div>
            <button onclick="register()">Register</button>
            <button onclick="login()">Log in</button>
        </div>
    </div>
    <script>
        // Funktion für den Register-Button
        function register() {
            const username = document.getElementById('username').value;
            const password = document.getElementById('password').value;
            alert(`Registrierung für Benutzer: ${username} mit Passwort: ${password}`);
            window.location.href = 'registrierung.html';
        }

        // Funktion für den Login-Button
        function login() {
            const username = document.getElementById('username').value;
            const password = document.getElementById('password').value;
            alert(`Login für Benutzer: ${username} mit Passwort: ${password}`);
            // Hier kann weiterer Code hinzugefügt werden, um die Login-Überprüfung durchzuführen
        }
    </script>
</body>
</html>

Here there are two textfields, one for the username and one for the password. So basically the login.
But this is not so important right now, I am now working at registering the user. So there is a button at index.html and the user is redirceted to “registrierung.html”:

<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login-Seite</title>
    <script src="index.js"  type="module" defer ></script>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #f0f0f0;
            margin: 0;
        }
        .container {
            text-align: center;
            background-color: #fff;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        input {
            width: 100%;
            padding: 10px;
            margin: 10px 0;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
        button {
            width: 48%;
            padding: 10px;
            margin: 10px 1%;
            border: none;
            border-radius: 5px;
            background-color: #4CAF50;
            color: white;
            cursor: pointer;
            font-size: 16px;
        }
        button:hover {
            background-color: #45a049;
        }
    </style>
</head>
<body>
    <div class="container">
        <h2>Register</h2>
        <input type="text" id="username" placeholder="User name" required>
        <input type="password" id="password" placeholder="Password" required>
        <input type="password" id="passwordR" placeholder="Repeat Password" required>
        <input type="email" id="email" placeholder="Email" required>
        <div>
            <button id="submitButton" onclick="testFunction()">submit</button>
            <button id="backButton">Go back to Login</button>
            
        </div>
    </div>
    <script>
        /* import { createUser } from 'index.js';

         
        
        // Funktion für den Register-Button
        document.getElementById("submitButton").onclick = function submit() {
            
            const username = document.getElementById('username').value;
            const password = document.getElementById('password').value;
            const email = document.getElementById('email').value;
            alert(`Registrierung für Benutzer: ${username} mit Passwort: ${password}`);
            createUser(email, password);
            // Hier kann weiterer Code hinzugefügt werden, um die Registrierung durchzuführen
        }*/

        // Funktion für den Login-Button
        /*document.getElementById("backButton").onclick =function goback() {
            const username = document.getElementById('username').value;
            const password = document.getElementById('password').value;
            alert(`Login für Benutzer: ${username} mit Passwort: ${password}`);
            window.location.href = 'index.html';
            // Hier kann weiterer Code hinzugefügt werden, um die Login-Überprüfung durchzuführen
        }*/
    </script>
</body>
</html>

So as you see, in “registrierung.html” the user can type a username, a password, repeat it and his email. When the button submit is pressed, then the user should be signed in at firebase. This is how “registrierung.html” should work.
But for testing, I have only programmed one thing, that is carried out, wenn the button submit is pressed: A test function from “index.js” should be carried out.
This is “index.js”:

// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getAuth, createUserWithEmailAndPassword } from "firebase/auth";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries

// Your web app's Firebase configuration
const firebaseConfig = {
  apiKey: "..."
  authDomain: "..."
  projectId: "..."
  storageBucket: "..."
  messagingSenderId: "..."
  appId: "..."
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);

const auth = getAuth();
function createUser(email, password){
    return createUserWithEmailAndPassword(auth, email, password)
    .then((userCredential) => {
      // Signed up 
      const user = userCredential.user;
      // ...
    })
    .catch((error) => {
      const errorCode = error.code;
      const errorMessage = error.message;
      // ..
    });

}

function testFunction(){
    const a = 1+1;
}



signInWithEmailAndPassword(auth, email, password)
  .then((userCredential) => {
    // Signed in 
    const user = userCredential.user;
    // ...
  })
  .catch((error) => {
    const errorCode = error.code;
    const errorMessage = error.message;
  });


So just look at the testFunction where a simple operation is done.

The problem is now, that, eventhough I included index.js in registrierung.html, index.js is not loaded, when I run it on my local server.

Even though when I use logs, they are not shown in the console.
I am working with Visual Studio Code and I am using Live Server which is running on http://127.0.0.1:5500/

Why doesn’t my home button work when using the same js file on multiple html pages?

I am making a simple site, and I have three following files:

1st file:

# home.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Test website</title>
</head>
<body>
    <h1>Welcome to my page</h1>
    <br />
    <button id="about">About me</button>
    <button id="contact">Contact me</button>
    <button id="pricing">Pricing</button>
    
    <script src="index.js"></script>
</body>
</html>

2nd file:

# about_me.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>About me</title>
</head>
<body>
    <h1>About me page</h1>
    <br />
    <button id="home">Home</button>
    
    <script src="index.js"></script>
</body>
</html>

3rd file:

# index.js
document.querySelector("#about").addEventListener("click", function() {
        window.location.href="about_me.html"
    })
    
    document.querySelector("#contact").addEventListener("click", function() {
        window.location.href="contact_me.html"
    })
    
    
    document.querySelector("#home").addEventListener("click", function() {
        window.location.href="home.html"
    })

The problem I am having is the following:

When I am at the home.html and click About me button, it takes me to the about_me.html file, but when I am in that page and click Home button it does nothing.

I have tried adding the JS code inside about_me.html file and it works that way.

Why it doesn’t work this way?

P.S. All of the files are in the same folder. And it works if I separate them in different JS files.

How to inherit the font styles from the parent of an iframe

How to inherit the font from the parent of an iframe.
If this is impossible, what could be the alternative?

I maintain a small website. The main menu looks like this:

<!DOCTYPE html>
<html lang="nl">
  <meta charset="utf-8">
  <title>Container for iframe</title>
  <style>
    html, body, #main   { height: 100%; }
    iframe              { height: 100%; width: 100%;}
    body, #main         { font-family: sans-serif; }
    #main               { background-color: azure; }
    iframe, #main       { height: 100%; width: 100%; }
  </style>
  
  <p>Container for iframe</p>
  <p><a href="choice-1.html" target="content">Inherit font from iframe</a>
  <p><a href="choice-2.html" target="content">Choice two</a>
  
  <div id="main" style="background-color: azure; color: red">
   <p>Show iframe below:
   <iframe name="content" src="choice-1.html">
    <p>Fall back.
   </iframe>
  </div>
</html>

This is the html of the child page:

<!DOCTYPE html>
<html lang="nl">
<meta charset="utf-8">
<title>Test</title>
<style>
html, body {font-family: inherit;}
</style>
<h1>I am choice one</h1>
<p>I try to inherit the font from my parent, but failed...
</html>

The problem is that the website should be manageable by someone with limited knowledge of html, css and javascript. A simple solution would be appreciated.

Why doesn’t esbuild work, it can’t resolve the entryPoint

This is my simple project structure:

.
├── build
│   ├── settings.js
│   ├── build.js
│   ├── serve.js
├── src
│   ├── scripts
|   |   ├── index.ts
|   |   ├── ...
│   ├── styles
|   |   ├── style.scss
|   |   ├── ...
├── www
│   ├── index.html
│   ├── style.css
│   ├── index.js
├── tsconfig.json
├── node_modules
├── package.json
├── package-lock.json
  • settings.js:

    import esbuildPluginTsc from "esbuild-plugin-tsc";
    
    export function createSettings(options) {
      return {
        entryPoints: ["../src/scripts/"],
        bundle: true,
        outdir: "../www",
        plugins: [
          esbuildPluginTsc({
            tsconfigPath: "../tsconfig.json",
            force: true,
          }),
        ],
        ...options,
      };
    }
    
  • build.js:

    import * as esbuild from "esbuild";
    import { createBuildSettings } from "./settings.js";
    
    const settings = createBuildSettings({ minify: true });
    
    await esbuild.build(settings);
    

Execution of node build/build.js fails with this error:

✘ [ERROR] Could not resolve "../src/scripts/index.ts"

I tried to solve that using tiny-glob according to Could not resolve esbuild entry points like so:

export async function createSettings(options) {
  return {
    entryPoints: await glob("../src/scripts/*.ts"),
    ...
}

This attempt also failed and await glob("../src/scripts/*.ts") only returns :

node:internal/modules/run_main:123
    triggerUncaughtException(
    ^

[Error: ENOENT: no such file or directory, scandir 'C:UsersusernameDesktopsrcscripts'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'scandir',
  path: 'C:\Users\username\Desktop\src\scripts'
}