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

1
vote
0answers
6 views

Bookmark application AngularJS controller complexity

I am working on a personal project for managing one's Pinboard bookmarks. Since this is already quite a big project, I am not sure if my question fits the guidelines. My main concern is with the ...
2
votes
0answers
10 views

RESTful API parsing DBF data HSET in Redis

I have this working code, but would like your review: sync.coffe ...
-3
votes
1answer
17 views

Using a for loop to get multiple values that mean the same thing

How would I clean up this code? Would I put it in a for loop and make it loop through and set the rand2, rand3, ...
0
votes
0answers
22 views

Detect image in viewpoint of browser window then show image

I am working on a web project and am trying to create a way to detect when an image is in viewpoint of the browser window then load/show the image. Since there are some rather large image that are ...
2
votes
2answers
46 views

AJAX call to make an HTTP request

I am using node.js with express. There is a button that the user can click, and doing so calls this method on the server: ...
3
votes
1answer
60 views

Fictional Hotel Website

I've made a fictional hotel website that shows you hotel details when you click on a button. jsFiddle ...
-1
votes
0answers
16 views

Pass more than one value in event parameter on jQuery On method [on hold]

I´m doing a code to make <p:rowEditor> in Primefaces have a hint. I did it ...
1
vote
1answer
45 views

Auto-populating user info from database

Auto populate user info from database when user inputs employee number. The same applies when the user inputs name/extension/mobile/email/ Some code is duplicated. Is there any way to make it ...
-2
votes
0answers
16 views

Javascript: How do I append a string to search query only once? [on hold]

In this case, Let's take Google as example: The code is JScript .NET, which is basically a .NET version of Javascript.Regardless of language, Anyone with appending type of skill can answer my ...
-1
votes
0answers
24 views

Positioned elements acting weird [on hold]

I'm looking for some tips on how to properly organize my code so I don't run into as many errors as I have been lately. One of my problems right now is that my elements are positioning weirdly. My ...
5
votes
0answers
31 views

PubSub and two-way data binding

I looked up how to use the PubSub pattern in JS and came across a few articles. I wanted to have two way data binding, so when a one of an Object's Properties value was set, it would update x number ...
4
votes
1answer
44 views

Animating a div element

I would like to see how would you write this code for best practices, it will help me to learn from you. This is my jQuery code I use on scroll event to addClass and animate div element. ...
3
votes
2answers
34 views

Null checks in user validation

I would like to know an alternative, more elegant way to write the following method. I am especially not enthusiastic of the nested if statement. ...
10
votes
2answers
794 views

Basic Terrain Generator - KhanAcademy

I'm new to JavaScript, and I've been learning off Khanacademy. I wrote the following basic terrain generator and I'm wondering if it could use any improvements. Here's the code: ...
1
vote
1answer
40 views

jQuery Widget - Progress Tracker

This is a follow up on JS Progress Bar Widget I've rewritten it as a jQuery Widget Factory widget, attempting to follow that standard as much possible and fixing the various problems pointed out in ...
2
votes
0answers
18 views

BST remove implementation

As practise, I implemented a BST and also the remove() method, but I figured I always have to check if the node being deleted is coming from the left child or the ...
4
votes
1answer
44 views

Character and word count functionality

I have this JS that has a lot of redundant functionality, and it works but looks unseemly. I would love some assistance with making this more DRY (Don't Repeat Yourself): ...
2
votes
1answer
34 views

Mapping object values from one object to another

I have an object called defaultOptions and a function that accepts as an argument an object called newValues meant to override ...
2
votes
1answer
27 views

Adding a class to an element in a plugin

I have the following code, and I just added a Class to the element that uses the plugin. I works perfectly, but I am wondering if there is a better way to do it. ...
2
votes
1answer
61 views

Separating values in string and returning them as comma separated string

I am iterating through a set of values that are in the following string format: 69;#Statements;#44;#Clarifications;#45;#Suggestions; (fields with multiple values ...
1
vote
1answer
24 views

jQuery animations with only one callback

I'm aware of doing that 'magic' inside $.when(). How should I achieve same effect writing code more readable ? I read something about a $.Defferer() that I think should help but I don't know how to ...
1
vote
1answer
24 views

JavaScript and callback: apply an action on each element of a callback input

I'm quite new to js. I even don't know how to call this problem: apply an action on each element of a callback input, but the elements are actually an output.. I crash a lot on this situation: I have ...
1
vote
1answer
31 views

JavaScript / jQuery stopwatch

Just as a learning exercise, I set out making a stopwatch without looking up how to do it etc. I know it will have been done many times before. I'm just looking for some feedback on what I should do ...
4
votes
0answers
21 views

Dragable infinite loop carousel, performance issues on dragging large number (25+) of slides

I have two instances of this carousel to test with, one with 7 slides and the other with 25. They run the exact same code. The 7 slide instance drags smoothly forever as intended, but the 25 slide ...
0
votes
0answers
15 views

NoSQL schema for weather data

I am using NodeJS and MongoDB for a weather app that takes the weather info from a logger, saves it to a database, and relays the data to the browser in real-time. It is hosted here with code here ...
5
votes
1answer
56 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 ...
3
votes
1answer
48 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 ...
5
votes
1answer
46 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 ...
1
vote
1answer
88 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
39 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
75 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
8 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
27 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
37 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
52 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
38 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 ...
2
votes
2answers
72 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
32 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 ...
6
votes
3answers
221 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 ...
15
votes
1answer
184 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 ...
13
votes
1answer
2k views

Bouncing stacking boxes

I'm not sure if it would be better to make the envelope into an extension of the Rectangle constructor. The physics seem a bit dodgy, it works well most of the time, but sometimes the boxes overlap ...
2
votes
0answers
29 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
51 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
26 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
25 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
24 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. ...
6
votes
1answer
127 views

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
33 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
277 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? ...