User:Sur/common.js

Revision as of 18:29, 22 September 2024 by Sur (talk | contribs)

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.addEventListener('DOMContentLoaded', function() {
    const infoboxes = document.querySelectorAll('.stat-infobox');

    infoboxes.forEach(function(infobox) {
        const hoverBox = infobox.querySelector('.stat-infobox-hover');
        const table = hoverBox.querySelector('.stat-infobox-table');

        // On hover, adjust the height of the stat-infobox to match the hover box
        infobox.addEventListener('mouseenter', function() {
            const hoverHeight = hoverBox.offsetHeight;
            infobox.style.height = hoverHeight + 'px';
        });

        // Reset height when hover ends
        infobox.addEventListener('mouseleave', function() {
            infobox.style.height = 'auto';
        });
    });
});