How to make event listener with switch in js

I am trying to use event listener with switch from bootstrap but event listener is not working its only firing at start of the page and after it doesnt work. Im trying to make something like real time switch with js, but Im stuck with this. Im new at js so I will appreciate any help or response.

    <body>
        <div class="form-check form-switch" id="dv">
            <input class="form-check-input" type="checkbox" role="switch" id="flexSwitchCheckDefault" name="sw">
            <label class="form-check-label" for="flexSwitchCheckDefault" id="lb">Default switch checkbox input</label>
        </div>
    <script>//bootstrap link</script>
<script>
    const el = document.getElementById('flexSwitchCheckDefault');
    console.log(el);
    el.addEventListener('click', console.log("sasrwegerw"));
</script>
</body>

Input field error when using decimal numbers on apple touch devices

I am encountering a problem when using input field on apple touch devices. When i write a number and add a decimal dot (.) after it, the number is replaced with 0 immediately, but if i add a decimal dot after 0, then it works. It only happens on apple touch devices, on other devices it’s working fine. Any ideas how to solve this?

<input
      v-if="!advancedAttributeUsed"
      ref="input"
      step="any"
      :value="internalAttribute.value"
      :type="type"
      :disabled="disabled"
      :data-test-id="dataTestId"
      :data-cy="dataCy"
      class="custom-text-field"
      @input="handleInput"
      @blur="handleBlur"
      @focus="handleFocus"
      @keyup.enter="
        () => {
          $refs.input.blur();
          $emit('unfocus');
        }
      "
    />

handleInput(event) {
      let value = event.target.value;
      value = value.replace(/,/g, ".");
      if (!isNaN(value)) {
        this.internalAttribute.value = Number(value);
        console.log("handleInput", this.internalAttribute);
        this.$emit("input", this.internalAttribute);
      }
    },

Ar move Object in ar in android studios

I have problems to find a solution to move an object in augmented reality. Here is the code for the object:

`virtualObjectAlbedoTexture =
Texture.createFromAsset(
render,
“models/Download.jpg”,
Texture.WrapMode.CLAMP_TO_EDGE,
Texture.ColorFormat.SRGB);
virtualObjectAlbedoInstantPlacementTexture =
Texture.createFromAsset(
render,
“models/Download.jpg”,
Texture.WrapMode.CLAMP_TO_EDGE,
Texture.ColorFormat.SRGB);
Texture virtualObjectPbrTexture =
Texture.createFromAsset(
render,
“models/Download.jpg”,
Texture.WrapMode.CLAMP_TO_EDGE,
Texture.ColorFormat.LINEAR);

  virtualObjectMesh = Mesh.createFromAsset(render, "models/uploads_files_2086791_toy-brick.obj");
  virtualObjectShader =
      Shader.createFromAssets(
              render,
              "shaders/environmental_hdr.vert",
              "shaders/environmental_hdr.frag",
              /* defines= */ new HashMap<String, String>() {
                {
                  put(
                      "NUMBER_OF_MIPMAP_LEVELS",
                      Integer.toString(cubemapFilter.getNumberOfMipmapLevels()));
                }
              })
          .setTexture("u_AlbedoTexture", virtualObjectAlbedoTexture)
          .setTexture("u_RoughnessMetallicAmbientOcclusionTexture", virtualObjectPbrTexture)
          .setTexture("u_Cubemap", cubemapFilter.getFilteredCubemapTexture())
          .setTexture("u_DfgTexture", dfgTexture);
} catch (IOException e) {
  Log.e(TAG, "Failed to read a required asset file", e);
  messageSnackbarHelper.showError(this, "Failed to read a required asset file: " + e);
}

}`

I have tried to do it with AnchorNode and TransformableNode but my ideas are going out.

when am connecting database showing this error [closed]

node:events:492
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use :::3000
    at Server.setupListenHandle [as _listen2] (node:net:1872:16)
    at listenInCluster (node:net:1920:12)
    at Server.listen (node:net:2008:7)
    at Function.listen (C:UsersDELLDesktopentri mern stackweek10,class2, 20-10-2023 fryecom backnode_modulesexpresslibapplication.js:635:24)
    at Object.<anonymous> (C:UsersDELLDesktopentri mern stackweek10,class2, 20-10-2023 fryecom backindex.js:13:5)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
