Walkthrough: Making a self-updating table of contents with jQuery

Recently, I had a problem where I had to make a Table of Contents out of the headings on a page. This would be a trivial task if we could just list out all the headings in one flat list:

var headings = $('h1, h2, h3, h4, h5, h6');
var listWrapper = $('#toc'); // the container where our table-of-contents goes
var counter = 0;
headings.each(function() {
    $(this).attr("id", "h" + (++counter));
    var li = $('<li></li>')
            .attr( { "href" : "#" + $(this).attr("id") } )
         ); // this creates the list item, and links it to the appropriate header
} );

This would generate a straight list of all the headings on the page, with no apparent hierarchical order. It would also work with any heading <h1> to <h6>. If you’re not concerned with hierarchical order, this will work beautifully.

However, what if we have to generate a hierarchical table of contents, like what Wikipedia does in its articles? This is a bit of a tricky problem, as header tags are not nested. An h2 can appear at any level in the DOM in relation to an h6 tag. With no sense of inherent hierarchical order in the heading tags, how do we make a hierarchical structure?
Read more »

Software review: Able2Extract 8.0 PDF converter

There are many times when you might find yourself looking at a PDF document and thinking, “I need this in a different format”. While there are some decent PDF converters online, all seem to fail when it comes to processing more complicated documents. Not to worry though, there is a better solution.

Meet Able2Extract PDF converter, by Investintech PDF solutions. According to the company, 90% of Fortune 500 companies use this product to some capacity. That sounds pretty stellar; however, the website does not list exactly whom among the 500 use the converter.

Nevertheless, I decided to take the converter for a spin. As a courtesy, Ana Stanojevic of InvestInTech.com allowed me to try the full version for free. After a thorough 6 month testing period, here’s what I found.

Read more »

[Reblog] How Using Too Many WordPress Plugins Can Kill Your Website

A great article from WPHacks.com, addressing the issues about plugin overload. I advise all bloggers out there to be very picky when choosing plugins to add. 6 quality plugins may benefit your website in the end more than 60 plugins that you have to micro-manage.

This article first appeared on WPHacks.com.

There are many thousands of WordPress plugins you can use for free, and there are also more you can buy for different purposes. According to WP Beginner, as of September 2012 there were more than 21,000 free plugins in the WordPress plugins repository! The question is; do you have to use all of them? You have probably seen a sidebar of a blog with a mile long list of awards and a multitude of links to other pages. Some people go as far as including hundreds of flashy widgets. If you are thinking of using several plugins, you should first learn why using too many of them will impact negatively on your readership.
Read more »

Random website of the day: Win solitaire!


If you ever played Solitaire on the archaic Windows 2000/XP operating systems, and won, congratulations! Like me, you probably enjoyed watching the card waterfall at the end.

Now you can relive the nostalgia at WinningSolitaire.com. Click anywhere, and it will spawn a bouncing playing card. Click again, and it spawns more.

Protip: This website is especially entertaining on touch devices. If your browser supports multi-touch, it’s even more entertaining.

Composers and their most popular works, according to Google

This list was made by going to Google, searching the composer’s last name, and seeing which work by that composer came up as the first search result.

In some cases, I have had to search by the composer’s first and last name. Some composers have been omitted because the search suggestions were inconclusive.

Some of the entries may surprise you!

Read more »