JQUERY has fail to post to php script, its giving an error Uncaught ReferenceError with the login form. How can i fix this please?

I have a websites uses JQUERY,AJAX and PHP for the login Form.The website that has different types of accounts ie Buyers and Sellers accounts,

  1. When a Seller is logging both on localhost and Remote server it accepts to login but When Buyers is logging in on LocalHost is accepting login when it comes to a remote server(Host server) the login form keeps on refreshing without giving any error on the form, i checked on the Chrome Developer tool to debug its giving me two errors (i) Uncaught Reference Error: start_loader is not defined

AHK/Python/Java/PortableApp File renamer for multiple srt/sub files utility?

I’ve been looking for a renamer utility for AHK [v2] that has multiple panels, where lets say you have 3 windows.

ex:

LeftWindow:”SeriesName S06e06 Title [Quality].mkv” MiddleWindow:”SeriesName-Title-S06e06[2021].srt” ThirdWindow: NamesPreview: “SeriesName S06e06 Title [Quality].Eng.srt”

“SeriesName S06e07 Title [Quality].mkv” and on the right “Series-S6e07[2021].srt”
“SeriesName S06e08 Title [Quality].mkv” and on the right “Name-Title-S6e8[2020].srt”
“SeriesName S06e09 Title [Quality].mkv” and on the right “name-Title-S6e9[2001].srt”

an on the tird windows a preview of the name the files on the second windows would look like.
also IDK if you can add an option to lets say change/add/remove the extensions name or type. or for instance replace function of “replace .mp4 for .Eng.srt.

so the output would be “SeriesName S06e06 Title [Quality].Eng.srt”.

any help is greatly appreciated.

I have tried some utilities around, but nothing really has got what I’ve really been looking for.

I tried:
https://github.com/majkinetor/multi-rename-script

https://www.reddit.com/r/AutoHotkey/comments/loehzo/i_made_a_tool_for_batch_renaming_subtitles_files/

https://www.autohotkey.com/boards/viewtopic.php?t=111142
https://www.reddit.com/r/AutoHotkey/comments/rvhp0e/simplest_regex_multi_files_renamer/

How to get the result from API with Axios

