MediaWiki:Common.js

Revision as of 06:16, 27 June 2024 by Domi (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.
/* Any JavaScript here will be loaded for all users on every page load. */
importScriptURI('https://code.jquery.com/jquery-3.5.1.min.js');
importScriptURI('https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js');
importScriptURI('https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js');

document.addEventListener("DOMContentLoaded", function() {
    let count = 0;
    document.querySelectorAll('.btn.btn-primary.places-button').forEach(button => {
        const uniqueId = 'details-' + Date.now() + '-' + count++;
        const collapseDiv = button.parentElement.nextElementSibling;
        if (collapseDiv) {
            collapseDiv.id = uniqueId;
            button.setAttribute('data-target', '#' + uniqueId);
            button.setAttribute('aria-controls', uniqueId);
        }
    });
});