View Single Post
Old 01-29-2003, 12:55 AM   PM User | #11
ca_redwards
Regular Coder

 
Join Date: Dec 2002
Posts: 169
Thanks: 0
Thanked 0 Times in 0 Posts
ca_redwards is an unknown quantity at this point
Here's an update utilizing Algorithm's suggestions:

I've simplified the HTML() bookmarklet library's invocation significantly. True to its name, the HTML() function can now be called (implicitly on window), with a string parameter that specifies what tags/attributes/containers to implement. These are identified by mixed/lower/uppercase respectively. I used to impose my huge list of 108 tag/attrs. But now you provide only what you need! By itself (without comments or volumes of tag/attrs), it weighs in at only 0.81K !!

Per Algorithm's suggestion, the factory functions (formerly called "template" functions) return lowercased tag names and attributes with the trailing space-slash inside of tags (formerly called "elemental" tags -- namely, those without any end tag). Attributes are still returned with a leading space, for easy concatenation and subsequent inclusion as the attributes parameter to the tag/container functions. These changes should not affect any existing html constructs that folks have already built with the old returns-everything-capitalized library.

One interesting optimization I made to both the HTML() bookmarklet library itself and the calendar's constructor code is how I define all the necessary functions in an array of functions known by a single identifier. Furthermore, I encapsulated these functions to reduce potential naming clashes with any outside JavaScript code.

In my attachment, I've partially commented the five-line JavaScript source that builds a fully-navigable cross-browser pop-up calendar (IE5.5, NS4.7/6.2/7.0, MZ1.1). Without the comments, it is only 2.84K of JavaScript code (but it generates a staggering 9.1K of html for each calendar!).

See you at the5k.org contest next year!

Quote:
Originally posted by Algorithm
After looking over your code, I found a number of things that could be improved upon, so I tinkered with it. Hope you don't mind!

I removed the global templates (improving interoperability), updated the syntax to meet XHTML standards, removed that annoying 'empty string' bug, and squeezed the filesize down to 1.4KB.

This is a great concept, and I can definitely see myself using this in the future. Thanks!
Attached Files
File Type: txt calendar.txt (3.6 KB, 237 views)

Last edited by ca_redwards; 01-29-2003 at 01:15 AM..
ca_redwards is offline   Reply With Quote