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

4
votes
1answer
30 views

JavaScript path parsing

I was attempting to do some contribution to the underscore-contrib library, and I ended up writing a function that will parse a JavaScript path to later on expose through an API if the path exists or ...
2
votes
1answer
24 views

Optimizing gulpfile.js

I'm fairly new to JavaScript and Gulp. I was following this article for creating my gulpfile, trying to follow best practices, but it seems to me that this peace of code can be optimized and written ...
4
votes
0answers
10 views

JS Progress Bar Widget

Demo of the widget: http://jsfiddle.net/slicedtoad/Lywvbsf4/ It's a progress bar that shows a list of steps and which one is being completed as well as allowing previous steps to be revisited. It ...
0
votes
0answers
50 views

Reduce CPU usage in mouse-scrolling script

I'm working on a jQuery plugin. The problem is that when I use it I can see a high CPU usage in task manager. I think the problem is here: ...
6
votes
1answer
31 views

Tracking (uniform spacing) between 2D elements

The problem I am solving: I select multiple 2D SVG elements in an editor(the elements are in arbitrary positions on my canvas). I run the function ...
7
votes
2answers
68 views

JavaScript Validation

Bit of a preface on my motive: I'm self taught and have never really worked in a collaborative environment. My only benchmark for quality is "does it work" and I've never been really subject to peer ...
0
votes
0answers
7 views

AngularJS factory, return object to be used again in factory

I'm trying to create a wrapper / factory around the cordova media plugin, which requires you to create a new Media object, and then use it again to pause, stop, play, etc it. The factory + link to ...
0
votes
0answers
17 views

Push-pull pattern with nodejs and zmq

I created the code below to illustrate push-pull pattern with zmq and to benchmark some concurrent job. ...
2
votes
0answers
30 views

Lazily Load CSS and JS

I have written this piece of JS and CSS loading code and I would like some advice on it. Anything some of the Javascript Gurus could possibly point out would be much appreciated. The code works, but I ...
3
votes
2answers
46 views

Performance of a method to mask all but one rectangular element on the page

The point of this code is to mask a page where the user is editing the page's 'body' content. This is in a CMS. The rest of the page is the website template (i.e. header, index bar etc...). I've ...
1
vote
2answers
15 views

Enable and disabled multiple inputs

I have to enable/disable multiple inputs when a select change. It works but I want to do it better. How can I improve my code? ...
1
vote
1answer
34 views

Dealing with the need to pass the root view model down to the children

I tend to feel the need in my Knockout applications to pass along a reference of the root view model down to the sub view models. However, I don't like the fact that I then have a dependency that lies ...
-3
votes
0answers
12 views

writing code for an image to spawn when x hits 900 [on hold]

