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
0answers
10 views

Slow Javascript code to get Taxonomy terms from Sharepoint

We have the following code which takes about 5 seconds in a modern computer, however the application is also executed on old PCs with Windows XP, and in there it takes 5 minutes to load. I know the ...
0
votes
0answers
20 views

Set Resource String in javascript [on hold]

To get Resource strings in javascript, e.g. for localized messages, I often implement IScriptControl and pass the values to JS in method GetScriptDescriptors(). In cases where I don't really need a ...
3
votes
2answers
43 views

Making at least one checkbox required

I have written a piece of code, the purpose of which is to control whether the user has checked at least one checkbox field before saving the record. If the user has failed to do so the code throws an ...
4
votes
0answers
28 views

Basic Block Building Game Part 2

I've taken my previous block building game and added some performance improvements, and commented out some things that needed to be commented. ...
6
votes
0answers
14 views

Tag Fit: Team based mapping of wearable data

Our company is planning on doing a fitness competition. So as the hackathon project I threw together this team based tracking service. It measure a walk from Seattle to New York Player can log in via ...
5
votes
2answers
70 views

My Google Maps Script

I've written a script with the Google Maps JavaScript API v3. I've ran it through JSHint and everything seems to be valid. I'm wondering if my script has room for improvement. Any suggestions are ...
-12
votes
0answers
32 views

Javascript Prototype [on hold]

I have a class called "Ball", to which I have created a "prototype"(to specify properties and methods to particular objects). I am wondering if there is a way to specify a further either property or ...
2
votes
0answers
22 views

Pluggin' in a Plugin [on hold]

Can anyone tell me if I'm correctly binding an event inside my jQuery plugin? If not, what's the best way to achieve that? Here is my plugin code: ...
1
vote
2answers
50 views

Find a nested property in an object

This works fine and returns an object from a nested "structure" by Id. I would like to know if you could suggest a better approach, possible a faster one. ...
2
votes
0answers
32 views

Binding model to view

What I need - if there are some changes to model in must be rendered in view (HTML). The main problem here is to catch changes in model. Firstly I tried to use watch. However it can't work with IE8 ...
5
votes
1answer
49 views

Multi-level image slider

Here is my code I'm working with: ...
2
votes
1answer
36 views

Sane ranges for DB queries

I have a function that has, as input, a ranges object which may define from, to and ...
0
votes
0answers
36 views

Web socket server which needs to query some API and to pass chunk per chunk of data to its socket clients every M seconds

Let's say that I want to query some API which will respond with array of random numbers: [4, ..., 17, ..., 25] To keep things simple enough, let's say that array has always 10 elements. For ...
1
vote
0answers
20 views

CPU friendly infinite text scroller - velocity

I've done some research today and read a lot about JavaScript performance. I learned that animating using the transform: translate makes a use of the GPU, hence ...
2
votes
1answer
27 views

Outputting a user's name, day of birth, and test scores in a bar chart

I've been asked to output the users name, what day of the week they were born on, output a line from a poem corresponding with the day they were born on, and their scores for a vark test. We were told ...
6
votes
1answer
46 views

Stack Overflow tab notifier user-script

I searched for a notification script that shows inbox and rep change items on the browser tab in stackapps.com but either they didn't work or were outdated. So, I've done this raw script myself and ...
0
votes
0answers
10 views

hapi.js + node.js route reply with external data

My code responds to a request with data from an external site – it retrieves data from the internet that gets packaged with any response. I am a javascript beginner and am not used to asynchronous ...
1
vote
0answers
17 views

Backbone/Marionette form with list of inputs

Using Backbone/Marionette, I'm building a simple widget that looks like: I'm hoping to get some feedback on my approach because I think I may be doing it wrong. jsfiddle ...
1
vote
1answer
38 views

Simple use of mouse clicks to position a ball

Here's a simple program I wrote to teach myself the basics of using a mouse for a potential HTML5/JavaScript game. The thing that tripped me up was event.clientX ...
3
votes
2answers
61 views

Speed up loop through JSON

I have the following function that takes JSON and turns it into table rows: ...
4
votes
1answer
60 views
+50

jQuery scroll-prevention plugin

This plugin is for article pages that has a very long main content (left side) and a shorter sidebar. When the user scrolls down mostly the right part will be white space. What this plugin does is ...
1
vote
1answer
44 views

Replacing if validations with a better error handling

I have this little piece of front-end code, and I had a little code smell about the handling of errors. ...
6
votes
1answer
45 views

Simple example to get started with a browser based game

Here is a "hello world" simple skeleton I wrote to get started on an HTML5/javascript game. I converted it from a python example provided in Coursera's "An Introduction to Interactive Programming in ...
2
votes
1answer
14 views

Custom moment formats based on string length

Just wanted to gage how solid this code is. With moment cracking down on lazy formatting I thought this was a good way to parse the string for what format to use. ...
7
votes
3answers
87 views

Better card validity check in JS card game

I am writing a card game in Javascript. The game is played with a 32 card deck. When a card is selected to be played by a user, i do a validity check on the server to check whether it matches the ...
1
vote
0answers
16 views

Bitcoin, detecting deposits to the node.js server

