Need help debugging a “MODULE NOT FOUD” error in my code

I’m trying to start my server in order to run my application and test my requests through insomnia and see my data in mongoose. I keep running into this error “MODULE_NOT_FOUND”, I know this is in reference to the path I’m using to import models, but every way I troubleshooted the path it resulted in the same error. Is this being caused by the use of “exports.”?

I’m expecting for the server to start when I enter the command “node server.js”. I have tried multiple ways to change the path and double checked all of my files.

Details:

Error

thoughtController.js file

Repository: https://github.com/RG-GitUser/Social-Network-API

JS works inline but not in .js file– src working [duplicate]

I am running a simple table population, but when I move the js from inline html to its own file, it no longer works. Of course, my first guess was that there was an error in the reference to the .js src, but alerts in the .js file work as expected, so I know the reference is working.

const items1 = [{
    date: "10/17/2018",
    name: "john doe"
  },
  {
    date: "10/18/2018",
    name: "jane doe"
  },
];
const items2 = [{
    date: "10/17/2019",
    name: "john doe"
  },
  {
    date: "10/18/2019",
    name: "jane doe"
  },
];

function loadTableData(items) {
  const table = document.getElementById("testBody");
  items.forEach(item => {
    let row = table.insertRow();
    let date = row.insertCell(0);
    date.innerHTML = item.date;
    let name = row.insertCell(1);
    name.innerHTML = item.name;
  });
}

loadTableData(items1);
loadTableData(items2);
<!DOCTYPE html>
<html lang="en">

<head>
  <title>whiteboard</title>
  <link rel="stylesheet" type="text/css" href="whiteboard.css">
  <script type="text/javascript" src="whiteboard.js"></script>
</head>

<body>
  <table id="myTable" class="table table-borderless table-striped table-earning">
    <thead>
      <tr>
        <th>date</th>
        <th>file name</th>
      </tr>
    </thead>
    <tbody id="testBody"></tbody>
  </table>
</body>

</html>

If my src reference is working, then what else might cause an error to happen not in but in the .js file?

What regex in JavaScript can put numbers into the parentheses [closed]

I have texts like this:

Line 7 introduces the concept of "winter sleep," 
which is further developed in the following lines 8-17. 

I need to put all numbers following words “line” or “lines” into the parentheses.

For example:

  • “Line 7” => “Line (7)”
  • “line 7” => “line (7)”
  • “Lines 8-17” => “Lines (8-17)”
  • “lines 8-17” => “lines (8-17)”

Unable to send GET API request using proxy server in javascript

I am trying to send GET request in javascript through my proxy server. My proxy server requires authorization, so I use Authorization: Bearer header. However, regardless of endpoint website I am sending GET request to, I always get 2 types of errors:
1)ERR_SSL_PROTOCOL_ERROR if I use HTTPS for my proxy server URL;
2)ERR_UNEXPECTED_PROXY_AUTH if I use HTTP for that purpose
My code:

const proxyURL = 'https://134.195.153.108:9870/'
const apiURL = 'https://httpbin.org/ip'

fetch(proxyURL + apiURL, {headers: {
    'Authorization' : 'Bearer ' + btoa('username:password') // of course i put my real creds
}})
.then(response => response.json())
.then(data => {
    console.log(data)
})

I tried different proxy servers even without required Authorization, I tried using Proxy-Authorization header instead of usual Authorization. And I tried many websites as an endpoint. For some reason in python configuring aiohttp.ProxyConnector from aiohttpI easily manage to receive data through my proxy server, however I need to do the same using pure javascript.

How do I upload an image to Firebase Storage? How do I go from a local filepath to a File object or a blob?

I have an Angular service which is supposed to have an uploadImage() method that takes the image’s local filepath from an html form and is supposed to upload the image to a specific uri at Firebase storage (I use angular fire v7.6).

The problem is that there does not seem to be a function in Firebase (well angular/fire to be exact) that uploads the file from a local path string. Instead, there is uploadBytes(), which requires some other format (Blob, Bytes, I am not sure).

I have no idea nor have I been able to find how in god’s name am I supposed to read the image file into that format so I can use it in uploadBytes().

This is what I have so far:

import {Injectable} from '@angular/core';
import {Storage, ref, uploadBytes} from '@angular/fire/storage';
import {from, map, Observable} from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class ImageService {
  constructor(private firebaseStorage: Storage) { }

  uploadImage(id:number, filePath: string, name: string): Observable<string> {
    const ext = filePath.split('.').pop();
    const fileRef = ref(this.firebaseStorage, '/' + id + '/' + name + '.' + ext);
    
    const correctFormat = ??????;

    return from(uploadBytes(fileRef, correctFormat)).pipe(
      map(taskSnapshot => {
        return taskSnapshot.ref.fullPath;
      })
    );
  }

}

Please help me.

v-if using boolean result from array [vue3]

i had a follow problem.

I need to show or hide contents using v-if, but i have my content on an array: this is my example.

    <v-expansion-panel v-for="item in flightOptionData" :key="item.type" elevation="0" class="rounded-lg foExpansion">
        <v-expansion-panel-title class="pa-3 bg-card" v-slot="{ open }" expand-icon="" collapse-icon="">
            <section class="foCard">
                  <p>{{item.finalPrice}}</p>
                  <p>{{item.number}}</p>
                  <p v-if="true" class="nextDay">+1</p>

            </section>
       </v-expansion-panel-title>
  </v-expansion-panel>

js...

