Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Gadget-Confetti.js

MediaWiki interface page

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.
/* A Test for commands, from Star citzen tools */

// console.log( '[Gadget-Confetti] Gadget loaded' );
function confettiFromPageSide() {
	confetti({
		particleCount: 100,
		angle: 60,
		spread: 55,
		origin: { x: 0 },
	});
	confetti({
		particleCount: 100,
		angle: 120,
		spread: 55,
		origin: { x: 1 },
	});
}

const confettiCommand = {
	id: 'confetti',
	triggers: [ '/confetti', '🎉', '🎊', '🥳' ],
	label: 'Confetti',
	description: 'Because why not?',
	onCommandSelect( item ) {
		confettiFromPageSide();
		// Close the palette after execution
		return { action: 'close' };
	}
};

// Confetti code is in the ext.gadget.Confetti module
mw.loader.using('ext.gadget.Confetti', () => {
	// Celebrate after edit
	mw.hook('postEdit').add( () => {
		confettiFromPageSide();
	} );

	// Add to Command Palette
	mw.loader.using( 'skins.citizen.commandPalette' ).then( () => {
		mw.hook( 'skins.citizen.commandPalette.registerCommand' ).add( ( registrationData ) => {
			if ( registrationData && registrationData.registerCommand ) {
				registrationData.registerCommand( confettiCommand );
			}
		} );
	} );
} );
🍪 Yum Yum Yum! Cookies help us better deliver our services. By using our site, you agree to our use of cookies.