Jump to content

User:Svick/SectionInput.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Svick (talk | contribs) at 15:25, 23 June 2010 (Created page with '// 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 bec...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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.
// 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.
if (wgAction == 'edit')
{
	var summary = document.getElementById('wpSummary');
	summary.style.width = '74%';
	var section = document.createElement('input');
	section.id = section.name = 'section';
	section.style.width = '23.8%';
	section.style.setProperty('margin-right', '1%', '');
	section.tabIndex = 1;
	summary.parentNode.insertBefore(document.createElement('br'), summary);
	summary.parentNode.insertBefore(section, summary);
	var re = RegExp('/\\*\\s*(.*?)\\s*\\*/\\s*');
	section.value = re.exec(summary.value)[1];
	summary.value = summary.value.replace(re, '');
	summary.form.onsubmit = function(){
		if (section.value)
			summary.value = '/* ' + section.value + ' */ ' + summary.value;
	};
}