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
15 views

Client-side API design

I'm working on a client-side API for my Asp.net MVC application and I'm not quite sure I've got the code right. This API allows me to call server-side action methods via Ajax and I've designed it to ...
0
votes
0answers
6 views

jQuery Dialog Settings

The goal of the code is to initialize a Dialog with settings make sure the object is reusable Setup the options to reuse the code I'm not quite sure if this is overkill, or I am going about ...
2
votes
1answer
19 views

“Function Buffer” to avoid triggering an event handler too frequently

If some big event handler is triggered too frequently, it will cause computer lagging. In my example $(window).resize(), I want the function to be called after the ...
2
votes
0answers
39 views

Web page based on a sample from a book

I've created a web page based on a sample from a book. It works fine, but seems to have become too complicated. ...
1
vote
0answers
26 views

Im trying to convert this into a else if else statement [on hold]

Hello I have this line right now with an if else statement and Im trying to convert it to if else if else statement. This is coffescript ...
7
votes
2answers
49 views

Increase the performance of a random weighted 'tick' function

This is a very simple function, but it gets run on a roughly 10ms interval, so I'm looking for ways to improve it. The first obvious thing is that it has to run the comparisons nearly every time as it ...
3
votes
0answers
28 views

Getting all likes from a specific user on a news wall with fewer graph API calls

Right now, my solution counting likes of a specific user is Starting a recursive call on the "/{user-id}/posts" edge Iterate through all posts On each post iterate through each like on the likes ...
1
vote
0answers
20 views

Is this approach correct when testing an Angular controller?

I'd like someone to review these tests to make sure I'm along the right lines in Angular testing. Note - They do all pass (great) but I feel like I'm struggling to understand the finer points of ...
1
vote
0answers
25 views

Which method is better for checking if jQuery has been loaded in bookmarklet? [on hold]

I am creating a bookmarklet which requires jQuery. So before I execute the main JavaScript code of the bookmarklet, I have to make sure jQuery has been loaded in the page. So far I have come up with ...
4
votes
1answer
70 views

Bank account number validation in IBAN format

I wrote a JavaScript function for validation bank account numbers in IBAN format. Please tell me how can I make this better. ...
4
votes
2answers
48 views

Photoshop Color Picker Gradient

I'm trying to improve my Color Picker code. It works like Photoshop and I don't want to use a library. ...
2
votes
1answer
25 views

Comparing numbers and making a calculation

I have a piece of javascript I wrote for a recent work project that is essentially taking a deviceorientation event object, taking either the ...
7
votes
0answers
43 views

Brainfuck interpreter in JavaScript, take 2

The previous version is here. This version takes suggestions from that review into account: brainfuck is now an object instead of a function, and ...
12
votes
1answer
191 views

Brainfuck interpreter in JavaScript

Just what it says on the tin: a brainfuck interpreter in JavaScript. ...
0
votes
0answers
19 views

Variable assignment inside condition [on hold]

Given this function: function myFunc(arg) { var result = []; if(arg === 0){ result = false; } return result; } I'd like to perform some ...
0
votes
0answers
8 views

Query for multiple timeframe in Mongoose

Here is the code I use to query the number of view (separated by new users and non-new users) with Mongoose: ...
2
votes
2answers
61 views

Creating an interactive tour for a website [on hold]

