How do I fix this cross-windows-installation persistent JavaScript error in Windows 11?

This is a very broad problem, something I’ve never encountered before and I feel as though it may be a hardware issue at this point.

To sum it up, many of my web-based programs (more specifically JavaScript, I believe), are acting up, with no solution in sight and it persists across windows installations.

I believe the issue has to do with floating point numbers not converting to integers properly, and causing errors due to that.

The list of programs that I’ve noticed being affected are:

  1. Discord
    • Fails to launch entirely
    • I have to launch it 10 – 30 times before it is functional
    • The error I get each time says “RangeError [ERR_OUT_OF_RANGE]: The value of “position” is out of range. It must be an integer. Received 1000001.0000000149″ with some variation of a slight miscalculation in the float to integer conversion. My guess is that it only launches properly when the float lands perfectly on an integer.

Discord Launch Error

  1. Chrome

    • YouTube loads strangely sometimes
    • Facebook flat out will not load my messages
    • YouTube Music sometimes stutters and skips tracks, or will freeze entirely, I will also occasionally see the track time indicator show floating point numbers
    • All Google Drive applications are basically unusable, as they’ll crash every 5 – 15, simply stating “Oops, something went wrong” and force me to refresh the page.
  2. Steam

    • Various web UI elements will sometimes crash, although not as aggressively or commonly as Google Drive, it acts much in the same way, forcing me to refresh the web UI elements, sometimes multiple times. This does include the games library sidebar, and only seems to happen when I’m scrolling…
    • Sometimes the “PLAY TIME” in a game will show a long, unrounded floating point number. E.g. “169.1000000356 hours” instead of the properly formatted 1-decimal place number.
  3. Corsair iCue?

    • Not sure if it’s related but my Corsair Scimitar won’t light up while iCue is running, really hard to say if it’s related or not because iCue itself is a steamy pile of garbage.
  4. Various Others

    • Can’t think of any offhand but I’ve seen random floating point numbers in spots that they don’t belong, in many other locations as well.

All of these problems have persisted after multiple windows reinstalls. Maybe it’s my Windows 11 install drive, maybe it’s a hardware issue, but if anyone has any advice, I’d really appreciate it. I have no idea where to begin looking to resolve this issue on my own, because 99% of searches related to JavaScript are for beginner web programmers, but this seems to be an issue with… the runtime environment? Help plz, thank you.

I’ve tried reinstalling windows, but other than that I haven’t tried anything. It did not fix the issue, I’ve tried multiple times. I’m really hoping this can be resolved with a patch or something.

URL Regex, how to enforce .tld?

I am trying to validate urls currently I have the following regex:

^(?:https?://)?(?:www.)?(?![.-])[a-zA-Z0-9]+(?:.[a-zA-Z0-9-]+)*.[a-zA-Z]{2,}(?!..)(/(?!/)[^s]*)?$

This correctly matches:

example.com
www.example.com
http://example.com
https://www.example.com
example.com/exam1/exam.php
example.com/exam
http://www.example.com.be/example-web-site
http://www.example

These are the ones it shouldn’t match, it correctly doesn’t:

.example.com
www.example.-com
www.example.com//ex
www.example..com

However it matches these last 2 while it shouldn’t

www.example/ex
www.example

I have tried to find a solution but can’t really find how to make those 2 not match while not breaking the rest.

Discord.JS Show Modal Error (Announcement Creation Bot)

I am making a command for my bot that when you the /createannouncement it shows a modal that you can put in the information for. it keeps coming up with an error and also in discord saying “The Application Did Not Respond”

this code worked before when i only had it replying to the message and using emphemeral idk why modals hate me but they do,

I followed the discordjs.guide websites guide on it but it just errors and idk why

This Is the code that i have:

const { SlashCommandBuilder, EmbedBuilder, ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle} = require('discord.js');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('createannouncement')
        .setDescription('Creates An Announcement')
        .addChannelOption(option =>
                        option
                            .setName('announcement-channel')
                            .setDescription('The Channel to Send the Announcement to')),
    
    async execute(interaction) {
        const channel = interaction.options.getChannel('announcement-channel');
        
        const announcementModal = new ModalBuilder()
            .setCustomId('announcementCreator')
            .setTitle('Announcement Creator');
        
        const announcementTitleInput = new TextInputBuilder()
            .setCustomId('announcementTitleInput')
            .setLabel('Announcement Title')
            .setStyle(TextInputStyle.Short);
        
        const firstActionRow = new ActionRowBuilder().addComponents(announcementTitleInput);
        
        announcementModal.addComponents(firstActionRow);
        
        await interaction.showModal(announcementModal);
        //await channel.send({content: 'your announcement will look like this:', embeds: [announcementEmbed]});
    },
};

