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

2
votes
1answer
20 views

Rotating `n` random items in an array

Honestly, it should be an incredibly simplistic function, yet it has become the following atrocity: ...
0
votes
1answer
21 views

How to achieve or ensure efficient and RAM kind Node.js code?

I'm sharing this REST API controller code in order to make it work better, also, to become a better developer. I'm having this issues with the application that API handles and I also need to improve ...
0
votes
1answer
35 views

Offline Euler problem viewer (text only)

I've created a single page web application (that should work offline, without a database, etc.) using bootstrap and JavaScript to act as an Euler question viewer (text only). It simply renders the ...
4
votes
0answers
40 views

jQuery plugin that makes a <div> slide to the side of the page on scroll

This is my very first jQuery plugin. In short: it makes, on scroll, a <div> to move from outside to any side of the page. Just follow this JSFiddle link to ...
0
votes
1answer
44 views

Formatting data for use in a controller

I am using the function inputSetup to prepare an array for a multi-select directive. I am passing in an array with the existing selections (...
1
vote
1answer
30 views

Website register functionality

I have two links in my header: Register Login I am not creating it dynamically. If the user clicks on "login," the login form will be visible, similarly for the register form. My registration: ...
0
votes
0answers
14 views

Adding methods to Date prototype in JavaScript [on hold]

I am refactoring a project into an Angular app. Before Angular I had file called functions.js that had helper functions like: ...
4
votes
1answer
50 views

Basic JavaScript quiz app

I struggled my way through the first quiz and here are the results. Since I have some experience in jQuery I really wanted to use only vanilla JavaScript. I know the code is pretty choppy and there ...
-2
votes
1answer
54 views

Best way to work with async [on hold]

I'm searching for a better way to work with async functions avoiding callback hell. Here's what I have (http://codepen.io/rochapablo/pen/xGQvWq): ...
2
votes
0answers
16 views

Modify records at one time

Do you think this works well? I.e, do I need to close the database connection at the end? The goal is to be able to upsert and delete many records in one shoot. Here is is an example HTTP POST ...
1
vote
0answers
29 views

Knockout after-school implementation

Please provide some feedback. Example Repository JavaScript ...
4
votes
1answer
37 views

Custom dynamically generated slide show container

I've created a custom slide show container to use with Jekyll. This is the platform used by Github pages. It works by converting plain text Markdown to HTML. I wanted to be able to embed the slide ...
3
votes
1answer
29 views

Desktop notifications for queue items

I wasn't satisfied with Simon's alert on the orange alert. I wanted to know if even 1 review item was available, so I made some modifications to the userscript so that it runs on the Review page, and ...
1
vote
0answers
41 views

Sending file through socket

I'm trying to get some confidence with rxjs and frp. The code below handle file sharing throw socket.io. ...
-1
votes
2answers
38 views

Toggling class on mouse hover

I am using this code to add a class on mouse hover to a link button and remove it on mouse leave. ...
0
votes
0answers
13 views

Mocking dependencies when unit testing AngularJS services with QUnit

I'm trying to unit test an AngularJS service that is dependent on another service, using QUnit as my testing framework. The first test I'm writing is one to verify that my service calls another ...
1
vote
1answer
33 views

Capture time spent viewing media

I've created some custom code that will capture how long a user spent viewing a picture. The timer will stop when the user clicks or escapes from the fancybox view. Is there an alternate way for me ...
-1
votes
0answers
10 views

Using R.wrap to wrap a function

Below are two functions, one is built with Ramda, the other is not. They do the same thing. I was wondering why someone would prefer to use version one over version two. update: The bind function is ...
0
votes
0answers
15 views

Mapping a promise to an object

Below is a demonstration of how to map over an object when you want one of the values to be a promise. ...
0
votes
1answer
27 views

Updating CSS for “active” tab

I'd like to get some feedback on this very basic JavaScript to update which tab is showing as "active" on my simple web page. This is all in a file titled adjustactive.js and included in my footer ...
2
votes
1answer
31 views

Multiple Google Maps using V3 API

I have several Google Maps on one page and each has its own set of Lat/Lng co-ordinates. As a result I have added in the JavaScript options for each one individually as follows: ...
4
votes
2answers
83 views

Free Code Camp - Pairwise

I'm working through the Free Code Camp syllabus and I'm on to Intermediate JavaScript Algorithms. This Pairwise problem was the last challenge in that section. The section came just after "Object ...
1
vote
2answers
53 views

Emptying and populating an element in jQuery

I have written the following function to empty and then populate multiple elements using jQuery: ...
1
vote
1answer
19 views

Parse.com simple query: login and display account balance

I was recently at a hackathon and saw quite a few people using Parse, so I decided to check it out and read some guides online. Can someone take a look at my code? I followed Parse documentation so it ...
-1
votes
0answers
23 views

Simple cash register function [on hold]

I finally finished this online cash register, but I feel like it's a bit messy. Is there any way to trim this down a bit? The code is complete but the if/...
2
votes
0answers
19 views

Filtered Search Plugin

I need opinions on how to improve this code example github ...
2
votes
0answers
8 views

Fire analytics tag based on message event from window

I have some code that checks to see what event data is being passed back from two different media players. The first player sends back play button clicked, but the ...
-1
votes
0answers
17 views

HTML Form data into a Object to pass a method [on hold]

So i'm trying to make this basic cash register type of app for practice, i'm just wondering how do I pass the form data from this : ...
3
votes
1answer
24 views

Adjusting Angular.js model based on browser width

I have an Array of 5 objects, some key values need to be changed based on the browser width. ie: 5 cols, 4 cols, 3 cols or 2. vs.streams is an Array which is tied to a AngularJS model. When the ...
5
votes
1answer
1k views

Don't search for minors, it isn't allowed

I have a search form that doesn't require much in terms of input parameters, but the Date Of Birth is import for this particular search. I have been working on creating a way that the form can be ...
-1
votes
0answers
13 views

need help replacing hard coded arrays with strings and integers pulled from a text file [closed]

My program needs to take information from a text file. read it and summarize the information inside. right now i have everything working except for the reading. ive tried all the methods i could find ...
6
votes
2answers
26 views

Div circular scroll

Have one div: Here's what scrolling of this div should look like: The only way I see is to duplicate ...
0
votes
1answer
33 views

Sorting object with null values underscore sortBy

I'm sorting my object by its property ActivityOrder, which will sometimes contain null values if the user has not explicitly ...
0
votes
0answers
12 views

Writing functions with ramda and lodash

I've been pointed diving more and more into two libraries, ramda and lodash, and the power that these two libraries have to create reusable functions. Code goes from a function like this: ...
0
votes
1answer
25 views

File existence promise

I hate to have to write a custom exists promise every time I need to know if a file exists, so I came up with this. Thoughts? ...
2
votes
1answer
42 views

Function to check that two objects have “equivalent” values

I have two objects, a bet and a match. A match has 2 teams and both teams get a score at the end of the match. A bet has two scores set up before the match begins. Here I need to know if the bet ...
2
votes
0answers
9 views

Ordering league table with live data

I've created a small project that contains a league table from Premier League updated constantly using local node.js server. Data is fetched from local server. I'm wondering whether my solution is ...
5
votes
1answer
148 views

Deleting a section of a website using Ajax

I am currently writing a decent amount of ajax to help me delete a section of a website. It's already becoming a pretty big piece of code, I wondered if it were possible to compact a section of my ...
0
votes
0answers
66 views

Appending JSON values to the DOM

My code below uses JSON to append images into the DOM. It works properly but I want to optimize my JavaScript to see if I can write it in fewer lines or if there are methods I can use that optimize my ...
1
vote
0answers
33 views

Making all directories to a path

Below are two promises: the first does a bit of nesting and the second is all anon then calls that return one function in them. Which do you prefer? Any improvements? Promise A: ...
1
vote
1answer
48 views

Countdown script

I made a script in JavaScript to calculate how long it takes until a certain date. Do you find it user-friendly enough? Is the code correct? ...
1
vote
2answers
21 views

Function queue for synchronous execution

This code was made just simply for fun! The idea of this code is to allow to add functions to a queue, that will execute them sequentially. With this in mind, it also allows to execute them with a ...
1
vote
3answers
75 views

Loading images according to screen width

This uses HTML5 data attributes to load the image according to the screen width. For example, for laptops. it loads only laptop-sized images. saving bandwidth and optimizing speed. Live example ...
1
vote
2answers
44 views

Listing every date between two dates in input fields

Using the following HTML: <input type="date" value="2015-07-26" name="startdate"> <input type="date" value="2015-07-29" name="enddate"> First, the JS ...
0
votes
0answers
13 views

Timer instead of delay javascript function [closed]

I'm making loading screen on my page that will cover the entire screen for about 10 seconds before it fades into the main content which should have loaded during those 10 seconds. It works but the ...
3
votes
0answers
44 views

String sequence in ES6

Given an unique string that represents a sequence of characters, the class should implement three methods (getNextChar, getNextString and the genSequence generator). How it works We give a sequence ...
0
votes
0answers
9 views

Chain-able promise file system functions

I'm trying to invent an easier way of working with the file system. Here I chain promise methods together. ...
-1
votes
0answers
15 views

Incorporating Mansory.JS in a my code [closed]

I am trying to incorporate the Mansory library in my project and I have no clue what I am doing wrong. I've tried looking at this example http://masonry.desandro.com/layout.html. And other websites ...
-1
votes
0answers
26 views

Hapi Lab e2e test workflow

This is my first attempt to set up a test suite with Hapi and Lab. What do you think of this workflow? Is there a better way (error-checking aside)? controller/user.js ...
5
votes
2answers
56 views

Optimising a user's-choice sorting algorithm

With the help of some nice folks at Stack Overflow, I wrote an algorithm that will give a user three buttons: option a neither ...