Hot answers tagged

42 votes
Accepted

Rendering a person's time clock record in HTML, with many color-coded conditions

There are a few good practices that will help this code out. Close the HTML tags that you open - generate valid HTML Newer browsers will probably render your content properly, but older browsers may ...
user avatar
41 votes

Celebratory fireworks animation

Portability / Compatibility: Does it work correctly on all modern browsers (excluding old versions of Internet Explorer)? In Safari, there is a cute tingly-shiny (don't know how to call it) effect as ...
user avatar
  • 108k
40 votes
Accepted

Celebratory fireworks animation

Performance It works fine for me in Opera and Chrome, but it is buggy in Firefox. Profiling reveals that redraw is responsible (big surprise :) ), and there is ...
user avatar
  • 24.9k
23 votes

Celebratory fireworks animation

You should always have an Alt attribute in your img tags ...
user avatar
  • 28.5k
21 votes
Accepted

Don't search for minors, it isn't allowed

This part of the review is focused on the Javascript aspect of the answer I will be really light on this review. I will try to make it short and quick. You have some mixed quotes. Consider the ...
user avatar
19 votes
Accepted

Javascript Minesweeper (with Stack Snippets!)

thisButton.attr('data-x') You can use jQuery's .data(). It uses an internal cache for storing key-value pairs, but if it doesn'...
user avatar
  • 24.8k
18 votes

Rendering a person's time clock record in HTML, with many color-coded conditions

That's a big mess of conditionals. Hopefully they all match the comments near them, though given typical code that's likely not the case. You are repeating a lot of HTML code that could be addressed ...
user avatar
17 votes
Accepted

Is this form submission validator professional?

A few things: Variables in JavaScript should be camelCased. PascalCase is traditionally left for types. CSS classes are ...
user avatar
  • 3,753
16 votes
Accepted

In-browser syntax highlighter

To make it more maintainable and reduce duplication, I'd list the keywords etc. in arrays, and use classes for the styling. That fits nicely as an object with class names as the keys, and an array of ...
user avatar
  • 32.9k
16 votes
Accepted

A game of nodes and pixels

I will only address the repetition in your collision detection code in this answer. The following lines of code are repeated several times: ...
user avatar
  • 1,413
14 votes
Accepted

Refactoring multiple `else if` code

I know I'm late to the game, but each filter function contains essentially the same lines of code. Only the container element differs: ...
user avatar
14 votes
Accepted

Checking conditions before allowing a play button to become visible

Just a few more minor things on top of jt0dd's excellent review. Anonymous functions in JavaScript are awesome, but your program will be more readable if you give the main functions names and declare ...
user avatar
  • 108k
14 votes

Rendering a person's time clock record in HTML, with many color-coded conditions

The first if block can be narrowed by using a color variable; something like this: ...
user avatar
  • 251
14 votes
Accepted

Simplify this document.referrer check

Easily! You can use a regular expression to match page[1-7].html and also search/?: ...
user avatar
  • 108k
14 votes

Is this form submission validator professional?

Code should read like poetry People who don't know that jQuery(function); is the same as jQuery(document).ready(function); will ...
user avatar
  • 2,950
14 votes

Celebratory fireworks animation

(I know I'm quite late to celebrate...anyway) I wanted the firework to sparkle, so I created a Color object. When the firework is "old enough", the particles ...
user avatar
  • 1,862
14 votes

To-do list in jQuery

Use CSS classes rather than inline styles. Instead of modifying the style of each TODO item, use CSS classes. This offloads the styling into a style sheet where it ...
user avatar
13 votes
Accepted

Rock Paper Scissors in JavaScript

The definition of the winningMap is very confusing. I suggest a different form of input: var winningMap = {Rock: "Scissors", Paper: "Rock", Scissors: "Paper"}; ...
user avatar
  • 377
13 votes
Accepted

Gmail Mouse Gesture

First, a word about usage: $().mousePointer is sub-optimal. Why instantiate a jQuery object that you never even touch? Instead, you can attach your plugin as ...
user avatar
  • 1,218
13 votes
Accepted

jQuery duplicated selector

You should cache your selector in a variable: var $addedColors = $("#colors_added"); $addedColors.html(parseFloat($addedColors.html()) + 1); Reason: placing ...
user avatar
  • 5,553
13 votes

jQuery AJAX form using bad practice

In a sense, your code has already been reviewed, though I disagree with the excessively negative assessment. It is far from being awful and some of the worst JavaScript code ever. you manually ...
user avatar
12 votes
Accepted

Efficiency of this constantly running time processor for an HTML5 video control bar

If you're worried about performance, this should raise a red flag: someJQueryObject = $("#some-id"); ... someJQueryObject.html(aPlainOldString); ...
user avatar
  • 4,531
12 votes

Human anatomy quiz

Sorry for being a bit harsh here, but if you're making a quiz, please be sure to proof-read everything! I will not play a quiz game that suggests this kind of answer: help u gain nutrients ...
user avatar
  • 6,661
12 votes

Human anatomy quiz

I'm not a fan at all of the mixed spacing and indentation. I'm hopeful (but doubtful) that this is due to something like mixed spaces and tabs. I can't easily skim your code, because you have distinct ...
user avatar
  • 3,595
12 votes

Restricting user to one open tab in browser

I can't think of a better approach than a session cookie. It feels safe in that you have three potential ways of leaving the page: Navigate away Close browser/tab Browser crashes So you're either ...
user avatar
  • 16.7k
12 votes
Accepted

Code-Q2A - copy code blocks from questions to answers

Naming I realize naming can be hard, but 'Auto-Review' is a name that conflicts a bit with the exiting UserScript on StackExchange called AutoReviewComments Protocols There are a number of ...
user avatar
  • 96.8k
11 votes
Accepted

Custom JavaScript validation using the factory / module patterns

This review is mostly about improving the implementation. I don't know JavaScript enough to answer your big questions. Try to catch @konijn or @flambino in the 2nd monitor chat room. Naming The ...
user avatar
  • 108k
11 votes

Code-Q2A - copy code blocks from questions to answers

Coding style I'm not a JavaScript guru, but I'm pretty sure the coding style guide is much less strict compared to Java, for example. The way used spacing around operators, and the placement of ...
user avatar
  • 108k
11 votes
Accepted

Slot Machine Constructor

You have a bug/basic misunderstanding of JS syntax: You can't do chained comparisons in JavaScript, so none of the if(x > num < z) lines work the way you ...
user avatar
  • 32.9k

Only top scored, non community-wiki answers of a minimum length are eligible