User:Iritscen/TestSpace.js: Difference between revisions

From OniGalore
Jump to navigation Jump to search
m (syntax)
m (syntax)
Line 1: Line 1:
function showDescrip(typeID, show_or_not)
function showDescrip(typeID, show_or_not)
{
{
     var DescripPanel = document.getElementsByClassName("hovertable_descrip");
     var DescripPanel = document.getElementsByClassName("hovertable_descrip")[0];
     var Descrip = DescripPanel.getElementById(typeID);
     var Descrip = DescripPanel.getElementById(typeID);



Revision as of 14:16, 16 November 2012

function showDescrip(typeID, show_or_not)
{
    var DescripPanel = document.getElementsByClassName("hovertable_descrip")[0];
    var Descrip = DescripPanel.getElementById(typeID);

    if (!DescripPanel || !Descrip)
        return false;

    if (show_or_not)
        Descrip.style.display = "block";
    else
        Descrip.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], "hovertable_descrip")) continue;
            addHandler(Cells[j],  "mouseover", new Function("evt", "showDescrip(" + this.id + ", true);"));
            addHandler(Cells[j],  "mouseout", new Function("evt", "showDescrip(" + this.id + ", false);"));
        }
    }
}

addOnloadHook(initHoverTables);