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

How to wait for function call in Javascript without calling it directly

you can use Promises. In your case, you can modify your First and Second functions to return Promises. This way, you can await the completion of Second without having to call it directly. like this function First() { console.log('First is called'); return new Promise(resolve => { setTimeout(() => { Second(); resolve(); // Resolve the promise

Read More
javascript

zxing-js refuses to scan barcodes

@model Pocos.MCD_Stores @{ ViewBag.Title = "DoVisit"; } Records Loaded: 0 Do Visit Start Scanner Scan it now! Reset Scanned Barcode: None Product Details: None Select a product { codeReader.listVideoInputDevices() .then(videoInputDevices => { selectedDeviceId = videoInputDevices.deviceId; codeReader.decodeFromVideoDevice(selectedDeviceId, 'barcode-scanner', { formats: [ZXing.BarcodeFormat.EAN_13] }, (result, err) => { if (result) { console.log('Barcode detected:', result); document.getElementById('scannedBarcodeLabel').innerText = `Scanned Barcode:

Read More
javascript

Signing and encrypting data sent to frontend

I’m planning on sending some sensitive data to the font-end in an encrypted form, storing it for a short time and then sending it back to the backend where it’s decrypted and used. For this I guess I would need to both encrypt and sign the data for extra security. There are a lot of

Read More
javascript

Customizable Color Picker

I’m building a web app, and I’m wanting to put in a color picker. However, I want to limit the color options to a limited set of colors. Specifically, I’ll be identifying what hex colors most closely match up to available DMC embroidery thread, and I want the color picker to only show those colors.

Read More
javascript

Changing classname of “

New to JS. I’m trying to change the class of this: <div data-node-key="holders" class="ant-tabs-tab"> To this: <div data-node-key="holders" class="ant-tabs-tab ant-tabs-tab-active"> But nothing seems to work since all the tutorials are for query selecting of id’s or classes. I think this code I worked out should do the trick, but I get an error saying: Uncaught

Read More
javascript

Website getting stuck when scrolling. Using Locomotive Scroll Plugin

Our website (https://www.4media-group.com/) just started getting frozen when the page gets to the two Swiper carousels (Case Studies and Client We Believe in). I was thinking it might be something with how and when Locomotive Scroll and Swiper are initiated. But I can’t seem to figure out what to change. When the window resizes you

Read More