data() {
        return {
            flightOptionData: [
                { finalPrice: '5.431,00', number: 'A12314', overnight: true }, { finalPrice: '5.431,00', number: 'A12314', overnight: false }
]}

I tried to solve at this way:

    <v-expansion-panel v-for="item in flightOptionData" :key="item.type" elevation="0" class="rounded-lg foExpansion">
        <v-expansion-panel-title class="pa-3 bg-card" v-slot="{ open }" expand-icon="" collapse-icon="">
            <section class="foCard">
                  <p>{{item.finalPrice}}</p>
                  <p>{{item.number}}</p>
                  <p v-if="{{item.overnight}}" class="nextDay">+1</p>

            </section>
       </v-expansion-panel-title>
  </v-expansion-panel>

js...

data() {
        return {
            flightOptionData: [
                { finalPrice: '5.431,00', number: 'A12314', overnight: true }, { finalPrice: '5.431,00', number: 'A12314', overnight: false }
]}

Recursive Regex for Parsing SGF with JS

1. What SGF is

SGF is what’s widely used to save Go (board game) games as text. In essence, it’s basically the text encoding of something like a trie.

Here’s an example of what it looks like — I suggest using software like the Sabaki editor to create files and then look at the resulting text in it —:

(;GM[1]FF[4]CA[UTF-8]AP[Sabaki:0.52.2]KM[6.5]SZ[19]DT[2023-12-25];B[pd];W[dd](;B[pq];W[dp])(;B[dp];W[pp]))

A more readable version, only for reference — the comments are not part of the SGF specification actually —:

(
  ;GM[1]FF[4]CA[UTF-8]AP[Sabaki:0.52.2]KM[6.5]SZ[19]DT[2023-12-25] // Game Metadata
  ;B[pd] // Black's Move (`pd` = coordinates on the board)
  ;W[dd] // White's Move
    ( // Parentheses denote a branch in the tree
      ;B[pq]
      ;W[dp]
    )
    (
      ;B[dp]
      ;W[pp]
    )
)

The whole SGF grammar is described like this:

Collection     = { GameTree }
GameTree       = "(" RootNode NodeSequence { Tail } ")"
Tail           = "(" NodeSequence { Tail } ")"
NodeSequence   = { Node }
RootNode       = Node
Node           = ";" { Property }
Property       = PropIdent PropValue { PropValue }
PropIdent      = UcLetter { UcLetter }
PropValue      = "[" Value "]"
UcLetter       = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" |
                 "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" |
                 "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"

2. What I’m Looking For

What I’m looking for is a recursive regex capable of turning an SGF string down to a recursive tree object in JS. Checking if the file is valid SGF would be a plus, but not necessary.

The tree shape would be something like this — this one comes from Sabaki’s SGF Parser —:

{
  id: <Primitive>,
  data: {
    [property]: <Array<String>>
  },
  parentId: <Primitive> | null,
  children: <Array<NodeObject>>
}

ECMA, the standard for JS, doesn’t comprise recursive regexes. So, an external package would probably necessary, like the XRegExp package, mentioned in this answer.

3. My Non-Regex Solution

Others have, in the past, parsed SGF through various means, I’ll leave my own version here for reference, as it might help in understanding the problem — you can also find it here on Github. It uses a tree class and some sort of flattened recursion:

export class SgfTree {
  constructor(
    // The pointer to the parent isn't really necessary, but
    // it makes parsing much easier.
    public parent?: SgfTree,
    public data: string = "",
    public children: SgfTree[] = []
  ) {}

  toJSON(): Object {
    return {
      data: this.data,
      children: this.children.map((c) => c.toJSON()),
    };
  }
}

// An SGF tree is basically a *trie* data structure encoded
// in text.
//
// I bet you could also do the whole parsing with only
// Regexes. (I think I'm gonna create a Stack Overflow
// question for this.)
export function parseSgf(sgf: string) {
  // 1. Cleanup
  sgf = sgf
    .replaceAll("n", "")
    .replaceAll("t", "")
    .replaceAll(" ", "")
    .trim();

  // 2. Initialization
  const trees = new SgfTree();
  let currentTree: SgfTree = trees;
  let currentString: string = "";

  // 3. Flattened Recursion
  for (const char of sgf) {
    switch (char) {
      case "(":
        // 3.1. Opening a Branch
        currentTree.data = currentString;
        const newTree = new SgfTree(currentTree);
        currentTree.children.push(newTree);
        currentTree = newTree;
        currentString = "";
        break;
      case ")":
        // 3.2. Closing the Current Branch and Going Back to the
        //      Parent.
        parseMovesAndMetadata(currentString);
        currentTree.data = currentString;
        currentTree = currentTree.parent!;
        currentString = currentTree.data;
        break;
      default:
        currentString += char;
    }
  }

  return trees.children;
}

// Not all the SGF fields, but probably the most common ones...
export type SgfData = {
  // 1. Metadata
  GM?: "1"; // Game Type (GM = "1" is Go)
  FF?: string; // File Format
  CA?: string; // Character Set
  AP?: string; // Application used to produce the file
  // 2. Game Info
  KM?: string; // Komi
  SZ?: string; // Board Size
  DT?: string; // Date
  HA?: string; // Number of Handicap Stones
  RU?: string; // Rules Set in Use
  GN?: string; // Game Name
  EV?: string; // Event
  // 3. Players
  PB?: string; // Black Player
  BR?: string; // Black's Rating
  PW?: string; // White Player
  WR?: string; // White's Rating
  // 4. Comments
  C?: string; // (Move) Comments
  GC?: string; // Game Comment
  // 5. Editing the Goban
  PL?: string; // Who plays next
  AB?: string; // Add Black stones
  AW?: string; // Add White stones
  // 6. Moves
  B?: string; // What Black plays
  W?: string; // What White Plays
};

// TODO: Complete
function parseMovesAndMetadata(sgfData: string) {
  const metadataAndMoves = sgfData
    .split(";")
    .filter((m) => m !== "");

  const regex =
    /(?<key>[A-Z](?:s*[A-Z])*)[(?<value>(?:\]|[^]])*)/g;
  const matches = [...metadataAndMoves[0].matchAll(regex)];

  console.log(matches[0].groups!["value"]);
}

// Straight Branch
const test1 = `
  (
    ;GM[1]FF[4]CA[UTF-8]AP[Sabaki:0.52.2]KM[6.5]SZ[19]DT[2023-12-25]
    ;B[pd]
    ;W[dd]
    ;B[pq]
    ;W[dp]
  )
`;
// Two Branches
const test2 = `
  (
    ;GM[1]FF[4]CA[UTF-8]AP[Sabaki:0.52.2]KM[6.5]SZ[19]DT[2023-12-25]
    ;B[pd]
    ;W[dd]
      (
        ;B[pq]
        ;W[dp]
      )
      (
        ;B[dp]
        ;W[pp]
      )
  )
`;
// Two Branches + Added (Edited) Stones
const test3 = `
  (
    ;GM[1]FF[4]CA[UTF-8]AP[Sabaki:0.52.2]KM[6.5]SZ[19]DT[2023-12-25]
    ;B[pd]
    ;W[dd]
      (
        ;B[pq]
        ;W[dp]
      )
      (
        ;B[dp]
        ;W[pp]
        ;PL[B]AE[jk]AB[jj]AW[ji]
        ;B[jq]
      )
  )
`;
// Two Branches + Added (Edited) Stones + Comments
const test4 = `
  (
    ;GM[1]FF[4]CA[UTF-8]AP[Sabaki:0.52.2]KM[6.5]SZ[19]DT[2023-12-25]
    ;B[pd]C[Comment on move.]
    ;W[dd]
      (
        ;B[pq]
        ;W[dp]
      )
      (
        ;B[dp]
        ;W[pp]
        ;PL[B]AE[jk]AB[jj]AW[ji]C[Comment on editing.]
        ;B[jq]
      )
  )
`;

const sgf = parseSgf(test4);
const sgfAsJSON = sgf.map((c) => c.toJSON());
const prettyPrintSgf = JSON.stringify(sgfAsJSON, null, 2);

// console.log(prettyPrintSgf);

4. References

Repetitive Info appearing using Blade HTML and JS

Below is my code, I want to understand how to fix the problem of my main functions section include the management, cashier and report appearing twice on the web page. I also added some javascript code at the bottom trying to call the ID from the ‘you’re logged in’ message and have it disappear after three seconds. When I added this code, it is just making the duplicate section disappear after three seconds and not the message. Pls and ty for anyone with any type of suggestion!

{{ __(‘Restaurant Manager’) }}

<div class="py-12">
    <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
        <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg" id="loggedInMessage"> 
            <div class="p-6 text-gray-900 dark:text-gray-100">
                {{ __("You're logged in!") }}
            </div>

    <div class="center-container">
        <div class="center-content">
            <div class="row justify-content-center">
                <div class="col-md-8">
                    <div class="card">
                        <div class="card-header">Main Functions</div>
                    </div>
                </div>
            </div> 
        </div>
    </div>

        <div class="container">
        <div class="row text-center"> 
            <div class="col-sm-4 management"> 
            <a href="/management">
                <h4>
                <i class="fa-solid fa-database"></i> Management
                </h4>
                <img width="50px" src="{{asset('images/management.svg')}}"/>
                </a>
            </div> 

            <div class="col-sm-4 cashier"> 
            <a href="/cashier">
                <h4> 
                <i class="fa-solid fa-money-bill-transfer"></i> Cashier
                </h4>
                <img width="50px" src="{{asset('images/cashier.svg')}}"/>
                </a>
            </div>

            <div class="col-sm-4 report">
            <a href="/report">
                <h4>
                <i class="fas fa-list-check"></i> Report
                </h4>
                <img width="50px" src="{{asset('report/management.svg')}}"/>
                </a>
            </div>

        </div>               
        </div>
        </div>
    </div>
</div>
<script>
    document.addEventListener('DOMContentLoaded', function() {
    const loggedInMessage = document.getElementById('loggedInMessage');

    const hideLoggedInMessage = () => {
        if (loggedInMessage) {
            setTimeout(() => {
            loggedInMessage.style.display = 'none';
        }, 3000);
    }
};

    hideLoggedInMessage();
});

</script>

I tried adding this block – loggedInMessage.style.display = ‘block’; – to the js code, below the start of the if statement, but that is just making the whole web page disappear after three seconds.

Fetch from HTTP site by Chrome Extension

I would like to know how to fetch from a HTTP site (not HTTPS) from Chrome Extension (v3 manifest).

Currently I’m using a Tampermonkey userscript, which works perfectly fine so far. And for some reason, I want to migrate the script to my own Chrome extension.
The userscript is below:

    function requestServer(){
        return new Promise((resolve, reject) => {
            GM.xmlHttpRequest({
                method: "POST",
                url: 'http://221.xxx.yyy.zz/login',
                headers: {'Content-Type':'application/x-www-form-urlencoded;charset=utf-8'},
                data: 'username=abc_ENQUIRY&password=123456',
                onload: e => resolve(e.response),
                onerror: reject,
                ontimeout: reject,
            });
        });
    }

As you can see the userscript is currently using xmlHttprequest, I first tried to rewrite the request back to the original xmlHttprequest syntax, instead of using tampermonkey api
The following is how it’s write:

function requestServer(){
    return new Promise((resolve, reject) => {
        var xhRequest = new XMLHttpRequest();
        xhRequest.open('POST', 'http://221.xxx.yyy.zz/login', true);
        xhRequest.onload = function () {
            if (this.status >= 200 && this.status < 300) {
                resolve(xhRequest);
            } else {
                reject(xhRequest);
            }
        };
        xhRequest.onerror = function () {
            reject(xhRequest);
        };
        xhRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=utf-8');
        xhRequest.send('username=abc_ENQUIRY&password=123456');
    });
}

But the following error is shown:

Mixed Content: The page at 'https://w3.abcdef.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://221.xxx.yyy.zz/login'. This request has been blocked; the content must be served over HTTPS.

I searched the solution of this is to move the request to background script (Ref: https://medium.com/@chantlong/performing-http-https-requests-in-a-chrome-extension-ccba3367d2f8, sending request from https to http from chrome extension). And moving it to background means I need to change from old xmlhttprequest to the newer fetch.

And now it’s how the function moved to background/service-worker script:

function requestServer(){
    fetch('http://221.xxx.yyy.zz/login', {
        method: 'POST', 
        headers: {'Content-Type': 'application/x-www-form-urlencoded'},
        body: 'username=abc_ENQUIRY&password=123456'
    })
    .then(console.log("SUCCESS"))
    .catch(console.log("FAIL???"));
}

And the following error is shown:

Uncaught (in promise) TypeError: Failed to fetch

In fact, the xmlrequest is simulating the login form submission from the website http://221.xxx.yyy.zz/login. The following is the “Copy as fetch” of the xml request if I really using the login page itself:

fetch("http://221.xxx.yyy.zz/login", {
  "headers": {
    "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
    "accept-language": "en,zh-HK;q=0.9,zh-TW;q=0.8,zh;q=0.7,en-US;q=0.6",
    "cache-control": "max-age=0",
    "content-type": "application/x-www-form-urlencoded",
    "upgrade-insecure-requests": "1"
  },
  "referrer": "http://221.xxx.yyy.zz/login",
  "referrerPolicy": "strict-origin-when-cross-origin",
  "body": "username=abc_ENQUIRY&password=123456",
  "method": "POST",
  "mode": "cors",
  "credentials": "include"
});

And this is the “Copy as fetch” of the xml request if I use tampermonkey script:

fetch("http://221.xxx.yyy.zz/login", {
  "headers": {
    "accept": "*/*",
    "accept-language": "en,zh-HK;q=0.9,zh-TW;q=0.8,zh;q=0.7,en-US;q=0.6",
    "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
  },
  "referrerPolicy": "strict-origin-when-cross-origin",
  "body": "username=abc_ENQUIRY&password=123456",
  "method": "POST",
  "mode": "cors",
  "credentials": "include"
});

I have sort of imitates the fetch request, by putting different headers, such as CORS mode, putting referrer and referrer policy, but seems no luck. Btw, I found that no matter what URL I put on the referrer, the referrer is empty on request’s request header in developer tools

I’m thinking to using Offscreen document to imitate the fetch request like the tampermonkey does (it seems Tampermonkey is still using Manifest v2, as the xmlrequest is called by background.html, but in this way, the request data and its response need to be sent across a few script, from content script to service worker script to offscreen document script, which seems quite complicated. So I personally not really want to try/use such method.

So I would like to know how to fetch a HTTP site from an extension (in a simply way), it can be directly from a content script or from a service worker script. Appreciate your help. Thank you so much:)

How to create a pdf file from a google doc that has been saved and stored in a google drive folder

Can someone help me with the code that I need to convert and save a google doc into a pdf file. THe script is this:

var plantillaId = '12233336566666';
var destinationFolderId = '4545656454566';
var temporalFolderID = '456456151566151';

function onFormSubmit() {
  var hoja = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Form1");
  var lastRow = hoja.getLastRow();
  var accionFormativaRespuesta = hoja.getRange(lastRow,3).getValue();
  var accionesFormativas = accionFormativaRespuesta.split(', ');

  accionesFormativas.forEach(function (accionFormativa) {
    var destinationFolder = DriveApp.getFolderById(destinationFolderId);
    var temporalFolder = DriveApp.getFolderById(temporalFolderID);
    var archivoPlantilla = DriveApp.getFileById(plantillaId);
    var copiaArchivoPlantilla = archivoPlantilla.makeCopy(temporalFolder);
    var copiaID = copiaArchivoPlantilla.getId();
    var doc = DocumentApp.openById(copiaID);
    doc.setName(nombre + ' ' + primerApellido + ' ' + segundoApellido + ' ' + accionFormativa);
    const document = doc.getBody();
    var text = document.editAsText();
    var startIndex = text.getText().indexOf('{{Acc}}');
    if (startIndex !== -1) {
      var endIndex = startIndex + '{{Acc}}'.length;
      text.replaceText('{{Acc}}', accionFormativa);
      text.setBold(startIndex, startIndex + accionFormativa.length - 1, true);
    };
    // * HERE IT WOULD BE CONTAINED THE CODE THAT HANDLES THE PDF CONVERSION * //  
  })
}

I have left out much of the not needed code that gets the data from the google sheet and saves into the google doc files for the sake of simplicity. I pretend to create a pdf file for each google doc created through each iteration of “accionesFormativas”. I have tried many different ways but javaScript makes it very difficult to make pdf conversions. Can someone help me out?

I have tried several ways. Lastly with this code:

    var copiedDoc = DocumentApp.openById(copiaID);
    var copiedBody = copiedDoc.getBody();

    var newDoc = DocumentApp.create('Temp Document');
    var newBody = newDoc.getBody();

    copiedBody.getParagraphs().forEach(function (paragraph) {
      newBody.appendParagraph(paragraph.copy());
    });

    var pdfFileName = nombre + ' ' + primerApellido + ' ' + segundoApellido + ' ' + accionFormativa;
    var pdfBlob = DriveApp.createFile(newDoc.getAs(MimeType.PDF));

    destinationFolder.createFile(pdfBlob).setName(pdfFileName + ".pdf");

    DriveApp.getFileById(newDoc.getId()).setTrashed(true);
    copiedDoc.setTrashed(true);

But nothing seems to work right

Typescript generics: union of generic types that extend string

I have a function that takes one parameter of type: Options. Type Options contains a couple of properties (obj1 and obj2) that are basically plain old js objects and an item property whose value should be a key of obj1 or a key of obj2. Is it possible to achieve this in typescript? Here’s what I tried:

declare function f<t1 extends string = never, t2 extends string = never>(opts?: Options<t1, t2>): void;

export interface Options<t1 extends string = never, t2 extends string = never> {
    obj1: {[K in t1]: any}
    obj2: {[K in t2]: any}
    item: t1 | t2;
}

// this should work but doesn't
f({
    obj1: {
        red: null,
        green: null
    },
    obj2: {
        black: null,
        white: null
    },
    item: 'white'
});

Basically I was hoping that type argument t1 would resolve to red | green and t2 to black | white so that t1 | t2 would resolve to red | green | black | white. Instead what happens seems to be that t1 | t2 is first resolved to white, then both t1 and t2 are inferred to be white as well. Any hint?

Stop the scroll event listener in React.js

I’m trying to stop listening to the scroll event because I need to control when the event should scroll and when to remove the scroll event.

I’m trying to e.prevent but it doesnot work. Is there any way to controll the scroll by using react-js?

const handleScroll = (e) => {
        //I need to stop scrolling when a certain condition is true
        if (e.target.scrollHeight == 0) {
            // e.removeEventListener('scroll', handleScroll); DOES NOT WORK
            //e.pree.preventdefault() DOES NOT WORK    
        } else {
            //Turn on the listenner
        }
       
    }

    return (
        <main onScroll={handleScroll}data-status={valor}>
              <div>Conteudo</div> 
        </main >
    );

If you guys can help me i really appreciate it. Thanks for all, Have a good day.

How to find vowels in given sting?

I have requirement like if the given string contains vowels it should print the founded vowels , if it does not contain vowels it should print message like no vowels found.

function findVowels(str) {

    const vowels = ['a', 'e', 'i', 'o', 'u'];

    const foundVowels = str.contains(vowels);

    if (foundVowels.length > 0) {
        console.log('Found vowels:', foundVowels.join(', '));
    } else {
        console.log('No vowels found.');
    }
}

const inputString = "Hello, World!";
findVowels(inputString);

Going to Anchor Text inside a Bootstrap Tab

I’m trying to create a URL link that opens a particular page at a particular element (a form).

But the element is inside a bootstrap tab on that page.

To get the correct tab to open I’ve followed this javascript Twitter Bootstrap Tabs: Go to Specific Tab on Page Reload or Hyperlink

As I now have a # hashtag for the tab in the URL I can’t seem to find how to add second hashtag or element reference.

Any thoughts on how I can open the page to the form inside the second tab?

My tabs:

<div class="col-md-12">
     <ul class=" nav-tabs nav">
         <li id="tab-1" class="active nav-tab nil-tick ">
             <a href="#stays" data-toggle="tab" aria-expanded="false">List<span class="pronoun"> a</span> Stay </a>
         </li>
         <li id="tab-2" class="nil-tick">
             <a href="#experiences" data-toggle="tab" aria-expanded="false">List<span class="pronoun"> an</span> Experience </a>
         </li>
         <li id="tab-3" class="nil-tick">
             <a href="#other" style="color:unset" data-toggle="tab" aria-expanded="false"> Other </a>
         </li>
     </ul>
 </div>

And the section I wish to link to

<form class="subscribe_form" method="POST" style="background:white" id="experience-application-form" autocomplete="off">

And the javascript

  // Javascript to enable link to tab
  var hash = document.location.hash;

  var prefix = "tab-";
  if (hash) {
      $('.nav-tabs a[href="' + hash.replace(prefix, "") + '"]').tab('show');
  }

  // Change hash for page-reload
  $('.nav-tabs a').on('shown.bs.tab', function (e) {
      window.location.hash = e.target.hash.replace("#", "#" + prefix);
  });

How to prevent the alpha-values to add together on html canvas

If I set globalAlpha=0.5 and draw two rectangles that overlap, the overlapping area will be totally opaque:

image of two overlapping rectangles

Is there any way to prevent this behaviour? I just want everything to have an alpha value of 0.5. So the overlapping area should be of the same color and transparency as the rest.

I already tried to play around with globalCompositeOperation but it did not solve my problem.