A problem with Firefox

Oliver Brown
— This upcoming video may not be available to view yet.

For a while I’ve noticed my computer running slower and slower for no apparent reason. Although I have a fairly old computer (Athlon 1.2GHz) it was running far slower than it should have been.

A (not so) quick look in task manager revealed a possible culprit - Firefox was running and taking up 80Mb of memory and it was increasing. Anybody any ideas what could cause a sudden and persistent memory leak in Firefox? The only extra I have installed is LiveHeaders. Until it’s fixed I’ve had to revert to IE.

A tacky competition

Oliver Brown
— This upcoming video may not be available to view yet.

I’ve decided to run a silly little competition in an attempt to get people looking around the site more. The traffic I’ll be getting is probably going to be of a pretty low quality but if you sling enough mud, some must stick.

So check it out and you might just win $10.

Finally a use for Netscape!

— This upcoming video may not be available to view yet.

I’m a Mac user (and proud). When it came to the ‘big switch’ there were several things that I needed: my documents, my music, my pictures and my internet (emails and bookmarks and so on). All of these were easily copied across using a cross over cable, no problems there - but shock horror, my emails were another story. Microsoft Outlook Express stores emails in a non-standard format which can’t be read by Apple Mail - disaster! It was then that I remembered once installing Netscape to test compatibility of my web site. Netscape had very nicely offered to import the Internet and email settings from Internet Explorer and Outlook Express. Checking up on this I found that when it does this it stores the resulting emails in a standard .mbox format - which can then be read by any sensible email client. Wohoo! So the basic steps to import your emails from Outlook Express on Windows to Apple Mail on the Mac:

  • Install Netscape on the Windows box.
  • Allow it to import from your Outlook Express.
  • Copy the newly created .mbox files to your Mac.
  • Show Apple Mail where it can find them when it asks.

That’s it - yay! Ooo and make sure you remember to uninstall Netscape afterwards or your PC might become contaminated or something hehehe.

Wow, Wil Wheaton

Oliver Brown
— This upcoming video may not be available to view yet.

I was idly wandering around Technorati and found the 16th most popular blog on there is apparently Wil Wheaton’s blog.

Playing possibly the most annoying Star Trek character of all time doesn’t seem to have been a problem after all. A quick glance around at the stuff on the page suggests a person far more web aware than I imagined: Firefox supporter, Onion reader, blogads user…

I might just have to buy that book of his (a review of which on Amazon reveals I’m rather late in discovering his blog).

Target denied

Oliver Brown
— This upcoming video may not be available to view yet.

I found something out today that really caught me by surprise. It makes sense in theory but in practice I think it’s a bad idea. Not doing it would just be a slight niggle on purists.

The target attribute of a tags is no longer allowed in HTML (HTML 4.01 Strict and XHTML 1.0 Strict). This is technically correct since HTML is for marking structure of a document and opening things in different windows is a user-interface issue and hence is within the domain of javascript. What’s really odd though is the suggested workaround. Mark tags that need to open in a different frame or window somehow (rel="external" for instance) and then use a javascript function to give all those links a target attribute. Seems silly to me.

Progress in Finnish

Oliver Brown
— This upcoming video may not be available to view yet.

Unfortunately Pimsleur don’t do Finnish so I’m having to learn it manually. I have a couple of Finnish course books but the bulk of my effort at the moment is aimed at learning vocabulary. According to the flashcard software I have I know 700 Finnish terms (mainly words but a few short phrases as well). I’m hoping to get to 5000 by New Year (an average of 30 a day).

Start semantics simply

Oliver Brown
— This upcoming video may not be available to view yet.

You may or may not have heard of microformats. They’re basically along the lines of the semantic web project but in a more practical way that is more likely to take off. It basically involves adding extra bits of semantics to web pages (or any XML-based documents) in a consistent way that doesn’t limit what already exists. But there are much simpler good practices that need to be encouraged regarding semantic markup first.

This blog post illustrates a wonderful misuse of HTML and offers an important explanation about why it is a misuse (or at least a decidely-less-useful use).

Making progress in German

Oliver Brown
— This upcoming video may not be available to view yet.

I’m now officially one ninth of my way through the Pimsleur German course (that is I’ve finished Unit 10 of German I - Beginner). It’s still as good as I said previously. Although I think perhaps they should rename “How to be annoying in German”. Towards the end of unit 10, you have a conversation with a woman about having a meal.

“She will suggest a series of times to you. Refuse each time in turn and suggest an hour later.”

Another funny thing I noticed looking at the covers for the rest of the course, the three levels are “Beginner”, “Intermediate” but not “Advanced”. The third level is “Intermediate Plus”. Subtle way of saying even if you complete the course you have a way to go yet.

Least favourite German fragment so far: “jetzt nichts”.

Bad DOM

Oliver Brown
— This upcoming video may not be available to view yet.

The Dom Scripting Taskforce says adding non-standard markup to page using Javascript is OK. Well I wouldn’t call it a “best practice” but from a personal point of view I can’t see a practical disadvantage.

For me the problems with bad markup come from trying to parse it automatically (using PHP’s SimpleXML object for instance). Since the javascript will basically only affect the page a human sees and not a machine, many of the disadvantages of non-standard markup fade away.

How I wrote the list thingy in Javascript

Oliver Brown
— This upcoming video may not be available to view yet.

It is assumed you know basic Javascript before reading this and know what the DOM is.

First the source code:

function setUp() {
    var myULs = document.getElementById('tree').getElementsByTagName('ul');
    for (var i = 1; i < myULs.length; i++) {
        var toggleObject = document.createElement('a');
        toggleObject.innerHTML = '+ ';
        myULs\[i\].parentNode.insertBefore(toggleObject, myULs\[i\].parentNode.firstChild);
        toggleObject.onclick = eventCaller(toggleObject, myULs\[i\]);
    }
}

function eventCaller(toggleButton, list) {
    list.style.display = 'none';
    return function() {
        if (list.style.display == 'none') {
            list.style.display = '';
            toggleButton.innerHTML = '- ';
        } else {
            list.style.display = 'none';
            toggleButton.innerHTML = '+ ';
        }
    }
}

onload = setUp;

First, how function setUp works.

var myULs = document.getElementById('tree').getElementsByTagName('ul');

To use the code you need an element with the id of “tree” surrounding the list you want it to work. This code just gets a collection of ul tags with in the id="tree" tag. This collection is looped through using a for loop.

var toggleObject = document.createElement('a');
toggleObject.innerHTML = '+ ';

This creates a new anchor a element and sets the text inside to a plus sign. I probably shouldn’t use innerHTML but it makes things simpler.

myULs[i].parentNode.insertBefore(toggleObject, myULs[i].parentNode.firstChild);

This looks messy but is really simple. _someNode_.insertBefore adds a node to _someNode_ before some child of _someNode_. In this case we want our newly created anchor tag to be the first child of the ul’s parent. (i.e. place the link before the ul and before any text as well).

toggleObject.onclick = eventCaller(toggleObject, myULs[i]);

The onclick event is then set to some function. It is important to realise the onclick is not set to eventCaller but the function eventCaller returns.

function eventCaller(toggleButton, list)

The function is called with two arguments: a list and the link before it that will toggle the display of the list.

list.style.display = 'none';

First we just set the list to not display by default.

Then the clever bit, we return a function.

What the function does is simple, it toggles the display style attribute of the list and changes the “button” between plus and minus signs.

But the function is different for each list. Because the function is declared within another function, this new anonymous function still has the scope of the function that created it. This means each copy of this new function has different list and toggleButton variables.