[sf-perl] OffTopic: Any JavaScript programmers here?

Vicki Brown vlb at cfcl.com
Sat Jul 5 14:42:20 PDT 2008

> Also, of course JS has hashes.  They are called a variety of things -
> 'associative arrays', 'object literals', 'objects', etc. depending on
> where you look.

Thanks. I still have the 3rd ed. of "JavaScript, the Definitive Guide"
(5th edition in the mail) and it's very light on the subject of
"associative arrays". It pretty much handwaves them away as far as I could

Kevin's example
> var foo = { hat : 'Fedora', cat : 'Gattopardo' };
is VERY much appreciated. I may print it out and tape it into the book. :)

At 07:45 -0700 07/05/2008, David Scott wrote:
> Of course if you're scraping someone else's HTML then you don't have a
> lot of choice, and innerHTML could be your friend.  Then again, I'm not
> sure why you're scraping HTML code in Javascript.  I can't quite see the
> use case.

As Rich has already mentioned, the use case in this case is TWiki :)

I initially wanted to be able to sort a table of contents but I figured
the functionality should be extensible to any bullet list.

>> Aren't the list items coming to you
>> from some source, like a database query? ...

Nope. A bullet list is just typed in order on the page. A TOC is generated
dynamically from the section headers on the page.

TWiki TOCs are built as

Bullet lists are built as
   * item
   * another item
      * indented line

If you're asking wth I would want to _sort_ a TOC, go read my page...

The HTML is generated on the fly and I don't control it.  Of course, I
_could_ write the page in HTML but then I'm working counter to the
simplicity and ease of use of TWiki.

So -
   it's someone else's CGI backend code
   it's someone else's HTML frontend code
but with a little bit of JS, I can do magic.

At 13:31 -0700 07/05/2008, David Scott wrote:
> If it were me, though, I'd reverse-engineer the HTML blob from
> the list element

Unfortunately, I have no idea what you mean by that. :(
It may be "The Right Thing to Do" but in this case The Thing I Understand
is a heckuva lot easier.

- Vicki

  zzZ                   San Francisco Bay Area, CA
 z  |\     _,,,---,,_   Books, Cats, Tech
zz /,`.-'`'    -.  ;-;;,_  http://cfcl.com/vlb
  |,4-  ) )-,_. ,\ ( `'-'  http://cfcl.com/vlb/weblog
 '---''(_/--'  `-'\_)      http://twitter.com/vlb

More information about the SanFrancisco-pm mailing list