nativescript-firebase issue to get push token

I implemented the nativescript-firebase (https://github.com/EddyVerbruggen/nativescript-plugin-firebase) plugin in my mobile app. It used to work fine but since I updated to the 11.1.3 version I cannot get the push token. I tried to get back to the 10.6.3 version but it says it is not available anymore when I execute npm install.

Here is what I do in my main.js

import { messaging } from "@nativescript/firebase/messaging";
import { firebase } from "@nativescript/firebase"
firebase.init({
    onMessageReceivedCallback: function(message) {
      //do stuff
    }
}).then(function () {
    messaging.getCurrentPushToken().then(token => {
        console.log(token)
    }).catch(e => {
    console.log(e);
  })
},function (error) {
  console.log("firebase.init error: " + error);
});

This does not log the token but goes into the catch and logs this
Uncomment firebase-messaging in the plugin's include.gradle first

Here is my package.json

{
  "name": "*****",
  "main": "./src/main.js",
  "version": "4.4.0",
  "description": "A native application built with NativeScript-Vue",
  "author": "*****",
  "license": "Propriétaire",
  "dependencies": {
    "@carployee/openapp": "^1.0.1",
    "@nativescript-community/ui-material-bottomnavigationbar": "^6.2.4",
    "@nativescript/appavailability": "^2.0.0",
    "@nativescript/appversion": "^2.0.0",
    "@nativescript/camera": "^5.0.10",
    "@nativescript/core": "~8.1.5",
    "@nativescript/datetimepicker": "^2.1.9",
    "@nativescript/firebase": "^11.1.3",
    "@nativescript/imagepicker": "^1.0.6",
    "@nativescript/ios": "^8.1.0",
    "@nativescript/iqkeyboardmanager": "^2.0.0",
    "@nativescript/theme": "^3.0.2",
    "@nstudio/nativescript-cardview": "^2.0.1",
    "@nstudio/nativescript-loading-indicator": "^4.1.0",
    "@nstudio/nativescript-pulltorefresh": "^3.0.1",
    "@proplugins/nativescript-purchase": "git+https://gitlab.******",
    "@vue/devtools": "^5.3.4",
    "nativescript-dna-deviceinfo": "^3.7.3",
    "nativescript-feedback": "^2.0.0",
    "nativescript-google-maps-sdk": "^3.0.2",
    "nativescript-inappbrowser": "^3.1.2",
    "nativescript-open-app": "^0.3.0",
    "nativescript-phone": "^3.0.2",
    "nativescript-socketio": "^3.3.1",
    "nativescript-toasty": "^3.0.0-alpha.2",
    "nativescript-ui-dataform": "^8.0.1",
    "nativescript-ui-listview": "^10.0.2",
    "nativescript-ui-sidedrawer": "^10.0.2",
    "nativescript-vue": "^2.9.0",
    "nativescript-vue-devtools": "^1.5.1",
    "nativescript-vue-fonticon": "^1.0.3",
    "nativescript-websockets": "^2.0.0",
    "npm-check": "^5.9.2",
    "npm-check-updates": "^12.0.2"
  },
  "devDependencies": {
    "@babel/core": "^7.16.0",
    "@babel/preset-env": "^7.16.4",
    "@nativescript/android": "~8.1.1",
    "@nativescript/webpack": "~5.0.1",
    "babel-loader": "^8.2.3",
    "nativescript-vue-template-compiler": "^2.9.0",
    "nativescript-worker-loader": "~0.12.1",
    "sass": "^1.44.0",
    "vue-loader": "^15.9.8"
  }
}

How in JS to compare from an array of objects from all the results 2 keys are equal to 2 other variables

I’m trying to understand how to get from an array of objects 2 specific keys and compare them with 2 other values for a boolean statement.

What I need to achieve is that for all results from an array of objects I have to check if
ownerId or ownerType are equal to example this.ownerId or this.ownerType.

To give an example I have a result Obj as

const results = [
    {
        ownerId: '1'
        ownerType: SOME_TYPE,
        id: 1
        ...
        <other key_values>
        ...
    },
    {
        ownerId: '1'
        ownerType: SOME_TYPE,
        id: 2
        ...
        <other key_values>
        ...
    },
    ... more ...
];

From the results, I have to extract all ownerId and ownerType and check if all are equal to another value as example

(ownerType === 'USER' && ownerId === userId) ||
(ownerType === 'PARTICIPANT' && ownerId === participantId)

So that means where all ownerType === 'USER' && all ownerId === to this userId then is true.

like all ownerId in my examples are 1 and we suppose ‘USER’ as a type then that is true.

but

If the result doesn’t have all the same ownerId that is false.

I’m not sure what kind of function I need to write for it.

If any comments I’ll try to explain better m issue

Why ‘Get’ request is returning blank object for particular request?

This is the code in which the problem is occurring:
router.get("/", async(req, res) => {
    const username = req.query.user;
    const catName = req.query.cat;

    try {
        let posts;
        if (username) {
            posts = await Post.find({ username: username });
        } else if (catName) {
            posts = await Post.find({ categories: { $in: [catName], }, });
        } else {
            posts = await Post.find();
        }
        res.status.json(posts);
    } catch (err) {
        res.status(500).json(err)
    }
});
if I am using this its working fine
   router.get("/", async(req, res) => {
         try {
             const post = await Post.find()
    
             res.status(200).json(post)
    
         } catch (err) {
             res.status(500).json(err)
         }
     })
I want to use the first request with queries but that is returning a empty object I can’t find error!

Every other requests are working just fine in this route expect the first one!

Can’t pass JSON from PHP to Javascript in Laravel component

We have a Laravel 8 project.

In it, we have a Blade template, and from this Blade template we are including a Laravel component like this:

<x-key-figure-graph
    measure="IQ_TOTAL_REV"
    dividend-history="{{ json_encode($dividend_history) }}"
    show-last="10">
</x-key-figure-graph>

The $dividend_history is an associative array that looks like this:

['2002' => ['date' => '2002-06-30', 'IQ_CLOSEPRICE' => 27.35]],
['2003' => ['date' => '2003-06-30', 'IQ_CLOSEPRICE' => 33.81]],
...

I am doing json_encode on the array to transform it into a string so I can pass it as a prop to the x-key-figure-graph component.

Within the component is where problems arise. If I print out the passed prop:

{{ $dividendHistory }}

I get:

{&quot;2002&quot;:{&quot;date&quot;:&quot;2002-06-30&quot;,&quot;IQ_CLOSEPRICE&quot;:27.35 [...]

So this is a string with the quotes turned into their ASCII equivalents (&quot;). The thing is, now we need to pass this to a Javascript script inside this component. I have not found a way to convert this string back into a working JSON for Javascript.

Attempt 1:

let stock = JSON.parse({!! $dividendHistory !!});

Result:

Uncaught SyntaxError: Unexpected token '&'

Attempt 2:

let stock = JSON.parse("{!! $dividendHistory !!}");

Result:

Uncaught SyntaxError: Unexpected token & in JSON at position 1 at JSON.parse (<anonymous>)

Attempt 3:

let stock = JSON.parse({!! json_decode($dividendHistory) !!});

Result:

Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>)

I don’t know what else to try. Surely it should be possible to convert the string, which was encoded from JSON, back into JSON so it can be used by Javascript. How?

plugin:vite:import-analysis Failed to resolve import “../components/x.vue” from “srcrouterindex.js”. Does the file exist?

In my Vue JS application, I have the following js inside src/routes

index.js

import { createRouter, createWebHistory } from "vue-router";
import Dashboard from '../views/Dashboard.vue';
import Customers from '../views/Customers.vue';
import Login from '../views/Login.vue';
import Register from '../views/Register.vue';
import DefaultLayout from '../components/DefaultLayout.vue';
import AuthLayout from '../components/AuthtLayout.vue';
import store from "../store";

const routes = [
        {
        path : '/',
        redirect : '/dashboard',
        component : DefaultLayout,
        meta : { requiresAuth : true },
        children : [
            {path : '/dashboard', name : 'Dashboard', component : Dashboard},
            {path : '/customers', name : 'Customers', component : Customers}
        ]
    },

    {
        path : '/auth',
        redirect : '/login',
        name : 'Auth',
        component : AuthLayout,
        children:[

                {
                    path : '/login',
                    name : 'Login',
                    component : Login,
                },

                {
                    path : '/register',
                    name : 'Register',
                    component : Register,
                },
            
        ],
    },

    
];

const router = createRouter({
    history : createWebHistory(),
    routes
})

router.beforeEach((to, from, next) => {
    if(to.meta.requiresAuth && !store.state.user.token){
        next({name : 'Login'})
    } else if (store.state.user.token && ( to.name === 'Login' || to.name === 'Register' )  ) {
        next({ name : 'Dashboard' });
    } else{
        next ()
    }
})

export default router;

And I have the following Login.vue inside src/views.

<template> 
      <div>
        <img class="mx-auto h-12 w-auto" src="https://tailwindui.com/img/logos/workflow-mark-indigo-600.svg" alt="Workflow" />
        <h2 class="mt-6 text-center text-3xl font-extrabold text-gray-900">
          Sign in to your account
        </h2>
        <p class="mt-2 text-center text-sm text-gray-600">
          Or
          {{ ' ' }}
          <a href="#" class="font-medium text-indigo-600 hover:text-indigo-500">
            start your 14-day free trial
          </a>
        </p>
      </div>
      <form class="mt-8 space-y-6" action="#" method="POST">
        <input type="hidden" name="remember" value="true" />
        <div class="rounded-md shadow-sm -space-y-px">
          <div>
            <label for="email-address" class="sr-only">Email address</label>
            <input id="email-address" name="email" type="email" autocomplete="email" required="" class="appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-t-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm" placeholder="Email address" />
          </div>
          <div>
            <label for="password" class="sr-only">Password</label>
            <input id="password" name="password" type="password" autocomplete="current-password" required="" class="appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm" placeholder="Password" />
          </div>
        </div>

        <div class="flex items-center justify-between">
          <div class="flex items-center">
            <input id="remember-me" name="remember-me" type="checkbox" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded" />
            <label for="remember-me" class="ml-2 block text-sm text-gray-900">
              Remember me
            </label>
          </div>

          <div class="text-sm">
            <a href="#" class="font-medium text-indigo-600 hover:text-indigo-500">
              Forgot your password?
            </a>
          </div>
        </div>

        <div>
          <button type="submit" class="group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
            <span class="absolute left-0 inset-y-0 flex items-center pl-3">
              <LockClosedIcon class="h-5 w-5 text-indigo-500 group-hover:text-indigo-400" aria-hidden="true" />
            </span>
            Sign in
          </button>
        </div>
      </form>
</template>

<script>
import { LockClosedIcon } from '@heroicons/vue/solid'

export default {
  components: {
    LockClosedIcon,
  },
}
</script>

Then I have a component called, AuthLayout.vue inside src/components

<template> 
  <div class="min-h-full flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
    <div class="max-w-md w-full space-y-8">
      <div>
        <router-view></router-view>
    </div>
  </div>
</template>

<script>
import { LockClosedIcon } from '@heroicons/vue/solid'

export default {
  components: {
    LockClosedIcon,
  },
}
</script>

Every time I tried to run my application, it kept giving me the following errors.

[plugin:vite:import-analysis] Failed to resolve import “../components/AuthtLayout.vue” from “srcrouterindex.js”. Does the file exist?

When I comment import AuthLayout from '../components/AuthtLayout.vue'; from the index.js application runs fine. But every time I try to enable it, it gives me an error.

I’m using tailwind CSS and Vue 3

how do i put a three.js animation between html tags

how do I put a three.js animation between html syntax? I am trying to put my three.js animation in between the header and the footer but I can’t I tried putting it in a canvas or a div but still not working (I am using a bootstrap template and a grid of cubes animation) here is the code:

Html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <nav class="navbar navbar-expand-lg bg-secondary text-uppercase fixed-top" id="mainNav">
        <div class="container">
            <a class="navbar-brand" href="#page-top">Teamseas</a>
            <button class="navbar-toggler text-uppercase font-weight-bold bg-primary text-white rounded" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
                    Menu
                    <i class="fas fa-bars"></i>
                </button>
                <div class="collapse navbar-collapse" id="navbarResponsive">
                    <ul class="navbar-nav ms-auto">
                        <li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" href="#portfolio">Portfolio</a></li>
                        <li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" href="#about">About</a></li>
                        <li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" href="#contact">Contact</a></li>
                    </ul>
                </div>
      </div>
    </nav>








  <script type="module" src="script.js">
  </script>
 <footer class="footer text-center">
  <div class="container">
      <div class="row">
          <!-- Footer Location-->
          <div class="col-lg-4 mb-5 mb-lg-0">
              <h4 class="text-uppercase mb-4">Location</h4>
              <p class="lead mb-0">
                  2215 John Daniel Drive
                  <br />
                  Clark, MO 65243
              </p>
          </div>
          <!-- Footer Social Icons-->
          <div class="col-lg-4 mb-5 mb-lg-0">
              <h4 class="text-uppercase mb-4">Around the Web</h4>
              <a class="btn btn-outline-light btn-social mx-1" href="#!"><i class="fab fa-fw fa-facebook-f"></i></a>
              <a class="btn btn-outline-light btn-social mx-1" href="#!"><i class="fab fa-fw fa-twitter"></i></a>
              <a class="btn btn-outline-light btn-social mx-1" href="#!"><i class="fab fa-fw fa-linkedin-in"></i></a>
              <a class="btn btn-outline-light btn-social mx-1" href="#!"><i class="fab fa-fw fa-dribbble"></i></a>
          </div>
          <!-- Footer About Text-->
          <div class="col-lg-4">
              <h4 class="text-uppercase mb-4">About Freelancer</h4>
              <p class="lead mb-0">
                  Freelance is a free to use, MIT licensed Bootstrap theme created by
                  <a href="http://startbootstrap.com">Start Bootstrap</a>
                  .
              </p>
          </div>
      </div>
  </div>
</footer>
<!-- Copyright Section-->
<div class="copyright py-4 text-center text-white">
  <div class="container"><small>Copyright &copy; Your Website 2021</small></div>
</div>
</body>
</html>

JavaScript

import * as THREE from "https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js";
import { OrbitControls } from "https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/controls/OrbitControls.js";
let s = prompt("g");
function animates(){ 
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
0.1,
1000
);
const controls = new OrbitControls(camera, renderer.domElement);

const grid = new THREE.Group();

const cubeSize = 0.5;
const size = Math.cbrt(s);
const gap = 0.01;

const geometry = new THREE.BoxBufferGeometry(
cubeSize,
cubeSize,
cubeSize
);
const material = new THREE.MeshNormalMaterial();
const cubes = new THREE.InstancedMesh(
geometry,
material,
Math.pow(size,3)
);

cubes.instanceMatrix.setUsage(THREE.DynamicDrawUsage);

grid.add(cubes);
scene.add(grid);

const cube = new THREE.Object3D();
const center = (size + gap * (size - 1)) * -0.5;

grid.position.set(center, center, center);
if(s <= 10000){
camera.position.z = 25;
}
else if (s <= 100000){
camera.position.z = 75;
}
else if (s <= 1000000){
    camera.position.z = 100;
    }
(function animate() {
requestAnimationFrame(animate);

let i = 0;
for (let x = 0; x < size; x++) {
for (let y = 0; y < size; y++) {
for (let z = 0; z < size; z++) {
  cube.position.set(x, y, z);
  cube.updateMatrix();
  cubes.setMatrixAt(i, cube.matrix);
  i++;

}
}
}
/*
grid.rotation.x+=0.003;
grid.rotation.y+=0.003;
grid.rotation.z+=0.003;
*/
cubes.instanceMatrix.needsUpdate = true;

controls.update();
renderer.render(scene, camera);
})();
animate();
}
animates();

How to play the song of on button click in wavesurfer

I’m trying to make a custom music player using Wavesurfer.JS. I have made a playlist with the play button in front of each song wave. The songs load at load time. Now, I want that when I click on the play button the song in front of that button should be played on the same div where it is already loaded as I have shown in the screenshot as I want to play the song

when i try to play it plays something like this: when i played the song
the HTML is as follows:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Player</title>
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
  <link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css"/>
  <link rel="stylesheet" type="text/css" href="css/render5.css">
</head>
<body>



<section class="player py-5">
  <div class="container mb-5">
    <div class="row">
      <h3 class="text-center text-danger"><i class="fa fa-music"></i> Custom Music Player</h3>
    </div>
  </div> 

  <div class="player-playlist">
    <div class="container">
      
      <div class="row border-bottom g-3  player-song-detail">
        <div class="col-md-1 col-2 my-auto text-center">
          <!-- play button -->
          <button href="songs/song1.mp3" class="songlink songBtn btn"><i class="fa fa-play fa-lg playbtn"></i></button>
          <input type="text" value="Song Title" placeholder="write song title here" hidden>
        </div>
        <div class="col-md-4 col-8 my-auto">

          <!-- song waves -->
          <div class="wavetest w-100"></div>

        </div>
        <div class="col-md-1 col-1 my-auto">
            <span id="songdur"></span>
        </div>
        <div class="col-md-3 song-desc">
          <p class="song-date">May 2020</p>
          <p class="m-0"> <span class="fw-bold">Gas carrier</span> - Maadi, man banging on gas tank and calling out, recorded from balcony</p>
        </div>        
      </div>


      <div class="row border-bottom g-3  player-song-detail">
        <div class="col-md-1 col-2 my-auto text-center">
          <button href="songs/song2.m4a" class="songlink songBtn btn"><i class="fa fa-play fa-lg playbtn"></i></button>
        </div>
        <div class="col-md-4 col-8 my-auto">
          <div class="wavetest w-100"></div>
        </div>
        <div class="col-sm-1 col-1 my-auto">
            <span id="songdur"></span>
        </div>
        <div class="col-md-3 song-desc">
          <p class="song-date">May 2020</p>
          <p class="m-0"> <span class="fw-bold" id="songName">Gas carrier</span> - Maadi, man banging on gas tank and calling out, recorded from balcony</p>
        </div>
        
      </div>


      <div class="row border-bottom g-3  player-song-detail">
        <div class="col-md-1 col-2 my-auto text-center">
          <button href="songs/song3.mp3" class="songlink songBtn btn"><i class="fa fa-play fa-lg playbtn"></i></button>
        </div>
        <div class="col-md-4 col-8 my-auto">
          <div class="wavetest w-100"></div>
        </div>
        <div class="col-sm-1 col-1 my-auto">
            <span id="songdur"></span>
        </div>
        <div class="col-md-3 song-desc">
          <p class="song-date">May 2020</p>
          <p class="m-0"> <span class="fw-bold" id="songName">Gas carrier</span> - Maadi, man banging on gas tank and calling out, recorded from balcony</p>
        </div> 
        
      </div>

    </div>
  </div>
</section>



<section class="bottom-player w-100">
  <div class="container">
    <div class="row">
      
      <div class="col-md-5 border-end border-secondary my-auto">
        <div class="play-menu">
          <button class="me-2 btn play-all" id="playAll"> Play All</button>
          <button class="me-2 btn paly-icon" id="preSong"> <i class="fa fa-step-backward"></i></button>
          <button class="me-2 btn paly-icon" id="pausePlay"><i class="fa fa-play"></i></button>
          <button class="me-2 btn paly-icon" id="nextSong"> <i class="fa fa-step-forward"></i></button>
          <button class="me-2 btn" id="volicon"><i class="fa fa-volume"></i></button>
          <input id="volume" type="range" min="0" max="1" value="1" step="0.1" class="me-2">
          <span class="me-2" id="current">0:00</span> /
          <span id="duration">0:00</span>
        </div>
      </div>

      <div class="col-md-7 my-auto">
        <span>Playing: <span id="songTitle"></span></span>
      </div>
    </div>
  </div>
</section>






  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
  <script src="https://unpkg.com/[email protected]/dist/wavesurfer.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</body>
</html>

JS code is as follows:

 //loading all songs in top list
  $(document).ready(function(){
    $('.player-playlist .player-song-detail').each(function () {
        const link = $(this).find('.songlink').attr("href");
        const waveContainer = $(this).find('.wavetest');
        const dur = $(this).find('#songdur');
        var wavesurfer = WaveSurfer.create({
          container: waveContainer[0],
          waveColor: '#CCCCCC',
          progressColor: '#E64C51',
          height:40,
          barWidth:2,
          barGap:2
        });
        wavesurfer.load(link); //generating wave for given song
         wavesurfer.on('ready', function () { 
          var timeCalculator = function (value) {  //changing the song duration in seconds and minutes
            second = Math.floor(value % 60);
            minute = Math.floor((value / 60) % 60);
            if (second < 10) {
                second = "0" + second;
            }
            return minute + ":" + second;
        };
        $(dur[0]).text(timeCalculator(wavesurfer.getDuration())); //printing the 
      }); 
        
    });
  }); //end loading 


$(".player-playlist .songlink").click(function(){
      $('#songTitle').text($(this).next().val()); 
          var songLink = $(this).attr('href');
          var wavesurfer = WaveSurfer.create({
                container: '.wavetest',
                waveColor: '#CCCCCC',
                progressColor: '#E64C51',
                barWidth:2,
                height:40,
                barGap:2,
                backgroundColor: 'transparent'
            });
          if (wavesurfer.isPlaying()) { //checking if already any song is playing
              wavesurfer.stop();
          }
          wavesurfer.load(songLink);
          wavesurfer.on('ready', function () {
          wavesurfer.play();
        //end volume

      });
          //stops on finishing the song
          wavesurfer.on('finish', function () {
          wavesurfer.stop();
        });

    }); //end top play button click

RegExp in JavaScript: include one Unicode group and exclude another one

I have to write some regexp. And I know where is a lot of variants. But I find the thing that I don’t understand, so I want to ask.

I had this regexp:
/^[p{Letter} -'`’–]+$/u
It has to allow Latin and symbols like Ü, Æ ect.

And it has bug – it allows also Ukrainian (Cyrillic) symbols “і Ї”.
So I want to add the rule “exclude Cyrillic”. But I don’t know how to do it.

I tried /^[p{Letter} -'`’–][^p{sc=Cyrillic}]+$/u; but the last part [^] means all except Cyrillic ((

Please, don’t say me to rewrite regexp. I just want to learn how can I write “exclude” rule.

Thanks)

How to make custom changes in trading view chart

So I am working on this trading view chart in which the data is coming from API and the attributes are Open, Close, Low, High, Volume, Time. The candles are being plotted on this data now I want to add bonus and dividend mark on each candle just like you can see in the image below.enter image description here
I have the dividend and the bonus data in my database. I want to display on my chart.

The code below is initializing the chart on the data from the API.

function initOnReady() {
                var widget = window.tvWidget = new TradingView.widget({
                    debug: true, // uncomment this line to see Library errors and warnings in the console
                    fullscreen: true,   
                    symbol: '<?php echo $stock_symbol; ?>',
                    interval: '1D',
                    container_id: "tv_chart_container",
                    timezone:"Asia/Ashkhabad",
                    has_intraday: 'true',
                    supports_marks: true,
                    supports_timescale_marks: true,
                    supports_group_request: false,
                    resolutions: ['1', '5', '15', '30', '60', '240', 'D', 'W', 'M', '6M', '12M'],
                    datafeed: new Datafeeds.UDFCompatibleDatafeed(api),
                    library_path: "charting_library/",
                    locale: getParameterByName('lang') || "en",

                    disabled_features: ["use_localstorage_for_settings"],
                    enabled_features: ["study_templates"],
                    charts_storage_url: "*"    ,  
                    charts_storage_api_version: "1.1",
                    client_id: '*',
                    user_id: '<?php echo $session_user_id; ?>',
                    theme: getParameterByName('theme'),
                });
            };

Map fuction on JSON object not working in ReactJS

I am using react with typescript. I have one external JSON file from which I am getting data to create elements on my front end. I have one button also when the user enables that button then only elements should create otherwise do nothing but my map function is not working.

Here is my code:

import Button from '../Button/Button';
import { useState } from 'react';
import Box from './Box';

const jsonObj = require("./Helpers/dataList.json");

type JsonData = {
    index: number,
    x: number,
    y: number,
    width: number,
    height: number,
  }
  
  type JData = {
    index: number,
    indexData: JsonData[]
  }

 const updateIndex = () => {
            let cIndex: number = ...;
            setCurrentIndex(cIndex);
        }
    }

const Test = () => {
    const [currentIndex, setCurrentIndex] = useState(0);
    const [boxFlag, setBoxFlag] = useState(false);
    const [boxText, setBoxText] = useState("Show Box");

    const showBoxes = () => {
        if(!boxFlag){
            setBoxText("Disable Box");
        }
        else{
            setBoxText("Show Box");
        }
        setBoxFlag(!boxFlag);
    }

  return <div className='container'>
        <div>
        {boxFlag &&
                jsonObj.map((x: JData) => {
                    if(currentIndex === x.index){
                        x.indexData.map((y: IData) => {
                            <Box x={y.x} y={y.y} height={y.height} width={y.width}/>
                        })
                    }
                })
        }
      </div>
          <Button name={boxText} onClick={showBoxes}/>
  </div>;
};

export default Test;

and my JSON file:

[
  { "index": 8, "x": 1141, "y": 582, "width": 238, "height": 268 },
  { "index": 8, "x": 265, "y": 572, "width": 291, "height": 317},
  { "index": 8, "x": 1665, "y": 491, "width": 266, "height": 323 }
 
]

cannot access the variable under same scope in javascript

I have written a code

(
      candidatesSubjectMapping,
      candidateIdsArray,
      emailHtmlTemplate,
      callback
    ) => {
      const EMAIL_BATCH_SIZE = 3;
      let counter = 0;
      let emailers = []
      let emailerPayload = {}

      for (let i = 0; i < candidateIdsArray.length; i++) {
        if (counter == EMAIL_BATCH_SIZE) {
          break;
        } else {
          const candidateId = candidateIdsArray[i];
          const candidateMissingSubjects =
            candidatesSubjectMapping[candidateId];

          candidateengagement.getCandidateInfo(candidateId, (err, result) => {
            if (err) callback(err);
            else {
              const candidateDetails = result[0];

              const seedResponse =  seedEmailers(
                candidateDetails,
                candidateMissingSubjects,
                emailHtmlTemplate
              );

              emailerPayload["replacements"] = seedResponse["replacements"]
              emailerPayload["emailObj"] = seedResponse["emailObj"]
        
              //   TODO : log activity
            }
          });

          console.log(emailerPayload);
          emailers.push(emailerPayload)

        //   emailers.push({ replacements: emailerPayload["replacements"],template:emailerPayload["emailObj"]});
          counter = counter + 1;
        }
      }
      callback(null,emailers);
    },

I am trying to access emailers array where I am pushing some payload ,the issue is here , I do not know what is happening here but emailers is always coming empty here and also the emailerPayload

Como alterar o value de um input sendo q ele ja recebe previamente um value vem de uma api?

Olá, estou com dificuldade para conseguir alterar o valor de dois inputs (especificamente). Esses dois inputs ja possuem um value que vem de uma api, porém vai ser necessário alterar esse valor também, como pode ser visto na imagem abaixo.

Como pode ser visto também eu possuo outros inputs na tabela. Aqui está o meu código:

<Table.Body>
                {tableSeparations.map((item: InfoInterface, index: number) => (<TableCellInput>
                            <InputField
                                    label=""
                                    name="volumeExpedido"
                                    value={item.volumeExpedido}
                                    onChange={(event) => handleChange(event, index)}
                                    type="number"/>

))}

Esse é so o input que recebe o valor 13, como está na imagem.

const handleChange = (event:any, index:any) => {   
    const {value, name} = event.target
    setValue({...value, [name]: value})
    console.log(value)
    };

E essa é a função que eu estou passando no onChange do input.

const [value, setValue] = useState({
    numeroDoTranporte: '',
    veiculo: '',
    volumeSeparado: '',
    volumeExpedido: ''
});

E esse é o estado que eu estou utilizando, eu desestruturei ele com o nome de cada input.
E ai eu nao to conseguindo alterar o valor do input, ele fica travado no 13. Alguém poderia me ajudar nisso? Ficarei mt grato, de verdade!!

How can i add Preset Ranges in MUI 5 date picker range

I am using MUI 5 date picker range my task is I need to add Preset Ranges in the place of the footer in the date range picker if any way we can do it so I need to add that in my MUI date picker if I click on that any range that date picker date will change accordingly

                ranges={{
                  Yesterday: [
                    moment().subtract(1, "day").startOf("day"),
                    moment().endOf("day"),
                  ],
                  Today: [
                    moment().startOf("day"),
                    moment().add(1, "day").endOf("day"),
                  ],
                  "Last Week": [
                    moment().subtract(1, "week").startOf("isoWeek"),
                    moment().subtract(1, "week").endOf("isoWeek"),
                  ],
                  "Last Month": [
                    moment().subtract(1, "month").startOf("month"),
                    moment().subtract(1, "month").endOf("month"),
                  ],
                  "This Month": [
                    moment().startOf("month"),
                    moment().endOf("month"),
                  ],
                  "Last Year": [
                    moment().subtract(1, "year").startOf("year"),
                    moment().subtract(1, "year").endOf("year"),
                  ],
                  "This Year": [
                    moment().startOf("year"),
                    moment().endOf("year"),
                  ],
                }}
export default function BasicDateRangePicker() {
  const [value, setValue] = React.useState([null, null]);

  return (
    <LocalizationProvider dateAdapter={AdapterDateFns}>
      <DateRangePicker
        startText="Check-in"
        endText="Check-out"
        value={value}
        onChange={(newValue) => {
          setValue(newValue);
        }}
        renderInput={(startProps, endProps) => (
          <React.Fragment>
            <TextField {...startProps} />
            <Box sx={{ mx: 2 }}> to </Box>
            <TextField {...endProps} />
          </React.Fragment>
        )}
      />
    </LocalizationProvider>
  );
}

I need like this
See image need output like this

CodeSandBox Link