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

5
votes
0answers
22 views

2048 (game) solver

The code contains an AI function, that searches breadth-first all possible moves and get the score of their grids, a depth of 6 is used which makes at most \$4+4^2+...+4^6\$ computed grids. The ...
0
votes
0answers
15 views

Javascript Object Oriented Programming with virtual, private, protected and public members [on hold]

Everything you need to do OOP in one neat little package without having to do all the work by hand. Almost like C++. MyJOOP.js ...
2
votes
0answers
24 views

Efficient JavaScript/jQuery typewriter effect that handles HTML5, entities, and text

How should this code be improved? For instance: How could it be shorter, clearer, deal with memory better, use a plugin/library, better prepared for web input? I can break up and clarify the regex ...
4
votes
2answers
17 views

Using prototype to simulate extending a 'base class' object in JavaScript

I'm investigating using prototypes in JavaScript to simulate using 'base classes' which can be 'extended'. I've created an example where dialogBox is my 'base' and ...
2
votes
0answers
17 views

Search box with multiple terms

I'm implementing a live search in a Chrome app (no cross-browser magic required), and have separated the search functionality out into its own module. I want the user to be able to enter multiple ...
3
votes
1answer
22 views

Toolbar using jQuery

I am a beginner in JavaScript and starting to understand jQuery. I've written a toolbar that uses jQuery. I've also put comments based on what I understand of how the code works, though through the ...
1
vote
3answers
54 views

Checking and displaying JSON data

I mainly develop in PHP and every now and again I have to do stuff in JavaScript which I'm not really comfortable, so I would like a review of how I can improve my code and knowledge. This script ...
3
votes
2answers
24 views

Changing the background color when a link is clicked

What I'm trying to do is to change the background color when a link is clicked (in this case a list item). When it is no longer clicked, it should revert back to its normal color. I was able to get ...
0
votes
0answers
22 views

Simple alternative to `replace()` for JavaScript tabs

The Set-Up: I am working on an HTML / JavaScript listing template for on-line auctions. There are two sets of tabbed navigation features in the listing that are driven by javascript as well as a ...
3
votes
0answers
25 views

JavaScript Doubly Linked List

I coded up a basic DLL for use in a Stack or a Queue in JAvaScript for practice. Coming from a C++/Java background so I basically just converted how I would code it up in one of those, not sure if ...
3
votes
0answers
32 views

Asynchronous Conditional in Javascript

I'm trying to figure out the most elegant solution to do the following asynchronously using JavaScript (specifically node): Given a destination file name, check if it is a directory If it is a ...
1
vote
2answers
29 views

Angular Models as Property or Injectable?

I have an application that looks like such: ...
3
votes
1answer
37 views

correctGuess() and incorrectGuess() functions for a quiz

In my JavaScript quiz, I have two functions below which are not DRY. What i want to do is to cut it, so everything below var = text would be used only once not ...
2
votes
2answers
50 views

Sieve of Eratosthenes JavaScript implementation - performance very slow over a certain number

I've been playing around with the code challenges on projecteuler.net. A few of them involve prime numbers, so I've created a function to find them based on the sieve of Eratosthenes. It works fine, ...
0
votes
0answers
8 views

I am having trouble styling my map [on hold]

I have 2 google maps that I want to add to my page, they show up fine but I can't style them, what am I doing wrong? here is the code: ...
2
votes
1answer
21 views

Summing 3 jQuery modal dialog functions

I am getting better with jquery day by day, but there are still things I don't know how to sum up several functions to reduce some code. So I am using three jquery modal dialog popups and I have ...
1
vote
0answers
10 views

Pagination handlebars helper

I've build a handlebars helper that takes n total pages and currentPage and returns the HTML for the page number links, skipping ...
1
vote
1answer
18 views

Removing duplication in AngularJS Factory

I have multiple API calls so I created a service however I would like to find a way to remove the duplication ...
0
votes
0answers
11 views

Organization options email to send email with sendgrid

I am working in this controller: ...
4
votes
0answers
39 views

Xonix game in JavaScript

This is my very first program in JavaScript. I am trying to teach myself from JavaScript: The Definitive Guide, 6th Edition. The code is also available on my bitbucket. I decided to remake the ...
7
votes
3answers
66 views

Project Euler #8 - Largest product in a sequence

I've just finished Project Euler Problem 8, which ask for the greatest product of any sequence of 13 consecutive digits in a given string. I wonder if there's something that could be improved. ...
0
votes
1answer
28 views

Testing a UI related revealing module [on hold]

When I write my JavaScript modules I tend to keep a lot of methods private in an IIFE. A simplified example below: ...
1
vote
1answer
91 views

Checking that a filename does not end with “Com.js”

I'm fairly new to JavaScript and I wonder if there is a way to write this function shorter and better? ...
2
votes
0answers
11 views

Using one service ($http) on all the controllers angularjs

I have recently started working on angular.js and I like it. I have decided to use a single controller per view. I use the json data from the backend. As my work is ...
-2
votes
0answers
11 views

Implementing Scanline Algorithm [on hold]

