How can I combine my two launch configurations into one webRoot?

I have a legacy website project written mostly in JavaScript and jQuery. I’m working on converting it to React 18 / TypeScript. Personally can’t work with out a proper debugger, and for an IDE I’m using VS Code.

The debugging works fine for both the types together, but only if I try and debug them separately.

    {
        "name": "pyHFS JS Debug Chrome launch",
        "type": "chrome",
        "request": "launch",
        "url": "https://127.0.0.1:8080/#",
        "webRoot": "${workspaceFolder}/web_interface/src",
    },
    
    {
        "name": "pyHFS React Debug Chrome launch",
        "type": "chrome",
        "request": "launch",
        "url": "https://127.0.0.1:8080/#",
        "webRoot": "${workspaceFolder}/web_interface",
        "skipFiles": [
            "node_modules",
        ],
    }

But when I try to use either of these at the same time it I get something like this. Usually the legacy JavaScript, which is not being bundled but just loaded via script tags into the browser.

enter image description here

How can i use vue with .vue file

Vue is simply manipulate html with javascript.In basic you create a vue object and You mount that object on a div with an id.I wanted to test that i create a .vue file and import this .vue file to a js file and mount it on a div. But it fails. This project is just for trying. This is my project schema. Project Schema

App.vue content :

<template>
<h1>{{ msg }}</h1>
<h1>.Vue file</h1>
</template>
<script>
export default{
    name: 'App',
    data(){
        return{
            msg: 'VUE JS 3'
        }
    }
}
</script>

app.js content :

import App from './App.vue';
const app = Vue.createApp(App);

app.mount('#app');

index.html content :

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Vue Basics</title>
    <link
      href="https://fonts.googleapis.com/css2?family=Jost:wght@400;700&display=swap"
      rel="stylesheet"
    />
    <link rel="stylesheet" href="styles.css" />
    <script src="https://unpkg.com/[email protected]/dist/vue.global.js" defer></script> 
    <script src="app.js" defer></script>
  </head>
  <body>
    <div id="app"></div>
  </body>
</html>

In chrome console output is chrome console

when i add type=”module” to script tag of app.js output is :
type module output

when i change type=”module” to type=”application/octet-stream”, there is no error in console but nothing on web page.
I think i can not import a .vue file or .vue file is not working when i import it but why?

Problem positioning an icon in a search bar

In this div I have an input for my search bar, an icon that performs the search and an icon that deletes the text the user has typed.
I have a problem with the positioning of my delete icon, it doesn’t stay in the search bar and goes out to the right depending on the size of the screen.
I’d like it to stay in the search bar. Do you know how to do this?

This code looks good to me, but it doesn’t do what I want it to do :

        <div class="col-lg-4 col-sm-4 searchbarDiv" style="margin: 0 auto; position: relative;">
            <cc1:PSTextBox runat="server" ID="edbName" AutoCompleteType="Search" MLNullKey="PANELADMINSOFTWARE_TITLE" MLToolTipKey="RQSearchTooltip" CssClass="form-control searchbar" Style="padding-left: 40px; padding-right: 40px;" />
            <span id="edbNameIcon" class="material-icons searchIcon" style="position: absolute; left: 20px; top: 50%; transform: translateY(-50%);">search</span>
            <span id="clearSearch" class="material-icons searchDelete" style="position: absolute; left: 20px; top: 50%; transform: translateY(-50%);">close</span>
        </div>

How do I get the input value and calculates rightaway? [closed]

I have an HTML file where I’d like to perform calculations as the user enters input, updating the results dynamically. but the function seems like it is not updating the tax Amount value, have similar functions for other fields all of the fields are working just due tax does not do anything

const taxAmountsInput = document.getElementById('taxAmount');
const dueTaxInput = document.getElementById('dueTax');
const dueTaxHiddenInput = document.getElementById('dueTaxHidden');

function updateDueTax() {
  const taxAmount = parseFloat(taxAmountsInput.value) || 0;
  const TotalDueTax = taxAmount * 0.05;
  dueTaxInput.value = TotalDueTax.toFixed(2);
  dueTaxHiddenInput.value = TotalDueTax.toFixed(2);
}
taxAmountsInput.addEventListener('input', updateDueTax);
updateDueTax();
<div class="row">
  <div class="col-md-3 mb-3">
    <label for="examptions" class="form-label">Exampltions</label>
  </div>
  <div class="col-md-3 mb-3 input-group" style="width: 75%">
    <span class="input-group-text custom-label" id="basic-addon1">270</span>
    <input type="text" class="form-control" id="examptions" name="examptions" required>
  </div>
