I have a web app that uses firebase realtime database that holds a large json file. Problem with keeping users data separate

I have a basic web app that takes objects from a large json file in the database and lists them onto the page with styling. When the user clicks on an object, it fades out and they can undo this by clicking on it again.

const handleButtonClickKilled = (e, boss) => {   
    if (selectedBosses.includes(boss)) { 
      setSelectedBosses(selectedBosses.filter(b => b !== boss)); 

    } else { 
      setSelectedBosses([...selectedBosses, boss]); };   
      setChangedBossCount(prevCount => Number(prevCount) + 1);
     
  const updateKilled = () => { 
        const db = getDatabase(); 
        const postData = { 
          changed: 'killed'
        } 
 
        const updates = {};  
        updates['/data/' + e.target.id + '/killed'] = postData;
        return update(ref(db), updates); 
      } 
      updateKilled();  
    }  


useEffect(() => { 
  const savedCount = localStorage.getItem('changedBossCount', JSON.stringify(changedBossCount)); 
  if (savedCount) { 
    setChangedBossCount(JSON.parse(savedCount));
  }
}, [changedBossCount]); 

useEffect(() => { 
  localStorage.setItem('ChangedBossCount', (changedBossCount));
}, [changedBossCount]); 

   const handleButtonClickUndo = (e, boss) => { 
    setSelectedBosses(selectedBosses.filter(b => b !==boss)); 
    setChangedBossCount(changedBossCount - 1);
    const removeChange = () => { 
      const database = getDatabase(firebase); 
        const dbRef = ref(database, '/data/' + e.target.id + '/killed');
        remove(dbRef)
    }; 
    removeChange();     
  } 

I need to change my app so that people using the app are not interefering with each others firebase data.

I would like to accomplish this without requiring the user to sign in. Is this even possible? I’ve attmepted generating a random key on login, and saving this key inside the users local storage so they can access their own version of the json data on page load but I’m stuck on how I’m meant to carry over the json data to their own random key node.

Am I going about this the wrong way? I’ve started looking into using firebase storage for my json file and seeing if I have more luck with that, but I wanted to make sure there isn’t a simpler solution before diving into something I’ve never used before.

API response do not return date for some events

I have Events API on my website, some of the events do not return/display date – there is an empty string(?).
Is there any way to replace it with “Check website” sting in case if it’s empty?

my code:


.fetch(url)