I'm using grumble to create an interactive tour for a website I'm working on (I'm aware there is a plugin called crumble that does this but I want to have full control of the functionality). ...
1
vote
1answer
34 views

Module pattern callback implementation

I'm rewriting a simple app using HTML/CSS/JavaScript that creates animations with images using intervals, and there's a bunch of buttons that controls these animations. It's scaling and becoming ...
4
votes
2answers
50 views

Deep pick using lodash/underscore

Use Case _.pick creates a shallow clone of an object given a predicate that identifies which keys to keep. pickDeep would ...
-1
votes
1answer
31 views

Dropdown Form to Link to Another Page [closed]

I'm trying to create a dropdown form that will allow me to link to another page after the user clicks on one of the dropdown items. I've tried searching forums and lynda.com (this code is based off ...
1
vote
0answers
13 views

Filter by a distinguishing field when making publications using meteor

In my publications with meteor.js, I find myself repeating the same style of code and would like a cleaner approach. For example: I have a users collection that ...
2
votes
1answer
63 views

Checking if switch is checked and doing something with the data

How can I optimize this code? ...
2
votes
1answer
35 views

Recognizing elements and doing event handling for repeating templates

This fiddle has an ADD button when you click it a Chat window is added. When there are more than 1 windows the message from one window is reflected across all the windows. Say you have templates (in ...
4
votes
3answers
120 views

Tic-Tac-Toe Game

I want recommendations on how to improve this code. JSFiddle for you to play in (It's laggy, so it would be better if you download the images and try it in your own PC). ...
2
votes
2answers
66 views

Validate multiple regexes without a for loop in JavaScript

For a project, I need to validate a VAT number against the correct algorithm. I found a library for this here (freeware, so I should be able to reuse it) that I'm grateful exists. However, I feel like ...
4
votes
4answers
110 views

Advice needed in refactoring/cleaning up my javascript code

I am fairly new to Javascript. I have written a website that works as designed. However, I have a strong feeling that my code could be heavily refactored. Can anyone see anything, besides line ...
11
votes
2answers
487 views

Checking conditions before allowing a play button to become visible

I have this code to check a couple conditions before allowing a play button to become visible. Is there anything to do to consolidate this code, possibly shrink it down some? ...
2
votes
2answers
142 views

Efficient way to iterate over elements of array for matching contents of another array

Using jQuery I'm trying to find an efficient way to iterate through an array excludeMe and check if elements from another array ...
11
votes
5answers
537 views

Categorising a number in JavaScript

I've written a function that takes a number and returns a value depending on where that number lies on a pre-defined scale. That's probably a little confusing so I've put the code below and added a ...
7
votes
2answers
262 views

Improving nested for loops for sub menu creation

I have a nested loop which creates a drop down with 3 levels. Works fine on modern browsers but on IE8 it hangs and takes several seconds when there's even a moderate volume of data. It creates a ...
3
votes
1answer
41 views

Angular directive for unique username

I looked at a bunch of AngularJS directives checking for uniqueness of a username and decided to try for the simplest implementation. It does what I want but may not really be 'idiomatic' Angular. ...
0
votes
1answer
32 views

Convert object array to hash map using lodash

Use Case Fairly new to Lodash/Underscore. The use case is to convert an array of objects into a hash map where one property is the key and the other property is the value. Common case of using this ...
2
votes
2answers
48 views

Date Comparison Script

The University Library where I work is in the process of redesigned our home page. One of the features we wish to include is a widget to display the current hours. Unfortunately for a variety of ...
0
votes
0answers
13 views

Reading values from JSON

I would like to improve my code performance. Can you review my code? I am using Backbone Marionette plugin and it's reading the values from JSON. ...
6
votes
2answers
147 views

How can I quickly find unique list items?

I use the loop-every-single-list-item approach to filter out unique elements in a given list, which tends to be very inefficient way as a list grow in size, or as function call frequency increases. ...
2
votes
2answers
171 views

Acquiring and formatting data from a JSON file

I have a JavaScript function that is getting data out of a JSON file and then doing some formatting to it. The code works but I feel like it just an awful way of doing it. All criticism and help ...
7
votes
1answer
90 views
+50

Simple AngularJS controller for REST API

We record software builds from our build machine into a database and for practice purposes I'm building a little web dashboard for it. The API is REST (WebApi) and provides access to query for ...
1
vote
0answers
51 views

I just released a TypeScript library to help write better conditional statements

http://jumpkick-studios.github.io/Is/ I was attempting to understand the "Maybe Monad" concept, and I found it really fascinating. However all of the implementations ended up looking just as weird ...
3
votes
1answer
40 views

Ajax for RESTful web service

I wrote an Ajax function, which should be used in a framework to interact with a webserver. The (self-written) Java-Webserver can be used to fetch files and folder-contents, create files and folders, ...
10
votes
1answer
69 views

A directive allowing to make a whole DOM subtree readonly

What do you think about this directive? For each input, it traverses the DOM towards the root and if it finds an element with the class ...
1
vote
1answer
19 views

ChunkerTransformStream, a transform stream to take arbitrary chunk sizes and make them consistent

I have some code to interface with a wire protocol that requires data to be inserted into a stream at regular byte intervals. Every 8KB (or at some other definable interval), a small chunk will be ...
4
votes
1answer
69 views

Optimizing display of various famous quotes

If it is possible, I'd like to be able to mash all of my arrays into one array, but still have the same functionality within my function (pick quote, pick creator, set padding). Pastebin ...
5
votes
1answer
59 views

Cover letter generator: guides writing a template and autofills information

This is my first public web-application. I'm a beginner to JavaScript and this is my first time using jQuery. It's not complete, but I'd love some feedback on the programming and the functionality. As ...
6
votes
1answer
88 views

Is this a good approach to loading JavaScript files asynchronously?

I want to load JS files asynchronously to speed up page loading, but also need to execute JS code only once the scripts finish loading (so I need a way to implement callbacks). I based this off of ...
8
votes
1answer
112 views

Proper prototypal programming with Node.JS

Practicing Prototypal Code I'm focusing on practicing a very prototypal structure with my code (non library oriented) to begin learning to reuse large portions of my application infrastructures where ...
1
vote
0answers
40 views

Moving shapes to random locations on hover [closed]

What I'm trying to achieve: So this JavaScript code create circles and rectangles on the html canvas at random positions (x, y). What I want to do is whenever the user hovers over a shape, I want the ...
5
votes
2answers
63 views

Possible combinations following a rule

The problem is the following: We have a number of months to buy a number of supplies. The sooner we finish buying them, the better, but we don't know how much we can buy per month and would like to ...
1
vote
1answer
94 views

Simple JavaScript inheritance

I'd like to know what you think about my implementation of inheritance. It's pretty small and intuitive I think, but I don't know if there are any drawbacks. I really want to keep it as simple as ...
1
vote
2answers
78 views

How can I simplify similar functions using a hover state with different div content?

Updated: I need some help simplifying the code below. It works just fine, but maybe there is an easier way. What I'm trying to achieve: Hover over the img then use Greensock Tweenmax on hover to ...
7
votes
1answer
90 views

Is there a better way to design this quiz?

I just programmed a quiz and the code is given below. Is there a better way to program to do what I have done? Also I tried to do transition effect while the question is changing, but it isn't ...