Older blog entries for logic (starting at number 152)

More DOM stuff

So, a few more random observations on DOM browser compatibility.

First, don't bother using element.setAttribute('class', 'someclass'). Oh, it looks fine in Firefox, but it won't do squat in Internet Explorer. Use element.className = 'someclass' instead, which seems to work in both browsers. (The problem I noticed, if someone catches this in a search, is that no errors were being raised anywhere, but the styles I specified in the stylesheet weren't being applied in IE. I have no idea if this problem applies to other element attributes. I found a reference to the solution at WebmasterWorld.)

Next, dynamically creating DOM objects in JavaScript is cool. ;-) By being able to yank the navigational aids out of the HTML source, browsers like Lynx and ELinks render with less useless fluff, and if you disable JavaScript in your browser, it "just works" (and looks basically correct).

Finally, I am amazed at how well Opera "just works". I didn't have to touch anything at all to make Opera render everything as I wanted; as far as I can tell, it behaved exactly like Firefox in most cases (specifically, it looks like they implemented the W3C DOM Events specification). Happiness.

Syndicated 2005-11-18 14:34:00 from esm

Depricated to DOM in 30 seconds!

So, an old friend of mine (one of the few people who actually reads this blog, methinks) dropped me an email to let me know that my wonderful new standards-compliant navel-gazing website wasn't as up-to-date as it should be: horror of horrors, I dared to use <blah onclick="javascript goodness"> all over the damn place, giving everything that oh-so-1999 feel. Okay Ben, here you go; both the sidebar hide/show functionality and the resume section expansion has been unceremoniously ripped from the HTML (along with the plethora of id="XXX" tags I had to sprinkle everywhere) and replaced with a gaggle of JavaScript borrowed from several places and a bunch of DOM manipulation.

May I point out, however, that getting the "new DOM way" working was a huge PITA? My first cut working with Firefox worked like a champ. Then I fired up Internet Explorer (why does firing up that web browser always mean I'm going to have a late nigh?), and was greeted by...nothing. A big, fat blank screen. WTF? I notice that if I comment out the call to the external JavaScript file, the page displays properly. Hmm. On a whim, I tried changing the reference from <script ... /> to <script ...></script> and viola, it works. You have got to be kidding me.

Then, we get into the mess that is addEventListener vs. attachEvent vs. document.eventname. That took a lot of straightening out; I eventually completely ditched the code that Ben originally suggested from Scott Andrew, and ended up using Andy Smith's very nice cross-browser event addition handler, using anonymous functions so that this works like it bloody well should. (Microsoft, are you listening? Of course you aren't, how silly of me. :-P). Andy's code has the additional benefit of handling nested event handlers in a very slick manner.

