React native : npx react-native run-android

I facing issue on react native running, build success automatically cut-off `

BUILD SUCCESSFUL in 5m 56s

58 actionable tasks: 58 executed

info Connecting to the development server…

info Starting the app on “V8TC7TMJS4EYCIGU”…

Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.mercantile_society/.MainActivity }

syedzubyl@syedzubyl:~/Desktop/New Folder/Mercantile_society$`

I trying to build app in myfirst application. Try to run the app is running successfully after its automatically come out from debugging

Button type submit not triggering the onSubmit function in React.js

I am trying to submit the form values. I had defined the initial values and using the controlled input. When I am clicking on the Register button the onSubmit is not triggering. On clicking of the submit button there is no action triggered. I tried to use an explicit onClick function but it only triggers the event and no the values. Here I am using React with Material UI and Formik for handling form validation and submit.

    const Register = () => {
  const { palette } = useTheme();
  const dispatch = useDispatch();
  const navigate = useNavigate();
  const isNonMobile = useMediaQuery("(min-width:600px)");

  const register = async (values, onSubmitProps) => {
    // this allows us to send form info with image
    const formData = new FormData();
    for (let value in values) {
      formData.append(value, values[value]);
    }
    formData.append("picturePath", values.picture.name);

    const savedUserResponse = await fetch(
      "http://localhost:3001/auth/register",
      {
        method: "POST",
        body: formData,
      }
    );
    const savedUser = await savedUserResponse.json();
    console.log("saved User : ", savedUser);
    
    onSubmitProps.resetForm();


    // if (savedUser) {
    //   setPageType("login");
    // }

    navigate("/");
  };

  const handleFormSubmit = async (values, onSubmitProps) => {
    console.log("Register handler: ", values);
        return await register(values, onSubmitProps);
  };

  return (
    <Formik
      onSubmit={handleFormSubmit}
      initialValues={initialValuesRegister}
      validationSchema={registerSchema}
    >
      {({
        values,
        errors,
        touched,
        handleBlur,
        handleChange,
        handleSubmit,
        setFieldValue,
        resetForm,
      }) => (
        <form onSubmit={handleSubmit}>
          <Box
            display="grid"
            gap="30px"
            gridTemplateColumns="repeat(4, minmax(0, 1fr))"
            sx={{
              "& > div": { gridColumn: isNonMobile ? undefined : "span 4" },
            }}
          >           

            <TextField
              label="Email"
              onBlur={handleBlur}
              onChange={handleChange}
              value={values.email}
              name="email"
              error={Boolean(touched.email) && Boolean(errors.email)}
              helperText={touched.email && errors.email}
              sx={{ gridColumn: "span 4" }}
            />
            <TextField
              label="Password"
              type="password"
              onBlur={handleBlur}
              onChange={handleChange}
              value={values.password}
              name="password"
              error={Boolean(touched.password) && Boolean(errors.password)}
              helperText={touched.password && errors.password}
              sx={{ gridColumn: "span 4" }}
            />
          </Box>

          {/* BUTTONS */}
          <Box>
            <Button
              fullWidth
              type="submit"       
              sx={{
                m: "2rem 0",
                p: "1rem",
                backgroundColor: palette.primary.main,
                color: palette.background.alt,
                "&:hover": { color: palette.primary.main },
              }}
            >
             REGISTER
            </Button>
            <Typography
              sx={{
                textDecoration: "underline",
                color: palette.primary.main,
                "&:hover": {
                  cursor: "pointer",
                  color: palette.primary.light,
                },
              }}
            ><Link href="/">
            Already have an account? Login here.
            </Link>
            </Typography>
          </Box>
        </form>
      )}
    </Formik>
  );
};

export default Register;

The decimal point is in the wrong place when typing into the input field

I am making a very simple percentage calculator for my own use as a small app for my Android phone, consisting of HTML, CSS and JS.
I’ve encountered a problem that so far seems unsolvable, preventing me from completing the entire project.

When I enter a decimal number like “1.” the dot appears first, and then when I continue typing, the number shifts and becomes correctly positioned (e.g., “1.2”). I want the input to behave correctly from the very beginning, so that if I type “1.” it immediately shows as “1.” and not “.1”. (The calculator is using it’s own coded keypad, not the browser’s native.)

