User:Najzere/spoilerimage.js

From StrategyWiki, the video game walkthrough and strategy guide wiki
Revision as of 23:15, 6 July 2012 by Najzere (talk | contribs) (crazy)

Note: After publishing, 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)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
$(document).ready(function() {
  $('span.spoilerimage img').each( function() {
alert($(this).attr('width'));
    var spWidth=(parseFloat($(this).attr('width').substring(0,$(this).attr('width').length-2))/2)-25;
    var spHeight=(parseFloat($(this).attr('height').substring(0,$(this).attr('height').length-2))/2)-6;
    var hiddensrc=$(this).attr('src');
    var spoilersrc='http://cdn.wikimg.net/strategywiki/images/b/be/Yellow-background-24x24.png';
    $(this).attr('src',spoilersrc);
    var $spoilerImage=$('<img src="http://cdn.wikimg.net/strategywiki/images/6/60/NajzereTestSpoilerImage.png"></img>');
    $(this).parent().prepend($spoilerImage);
    $(this).parent().css({
      position: 'relative',
      top: 0,
      left: 0
    });
    $spoilerImage.css({
      position: 'absolute',
      left: 75,
      top: 0
    });
    $(this).attr({
      onMouseOver: "$(this).attr('src','"+hiddensrc+"');",
      onMouseOut: "$(this).attr('src','"+spoilersrc+"');"
    });
  });
});