How would I go about spawning in enemies once the current enemies hit an x location of 900? it would have to be like if(enemy.x<=900){ //spawn enemies } ...
1
vote
1answer
35 views

Fizz Buzz in JS

This is a simple JavaScript Fizz Buzz solution based on a Codecademy exercise. I refactored it down a few lines after seeing these implementations. I wanted to post here and see what else I can ...
3
votes
1answer
26 views

Developing an alert notification in AngularJS

I'm studying Angular and want to develop my own notification alert. This is what I done, I like it and it's working like a charm but I think that it can be improved: Do I need to use it in ...
3
votes
3answers
198 views

Recursive linear search - branch style and layout

Is my layout of the if/else statement reasonable? It feels clumsy to me to spread the termination condition over the first three lines of the function. Can I ...
12
votes
1answer
99 views

Javascript Minesweeper (with Stack Snippets!)

As Stack Snippets are live on Code Review now, I wanted to do something quick in it as part of rolfl's challenge on meta. And when you make things quick, they probably get dirty. And when things get ...
10
votes
1answer
101 views
2
votes
0answers
27 views

Editing <option> values through a textbox with jquery

I've written a script that will allow me to enter a serial number for each received product, in-line in a table. First you enter the amount received, which increases the size of the ...
3
votes
1answer
48 views

jQuery menu: hide and show on click

I am new to jQuery and currently practicing. I wrote a little piece of code to show and hide a navigation on click and change the text of the button when the navigation is opened and closed. I am ...
1
vote
0answers
25 views

Marking items as selected in Angular directives

I am new to Angular and feel that I'm doing mistakes and reinventing the wheel. Could you please review my code and share your ideas about how it can be improved. Demo The problem is very common. I ...
2
votes
1answer
23 views

Move uploaded file

As I mentioned in Node.JS fs.rename can not move files in right way. And it should be solved with stream piping. Please verify this code and answer questions in comments: ...
1
vote
1answer
23 views

Grey to Colored Image

I want to improve the code, in which you can enter a grey bitmap and it will return you a colored one. ...
4
votes
1answer
94 views
+50

Thumbnails for bootstrap carousel jQuery plugin

Codepen: http://codepen.io/srkimir/pen/mGbrf Github: https://github.com/srkimir/thumbnails-carousel While you slide left or right appropriately, thumbnails gets selected and change their opacity to ...
3
votes
1answer
29 views

Optimizing a Node.io server code for self-balancing robot

I am building a 3D printed self-balancing robot, and use the attached server script to control it. I coded using node.io, express and socket.io. The system is working, but I would appreciate some ...
4
votes
3answers
274 views

JavaScript constructor and namespace in object literal style

Is this a good way to create a class with a constructor and namespace in object literal style? ...
2
votes
0answers
32 views

Creating a menu for widgets with editable settings

I'm trying to create a menu for widgets with editable settings. As of now I'm setting these settings per object by coding them in like you can see below. How could I make this shorter / ...
3
votes
2answers
70 views

Cleaner structure for Battleships code

The code provided is working fine, but I would like to see if there is room for improvement for the code provided: ...
2
votes
1answer
18 views

Controller code using the koa framework

I would like to gather ideas on how to refactor the JavaScript/NodeJS controller code below to be more aesthetic. The code is using the koa framework thus I use ...
1
vote
3answers
353 views

Faster way to check for a string in a array of string

I have a array of object, I need to sort them by time (hours, days or months) and separate the number of new IP. result is an array of object with property time (JavaScript timestamp), user IP ...
3
votes
1answer
45 views
5
votes
1answer
52 views

Creating a class library in JavaScript

I am an experienced Java programmer, but fairly new to JavaScript. I am creating a chat library in JavaScript, and have it working, but want to know if I am going about this correctly, and following ...
2
votes
1answer
44 views

Simple web application for benchmark

There is an article where the author tries to compare performance of different web stacks. The result looks pretty controversial. I try to prove that in real use case the difference between scores of ...
1
vote
1answer
40 views

Checking form input for an AJAX request

I've made a few functions to check form input for an AJAX request. I am still getting used to JavaScript and some of these AJAX requests. I am looking for any suggestions to better work with ...
3
votes
1answer
34 views

Responsive menu highlights page with JavaScript

This is a responsive navigation menu (pure css), that highlights the page with a short JavaScript I found online. I have it all working, but the CSS is totally a mess. The menu is actually a PHP ...
2
votes
2answers
57 views

Using jQuery and AJAX process a form with PHP

I'm looking to collect form input and pass it to a file called processing.php with AJAX JS: ...
6
votes
3answers
147 views

Efficient if-statements and how to use variables

The first part of the code (above the in-code comment in the middle) looks messy. I know I could use variables to make it cleaner, I just don't exactly know yet how can I effectively apply those when ...
6
votes
6answers
551 views

Prevent repetitive random numbers

Is this a good way to prevent repeating numbers, or is there a better a better, more efficient way of doing this? By efficient, I mean a less CPU and memory consuming process. I only mean two numbers ...
2
votes
0answers
28 views

Show with delay directive

I'm pretty new to AngularJS and have made my first directive. Is this a good or a bad way to do this? It works, but can't figure out if this is clever or not. ...
5
votes
1answer
57 views

Wrapping JS file in function, and assigning that function to a variable

I've been reading about wrapping JS files in functions to call them on load, etc. I also was looking at namespaces and how to avoid collisions with functions/objects/variables of the same name. What ...
0
votes
0answers
25 views

Is there a better way of designing this MongoDB schema?

My schema is based around a JSON response I'm getting from an API call. A gist of which is like so: ...
5
votes
1answer
98 views

Transforming jQuery form code into clean code

The following JS code handles when the form is submitted and some little extra stuff. I'd like to have it reviewed on the following aspects: Readability Efficiency Usability OOP It works exactly ...
2
votes
1answer
30 views

Pyramidal promises

I have a situation in my Node (express) controller where I need to check whether a particular language has a parent language, if it does, I need to do a new DB (SQL) call to retrieve the parent ...
1
vote
0answers
25 views

Gulp file for a simple SVG/Sass project

Here's a simple gulpfile.js I'm using on a very simple project which basically consists of an animation built with Sass, SVG and very little JS. ...
3
votes
1answer
28 views

How can I reverse the first K elements of an array?

I have an array and I need to make one function which has two parameters, array and K. I need to return a new array with only ...
10
votes
1answer
222 views

Draggable Resizeable Box

This is my first angular code. I've been working with jQuery for a while, so I don't have the same approach. I'm looking for advice and code improvement. The following code has 3 directives: ...
3
votes
1answer
43 views

Solving the Shortest Path problem (little bit of TSP, too)

Some background info: I'm working at a shipping company and the company's web developer has been fired a week ago. My boss knew that I had some knowledge in web development, so until we get a new ...
13
votes
2answers
1k views

Is this form submission validator professional?

I have written some jQuery code for AJAX form submission: ...
2
votes
1answer
66 views

Can the performance of this canvas drawImage() test be improved?

I have a quite simple loop that draws an 8px by 8px image many times in a canvas in a tiling fashion. Currently it's drawing 7500 images each loop. See the jsfiddle. ...
6
votes
4answers
212 views

Australian income tax calculator

I'm looking for some feedback on my first Javascript app. I've build an app that calculates tax for Australian tax payers. Would be great if someone could have a look over the code that I have ...