Template talk:Inform

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

The second column[edit]

With the parameter col2 the information box is expanded to a table of one row and two columns; the left column contains the information box,
right of it the second column can contain anything else - one or more images with {{F}} or [[File: .. ]], source code, another table.
Depending on the size of the second row, with wid2 the width percentage of it should be specified.

Examples




Upload with prefilled form[edit]

Into your commons.js you may copy from the code

var ns = mw.config.get('wgNamespaceNumber'),
	ul = mw.config.get('wgUserLanguage'),
	pn = mw.config.get('wgPageName'),
	un = mw.config.get('wgUserName'),
	dt = new Date();
	fd = dt.getFullYear()+'-'+String(dt.getMonth()+1).padStart(2,'0')+'-'+String(dt.getDate()).padStart(2,'0');	// formatted date

$.when(mw.loader.using('mediawiki.util'), $.ready).done(function () 
{	"use strict";

//    ..... other utilities 

	// Insert a personalized text-template into the Special:Upload edit box.
	// input form, prefilled for uploading own work on current date, {{PD-self}} 
	if (pn === 'Special:Upload' && /&uselang=([^&]*)ownwork/.test(location.search)) 
	{	setTimeout(function () 
		{	$('#wpUploadDescription').val
			(	'=={{int:filedesc}}==\n\{{Inform\n' +
				'| desc = \n' +			// {{F|F}}
			//	'| dese = \n' +			// {{en|…}}
				'| date = ' + fd + '\n' +	// yyyy-mm-dd
				'| sour = \n' +			// {{own based|…}}
				'| auth = ' + un + '\n' +	// mw.config.get('wgUserName')
				'| imag = \n}}\n'		// igen parms
			//	   vers; fiel; perm; oloc;  (when params are required)
			);
		}, 100);
	} else 
	{ // If not on Special:Upload change the Upload-link.
		$('#n-uploadbtn').find('a').attr('href', '//commons.wikimedia.org/w/index.php?title=Special:Upload&uselang=' +
			((ul === 'en') ? '' : ul) + 'ownwork&uploadformstyle=basic');
	}
    
//    ..... more utilities 

}); // end mw.util

You may customize the code for your special needs.