How to display text when hover over videos/images

My image and videos are blurred whenever they are hovered over. Now, I also want them to both blur and display text whenever I hover over. I have tried to use hover for both but only the blur part is applicable so far. I also want the text to be able to resize accordingly with the video box so that when scaling down, it will resize accordingly. Thank you very much !

Code so far:

html{
    margin:0;
    padding: 0;
    font-size:62.5%;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-font-smoothing: grayscale;
}

*{
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}

.header{
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1rem;
    z-index: 100;
}

.wrapper1{
    display:flex;
    flex-direction: row;
    justify-content: flex-start | center | flex-end;
    margin: 0;
    height: 100%;
    width:100%;
}

h4{
    display:block;
    font-size: 1.5em;
    margin-block-start: 0.83em;
    margin-block-end: 0.83em;
    margin-inline-start: 0px;
    margin-inline-end: 0px;
    font-family: 'Roboto Mono', monospace;
    z-index:50;
}

.type2{
    text-align: left;
    margin-left: 10rem;
    margin-right: 10rem;
    animation: fadein 2s;
    -moz-animation: fadein 2s; /* Firefox */
    -webkit-animation: fadein 2s; /* Safari and Chrome */
    -o-animation: fadein 2s; /* Opera */
}

@keyframes fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Firefox < 16 */
@-moz-keyframes fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Safari, Chrome and Opera > 12.1 */
@-webkit-keyframes fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Internet Explorer */
@-ms-keyframes fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Opera < 12.1 */
@-o-keyframes fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}

body{
    margin:0;
    padding: 0;
    width: 100%;
}

.main{
    padding:0;
    margin:0;
}

.wrapper{
    overflow-y:hidden;
    overflow-x:auto;
    margin: 0;
    height: 100%;
    width:100%;
}









@media only screen and (max-width: 1000px){
    .type2{
       display: none;
    }

    .type1{
        font-size: 24px;
    }
}


video{
    display: block;
    margin-bottom: 1em;
    object-fit: contain;
}

.main-section{
    display:flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 0;
    margin: 0;
    top: 25%;

}

.main-section div{
    flex:1;
}



.vid_vertical{
    position: absolute;
    height: auto;
    width: 20%;
}

.vid_1{
    position: absolute;
    left: 25.5%;

    z-index: 1;

}

.vid_1:hover {
    filter:blur(10px);
}

.type_ins: hover{
    display: block;
}



.type_ins{
    font-size: 0.7vw;
    position: absolute;
    left: 30%;
    z-index: 50 !important;
    text-align: center;
    display: none;    
}
.vid_2{
    positon: absolute;
    left: 50% ;
    z-index:2;
}

.vid_3{
    positon: absolute;
    left: 148%  ;
    z-index:3;

}

.vid_4{
    positon: absolute;
    left: 74%  ;
    z-index:3;

}

.vid_5{
    positon: absolute;
    left: 98%  ;
    z-index:3;

}

.vid_6{
    positon: absolute;
    left: 122.5%  ;
    z-index:3;

}


.img1{
    position: absolute;
    height: auto;
    width: 20%;
    left: 0;
    z-index:0;
}
<html>
    <head>
        <meta name="viewport" content="user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1,width=device-width">        
        <meta charset="utf-8">
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <meta charset="utf-8">
        <link rel="stylesheet" href="Interactive story.css">
        <title>Interactive Storytelling</title>
       
    </head>

    <body>
      
        <div class="main">
            <div class="header">
                <div class="wrapper1">
                    <div class="type1">
                        <h4>2019</h4>
                    </div>
                    <div class="type2">
                         <h4>I came to Toronto in August 2018 so we (me and my friend)
                            adopted Hershey when we were still in our first year. <br>
                            Before adopting Hershey, we nearly got scammed by buying a dog with a cheaper price so we decided to adopt rather than buying.<br>
                            She was actually our second choice, the first one having a lot of medical issues so we had to move on.<br>
                            I think she chose us actually because of all the people who wanted her, we were the only one whom she didn't hiss at. </h4>


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


        <section>
            <div class="wrapper">
                
                <div class="main-section">
          
                   
                  
                    <video class="vid_vertical vid_1" autoplay loop muted preload playsinline>
                        <source src="IMG_1362.mp4" type="video/mp4">    
                    </video>

             

                
                    <video class="vid_vertical vid_2"  autoplay loop muted preload playsinline>
                        <source src="IMG_1364.mp4" type="video/mp4">
                    </video>

                    <video class="vid_vertical vid_3"  autoplay loop muted preload playsinline>
                        <source src="IMG_1832.mp4" type="video/mp4">
                    </video>
                    
                    <video class="vid_vertical vid_4"  autoplay loop muted preload playsinline>
                        <source src="1080p.mp4" type="video/mp4">
                    </video>

                    <video class="vid_vertical vid_5"  autoplay loop muted preload playsinline>
                        <source src="IMG_1381.mp4" type="video/mp4">
                    </video>

                    <video class="vid_vertical vid_6"  autoplay loop muted preload playsinline>
                        <source src="IMG_1391.mp4" type="video/mp4">
                    </video>






                    <img src="IMG_1275_2.jpg" class="img1">

                </div>
            </div>

        </section>
        
        </div>  

       
              

        <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
        <script src="Interactive story.js"></script>

        <!-- <section>
            <div class="wrapper">
                <div class="vid">
                    <iframe id="vid_vertical" class="vid_2" autoplay loop muted preload playsinline>
                        <source src="IMG_1363.MOV" type="video/mp4">
                    </iframe>
                </div>
            </div>
        </section> -->


    </body>

