cut a leftover comment, fix a bit of spacing
[invirt/packages/invirt-web.git] / code / static / stripe.js
1 /*
2  * The general idea is from the following A List Apart article:
3  * http://www.alistapart.com/articles/zebratables/
4  *
5  * The structure is inspired by the code fragment they supply, but the
6  * code here is significantly cleaner. It also colors every two lines
7  * rather than every line, since XVM uses two rows for each item.
8  */
9
10 function stripe(table, darkClass, lightClass) {
11     for (var i = 0; i < table.rows.length; i++ ) {
12         /* The header row should be light; the next two are dark. */
13         if (i%4 == 1 || i%4 == 2)
14             table.rows[i].className += ' ' + darkClass;
15         else if (lightClass)
16             table.rows[i].className += ' ' + lightClass;
17     }
18 }