MediaWiki

Gadget-sandbox.js

From Dogcraft Wiki

Revision as of 17:00, 27 November 2021 by Domino (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.
$(document).ready(function() {
	
	if (mw.config.get('wgPageName') === 'User:Domino/Sandbox') {
		
		mw.loader.using( ['oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows'] ).done( function () {
			$( function () {
				var button = new OO.ui.ButtonWidget( {
					label: 'Click me!',
					classes: [ 'confirm-sandbox' ]
				});
				//button.on( 'click', function () {
					//alert( 'You clicked the button!' );
					/*OO.ui.alert( 'Something happened!' ).done( function () {
    					console.log( 'User closed the dialog.' );
					});*/
					/*OO.ui.confirm( 'Are you sure?' ).done( function ( confirmed ) {
    					if ( confirmed ) {
        					console.log( 'User clicked "OK"!' );
    					} else {
        					console.log( 'User clicked "Cancel" or closed the dialog.' );
    					}
					});
				});*/
				$( '#mw-content-text' ).append( button.$element );
				
				$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('click', function (e) {
					e.preventDefault();
					console.log('1');
					OO.ui.confirm( 'Are you sure?' ).done( function ( confirmed ) {
    					console.log('2');
    					if ( confirmed ) {
        					console.log( 'User clicked "OK"!' );
        					window.location.href = e.target.href;
        					return true;
    					} else {
        					console.log( 'User clicked "Cancel" or closed the dialog.' );
        					return false;
    					}
					});
					console.log('3');
				});
				
			});
		});
		
	}
	
});
This page was last modified on 27 November 2021, at 17:00. (2 years ago)
Background SRN Opening by Montenator