Emitted 'error' event on Server instance at:
    at emitErrorNT (node:net:1899:8)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'EADDRINUSE',
  errno: -4091,
  syscall: 'listen',
  address: '::',
  port: 3000
}

I’m trying to connect with the database but this error is showing

How can I decode Base64 encrypted data [closed]

I have one URL and in this url parameters is encrypted with base64.
My url is :

https://irfdamobile.ttac.ir/Api/MobilePharmacy/GetRecentlySoldDrugPharmacy?MobileNumber=%2B989120174757&DeviceId=c9ff8a48-3f8a-454a-8f85-cfc201acc981&VerifiedData=7J09%2BgCK5oMgY7soYGAIcw%3D%3D&Data=43ispesedSxMDtXxs8QoaCYXE4JAAgW7Sppqn7wC6UFsc3Yaq81Oj%2FFN1hxMi8IJFvt5OEjJvokymrtk7zgR2c2%2BEL7HMaWjF5Ho%2Fn3Va2cCrBr5W7OKeDd%2B2919%2FSYTzClVn2K0AkwypDZ%2FOcjjLUrfrSLb1RUhbTnpSVe3%2F9M%2BaoNEp5rwNgptRNf7sdXWmdfvT%2FHTFSSQgRsdW%2Fa6WdbJFNDTBBsI7szyDzaUPHc%3D

I want know what is the Data !
I decode this base64 codes into this website : https://www.base64decode.org

But just show me strange characters !

How can I know what is this Data ?

Fetching hashes and amounts of USDT transactions

I’m super new to coding, and kindly ask you for any help.
Trying to fetch hashes and amounts of USDT transactions on TRC20 and ERC20 systems, without binding to single wallet.

