Find the currently focused span element inside an editable div

I have a sample at Finding currently focused span in an editable div.

The editable div i.e. a div having the attribute contenteditable="true", contains 3 different spans with each span wrapped in a div. A user could position the cursor in any one of the three spans. My goal is to find out which span is being edited when user clicks on a span content to start editing or types into it. I would like this to work on desktop or mobile devices.

I tried getting the span using document.activeElement as you can see in my code sample, but it gets the editable div and not the current span. I was looking for a JavaScript solution to this problem.

Question:
How would I get the id of span element whose text is being edited using JavaScript?

Html code

<div id="input" contenteditable="true" onfocus="findCurrentSpan(this)">
<div>
<span id="first">first span</span>
</div>
<div>
<span id="second">second span</span>
</div>
<div>
<span id="third">third span</span>
</div>

Javascript code

function findCurrentSpan(editor) {
var element = document.getElementById("input");
var currentSpan = document.activeElement;
document.getElementById("info").innerHTML = "Active element's id is " + currentSpan.id;

}

How to make php function according to the drop down menu list selection without a button

Hello im working with php and i have this drop down menu list code:

 <form method="POST" >
                <select name="users" id="users">
                    <option <?php if(isset($_POST['users']) && $_POST['users'] == '2') echo "selected='selected'";  ?> value="2">User one</option>
                    <option <?php if(isset($_POST['users']) && $_POST['users'] == '3') echo "selected='selected'";  ?> value="3">User Two</option>
                </select>
                    <input type="submit" class="fadeIn fourth"  name="refresh" value="Refresh">
                </form>

