str = “find().nodes() as n3” ==> find
str = “with n1,n2,n3” ===> with
Category: javascript
Category Added in a WPeMatico Campaign
Why is the Heatmap Leaflet in Map not showing up?
SITUATION:
Not showing heatMap in my Map not showing properly.
- What have I done wrong ?
- Why doesn’t the Heatmap Leaflet appear on the Map?
And part heatmapLayer.setData(FeatureCollection); if removed heatmapLayer so setData(FeatureCollection); it pops up but instead appears a marker on the map like this:

CODE:
import React, { useEffect, useState, useRef } from "react";
import { GeoJSON } from "react-leaflet";
import { useRecoilValue, useSetRecoilState } from "recoil";
import HeatmapOverlay from "leaflet-heatmap";
import { arcgisToken } from "../recoil";
import { mapBounds, loadingMap } from "../state";
import { getLocationCity } from "../data/arcgis";
import "leaflet.heat";
export default function HSales() {
const [data, setData] = useState();
const setIsLoading = useSetRecoilState(loadingMap);
const bounds = useRecoilValue(mapBounds);
const tokenArcgis = useRecoilValue(arcgisToken);
const geoJsonLayer = useRef(null);
useEffect(() => {
const fetchDataSpeedtestKel = () => {
const body = {
returnGeometry: true,
rollbackOnFailure: true,
geometry: JSON.stringify({
xmin: bounds.west,
ymin: bounds.south,
xmax: bounds.east,
ymax: bounds.north,
spatialReference: { wkid: 4326 },
}),
geometryType: "esriGeometryEnvelope",
token: tokenArcgis,
};
setIsLoading(true);
getLocationCity(body)
.then((response) => {
const array = [];
response.features.forEach((element) => {
array.push({
type: "Feature",
properties: element["attributes"],
geometry: {
type: "Point",
coordinates: [
element["coordinates"]["x"],
element["coordinates"]["y"],
],
},
});
});
const FeatureCollection = {
type: "FeatureCollection",
features: array,
};
if (geoJsonLayer.current) {
geoJsonLayer.current.clearLayers().addData(FeatureCollection);
}
var cfg = {
radius: 0.1,
maxOpacity: 1,
scaleRadius: true,
useLocalExtrema: true,
latField: "x",
lngField: "y",
};
var heatmapLayer = new HeatmapOverlay(cfg);
setData(FeatureCollection);
// setData(FeatureCollection);
})
.catch((err) => console.log(err))
.finally(() => setIsLoading(false));
};
fetchDataSpeedtestKel();
}, [bounds, setIsLoading, tokenArcgis]);
if (data) {
return (
<>
<GeoJSON
ref={geoJsonLayer}
data={data}
/>
</>
);
}
}
your response from getLocationCity in the example:
export const getLocationCity = async (params) => {
try {
const body = DataCustom(params);
const result = await instanceArcgis.post(
"/rest/HomeLocation/4/query",
body,
);
return await result?.data;
}
EXIF data not available when upload image using camera in iPhone
I created component for image upload and it’s display image details including the GPS location. I read the GPS details using EXIF data. Its work fine when we upload images using computer. Its also work fine if we use “Photo Library” or “Choose Files” options in iPhone. The problem is GPS details not display in EXIF data while uploading images using iPhone camera “Take photo” option. I already changed my camera format settings to “Most Compatible”.
I’m using exif-js library for read EXIF data.
Regex finding entire line from paragraph
I need to find the actual line from the paragraph, the paragraph drawing by the markdown editor you can add a checkbox, radio, textbox, and paragraph through the editor.
The actual str is something like this,
this is paragraph line1
?[question_2]{"category":[]}[who are you]=[] {1,2}
[] OPTION 1
[] OPTION 2
[] OPTION 3
this is paragraph line3
?[question_3]{"category":[]}[picode]=_ [PLACEHOLDER_TEXT]
?[question_1]{"category":[]}[sex]=() {1}
() male
() femele
this is paragraph line3
Do all question types have to start with ?[sometext], so I can use this regex
radio -> [?] ?[([0-9a-z_].?)]({(?:[^{}]|?)})? ?[?(.?)]? ?[=] ?() ?({[0-9,]+})?([^]?)(nn|^n)
checkbox -> [?] ?[([0-9a-z_].?)]({(?:[^{}]|?)})? ?[?(.?)]? ?[=] ?[] ?({[0-9,]+})?([^]?)(nn|^n),
similar to all inputs, my question how can i get the paragraph line text (those are not start with ?[] which may have small/caps/digits include)
Custom Calendar in JavaScript
How can I use Javascript to simplify this code?
I started to learn Javascript and I’m building some sites to improve my skills. But here I would like to share with you a code that I couldn’t simplify. As you will realize, I’m getting the ID of some DIVS to then add a event that go to differents categories. But, I can’t find the way to make it easier without use all this code.
let entradas = document.getElementById("entradas");
entradas.addEventListener("click",irUrl1);
function irUrl1 () {
window.location = "https://jikan.es/menu/entradas"
}
let veggie = document.getElementById("veggie");
veggie.addEventListener("click",irUrl2);
function irUrl2 () {
window.location = "https://jikan.es/menu/veggie"
}
let rollsEspeciales = document.getElementById("rolls-especiales");
rollsEspeciales.addEventListener("click",irUrl3);
function irUrl3 () {
window.location = "https://jikan.es/menu/especiales"
}
let pokeBowls = document.getElementById("poke-bowls");pokeBowls.addEventListener("click",irUrl4);
function irUrl4 () {
window.location = "https://jikan.es/menu/poke-bowls"
}
let sashimi = document.getElementById("sashimi-niguiris");
sashimi.addEventListener("click",irUrl5);
function irUrl5 () {
window.location = "https://jikan.es/menu/sashimi-niguiris"
}
let combinados = document.getElementById("combinados");
combinados.addEventListener("click",irUrl6);
function irUrl6 () {
window.location = "https://jikan.es/menu/combinados"
}
let rollsClasic = document.getElementById("rolls-clasicos");
rollsClasic.addEventListener("click",irUrl7);
function irUrl7 () {
window.location = "https://jikan.es/menu/rolls-clasicos"
}
let rollsSignature = document.getElementById("rolls-signature");
rollsSignature.addEventListener("click",irUrl8);
function irUrl8 () {
window.location = "https://jikan.es/menu/rolls-signature"
}
let promociones = document.getElementById("promociones");
promociones.addEventListener("click",irUrl9);
function irUrl9 () {
window.location = "https://jikan.es/menu/promociones"
}
</script>```
scrollTo and scroll-behaviour: smooth canceling eachother
I have a link to an element within the page on my navbar. I’m trying to get the link to center itself in the navbar using js’s element.scrollTo() with smooth behavior.
I’m using css’s scroll-behavior: smoth; to animate the scroll to a specific element when my user clicks the anchor.
Using element.scrollTo() interferes with the link click itself as, the link only works if there is no scrolling happening in the navbar. Is there a solution that doesn’t involve animating one of the scrolls myself?
Vue.js + get selected li item of ul
I have a list displayed like a dropdown –
Each of the items except ‘Create New Filter’ is bound to a key so i can understand when the other items are clicked.
I want to know how can i get the selected li item on save and do operations accordingly
What would be the good approach for this so i can understand on save which item was selected

Below is the code –
<ul>
<li v-on:click="create">Create New</li>
<li v-for="item in list" :key="item.id" v-on:click="Change(item.id,item.text)">{{ item.text }}</li>
</ul>
Develop vs code extension to edit text
I want to build an extension that edits all the links in a file in the editor. If should be something like this
BEFORE:
<img src="assets/images/avatars/avatar-1.jpg" alt="">
<link rel="stylesheet" href="assets/css/icons.css">
<link rel="stylesheet" href="assets/css/uikit.css">
<link rel="stylesheet" href="assets/css/style.css">
AFTER:
<img src="{% static 'assets/images/avatars/avatar-1.jpg' %}" alt="">
<link rel="stylesheet" href="{% static 'assets/css/icons.css' %}">
<link rel="stylesheet" href="{% static 'assets/css/uikit.css' %}">
<link rel="stylesheet" href="{% static 'assets/css/style.css' %}">
This is the code of my extension.js file so far
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
const vscode = require('vscode');
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
/**
* @param {vscode.ExtensionContext} context
*/
function activate(context) {
// Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated
console.log('Congratulations, your extension "auto-django" is now active!');
// The command has been defined in the package.json file
// Now provide the implementation of the command with registerCommand
// The commandId parameter must match the command field in package.json
let disposable = vscode.commands.registerCommand('auto-django.autoDjango', function () {
// The code you place here will be executed every time your command is executed
const editor = vscode.window.activeTextEditor
const selection = editor.selection
const text = editor.document.getText(selection)
var url = "<img height="100" src="data:image/png;base64,testurlhere" width="200"></img>";
var regexp = /<img[^>]+srcs*=s*['"]([^'"]+)['"][^>]*>/g;
var match = regexp.exec(text);
var src = match[1];
const newText = `{% static '${src}' %}`
editor.edit(builder => builder.replace(selection, newText))
// Display a message box to the user
// vscode.window.showInformationMessage(newText);
});
context.subscriptions.push(disposable);
}
// this method is called when your extension is deactivated
function deactivate() {}
module.exports = {
activate,
deactivate
}
And all this code does is that it takes the first image src link and changes it to the edited link, that is good, but it also replaces it with the whole text in the editor.
But what i want to do is that it should just replace with each of the links in the editor.
Any help will be appreciated.
Thanks
Why My React Component Render Multiple Times In Console?
Im new in react.
I’m Created two file App.js and UseEffect.js
I’m Learn about lifecycle in react with function.
So When I See in console, that’s render multiple time.
You can see my picture below.
This Is My Code
UseEffect.js
import React, {useState, useEffect} from "react";
function MyFunction(){
console.log('-> Function Init')
const [count, setCount] = useState(0)
const handleCount = () => {
setCount(prevState => {
return prevState+1
})
}
//LifeCycle
useEffect(() => {
console.log('my first effect')
})
console.log(`-> Start Render (${count})`)
return(
<div>
<h1>Function Component</h1>
<p>
<button onClick={handleCount}>Count</button>
{count}
</p>
</div>
)}
export default MyFunction
App.Js
import './App.css';
import UseEffect from './components/UseEffect'
function App() {
return (
<div className="App">
<UseEffect />
</div>
);
}
export default App;
How do it’s work?, I Want it. it’s just render one times.
Why javascript error stack for just one loop?
Why error stack even for n = 1?
function f(n) {
const f1 = f(n - 1);
const f2 = f(n - 2);
return n == 0 ? 0 : (n == 1 ? 1 : f1 + f2);
}
console.log(f(1));
Update entire HTML table column using JS
I want to update entire column with new_data
I tried to update as bellows
response.json().then(function (new_data){
console.log(new_data)
var body_data = " ";
new_data.forEach((item) => {
var list_data = "";
list_data += "<td>" + item.vc_state + "</td>";
body_data += list_data;
});
$('#vc_state').html(body_data); })
But it update only the cell as bellows

I want to update entire State column with new data
Please help me to solve this
SVG w/ linearGradient only displays when page reloads in a react Storybook
I have two icon compound components in my react storybook using linearGradient likeso:
Icons.Facebook = function FacebookIcon() {
return (
<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="..." fill="url(#facebookGradient)"/>
<defs>
<linearGradient id="facebookGradient" x1="27.5" y1="2.49999" x2="1.04211" y2="4.16368" gradientUnits="userSpaceOnUse">
<stop offset="0%" style={{ stopColor: "#5936E3" }} />
<stop offset="100%" style={{ stopColor: "#6E56B5" }}/>
</linearGradient>
</defs>
</svg>
);
}
Icons.Instagram = function InstagramIcon() {
return (
<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="..." fill="url(#instagramGradient)"/>
<defs>
<linearGradient id="instagramGradient" x1="27.5" y1="2.49999" x2="1.04086" y2="4.15369" gradientUnits="userSpaceOnUse">
<stop offset="0%" style={{ stopColor: "#5936E3" }} />
<stop offset="100%" style={{ stopColor: "#6E56B5" }} />
</linearGradient>
</defs>
</svg>
);
}
In my story, Icons.stories.jsx, I render them:
const Template = (args) => (
<Icons {...args}>
<Icons.Facebook />
<Icons.Instagram />
</Icons>
);
export const AllIcons = Template.bind({});
AllIcons.args = {};
The issue I’m having with is that, these two Icons will only be visible after I reload the page. If I go to the canvas tab and back into the control tab, they remain in the dom, but they are not visible. If I remove the linearGradient and just use a regular hex color or a color (like red), they show without a problem.
As you can see, the ids are not the same, I’m using proper syntax as I read on other posts and github issues, but I’m still not able to find a solution.
Any ideas?
Vue3 composition API template replacement without eval
So, I’m building a system that allows users to create document templates. I have a pretty simple, human readable way of adding “dynamic” data to the templates:
#firstName from client#” <— where “client” is a ref(), and firstName would be a property of that object.
Now, I can figure out how to replace these tags with the actual data without using eval(). Now, obviously I can’t trust what people enter here, so I have an array of “allowedTags”, and when I parse, I only parse the RegEx matched list of #..# values. So they can’t do anything like #someEvil code here from SomeOtherEvilStuff” because it won’t be an allowed tag.
Is this really that bad, or is there another way to dynamically replace using ref() values?
function processTemplate(text: string): string {
const re = new RegExp(/#w+ from w+#/, 'g')
const matches = text.match(re) ?? []
for (const match of matches) {
if (!allowedTemplateTags.includes(match)) {
continue
}
const split = match.replace(/#/g, '').split(' from ')
const replaceRegEx = new RegExp(`(${match})`, 'g')
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
text = text.replace(replaceRegEx, eval(`${split[1]}?.value.${split[0]}`))
}
return text
}
Queue with delay or alternative
I have a chatbot application that needs to finish its session X minutes after the latest message from user. I run a job each X minutes which I verify if the last message has been sent X minutes ago. Do you guys have some suggestion for that problem without a job use? I think something as a queue with a X minutes delay or something like that. What is a better way to do that?



