User:ErrantX/defaultsummaries.js

This is an old revision of this page, as edited by ErrantX (talk | contribs) at 20:42, 10 May 2011 (f). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// ============================================================
// Standard edit summaries
// ============================================================
 

function editSummaries() {
	var $box = $('#wpSummary');
        var $label = $box.next();
        alert("here");
	if (!$label.size()) {
		return;
	}
 
	$combo = $('<select />').attr('id', 'stdSummaries').change(function() {
		var val = $(this).val();
		if (val != '') {
			$('#wpSummaryEnhanced,#wpSummary').val(val);
		}
	});
 
	$label.prepend('<br />').prepend($combo).prepend('Summaries: ');
 
	$.ajax({
		'dataType': 'text',
		'data': {
			'title': 'User:ErrantX/template',
			'action': 'raw',
			'ctype': 'text/plain'
		},
		'url': wgScript,
		'success': function(data) {
			var lines = data.split("\n");
			for (var i in lines) {
				var val = (lines[i].indexOf('-- ') == 0) ? lines[i].substring(3) : '';
				var $opt = $('<option />').val(val).text(lines[i]);
				$combo.append($opt);
			}
		}
	});
}

addOnloadHook(editSummaries);