Dexie js Changable tables

I am using Dexie.js as a wrapper for my IndexedDB local database.
I have a list of tables that i am getting from my server, each table is also contains its own schema and then i am creating the IndexedDB tables according to this info.

I am trying to achieve the following behaivior:

  1. hold DB version in configurable file
  2. first time the browser opens, get all the tables info and create them with Dexie
  3. save all the data
  4. next time the application opens – check if the version changed, if it did – fetch the tables info again and upgdrade the db, if not – just open the DB.

so 1-3 works perfectly, my problem is:
if the version DID NOT change, i dont want to fecth the data again, but Dexie wont let me access any of the stores if im not passing them before open.

is there any way to solve it without saving the entire tables schemas in localStorage ?

Getting a red squiglly line under the first cards[0], I dont know what is causing it

this is minimal js, everything else is commented. I cannot understand why “cards[i]”(first one in the for loop) has a red squiggly line under it, I cannot run any console commands. Please help!

    let cards=document.querySelectorAll(".blocks");
    let pic,card,rand;
    let finals = [];
    const count = 10; 
    const max = 9;
    
    for(let k = 0; k < 1000; k++){
      rand = Math.round(Math.random() * max);
    //   !finals.includes(rand) && finals.push(rand)
      if(!finals.includes(rand))
      finals.push(rand);
    }
    finals = finals.slice(0, count)
    setupCards(finals);
    
    function setupCards(arr){
        
        for(let i=0;i<=arr.length;i++){
    ====>cards[i].style.backgroundImage=`url(images/${arr[i]}.jpg)`;
        // cards[i].style.transform="rotateY(180deg)";
        // cards[i].style.backgroundImage="url(images/back6.jpg)";             
     }
}

How to integrate Php array to Javascript Using Ajax

I am working on ajax and php,I want to use Php array in javascript,But right not unable to integrate Php array to javascript,
Here is my Controller code where i am getting Php array as json(Using Json encode)

function GetFollowingCoinUsers()
        {
            $CoinId=$_POST['coin_id'];
            $result = $this->M_main->GetAllCoinFollower($CoinId);
            $UserId=array();
            foreach($result as $res)
            {
                $UserId[]=$res['UserId'];
            }
            echo json_encode($UserId);
        }

Above code give me result in following way

["463","500","505"]

And i am trying to use this array in Javascript/Ajax Response

$.ajax({
            type: "post",
            url:'<?php echo base_url();?>Main/GetFollowingCoinUsers',
            data: {coin_id:coin_id},
            success: function (datan) {
                    var cars = datan;
                    let text = "";
                    for (let i = 0; i < cars.length; i++) {
                      text += cars[i] + "<br>";
                    }
                    alert(text);
                    
            }
        });

Add new option to a select from select2 matcher

The problem: I need to add new option with data from api when there is no results in matcher.
Is it possible to add a new option from matcher function in select2 library?
When I use

var option = new Option("text", "id");
$("#id").append(option);
$("#id").trigger("change");

in matcher function, it adds a new option but only on the next input event.

Model.mongoose.findeOne change to Model.monooose.updateOne

need help. I have this code

import timeConvert from "./timezone.js";

const time = async (chatId, time) => {
  const availableUser = await User.findOne({ chatId: chatId });
  const { latitude, longitude } = availableUser.location;
  if (availableUser) {
    availableUser.time = timeConvert(time, latitude, longitude);
    return await availableUser.save();
  }
};

export default time;

and need to change User.findOne to User.updateOne without change any logic. I mean this code wirking but need to use User.updateOne. I know syntax of updateOne but I dont know how update timeConvert with legal way

localhost:3000 continuously loading in react app

I am running a website on react localhost:3000 but I can’t do anything on the page as it’s continuously loading while starting the localhost. Also before starting localhost I get a message on the terminal

'Browserlist:caniuse-lite is outdated. Please run:npx browserslist@latest --update-db

Expand and Collapse of 4 level hierarchical rows in html table

I have some hierarchical data in a table structure as so: (example 1)

A

A.1

A.1.1 

A.1.2

   A.1.2.3

A.2

A.2.1

A.2.2

  A.2.2.3

I would like to be able to expand and collapse within each level, so example, If I click on A.2, it’s children should collapse: (example 2)

A

A.1

A.1.1 

A.1.2 

   A.1.2.3

A.2

B

B.1

