react-snap redirect URL to new URL with ‘/’ slash

I’ve implemeted a react-snap to create static html. However, after implemetin the react-snap I noticed SEO issues which the old urls (which were index) have been redirected to new urls with slash

example :

This URL: https://do-calculate.com/calculator/en/percentage

Gets redirect to : https://do-calculate.com/calculator/en/percentage/

Crawling search engine see this as two different url. I want to prevent such behaviour and keep urls WITHOUT slash

Here is an example of my App.

const calculatorRoutes = [
  {
    // Gregorian age Arabic
    path: '/calculator/ar/agegregorian',
    component: lazy(() => import('./Components/Ar/HumanCalculator/AgeCalculatorGregorian')),
  },etc..
]


function App() {
  // Use the Router component to wrap everything
  return (
    <Router>
      <AppContent />
    </Router>
  );
}

function AppContent() {
  const location = useLocation();

  // Determine the current language based on the URL path
  const currentLanguage = location.pathname.includes('/en') ? 'en' : 'ar';
  console.log(location.pathname)

  return (
    <>
      {currentLanguage === 'ar' ? <Header /> : <HeaderEN />}
      <HomePageUpperCenterAds />

      <Routes>
        {calculatorRoutes.map((route, index) => (
          <Route
            key={index}
            path={route.path}
            element={<CalculatorWrapper component={route.component} />}
          />
        ))}

        <Route path="*" element={<LandingPage />} />
        <Route path="/ar" element={<LandingPage />} />
        <Route path="/en" element={<LandingPageEN />} />
      </Routes>
      {/* <Footer /> */}
    </>
  );
}

// Wrapper component for dynamically imported calculator components
function CalculatorWrapper({ component: Component }) {
  return (
    <Suspense fallback={<div>Loading...</div>}>
      <Component />
    </Suspense>
  );
}

Index.js

import { hydrate, render } from "react-dom";
import App from "./App";  // Import your main App component here.

const rootElement = document.getElementById("root");
if (rootElement.hasChildNodes()) {
  hydrate(<App />, rootElement);
} else {
  render(<App />, rootElement);
}

Crawling search engine see this as two different url. I want to prevent such behaviour and keep urls with slash

SVG.js get function to run after animation timeline has completed running and then reverse the animation to original state

With the this code i create a timeline and bind it to a svg element and want a function to run after the timeline is completed and then reverse back to initial state. As documentation use …

function reverse(){
    let runner = el1dd94639.animate();
    runner.reverse();
}

var timeline = new SVG.Timeline();
var draw = SVG.find('#symbologySVG');
var el1dd94639 = SVG('#el1dd94639');
el1dd94639.timeline(timeline)
.animate(9900,100,'absolute').rotate(40)
.animate(9900,100,'absolute').translate(x,y)
.animate(9900,100,'absolute').attr({opacity:1})
.animate(9900,100,'absolute').scale(0.6)
.animate(9900,100,'absolute').attr({fill:'#ccccff'})
.animate(9900,100,'absolute').attr({stroke:'#6666ff'});//group : 30083758
let runner = el1dd94639.animate();
runner.after(reverse());

but reverse(); runs immediately and not afterwards.
What is the correct way of doing this. Afterwards i want to be able to revere the animation to its original state. So the 1st is how to execute the reverse() after the animation is complete and 2nd reverse the animation to original state of element.

How do I separate 4 dot from 1 dot using amCharts5

I want to make an amCharts5 simple design that shows big blacbk ball go and back from a side to another and every time it hits it changes its color to yellow and then return to black again and so on, meanwhile when it hits the first time there is 2 small orange balls that come from the ground to up and stops at some point they seperate to other 4 small balls in diffrint directions.

I tried to make it but I have a problem seperating the 4 small balls from each one of them, I will attach the FINAL output I should do, and the code I’m trying on.

var root = am5.Root.new("chartdiv");

root.setThemes([
  am5themes_Animated.new(root)
]);

