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

0
votes
0answers
2 views

Creating chat box with comet

I'm writing chat application.I would like to know if there are some problem in this codes that I fix poblem. This function sends message: ...
0
votes
0answers
12 views

JavaScript String.split on a string literal to produce an array [on hold]

I've seen a few javascript programmers use this pattern to produce an array: "test,one,two,three".split(); // => ["test", "one", "two", "three"] They're not ...
13
votes
2answers
243 views

Code-Q2A - Copy code blocks from Questions to Answers

I came up with an idea for a userscript to simplify writing answers on Stack Exchange while writing a previous answer This userscript adds "Review"-links on the top of each code segment. When ...
1
vote
0answers
17 views

MVC + Events in JavaScript

I'm a bit lost with implementing MCV pattern on javascript. Where should events (such as 'click','change') come in on MVC in javascript? I have this event function, ...
1
vote
1answer
22 views

Storing Data In a Image pixels

I wrote a tool to store text as colors in a image around the border. I then saved the resulting image to file. To use the resulting file I set it's path to a the src attribute of a tag and call ...
6
votes
2answers
64 views

Saving preferences in localStorage

I am working on a small app to help my kids study their multiplication and addition. And I have various preferences I want to be persisted between visits. What do you think of the below to get the ...
1
vote
1answer
24 views

Direction array to support multiple keydowns in 4-directional movement

To get a simple, responsive, 4-directional movement in a 2D game, I've implemented the following. When a key is pressed, the add method adds the direction to the ...
5
votes
1answer
72 views

Creating chat commands properly with Socket.IO

I am developing a chat program (mountreus-chat and GitHub) in Node.js using Socket.io however my code looks awful. I'm starting to use commands and now it's even worse. Here's a code snippet (you can ...
2
votes
1answer
23 views

geoInput jQuery Plugin

I made my first jQuery plugin, and was hoping to get a review. I'm especially interested in comments on whether I went about building up my html and applying the css in a reasonable manner (I chose to ...
-1
votes
0answers
21 views

How to simplify my conditional statement

I am trying to see if I can simplified some of my codes. It looks messy now. I have something like ...
4
votes
0answers
42 views
+200

Unit testing a click event with asynchronous content

I'm writing unit tests for a web application that has quite a lot of UI interactions. I would like some feedback regarding on how to handle click events with asynchronous code. My goal here is to ...
2
votes
0answers
46 views

Clearing the text when `text select` release

I required a trigger, whenever the window text selection cleared. Finally I found this approach. Using the same id, I have ...
0
votes
0answers
19 views

Matching characters in different languages [migrated]

Is this a right way to check for characters (both English and non English characters like umlauts in German and others)? ...
5
votes
1answer
60 views

App for painting images

I am a newcomer to jQuery and am working on an app that allows the user to paint images. To do that, I've created a color palette, and if a user clicks on a color, the paint brush successfully changes ...
3
votes
1answer
52 views

Simplistic flash card web-app

Feedback I would love to hear: Since this is really my first real JavaScript app, being that I can never find a project I want to actually work on, I want to know how I can improve my JS techniques. ...
-1
votes
2answers
50 views

Documenting an intToRuleset function line by line

I'm currently working on an enormous, enterprise level project. There are about 130 other devs on said project, and I aim to document my code in the clearest way, so others may easily see what I'm ...
-1
votes
0answers
12 views

Fixing CSS Drop-Down Menus [closed]

I have a CSS based drop-down menu in your navigation and a flash element near it the menus may get “hidden” behind the flash object. http://zrealizujkupon.pl/
-1
votes
0answers
24 views

About my DB queries (Mongo) [closed]

When a user first visit the site, I'm making a few DB calls and emitting them with socket.io: ...
0
votes
0answers
35 views

Error handling in directory iterator using promises

I wrote this example of IS.File.directoryIterator for Firefox. Can you please help me to review it so if an error occurs it is caught? I'm not so great with ...
0
votes
0answers
21 views

Cursor index on textbox onClick event without highlighte/selected content [closed]

Scenario : User makes just onClick on a textbox/textarea with some content(somewhere between the content). The code snippet used : ...
1
vote
1answer
31 views

Efficient Traversal and Manipulation of the DOM with Native JavaScript Using For/In Loop

With native JavaScript, I intend to traverse a collection of elements in the DOM that contain a link and an image (and possibly other elements). The image may or may not be inside the link—in ...
2
votes
0answers
23 views

Bootstrap Tabs With SammyJs

Is there a better way to implement bootstrap tabs routing with SammyJS besides this? ...
1
vote
1answer
46 views

DRY code for sending email with SendGrid

I have this code inside a post route: The first one is to alert me when a user registers on my site: ...
1
vote
0answers
27 views

Mocha + should.js, testing for node

I'm new to the world of BDD, but I'd like to get a grip of it as soon as possible. It's one of my first tests: Fluent.js ...
15
votes
1answer
237 views
+150