Pushing items into array not working inside of jquery POST [duplicate]

my post was just deleted and they linked AJAX asynchronosity which didn’t help at all and is completely unrelated to my problem.

My problem is that I cannot push ITEMS, into my array using .push when it’s inside of a POST and not ajax…

CODE:

var rolearray = [];
$.post(
  "https://URL/getRoleData", 
  JSON.stringify({ businessid: $(this).data('businessid') }), 
  function(roles){
    $(roles).each(function(e) {
      rolearray.push({label: roles[e].role, value: roles[e].role})
    })
  }
)

This time please don’t just dismiss it. Cause the thread linked didn’t help.

Also yes the post is returning data.. For each is working as intended but it won’t push my values after it’s returned the result.

Timestamp field from firestore showing an invalid date if the field does not exist

These are my codes. selectedDate is a timestamp field:

<ListItemText
                          primary={
                            new Date(
                              user.items?.selectedDate?.seconds * 1000
                            ).toDateString() +
                            " at " +
                            new Date(
                              user.items?.selectedDate?.seconds * 1000
                            ).toLocaleTimeString()
                          }
                    />

It does show the data correctly. However, if the selectedDate does exist, it will show:

Invalid date at Invalid date

How can I fix this?

Is there a way to find only unused JSDoc type definitions?

For example:

/**
 * A number, or a string containing a number.
 * @typedef {(number|string)} NumberLike
 *
 * Dummy type
 * @typedef {(string|null)} StringLike
 */

/**
 * Set the magic number.
 * @param {NumberLike} x - The magic number.
 */
function setMagicNumber(x) {
}

As you can see NumberLike is used, but the StringLike type is not used and I’d like to find all such unused type definitions on our project. It’s a Nodejs project with typescript installed.

Here’s our tsconfig.json file:

{
  "compilerOptions": {
    "baseUrl": ".",
    "jsx": "react",
    "allowJs": true,
    "checkJs": true,
    "target": "ESNext",
    "noEmit": true,
    "moduleResolution": "node",
    "isolatedModules": true,
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "strictNullChecks": true,
  },
}

How can I filter these JSON data where it check if category 1 and 2 is true and that the selectedDate exist?

I have this sample JSON data:

[
  {
    category: {
      selectedDate: { seconds: 1639903368, nanoseconds: 392000000 },
      category1: true,
      category2: true
    },
    name: "Sample 1"
  }
];

There are some cases where category1 and category2 are true, but the selectedDate is not present there. So how can I filter these where category 1 and category 2 are true and that the selectedDate exist?

These are my codes, however, this would not filter correctly.

 const filter = users.filter(
    (f) =>
      f.choices.category1 == true &&
      f.choices?.category2 == true &&
      f.choices?.selectedDate !== null
  );

  console.log(booster);

In Adobe Illustrator, How to change white color of Edittext to transparent with javascript when it is active

enter image description here

I want to change white color to transparent when the edittext is active.
Please help me.

w.alignChildren = ["fill","fill"];
w.preferredSize = [150, 250];
w.inputBox = w.add('panel', undefined, "Input Box");

w.inputBox.add('statictext{text: "Height: "}');

var heightInput = w.inputBox.add('edittext {characters: 12, active: true}');

w.inputBox.add('statictext{text: "Width: "}');

var widthInput = w.inputBox.add('edittext {characters: 12, active: false}');

w.inputBox.add('statictext{text: "Spine: "}');

var spineInput = w.inputBox.add('edittext {characters: 12, active: false}');

