User:DannyS712/Scripts writer.js

// $( function {

var ScriptsWriter = {}; window.ScriptsWriter = ScriptsWriter;

// ********** BEGIN UserScript class ******** // Represents a single script that is included in the issue function UserScript( userName, scriptName, linkTarget, descriptionText ) { this.userName = userName; this.scriptName = scriptName; this.linkTarget = linkTarget; this.descriptionText = descriptionText; } UserScript.prototype.getDisplay = function { var $link = $( '' ) .attr( 'href', mw.util.getUrl( this.linkTarget ) ) .attr( 'target', '_blank' ) .text( userName + '\'s ' + scriptName ); var $display = $( ' ' ) .append( $link ) .append( ' ' + this.descriptionText ); return $display; }; UserScript.prototype.getWikitext = function { var link =  + userName + '\'s' + scriptName + ; var wikitext = link + ' ' + this.descriptionText; return wikitext; }; // ********** END UserScript class ********

ScriptsWriter.init = function { window.document.title = 'Scripts writer'; $( '#firstHeading' ).text( 'Scripts writer' ); mw.loader.using(		[			'mediawiki.api',			'mediawiki.util',			'oojs-ui-core',			'oojs-ui-widgets',			'oojs-ui-windows'		],		ScriptsWriter.run	); };

ScriptsWriter.run = function { // TODO fill in Widgets // Featured script var featuredScriptInput = new OO.ui.TextInputWidget( {		value: ''	} ); var featuredScriptLayout = new OO.ui.FieldLayout(		featuredScriptInput,		{ label: 'Featured script' }	);

var submit = new OO.ui.ButtonInputWidget( { 		label: 'Publish',		flags: [			'primary',			'progressive'		]	} ); submit.on( 'click', function {		// CONVERT YOUR WIDGETS TO INPUT		var submittedValues = {};		console.log( submittedValues );		ScriptsWriter.onSubmit( submittedValues );	} ); $( window ).on( 'keypress', function ( e ) {		// press enter to start		if ( e.which == 13 ) {			submit.simulateLabelClick;		}	} ); var fieldSet = new OO.ui.FieldsetLayout( { 		label: 'Scripts writer'	} ); fieldSet.addItems( [		featuredScriptLayout,		new OO.ui.FieldLayout( submit )	] ); var $results = $( ' ' ) .attr( 'id', 'ScriptsWriter-results' ); $( '#mw-content-text' ).empty.append(		fieldSet.$element,		$( ' ' ),		$results	); };

ScriptsWriter.onSubmit = function ( inputs ) { $( '#ScriptsWriter-results' ).empty; console.log( inputs ); }; } );

$( document ).ready( function {	if ( mw.config.get( 'wgNamespaceNumber' ) === -1 ) {		var page = mw.config.get( 'wgCanonicalSpecialPageName' );		if ( page === 'Blankpage' ) {			const page2 = mw.config.get( 'wgTitle' ).split( '/' );			if ( page2[1] && page2[1] === 'ScriptsWriter' ) {				window.ScriptsWriter.init;			}		}	} } );

//