var container = root.container.children.push(
  am5.Container.new(root, {
    width: am5.p100,
    height: am5.p100,
    layout: root.gridLayout 
  })
);

function createAnimation(easing, positionY, positionX, size,loops,axis , color,range,duration) {
  var animationContainer = container.children.push(
    am5.Container.new(root, {
      width: 0,
      height: 0,
      layout: root.gridLayout
    })
  );

  var colors = [am5.color(0x000000), am5.color(0xFF621F)];
  var colorIndex = 0; 

    if(axis==='custom'){
      var varX=100;
      var varY=400;
      // circle.set("x", varX);
      // circle.set("y", varY);

    }


  var circle = animationContainer.children.push(
    am5.Circle.new(root, {
      radius: (size === 'small') ? 10 : 40,
      fill: colors[colorIndex] ,
      x: (positionX === 'left') ? 100:700,
      y: (positionY === 'bottom') ? 400 : 60
    })
  );
  

  circle.animate({
    key: axis,
    to: range,
    loops: loops,
    duration: duration,
    easing: easing
  });


  setInterval(function() {
    if (color === 'c') {
      colorIndex = (colorIndex + 1) % 2;
      circle.set("fill", colors[colorIndex]);
    }
  }, 1000);  

  var progress = 20;
  setInterval(function() {
    if(axis === 'custom'&&progress<100){
      progress=progress+10;
      varX+=progress;
      varY+=progress;
      circle.set("x", varX);
      circle.set("y", varY);
    }
  }, 500);

}

createAnimation(am5.ease.yoyo(am5.ease.linear), 'top', 'right', 'big',Infinity,"x","c",100,2000);

createAnimation(am5.ease.out(am5.ease.linear), 'bottom', 'left', 'small',1,"y","n",300,1000);
createAnimation(am5.ease.yoyo(am5.ease.linear), 'bottom', 'left', 'small',1,"y","n",300,2000);

createAnimation(am5.ease.out(am5.ease.linear), 'bottom', 'right', 'small',1,"y","n",300,1000);
createAnimation(am5.ease.yoyo(am5.ease.linear), 'bottom', 'right', 'small',1,"y","n",300,2000);


setTimeout(function () {
  createAnimation(am5.ease.out(am5.ease.linear), 'bottom', 'left', 'small',1,"y","n",500,1000);
  createAnimation(am5.ease.out(am5.ease.linear), 'bottom', 'right', 'small',1,"y","n",500,1000);

}, 2000);

THE EXPECTED FINAL OUTPUT:
Frame1

Frame2 – the ball is coing back and the balls started seperating

Frame3- the balls seperated and the Big ball is in infinity loop

how to make such glowing dots on css? so that they randomly glow

enter image description here

<div class="features_switchboard__F11Mv">
    <div data-index="0" data-light="true" data-state="off"></div>
    <div data-index="1" data-light="true" data-state="off"></div>
    <div data-index="2" data-light="true" data-state="off"></div>
    <div data-index="3" data-light="true" data-state="high"></div>
    <div data-index="4" data-light="true" data-state="off"></div>
    <div data-index="5" data-light="true" data-state="off"></div>
    <div data-index="6" data-light="true" data-state="off"></div>
    <div data-index="7" data-light="true" data-state="off"></div>
    <div data-index="8" data-light="true" data-state="medium"></div>
    <div data-index="9" data-light="true" data-state="off"></div>
    <div data-index="10" data-light="true" data-state="off"></div>
</div>


.features_switchboard__F11Mv 
    width: 100%
    height: 100%
    gap: 19px
    display: grid
    grid-template-columns: repeat(18,1fr)
    --transition-duration:250ms


.features_switchboard__F11Mv [data-light] 
    padding: 30px
    width: 3px
    height: 3px
    background: #888
    position: relative
    border-radius: 9999px
    transition: transform 250ms ease


.features_switchboard__F11Mv [data-light]:after
    content: ""
    position: absolute
    inset: 0
    opacity: 0
    width: inherit
    height: inherit
    border-radius: inherit
    transition: opacity 250ms ease
  