and then i have the php code that starts:

     <?php
                    if(isset($_POST['refresh'])){
    ....
?>

Now i want to remove the button from the html and i want to make the php code execute automatically when i select from the drop down list menu. I tried something with javascript but wasnt what i needed it was just printing the value as alert.

How to delete an item from a list using input in form (React using states)?

I want to delete an object from an array using its name.

  const [formDataRemoval, setFormDataRemoval] = React.useState({
    name: "",
  });

When input changes, the following function detects it.


  function handleChangeRemoval(event) {
    setFormDataRemoval((prevFormDataRemoval) => {
      return {
        ...prevFormDataRemoval,
        [event.target.name]: event.target.value,
      };
    });
  }

When button “Remove Item” which is set in form, is clicked, the function removeItem() is run.

  function removeItem(event) {

    console.log("Remove item");
    event.preventDefault()
    setAllThingsArray({allThingsArray: this.state.allThingsArray.filter((thing) => 
        thing.name !== event.target.name
    )});
  }

However, when I click the button, nothing happens and nothing shows in the console. How to fix this?

React is not defined when using SystemJS

I was trying using SystemJS to load React but it didn’t loaded instead throwing an error message in Console > ‘React is not defined’
I’ve read their documentation also searching through similar questions but doesn’t satisfy my need, did i miss something?
Here’s is what I was tried

<!DOCTYPE html> <html lang="en"> <head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>React 18 with SystemJS</title>

<script src="dependencies/systemjs-6.12.1.min.js"></script>
<script type="systemjs-importmap"> {
  "imports": {
    "react" : "/react.production-18.min.js" 
  , "reactDOM" : "/react-dom.production-18.min.js"
} }
</script>
</head><body>
  <div id="root">

  <script type="systemjs-module">
System.import('react');
System.import('reactDOM');

class Hello extends React.Component {
  render() {
    return React.createElement('div', null, `Hello ${this.props.toWhat}`);
} }
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(React.createElement(Hello, {toWhat: 'World'}, null));
  </script>

</div></body></html>

how can I get a link to open in the parent frame

I am using the following code to open a page on the same website from a canvas animation (produced in adobe animate) in an iframe. It works fine in safari, but not chrome. Any advice would be greatly appreciated.

window.top.location.href = 'https://iamsteve.co.uk/renovations2';

The adobe animation is here: https://iamsteve.co.uk/houseofholmes/header-05.html
The link is in the first box ‘renovations & extension’ and works fine on this page.
I am then pulling it into an iframe at https://iamsteve.co.uk/holme03 which is when it stops working.

I’ve tried ‘parent’ also, and again it works fine in Safari but not Chrome. Any help would be greatly appreciated.

Thanks
Steve

Draw polygon with multiple cut points in Here Map reactjs

I am currently having problems drawing polygons when custom component Here Map with intersecting points then the parts are filled color wrong and It’s even more wrong when zooming in. For non-intersecting points, it works fine. Here map version I used: 1.30.15. pls, let me know where i did wrong


enter image description here

My code:

import {
  FC,
  MouseEvent,
  RefObject,
  useCallback,
  useEffect,
  useRef,
  useState,
} from "react";
import clsx from "clsx";
import H from "@here/maps-api-for-javascript";
import onResize from "simple-element-resize-detector";

import styles from "./DisplayMap.module.scss";

const MARKER_SIZE = 10;

const DisplayMap: FC = () => {
  const mapRef = useRef<HTMLElement>();
  const ctxRef = useRef<CanvasRenderingContext2D>();
  const renderingParamsRef = useRef<H.map.render.RenderingParams>();

  const [map, setMap] = useState<H.Map>();
  const [lineString, setLineString] = useState<H.geo.LineString>(
    new H.geo.LineString()
  );
  const [points, setPoints] = useState<H.geo.IPoint[]>([]);
  const [isMove, setIsMove] = useState(false);
  const [isDrawing, setIsDrawing] = useState(false); // false: end, true: start

  const initMap = useCallback((lat: number, lng: number) => {
    if (mapRef.current) {
      const platform = new H.service.Platform({
        apikey: "apiKeyssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss",
      });
      const layers = platform.createDefaultLayers();
      const mapObj = new H.Map(mapRef.current, layers.vector.normal.map, {
        pixelRatio: window.devicePixelRatio || 1,
        center: { lat, lng },
        zoom: 5,
      });
      onResize(mapRef.current, () => {
        mapObj.getViewPort().resize();
      });
      mapObj.addLayer(
        new H.map.layer.CanvasLayer(function (
          ctx: CanvasRenderingContext2D | WebGLRenderingContext,
          renderingParams
        ) {
          if (ctx instanceof WebGLRenderingContext)
            return H.map.render.RenderState.PENDING;

          ctxRef.current = ctx;
          renderingParamsRef.current = renderingParams;
          return H.map.render.RenderState.DONE;
        })
      );
      const behavior = new H.mapevents.Behavior(
        new H.mapevents.MapEvents(mapObj)
      );
      behavior.disable(H.mapevents.Behavior.Feature.DBL_TAP_ZOOM);
      H.ui.UI.createDefault(mapObj, layers);

      setMap(mapObj);
    }
  }, []);

  const handleMove = (status: boolean) => {
    setIsMove(status);
  };

  const handleEndDraw = () => {
    if (points.length >= 2) {
      lineString.pushPoint(points[0]);

      const polygon = new H.map.Polygon(lineString, {
        style: { lineWidth: 4 },
      } as H.map.Polygon.Options);
      map?.addObject(polygon);
    }

    setIsDrawing(false);
    setPoints([]);
    setLineString(new H.geo.LineString());

    if (ctxRef.current && renderingParamsRef.current) {
      ctxRef.current.clearRect(
        0,
        0,
        renderingParamsRef.current.size.w,
        renderingParamsRef.current.size.h
      );
    }
  };

  const handleToggleDraw = (e: MouseEvent<HTMLDivElement>) => {
    if (isMove) return;

    const { clientX: viewportX, clientY: viewportY } = e;
    const coord = map?.screenToGeo(viewportX, viewportY);
    if (points[0]) {
      const lastPointCoord = map?.geoToScreen(points[0]);
      if (
        Math.abs((lastPointCoord?.x || 0) - viewportX) <= MARKER_SIZE / 2 &&
        Math.abs((lastPointCoord?.y || 0) - viewportY) <= MARKER_SIZE / 2
      ) {
        handleEndDraw();
        return;
      }
    }
    const pos: H.geo.IPoint = {
      lat: coord?.lat ?? 0,
      lng: coord?.lng ?? 0,
      alt: 5,
    };

    lineString.pushPoint(pos);
    setPoints([...points, pos]);

    // danh dau diem
    const markerEl = document.createElement("div");
    markerEl.style.cursor = "pointer";
    markerEl.style.width = `${MARKER_SIZE}px`;
    markerEl.style.height = `${MARKER_SIZE}px`;
    markerEl.style.marginTop = `-${MARKER_SIZE / 2}px`;
    markerEl.style.marginLeft = `-${MARKER_SIZE / 2}px`;
    markerEl.style.position = "relative";
    markerEl.style.userSelect = "none";
    markerEl.style.borderRadius = "50%";
    markerEl.style.backgroundColor = "transparent";
    const domIcon = new H.map.DomIcon(markerEl);
    const markerObj = new H.map.DomMarker(pos, {
      icon: domIcon,
    } as H.map.DomMarker.Options);
    map?.addObject(markerObj);

    if (!isDrawing) {
      setIsDrawing(true);
    } else {
      map?.addObject(
        new H.map.Polyline(lineString, {
          style: { lineWidth: 4 },
        } as H.map.Polyline.Options)
      );
    }
  };

  const handlePreviewDraw = (e: MouseEvent<HTMLDivElement>) => {
    if (ctxRef.current && renderingParamsRef.current) {
      ctxRef.current.clearRect(
        0,
        0,
        renderingParamsRef.current.size.w,
        renderingParamsRef.current.size.h
      );
      if (!isDrawing || isMove) return;

      const { clientX: viewportX, clientY: viewportY } = e;
      const lastPos = map?.geoToScreen({
        lat: points.at(-1)?.lat || 0,
        lng: points.at(-1)?.lng || 0,
      });
      if (lastPos) {
        ctxRef.current.strokeStyle = "red";
        ctxRef.current.lineWidth = 4;
        ctxRef.current.beginPath();
        ctxRef.current.moveTo(lastPos.x, lastPos.y);
        ctxRef.current.lineTo(viewportX, viewportY);
        ctxRef.current.stroke();
      }
    }
  };

  useEffect(() => {
    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(function (position) {
        const lat = position.coords.latitude;
        const lng = position.coords.longitude;
        initMap(lat, lng);
      });
    } else {
      initMap(0, 0);
    }
  }, [initMap]);

  return (
    <div
      onClick={handleToggleDraw}
      onDoubleClick={handleEndDraw}
      onMouseMove={handlePreviewDraw}
      onMouseDown={() => handleMove(true)}
      onMouseUp={() => handleMove(false)}
      className={clsx(styles.container)}
      ref={mapRef as RefObject<HTMLDivElement>}
    ></div>
  );
};

