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
1answer
22 views

Changing the prototype of the String object

Are there any pitfalls in changing the prototype of the String object? I'd like to change the word substr to "left": ...
-1
votes
0answers
4 views

How to specify dimensions to image that's served through JavaScript? (EV SSL logo) [on hold]

Speed optimization tools ask that all image sizes be specified, to speed up rendering. I have an image that's called through JavaScript, it's an SSL logo that MUST be served through JS, otherwise it ...
0
votes
2answers
85 views

Increment a text field value

So let's take this code which increments a Javascript text field value: ...
6
votes
1answer
54 views

Basic particle system

After about half an hour of fooling around with Processing.js/Javascript, I got this, fairly decent particle system set up. ...
1
vote
0answers
15 views

AJAX/JSON based portfolio [on hold]

This is a design portfolio page. On load, the JSON data is retrieved via ajax, and one of the keys is used to generate a list of '.project-links', however none of the projects are loaded by default. ...
3
votes
5answers
35 views

Handing focusing and unfocusing of multiple form fields

Here is a link to my problem ...
2
votes
1answer
47 views

Building a basic framework

I am trying to build a very basic JS framework for my own uses, ultimately collating a lot of pieces of JavaScript I have created over the years. But I would not call myself a JavaScript expert. What ...
2
votes
1answer
44 views

Using array values to create variables, if statements and highchart dataset

I am trying to make my script maintenance-free by replacing some "static" variables and labels with dynamic ones. The main function of my code is to extract data from a SharePoint-list which contains ...
1
vote
1answer
21 views

Event handlers & helper methods for a Kendo Grid

Below are a few of my handlers and helper methods. This works perfectly fine, but I'm pretty sure I'm breaking about 1001 modern conventions and possibly even optimizations. Could you provide some ...
1
vote
1answer
25 views

UI-slider widget

This represents a UI-slider widget - there are a number of different widgets on the page. This function is repeated per widget - 90% of the code is the same - the only difference being that each has a ...
1
vote
1answer
46 views

Add a class to an element when it's loaded

I want to add a class to only those <p> elements that have an <img>. So far this is what I have, it works, but I ...
6
votes
2answers
138 views

Parsing integers safely

Background I'm writing user input validation for a client-side JavaScript web application. Users enter numerals representing an integer into an <input>. As ...
2
votes
2answers
23 views

A more efficient/cleaner way of scrolling a div's contents in HTML

My current code for scrolling an image contained within a div is: ...
2
votes
1answer
17 views

Row and Column input picker

I've created a simple picker which is going to be used to select the number of rows and columns when constructing a table. Here's the example: http://jsfiddle.net/tnn3qgvj/8/ HTML ...
0
votes
0answers
31 views

Sticky navigation using jQuery waypoints

I have built a one-page website with a sticky navigation using jQuery waypoints. Now I just added a highlight function for the menu buttons for when the user scrolls to that certain area. However, I ...
4
votes
1answer
67 views

Custom marquee consumes a lot of CPU power

I've a code which applies marquee to certain elements by using the requestAnimFrame method. However, when I test my application on a lower spec PC (Intel Celeron ...
4
votes
1answer
37 views

Set of handlers for commonly used functionalities

I am developing a set of simple JS functions which can be used for most commonly required JS functionalities. I want the functions to be very easy to use for new JS developers. Is the code structured ...
-3
votes
0answers
25 views

Spot the error(s) in this script [on hold]

I'm working on a little text based javascript game and I've been using chromes Javascript console for the output. The 'game' works off a series of methods written into an object called ...
-1
votes
0answers
16 views

HTML Sort function [on hold]

I created a jsfiddle to show my code that I need reviewed http://jsfiddle.net/DL7Xa/4/ I am trying to create a generic sort function that will sort html or just a simple array. The important feature ...
0
votes
0answers
7 views

Having a difficulty passing a VERY simple bit of JSON out of the d3.json function [migrated]

I'm trying to assign retrieved JSON to a global variable using d3.json as Mike Bostock suggests. The first code snippet on the page says you can "simply assign ...
4
votes
1answer
34 views

Efficiency of looping though a text map to draw objects

I am making a game that uses a text map to draw obstacles and courses for the player to navigate. However, I am concerned that my method of looping through the text map to draw objects on the screen ...
2
votes
0answers
30 views

Using a Wrapper Promise

I wrote some code for an application that uses the following pattern: ...
5
votes
1answer
57 views

Custom JavaScript validation using the factory / module patterns

I am in the process of diving a bit deeper into JavaScript development and am looking at some common language patterns (module, and factory in particular). In this code, my aim is to create a ...
5
votes
2answers
495 views

Javascript condition optimization

Can the following condition be optimized/simplified ? ...
2
votes
1answer
17 views

Making empty cells in Underscore template

From the back-end, I am receiving 8 data. The client requires showing that the row per data is 7, so I have 1 data in balance. I have created empty data and made the empty cells, which works fine. But ...
3
votes
2answers
46 views

Adding markers to a Google Maps map from a source

