Questions tagged [javascript]
JavaScript is a versatile, high-level programming language. It is the programming language in all browsers, and can be used for back-end programming with Node.js. Use this tag for questions regarding vanilla JavaScript; optionally tagged with an ECMAScript version. If you are using a preprocessor such as TypeScript please tag with that too.
9,430 questions
0
votes
0
answers
27
views
Sending and receiving TypedArray's in Chromium Web extension messages
This is an alternative approach and follow up dealing with this issue Extension messaging uses base::Value (JSON) serialization but could use WebSerializedScriptValue (structured cloning), closely ...
5
votes
1
answer
124
views
Breakout Game as a Bookmarklet in JavaScript
Why I made it
I wanted to experiment with javascript: bookmarklets and see how far a small injected script could go on any site by making a simple injectable game.
...
1
vote
0
answers
145
views
Force Google Translate to translate text between <code....> and </code> tags on my webpage by replacing code with span and revert it after translation
Some browsers were not showing text on my webpage in bold so I put some text that was between <span> tags between ...
5
votes
1
answer
131
views
On the absence of protected member concept in javascript
I wanted to create a protected member in a javascript (ES) class but, of course, there is no such concept. So I devised a way that would let me create a member or something that "no one could ...
1
vote
0
answers
56
views
Streaming messages for Chrome MV3 Web extensions
Explainer
Problem
No standardized Web Extension API to send or transfer TypedArrays or ArrayBuffers or
...
0
votes
0
answers
49
views
WebSocketStream implementation, JavaScript runtime agnostic
References
WebSocketStream Explained
WebSocketStream API design
Source code
https://github.com/guest271314/websocket-stream-impl
Implementation
...
1
vote
1
answer
160
views
A different way to create HTML elements
I created this module to help with the creation of HTML elements:
...
3
votes
0
answers
98
views
Native Messaging performance test
I put together this Native Messaging performance test to determine based on evidence which programming language, JavaScript engine or runtime, and WebAssembly compiled code is fastest to round trip 1 ...
1
vote
0
answers
48
views
SpiderMonkey JavaScript engine Native Messaging host
Native Messaging host using Mozilla SpiderMonkey JavaScript/WebAssembly engine.
Documentations
Chrome Developers
MDN Web Docs
Microsoft Edge Developer documentation
Messaging between the app and ...
6
votes
5
answers
1k
views
JavaScript program that calculates the sum and difference of a pair of numbers
The goal of the following openprocessing.org JavaScript program is to calculate the sum and difference of a pair of numbers and print the 2 results if they are both positive. I want to do the ...
1
vote
0
answers
44
views
A calendar event element
Below is code for a front end calendar event element I have just finished. Though I have been programming in JavaScript for a while, this is the first time I have created a custom class and element, ...
7
votes
1
answer
97
views
Fruity Balance GUI Remake
I am new to front end development and thought to recreate the GUI of Fruity Balance just for practice. I would love to hear any advice on best practices. I am also wondering if any improvements could ...
0
votes
0
answers
107
views
TCP and UDP sockets in the browser, Part 2: fetch() and WebRTC
A branch of a repository I maintain has a function that can do different things based on the input and expected result, and structure of a particular inner function call.
I can echo 20 MB to and from ...
-1
votes
2
answers
144
views
How would a more seasoned developer un-quag this quagmire?
I'm looking for suggestions on how this code structure can be improved. It feels like there's a smarter way.
The purpose of the script is to create live stream players if the following conditions are ...
2
votes
1
answer
153
views
Program to get all possible words from a set of letters
I wrote this code below to get all possible words for an array containing \$n\$ letters.
The logic of the code is that the letters of the array are mixed up in random positions and checks if this ...
6
votes
1
answer
554
views
Creating a fast connect 4 ai solver in JavaScript
I’ve implemented a Connect 4 AI in JavaScript using a Negamax search. My goal is to solve the game completely from the starting position (depth 42). I’m trying to make it as fast as possible and would ...
5
votes
1
answer
79
views
Web component (custom element) for a Swing-like (Java) tree with a shared style sheet
This is my first web component. I implement it as an autonomous custom HTML element. I cannot use a customized built-in element because it's not supported by Safari. Nevertheless, as it mainly ...
3
votes
1
answer
99
views
UDP and TCP sockets in the browser
I'm using a Web extension to communicate with an Isolated Web App over externally_connectable for the capability to use Direct Sockets UDP and TCP sockets from ...
4
votes
3
answers
202
views
My first web project; calculate the GCD and LCM of two numbers and save cookies
I made my first ever JavaScript project. It is a program that calculates the GCD and LCM of 2 numbers that the user inputs. It also stores these 2 numbers in cookies so that they can be accessed for ...
3
votes
1
answer
108
views
OpenProcessing.org JavaScript program - Building a list of matrices
My openprocessing.org JavaScript code listed below produces the output I want but doesn’t seem very elegant to me especially the “.M” in “matrices[mat].M[row][col]”. Any comments to improve the ...
5
votes
1
answer
405
views
JavaScript Text Summarizer
I wrote this both to help read (and edit/summarize) my own work, but mainly to be able to get through the mounds of papers I was asked to read as a graduate student.
This is a summarization algorithm ...
8
votes
1
answer
548
views
An electronic implementation of the Change Change game
I am fairly new to programming using the site openprocessing.org.
My program, available to play online here, is a simple puzzle game in which you slide the circles so that you end up with 4 circles in ...
0
votes
1
answer
170
views
Transfer-Encoding: chunked parser - JavaScript
This code parses a series of Uint8Arrays that comprise a Transfer-Encoding: chunked request
...
3
votes
1
answer
129
views
Informal Text HTML & JavaScript Scorer
This is something I've been writing for a paper I'm working on. There is a debate about what is formal text and what is not, but what I know about myself and my writing is that I use certain words (...
2
votes
0
answers
111
views
Simple image captcha test in Java and JS (revised version)
Following on from my previous question, I would like to know what could be improved here and whether it is now secure.
I had to use Java 8 because the Blade lib was built with it, and I want to extend ...
4
votes
1
answer
154
views
Implement a simple image captcha test yourself in Java and JS
First of all: I was looking for a simple image captcha solution for a website, but all I found were "Over-the-top" solutions for me. So I decided to write something to self.
I mainly use two ...
1
vote
1
answer
92
views
Runtime agnostic WebSocket server
A runtime agnostic WebSocket server. Tested with node, deno, bun, ...
6
votes
3
answers
152
views
Function to reduce dead band when reading a pressure transducer that has calibration device under test information
When reading a pressure transducer, I'm currently using the following code to apply the "device under test data" from the calibration report.
How can I determine which range segment of ...
3
votes
2
answers
186
views
A Pacman clone in Javascript with binary heap and A*-based AI
rodde's Pacman clone
I have this clone implementation of Pacman. It looks pretty much like the original, yet I had to impose some relaxations as I am not sufficiently masochistic to implement all the ...
4
votes
1
answer
171
views
openprocessing.org program - After screen tap, erase red circle, pause and lastly draw new white circle
I am new to programming using the site openprocessing.org.
The code given does the following on my iPad:
Draw a red circle
Wait until I finger tap near the red circle’s center
Erase the red circle
...
6
votes
2
answers
155
views
WebRTC Data Channel over WHATWG Streams
There's been talk about implementing WebRTC Data Channel over WHATWG Streams for a while
https://github.com/w3c/webrtc-pc/issues/1732
https://github.com/w3c/webrtc-nv-use-cases/issues/44
https://...
4
votes
4
answers
281
views
JavaScript live validation for a registration form
I am working on a blogging application in Laravel 8.
I have added "live validation" to the registration form with JavaScript. For password strength, I use Zxcvbn.
The registration form ...
2
votes
1
answer
115
views
Deploying a chatbot on Vercel
I developed a chatbot using the Telegraf.js framework. Although the latest version of Telegraf offers TypeScript support, I chose to use JavaScript. I followed a tutorial to deploy it and would like ...
2
votes
1
answer
114
views
Locate \r\n\r\n in a HTTP POST request (Uint8Array)
The requirement is to split the headers from the request body, most efficiently.
Possible approaches I have employed and/or considered
Decode to text, match ...
2
votes
1
answer
237
views
Flash Card Program I Wrote in JavaScript
I really don't post a lot on here, but decided to share this because I thought first that it could be helpful and second that it could be improved. In my first versions, It was all javascript, like ...
2
votes
2
answers
155
views
State management patterns in vanilla JavaScript
I am trying to manage state in vanilla JavaScript—without using frameworks like React or Vue. I am also not using state management libraries.
My requirements are:
Reactivity
Time Travel (Undo/Redo)
...
1
vote
1
answer
179
views
FreeCodeCamp todo list
I'm writing JS for the FreeCodeCamp todo list; the corresponding HTML and CSS for this can be found on their page. I have made one edit to the HTML - the button with type "submit" has been ...
5
votes
1
answer
70
views
Generate Javascript call graph in Graphviz DOT language
I use the following code to create a call graph from javascript file(s). I generate the output in Graphviz DOT language in order to create visualizations of that graph using the Graphviz command line.
...
3
votes
1
answer
241
views
Image preview and delete for Laravel blog application
I am working on a blogging application in Laravel 8.
I have put together a way to preview and remove the main article image.
In the ArticleController.php controller,...
3
votes
1
answer
343
views
HTML Editor: Online HTML Editor with Real-Time Preview (version 6)
Overview
HTML Editor is a web-based HTML editor designed for web developers, designers, and learners. It offers a lightweight, minimalist environment for writing and previewing HTML, CSS, and ...
3
votes
1
answer
177
views
Bulk Text Replacer
I have created a simple text editor with a "replace all" feature. It's meant to be part of a larger project, so it needs to be robust and work reliably across various scenarios. Please ...
0
votes
0
answers
62
views
Sandboxed, block scope for evaluating user code
I'm working on a modeling app and want to provide block scope for evaluation of user entered code. I'm assuming that the user is not malicious, but error prone, like all of us. At the same time, I ...
5
votes
1
answer
267
views
Parsing Markdown with bare hyperlinks: Hoping to find a way to workaround the "noscript" workaround
The following example shows how to use markdown-it to parse and render Markdown.
It works, but there is a dirty trick there, which I absolutely don't like: to ...
1
vote
1
answer
125
views
React TODO list component
The code makes unnecessary API calls because there are two useEffect hooks that both fetch data. The first useEffect runs on mount and fetches data for page 1, while the second useEffect runs whenever ...
4
votes
1
answer
132
views
Checking that GEE code correctly computing distance to nearest bright pixel using tiff data
I'm using Google Earth Engine (GEE) to calculate the Euclidean distance from sample points to the nearest brightest pixel above the threshold value "avg_rad > 10" in nighttime light data. ...
4
votes
2
answers
105
views
better-SQLite3 and JS/Next.js - updating data using "transaction"- shorter / better code?
I am pretty new to SQL databases and in particular to the better-SQLite3 database. I have managed to insert, update, and delete data in a way I desire. All of it running in the background of a self-...
1
vote
1
answer
96
views
Pomodoro timer with notification popup [closed]
I have this code that I feel like could be done more efficiently; is there any way i could fix it?
I'm trying to make a pomodoro timer with html,css and javascript and i want to add popup ...
6
votes
1
answer
170
views
Dynamic image gallery with filters pulling from a JSON file
I have an image gallery of old internet banner ads that pulls URLs and metadata from a JSON file and then displays them based on a set of user-selectable filters. The filters can show/exclude images ...
5
votes
2
answers
195
views
Tags selector in plain JavaScript, without using any plugin
I have made a "tags selector" in plain JavaScript, without using any plugin.
...
6
votes
3
answers
867
views
Collision detection of two rects with rounded borders
I wrote an algorithm how to detect the collision detection of two rects with rounded borders (the code was written using TypeScript but I tried to name things as clear as possible to code be readable ...