Get Previous URL Path from react router v6 navigate

I want to display the success payment component in my web app only when it comes from a specific url in my case stripe payment link. I want to block its access manually. So how can I get the previous url i want to store it in a variable and then preform some checks. navigate(-1) takes me to previous url but how can i extract that url from it.

I keep getting this error: You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file

Here’s the full error:

ERROR in ./src/Component/logos.html 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

|
|

Here’s my logos.html

<!DOCTYPE html>
<html>
<head>
  <title>Page Title</title>
</head>
<body>
    <script src="https://code.jquery.com/jquery-2.2.0.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">    
    <div class="container">
        <section class="customer-logos slider">
           <div class="slide"><img src='./logo1.png'></div>
           <div class="slide"><img src='./logo2.png'></div>
           <div class="slide"><img src='./logo3.png'></div>
           <div class="slide"><img src='./logo4.png'></div>
           <div class="slide"><img src='./logo5.png'></div>
           <div class="slide"><img src='./logo6.png'></div>
         
 
        </section>
     </div>
     

</body>
</html>

here’s my webpack.config.js

module.exports = {
    module: {
      rules: [
        {
          test: /.html$/i,
          loader: 'html-loader', 
         },
      ],
    },
  };

Thanks in advance!!

I tried adding the webpack.config.js code, but the same error still occurs.

How to view hidden console errors in js?

I am inspecting chrome extension popup and I see there is an error triggered but I can’t view it. Is there a way I can se the error ? I guess, from blogs I were searching about JS errors that should be a syntax error, in this case how can I find the problem ? My code looks correct and didn’t have this issue in past, just came up from nowhere.

I tried to use try…catch on full JS file but still can’t find the error.

dyanmicly change dependent option dropdown based on parrent selection

actually i have two diffrent diffrent table first one is residential another is commercial.

residetial table have one column name city
commercial table have one column name area

i wanna if user selected residential option then change second dropdown option based column name city data

if user select commercial the data fetch commercial table from column area in same dropdown

here is the my html parrent option selection code

<div class="select-wrap style2-dropdown">
 <select class="selectpicker show-tick" name="property_type" id="property_type">
 <option value="Residential">Residential</option>
 <option value="Commercial">Commercial</option>
  </select>
   </div>

here is the child option code html and php

<div class="select-wrap style2-dropdown">
   <select class="selectpicker" name="R_Locality" id="Locality">
   <option value="">All Cities / Areas</option>
<?php
$options = "";
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
if ($property_type == "Residential") {
$options .= '<option value="' . $row["city"] . '">' . $row["city"] . '</option>';
 } 
elseif ($property_type == "Commercial") {
 $options .= '<option value="' . $row["area"] . '">' . $row["area"] . '</option>';
 }
?> 
<?php echo $options;?>
<?php
 }
 } else {
 echo "No records found.";
  }
 ?>
</select>
</div>

how to fix this problem if my code have anyone seen issue please suggest or new code generate

if anyone have an idea please given answer

Javascript sorting array day name

I’m going to sort day name based on array list day with below code:

var dayList = ['Mon', 'Fri', 'Sun', 'Wed', 'Sat'];

const map = {
   'Mon': 1,'Tue': 2,'Wed': 3,'Thu': 4,'Fri': 5,'Sat': 6, 'Sun': 7
};

dayList.sort((a, b) => {
   return map[a.day] - map[b.day];
});

console.log(dayList);

But it show me same sort result to :
[ "Mon", "Fri", "Sun", "Wed", "Sat"]

It should be like this:

[ "Mon", "Wed", "Fri", "Sat", "Sun"]

Any idea how to make it work?

how to set the files array to update?

i’m trying to update the form with the files array maybe removing or add a file and update, but when i press update button in the logs show this JSON::ParserError – Empty input (after ) at line 1, column 2 [parse.c:1058] error

this what i’ve tried

to fix this parse error i tried to refreshPreviewFileList as mentioned on here https://github.com/thetbw/jquery-uploader/issues/1

i tried to .serializeArray(); on uploadFiles and stringify the formdata even split the uploadFiles array. none of this worked to fix the ParserError, so someone can give a help?