I don’t know how to correct this, neither long time spent with ChatGpt was of any help. I’ve already tried several approaches, none of them have worked but I kept the latest one in the JS example I attached below, so it might look messy, I am aware of that:)

Thank you very much for any helpful input.

// Calculator 1
function calculatePercentage() {
    const percent = parseFloat(document.getElementById("percentInput").value);
    const whole1 = parseFloat(document.getElementById("wholeInput1").value);
    const part = parseFloat(document.getElementById("partInput").value);
    const whole2 = parseFloat(document.getElementById("wholeInput2").value);


   if (!isNaN(percent) && !isNaN(whole1) && whole1 !== 0) {
        let result1 = (percent / 100) * whole1;
        document.getElementById("result1").value = result1 % 1 === 0 ? result1 : result1.toFixed(3); 
   } else {
        document.getElementById("result1").value = "";    }


// Calculator 2
   if (!isNaN(part) && !isNaN(whole2) && whole2 !== 0) {
        let percentage = (part / whole2) * 100;
        document.getElementById("result2").value = percentage % 1 === 0 ? `${percentage}%` : `${percentage.toFixed(3)}%`; 
   } else {
        document.getElementById("result2").value = "";
   }
}


    const input = document.getElementById("wholeInput1", "wholeInput2", "partInput",       "percentInput");
        input.addEventListener("input", (event) => {
            input.value = input.value.replace(/[^0-9.-]/g, "");
        });





// highlighted button when active session

document.addEventListener('DOMContentLoaded', function () {
    const navLinks = document.querySelectorAll('.navButton');
    const sections = document.querySelectorAll('.section');

    function highlightActiveSection() {
        let currentSection = null;

        // Check which section is currently in view
        sections.forEach(section => {
            const rect = section.getBoundingClientRect();
            if (rect.top <= window.innerHeight / 2 && rect.bottom >= window.innerHeight / 2) {
                currentSection = section.id;
            }
        });

        // Highlight the correct nav link
        navLinks.forEach(link => {
            const parentLi = link.parentElement; // Get the <li> of the link
            if (link.getAttribute('href').substring(1) === currentSection) {
                parentLi.classList.add('active');
            } else {
                parentLi.classList.remove('active');
            }
        });
    }

    // Initial highlight check
    highlightActiveSection();

    // Highlight on scroll
    window.addEventListener('scroll', highlightActiveSection);
});

////////

// Keypad and input field
const numKeypad = document.querySelector('.num-keypad');
const inputFields = document.querySelectorAll('.numberInput'); // All number input fields

let activeInput = null; // Track the active input field

// Show keypad on focus
inputFields.forEach(input => {
    input.addEventListener('focus', function () {
        numKeypad.classList.remove('hidden');
        activeInput = input; // Set the currently focused input
    });

    input.addEventListener('input', function () {
        // Automatically correct the input format during typing
        this.value = formatInput(this.value);
        // Scroll to the right to ensure the latest input is visible
        this.scrollLeft = this.scrollWidth;
    });
});

// Hide keypad when clicking outside
document.addEventListener('click', function (e) {
    if (!numKeypad.contains(e.target) && !Array.from(inputFields).some(input => input.contains(e.target))) {
        numKeypad.classList.add('hidden');
    }
});

// Handle number and backspace button clicks
numKeypad.addEventListener('click', function (e) {
    const button = e.target;

    if (button.classList.contains('num-button')) {
        const value = button.dataset.value; // Get the number or dot value
        const action = button.dataset.action; // Check if it's a backspace button

        if (activeInput) { // Ensure there is an active input field
            if (action === 'backspace') {
                activeInput.value = activeInput.value.slice(0, -1); // Remove the last character
            } else if (value === '.' && activeInput.value.includes('.')) {
                // Prevent adding another dot if one already exists
                return;
            } else if (value === '.' && (activeInput.value === '' || activeInput.value === '-')) {
                // Allow `0.` to start if input is empty or has a negative sign
                activeInput.value += '0.';
            } else if (value) {
                activeInput.value += value; // Append the value to the active input field
            }

            // Trigger the calculation after the input is updated
            calculatePercentage();

            // Ensure the input scrolls to the latest character
            activeInput.scrollLeft = activeInput.scrollWidth;
        }
    }
});

