SVG Button Toggle

Hi I’m trying to toggle a svg button from one state to the other.
They are two seperate svgs contained in a larger svg.
For reference I’ve attched these images here:
enter image description here

enter image description here

So far I have come up with this where onlclick I change the svg id value from display on or off as shown below. I’m sure there is a much cleaner way to do this using Jquery?

$( "#off-btn-nav-01-category" ).on( "click", function() {
  $("#off-btn-nav-01-category").css("display", "none");
  $("#on-btn-nav-01-category").css("display", "block");
});

$( "#on-btn-nav-01-category" ).on( "click", function() {
  $("#on-btn-nav-01-category").css("display", "none");
  $("#off-btn-nav-01-category").css("display", "block");
});

One last thing I’ve got this svg running inline to be able to change the css properties is there any way to have this svg file externally so I can apply css properties to it?

React-native input mask

I need to implement a data entry in which the values ​​are replaced by a mask of XXX characters, by the type of phone number + 123456789, it should be +123ХХХХХХХ in places where there is no data yet. At each input, instead of X, there must be a character that the user entered. is there a library that allows me to implement such a mask?

I did not find a suitable library to implement this functionality in react-native. has anyone encountered a similar problem?

Module federation, package versioning explanation

Despite my research online, I cannot find an explicit explanation of how package versions are resolved when I use webpack’s Module Federation, so I’m hoping for some help.

Example 1:
host (singleton version 16.x.x)
client (singleton version 17.x.x)
What Module Federation will use in this case? (I know that there will be some warnings in the dev tools, but I want a way to figure out what is actually being used)

Example 2:
host (version 17.x.x)
client (version 16.x.x)
I think I figured this out based on semantic versioning, client will get version from host.

Is there any way to see what version webpack decides to use in the end and not rely in hypotheses?

Want to add show more to every tag using javascript

I used parentElement.appendChild(SpanTag) for every class but the span tag gets added only to the last

tag.

this is my html code

`<!DOCTYPE html>

Document




<h1>Cutting the Text</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Mollitia debitis beatae asperiores corrupti fugiat perferendis minima hic aliquid quibusdam et, molestiae tempore commodi amet.
    Lorem, ipsum dolor sit amet consectetur adipisicing elit. A perspiciatis praesentium hic eum facere earum aliquid, quas, animi est vitae quidem molestiae corrupti ullam, laboriosam cupiditate neque beatae quod impedit.
    Lorem, Lorem ipsum, dolor sit amet consectetur adipisicing elit. Dolorum corporis repudiandae quo doloribus. Eligendi ullam sunt minus hic, accusantium quae!
</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Mollitia debitis beatae asperiores corrupti fugiat perferendis minima hic aliquid quibusdam et, molestiae tempore commodi amet.
    Lorem, ipsum dolor sit amet consectetur adipisicing elit. A perspiciatis praesentium hic eum facere earum aliquid, quas, animi est vitae quidem molestiae corrupti ullam, laboriosam cupiditate neque beatae quod impedit.
    Lorem, Lorem ipsum, dolor sit amet consectetur adipisicing elit. Dolorum corporis repudiandae quo doloribus. Eligendi ullam sunt minus hic, accusantium quae!
</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Mollitia debitis beatae asperiores corrupti fugiat perferendis minima hic aliquid quibusdam et, molestiae tempore commodi amet.
    Lorem, ipsum dolor sit amet consectetur adipisicing elit. A perspiciatis praesentium hic eum facere earum aliquid, quas, animi est vitae quidem molestiae corrupti ullam, laboriosam cupiditate neque beatae quod impedit.
    Lorem, Lorem ipsum, dolor sit amet consectetur adipisicing elit. Dolorum corporis repudiandae quo doloribus. Eligendi ullam sunt minus hic, accusantium quae!
</p>

`
this is my javascript code

var divsToControl = document.getElementsByClassName('text');
var spanTag=document.createElement('span');
spanTag.innerText="...see more";
spanTag.addEventListener("click",(e)=>{
window.location="``https://stackoverflow.com``";
});

