Reset Stack Navigators is nested inside Drawer Navigator

First of all, I would like to present My Navigation State:

■ RootStack (Stack)
   ▪ MainDrawer (Drawer)
      ▪ ServicesNavigator (Stack)
      ▪ TurnTrackingNavigator (Stack)
      ▪ EmployeesNavigator (Stack)

in ServicesNavigator, I build the App with ServicesStack –> ServiceDetails Screen.
enter image description here

*I press the Services of MainDrawer it navigate ServicesStack, When my App to ServiceDetails Screen, I right away use the Drawer to go to another Stack (ex: EmployeesNavigator), and then I press the Services in Drawer to back ServicesScreen.
But it native Stack ServiceDetails (that Stack stored), what I need is ServicesStack.

I want to ask how can when I click Drawer it resets the stack or what way to resolve.

Randomly show max 3 blocks per page

I have several blocks in the form of circles.

I made it so that when you click on the block, it dissolves. But if you dissolve all the blocks, the page will remain empty.

How can I make it so that there are a maximum of 3 blocks on the page, which are selected randomly? Also, the page is never blank.

To select 3 random I use

var randomnumber = Math.floor(Math.random()*10) + 1;
var circle1 = $('#circle' + randomnumber);
var circle2 = $('#circle' + randomnumber);
var circle3 = $('#circle' + randomnumber);

But I can’t hide everything and still show 3 selected ones. In addition, when we clicked on one of them and it disappeared, a new one should appear in its place

I tried to style all blocks visibility: hidden; and in the script like this var circle1 = $('#circle' + randomnumber).css('visibility', 'visible'); but in the end nothing comes up.

$("div").click(function() {
  $(this).fadeOut("slow");
});

const nodes = document.querySelectorAll('.animation');
for(let i = 0; i < nodes.length; i++) {
  nodes[i].addEventListener('click', (event) => {
    event.target.style.animation = 'Animation 200ms linear';
    setTimeout(() => {
      event.target.style.animation = '';
    }, 220);  });
}
.circle1 {
  background: #456BD9;
  clip-path: circle(50%);
  height: 50px;
  width: 50px;
  margin: 20px;
}

.circle2 {
  background: #fb6df9;
  clip-path: circle(50%);
  height: 50px;
  width: 50px;
  margin: 20px;
}

.circle3 {
  background: #6de2fb;
  clip-path: circle(50%);
  height: 50px;
  width: 50px;
  margin: 20px;
}

.circle4 {
  background: #81fb6d;
  clip-path: circle(50%);
  height: 50px;
  width: 50px;
  margin: 20px;
}

.circle5 {
  background: #e9fb6d;
  clip-path: circle(50%);
  height: 50px;
  width: 50px;
  margin: 20px;
}

.circle6 {
  background: #6bfc90;
  clip-path: circle(50%);
  height: 50px;
  width: 50px;
  margin: 20px;
}

.circle7 {
  background: #a5950a;
  clip-path: circle(50%);
  height: 50px;
  width: 50px;
  margin: 20px;
}

.circle8 {
  background: #a50a74;
  clip-path: circle(50%);
  height: 50px;
  width: 50px;
  margin: 20px;
}

.circle9 {
  background: #ff0c00;
  clip-path: circle(50%);
  height: 50px;
  width: 50px;
  margin: 20px;
}

.circle10 {
  background: #06aec2;
  clip-path: circle(50%);
  height: 50px;
  width: 50px;
  margin: 20px;
}

@keyframes Animation {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(.8);
  }
  100% {
    transform: scale(1);
  }
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div class="circle1 animation"></div>
<div class="circle2 animation"></div>
<div class="circle3 animation"></div>
<div class="circle4 animation"></div>
<div class="circle5 animation"></div>
<div class="circle6 animation"></div>
<div class="circle7 animation"></div>
<div class="circle8 animation"></div>
<div class="circle9 animation"></div>
<div class="circle10 animation"></div>

How to generate true randomness in JavaScript

How to generate true randomness in JavaScript

I’ve been wondering on this question for a little while now, and I don’t have like a reason to know this, I am just curious.

So we all know the Math.random() function in JavaScript. But this is not the answer, because I want to know how to generate a random number without this function, just pure randomness.

