How to save variable using cookies or something else with javascript and html

I am making a clicker game with javascript and html and I was just wondering how I could use cookies, or if you have a better option that, to save the user’s progress after they close or refresh the page.
Here is my code:

<body style="background-color:#ACE087">
  <header id="myHeader">
    <h3 style="font-size: 40px">Restaurant Tycoon</h3>
  <h3 style="font-size: 13px">Made By Terry Morgan</h3>
  </header>
  <style>
  .button {
  background-color: #FAF3E3; 
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  cursor: pointer;
}</style>
  <p id="karpartz"></p>
  <p id="ohio"></p>
  <p id=curry></p>
  <p id="invaid"></p>
  <p id="cawfee"></p>
  <p id="bargir"></p>

  <button  style="color: black;" class= "button" id="government">
    buy lemonade stand
  </button>
  <button style="color: black;" class="button" id="ohiow">
    buy bake sale
  </button>
  <button style="color: black;" class="button" id="kar">
    buy food court stand
  </button>
  <button style="color: black;" class="button" id="invadio">
    buy coffee shop
  </button>
  <button style="color: black;" class="button" id="babiq">
    buy barbecue resturant
  </button>
 <button style="color: black;" class="button" id="burgs">
 buy burger restaurant
 </button>
 <header style="font-size: 30px">
    Unlock new buttons</header>
  <button style="color: black;" class="button" id="unlockinvade">
    unlock coffee shop (5 lemonade stands)
  </button>
  <button style="color: black;" class="button" id="unlockbbq">
    unlock barbecue resturant (20 coffee shops)
  </button>
  <button style="color: black;" class="button" id="unlockburgers">
  unlock burger restaurant (50 barbeque restaurants)
  </button>
  <header style="font-size: 30px">
  Unlock upgrades
  </header>
  <button style="color: black;" class="button" id="2cpower"> 
  1 more click power (25 lemonade stands)
  </button>
      <body>
    <h1>
      <script type="text/javascript">
        karpartz.innerHTML = karpartz
        ohio.innerHTML = ohio
        curry.innerHTML = curry
        invaid.innerHTML = invaid

      </script>
    </h1>
  <script>

console.log("loading...")

function cantafford() {
  alert("You cannot afford this.")
}

function oauwenzijkb() {
  var denrs = document.getElementById('invadio');
  var denrsss = document.getElementById('babiq');
  var denrssss = document.getElementById('burgs');
  denrs.style.display = 'none';
  denrsss.style.display = 'none';
  denrssss.style.display = 'none';
}
oauwenzijkb()

function hide2clickpower(){
var div19191919 = document.getElementById('2cpower')
div19191919.style.display = 'none';}
function hideburgers() {
  var div5 = document.getElementById('unlockburgers');
  var div6 = document.getElementById('burgs');
  div5.style.display = 'none';
  div6.style.display = 'block';
}

function hideinvade() {
  var div = document.getElementById('unlockinvade');
  div.style.display = 'none';
  var div2 = document.getElementById('invadio');
  div2.style.display = 'block';
}

function cool63473() {
  var div3 = document.getElementById('unlockbbq');
  div3.style.display = 'none';
  var div4 = document.getElementById('babiq');
  div4.style.display = 'block';
}

