How do I insert a tab character into a string in a clipboard-friendly way?

A string in Javascript can contain tab characters. I can see this in my text editor, and I can copy-and-paste it into my browser console and operate with it (e.g, perform Regex searches for it). When I tried to replace something in the string with the tab character, the string rendered the replacement as literal characters (e.g, t). “No problem,” I thought; “it’s just the way the console renders stuff.” But when I copy-and-paste it out of the console, I copy the literal characters (e.g, and t), not the expected tab.

I’ve tried:

"word word".replace(/s/, " ") //=> "wordtword" (you can’t see it, but the "   " is a tab character copied from VS Code, and no, the console didn’t transform it to four spaces or t immediately on paste.)

"word word".replace(/s/, /t/)   //=> "word\tword"

"word word".replace(/s/, "t")   //=> "wordtword"

"word word".replace(/s/, "&#9")  //=> "word&#9word"

"word word".replace(/s/, "	") //=> "word	word"

"word word".replace(/s/, &#9)    //=> SyntaxError: Unexpected token '&'

"word word".replace(/s/, /&#9/)  //=> "word/&#9/word"

…but none of them yield a tab character that I can copy and paste between applications.

How do I change the background colour of a class at midnight everyday rather than by a user event

Currently I have a piece of code that changes the background colour of a class every 24 hours. However if a user refreshes the page, the 24 hour cycle starts from the beginning – so they would only see the colour change if they stayed on the page for 24 hours without refreshing.

Instead I want the background colour to change every 24 hours at midnight, regardless of a user event.

Here is my code as it stands:

<script>

const bgColor = ["#DA6F33", "#33B2dA", "#66BD9E", "#667FBD"];
const backgroundSection = document.querySelector(".twofirst");
let i = 0;

function changeColor() {
  backgroundSection.style.backgroundColor = bgColor[i];
  i = (i + 1) % bgColor.length;
};

setInterval(changeColor, 86400000);

</script>

the error not is identified, because dont show the place of error, I hope you can help me pleas,

i need help with this error, i can´t creat build of my proyect, when i try buil my proyect this error appears

Failed to compile.

static/chunks/pages/AdminProfile-c64c187ef918a898.js from Terser
invalid unicode code point at line 1 column 57709
Error: invalid unicode code point at line 1 column 57709
    at Object.minify (/app/node_modules/next/dist/build/swc/index.js:784:33)
    at Object.minify (/app/node_modules/next/dist/build/swc/index.js:857:21)
    at async Object.minify (/app/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js:147:44)
    at async /app/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js:203:42
    at async Span.traceAsyncFn (/app/node_modules/next/dist/trace/trace.js:151:20)

static/chunks/pages/DashBoardEgas-c4120587825a1ed1.js from Terser
invalid unicode code point at line 1 column 683614
Error: invalid unicode code point at line 1 column 683614
    at Object.minify (/app/node_modules/next/dist/build/swc/index.js:784:33)
    at Object.minify (/app/node_modules/next/dist/build/swc/index.js:857:21)
    at async Object.minify (/app/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js:147:44)
    at async /app/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js:203:42
    at async Span.traceAsyncFn (/app/node_modules/next/dist/trace/trace.js:151:20)

static/chunks/pages/index-712d2aeb780bdbd7.js from Terser
invalid unicode code point at line 1 column 135660
Error: invalid unicode code point at line 1 column 135660
    at Object.minify (/app/node_modules/next/dist/build/swc/index.js:784:33)
    at Object.minify (/app/node_modules/next/dist/build/swc/index.js:857:21)
    at async Object.minify (/app/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js:147:44)
    at async /app/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js:203:42
    at async Span.traceAsyncFn (/app/node_modules/next/dist/trace/trace.js:151:20)

static/chunks/435-9769e7a83a0e1690.js from Terser
invalid unicode code point at line 1 column 285071
Error: invalid unicode code point at line 1 column 285071
    at Object.minify (/app/node_modules/next/dist/build/swc/index.js:784:33)
    at Object.minify (/app/node_modules/next/dist/build/swc/index.js:857:21)
    at async Object.minify (/app/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js:147:44)
    at async /app/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js:203:42
    at async Span.traceAsyncFn (/app/node_modules/next/dist/trace/trace.js:151:20)


> Build failed because of webpack errors
The command '/bin/sh -c npm run build' returned a non-zero code: 1

i can´t resolve this error, can you help me?

i try update the Tarser, delete cache to my proyect, update dependences, etc, and this error doese´t disappear

The picture in HighSlide is displayed lower than it should be

The picture in HighSlide is displayed lower than it should be.
An example from the link: https://adam-platten.de/apl.php
When we open any image, we will see that it is located under the text. At the top, the inscription “Powered by Highslide” is located separately.

The only thing I could figure out is that margin is incorrectly spelled out. The example in the photo.
enter image description here

I want to achieve the result as on the website: https://adam-kuechen.de/kuecheninsel.php

I need the whole text to be under the picture.

There is access to both projects. I didn’t notice any differences when comparing the code.
I tried changing the css. I tried changing the highslide settings. I tried reinstalling the highslide library.

POST method to an API and display result in HTML for end-users

I’m trying to create a POST method to an API where I can send some data to the API and receive response for end-users to use (i.e display results in html for users to use)

I’ve tried the following JavaScript code but not working.

const apiKey = 'my_api_key_here';
const apiUrl = 'https://api.nowpayments.io/v1/payment';
const data = {
  "price_amount": 1.00,
  "price_currency": "usd",
  "pay_currency": "usdtbsc",
  "order_id": "qwerty",
  "order_description": "NewAge Novel",
};

const requestOptions = {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${apiKey}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(data),
};

fetch(apiUrl, requestOptions)
  .then(response => {
    if (!response.ok) {
      throw new Error('Network response was not ok');
    }
    return response.json();
  })
  .then(data => {
    outputElement.textContent = JSON.stringify(data, null, 2);
  })
  .catch(error => {
    console.error('Error:', error);
  });

It keeps showing me this error:

Error message

Only fire set if object data has changed in Svelte store

In Svelte, when using a writable store that takes a single primitive value (e.g. a string), when firing set multiple times for the same value, subscribe will only be called when the value changes. Demo in Svelte REPL

However, when storing a complex object, every time set is called, even if the object has the same properties, subscribe will still be fired. Demo in Svelte REPL

I’m running a fairly expensive external API call on updates (handled via subscribe), so I want to limit if the data hasn’t changed. How best should I prevent firing set or listening to subscribe if the data is the same as the previous run?

An attempt at a solution would be to keep the previous value inside a closure and compare before calling set and then carefully expose which API methods are available for consumers of the store like this:

import { writable, get } from "svelte/store";

const initialContentState = {
  title: "",
  body: "",
};

const { subscribe, set } = writable(initialContentState);

const isQuestionEqual = (a,b) => {
    return a.title === b.title && a.body === b.body;
}

const initQuestionContentStore = () => {
    let prevValue = initialContentState;

    return {
        subscribe,
        reset() {
            set(initialContentState)
        },
        setContent(content) {
                if (!isQuestionEqual(content, prevValue)) {
                    set(content);
                    prevValue = content;
            }
        }
    }
}

export const questionContentStore = initQuestionContentStore()

Demo in Svelte REPL

However, feels weird to have to keep track of the state within the store which is supposed to be responsible for keeping track of state itself. I could also use get to fetch the value from the store inside of the setContent method, but docs suggest against it for perf reasons

Note: This is similar to Why does my Svelte store subscribe() get fired when the value hasn’t changed?, but I want a workaround, not a reason.

How to get history message from pubsub with js-libp2p?

I have a pubsub connection between two nodes with js-libp2p

const libp2p = await createLibp2p({
  addresses: {
    listen: [
      '/webrtc'
    ]
  },
  transports: [
    webSockets({
      filter: filters.all
    }),
    webRTC(),
    circuitRelayTransport({
      discoverRelays: 1
    })
  ],
  connectionEncryption: [noise()],
  streamMuxers: [yamux()],
  connectionGater: {
    denyDialMultiaddr: () => {
      return false
    }
  },
  services: {
    identify: identify(),
    pubsub: gossipsub(),
    dcutr: dcutr()
  },
  connectionManager: {
    minConnections: 0
  }
})

I see this methods.

  libp2p.services.pubsub.getSubscribers()
  libp2p.services.pubsub.subscribe(topic)
  libp2p.services.pubsub.publish

Is it possible to get the history of written messages when connecting the second node?
Or where can i see interface where i will see of help about history message ?

How to change the Favicon in Storybook

I’m trying to implement Storybook into my project and I can’t seem to figure out how to change the Favicon. I’m using version 8.2.9 and I can’t find any relevant information online. I don’t have a manager-head.html file and I’ve tried things like

In my manager.ts file

document.addEventListener('DOMContentLoaded', () => {
  document.querySelector('link[rel="shortcut icon"]')?.setAttribute('href', favicon);
});

and also this in my main.ts file

config.plugins?.push(
      new HtmlWebpackPlugin({
        title: 'Title',
        favicon: './public/favicon.png', 
      })
    );

Does anyone know how to do this?

Coldfusion Scheduled task with Async function

I have an issue that I can’t figure out online to resolve.

I am using CF 2021 (Update 8) and I have my main.cfm file which will make a call to my database using Ajax (have a service.cfc file with the query), once data is retrieved from the DB, I render it on the UI and then call another function within the service.cfc file to email the UI content. This works perfectly in my browser so I assumed I could just create a scheduled task to execute main.cfm hourly and an email would be created… Boy was I wrong.

I know for a fact that email works and scheduling tasks are good as I have removed all logic in the main.cfm with just mail task and I do get the empty email.

My thought process its an async problem, so I set the Ajax async field to false but this didn’t help. Any idea of a fix for this?

Invalid `prisma.product.findMany()` invocation when deployed on Vercel

I’m trying to deploy my site after have added prisma, but keep getting this error and I don’t know how to fix this.

PrismaClientKnownRequestError: 
Invalid `prisma.product.findMany()` invocation:
Raw query failed. Code: `unknown`. Message: `Kind: Server selection timeout: No available servers. Topology: { Type: ReplicaSetNoPrimary, Set Name: atlas-3d8clu-shard-0, Servers: [ { Address: ac-fysecpf-shard-00-01.7qknsd4.mongodb.net:27017, Type: Unknown, Error: Kind: I/O error: received fatal alert: InternalError, labels: {} }, { Address: ac-fysecpf-shard-00-00.7qknsd4.mongodb.net:27017, Type: Unknown, Error: Kind: I/O error: received fatal alert: InternalError, labels: {} }, { Address: ac-fysecpf-shard-00-02.7qknsd4.mongodb.net:27017, Type: Unknown, Error: Kind: I/O error: received fatal alert: InternalError, labels: {} } ] }, labels: {}`
    at _n.handleRequestError (/vercel/path0/node_modules/@prisma/client/runtime/library.js:121:7749)
    at _n.handleAndLogRequestError (/vercel/path0/node_modules/@prisma/client/runtime/library.js:121:7057)
    at _n.request (/vercel/path0/node_modules/@prisma/client/runtime/library.js:121:6741)
    at async l (/vercel/path0/node_modules/@prisma/client/runtime/library.js:130:9355)
    at async j (/vercel/path0/.next/server/pages/produto/[id].js:1:2826)
    at async buildStaticPaths (/vercel/path0/node_modules/next/dist/build/utils.js:786:33)
    at async /vercel/path0/node_modules/next/dist/build/utils.js:1215:110
    at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/trace/trace.js:151:20) {
  code: 'P2010',
  clientVersion: '5.18.0',
  meta: {
    modelName: 'Product',

I checked everything, I searched on Google but nothing looks like that

Input values of Row subject Shouldn’t intereact with each other

enter image description here

I recommend running the code to observe the issue. When you examine the form, you’ll notice that the values entered in the second row (specifically, the course marks) are unintentionally affecting the grade calculation in the first row. This interaction is unexpected and indicates a problem with the way the form is handling inputs across different rows. Could you help me identify the cause of this issue and suggest a solution to ensure that the values in each row are processed independently, without interfering with other rows?

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link
      rel="stylesheet"
      href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css"
      integrity="sha512-Kc323vGBEqzTmouAECnVceyQqyqdsSiqLQISBL29aUW4U/M7pSPA/gEUZQqv1cwx4OnYxTxve5UMg5GT6L4JJg=="
      crossorigin="anonymous"
      referrerpolicy="no-referrer"
    />
    <style>
      .hidden {
        display: none;
      }
    </style>
  </head>
  <body>
    <header>
      <h1>Transcript</h1>
    </header>

    <section>
      <form action="" method="post">
        <fieldset id="personalSet">
          <legend class="personal-legend">Personal Information</legend>

          <label for="fname">First Name</label>
          <input
            type="text"
            placeholder="First Name"
            name="fname"
            required
            autocomplete="on"
            onkeypress="return restrictToAlphabets(event)"
          />

          <label for="lname">Last Name</label>
          <input
            type="text"
            placeholder="Last Name"
            name="lname"
            required
            autocomplete="on"
            onkeypress="return restrictToAlphabets(event)"
          />

          <label for="email">Email</label>
          <input
            type="email"
            name="email"
            id="email"
            required
            autocomplete="on"
            placeholder="E-mail"
          />

          <label for="telephone">Phone No.</label>
          <input
            type="tel"
            name="telephone"
            id="telephone"
            required
            autocomplete="on"
            placeholder="Phone No."
            oninput="validatePhone(this)"
            onkeypress="return restrictToDigits(event)"
          />

          <label for="bname">Birth Date</label>
          <input type="date" name="bdate" required />

          <label for="address">Address</label>
          <input
            type="text"
            name="address"
            placeholder="1234 Main St, Apt 101"
            autocomplete="on"
          />

          <label for="program">Programs</label>
          <select name="program" id="program">
            <option value="BS.IT">BS.IT</option>
            <option value="BS.ED">BS.ED</option>
            <option value="BS.PHY">BS.PHY</option>
            <option value="BS.ENG">BS.ENG</option>
          </select>

          <label for="semester">Semester</label>
          <select name="semester" id="semester">
            <option value="1st">1st</option>
            <option value="2nd">2nd</option>
            <option value="3rd">3rd</option>
            <option value="4th">4th</option>
            <option value="5th">5th</option>
            <option value="6th">6th</option>
            <option value="7th">7th</option>
            <option value="8th">8th</option>
          </select>

          <label for="start-year">Academic Year</label>
          <input
            type="number"
            id="start-year"
            name="start-year"
            placeholder="2021"
            min="1900"
            max="2100"
            oninput="generateEndYear()"
          />
          -
          <input
            type="number"
            id="end-year"
            name="end-year"
            readonly
            disabled
          />
        </fieldset>

        <fieldset id="courseSet">
          <legend class="course-legend">Course Information</legend>
          <div id="subject-list">
            <div id="subject-row">
              <label for="c-code">Course Code</label>
              <input
                type="text"
                id="c-code"
                name="c-code"
                pattern="d{4}"
                placeholder="ICTC-101"
                required
                oninput="validateCourseCode(this)"
              />
              <span class="error">Please enter exactly 5 digits.</span>

              <label for="c-name">Course Name</label>
              <input
                type="text"
                placeholder="Course Name"
                name="c-name"
                required
                autocomplete="on"
              />

              <label for="c-hours">Course Marks</label>
              <input
                type="text"
                placeholder="Course Marks"
                name="c-marks"
                required
                autocomplete="on"
                oninput="validateMarks(this); calculateGrade(this.value);"
                onkeypress="return restrictToDigits(event)"
              />

              <label for="grade">Grade</label>
              <input type="text" id="grade" name="grade" required disabled />

              <label for="c-hours">Course Hours</label>
              <input
                type="text"
                placeholder="Course Hours"
                name="c-hours"
                required
                autocomplete="on"
                onkeypress="return restrictToDigits(event)"
              />

              <label for="instructor-name">Instructor Name</label>
              <input
                type="text"
                placeholder="Instructor Name"
                name="instructor-name"
                required
                autocomplete="on"
                onkeypress="return restrictToAlphabets(event)"
              />
            </div>
          </div>
        </fieldset>

        <div class="plus-icon">
          <button type="button" id="plusButton" onclick="duplicateRow()">
            <i class="fa-solid fa-plus"></i>
          </button>
        </div>

        <div class="minus-icon">
          <button
            type="button"
            id="minusButton"
            onclick="deleteDuplicatedRow()"
          >
            <i class="fa-solid fa-minus"></i>
          </button>
        </div>

        <input type="submit" value="submit" />
      </form>
    </section>
  </body>
  <script>

function generateEndYear() {
  const startYear = document.getElementById("start-year").value;
  const endYear = parseInt(startYear) + 4;
  document.getElementById("end-year").value = endYear;
}

function restrictToDigits(event) {
  const char = String.fromCharCode(event.which);
  if (!/^d$/.test(char)) {
    event.preventDefault();
    return false;
  }
  return true;
}

function restrictToAlphabets(event) {
  const char = String.fromCharCode(event.which);
  if (!/^[a-zA-Z]+$/.test(char)) {
    event.preventDefault();
  }
}

function validateCourseCode(input) {
  const value = input.value;
  if (value.length > 9) {
    input.value = value.slice(0, 9);
  }
}

function validateMarks(input) {
  const value = input.value;
  if (value.length > 2) {
    input.value = value.slice(0, 2);
  }
}

function calculateGrade(marks) {
  let grade = "";
  const gradeInput = document.getElementById("grade");
  marks = parseInt(marks);

  if (!isNaN(marks)) {
    if (marks >= 90 && marks <= 100) {
      grade = "A";
    } else if (marks >= 80 && marks < 90) {
      grade = "B";
    } else if (marks >= 70 && marks < 80) {
      grade = "C";
    } else if (marks >= 60 && marks < 70) {
      grade = "D";
    } else if (marks >= 0 && marks < 60) {
      grade = "F";
    } else {
      grade = "Invalid marks";
    }
  }

  gradeInput.value = grade;
}

function validatePhone(input) {
  const value = input.value;
  if (value.length > 11) {
    input.value = value.slice(0, 11);
  }
}

const subjectList = document.getElementById("subject-list");
const deleteButton = document.getElementById("minusButton");
if (subjectList.children.length === 1) {
  deleteButton.classList.add("hidden");
}

function duplicateRow() {
  const elementToDuplicate = subjectList.firstElementChild;
  const clone = elementToDuplicate.cloneNode(true);
  subjectList.appendChild(clone);
  updateDeleteButtonVisibility();
}

function deleteDuplicatedRow() {
  const lastChild = subjectList.lastElementChild;
  if (lastChild) {
    subjectList.removeChild(lastChild);
  }
  updateDeleteButtonVisibility();
}

function updateDeleteButtonVisibility() {
  const deleteButton = document.getElementById("minusButton");
  if (subjectList.children.length === 1) {
    deleteButton.classList.add("hidden");
  } else {
    deleteButton.classList.remove("hidden");
  }
}

</script>
</html>

I want that each row’s value should react only with their elements.

How To Narrow Down The Scope Of “Script Error” In JavaScript

I run a small marketing agency where I have lead-generation efforts in place for several client websites. As you can imagine running a lot of WordPress sites you need a good way to find errors and such on them without doing too much heavy lifting. I tend to log JavaScript errors into Google Analytics via Google Tag Manager, but having done this for a while now I keep bumping up against the annoying and cryptic “Script Error” issue on Cross-Origin scripts.

Unfortunately, with the way modern marketing has developed EVERYTHING is on a damn Cross Origin script. Aside from things like CRMs and 3rd party marketing tools that tend to have Cross-Origin scripts associated with them, there are also browser extensions and possibly even Google Translate that can be the source of these errors.

It’s pretty infuriating to be honest to see JavaScript errors logged and be given ZERO INFORMATION about where they are coming from. Surely we should at least be able to see the calling script as it was viewed from our domain/web app before the error occurred, right?

As far as I know, there is no workaround according to my research, but I wanted to create another question here asking if someone had found a workaround to at least narrow down the scope. Like, I understand that we probably won’t ever be able to see the error message, line number, etc for privacy reasons, but has someone found a workaround to at least narrow down the source of the script errors? Maybe like tracking the most recently called script and allowing us to at least infer what script may have caused the error?

I would feel a lot more comfortable knowing that when I see 50 “Script Errors” on a website they came from a script related to Google Translate, than having to wonder if my HubSpot forms are experiencing an error that is causing my clients not to be able to have their forms submitted and they are missing out on leads. Right now I have no way to discern that. There are a lot of Javascript based form submission products these days and I don’t always have access to tech stacks or tech stack choices. Even my preferred form builder on WordPress (Ninja Forms) uses JavaScript-based form submits (though error logging here isn’t a problem).

Looking for creative solutions to this problem that other people may have encountered to at least narrow down the scope of the cryptic “Script Error”.

how to enable to use require and import statment in javascript file?

I have below package.json and using a package and try to use both require and import statment in same file; to do that here is what did so far but not working

First Trial

// package.json (v1)
{
  "main": "src/index.js",
  "scripts": {
    "start": "node src/index.js"
  },
  "dependencies": {
    "@xkeshav/day": "latest"
  }
}

and called as below

// src/index.js
const { oneDay } = require("@xkeshav/day");
console.log({ oneDay });
console.log("Hello from template repository");

above works fine


now changes from require to import statament

import { oneDay } from "@xkeshav/day";
console.log({ oneDay });

and when run the file, it throws error

(node:14233) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/home/recursive/dev/template/src/index.js:1
import { oneDay } from "@xkeshav/day";
^^^^^^

SyntaxError: Cannot use import statement outside a module

highlight

add type:"module" in package.json

so added as below

// package.json ( v2 )
{
  "type": "module",
  "main": "src/index.js",
  "scripts": {
    "start": "node src/index.js"
  },
  "dependencies": {
    "@xkeshav/day": "latest"
  }
}

and now this works.


now removed import statment and added require statment

const { oneDay } =  require("@xkeshav/day");
console.log({ oneDay });

and run the file ; it throws error

at /src/index.js:1
const { oneDay } = require("@xkeshav/day");
                   ^

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/home/recursive/dev/template/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.

hightlight is

package.json contains “type”: “module”, To treat it as a CommonJS script, rename it to use the ‘.cjs’ file extension.

so rename index.js to index.cjs and make changes in package.json also

// package.json ( v3 )
{
  "type": "module",
  "main": "src/index.cjs",
  "scripts": {
    "start": "node src/index.cjs"
  },
  "dependencies": {
    "@xkeshav/day": "latest"
  }
}

this works.


import and require together

now addd the import statement along with require as below

const { oneDay } = require("@xkeshav/day");

import { oneDay as dayOne } from "@xkeshav/day";

console.log({ oneDay, dayOne });
console.log("Hello from template repository");

and when run the file; it throws error

(node:14757) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
at src/index.cjs:3
import { oneDay as dayOne } from "@xkeshav/day";
^^^^^^

SyntaxError: Cannot use import statement outside a module

Highlight

set “type”: “module” in the package.json or use the .mjs extension

so rename index.cjs to index.mjs and run in package.json also

 // # package.json ( v4 )
{
  "type": "module",
  "main": "src/index.mjs",
  "scripts": {
    "start": "node src/index.cjs"
  },
  "dependencies": {
    "@xkeshav/day": "latest"
  }
}

now gives another error


> @xkeshav/[email protected] start
> node src/index.mjs
at src/index.mjs:1
const { oneDay } = require("@xkeshav/day");
                   ^

ReferenceError: require is not defined in ES module scope, you can use import instead

so how can we use both kind of syntax in same file? and what that file extension would be ‘.mjs’ or ‘.cjs’ or ‘.js` and any changes in package.json required ?

Display or hide a div based on a clicked tabs’ class

I have tabs setup correctly i.e tab headings and the content is displaying correctly. However I want to also display a separate DIV just beneath the tabs based on which tabs is active.

So far I have gotten the correct extra div to display on initial page load but clicking on the other tab headings is not changing the displayed div.

document.addEventListener("DOMContentLoaded", function() {
  const tabs = document.querySelectorAll(".accomodation-tabs .sppb-tab-content .sppb-tab-pane");
  const galleryModules = {
    "standard-twin": ".twin-room-gallery",
    "standard-double": ".standard-double-gallery",
    "luxury-suites": ".luxury-suites-gallery"
  };

  // Hide all modules within the common container
  const allModules = document.querySelectorAll(".accomodation-gallery .sppb-addon");
  allModules.forEach((module) => {
    module.style.display = "none";
  });

  // Show the first gallery module (Twin Room Gallery) on page load
  const twinRoomModule = document.querySelector(".twin-room-gallery");
  twinRoomModule.style.display = "block";

  // Add event listener to tab container
  const tabContainer = document.querySelector(".accomodation-tabs .sppb-tab-content");
  tabContainer.addEventListener("click", function(event) {
    const clickedTab = event.target.closest(".sppb-tab-pane");
    if (!clickedTab) return; // Ignore clicks outside tabs

    // Hide all gallery modules
    Object.values(galleryModules).forEach((moduleClass) => {
      document.querySelector(moduleClass).style.display = "none";
    });

    // Show the corresponding gallery module based on the clicked tab
    const tabClass = clickedTab.classList[1];
    const moduleToShow = galleryModules[tabClass];
    document.querySelector(moduleToShow).style.display = "block";
  });
});

Having trouble with an onclick it does not want to fire

here is a code snippet. the variables are in place with the exception of this line
‘{% if current_user_playing %}remove{% else %}add{% endif %}’, which I am not sure how to resolve.

                    <button type="button" id="button-{{ t_time.id }}"
                            onclick="console.log('Button clicked'); togglePlayer(
                                '{% if current_user_playing %}remove{% else %}add{% endif %}',
                                '{{ t_time.id }}',
                                '{{ current_user.id }}',
                                this
                            )">

debug statement everywhere no luck