Is there a method in Javascript that tells you if a funciton was called?

I’m trying to create a function check(param) where param is some user defined function.
check() returns another function that checks if param was called within a certain time period after it was called once and if it was called again within that time period, I want to log an error.
I have no idea how to go about this? I’m writing in JS.

I’ve no idea how to approach this problem

Can I add JS code to the Case Resolution form in Dynamics 365 Customer Service?

My task is to filter the available status reasons for a Case, based on the BPF stage of the Case and the Case Type. I wrote JS function which works completely fine on the Case Form, but with that function I can only filter the status reasons for active cases.

My idea was, for cases that are about to be resolved, to create a custom JS, add the filtering logic that I have, and set it on the Case resolution form, so that way the available status reasons for Resolution Type would be filtered. But first I wanted to test if adding scripts is possible for this form. So I created a simple script that just logs to the console. However, when I added my script on the onLoad event of the main form, and tried to test it in browser ( by opening a case record, clicking on the “Resolve Case” button), I didn’t see anything in my console…I have “debugger” and console log statements in my script.

Change in css via javascript is not reflected in the UI

I have the following navbar:

I would like to use the following javascript to make the button and the <a> with id tLink disappear.

document.addEventListener("DOMContentLoaded", function() {
  const testB = document.getElementById("testb")
  testB.addEventListener("click", function() {
    console.log("click");
    const tLink = document.getElementById('tLink');
    tLink.style.setProperty('display', 'none', 'important');
    tLink.style.setProperty('visibility', 'hidden', 'important');
    tLink.style.setProperty('opacity', '0', 'important');
    console.log(window.getComputedStyle(tLink).display);
    testB.style.display = "none";
  });
});
.fh5co-nav {
  position: absolute;
  top: 0;
  margin: 0;
  width: 100%;
  padding: 40px 0;
  z-index: 1001;
}

@media screen and (max-width: 768px) {
  .fh5co-nav {
    padding: 20px 0;
  }
}

.fh5co-nav .container {
  display: flex;
  width: 50%;
  justify-content: space-between;
}

@media screen and (max-width: 768px) {
  .fh5co-nav .container {
    width: 100%;
    justify-content: unset;
  }
}

.fh5co-nav #fh5co-logo {
  font-size: 40px;
  margin: 0;
  padding: 0;
  line-height: 40px;
  font-family: "Sacramento", Arial, serif;
  margin-right: 5px;
}

.fh5co-nav a {
  padding: 5px 10px;
  color: #fff;
}

@media screen and (max-width: 768px) {

  .fh5co-nav .menu-1,
  .fh5co-nav .menu-2 {
    display: none;
  }
}

.fh5co-nav ul {
  padding: 0;
  margin: 2px 0 0 0;
}

.fh5co-nav ul li {
  padding: 0;
  margin: 0;
  list-style: none;
  display: inline;
}

.fh5co-nav ul li a {
  font-size: 14px;
  padding: 30px 10px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  -webkit-transition: 0.5s;
  -o-transition: 0.5s;
  transition: 0.5s;
}


.fh5co-nav ul li a:hover,
.fh5co-nav ul li a:focus,
.fh5co-nav ul li a:active {
  color: white;
}

.fh5co-nav ul li.has-dropdown {
  position: relative;
}

.fh5co-nav ul li.has-dropdown .dropdown {
  width: 130px;
  -webkit-box-shadow: 0px 14px 33px -9px rgba(0, 0, 0, 0.75);
  -moz-box-shadow: 0px 14px 33px -9px rgba(0, 0, 0, 0.75);
  box-shadow: 0px 14px 33px -9px rgba(0, 0, 0, 0.75);
  z-index: 1002;
  visibility: hidden;
  opacity: 0;
  position: absolute;
  top: 40px;
  left: 0;
  text-align: left;
  background: #fff;
  padding: 20px;
  -webkit-border-radius: 4px;
  -moz-border-radius: 4px;
  -ms-border-radius: 4px;
  border-radius: 4px;
  -webkit-transition: 0s;
  -o-transition: 0s;
  transition: 0s;
}