w.inputBox.add('statictext{text: "Joint: "}');

var jointInput = w.inputBox.add('edittext {characters: 12, active: false}');

var okBtn = w.add("button", undefined, "Draw");

How to add more objects to an array of objects continuing the numbering but not start over?

I have this minor issue but I’m so close.

I have a Array of Objects with 100 OBJECTS in it. [0-99]

I want to add another 100 or more objects to the end of the current object 99.

What I’m getting is [0-99], 100: [0-99]

Let me show you the code:

addEntry = (newEntry) => {

    let newSortedData = [];

    // Parse any JSON previously stored in allEntries
    let existingEntries = JSON.parse(sessionStorage.getItem("magic1")).data;
    if (existingEntries === null) {
        existingEntries;
    }
    sessionStorage.setItem("magic1", JSON.stringify(newEntry));
    // Save allEntries back to local storage
    existingEntries.push(newEntry[0].data);

    console.log("existing entries with push for new ones: ", existingEntries);

    table.clear().draw();
    newSortedData.push(existingEntries);
    table.rows.add(_.sortBy(newSortedData, "title")); // Add new data
    table.columns.adjust().draw(); // Redraw the DataTable

    console.log("Existing and new ones sorted: ", newSortedData[0].data);

    sessionStorage.setItem("magic1", JSON.stringify(newSortedData[0].data));

};

What I’m getting is this:

magic1 starts out with 100 OBJECTS in the array. Where I’m getting the data from, there are 7000 items/products. I’m using a PHP to pull the data from the source. They only come in pages 1 – 70 with 100 objects in each page. hence, 7000 objects. It’s a BIZARRE way of me having to do this but I have to PING the server going past 100, 201, 301, 401, 501, 601, and so on, through all 70 hits to the server, 100 items at a time. They just can’t give me a getRowcount() as rowcount from the SQL. I have to continually ping or hit the server until I get a number of items LESS than 100 meaning, I’ve hit the last page of less than 100.

Here’s what the end of one array looks like and the beginning of the new one.

All I want to do is to KEEP appending the additional pages to continue the count with 100, 101, 102, all the way to 199. Then 200, 201, 201 – 299 and so on. Apparently obj.push(newObj) does what you see in the pic.

enter image description here

How to call external function in chain function?

This is a case about React and Dapp.

I call web3j to sendTransaction and wait callback by chian fucntion.
While error occur , I can’t call the function inside App.

I descibe the situations below codes around error block.

Is it possible to call function handleError?

//My code
class App extends Component {
    constructor(props) {
        super(props);
            this.state = {
            status: ''
            };
    };
    
    startTrade(){
        web3.eth.sendTransaction({
            from: "0x123....",
            to: "0x456....", 
            value: web3.utils.toWei("2", "ether"),
        }).on('error', (error)=>{
            
            //If write this line,the browser shows directly:
            //Failed to compile
            //srcApp.js
            //Line 62:7:  'handleFail' is not defined  no-undef     
            
            //handleError(); 
            
            //If add this. when error occurs,the console shows:
            //App.js:62 Uncaught TypeError: Cannot read properties of undefined (reading 'handleFail')
            
            //this.handleFail();

            //If I call otherHandle,It's work.
            //However I don't have the instance of App to change something...
            //otherHandle();
        }); 
    }
    handleError(){
       console.log("Do something..");
    }
    render(){ return();
    }
}
function otherHandle(){
    console.log("Do something..");
}

JavaScriptt React Issues with passing prop from a function in a child array to a function in the parent

I’m dealing with a problem passing a prop to a parent component from it’s child.

The idea of the code that I’m trying to make work is a set of buttons in a header component that when clicked, load new component pages for other parts of the website. I’m dealing with a couple of smaller bugs that I can fix at another time but the primary issue is when I try to pass the results of the function for handling the switch and the values showing as ‘undefined’ once they get to the App component. I doubt I’m explaining it well so allow me to show the code.

Parent Component (App)

import React from "react";
import Header from "./Components/Header/Header";
import Footer from "./Components/Footer/Footer";
import Pane from "./Components/Pane/Pane";
import MainPane from "./Components/Pane/MainPane";
import BookViewPane from "./Components/Pane/BookViewPane";
import AddBookPane from "./Components/Pane/AddBookPane";
import SignInPane from  "./Components/Pane/SignInPane";
import "./App.css";

