MediaWiki

Gadget-sandbox.js

From Dogcraft Wiki

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 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();
				//}*///);
				
				
			});
		});
		
	}
	
});