User:Equazcion/NewSectionSummary.js

if ( $('input[name="wpSection"][value="new"]').length > 0) {

preSum = $('#wpSummary').attr('value');

$('#wpSummary').attr('value','').attr('name','wpSectionTitle');

var summary = '

'Edit summary (Briefly describe the changes you have made)' +

'

'title="Enter a short summary [alt-shift-b]" spellcheck="true" size="60" tabindex="1" maxlength="255">';

$('.editOptions').prepend(summary);

preSumReg = /\/\* (.*?) \*\/ (.*)/;

var preSumRaw = preSumReg.exec(preSum);

if (preSumRaw != null){

$('[name="wpSectionTitle"]').attr('value', preSumRaw[1]);

if (preSumRaw[2] == ''){

$('[name="wpSummary"]').attr('value', 'new section');

} else {

$('[name="wpSummary"]').attr('value', preSumRaw[2]);

}

//$('.mw-content-ltr h2:first').html(preSumRaw[1]);

}

var rawTitle = $('.mw-headline:first').html();

var titleReg = /\/\* (.*?) \*\//;

var fixedTitle = titleReg.exec(rawTitle);

if (fixedTitle != null) $('.mw-headline:first').html(fixedTitle[1]);

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

var title = $('[name="wpSectionTitle"]').attr('value');

var summary = ($('[name="wpSummary"]').attr('value') == '') ? 'new section': $('[name="wpSummary"]').attr('value');

$('[name="wpSummary"]').attr('value', '/* ' + title + ' */ ' + summary);

});

}