I’ve started learning API. I’ve made an app where the API has this result (It’s the F1 Motorsport API” from RapidAPI

{
    "standings":{
       "id":"0",
       "name":"Driver",
       "displayName":"Driver Standings",
       "season":2024,
       "seasonType":2,
       "entries":[
          {
             "athlete":{
                "id":"4665",
                "uid":"s:2000~a:4665",
                "displayName":"Max Verstappen",
                "abbreviation":"VER",
                "name":"Max Verstappen",
                "shortName":"M. Verstappen",
                "flag":{
                   "href":"https://a.espncdn.com/i/teamlogos/countries/500/ned.png",
                   "alt":"Netherlands",
                   "rel":[
                      "country-flag"
                   ]
                }
             },
             "stats":[
                {
                   "name":"rank",
                   "displayName":"Rank",
                   "shortDisplayName":"RK",
                   "description":"Rank",
                   "abbreviation":"RK",
                   "type":"rank",
                   "value":1,
                   "displayValue":"1"
                },
                {
                   "name":"championshipPts",
                   "displayName":"Points",
                   "shortDisplayName":"PTS",
                   "description":"Championship Points",
                   "abbreviation":"PTS",
                   "type":"points",
                   "value":393,
                   "displayValue":"393",
                   "topFinish":1
                },
          {
             "athlete":{
                "id":"5579",
                "uid":"s:2000~a:5579",
                "displayName":"Lando Norris",
                "abbreviation":"NOR",
                "name":"Lando Norris",
                "shortName":"L. Norris",
                "flag":{
                   "href":"https://a.espncdn.com/i/teamlogos/countries/500/gbr.png",
                   "alt":"Britain",
                   "rel":[
                      "country-flag"
                   ]
                }
             },
             "stats":[
                {
                   "name":"rank",
                   "displayName":"Rank",
                   "shortDisplayName":"RK",
                   "description":"Rank",
                   "abbreviation":"RK",
                   "type":"rank",
                   "value":2,
                   "displayValue":"2"
                },
                {
                   "name":"championshipPts",
                   "displayName":"Points",
                   "shortDisplayName":"PTS",
                   "description":"Championship Points",
                   "abbreviation":"PTS",
                   "type":"points",
                   "value":331,
                   "displayValue":"331",
                   "topFinish":1
                },
}

But when I implement it in my code like this

import React, { useEffect, useState } from "react";
import { StyleSheet, View, Text, TouchableOpacity, FlatList } from "react-native";
import axios from "axios";

function DriverStandings(props) {
  const [standings, setStandings] = useState([]);

  useEffect(() => {
    const fetchStandings = async () => {
      const options = {
        method: "GET",
        url: "https://f1-motorsport-data.p.rapidapi.com/standings-controllers",
        params: { year: "2024" },
        headers: {
          "x-rapidapi-key": "api key example",
          "x-rapidapi-host": "f1-motorsport-data.p.rapidapi.com",
        },
      };

      try {
        const response = await axios.request(options);
        setStandings(response.data.standings.entries);
      } catch (error) {
        console.error(error);
      }
    };

    fetchStandings();
  }, []);

  const renderItem = ({ item }) => {
    const rank = item.stats.find(stat => stat.name === "rank")?.displayValue;
    const points = item.stats.find(stat => stat.name === "championshipPts")?.displayValue;
    const driverName = item.athlete.displayName;

    return (
      <TouchableOpacity
        onPress={() => props.navigation.navigate("DriverDetail", { driverId: item.athlete.id })}
        style={styles.button}
      >
        <View style={styles.rect2}>
          <Text style={styles.number}>{rank}</Text>
          <Text style={styles.name}>{driverName}</Text>
        </View>
        <View style={styles.rect3}>
          <Text style={styles.points}>{points}</Text>
        </View>
      </TouchableOpacity>
    );
  };

  return (
    <View style={styles.container}>
      <FlatList
        data={standings}
        renderItem={renderItem}
        keyExtractor={(item) => item.athlete.id.toString()}
      />
    </View>
  );
}

export default DriverStandings;

The result won’t load and it says that undefined id when I check it through console? What’s wrong with my code. Is it because I called it wrongly in my code? Thanks in advance

p-dropdown Stopped Working After Upgrading From primeng 9 to primeng 10

I have a 3 p-dropdown components that are shown or hidden based on what tab the user is on in a modal. When the component loads, 3 api calls are made to the 3 endpoints that supply the entries for the 3 dropdowns and those objects are stored in 3 lists. The html looks like this:

<p-dropdown
     *ngIf="activeTabIndex === 0"
     [style]="{'z-index': '9999', 'width': '430px'}"
     name="skillId"
     id="skillId"
     placeholder="Skill Requirement"
     [filter]="true"
     optionLabel="label"
     [options]="skillsVocab"
     [(ngModel)]="selectedCapability"
></p-dropdown>
...two more dropdowns with activeTabIndex 1 and 2...

I know the api calls and the tab index variable is working, because I put in console logs that are showing the expected outputs of 0 and a list of objects that populate the dropdown. I have other dropdowns in the project that still work just fine and are set up similarly, the main difference here is the use of ngIf. This dropdown worked just fine in primeng 9 and didn’t start having an issue until the upgrade to 10, but I don’t see anything in the 10 changelog that would indicate the need to change how the options are written. When clicking the dropdown, the component flashes for a single frame like it’s trying to load but nothing appears. There are no errors in the console.

Manually placing div start and end tags with javascript

I use Madcap Flare to write web help. This comes with useful proxies that auto-generate navigation when built. I need to manipulate one of these proxies. This is important because I have to work within the structure they use, and can’t just add my div in the html as usual.

PLEASE NOTE: I cannot directly change the html in this situation. I can only add css or javascript.

So here’s the problem. I need to add <div class="eplanation-wrapper"> before <p class="explanation-heading"> and it’s closing </div> after the last <p class="explanation-item">.

I’ve gotten the selectors to work and place the inserts in the correct places, but they are registering as strings, not code.

(The other heading/item class pairings will get the same treatment)

<div class="MCRelationshipsProxy_0">
    <p class="explanation-heading">Related Articles</p>
    <p class="explanation-item"><a href="">link</a></p>
    <p class="explanation-item"><a href="">link</a></p>
    <p class="explanation-item"><a href="">link</a></p>
    <p class="howTo-heading">How To Guides</p>
    <p class="howTo-item"><a href="">link</a></p>
    <p class="reference-headaing">Reference Articles</p>
    <p class="reference-item"><a href="">link</a></p>
</div>

<script>
    const explanationHeading = document.querySelector('p.explanation-heading');
    explanationHeading.before('<div class="explanation-wrapper">');

    const explanationItem = document.querySelectorAll('p.explanation-item');
    const lastExplanationItem = explanationItem[explanationItem.length - 1];
    lastExplanationItem.after('</div>');
</script>

Current broken state:
current broken state

GOAL :

<div class="MCRelationshipsProxy_0">
    <div class="explanation-wrapper"><p class="explanation-heading">Related Articles</p>
    <p class="explanation-item"><a href="">link</a></p>
    <p class="explanation-item"><a href="">link</a></p>
    <p class="explanation-item"><a href="">link</a></p></div>
    <p class="howTo-heading">How To Guides</p>
    <p class="howTo-item"><a href="">link</a></p>
    <p class="reference-headaing">Reference Articles</p>
    <p class="reference-item"><a href="">link</a></p>
</div>

I have tried:

before() after()

prepend() append()

insertAdjacentHTML(beforebegin / afterend)

insertAdjacentText(beforebegin / afterend)

JS window.prompt executing before all code

I’m trying to make a text-based fight simulator for myself based on undertale (why not?) and I’m using JavaScript with an HTML shell so it can run in a browser.

Here is my [UNFINISHED!!] code example:

const enemy = 'Mettaton'.toUpperCase();
const player = window.prompt("Enter your Name, Player").toUpperCase();
let enemyHP = 500;
let enemyMercy = 0;
let playerHP = 150;

document.write(`${enemy} attacks!`);
document.write('<br>');
document.write(`Your stats:`.toUpperCase());
document.write('<br>');
document.write(`${playerHP} HP`);
document.write('<br>');

function yourTurn() {
  let yourMove = window.prompt("FIGHT, ACT, CHECK, or SPARE").toUpperCase();
  switch (yourMove) {
    case "FIGHT" || "fight" || "Fight":
      document.write(`${player} used FIGHT!`);
      document.write('<br>')
      let fightPower = Math.floor(Math.random() * 100 / 5);
      document.write(`${enemy} took ${fightPower} damage!`)
      enemyHP = enemyHP - fightPower
      break;
    default:
      document.write(`Invalid.`)
  }
}

function enemyTurn() {
  let enemyPower = Math.floor(Math.random() * 100 / 3);
  document.write('<br>')
  document.write(`${player} took ${enemyPower} damage!`)
}

yourTurn();
enemyTurn();

For some reason, the prompt that asks for your move (or how you choose to attack) before the stats and the enemy’s name is even displayed!!
How do I get the code above a prompt to run first?

jsPDF Center Text Alignment Doesn’t Work with setCharSpace

I am using jsPDF in a project and mostly have things working as expected. If, however, I decide to change the default character spacing to any non-zero value, centering gets thrown off by the character spacing and text eventually bleeds off the right edge of the page if the value is set high enough. Is there any way to get the alignment property working properly with setCharSpace that I’m missing? If not, is there some way to construct a calculation that accounts for the character spacing?

const lineHeight = 1.35;
const doc = new jsPDF({
    unit: "mm",
    lineHeight: lineHeight,
});

const margin = 24;
const fontSize = 10;
const pageWidth = Math.round(doc.internal.pageSize.width);
const pageHeight = Math.round(doc.internal.pageSize.height);
const maxLineWidth = pageWidth - 2 * margin;
const charSpace = 0.3; // Default = 0
const para = 'This is my repeating text. '.repeat(100);

let textLines = doc
    .setFont("Helvetica", "normal") //
    .setFontSize(fontSize)
    .setCharSpace(charSpace)
    .splitTextToSize(para, maxLineWidth);

JavaScript – YouTube Live, Chat

Can you help me write simple code in JavaScript. I haven’t studied the intricacies of the code and don’t want to delve into the details. I need to connect the chat to the broadcast.

The page contains a live broadcast from YouTube located in an <iframe>.

<iframe width="560" height="315" src="https://www.youtube.com/embed/live_stream?channel=UCM-n0BKVvTOxC45B4yxZQpA" frameborder="0" allowfullscreen></iframe>

From <iframe> you need to get the video identifier. Once it has been opened to the user.

In <iframe> → <head> you need to copy the video identifier.

<link rel="canonical" href="https://www.youtube.com/watch?v=I0Km7xrqN-g">

And replace the video identifier in chat

<iframe height="500" width="300" src="https://www.youtube.com/live_chat?v=I0Km7xrqN-g&embed_domain=stackoverflow.com" style="border: 0; width:300px; height:100px; background-color: transparent;"></iframe>

Sample code

<iframe id="yt" width="560" height="315" src="https://www.youtube.com/embed/live_stream?channel=UCM-n0BKVvTOxC45B4yxZQpA&autoplay=1" frameborder="0" allowfullscreen></iframe>
<iframe id="chat" height="500" width="300" src="https://www.youtube.com/live_chat?v=<IDVideo>&embed_domain=stackoverflow.com" style="border: 0; width:300px; height:100px; background-color: transparent;"></iframe>
<script>

</script>

<link rel=”canonical” href=”https://www.youtube.com/watch?v=I0Km7xrqN-g“>

<IDVideo> → I0Km7xrqN-g


It is not possible to use .php since the resource is hosted on https://github.io/ I’m self-taught, but I’ve seen a lot of things JavaScript does. And I think it is possible to do. This is all due to the fact that the video identifier is unique for each broadcast. And there is no universal link for the chat.

I would be happy if I knew. But for me it’s hard. I will be grateful if you can help.

Chrome extensions exchange message between extension script (from popup) and content script (not isolated)

I’m writing Chrome Extension where my extension script needs some data for current tab. I have content script which have access to DOM and window object. It is run with “world” “MAIN” property, non isolated, because I want access to actual window object with augmented with specific data with third party script. I have following code:
Manifest.json:

{
  "manifest_version": 3,
  "name": "Plugin",
  "version": "1.0",
  "description": "Plugin",
  "permissions": [
    "cookies",
    "activeTab",
    "storage",
    "scripting",
    "tabs"
  ]
  "host_permissions": [
    <list of urls>
  ],
  "content_scripts": [
    {
      "world": "MAIN",
      "js": ["content.js"],
      "matches": [
        <list of urls>
      ]
    }
  ],
  "action": {
    "default_popup": "popup.html"
  },
  "icons": {
    "16": "icon_16x16.png",
    "48": "icon_48x48.png",
    "128": "icon_128x128.png"
  }
}

content.js

chrome.runtime.onConnect.addListener(port => {
    if (port.name === 'test') {
        port.postMessage({
            type: 'test',
            status: window.someCustomProperty,
        })
    }
});

And my script from popup.html

const port = chrome.tabs.connect(activeTabId, {name: 'test'});

port.onMessage.addListener((message) => {
  resolve(message.status);
  console.log('MESSAGE', message);
});

port.onDisconnect.addListener(() => {
  reject();
  console.log('DISCONNECTED');
});

Problem is that it isn’t working. When I run my content.js script with "world": "MAIN" in manifest.json, chrome.runtime is undefined. When I run content.js script without "world": "MAIN", window.someCustomProperty is undefined, because it runs in isolation. I’ve read several resources about similiar problem on SO and web, but none solved this issue.

TypeScript definitions for `zip` and `zipObj` functions

I would like to combine/reuse the type definitions for the following functions.

const zip = <T, K>(arr1: readonly T[], arr2: readonly K[]): Array<[T, K]> => arr1.map((k, i) => [k, arr2[i]])

const zipObj = <T extends string, K>(arr1: readonly T[], arr2: readonly K[]): { [key: string]: K} => 
  Object.fromEntries(zip(arr1, arr2))

// usage
const names = ['bob', 'sally', 'dave'] as const
const ages = [50, 40, 30] as const

const myEntries = zip(names, ages) // [['bob', 50], ['sally', 40], ['dave', 30]]
const myObj = zipObj(names, ages) // { 'bob': 50, 'sally': 40, 'dave': 30 }

How could I define type GeneralZipFunction in a way that re-uses T and K but allows me to A) override the return type and B) specify that T needs to extend string.

Ideally I could write:

const zip: GeneralZipFunction<some specifiers go in here> = // zip implementation
const zipObj: GeneralZipFunction<some specifiers go in here> // zipObj implementation

I’m using vite Vanlilla js framework ,want to connection my API but the api url port is the same as host port

I Have a problem with setting API proxy in vite.config.js
when I run NPM dev to my web and want to call API it is not using the proxy that I have defined, instead it is using my host debug URL.

I am expecting it to obey my set API target http://127.0.0.1:29985, instead it is using http://localhost:5173 as you can see in this snip from the network trace:

weberror

500 error is because the URL is wrong.

This is my JS code that calls the API

 try {
      const response = await axios.get("/api/Home/getdayoff");
      const data = response.data; 
      this.populateTable(data);
    } catch (error) {
      console.error("Error fetching data:", error);
    } finally {
      table.removeAttribute("loading"); 

      table.addEventListener("row-click", (e) => {
        const selectedRow = e.detail.row;
        const rowData = Array.from(selectedRow.cells).map(
          (cell) => cell.innerText
        );
        console.log(rowData);
        dialog.open = true;
        const leaveType = rowData[0];
        document.getElementById("type").value = leaveType;
      });
    }

this is my vite.config.js where I have configured the proxy

import { sync } from "glob";
import path from "path";
import { defineConfig } from "vite";

export default defineConfig({
  root: "src",
  build: {
    target: "es2022", 
    outDir: "../dist",
    emptyOutDir: true,
    rollupOptions: {
      input: sync("./src/**/*.html".replace(/\/g, "/")),
    },
  },
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src/assets"),
    },
  },
  server: {
    host: "0.0.0.0",
    proxy: {
      "/api": {
        target: "http://127.0.0.1:29985",  //It should proxy to this url 
        changeOrigin: true, 
        secure: false, 
        rewrite: (path) => path.replace(/^/api/), 
      },
    },
  },
});

How can I get the API URL at runtime to resolve to the proxy that I have configured?

How to regex replace a repeated sequence?

For example, if there a sequence of 2 or more :0000: then I like to replace them with :.

In the code below, the result should be 2a00:1450:4028:805::00001111:2005 but it just ignores the replacement, so I guess it requires a lookahead.

BTW, if it’s just a single :0000: then it should be replaced with :0:, but this should be fairly easy once the real issue is solved. Note I’ve deliberately used 00001111 to make sure it doesn’t get replaced.

let str = document.getElementById("input").textContent; 
let res = str.replace(/(:0000:){2,}/g, ":");
document.getElementById("output").textContent = res;
Before:
<p id="input">
2A00:1450:4028:080B:0000:0000:00001111:2005
</p>
After
<p id="output">
</p>

A Simple Electron App with a Button that calls a function reports to the console

/*
Hello everyone, I am working for the first time with electron. I have used JavaScript before. Can someone please show me what I am doing wrong trying to get the button onclick event to call a simple function with a console.log operation in it. Any help would be appreciated because I am not sure where all the pieces go together.

Here’s my code:
*/

// main.js
const { app, BrowserWindow, ipcMain } = require("electron");

let win = null;

const createWindow = () => {
  win = new BrowserWindow({
    width: 800,
    height: 600,
    resizable: false,
    webPreferences: {
      nodeIntegration: true
    }
  });

  win.loadFile("index.html");
};

app.whenReady().then(createWindow);

ipcMain.on("callMyFunction", (event, data) => { 
  // Prints inside the label called funcCallTxt
  funcCallTxt.innerHTML =  "This event: " + event + " and This data: " + data;

  // Writes to the console just to see what in the variables
  console.log("This event: " + event + " and This data: " + data) 
});



// renderer.js
const { contextBridge, ipcRenderer } = require("electron");

contextBridge.exposeInMainWorld("electron", {
    send: (channel, payload) => ipcRenderer.send(channel, payload),
});


// index.html
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script defer src="renderer.js"></script>
        <title>Call a Function</title>
    </head>
    <body>
        <h1>A Function Call</h1>
        <label for="funcCallTxt"></label>                
        <button type="button" onclick="callMyFunction()">Call My Function</button>
    </body>
</html>

Function in addEventLister is not called (JavaScript + w2ui)

I have a JavaScript frontend where I use w2ui elements.
I have a nested layout as follows.

  let layout = new w2layout(outerConfig.layout);
  let grid = new w2grid(outerConfig.grid);
  let formLayout = new w2layout(innerConfig.layout);
  let form = new w2form(innerConfig.form);

  layout.render('#ownskillsdiv');
  layout.html('left', grid);
  layout.html('main', formLayout);
  formLayout.html('main', form);
  formLayout.html('bottom', '<div id="ownskillsbuttoncontainer" style="width: 100%;"></div>');

In the bottom part I dynamically add and remove buttons depending on which row is selected in the grid. Example code for adding a button:

  let ownSkillsButtonDiv = document.getElementById("ownskillsbuttondiv");

  while(ownSkillsButtonDiv.childNodes[0] ) {
    ownSkillsButtonDiv.removeChild(ownSkillsButtonDiv.childNodes[0]);
  }
  
  let btn = document.createElement('button');
  ownSkillsButtonDiv.append(btn);
  btn.id = "ownskillformsave";
  btn.innerText = "Save";
  btn.className = "w2ui-btn";
  btn.addEventListener("click", function() {
    console.log("Save");
  });  

Adding and removing buttons works fine. If I call document.getElementById() after the code block above, I get the button, so it is part of the DOM.

The issue is that the addEventListener callback function is not called (i.e. nothing is printed)

What could be wrong? Who can I fix it?

Thank you