I'm trying to detect deposits that user will made. I explained it with comment lines in below. Can you say are there any flaw in it? ...
0
votes
1answer
57 views

Recursive functions

I am using the following code which recursively executes function findWpisInZone(), code works fine, I just wondering if there is any better way to do it in JS, ...
4
votes
2answers
61 views

Safe navigating function for nested object properties

I've made a function to safely traverse deep objects. ...
1
vote
0answers
29 views

Injecting a variable into a required function

I have a sort of plugin loader in a node-webkit app, but when a file is required using it, it doesn't inherit the window variable. Meaning I'd have to use ...
0
votes
2answers
43 views

Optimizing regex alternation, ability to view which choice matched?

So I've got a regular expression parsing tcp responses from a music daemon. In case responses pile up I've come up with an expression to separate full responses from the data, however I'd like to also ...
1
vote
1answer
81 views

Excel-like column numbering

I have a working code (below) to convert a number to Excel-like (A...Z AA...AZ BA...BZ ...ZA-ZZ) column codes (headers). For ...
3
votes
1answer
48 views

Functional organisation of JavaScript functions

In one of the web apps I contribute to, the main.js file has multiple interacting "objects". Unfortunately, I'm so bad at OOP in JavaScript, despite studying other ...
2
votes
1answer
22 views

Checking for JSON or YAML file with promises

I'm using bluebird promises. I'm converting fs.exists to existsAsync (here's how) and ...
1
vote
1answer
46 views

Visual increment and decrement button controls in jQuery

I currently have a working implementation of a + and - tank level thingy (I don't really know what to call it). In which will be able to 'add' or 'remove' so-called 'liquid' from the container. ...
4
votes
3answers
213 views

Initializing a multidimensional with many default values

I need to create a \${n} \times {n}\$ multidimensional array filled with default values. Right now, I'm using this code: ...
3
votes
0answers
13 views

Require.js - the best way to define classes and packages [closed]

I've optimized everything I could and got the following result: require.config({ paths: { 'com.company.MyClass': '....../MyClass' } }); ...
3
votes
1answer
70 views

Cleaning up website code

I am a bit of noob to jQuery so I got this jQuery code what I think can be way faster. Does someone want to help me clean it up? Explaining why you did what would be real nice but not needed. The ...
1
vote
2answers
44 views

Angular Todo Lists - Factories? Controllers?

I have an angular app using a restful API which works, but I know is structured poorly. I'm using a projectService (factory) to do all interfacing with the REST ...
7
votes
2answers
247 views

Set theory clock code

I wrote some JS to power an HTML/CSS "set theory" clock, and I'd like to share what I have so far and ask if anyone can suggest improvements. Specifically, I'm wondering: Should I bother checking ...
6
votes
7answers
331 views

Changing element visibility based on multiple checkbox states

I am writing a script in JavaScript & HTML and have some optimization problems. In the for, loop I check a variable named ...
4
votes
1answer
25 views

Google Maps Api Lat/Lng pair to Fusion Tables Query

I'm trying to learn Javascript, and as a practice tool I recently wrote a simple web app that uses the Google Maps API Geocoder to get the latitude and longitude of a location (user input), manipulate ...
0
votes
1answer
22 views

JavaScript Tic Tac Toe - functional but could be DRYer

I've been working on a simple Tic Tac Toe game in JavaScript. It runs the way it should, but the Board.checkWin function (check every possible winning combo) could ...
2
votes
3answers
110 views

Hiding element based on content

I have a page that is part of a CMS and I cannot alter any existing HTML or CSS, but I can add additional custom JavaScript and CSS. There is some text on this page I want to hide and I found a ...
0
votes
1answer
19 views

Performing an auto complete look-up and building a form

I have written a jQuery function that is doing an auto complete look-up and then building the form for me. This is working fine but I want to reuse the code so I can have the form rebuild after ...
1
vote
1answer
32 views

jQuery slideshow code - adding previous and next classes a better way

I have a slideshow in jQuery slideshow switching picture automatically every 5 seconds with CSS3 transitions. The current picture has the current class, the ...
10
votes
1answer
88 views

Simon says HTML5

Here's a little game written in HTML5 using bleeding edge audio. Since I don't do much HTML5 or Javascript, I'm particularly interested in: Structure Is this a reasonable way to structure the ...
12
votes
1answer
235 views

Simon Says in Javascript (with Knockout) - Playable Code Snippet

I resolved to do the whole thing with just vanilla Javascript as a challenge, but man, Knockout's binding and state management is just too easy. A tiny bit of callback hell to get all the flashing / ...
1
vote
1answer
21 views

Vimeo API - Loading videos

I know my way around jQuery and JavaScript a little bit but as for optimising, I'm a bit weak but willing to learn new stuff. I'm currently loading videos onto our site from Vimeo when a user clicks ...
4
votes
2answers
135 views

Removing numbers from the middle of an array

I have an array like this (make sure you scroll to the right): ...
11
votes
1answer
78 views
+300

Alea implementation

The following is an implementation of the Alea random number generation approach by Johannes Baagøe, reworked from the rot.js implementation by dropping all the pesky underscore prefixes in the ...