You are viewing the MafiaScum.net Wiki. To play the game, visit the forum.
User:Yessiree/monobook.js: Difference between revisions
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(' | 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 ( | var table2 = document.getElementById('finished'); | ||
var container2 = table2.getElementsByTagName('tbody'); | |||
if ( | 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 { | } else { | ||
list3[k].className += "odd"; | |||
} | } | ||
} | } | ||
} | } |
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"; } } }