/Ugly/ + 'JavaScript'

A place for ugly, silly, or just-plain-crap JavaScript.

Evil Eval, strategy pattern to the resque

A dreadful and utterly painful attempt to create an interchangeable operator.

  • Inconsistent white space
  • No brackets
  • eval !!

My suggestion, use a strategy pattern.

Read the story here http://stackoverflow.com/a/9989085/1173062

Posted by Helmus on 03 Apr 2012 | linky

Oracle Job Site JS - a new frontier in ugliness

One of the many highlights in oafcoreR121.js:

And who needs CSS classes?

Thank goodness there’s a comment. Without it we might not understand what’s going on. Oh wait…

And awesome browser detection:

Posted by Daniel on 10 Feb 2012 | linky

No errors here

I’m not sure what’s worse - The fact that all JavaScript errors are silently ignored, doCallback2 having three callbacks and doCallback3 having two callbacks, or the use of globals (Callback1, Callback2, Callback3). The same site had JavaScript functions with names like “foo” and “bar”.

As a side note, an interesting oddity in JavaScript: When you return true in the window.onerror handler, this prevents the default event handler. This is the opposite to all the other DOM 0 events (such as onclick), where returning false prevents the default handler.

Posted by Daniel15 on 23 Dec 2011 | linky

Hating the back button, and exception abuse

Saw these snippets on the site of a company that provides “industry leading solutions”. Firstly a snippet that was in the <head> of every page, intentionally breaking the back button:

And there was also this function which abuses exceptions for control flow (I’m not too sure why):

Posted by Daniel15 on 22 Oct 2011 | linky

Links plus

Working on a recent project I kept coming across anchor tags like this:

I was really curious as to what visit_url() would do, eventually I found it:

Posted by Gavin Logan (@tamewhale) on 13 Oct 2011 | linky

Subscribe or follow @UglyJS!
.........
Fork then send a pull request to contribute.