User:Fwangel/monobook.js

// http://en.wikibooks.org/wiki/User:GreyCat/comparison.js // Comparison tables extension // (C) GreyCat, 2006 // License: GPLv2 // // Note: changes to this file may affect many users; //      please discuss on the talk page before editing. // // fwangel, 2009-05-13: minor changes function switchColumn(el, col) { var tbl = el.parentNode.parentNode.parentNode.nextSibling; var state = el.checked ? '' : 'none'; for (var i = 0; i < tbl.rows.length; i++) { var row = tbl.rows[i]; row.cells[col].style.display = state; } } function processTable(tbl) { var headrow = tbl.rows[0]; var selector = ' '; for (var i = 0; i < headrow.cells.length; i++) { var el = headrow.cells[i]; selector += ' ' + el.textContent + ' \n'; }	selector += ' '; var selectorDiv = document.createElement('DIV'); selectorDiv.innerHTML = selector; tbl.parentNode.insertBefore(selectorDiv, tbl); } function setupComparisonTables { var notice = document.getElementById('comparison_notice'); if (notice) { notice.style.display = 'none'; var tables = document.getElementsByTagName('TABLE'); for (var i = 0; i < tables.length; i++) { if (tables[i].className == 'wikitable') { processTable(tables[i]); }		}	} } $(setupComparisonTables);