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 ...

learn more… | top users | synonyms

3
votes
0answers
29 views

JavaScript function for to toggle multiple CSS-classes at once

The method toggle of Element.classList expects a parameter which names a CSS-class. You can't assign multiple classes at once ...
1
vote
1answer
33 views

Simple function to generate an HTML-safe string

Sometimes, we have to do some fixing to insert a string into an HTML property. Or just to display it. But not everything is safe! Consider the following example: ...
0
votes
2answers
49 views

Returning functions within Javascript objects

After coming across Douglas Crockford's views on class-free OOP, and doing away with new and this in Javascript I tried defining an object with its own variable and function, and returning it in JSON, ...
3
votes
1answer
18 views

Optimizing jQuery list filtering

Scenario Currently filtering through a list of ~3100 rows of data presented to the end-user in the form of an index (think, list of car models). This is done in such a way that every item is ...
-6
votes
0answers
20 views

How can I solve this problem about decreasing values? [on hold]

I'm a beginner to programming (starting with Javascript), and I'm making my own exercises for practice. I successfully completed problem 1 that I created, but need help implementing problem 2. I've ...
1
vote
0answers
7 views

Insert an interval into a list of sorted disjoint intervals

The code works on my one test case. What do you think about it? Can it be simplified? ...
-5
votes
0answers
25 views

How can this code be improved?

Looking for feedback on anything but the naming conventions. Please read the notes. One problem with this code and it is commented out is that jQuery shake does not seem to work with absolutely ...
2
votes
0answers
14 views

Vertical cycle slideshow

I want to make a vertical cycle slideshow. This works perfectly for me but I'm just wondering if it's possible to achieve the same functioning with a better code. I don't know if my code would provoke ...
3
votes
0answers
26 views

Prevent multiple async calls from all attempting to refresh an expired OAuth token

I have some code that needs to access an API that requires OAuth authorization in the form of a token, and every time the token expires, it needs to be refreshed. I made a function called ...
3
votes
1answer
35 views

OOP and non-OOP versions of layout and page animation code

I am trying to learn how to write more object oriented javascript code, but I am having a hard time understanding the correct way to do it, and how it is useful for front end development. As you can ...
1
vote
1answer
18 views

Using toString() as a hack to generate keys for react-select component

While trying to integrate react-select component on my codebase on documentation it's explained that you can pass an array of options with label and value ...
1
vote
1answer
32 views

JavaScript to fire event every second until 10s then gradually increase

I have a piece of JavaScript that's going to fire event every second after 10s, it's going to gradually increase the interval time. I'm new to JavaScript so it would be nice to have a codereview. ...
-2
votes
0answers
21 views
-1
votes
0answers
19 views

Template for a table to display suggested pledge amounts

I am building a template that will: need to be edited by people with minimal JS/CSS/HTML training need to be flexible enough to accept changing text and layout need number of rows/columns will ...
2
votes
1answer
45 views

Stock performance app

I'm building an app that tells you a stock's percentage change in price between two dates by using Yahoo's API. Given a stock ticker and two dates, it currently outputs the percentage return to the ...
-1
votes
0answers
9 views

Code structure for complex UI module with strongly bonded components [on hold]

