LibraryLookup: Aleph

Thanks to Janet Lefkovitz, a librarian at the Hebrew University of Jerusalem, the LibraryLookup project has added support for a fifteenth class of OPAC (online public access catalog) system: Ex Libris Aleph. This was an interesting collaboration. I'd looked at a few different Aleph systems, and found that their URLs varied from one implementation to the next in ways that I didn't have time to unravel. But Janet was willing to do this research, and she presented me with a set of Aleph URLs that illustrated the variations. I updated the Build your own Bookmarklet (BYOB) script accordingly.

A technical note: the BYOB script falls back on one of those guilty pleasures of scripting, eval. The fifteen URL templates are classified in a JavaScript array, like so:

queries['eosQ'] = '/VAR1/search/AdvancedSearch.asp?selectField1=IS&txtSearch1=\'+isbn,';
When an OPAC's bookmarklet needs to be parameterized, the form provides fill-in boxes like so:
<input name="eosQ" value="WEBOPAC"/>
The script needs to replace VAR1, in the URL template, with the value of the fill-in box. In order to capture that value, it has to choose from a namespace that looks like this:
The OPAC name -- eosQ, or aleph, or another of the fifteen choices on the form -- is captured in a variable called vendor. Interpolating that name into a JavaScript expression at runtime is a job for eval:
var1 = eval ( "document.forms['byo']." + vendor + ".value" ); 
Is eval evil? Yeah, I guess, but at times like this I drift over to the dark side. If there's a high road I'm not seeing, let me know and I'll report it.

Update: In swift succession Florian Gross, Sjoerd Visscher, and Simon Willison all pointed out the high road:

var1 = document.forms['byo'][vendor]['value']
var1 = document.forms['byo'][vendor].value;
Simon adds:
In JavaScript, [ ] is an object property lookup (an associative array IS an object) so obj['property'] means exactly the same thing as In the vast majority of cases where eval is used it's because people misunderstand this aspect of the language.
Thanks, guys!

A historical note: Aleph, the first letter of the alphabet for more than three centuries millenia (thanks, Eric Promislow) is a leading character in a book I just happened to pick up at the library last night: Language Visible: Unraveling the Mystery of the Alphabet from A to Z, by David Sacks. The name 'aleph' meant 'ox' to the Phonecians, and the letterform evolved from a picture of an ox's head.

The book is full of fascinating bits of trivia like that. What really grabbed me, though, was this discussion of the portability of alphabets:

Even if two languages are totally unlike, letters often can make the transition. Because their core selection of sounds (inherited from the alphabet's earliest stages) is close to being universal, letters usually can be adapted to a different tongue through only a few changes: three or four letters revalued to new sounds, a letter or two invented, unneeded letters discarded.
The newly independent countries of Azerbaijan, Turkmenistan, and Uzbekistan have not altered their spoken languages, which are Turkish tongues. But the governments have moved to replace Cyrillic street signs, textbooks, tax forms, etc., with new ones printed in a modified, 29-letter Roman alphabet. Elementary schools now teach Roman letters. The massive, disruptive changeover -- inspired by westward trade ambitions and hatred of the Soviet memory -- was declared officially complete in Azerbaijan, at least, in 2001. The new alphabet is modeled on that of modern Turkey, which switched from Arabic to Roman letters in 1928, under the westernizing regime of Kemal Atatürk.

Prior to 1940, Azerbaijan, Turkmenistan, and Uzbekistan used the Arabic alphabet, until the early Soviets imposed the Roman one in the 1920s. Thus the three regions have seen all three major alphabets in the last 80 years: Arabic, Cyrillic, and (twice) Roman. Although the languages of the three countries are unrelated to Arabic, Russian, or Latin, each alphabet has taken hold in turn.
Amazing. I knew, of course, that the family tree of alphabets is far simpler than the family tree of languages. But the portability of alphabets, with respect to languages, just never occurred to me. Live and learn.

Former URL: