Error: submit is not a function with alertify function

Let’s see if someone could help me solve this problem that I don’t understand.

I’ve been looking to solve a problem for a couple of days, I have a confirmation alertify function.

With an html form I call the alertify function with the onclick event, but in the chrome dev tools it appears that submit is not a function. The Id of the form matches the javascript function and with a console.log the DOM identifies the form correctly.

html form

<form name="formulario" id="edit-form" method="POST" action="#" enctype="multipart/form-data">
<input class="button" type="submit" name="submit" id="submit" onclick="return showAlertConfirm('¿Está seguro de que desea editar el registro?','edit-form',url)" value="Editar" />

javascript function

//Funcione alertify para editar/eliminar registro
function showAlertConfirm(message,formId,url) {
  // Prevent the default form submission
  document.getElementById(formId).addEventListener("submit", function (event) {
    event.preventDefault();
  });

  // Display the confirmation dialog
  alertify.confirm(
    "ATENCIÓN",
    message,
    function () {
      console.log("ok clicked");
      console.log(formId);
      console.log(document.getElementById(formId));          
      let formObj = document.getElementById(formId);
      formObj.submit();
     
    },
    function () {
      console.log("Cancel clicked"); 
      setTimeout(function() {
        showNotification("Operación Cancelada");        
        // Después de 5 segundos, redirige
        setTimeout(function() {
            window.location.href = url;
        }, 5000);
    }, 0); // Espera 5 segundos antes de mostrar la notificación
    }
  );

  // Always return false to prevent the default form submission
  return false;
}

Error

jscript.js:212 Uncaught TypeError: formObj.submit is not a function
    at Object.<anonymous> (jscript.js:212:15)
    at Object.callback (alertify.min.js:3:2247)
    at U (alertify.min.js:2:13068)
    at Object.V (alertify.min.js:2:13159)
    at HTMLDivElement.<anonymous> (alertify.min.js:2:1267)

Preventing Data Tampering in HTTPS Requests: Safeguarding User-Initiated Donations

Could a Man-in-the-Middle (MITM) attack compromise the integrity of user-initiated transactions over HTTPS? Specifically, if a user selects an amount to donate on a website, is it possible for a hacker to intercept and modify the donation amount?If yes, what strategies can be implemented to safeguard against unauthorized alterations and ensure the security of transactions conducted over HTTPS?

note: I’m using django in development.

Can I scale layout to a smaller screen?

I did layout (using flex) for width 1280px. But it turned out that screen on which it will be shown has only 960px of browser width (and 1280px os screen width with some fractional pixel ratio)

Do I have any simple option programmatically to scale my layout to new size, something like “zoom out” it?

how can i calculate mutual friends/followers efficiently?

i need to calculate mutual friends between users, right now it is working fine, but i don’t think it will work for users who have a large follower base, it will take a long to load and compare. please suggest me good db design/query(if needed).
I’ve created tables and have a query like this:

table:

export enum FollowStatus {
  REQUESTED = "REQUESTED",
  APPROVED = "APPROVED",
  DECLINED = "DECLINED"
}

@Entity("followers")
export class Followers {
  @PrimaryGeneratedColumn()
  @Property()
  id: number;

  @Property()
  @Column()
  followerId: string;

  @ManyToOne(() => Users, { eager: true })
  @JoinColumn({ name: "followerId" })
  follower: Users;

  @Property()
  @Column()
  followedId: string;

  @ManyToOne(() => Users, { eager: true })
  @JoinColumn({ name: "followedId" })
  followed: Users;

  @Column({
    type: "enum",
    enum: FollowStatus,
    default: FollowStatus.REQUESTED
  })
  @Property()
  status: FollowStatus;
}

query:

  async getFollowers(userId: string, page: number, limit: number) {
    const builder: SelectQueryBuilder<Followers> = this.createQueryBuilder("followers")
      .where("followers.followedId = :userId", { userId })
      .andWhere("followers.status = :status", { status: "APPROVED" })
      .leftJoinAndSelect("followers.follower", "follower")
      .leftJoinAndSelect("follower.followers", "followerFollowers")
      .take(limit)
      .skip((page - 1) * limit);

    const followers = await builder.getManyAndCount();
    return followers;
  }

main function:

async getFollowers(userId: string, page: number, limit: number) {
    page = page || DEFAULT_PAGE_NUMBER;
    limit = limit || DEFAULT_PAGE_SIZE;

    const followers = await this.followersRepository.getFollowers(userId, page, limit);
    const myFollowers = followers[0].map((follower) => follower.followerId);

    const response: SearchResponse<FollowerUsersInterface> = {
      data: await Promise.all(
        followers[0].map(async (user) => {
          const isFollowing = user.follower.followers.findIndex((follower) => follower.followerId == userId);

          const userFollowers = user.follower.followers;

          // count mutual followers, exluding the user itself
          const mutualFollowersCount = userFollowers.filter((follower) => {
            if (follower.followerId !== user.followerId) {
              return myFollowers.some((myFollower) => myFollower === follower.followerId && follower.status === FollowStatus.APPROVED);
            }
          }).length;

          return {
            isFollowing: isFollowing > -1,
            userId: user.follower.id,
            userName: user.follower.userName,
            profilePic: await this.s3.getSignedUrl(user.follower.profilePic),
            mutualFollowers: mutualFollowersCount
          } as FollowerUsersInterface;
        })
      ),
      totalCount: followers[1]
    };

    return response;
  }