And The Error:

DiscordAPIError[10062]: Unknown interaction
    at handleErrors (/home/container/node_modules/@discordjs/rest/dist/index.js:727:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async BurstHandler.runRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:831:23)
    at async _REST.request (/home/container/node_modules/@discordjs/rest/dist/index.js:1272:22)
    at async ChatInputCommandInteraction.showModal (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:257:5)
    at async Object.execute (/home/container/src/commands/tools/createannouncement.js:28:9)
    at async Object.execute (/home/container/src/events/client/interactionCreate.js:12:9) {
  requestBody: { files: undefined, json: { type: 9, data: [Object] } },
  rawError: { message: 'Unknown interaction', code: 10062 },
  code: 10062,
  status: 404,
  method: 'POST',
  url: 'https://discord.com/api/v10/interactions/1300260874266742834/aW50ZXJhY3Rpb246MTMwMDI2MDg3NDI2Njc0MjgzNDpxeDBNTlhpd1FXam95UzhYUHp5b0tXQnRRUmNxRnVwenFMb1BXNXMwOEw2M1VBcElhMTJpbzdSSWQ4eFNERHd1T211OHA0VHFjaFR1MEkyeWoxY01kdEZmakxtS3hVakN2SEFXWjZ3RTVCQXlDRDU2Q3lCcFZKZktqYmVxVUQxMQ/callback'
}
node:events:491
      throw er; // Unhandled 'error' event
      ^
DiscordAPIError[10062]: Unknown interaction
    at handleErrors (/home/container/node_modules/@discordjs/rest/dist/index.js:727:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async BurstHandler.runRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:831:23)
    at async _REST.request (/home/container/node_modules/@discordjs/rest/dist/index.js:1272:22)
    at async ChatInputCommandInteraction.reply (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:115:5)
    at async Object.execute (/home/container/src/events/client/interactionCreate.js:15:9)
Emitted 'error' event on Client instance at:
    at emitUnhandledRejectionOrErr (node:events:394:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
  requestBody: {
    files: [],
    json: {
      type: 4,
      data: {
        content: 'Something went wrong...',
        tts: false,
        nonce: undefined,
        enforce_nonce: false,
        embeds: undefined,
        components: undefined,
        username: undefined,
        avatar_url: undefined,
        allowed_mentions: undefined,
        flags: 64,
        message_reference: undefined,
        attachments: undefined,
        sticker_ids: undefined,
        thread_name: undefined,
        applied_tags: undefined,
        poll: undefined
      }
    }
  },
  rawError: { message: 'Unknown interaction', code: 10062 },
  code: 10062,
  status: 404,
  method: 'POST',
  url: 'https://discord.com/api/v10/interactions/1300260874266742834/aW50ZXJhY3Rpb246MTMwMDI2MDg3NDI2Njc0MjgzNDpxeDBNTlhpd1FXam95UzhYUHp5b0tXQnRRUmNxRnVwenFMb1BXNXMwOEw2M1VBcElhMTJpbzdSSWQ4eFNERHd1T211OHA0VHFjaFR1MEkyeWoxY01kdEZmakxtS3hVakN2SEFXWjZ3RTVCQXlDRDU2Q3lCcFZKZktqYmVxVUQxMQ/callback'
}
Node.js v19.9.0

Injecting JavaScript in WordPress plugin

The following code works as expected on my WordPress setup, but when I send it to my friend who is running a cPanel managed version of WordPress, the JavaScript never runs. I can inspect the DOM and see that the js-test div is inserted though, verifying that the php ran. Any thoughts on what might be causing this? Am I doing something improper with the way I am enqueuing the script? I’d ideally like to only enqueue the script if the plugin’s shortcode is present on the page, to avoid an unnecessary request.

js-test.php

<?php
/*
Plugin Name:  JS Test
Description:  JS Test
Version:      1.0
License:      MIT
License URI:  https://opensource.org/license/mit
*/

add_shortcode( 'js_test', function( $atts, $content, $tag ) {
  add_action("wp_enqueue_scripts", function() {
    wp_enqueue_script('js-test', plugin_dir_url( __FILE__ ) . 'js-test.js');
  });

  return "<div id='js-test' />";                                                
});

js-test.js

document.addEventListener('DOMContentLoaded', function() {
  const target = document.getElementById("js-test");                            
  console.log('target: ', target);
  if (target == null) {
    return;
  }

  target.innerHTML = "hello!!!";
});

How do I make a JavaScript editor, html editor, and css editor in html