var cpower = 1
var burgers = 0
var bbq = 0
var invades = 0
var cars = 0
var hacks = 0
var hacked = 0
var files = 0
var leaked_files = files + (" lemonade stands")
document.getElementById("bargir").innerHTML = burgers + " burger restaurants"
document.getElementById("cawfee").innerHTML = bbq + " barbecue resturants"
document.getElementById("ohio").innerHTML = hacks + " bake sales"
document.getElementById("karpartz").innerHTML = leaked_files;
document.getElementById("curry").innerHTML = hacked + " food court stands";
document.getElementById("invaid").innerHTML = invades + " coffee shops";
function onButtonClick() {
  if (event.target.id === "2cpower") {
    if (files > 24){
      cpower = cpower + 1
      files = files - 25
      leaked_files = files + (" lemonade stands")
      document.getElementById("karpartz").innerHTML = leaked_files;
      alert("2x clickpower!")
      hide2clickpower()}
    else{
      cantafford()}
  }
  else if (event.target.id === "burgs") {
    burgers = burgers + cpower
    document.getElementById("bargir").innerHTML = burgers + " burger restaurants"
  } else if (event.target.id === "unlockburgers") {
    if (bbq > 49) {
      hideburgers()
      bbq = bbq - 50
      document.getElementById("bargir").innerHTML = burgers + " burger restaurants"
      alert("you can now buy burger restaurants!")
    } else if (bbq < 50) {
      cantafford()
    }
  } else if (event.target.id === "government") {
    files = files + cpower
    leaked_files = files + (" lemonade stands")
    document.cookie = "files"
  

    document.getElementById("karpartz").innerHTML = leaked_files;
  } else if (event.target.id === "ohiow") {
    hacks = hacks + cpower
    document.getElementById("ohio").innerHTML = hacks + " bake sales";
  } else if (event.target.id === "kar") {
    cars = cars + cpower
    document.getElementById("curry").innerHTML = cars + " food court stands";
  } else if (event.target.id === "unlockinvade") {
    if (files > 4) {
      hideinvade()
      files = files - 5
      leaked_files = files + (" lemonade stands")
      document.getElementById("karpartz").innerHTML = leaked_files;
      alert("coffee shops now available!!")
    } else if (5 > files) {
      cantafford()

    }
  } else if (event.target.id === "invadio") {
    invades = invades + cpower
    document.getElementById("invaid").innerHTML = invades + (" coffee shops");
  } else if (event.target.id === "unlockbbq") {
    if (20 > invades) {
      cantafford()
    } else if (invades > 19) {
      cool63473()
      if (lemonlemon = 1){
        invades = invades - 20
        document.getElementById("invaid").innerHTML = invades + " coffee shops";
      }
      alert("barbecue resturants now available!")
    }
  } else if (event.target.id === "babiq") {
    bbq = bbq + cpower
    document.getElementById("cawfee").innerHTML = bbq + " barbecue resturants";
  }
}

const buttons = document.querySelectorAll('button');
for (const button of buttons) {
  button.addEventListener('click', onButtonClick);
}
console.log("loading complete!")

    </script>
  </body>
 email [email protected] if you have ideas or to report bugs.

<header></header>
support my game
<a href="https://restauranttycoon.mysellix.io/">here</a>
</body>
<header></header>
<button id="dev">
this button does nothing and wastes your time
</button>

Any help is appreciated, thanks . Any help is appreciated, thanks . Any help is appreciated, thanks . Any help is appreciated, thanks . Any help is appreciated, thanks . Any help is appreciated, thanks . Any help is appreciated, thanks . Any help is appreciated, thanks .

How to capture variable data in Edge Browser with Access 365 from javascript event listener

I am trying to figure out how to capture the data passed from this JavaScript event listener…

I am opening the webpage in an edge browser control inside of my access database.

I do have the references for Microsoft HTML object Library and Microsoft Internet Controls as well as XML and scripting runtime.

Thanks in advance for your assistance!

<script>
    window.addEventListener("array-event", function arrayEvent(arrayEvent) {
        const {
            tagName,
            event,
            metadata = {},
        } = arrayEvent.detail;
    console.log("component: " + tagName + "; user action: " + event);
    if (metadata){console.log(metadata);
    }
    });
</script>

I haven’t really tried too much as I am new to the Java side of this and am not really sure how to capture the data…

How to Fix Webpack Dev Server Deprecation Warnings for Middleware Options?

Im encountering the following warnings while running my webpack dev Server:

