User:Iritscen/TestSpace.js: Difference between revisions
Jump to navigation
Jump to search
(oops, this.id is supposed to be within the JS) |
(adding handlers only to hovercells; fun fact, creating this page took our Main Page's page count to 666) |
||
Line 32: | Line 32: | ||
for (var j = 0; j < Cells.length; j++) | for (var j = 0; j < Cells.length; j++) | ||
{ | { | ||
if (hasClass(Cells[j], " | if (hasClass(Cells[j], "hovercell")) | ||
addHandler(Cells[j], "mouseover", new Function("evt", "showDescrip(this.id, true);")); | { | ||
addHandler(Cells[j], "mouseover", new Function("evt", "showDescrip(this.id, true);")); | |||
addHandler(Cells[j], "mouseout", new Function("evt", "showDescrip(this.id, false);")); | |||
} | |||
} | } | ||
} | } |
Revision as of 17:49, 16 November 2012
function showDescrip(typeID, show_or_not) { var DescripPanel = document.getElementsByClassName("hovertable_descrip")[0]; var Descrips = DescripPanel.getElementsByTagName("span"); if (!DescripPanel || !Descrips) return false; for (var i = 0; i < Descrips.length; i++) { if (Descrips[i].id == typeID) { if (show_or_not) Descrips[i].style.display = "block"; else Descrips[i].style.display = "none"; } } } function initHoverTables() { var Tables = document.getElementsByClassName("hovertable"); if (!Tables) return false; for (var i = 0; i < Tables.length; i++) { var Cells = Tables[i].getElementsByTagName("td"); if (!Cells) continue; for (var j = 0; j < Cells.length; j++) { if (hasClass(Cells[j], "hovercell")) { addHandler(Cells[j], "mouseover", new Function("evt", "showDescrip(this.id, true);")); addHandler(Cells[j], "mouseout", new Function("evt", "showDescrip(this.id, false);")); } } } } addOnloadHook(initHoverTables);