for (var i = 0; i < divsToControl.length; i++) {
var count=divsToControl[i].innerHTML.length;
if(count>200){
divsToControl[i].innerHTML=divsToControl[i].innerHTML.substring(0,300);
divsToControl.appendChild(spanTag);
}
}

I get the output like below

Cutting the Text
Lorem ipsum dolor sit amet consectetur adipisicing elit. Mollitia debitis beatae asperiores corrupti fugiat perferendis minima hic aliquid quibusdam et, molestiae tempore commodi amet. Lorem, ipsum dolor sit amet consectetur adipisicing elit. A perspiciatis praesentium hic eum facere earum a

Lorem ipsum dolor sit amet consectetur adipisicing elit. Mollitia debitis beatae asperiores corrupti fugiat perferendis minima hic aliquid quibusdam et, molestiae tempore commodi amet. Lorem, ipsum dolor sit amet consectetur adipisicing elit. A perspiciatis praesentium hic eum facere earum a

Lorem ipsum dolor sit amet consectetur adipisicing elit. Mollitia debitis beatae asperiores corrupti fugiat perferendis minima hic aliquid quibusdam et, molestiae tempore commodi amet. Lorem, ipsum dolor sit amet consectetur adipisicing elit. A perspiciatis praesentium hic eum facere earum a…see more

I want …more applied to every paragraph like below

Cutting the Text
Lorem ipsum dolor sit amet consectetur adipisicing elit. Mollitia debitis beatae asperiores corrupti fugiat perferendis minima hic aliquid quibusdam et, molestiae tempore commodi amet. Lorem, ipsum dolor sit amet consectetur adipisicing elit. A perspiciatis praesentium hic eum facere earum a…see more

Lorem ipsum dolor sit amet consectetur adipisicing elit. Mollitia debitis beatae asperiores corrupti fugiat perferendis minima hic aliquid quibusdam et, molestiae tempore commodi amet. Lorem, ipsum dolor sit amet consectetur adipisicing elit. A perspiciatis praesentium hic eum facere earum a…see more

Lorem ipsum dolor sit amet consectetur adipisicing elit. Mollitia debitis beatae asperiores corrupti fugiat perferendis minima hic aliquid quibusdam et, molestiae tempore commodi amet. Lorem, ipsum dolor sit amet consectetur adipisicing elit. A perspiciatis praesentium hic eum facere earum a…see more

Passing Data from Depending Dropdown to Object in React

I am still new in learning React. I just have a question regarding to my problem. I want to use dependent dropdown which take state, district and postcode value. District value is dependent on state value and postcode value is dependent on district value. I just want to pass the dependent dropdown value to my; const [formData, setFormData] = useState({…}), using hooks which then will save it in database. However, because of it is a dependent dropdown, I still stuck on how to pass it. Below is may code:

const [selectedState, setSelectedState] = React.useState("");
const [selectedDistrict, setSelectedDistrict] = React.useState("");
const [selectedPostcode, setSelectedPostcode] = React.useState("");

const availableDistrict = data.state.find((c) => c.name === selectedState);
const availablePostcode = availableDistrict?.city?.find(
  (s) => s.name === selectedDistrict
);

Below is code to pass the data to my back-end and save it into the database:

const [formData, setFormData] = useState({
    dobbyName: "",
    dobbyNum: "",
    openTime: "",
    closeTime: "",
    dobbyType: "",
    dobbyEmail: "",
    dobbyAddress: "",
    dobbyPostcode: "",
    dobbyDistrict: "",
    dobbyState: "",
    dobbyDescription: "",
  });

  const {
    dobbyName,
    dobbyNum,
    openTime,
    closeTime,
    dobbyType,
    dobbyEmail,
    dobbyAddress,
    dobbyPostcode,
    dobbyDistrict,
    dobbyState,
    dobbyDescription,
  } = formData;

  const onChange = (e) =>
    setFormData({ ...formData, [e.target.name]: e.target.value });

  const onSubmit = (e) => {
    e.preventDefault();
    createLaundry(formData, history);
  };

