LocalStorage.getItem not working properly

Basically I am using Pycharm for the first time to create a web application connected to Python. I am trying to send data between two HTML files. I noticed it was not working so I tried on a single file. When I click run main, it works and prints

i|f;/ITV?vqy<{/giT(7/0cFk%JC&iiW8ZL,RY<HwTN~mRd,V(iL+jqeJKdk>fJO~Y<a+0w7L3t!vagdV"pqDVy5_yK[}=a8Sj^,Xq#MmLX7g2<^cE`BBQ+*v?#2O`tvWT<mL"~$PePa:_`Y<PP:hf|wR~W&P[YB6nKmpql"n?]]HY`qq3@*b~q#27P!0>E]^N81H.$;=I-a;:dqAq)u!FDMhn)qs_I,bjhdJA1q8i[Z$CO?o:Kdu!7eU%v`z.0e

but if I just open the HTML page, it’s undefined. I feel like the other issue is similar. The only difference I know is the URL. When I do run main, the URL is

http://127.0.0.1:5000/

otherwise, it is

http://localhost:63342/main.py/templates/main.html?_ijt=gg9rhi2jh5afgf7fngill850rc&_ij_reload=RELOAD_ON_SAVE

Does anybody know how to fix this or another method? I’ve read that if you add the script file, then you can access the variable. Is that true? Another issue with that is that PyCharm CE does not allow separate JS or CSS files, so I’d need a new IDE

Show the Hubspot chat widget only on certain pages on an angular application

My website uses Hubspot live chat widget. I am also developing an Angular application where I add the widget to the index.html like so:

<script id="hs-script-loader" async defer src="//js.hs-scripts.com/xxxxxxxx.js"></script>
</body>

I have 2 issues:

First I want to show the widget on just the /signup page.

Second I get this following error in the console:

HubSpot Conversations: You are using conversations on a non-https site! Not using https puts your visitor's data at risk, please enforce using https.

the issue with this is the angular application will be compiled using capacitor for use as a Android appliacation. I am wondering if there are any solutions for this issue as currently its runs as http localhost even when run from the android app

“wheel” event is being fired infinitly and crashing my website

import React, { useEffect, useState } from "react";
import "./Skill.css";
import { Fade } from "react-reveal";
function Skill({ name, color }) {
  const [style, setStyle] = useState({ borderBottom: `4px solid ${color}` });
  
  window.addEventListener("wheel", () => {
    let scroll = window.scrollY;
    console.log(scroll);
    if (scroll >= 1300) {
      setStyle({
        animation: "load 2s ease-out",
        display: "block",
        borderBottom: `4px solid ${color}`,
      });
    }
  });
  return (
    <>
      <div className="skill">
        <Fade bottom>
          <div className="Skill__logo">
            <img
              className="logo__img"
              src="./images/html-5-logo-svgrepo-com.svg"
              alt=""
            />
          </div>
          <div className="skills__about">
            <div className="skillitem">
              <div className="skill__set">
                <div className="skill__Name" style={{ color: color }}>
                  {name}
                </div>
              </div>
              <div style={style} className="loading__skill"></div>
            </div>
          </div>
        </Fade>
      </div>
    </>
  );
}

export default Skill;

Here is my code and I dunno for some reason the wheel event is firing infinitely and crashing my application
kindly if somebody can tell me what is the issue

I dunno for some reason the wheel event is firing infinitely and crashing my application
kindly if somebody can tell me what is the issue

Trying to get Gravity forms calculate the highest 3 number fields in the form results

Currently have a personality test for my church that we are trying implement with Gravity forms. All the answers are calculated into key area traits (number fields). We would like to output the highest results. Currently This is what I have written. (I’m no mater of javascript).

add_action( 'gform_pre_submission_1', 'pre_submission_handler');
function pre_submission_handler( $form) {

const gifts = {};
const filter_fields =  ['98', '113', '115', '121' , '122', '110', '111', '123', '120', '118', '119', '117', '114', '124', '107', '109', '112', '104', '105', '103', '106', '116', '108', '100' ];

foreach ( $form['fields'] as $field ) {
    if filter_fields.includes(title) {
        let field_label = $field->title;
        let field_value = $field->value;
        gifts[field_label] = field_value;
    }
}

/* gifts.sort(field_value); */

Object.entries(gifts).sort((a, b) => b[1] - a[1])

let top1 = Object.keys(gifts)[0];
let top2 = Object.keys(gifts)[1];
let top3 = Object.keys(gifts)[2];


$_POST['#####'] = top1;
$_POST['####'] = top2;

}

I would love to have the code output the fields into the email responce

how to give firebase database collection item a unique ID

I have my code set up like this

const userCollectionRef = collection(db, 'users');

and then I create the data like this :

const addInfoToDataBase = async () => {
    checkLike();
    await addDoc(userCollectionRef, {
      likePost: userLikes,
      username: user,
      id: sale_id,
    });
  };

The way this is setup it generates users> random assigned id value > {id, username, likepost}

I’m trying to change that random assigned id value and assign it a dynamic item that I have called sale_Id. I tried doing this :

const userCollectionRef = collection(db, 'users', sale_id, 'id');

but this creates users> sale_id > id > random assigned id value > {id, username, likepost}

Is it possible to achieve users> sale_id > {id, username, likepost} ?

the edit mode of the jquery code for 3 related selects

I have this code and it wrks well when i had to load 3 selects by selecting one category and sunbcateory and subsubcategory is loaded

jq(document).on('change','#List1',function() {
    let iVal = jq(this).val();
    //alert(iVal);
    if(iVal !== '') {
        jq.ajax({
            url : jq(this).attr('data-href'),
            type: 'POST',
            data : 'categoryId=' + iVal,
        }).done(function(response){ // posts the response 
            jq("#List2").append(response);
        });
    } else {
        alert('Please Choose a Category');
    }
});

jq(document).on('change','#List2',function() {

    let iVal = jq(this).val();
    let iCat = jq(this).find(':selected').attr('data-id');
    //alert(iVal+ ' ' +iCat);
    if(iVal !== '') {
        jq.ajax({
            url : jq(this).attr('data-href'),
            type: 'POST',
            data : 'categoryId=' + iCat + '&subcategoryId=' + iVal,
        }).done(function(response){ // posts the response 
            jq("#List3").empty();
            jq("#List3").append(response);
        });
    } else {
        alert('Please Choose a Category');
    }
});

but how can i add a trigger when my category is already loaded, once that category is loaded, i want my script to execute on load or trigger automatically so it loads correct categories/subcategory and sub sub category if it is has

my function is returning me the options populated from database, i can;t use json becuase of security so came up with solution

This is my HTML code

<tr valign="middle">
    <td><strong>Category:</strong></td>
    <td>
        <select name='List1' id="List1" data-href="doc/tx_fetchAjax.cfm?action=subcat">
            <option selected> -- SELECT ONE -- </option>
            <cfoutput query="categories">
                <option value="#ID_categoryId#" <cfif form.categoryID eq ID_categoryId>selected</cfif>>#tx_categoryname#</option>
            </cfoutput>
        </select>
    </td>
</tr>
<tr valign="middle">
    <td><strong>Sub Category:</strong></td>
    <td>
        <select name='List2' id="List2" data-href="doc/tx_fetchAjax.cfm?action=subsubcat"><option selected > -- SELECT ONE -- </option></select>
    </td>
</tr>
<tr valign="middle">
    <td><strong>Sub Sub Category:</strong></td>
    <td>
        <select name='List3' id="List3"><option selected > -- SELECT ONE -- </option></select>
    </td>
</tr>

How to detect a loop in a graph using JavaScript – Course Prerequesits

I want to develop a function that will detect the loop in a graph.

The function will take two parameters: the number of courses, and the prerequisite array.

The prerequisites courses is an array as follows: [[b,a], [c,b], [f,e]]

This means, that course “a” is a prerequisite for course “b”, course “b” is a prerequisite for course “c”, and course “e” is a prerequisite for course “f”.

So if the number of courses is 3, and the prerequisite array is correct, then the output is

a > b > e
e > f

The above is 5 courses, and the output of the function is TRUE because we can take 3 courses by following the prerequisites.

However, if the prerequisits is [[b,a], [c,b], [a,c]]

then the output is FALSE because there is a loop:

a > b > c
c > a

Which is a circular reference. So you cannot take 3 curses because course “a” needs course “c” which is not possible.

So basically, we need to write a function to detect a loop in the graph.

I appreciate your help.

How to send piped response in Next.js API using wkhtmltoimage?

I’m new to Next.js, and I’m trying to use wkhtmltoimage but I can’t seem to send the generated image stream as a response in my Next.js API.

const fs = require('fs')
const wkhtmltoimage = require('wkhtmltoimage').setCommand(__dirname + '/bin/wkhtmltoimage');


export default async function handler(req, res) {
  try {
    await wkhtmltoimage.generate('<h1>Hello world</h1>').pipe(res);
    
    res.status(200).send(res)
  } catch (err) {
    res.status(500).send({ error: 'failed to fetch data' })
  }
}

I know I’m doing plenty of stuff wrong here, can anyone point me to the right direction?

Convert this class and componentDidMount to a react hook [duplicate]

I need help converting this class component to a react hook, so that it works with the material UI code I have.

export default class Fantasy extends Component {
state ={
  row: [],
}

componentDidMount() {
    this.getRows();
}

getRows = (id) => {
    let url = "http://localhost:3000/fantasy";
    if (id) {
      url += "?id=" + id;
      fetch(url)
        .then((response) => response.json())
        .then((data) => this.setState({ rows: data }));
    }
    else {
      fetch(url)
        .then((response) => response.json())
        .then((data) => this.setState({ rows: data }));
    }

}};

this all I need that needs to be converted to a react hook

Firebase Stripe Setup Issues

I am trying to deploy a new function called ‘createStripeCheckout’, but I keep getting an error stating that eslint command wasn’t found:

davidknight@Davids-MacBook-Air HTML % firebase deploy –only functions

=== Deploying to ‘studiopick-f6c1f’…

i deploying functions
Running command: npm –prefix “$RESOURCE_DIR” run lint

lint
eslint .

sh: eslint: command not found

Error: functions predeploy error: Command terminated with non-zero exit code127

How can I make a custom PDF viewing widget?

How would I go about making a custom PDF viewing widget for a webpage? I’ve seen systems like elfsight.com do this really well, any help?

I’v tried to use systems like adobe pdf embedded and get that code but I want to make my own version that is responsive as well.

If the option is selected, fills in the input

How, using only HTML and CSS, to make it so that when I select an option in , my input is filled in?
Here is my code

<select class="cod_art" name="cod_art" id="cod_art_01">
<option value="Default">Default1</option>
<option value="Default">Default2</option>
</select>
<input type="text" id="descrizione_01" name="descrizione" readonly>

So, if I select Default1 option, in input will fill a text, for example “example1”.
How can I do it in JS?

How to rotate custom select arrow on focus with only css?

I got this simple example to illustrate the problem.

import './style.css';

export default function App() {
    return (
        <div className="App">
            <div className="App">
                    <select id="mySelect">
                        <option>Option 1</option>
                        <option>Option 2</option>
                        <option>Option 3</option>
                    </select>
                    <span></span>
            </div>
        </div>
    );
}

and the styles fot that

#mySelect + span:after {
    content: '↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑';
}

#mySelect:focus + span:after {
    content: '↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓';
}

What I need is to replace “down arrow” to “up arrow” or rotate it on 180deg (doesen’t metter which it will be) when select was opened and to rotate it backwards if there was a click on the select or anywhere else. The problem that if you will open select and click on any other place one time the select will still have active state, so nothing gonna change. You have to click twice to rotate the arrow. So my question is how can I avhieve that without using any libraries or JavaScript. I have tried to do that with pseudo element’s but it’s doesn’t work for the same reason.

React Array.map() function not returning anything [duplicate]

I am making a chat app and everytime someone sends a message an useState element gets updated adding his message to the list. For some reason when the messages array gets updates, messages.map function doesn’t add it onto the screen. Here is my code.

const SendMessage = () => {
    let temp = messages;
    let currentDate = new Date();
    let vreme = currentDate.getHours() + ":" + currentDate.getMinutes();
    temp.push(JSON.stringify({
      from: "me",
      text: divText,
      time: vreme
    }));
    setMessages(temp);
    console.log(messages);
    document.querySelector(".chat-input").innerHTML = "";
  }
<div className='chat-box'>
          <span className='razmak'></span>
          {messages.length > 0 && messages.map((item) => {
            return (<span key={item}>{item}</span>)
            // let object = JSON.parse(item);
            // if (object.from === "me") {
            //   return (
            //     <MessageRight key={object.text} text={object.text} time={object.time}></MessageRight>
            //   )
            // }
            // else
            // {
            //   return (
            //     <MessageLeft key={object.text} username={object.from} text={object.text} time={object.time}></MessageLeft>
            //   )
            // }
          })}
          {!messages.length > 0 && <span>No messages</span>}
        </div>