How to skip return in ramda if condition is false?

So I need to replace two javascript if statements with ramda, they look like this:

 if (!is(String, name)) {
      return target[name]
    }
    if (includes(name, reserved)) {
      return target[name]
    }

It’s part of a Proxy object, and after these if statements there’s the rest of the code. I tried to do it in Ramda like this:

const target = path('target', 'name')
const isDefault = anyPass([!is(String), includes(reserved)])
return unless(isDefault, target)(name)

But this way the code after return statement is unreachable, unlike with usual if statements, how can I write it in Ramda without returning in place?

How to know a manual click vs a program click?

I want to set value to a variable inside the click event handler of an element :

$("#pills-tabContent").on("click", "a", function() {
    ...
    // here I want to set value to a global variable only when in manual click event
});

In some part of my code I call the click method :

$("#pills-tabContent a[data-id='"+posPrestationId+"']").click();

So how to know in the click event handler that it is a manual click ?

How does one E2E test OTP login?

I have developed login with OTP to verify the register mail id. I want to write cypress test case for this feature but the autogenerated OTP is receiving in the mail but when running the cypress test case based upon the predefined JSON file all the controls values get fetch from the JSON but the OTP is autogenerated so could not stored in the test spec file or JSON file. How do I write a test for this, given that the OTP changes every time when the new user is login with new Email ID?

To enter the email OTP in Cypress, I use the .type() command to simulate typing the OTP into the input field. However, since the OTP is generated dynamically, I need a way to retrieve it during the test execution.

One approach is to stub the API call that generates the OTP so that you can control its response and return a known OTP value
In the test code I use, the cy.intercept() command intercepts the API call to generate the OTP (POST /api/generate-otp) and returns a known OTP value (123456). This allows to control the OTP value during the test execution. After entering the OTP, you can proceed with the registration process as needed

Unable to mint SPL 2022 token but able to create it using metaplex

const umi = createUmi(connection)
      .use(mplTokenMetadata())
      .use(walletAdapterIdentity(wallet));

    const mint = generateSigner(umi);
    await createFungible(umi, {
      mint,
      name: 'Name',
      symbol: '$Symbol',
      uri: '....',
      sellerFeeBasisPoints: percentAmount(5.5),
      decimals: 3,
      splTokenProgram: publicKey(TOKEN_2022_PROGRAM_ID),
    })
      .sendAndConfirm(umi)
      .then(() => {
        console.log(
          'token created (',
          mint.publicKey,
          ')',
        );
      });

here is mint code:

  await mintV1(umi, {
        mint: publicKey(mint.publicKey),
        tokenOwner: publicKey(wallet.publicKey),
        amount: 10000000,
        tokenStandard: TokenStandard.Fungible,
        splTokenProgram: publicKey(TOKEN_2022_PROGRAM_ID),
      }).sendAndConfirm(umi);

Unable to Scroll Modal Window with Open Dropdown Menu in Vue.js and Bootstrap-Vue

I’m developing a Vue.js application using Bootstrap-Vue and encountering an issue with modal window scrolling. The modal window contains several input fields and a custom dropdown (custom-select) component. Here’s a simplified structure of my modal:

 <b-form @submit.prevent="submit">
      <b-form-group>
        <template #label>
          <fa icon="cog" class="fa-fw" /> Title
        </template>
        <b-form-group
          label="Name"
          label-for="name"
          label-align-md="right"
          label-cols-md="2"
        >
          <custom-select
            v-model="data.name"
            close-on-select
            :options="names"
          />
        </b-form-group>
....
</b-modal>

and here is the template structure of the custom-select component:

<template>
  <select
    :id="id"
    :class="myClass"
    :name="name"
    :placeholder="placeholder"
    :disabled="disabled"
    :required="required"
  >
  </select>
</template>

The issue occurs when I open the dropdown menu within the modal. While the dropdown is open, I’m unable to scroll through the modal window. Scrolling only becomes possible again after closing the dropdown menu.

Expected Behavior: I should be able to scroll through the modal window even when the dropdown menu is open.

Actual Behavior: Scrolling through the modal is not possible when the dropdown menu is open.

Attempts to Resolve: I’ve tried custom CSS to override potential overflow issues but to no avail.

How can I fix this issue to allow scrolling with an open dropdown?

Adding shaders to the style object in WebGLVectorLayerRenderer?

Upgrading from OpenLayers 7.5.0 to 9.0.0, the earlier spesific style object used in the WebGLVectorLayerRenderer is deprecated, and I am having trouble ajusting to the more standard webGL flat style that is now being used.

