MediaWiki:Common.js
From Stat DS Computing Wiki
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)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
// Load Bootstrap Icons CSS (site-wide)
(function () {
if (document.getElementById('bi-cdn-link')) return;
var link = document.createElement('link');
link.id = 'bi-cdn-link';
link.rel = 'stylesheet';
link.href = 'https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css';
document.head.appendChild(link);
})();
// ACCESS On-Ramps embed via ES module, mounted when placeholder div is present
(function () {
function mountOnRamps() {
var target = document.getElementById('resource-catalog-react');
if (!target) return; // Only act on pages that have the placeholder
// Build a <script type="module"> that mirrors ACCESS instructions
var script = document.createElement('script');
script.type = 'module';
script.textContent = `
const baseUrl = "https://esm.sh/@xras/ui@onramps_v1/dist";
import {
onRampsResourceCatalog,
shadowTarget,
} from "https://esm.sh/@xras/ui@onramps_v1/dist/xras-ui.js";
onRampsResourceCatalog({
target: shadowTarget(
document.getElementById("resource-catalog-react"),
{ accessStyles: true, baseUrl }
),
onRamps: true,
baseUrl
});
`;
document.body.appendChild(script);
}
// Run after the page is ready (and after MediaWiki’s JS pipelines)
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', mountOnRamps);
} else {
mountOnRamps();
}
})();