Difference between revisions of "MediaWiki:Common.js"
From EG1004 Lab Manual
Line 13: | Line 13: | ||
function highlightKmap(kmapTable) { | function highlightKmap(kmapTable) { | ||
var kmap = new Array(); | var kmap = new Array(); | ||
for (var i=2;i< | for (var i=2;i<4;i++){ | ||
kmapRow = new Array(); | kmapRow = new Array(); | ||
for (var j=2;j< | for (var j=2;j<6;j++) { | ||
kmapRow.push( | kmapRow.push(kmapTable.rows[i].cells[j]); | ||
} | } | ||
kmap.push(kmapRow); | kmap.push(kmapRow); | ||
Line 36: | Line 31: | ||
//check for 4-cell highlight | //check for 4-cell highlight | ||
for (i in kmap) { | |||
for (i | for (j in kmap[i]) { | ||
for (j | |||
if ((kmap[i][j].innerHTML == "1") && (j == 0)) { | if ((kmap[i][j].innerHTML == "1") && (j == 0)) { | ||
Revision as of 04:58, 4 August 2010
/* Any JavaScript here will be loaded for all users on every page load. */ function getKmaps() { var arrKmapsTBH = new Array(); var arrTables = document.getElementsByTagName("table"); for (var i in arrTables) { if (arrTables[i].className == "kmap km_highlight_8ls") { arrKmapsTBH.push(arrTables[i]); } } return arrKmapsTBH; } function highlightKmap(kmapTable) { var kmap = new Array(); for (var i=2;i<4;i++){ kmapRow = new Array(); for (var j=2;j<6;j++) { kmapRow.push(kmapTable.rows[i].cells[j]); } kmap.push(kmapRow); } //check for 8-cell highlight var full = true; for (i in kmap) { for (j in kmap[i]) { if (kmap[i][j].innerHTML == "0") full = false; } } //check for 4-cell highlight for (i in kmap) { for (j in kmap[i]) { if ((kmap[i][j].innerHTML == "1") && (j == 0)) { } if ((kmap[i][j].innerHTML == "1")) { kmap[i][j].style.border = "3px solid black"; } } } } function highlight_kmaps() { var arrKmaps = getKmaps(); for (var i in arrKmaps) { highlightKmap(arrKmaps[i]); } } addOnloadHook( highlight_kmaps );