Archive for the 'scripting' Category

Jeremy Keith and Me

Tuesday, October 11th, 2005

It managed to sneak past me for a few days, but my recent interview with Jeremy Keith has made its way into the latest issue of Digital Web Magazine. In the interview we cover the impetus behind his new book, WaSP’s DOM Scripting Task Force, and Jeremy’s future as a rockstar.

On a somewhat tangential note, if you’re interested in competing at the SXSW Web Awards in March, I recommend getting your entires in soon. If you enter by Friday (October 14th), you only have to pay $10 per category which is too cheap to miss out on. If you attend, you’ll get more of Jeremy & me on “How to Bluff Your Way in DOM Scripting.”

New tutorial: Westhost on Rails

Sunday, October 2nd, 2005

I have been hosting on WestHost for a little over four years now with no major complaints and I also host the majority of my clients there. They offer a lot of options for very little money and are always adding new features to the accounts. Unfortunately, Ruby on Rails is not one of them… yet.

As I have begun working a bit more with Rails, I have been looking to get it installed on my server (as well as some of my clients’). One of the major half-truths of Rails evangelism is the ease of install, especially with a host running Apache 1.3. After doing a few rather painful installs myself for some new projects, I finally decided to document the process of installing Ruby on Rails at WestHost for my own knowledge and to help any others who may be trying to do the same. Hopefully, WestHost will soon start to offer Rails installs as part of their hosting packages, but, until then, I offer up this humble tutorial.

Update 2006-04-14: WestHost has announced that Rails will be available for install via the Site Manager some time this month, making my tutorial unnecessary.

Getting Surreal with ActionScript

Friday, September 23rd, 2005

Hi all.

Being my first post here on my own blog I should take a couple of lines to introduce myself. Name is Dave Stewart and I work with Aaron at Cronin and here at Easy! Designs. Flash and ActionScript are my things and I hope to have plenty experiments to show you in the coming weeks. Anyway, to get the ball rolling I thought I might put up a link to my latest project.

To make a long story short, the Wadsworth Atheneum Museum of Art in Hartford, CT is due to launch a Surrealist Paintings exhibit October 7th to welcome home some of there paintings that have been on tour. They came to us with a tight deadline and limited funds (is there any other kind of client?) to produce an online advertising campaign and a viral piece. So we did. After one brain storming session we had some web banner ideas and a wacky idea for a “Create Your Own” Surreal painting program.

The challenges for me were

  1. creating original assets; and
  2. how to save a painting, since Flash has no way of producing a bitmap on the fly from a users actions.

My initial thoughts were to create an actual paint program with traditional pens, brushes, etc. but it seemed obvious that we would just get a bunch of crap scribbles in our gallery from lazy or artistically challenged peeps. I needed to take control and supply easy to use pre-made assets. So I did 20-30 minuets research on Surrealist Paintings to see what that lark was all about and proceeded to build a couple dozen 3D models and renders for assets. Then I coded her up for drag’n drop functionality with some basic manipulation tools. Then I wrote some crazy ActionScript and Flash Remoting PHP to store a painting (with all it’s hundreds of object attributes and arrays) in MySQL . Off it went yesterday to the live site and so far the response has been awesome. Lots of great feedback and such.

I hope to re-build it now that I have Flash 8 and get creative with some of the new bitmap filters and what-not. Have fun.

Cheers.

Playing catch-up

Tuesday, September 20th, 2005

I’ve been insanely busy building a new Rails app for a client and travelling a lot for speaking engagements. I just got back from an incredible trip to San Jose (well, Cupertino actually) where Molly, Andy and I were doing some training. I had an amazing time with both of them and it was really fun to see Andy in action (I, unfortunately, did not have the peasure of seeing him rock the audience at @media). We had a really great group of conference attendees too. I am a little saddened that this was my last stop on the WOW tour (I am missing Hawaii as it takes place on election day, but more on that later), but I have heard some rumblings that the show may go back on the road for a European leg. Fingers crossed.

Anyway, we’ve pushed a new issue of ALA out the door which includes a fantastic piece by Eric on the new ALA print stylesheet and I have a new article is in there as well: Improving Link Display for Print. It’s print mania at ALA aparently.

Anyway, I am apparently going to New Jersey today for work, so I need to get ready. Ta for now.

Death to bad DOM Implementations

Friday, September 2nd, 2005

I just encountered a DOM implementation issue in IE which took about three hours to solve (and like a year off my life). The story goes like this:

I could not, for the life of me, figure out why a form submitted in Firefox was coming through perfectly while it was missing fields in IE. The form in question has some normal fields and some dynamically generated ones (if JavaScript is enabled). The normal stuff was coming through fine, but I was getting no values for the dynamically generated fields when the form was submitted in IE. I checked the $_REQUEST variable (I am using PHP) to see what was coming through, just to be sure.

I immediately figured it was missing name attributes, but I was using the proper syntax to create the input elements via the DOM (note: the actual JS is more generic than this)

var inpt = document.createElement('input');
inpt.setAttribute('name', 'company');

Indeed, when I looked at the page through the Web Accessibility Toolbar’s View Generated Source, it was indeed missing the name attribute:

<INPUT id=company maxLength=255
       validatefor="title" required="required">

After about another hour or two of fruitless Google-ing, I finally typed in the magic phrase (setting the name attribute in Internet Explorer) and ended up on Bennett McElwee’s blog post of the same name. Suddenly it was all clear and (as I expected) IE’s botched implementation of the DOM’s createElement function was to blame.

According to the MSDN page on the name attribute (linked and quoted in the blog entry):

The NAME attribute cannot be set at run time on elements dynamically created with the createElement method. To create an element with a name attribute, include the attribute and value when using the createElement method.

It continued with the following example:

var oAnchor =
  document.createElement("<A NAME='AnchorName'></A>");

The script “solution” Bennett posted was somewhat of a red herring, however, as Firefox would actually execute the createElement intended for IE and end up with an element named “<input name="company" />” which would be rendered on the page as

<<input name="company" />  id="company"
        maxlength="255" validatefor="title" required="required" />

Perhaps you can see why this would be problematic.

I augmented Bennett’s script slightly and renamed the function createElementWithName so I wouldn’t have to use it on every element I created in the script:

function createElementWithName(type, name) {
  var element;
  // First try the IE way; if this fails then use the standard way
  if (document.all) {
    element =
      document.createElement('< '+type+' name="'+name+'" />');
  } else {
    element = document.createElement(type);
    element.setAttribute('name', name);
  }
  return element;
}

I am not a super fan of the reference to document.all as it feels so much like browser sniffing. I am up for suggestions to improve the function if you have any ideas.

Anyway, I am posting this to hopefully save someone else from the major headache I had today.