Old style:

this.renderer=new WebGLVectorLayerRenderer(this, {
        fill: {
          attributes: {
            color: ...
          },
        },
        stroke: {
          attributes: {
            color: ...
          },
        },
        point:{
            attributes:{
              speed:...
              }
          },
          vertexShader:`
          ...`,

          fragmentShader:`
          ...
          `
      },
});

New flat style:

this.renderer=new WebGLVectorLayerRenderer(this, {
   style:{
       "fill-color": ["get", "COLOR" ],
       "icon-opacity": 0.6,
       "stroke-color":  ["get", "COLOR"],
       "stroke-width": 1.5,
   }
});

Is it still possible to add shaders in the style object (in my case for point) as it was earlier? I see that I could use the WebGLPointsLayerRenderer, which accepts a vertex and fragmend shader in the setup object, but that would limit me to render only points(?).
I can see that there exists a shaderBuilder that might be used somehow, but I am very reluctant to setup my shaders using that, compared to providing it in code.

Filter an array by object and select properties as new array in Typescript

I have an array with the following values

 [
    {
        id: 101,
        name: 'Alex',
        tg: 'REV006',
       
    },
    {
        id: 101,
        name: 'Alex',
        tg: 'REV002',
       
    },
    {
        id: 101,
        name: 'Alex',
        tg: 'REV001',
       
    },
    {
        id: 104,
        name: 'Dave',
        tg: 'REV003',
       
    },
    {
        id: 101,
        name: 'Alex',
        tg: 'REV005',
       
    },
    {
        id: 108,
        name: 'Arun',
        tg: 'REV005',
       
    },
   
]

I would like to get filter by id and
make an array for the tg property it as below format.
In other words I need to make the tg as array for based on the id and avoid duplication of arrays by making it in single array ).

[
{
    id: 101,
    name: 'Alex',
    tg: ['REV006','REV002','REV001','REV005']

},
{
    id: 104,
    name: 'Dave',
    tg: ['REV003'],

},

{
    id: 108,
    name: 'Arun',
    tg: ['REV005'],

},

]

Convert PDF file to HTML format in Python

I am searching any library in Python to convert PDF files into HTML format without changing the layout structure.

If there isn’t a suitable library available in Python for converting PDF to HTML, please provide recommendations for other programming languages as well.
I prefer not to utilize any external APIs. Instead, I’m seeking suggestions for libraries or code snippets that can accomplish the task without relying on external services.

Can I prevent enter key press from calling change event of Input tag?

change event is required for other scenario but that shouldnt get triggered on enter key press.

JSFiddle : https://jsfiddle.net/Ljwa10es/1/

Sample Input

const inp = document.querySelector("#inp");
inp.addEventListener("change", changeHandler);
inp.addEventListener("keyup", keyupHandler);

function changeHandler(e) {
      console.log(e.target.value)
}

function keyupHandler(e) {
    if (e.keyCode === 13) {
        console.log("Enter key pressed")
    }
}

change event is required for other scenario but that shouldnt get triggered on enter key press.

how to get the content of a

I’ve got a .hbs file that uses {{#each}} to display each object in a table, and when i press a button from a specific row it sends me to a new page run by js, and i want to grab the contents of the row the button i pressed was in

this is my table:

    <form method="POST" action="addItem">
        <input type="hidden" name="itemID" value="">
        <table id="datatable">
            <tr>
                {{#each headings}}
                    <th>{{this.NAME}}</th>
                {{/each}}
                <th>ACTIONS</th>
            </tr>
            {{#each contents}}
            <tr>
                <td name="itemID">{{this.ID}}</td>
                <td>{{this.[NAME]}}</td>
                {{#if ARTIST}}
                    <td>{{this.ARTIST}}</td>
                {{/if}}
                {{#if ALBUM}}
                    <td>{{this.ALBUM}}</td>
                {{/if}}
                {{#if BRAND}}
                    <td>{{this.BRAND}}</td>
                {{/if}}
                {{#if CAST}}
                    <td>{{this.BRAND}}</td>
                {{/if}}
                <td>{{this.DURATION}}</td>
                <td><button type="submit">ADD</button></td>
            </tr>
            {{/each}}
        </table>
    </form>

and this is what i use in my js file to grab the value:
app.all(
‘/addItem’,
function (request, response) {
let selectedID = request.body.itemID
})

i tried using a request.body but it only returns an undefined

How to add a title over my columns headers?

I’m trying to create an XLS file with ExcelJs with two sheets. I want both sheets to have a “title” on the first line (the same title for both sheets) and then a bunch of columns with headers and values.
I’ve tried the headerFooter option when creating my sheets and I’ve tried to insert a row before creating my columns. Neither worked as my columns headers still appear on the first row.
There is this similar question on here : Add rows before the column header using excel.js module + node But it’s rather old and the answers don’t seem to work neither when looking at the various comments.

Is there any (clean) way to do this basic thing with ExcelJs ?