InboxSDK To load React application inside gmail webpage

I am stuck at the following and i really need some help to solve this issue
i am building a react app using InboxSDK and this is my code in the App.js File

/* eslint-disable react/jsx-no-undef */
/* eslint-disable no-undef */
/*global chrome*/
   import React from "react"
   import ReactDOM from "react-dom"
   import App from "./components/App"

   InboxSDK.load(2, "sdk_lettersnumbers_9b96f6fcb7").then(function (sdk) {
     alert("t");
    sdk.Toolbars.registerThreadButton({
    title: "React button",
    iconUrl: chrome.extension.getURL("/") + "images/logo192.png",
    hasDropdown: true,
    onClick: function (event) {

        ReactDOM.render(<App />, event.dropdown.el);

        event.dropdown.once('destroy', () => (
            ReactDOM.unmountComponentAtNode(event.dropdown.el)
        ));
      }
   });
})

A screenshot of the application files tree is the following

enter image description here

the complete project can be found at this link: https://drive.google.com/drive/u/0/folders/1EHPmF9Mkql6sdjMf2hT6HVpUqpEFVea9

my issue is that the add-in is not being loaded when i go to gmail website
it should show here
enter image description here

Search bar remains open with empty result

When i type something and then delete it the search bar remains open with no result, even if i click on something else in the same page, how can i make it to auto-close itself after i click somewere else on the screen?

    SearchBx.onkeyup = (e)=>{
  let userData = e.target.value;
  let emptyArray = [];
  if(userData){
    emptyArray = suggestions.filter((data)=>{
      return data.toLocaleLowerCase().startsWith(userData.toLocaleLowerCase());
    });
    emptyArray = emptyArray.map((data)=>{
      return data = '<li>'+ data + '</li>';
    });
    console.log(emptyArray);
    Main.classList.add("show");
  }else{

  }
  showSuggestions(emptyArray);
  let allList = AutoBox.querySelectorAll("li");
  // for (let i = 0; i < allList.length; i++) {
  //   allList[i].setAttribute("onclick", "select(this)");
  // }
  for(const el of allList){ // use for..of instead of indexed for
    el.addEventListener('click', (e) => { // attach an event listener instead of using the onclick attribute
      SearchBx.value = e.target.textContent; // can be a separate function like 'select', but whatever 
      ouvrirPage(); // trigger page opening from click event
    }); 
  }
}
// function select(element){
//   let selectUserData = element.textContent;
//   SearchBx.value = selectUserData;
// }
function showSuggestions(list){
  let listData;
  if(!list.length){
    userValue = SearchBx.value;
    listData = '<li>'+ userValue +'</li>'
  }else{
    listData = list.join('');
  }
  AutoBox.innerHTML = listData;
}

https://codepen.io/galusk0149007/pen/NWXEVmO

Prevent Form Submission When 2 Inputs Fields Do Not Match

I gift free tickets to students for free entry into a training class and I write each student’s phone number on their ticket to prevent another student from using a stolen ticket for entry.

I am trying to design a form for the students to register as candidates and also to have their data.

On the form, I want them to input their phone number and the unique code that is printed on the ticket that I gifted to them.

I am trying to make only students with my ticket be able to submit the form.

How do I prevent form submission with javascript when the phone number and the ticket number do not match?

Below is a sample of a javascript that I use to prevent form submission when email does not match.

I am aware that the sample below is not the best solution but I still need the solution. Thanks.

Code Sample;

function check_email()
{
    var email = document.getElementById("email").value;
    
 if(email.localeCompare("[email protected]" || "[email protected]")) {
      
        alert("ATTENTION! nThe email address that you provided did not match with the email that is associated.");
        return false;
    }
    return true;
}
    
<form action='' onsubmit="return check_email();">
<input type="password" name="email" placeholder="go*****b@*****.com" required='' id="email"/>

<button href='/' type='submit' id="submitForm">Submit</button> <button class="button" type="reset" value="Cancel">Reset</button>
</form>
 
  

Hiding the 0 that shows when a user presses the AC button on my calculator

I’ve added an AC button to my JS calculator which resets the variables and displays 0 in the displayArea.