.features_switchboard__F11Mv [data-light]:before
    content: ""
    position: absolute
    inset: 0
    opacity: 0
    width: inherit
    height: inherit
    border-radius: inherit
    transition: opacity 250ms ease

how to make such glowing dots on css? so that they randomly glow.
now they are just static how to add animations?
I’m doing this on a react maybe it can be done using states
help please

How do I make a timed circle progress bar using HTML, CSS and JS?

I want to create a circle progress bar using HTML, CSS, and JS that will fill dynamically within the given time. I want it to look like the following.

If I need to explain further, for example, it will be 100% filled in 2 seconds or 100% filled in 10 seconds, I will determine the time variable here, this is what I want, and below is how I want it to be visually.

enter image description here

I researched many sources but could not find the result I wanted anywhere.

In a React application, how to render a component once by passing it two arrays at the time

I am trying to render a component only once by passing it two arrays and I want it to take the first element of the first array and the first element of the second array and render once and so on. i am trying to use the map() method since they are arrays heres what i have tried:-

  1. combine them in a new array but it work well
  2. comnine them in a new object and i could not find an equivalent for the map() method
function AddNotes() {
  const [noteDraft, setNoteDraft] = useState('');
  const [notes, setNotes] = useState([]);
  const [titleDraft, setTitleDraft] = useState('');
  const [titles, setTitles] = useState([]);

  const wholeNote = [notes, titles];

  function handleSubmit(e) {
    e.preventDefault();
    if (!noteDraft && !titleDraft) return;
    onAddItems(noteDraft, titleDraft);
    setNoteDraft('');
    setTitleDraft('');
  }

  function onAddItems(note, title) {
    setNotes(notes => [...notes, note]);
    setTitles(titles => [...titles, title]);
  }

  return (
    <div>
      <form onSubmit={handleSubmit}>
        <input
          type="text"
          placeholder="enter your title..."
          value={titleDraft}
          onChange={e => setTitleDraft(e.target.value)}
        />
        <>
          <textarea
            type="text"
            placeholder="type your note..."
            rows="7"
            cols="60"
            wrap="hard"
            value={noteDraft}
            onChange={e => setNoteDraft(e.target.value)}
          ></textarea>
          <button>Add note</button>
        </>
      </form>
      <div>
        {wholeNote.map(note => (
          <SingleNote note={[...note[0]]} title={[...note[1]]} key={notes} />
        ))}
      </div>
    </div>
  );
}

the two arrays are supposed to show the title of a note and its body (description)

Is there a type for a regular expression in JSDoc

I have a regular expression stored in a variable like this:

const regex = /^(?=.*[A-Za-z])(?=.*d)[A-Za-zd]{1,}$/

I would now like to provide a type using JSDoc. VSCode intellisense suggests:

@type {{}}

which of course it is. But I am wondering if there is a way to be a little bit more precise by calling it something like:

@type {regex}

I have been searching the docs and I have been googling and stackoverflowing a few times over past week, but I cannot find a way to define a regular expression in JSDoc.

Handle every types of mandatory inputs with jQuery

I have an HTML form with different types of inputs. Some are required, and I need to check if they are empty with JavaScript and jQuery.

My current function to do so is the following:

function fieldIsEmpty(inputID){
  let element = $("#" + inputID);
  if (element.prop("nodeName") == "INPUT"){
    let value = element.val();
    return !value.trim().length;
  }
  if (element.prop("nodeName") == "SELECT"){
    let value = $("#" + inputID + " :selected").val();
    return !value.trim().length;
  } 
}

It works, however I would need to list every types of inputs. Is there a better way to do it?

Your assistance and insights are greatly appreciated!

in odoo 17 pos_discount i want to inhrrit the apply_discount function to add extra validation

