Tagged Questions
ECMAScript (commonly referred to as JavaScript) is primarily used for scripting web-pages but also has several embedded forms and stand-alone interpreters / JIT engines. Use this tag for questions regarding ECMAScript 5 or 6 and its dialects / implementations: JavaScript, JScript, etc., excluding ...
0
votes
0answers
4 views
Using Interface for context menu for a web application
I'm currently building an interactive web application that allows users to create flow charts using Angular2, typescript and PixiJS (the latter is a 2D rendering library).
The core part of my ...
-3
votes
1answer
54 views
Make my jquery shorter? [on hold]
I'd like shorten my jQuery. I know this is possible using this element and child but I don't know how it works.
I have an element being shown and hidden on click, basically. They all have the same ID,...
0
votes
2answers
35 views
Keep main content scrollable but not the body
For a template such as:
I'm using the following approach
Get the height of the viewport via javascript (Let's say 500px)
Deduct the header and footer height from it (Let's say header and footer are ...
3
votes
1answer
49 views
Extracting JSON from string using regex
I need to get the value of item inside of this string and parse it as JSON. I've got some working code but I feel like it could be optimized (a lot) and cleaned up (a lot). Any tips or pointers are ...
4
votes
2answers
235 views
CodeWars: Gap in Primes
I wrote a javascript code for finding the first two consecutive prime numbers (that doesn't have divisors except one and itself) with a specific gap between them. It works well but take too much time ...
1
vote
1answer
19 views
Building a UI to fetch list of features and edit them
I am building a UI which fetches a list of features based on an ID and then the user can edit the list of features and save it. The script also build the UI based on the data structure currently hard ...
-3
votes
0answers
19 views
Consolidating event listeners, or being unnecessarily redundant? [on hold]
In my project, I'm at a point where I need to attach a handful of event listeners to various HTML elements (buttons). A few, in particular, share a parent element, which makes me want to use a ...
7
votes
1answer
67 views
Single Player Repeatable BlackJack Game
You can play this game as much as you want and after every game, you win/loss is recorded. Javascript has -0 and +0 so I guess that's why the counter acts weird at the beginning. Took me 4 months to ...
1
vote
0answers
21 views
Implementation of user permissions
I am building a web-application in NodeJS (using TypeScript) and MongoDB (using Mongoose).
In my application I have 6 types of permissions. For the simplicity, let's use ...
2
votes
2answers
59 views
Finding the coordinates on an edge of a square
I wrote a calculation that finds coordinates on an edge of a square, but it came out as a really long nested tangle of conditions. After some reduction and finding common pieces I arrived at this ...
3
votes
0answers
27 views
Creating instances of a logger class for various logging levels
I provide a class to use but for convenience I want the class to implement some instance methods as static methods. This was fast and concise but it feels smelly, probably because I'm modifying the ...
-5
votes
0answers
20 views
0
votes
1answer
48 views
Javacript code to flatten JSON via recursion with conditional logic
I'm flattening a JSON structure where objects have their interaction type appended at the end, for use in an HTML/PDF generated file. I have variable names for Checkboxes, Text inputs, TextCheck is a ...
2
votes
0answers
20 views
Responsive layout for showing/hiding 4 panels
I have 4 panels that will contains tables for data. There will be instances where a panel will contain no data, so I have combated wasted space with the code below. I'm relatively new to both jquery ...
1
vote
2answers
40 views
Composing a CSS transformation
I have a function that creates a css transform property string
based on some global variables. This string can be copied later by a user, so I would prefer to keep the output short.
This is my code:
...
1
vote
0answers
25 views
Create Chrome Storage Sync Get Array [on hold]
Currently I have a working function that individually goes through, obtains the set synced data in Chrome and then sets the value of a corresponding ID element with the returned value of the get ...
1
vote
1answer
26 views
Display related images based on text name
Instead of "Black and Green" text, We are displaying "Black & Green" images with help of below code.
What we want is this concept should work for all colors, for that one solution is i need to ...
-1
votes
0answers
13 views
Server Sent Events Read Json and Update Clients [on hold]
Currently I'm updating my Digital Signage Solution to SSE. It's based on Codeigniter and client using javascript. I'm new to SSE. I have done below code in Rest API controller.
...
-4
votes
0answers
16 views
Cordova Native Page Transitions issue [on hold]
I been using the Native Page Transitions for phonegap for a while but I always had problems adjusting the timer to make a smooth transition cross device.
For those not familiarized with the plugin, ...
1
vote
0answers
26 views
Snaplogic Script to group key-value pairs based on a certain ID field
Following is the script I'm using to group key-value pairs based on an ID field viz. interface_id:
...
3
votes
1answer
24 views
Navigating HTML5 canvas checkerboard with nested loops / multi-dimensional arrays
I'm creating a web app to create pixelmaps for large LED displays. The maps are basically large checkerboard patterns of various sizes with different constraints.
I'm running into snags trying to ...
4
votes
2answers
39 views
Generate a series of random integers between 1 and 10
Is there a better way of generating a series of unique and random integers between 1 and 10 in JavaScript (ES6)?
...
1
vote
0answers
29 views
Angular MVC structuring and code usage
I use the following code which run OK with very simple Angular UI
that run intro page with form and when you click on button it navigate to another simple form to create data. since this is my first ...
2
votes
1answer
65 views
My grade calculator with special weighting
My school has a special 65% formal 35% informal weighting, so I made something to find what your grade would be if you added or ...
-5
votes
0answers
30 views
-5
votes
0answers
19 views
In JS is there a better way to get several levels deep in an object without null checking each one? [closed]
Currently i have the following code:
...
2
votes
1answer
33 views
Filtering script for products by category
I built a simple product filtering feature that works at least in the browsers and platforms that I have tried using it on, but I am unsure about a couple of aspects of it. I built this on a ...
-4
votes
0answers
14 views
How to handle else statements in Node.js style callbacks? [closed]
In JavaScript/Node.js it is quite common to see code which checks if an error exists and returns if it does.
This is often written by returning on an error or falling through if there is no error.
<...
-2
votes
1answer
19 views
Prototypical Javascript design approach [closed]
Is there anything functionally different about this prototypical design pattern:
...
1
vote
0answers
27 views
A vanilla JavaScript library for typesetting algorithms in HTML documents using XML and LaTeX - follow-up
This post is basically a follow-up to my related question. I added some new keywords, made the code less DRY. Also, the library inserts the required CSS to the HTML document, so that there is no need ...
2
votes
1answer
40 views
switchMap with array of Observables
I'm trying Rxjs 5 to simplify some Node.js nested callbacks. I need to read a directory (fs.readdir), then read stats of each file (fs.stats) and parse them if they were modified since last sync.
The ...
8
votes
1answer
75 views
Adding x86 assembly language syntax highlighting to Google Prettify
Frustrated by the lack of syntax highlighting on Stack Exchange sites for code snippets written in x86 assembly language, I decided to do something about it. The network uses Google Code Prettify as ...
-1
votes
0answers
24 views
How do I constantly update my Game of LIfe grid built using JavaScript? [closed]
I have a working model of Conway's Game of Life ready. But the problem is that I can get it to constantly update after it starts running. I am using a Run button to get it working. But instead of ...
2
votes
0answers
31 views
Define a model in Node.JS
I've created the following node module to define my model. Is this a reasonable approach?
Model.js:
...
1
vote
0answers
31 views
Cleanest way to write a callback that accepts a next sequence in javascript
I need to call multiple functions asynchronously before producing a result. In this case what are the possible improvements in the following code(also including other library like for promise etc.) ?
...
4
votes
1answer
39 views
Linq-like functions in JavaScript
Today was my first day working with JavaScript and I tried to implement some Linq-like (C#) functions as extension methods.
I'm pretty new to JavaScript and wanted to ask you for checking my ...
0
votes
1answer
41 views
Displaying weather data from an Arduino
Please review my code, for performance and readability.
3 issues I am facing are
Uncaught Exception : out of memory (in firefox)
randomly Failed to load resource: The request timed out.
Even if the ...
4
votes
1answer
39 views
JS Data Fetcher and Stripper for Statistics App
This is pretty much the first actual (not "hello world") program I'm writing. It's a rewrite of this app and my aim was to increase the fetch speed, and increase the cache storage efficency. I've more ...
6
votes
2answers
95 views
Simple Tic-Tac-Toe game in React.js
I'm relatively new to react and attempted to create a simple Tic-Tac-Toe game. Would be great if i could get some feedback on this. Again, at this point using only React (no Redux).
main.js - main ...
6
votes
0answers
56 views
Minesweeper JavaScript Prototype
I am looking for some review of a Minesweeper game that I made as my first JavaScript program. What I have here is simply the prototype for the minesweeper game while I handle the actual grid in a ...
2
votes
3answers
42 views
Get the difference between two dates, in the most convenient unit
I use the following code in Javascript to get the difference between two Date objects. I want the result to return the difference in:
seconds if the result is less than 60 secs
minutes if the result ...
7
votes
0answers
67 views
A vanilla JavaScript library for typesetting pseudocode in HTML documents
I have this plain JavaScript library for typesetting pseudocode in HTML documents. (See the documentation for details.) (See the GitHub repository - broken as of now.)
Source code
algotype.js
<...
7
votes
1answer
62 views
Piano, output all the keys and give a scale
I've two snippets below, the first one output all the keys of a piano and the second one give me a scale when given a starting note. For those who don't know how a piano is structured here is an image ...
2
votes
1answer
33 views
Extract rotation values from css string Javascript
I have the following function that takes out the rotation values from a css string and returns them as an array.
...
1
vote
1answer
28 views
Show weather data at client's location
I am beginner and I want some tips on this code i have written. How can i make it better, shorter cleaner. And the isMobile() Function is borrowed from the internet. It's a Weather App That gets Data ...
4
votes
0answers
26 views
A humble converter between “calendars”
For a special writing and/or worldbuilding project I have, I created a special program.
In the story, different factions have different ideas on what should be considered the first year of their ...
2
votes
0answers
26 views
MVC-fying number inputs, barely
Spoilers!!
(duh..)
This code manipulates two HTML number input controls and multiplies them.
I am trying my luck on implementing MVC in JavaScript by example. This is a very minimal and useless ...
5
votes
1answer
75 views
Drag and Drop Schedule for Community Radio Station
I'm working on the backend of a community radio station website, and fancied trying my hand at writing a drag and drop scheduler.
It's working, but I feel I've made a mess with the drag and drop ...
1
vote
0answers
25 views
Configure Webpack to handle cache-busting
I'm not very familiar with webpack, and I was very afraid that what I implemented for cache busting would break something. What I have seems to work. When I open up the built folder, under ...
0
votes
1answer
29 views
Abstracting out two lines of code in Coffeescript
I am currently working on refactoring two methods that exist in directives into a service.
This is method one:
...