However when the user starts typing their first number the 0 stay’s so it shows 03 instead of 3 etc – this doesn’t impact the calculation.

I’ve tried to remove this using parseInt and an IF statement however it doesn’t seem to work.

My best attempt so far is:

<p id="result-display">    </p>
let displayArea = document.getElementById('result-display');

else if (displayArea.innerHTML = 0) {
        buttonNumber = Number(e.target.innerText);
        displayValue = buttonNumber;
        displayArea.innerHTML = parseInt(displayArea.innerHTML += displayValue);
        }

If I change the 0 to a string e.g. ‘0’ it works but then also stops the user entering multiple number values e.g. 56 would show as 5 etc.

My JSFiddle is: https://jsfiddle.net/mh85skxv/3/

A window “Check your passwords” after axios request

After registering on the site, such a window pops up.

“Check your passwords. A data breach on a site exposed your password…”

Requests on server look like this:

import * as axios from 'axios'

const instance = axios.create({
    withCredentials: true,
    baseURL: 'api',
    headers: {
        'Content-Type': 'application/json'
    }
})

export const API = {
    signAPI : {
        signUp: (email, password, name, surname, username) => {
            return instance.post(`users/sign`, {email, password, name, surname, username})
                .then(response => {
                    return response
                })
        },
}

Perhaps I should pass some additional headers?

ag-grid cell rendering function in react js through json api

i have created one simple ag-grid using react js . after that i am call json data and pass data into ag-grid react table

actuall json data is :

{
  "posts": [{
    "cam1": " 3 persons, 1 car, 1 bottle, 2 chairs, 1 tv",
    "cam2": " 1 person",
    "date": "Tue, 19 April 12:16:29 ",
    "status": "High"
  }, {
    "cam1": " 3 persons, 2 chairs, 1 tv",
    "cam2": " 1 person",
    "date": "Tue, 19 April 12:16:32 ",
    "status": "Low"
  }, {
    "cam1": " 4 persons, 1 bottle, 2 chairs, 1 tv",
    "cam2": " 1 person",
    "date": "Tue, 19 April 12:16:35 ",
    "status": "Medium"
  }]
}

passing this json data into react table using json api call function.

const onGridReady=(params)=>{
  console.log("grid is ready")
  fetch("http://localhost:5000/posts").then(resp=>resp.json())
  .then(resp=>{console.log(resp)
    params.api.applyTransaction({add:resp})})
}

After passing data into react table. react table like this

Now i wanna cell rendering function for status column in ag-grid table, with some of following conditions.

if status high indicates with red

if status medium indicated with yellow

else highlight with green background .

how to resolve this using react js, i expected output like this
enter image description here

for more code referece click Here

Thanks in advance

Creating cookie with a form values makes a null cookie

First of all, i need to create a cookie with a values that are in a form, and a lot of values are in a radio input type, but i ran into a problem with creating it.

Here is the code:

<script>
        function setCookie(name, value, daysToLive) {
    var cookie = name + "=" + encodeURIComponent(value);
    
    if(typeof daysToLive === "number") {

        cookie += "; max-age=" + (daysToLive*24*60*60);
        
        document.cookie = cookie;
    }
}
function getCookie(name) {
    // Split cookie string and get all individual name=value pairs in an array
    var cookieArr = document.cookie.split(";");
    
    // Loop through the array elements
    for(var i = 0; i < cookieArr.length; i++) {
        var cookiePair = cookieArr[i].split("=");
        
        /* Removing whitespace at the beginning of the cookie name
        and compare it with the given string */
        if(name == cookiePair[0].trim()) {
            // Decode the cookie value and return
            return decodeURIComponent(cookiePair[1]);
        }
    }
    
    // Return null if not found
    return null;
}
function checkCookie() {
    // Get cookie using our custom function
    var firstName = getCookie("firstName");
    
    if(firstName != "") {
        alert("Welcome again, " + firstName);
    } else {
        firstName = prompt("Please enter your first name:");
        if(firstName != "" && firstName != null) {
            // Set cookie using our custom function
            setCookie("firstName", firstName, 30);
        }
    }
}
        function createCookie() { 
if (!document.f1.txt1.value) {
alert("Имя не введено");
document.f1.txt1.focus();
}
else { 
    name=document.f1.txt1.value;
    value=document.f1.gender.value+","+document.f1.edu.value+","+document.f1.theme.value;
    setCookie(name,value,4);
    checkCookie();
}
}

i got the code for all the functions from tutorialrepublic.com except the last one, which i made on my own. it should create a cookie from the values which i choose in a form when i click the button here:

<form name="f1">
        <p>Имя: <input type="text" name="txt1">

        <p>Пол: <input type="radio" id="male" name="gender" value="male" checked>
        <label for="male">Мужской</label> <br>
        <input style="margin-left: 215e-2%;" type="radio" id="female" name="gender" value="female">
        <label for="female">Женский</label>

        <p>Образование: <input type="radio" id="elem" name="edu" value="elem" checked>
        <label for="elem">Начальное</label> <br>
        <input style="margin-left: 53E-1%;" type="radio" id="sec" name="edu" value="sec">
        <label for="sec">Среднее</label><br>
        <input style="margin-left: 53E-1%;" type="radio" id="high" name="edu" value="high">
        <label for="high">Высшее</label>

        <p>Цветок: <input type="radio" id="flow1" name="theme" value="flow1" checked>
        <img for="flow1" src="flow1.png" width="200px" height="200px"> 
        <input type="radio" id="flow2" name="theme" value="flow2">
        <img for="flow2" src="flow2.png" width="200px" height="200px">  <br>
        <input style="margin-left: 325E-2%" type="radio" id="flow3" name="theme" value="flow3">
        <img for="flow3" src="flow3.png" width="200px" height="200px"> 
        <input type="radio" id="flow4" name="theme" value="flow4">
        <img for="flow4" src="flow4.jpg" width="200px" height="200px"> 

    </form>
    <button onclick="createCookie()">Create cookie</button>
    <button onclick="checkCookie()">Check cookie</button>

Fortunately, it creates a cookie, but with a null value. i consider that the problem is with the form values types,or with the form itself,but can’t see how i can fix this. i’m new in javascript so this problem can be easy to fix for you. can you help me to find my mistakes?

Why url is converted into sub-url in HTML when passing through input field?

I am taking URL as input from user in HTML form and creating a dynamic link with javascript.
The code is working fine when I am giving input as “https://www.google.com” but when I am passing input as something like “google.com” it is converting link to localhost path eg file:///path_where_html_exists/urlpassed
here is my 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>
  </head>
  <body>
    <form>
      <input id="inputurl" type="url" />
      <button type="submit" onclick="handleSubmit()">sunmit</button>
      <script src="newscript.js"></script>
    </form>

    <div id="newpara"></div>
  </body>
</html>

JS

function handleSubmit() {
  event.preventDefault()
  var elem = document.getElementById('inputurl').value
  console.log(elem)
  ele = document.getElementById('newpara')
  ele.innerHTML += `<a href="${elem}">link here</a>`
}

Thanks

Survey that returns a ranking based on the points awarded to a team

I own a wordpress site, I would like to create a “survey” which based on the answers assigned a score of 0, 1 or 3 to a ranking of n teams.

An example of a question is: Naples – Rome 1, X, 2

If the user’s answer is 1 then I give Naples 3 points

If the user’s answer is 2 then I give Rome 3 points

If the user’s answer is X then I give both Rome and Naples 1 point

What I want to do is return a table to the user at the end of the survey which represents the ranking based on the points assigned by the user.
The ranking must start with points already assigned.
The results must also be kept.

Do you know a plugin that allows you to do this? Or alternatively do you have other ideas? (in case I had to program it myself, which language should I use?)

How to call a function when any JavaScript event occurs?

I have a requirement to check if the user is active or inactive in UI5. So I need to call a function when there is some kind of user events. I have done it as follows. But is there a better way without listing the events as below?

**

jQuery(document).on("blur focus click dblclick mousedown mouseup mouseover mouseout etc", function(oEvent) {
    //call some function
    }

**