Order a delicious pie here

For a quick summary: I've created this internal web application, and I've hit a point where I can really see the mess I've made. I need some help separating the logic, the view, and the data. More ...
1
vote
1answer
59 views

How can I reduce this code javascript code so it's not as repetitve?

I have a function which goes through every name in an object. This object has an array parameter materials which holds other objects. Those objects have the same array parameter which hold more ...
1
vote
3answers
77 views

Converting text to colored pixels and back again

Any suggestions for improvement or critiques are welcome! ...
4
votes
1answer
57 views

How should I name a function which shows or hides an element?

I have a function to display or hide some elements. What I want to do is to manage the display of those elements regarding a value. How should I replace the term ...
4
votes
0answers
47 views

UI for adding roles and modules to a user list

I have a small UI that involves adding roles and modules to a user database array. The interface works as is, no problem at all, but it seems to have a bit of 'duplicate' code that I was hoping I ...
0
votes
0answers
34 views

Approach to avoid callback hell without third party modules

I am using the following approach to avoid callback hell. I am curious about what you think since I haven't seen this approach before. What are the pros and cons? To me the advantages are: Easy to ...
7
votes
1answer
104 views

Recursive dragon on a canvas

I've been doing some JavaScript for fun again. This time I tried my hand at drawing the Dragon curve - a neat fractal that consists of one line traveling across the plane, never crossing itself, and ...
2
votes
1answer
45 views

AJAX call with repetitive success/failure handlers

There's some repetition in here. I tried making it into a function but then the response wasn't filling up the ...
-2
votes
1answer
56 views

Pass a Boolean to a function or call one of two separate functions [closed]

Is it better performance or not to call one of two separate functions in response to an if statement over passing an argument to a function? And, what are the ...
3
votes
2answers
89 views

Applying an id attribute based on a variable's value

I have the following code that checks the value of a variable and then applies the correct id attribute accordingly. The value of ...
1
vote
0answers
28 views

Code exercise - Interactive JavaScript Quiz App [closed]

As an exercise to practice JavaScript, I built a quiz app, for which I would appreciate a short review for improvements. The quiz stores the questions in an array of objects, loads the questions ...
12
votes
1answer
431 views

Capitalize the first character of all words (even when following a '-')

I got it working, all variations are displayed Sint-Anna as should be, but I wonder, is there a simpler way to this, since it looks very cluttered? ...
1
vote
1answer
44 views

Best practice for properties initialization using constructor

I am declaring a "class" using a "constructor method". In both samples, properties uuid and dateCreated are initialized but in ...
0
votes
1answer
28 views

Toggling buttons within a div

This code is used to toggle buttons within a div: ...
2
votes
0answers
44 views

Implementing Simple and Fast Inheritance in JavaScript

I have been using the John Resig JavaScript class implementation in my web apps, but the tests shows it is really slow. I really find it useful for the way of extending objects, and the benefits got ...
2
votes
0answers
25 views

ThreeJS State Object

state object - a state or scene from the game. When the start function is called, the state starts rendering, shutting down any other state using the renderer, and calling the specified functions ...
1
vote
0answers
37 views
3
votes
1answer
50 views

Check if string can be rearranged into a palindrome

I created a function to test whether a single word string can be a rearranged into a palindrome (doesn't have to be a real word). My logic was if the string has an even number of letters, then each ...
1
vote
0answers
27 views

Node.js log parser for mongoDB

I have developed a log parser, the goal is to take whatever log type I can, and convert them in a mongoDB collection. I think I've done a pretty good job at reading whatever type of log are trhown at ...
0
votes
1answer
121 views

Animated bubbly font that then does something else based on input [closed]

I have written this code, but it contains a lot of repeating lines, so I thought maybe I could shorten this with switch. It basically displays in a bubbly font ...
2
votes
0answers
16 views

Assigning JSON object values to objects in a KnockoutJS setup

I am using this for in loop to loop through a JSON object and to assign the JSON object's value to my own object in a KnockoutJS setup. The JSON object looks like ...
1
vote
1answer
72 views

Super simple jQuery slider

I created the most simple though still quite flexible jQuery slider ever! Or at least, I hope so. ...
4
votes
1answer
53 views

Removing popup notification, the dirty way

I'm new to coding and I am self-taught up to this point, so my scope for creativity is quite limited. As such I'm doing something in particular that I suspect isn't the "best" way of achieving this ...
1
vote
1answer
74 views

Test & remove, or always remove [closed]

I have a simple function in jQuery I'm using for an event to show a tool tip that may fire a LOT (based on mouse movements): Code A: ...
4
votes
1answer
38 views

From object to array with revert and regroup

Basically, I need to regroup keys by values from an object to an array An example worth a thousand words in my case, as I don't know how to clearly explain my problem. Here is my input object: ...
3
votes
1answer
46 views

Detecting which properties have been changed from two objects

I have the following code. Providing two objects cmd and this.xxx.properties, script detects the only property changed and ...