Difference between revisions of "MediaWiki:Common.js"
From EG1004 Lab Manual
(New page: →Any JavaScript here will be loaded for all users on every page load.: addOnloadHook( function() { } );) |
|||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* 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 (elTable in arrTables) { | |||
if (elTable.className == "kmap km_highlight") | |||
arrKmapsTBH.push(elTable); | |||
} | |||
return arrKmapsTBH; | |||
} | |||
function highlightKmap(kmap) { | |||
var tblBody = kmap.getElementsByTagName("tbody")[0]; | |||
var tblNumRows = tblBody.childNodes.length; | |||
var tblNumCols = tblBody.childNodes[0].childNodes.length; | |||
var kmap = new Array(); | |||
for (i=2;i<tblNumRows;i++){ | |||
kmapRow = new Array(); | |||
for (j=2;j<tblNumCols;j++) { | |||
kmapRow.push(tblBody.childNodes[i].childNodes[j]); | |||
} | |||
kmap.push(kmapRow); | |||
} | |||
} | |||
function highlight_kmaps() { | |||
var arrKmaps = getKmaps(); | |||
for (kmap in arrKmaps) { | |||
highlightKmap(kmap); | |||
} | |||
} | |||
//addOnloadHook( highlight_kmaps ); |
Revision as of 11:58, 31 July 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 (elTable in arrTables) { if (elTable.className == "kmap km_highlight") arrKmapsTBH.push(elTable); } return arrKmapsTBH; } function highlightKmap(kmap) { var tblBody = kmap.getElementsByTagName("tbody")[0]; var tblNumRows = tblBody.childNodes.length; var tblNumCols = tblBody.childNodes[0].childNodes.length; var kmap = new Array(); for (i=2;i<tblNumRows;i++){ kmapRow = new Array(); for (j=2;j<tblNumCols;j++) { kmapRow.push(tblBody.childNodes[i].childNodes[j]); } kmap.push(kmapRow); } } function highlight_kmaps() { var arrKmaps = getKmaps(); for (kmap in arrKmaps) { highlightKmap(kmap); } } //addOnloadHook( highlight_kmaps );