MediaWiki

Gadget-sandbox.js

From Dogcraft Wiki

m (redoing what i already had working with fewer lines)
m (?)
Line 5: Line 5:
mw.loader.using( ['oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows'] ).done( function () {
mw.loader.using( ['oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows'] ).done( function () {
function confirmDialoge(event) {
function confirmDialog( event ) {
event.preventDefault();
event.preventDefault();
OO.ui.confirm( 'Are you sure?' ).done( function ( confirmed ) {
OO.ui.confirm( 'Are you sure?' ).done( function ( confirmed ) {
Line 34: Line 34:
$( '#mw-content-text' ).append( button.$element );
$( '#mw-content-text' ).append( button.$element );
$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('click', confirmDialoge(e));
$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('click', confirmDialog);
/*function (e) {
/*function (e) {
e.preventDefault();
e.preventDefault();

Revision as of 22:05, 2 December 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 confirmDialog( event ) {
						event.preventDefault();
						OO.ui.confirm( 'Are you sure?' ).done( function ( confirmed ) {
	    					if ( confirmed ) {
	        					window.location.href = event.target.href;
	    					}
						});
					}
			
			$( 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', confirmDialog);
				/*function (e) {
					e.preventDefault();
					console.log('1');
					var result = confirmDialoge();
					console.log('3');
					return result;
				});*/
				
			});
		});
		
	}
	
});
This page was last modified on 2 December 2021, at 22:05. (2 years ago)