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

User:Yessiree/monobook.js: Difference between revisions

From MafiaWiki
Jump to navigation Jump to search
(fiddling with javascript)
 
(Added logic to dynamically add class names to table rows in order to pick up css)
Line 1: Line 1:
/* dynamically add class names to table rows to apply css properties */
window.onload = init;
window.onload = init;


function init() {
function init() {
var table = document.getElementById('completed');
var table = document.getElementById('on-going');
 
var container = table.getElementsByTagName('tbody');
var container = table.getElementsByTagName('tbody');
var list = container[0].children;
var list = container[0].children;
var count = list.length;
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";
}
}
}


for ( i = 1; i < count; i++ ) {
var table2 = document.getElementById('finished');
console.log(list[i]);
var container2 = table2.getElementsByTagName('tbody');
if ( i % 2 == 0 ) {
var list2 = container2[0].children;
list[i].className += "even";
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 {
} else {
list[i].className += "odd";
list3[k].className += "odd";
}
}
}
}
console.log(container);
console.log(list);
console.log(count);
}
}

Revision as of 20:11, 23 January 2014

/* 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";
		}
	}
}