B.1.1

B.1.2

B.2

B.2.1

B.2.2

And if I click A, all of its children should collapse: (example 3)

A

B

B.1

B.1.1

B.1.2

B.2

B.2.1

B.2.2

and if I expand A again, A.2 should still remain collapsed (children hidden) (example 4)

A

A.1

A.1.1 

A.1.2 

A.2

B

B.1

B.1.1

B.1.2

B.2

B.2.1

B.2.2

I have tried this code:

toggleElement = function(context) {
      let current = context.parentElement
      if (current.className == 'level1') {
        toggleLevel1(current)
      } else if (current.className == 'level2') {
        toggleLevel2(current)
      }
    };

    toggleLevel1 = function(current) {
      let nextSibling = current.nextElementSibling;

      while (nextSibling && nextSibling.className == 'level2') {
        nextSibling.hidden = nextSibling.hidden ? false : true
        nextSibling = nextSibling.nextElementSibling
        while (nextSibling && nextSibling.className == 'level3') {
          if (!nextSibling.hidden) {
            nextSibling.hidden = nextSibling.hidden ? false : true
          }
          nextSibling = nextSibling.nextElementSibling
        }
      }
    };

    toggleLevel2 = function(current) {
      let nextSibling = current.nextElementSibling;

      while (nextSibling && nextSibling.className == 'level3') {
        nextSibling.hidden = nextSibling.hidden ? false : true
        nextSibling = nextSibling.nextElementSibling
      }
    };
B.2.2

the problem is that it is limited to 3 level of data and i have 4 levels.

Can anyone help?

Thanks in advance.

React.js – app works when running from npm start, but won’t build

I’m new to React.js and was unsure why my app won’t build properly. I’ve tried adding/removing .catch() after my async statements but it doesn’t seem to make any difference.

OS: Windows 10
React: 17.0.2

The compilation message (it just stays there):
error message

import {useState} from 'react' 

const Form = () => {
    const [text, setText] = useState('')
    const [data, setData] = useState('')

    const fetchData = async() => {
        const res = await fetch("https://avwx.rest/api/metar/" + text, 
            {headers : {"Authorization": "key"}})
            .catch((error) => {return Promise.reject()})
        const rawJSON = await res.json().catch((error) => {return Promise.reject()})
        console.log(rawJSON)
        setData(rawJSON)
    }
    
    const onSubmit = (e) => {
        e.preventDefault()
        if (text.length !== 4) {
            alert("Input valid ICAO airport code")
            return
        }
        
        fetchData()
        setText('')
    }
    
    return (
        <form onSubmit = {onSubmit}>
          <div className = "lbl">
            <label>
              Airport Code (ICAO): {' '}
            </label>
          </div>
          <input type="text" value={text} onChange={(e) => setText(e.target.value)}/>     
          <input className = 'btn' type="submit" value="Go" />
          <p className = "data">{JSON.stringify(data.raw, null, 2)}</p>
        </form> 
    )
}

export default Form

How to remove the default meta descriptions for blog posts on a Wix.pl

Does anyone know how to remove the default meta descriptions for blog posts on a Wix.pl website builder? Currently, meta descriptions takes 500 characters from the content of a post.

I tried from the Wix.pl panel, but the default settings automatically come back when trying to change. I also tried to remove meta descriptions with a JavaScript, but it failed.

Thank you in advance for your response.

How can I filter an object based on value passed

I will love to filter an object array based on value passed and return a modified array.

for example:

let sample = [
      {
        "lyzjmpkvbtocygakcoxu": {
          "hour": "12",
          "bdlmynfythqgyzrhruhw_add_date": "December 03, 2021",
        },
        "eueuuzvkteliefbnwlii": {
          "hour": "05",
          "brtmypzvuooqhvqugjbj_add_date": "December 02, 2021",
        },
         "eueuuzvkteliefbnwlii": {
          "hour": "08",
          "brtmypzvuooqhvqugjbj_add_date": "December 02, 2021",
        }
      }
    ]

I will love to get this modified array when “December 02, 2021” is passed :

          [
            {
              "hour": "05",
              "brtmypzvuooqhvqugjbj_add_date": "December 02, 2021",
            },
            {
              "hour": "08",
              "brtmypzvuooqhvqugjbj_add_date": "December 02, 2021",
            }
          ]

This is what I have currently but I guess I am still far away:

const result = sample.map((x) => {
        if (x.includes('December 02, 2021')) {
          return x;
        }})

Is possible to make function from code and make it shorter?

I have this lines of code

let value = productDetails.recentPurchaseDate;
if (!productDetails.salesPrice && !productDetails.recentPurchaseDate) {
  value = false;
}
if (!productDetails.presentEstimatedValue) {
  value = true;
}

Is it possible to refactor, I need to make it function and this two IF? Thanks in advance

When in tried to logging in its login in and showing undefine array key username [duplicate]

'''
welcome.php

<?php

session_start();

if(!isset($_SESSION['loggedin']) || $_SESSION['loggedin']!=true){
    header("location: login.php");
    exit;
}

?>
<!doctype html>[enter image description here][1]
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

    <title>Welcome - <?php $_SESSION['username']?></title>
  </head>
  <body>
    <?php require 'partial/nav.php' ?>
    
    <div class="container my-3">
    <div class="alert alert-success" role="alert">
      <h4 class="alert-heading"><?php $_SESSION['username']?></h4>
      <p>Hey how are you doing? Welcome to iSecure. You are logged in as <?php /*echo $_SESSION['username']*/?>. Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.</p>
      <hr>
      <p class="mb-0">Whenever you need to, be sure to logout <a href="/loginsys/logout.php"> using this link.</a></p>
    </div>
  </div>
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
  </body>
</html>

login.php

<?php

$Error = false;
$login= false;
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
include 'partial/dbconnect.php';
$username =$_POST['username'];
$password =$_POST['password'];
$exist =false;

//$sql = "Select * from users where username='$username' and  password='$password'";
$sql = "Select * from users where username='$username'";
$result = mysqli_query($conn,$sql);
$num = mysqli_num_rows($result);
  if($num == 1)
                  {
                    while($row = mysqli_fetch_assoc($result))
                    {
                      if(password_verify($password,$row['password']))//password entered and hash pass present 
                     {//in database:
                      $login = true;
                      session_start();
                      $_SESSION['loggedin'] =true;
                      $_SESSION['$username']  = $username;
                      header("location: welcome.php");}//for redirection}
                    
                    else
                    {
                      $Error = "invalid credentials ";
                    }

                }}
else 
{
  $Error = "invalid credentials ";
}}
?>
<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

    <title>LOGIN</title>
  </head>
  <body>
    <?php require 'partial/nav.php'; ?>
    <?php
if($login)  {
                    echo  '<div class="alert alert-success alert-dismissible fade show" role="alert">
                    <strong></strong>you are logged in 
                    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                    </div>';
                }
if($Error)  
{
                    echo  '<div class="alert alert-danger alert-dismissible fade show" role="alert">
                    <strong>sorry :( </strong>'.$Error.'
                    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                    </div>';
}
?>
<div class="container">
<h1 class= "text-center mt-3"></h1><h1 class = "text-center mt-2"> login Here</h1>
<!-- <div class="container center"> -->
<form action="/loginsys/login.php" method="post" style ="
    display: flex;
    flex-direction: column;
    align-items: center;"
>
  <div class="form-group col-md-6">
    <label for="username" class="form-label">username</label>
    <input type="text" class="form-control" id="username" name = "username" aria-describedby="emailHelp">
  </div>

  <div class="form-group col-md-6">
    <label for="password" class="form-label mt-2">Password</label>
    <input type="password" class="form-control" id="password" name = "password">
  </div>

  <button type="submit" class="btn btn-primary mt-3">Login</button>
</form>
<!-- </div> -->

</div>
    <!-- Optional JavaScript; choose one of the two! -->

    <!-- Option 1: Bootstrap Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

    <!-- Option 2: Separate Popper and Bootstrap JS -->

    <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>

  </body>
</html>

'''
please open this link 

  [1]: https://i.stack.imgur.com/fOzzc.png

while i am logging in it showing it login and showing undefine array key username

Warning: Undefined array key “username” in C:xampphtdocsloginsyswelcome.php on line 28
Hey how are you doing? Welcome You are logged in as . Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.

please help me to find where is problem
is there any session problem

Invalid date provided: Invalid Date

I got the following error
form.min.js:1 Error: Invalid date provided: Invalid Date
at Object.parseDate (form.min.js:1)

And I am using the flatpickr to pick the date in the input field.

If anyone has the solution please share it with me.

Thanks in Advance.