User:Jcgoble3/SectionInput.js

// Copied from User:Svick/SectionInput.js

// Updated to jQuery and modified to play nice with wikEd, and still work without it

// This script creates new text box for the name of the edited section.

// This way, the browser's autocomplete for edit summary doesn't contain section name and becomes much more useful.

// Tested in Firefox.

$(function() {

if (mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit') {

var summary = $('#wpSummary');

var sectionid = $('#editform input[name="wpSection"]');

if (sectionid.length && sectionid.val() === 'new') {

return;

}

summary.css('width', '74%');

summary.css('display', 'inline');

var section = $('');

section.attr('id', 'section');

section.attr('name', 'section');

section.css('width', '23.7%');

section.css('margin-right', '1%');

section.attr('tabIndex', '1');

// fix to work in wikEd

var wikEdSummary = $('.wikEdSummaryComboInput');

var anchor = wikEdSummary.length ? wikEdSummary : summary;

anchor.before($('
'));

anchor.before(section);

var re = /\/\*\s*(.*?)\s*\*\/\s*/;

var match = re.exec(summary.val());

if (match) {

section.val(match[1]);

}

summary.val(summary.val().replace(re, ''));

$('#editform').submit(function() {

if (section.val()) {

summary.val('/* ' + section.val() + ' */ ' + summary.val());

}

});

}

});