Cannot use import statement outside a module using NPM

This is my first time trying this kind of setup.

I’m following this article to develop a “Google Sheets Reader”.

Here is what I have tried:

  1. Executed this command npm install g-sheets-api --save-dev in my local project folder, which created a node_modules folder and some files in it.

  2. Cloned this project inside my project folder.

List item

  1. When I browse the page, it shows the error in console.
    enter image description here

index.html:

 <!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8" />
    <title></title>
  </head>
  <body>
    <main id="output">...loading</main>        
    <script src="./index.js"></script>
  </body>
</html>

index.js:

import GSheetProcessor from '../src/gsheetsprocessor.js';  

....  

....  

In the index.js, i have modified the file reference path to ../src/gsheetsprocessor.js.

Webshop with external programm to upload products [closed]

Best practises for sending data to a database then retrieving data and adding items to the website

Hello everyone, I am programming a website and I would like to know from best practises, how to send data like Products from a Java Programm to a Database and then add the products to the webshop after the database sent a trigger.

Do you have a good approach that is common?

How do I go about this please?

Windows_NT 10.0.19044
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Users\Legitxl\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! node v20.11.0
npm ERR! npm  v2.15.12

npm ERR! Unsupported URL Type: npm:wrap-ansi@^7.0.0
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm ERR! Windows_NT 10.0.19044
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Users\Legitxl\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! node v20.11.0
npm ERR! npm  v2.15.12

npm ERR! Unsupported URL Type: npm:string-width@^4.2.0
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm ERR! Windows_NT 10.0.19044
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Users\Legitxl\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! node v20.11.0
npm ERR! npm  v2.15.12

npm ERR! Unsupported URL Type: npm:strip-ansi@^6.0.1
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npx create-next-app@latest myapp

How do I toggle visibility of google translate, depending on the screen width?

My HTML:

   <div id="header_row">
        <div id="topmost_header">
            <span class="left" id="location"><span class="fas fa-map-marker"></span>Locate us</span>
            <div id="about_contact">
                <span id="about">About us</span>
                <span id="contact_us">Contact us</span>
            </div>
        </div>
        <header>
            <div id="logo-text-container">
                <img id="second" src="/images/rrb_logo.png" alt="RRB Logo">
                <h1>Railway Recruitment Board - Guwahati</h1>
            </div>
            <div id="logo-text-container-1">
                <div id="google_translate_element"></div>
                <img src="/images/emblem.png" alt="Indian emblem">
            </div>
        </header>
    
    <footer>
        <div style="text-align: center;">
            <div id="google_translate_element"></div>
        </div>
    </footer>

My CSS:

        .goog-logo-link {
            display:none !important;
        } 
    
        .goog-te-gadget{
            color: transparent !important;
        }

