MediaWiki:Common.js

From Happy Paws Travel Wiki
Revision as of 04:10, 29 June 2024 by Domi (talk | contribs)
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.
console.log("Common.js");
/* Load jQuery */
mw.loader.load('https://code.jquery.com/jquery-3.5.1.min.js');

/* 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');
console.log("After loding scripts");


document.addEventListener("DOMContentLoaded", function() {
    console.log("Fix cards");
    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++;
        }
    });
});