Can you use a substitute for the keyword const?

I’m trying to make a simple counter, but its proving difficult, $ was undefined, but I used:

function jQuery($) {
  'use strict';
  $(function() {
    //code here
  });
};

While that fixed the $ problem, i can’t figure out how to make the counter. This is my code:

var counter = 0;
    
function appendNumber() {
  const newElement = document.createElement('div');
  newElement.textContent = counter;
  document.body.appendChild(newElement);
  counter++;
}

It says it’s reserved i need some other way to do const, as it says “The keyword const is reserved.”
If you find a solution to this, or a different way to do a counter, it would be much appreciated.

I tried just using a var, then using append, but it just appended x. (the var’s name)
This was some of the code I tried:

function jQuery($) {
  'use strict';
  function findAnswer() {
    x = parseInt(x);
  }
  $(function() {
    var $counter = $( ".counter" );
    if (x < 0) {
      answer = x * y;
    }
    $( ".counter" ).append("answer");
    $( ".clickme" ).on("click", function() {
      answer++;
      $( ".counter" ).append ("answer")
    });
  });
}

The parseInt was an idea I had, because is school, it had me make a calculator, using parseInt.

Decrypt cloud storage file

I am trying to decryt cloud storage files. Those files have a header that I want to skip.

For example, this file is composed of [cloud storage header + salt + content + cloud storage footer]. Lets say salt is ‘SALT’.

------WebKitFormBoundaryMpzAvNgQ8HhW5A8i
Content-Disposition: form-data; name="file"; filename="blob"
Content-Type: application/octet-stream