this is the original code from odoo 17 pos_discount module i want to
extend the apply_discount function in new module named rgb_sale_update
to add some validation before apply the discount

    /** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";
import { useService } from "@web/core/utils/hooks";
import { NumberPopup } from "@point_of_sale/app/utils/input_popups/number_popup";
import { ErrorPopup } from "@point_of_sale/app/errors/popups/error_popup";
import { Component } from "@odoo/owl";
import { usePos } from "@point_of_sale/app/store/pos_hook";


export class DiscountButton extends Component {
    static template = "pos_discount.DiscountButton";

    setup() {
        this.pos = usePos();
        this.popup = useService("popup");
    }
    async click() {
        var self = this;
        const { confirmed, payload } = await this.popup.add(NumberPopup, {
            title: _t("Discount Percentage"),
            startingValue: this.pos.config.discount_pc,
            isInputSelected: true,
        });
        if (confirmed) {
            const val = Math.max(0, Math.min(100, parseFloat(payload)));
            await self.apply_discount(val);
        }
    }

    async apply_discount(pc) {
        // here i want to add my validation
    }
}

ProductScreen.addControlButton({
    component: DiscountButton,
    condition: function () {
        const { module_pos_discount, discount_product_id } = this.pos.config;
        return module_pos_discount && discount_product_id;
    },
});

i tried more and more to inherit it, but not working in odoo 17
please need help thank you

“listing.category” is not allowed

I am at beginner stage of Development. I am learning to make MERN applications. So I recreated/cloned Airbnb website front end and back end both. I want to seperate all listing on the basis of specific category for which i added category with enums in listing Schema. Every thing was going good Category was visible on front But upon creating a new Listing it showed error that “listing.category is not allowed*. I donot understand the error meaning. From my guess, it is coming from input feild name=”listing[category]”. I did everything same like how we stored the title city country and price but still error. Do i have to add a condition to check if the input from user in category is present in enum? Please if i miss anything guide me I am still learning.

Listing Schema :

const listingSchema = new Schema({
    title: {
        type: String,
        required: true,
    },
    description: String,
    image: {
        url:  String,
        filename : String,
    },
    price: Number,
    location: String,
    country: String,
    reviews : [
        {
            type : Schema.Types.ObjectId,
            ref : "Review"   //review model
        }
    ],
    owner : {
        type : Schema.Types.ObjectId,
        ref : "User",
    },
    category : {
        type : String,
        enum : ['Iconic Cities','Trending','Rooms','Mountains','Amazing Pools', 'Castles', 'Camping', 'Farms', 'Arctic', 'Domes', 'Boats'],
    },
    geometry : {
        type: {
          type: String, // Don't do `{ location: { type: String } }`
          enum: ['Point'], // 'location.type' must be 'Point'
          required: true
        },
        coordinates: {
          type: [Number],
          required: true
        }
    },
});

Rendered Form upon creating a new Listing (input feilds):

<div class="row">
            <div class="mb-3 col-md-7">
                <label for="title" class="form-label"><b>Title</b></label>
                <input type="text" class="form-control" name="listing[title]" placeholder="Add a catchy Title" required>

                <div class="valid-feedback">Title Looks Good!</div>
            </div>

            <div class="mb-3 col-md-5">
                <label for="category" class="form-label"><b>Category</b></label>
                <input type="text" class="form-control" name="listing[category]" placeholder="Add a category" required>

                <div class="invalid-feedback">Category Doesnot Exists!</div>
            </div>
        </div>

Chrome how to get the browser zoom level (from touchpad or mouse wheel)

I am trying to get the browser’s zoom level with JS. Not the built in zoom (by using command and + or -) but the zoom when the user resizes the window with touchpad or mouse wheel.

I tried for example with the Chrome API chrome.tabs.getZoom() but this gets the zoom option size.

Also devicePixelRatio just gets the DPI and is always 2.

I need this because I’m drawing an area in a web page which I will crop with canvas. I’m able to get the correct tab window screenshot (whether zoomed in or not) but the cropping is off if zoomed in (using touchpad or mouse wheel)