Finally, I had a problem with Firefox "bouncing" back to the top of the screen every time I'd click on one of my psuedo-links for expanding and collapsing a section. Easily solved by calling preventDefault() on the event object passed to the event handler, but once again, it's not supported by IE events (nor did IE do what, in retrospect, appears to be the right thing: fall through to the default event handler if mine doesn't explicitly say not to). So, that's all fixed up, and I appear to have, once again, a working cross-browser website (with substantially simpler HTML). Isn't standards-compliance fun? ;-)

As a side note, there's still a bit more to do; rather than mangling .innerHTML in my expand/collapse code, I should really just create a couple of objects that I can swap in and out there instead. But that will come tomorrow.

Syndicated 2005-11-18 02:04:00 from esm

pdftk

I'm making a note about this here mainly to refresh my own memory later, when I find myself needing to create a decrypted version of a PDF that I have the damn password for: pdftk is a handy little program which very neatly takes a password and PDF as input, and can produce an unencrypted version (with or without any of the permissions changed) as output. I can't believe I spent all night searching for something like this (and started looking at Ghostscript hackery as possible solutions) and never came across it. My Google-fu is weak. :-P

Syndicated 2005-11-17 22:16:00 from esm

CSS again

So, I apparently can't leave well enough alone. I rewrote most of the HTML that drives this website to use <div ...> sections and semi-proper semantic markup (where possible), and came up with a quickie stylesheet for the whole mess. The end result is actually something I'm fairly happy with; it still has some rough edges, but considering I'm finally calling it a night on this version at 2:45 AM, I think I can forgive a few minor problems. At least it validates as proper XHTML 1.0 and CSS, with no warnings, so I can sleep well knowing that it's standards-compliant, and renders pretty much the same in both Firefox and Internet Explorer, and appears to be readable in both Lynx and ELinks. I'll check on the Linux laptop tomorrow, which also has Opera installed.

As an aside, I'm loving Pyblosxom's "flavors" capability. It made building and testing a completely new website using the old content a breeze; just whip up a new set of flavor templates, and modify to your heart's content. In fact, the RSS feed RSS that Pyblosxom generates is just another flavor. Spiffy stuff.

Syndicated 2005-11-17 03:03:00 from esm

More resume updates

So, I took the resume update one step farther, and borrowed/mangled/rewrote a few bits of JavaScript for my resume that make it possible to switch to "printable" mode with a link and an updated stylesheet, and for certain chunks of details to be expandable/collapsable. I eneded up settling on using <div class=...> everywhere for it, because while using an unoredered list would have been more semantically correct, I just couldn't get it working the way I wanted to across multiple browsers, while this solution both validates and loads in both Firefox and Internet Explorer.

(For the curious: what I was trying to do with unordered lists was have the actual HTML itself be exceedingly simple: just a bit of <ul ...><li>...</li></ul> with some class="..." markup here and there as necessary. The idea was to have a bit of JavaScript tweak list-style: ... to change out the URL for the expand/collapse graphic, and change the display: ... attribute on an associated child list. Then I realized that, semantically, using an unordered list wasn't quite right; what I wanted to really use was a definition list (since what I'm displaying is really a title, and an associated bit of text that I want to toggle the visibility of). A definition list doesn't support bullets, which meant I'd need to add additional markup that didn't really need to be there; so much for separation of style and content. At the end of the day, I decided to just fall back to my original, working version, rather than keep fighting with something that really didn't give me much more over the original. Thus endeth Ed's foray, again, into stylesheets and markup.) need to stick another

Syndicated 2005-11-15 13:05:00 from esm

C# is a tool of the devil

Not really, but it's pretty close. Maybe it's because I'm using Mono instead of someone's commercial product, but I'm really not happy with how the latest incarnation of my languages project is turning out. Granted, it's short: I'm at 158 lines right now, and could probably trim that a bit, although it'll grow as I add the last few needed commands (so far, the shortest complete implementation is the Ruby asynchronous version). The problem is that the C# version of "asynchronous file I/O" is completely different from what you'd expect coming from any of the other languages I've implemented this in (that actually provide a language-offered async handler): it uses threads. Not a terrible thing in and of itself, mind you (heck, a few of versions I wrote for this little hobby project are done using threads, specifically the old Java version before NIO became more generally available). It's just not exactly what I was expecting, and made a few things more complicated than they needed to be. It seems as though select() is considered evil in the Windows world for some reason. Okay, no problem, I'll implement it their way; that was, after all, the point of the exercise...to really learn the idioms of the platform.

Doesn't mean I actually like it all that much, though. I was actually surprised by going through this exercise; I'm still a big fan of Python after this, but Ruby really proved it's worth here, and I was utterly amazed at how easy the Tcl version ended up being to implement (hear that, Prof. Dueck? one of your old students actually liking Tcl! ;-)). I still hate Perl, but less so than before (I still think it looks like line noise when you're done writing something, though), and the PHP version still amuses the heck out of me. The Java version ended up way more complicated than it needed to be, but that's mainly because I wrote it before NIO; I've only started work on a version using java.nio, but I suspect it will turn out much shorter and far less complicated. And, at the end of it all, the C version is by far the most complicated of the bunch, due to the complete lack of modern libraries of code that can be relied upon, and having to reinvent the wheel everywhere. A good learning experience, all around.

Syndicated 2005-11-15 13:05:00 from esm

Who are you, and why should we hire you?

In a fit of disgust with my online resume (mainly because it was quickly falling behind the Word version that I've been mailing to recruiters), I gave it a pretty decent facelift; even the printable version is looking better, and almost good enough to actually print, thanks to some simple Javascript and a much better stylesheet. Now I just need to address the actual content; that "skills grid" seemed like a good idea at the time, but it's proving to be a huge PITA to keep up-to-date.

Syndicated 2005-11-09 15:06:00 from esm

Pyblosxom

So, I finally got around to updating the software that drives this blog (Pyblosxom) to the latest release, and I'm surprised at how well it went, considering all the little hacks and tweaks I'd added to it over time. At this point, I'm running it on a pure vanilla version, with a few additional plugins and filters that I've written or borrowed, and it seems to be holding up nicely. And that damnable paging plugin is now set up to start at page 1 instead of page 0. ;-)

Syndicated 2005-10-28 13:52:00 from esm

Baka baka?

I've uncovered the secret to creating a rabidly addicting video game. It's really quite simple: start with a starving Japanese programmer, and convince him to come work for you with promises of mediocre pay and stale vending machine food. For the first week of their employment, lace the twinkies with meth, and task them with creating a children's game. Once the basics of the game are complete (this should only take a week, given their state of mind), triple the twinkie dosage, and tell them they have five days to finish the game. Then, feed the game's text through Google Translator, and have an American crack addict "spice it up" a bit for good measure. The end result, I suspect, will be something like Katamari Damacy, and while you won't understand why, you'll be as addicted to it as a certain game programmer is to twinkies.

Syndicated 2005-09-07 09:57:00 from esm

Ooh, pictures!

I finally got around to setting up a copy of Gallery for all the pictures I've taken. Not much there yet, but it's coming; we just picked up a 512MB compact flash card for my camera, so I'm no longer tied to the laptop (take 16 pictures, upload to laptop, delete pictures, repeat). The only downside: the camera is extremely slow with the new card. :-P Oh well, can't have everything. Meanwhile, Erica is still contemplating picking up the Canon 20D, since she wants a good digital camera, and as an added bonus, the 20D (sounds like a D&D die or a bust size to me) takes all of the lenses she already owns for her film camera.

Syndicated 2005-08-26 13:17:00 from esm

143 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!