MediaWiki

Gadget-sandbox.js

From Dogcraft Wiki

m (quick test)
Tag: Reverted
(testing middleclick)
 
(3 intermediate revisions by the same user not shown)
Line 33: Line 33:
$( '#mw-content-text' ).append( button.$element );*/
$( '#mw-content-text' ).append( button.$element );*/
/*$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('click', {clickType: "click"}, confirmDialog);
/*$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('click', {clickType: "click"}, confirmDialog);*/
$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('mouseup', {clickType: "middle"}, confirmDialog);
$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('mouseup', {clickType: "middle"}, false/*confirmDialog*/);
$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('mousedown', function( event ){
//$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('mousedown', false/*function( event ){
if (event.originalEvent.which != 2) return;
if (event.originalEvent.which != 2) return;
event.preventDefault();
event.preventDefault();
});*/
//}*///);
$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('click', {clickType: "click"}, function ( event ) {
return OO.ui.confirm( 'Are you sure?' ).then( function ( confirmed ) {
    if ( confirmed ) {
    return true;
        /*switch(event.data.clickType) {
        case "click":
        window.location.href = event.target.href;
        break;
        case "middle":
        window.open(event.target.href, "_blank");
        break;
        }*/
        }
    });
});

Latest revision as of 00:31, 18 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 ) {
						if (event.data.clickType == "middle")
							if (event.originalEvent.which != 2) return;
							
						event.preventDefault();
					    
						OO.ui.confirm( 'Are you sure?' ).done( function ( confirmed ) {
	    					if ( confirmed ) {
	        					switch(event.data.clickType) {
	        						case "click":
	        							window.location.href = event.target.href;
	        							break;
        							case "middle":
        								window.open(event.target.href, "_blank");
        								break;
	        					}
	        				}
	        					
	    				});
					}
			
			$( function () {
				/*var button = new OO.ui.ButtonWidget( {
					label: 'Click me!',
					classes: [ 'confirm-sandbox' ]
				});
				$( '#mw-content-text' ).append( button.$element );*/
				
				/*$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('click', {clickType: "click"}, confirmDialog);*/
				$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('mouseup', {clickType: "middle"}, false/*confirmDialog*/);
				//$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('mousedown', false/*function( event ){
					if (event.originalEvent.which != 2) return;
					event.preventDefault();
				//}*///);
				
				
			});
		});
		
	}
	
});
Background Valentine's Day Event 2024 by TheWhiteTigerNL