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

3
votes
1answer
40 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
43 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
77 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
48 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
77 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
55 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
35 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
43 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
66 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
63 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
66 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
37 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
2answers
53 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
41 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
91 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
100 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
37 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
43 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
39 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
203 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
47 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
58 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
45 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
48 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
23 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
33 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
42 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
85 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
93 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
24 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) { ...
1
vote
2answers
93 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
54 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
1answer
96 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
39 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
44 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
62 views

JSON lookup by key

I always did my lookup in json collection like that: var data = [ { "Key": "1111-1111-1111", "Email": "test@test.com" } ]; function getByKey(key) { var found = null; ...
1
vote
2answers
186 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
64 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
83 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 ...
2
votes
1answer
60 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
vote
0answers
54 views

Jquery Dropdown plugin looking for OOP tips or advice!

;(function ( $, window, document, undefined ) { if ( typeof Object.create !== 'function' ) { Object.create = function (o) { function F() {} F.prototype = o; return ...
1
vote
1answer
79 views

JQuery is working but clunky/slow

I'm coming close to finishing a site where there are a number of jQuery functions going on. They all work, but the page is just running a bit too clunky. The fading in and out is just not as smooth as ...
3
votes
1answer
70 views

JavaScript object to JSON

Since I didn't find a way to properly transform JavaScript object to JSON with PHP, I wrote a snippet. Lets assume the following excerpt from Google Fonts JavaScript API: WebFontConfig = { ...
0
votes
1answer
43 views

Roll your own widget factory

So for practice with Javascript, I wrote this lightweight widget factory which is similar in functionality (okay, that's a bit of a stretch) to jQuery's UI Widget factory. I was hoping I could get ...
-1
votes
1answer
46 views

Improve this jquery code

Such as the title, how to make it more clean and improve it. (from a jquery novice) $.extend({ misTip : function($tipSettings) { $tip = $tipSettings.tip ? $tipSettings.tip : ''; $closeTime = ...
3
votes
1answer
127 views

Jquery sortable style function

This is a basic sorting function written in jQuery that moves items in the DOM around to create empty spaces for a droppable(). Since there is so much going on in a droppable over event, i'd love some ...
1
vote
2answers
67 views

JavaScript - Does this link need improvement?

I would like to hear your feedback on the link below that lets users add a link to a website. I read that javascript:void(0) is suggested instead of a # for the <a href="" attribute. Is this still ...
0
votes
1answer
79 views

Tidying js files

I usually find the .js files to be quite messy and the truth is that mines are even worse than the average as, being soft, I'm not the sharpest tool neither at Jquery nor Javascript. So I would ...
0
votes
0answers
107 views

What's wrong with this javascript programming approach?

Helllo people I'm now developing an instant messaging system but I'm a little confused : I can't decide which approach do I have to choose! Here is a code and I want you to tell me what is good/bad ...

1 2 3 4 5 22