Below is the dependent dropdown menu:

<InputLabel id="demo-simple-select-helper-label">
   State
</InputLabel>
  <Select
    labelId="demo-simple-select-helper-label"
    id="demo-simple-select-helper"
    value={selectedState}
    label="State"
    onChange={(e) => setSelectedState(e.target.value)}
   >
   <MenuItem>--Choose State--</MenuItem>
    {data.state.map((value, key) => {
     return (
      <MenuItem value={value.name} key={key}>
        {value.name}
      </MenuItem>
    );
    })}
 </Select>

<InputLabel id="demo-simple-select-helper-label">
   District
</InputLabel>
  <Select
    labelId="demo-simple-select-helper-label"
    id="demo-simple-select-helper"
    value={selectedDistrict}
    label="District"
    onChange={(e) => setSelectedDistrict(e.target.value)}
   >
   <MenuItem>--Choose District--</MenuItem>
    {availableDistrict?.city.map((e, key) => {
     return (
       <MenuItem value={e.name} key={key}>
         {e.name}
       </MenuItem>
      );
    })}
 </Select>

<InputLabel id="demo-simple-select-helper-label">
   Postcode
</InputLabel>
  <Select
    labelId="demo-simple-select-helper-label"
    id="demo-simple-select-helper"
    value={selectedPostcode}
    label="Postcode"
    onChange={(e) => setSelectedPostcode(e.target.value)}
   >
   <MenuItem>--Choose Postcode--</MenuItem>
   {availablePostcode?.postcode.map((e, key) => {
     return (
       <MenuItem value={e} key={key}>
         {e}
       </MenuItem>
      );
    })}
 </Select>
                

Hope you all can help me. Thank you.

ReactJS does not load

Hi im noob to reactJS so idk a lot about it.

I’ve just finished the Header on my project and now im working on the footer.
The thing is that if I import the Footer in index.js when page refreshes it doesn’t load.

My index.js looks like this:

import React from 'react';
import ReactDOM from 'react-dom';

//Components
import Header from './component/header/Header';
import Footer from './component/footer/Footer';

//SCSS
import './index.scss';
import './custom.scss';

const app = (

  <div>
    <Header />

    <Footer />
  </div>

);

ReactDOM.render(
  app,
  document.getElementById('root')
);

I’ve tried to update node and react, upgrade the amount of memory in the package.json but none of this works…

Schedule cloud function to update a list of maps

I’m trying to write a scheduled cloud function to reset the value of “status” every day at 12 am. Here’s my firestore structure:
Firestore Data

I haven’t really tried coding in javascript before but here’s what I managed with my little knowledge:

const functions = require("firebase-functions");

const admin = require("firebase-admin");
admin.initializeApp();

const database = admin.firestore();


exports.Rst = functions.pubsub.schedule("0 0 * * *").onRun((context) => {
  const alist =
      database.collection("SA1XAoC2A7RYRBeAueuBL92TJEk1")
          .doc("afternoon").get().then((snapshot)=>snapshot.data["list"]);

  for (let i=0; i<alist.length; i++) {
    alist[i]["status"]=0;
  }

  database.collection("SA1XAoC2A7RYRBeAueuBL92TJEk1")
      .doc("afternoon").update({
        "list": alist,
      });

  return null;
});

I get the following error when I deploy this function:
Error

Expected Result:
Set the values of all “status” fields to 0.
Expected result

Getting the following error when I run npx cap sync to run an ionic Angular project in xcode

When i run npx cap sync to run my ionic angular project in xcode I get the following error.

[!] The plist file at path `/Users/user/Documents/GitHub/project-name/ios/App/App.xcodeproj/project.pbxproj`
        doesn't exist.