.fh5co-nav ul li.has-dropdown .dropdown:before {
  bottom: 100%;
  left: 40px;
  border: solid transparent;
  content: " ";
  height: 0;
  width: 0;
  position: absolute;
  pointer-events: none;
  border-bottom-color: #fff;
  border-width: 8px;
  margin-left: -8px;
}

.fh5co-nav ul li.has-dropdown .dropdown li {
  display: block;
  margin-bottom: 7px;
}

.fh5co-nav ul li.has-dropdown .dropdown li:last-child {
  margin-bottom: 0;
}

.fh5co-nav ul li.has-dropdown .dropdown li a {
  padding: 2px 0;
  display: block;
  color: #999999;
  line-height: 1.2;
  text-transform: none;
  font-size: 15px;
}

.fh5co-nav ul li.has-dropdown .dropdown li a:hover {
  color: #000;
}

.fh5co-nav ul li.has-dropdown:hover a,
.fh5co-nav ul li.has-dropdown:focus a {
  color: #fff;
}

.fh5co-nav ul li.btn-cta a {
  color: #F14E95;
}

.fh5co-nav ul li.btn-cta a span {
  background: #fff;
  padding: 4px 20px;
  display: -moz-inline-stack;
  display: inline-block;
  zoom: 1;
  *display: inline;
  -webkit-transition: 0.3s;
  -o-transition: 0.3s;
  transition: 0.3s;
  -webkit-border-radius: 100px;
  -moz-border-radius: 100px;
  -ms-border-radius: 100px;
  border-radius: 100px;
}

.fh5co-nav ul li.btn-cta a:hover span {
  -webkit-box-shadow: 0px 14px 20px -9px rgba(0, 0, 0, 0.75);
  -moz-box-shadow: 0px 14px 20px -9px rgba(0, 0, 0, 0.75);
  box-shadow: 0px 14px 20px -9px rgba(0, 0, 0, 0.75);
}

.fh5co-nav ul li.active>a,
#fh5co-offcanvas li.active a {
  color: #fff !important;
}
<nav class="fh5co-nav" role="navigation">
  <div class="container">
    <div id="fh5co-logo"><a href="index.html">W</a></div>
    <div class="col-xl-12 text-right menu-1">
      <ul id="navbarList">
        <li class="active"><a href="index.html">Home</a></li>
        <li><a href="c.html">C</a></li>
        <li><a href="d.html">d</a></li>
        <li><a href="f.html">f</a></li>
        <li><a href="l.html">l</a></li>
        <li><a id="tLink" href="t.html">Test</a></li>
        <li class="vertical-line"></li>
        <li id="langIT"><span class="active">Ita</span></li>
        <li id="langPT"><span onclick="switchLanguage('pt')">ptr</span></li>
      </ul>
    </div>
    <button id="testb">test</button>

  </div>
</nav>

Why does the button disappear while the <a> not? window.getComputedStyle(tLink).display is returning ‘none’, as expected, but in the browser tools I am not seeing any ‘display’ property assigned to the <a>.

[Model Driven App][PCF] Pain in the ass to create an iframe that host my pre-build HTML?

i am building a model driven app PCF control and i want to create a PDF viewer using PFF.js’s viewer html.

My plan is to modify this viewer to suit my need and then just simply upload it with my PCF bundle, and then my index.ts will load this html into an iframe together with all the PDF.js’s JS library needed to display the PDF file.

Then my index.ts file will query dataverse’s note attachment to show PDFs…

Firstly i found that the ControlManifest.Input.xml does not even allow you to include a html file in the resource. What?? How is everyone dealing with this limitation? We cant just create a complex HTML element on the fly using JS??

I am developing a PCF control for Power Apps and am attempting to load a custom viewer.html file, which includes the PDF.js viewer and necessary scripts for displaying PDF documents in an iframe. The viewer.html file is bundled correctly within my control, and I am trying to inject it into an iframe dynamically.

I used the context.resources.getResource method to retrieve the viewer.html file, expecting it to load into the iframe correctly. However, when I open my model-driven app in Chrome, I see that only my index.ts file and the pdf.mjs file are loaded in the browser’s developer tools, and the viewer.html is not being loaded. There seems to be a problem with how the viewer.html is being accessed or injected.