Have been trying to use TRX and ETH native API’s and third party API as well, such as QuickNode – which gave me better experience, but stil can’t get a proper result:(

Using QuickNode API managed to fecth some blocks, and TRX transactions, but have no idea how to get their amounts and properly filter them by contract – in another words, by token, such as USDT.

Expecting to be able to fetch hashes and amounts of latest USDT transactions on TRC20 or ERC20 ecosystems without binding fetch just to a single wallet

Mysql insert return not getting back to ajax

Well I am trying to insert data to a MySQL database. The data is getting inserted successfull. But I am not getting back the return msg after the successful insertion back to ajax. Also I am using the lastest jquery version and PHP version.

The script

<script>
  $(document).ready(function () {
    $('#data_form').on("submit",() => {
      var formData = $('#data_form').serialize();
      if (!$.active) {
        $.ajax({
          type: 'POST',
          url: '../../../controller/add_user.php',
          data :formData,
          cache: false,
          success: function (data) {
            console.log(data.message);
          },
          error: function(xhr, status, error) {
            console.log(xhr.responseJSON.message);
          }
        });
      }
    });
  });
</script> 

add_user.php

<?php
include_once('../model/database_11.php');
$db_obj = new Dbconnection();
$dbconn = $db_obj->ConnectToDB();

class admin
{
    public $dbconn;
    public $name;
    public $account_type;
    public $telephone = null;
    public $mobile;
    public $address;
    public $pincode;
    public $email_user;
    public $gender;
    public $dob;
    public $status;
    public $username;
    public $password;
    public $query;

    public function __construct($dbconn, $name, $account_type, $telephone, $mobile, $address, $pincode, $email_user, $gender, $dob, $status, $username, $password)
    {
        $this->dbconn = $dbconn;
        $this->name = $name;
        $this->account_type = $account_type;
        $this->telephone = $telephone;
        $this->mobile = $mobile;
        $this->address = $address;
        $this->pincode = $pincode;
        $this->email_user = $email_user;
        $this->gender = $gender;
        $this->dob = date('Y-m-d', strtotime($dob));
        $this->status = $status;
        $this->username = $username;
        $this->password = $password;
    }
    function adduser()
    {
        $this->query = "INSERT INTO `users` (`ID_USER`, `WEB_USERNAME`, `WEB_USERPASSWORD`, `USER_TYPE`, `NAME`, `IMAGE`, `TELEPHONE`, `MOBILE`, `ADDRESS`, `PIN`, `EMAIL`, `GENDER`, `DATE_OF_BIRTH`, `STATUS`) VALUES (NULL, '$this->username', '$this->password', '$this->account_type', '$this->name', NULL, '$this->telephone', '$this->mobile', '$this->address', '$this->pincode', '$this->email_user', '$this->gender', '$this->dob', '$this->status');";
        if ($this->dbconn->query($this->query) === TRUE) {
            return "200";
        } else {
            return "500";
        }
    }
    public function __destruct()
    {
        $this->dbconn->close();
    }

}
extract($_POST);
$admin = new admin($dbconn, $name, $account_type, $telephone, $mobile, $address, $pincode, $email_user, $gender, $dob, $status, $username, $password);
$res = $admin->adduser();
echo $res;
?>

I tried changing he echo statement to http_response_code. But still it’s not working.

Create JavaScript function to fulfills the condition price and pcs

Create JavaScript function (price, pcs)

With denomination

[100000, 50000, 20000, 10000, 5000, 2000, 1000]

So

function(40000, 4) return [10000, 10000, 10000, 10000]
function(10000, 4) return [5000, 2000, 2000, 1000]
function(40000, 2) return [20000, 20000]
function(50000, 2) return [] //  because there is no 25000 in denomination.

The length of result array must match the ‘pcs’ parameter and sum of result array must match the ‘price’ parameter. If there is no possible result return empty array ([]).

Help Me. I can’t find a pattern

Can errors in HTML/CSS of shadow DOM impact the parent DOM layout?

If user input HTML/CSS is rendered within a shadow DOM tree, is it guaranteed that, if that content is malformed, it will not disrupt the rendering of the parent or light DOM’s content?

Can it function as an SO code snippet does in an iframe but excluding the JS, of course, such that the HTML/CSS is otherwise isolated from the page layout?

I suppose that is sort of in reverse from the purpose of web components and the shadow DOM in that they are to be insulated from being manipulated by the parent CSS and JS; but I’m asking if errors in their content can impact the parent.

Thank you.

Ag grid table react how can we download all data

I am using Ag grid and ag grid has a const
your text`` onBtnExport = useCallback(() => {
gridRef.current.api.exportDataAsCsv();
}, []);
this function but the problem is it only download current page data but i want all data download if we has 3 page so all data able to download in one click how can we do this using ag grid table react

I am using this const onBtnExport = useCallback(() => {
gridRef.current.api.exportDataAsCsv();
}, []);““your text“

HTML5 canvas based Texture mapping optimization

In question Image manipulation and texture mapping

The following piece of code achieves texture mapping using vanilla javascript on
a canvas..

         function textureMap(ctx, texture, pts) {
             var tris = [[0, 1, 2], [2, 3, 0]]; // Split in two triangles
             for (var t=0; t<2; t++) {
                 var pp = tris[t];
                 var x0 = pts[pp[0]].x, x1 = pts[pp[1]].x, x2 = pts[pp[2]].x;
                 var y0 = pts[pp[0]].y, y1 = pts[pp[1]].y, y2 = pts[pp[2]].y;
                 var u0 = pts[pp[0]].u, u1 = pts[pp[1]].u, u2 = pts[pp[2]].u;
                 var v0 = pts[pp[0]].v, v1 = pts[pp[1]].v, v2 = pts[pp[2]].v;

                 // Set clipping area so that only pixels inside the triangle will
                 // be affected by the image drawing operation
                 ctx.save(); ctx.beginPath(); ctx.moveTo(x0, y0); ctx.lineTo(x1, y1);
                 ctx.lineTo(x2, y2); ctx.closePath(); ctx.clip();

                 // Compute matrix transform
                 var delta = u0*v1 + v0*u2 + u1*v2 - v1*u2 - v0*u1 - u0*v2;
                 var delta_a = x0*v1 + v0*x2 + x1*v2 - v1*x2 - v0*x1 - x0*v2;
                 var delta_b = u0*x1 + x0*u2 + u1*x2 - x1*u2 - x0*u1 - u0*x2;
                 var delta_c = u0*v1*x2 + v0*x1*u2 + x0*u1*v2 - x0*v1*u2
                               - v0*u1*x2 - u0*x1*v2;
                 var delta_d = y0*v1 + v0*y2 + y1*v2 - v1*y2 - v0*y1 - y0*v2;
                 var delta_e = u0*y1 + y0*u2 + u1*y2 - y1*u2 - y0*u1 - u0*y2;
                 var delta_f = u0*v1*y2 + v0*y1*u2 + y0*u1*v2 - y0*v1*u2
                               - v0*u1*y2 - u0*y1*v2;

                 // Draw the transformed image
                 ctx.transform(delta_a/delta, delta_d/delta,
                               delta_b/delta, delta_e/delta,
                               delta_c/delta, delta_f/delta);
                 ctx.drawImage(texture, 0, 0);
                 ctx.restore();
             }
         }

The bottle neck here is the context saving and restoring (for the clipping region).

Any ideas how I can do away with the clipping and significantly improve the performance ?

I tried several things, however as there is no way to restore the clipping
region with javascript without rolling it inside a save/restore, I’m
stuck for ideas.

jest runner extension showing error while running in react?

while running jest runner extension to run jest test case in react monorepo, its showing me error as

PS F:MySpace-Web> node “node_modules/jest/bin/jest.js” “f:/MySpace-Web/apps/myspace/src/app/views/login/login.spec.tsx” -c “f:/MySpace-Web/apps/myspace/jest.config.ts” -t “Login Component should render the login form”
Error: Jest: Failed to parse the TypeScript config file f:/MySpace-Web/apps/myspace/jest.config.ts
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath ‘./extend-expect’ is not defined by “exports” in f:[email protected]
at readConfigFileAndSetRootDir (F:MySpace-Webnode_modulesjest-configbuildreadConfigFileAndSetRootDir.js:116:13)
at async readInitialOptions (F:MySpace-Webnode_modulesjest-configbuildindex.js:392:15)
at async readConfig (F:MySpace-Webnode_modulesjest-configbuildindex.js:147:48)
at async readConfigs (F:MySpace-Webnode_modulesjest-configbuildindex.js:424:26)
at async runCLI (F:[email protected]:151:59)
at async Object.run (F:MySpace-Webnode_modulesjest-clibuildrun.js:130:37)

jest.config.ts

/* eslint-disable */
import '@testing-library/jest-dom/extend-expect';
export default {
  displayName: 'myspace',
  preset: '../../jest.preset.js',
  transform: {
    '^(?!.*\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
    '^.+\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }],
  },
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
  coverageDirectory: '../../coverage/apps/myspace',
  setupFilesAfterEnv: ['<rootDir>/support/setupTests.js'],
};

package.json

{
  "name": "@testing-library/jest-dom",
  "version": "6.1.5",
  "description": "Custom jest matchers to test the state of the DOM",
  "main": "dist/index.js",
  "module": "dist/index.mjs",
  "exports": {
    ".": {
      "require": {
        "types": "./types/index.d.ts",
        "default": "./dist/index.js"
      },
      "import": {
        "types": "./types/index.d.ts",
        "default": "./dist/index.mjs"
      }
    },
    "./jest-globals": {
      "require": {
        "types": "./types/jest-globals.d.ts",
        "default": "./dist/jest-globals.js"
      },
      "import": {
        "types": "./types/jest-globals.d.ts",
        "default": "./dist/jest-globals.mjs"
      }
    },
    "./matchers": {
      "require": {
        "types": "./types/matchers.d.ts",
        "default": "./dist/matchers.js"
      },
      "import": {
        "types": "./types/matchers.d.ts",
        "default": "./dist/matchers.mjs"
      }
    },
    "./vitest": {
      "require": {
        "types": "./types/vitest.d.ts",
        "default": "./dist/vitest.js"
      },
      "import": {
        "types": "./types/vitest.d.ts",
        "default": "./dist/vitest.mjs"
      }
    },
    "./package.json": "./package.json"
  },
  "types": "types/index.d.ts",
  "engines": {
    "node": ">=14",
    "npm": ">=6",
    "yarn": ">=1"
  },
  "scripts": {
    "build": "rollup -c",
    "format": "kcd-scripts format",
    "lint": "kcd-scripts lint",
    "setup": "npm install && npm run validate -s",
    "test": "kcd-scripts test",
    "test:update": "npm test -- --updateSnapshot --coverage",
    "test:types": "tsc -p types/__tests__/jest && tsc -p types/__tests__/jest-globals && tsc -p types/__tests__/vitest",
    "validate": "kcd-scripts validate && npm run test:types"
  },
  "files": [
    "dist",
    "types",
    "*.d.ts",
    "jest-globals.js",
    "matchers.js",
    "vitest.js"
  ],
  "keywords": [
    "testing",
    "dom",
    "jest",
    "jsdom"
  ],
  "author": "Ernesto Garcia <[email protected]> (http://gnapse.github.io)",
  "license": "MIT",
  "dependencies": {
    "@adobe/css-tools": "^4.3.1",
    "@babel/runtime": "^7.9.2",
    "aria-query": "^5.0.0",
    "chalk": "^3.0.0",
    "css.escape": "^1.5.1",
    "dom-accessibility-api": "^0.5.6",
    "lodash": "^4.17.15",
    "redent": "^3.0.0"
  },
  "devDependencies": {
    "@jest/globals": "^29.6.2",
    "@rollup/plugin-commonjs": "^25.0.4",
    "expect": "^29.6.2",
    "jest-environment-jsdom-sixteen": "^1.0.3",
    "jest-watch-select-projects": "^2.0.0",
    "jsdom": "^16.2.1",
    "kcd-scripts": "^14.0.0",
    "pretty-format": "^25.1.0",
    "rollup": "^3.28.1",
    "rollup-plugin-delete": "^2.0.0",
    "typescript": "^5.1.6",
    "vitest": "^0.34.1"
  },
  "peerDependencies": {
    "@jest/globals": ">= 28",
    "@types/jest": ">= 28",
    "jest": ">= 28",
    "vitest": ">= 0.32"
  },
  "peerDependenciesMeta": {
    "@jest/globals": {
      "optional": true
    },
    "@types/jest": {
      "optional": true
    },
    "jest": {
      "optional": true
    },
    "vitest": {
      "optional": true
    }
  },
  "eslintConfig": {
    "extends": "./node_modules/kcd-scripts/eslint.js",
    "parserOptions": {
      "sourceType": "module",
      "ecmaVersion": 2020
    },
    "rules": {
      "no-invalid-this": "off"
    },
    "overrides": [
      {
        "files": [
          "src/__tests__/*.js"
        ],
        "rules": {
          "max-lines-per-function": "off"
        }
      },
      {
        "files": [
          "**/*.d.ts"
        ],
        "rules": {
          "@typescript-eslint/no-empty-interface": "off",
          "@typescript-eslint/no-explicit-any": "off",
          "@typescript-eslint/no-invalid-void-type": "off",
          "@typescript-eslint/no-unused-vars": "off",
          "@typescript-eslint/triple-slash-reference": "off"
        }
      }
    ]
  },
  "eslintIgnore": [
    "node_modules",
    "coverage",
    "dist",
    "types/__tests__"
  ],
  "repository": {
    "type": "git",
    "url": "https://github.com/testing-library/jest-dom"
  },
  "bugs": {
    "url": "https://github.com/testing-library/jest-dom/issues"
  },
  "homepage": "https://github.com/testing-library/jest-dom#readme"
}

tried reinstalling the node modules which are showing in the error file, also installed some other extensions but they are showing the same result. tried to change preset in jest.config.ts also but its not working.

How to add special characters in url in angular 15

I’m upgrading an old application written in Angular JS to latest Angular 15. The migration is smooth but facing problem in urls. Actually our survey url exists like this below and it is different for every survey.
https://some-domain.com/#/77RqxKxiEdXDccBB8S3iahYS9MB4cGqQR9G6XciZKR0+U=

Ass you can see, the url contains ‘+’ and ‘=’. But when I’m using this url in my angular 15 application, it is replacing the special characters and especially removing the ‘=’ from the url.

But in DB, this encrypted id is being stored as an unique identifier and using this only all the details are fetched from DB.

The problem is that I cannot change the url as many previous surveys have been sent to customer with that url.

Any help will be really appreciated.

I’ve tried using some of the help found from google like using URIencode or help from this url
https://stackblitz.com/edit/allowing-angular-4-routes-to-pass-special-charact-ebpsmt?file=src%2Fapp%2Furl-serializer.service.ts

but it is still not working as the ‘=’ is still getting missed from the url.