Jump to content

MediaWiki:Common.js: Difference between revisions

oh, I need to get the actual <img>, right?
m (sigh, getElementById, not ByID)
(oh, I need to get the actual <img>, right?)
Line 151: Line 151:
function swapImage(gifID, show_gif)
function swapImage(gifID, show_gif)
{
{
     var gif = document.getElementById(gifID);
     var gif_span = document.getElementById(gifID);
    var gif_img = gif_span.getElementsByTagName("img");


     if (!gifID)
     if (!gif_img)
         return false;
         return false;


     if (show_gif)
     if (show_gif)
         gif.src = gif.src.replace('.jpg', '.gif');
         gif_img.src = gif_img.src.replace('.jpg', '.gif');
     else
     else
         gif.src = gif.src.replace('.gif', '.jpg');
         gif_img.src = gif_img.src.replace('.gif', '.jpg');
}
}


Line 165: Line 166:
{
{
     var gifs = document.getElementsByClassName("hovergif");
     var gifs = document.getElementsByClassName("hovergif");
     if (!gifs)
     if (!gifs)
         return false;
         return false;
Line 172: Line 174:
         addHandler(gifs[i], "mouseover", new Function("evt", "swapImage(this.id, true);"));
         addHandler(gifs[i], "mouseover", new Function("evt", "swapImage(this.id, true);"));
         addHandler(gifs[i], "mouseout", new Function("evt", "swapImage(this.id, false);"));
         addHandler(gifs[i], "mouseout", new Function("evt", "swapImage(this.id, false);"));
     }
     }
}
}