const App = ()=>{

    function LoadPaneHandler(props){
        var NewPaneName=props.paneName;

        // const NewPaneName={
        //  name: props.paneName
        // };
        
        // const NewPaneName=String(props);

        console.log(NewPaneName);
        switch(NewPaneName){
            case 'MainPane':
                return <MainPane />
            case 'AddBookPane':
                return <AddBookPane />
            case 'BookViewPane':
                return <BookViewPane />
            case 'SignInPane':
                return <SignInPane />
            default:
                return <Pane />
        }
    }

    return(
        <React.Fragment>
            <Header switchPane={LoadPaneHandler} />
            <main>
                <LoadPaneHandler paneName="MainPane" />
            </main>
            <Footer />
        </React.Fragment>
    );
}

export default App;

Child Component (Header)

import React from "react";
import "./Header.css";

const Header=(props)=>{
    var paneName="";

    const switchPaneHandler=event=>{
        event.preventDefault();
        console.log(paneName);
        props.switchPane(paneName);
    }

    return(
        <header id="header">
            <div id="header-title">
                <h1>Library</h1>
            </div>
            <div id="header-buttons">
                <button onClick={paneName="BookViewPane",switchPaneHandler}> View Books</button>
                <button onClick={paneName="AddBookPane",switchPaneHandler}> Add Books </button>
                <button onClick={paneName="SignInPane",switchPaneHandler}> Login</button>
            </div>
        </header>
    );
}

export default Header;

I’ve included the commented out code of other approaches I’ve used to get the data I need for the function to work properly so that you can have an Idea of what I’ve already tried.

The code works fine so long as I only pass values to the function from within the App component. Whenever I click on one of the buttons in the header though, it shows the ‘paneName’ correctly in the ‘switchPaneHandler’ function but then in ‘LoadPaneHandler’ it prints as ‘undefined’.

I’m still quite new to React so it’s likely a very obvious mistake that I’ve made but any help is appreciated all the same. Thanks!

Cannot Connect to MySQL with NodeJS, but can via Windows Powershell

I’ve seen many variations of this question, but I couldn’t find an answer – and in fact am not sure where to look for logs that could help me. Here’s the situation.

I was following this tutorial

I have the following in a file called “server.js”:

const mysql = require("mysql");
const express = require("express");
const bodyParser = require("body-parser");

var app = express();

app.use(bodyParser.json());

var mysqlConnection = mysql.createConnection({
    host: "localhost",
    user: "root",
    password: "confidential666!",
    database: "blunt",
    multipleStatements: true
});

mysqlConnection.connect((err)=>{
    if(!err){
    console.log("Connected");
        }
    else{
        console.log("connect failed");
        console.log("big woof");

    }
});

app.listen(3000);
console.log("did run");

I run this code with “nodemon server.js”

However, my console shows me “connect failed” and “big woof”.

I then tried to connect to my database with mysql.exe with the same credentials, and could connect to “blunt” just fine.

Port is missing from my connection, but documentation suggests 3306 is the default and that’s what my server is using. Adding it made no difference. Any idea on how I can figure out why I can’t get my nodemon to connect to my database?

Compressing repeating code so file becomes tolerable to work on?

Hello folks.

I wanna try to make a simple grid based game, and currently with my 3×3 grid finding myself copying alooot of code. I’m simply wondering if there are huge solutions to compress repeating code I’m missing out on? see jsfiddle at bottom

