Gregg Hilferding


Prototype 1.5.1 Out! Scriptaculous 1.7.0 *Not* Compatible. :(

Congratulations to the Prototype team for rolling out Prototype v1.5.1! :D

Sadly, the current stable version of Scriptaculous (v.1.7.0) is not compatible. In Safari, calling any Effect will fill the Javascript console with an infinite number of "Maximum call stack size exceeded." warnings.

You'll need to run the Scriptaculous v1.7.1 beta 2 to avoid this issue until a new stable version comes out.

Published by Gregg Hilferding on May 2nd, 2007 at 4:20 pm. Filed under Javascript, Signal, WebmasterNo Comments

Prototype Internet Explorer Gotchas

One week into building a technology preview for a new web application, I finally decided to check and "just make sure" that everything was working as well in Windows Internet Explorer as it was working in Safari and Firefox. Imagine my chagrin when the page loaded and was completely blank.

Not even a joyous error message or self-destruct error report to pore over for clues. Just a blank screen. Nothing. Nada.

First some background... I'm building the client side of the in Javascript using the amazing Prototype and Scriptaculous libraries.

It turns out that there are two very important things to keep in mind for Internet Explorer. First, Element.extend is your friend when adding to the DOM. Example:

var my_div = document.createElement('div');
Element.extend(my_div); // without this line, the next line causes IE to stop processing the script!
my_div.addClassName('thumbnail');

Second, be careful what you use as names for custom attributes! If you inadvertently cross the streams by using form attributes on non-form elements then Internet Explorer will suffer total protonic reversal (or, in other words, forcibly shut down). Example:

var my_li = document.createElement('li');
Element.extend(my_li);
my_li.setAttribute('value', s.id); // IE self-destructs
my_li.setAttribute('valuetest', s.id); // IE works fine

Although there is little else I can share about the application I am working on, suffice it to say in about, oh, six months I should have both good news to share and a fantastic grasp on Javascript programming. :)

Published by Gregg Hilferding on April 15th, 2007 at 2:10 pm. Filed under Javascript, Signal5 Comments

Convert Unix Timestamp to Javascript Date Object

Passing a timestamp to javascript? Use this to convert it to a Javascript date object:

var timeStamp = 10000; var theDate = new Date(timeStamp * 1000); var dateString = theDate.toGMTString();

Published by Gregg Hilferding on February 19th, 2007 at 3:55 pm. Filed under Javascript2 Comments

del.icio.us Isn’t It?

Because I chose toyed with the idea of using the very chic Japanese Cherry Blossom template, I was introduced to the del.icio.us bookmarking site yet again. The difference between this time and the last dozen or so times I've run across it? This time I signed up and converted.

The idea of moving my bookmarks online has been nagging at me for almost a year so it's good that I had an excuse. :)

Bad News

The bookmarklet provided during the sign up process (v3) and the one I downloaded from the help section (v4) both failed to work in Safari. Each threw a syntax error.

Bad Bookmarklet v3:

javascript:location.href='http://del.icio.us/post?v=3&url='+ encodeURIComponent(location.href)+ '&title='+encodeURIComponent(document.title.replace(/^\s*|i\s*g,''))

See the problem? The regular expression in the title.replace bit is missing the closing "/" plus it has the critical flaw that it removes all the spaces from the entire title, Not just the ones at the beginning and the end.

Bad Bookmarklet v4:

javascript:location.href='http://del.icio.us/post?v=4;url='+ encodeURIComponent(location.href)+';title='+ encodeURIComponent(document.title.replace(/^\s*|\s*g,''))

Same problem here, the only difference between versions is that this passes the variables via javascript instead of in the URL. Probably to deal with extraordinarily long URLs and titles breaking the maximum character length of the URI field.

Corrected Code (Just for fun, I'll call it v5):

javascript:location.href='http://del.icio.us/post?v=5;url='+ encodeURIComponent(location.href)+';title='+ encodeURIComponent(document.title.replace(/^\s*|\s*$/g,''))

Here we go! We've added our closing "/" and dropped in the dollar sign into the second condition to mean "only remove extra spaces from the end of the title."

Oh right, the link

Gregg's Bookmarks

Published by Gregg Hilferding on October 14th, 2006 at 3:46 pm. Filed under Administrative, Javascript2 Comments