.then((response) => response.json())
    .then((response) => {
      let data = response.data;
      let html = "";
      data.forEach((item) => {
html += `
      <div class="card" style="width: 18rem;">
      <img src=${item.image} alt="img" class="images">
      <div class="card-body">
        <h5 class="name">${item.name}</h5>
        <p class="city">${item.location.address.addressLocality} - ${
          item.location.name
        }</p>
        <p class="date">Date: ${item.startDate.slice(
          0,
          -14
        )} ${item.startDate.slice(11, -8)} </p>
        <a href="${
          item.location.sameAs
        }" target="_blank" class="btn btn-outline-danger">More Info</a>
      </div>
    </div>
      `;
  document.getElementById("root").innerHTML = html;
    });

Checked google and nothing helped me.

TypeError: e.isLid is not a function when sending message on WhatsApp

I am using a WhatsApp function to send an automated message, the message is sent, but it remains pending and does not reach the recipient.

Code:

window.WAID.sendChatMessage =  async function(ch, body) {
                var chat = ch.id ? ch : window.WAID.Store.Chat.get(ch);
                var chatId = chat.id._serialized;
                var msgIveSent = chat.msgs.filter(msg => msg.__x_isSentByMe)[0];
                if(!msgIveSent) return chat.sendMessage(body);
                var tempMsg = Object.create(msgIveSent);
                var newId = window.WAID.getNewMessageId(chatId);
                var extend = (0, o.Z)({
                    id: newId,
                    ack: 0,
                    local: !0,
                    from: window.WAIDS.Store.WAIDUser.getMaybeMeUser(),
                    to: ch.id,
                    local: !0,
                    self: "out",
                    t: parseInt(new Date().getTime() / 1000),
                    isNewMsg: !0,
                    type: "chat",
                }, body);

                console.log(chat, tempMsg, extend)

                Object.assign(tempMsg, extend);
                const res = await Promise.all(window.WAIDS.Store.addAndSendMsgToChat(tempMsg, extend))
                return newId._serialized;

                
            }

addAndSendMsgToChat is a native WhatsApp feature

TypeError: e.isLid is not a function
    at t.findChatActionLog (app.208e5a49d844a8c35245.js:40:229672)
    at app.208e5a49d844a8c35245.js:40:313277
    at t.promiseCallSync (app.208e5a49d844a8c35245.js:40:104856)
    at app.208e5a49d844a8c35245.js:40:313200
    at Generator.next (<anonymous>)
    at t (vendor1~app.0c8e960e5dfd7020f562.js:2:66483)
    at s (vendor1~app.0c8e960e5dfd7020f562.js:2:66694)
    at vendor1~app.0c8e960e5dfd7020f562.js:2:66753
    at Y (app.208e5a49d844a8c35245.js:5:140300)
    at new y (app.208e5a49d844a8c35245.js:5:132867)

I expected the message to be sent and received by the recipient

How to save a value in a ReactJS page and use it in other pages?

Let me start by giving you a heads-up of me being a total noob in ReactJS.

I have this back-end code for the login page written in nodejs:

app.post("/login", (req, res) => {
    const { username, pass } = req.body;
    sqlLoginuser = "SELECT * FROM users WHERE username = ?"
    db.query(sqlLoginuser, [username], (error, results) => {
        if (error) throw error;

        if (results.length === 0) {
            return res.status(401).json({ message: "Username or password is incorrect" });
        }

        const user = results[0];

        bcrypt.compare(pass, user.pass, (error, result) => {
            if (error) throw error;

            if (!result) {
                return res.status(401).json({ message: "Username or password is incorrect" });
            }

            const token = jwt.sign({ userId: user.id }, JWT_SECRET, { expiresIn: "1h" });

            res.status(200).json({
                token,
                isAdmin: user.is_admin,
                message: "User logged in successfully",
            });
        });
    }
    );
});

I want to save the value of isAdmin sent by the backend from the database after a user is logged in in this Login page:

import React, { useState } from "react";
import { useNavigate, Link } from "react-router-dom";
import axios from "axios";
import { toast } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";

const Login = () => {
    const [username, setUsername] = useState("");
    const [pass, setPass] = useState("");
    const [isAdmin, setIsAdmin] = useState(null);
    const navigate = useNavigate();

    const handleSubmit = async event => {
        event.preventDefault();
        try {
            const response = await axios.post("http://localhost:5000/login", {
                username,
                pass
            });
            const isAdmin = response.data.isAdmin;
            setIsAdmin(isAdmin);
            toast.success("Te-ai logat cu succes")
            localStorage.setItem("token", response.data.token);
            setIsAdmin(response.data.isAdmin)
            navigate("/ip");
            setTimeout( () => {window.location.reload()}, 2000) ;
        } catch (error) {
            toast.error(error.response.data.message);
        }
    };

    return (
        <div style={{ marginTop: "150px" }}>
        <form style={{
            margin: "auto",
            padding: "15px",
            maxWidth: "400px",
            alignContent: "center"
        }}
        onSubmit={handleSubmit}>
            <div>
                <label htmlFor="username">Username:</label>
                <input
                    type="text"
                    id="username"
                    placeholder="Username"
                    value={username}
                    onChange={(event) => setUsername(event.target.value)}
                />
            </div>
            <div>
                <label htmlFor="password">Password:</label>
                <input
                    type="password"
                    id="password"
                    placeholder="Password"
                    value={pass}
                    onChange={(event) => setPass(event.target.value)}
                />
            </div>
            <input type="submit" value={"Login"} />
            <Link to="/register"> 
                    <input type="button" value="Fa-ti cont"/>
            </Link>
        </form>
    </div>
    

);
};

export default Login;

So that I can later use it’s value in other pages, let’s say for example in this page:

import React, { useState, useEffect } from 'react';
import ReactPaginate from 'react-paginate';
import { Link } from 'react-router-dom';
import './home.css';
import { toast } from 'react-toastify';
import axios from 'axios';


const IP = ({location}) => {

    const isAdmin = location.state?.isAdmin;
    const [isLoading, setIsLoading] = useState(0);
    const [data, setData] = useState([]);
    const [currentPage, setCurrentPage] = useState(1);
    const [totalPages, setTotalPages] = useState(1);

    const itemsPerPage = 10;

    const handleClick = () => {
        setIsLoading(true);
        // Make a request to the backend to extract the information and store it in a text file
        axios.get("http://localhost:5000/extract-ip")
            .then(response => {
                if (response.status !== 200) {
                    throw new Error("Failed to extract data!");
                }
                const data = response.data;
                const file = new Blob([data], { type: 'text/plain' });
                const url = URL.createObjectURL(file)
                const link = document.createElement('a');
                link.href = url;
                link.download = 'ip.txt';
                document.body.appendChild(link);
                link.click();
                document.body.removeChild(link);
                URL.revokeObjectURL(url);

                setIsLoading(false);
            })
            .catch(error => {
                console.error(error);
                setIsLoading(false);
            });
    };
    // code for fetching the users from the node.js backend to bring them to the frontend

    const loadData = async () => {
        const response = await axios.get(`http://localhost:5000/ip?page=${currentPage}`);
        setData(response.data.data);
        setTotalPages(response.data.totalPages);
    };

    useEffect(() => {
        loadData();
    });

    const deleteIp = (id) => {
        if (
            window.confirm("Stergeti intrarea?")
        ) {
            axios.delete(`http://localhost:5000/delete-ip/${id}`)
            toast.success("Intrare eliminata cu succes!")
            setTimeout(() => loadData(), 500);
        }
    }

    const handlePageClick = (pageNumber) => {
        setCurrentPage(pageNumber);
    }

    return (
        <div style={{ marginTop: "50px" }}>

            <Link to="/addIp">
                <button className="btn btn-ip">Add IP</button>
            </Link>

            <table className='styled-table'>
                <thead>
                    <tr>
                        <th style={{ textAlign: "center" }}>No.</th>
                        <th style={{ textAlign: "center" }}>IP address</th>
                        <th style={{ textAlign: "center" }}>Added on</th>
                        <th style={{ textAlign: "center" }}>Added by</th>
                        <th style={{ textAlign: "center" }}>Action</th>
                    </tr>
                </thead>
                <tbody>
                    {data.map((item, index) => {
                        const startIndex = (currentPage - 1) * itemsPerPage;
                        const rowNumber = startIndex + index + 1;
                        return (
                            <tr key={item.id}>
                                <th scope="row">{rowNumber}</th>
                                <td>{item.ip_address}</td>
                                <td>{item.creation_date.replace("T", " ").replace("Z", "").replace(".000", "")}</td>
                                <td>{item.published_by}</td>
                                <td>
                                    {isAdmin === "1" ?
                                        <>
                                            <Link to={`/update-ip/${item.id}`}>
                                                <button className="btn btn-edit">Edit</button>
                                            </Link>
                                            <button className="btn btn-delete" onClick={() => deleteIp(item.id)}>Delete</button>
                                            <button className="btn btn-edit" disabled={isLoading} onClick={handleClick}>{isLoading ? "Loading..." : "Extract Data"}</button>
                                        </>
                                        :
                                        <>
                                            <Link to="/addIp">
                                                <button className="btn btn-ip">Add IP</button>
                                            </Link>
                                        </>
                                    }
                                </td>
                            </tr>
                        )
                    })}
                </tbody>
            </table>
            <div className="pagination">
                <ReactPaginate
                    pageCount={totalPages}
                    pageRangeDisplayed={5}
                    marginPagesDisplayed={2}
                    onPageChange={(data) => handlePageClick(data.selected + 1)}
                    containerClassName={"pagination"}
                    activeClassName={"active"}
                />
            </div>
            {/* <Link to="/">
                <button className="btn btn-ip">Back</button>
            </Link> */}
        </div>
    )
}

export default IP;

First I try to save the value as a cookie, encrypt it(security) and then decrypt it to use the real value which can be a 0 or a 1. I tried to use the jose library to achieve this, but failed(because i am a complete noob).

From what I understood from multiple sources, this can be achieved by using props, only that I don’t know how I can achieve this, I tried to follow multiple tutorials, but failed lamentable.

I’m getting frustrated and I can’t accomplish what I want.

Can you please help me figuring this out?

A little guidance will be of so much help, as I said, I am a complete noob in React.

Are there multiple ways of achieving what I want?

Thank you in advance guys!

Call a function inside an array

I have a function, which through an api, I bring the data and place it in an array.

self.PrestamosXUsuario = function () {
       fetch(environment.apiPoint + '/prestamos?empresa=' + empresa + '&anexo=' + anexo, {
       method: 'GET',
       headers: {
           'Content-Type': 'application/json'
          }
       })
       .then(res => res.json())
       .then(datos => {
            datos.forEach(e => {
                  self.arrayPrestamos.push({
                    observacion: e.observacion,
                    monto: e.monto,
                    desctTotal: e.desctTotal
                  })
                })                   
            })
            self.openModalPrestamos();
        }

But when I add another td with an image so that when I click it, a modal opens with the details of that data, I get an error.

<thead class="thead-dark">
  <tr style="text-align: center;">
    <th scope="col">PRÉSTAMO</th>
    <th scope="col">TOTAL</th>
    <th scope="col">SALDO</th>
  </tr>
</thead>
<tbody data-bind="foreach: arrayPrestamos">
  <tr>
    <td style="text-align: center;" data-bind="text: observacion"></td>
    <td style="text-align: right;" data-bind="text: monto"></td>
    <td style="text-align: right;" data-bind="text: desctTotal"></td>
    <td><img id="details" class="details" src="../../img/details.png" height="30px" 
         data-bind="click: DetallePrestamos"></td>
  </tr>
</tbody>

The error message is as follows

Uncaught (in promise) ReferenceError: Unable to process binding "click: function(){return DetallePrestamos }"
Message: DetallePrestamos is not defined

What I hope is that when clicking on that image that is in the table, another modal will open with the details of each data.

Getting rgb colours of selected area in an image

I have prepared a code which can give the average colour of an image properly. But now I want users to select some area in that image and get average RGB values of that specific area. For this purpose I have tried to use jCrop library and it is also giving me image x, y, width and height values after selection. But when I am appying these jCrop variables inside getRGB function then function is not working. What should be the solution for this, please suggest.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Jcrop Example</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.15/css/jquery.Jcrop.css">
  </head>
  <body>
    <img id="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAABD0lEQVR4nOzSMQ0CYRgEUUJOAQUmMIEQapycA4IZbCEAA38z1ccl7ynYTHbb9+/p/zxe9+kJC+fpAUciViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFaw3a7v6Q0Ll+dnesKCZwViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgW/AAAA//+j+wYF8oSWtwAAAABJRU5ErkJggg=="/>
    <div>
      <p class='inr'></p>
      <p class='ing'></p>
      <p class='inb'></p>
    </div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.15/js/jquery.Jcrop.js"></script>
    <script>
      $('#img').on('load change',function(){
        var rgb = getRGB(this);
        $('.inr').text(rgb.r);
        $('.ing').text(rgb.g);
        $('.inb').text(rgb.b);
      });
      function getRGB(img) {
        var dx, dy, dw, dh;
        $("#img").Jcrop({
          onSelect: function(c){
            var dx = c.x, dy = c.y, dw = c.w, dh = c.h;
            console.log(dx,dy,dw,dh);
          }
        })
        var canvas = document.createElement('canvas'),
            context = canvas.getContext('2d'),
            rgb = {r:0,g:0,b:0},
            i = -4,
            count = 0,
            height = canvas.height = img.naturalHeight,
            width = canvas.width = img.naturalWidth;
        context.drawImage(img, 0, 0);
        var data = context.getImageData(0, 0, width, height),
            length = data.data.length;
        while ( (i += 4) < length ) {
          ++count;
          rgb.r += data.data[i];
          rgb.g += data.data[i+1];
          rgb.b += data.data[i+2];
        }
        rgb.r = (rgb.r/count);
        rgb.g = (rgb.g/count);
        rgb.b = (rgb.b/count);
        return rgb;
      }
    </script>
  </body>
</html>

Sequelize eager loading if an array contains an ID

I’m using Sequelize with a postgresql database, which natively supports arrays. So I am trying to load a single artifact by pk, and all artists where the artistID is contained within the artist model at artist.artifactID, which is an array of integers.

If I don’t try to eagerly load the artists and just load them all it returns the proper data. I’m sure I’m not eagerly loading the data correctly, but I haven’t had any luck finding info on this since arrays in Sequelize are specific to postgresql databases.

Sorry if the answer is obvious, I’m new and still learning.

API

const router = require('express').Router();
const Sequelize = require('sequelize');
const Op = Sequelize.Op;
const { Artist, Post, Artifact } = require('../db');


//GET /api/ all artifacts
router.get('/', async(req, res, next) => {
    try {
        const artifactList = await Artifact.findAll();
        res.send(artifactList)
    } catch (e) {
        next(e);
    }
});

router.get('/:id', async(req, res, next) => {
    try {
        const artifact = await Artifact.findByPk(req.params.id);
        const artists = await Artist.findAll({
            where: {
                [Op.in]: parseInt(req.params.id)
            }
        });
        res.send({artifact, artists});
    } catch (e) {
        next(e);
    }
})

module.exports = router;

ERROR

GET https://octopus-house.herokuapp.com/api/artifacts/1 500 (Internal Server Error)

Is there a function to resolve this issue [closed]

I am trying to register a user but this error occured

ValidationError: User validation failed: name: Cast to string failed for value “[ ‘sher karim’ ]” (type Array) at path “name”, email: Cast to string failed for value “[ ‘[email protected]’ ]” (type Array)
at path “email”, password: Cast to string failed for value “[ ‘jkdikej78393’ ]” (type Array) at path “password”
at Document.invalidate (E:React Coursenorth-fruitsbackendnode_modulesmongooselibdocument.js:3125:32)
at model.$set (E:React Coursenorth-fruitsbackendnode_modulesmongooselibdocument.js:1465:12)
at model.$set (E:React Coursenorth-fruitsbackendnode_modulesmongooselibdocument.js:1148:16)
at model.Document (E:React Coursenorth-fruitsbackendnode_modulesmongooselibdocument.js:166:12)
at model.Model (E:React Coursenorth-fruitsbackendnode_modulesmongooselibmodel.js:122:12)
at new model (E:React Coursenorth-fruitsbackendnode_modulesmongooselibmodel.js:5092:15)
at E:React Coursenorth-fruitsbackendnode_modulesmongooselibmodel.js:3197:22
at E:React Coursenorth-fruitsbackendnode_modulesmongooselibmodel.js:3232:7
at Array.forEach ()
`

I have try to register but this validation error occured.

Why this code doesn’t work on Google Chrome

I’ve got code like below, any ideas why this code work on Mozille Firefox and doesn’t on Google Chrome ?
I tried to do something with if statement and for ( let of elements), but nothing helps.
There is no error in browser console.
active_item_2 can’t be added on Google Chrome.
It should work without reloading the page. On Mozilla Firefox everything is ok.

app_shop.run(function() {
  const elements = document.getElementsByClassName('active_filter');
  if (elements) {
    for (let el of elements) {
      el.parentElement.classList.add('active_item_2');
    }
  }
}, [3, 4], '#Filters', true);

d3 ignoring bars with same data despite using a key function

I’m trying to create a Bar chart and add mouseover and mouseout events on the bars. I’m using scaleBand() in my code. Therefore, from the accepted solution here, I gathered that ordinal scale treats repeated values as same. Therefore, I tried adding a key to the data() function which I expected would resolve the issue and give me all my bars, but that did not happen.

Here’s my code:

<!DOCTYPE html>
<html>
    <head>
        <title>Tooltip</title>
        <script src="https://d3js.org/d3.v7.min.js"></script>
    </head>
    <body>
<script>
            var bardata = [100, 200, 60, 150, 80, 300, 25, 75, 200, 50, 10, 200];

            var svgHeight = 400,
                svgWidth = 600;

            var barWidth = 30,
                barOffset = 1;

            var yScale = d3.scaleLinear()
                           .domain([0, d3.max(bardata)])
                           .range([0, svgHeight-10]);

            var xScale = d3.scaleBand()
                           .domain(bardata)
                           .range([0, svgWidth])
                           .paddingOuter(.5)
                           .paddingInner(.01);

            var colorYScale = d3.scaleLinear()
                                .domain([0, d3.max(bardata)*0.33,
                                            d3.max(bardata)*0.66],
                                            d3.max(bardata))
                                .range(['green', 'yellow', 'orange', 'red']);

            d3.select('body')
                .append('svg')
                .attr('width', svgWidth)
                .attr('height', svgHeight)
                .style('background-color', '#eeeeee');
                
            function id (d) { return d; }
            function idx (d,i) { return i;}

            var barchart = d3.select('svg')
                             .selectAll('rect')
                             .data(bardata, function(d,i){
                                return i;
                             })
                             .join(
                                enter => {
                                    enter.append('rect')
                                         .attr('width', xScale.bandwidth())
                                         .attr('height', d => yScale(d))    // animate
                                         .attr('x', d => xScale(d))
                                         .attr('y', d => svgHeight-yScale(d))   //animate
                                         .attr('fill', d => colorYScale(d))

                                         .on('mouseover', function(event){
                                            d3.select(this)
                                              .style('opacity', 0.3)
                                         })

                                         .on('mouseout', function(event){
                                            d3.select(this)
                                              .style('opacity', 1)
                                         })
                                }
                             )
        </script>
    </body>
</html>

Is this an issue with the key I’m using in data()?
Or is there something more to be done while using ordinal scale to make this code work?

Thanks!

In Ionic 6/capacitor, Infinite Scroller does not work with SQL lite data

I have some data in a SQL lite database. I’d like to use the infinite scroll to boost performance. I read the Ionic frame documentation at the following link.

https://ionicframework.com/docs/api/infinite-scroll

This is my Home.html

<ion-header>
  <ion-toolbar class="app-theme-color">
    <ion-buttons slot="start">
      <ion-menu-button></ion-menu-button>
    </ion-buttons>
    <ion-title>Routes</ion-title>
  </ion-toolbar>
</ion-header>

<ion-content color="secondary">
  <ion-grid>
    <ion-row>
      <ion-col>
        <ion-card *ngFor="let route of itemListData">
          <ion-row>
            <ion-col>
              <div class="ion-text-begin">
                {{ route.nameroute }}
              </div>
            </ion-col>
            <ion-col>
              <div class="ion-text-end">
                {{ route.cost }}
              </div>
            </ion-col>
          </ion-row>
        </ion-card>
      </ion-col>
    </ion-row>
  </ion-grid>
  <ion-infinite-scroll (ionInfinite)="doInfinite($event)">
    <ion-infinite-scroll-content loadingSpinner="bubbles" loadingText="Loading">
    </ion-infinite-scroll-content>
  </ion-infinite-scroll>
</ion-content>

And this is my Home.ts file

import { Component, OnInit } from '@angular/core';
import { DatabaseService } from '../services/database.service';

@Component({
  selector: 'app-home',
  templateUrl: './home.page.html',
  styleUrls: ['./home.page.scss'],
})
export class HomePage implements OnInit {

  itemListData = [];
  page_number = 1;
  page_limit = 8;

  constructor(private databaseService: DatabaseService) { }

  ngOnInit() {
    this.getFavoriteRoutes(false, "")

  }

  getFavoriteRoutes(isFirstLoad, event) {
    this.databaseService.getDatabaseState().subscribe((data: any) => {
      for (let i = 0; i < data.length; i++) {
        data = this.databaseService.getRoutes();
        this.itemListData.push(data[i]);
      }

      if (isFirstLoad)
        event.target.complete();
      this.page_number++;
    })
  }

  doInfinite(event) {
    this.getFavoriteRoutes(true, event);
  }

}

And these are my Database Service methods.

  getDatabaseState() {
    return this.dbReady.asObservable();
  }

  getRoutes(): Observable<any[]> {
    return this.routes.asObservable();
  }

Getting the favorite routes works, and all of the data is visible in my ionic app. I modified the getFavourites method to make use of the infinite scroll.

I followed this tutorial to do it.

https://www.freakyjolly.com/ionic-infinite-scroll-example/

The data is no longer visible as a result of the changes.

To improve performance, how can I add infinite scroll to SQL data?

Skyward Login from Iphone problems [closed]

I login to Skyward Finance everyday at work in order to clock-in. Our boss gets mad if it’s from our Iphone as it shows the email type stamp “Sent from Iphone” and threatens to take our pay. How do I access skyward from an Iphone without tipping off this stamp?

I tried browser changes, I’ve tried accessing a desktop browser on my phone. I haven’t tried VPN or spoofing my location as I am very new to these things.

use the enter key to submit with javascript

with my current program i am makeing a simple sign in form with the use of javascript.
i have it set up but cant set up the text field to use the enter key as another way to submit the current input field. i am using javascript to proform these functions but am unable to find the solution.

here is my code
index.html

<!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.0">
    <script src="https://kit.fontawesome.com/7781ca377a.js" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="./style.css" >
    <title>simple form</title>
</head>
<body>
<!-- icons by fontawesome.com -->
    <form>
        <div class="field-name">
            <i class="fa-solid fa-user"></i>
            <input type="text" placeholder="Username" required> 
            <i class="fa-sharp fa-solid fa-arrow-right"></i>
        </div>
        <div class="field-email innactive">
            <i class="fa-solid fa-envelope"></i>
            <input type="email" placeholder="Email" required> 
            <i class="fa-sharp fa-solid fa-arrow-right"></i>
        </div>
        <div class="field-password innactive">
            <i class="fa-solid fa-key"></i>
            <input type="password" placeholder="Password" required> 
            <i class="fa-sharp fa-solid fa-arrow-right"></i>
        </div>
        <div class="field-finish innactive">
            <i class="fa-solid fa-heart"></i>
            <p>Thank you!</p>
            <i class="fa-solid fa-heart"></i>
        </div>
    </form>

    <script src="app.js"></script>
</body>
</html>

style.css

* {
    margin: 0;
    box-sizing: border-box;
    padding: 0;
}

body{
    height: 100vh;
    display: flex;
    background-color: rgb(87, 189, 130);
    transition: background 0.5s ease;
    position: relative;
}

.field-name, .field-email, .field-password, .field-finish {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    height: 50px;
    width: 400px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 5px;
    transition: all 0.5s ease;
}

.field-name i, .field-email i, .field-password i, .field-finish i {
    padding: 10px;
}

.field-name i:last-child, .field-email i:last-child, .field-password i:last-child, .field-finish i:last-child {
    padding: 10px;
    cursor: pointer;
}

.field-name input, .field-email input, .field-password input {
    background: none;
    border: none;
    flex: 1;
    height: 100%;
    outline: none;
}

div.innactive{
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 50%);
}

div.active {
    opacity: 1;
    pointer-events: all;
    transform: translate(-50%, -50%);
}

@keyframes shake{
    0%{
        transform: translate(-50%, -50%) rotate(0deg);
    }
    50%{
        transform: translate(-50%, -50%) rotate(10deg);
    }
    100%{
        transform: translate(-50%, -50%) rotate(0deg);
    }   
}

app.js

function animatedForm() {
    const arrows = document.querySelectorAll('.fa-arrow-right');
    
    arrows.forEach(arrow => {
        arrow.addEventListener("click", () => {
            const input = arrow.previousElementSibling;
            const parent = arrow.parentElement;
            const nextForm = parent.nextElementSibling;

            //check for validation
            if(input.type === "text" && validateUser(input)){
                nextSlide(parent, nextForm);
            } else if(input.type === 'email' && validateEmail(input)){
                nextSlide(parent, nextForm);
            } else if(input.type === 'password' && validateUser(input)){
                nextSlide(parent, nextForm);
            } else {
                parent.style.animation = "shake 0.5s ease";
            };
            //animation reset
            parent.addEventListener('animationend', () => {
                parent.style.animation = "";
            });
        });
    });
    
}

//check if username or password has more than 6 characters 
function validateUser(user){
    if(user.value.length < 6){
        console.log('error not enough characters');
        error("rgb(189,87,87");
    } else {
        error("rgb(87, 189, 130");
        return true;
    }
}

//check if email is valid 
function validateEmail(email){
    const validation = /^[^s@]+@[^s@]+.[^s@]+$/;
    if(validation.test(email.value)){
        error("rgb(87, 189, 130");
        return true;
    } else {
        error("rgb(189,87,87");
    }
}

//change which input is active 
function nextSlide(parent, nextForm){
    parent.classList.add('innactive');
    parent.classList.remove('active');
    nextForm.classList.add('active');
}

//change background color if you fail to meet minimum requirements 
function error(color){
    document.body.style.backgroundColor = color;
}

//start
animatedForm();

i have atempted a plethora of resourses from external websites like https://www.w3schools.com/howto/howto_js_trigger_button_enter.asp

and https://developer.mozilla.org/en-US/docs/Web/API/Element/keydown_event

but i dont know after atempting the implement these resourses if they work or not.

Cannot create a react native library

I’ve been creating a react native component library since a month now, and I think it’s ready to be posted as a package on npm. So I pushed it on github, I npm publish, everything’s fine.

To publish it, I replaced my index.ts:

// index.ts
import createRComps from 'Base.tsx';

export default createRComps; // That's the only object I need to export because it calls the others from itself

I also tried to use create-react-native-library on another copy of this repo, which didn’t get any more success.

Now, I create another react native project to test my new library : I install my library with npm i react-native-ready-comps, add some of my lib’s code in it :

export default function App() {
  const RComps = createRComps();  // my lib's main function

  return (
    <RComps.Title bold>Hello world !</RComps.Title>    // one of my lib's components
  );
}

But when I launch it with metro (npx react-native run-android && npx react-native start), I get this error :

 ERROR  TypeError: Cannot read property 'createNode' of null, js engine: hermes
 ERROR  Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 10): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient.
        A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
 ERROR  Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 10): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient.
        A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes

I know it comes from my lib, but I didn’t encoutered this problem when I was working on it. Maybe did I miss something when publishing it ?

Can you please explain me what I did wrong ? And if you have resources on how to export a react native component library, I’dd be glad if you shared them ! Everything I found on Google/Stack couldn’t help me.

Thanks a lot !

PS : here is the repository of my library, if you want to see the code. As soon as it’s a project problem, I cannot create a minimal reproducible example…

Use a map ID in my code to display this custom map on a webpage

(very weak level in frontend)

I basically follow this tuto :
https://youtu.be/CdDXbvBFXLY
the coder uses a code slightly different that what we have now on Google Platform, instead of

<script async
    src="https://maps.googleapis.com/maps/api/js?keyYOURKEY&callback=initMap">
</script>

she uses

<script
    src="https://maps.googleapis.com/maps/api/js?key=YOURKEY&map_ids=YOURMAPID&callback=initMap&v=weekly"
    defer
  ></script>

Anyway, doesn’t work for me.

Now on the Google documentation they mention Map Id’s feature only on the function Initmap.
https://developers.google.com/maps/documentation/get-map-id

map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 8,
mapId: 'MAP_ID'
});

here is my test page. It actually doesn’t display my custom map, only the reel Google map, because of the coordinates I put in :
https://eostation.xyz/

<script> function initMap() {
      map = new google.maps.Map(document.getElementById("map"), {
        center: { lat: 69.4865, lng: 88.3972 },
        zoom: 13,
        mapID: '6c69da475e7f7301'
      });
      let marker = new google.maps.Marker({
      position: talnakh,map: map});
}

I don’t really understand what is a InitMap

In other words, I need the correct syntaxe to call my custom map and not Google map.
When I say “custom map”, i don’t mean a map with markers, i don’t mean a trail of landmarks done on Google Map, I’m talking about a fictionnal map, for a game, using GoogleMap API.

Thank you