I'm trying to implement a scan line filling algorithm for random triangles given 3 points as arrays and a color. I'm getting some weird results. Please ignore the optimization of the code, I'm just ...
3
votes
0answers
16 views

Optimization for better response time to use in analytics application

We are trying to use NodeJS for analytics. The following code gets the parameter from a URL and dumps it into a flat file. Is there any way to optimize it to get better response time? ...
1
vote
0answers
18 views
2
votes
0answers
27 views

Create one function instead of two bootstrap modal

I have a form that reads a JSON file for default wrong answers to be applied to a 'summary div' at the end of the form. I wondered if I could make these two functions one somehow? It is a bootstrap ...
3
votes
0answers
11 views

Salsa20 stream cipher

I have been implementing Salsa20 by studying the design and specification. I have made sure to unit test every function along the way and match the outputs against the test vectors in the spec. I am ...
-1
votes
0answers
32 views

Radial Tree d3 wrapping text [on hold]

The below is a modified code taken from the link http://bl.ocks.org/mbostock/7555321 which I am using in my project. In the input json file which looks like the below ...
4
votes
1answer
42 views

Full web app utilizing HTML, CSS, and JavaScript

Having started a new software dev role recently I'm in the process of developing my first full web app project using the following stack HTML + CSS + JavaScript + PHP. I'm new in terms of applying ...
1
vote
0answers
21 views

Python DefaultDict implementation in JavaScript

I found Python's default dict and ordered dict incredibly useful, hence I attempted an implementation in JS. As JavaScript objects only supports string as key, it is not as powerful as the Python ...
0
votes
0answers
34 views

Change color of link if radio button is not checked

I have created an online exam system in PHP and JavaScript. In the HTML page, my questions are fetched from the database. If any question is unanswered or the radio button is unchecked, then the ...
0
votes
0answers
23 views

Module based todo list [closed]

This is my todo list based on the Module Pattern. This is working fine and just want to know two things. Can my code be simplified? Once I've added a list, if I refresh the page, then these lists are ...
1
vote
2answers
48 views

Alternate for nested Ajax requests

I have one button on clicking I need multiple things need to be done, so I went for AJAX and PHP: ...
3
votes
2answers
57 views

Removing duplicates from an array

I recently wrote this JavaScript algorithm for removing duplicates from an array as part of a job interview process, but was turned down for the position after submitting the code. I didn't receive ...
0
votes
1answer
14 views

Creating object Nodes an easier way

I am required to create a bunch of object nodes to an object: ...
3
votes
0answers
37 views

How can I speed up the reading and writing of pixels of BufferedImages?

I'm working on a project that takes in a video file and does some image processing on each individual frame. The first step in that processing is to take each source frame and generate three ...
1
vote
2answers
22 views

Handling with the 'error' parameter inside a callback function in node.js

I have multiple controllers and every controller has this error handler: if (error) { res.render('error', { error: error }); } Sometimes I have more ...
4
votes
1answer
296 views

Polyglot array_extend() function for Javascript and PHP

This is a polyglot function I've made out of fun. The goal is to grab n arrays (or Javascript Objects) and 'extend' them in ...
2
votes
1answer
57 views

Changing background colour

I am currently changing the background colour of a sidebar each time a menu item is clicked using the following code: ...
0
votes
0answers
31 views

My first Quine - javascript [closed]

My first Quine: ...
2
votes
1answer
42 views

Method for parsing floats and adding totals

My intention is to create a nice DRY method (add) which will take care of parsing floats and adding totals internally and will be called by other methods. I feel ...
-1
votes
0answers
26 views

JavaScript ForEach function [closed]

Is this a good forEach-function? Is there something important I missed or is there a smarter/shorter way to do it? ...
0
votes
1answer
37 views

Implementing Command Pattern - How to make more readable if else statements for commands? [closed]

I have a method, that execute some operations on a passed object. Accordingly to the object type (cmd.declaredClass) I need to run some specif logic. The execute ...
2
votes
1answer
33 views

Assembling a json object from an array

Is there a way to make this code shorter and more succinct? Thanks My objective is to: Take an array of objects (someArray) Use get() to get one specific ...
3
votes
1answer
76 views

Notepad5, a simple HTML5, JavaScript notepad webapp

I made a simple notepad webapp, called Notepad5. You can use it to make notes while browsing the web and don't want to open up a separate application or extension to put the notes down and don't want ...
0
votes
1answer
24 views

Natural sorting/comparing algorithm in TypeScript

This code sorts string that may contain numbers in natural order, that's it, "item 2" comes before than "item 10". It currently ignores case. I plan to implement options to handle case sensitivity and ...
3
votes
1answer
29 views

JavaScript/jQuery DatePicker

I created some functionality for JavaScript datepicker. I'm trying to store a value in the datepicker with the selected month along with which half it is. To do ...
3
votes
0answers
25 views

Custom dropdown selector

I'm working on improving my knowledge of OOP in JS. I just created this custom dropdown selector. It's working nicely, but I'm not super happy about the Filter ...