Ive been trying to find some code for three of these editors. I’m making a huge update to my app kitty cat for developers and I wanted to add more programming languages the app is made in appcreator24 and you can’t download in apps made in that website and the only code app creator supports is html

I was expecting to find a GitHub page with open source code but nothing was there

Google Script with Time-Base trigger: email are sent, but without data

I am looking for guidance!

I have a Google Sheet that is populated from a Google Form. From those data (in the Google Sheet), I am doing some test, and I would like the Google Script to send me an email with some information.

For testing purpose, I am using a time based trigger set to Every Minutes; once I know it works, I will go back to once a day.

In the same spreadsheet, I have 2 sheets: INPUT and analysis.

  • The Google Form fills in the INPUT sheet.
  • On the analysis sheet, I do the test using from data that have a live link from INPUT to analysis (updating the data in the destination sheet analysis whenever changes are made in the source sheet INPUT).

The issue I am having:

  • when I manually execute the Google Script, the Execution Log shows correct values (see below), AND the email is sent the way I would like to, with the numerical values (see below):
Execution log:
5:41:37 PM  Notice  Execution started
5:41:48 PM  Info    23.0
5:41:52 PM  Info    300.0
5:41:52 PM  Info    150.0
5:41:52 PM  Info    No
5:41:52 PM  Info    Do Not Send EMail
5:41:55 PM  Notice  Execution completed
Email:
Oil Change due soon! Current time on oil is: 300 FH; remaining: 150 FH.
  • now, when I let the Google Script executes with the time based trigger, I got the email (yeah!), and the text in the body of the email, but WITHOUT numerical values (see below): the 300 and 150 are missing.
Email:
Oil Change due soon! Current time on oil is:  FH; remaining:  FH.

(For testing purpose, I am sending the email, regardless of the test condition).

I am not sure where the issue is. For me, if I manually run the Google Script and the output is correct, the automatic triggered execution should provide the same output…

I think I am not too far, but I can’t figure out what I am doing incorrectly.

Any help would be much appreciated!

Thank you very much!!

Here is my Google Script:

//@OnlyCurrentDoc
function MaintenanceEmail(e) {
  if(SpreadsheetApp.getActiveSheet().getSheetName() != "analysis") return;

  //find the last input, looking at the Date Submission column.
  var Avals = SpreadsheetApp.getActiveSheet().getRange("A1:A").getValues();
  var Alastend = Avals.filter(String).length;
  Logger.log(Alastend);

  //############################ OIL CHANGE
  var cellL1 = SpreadsheetApp.getActiveSheet().getRange("L"+ Alastend).getValue();  //Time on oil
  var cellM1 = SpreadsheetApp.getActiveSheet().getRange("M"+ Alastend).getValue();  //Time on oil remaining
  var cellN1 = SpreadsheetApp.getActiveSheet().getRange("N"+ Alastend).getValue();  //Oil due?
  Logger.log(cellL1);
  Logger.log(cellM1);
  Logger.log(cellN1);

  if(cellN1 == "Oil Change due"){
    Logger.log("Send EMail");
    MailApp.sendEmail({
      to: "[email protected]",
      subject: "Aircraft: Oil Change due soon",
      body: "Oil Change due soon! Current time on oil is: " + cellL1 + " FH; remaining: " + cellM1 + " FH."
    });
  } else {
    Logger.log("Do Not Send EMail");
    MailApp.sendEmail({
      to: "[email protected]",
      subject: "Aircraft: Oil Change due soon",
      body: "Oil Change due soon! Current time on oil is: " + cellL1 + " FH; remaining: " + cellM1 + " FH."
    });
  }
  //############################ OIL CHANGE
}

The trigger is the following (see picture).
enter image description here

Chart Js; Bar chart; Can the X axis labels be simply left aligned/justified rather than appearing centered?

Can the labels on the X axis be left aligned/justified as opposed to appearing centered like the following example?

i.e. the requirement is that the label should be aligned with the grey vertical separation line of each bar.

Original X Axis Labels

Left Justified X Axis Labels

I have read the documentation and it seems it maybe possible via “ticks:” using the “userCallback function overrides” to modify the x-axis label itself, but I am unsure if I am over complicating this, and if this is the correct way to do it – And then if it is the correct way, then what ticks: attribute/option/parameter is required to left justify the label?

Or is there a simpler way other than using ticks/userCallback?

Snippet of code…

xAxes: [{
  ticks: {
    userCallback: function(value, index, values) {
      return value ??? Not sure what return here/ barWidth???
    }
  }
}]

Thanks

Convert pixel to percentage React-Native javascript

