User:Prtksxna/block.js

// 1. Find your common.js //       https://mediawiki.org/wiki/Special:MyPage/common.js

// 2. Add the following code to it: //       mw.loader.load('/w/index.php?title=User:Prtksxna/block.js&action=raw&ctype=text/javascript', 'text/javascript'); //       mw.loader.load('/w/index.php?title=User:Prtksxna/block.css&action=raw&ctype=text/css', 'text/css');

// 3. Go to Special:BlankPage (that is where we'll load the form) //       https://www.mediawiki.org/wiki/Special:BlankPage

// 4. ???

// 5. PROFIT!

mw.loader.using( 	[		'oojs', 		'oojs-ui-core', 		'oojs-ui-widgets', 		'mediawiki.widgets.UserInputWidget',		'mediawiki.widgets.SelectWithInputWidget',		'mediawiki.widgets.expiry'	],	function {		if ( window.location.pathname === "/wiki/Special:BlankPage") {			updateTitle;			makeForm;		}	} );

function updateTitle { $('#firstHeading').text( 'Block user' ); }

function makeForm { var $c = $('#mw-content-text'); $c.empty; $c.append( 'This is a test, it is not the real block page.  '); var user = new mw.widgets.UserInputWidget({		required: true	}); var create = new OO.ui.ButtonWidget( {		label: 'Create block',		flags: [		'primary',		'progressive'		]	} ); var reason = new mw.widgets.SelectWithInputWidget( {    	or: true,    	dropdowninput: {    	options: [	        { data: 'other', label: 'Other' },        	{ data: 'a', label: 'Inserting false information' },        	{ data: 'b', label: 'Removing content from pages' },        	{ data: 'c', label: 'Spammings links to external sites' },        	{ data: 'c', label: 'Inserting nonsense/gibberish into pages' },        	{ data: 'c', label: 'Intimidating behavior/harassment' },        	{ data: 'c', label: 'Abusing multiple accounts' },        	{ data: 'c', label: 'Unacceptable username' }    	]    	},    	textinput: {    	}	} ); var expiry = new mw.widgets.ExpiryWidget({		noDatePicker: false,		RelativeInputClass: mw.widgets.SelectWithInputWidget,		relativeInput: {			or: true,			dropdowninput: {				options: [					{ data: 'c', label: '2 hours' },					{ data: 'c', label: '1 day' },					{ data: 'c', label: '3 days' },					{ data: 'c', label: '1 week' },					{ data: 'c', label: '2 weeks' },					{ data: 'c', label: '1 month' },					{ data: 'c', label: '3 months' },					{ data: 'c', label: '6 months' },					{ data: 'c', label: '1 year' },					{ data: 'c', label: 'Indefinite' },					{ data: 'other', label: 'Other time:' }				]			},			textinput: {}		}	}); $c.append( 		$(' ').text('Username or IP address').addClass( 'block' ).addClass( 'bold' ),		user.$element,		$(' ').text('Actions to block:').addClass( 'block' ).addClass( 'bold' ),		check( 'Editing' ),		check( 'Sitewide', true, 'shift' ),		check( 'Partial', true, 'shift' ),		multi( 'Pages', [], 'shift2' ),		multi( 'Namespaces', [], 'shift2' ),		check( 'Uploading files', false, 'shift2' ),		check( 'Moving pages', false, 'shift2' ),		check( 'Account creation' ),		check( 'Sending email' ),		check( 'Editing their own talk page' ),		$(' ').text('Expiration:').addClass( 'block' ).addClass( 'bold' ),		expiry.$element,		$(' ').text('Reason:').addClass( 'block' ).addClass( 'bold' ),		reason.$element,		$(' ').text('Additional options:').addClass( 'block' ).addClass( 'bold' ),		check('Automatically block the last IP address used by this user, and any subsequent IP addresses they try to edit from'), check('Watch this user‘s user and talk pages'), ' ',		create.$element ); }

function wrap( $element, className ) { return $( ' ' ).addClass( className ).append( $element ); }

function check( label, radio, className ) { var el; if ( radio ) { el = new OO.ui.RadioInputWidget; } else { el = new OO.ui.CheckboxInputWidget; }	var label = $( ' ' ).text( label ); return wrap( [ el.$element, label ], className ); }

function multi( label, options, className ) { var el = new OO.ui.TagMultiselectWidget( {		placeholder: '',		allowArbitrary: true	} ) var label = $( ' ' ).text( label ); return wrap( [ label, el.$element ], className ); }