User:Iritscen/TestSpace.js

From OniGalore
< User:Iritscen
Revision as of 14:03, 16 November 2012 by Iritscen (talk | contribs) (first try at hovertable script)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Microsoft Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
function showDescrip(typeID, show_or_not)
{
    var DescripPanel = document.getElementByClassName("hovertable_descrip");
    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.getElementsByTagName("td")[0];
            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);