I’m building an app on RN and I made the mistake to put my values in pixels instead of percentages so it fits with all screen sizes…
Can someone help me convert those values into percentage in my javascript code ?

buttonContainer: {
flexDirection: ‘row’,
justifyContent: ‘space-between’,
width: ‘80%’,
marginTop: 10,
},
arrowButton: {
padding: 10,
marginHorizontal: ‘50%’,
marginLeft: ‘0%’,
},
arrowImage: {
width: 60, // Adjust the width as needed
height: 40, // Adjust the height as needed
right: ‘30%’,
marginHorizontal: ‘10%’,
top: ‘150%’,
},
selectButton: {
marginBottom: ‘10%’,
paddingVertical: 10,
paddingHorizontal: 20,
backgroundColor: ‘#007BFF’,
borderRadius: 8,
left: ‘1%’,
},

How to get the file URL from hyperlinked file name in Google Sheets cells with an app script code

I have some image files in my google drive folders. I have gotten their links and have put them in cells of column G of my google sheets file. they were too long so i decide to make the lookalike “image11.jpg” but hyperlinked (blue color).

now i need to get their created date by a code. code are working very fine with google drive links but not vworking with hyperlinked file names.

so please help me with a code to get created date from hyperlinked file name automatically

Issues Rendering Plotly OHLC Plot with EJS and Passing Data

I am trying to render a Plotly OHLC plot in my chart.ejs file and pass a variable called result to it. However, when I attempt to use EJS templating to include result in the chart.ejs file, the plot does not display. I also tried using <script> tags for the logic, but the plot still doesn’t show. I made another file chart.js to contain the logic concerning the plot but I’m not sure how to make it work.

What could be causing this issue, and how can I successfully render the Plotly OHLC plot with the result data in my EJS template?

index.js:

import express from "express";
import axios from "axios";

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

app.use(express.static("public"));
app.set("view engine", "ejs"); // Set EJS as the view engine

const base_url = "https://api.coingecko.com/api/v3";

app.get("/", (req, res) => {
  res.render("index.ejs", { result: null, error: null });
});

app.get("/ohlc", async (req, res) => {
  const { id, currency, days } = req.query;

  if (!id || !currency || !days) {
    return res
      .status(400)
      .json({ error: "Please provide id, currency, and days parameters." });
  }

  try {
    const ohlc_result = await axios.get(`${base_url}/coins/${id}/ohlc`, {
      params: {
        vs_currency: currency,
        days: days,
      },
    });

    let day = [];
    let open = [];
    let high = [];
    let low = [];
    let close = [];

    for (let i = 0; i < ohlc_result.data.length; i++) {
      const unix_timestamp = ohlc_result.data[i][0];
      const date = new Date(unix_timestamp);
      const formattedDate = date.toISOString().split('T')[0];

      if (!day.includes(formattedDate)) {
        day.push(formattedDate);
        open.push(ohlc_result.data[i][1]);
        high.push(ohlc_result.data[i][2]);
        low.push(ohlc_result.data[i][3]);
        close.push(ohlc_result.data[i][4]);
      }
    }

    // Create the OHLC trace
    const result = {
      x: day,
      open: open,
      high: high,
      low: low,
      close: close,
      type: "ohlc",
      increasing: { line: { color: "#17BECF" } },
      decreasing: { line: { color: "#7F7F7F" } },
    };

    console.log("OHLC Result:", ohlc_result.data);
    console.log("Formatted Result:", result);
    res.render("chart.ejs", { result: result });

  } catch (error) {
    console.log(error.message);
    res.status(500).send(error.message);
  }
});

app.listen(port, () => {
  console.log(`Server is running on port ${port}`);
});

chart.js:

const trace = {
    x: result.x,
    open: result.open,
    high: result.high,
    low: result.low,
    close: result.close,
    type: "ohlc",
    increasing: { line: { color: "#17BECF" } },
    decreasing: { line: { color: "#7F7F7F" } },
};

const layout = {
    title: "OHLC Chart",
    dragmode: "zoom",
    xaxis: {
        title: "Date",
        type: "date",
    },
    yaxis: {
        title: "Price",
        type: "linear",
    },
};

Plotly.newPlot("ohlc-result-div", [trace], layout);

chart.ejs:

<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>CryptoLens</title>
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
        <link rel="stylesheet" href="styles/main.css">
        <script src='https://cdn.plot.ly/plotly-2.35.2.min.js'></script>

        <!-- <script src="/chart.js" defer></script> -->

    </head>

    <body>
        <h1>OHLC Chart</h1>

        <!-- THE FOLLOWING DOES NOT WORK -->
        <!-- <script>
            const trace = {
                x: result.x,
                open: result.open,
                high: result.high,
                low: result.low,
                close: result.close,
                type: "ohlc",
                increasing: { line: { color: "#17BECF" } },
                decreasing: { line: { color: "#7F7F7F" } },
            };

            const layout = {
                title: "OHLC Chart",
                dragmode: "zoom",
                xaxis: {
                    title: "Date",
                    type: "date",
                },
                yaxis: {
                    title: "Price",
                    type: "linear",
                },
            };

            Plotly.newPlot("ohlc-result", [trace], layout);
        </script> -->

        <div id="ohlc-result-div"><!-- Plotly chart will be drawn inside this DIV --></div>
    </body>

</html>

I understand that there is some issue with sending over result to chart.ejs, I’m just not sure what.

How to use a JS SDK Payment API for Woocommerce WordPress website at checkout?

The payment gateway provider has a wordpress plugin but it does not have all the gateway functions built in and also they have a seperate portal made available to merchants to get following data;

Merchant ID :
LC13106
API Key :
Merchant Secret Key :
Confirmation Endpoint
Endpoint

Private key

Download
Server Public key

Download
Public key

Download

Their most uptodate plugin can be downloaded here;
https://www.npmjs.com/package/directpay-ipg-js

IPG User Wise Card Management API Documentation https://justpaste.it/7w34p

IPG Integration Payment Link V1.0.1 Integration document https://justpaste.it/gj7ny

I need support to help setup all this on wordpress explain steps need to setup as If I know nothing about JS, HTML, CSS or APIs

Installed plugin provided by them and researched all options inside their merchant portal but those functions provided by sdk seem to have no GUI to be easily accessed and edited

Why it shows 1 item on y array when selecting

below code shows the output expected for code:

let x = [10, 20, 30, 40];
let y = [50, 60];
x.reverse().push(y[0,1]);
console.log(x);
// [40, 30, 20, 10, 60];

when adding “y” array it only shows one element

let x = [10, 20, 30, 40];
let y = [50, 60];

x.reverse().push(y[1,0]);
console.log(x);
// (5) [40, 30, 20, 10, 50]

x.reverse().push(y[1,0]);
// (5) [40, 30, 20, 10, 50]

import method to other file without ES6 in firefox extension

I develop web extensions for the browser. I have a js file code from which is designed to create a specific ui on the site page, the problem here is that I do not want to duplicate this code in 2 different content_scripts for different pages of the site.

Since I want my application to work also for firefox, I cannot use the basic method import because it is not available in firefox on manifest_version 3.

What are the current workarounds to solve this problem? I currently have 1 working option such as creating a ui by calling code from background.js

Evaluate Bezier Curve like cubic-bezier in css

My problem is simple I want to get the value at a specific t value of a Bezier curve that has 2 points. One at position (0, 0) and the other at position (1, 1). Both have one tangent with both an x and y coordinate. Weirdly, when I scoured the internet I ended up with both the x and y coordinate at the t value. Is it possibly to make a method that takes both tangents x and y coordinates as a parameter and returns the evaluated value like it is with the cubic-bezier transition effect.

I have tried implementing Wikipedia’s formula for evaluating curves as well as De Casteljau’s algorithm but neither worked. I tried to just use the y coordinates but the the formula calculated all the x coordinates separately from the y coordinates. So the tangent x coordinates where not taken into account which is not what I want.

I don’t care about the programming language although Javascript would be preferred. Mathematical formulas would be OK too. Thanks in advance :).

Chaining requests to PokeAPI

My app have to connect to PokeApi to obtain 12 random pokemons,now it’s doing this by randomly selecting 12 pokemon IDs and calling the API 12 times in the form:

fetch(`https://pokeapi.co/api/v2/pokemon/${id}`)

I wonder if there’s some way to chain those IDs in the url and recieve 12 objects in one JSON.
My full fetching code:

export async function fetchPokemons() {
  let pokemonIDs = [];

  let pokemons = [];
  for (let i = 0; i < 12; i++) {
    pokemonIDs.push(getRandomPokemonID());
  }
  const promises = pokemonIDs.map(async (id) => {
    const promise = await fetch(`https://pokeapi.co/api/v2/pokemon/${id}`);
    return promise.json();
  });
  pokemons = await Promise.all(promises);
  console.log(pokemons);
  pokemons = pokemons.map((pokemon) => ({
    id: pokemon.id,
    pokeName: pokemon.name,
    image: pokemon.sprites.other["official-artwork"].front_default,
    reactID: uuidv4(),
  }));

  return pokemons;
}