I'm trying to figure out a new approach in organizing my code structure. Let's say I have a single-page module which UI consists of: form with search filters, very interactive table (paginated, ...
2
votes
1answer
35 views

Google maps API code

I have inherited a site which uses the Google API to create a map on my webpage. I don't know much about JavaScript but from the research I've done, I dont think this code is optimal as it is not ...
3
votes
1answer
31 views

Conditional async validation function

We have the following validation function: ...
1
vote
2answers
41 views

Traversing javascript/json based on a dot-separated lookup string

I have an object of arbitrary depth, and a string (or array) containing the keys which have to be traversed to get to the value. As far as I know, there's no method to get to the value directly: ...
-2
votes
0answers
19 views

AS3 1067: Implicit coercion of a value of type uint to an unrelated type String [on hold]

I'm getting the error 1067: Implicit coercion of a value of type uint to an unrelated type String. The box1 and box2 are dynamic text boxes. I would like the random number to be put into the dynamic ...
6
votes
1answer
81 views

Self-playing Baseball game — An es6 update

A long long time ago I asked this question which has since garnered about one thousand views. Now for something new. The demo for what I have is located here. I am generally happy with what I have ...
0
votes
0answers
17 views

Silly redis implementation

This is a silly Redis implementation that handles only three commands: INFO, ECHO, PING. The implementation is based on streams: ...
1
vote
1answer
29 views

Backbone subviews and switch

ActiveWindow is like the main container and below the subviews. Router trigger activewindow.render(options) then the switch operates. Is it fine to do that Or how ...
6
votes
3answers
73 views

Find the date for the nearest day of the week, in this case Fri & Sat

General objective: Find the date (day of the month) of the nearest specified day of the week and output. More specifically: Focusing on events which take place every Fri & Sat, want the page to ...
0
votes
2answers
35 views

Simple Matrix Rotation

I needed to rotate a non-square matrix in my program to transpose some spreadsheet data and decided to make a function to rotate 90, 180, or 270 degrees. It doesn't rotate the matrix in place, but ...
2
votes
0answers
31 views

Finding all paths between nodes in a graph

I wanted to write a function paths that returns the possible routes between two nodes in a graph. For example: ...
3
votes
1answer
30 views

Implementing tabs with panes

I am new to AngularJS. Here is my basic code for implementing Tabs with Pane. Eventually, each tab-pane will have a form and a ui-grid that will display data from the DB. Can I use separate ...
2
votes
1answer
35 views

JavaScript text-analyser to determine how often a defined word appears in text

The idea of my application is to have the user provides text which is pasted (or written) inside the textbook and further provides a search word. The application then shows the overall count of words ...
0
votes
1answer
39 views

Submitting a form via JSON

I have a feedback.js that I would like to improve. ...
2
votes
0answers
24 views

JavaScript AJAX page flipper

I rarely see this kind of navigating on the web. But basically I load all the content in the background and then flip pages as needed while loading user specific data via ajax. Are there any ...
1
vote
0answers
10 views

Set the direction a Sprite faces based on its velocity

I'm learning Phaser, and decided to make a Mario-type clone. I'm writing a function that ensures the sign of the Sprites horizontal scale matches the sign of it's velocity. For a Sprite that's ...
0
votes
1answer
33 views

Compiler for grond, a language-in-the-making

I'm working on a language called grond (see it on GitHub); the compiler is so small it is included in this post. My gut tells me that this code is awful, but it works. I am hesitant to change things ...
-3
votes
0answers
22 views

Tracker to track time spent on a website in JavaScript [closed]

This is a stripped down version of the functionality I'm building. It's going to start tracking estimated time spent of a user on a page. It's going to start at the 5th second and gradually increase ...
0
votes
0answers
33 views

Dynamic create items in view

This script is for creating / selecting / deleting items dynamically. As I am at the beginning of my studies. I wonder if this is the best way to do this. ...
-2
votes
0answers
20 views

Javascript model class, should I refactor it using methods in prototype? [closed]

Usually I am using code below as boilerplate for my JavaScript models (jquery plugin or knockout one). Looking to bootstrap sources (and many other) I see that it uses methods definition in object's ...
2
votes
1answer
67 views

Editing HTML based on instructions in a data structure

My getExtend() function, which will be included via require.js, has two inputs and one output: HTML file content config object which determine how to ...
-5
votes
0answers
24 views

Returning a resolved promise from the error handler of a catch block in one of the promises in Promise.all [closed]

I'm looking at this piece of code and whilst it works, it feels wrong to me. I'm wondering if I am looking at an anti-pattern? The code starts with two promises, ...
-2
votes
0answers
11 views

week by week countdown, need a process for php to store information to mysql db [closed]

I have this script and i need to go with php to store the infos to the db, and a form to setup the countdown date for my users. thanks! Script: ...
-2
votes
0answers
33 views

Wanting a better MVC to Javascript pattern to get Resource Files from C# mvc into Javascript [closed]

Currently Resource Files in asp.net mvc c# are the typical file.resx MVC controller method: ...
1
vote
2answers
121 views

My favorite privacy settings

I'm looking for general feedback on this module. Here is what it handles on the page: This is a private "class" meaning none of its properties are available outside of it. ...
4
votes
2answers
76 views

Adding links to tags on StackExchange sites

This Greasemonkey script adds links to tags on StackExchange sites which allow for activating, deactivating and ignoring favorite and related tags by using UI components. Since JavaScript is not my ...
1
vote
1answer
30 views

Custom form validation using jQuery

Recently I have been doing a bit of work with Contact Form 7 and Wordpress. I've begun looking at form validation using ...
0
votes
2answers
31 views

delegate click event on document

I'm adding an onclick listener to the whole document then checking the source of the click. If the source of the click contains the attribute data-widget I want to ...
1
vote
1answer
20 views

Node module to fetch/post API data

I'm fairly new to JavaScript and Node and am wondering if I'm on the right track. Module file: ...
4
votes
2answers
69 views

Parse HTML to modify it

I'm using the following code to parse html, This code is working but since I'm new to JavaScript and working in alone project I would appreciate if you can give me some tips and feedback how can I ...
4
votes
2answers
24 views

Window-size-dependent content toggler for an HTML form

I had to build a responsive component which allows the user to display specific content in a page. I called it the contentToggler. Here is my component in action ...
0
votes
1answer
37 views

PHP's array_diff in JavaScript

I shall make a JavaScript-function which does the same as PHP's array_diff: http://php.net/manual/de/function.array-diff.php Because it is intended to use the function as a (internal) ...
-1
votes
0answers
13 views

MultiTouch HTML [closed]

I would like to know if it is possible for MultiTouch to be implemented on HTML. Scenario like this: ...
-2
votes
0answers
17 views

What's wrong with my jQuery code? [closed]

Developing an application in Laravel, i am working on the invoice section with the help of jQuery.Actually everything works fine but when i added the below jQuery code then my page do nothing via ...