For example:
if(cell1.innerHTML == <img src="/images/character.png"> || cell2.innerHTML == <img src="/images/character.png"> || cell3.innerHTML == <img src="/images/character.png">){

Could I maybe write this as something like:
if (cell[1,2,3].innerHTML == <img src="/images/character.png">){

The biggest issue is I wanna expand to 9×9 or larger–, which is 81+ cells. So I can have more room to work with and actually make a small game. But unless there is a smart way to compress the repeating code its simply going to be overwhelming to work with i think..

What I’ve tried to create so far is a 3×3 grid with a character in the middle and (shadow) on the adjacent tiles. To remove the shadow the character.png in the middle has to move to said cell to reveal whats underneath (havent added anything underneath any cell yet).

I’ve not found a smart way to move character from one cell to another either.
So currently I’ve landed on this repetetive cellNumber.innerHTML = “”; thing to clear out all cells.

https://jsfiddle.net/ykj9e2cs/

Any answers are welcome. Thx 🙂

How do I create a bubble chat based on sale price in D3?

I’m trying to create an interactive bubble chart in D3. The size of the cirlces and the shade of color (green) is supposed to be based on how much a hotel sold for. When the user hovers over the cirlce with their mouse a tooltip should display additional information from the other columns.

A list of columns and data are below. I keep getting the following error:
Error: <circle> attribute cx: Expected length, "NaN"

I’m reading the data in from a csv file with the following columns:

PropertyName,
PropertyAddress,
City,
SalePrice,
Square_Footage,
Units,
Price_SF,
Price_Unit,
SaleDate,
Buyer,
Seller,
Link

And my code is below:

(function () {

    // Margin convention
    const margin = { top: 30, right: 50, bottom: 50, left: 50 }
    const width = 600 - margin.left - margin.right
    const height = 425 - margin.top - margin.bottom
  
    const svg = d3.select("#chart").append("svg")
        .attr("width", width + margin.left + margin.right)
        .attr("height", height + margin.top + margin.bottom)
        .append("g")
        .attr("transform", "translate(" + margin.left + "," + margin.top + ")")
  
    // Define colour scale
    const colorScale = d3.scaleOrdinal()
      .domain(['SalePrice'])
      .range(["#228C22"])
  
    // Set radius scale
    const radiusScale = d3.scaleSqrt()
      .domain([0, 300001])
      .range([0, 40])
  
    // Define years
    const years = [2021]
  
    // Define x axis position
    const xPositionScale = d3.scalePoint()
      .domain(years)
      .range([140, width - 110])
  
    // Create currency formatted
    var formatter = new Intl.NumberFormat('en-US', {
      style: 'currency',
      currency: 'USD',
      minimumFractionDigits: 0
    });
  
    // Create tooltip
    const tooltip = d3
      .select("body")
      .append("div")
      .attr("class", "svg-tooltip")
      .style("position", "absolute")
      .style("visibility", "hidden");
    
    // Force simulation and prevent overlap
    const forceX = d3.forceX(d => xPositionScale(d.year)).strength(1)
    const forceY = d3.forceY(200).strength(1)
    const forceCollide = d3.forceCollide((d => radiusScale(d.amount) + 4))
    const simulation = d3.forceSimulation()
      .force("overlap", forceCollide)
      .force("y", forceY)
      .force("x", forceX)
      .force('charge', d3.forceManyBody().strength(-50))
  
    // Read in csv
    d3.csv("2021_hotel_sales_for_graphic.csv")
      .then(ready)
    function ready (datapoints) {
      datapoints.forEach(d => {
        d.x = 0;
        d.y = 0;
      })
  
      // Show text labels
      svg.selectAll('text')
        .data(years)
        .join('text')
        .attr('text-anchor', 'end')
        .attr('x', d => xPositionScale(d))
        .attr('dx', 20)
        .attr('dy', 0)
        .text(d => d)
  
      // Set position of circles
      svg.selectAll('circle')
        .data(datapoints)
        .join('circle')
        .attr("id", "circleBasicTooltip")
        .attr('r', d => radiusScale(d.SalePrice))
        .attr('cx', 200)
        .attr('fill', d => colorScale(d.colorScale))
        .attr('cy', 200)
        .attr('stroke', 3)
  
      // Trigger tooltip
      d3.selectAll("circle")
        .on("mouseover", function(e, d) {
          d3.select(this)
            .attr('stroke-width', '2')
            .attr("stroke", "black");
          tooltip
            .style("visibility", "visible")
            .attr('class','tooltipdiv')
            .html(`<h4>${d.PropertyName}</h4>` + 
                  `<p><strong>Address</strong>: ${d.PropertyAddress}<br />` +
                  `<p><strong>City</strong>: ${d.City}<br />` +
                  `<p><strong>Sale Price</strong>: ${d.SalePrice}<br />` +
                  `<p><strong>Square Footage</strong>: ${d.Square_Footage}<br />` +
                  `<p><strong>Units</strong>: ${d.Units}<br />` +
                  `<p><strong>Price per Sq Ft</strong>: ${d.Price_SF}<br />` +
                  `<p><strong>Price per Unit</strong>: ${d.Price_Unit}<br />` +
                  `<p><strong>Sale Date</strong>: ${d.SaleDate}<br />` +
                  `<p><strong>Buyer</strong>: ${d.Buyer}<br />` +
                  `<p><strong>Seller</strong>: ${d.Seller}<br />`);
        })
        .on("mousemove", function(e) {
          tooltip
            .style("top", e.pageY - 10 + "px")
            .style("left", e.pageX + 10 + "px");
        })
        .on("mouseout", function() {
          d3.select(this).attr('stroke-width', '0');
            tooltip.style("visibility", "hidden");
      });
  
      simulation.nodes(datapoints)
        .on('tick', ticked)
      function ticked() {
        svg.selectAll('circle')
          .attr("cx", d => d.x)
          .attr("cy", d => d.y)
        
      }
    }
  })();