My JS:

     function toggleGoogleTranslateElement() {
        var headerGoogleTranslate = document.querySelector("#header_row header 
        #google_translate_element");
        var footerGoogleTranslate = document.querySelector("footer #google_translate_element");

        if (window.innerWidth <= 1000) {
            headerGoogleTranslate.style.display = "none";
            footerGoogleTranslate.style.display = "block";
        } else {
            headerGoogleTranslate.style.display = "block";
            footerGoogleTranslate.style.display = "none";
        }
    }

    toggleGoogleTranslateElement();

    window.addEventListener('resize', function() {
        toggleGoogleTranslateElement();
    });

        function googleTranslateElementInit() {
            new google.translate.TranslateElement({pageLanguage: 'en' , includedLanguages : 'en,hi'}, 'google_translate_element');

            var googleDiv = document.querySelector("#google_translate_element .skiptranslate");
            var googleDivChild = document.querySelector("#google_translate_element .skiptranslate div");

            // Remove the next sibling of the child div
            if (googleDivChild.nextElementSibling) {
                googleDivChild.nextElementSibling.remove();
            }

            // Remove text nodes that are empty or only contain whitespace
            Array.from(googleDiv.childNodes).forEach(function(node) {
                if (node.nodeType === Node.TEXT_NODE && node.nodeValue.trim() === '') {
                    googleDiv.removeChild(node);
                }
            });
        }

My problem:

Right now the google_translate inside the header is showing, and the one inside footer is not. I want to keep it this way, until the screen width is less than or equal to 1000px, in which case the one inside header should be invisible and the one inside footer should be visible. But when I check the console, even though the google_translate inside footer’s display is block, it never shows. Where am I going wrong?

Request via Fetch and performing the function of drawing markers in OSM MAP

I am engaged in drawing objects on OSM maps on OPEN Layers. I get a json array via Fetch

    $(document).ready(function () {
    var pointsStation = []
    fetch('getdata.php')
    .then(response => response.json())
    .then(data => {
    data.forEach(point => {
    var newPoint = {
    id: point.idstation,
    name: point.stationName,
    timearr: point.timearrft,
    timesend: point.timesendft,
    cords: [point.longitude, point.latitude]
    };
    pointsStation.push(newPoint);
    });
    console.log(pointsStation);
    })

Further, this array is used in the functions of adding markers – bus stops. And the problem is that these functions are trying to be completed when the request has not yet been completed and the array with the data is not ready, as I understand it. Here are the functions:

    function addMarkerStations() {
    for (var j = 0; j < pointsStation.length; j++) {
    var iconFeature = new ol.Feature({
    geometry: new ol.geom.Point(ol.proj.transform(pointsStation[j].cords, 'EPSG:4326,'EPSG:3857')),
    name: pointsStation[j].name,
    timearr: pointsStation[j].timearr,
    timedep: pointsStation[j].timedep,
    id: 'station-' + pointsStation[j].id
    });
    var iconStyle = new ol.style.Style({
    image: new ol.style.Icon({
    scale: 0.28,
    opacity: 0.8,
    src: "https://school.stnorbert.org/wp-content/uploads/2018/01/bus-stop-filled-100.png"
    })
    });
    iconFeature.setStyle([iconStyle]);
    iconFeatures.push(iconFeature);
    }
    iconSource = new ol.source.Vector({features: iconFeatures});
    }
    function addLabelStations() {
    for (var j = 0; j < pointsStation.length; j++) {
    var labelFeature = new ol.Feature({
    geometry: new ol.geom.Point(ol.proj.transform(pointsStation[j].cords, 'EPSG:4326','EPSG:3857')),
    name: pointsStation[j].name,
    timearr: pointsStation[j].timearr,
    timedep: pointsStation[j].timedep,
    id: 'station-' + pointsStation[j].id
    });
    var labelStyle = new ol.style.Style({
    text: new ol.style.Text({
    font: '12px Arial',
    text: pointsStation[j].name,
    overflow: true,
    fill: new ol.style.Fill({
    color: '#000'
    }),
    stroke: new ol.style.Stroke({
    color: '#000',
    width: 0.5
    }),
    textBaseline: 'bottom',
    textAlign: 'top',
    rotation: 0,
    offsetY: -8
    })
    });
    labelFeature.setStyle([labelStyle]);
    labelFeatures.push(labelFeature);
    }
    labelSource = new ol.source.Vector({
    features: labelFeatures
    });
    }
    addMarkerStations(pointsStation);
    addLabelStations(pointsStation)

I need these functions to take the elements of the woop mass of the resulting from the server and are used for drawing. As I said, it all was implemented by JS Open Layers.

What are good Ashley furniture store near Oxford Circus

If you’re in search of a premier furniture store near Oxford Circus that offers a wide selection of nice-looking yet affordable Ashley furniture store, you’re in luck. There are several Ashley furniture stores in Edmonton that fit this description perfectly.

One such store is located near Oxford Circus and is known for its exceptional collection of Ashley furniture. They offer a range of stylish and high-quality pieces that are sure to elevate the aesthetic appeal of your home, all at affordable prices.

Whether you’re looking for a new sofa, dining set, bedroom furniture, or any other type of Ashley furniture, this store has got you covered. Their knowledgeable staff will assist you in finding the perfect pieces to suit your style and budget. Visit this page : Soletren swivel chair

When it comes to Ashley furniture in Edmonton, this premier store stands out from the rest. With their commitment to offering both quality and affordability, they have become a go-to destination for those seeking stylish yet reasonably priced furnishings.

Visit this premier Ashley furniture store near Oxford Circus and experience the perfect blend of style and affordability firsthand. Transform your living space into an inviting haven with their exquisite collection today!

What are some good Ashley furniture store near Oxford Circus that sell nice looking yet affordable furniture?

how to get buttons to have its own pop up

I have two buttons. When each is pressed, I want the user to be able to enter an answer to the same question. What I have now the button and pop up work correctly but when button1 is pressed and the user enters something when pressing button2 what was entered in button1 appears. Is there a way I can continuing using one pop up div or would I have to make one individually for each button.

here is what I currently have:

    <div class='firstRow'>
        <button class="button">animal1</button>
        <button class="button">animal2</button>
    </div>
    <div id="myPopup">
        <span id="myPopupClose">x</span>
        <h3>Enter any animal</h3>
        <textarea id="myPopupTextbox" placeholder="Write something..."></textarea>
    </div>
    <script>
        var btn = document.getElementsByClassName("firstRow")[0];;
        var popup = document.getElementById("myPopup");
        var close = document.getElementById("myPopupClose");
        btn.onclick = function () {
            popup.style.display = "block";
            $("body").css("opacity", "0.25");
        }
        close.onclick = function () {
            popup.style.display = "none";
        }

        window.onclick = function (event) {
            if (event.target == popup) {
                popup.style.display = "none";
            }
        }
    </script>

When I’m trying to generate canvas than it’s not generate properly

In a Vue.js component, I’m loading an image and then adding text with specified size, color, and font-family. After adding text, the user can drag it anywhere on the image and then download the modified image. Everything works perfectly, but when I try to create a canvas, the Y position of my text changes every time.

<template>
    <div class="col-12">
        <div ref="imageContainer" id="imageContainer" class="p-0 m-0">
            <img
                :src="photo.file_path"
                alt=""
                class="img-fluid"
                draggable="false"
                id="image"
                ref="image"
            />

            <p
                v-for="(text, index) in texts"
                :key="index"
                class="text-box mb-0"
                :style="{
                    top: text.top + 'px',
                    left: text.left + 'px',
                    color: text.color,
                    fontSize: text.size + 'px',
                    fontFamily: text.font,
                }"
                @mousedown="startDrag(index)"
            >
                {{ text.content }}
            </p>
        </div>

        <div class="col-12 mt-4">
            <div class="row">
                <div class="col-md-4 form-group mb-2">
                    <label for="textInput">Text:</label>
                    <input
                        type="text"
                        v-model="textInput"
                        id="textInput"
                        class="form-control"
                    />
                </div>
                <div class="col-md-4 form-group mb-2">
                    <label for="textSize">Text Size:</label>
                    <input
                        type="number"
                        v-model="textSize"
                        id="textSize"
                        class="form-control"
                    />
                </div>
                <div class="col-md-4 form-group mb-2">
                    <label for="textColor">Text Color:</label>
                    <input
                        type="color"
                        v-model="textColor"
                        id="textColor"
                        class="form-control"
                    />
                </div>
                <div class="col-md-4 form-group mb-2">
                    <label for="textFont">Font family:</label>
                    <select
                        v-model="textFont"
                        id="textFont"
                        class="form-control form-select"
                    >
                        <option v-for="font in fonts" :key="font" :value="font">
                            {{ font }}
                        </option>
                    </select>
                </div>
            </div>
            <div class="text-end">
                <button class="btn btn-primary" @click="addText">
                    Add Text
                </button>
                <button class="btn btn-success mx-1" @click="downloadImage">
                    Download Photo
                </button>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name: "EditPhoto",
    props: ["photo"],
    data() {
        return {
            texts: [],
            fonts: ["sans-serif", "Arial", "Times New Roman", "Courier New"],
            dragging: null,
            textInput: "",
            textColor: "#000000", // Default text color
            textSize: 100, // Default text size
            textFont: "sans-serif", // Default font family
        };
    },
    mounted() {
        window.addEventListener("mousemove", this.handleMouseMove);
        window.addEventListener("mouseup", this.handleMouseUp);

        this.setContainer();
    },
    methods: {
        setContainer() {
            const imageContainer = this.$refs.imageContainer;
            const image = this.$refs.image;

            image.onload = () => {
                // imageContainer.style.width = image.naturalWidth + 'px';
                // imageContainer.style.height = image.naturalHeight + 'px';
                imageContainer.style.overflow = 'hidden';
                imageContainer.style.position = 'relative';
            };

        },

        startDrag(index) {
            this.dragging = index;
        },

        handleMouseMove(event) {
            if (this.dragging !== null) {
                this.texts[this.dragging].left = event.pageX;
                this.texts[this.dragging].top = event.pageY;
            }
        },

        handleMouseUp() {
            this.dragging = null;
        },

        addText() {
            if (this.textInput == "") {
                toastr.success("Write something to add text.");
                return;
            }

            this.texts.push({
                content: this.textInput,
                color: this.textColor,
                size: parseInt(this.textSize),
                font: this.textFont,
                top: 100, // Initial position
                left: 100, // Initial position
            });

            this.textInput = "";
            toastr.success("Text added successfully.");
        },

        downloadImage() {
            const img = this.$refs.image;

            // Wait for the image to load before performing operations
            // img.onload = () => {
                const canvas = document.createElement("canvas");
                const context = canvas.getContext("2d");

                // Set canvas dimensions to match the displayed image dimensions
                canvas.width = img.width;
                canvas.height = img.height;

                // Draw the image
                context.drawImage(img, 0, 0, img.width, img.height);

                // Add a border to the canvas
                const canvasBorderWidth = 5; // Set the width of the border
                const canvasBorderColor = 'red'; // Set the color of the border

                context.lineWidth = canvasBorderWidth;
                context.strokeStyle = canvasBorderColor;
                context.strokeRect(0, 0, canvas.width, canvas.height);

                // Replace texts on their positions
                this.texts.forEach((text) => {
                    context.fillStyle = text.color;
                    context.font = `${text.size}px ${text.font}`;

                    const scaledLeft = text.left;
                    const scaledTop = text.top;
                    context.fillText(text.content, scaledLeft, scaledTop);

                    console.log('position:', scaledLeft, scaledTop);
                    console.log(canvas);
                });

                // Display the canvas in the image container
                const imageContainer = this.$refs.imageContainer;
                imageContainer.innerHTML = ''; // Clear existing content
                imageContainer.appendChild(canvas);

                // Use a try-catch block to handle errors when creating the download link
                try {
                    const downloadLink = document.createElement("a");
                    downloadLink.href = canvas.toDataURL();
                    downloadLink.download = "edited_image.png";

                    // Append the link to the document and trigger a click
                    document.body.appendChild(downloadLink);
                    downloadLink.click();

                    // Remove the link from the document
                    document.body.removeChild(downloadLink);
                } catch (error) {
                    console.error("Error creating or triggering download link:", error);
                }
            // };
        }
    },
};
</script>

<style scoped>
.text-box {
    position: absolute;
    cursor: pointer;
}

img {
    user-select: none;
}
</style>

I want my users to be able to upload an image, add text to it, freely drag the added text anywhere on the image, and then download the modified image.

How to Encrypt data of network payload and the response of the data that is received after hitting the api [closed]

How to Encrypt data of network payload and the response of the data that is received after hitting the api.

like there is a login page that have Email and password, it is hitting user/login Api ithis api payload Email & password is present and After the success of this request it gives the response.
in response user Details is present i want to encrypt both payload and response both.

If any one Know that please tell me

I have try using crypto-js but it not working

How to disable a URL after specific time considering the code is deployed in one time zone and client can used the app anywhere

I have an application in which , a URL is to be clicked for financial transactions, so for security reasons, i want to disable this link after a specific time , but the problem is link is not expired even after a specific time period as the code is deployed in one time zone and client is using the app on another time zone. The URL is expiring randomly.

I want to synchronize with the time period specified for the URL to expire so that the URL will disable after a specific time when the client uses the app anywhere across timezones.

i have tried to various approach:

Approach 1 : Using time

expiration_time = int(time.time()) + 5

url_temp = f”https://example.com?expiration_time=%7Bexpiration_time%7D”

return {“respmsg”: f”””To enter pin, please <a href=”{url_temp}” target=”_blank”>click here to enter pin</a>”””,}

Approach 2 : Using HTML

If we modify in the html page,then it cant work in app.also we dont want to use this approach.

Approach 3 :Using UTC

from datetime import datetime,timezone

utc_time = datetime.utcnow().replace(tzinfo=timezone.utc)

utc_time_str = utc_time.strftime(“%Y-%m-%d %H:%M:%S.%f%z+00:00”)

utc_time_format = datetime.strptime(utc_time_str, “%Y-%m-%d %H:%M:%S.%f%z+00:00”)

expiration_time = int(utc_time_format.timestamp()) + 20

url_temp = f”https://example.com?expiration_time=%7Bexpiration_time%7D”

return {“respmsg”: f”””To enter pin, please <a href=”{url_temp}” target=”_blank”>click here to enter pin</a>”””,}

Unable to catch, when a user cancels MetaMask transaction

Here is my code example:

const userAccount = '0x...';

// Call the contract method helloWorld()
const transaction = this.contract.methods
  .helloWrold('some parameter 1', 'some parameter 2')
  .send({ from: userAccount });

// Handle errors from the transaction
transaction.on('error', (error: any) => {
  console.error('Transaction error:', error);
});

// Handle success
transaction.on('receipt', (receipt: any) => {
  console.log('Transaction success:', receipt);
});

When the send() method is executed then MetaMask‘s popup appears.
And the problem is, if a user cancels the transaction by pressing cancel in that popup.

My error handler is not executed. I have tried to use different events, I have tried to use try...catch block, but that doesn’t seems to work with an async functions.

Is there any solution on this?

All I can see – that is the error in the console, that comes from MetaMask, that the user has denied to sign the transaction.

Process exited with code 1 Uncaught Error Error: Access denied for user ‘ ‘@’localhost’ (using password: NO) express js

While debugging it is showing same error ,but without debugging it is working .

I tried all solutions which i saw but till is’t working i need some suggestions

The below code is in index.js
//db connection

dotenv.config();
const connection = require("./models/index");
connecton code is present in models
const mysql = require('mysql2')

const connection = mysql.createConnection({
    host: process.env.DB_HOST,
    user: process.env.DB_USER,
    password: process.env.DB_PASSWORD,
    database: process.env.DB_DATABASE,
    port: process.env.DB_PORT,
    multipleStatements: true
});


module.exports = connection

Error is showing like this below

server is running on 8011
index.js:37
Process exited with code 1
Uncaught Error Error: Access denied for user ''@'localhost' (using password: NO)
    at asError (file:///home/rohitchitampalle/auth_process/backend_auth/node_modules/mysql2/lib/packets/packet.js:728:17)
    at execute (file:///home/rohitchitampalle/auth_process/backend_auth/node_modules/mysql2/lib/commands/command.js:29:26)
    at handlePacket (file:///home/rohitchitampalle/auth_process/backend_auth/node_modules/mysql2/lib/connection.js:481:34)
    at <anonymous> (file:///home/rohitchitampalle/auth_process/backend_auth/node_modules/mysql2/lib/connection.js:97:12)
    at executeStart (file:///home/rohitchitampalle/auth_process/backend_auth/node_modules/mysql2/lib/packet_parser.js:75:16)
    at <anonymous> (file:///home/rohitchitampalle/auth_process/backend_auth/node_modules/mysql2/lib/connection.js:104:25)
    at emit (node:events:514:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)
    at onStreamRead (node:internal/stream_base_commons:190:23)
    at callbackTrampoline (node:internal/async_hooks:130:17)
    --- TCPWRAP ---
    at init (node:internal/inspector_async_hook:25:19)
    at emitInitNative (node:internal/async_hooks:202:43)
    at Socket.connect (node:net:1176:7)
    at connect (node:net:244:17)
    at Connection (file:///home/rohitchitampalle/auth_process/backend_auth/node_modules/mysql2/lib/connection.js:50:27)
    at exports.createConnection (file:///home/rohitchitampalle/auth_process/backend_auth/node_modules/mysql2/index.js:10:10)
    at <anonymous> (file:///home/rohitchitampalle/auth_process/backend_auth/src/models/index.js:4:26)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:121:18)
    at <anonymous> (file:///home/rohitchitampalle/auth_process/backend_auth/src/index.js:10:20)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at executeUserEntryPoint (node:internal/modules/run_main:81:12)
    at <anonymous> (node:internal/main/run_main_module:23:47)