</div>
<div class="row">
  <div class="col-md-3 mb-3">
    <label for="taxAmount" class="form-label">Lable Tax Amount</label>
  </div>
  <div class="col-md-3 mb-3 input-group" style="width: 75%">
    <span class="input-group-text custom-label" id="basic-addon1">280</span>
    <input readonly style="background-color: #e5f1f6;" type="text" class="form-control" id="taxAmount" name="taxAmount" required>
    <!-- Hidden input field to store the calculated taxAmout -->
    <input type="hidden" id="taxAmountHidden" name="taxAmountHidden">
  </div>
</div>
<div class="row">
  <div class="col-md-3 mb-3">
    <label for="taxRate" class="form-label">Tax Rate</label>
  </div>
  <div class="col-md-9 mb-3">
    <lable class="form-control" id="taxRate" name="taxRate"> %5</lable>
  </div>
</div>
<div class="row">
  <div class="col-md-3 mb-3">
    <label for="dueTax" class="form-label">Due Tax</label>
  </div>
  <div class="col-md-3 mb-3 input-group" style="width: 75%">
    <span class="input-group-text custom-label" id="basic-addon1">290</span>
    <input readonly style="background-color: #e5f1f6;" type="text" class="form-control" id="dueTax" name="dueTax" required>
    <!-- Hidden input field to store the calculated taxAmout -->
    <input type="hidden" id="dueTaxHidden" name="dueTaxHidden">
  </div>
</div>
</div>

I am not able to get the value of tax amount after entered

Finding locator by the first part of the locator value

I have the following line of code that clicks on a locator

await page.locator('#react-select-4-option-0').click();

How can i click the same locator based on only the first part of the code, something like this

await page.locator('#react-select-').click();