I decided to make a simple project to learn the Google Maps API. I'd appreciate a review of the code below. I'd like to know what I did right and wrong. The code pulls data from one source and adds ...
0
votes
0answers
18 views

JavaScript prototype inheritance [migrated]

I've been spending my past couple hours researching prototypical inheritance, but I'm left with conflicting/unclear answers on how it should be done. It seems to be working for how I'm using it right ...
4
votes
2answers
72 views

Get all the attributes of a DOM Node

I needed this small function for one of my project. Fetch Attributes ...
12
votes
1answer
112 views
+100

Mongodb making efficient and healthy db call

I'm doing a calculation for a real-time browser game, where users can invest some of their balances to the site. I need to update their invest's based on ...
-3
votes
0answers
4 views

Structure to manage a drawing/animating web application [closed]

So I am trying to build a small web application, which is supposed to emulate a small set of functionalities of photoshop. It should allow me to add layers. Every layer has a type - Image, Freehand, ...
2
votes
1answer
40 views

Node.js API route for POSTing a resource. Getting rid of callback pyramid

I'm writing an API for simple GET and POST routes. The app is a shared to-do-list. Users and lists are stored separately. A list can belong to many users, and a user can have many lists. ...
1
vote
1answer
13 views

Name to substitute setDimensionAndLocation

I'd like to have a function name that is brief but comprehensive, nothing like setDimLoc() or setDL() because they sound funny. ...
2
votes
2answers
37 views

Is my Node/Express-based authentication implementation with session properly done?

I know that Passport.js exists, however, I wanted to code my own implementation using express-session module. I'm using: Express Mongoose express-session So I basically have 2 routes for handling ...
2
votes
0answers
23 views

Architecture-dependent to DataView

I have this code here which varies depending on the system architecture (typed arrays depends on endianness). I'm trying to get a 32bit ARGB data array. I was trying to learn ...
0
votes
1answer
36 views

jQuery hide and show option value from a dropdown

I have form with an "add field" button that does an Ajax call to add a new field. Each field contains a list of options to choose from. When is public is Yes, I ...
6
votes
3answers
360 views

Bouncing ball simulation

I was fooling around with some maths and realized that I could use a parabola to represent a bouncing ball. So, naturally, I decided to make it in code. ...
6
votes
0answers
41 views

Unlock codes for a mobile app [migrated]

This is for an Android (via Cordova/Phonegap) game project. My goal is to be able to provide a "promo code" that will allow anyone to unlock the game for free, but I want to limit each code to only ...
2
votes
1answer
29 views

Simple for loop to calculate headers size based on a specific ratio

How can I improve the following for loop (wannabe function) to create harmonic sizes for headers based on a specific ratio? ...
6
votes
2answers
59 views

Count bits that differ between integers X and Y

I'm trying to solve the following problem : You are given two integers, X and Y. Calculate the number of bits that will be changed in order to convert integer X to integer Y. Here is my ...
10
votes
4answers
2k views

Possible antipattern: looping until a search condition is met

Whenever I write a loop, I always use closure if it's appropriate by way of a self-executing anonymous function. I will typically write my searching loops as follows: ...
3
votes
1answer
37 views

Count Point in an area

I created this to count points in an area. This is my JavaScript code: ...
0
votes
0answers
13 views

Compare Objects and show divergent keys [closed]

I want to deep compare N objects and show all keys that are not present in all objects. The value doesn't matter: ...
0
votes
0answers
15 views

App using JQueryMobile and Cordova

I have received a project that is built on Cordova with JQueryMobile. The app is already published on three platforms and is being used by 100K+ users. Now I have to add new functionality in it. But ...
2
votes
1answer
35 views

ExpressJS easily serve static files

I have a NodeJS package, staticize, which takes an object of HTTP routes -> file locations, then serves them dynamically on each request. Could I get some feedback on the latest rewrite of the main ...
0
votes
0answers
29 views

Multithreaded queue manager

I've written a simple multithreaded queue manager in JavaScript which will be seeing some pretty heavy usage at a later point in the project I'm working on. I think it's pretty solid, but I wouldn't ...
1
vote
1answer
38 views

Lazy singleton with BackboneJS

I am trying to have a Backbone.Model which is a singleton and I wish to instantiate it lazily. I only need to support modern browsers so please do not worry about the use of ES5 getter. Is this the ...
5
votes
2answers
82 views

Reducing code for animation of expanding menus

I wonder if I can reduce the code to optimize it better? ...
1
vote
1answer
28 views

groupBy implementation in NodeJS

I came across a problem in my NodeJS app, which I solved by creating a method called groupBy. The purpose of this method is simple: take an array, and a function ...
4
votes
2answers
80 views

Structuring a HTML5 game without a framework

After trying a couple different HTML5 frameworks, I've always found pure JS the most appealing. However, I am uncertain about the way I'm structuring it. ...
2
votes
0answers
6 views

Compressing a blog into a preview using tumblr_api_read

Here is what I have currently working. I would like to make it look more aesthetically pleasing, so not finish words in mid word. Also not have the two previews be so much larger than the other. ...