TruerWords Logo
Google
 
Web www.truerwords.net

Search TruerWords

Welcome
Sign Up  Log On

“Apple, On Custom JavaScript Events”

From: Seth Dillingham In Response To: Top of Thread.  
Date Posted: Wednesday, July 4, 2007 1:45:35 PM Replies: 1
   
Enclosures: None.

This morning when I checked my Gmail account, I read a message (from someone named "Filippelli Christophe") that said Apple seemed to be using my Custom JavaScript Events code on the iPhone page. (In case anyone misunderstands: this is a very good thing in my opinion.)

"Yeah right," I thought.

But it's true, at least at the moment. You can see it for yourself:

  1. Go to the iPhone home page
  2. View the source.
  3. About 20 lines down (in the source) there's an indented bundle of <script> tags, the first of which points to “/global/scripts/lib/event_mixins.js”. Copy that path, and load it up in your browser.
  4. See? Third line down says, “(c) 2006 Seth Dillingham …”. How cool is that?

Boring Mac Programmer Stuff

The irony is that my custom events code is based on Apple's own work.

Huh?

Well, in the early 90's, Apple pushed the Mac application developers to make their applications scriptable and recordable.

  • Scriptable meant you could automate (control) the application with AppleScript scripts.
  • Recordable meant you could tell your script editor to start recording, then do something in the application and your actions would be translated to a re-usable applescript in the script editor.

The way it worked was that a button click or menu selection (to name just two examples) in the application would cause the application to send an AppleEvent (the tech on which AppleScript was built) to itself. So it was like you had two applications in one: the one the user interacts with, and the "engine room" where all the real work was done, and the UI communicated with the engine room by sending AppleEvents.

Many well-written applications already “decoupled” the UI from the rest of the code anyway. If the application was also going to be scriptable, then also making it recordable (with the above approach) was at least a realistic consideration (though it was still a lot of work.)

My "Custom Events for JavaScript" article uses the word ‘decoupling’ in the title for exactly that reason: the intent is to allow you to decouple the UI of a web application from the data processing you do in JavaScript, and/or on the server side. It's not identical to Apple's recordability model, but it's inspired by it.

Blah blah blah... most people don't care about that stuff, I know.

Anyway, I told Rich about this and he said Apple owes me an iPhone. Hah.

“Dear Apple: my friend Rich Siegel — you've heard of him, right? — says you owe me an iPhone. Love, Seth”

(Of course, they don't actually owe me anything. I did release the code for free, after all...)

Rich had a funny response to the above (in the form of a faux letter back from Apple), but I'll leave it to him to post (or not). ;-)

I told Flip about it, too (hey, I was excited!), and he said he's going to tell his friends that he knows someone who made the iPhone possible. Hear that popping sound? That was my ego. ;-)

Update: forgot to mention that the custom events stuff is what landed me on the Prototype Core team in the first place... and they (the rest of the team) expect me to roll some form of the custom events code into Prototype itself. Have to do it soon, or Sam is going to send me a Howler...



Discussion Thread:
Trackbacks:

There are no trackbacks.


Until August 31
My Amazon sales
benefit the PMC

Homepage Links

Apr 1 - Aug 31
Ad revenue
benefits the PMC


TruerWords
is Seth Dillingham's
personal web site.
More than the sum of my parts.