I expected the viewer.html file to be correctly bundled and accessible within the iframe, with the PDF document displayed as per the logic defined. But in reality, the HTML content doesn’t load, and there is no indication that the viewer.html file was successfully retrieved or injected into the iframe.

Get the html dom of the loaded html inside the tag

I would like to access the html file read through the tag.
How can I access the uploaded html file?

example:

<embed id="htpage" type="text/html" src="http://localhost/site/test.html"

I need to get the DOM of the test.html file loaded in the main page. (javascript or Jquery).

Thanks

is it faster javascript or php? [closed]

concept: create an electronic flight logbook
each flight data is stored in a json file on the web server
each pilot get access via private login
the idea is to have a logbook with the same layout of the paper one
each page has and is actually the same framework (based on html table and input elements) filled up with different data (got from the selected 12 flights stored in 12 different json files)
the question is:
is it faster to fill up the table via JavaScript via fetch API for each json file (client side) or is it better to fill up the table via PHP (server side)?

to modify the content I will use JavaScript (client side) and send the data to the web server via fetch API or via post form

js confused by multiple instances of class

I create instances of a media player class on click by several dif buttons. they will all load fine, but when it comes to closing, the event listeners on all players are affected.

#add_yt_event_listeners(row_class){
  var yt_play_btns = document.querySelectorAll('.yt_play_icon_container');
  yt_play_btns.forEach(btn => {
    btn.addEventListener('click', (e) => {
      var vid_id = btn.getAttribute('ext_loc');
      var row_c = row_class+'_yt_player';
      var post_args = {video_id:vid_id,row:row_c};
      var yt_player = new LOAD_YT_MEDIA_PLAYER(post_args,row_class);
      document.addEventListener('player_closed', (e) => {
        console.log(e.detail.closed);
        yt_player.destruct();
        yt_player = null;
        this.#option_btn_clicked == 'latest';
        this.#set_post_args_call_ajax();
      })
    });
  })
}

now the class has a destructor function as follows:

destruct() {
  this.#search_close_toggles_container.removeEventListener('click', this.search_options_toggle_event);
  const yt_playlist_option_btns_container = this.#this_player.querySelector('.yt_playlist_option_btns_container');
  const interaction_ics = yt_playlist_option_btns_container.querySelectorAll('.interaction_ic');
  interaction_ics.forEach(option => {
    option.removeEventListener('click', this.playlist_options_interactions_event);
  });
  const playlist_items = this.#this_player.querySelectorAll('.playlist_item_cont');
  playlist_items.forEach(video => {
    video.removeEventListener('click', this.playlist_video_event);
  });
  const pod_des_read = document.querySelector('.pod_des_read');
  if (pod_des_read != null) {
    const pod_des_rest = document.querySelector('.pod_des_rest');
    pod_des_read.removeEventListener('click', this.#media_description_event);
  }
  const player_close_btn = this.#this_player.querySelector('.media_row_close_btn');
  player_close_btn.removeEventListener('click', this.close_player_event);
  this.#row.classList.remove('yt_player');
  this.#row.classList.add('exp');
  this.#snippets_container.classList.add('news_snippets');
  this.#snippets_container.classList.remove('yt_player');
  this.#player_id = null;
  this.#bias = null;
  this.#post_args = null;
  this.#this_player = null;
  this.#player_playlist = null;
  this.#search_close_toggles_container = null;
  this.#ajax_url = null;
  this.#post_values = null;
  this.#snippets_container = null;
  this.#row = null;
  this.#row_title = null;
  this.#player_closed = null;
}

why are all instances affected rather than the one in which the close button was clicked. any help greatly appreciated

what to know about how setter works in JavaScript

So, i’m preparing myself for a technical intervew, i’m creating some customs web components, and after i creat my Class ArticleCard, i fetch some articles and create a new instance looking like this.

`this.articlesContainer = this.shadowRoot.getElementById(‘articles-container’);
}

connectedCallback() {

fetch('/article.json')
  .then(response => response.json())
  .then(articlesRetrieved => this.articles = articlesRetrieved);
}

set articles(value) {
    value.forEach(article => {
      const articleCard = new ArticleCard();
      articleCard.title = article.title;
      articleCard.image = article.image;
      articleCard.autor = article.autor;
      articleCard.company = article.company;
      articleCard.description = article.description;
      articleCard.id = article.autorId;
      this.articlesContainer.appendChild(articleCard);
    });
}

look closely at the line articleCard.id = article.autorId;
because in my ArticleCard class, I have a setter

set authorId(id) { this.authorId = id; }

this is to pass this.authorId when I create a new instance of author

autorButton.addEventListener('click', () => {
      const autor = new Author(this.authorId);
      autor.name = this.autor;
      autor.image = this.image;
      autor.description = this.description;
      this.shadowRoot.appendChild(autor);
    });

const autor = new Author(this.authorId);

This code WORKS, and do what it suppose to do, but why? I mean, in this line articleCard.id = article.autorId; JavaScript should call the setter method (if exist) i.e. = set id(id){this._id = id} and then i can use it when i create the new Author instance, but how JavaScript knows (for the love of GOD) that when i do this set authorId(id) { this.authorId = id;} it correctly sets the articleCard.id = article.autorId; to this.authorId, why?

Trying to understand how JavaScript connects a setter method with different names.

How to connect twsapi with @stoqey/ib in clojurescrip

When execute the script in javascript, it is normal as expected, however,
using @stoqey/ib with clojurescript unsuccessfully.

  1. Please comment how to access the constructor of @stoqey/ib with clojurescript correctly.
  2. should I modify the section npm-deps in deps.edn, in order to import @stoqey/ib correctly

section npm-deps in deps.edn

   ;; Specify npm dependencies
   :npm-deps {mathjs "^14.0.0"
           ;; "@stoqey/ib" "^1.4.4"
           
           }}

When execute the following clojurescript in repl,

**

;; Create IBApi object with configuration
(def ib
  (IBApi. #js {:port 7497}))
  ;; You can uncomment and set these options if needed
  ;; {:clientId 0
  ;;  :host "127.0.0.1"
  ;;  :port 7497})

encountered an error.

Execution error (TypeError) at (<cljs repl>:1).
; module$node_modules$$stoqey$ib$dist$index.IBApi is not a constructor

**

version in clojurecript

(ns trading-system.core
  (:require
   ["@stoqey/ib" :refer [IBApi EventName]]))

;; Create IBApi object with configuration
(def ib
  (IBApi. #js {:port 7497}))
  ;; You can uncomment and set these options if needed
  ;; {:clientId 0
  ;;  :host "127.0.0.1"
  ;;  :port 7497})

;; Initialize a mutable counter for positions
(def positions-count (atom 0))

;; Register event handler for errors
(.on ib EventName.error
     (fn [err code reqId]
       (js/console.error
        (str (.-message err) " - code: " code " - reqId: " reqId))))

;; Register event handler for each position received
(.on ib EventName.position
     (fn [account contract pos avgCost]
       (js/console.log
        (str account ": " pos " x " (.-symbol contract) " @ " avgCost))
       (swap! positions-count inc)))

;; Register a one-time event handler for the end of positions
(.once ib EventName.positionEnd
       (fn []
         (js/console.log
          (str "Total: " @positions-count " positions."))
         ;; Disconnect from the IB API after processing
         (.disconnect ib)))

;; Connect to the IB API
(.connect ib)

;; Request the current portfolio positions
(.reqPositions ib)

;; Start the connection and process
;;(start)
;; Call the start function to execute
;; (load-file "src/trading_system/core.cljs")
;; (-main)

Version in javascript

/* Example: Print all portfolio positions to console. */

import { IBApi, EventName } from "@stoqey/ib";

// Create IBApi object
const ib = new IBApi({
  // clientId: 0, // Optional: specify clientId if needed
  // host: '127.0.0.1', // Optional: specify host if different
  port: 7497, // Default port for TWS
});

// Register event handlers
let positionsCount = 0;

ib
  .on(EventName.error, (err, code, reqId) => {
    console.error(`${err.message} - code: ${code} - reqId: ${reqId}`);
  })
  .on(EventName.position, (account, contract, pos, avgCost) => {
    console.log(`${account}: ${pos} x ${contract.symbol} @ ${avgCost}`);
    positionsCount++;
  })
  .once(EventName.positionEnd, () => {
    console.log(`Total: ${positionsCount} positions.`);
    ib.disconnect();
  });

// Connect to the IB API and request positions
ib.connect();
ib.reqPositions();

Issue with playing animation while visiting the personal portfolio [closed]

I have a starting animation which should play at the beginning of visiting the website but it doesn’t play but it plays when the path is http://127.0.0.1:5504/index.html but it should play like on this http://127.0.0.1:5504 what should I do?

Here is my code attached

const isHomePage =
window.location.pathname === "/" || window.location.pathname === "/index.html" || window.location.pathname.endsWith("/index.html") || window.location.pathname.includes("Portfolio");
// Check if this is a page refresh
const lastLoadTime = localStorage.getItem("lastLoadTime");
const currentTime = new Date().getTime();
const isRefresh = lastLoadTime && currentTime - lastLoadTime < 3000; 
// Within 3 seconds considered a refresh
console.log(isRefresh);
// Update last load time
localStorage.setItem("lastLoadTime", currentTime);
const shouldPlayAnimation = isHomePage && (!localStorage.getItem("hasVisited") || isRefresh);
const shouldPlayAnimation = isHomePage && !localStorage.getItem("hasVisited");
console.log(shouldPlayAnimation);
// Only run animations if we're on home page AND animation hasn't played yet
if (shouldPlayAnimation) {
  document.body.classList.add("initial-load");
}

I did try making changes here and there to the code but no use

DB.transaction not waiting for Promise.all to resolve and moves to the next then statement

I have the following code in a function

          return Database.createDatabase()
          .then((database)=> {
            return insertSurvey(parsedData,database)
          })
          .then((outa)=>{
            console.log(outa)
          })

The createDatabase enables sqlite promises
The insertSurvey code is as follows

const insertSurvey =  (surveyObject : any, database) => {

  return database.transaction((tx) => {
    console.log("BEFORE SURVEY_INSERT_STRING executeSql")
    return tx.executeSql(
        Database.SURVEY_INSERT_STRING ,
        [
          surveyObject.troubleShooting,
        ]
       )
       .then(async ()=>{
        let arrayOfPromisesForAssetInsertion = []
        for(let count = 0 ; count < survey.assets.length; count ++)
        {
          arrayOfPromisesForAssetInsertion.push(insertAsset(tx,survey.assets[count], survey.surveyId))
        }
    
        return Promise.all(arrayOfPromisesForAssetInsertion) // REACHED POINT
      })
      .then((valuesAfterAssetInsertion)=>{. 
        console.log(valuesAfterAssetInsertion)  // DOES NOT REACH HERE

        let arrayOfIssuesInsertion = survey.assets.map((asset) => 
          insertIssues(tx, asset, survey.surveyId)
        );
        return Promise.all(arrayOfIssuesInsertion)
      })
      .catch((msg)=>{
        console.log("error caught ",msg)
      })
  })
    .then((sur)=>{
      // console.log("returning transaction and surveyObject",tx,surveyObject)
      return "output". // LINE OUTPUT
    })
  }




function insertAsset(tx, asset, surveyId) {
  setLoadingText ( "Assets")

  return tx.executeSql(
    Database.ASSETS_INSERT_STRING ,
    [
      asset.completed ?? false
    ])
  .then((values)=>{
      return values
  })
}


Here when the insertSurvey executes after reaching “return Promise.all(arrayOfPromisesForAssetInsertion)” the code jumps to “return “output” i.e // LINE OUTPUT. The following “console.log(valuesAfterAssetInsertion)” statement is not reached. The point // DOES NOT REACH HERE is not reached. There is no error as even catch is not reached.
Why is the DB.transaction not hitting the “console.log(valuesAfterAssetInsertion)” point

Format JSON file from text [duplicate]

I would change format file

My current files format

Email:Password 
Email:Password 
Email:Password 

I would like to change it to JSON format but can’t do it manually because there are around 500+ lines.

[

    {

        "Email": "your_email_address",

        "Password": "yourpassword "

    },

    {

        "Email": "your_email_address",

        "Password": "your_passworr_ "

    }

]