export default DisplayMap;

window.location.href infinite looping

im using firebase auth to allow users to signup and login to the website,so im using onAuthStateChanged to allow them access to other pages when logged in,and to have them stay on the login page if they are not logged in ,however i am running into an infinite loop with my window.location.href and i don’t understand why at all this is my code

auth.onAuthStateChanged(user =>{
if(user){
  window.location.href = "/pages/home.html";
}else{
  
  window.location.href = "/";
}

});

the solution i tried was this:

auth.onAuthStateChanged(user =>{
if(user){
  if(windows.location.href !== "/pages/home.html"){
  window.location.href = "/pages/home.html";
  }
}
if(!user){
  if(windows.location.href !== "/"){
    window.location.href = "/";
  }
}
  

});

to try to avoid the infinite looping since it shouldn’t go into the if more than once but it did not work at all,i also tried window.location.replace and i got the same result.. any help is appreciated thank you

I use Fetch API to get data from wikipedia open api, the console has result, but Promise of fetch hasn’t data

First, I try to send request by browser, everything is ok.

Second, I tried following code, the console of Microsoft Edge show this error:

Access to fetch at ‘https://en.wikipedia.org/w/api.php?format=json&action=opensearch&search=hello&callback=JSON_CALLBACK’ from origin ‘http://127.0.0.1:5500’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.

