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 and its dialects / implementations: JavaScript, JScript, etc., excluding ...

learn more… | top users | synonyms

1
vote
2answers
55 views

How to make this code cleaner

Is there a way to write this code block cleaner and more readable? var shareNavigate = function () { scope.sharingActions.shareOnFacebook().done(function () { ...
3
votes
2answers
46 views

Replacing simple jQuery methods for better use

There are a few common jQuery call I find my self calling when creating my app. I need some help and maybe a better way to do all this or rewrite it. 1) Singleton Selector If I want to select only ...
1
vote
1answer
27 views

Javascript objects listening to their own events

I have been playing with event driven javascript lately, and have wondered if it's a good/bad thing for objects listening for their own events as a way of abstracting and simplifying internal logic. ...
0
votes
1answer
19 views

Showing jQuery UI tooltip on focus of text box

Firstly, here's a link to the fiddle. Basically my situation is that there is a requirement to show tooltips on textboxes on some forms being created for a website to allow employees to update their ...
0
votes
1answer
37 views

How to make this function reusable instead of repeating it? [closed]

I'm using JavaScript and JQuery 1.8.3 to rebuild a form built by Django-filter. My purpose is to only present options that will yield a result to the user. The Django stuff all works fine and this is ...
1
vote
1answer
45 views

Better way to hide, change and show DIVs in Javascript

I made this Javascript to hide, show and change some DIVs but I believe it's not really good code. Can you help me to make it better? function colorM(n) { switch(n){ case 1: ...
2
votes
1answer
36 views

Need suggestions to improve the code for an open source web based drafting application

My application. The repository and the file that needs review. Here is the source code $(function () { var draft = function (parsed, title) { var self = this; var wordCount = ...
0
votes
0answers
14 views

Backbone Marionette code improvement 2

What's a better way to implement the code below? As much as possible, lessen the repeated lines: vent.on("createAccountLayout:rendered", function() { ...
3
votes
1answer
33 views

Improvement on code

Okay, I'm just a little newbie in programming just doing it for a past time hobby. I am just recently making a web editor for fun and the way I was doing it (Using PHP) I was told would be a bad way. ...
-1
votes
0answers
39 views

Why does my validation not work on all PC browsers? [closed]

The validation code below works 100% on all MAC browsers. But on all PC browsers the validation is ignored. After the user submits the form the email is validated and returns a thank you message. Is ...
2
votes
0answers
53 views

Javascript / Jquery Recursive find function

I wrote the following code as a way of plucking data from a n-depth javascript object. It works a charm and even appends the parents of the the found item. I was just wondering if you guys had any ...
2
votes
2answers
38 views

How to improve this jQuery code for tabs

I'm quite new to javaScript and jQuery and wrote the following function to creat some dynamic tabs. I'd be very interested to know how professional programmers would improve this code. jsFiddle ...
2
votes
2answers
59 views

Best coding practice for classes

I just have a somewhat simple question on coding practices. I have never written a large application before and I am currently working on building a game engine in Javascript. The part that confuses ...
3
votes
1answer
50 views

Collision detection accuracy

How do you guys think I can improve the code for collision detection on my website asteroidfield.eu5.org? The current code is var dx = Math.abs(c1.getcx() - c2.getcx()); var dy = Math.abs(c1.getcy() ...
1
vote
0answers
26 views

Help Improve this Code: Notifications Dropdown with TinyScroll

I'm relatively new to jQuery and am trying to learn best practices/design patterns with javascript. Came across this link (http://addyosmani.com/resources/essentialjsdesignpatterns/book/) and decided ...
1
vote
1answer
39 views

How can I improve my code which dynamically populates a section of a page?

My site consists of a lot of asynchronous calls, and because of this a lot of content is dynamically added to the page. For this section of code I've dynamically added tabs to a page and need to ...
-1
votes
0answers
42 views

Can this code be minified even more?

I have an insane idea of minimizing this code. It searches though table for a entered string, and if found, adds number from another column and returns total number for coincidences. row #5 has ...
-1
votes
0answers
40 views

Boiler.js - A new JavaScript utility library. Room for improvement? [closed]

Boiler.js @ GitHub Boiler.js Homepage I wrote Boiler.js from the ground up for a few reasons: Underscore.js and other similar libraries do not have enough methods for working with object-literals ...
2
votes
1answer
50 views

How bad is it Doc? (Vanilla Javascript)

2 months ago, I wrote a chrome extension called hotfix. I recently went back to look over the code and it made me cringe a bit. I refactored it a little, but before I get knee deep in it, I would like ...
1
vote
1answer
59 views

Should I use anonymous functions in my javascript program?

This question is about the best way to declare functions in Javascript. the app is a small 2 player board game I'm working on as part of a bigger web page. Basically I have a socket which receives and ...
0
votes
0answers
35 views

JavaScript regular expression literal as string literal

Please refer to this question for more discussion. JavaScript string literal sometimes to many escaping slashes. The following address this problem by converting a regular expression literal into a ...
0
votes
1answer
32 views

Is there a better way to read json in node

I have this view that populates an unordered list from values in a json file. I am doing this in node. So is there a better way to do this, or a mode 'node-like' way? Can I load the json file without ...
-1
votes
0answers
33 views

Checklist for coding MVVM web application [closed]

We are a small team working on a web application using MVVM design pattern using technologies like .NET, Knockout and HTML. I am trying to come up with a code review process and as a first step trying ...
0
votes
1answer
70 views

Review my first attempt at a jQuery plugin

So this is my first attempt at creating a jQuery plugin. InstaSlider is a lightweight jQuery image slider / carousel plugin that populates content from an Instagram hashtag. After searching for a ...
3
votes
1answer
86 views

First Javascript - Geocoder - Can it be improved?

So I'm pretty excited to have coded my first javascript file which now works, and I've spent my evening trying to improve it. It takes a location in the #loc input box and geocodes it (gets ...
-2
votes
1answer
34 views

Is this a good use case for a database or will I be fine with tables? [closed]

I am doing a rebuild of a website that needs to be converted to responsive. Originally, I was under the impression that the table of listings for locations of offices was perhaps under a hundred. ...
0
votes
0answers
26 views

Critique my RTCPeerConnection signaling library

I created a library/npm module to handle the signaling process for RTCPeerConnection. There is still a good bit of work that needs done (error handling, dealing with users disconnecting during the ...
0
votes
1answer
34 views

Backbone Marionette code improvement

I have this repetitive block of code and I'm looking for ways to make it reusable and as flat as possible. Here it is: Controller.showKeyboardRegion = function() { ...
4
votes
3answers
159 views

Getting all number from a String like this “1,2,5-9”

I need to get the numbers in a string like "1,2,5-9", the function should return a list with these values ​​[1,2,5,6,7,8,9] Here's what I did. Is this the best way or there's something ...
1
vote
0answers
37 views

Review my Zepto / jQuery plugin base

I am looking for a starting point to code plugins, primarily for Zepto.js (with fall back for jQuery). These will provide reusable functions for Tumblr theming. However, I can't seem to find ...
0
votes
1answer
56 views

Javascript optimizing the code

I have written the following Javascript class function InScroll( container, options ) { "use strict"; var isRunning = false; // utilities var noop = function() {}; var inter = ...
0
votes
1answer
32 views

Code review jQuery form preview

How can I improve my jQuery form preview implementation. Currently using the jQuery Instagram Plugin to get the hashtag from Instagram. var timeoutReference; var element; var tagsa; ...
0
votes
1answer
46 views

Box(x,y,X,Y), box(x,X,y,Y), box(x,w,y,h), box(x,y,w,h) or box(fromPos,toPos)?

Say you are representing a box, or creating a function that slices a 2d array, or whatever. How do you represent it?
0
votes
1answer
19 views

XMLRequest Function

I've written a short snippet of code to replace JQuery's $.post ( to get ride of JQuery, mainly ). The function does seem to work. But, since I might be using this function in a couple of other pages, ...
1
vote
1answer
29 views

when we need to add some javascript code to html, where we have to put it?

when we need to add some javascript code to html, where we have to put it? What is the best practice: in line: <script type="text/javascript">document.write(new ...
0
votes
1answer
34 views

Using jquery to prepare jQuery UI tabs, optimize?

I am looking for someone to review my solution to a jQuery DOM manipulation exercise on appendto.com: http://learn.appendto.com/lesson/dom-manipulation-101#exercise I'm wondering if there is a way I ...
1
vote
1answer
71 views

Elegantly check for null before method call

How do I elegantly check for null before calling a method on an object? This is how I do it right now: var title = document.querySelector('title'); title = title ? title.text : ''; Null Object ...
2
votes
2answers
75 views

Suggestions for improving my Tic-Tac-Toe code in Javascript

I have some hack-ey programming experience and recently made a Tic-Tac-Toe game in javascript. The game seems to work fine. I am looking for some constructive criticism to understand what can be ...
1
vote
0answers
17 views

Code review for javascript and sencha touch with XML

Hi could you please code review the following, my concern is XML parsing is hardcoded: Ext.Ajax.request({ url: storageDataItem.contentlink, success: function (response) { ...
0
votes
1answer
78 views

My take at OOP module/prototyping JavaScript

The last month I've been reading up on how to take my JavaScript code to the next level. I am a Java programmer at heart, so it feels nice when everything is encapsulated in classes/objects, and these ...
2
votes
1answer
46 views

Javascript modules loading with eval()

Recently i asked to use eval() for a module function. Now i ended up doing a very weird function which does what i want. I like the idea i made it but im not so sure if this is state of the art, or ...
-2
votes
0answers
101 views

How to better structure my Javascript code? [closed]

The way I currently write my Javascript code is the following: $(document).ready(function(){ // store vars var $var1 = $('.element1'); var $var2 = $('.element2'); function doThis(){ ...
2
votes
1answer
56 views

My login with AJAX and PHP

In your opinion, do I need to do all these validations. I thought to do well and stay safe but I seriously raises the question if it isn't slower. jQuery code $(document).ready(function () { ...
1
vote
0answers
27 views

Adding events to multiple markers in a google map

I was looking over questions related to setting up markers on a google map, and though the following works perfectly fine for me, it was different from the other (and accepted) answers. I just wanted ...
1
vote
0answers
41 views

Object map in Javascript

I want to make a map object that key is object. But, javascript only allows string as a hash key. (at least before ECMAScript6 comes?) So, I tried to write auxiliary functions to emulate, hash-ish ...
1
vote
2answers
55 views

JSON lookup by key

I always did my lookup in json collection like that: var data = [ { "Key": "1111-1111-1111", "Email": "[email protected]" } ]; function getByKey(key) { var found = null; ...
1
vote
2answers
68 views

Using AJAX to look up MySQL value using two dropdown inputs

I have a list of cities, and a set of "travel time" between any given two cities. The "travel time" is fixed and not necessarily dependent on absolute distance between the two cities, and it currently ...
1
vote
0answers
54 views

JavaScript xor function

I made simple JavaScript xor function. It accepts string, numeric array and mixed array (char, string, num) as params. It returns string or an array. Returning an array is a must!. All numbers are ...
0
votes
2answers
78 views

Cleaning up an if…else statement

I'm making a function that takes the date a page was last edited, accessed through MediaWiki's API, compares it to the current date, and returns how long ago the page was edited, e.g. 1 year/2 ...
1
vote
1answer
50 views

Revealing module implicity calling an internal function - is this a “smell”

I'm trying to improve my javascript and have been using the revealing module pattern to good effect but I noticed that code in the module not in a function or the return is executed on creation have ...

1 2 3 4 5 21