//<pre><nowiki>
function createMessage(section) {
var edit = document.getElementById('wpTextBox1');
var replyToPos = document.URL.lastIndexOf('replyto=');
edit.value += '{{msg start|id=' + wgArticleId;
if (replyToPos != -1)
edit.value += '|' + document.URL.slice(replyToPos);
edit.value += '}}\n';
edit.value += '<!--Insert message here-->\n';
edit.value += '{{msg end|signature=~~~~|username='
+ wgUserName + '|section=' + section + '}}';
}
addOnloadHook(function() {
var addSection = document.getElementById('ca-addsection');
var section = document.getElementsByName('wpSection')[0];
if (addSection) {
var sections = document.getElementsByTagName('h2').length + 1;
addSection.firstChild.href =
wgServer + wgScriptPath + '/index.php?title=' + wgPageName +
'&action=edit§ionnum=' + sections;
} else if (section.value != "") {
createMessage(section);
} else if (section.value == "") {
var url = document.URL;
var sectionNum =
url.slice(parseInt(url.indexOf("sectionnum=")) + 11);
if (isFinite(sectionNum)) {
var sectionName = prompt("Enter new section name", "");
if (sectionName != null && sectionName != "")
createMessage(sectionNum);
}
}
});
//</nowiki></pre>