Please bear in mind that using something like locator("[id$=react-select-] will not work for some reason. The full html element is something like this:

<input class="" autocapitalize="none" autocomplete="off" autocorrect="off" id="react-select-4-input" spellcheck="false" tabindex="0" type="text" aria-autocomplete="list" aria-expanded="false" aria-haspopup="true" role="combobox" aria-activedescendant="react-select-4-option-0" value="" style="color: inherit; background: 0px center; opacity: 1; width: 100%; grid-area: 1 / 2; font: inherit; min-width: 2px; border: 0px; margin: 0px; outline: 0px; padding: 0px;">

The only way react-select-4-option-0 appears in the html code is when it is mouser over,but for some reason await page.locator('#react-select-4-option-0') is the only line that can find it. Based on what information i have given, is there any way to select the locator based on the react-select- part ?

Why does stopPropagation method block events attached to the same element?

Here is what I’m trying to do:

  1. Attach two events to the same object (and have them both active)
  2. Prevent propagating event up in DOM hierachy (event attached to parent element should not fire)

I’m facing a problem with point 1. I’ve attached two events, but only one is being fired.

I’ve reproduced my case on jsfiddle: https://jsfiddle.net/bavdnthu/

$('.main').on('click', '.testedDiv', function() {
  alert('div clicked #1');
  e.stopPropagation();
});

$('.main').on('click', '.testedDiv', function() {
  alert('div clicked #2');
  e.stopPropagation();
});

$('.main').on('click', 'span', function() {
  alert('span clicked');
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<div class="main">
  <div class="testedDiv">
    DIV
    <span>
      Span
    </span>
  <div>
</div>

Here is what I see: only ‘div clicked #1’ alert is being fired. I expect to see also the second one: ‘div clicked #2’.

Judging from description of stopPropagation on w3schools:

Propagation means bubbling up to parent elements or capturing down to child elements.

At the same time stopImmediatePropagation() exists which according to MDN:

If several listeners are attached to the same element for the same event type, they are called in the order in which they were added. If stopImmediatePropagation() is invoked during one such call, no remaining listeners will be called, either on that element or any other element.

So my code behaves as if I used stopImmediatePropagation(), but I did not. What am I missing?

How to drag several objects together with react-draggable?

I use react-draggable in my project. It helps to visualize some data as tables (draggable tables) collected in a diagram. Now I can move (drag) only one table at a time, but we want to choose some tables and drag them together. Has anyone tried to make the same feature with this library?
Here’s a part of my code:

<Draggable
                onDrag={onDrag}
                onStop={onChangePositionHandler}
                nodeRef={nodeRef}
                position={{ x: table.position.x, y: table.position.y }}
                zIndex="8"
            >
                <div
                    className={styles.MainContainer}
                    id={table.name}
                >
                {table.name}
               </div>
            </Draggable>

And a function for moving a table to save it’s coordinates later:

const onChangePositionHandler = (event, dragElement) => {
        onStop();
        const changedTable = {
            id: table.id,
            name: table.name,
            isCreatedByUser: table.isCreatedByUser,
            isAssociator: table.isAssociator,
            color: tableColor,
            position: {
                x: dragElement.x,
                y: dragElement.y
            },
            columns: table.columns
        };

        onChangeTableHandler(changedTable, areaName);
    };

I found one answer which is close (How to drag multiple objects at once in React?), but all of the tables should drag.
I can put selected tables in a new array, but how to find new coordinates for each after dragging?

How to declare a Tree entity in TypeORM using JavaScript

I know that typeorm support tree entities and we can implement it in Typescript with decorator. But I wonder that is there any way to declare a tree entity in JavaScript?

  • I have read the source code of EntitySchemaOptions, but I can’t find any useful information.
  • I also read the source code of EntitySchemaColumnOptions, even there are some attributes such as treeChildren and treeParent, I still don’t know how to use it.

How to implement k6 webcrypto encryption same way as PHP openssl_encrypt function

I got a code to encrypt some text in PHP, it looks like this:

$key = '1234aaaff80b56233525ac2355ac3456'; // something like this
$utf16Content = mb_convert_encoding('Some text', 'UTF-16LE');
$cipher = 'aes-256-gcm';
$nonceLength = openssl_cipher_iv_length($cipher);
$nonce = openssl_random_pseudo_bytes($nonceLength);

$encryptedContent = openssl_encrypt($utf16Content, $cipher, $key, $options=0, $nonce, $tag);

How could I implement the same behavior in JS webcrypto? (I need that for the k6 tests) I found a documentation but it isn’t clear for me.

For now I have code like this but I cannot decrypt that successfully so I guess something isn’t right.

const rawKey = Uint8Array.from(new String('1234aaaff80b56233525ac2355ac3456'), (x) => x.charCodeAt(0));

const key = await crypto.subtle.importKey(
     'raw',
     rawKey,
     { name: 'AES-GCM', length: 256 },
     false,
     ['encrypt', 'decrypt']
);
const nonce = crypto.getRandomValues(new Uint8Array(12));
const authTag = crypto.getRandomValues(new Uint8Array(10));

const encrypted = await crypto.subtle.encrypt({
       name: 'AES-GCM',
       iv: nonce,
       additionalData: authTag,
    },
    key,
    stringToArrayBuffer('Some text')
);

function stringToArrayBuffer(str) {
    const buf = new ArrayBuffer(str.length * 2);
    const bufView = new Uint16Array(buf);
    for (let i = 0, strLen = str.length; i < strLen; i++) {
        bufView[i] = str.charCodeAt(i);
    }
    return buf;
}

I think the main problem is creating correct authTag and changing String rawKey to ArrayBuffer.

How to Access localhost on mobile

I am building a web application using Laravel for APIs and React for the frontend . I want to test the app on a mobile phone. I usually test React alone, and it works, but the information from the backend is not working (authentication, CRUD, etc.). Can I access it? I run React using npm run dev — –host and Laravel using php artisan serve –host=0.0.0.0 –port=8000, but nothing is displaying except the static data.

ffmpeg is making my audio and video frozen and I don’t know why

I’m using bunjs runtime to execute ffmpeg as terminal code but I don’t know if my code is typescript code is wrong or ffmpeg is wrong
and I’m using json file to get the clips correctly

    let videos = 0;
    let stepsTrim = "";
    let concatInputs = "";

    for (let i = 0; i < 40; i++) {
        if (unwantedWords[i].keepORdelete === true) {
            stepsTrim += `[0:v]trim=0:${
                unwantedWords[i].start
            },setpts=PTS[v${i}];[0:a]atrim=0:${
                unwantedWords[i].start
            },asetpts=PTS-STARTPTS[a${i}];[0:v]trim=${unwantedWords[i].start}:${
                unwantedWords[i].end
            },setpts=PTS[v${unwantedWords.length + i + 1}];[0:a]atrim=${
                unwantedWords[i].start
            }:${unwantedWords[i].end},asetpts=PTS-STARTPTS[a${
                unwantedWords.length + i + 1
            }];`;

            concatInputs += `[v${i}][a${i}][v${unwantedWords.length + i + 1}][a${
                unwantedWords.length + i + 1
            }]`;
            videos += 2; 
        }
    }

    stepsTrim = stepsTrim.slice(0, -1);

    await $`ffmpeg -hide_banner -i ${videoRequirements.output} -filter_complex "${stepsTrim},${concatInputs} concat=n=${videos}:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" -c:v libopenh264 -preset slow -c:a mp3 -vsync 1 -y ${removedUnwantedWords}/fastAf.mp4`;

at the end after everything was done:

warning
[vost#0:0/libopenh264 @ 0x558f80ea1dc0] More than 1000 frames duplicated.9kbits/s dup=110 drop=1 speed=0.831x    
[out_0_0 @ 0x558f8100a880] 100 buffers queued in out_0_0, something may be wrong. dup=1064 drop=1 speed=1.43x    
[out_0_1 @ 0x558f8100af80] 100 buffers queued in out_0_1, something may be wrong.
[out_0_1 @ 0x558f8100af80] 1000 buffers queued in out_0_1, something may be wrong.
I can't figure out why ffmpeg is sometimes making the audio + video work and sometimes not
[enter image description here](https://i.stack.imgur.com/PicaA.png)
[
  {
    "word": "Hello",
    "id": 0,
    "keepORdelete": false,
    "start": 0,
    "end": 9.06
  },
  {
    "word": "guys,",
    "id": 1,
    "keepORdelete": false,
    "start": 9.06,
    "end": 10.2
  },
  {
    "word": "there",
    "id": 2,
    "keepORdelete": false,
    "start": 11.76,
    "end": 12.06
  },
...

I have tried commands from many types of ffmpeg commands changing the code and I can’t seem to get the audio and video right

Facing Issue in Debouncing concept in react

import React,{useState} from 'react';

const app = () =>{
    const [inputValue,setInputValue] = useState();    

    const handleChange = (e)=>{
        setInputValue(e.target.value);
        console.log(inputValue);
    }

    const debounce =function (fn , d) {
        let timer;
        return function(){
            let context = this,
                args=arguments;
        clearTimeout(timer);
          timer = setTimeout(() =>{
              fn.apply(context,args)
          },d)      
        }
    }
    
    const betterFunction = debounce(handleChange, 300);
    
    return (
    <>
        <input type='text' value={inputValue} onChange={betterFunction}/>
        <div>{inputValue}</div>
    </>
    )
    
}

export default app;

In the above code, I’m unable to make any changes once enter anything in inputfield. Basically updating inputfield stuck. Please help with the reasoning and thanking you in advance.

Does handson library support to angular v16?

Does handson library support to angular v16 ?
Im trying to update angular version from angular 15 to angular 16 but facing issues in handsson key-value library .Let me know if i can use handson-key-value library in angular 16 or not and if not any alternative for handson library?

Unable to understand for…in in JavaScript objects

I have below spaceship object in JavaScript and then nested objects as well.

let spaceship = {
    crew: {
    captain: { 
        name: 'Lily'
       },
    'chief officer': { 
        name: 'Dan', 
        },
    medic: { 
        name: 'Clementine', 
        },
    translator: {
        name: 'Shauna', 
        }
    }
}; 

I am trying to use forin loop but:

for(let crewMember in spaceship.crew){
  console.log(`${crewMember}:${crewMember.name}`)
}

displays output as:

captain:undefined
chief officer:undefined
medic:undefined
translator:undefined

Whereas I expect:

captain:Lily
chief Dan
medic:Clementine
translator:Shauna

To achieve the above result, I can do this instead

console.log(`${crewMember}: ${spaceship.crew[crewMember].name}`)

But I am unable to understand why I can’t achieve the same using former code, i.e.

console.log(`${crewMember}:${crewMember.name}`)

What are the most important concepts to know in the following languages to land a job? [closed]

So I’ve been learning web development for a while, and I’m quite curious about what the most important concepts are that I should know in the following languages/frameworks (including HTML & CSS) to land a job:
HTML/CSS
Javascript
React
Node Js
Typescript

Basically, I want to know what the most important concepts are that interviewers look for.