Extension:TODOListProgressBar

What can this extension do?
This extension is aimed at making the process of tracking the progress of a TODO list (or other list) easier. When creating your TODO list, you include the tag along with each item. As you complete an item, you update its status accordingly and the rest of the extension takes care of displaying the nice progress bar for a visual indicator as to the progress of completing the TODO list. In addition, it places a status string where the tag is located so that your TODO list will tell you which items are complete and which arent.

Usage
The tag has two modes of operation:
 * Item Mode   -  or Item Text
 * Graphic Mode -  or Caption Text

All tags require the "type" attribute. It only has two values: This tells the code what to do with the tag. As such, it has no default value.
 * "item"
 * "graphic"

For Item Mode, the parameters are as follows:
 * name
 * The name of the item. This parameter is a string value and must be unique for the group the item is in. If this parameter is not given, a unique value will be assigned. This parameter is optional.


 * status
 * Determines the staus of the item. The default value is "incomplete". This parameter is optional. Valid values are:
 * The item is complete.
 * "complete"
 * "completed"
 * "done"
 * "finished"
 * The item is being worked on but is not completed (counts as incomplete).
 * "ip"
 * "in progress"
 * "working"
 * The status of the item is unknown.
 * "unknown"
 * The item is incomplete or has not been started on.
 * "incomplete"
 * "pending"
 * "held"


 * group
 * The group an item belongs to. This parameter is a string value. The default value for this parameter is "global". This parameter is optional.


 * value
 * The "point value" of this item. The default value for any item is 1. This parameter is an integer value. This changes the point value of the item, and changes the final point value of the entire group. This parameter is optional.


 * nostatus
 * This is a single word parameter that will hide the status indicator. This can be useful if you just want to track items but aren't worried about them being marked in the list itself. This parameter is optional.


 * $text
 * The text for the item. This will be the text that is between the  tags. This parameter is optional.

When an item is complete, its point value is added to the total of completed items and rendered in the graphic.

For Graphics Mode, the parameters are as follows:
 * group
 * The group of items that are going to be rendered. This parameter is a string value. The default value for this parameter is "global". This parameter is optional.


 * color
 * The color that will be used to fill the progress bar. The default value is black. This parameter is any valid hex RGB value or HTML color. This parameter is optional.


 * height
 * The height (in pixles, aka "px") of the progress bar. The default value is 10px. This parameter is an integer value. This parameter is optional.


 * width
 * The width (in pixels, aka "px") of the progress bar. The default value is 400px. This parameter is an integer value. This parameter is optional.


 * $text
 * The text for the progress bar caption. This will be the text that is between the  tags. This parameter is optional.

Once a progress bar has been rendered, the data for the rendered group will be erased, thus allowing it to be re-used again further down in the code.

It is important to note, you do not have to group similar items together. The group parameter will allow you to mix items from different lists together and still keep them separate once the progress bar is rendered.

It is equally important to note that you cannot (at this point) place the progress bar tag before the item tags. This is due to the fact that HTML is parsed top down, as well as the fact that I have not added any AJAX that would bypass this restriction. Maybe for the next version...

Examples
Examples can be found here. These are working examples.

If you think of an example that should be included, let me know via the discussion page.

Download instructions
Please cut and paste the code found below and place it in. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

Installation
To install this extension, add the following to LocalSettings.php:

Credits
A portion of this code is based directly on Progressbar, I have merely modified it to work with my needs. I take no credit for the portion that is based on Progressbar.

Change Log

 * 20100612.0
 * Inital release
 * 20100613.0
 * Changed all the div elements to use the inline display style rather than the block style.
 * 20100613.1
 * Realized I added an inline where I shouldn't have.
 * Fixed some nasty XSS bugs I had introduced. (Thanks to Max Semenik for noticing this.)
 * Changed the  tag to allow text to appear between the tags and be displayed along with the status indicator.
 * 20100613.2
 * Made the name parameter optional to simplify the tag syntax.
 * Added a "nostatus" parameter to the item tag.
 * Added an "unknown" status value.
 * 20100613.3
 * Fixed a bug related to "nostatus" causing items marked with nostatus to not be calcualted in the final tally.

Code:

TODO (pun)

 * 1) Add a  for setting page wide defaults.
 * 2) This will require an array to store the defaults so they can be changed.
 * 3) Add a  that will output the name, value, and status of each item in a group.
 * 4) Add a "percent" parameter that allows giving a percent complete value to items that are not completed.
 * 5) This will cause only a portion of the items value to be added to the final tally.
 * 6) Add an option to  to not wipe the group data.
 * 7) This could be useful for implementing an "advanced features todo list". In such a list, the basic features are listed first (which then display their own progress bar) followed by the advanced features (which then displays another progress bar containing both sets of items).