$(document).ready(function () {
  $("#upload-input")
    .uploader({
      multiple: true,
      autoUpload: false,
      maxLength: 6,

      defaultValue:
        <%= @item.photos.map { |photo| { url: photo.image.url, name: photo.item.name } }.to_json.html_safe %>,
    })
    .on("file-remove", (event, files) => {
      console.log(files);
    });
});

$(document).ready(function () {
  $("#new_item").on("submit", function (event) {
    event.preventDefault(); // Prevent the default form submission

    // Manually submit the form after Uppy files have been added
    var form = this;
    var formdata = new FormData(form);

    //var formdata = $(this).serializeArray();

    var files = $("#upload-input").uploader("uploadFiles");

    $("#upload-input").uploader("refreshPreviewFileList");

    //$("#upload-input").uploader("refreshPreviewFileList");
    for (let i = 0; i < files.length; i++) {
      formdata.append("files[]", files[i].file);
    }

    //var data = JSON.stringify(files.serializeArray());

    //for (let i = 0; i < data.length; i++) {
    // formdata.append('files[]', data[i].file)

    //}

    // Submit the form using AJAX
    $.ajax({
      url: "/items/<%= @item.slug%>", // Change this URL to your endpoint
      method: "patch",
      data: formdata,

      contentType: false,
      processData: false,
      success: function (response) {
        console.log("Upload successful:", response);
        // Handle success as needed
      },
      error: function (response) {
        console.error("Error:", response);
        // Handle error as needed
      },

      xhr: function () {
        let xhr = new XMLHttpRequest();

        xhr.upload.addEventListener("progress", function (e) {
          let progressRate = (e.loaded / e.total) * 100;

          progressCallback(progressRate);
        });

        return xhr;
      },
    });
  });
});

files-to-upload
logs-error
logs2-error

Google Maps Polyline cannot drag corners

I have been using Google maps for many years. But I got tired of seeing the warning that I was requesting an obsolete version. So I changed the invocation to:

 <script defer src="https://maps.googleapis.com/maps/api/js?v=weekly&region=CA&key=*****&callback=initMap" 
        type="application/javascript">

But I have encountered a number of problems. I am using Google Maps to support a genealogical service. For example go to https://www.jamescobban.net/FamilyTree/Location.php?id=114191&lang=en and click on the Show Map button. This shows the boundaries of this farm lot. If this same URL is accessed by an registered user of the site the Show Map button displays an editable version of the map so the user can change the centre and the boundaries.

enter image description here

However I cannot drag the corners of the Polyline to correct the boundary. I can add new points to the end of the Polyline, but I cannot correct the positions of the existing corners. I am running Firefox 116.0.3.

var map             = null;

var path            = [];

var polyOptionsEdit = {strokeColor:     "red", 
                       strokeOpacity:   0.5,
                       strokeWeight:    2,
                       draggable:       true,   
                       editable:        true};
var boundary        = null;
var geocoder        = null;

function initMap()
{
    // support for displaying map and geocoding
    try {
        geocoder    = new google.maps.Geocoder();
    }
    catch(e)
    {
        geocoder    = null;
    }
    map             = null;
}       // function initMap

window.initMap      = initMap;
boundary = new google.maps.Polyline(polyOptionsEdit);
boundary.setPath(path);

Image Field in a pdf form using chrome

I have created a PDF form and have an image field to upload images when clicking on it but it is working in adobe acrobat but when I open the PDF in Chrome or in Firefox the Image field will not work. The following script is in the image field

event.target.buttonimporticon()

How to: I would like to make my website completely offline

I want to store my website in the user’s browser such that the second time they visit it, they should be able to use it without connecting to the internet. I have studied about SessionStorage and LocalStorage but they are not enough in my case. My website is a simple clock with 3 files, a javascript file, css file and an index.html
The link of the website text
Tell me how to store files in the user’s storage and accessing the later.
I am inspired by YouTube website and Mega cloud storage website. On the YouTube website, when I visit it while offline, it shows a nice animation saying that you’re offline. I’m sure it is not browser generated.
Also on the mega website, it downloads files in the user storage and then somehow transfers them to the download section of the browser.