So, if you know an answer, please let me know.

Pass variable from function js to other function js

I’m trying to pass and hold the value of store so that everytime user selects a different day, the value of store remains the same.

store and day chart

At first, I managed to show the result when I chose the store and the day values. However, when I changed to a different day, it doesn’t hold the store value.

function changestore(){
      var filterstoregen = document.getElementById("filterstoregen").value;
      return filterstoregen;
      window.location.href='/new-retail/visitorreport?storename_='+filterstoregen;
 }


function changeday(){
      var storename2 = changestore();
      var filterday = document.getElementById("filterday").value;
      window.location.href='/new-retail/visitorreport?storename_='+storename2+'&dayname='+filterday;
 }

If I want to see the results of a different day, I need to choose again the store value first. This is because the chart becomes blank as if the store value is not selected.

Note that the functions written in the same file which is visitorreport.php.

Hopefully I have provided enough information to get some help. Thanks in advance.

Selenium with user interaction

I have a project in which selfie will automatically be clicked by detecting the face in the frame. There is no click button to take the selfie.
Now what i need to do is to automate the whole process using selenium(in python). So is there any way we can pass the data to that capture?

Or is there any other way i can achieve this?

How to store images in database?

I’m working on a platform using HTML, Javascript, SQL, Ajax and PHP.
The platform asks for a pictures and those pictures will have to be displayed later.
I’ve seen people saying that you shouldn’t store them in a database if they’re a lot, but just storing the path doesn’t seem like it would work because that would mean that the user could never change the pictures to another folder or delete them, right? And that wouldn’t work for what I want.
Does anyone have any suggestions on what I should do?

Javascript Array Foreach Callback Function With Recursion Push Values

I’ve been following this awesome solution. However for some reason on this block of code:

nodes.forEach(function(e){
    if(e.parent === currentNodeId){
        e = addChildrenToNode(e);
        node.children.push(e);
    }
});

The forEach callback function “e” param results to null instead of pushing the whole object into the node.children array. In order for me to get the actual values, I’ve manually set the values instead of using the “e” which will be the whole object e.g.:

node.children.push({ _id: e._id, name: e.name });

However, I’m not able to convert this line:

e = addChildrenToNode(e);

To do the recursion and append the children. I’m thinking that this is due to the old version of JS that we’re using on the server without the ES6 functionalities? Need your inputs. Thank you very much!

MongoDB TTL index never deletes records

I created an index as shown below and added a createdAt field to each new record added to the db. The records should be auto-deleted after 24 hours however I have waited days and nothing has been deleted.

db_connect.collection("records").createIndex( { "createdAt": 1 }, { expireAfterSeconds: 3600 } )

Adding record to the database

// Add info to db to search
    console.log("Adding info to database..");
    const otherAddress = e.target.address.value;
    const newRecord = {
        holderAddress: this.props.account,
        otherAddress: otherAddress,
        date: new Date(),
        data: encryptedData
    }
    await fetch("http://localhost:420/record/add", {
        method: "POST",
        headers: {
            "Content-Type": "application/json",
        },
        body: JSON.stringify(newRecord),
    }).catch(error => {
        window.alert(error);
    });

Endpoint it calls:

recordRoutes.route("/record/add").post(function (req, response) {
let db_connect = dbo.getDb();
let myobj = {
    holderAddress: req.body.holderAddress,
    otherAddress: req.body.otherAddress,
    data: req.body.data,
    createdAt: req.body.date
};
db_connect.collection("records").insertOne(myobj, function (err, res) {
    if (err) throw err;
    response.json(res);
});

Below is a screenshot from MongoDB website confirming there is an index..

enter image description here

Any help is greatly appreciated!

Javascript for loading a large number of facebook activity log comments rather than manually scrolling?

A script for deleting a number comments at once from facebook posts has worked as follows:

  • fb.com > Account > Settings & privacy > Activty log > Comments
  • Function F12 > Console
  • Copy and paste to the console:

.

setInterval(() => {
    for (const Button of document.querySelectorAll('div[aria-label="Action options"]')) {
        Button.click();
        document.querySelector('div[role="menuitem"]').click()
    }
}, 1000)

It processes (deletes) the comments that have been loaded on the screen. By scrolling down, the page loads and displays more comments. Without having to manually do this scrolling to load more, is there a away to load many screens worth?

How do I pass a .js variable to HTML input

I have been looking for a way to pass a js function to a HTML input. Is there any easy way to do that or my approach is wrong?

    <script>
            const input = window.location.search
            const clientID = input.split('?clientID=').pop()
   </script>

    <form action="" method="POST">
        <input type="submit">
    </form>

Opening a json file with javascript

I am trying to open a json file in javascript,

function test() {
  
    const jsonData= require('logins.json'); 

    alert(jsonData)
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>test</title>
  <script defer src="test.js"></script>
</head>

<body>
  
</body>
    <button onclick="test()">test</button>
</html>

this is not working and logins.json is a thing, this is what is in it:


{

"Students":[
    {
        "username":"test",
        "password":"testi"    }
  ]
 }

any help is great, do I need to use Ajax or is it a silly mistake? I am new to javascript.

webpack asset resource not included for each import

in the context of aws lambda functions i currenlty need to access certain files in their runtime, for this i included this function below which will put a file that i import into the same folder importing the file.

const resolveWsdlInCurrentRuntime: Configuration['output']['assetModuleFilename'] = (pathData) => {
    return join(dirname(pathData.runtime.toString()), '[path]', '[base]');
}

// ... Webpack config ...
  module: {
    rules: [
      { test: /.ts$/, loader: 'ts-loader', options: {transpileOnly: true} },
      {
        test: /.(wsdl|xml)$/,
        type: 'asset/resource',
        generator: {
          filename: resolveWsdlInCurrentRuntime,
        },
      }
    ],
  },
  resolve: {
    extensions: ['.js', '.ts'],
    alias: {
      wsdl: resolve(__dirname, 'wsdl'),
    },
  },
// ...

so when import like below it automaticaly puts the file in the same folder and i can access it

import 'wsdl/some.wsdl'

the problem i encounter now however is that when i do the import import 'wsdl/some.wsdl' in two separate files the file will only be included in one of their outputs. Instead i would like for the file to be included each time i import it in a specific runtime.

does anyone have any idea how i can achieve this?

Is there a way to disable color mixing/overlapping in html canvas

I have a canvas and when i draw 2 things overlapping with low opacity, the opacity gets higher in the part where they are overlapping. Is there a way to make it all the same opacity even if 2 things are overlapping.

const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");

canvas.width = window.innerWidth;
canvas.height = window.innerHeight;

ctx.fillStyle = "rgba(0, 0, 255, 0.2)";

ctx.fillRect(10, 10, 50, 50);
ctx.fillRect(20, 20, 50, 60);
ctx.fillRect(40, 5, 50, 40)
canvas {
  width: 100vw;
  height: 100vh;
}
<p>all of it should be the same color but the overlapping parts are darker</p>
<canvas id="canvas"></canvas>

How to persist resultset in Snowflake Stored Procedure written in Javascript?

I have a stored procedure that runs a sql command then it is run multiple times to call it multiple times. Is there a way to persist the resultSet so as not to run the snowflake query multiple times?

Currently

var my_sql_query = ` select * from table`;
var results = snowflake.execute({sqlText: my_sql_query});


while (results.next())
{
     script += results.getColumnValue(1);
}

... other script additions ...

// Second Run of the same script
var results = snowflake.execute({sqlText: my_sql_query});
while (results.next())
{
     script += results.getColumnValue(1);
}

Desired Output (as best as I can describe)

var my_sql_query = ` select * from table`;
var results = snowflake.execute({sqlText: my_sql_query});


while (results.next())
{
     script += results.getColumnValue(1);
}


// Second Run of the same script
while (results.next())
{
     script += results.getColumnValue(1);
}

How to speed up clock of browser

I want to speed up time in the browser without interfering local clock.

I’ve found an userscript that does exactly this (https://github.com/canguser/hooker-js/blob/master/src/plugins/timer-hooker/timeHooker.js)
But, I’m having trouble understanding it (I have a moderate understanding of js).

It’d be nice if anyone could explain the specific code responsible for speeding up the browser clock (The user script is large and most of it responsible for UI, which I’m not interested in).

I’d appreciate code snippets to run on the browser console to test the effects.

Test site: https://www.timeanddate.com/timer/