(node:5456) [DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning: 'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:5456) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.

Ive tried to resolve this issue by updating my webpack configuration to replace the deprecated options with the recommended setupMiddlewares option, but unfortunately, it doesn’t seem to work.

I tried updating my webpack Dev Server config by swapping out the old onBeforeSetupMiddleware and onAfterSetupMiddleware options for the new setupMiddlewares option I was hoping this would get rid of those annoying deprecation warnings when I run the server But even after making the change the warnings are still popping up which makes me think I might’ve missed something or that the new setup isn’t working right

Node.js Javascript heap out of memory even with 64 GiB –max-old-space-size

I am having an issue of my Javascript application on our deployment server. It processes a few large CSVs (about 3 GB in size) by means of loading into memory (it is necessary because there are interdependencies between them).

However, the application crashes with follow:


[3910795:0x7f2d1c144000]   153589 ms: Scavenge (interleaved) 15.0 (17.9) -> 14.4 (16.1) MB, pooled: 2 MB, 487.30 / 0.00 ms  (average mu = 0.962, current mu = 0.962) allocation failure; 


<--- Last few GCs --->

[3910795:0x7f35941ef000]   118015 ms: Scavenge (interleaved) 10.3 (14.1) -> 9.6 (14.1) MB, pooled: 2 MB, 0.37 / 0.00 ms  (average mu = 0.988, current mu = 0.988) task; 
[3910795:0x7f35941ef000]   151219 ms: Mark-Compact (reduce) 9.8 (14.1) -> 9.5 (11.1) MB, pooled: 0 MB, 32232.90 / 0.01 ms  (+ 151.2 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 32418 ms) (average mu = 0.778, c

<--- JS stacktrace --->


<--- JS stacktrace --->

FATAL ERROR: Committing semi space failed. Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

FATAL ERROR: Committing semi space failed. Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

 1: 0xe3811e node::OOMErrorHandler(char const*, v8::OOMDetails const&) [node]
 1: 0xe3811e node::OOMErrorHandler(char const*, v8::OOMDetails const&) [node]
 2: 0x125faf0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 2: 0x125faf0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 3: 0x125fdc7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 4: 0x148d805  [node]
 3: 0x125fdc7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 5: 0x14fadce  [node]
 4: 0x148d805  [node]
 5: 0x14fadce  [node]
 6: 0x14a4ab0 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [node]
 7: 0x14a6629  [node]
 8: 0x14a9ab8  [node]
 9: 0x1ce6351  [node]

I am already running the application with node --max-semi-space-size=1024 --max-old-space-size=65536 and the memory allocation has never reached 64 GiB, while on my local workstation it doesn’t crash even I have only allocated 32 GiB to max-old-space-size.

How can I prevent it from crashing?

Black Car Service Dallas

Looking for a transportation solution that combines luxury, reliability, and professionalism? At** Black Car Service Dallas**, we specialize in providing premium rides tailored to your needs. Whether it’s a seamless airport transfer, a stylish arrival at a corporate meeting, or transportation for special occasions, we ensure every journey is smooth and stress-free.

Our fleet of elegant vehicles and experienced chauffeurs guarantee punctuality, comfort, and safety. We’re committed to delivering exceptional service that exceeds expectations.

Visit Our Website: Black Car Service Dallas/

Contact Us: 1-877-219-0565
**
Email Us :** [email protected]

#LuxuryTravel #BlackCarService #DallasTransportation

Have questions or need to book a ride? Let us know your requirements, and we’ll handle the rest!

Share your experiences or ask about our services—let’s make your travel unforgettable with Black Car Service Dallas!

Next.js Image not loading from firebase {Next.js 15}

In my code Next.js 15 Image component Is not loading from the local host but it is working in Vercel. The image URL also working and I have done the necessary configuration in the next.js config file.

This is my Code

"use client";

import { formatPrice } from "@/utils/formatprice";
import { truncatetext } from "@/utils/truncateText";
import { Rating } from "@mui/material";
import Image from "next/image";
import { useRouter } from "next/navigation";

interface ProductCardProps {
  data: any;
}

const ProductCard: React.FC<ProductCardProps> = ({ data }) => {
  const router = useRouter();
  const productrating =
    data.reviews.reduce((acc: number, item: any) => item.rating + acc, 0) /
    data.reviews.length;
    console.log("Main Image URL", data.images[0].image);

  return (
    <div
      onClick={() => router.push(`/product/${data.id}`)}
      className="
        col-span-1
        cursor-pointer
        border-[1.2px]
        border-slate-200
        bg-slate-50
        rounded-md
        p-2
        transition-transform
        duration-300
        ease-in-out
        hover:scale-105
        shadow-md
        text-center
        text-sm
      "
    >
      <div className="flex flex-col items-center w-full gap-1">
        <div className="aspect-square overflow-hidden relative w-full">
          <Image
            fill
            src={data.images[0].image}
            alt={data.name}
            className="w-full h-full object-cover"
          />
        </div>
        <div className="mt-4 font-medium text-gray-700">
          {truncatetext(data.name)}
        </div>
        <div>
          <Rating value={productrating} readOnly />
        </div>
        <div className="text-xs text-gray-500">
          {data.reviews.length} reviews
        </div>
        <div className="font-semibold text-blue-600">
          {formatPrice(data.price)}
        </div>
      </div>
    </div>
  );
};

export default ProductCard;

this is http://localhost:3000/ example :

enter image description here

This is Vercel example :

enter image description here

Dont know the reason for that. please help me to fix that.

My form input boxes are clearing when the value is changed (password validation)

I have developed a React+NextJS application. The login page on load uses a useEffect hook to ask my server if the admin account exists. This in turn sets a hook, which affects what content is loaded.

const [adminExists, setAdminExists] = useState(false); // <- assume account does not exist    
const [submitEnabled, setSubmitEnabled] = useState(false);
const [errors, setErrors] = useState("");

useEffect(() => {
    ... request from server
    setAdminExists(true/false)
})

Then the return function of the page:

const LoginForm = () => {
    if (adminExists) {
        return (...loginForm)
    } else {
        return (
            <div ...props>
                <h1>title</h1>
                <Form ...props>
                    <div ...props>
                        <Input ...props/> // <- username
                    </div>
                    <div ...props>
                        <Input ...props/> // <- password
                    </div>
                    <div ...props>
                        <Input ...props/> // <- password confirm
                    </div>
                    <div ...props>
                        <Button ...props isDisabled={!submitEnabled}/> // <- submit button
                    </div>
                    <div ...props>
                        {errors}
                    </div>
                </Form>
            </div>
        )
    }
}

return (
    <LoginForm/>
)

The Input boxes have a key up listener as follows:

onKeyUp={validatePasswords}

And validatePasswords:

const validatePasswords = (e) => {
    // extract form data
    const password = form.get('password')
    const passwordConfirm = form.get('passwordConfirm')

    setSubmitEnabled(password.length > 0 && passwordConfirm > 0 && password === passwordConfirm)

    if (!password.startsWith(passwordConfirm)) {
        setErrors("Passwords must match")
    } else {
        setErrors("") // <- clear errors
    }
}

The problem:

  • When I type in the input box, if the startsWith check is true, nothing happens (as expected)
  • When the passwords match exactly, the input boxes clear and the submit button doesn’t actually get enabled
  • When the confirm password input doesn’t match the startsWith check, the input boxes clear. The error appears for a split second and disappears.

I believe the parent component is re-rendering when the hook is changed or am I wrong?

How do I get this to work? I am not very experienced with React or NextJS so help is much appreciated.

Why Cursor IDE automatically sorting my imports in React project?

I’ve installed Cursor IDE and opened my React project which I developed using Webstorm IDE. When I did some changes in one of my .jsx files, Cursor automatically sorted my imports by it’s own point of view or by alphabet, I’m not sure yet.

Why it is doing that and how I can switch it off?

I tried to find such option in Cursor settings, but did not find that.

How to stop chokidar from triggering on root folder it’s watching?

I am trying to set up a script that watches for new folders that are added to a directory called /test.

I am using Chokidar to watch for folder changes. The problem is, it fires an event for the folder it is supposed to be watching.

The script looks like this

import chokidar from "chokidar";

const watchDirectory = async () => {  
  const watcher = chokidar.watch('./test');

  watcher
    .on("addDir", (dirPath) => {
      const dirName = path.basename(dirPath);
      console.log(`Detected new folder: ${dirName}`); // logs: Detected new folder: test
    })
};

watchDirectory();

the addDir event callback runs and thinks that /test has just been added. But /test is the name of the folder I am watching.

How do I get Chokidar to ignore /test and just watch for new folders that are added to the test /test path?

Datatable search all records on pagination Laravel

I have a Laravel application with a paginated table for leads, and I’m using DataTables for enhanced functionality. While the DataTable works well with pagination for performance, the search functionality only searches the currently loaded page, not across all records in the database.

Here is my LeadController that handles the backend logic for fetching paginated records:

LeadController.php

    public function index()
{
    $users = User::all();

    // Check if a user is authenticated
    if (Auth::check()) {
        // Get the currently authenticated user
        $user = Auth::user();
        
        // Check if the user has the role of 'superadmin'
        if ($user->role === 'superadmin') {
            // Show all leads for superadmin, paginated
            $leads = Lead::latest()->paginate(10); // Change 10 to the number of leads per page
        } else {
            // Filter leads assigned to the current user, paginated
            $leads = Lead::where('lead_user', $user->id)->latest()->paginate(10); // Change 10 as needed
        }
    } else {
        // If no user is authenticated, handle as needed
        $leads = Lead::latest()->paginate(10);  // Change 10 as needed
    }

    return view('leads.index', compact('leads', 'users'));
}

Script.js

  <script>
        // var e;
        c1 = $('#style-1').DataTable({
            headerCallback:function(e, a, t, n, s) {
                e.getElementsByTagName("th")[0].innerHTML=`
                <div class="form-check form-check-primary d-block">
                    <input class="form-check-input chk-parent" type="checkbox" id="form-check-default">
                </div>`
            },
            columnDefs:[ {
                targets:0, width:"30px", className:"", orderable:!1, render:function(e, a, t, n) {
                    return `
                    <div class="form-check form-check-primary d-block">
                        <input class="form-check-input child-chk" type="checkbox" id="form-check-default">
                    </div>`
                }
            }],
            "dom": "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'f>>>" +
        "<'table-responsive'tr>" +
        "<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count  mb-sm-0 mb-3'i><'dt--pagination'p>>",
            "oLanguage": {
                "oPaginate": { "sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>', "sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>' },
                "sInfo": "Showing page _PAGE_ of _PAGES_",
                "sSearch": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
                "sSearchPlaceholder": "Search...",
               "sLengthMenu": "Results :  _MENU_",
            },
            "lengthMenu": [5, 10, 20, 50],
            "pageLength": 10
        });

        multiCheck(c1);

       
    </script>

i have tried to use seperate search and it doesnt look good

Using separate search logic by adding an additional backend search endpoint. However, this approach is clunky and doesn’t integrate well with DataTables’ built-in search.

Adjust Iframe height every time the content changes

I have seen similar questions like Adjust width and height of iframe to fit with content in it but i think that mine is different.
I have a Table inside a Iframe and few searching fields, my search is instant (onkeyup) and not after i pressed on a button.

My problem is that i dont want to reload the iframe every time i search something, i only want to “filter” the content when searching for something. I use Datatables for my table if it helps

I tryed this code, but it only works if i reload the i frame. I also want to keep the serach instant and not add a button to search.

my js code for the height of the iframe:

document.addEventListener('DOMContentLoaded', function() {
    
    var iframe = document.getElementById("iframeindex");

    if (iframe) {
        iframe.onload = function() {
            iframe.style.height = iframe.contentWindow.document.documentElement.scrollHeight + 'px';
        };
    }
});

and this is the search js code:

    function applyTextFilter() {
        // Volltext-Filter
        const volltext = $("#volltext-filter", parent.document);
        table.search(volltext.val()).draw();
    
        // Name-Filter
        const nameFilter = $("#name-filter", parent.document);
        table.columns(1).search(nameFilter.val()).draw();
    
        // Vorname-Filter
        const vornameFilter = $("#vorname-filter", parent.document);
        table.columns(2).search(vornameFilter.val()).draw();
    
        // Abteilung-Filter
        const abteilungFilter = $("#abteilung-filter", parent.document);
        table.columns(9).search(abteilungFilter.val()).draw();
    }
    
    // Keyup-Event-Listener für alle Filter anwenden
    $("#volltext-filter", parent.document).on('keyup', applyTextFilter);
    $("#name-filter", parent.document).on('keyup', applyTextFilter);
    $("#vorname-filter", parent.document).on('keyup', applyTextFilter);
    $("#abteilung-filter", parent.document).on('keyup', applyTextFilter);
    
    // Initiale Anwendung der Filter
    applyTextFilter();

I also use datatables for my table.

TypeScript signatures for functions related to the subclasses of `Array`

I need to define a type Objs which extends Array<Obj>. I’d like to use it where a regular Array is expected (for instance with the Array.prototype.* functions) and I’d like to extend it with some functionalities specific for my Objs type.

This is possible and very simple in JavaScript:

function id(val) { return val; }

class Objs extends Array {
  objsMethod() {}
}

const objs1 = Objs.from([]);
console.log(objs1.constructor.name); // Objs
const objs2 = objs1.map(id);
console.log(objs2.constructor.name); // Objs
const objs3 = objs2.filter(id);
console.log(objs3.constructor.name); // Objs

However in TypeScript none of this works. Every function related to Array returns an Obj[] rather than an Objs. Try for yourself:

function id<T>(val: T): T { return val; }
class Obj {}

class Objs extends Array<Obj> {
  objsMethod() {}
}

const objs1 = Objs.from([]); // Obj[]
//    ^?
const objs2 = (objs1 as unknown as Objs).map(id); // Obj[]
//    ^?
const objs3 = (objs2 as Objs).filter(id); // Obj[]
//    ^?

Is there any way to fix it without re-implementing the various functions?

For instance, can I forcefully override the type of Objs.from, Objs.prototype.filter etc without redefining them?

looking for scolling feature like https://mlu-explain.github.io/linear-regression/?

looking for scolling feature like https://mlu-explain.github.io/linear-regression/ ,
where in the graph section one side is scrolling the other side is constant but changing ,
i want to implement the idea for my portfolio project section does anyone know boiler plate for this ?

i tried but the result are not coming as expected , they both are scrolling like a normal container , hope any boilerplate exists thanks.

Can new Date return the next day at a particular time interval in a day

I have been using the library “date-fns-tz” that returns some time in this format:

20250111000000

Now I’m extracting the year, month and date in this way:

export function getAPIDateFormat({ ISOStartDateString }) {
  const formatTimeToUTC = zonedTimeToUtc(ISOStartDateString);
  return format(formatTimeToUTC, 'yyyyMMdd000000');
}

let dateString = getAPIDateFormat({ ISOStartDateString: new Date()});
// returns something like this "20250111000000"

Then I do some operations:

const [sYear, sMonth, sDay] = [
      dateString.substring(0, 4),
      dateString.substring(4, 6),
      dateString.substring(6, 8),
    ];

const start = new Date(sYear, sMonth - 1, sDay);

console.log("start - utils", start);

What’s starnage is during particular time in a day (between 6:30PM IST to 12AMIST), it prints
start - utils 2025-01-10T18:30:00.000Z

Before 6:30PM, it prints,

start - utils 2025-01-09T18:30:00.000Z

What I am pretty sure is sYear, sMonth - 1, sDay remains same, yet after 6:30 PM, the new Date for this same parameters return the next day instead of the same day.

As a result my test cases are failing in this interval.

emailfield.value is returning an empty string [duplicate]

import {
  getAuth,
  createUserWithEmailAndPassword,
  sendEmailVerification,
} from "https://www.gstatic.com/firebasejs/11.1.0/firebase-auth.js";
import { initializeApp } from "https://www.gstatic.com/firebasejs/11.1.0/firebase-app.js";
// https://firebase.google.com/docs/web/setup#available-libraries

// Your web app's Firebase configuration
const firebaseConfig = {
   //My firebase config
};

// Initialize Firebase and declare all variables
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const emailfield = document.getElementById("email");
const email = emailfield.value;
const passwordfield = document.getElementById("password");
const password = passwordfield.value;
const loginbtn = document.getElementById("loginbtn");

loginbtn.addEventListener("click", (event) => {
  event.preventDefault();

  //log email and password

  console.log(email);
  console.log(password);
});

^

| JavaScript Code

So, I was trying to set up a login App with Firebase Authentication but I encountered this Error:

When I am logging the Value of “password” and “email” with the console I am getting an empty String, but not undefined.

I am getting this Error even when I enter something in the Email and/or Password Field.

This is the HTML Code:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Sample Account Page</title>
    <link rel="stylesheet" href="styleaccount.css" />
    <link
      href="https://unpkg.com/[email protected]/css/boxicons.min.css"
      rel="stylesheet"
    />
    <script type="module" src="../scripts/accounthandler.js" defer></script>
  </head>
  <body>
    <div class="wrapper">
      <form>
        <h1>Login</h1>
        <div class="input-box">
          <input type="email" placeholder="Email" id="email" />
          <i class="bx bxs-user"></i>
        </div>
        <div class="input-box">
          <input type="password" placeholder="Password" id="password" />
          <i class="bx bxs-lock-alt"></i>
        </div>
        <div class="remember-forgot">
          <label><input type="checkbox" />Remember me</label>
          <a href="#">Forgot Password?</a>
        </div>
        <button type="submit" id="loginbtn" class="btn">Login</button>
        <div class="register-link">
          <p>
            Don't have an Account?
            <a href="register.html">Register</a>
          </p>
        </div>
      </form>
    </div>
  </body>
</html>

I tried the following things:

  1. Change the ID of the HTML element ( and the JS code )

  2. I also tried getting the Text of the Element instead of the Value