at the beginning of working with next ys there you have such problems, after 3 weeks it started to appear And don’t understand from VNAT some kind of error, I rummaged around and I realized that it’s SourceMap
I don’t even know how to decide
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
at the beginning of working with next ys there you have such problems, after 3 weeks it started to appear And don’t understand from VNAT some kind of error, I rummaged around and I realized that it’s SourceMap
I don’t even know how to decide
Before i start, i like to point out i am learnging JS, so this may be trivial, but having hard time do lazy load immidiate function https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.js
Example, I have click event that should load the said Swiper-bundle.js and then initiate the Swiper:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Swiper demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" />
<!-- Link Swiper's CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css" />
<!-- Demo styles -->
<style>
html,
body {
position: relative;
height: 100%;
}
body {
background: #eee;
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
font-size: 14px;
color: #000;
margin: 0;
padding: 0;
}
.swiper {
width: 100%;
padding-top: 50px;
padding-bottom: 50px;
}
.swiper-slide {
background-position: center;
background-size: cover;
width: 300px;
height: 300px;
}
.swiper-slide img {
display: block;
width: 100%;
}
</style>
</head>
<body>
<!-- Swiper -->
<h1>Making Swiper Web Component</h1>
<button type="button" id="swiperbtn">Try Swiper</button>
<div id="placehodler">
</div>
<div class="swiper mySwiper">
<div class="swiper-wrapper">
<div class="swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-1.jpg" />
</div>
<div class="swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-2.jpg" />
</div>
<div class="swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-3.jpg" />
</div>
<div class="swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-4.jpg" />
</div>
<div class="swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-5.jpg" />
</div>
<div class="swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-6.jpg" />
</div>
<div class="swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-7.jpg" />
</div>
<div class="swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-8.jpg" />
</div>
<div class="swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-9.jpg" />
</div>
</div>
<div class="swiper-pagination"></div>
</div>
<script>
var type = 'coverflow';
window.addEventListener("DOMContentLoaded", e => {
//add click listener to the button
document.getElementById('swiperbtn').addEventListener('click', e => {
(async () => {
const object = await import("https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.js");
console.log("Swiper-bundle.min.js loaded...");
var swiper = new Swiper(".mySwiper", {
effect: "coverflow",
grabCursor: true,
centeredSlides: true,
slidesPerView: "auto",
coverflowEffect: {
rotate: 50,
stretch: 0,
depth: 100,
modifier: 1,
slideShadows: true,
},
pagination: {
el: ".swiper-pagination",
},
});
})();
});
});
</script>
</body>
</html>
When i click on the button, i got error:

I see the swiper-bundle.js doesn’t have Module export structure but it has immidiate function. How is that made work on import()? Thank you for any help
I’m passing data to Modal for editing. The problem is whenever my products data is updated (Every 5s via fetchData), input field in modal also changed. How to prevent it?
Below is a simplified version of my code.
<div id="app">
<div class="modal" id="modal1">
<form method="post">
<input type="text" :value="passedData.category" />
<input type="text" :value="passedData.rating" />
<input type="text" :value="passedData.price" />
<input type="text" :value="passedData.stock" />
<button>Submit</button>
</form>
</div>
<table>
<tr v-for="item in items">
<td>{{ item.sku }}</td>
<td>{{ item.stock }}</td>
<td><button @click="openModal('modal1', item)">Edit</button></td>
</tr>
</table>
</div>
<script>
const app = Vue.createApp({
data() {
return {
items: [],
passedData: [],
};
},
mounted() {
this.fetchData();
setInterval(this.fetchData, 5000);
},
methods: {
async fetchData() {
const response = await fetch("https://dummyjson.com/products");
const data = await response.json();
this.items = data.products;
},
openModal(idModal, item) {
this.passedData = Object.assign({}, item);
},
},
});
app.mount("#app");
</script>
I was trying to create an array using existing array.
Then sort the new array’s sub array.
For this I used spread operator to copy the values to new array. But when I try to sort the sub array of new array it is reflecting in main array also.
I’m working on a project where a user uploads an image and a description, and the server processes it with the Gemini API. The server correctly logs the response, but I can’t display the response on the webpage. The response text is meant to replace a “Waiting for response…” placeholder in a element.
Front-End (HTML + JS)
<div id="response-container">Waiting for response...</div>
<script>
document.getElementById("upload-button").addEventListener("click", async () => {
const file = document.getElementById("file-upload").files[0];
const description = document.getElementById("user-description").value.trim();
const responseContainer = document.getElementById("response-container");
if (!file) {
responseContainer.textContent = "Please upload a file.";
return;
}
responseContainer.textContent = "Processing, please wait...";
const formData = new FormData();
formData.append("image", file);
formData.append("description", description);
try {
const response = await fetch("http://localhost:3000/upload-image", {
method: "POST",
body: formData,
});
if (response.ok) {
const data = await response.json();
console.log("Response received:", data);
responseContainer.textContent = data.reply || "No response received.";
} else {
responseContainer.textContent = "Error processing your request.";
}
} catch (error) {
console.error("Error:", error);
responseContainer.textContent = "An error occurred.";
}
});
</script>
Back-End (Node.js+Express)
app.post("/upload-image", upload.single("image"), async (req, res) => {
const imagePath = req.file.path;
const description = req.body.description;
try {
const geminiApiKey = process.env.GEMINI_API_KEY;
const geminiApiUrl = `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent?key=${geminiApiKey}`;
const mimeType = req.file.mimetype;
const base64Image = fs.readFileSync(imagePath, { encoding: "base64" });
const requestBody = {
contents: [
{ parts: [{ inlineData: { mimeType, data: base64Image } }, { text: description }] },
],
};
const response = await axios.post(geminiApiUrl, requestBody);
const reply = response.data?.candidates?.[0]?.content?.parts?.[0]?.text || "No response generated.";
console.log("Gemini API Response:", reply);
res.json({ reply }); // Send the reply directly as JSON
} catch (error) {
console.error("Error:", error);
res.status(500).json({ error: "Failed to fetch response." });
} finally {
fs.unlinkSync(imagePath);
}
});
Expected Result:
The should display the server’s response (e.g., “Luxurious bar with plants and lighting”).
Actual Result:
What could be preventing the DOM from updating with the server response? Am I missing something obvious?
How do I format a JS Date into an RFC 9557 format with a time zone suffix, so that I can record both the exact time that something happened as well as the time zone and local time that it happened?
This format is also helpful for interoperating with java.time.ZonedDateTime or for using the upcoming JavaScript API Temporal.ZonedDateTime.
I’d like output like this:
2024-12-18T08:32:23.95+00:00[Europe/London]2024-12-18T03:38:58.765-05:00[America/New_York]2024-12-18T05:43:12.150+09:00[Asia/Tokyo]I use DataTables to paginate and order a table containing user data.
The first column contains links instead of plain text. It seems that for this reason, the ascending/descending ordering is wrong (random).
It seems that the presence of diacritics on the Name column is also part of the ordering issue.
new DataTable('#employees', {
info: false,
filter: false,
paging: true,
"aLengthMenu": [5, 10, 25, 50, 100],
initComplete: function() {
if (this.api().page.info().pages < 2) {
$('.dt-paging').hide();
}
}
});
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js"></script>
<script src="https://cdn.datatables.net/2.1.8/js/dataTables.min.js"></script>
<script src="https://cdn.datatables.net/2.1.8/js/dataTables.bootstrap5.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.datatables.net/2.1.8/css/dataTables.bootstrap5.min.css" rel="stylesheet"/>
<div class="container my-2">
<h2>Data Tables</h2>
<table id="employees" class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="#">Tiger Nixon</a></td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011-04-25</td>
<td>$320,800</td>
</tr>
<tr>
<td><a href="#">Garrett Winters</a></td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011-07-25</td>
<td>$170,750</td>
</tr>
<tr>
<td><a href="#">Ashton Cox</a></td>
<td>Junior Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2009-01-12</td>
<td>$86,000</td>
</tr>
<tr>
<td><a href="#">Cedric Kelly</a></td>
<td>Senior Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td>
<td>2012-03-29</td>
<td>$433,060</td>
</tr>
<tr>
<td><a href="#">Ștefan Popa</a></td>
<td>Accountant</td>
<td>Tokyo</td>
<td>33</td>
<td>2008-11-28</td>
<td>$162,700</td>
</tr>
<tr>
<td><a href="#">Brielle Williamson</a></td>
<td>Integration Specialist</td>
<td>New York</td>
<td>61</td>
<td>2012-12-02</td>
<td>$372,000</td>
</tr>
<tr>
<td><a href="#">Herrod Chandler</a></td>
<td>Sales Assistant</td>
<td>San Francisco</td>
<td>59</td>
<td>2012-08-06</td>
<td>$137,500</td>
</tr>
<tr>
<td><a href="#">Rhona Davidson</a></td>
<td>Integration Specialist</td>
<td>Tokyo</td>
<td>55</td>
<td>2010-10-14</td>
<td>$327,900</td>
</tr>
<tr>
<td><a href="#">Colleen Hurst</a></td>
<td>Javascript Developer</td>
<td>San Francisco</td>
<td>39</td>
<td>2009-09-15</td>
<td>$205,500</td>
</tr>
<tr>
<td><a href="#">Sonya Frost</a></td>
<td>Software Engineer</td>
<td>Edinburgh</td>
<td>23</td>
<td>2008-12-13</td>
<td>$103,600</td>
</tr>
<tr>
<td><a href="#">Jena Gaines</a></td>
<td>Office Manager</td>
<td>London</td>
<td>30</td>
<td>2008-12-19</td>
<td>$90,560</td>
</tr>
<tr>
<td><a href="#">Quinn Flynn</a></td>
<td>Support Lead</td>
<td>Edinburgh</td>
<td>22</td>
<td>2013-03-03</td>
<td>$342,000</td>
</tr>
</tbody>
</table>
</div>
The problem does not happen if instead of links, the table cell contains just text:
new DataTable('#employees', {
info: false,
filter: false,
paging: true,
"aLengthMenu": [5, 10, 25, 50, 100],
initComplete: function() {
if (this.api().page.info().pages < 2) {
$('.dt-paging').hide();
}
}
});
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js"></script>
<script src="https://cdn.datatables.net/2.1.8/js/dataTables.min.js"></script>
<script src="https://cdn.datatables.net/2.1.8/js/dataTables.bootstrap5.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.datatables.net/2.1.8/css/dataTables.bootstrap5.min.css" rel="stylesheet"/>
<div class="container my-2">
<h2>Data Tables</h2>
<table id="employees" class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011-04-25</td>
<td>$320,800</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011-07-25</td>
<td>$170,750</td>
</tr>
<tr>
<td>Ashton Cox</td>
<td>Junior Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2009-01-12</td>
<td>$86,000</td>
</tr>
<tr>
<td>Cedric Kelly</td>
<td>Senior Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td>
<td>2012-03-29</td>
<td>$433,060</td>
</tr>
<tr>
<td>Ștefan Popa</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>33</td>
<td>2008-11-28</td>
<td>$162,700</td>
</tr>
<tr>
<td>Brielle Williamson</td>
<td>Integration Specialist</td>
<td>New York</td>
<td>61</td>
<td>2012-12-02</td>
<td>$372,000</td>
</tr>
<tr>
<td>Herrod Chandler</td>
<td>Sales Assistant</td>
<td>San Francisco</td>
<td>59</td>
<td>2012-08-06</td>
<td>$137,500</td>
</tr>
<tr>
<td>Rhona Davidson</td>
<td>Integration Specialist</td>
<td>Tokyo</td>
<td>55</td>
<td>2010-10-14</td>
<td>$327,900</td>
</tr>
<tr>
<td>Colleen Hurst</td>
<td>Javascript Developer</td>
<td>San Francisco</td>
<td>39</td>
<td>2009-09-15</td>
<td>$205,500</td>
</tr>
<tr>
<td>Sonya Frost</td>
<td>Software Engineer</td>
<td>Edinburgh</td>
<td>23</td>
<td>2008-12-13</td>
<td>$103,600</td>
</tr>
<tr>
<td>Jena Gaines</td>
<td>Office Manager</td>
<td>London</td>
<td>30</td>
<td>2008-12-19</td>
<td>$90,560</td>
</tr>
<tr>
<td>Quinn Flynn</td>
<td>Support Lead</td>
<td>Edinburgh</td>
<td>22</td>
<td>2013-03-03</td>
<td>$342,000</td>
</tr>
</tbody>
</table>
</div>
I’m building a Chrome extension that performs Automatic Speech Recognition (ASR) on audio data. The transcription happens in chunks, and I want to send progress updates to the content script while transcription is still in progress. However, I’ve encountered an issue where the updates only seem to be sent after the entire transcription process finishes, rather than in real-time as I would like.
setTimeout: Introduced small delays between update sends using setTimeout, but it still doesn’t send updates sequentially during the transcription process.chrome.tabs.sendMessage: I attempted to use promises to ensure sequential message sending, but updates still get queued and sent after the transcription is complete.I want to update the content script with each chunk of transcribed text while it’s still processing the audio. However, it seems like the message is only sent after the entire transcription finishes, likely because of the synchronous nature of chrome.tabs.sendMessage. I’ve also tried promisifying and using async/await, but I still cannot achieve sequential message passing.
const sendMessageToContentScript = (message) => {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
if (tabs.length === 0) {
console.warn("No active tab found.");
return;
}
const activeTabId = tabs[0].id;
chrome.tabs.sendMessage(activeTabId, message, (response) => {
if (chrome.runtime.lastError) {
console.warn("Error sending message:", chrome.runtime.lastError.message);
} else {
console.log("Response from content script:", response);
}
});
});
};
const callback_function = (item) => {
let last = chunks_to_process[chunks_to_process.length - 1];
last.tokens = [...item[0].output_token_ids];
let data = transcriber.tokenizer._decode_asr(chunks_to_process, {
time_precision: time_precision,
return_timestamps: true,
force_full_sequences: false,
});
console.info(data);
sendMessageToContentScript({
status: "update",
task: "automatic-speech-recognition",
data: data,
});
return data;
};
chrome.tabs.sendMessage calls are not sent sequentially as the transcription progresses but rather after the full process completes.chrome.tabs.sendMessage is executed sequentially and messages are sent after each chunk is processed, not all at once after the transcription is finished.i am writing this as a depleted person. After having 9 cellphones in the last 7 months, countless fights ith my girlfriend, late nights – affecting my job = loss of job. I am trying to stop my neighbour from acesing my cellphone every single time!! Basically i am beong made a mockery around in my street whenenever i am using my cellphone or trying to investigate where the problem is coming from. i am a newbie in what i am trying to execute and not entirely sure how people are seeing my screen or cellphone activity. One thing is for sure my gmail or email accounts gets compromised. I created yet another account but this is from my work pcto saegaurd myself. I think i have been sideloaded via ABD and i have noticed that there is a OTA update everytime i insert a diferent number. My guesses are that it changes my wireless settings and allocates a different network overlay stack (newbie talk) and my p address changes from my local internet service provider to a different router (next to door neighbour) i am confident in saying this as my ip address proves that.
i tried everything, every app on playstore, nothing can assist me. apk, reinstalls restarts, every single thing!! im tired of this and i am tired of my neighbour.
Caused by: android.view.InflateException:
Binary XML file line #31 in android:layout/screen_toolbar: Binary XML file line layout/screen_toolbar: Error inflating class com.android.internal.widget.Action Bar Container
i try updete implementation.and line 31 remove bot same issue
I have installed latest react router dom and in package.js its showing "react-router-dom": "^7.0.2".and when i check npm -v react-router-dom its showing 10.9.0. And in my code
import React from "react";
import ReactDOM from "react-dom";
import Header from "./components/Header";
import Body from "./components/Body";
import About from "./components/About";
import {
createBrowserRouter as Router,
RouterProvider
} from "react-router-dom";
const AppLayout = () => {
return (
<div className="app">
<Header />
<Body />
</div>
);
};
const appRouter= createBrowserRouter ([
{ path: "/", element: <AppLayout /> },
{ path: "about", element: <About /> },
])
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<RouterProvider router= {appRouter} />);
I am getting and error like
@parcel/core: Failed to resolve ‘react-router/dom’ from
‘./node_modules/react-router-dom/dist/index.mjs’
D:Namsthenode_modulesreact-router-domdistindex.mjs:13:48 12 |
// index.ts13 | import { HydratedRouter, RouterProvider } from “react-router/dom”;
| ^^^^^^^^^^^^^^^^^^ 14 | export * from “react-router”; 15 | export
{ @parcel/resolver-default: Cannot load file ‘./dom’ from module
‘react-router’
{divisVisible && (
<div className="absolute bg-[#ffffff] text-gray-700 w-[300px] h-auto py-3 px-3 rounded-lg mt-2 z-20 border-black border-2 border-solid ">
{data && data.length > 0 ? (
data?.map((item: any) => {
return (
<>
<div
className="py-2 cursor-pointer hover:bg-[#0000ffbe] hover:text-white hover:rounded-lg px-2"
key={item._id}>
<div
onClick={() => {
router.push(`/allproducts/${item._id}`);
setInput("");
}}>
{item.title}
</div>
{/* </Link> */}
</div>
</>
);
})
) : (
<>
{" "}
<div className="py-1 cursor-pointer px-2">
No result found...
</div>
</>
)}
</div>
)}
I tried adding keys to the rendered div but still the problem persists. This is working perfectly otherwise. Just the error keeps coming.
I want to make either of phone number or email field required in the form. I changed the phone validation schema in Yup from a string to an object, but now the error message doesn’t display when the phone number field is empty even though validation fails. It worked fine when the schema was a string, but I can’t figure out why the error message isn’t appearing.
Previous (works fine):
const contactDialogFormSchema = yup.object({
phone: yup
.string()
.test("required", "Either phone number or email is required", (value, values) => {
const { email } = values.parent;
return !!(value || email);
})
.test("invalid", "Invalid Phone Number", async (value) => {
if (value === "") return true;
return phoneRegex.test(value);
}),
email: yup
.string()
.test("required", "Either phone number or email is required", (value, values) => {
const { phone } = values.parent;
return !!(value || phone);
})
.test("invalid", "Invalid Email", async (value) => {
if (value === "") return true;
return emailRegex.test(value);
}),
});
Current (not working):
const contactDialogFormSchema = yup.object({
phone: yup
.object()
.shape({
code: yup.string().required("Required"),
iso: yup.string().required("Required"),
number: yup
.string()
.ensure()
.when(["code", "iso"], {
is: (code, iso) => code && iso,
then: (schema) => {
return schema.test("is-valid-phone-number", "Please provide a valid phone number", function (value) {
return yup.string().phone(this.parent.iso, true).isValidSync(value);
});
},
}),
})
.test("required", "Either phone number or email is required", (value, values) => {
const { email } = values.parent;
console.log("validation: ", !!(value.number || email)); // returns false
return !!(value.number || email);
}),
email: yup
.string()
.test("required", "Either phone number or email is required", (value, values) => {
const { phone } = values.parent;
return !!(value || phone.number);
})
.test("invalid", "Invalid Email", async (value) => {
if (value === "") return true;
return emailRegex.test(value);
}),
});
I am creating a web tool used on a kiosk that where 2 persons can insert their smart card. The tool will interact with our SmartCard-authenticated web app. The widget should prompt for user1’s SmartCard and run fetch 1, then it should prompt for user2’s SmartCard and run fetch 2.
If I use “credentials:include” in the fetch, it correctly authenticates with user1’s Smart Card, but then both fetches use user 1’s credentials. How can I initiate a second session/clear the LTPA Token/use a different session for each fetch? (Our web page, during SmartCard authentication uses ‘Set-Cookie’ and then carries auth in a cookie labeled ‘LTPA2 Token’).
Thanks in advance!
firebase/init.json shows 404 – While using signInWithPopup for Google Login . I am using authdomain with firebaseapp.com itself.
"use client";
import { Container, Button, Typography, Box, CircularProgress } from '@mui/material';
import { initializeApp } from "firebase/app";
import { getAuth, getRedirectResult, GoogleAuthProvider, signInWithCredential, signInWithPopup, signInWithRedirect } from "firebase/auth";
import axios from "./utils/axiosInstance";
import { useEffect, useState } from 'react';
import { useRouter } from 'next/navigation'
export default function Login() {
const [inprogress, setInProgress] = useState(false);
const [loginResponse, setLoginResponse] = useState<any | null>(null);
const router = useRouter()
const firebaseConfig = {
apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxx",
authDomain: "xxxxxx.firebaseapp.com",
projectId: "xxxxxx",
storageBucket: "xxxxx.firebasestorage.app",
messagingSenderId: "xxxxxx",
appId: "xxxxxxxxxxx",
measurementId: "xxxxxx"
};
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
getRedirectResult(auth).then((data)=>{
console.log(data)
})
const signInWithGoogle = async () => {
try {
setInProgress(true)
const provider = new GoogleAuthProvider();
await signInWithRedirect(auth, provider);
} catch (error) {
}
};
return (
<Container maxWidth="xs">
...
</Container>
);
}