RSVP - Please Reply

Armin's Spot on the Web


Home

Impressum

My Code


What is a Weblog?

Pictures (.Mac)


NetNewsWire: More news, less junk. Faster

Discussion

Recent Discussion

Create New Topic


Address Book Menu Plug-In: Stadtplandienst

One of the great features of Address Book has always been that you could click on any label and functionality for the associated data. It would display the phone number in a huge font on the screen, send a mail, start a chat or display a map of the address in the browser.

With Panther, AppleScript developers get a great feature: they can extend these 'label menus' with their own AppleScripts. The syntax ist straight forward and very flexible.

The first scripts I saw would add a different map service and my script will do that, too, but with a twist. My favorite map service Stadtplandienst does not allow 'third-party developers' (like me) to link directly into their pages. This means that you cannot code a URL with the parameters (in this case the zip, city and street) and call that to display the relevant results pagee. Instead of allowing this direct access, this service site, require user interaction in a portal page, so you have to enter the data in a web form.

Safari and AppleScript to the rescue. Safari, through an ingenius AppleScript command called do JavaScript allows you to access every element of a web page's document object model. (see, it does pay off to know more than one programming language and technology).

What this script does is open the relevant starting page and enter the value into the form fields using javascript, then it submits the form again using javascript. This implementation will break if the service changes it's web site though, that is a drawback, but better than not working at all. This script also uses Safari, no matter what your default browser is. That might not be nice but I use the Safari scripting interface, so I have no choice.

So now using Safari, JavaScript and AppleScript I can finally call my favorite map service directly out of Address Book.

I posted the code below for clarity, but this will only work on Panther anyway, so you might as well click here to have the script appear in your Script Editor.

You now need to save the script as a 'Compiled Script' with the extension.scpt in the folder Address Book Plug-Ins in the Library folder of your home folder (or ~/Library/Address Book Plug-Ins/ in Unix syntax). Please note that Stadtplandienst does not yet support every city in Germany, but it still remains my favorite. You should be able to simply adapt the script to your favorite service.

Also take a look at the Postleitzahlen Plug-In

Update (15. April 2004): I noticed that Stadtplandienst changed their web appearance and the page now takes a little longer to load. I adjusted the delay parameter in the code to reflect that. YMMV, play around with that parameter until it works for you.

More Scripts on RSVP

Discuss

Google
WWW RSVP.atsites.de

This page was last updated: Thursday, April 15, 2004 at 2:00:53 PM
Copyright 2010 RSVP - Please Reply
Mail me @ arminbatmacdotcom
Create your own Manila site in minutes. Everyone's doing it!