<body>
    <h1>Hello</h1>
    <script>
        (async function (){
            let response = await fetch("https://en.wikipedia.org/w/api.php?format=json&action=opensearch&search=hello&callback=JSON_CALLBACK", {
                method: "GET",
            })
            let text = await response.text();
            console.log(response);
            console.log(text);
        })();
    </script>
</body>

Then, I add mode property like this:

let response = await fetch("https://en.wikipedia.org/w/api.php?format=json&action=opensearch&search=hello&callback=JSON_CALLBACK", {
    method: "GET",
    mode: "no-cors"
})

the console doesn’t show error, but the response.ok is false, and the response.body is null.

enter image description here

but if i open network tool, I can see all data I want.
enter image description here


I know if I want to get data by json padding, I should create a script label, and use docuemnt.body.appendChild(script) to get data. I just don’t know why i failed by Fetch API.

Sum array of objects value based on month – ReactJS

So first of all, because I am using a MomentJS I need to generate an array of months.
The creation is looking like this :

const [generatedMonths, setGeneratedMonths] = useState<string[]>([])
const [totalValues, setTotalValues] = useState<number[]>([])

const months = []
const dateStart = moment()
const dateEnd = moment().subtract(11, 'month')

while (dateEnd.isBefore(dateStart, 'day')) {
    months.push(dateEnd.format('MMM'))
    dateEnd.add(1, 'month')
}
months.push(dateEnd.format('MMM'))

setGeneratedMonths(months)

After that i receive my data like this :

  const myArray = [
    {date: "2022-04-13", vat_percentages: {21: 92.31}, total: 92.31}
    {date: "2022-05-04", vat_percentages: {21: 21.24}, total: 21.24}
    {date: "2022-05-05", vat_percentages: {21: 47.41}, total: 47.41}
    ]

Then in my useEffect hook i am performing the sum :

useEffect(() => {
    if (myArray.length > 0) {
        const labelValues: number[] = generatedMonths.map(
            (label, index) => {
                const result = revenueArray.reduce((acc, curr) => {
                    const foundItem = acc.find(
                        (item) => item.date.format('MMM') === label
                    )

                    if (foundItem) {
                        foundItem.total += curr.total
                    } else {
                        acc.push(curr)
                    }

                    return acc
                }, [])
            }
        )

      setTotalValues(labelValues)
    }


},[myArray])

So the final idea would be to have a sum for each month based on my find method based on the total value. Like this:

console.log(totalValues)
// [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92.31, 68.65]

nextjs firebaseauth redirect before render page if logged in

I have a login page and an auth provider as follow

import * as yup from "yup";

import { useState } from 'react'