The same also happens if I run ionic cap sync. Have tried recloning the repo and performing a fresh ionic build and ionic cap copy but that doesn’t seem to resolve the issue and googling about hasn’t helped either. I’m pretty new to angular and ionic so any help regarding this would be greatly appreciated.

Need to Improve Image Quality

We are creating report in Qliksense ,We send report using Nprinting .when your creating Nprinting report we need to send report as HTML Format of Image so we have issue with image quality is not good .How can I achieve Image quality using HTML
Regards,
Saichand

Apple auth node js react native ignore expiration of id_token in back end

I have a React native front end where I use this library to handle Apple Authentication.

Then I have a NodeJS back end, where I use this library to handle Apple authenticated users and let them access routes.

I want the users to be able use the app without logging in again without a time limit.
Therefore I save the identity token, which I get when the user does the first sign up in Async Storage in the front-end. Every time the user tries to access routes the user will be checked if he/she has a identityToken in the Header in my isAuth middleware in the NodeJS backend for the respective request.

It seems like the token expires after one day and the get the following error message in the backend in my isAuth middleware:

isAuth errorMessage JsonWebTokenError: error in secret or public key callback: input error: Invalid id token public key id

The error is thrown in the apple-signin-auth library when executing this code:

const appleSignin = require("apple-signin-auth");

result = await appleSignin.verifyIdToken(token, {
    audience: config.CLIENT_ID_APPLE,
    ignoreExpiration: true, // ignore token expiry (never expires)
});

I thought the token does not expire, because I set the ignoreExpiration flag to true. But when I read up their documentation this seems to be wrong. They state that I also need to add

nonce: 'NONCE', // nonce // Check this note if coming from React Native AS RN automatically SHA256-hashes the nonce https://github.com/invertase/react-native-apple-authentication#nonce // If you want to handle expiration on your own, or if you want the expired tokens decoded

So I should add nonce if I want to decode the expired tokens, as far as I understand?

As a result I need to save the nonce I get at the first Signin from the user in the AsyncStorage as well as the id_token and then every time I need to add the nonce to the appleSignin.verifyIdTokenrequest. Would that be a solution to my problem or is that a wrong approach or is there an easier solution?

Thanks for the help!

Javascript aggregate with multiple matches

I am trying to create a aggregate pipeline with multiple matches, but not sure how to go about it?!?

Here is what I am trying:

const pipeline = [
  { match: { oomId: oomId, holes: 0, collectPutts: true } },
  { group: { 
    objectId: '$userId',
    puttsPlayed: { $sum: 1 },
    puts: {$sum: '$puts'},
    gir: {$sum: '$gir'},
    girHcp: {$sum: '$girHcp'}
  } },
  { match: { oomId: oomId, holes: 0, collectHits: true } },
  { group: { 
    objectId: '$userId',
    hits: {$sum: '$hit'},
    holesHit: {$sum: '$holesToHit'}
  } },
  { match: { oomId: oomId, holes: 0 },
  { group: { 
    objectId: '$userId',
    totalPlayed: { $sum: 1 },
    points: {$sum: '$points'},
    strokes: {$sum: '$strokes'}
  } },
  { project:{ 
      played: '$totalPlayed',
      puttsPlayed: '$puttsPlayed',
      puts: {$divide: ['$puts', '$puttsPlayed']},
      gir: {$divide: ['$gir', '$puttsPlayed']},
      girHcp: {$divide: ['$girHcp', '$puttsPlayed']},
      hits: '$hits',
      holesHit: '$holesHit',
      hitsPercentage: {
        $multiply: [
          { $divide: [ "$hits", "$holesHit" ] },
          100
        ]
      },
      points: {$divide: ['$points', '$totalPlayed']},
      strokes: {$divide: ['$strokes', '$totalPlayed']}
  }}
];

I am getting this error: Unexpected token ‘{‘

Not sure where the error is, and is it even possible to do what I am trying to do? or should I user 3 different pipelines?

Any help is appreciated… New to aggregate :-/