_ _    _ _____  ___   __                       
 __      _(_) | _(_)___ / ( _ ) / /_   ___ ___  _ __ ___  
 \ \ /\ / / | |/ / | |_ \ / _ \| '_ \ / __/ _ \| '_ ` _ \ 
  \ V  V /| |   <| |___) | (_) | (_) | (_| (_) | | | | | |
   \_/\_/ |_|_|\_\_|____/ \___/ \___(_)___\___/|_| |_| |_|

User:Siddhartha Ghai/MTC.js

In this article, we will explore the fascinating world of User:Siddhartha Ghai/MTC.js and all the implications this topic has on our society. User:Siddhartha Ghai/MTC.js is a topic that has captured the attention of experts and fans alike, generating passionate debates and sparking growing interest in its many facets. Throughout these pages, we will delve into the history, impact and possible future implications of User:Siddhartha Ghai/MTC.js, analyzing every detail and offering a comprehensive vision of this topic that is so relevant today. From its origins to its most recent applications, this article dives into a comprehensive analysis of User:Siddhartha Ghai/MTC.js with the goal of providing the reader with a deep and enriching understanding of this exciting topic.
// <nowiki>
var mtc = {};

mtc.callback = function callback() {
	var dialog;
	mtc.dialog = new SimpleWindow(550, 355 );
	dialog = mtc.dialog;
	dialog.setTitle( 'Create International Membership Templates' );
	dialog.setScriptName( 'MTC' );
	dialog.addFooterLink( 'Project page', 'Wikipedia:International membership templates' );
	dialog.addFooterLink( 'MTC help', 'User:Siddhartha Ghai/MTC' );

	var form = new QuickForm( mtc.evaluate);
	form.append({
		type: 'input',
		name: 'cname',
		label: 'Name of the country',
		value: ''
	});
	form.append({
		type: 'input',
		name: 'clink',
		label: 'Display name of the country, if different from the name (optional)',
		value: ''
	});
	form.append({
		type: 'input',
		name: 'sdate',
		label: 'Start date of the country(yyyy-mm-dd)',
		value: ''
	});
	form.append({
		type: 'input',
		name: 'edate',
		label: 'End date of the country(yyyy-mm-dd)',
		value: ''
	});
	form.append({
		type: 'checkbox',
		name: 'orgs',
		list: mtc.orglist
	});
	form.append( { type:'submit' } );
	var result = form.render();
	dialog.setContent( result );
	dialog.display();
};

mtc.orglist = [
	{label:'African union', value:'AU', name:'AU', 
		subgroup: {type: 'input', label: 'Enter the joining date', name: 'sdate', value: ''}
	},
	{label:'Arab League', value:'AL', name:'AL', 
		subgroup: {type: 'input', label: 'Enter the joining date', name: 'sdate', value: ''}
	},
	{label:'Commonwealth of Nations', value:'CON', name:'CON', 
		subgroup: {type: 'input', label: 'Enter the joining date', name: 'sdate', value: ''}
	},
	{label:'East African Community', value:'EAC', name:'EAC', 
		subgroup: {type: 'input', label: 'Enter the joining date', name: 'sdate', value: ''}
	},
	{label:'European Union', value:'EU', name:'EU', 
		subgroup: {type: 'input', label: 'Enter the joining date', name: 'sdate', value: ''}
	},
	{label:'Interpol', value:'IP', name:'IP', 
		subgroup: {type: 'input', label: 'Enter the joining date', name: 'sdate', value: ''}
	},
	{label:'North American Treaty Organisation', value:'NATO', name:'NATO', 
		subgroup: {type: 'input', label: 'Enter the joining date', name: 'sdate', value: ''}
	},
	{label:'Organisation of Islamic Cooperation', value:'OIC', name:'OIC', 
		subgroup: {type: 'input', label: 'Enter the joining date', name: 'sdate', value: ''}
	},
	{label:'Organisation of Petroleum Exporting Countries', value:'OPEC', name:'OPEC', 
		subgroup: {type: 'input', label: 'Enter the joining date', name: 'sdate', value: ''}
	},
	{label:'United Nations', value:'UN', name:'UN', 
		subgroup: {type: 'input', label: 'Enter the joining date', name: 'sdate', value: ''}
	},
	{label:'World Trade Organisation', value:'WTO', name:'WTO', 
		subgroup: {type: 'input', label: 'Enter the joining date', name: 'sdate', value: ''}
	}
];

mtc.create = function create(pageobj) {
	var statelem = pageobj.getStatusElement();
	var i, pname, pdate;

/*	if (pageobj.exists()) {
		statelem.error( 'The template already exists! Please edit it manually.' );
		return;
	}
*/	
	var params = pageobj.getCallbackParameters();
	var code = '<noinclude>{{Membership/Sub/Head}}</noinclude>\n{{Membership/Sub/T\n';
	code+= '|start=' + params.sdate + '\n';
	if(params.edate.value!=='') {
	code+= '|end=' + params.edate + '\n';
	}
	code+= '|CountryNamesup={{{CountryCodesup|}}}\n' + '|year={{{year|{{CURRENTYEAR}}}}}\n|month={{{month|{{CURRENTMONTH2}}}}}\n' + '|day={{{day|{{CURRENTDAY}}}}}\n|Datesup={{{Datesup|}}}\n';
//	alert(code);
	for (i in params.tags) {
//		alert(i);
//		if (params.tags.date !== '') {
			pname = params.tags.value;
//			ptext = params.value + 'sdate';
			pdate = params.tags.sdate;
//			alert(pdate);
			if (params.tags.checked) {
				if (pdate === '') {
					code+= '|' + pname + 'org={{{' + pname + 'org|}}}';
				}
				else {
					code+= '|' + pname + 'org={{{' + pname + 'org|' + pname + '}}}';
				}
			}
			else {
				code+= '|' + pname + 'org={{{' + pname + 'org|}}}';
			}
			code+= '|' + pname + 'sup={{{' + pname + 'sup|}}}|' + pname + '={{{' + pname + '|Show}}}';
			if (params.tags.checked && pdate!== '') {
				code+= '|' + pname + 'membership={{{' + pname + 'membership|' + pdate + '}}}';
			}
			code+= '\n';
//		}
	}
	code+= '|CountryName=' + params.cname + '\n';
	code+= '}}';
	pageobj.setPageText(code);
//	alert(code);
	pageobj.setEditSummary('Creating template using MTC');
	pageobj.setCreateOption('recreate');
	pageobj.save();
};

mtc.evaluate = function evaluate(e) {
	var i;
	var params = {
		sdate: e.target.sdate.value,
		edate: e.target.edate.value,
		cname: e.target.cname.value,
		clink: e.target.clink.value
	};
	
	params.tags = {
		AU: e.target.AU,
		AL: e.target.AL,
		CON: e.target.CON,
		EAC: e.target.EAC,
		EU: e.target.EU,
		IP: e.target.IP,
		NATO: e.target.NATO,
		OIC: e.target.OIC,
		OPEC: e.target.OPEC,
		UN: e.target.UN,
		WTO: e.target.WTO
	};
	for (i in params.tags) {
		if (i.match(/sdate/) === null ) {
			var sdid = params.tags.value + '.sdate';
			if (e.target !== undefined) {
				params.tags.sdate = e.target.value;
			}
			else {
				params.tags.sdate = '';
			}
		}
	}
	
//	params.orgs = $.extend(true, {}, e.target.orgs);
	
	var pname = 'User:Siddhartha Ghai/Sandbox' /*'Template:Membership/test' + params.cname*/;

	SimpleWindow.setButtonsEnabled( false );
	Status.init( e.target );

	Wikipedia.actionCompleted.redirect = pname;
	Wikipedia.actionCompleted.notice = 'Template created';
	var wikipedia_page = new Wikipedia.page(pname);
	wikipedia_page.setCallbackParameters(params);
	wikipedia_page.load(mtc.create);
};

mw.loader.using( , function(){
	mw.loader.load('//en.wikipedia.org/w/index.php?title=Mediawiki:Gadget-morebits.js&action=raw&ctype=text/javascript');
	mw.loader.load('//en.wikipedia.org/w/index.php?title=Mediawiki:Gadget-morebits.css&action=raw&ctype=text/css', 'text/css');
	$(document).ready(mw.util.addPortletLink( 'p-variants', 'javascript:mtc.callback()', 'MTC', 'ca-mtc-main', 'Try this!' ));
});
// </nowiki>