MediaWiki:Common.js

From Happy Paws Travel Wiki
Revision as of 07:26, 29 June 2024 by Domi (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.
/* Load Popper.js */
mw.loader.load('https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js');

/* Load Bootstrap JS */
mw.loader.load('https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js');

function initializePlacesButtons() {
    var count = 1;
    document.querySelectorAll('.btn.btn-primary.places-button').forEach(function(button) {
        var uniqueId = 'details-places-' + count;
        var collapseDiv = button.parentElement.nextElementSibling;
        if (collapseDiv) {
            collapseDiv.id = uniqueId;
            button.setAttribute('data-target', '#' + uniqueId);
            button.setAttribute('aria-controls', uniqueId);
            count++;
        } 
    });
}

if (document.readyState !== 'loading') {
    initializePlacesButtons();
} else {
    document.addEventListener('DOMContentLoaded', function () {
        initializePlacesButtons();
    });
}