MediaWiki

Gadget-sandbox.js

From Dogcraft Wiki

(-)
m (minor cleanup)
Line 26: Line 26:
$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('click', function (e) {
$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('click', function (e) {
e.preventDefault();
e.preventDefault();
console.log(e);
console.log(e.target.href);
OO.ui.confirm( 'Are you sure?' ).done( function ( confirmed ) {
OO.ui.confirm( 'Are you sure?' ).done( function ( confirmed ) {
     if ( confirmed ) {
     if ( confirmed ) {
Line 38: Line 36:
     }
     }
});
});
console.log(conf);
return conf;
});
});

Revision as of 00:06, 26 November 2021

$(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();
					OO.ui.confirm( 'Are you sure?' ).done( function ( confirmed ) {
    					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;
    					}
					});
				});
				
			});
		});
		
	}
	
});
This page was last modified on 26 November 2021, at 00:06. (2 years ago)