SALTáB†nJÎÆBÂÀ?ó“´ZM¥SJz·xM×±È(ºKéGw#²ÇœQëKBt'ø%ÄkæsUA-h]aWA¯(•Ÿ€Ø&©€
------WebKitFormBoundaryMpzAvNgQ8HhW5A8i--

My decrypt function works fine for ‘normal’ files but returns undefined for cloud storage ones. I have tried to skip/delete header but I am missing something. The footer problem I haven’t figured out how to solve it yet.

... some code...
const file = input.file;

const GCP_HEADER = await readGGCPHeader(file);
const header = await readSignatureAndHeader(file, SIGNATURE, HEADER_SIZE, GCP_HEADER);
const decRx = decodeKeys(publicKey.value, privateKey.value);
const state = initializeDecryption(header, decRx);

let buffer = [];
let index = SIGNATURE.length + HEADER_SIZE;
while (index < file.size) {
  const offset = index + CHUNK_SIZE + ABYTES_SIZE;
  const chunk = file.slice(index, offset);
  index = offset;

  // Decrypt the chunk and update the decrypted buffer
  buffer = await decryptChunk(chunk, state, buffer);

  // Define a new blob and set output element to it
  const blob = new Blob(buffer, { type: "application/octet-stream" });
  input.file = blob;
}

async function readSignatureAndHeader(file, signature, HEADER_SIZE, GCP_HEADER) {
  const fileReader = new FileReader();
  fileReader.readAsArrayBuffer(file.slice(0, signature.length + HEADER_SIZE + GCP_HEADER.length));

  const signatureAndHeader = await new Promise((resolve) => {
    fileReader.onload = () => resolve(new Uint8Array(fileReader.result));
  });

  return signatureAndHeader.slice(signature.length + GCP_HEADER.length);
}

async function readGGCPHeader(file) {
  const fileReader = new FileReader();
  fileReader.readAsArrayBuffer(file);

  const header = await new Promise((resolve) => {
    fileReader.onload = () => {
      const text = new TextDecoder().decode(fileReader.result);
      const gcpHeaderEnd = text.indexOf("SALT");
      resolve(new Uint8Array(fileReader.result.slice(0, gcpHeaderEnd)));
    };
  });

  return header;
}

I think the problem is related to how I read the headers and the salt in the readSignatureAndHeader function.

How to keep annotations within range in ApexCharts?

I’ve got a chart with a couple of annotation points in it. One of these points is within the Y-axis range, but the other is not.

Is there a way to automatically have ApexCharts include every annotation within the rendering range so that all annotations are always visible at least?

This is what my chart looks like:

import ApexCharts from "apexcharts";

var options = {
  chart: {
    type: "line",
  },
  series: [
    {
      name: "sales",
      data: [30, 40, 35, 50, 49, 60, 70, 91, 125],
    },
  ],
  xaxis: {
    categories: [1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999],
  },
  annotations: {
    points: [
      {
        x: 1993,
        y: 150,
        marker: {
          size: 4,
          fillColor: "#f00",
          strokeColor: "transparent",
        },
      },
      {
        x: 1996,
        y: 50,
        marker: {
          size: 4,
          fillColor: "#f00",
          strokeColor: "transparent",
        },
      },
    ],
  },
};

var chart = new ApexCharts(document.querySelector("#chart"), options);

chart.render();

Here is a working example of my chart and the annotations.

Adding reveal.js presentations to an existing site?

I have several reveal.js presentations, and I want to host them online so that I can access them from anywhere, rather than just on my laptop. I also host a blog site using the static engine Hugo, which serves up html pages. Hugo has the concept of “pages”: currently one page contains the blog posts, another one has a little bit about me, and another lists all the blog tags. It would be easy to add a page called “presentations”.

My presentations include text, mathematics with MathJax, and various interactive diagrams included as iframes. It would be very nice to include everything in a single html file, with reveal.js material from a CDN such as

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/reveal.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/reveal.min.css" rel="stylesheet">

I also have a few local files, such as my own theme. I don’t know whether the files above include plugins (for mathematics, menus, highlighting) or whether they have to included as well.

I appreciate that questions similar to this have been asked before, but most seem to be several years old, or involve github, which I’d rather avoid, since every time I attempt to use it I get caught up in an almighty tangle and confusion. Anyway, I don’t need version control or sharing, just an online presence.

Anyway, I’d be happy of any advice!

Twilio is sometimes turning brackets (`[`, `]`) into angle brackets (“)

I’m using the twilio api (specifically, the nestjs twilio module) and my texts have a structure like this: “[company name] some notification” with square brackets.

Sometimes the square brackets will be replaced by angle brackets. Does anyone have an idea why this might be happening?

example replacments:

“[company name] some notification” -> “[company name> some notification”

“[company name] some notification” -> “<company name> some notification”

Changes to js file not picked up for Blazor server app

I just noticed a strange behavior in Visual Studio 22 ver 17.11.5.

If I add a function to .js file, add a call to the function on a razor page and hit F5, I get an exception that the method cannot be found. This used to work just fine.

If I add a new .js file and add it to _Layout.cshtml it works for a little bit. That is, I can add new functions and they are picked up, but at some random point, changes to this new file also stops being picked up.

Anyone else seeing this?

Programatically Select eventMarker with Anychart Stock v8

How do I programmatically choose which eventMarker is selected using Anychart Stock? I have a modal that appears when you click a eventMarker to provide more info, and I want to be able to navigate between the markers using he modal rather than having to click on the graph again

(this seems to have been possible in previous versions, but I can’t seem to figure it out in v8)
see example of previous version: https://6.anychart.com/products/stock/online-demos/html-js-samples-center/selecting-event-markers/index.html#sampleView

When reviewing the documentation (https://docs.anychart.com/Stock_Charts/Event_Markers/Basics#individual_markers) I cannot find any methods that can select a specific eventMarker, only configure the behavior when eventMarkers are selected

Does the Outlet rerender with the parent component in React JS?

I have useWindowSize hook that triggers each time when the window is resized so the MainWrapper component rerenders many times. But the Outlet element is not rerendered. Is that allright?
Are there any documentation links to that?

const MainWrapper = () => {
  useWindowSize();

  return (
    <Layout className={styles.layout} hasSider>
      <Sider />
      <Layout className={styles.container}>
        <Layout.Content id="layoutContentRoot">
          <Suspense fallback={<Loading />}>
            <Outlet />
          </Suspense>
        </Layout.Content>
      </Layout>
    </Layout>
  );
};
export default MainWrapper;

How to set time zone with data-fns isSameDay function

I have a chunk of code where I need to see if two dates are on the same day. What I have found is that if one date is after 7pm, the “isSameDay” function from date-fns returns a false.

If I create two javascript date objects for the two dates I am comparing and compare the two with getDay, getMonth, and getFullYear, it fails as well.

I believe that there is some time zone issue going on and I expected date-fns functions to account for time zone – or at least allow for it. The problem is that if this is the case, I don’t see it in the documentation.

javascript library is not loaded into an angular typescript project

We are trying to build a javascript library (dwbn-event-webcomponents), that can be imported into a typescript project (angular 17) and also used standalone. It was installed via npm from git url.

In the angular project however, we get the following error:

event.module.ts:5:0-52 - Error: Module not found: Error: Can't resolve 'dwbn-event-webcomponents' in 'src/app/modules/ondemand'

The package.json of dwbn-event-webcomponents looks like this:

{
  "name": "dwbn-event-webcomponents",
  "version": "1.0.8",
  "description": "A powerfull but easy to integrate web component",
  "main": "src/js/events-webcomponents.js",
  "module": "src/js/events-webcomponents.js",
  "source": "src/js/events-webcomponents.js",
  "types": "types/event-webcomponents.d.ts",
  "type": "module",
  "keywords": [
    "events"
  ],
  "devDependencies": {
    "@inquirer/prompts": "^7.0.1",
    "clean-webpack-plugin": "^4.0.0",
    "gulp": "^5.0.0",
    "semver": "^7.6.3",
    "typescript": "^5.6.3",
    "webpack": "^5.95.0",
    "webpack-stream": "^7.0.0"
  },
  "engines": {
    "node": ">= 18"
  }
}

The files are all in the defined location and we have generated the typescript type definition file via npx tsc.

How can we resolve this error and make the library usable in a typescript project?

Conflict between fabric.js and @imgly/background-removal-node causing Sharp module errors in Next.js

I’m working on a Next.js project where I’m using both fabric.js and @imgly/background-removal-node. The @imgly/background-removal-node package depends on sharp for background removal functionality. My project works perfectly on the main branch where @imgly/background-removal-node alone is used. However, once I add fabric.js in a new branch, I start seeing errors related to sharp, specifically:

Something went wrong installing the "sharp" module
\?C:UsersUsernameDesktopmyprojectnode_modules@imglybackground-removal-nodenode_modulessharpbuildReleasesharp-win32-x64.node

Steps Taken:

Reinstalled sharp with npm install sharp.
Tried loading fabric.js dynamically to reduce conflicts.
Attempted various versions of fabric.js and sharp to check compatibility issues.

Despite these attempts, I keep getting sharp module errors as soon as fabric.js is installed. If I remove fabric.js, everything works again.

Environment:

Node.js version: 20.10.0
"next": "14.0.4",
"@types/fabric": "^5.3.0",
"fabric": "^5.3.0",
"@imgly/background-removal": "^1.4.5",
"@imgly/background-removal-node": "^1.4.5",

Question:
Has anyone encountered a similar conflict between fabric.js and sharp dependencies in Next.js? Are there any known compatibility issues or specific configurations required to get both fabric.js and @imgly/background-removal-node working together without causing sharp errors?

Any guidance or alternative approaches to prevent these conflicts would be greatly appreciated!

Node,js code not printing 24 bits colors in Git Bash terminal, But direct commands works

I’m experiencing a weird problem with printing 24-bit colors in the Git Bash terminal using Node.js. When I run a simple JavaScript script that uses ANSI codes to print 24-bit (true color) text, only the basic 16 colors are displayed. However, when I run a direct ANSI command in the Git Bash terminal, the 24-bit colors display perfectly. This problem doesn’t happen with other terminals(windows cmd in my case).

It seems that the issue might be related specifically to Node.js in Git Bash. Has anyone else encountered this, or is there a known workaround to get Node to display 24-bit colors in Git Bash?

Expanding on tests and context:
my node version is v20.10.0, my git version is 2.47.0.windows.2 and my OS is Windows.

This is a simple JavaScript code to test the colors:

console.log("x1b[38;2;255;0;0m█x1b[38;2;200;0;0m█")
process.stdout.write("x1b[38;2;255;0;0m█x1b[38;2;200;0;0m█")
process.stdout.write('x1b[0mn');

Executing through Git Bash it display only one basic color (console.log and process.stdout.write present the same result):
bash doesn’t display the full colors

If I execute the same command in a Windows cmd terminal it gives the correct colors:
cmd display the full colors

However! If I do the equivalent code directly into bash terminal, it gives the expected result:
bash displays the colors with direct code

These test imply that the code works on other terminals and that bash is capable of displaying the correct colors.
I feel that it has to have an obvious reason. But, I wasn’t able to find any mention to this specific problem.

Audio playing onload and not onclick (involves webpack)

I’m making a note sequencer web application and I am currently trying to implement the function of playing a note on pressing a button corresponding to the note. I am currently using a test sound to understand how playing audio works as this is my first time dealing with audio in HTML.

I am also using webpack, and my problem at first was getting webpack to recognize the mp3 file, but I quickly solved that by using file-loader.

Now my problem lies in the fact that the test audio I am using does not play on the click of a button, but does play perfectly fine onload of the site. There are no errors given to me by the console.

Here is script.js: (note: this may be poorly written for the meantime of me understanding this issue)

import "./style.css";
import myAudioResource from './click-234708.mp3';

const CONTROL_BAR = document.createElement("div");
CONTROL_BAR.id = "control-bar";

const MAIN_BAR = document.createElement("div");
MAIN_BAR.id = "main-bar";

const testbutton = document.createElement("button");
const testaudio = new Audio();
testaudio.src = myAudioResource;
testbutton.addEventListener('click', testaudio.play())
MAIN_BAR.appendChild(testbutton);

const SCALE_BAR = document.createElement("div");
SCALE_BAR.id = "scale-bar";

const MAIN = document.createElement("div");
MAIN.id = "main";

MAIN.appendChild(CONTROL_BAR);
MAIN.appendChild(MAIN_BAR);
MAIN.appendChild(SCALE_BAR);
document.body.appendChild(MAIN);

I want to make testaudio play on clicking testbutton, and NOT onload of the site.

Here is webpack.config.js:

const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');

module.exports = {
  mode: 'development',
  entry: "./src/script.js",
  devtool: 'inline-source-map',
  output: {
    filename: "main.js",
    path: path.resolve(__dirname, 'dist'),
    clean: true,
  },
  plugins: [
    new HtmlWebpackPlugin({
      title: 'Leitmotif',
      filename: 'index.html',
      template: './src/template.html',
    })
  ],
  module: {
    rules: [
      {
        test: /.css$/,
        use: ['style-loader', 'css-loader'],
      },
      {
        test: /.mp3/,
        loader: 'file-loader',
      },
    ],
  },
};

I attempted some of the solutions in this forum but to no avail.

I do believe this could be a problem with the way I’ve written my program, considering I have to also ensure everything works well with webpack. I have tried different syntaxes and creating separate functions to play the audio, but all of it just ended up playing the audio on load again.

Can anyone help out here?

I cannot save the incoming data of communication to the database

I partially divided the asp mvc net8 html component into communication parts in the form of createmessage. The default index directory is not saved in any way.

[Messagecontroller](https://i.sstatic.net/eAdEnZFv.png)
[/views/message/createmessage.cshtml](https://i.sstatic.net/lGYdQQq9.png)
[main.js](https://i.sstatic.net/ClTZBgrk.png)
[default/index](https://i.sstatic.net/pwlXpQfg.png)
[solution explorer](https://i.sstatic.net/pBCCttvf.png)
[sendEmail.php errors](https://i.sstatic.net/Aj47Rz8J.png)

I changed the path of sendemail.php in the javascript file and tried createmessage, but it didn’t work.
When I open the page from the createmessage view, the theme does not appear, but the boxes appear. When I fill the boxes with information and send the data, the data is stored in my database. This storage process is not in the default index.

How to link to embedded SharePoint Video similar to youtube

How can I make the “Jump to 1:30” text link jump to the embedded SharePoint video above and start autoplay at 1:30, without modifying the default start time of the embedded video? Youtube has this feature where user can post comments and link to the video above that starts at a specific time. Is it possible with SharePoint?
Here is my code

<iframe id="videoEmbed" src="abc.sharepoint.com/sites/"></iframe>

<script>   document.getElementById('jumpLink').addEventListener('click', function (e) {
    e.preventDefault(); // Prevent the default link behavior

    const videoIframe = document.getElementById('videoEmbed');
    const startTime = 90; // 1:30 in seconds

    // Send the seek command to the iframe via postMessage
    videoIframe.contentWindow.postMessage(JSON.stringify({
      event: "command",
      func: "seek",
      args: [startTime]
    }), "*");   }); </script>