August 24th, 2007
If you feel like being a little bit silly today, you might check out some code I wrote to generate BMP images right in the browser, using javascript. For maximum compatibility, I'm using the v3 header and uncompressed 24-bit color.
All mine does so far is generate a quasi-random bitmap. The same technique could be used to generate very small rounded-corner images and other progressive enhancements. Perhaps some other file formats might be interesting to play with as well. Excel spreadsheets, perhaps? I don't have much interest in continuing work on javascript-based file production, but I'd love to see other people take this idea for a spin.
Comments Off | Posted in Software
February 6th, 2007
Combining the power of hot buzzwords such as "closures", "private and privileged scoping", "anonymous functions", and "object namespacing", I present a framework for future Javascript libraries.
Read full entry »
Comments Off | Posted in Software
September 27th, 2006
While working on a project for school, I discovered that there was no easy way to add, modify, and remove global CSS. There are three well-known ways of dynamically modifying the CSS in a page: 1) Set the style of individual named elements, 2) set the class of the <body> element to invoke CSS predefined for the circumstance, or 3) add or remove links to existing stylesheets. None of these address the issue of adding arbitrary global CSS at an arbitrary time.
After several attempts (including modifying the contents of a text node inside a <style> node), I found a working solution using data: protocol URLs in <link> nodes. Here, for your coding pleasure, is DynamicStyle-0.4.js:
The DynamicStyle library is ridiculously easy to use, since initialization and cleanup are handled automatically. Here are some sample calls to the DynamicStyle library:
DynamicStyle.setStyle('search-hilite', 'span.search-1 { background-color: yellow; }');
DynamicStyle.getStyle('search-hilite');
DynamicStyle.removeStyle('search-hilite');
The code is available under both the Creative Commons Attribution Share-Alike license and the GPL.
Update: Newer versions and change log.
Comments Off | Posted in Software