I tried searching the whole web, but didn’t find any useful information.
I’m expecting to make this website completely offline. Even if the user is offline, they should be able to use it.

How can I append the data to follow columns instead of rows and add more column to input in sheet input data?

I have a code to append the data follow rows, now how can i change it to show the data follow columns instead of rows

Link google sheet

this is the output that I need

instead of

function appendEvLog() {

  // We will add our code here. 
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  // collect the data
  const sourceRange = ss.getRangeByName("InputData");
  const sourceVals = sourceRange.getValues().flat();

  // validate all cells are filled
  const anyEmptyCell = sourceVals.findIndex(cell => cell == "");
  if(anyEmptyCell !== -1){
    const ui = SpreadsheetApp.getUi();
    ui.alert(
      "Input Incomplete",
      "Please enter a value in All input cells before submitting",
      ui.ButtonSet.OK
    );
    return;
  }
  // Gather current dts and user email.
  const date = new Date();
  const email = Session.getActiveUser().getEmail();
  const data = [date, email, ...sourceVals];
  // append the data
  const destinationSheet = ss.getSheetByName("DataLog");
  destinationSheet.appendRow(data);
  // clear the source sheet rows
  sourceRange.clearContent();
  ss.toast("Success: Item Added to the data Log!");

};

hope you can help, thank you so much

Trouble with small game

Im trying to make a small game and I am having trouble displaying a randomly selected question when a specific player is chosen. Sort of hard to explain but the code helps you to understand.

I’m having problems getting the question onto the screen, then also changing the question when another button is clicked.

HTML:

    <body>
        <form>
            <input type="text" id="screen" dir="ltr" READONLY /><br><br><br>
            <script src="script.js"></script><br>
            <input type="reset" id="clear" value="C" class="outB">
        </form>
    </body>

JS:

    const Questions1 = [
        "Most likely to break a world record?", 
        "Most likely to become a CEO?", 
        "Most likely to never get married?",
        "Most likely to commit a crime?",
        "Most likely to become prime minister?",
        "Most likely to give their kid an unusual (terrible) name?",
        "Most likely to be late for everything?",
        "Most likely to get lost in their own hometown?",
        "Most likely to accidentally poison someone with terrible cooking?",
        "Most likely to lock themselves out of their own home?",
        "Most likely to cancel plans at the last moment?",
        "Most likely to be killed first if they were in a horror movie?",
        "Most likely to break their phone the first day they get it?",
        "Most likely to cry whilst watching a sad movie?"
    ]

    const Questions2 = [
        "Who is most likely to actually be a spy?",
        "Who is most likely to finish a jug of ice cream in one sitting?",
        "Who is most likely to miss their flight because they packed at the last minute?",
        "Who is most likely to call in sick at work to go to the beach?",
    ]

    var truth = Questions1[Math.floor(Math.random() * Questions1.length)]
    var lie = Questions2[Math.floor(Math.random() * Questions2.length)]


    const players = []

    numberPlayers = prompt("How many players?")

    for (i = 0; i < numberPlayers; i++) {
        const playerName = `Player ${i + 1}`;
        const playerInt = true;
        const question = "";
        players.push({ name: playerName, intention: playerInt, question: question});
    }

    players[Math.floor(Math.random() * players.length)].intention = false

    for (let i = 0; i < players.length; i++) {
        if (players[i].intention === true) {
            players[i].question = truth;
        } else {
            players[i].question = lie;
        }
    }
    console.log(players)


    for (x = 0; x < numberPlayers; x++) {
        var number = `${x + 1}`
        var btn = document.createElement("button")
        btn.id = number
        btn.textContent = number
    
        btn.addEventListener("click", function(event){});

        document.body.appendChild(btn);
    }

    function display() {


        var screenElement = document.getElementById("screen");
        screenElement.value = players[x].question;
    }

Puppeteer – Getting stack trace of what triggered ‘pageerror’ event?

So I have this pageerror event handler catching an error, and it’s working fine. But if I wanted more details from the stacktrace, I’m not sure how to do it.

Here’s what I’ve written so far

(context: reportStatus is a function that sends a status report to an API endpoint and prints to console as well. It takes the title of the status, and a callback function)

        pupPage.on('pageerror', async (error) => {
        console.log("ERROR'd");
        console.log(Object.getOwnPropertyNames(Object.getPrototypeOf(error)));


        reportStatus('WEB_APPLICATION_ERROR', async function () {
          var stackTrace;

          utl.print('Error message: ' + error);

          // GET THE STACKTRACE THAT CAUSED THE ERROR AND PRINT IT!

          quit();
        });
      });

And this is what I see in the console.

ERROR'd
[ 'constructor', 'name', 'message', 'toString' ]
WEB_APPLICATION_ERROR
Error message: ReferenceError: params is not defined
QUITTING

So I know that the error is a ReferenceError where some “params” variable is not defined. But I want to know more details, like what line in what script caused that error.

Unfortunately, it doesn’t seem like the error object has anything related to the stacktrace.

Is there a function I could use to get the stacktrace of the error that triggered the pageerror event?

Turn ON and OFF checkbox for an autocomplete function

I have a wep app that has an autocomplete feature that being triggered when the user insert’s a few specifhic words.

I would like to know how can I create a checkbox using HTML that will enable and disable the autocomplete.

Thanks,
Shoam

I was trying to find a way to do that but did not found a way, even tho I knlw it should not be too complex.

AxiosError: read ECONNRESET

I’ve encountered read ECONNRESET error while I was trying to make a get request through axios.

Configuration is as below:

import express from "express";
import bodyParser from "body-parser";
import axios from "axios";

const app = express();
const port = 3000;

app.use(express.static("public"));
app.use(bodyParser.urlencoded({ extended: true }));

Get request that I made:

app.get("/", async (req, res) => {
  try {
    const response = await axios.get("https://bored-api.appbrewery.com/random");
  } catch (error) {
    console.error("Failed to make request:", error);
  }
});

However, it turns out to be this error:

Failed to make request: AxiosError: read ECONNRESET
    at AxiosError.from (file:///C:/Users/BENLOW/Desktop/Web%20Development/2023/28.3%20Axios/node_modules/axios/lib/core/AxiosError.js:89:14)
    at RedirectableRequest.handleRequestError (file:///C:/Users/BENLOW/Desktop/Web%20Development/2023/28.3%20Axios/node_modules/axios/lib/adapters/http.js:591:25)
    at RedirectableRequest.emit (node:events:513:28)
    at eventHandlers.<computed> (C:UsersBENLOWDesktopWeb Development202328.3 Axiosnode_modulesfollow-redirectsindex.js:14:24)
    at ClientRequest.emit (node:events:513:28)
    at TLSSocket.socketErrorListener (node:_http_client:502:9)
    at TLSSocket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  syscall: 'read',
  code: 'ECONNRESET',
  errno: -4077,
  ...

Any idea on resolving the error?

Fixing “Uncaught TypeError: cannot read properties of undefined (reading ‘add’) at HTMLDivElement.”

I’m trying to make it so that hovering over any of the squares inside the play area adds the class “darken” to them. The play area generates as expected, but instead of adding the class, any time I hover over the squares in question I get “Uncaught TypeError: cannot read properties of undefined (reading ‘add’) at HTMLDivElement.”.

I’ve tried both the line with the event listener in the “createPlayArea” function and the commented out variable + function combo below and I end up with the exact same error in my chrome console.

function createPlayArea() {
    for (i = 0; i < (squareAmount * squareAmount); i++) {
        let squares = document.createElement('div')
        squares.setAttribute('style', 'display: flex; flex-wrap: wrap;')
        squares.classList.add('square')
        squares.style.height = dimensions
        squares.style.width = dimensions
        squares.addEventListener('mouseover', square => square.classList.add('darken'))
        playArea.appendChild(squares)
    }
}

createPlayArea()

// let playSquares = document.querySelectorAll('.square')

// function pen() {
//     playSquares.forEach(square => square.addEventListener('mouseover', function (e) {
//         e.classList.add('darken')
//     }))
// }

// pen()

What I was expecting is for the .darken class to be added to the squares that get hovered over. All I got was this stupid error :’)