I am creating a page-break plugin in platejs using it’s document and Ai but there is a lot of error type or structure problem.
can you help me to do this with helping of these two link below:
Category: javascript
Category Added in a WPeMatico Campaign
Calculation Bug in ExtJS 6.5.0 and 7.8.0 and JavaScript [duplicate]
Question:
I have encountered a floating-point calculation issue in both ExtJS 6.5.0 and 7.8.0. When multiplying certain decimal numbers by powers of 10, the results are slightly incorrect due to precision errors. This issue occurs in any browser (Chrome, Firefox, Edge, etc.).
console.log(2.3 * 100); // Expected: 230, Actual: 229.999999997
console.log(2.3 * 100000); // Expected: 230000, Actual: 229999.99999999997
console.log(2.3 * 100000000); // Expected: 230000000, Actual: 229999999.99999997
Unable to download files in playwright javascript
Button is clicked and file is getting downloaded but I am unable to see any file which is downloaded.
Here is the code:
test('Upload Download Excel Validation', async ({ page }) => { await page.goto("https://rahulshettyacademy.com/upload-download-test/index.html")
const downloadPromise = page.waitForEvent('download');
await page.getByRole('button',{name:'Download'}).click();
await page.pause();
await page.locator("#downloadButton").click();
const download = await downloadPromise;
await download.saveAs('C:UsersKrishnenduDasDownloadsdownload.xlsx' + download.suggestedFilename());
writeExcelTest("Apple", 350, "C:UsersKrishnenduDasDownloadsdownload.xlsx", { rowchange: 0, colchange: 2 })
await page.locator("#fileinput").click();
await page.locator("#fileinput").setInputFiles("C:UsersKrishnenduDasDownloadsdownload.xlsx")
})
It is saving as below
I am simply trying to download and save the file.
Button is getting clicked but the file is not saved. My drive is locked with Bit locker. I can download it manually. can it be a problem ?
How to properly do ssr with bun and serve index.html as a starting point?
I have 2 folders
client
server
inside my client folder i use bun bundler to bundle my scripts and styles
index.html
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="./src/css/app.css" />
</head>
<body>
<div id="root"></div>
<script src="./src/js/app.js" type="module"></script>
</body>
</html>
when i run bun build index.html it will automatilly bundle them in dist folder now I’m confused how to do server side rendering inside my server folder ? since client foldler is just to bundle my assets
here is what i did
server/src/index.ts
// server/src/index.ts
import { Elysia } from 'elysia';
import { staticPlugin } from '@elysiajs/static';
import { readFile } from 'node:fs/promises';
import path from 'node:path';
const app = new Elysia()
.use(staticPlugin({
prefix: '/static',
assets: path.join(__dirname, '..', '..', 'client', 'dist'), // Static files from client/dist
}))
.get('/', async () => {
// 1. Read the bundled index.html file
// Corrected path to client/dist/index.html from server/src/index.ts
const indexHTMLPath = path.join(__dirname, '..', '..', 'client', 'dist', 'index.html');
let indexHTML;
try {
indexHTML = await readFile(indexHTMLPath, 'utf-8');
} catch (error) {
console.error("Error reading index.html:", error);
return new Response("Error loading application", { status: 500 });
}
// 2. (Optional) Insert dynamic data here if needed
// 3. Return the index.html as the response
return new Response(indexHTML, {
headers: { 'Content-Type': 'text/html' },
});
})
.listen(3000);
console.log(`Elysia server started on port ${app.server?.port}`);
is that is correct to do ssr ? basically I want this index.html as a starting point to include my styles and scripts from bun on the front end but i dont want to use react but i want my website to do ssr with tsx as a template engine later on
Framer Motion – useScroll / useTransform jumps on hard refresh
const ref = useRef(null)
const { scrollYProgress } = useScroll({
target: ref,
offset: ['0%', '0% 50%']
})
const scale = useTransform(scrollYProgress, [1, 0], [0.9, 1])
return (
<motion.div
style={{ scale: scale }}
initial={{ scale: 0.9 }}
ref={ref}
layout
layoutRoot
>
<div>{children}</div>
</motion.div>
)
I’m trying to build a component which scales elements as the user scrolls. It’s only subtle.
I’ve got an issue when the component is ‘above the fold’. The animation ‘jumps’ once you start scrolling, inspecting the inline styles from framer shows that on page load the element has a scale of transform: scale(0.938332); but if you scroll down, and then back up it shows transform: scale(0.91334) which is what causes the jump.
Am i missing something? I feel like this must be a common use case of animating elements which are in view on page load.
It’s also worth noting that this only happens on hard navigations (e.g manually refreshing) but on soft navigations it works fine.
Why won’t my filtering data-tag buttons work?
For some reason not all the buttons will filter. All still works, markdown and mermaid show some but not all of the cards they should.
Code:
const filterButtons = document.querySelectorAll(".filter-buttons button");
filterButtons.forEach(button => {
button.addEventListener("click", function() {
filterCards(this.getAttribute("data-tag"), this);
});
});
});
function filterCards(tag, button) {
console.log("filterCards called with tag:", tag);
let cards = document.querySelectorAll(".card");
let buttons = document.querySelectorAll(".filter-buttons button");
// Remove "active" class from all buttons
buttons.forEach(btn => btn.classList.remove("active"));
// Add "active" class to the clicked button
button.classList.add("active");
// Filter cards
cards.forEach(card => {
let cardTags = card.getAttribute("data-tags").split(" ");
if (tag === "all" || cardTags.includes(tag)) {
card.classList.remove("hidden");
} else {
card.classList.add("hidden");
}
});
}
.filter-buttons {
margin-bottom: 20px;
text-align: center;
width: 100%;
}
.filter-buttons button {
margin: 5px;
padding: 10px;
cursor: pointer;
border: none;
background-color: var(--background-color);
border-radius: 5px;
outline-color: var(--primary-color);
}
.filter-buttons button.active {
background-color: var(--primary-color);
color: white;
}
.cards {
display: flex;
flex-wrap: wrap;
/* Allows wrapping if necessary */
gap: 20px;
/* Adds space between cards */
justify-content: center;
/* Centers cards in the container */
}
.card {
width: 200px;
padding: 15px;
border: 1px solid var(--accent-color);
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
text-align: center;
display: block;
cursor: pointer;
}
.card-link {
background-color: #4CAF50;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
text-decoration: none;
}
.card-link:hover {
background-color: #3e8e41;
}
.hidden {
display: none;
}
<button data-tag="all">All</button> <!-- All projects button DO NOT DELETE -->
<button data-tag="design">Design</button> <!-- Design projects button -->
<button data-tag="UI/UX">UI/UX</button> <!-- UI/UX projects button -->
<button data-tag="database">Database</button> <!-- Database projects button -->
<button data-tag="scripting">Scripting</button> <!-- Scripting projects button -->
<button data-tag="HTML5">HTML5</button> <!-- HTML5 projects button -->
<button data-tag="CSS3">CSS3</button> <!-- CSS3 projects button -->
<button data-tag="JavaScript">JavaScript</button> <!-- JavaScript projects button -->
<div class="cards">
<div class="card" data-tags=" design , css3 , html5 , Javascript , scripting , frontend , game , web , UI/UX , markdown , mobile ">
<a href="https://alexmcvay.github.io/DragonFighter.github.io/">
<h3>DragonFighter RPG</h3>
<p>A text-based monster fighting role-playing game.</p>
</a>
</div>
<div class="card" data-tags=" design , css3 , html5 , javascript , scripting , frontend , web , UI/UX , markdown , mobile ">
<a href="https://alexmcvay.github.io/Portfolio/">
<h3>Portfolio</h3>
<p>This portfolio website.</p>
</a>
</div>
<div class="card" data-tags=" UI/UX , design , css3 , html5 , javascript , frontend , web , react ">
<a href="https://studentcalendar.netlify.app/">
<h3>Student Calendar</h3>
<p>A student calendar app.</p>
</a>
</div>
<div class="card" data-tags=" UI/UX , design , css3 , html5 , javascript , frontend , web , mobile ">
<a href="https://alexmcvay.github.io/Contact-Card/">
<h3>LinkTree Clone</h3>
<p>A linktree clone with a Download button for contact info.</p>
</a>
</div>
<div class="card" data-tags=" Database , SQL , mermaid ">
<a href="https://github.com/AlexMcVay/UBER-Data">
<h3>UBER-Data</h3>
<p> A data analysis clone of UBER</p>
</a>
</div>
<div class="card" data-tags=" UI/UX , design , css3 , html5 , javascript , frontend , web , mobile ">
<a href="https://alexandra-mcvay.netlify.app/">
<h3>Tic Tac Toe</h3>
<p>A game of Tic Tac Toe</p>
</a>
</div>
</div>
The console is showing that everything should be working filterCards called with tag: CSS3
The Database HTML5 CSS3 show no cards even though there are cards with the appropriate data-tags. I expected the buttons to filter out only the cards not containing the appropriate data-tags.
Screenshots:
Here it is when I click all:

Here it is when I click design ( a button that works):

Here is is when I click Database, one of the buttons that do not work:

Javascript calculations [duplicate]
I am trying to do some basic arthmetic in javascript, but I am running into some calculation ‘errors’.
I am building a cash register but at the end of calculations, there is a difference of $0.01, how can I get this issue sorted out ?
I have used .toFixed(2) method so that the value is truncated to two decimal places.
Why can’t I get the content using `fetch` [duplicate]
const response = await fetch('https://uuooo.com/l?page=2&ajax=list');
const data = await response.json();
it is normal when I access it directly.
Access to fetch at ‘https://uuooo.com/l?page=2&ajax=list’ from origin ‘http://127.0.0.1:8021’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.
const response = await fetch('https://uuooo.com/l?page=2&ajax=list');
const data = await response.json();
Get json data.
Is it more efficient to display an existing HTML element or to hide it? [closed]
I have an AB test for an element on my page.
This element is already in the page’s HTML.
My test consists of showing it to some users, and hiding to others.
The testing tool uses javascript on the client to determine if the element should be displayed or not.
I’m wondering if it is better, to have this element:
- displayed and have js hiding it (with
display:none) - hidden and have js displaying it (with
display:block)
Why does my ARIA live region only announce the first update when using a Web Component?
I’m building a custom Web Component that displays live sustainability stats for hotels. The component updates CO₂ savings in real-time, and I want screen readers to announce the updates using an ARIA live region.
The problem is that the screen reader only announces the first update, but ignores all future changes unless I manually re-render the component.
Here’s my Web Component:
class LiveStats extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
this.shadowRoot.innerHTML = `
<div aria-live="polite" id="co2-output">CO₂ Saved: 10kg</div>
`;
}
updateCO2(newValue) {
const output = this.shadowRoot.getElementById("co2-output");
output.textContent = `CO₂ Saved: ${newValue}kg`;
}
}
customElements.define("live-stats", LiveStats);
I expected that calling updateCO2(15) would trigger a screen reader announcement for the new value.
I also tried forcing a reflow:
output.textContent = "";
setTimeout(() => {
output.textContent = `CO₂ Saved: ${newValue}kg`;
}, 10);
But this doesn’t work reliably.
Are ARIA live regions inside Shadow DOM unreliable, or is there another technique to ensure screen readers consistently read dynamic updates?
How can i link my javascript code to my handlebars file in nestjs
I’m building a data collection app using NestJS for the backend and Handlebars (hbs) for templating. The app allows users to submit personal information via a form without requiring registration. Administrators can access the collected data based on three roles: viewAdmin, modifyAdmin, superAdmin
The Problem:
I’m working on an update form feature where administrators can edit a submitted form. However, I’m running into issues with embedding JavaScript into Handlebars views. Specifically:
Handlebars escapes tags, making it difficult to include inline JavaScript,
External JS files weren’t working as expected, leading me to explore Handlebars helper functions,
Whenever I try to run the update form on the browser, the page just goes blank without any errors in the console. I suspect it might be related to the way the template is rendered or how JavaScript is being injected, but I’m not sure what’s causing it
Has anyone faced a similar issue? Any guidance, examples, or best practices would be greatly appreciated
I initially linked an external JS file using , but it didn’t work.
I tried wrapping the script in a Handlebars {{#raw}} … {{/raw}} block, but the script still didn’t execute.
I added console.log statements inside DOMContentLoaded, but nothing was logged when the page loaded.
here is my main.ts file
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ValidationPipe } from '@nestjs/common';
import { NestExpressApplication } from '@nestjs/platform-express';
import { join } from 'path';
import * as hbs from 'hbs'
import Handlebars from 'handlebars'
async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(AppModule);
app.enableCors({
origin: 'http://127.0.0.1:5500',
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
preflightContinue: false,
optionsSuccessStatus: 204,
});
app.useStaticAssets(join(__dirname, '..', 'public'));
app.setBaseViewsDir(join(__dirname, '..', 'views'));
app.setViewEngine('hbs')
hbs.registerHelper('raw', function (options) {
return new Handlebars.SafeString(options.fn(this));
});
app.useGlobalPipes(new ValidationPipe({
whitelist: true
}));
await app.listen(3000);
}
bootstrap();
this is my handlebars code snippet
<link rel="stylesheet" href="../css/table.css">
<h2 style="text-align: center;">Update Form</h2>
<form id="update-form">
<table>
<thead>
<tr>
...
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" value="{{formById.date_time}}" name="date_time"></td>
...
</tr>
</tbody>
</table>
<button type="submit">Update Form</button>
</form>
<script src="/patch.js"></script>
{{#raw}}
<script>
console.log('form submitted')
const form = document.querySelector('form');
// Add an event listener to the form submission event
form.addEventListener('submit', (event) => {
event.preventDefault();
// Get the form data
const formData = new FormData(form);
const updatedData = Object.fromEntries(formData.entries());
// Send a PATCH request to update the form data in the database
fetch(`http://localhost:3000/admin-control/${formId}`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`,
},
body: JSON.stringify(updatedData),
})
.then((response) => response.text())
.then((data) => {
// Reload the page
window.location.reload();
})
.catch((error) => console.error(error));
});
</script>
{{/raw}}
now the problem is i dont think the javascript is being executed at all…because if it is, then at least i should get the message “form submitted” on the console but i dont…i need help on this please
Can’t understand how to handle nested categories in next.js when changing categoryId
I am using nest.js with useSWR recommended by nest.js my job is to fetch categories and display them to user as links. When a user clicks on a link, the link is associated to a specific category ID and the refetch happens to bring sub-categories of this category and display new links and so on.
My code works only on second click, and then, the right sub-categories are fetched, but then, the component re-renderes and it all rolls back to initial categories, why is that? useRef instead of useState didn’t help either. I need to fetch subcategories and display them to a user and the component should not re-render and default categoryId to null.
Can anyone help? I am new to next.js and don’t know how to fix it.
“use client”;
const fetcher = (...args) => fetch(...args).then((res) => res.json());
export const CategoryLinks = () => {
const [categoryId, setCategoryId] = useState(null);
const API_URL = categoryId
? `api/categories=1&category_id=${categoryId}`
: "api/categories=1";
const { data, isLoading } = useSWR(API_URL, fetcher);
const getCategoryId = (id) => {
setCategoryId(id);
};
if (isLoading) {
return <div>Loading in progress...</div>;
}
return (
<Flex
mih={50}
gap="md"
justify="flex-start"
align="flex-start"
direction="row"
wrap="wrap"
>
{data.map(({ ID, path, name }) => {
return (
<div key={ID}>
<Link
href={`/cat/${path}/`}
onClick={() => getFuckingCategoryId(ID)}
>
<Button color={"grape"}>{name}</Button>
</Link>
</div>
);
})}
</Flex>
);
};
No response sent from an api
I don’t receive any response on client side. This is the server side api:
export async function GET(request: NextRequest) {
const client = new ftp.Client();
client.ftp.verbose = true;
try {
console.log("Connecting to FTP server...");
await client.access(ftpConfig);
const remoteFilePath = "/public_html/images/data/gallery.json";
const chunks: Uint8Array[] = [];
const writableStream = new Writable();
writableStream._write = () => {};
writableStream.on("data", (chunk) => {
chunks.push(chunk);
});
console.log(`Downloading file from: ${remoteFilePath}`);
await client.downloadTo(writableStream, remoteFilePath);
console.log("File downloaded successfully.");
const fileContent = Buffer.concat(chunks).toString("utf8");
console.log("File content:", fileContent);
const jsonData = JSON.parse(fileContent);
console.log("File downloaded successfully.");
return NextResponse.json({ success: true, data: jsonData, message: "File downloaded successfully." });
} catch (error) {
console.error("FTP connection error:", error);
return NextResponse.json({ success: false, message: "FTP connection error." });
} finally {
client.close();
}
}
Client side I have this:
useEffect(()=>{
const fetchImagesData = async () => {
const response = await fetch("api/galleryData")
const data = await response.json()
}, [])
And no log is displaying.
Also, I try to download the file to read it is that the correct way ?
How to spoof Action script 3 ExternalInteface.call(“window.navigation.userAgent.toString”)
im trying to spoof that call to look like a electron environment using the javascript below. though it works for the browser it keeps returning in flash “the thing it got is Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:115.0) Gecko/20100101 Goanna/6.7 Firefox/115.0 Basilisk/20250220”
Object.defineProperty(navigator, "userAgent", {
get: function () {
return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Electron/9.0.0";
},
configurable: true
});
console.log(window.navigator.userAgent.toString());
the flash script gets the user agent like this
public static function getUserAgent() : String
{
var _loc1_:String = null;
if(ExternalInterface.available)
{
_loc1_ = ExternalInterface.call("window.navigator.userAgent.toString");
}
return _loc1_;
}
I tried a couple of things.
thought maybe the flash environment would use some other weird function calling
window.getUserAgent = function() {
return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Electron/9.0.0 ";
};`
also tried directly setting the user agent
window.navigator.userAgent = “Mozilla/5.0 (Windows NT 10.0; Win64; x64) Electron/9.0.0″`
Chrome extension fetch to GoHighLevel API returns 401 Unauthorized despite correct Bearer token
I’m building a Chrome extension that calls the GoHighLevel (GHL) API to create and manage contacts. When I do the same request in Postman using my GHL API key as a bearer token, it works (status 200). But when my extension code runs, I get 401 Unauthorized.
What I’m Doing
Manifest.json (Manifest v3) has:
json
Copy
Edit
{
"manifest_version": 3,
"name": "GoHighLevel Messenger Extension",
"version": "1.0",
"permissions": [
"storage",
"activeTab",
"scripting"
],
"host_permissions": [
"https://app.gohighlevel.com/*"
],
"background": {
"service_worker": "background.js"
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content_script.js"]
}
],
"action": {
"default_popup": "popup.html"
}
}
I added “host_permissions” for https://app.gohighlevel.com/* to handle possible CORS or cross-origin issues.
popup.js snippet (where I fetch the GHL endpoint):
js
Copy
Edit
chrome.storage.local.get("ghl_api_key", async (res) => {
if (!res.ghl_api_key) {
alert("No GHL API key found. Please save one first.");
return;
}
const apiKey = res.ghl_api_key;
const url = "https://app.gohighlevel.com/v2/location/54HQKNLdRdp1puWWYfv7/contacts";
// Note: 54HQKNLdRdp1puWWYfv7 is my location ID
try {
const resp = await fetch(url, {
method: "POST",
headers: {
"Authorization": `Bearer ${apiKey}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
firstName: "Test",
email: "[email protected]",
phone: "+15555555555"
})
});
console.log("Fetch status:", resp.status); // Logs 401
if (!resp.ok) {
// e.g. "Error creating contact: 401"
alert(`Error creating contact: ${resp.status}`);
} else {
const data = await resp.json();
console.log("Success:", data);
}
} catch (err) {
console.error("Fetch error:", err);
}
});
Testing in Postman:
http
Copy
Edit
POST https://app.gohighlevel.com/v2/location/54HQKNLdRdp1puWWYfv7/contacts
Authorization: Bearer <MY_SAME_API_KEY>
Content-Type: application/json
{
"firstName": "Test",
"email": "[email protected]",
"phone": "+15555555555"
}
This returns 200 OK and creates a contact successfully.
But in the Chrome extension environment, the same token and body yield 401 Unauthorized.
What I’ve Tried
- Verified the key is correct (no typos) and it works in Postman.
- Added “host_permissions”: [“https://app.gohighlevel.com/*”] in manifest.json.
- Ensured I only set “Content-Type”: “application/json” on POST calls (for GET calls, I omit it).
- Confirmed my extension logs say 401 with no additional message.
- Double-checked the location ID matches the one in Postman.
- Generated a new API key in GHL, tested in Postman again (works), extension still 401.
Question:
Why might my extension’s fetch call get a 401 from GoHighLevel, even though the same bearer token works in Postman? Am I missing any additional headers or steps in a Chrome extension context?
Any insight is appreciated — thanks in advance!
