October 21, 2024
Chicago 12, Melborne City, USA
javascript

Regex that detects if the key has a missing character

const placeholders = { "Luke": "{{candidate_first_name}}", "xxx@gmail.com": "{{candidate_email}}", } const text = <div>Hi&nbsp; Luke ,</div><div><strong>Email: </strong>xxx@gmail.com</div> export default function removeTextPlaceholders( text: string, placeholders: any ) { try { for (const [key, value] of Object.entries(placeholders)) { if (value) { const regex = new RegExp(`^${key}(?:\\s*|.{0,1})$`, 'g'); // Check if the key is a complete match before replacing

Read More
javascript

How to dynamically fetch nested json arrays keys and properties without explicitly mentioning the fields?

I have a requirement to create a nested JSON to create an issue in JIRA. The thing is this will work for only content.content.text path. If new keys and values are added in the future, this means it will not work. I’ve tried to automate it by fetching the keys and values in the payload.

Read More
javascript

Using non-ASCII character as JavaScript object key

In my home automation (nodered) there is a device that is sending it’s actual state. Within this state there is a property ‘switch’. I.e.: myDevice.state.switch. ‘switch’ is a key word in javascript, so I cannot access it in the normal way. Furthermore I’m not able to change the property’s name, because it is implemented in

Read More
javascript

How can a mid-level developer evaluate their skills and identify areas for growth?

I’m currently working as a mid-level frontend developer with React and TypeScript. However, compared to other mid-level developers, I sometimes feel like I’m not quite on the same level as I’d like to be. I want to improve, but it’s not always clear where to focus my efforts. In your experience, what distinguishes strong mid-level

Read More
javascript

Why JSON file value is not displayed?

<script> // Fetch JSON data fetch('dat.json') .then(response => response.json()) .then(data => { const tbody = document.querySelector('#dataTable tbody'); data.forEach(item => { const row = document.createElement('tr'); row.innerHTML = ` <td>${item.name}</td> <td>${item.age}</td> <td>${item.city}</td> `; tbody.appendChild(row); }); }) .catch(error =>console.error('Error fetching the data:', error)); </script> Why JSON file value is not displayed? The code I took from ChatGPT. I

Read More
javascript

How to use image ressource from sitepackage in javascript file in TYPO3 12?

Within a TYPO3 12 website I use the Sitepackagebuilder to create a sitepackage. The Resources are structured as following: Resources ... Public JavaScript scripts.js Icons arrow.png ... Within my scripts.js I would like to access an icon from the Icons-folder (arrow.png) to use it with the slick slider as follows: $slider.slick({ infinite: true, slidesToShow: 3,

Read More
javascript

Is there a native javascript API to manipulate the undo stack of HTML elements?

I created a contenteditable element in my page and during some events I update it by replacing the innerHTML. When I do that, the undo stack gets reset. I found some recommendations to use the executeCommand api, but the MDN doc says it’s deprecated and does not offer an alternative. Is there a way to

Read More
javascript

Nothing appears in browser console while inspecting element while executing dynamic action in oracle apex

Problem: When I examine the element in the browser console, it does not return any details about the procedure as it was before. I don’t know if the latest update of Chrome browser is the reason. If anyone has any details about the subject, I am very grateful and thankful. item 1 : P2_ITEM1 item

Read More
javascript

Load Local WebSite Folder from Document Directory

I am trying to load Website Folder from the Document Directory. It’s a PWA Bundle. When i load the Folder from the Bundle, It loads in WkWebview. But when i try to load it from Document Directory, it’s not loading from the folder. May files are missing including main.js, though all those files are there

Read More
javascript

How to Execute a Javascript Callback based on a Variable or Parameter

I have an array that is passed to React from a Laravel back end, representing columns in a database. I iterate over this array to construct headings for a table. For each column, I want to run a callback function to mutate or transform the corresponding data (of each row) for each column. For example,

Read More