matthew ephraim

Archive for October, 2007

Textmate Hyperlink Helper Menu

Tuesday, October 30th, 2007

The Hyperlink Helper menu is another fun bundle that I had never noticed in TextMate.

Ctrl + Shift + L - Wraps the selection in an anchor tag with a default href attribute, pretty simple.

The real interesting stuff is the Google and Yahoo web lookups:

Ctrl + Shift + Apple + L - Performs a Google search for the selection and links to the first result found

Even better:

Ctrl + Shift + Y - Pops up a menu with 4 different Yahoo search options. Then performs your selected search and pops up a menu with the option to link to any of the top 10 search results.

Be wary of JavaScript reserved words and globals

Monday, October 29th, 2007

If you’re writing some JavaScript and suddenly it stops working without any warnings or errors, make sure you’re not stepping on any reserved words or global objects. Tonight, I had a script that was working perfectly in Firefox, but as soon as I tested it in Safari it completely failed. It took me a little while to realize that I had named a property on an object “default”. Stupid mistake, but Firefox didn’t warn me about it and instead happily ran the script. I guess it goes to show that even standards compliant browsers don’t always behave the way you expect them to.

The Core JavaScript Reference is a good place to start if you’re looking for a list of keywords. Particularly the sections on Global Objects and Reserved Words. This list also wrapped many of them up nicely.

Align Assignments in TextMate

Saturday, October 27th, 2007

This is a cool feature that I didn’t realize TextMate had until today. Say you have a series of assigmnents like this:

var administrator = "Dave";
var guest = "Matt";
var blocked = "Tim";

And you want to have all of the assignments aligned. Select the code and hit Apple + Option + ]. It will automatically align the statements like this:

var administrator = "Dave";
var guest         = "Matt";
var blocked       = "Tim";

I love you TextMate.

JavaScript Mouse Tracker

Saturday, October 20th, 2007

A while ago, I was thinking about software programs like Camtasia that allow you capture a user’s activity as they work on a computer. Screen capturing programs are useful for usability studies because they allow you play back a user’s activity later on when you are evaluating their performance on a set of tasks. I started to wonder if their were any options for capturing a user’s activity remotely through the browser. When I didn’t find anything I thought was compelling, I decided to try writing my own.

What I came up with was a JavaScript class I called MouseMovie that could be used to record the mouse movements a user made while on a page. The first draft is pretty rough, but it will allow you to create a new mouse tracker, start tracking the mouse movements a user makes on a page and then stop the tracker. Once data has been captured by the tacker, you can use the mouse timeline to replay the user’s movements or trace the path of the user’s movements.

JavaScript
/* Create a new tracker, 
start it and stop it and then use 
the timeline to animate 
and trace the mouse path. */
var MyTracker = new MouseMovie.Tracker(); 
MyTracker.start(); 
MyTracker.stop(); 
MouseMovie.Animate({TimeLine : MyTracker.TimeLine});
MouseMovie.Trace(MyTracker.TimeLine);

Currently, there is no way to persist the user’s movements to a file or database, but I’d like to make it possible to store the movements and play them back at another time. A simple demo of the mouse tracker can be found here