import { AuthErrorCodes } from 'firebase/auth'
import Cover from '../../components/Cover'
import Head from 'next/head'
import Headingblock from '../../components/Headingblock'
import Section from '../../components/Section'
import { authErrorCodesTranslation } from '../../config/firebase';
import { siteTitle } from '../_app'
import { useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup';
import { useRouter } from 'next/router';
import { useAuth } from "../../contexts/auth";
import { auth } from '../../config/firebase';
import { signInWithEmailAndPassword } from "firebase/auth";
import {useEffect} from 'react'

export default function Login() {

  const [response, setResponse] = useState({});
  const [user, userLoading] = useAuth();
  const router = useRouter();

  console.log(userLoading);

  if (!userLoading && user)
    router.push('/');

  const schema = yup.object().shape({
    email: yup.string().email('Adresse email invalide').required('Veuillez renseigner votre adresse email.'),
    password: yup.string().required('Veuillez renseigner votre mot de passe')
  });

  const { register, handleSubmit, formState } = useForm({
    resolver: yupResolver(schema),
  });

  const { errors } = formState;
  

  const onSubmit = async (data) => {
    
    await signInWithEmailAndPassword(auth, data.email, data.password)
        .then(userCredential => {
          router.push("/profile");
        }).catch(error => {
            const authErrorCode = Object.keys(AuthErrorCodes).find(k => AuthErrorCodes[k] === error.message);

            let errorTranslation = authErrorCodesTranslation.GLOBAL_AUTH_ERROR;

            if (authErrorCode !== undefined)
              errorTranslation = authErrorCodesTranslation[authErrorCode];

            setResponse({ status: 'error', message: errorTranslation });
        })
  }

  return (
    <>
      <Head>
        <title>{siteTitle} - Connexion</title>
      </Head>

      <Cover />

      <Section>
        <div className='container marginNTop100'>
          <div style={{ padding: '3rem 1.5rem', background: 'white', boxShadow: '0 30px 50px 0 rgb(1 1 1 / 15%)' }}>
            <Headingblock main="Connexion" />
            <form onSubmit={handleSubmit(onSubmit)}>
              <div className="form-row">
                <div className="form-group col" style={formgroupStyle}>
                  <label style={labelStyle}>Adresse email</label>
                  <input {...register("email")} type="text" className='form-control' style={formcontrolStyle} />
                  <div className="invalid-feedback" style={invalidStyle}>{errors.email?.message}</div>
                </div>
                <div className="form-group col" style={formgroupStyle}>
                  <label style={labelStyle}>Mot de passe</label>
                  <input {...register("password")} type="password" className='form-control' style={formcontrolStyle} />
                  <div className="invalid-feedback" style={invalidStyle}>{errors.password?.message}</div>
                </div>
              </div>
              <div className="form-group" style={formgroupStyle}>
                <button type="submit" style={Object.assign(btnStyle, btnprimaryStyle)}>
                  Connexion
                </button>
              </div>
              {
                response.status === 'error' && <div style={Object.assign(alertStyle, alertDangerStyle)}>{response.message}</div>
              }
            </form>
          </div>
        </div>
      </Section>
    </>
  )
}
import { createContext, useState, useEffect, useContext } from 'react';
import { onAuthStateChanged } from 'firebase/auth';
import { auth } from '../config/firebase'

const AuthContext = createContext({ user: null, userLoading: true });

export const AuthProvider = ({ children }) => {
    const [userLoading, setUserLoading] = useState(true);
    const [user, setUser] = useState();

    useEffect(() => {
        
        return onAuthStateChanged(auth, (user) => {
            
            console.log('autstatechanged');
            if (user) {
                console.log("1");
                setUser(user);
                setUserLoading(false);
                // ...
            } else {
                console.log("2");
                setUser(null);
            }
        });
    }, []);

    return (
        <AuthContext.Provider value={[user, userLoading]}>
            {children}
        </AuthContext.Provider>
    );
};

export const useAuth = () => useContext(AuthContext);

Once user is logged in I would like that page being not available anymore so I made a redirect once user is set and userloading is false but the page is rendering before redirect that causes a blink effect.

I wouldn’t like return a loading screen I think It should be possible to not render login page if user is logged in

Need to return more than 1 value from a recursive fuction in javascript. Needto return the data in the format mentioned

Code for reference. There is an issue for the value returned as removeKey, it is always getting a null value.

const clearEmpties = (obj: IParms) => {
        var removeKey: string[] = []
        for (var key in obj) {
            if (!obj[key] || typeof obj[key] !== "object") {
                continue
            }
            clearEmpties(obj[key]);
            if (Object.keys(obj[key]).length === 0) {
                removeKey.push(key)
                console.log("k", key, obj[key]);
                delete obj[key];
            }
        }
        return {obj , removeKey};
    }

Input for the code snippet is :

{"a" :{
"m": {
"m1": "cmp",
"m2": "M2M",
"m3": "2"
}
"p":{}
}
}

Output should be : 2 values , return an object by removing all empty objects & list the removed path.

{"a" :{
    "m": {
    "m1": "cmp",
    "m2": "M2M",
    "m3": "2"
    }   
    }
 }

& removeKey = a.p

Mocha loop at the middle of describe function

Can we run a dynamical loop test in mocha when we obtain the dynamic array from one of the test cases something like below?

describe('test', () {
  var array = []; 
  it('test 1', function(done) {
    // get the array
    // assume JSON = [ {number : 1, value : 1}, {number : 2, value : 2}]
  }
  // run loop test base on the array from test 1
  array.forEach() {
    it(`test {array.number}`, function(done) {
      // sample
      expect(array.number).to.be.equal(array.value)
    }
  }

  it('test 3', function(done) {
    // another test 
  }
}

So far, it seems to work fine if I ran in a separate js file instead of just one js file by passing the result of the JSON array (callback) to another test js file. What if I want it in one js file?

Reference: https://mochajs.org/#dynamically-generating-tests

When I resize my window and make it smaller I get this white gap at the bottom of my project

body{
    margin-top: 140px;
}
.outline{
    font-size: 75px;
    text-align: center;
    text-shadow: 
    0 0 7px #fff,
      0 0 10px #fff,
      0 0 21px #fff,
      0 0 42px #999,
      0 0 82px #999,
      0 0 92px #999,
      0 0 102px #999,
      0 0 151px #999;;
    -webkit-text-stroke:1px white;
  -webkit-text-fill-color:transparent;
}
.container{
    max-width: 400px;
    margin:10vh auto 0 auto;
    box-shadow: 0px 0px 43px 17px grey;
}
#display{
    text-align: right;
    height: 120px;
    line-height: 120px;
    padding-top: 18px;
    font-size: 50px;
    font-weight: 200;
    border-left: 1.5px solid #999;
    color: white;
    text-shadow: 0 0 10px white;
}

.buttons{
    display: grid;
    border-bottom: 1px solid #999;
    border-left: 1px solid #999;
    border-bottom: 3px solid #edebe8;
    grid-template-columns: repeat(4,1fr);
    font-weight:200px; 
    color:white;
}

.buttons > div {
    border-top: 2.5px solid #edebe8;
}

.button{
    border:0.5px solid #999;
    line-height: 100px;
    text-align: center;
    font-size: 25px;
    cursor:pointer;
}

#equal{
    background-color: whitesmoke;
    font-size: 35px;
    opacity: 0.3;
    color:black;
}

.button:hover{
    background-color: #323330;
    color:white;
    transition: 0.5s ease-in-out;
}
.foot{
    position: relative;
    text-align: center;
    top:200px;
    color:white;
    text-shadow: 0 0 10px white;
}
@keyframes move-twink-back {
    from {background-position:0 0;}
    to {background-position:-10000px 5000px;}
}
@-webkit-keyframes move-twink-back {
    from {background-position:0 0;}
    to {background-position:-10000px 5000px;}
}
@-moz-keyframes move-twink-back {
    from {background-position:0 0;}
    to {background-position:-10000px 5000px;}
}
@-ms-keyframes move-twink-back {
    from {background-position:0 0;}
    to {background-position:-10000px 5000px;}
}

@keyframes move-clouds-back {
    from {background-position:0 0;}
    to {background-position:10000px 0;}
}
@-webkit-keyframes move-clouds-back {
    from {background-position:0 0;}
    to {background-position:10000px 0;}
}
@-moz-keyframes move-clouds-back {
    from {background-position:0 0;}
    to {background-position:10000px 0;}
}
@-ms-keyframes move-clouds-back {
    from {background-position: 0;}
    to {background-position:10000px 0;}
}

.stars, .twinkling {
  position:absolute;
  top:0;
  left:0;
  right:0;
  bottom:0;
  width:100%;
  height:100%;
  display:block;
}

.stars {
  background:#000 url(http://www.script-tutorials.com/demos/360/images/stars.png) repeat top center;
  z-index:-2;
  min-height: 100%;
}

.twinkling{
  background:transparent url(http://www.script-tutorials.com/demos/360/images/twinkling.png) repeat top center;
  z-index:-1;
  -moz-animation:move-twink-back 200s linear infinite;
  -ms-animation:move-twink-back 200s linear infinite;
  -o-animation:move-twink-back 200s linear infinite;
  -webkit-animation:move-twink-back 200s linear infinite;
  animation:move-twink-back 200s linear infinite;
  min-height: 100%;
}
<!DOCTYPE html>

<html>
    <head>
        <meta charset="utf-8">
        <title>Calculator</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="styles/style.css">
        <link rel="stylesheet" href="styles/background.css">
    </head>
    <body>
        <h1 class="outline">The Galaxy Calculator</h1>
        <div class="stars"></div>
        <div class="twinkling"></div>
        <section>
            <div class="container">
                <div id="display"></div>
                <div class="buttons">
                    <div class="button">%</div>
                    <div class="button">/</div>
                    <div class="button">C</div>
                    <div class="button">&larr;</div>
                    <div class="button">7</div>
                    <div class="button">8</div>
                    <div class="button">9</div>
                    <div class="button">*</div>
                    <div class="button">4</div>
                    <div class="button">5</div>
                    <div class="button">6</div>
                    <div class="button">-</div>
                    <div class="button">1</div>
                    <div class="button">2</div>
                    <div class="button">3</div>
                    <div class="button">+</div>
                    <div class="button">&plusmn</div>
                    <div class="button">0</div>
                    <div class="button">.</div>
                    <div id="equal" class="button">=</div>
                </div>
            </div>
        </section>
        <footer>
            <p class="foot">&copy;MSA 2021, The Galaxy Calculator; Design by Samee</p>
        </footer>
        <script src="index.js"></script>
    </body>
</html>

I tried fixing the margins however it still leaves a bit of whitespace at the bottom. I tried removing certain elements, adjusting my width and height for different tags to see if it made a difference and still the same. I’m guessing it has something to do with my stars and twinkle div. Also when i check my project in developer tools my html and body tag dont extend to the bottom of the page. Really confused, any help would be appreciated.

MongoError: TypeError: callback is not a function

Environment:-

Ubuntu: 20.04.4 LTS
Node version: v10.19.0
DB - Docker containers: mongo-express and mongo:4

Our Node js web application using docker container based DB. Very often our web application shows below errors.

2022-05-06 08:27:59.712 - error: web-app: { MongoError: TypeError: callback is not a function
    at Connection.messageHandler (/home/admin/webms/workspace/65.66.67.6890000/node_modules/mongodb-core/lib/topologies/server.js:360:39)
    at Socket.<anonymous> (/home/admin/webms/workspace/65.66.67.6890000/node_modules/mongodb-core/lib/connection/connection.js:292:22)
    at Socket.emit (events.js:198:13)
    at Socket.EventEmitter.emit (domain.js:448:20)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at Socket.Readable.push (_stream_readable.js:224:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:94:17)
  name: 'MongoError',
  message:
   TypeError: callback is not a function
       at Callbacks.emit (/home/admin/webms/workspace/65.66.67.6890000/node_modules/mongodb-core/lib/topologies/server.js:119:3)
       at Connection.messageHandler (/home/admin/webms/workspace/65.66.67.6890000/node_modules/mongodb-core/lib/topologies/server.js:358:23)
       at Socket.<anonymous> (/home/admin/webms/workspace/65.66.67.6890000/node_modules/mongodb-core/lib/connection/connection.js:292:22)
       at Socket.emit (events.js:198:13)
       at Socket.EventEmitter.emit (domain.js:448:20)
       at addChunk (_stream_readable.js:288:12)
       at readableAddChunk (_stream_readable.js:269:11)
       at Socket.Readable.push (_stream_readable.js:224:10)
       at TCP.onStreamRead (internal/stream_base_commons.js:94:17) }

node_modules/mongodb-core/lib/topologies/server.js Line from 356 to 364 as follows,

      if(state.logger.isDebug()) state.logger.debug(f('message [%s] received from %s', response.raw.toString('hex'), self.name));
      // Execute the registered callback
      state.callbacks.emit(response.responseTo, null, response);
    } catch (err) {
      state.callbacks.flushConnection(new MongoError(err), connection);
      self.destroy();
    }
  }
}

node_modules/mongodb-core/lib/connection/connection.js Line from 292 to 300 as follows,

                self.messageHandler(new Response(self, self.bson, emitBuffer, self.responseOptions), self);
              } catch (err) {
                var errorObject = {err:"socketHandler", trace:err, bin:self.buffer, parseState:{
                  sizeOfMessage:self.sizeOfMessage,
                  bytesRead:self.bytesRead,
                  stubBuffer:self.stubBuffer}};
                // We got a parse Error fire it off then keep going
                self.emit("parseError", errorObject, self);
              }

Can someone please help me to solve this issue. Thanks.