You are viewing the MafiaScum.net Wiki. To play the game, visit the forum.

User:Yessiree/monobook.js

From MafiaWiki
< User:Yessiree
Revision as of 20:11, 23 January 2014 by Yessiree (talk | contribs) (Added logic to dynamically add class names to table rows in order to pick up css)
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* dynamically add class names to table rows to apply css properties */

window.onload = init;

function init() {
	var table = document.getElementById('on-going');
	var container = table.getElementsByTagName('tbody');
	var list = container[0].children;
	var count = list.length;
	if ( count > 2 ) {
		for ( i = 1; i < count; i++ ) {
			if ( i % 2 == 0 ) {
				list[i].className += "even";
			} else {
				list[i].className += "odd";
			}
		}
	}

	var table2 = document.getElementById('finished');
	var container2 = table2.getElementsByTagName('tbody');
	var list2 = container2[0].children;
	var count2 = list2.length;

	if ( count2 > 2 ) {
		for ( j = 1; j < count2; j++ ) {
			if ( j % 2 == 0 ) {
				list2[j].className += "even";
			} else {
				list2[j].className += "odd";
			}
		}
	}

	var table3 = document.getElementById('completed');
	var container3 = table3.getElementsByTagName('tbody');
	var list3 = container3[0].children;
	var count3 = list3.length;

	for ( k = 1; k < count3; k++ ) {
		if ( k % 2 == 0 ) {
			list3[k].className += "even";
		} else {
			list3[k].className += "odd";
		}
	}
}