MediaWiki:Gadget-spawncalc-boot.js

From Pixelrus
Revision as of 06:58, 17 June 2026 by NewAdmin (talk | contribs) (Create MediaWiki:Gadget-spawncalc-boot.js)
(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.
/*
 * Spawn-chance calculator bootstrap (loads on every page, tiny).
 * This Gadgets version can't scope a gadget to a page/category, so this minimal
 * loader ships sitewide and pulls the heavier data + UI module
 * (ext.gadget.spawncalc-app) only on pages that contain the
 * <div id="spawn-calculator"> mount point (the species pages).
 */
( function () {
	'use strict';
	function go() {
		if ( !document.getElementById( 'spawn-calculator' ) ) { return; }
		mw.loader.using( [ 'ext.gadget.spawncalc-app' ] ).catch( function () {
			var n = document.getElementById( 'spawn-calculator' );
			if ( n ) { n.textContent = 'Spawn calculator failed to load.'; }
		} );
	}
	if ( document.readyState !== 'loading' ) { go(); }
	else { document.addEventListener( 'DOMContentLoaded', go ); }
}() );