Content deleted Content added
meh |
try |
||
Line 1:
// The original value of the edit summary field is stored here
var editsummOriginalSummary = new String();
// A global ref to the dropdown with canned edit summaries
var editsummDropdown = null;
function editsummInitialize()
{
// Save the original value of the edit summary field
editsummOriginalSummary = document.forms.editform.wpSummary.value;
// For convenience, add a dropdown box with some canned edit
// summaries to the form.
var dropdown = document.createElement("select");
dropdown.onchange = new Function("editsummOnCannedSummarySelected()");
editsummAddOptionToDropdown(dropdown,"");
editsummAddOptionToDropdown(dropdown,"add categories");
editsummAddOptionToDropdown(dropdown,"add category");
editsummAddOptionToDropdown(dropdown,"add citation");
editsummAddOptionToDropdown(dropdown,"add external link");
editsummAddOptionToDropdown(dropdown,"add internal link");
editsummAddOptionToDropdown(dropdown,"add quotation");
editsummAddOptionToDropdown(dropdown,"add ref");
editsummAddOptionToDropdown(dropdown,"add section");
editsummAddOptionToDropdown(dropdown,"create redirect page");
editsummAddOptionToDropdown(dropdown,"create stub article");
editsummAddOptionToDropdown(dropdown,"delete external link");
editsummAddOptionToDropdown(dropdown,"delete internal link");
editsummAddOptionToDropdown(dropdown,"delete section");
editsummAddOptionToDropdown(dropdown,"fix broken link");
editsummAddOptionToDropdown(dropdown,"fix case");
editsummAddOptionToDropdown(dropdown,"fix grammar");
editsummAddOptionToDropdown(dropdown,"fix punctuation");
editsummAddOptionToDropdown(dropdown,"fix quote marks");
editsummAddOptionToDropdown(dropdown,"fix spelling");
editsummAddOptionToDropdown(dropdown,"indent");
editsummAddOptionToDropdown(dropdown,"make existing text into link (wikify)");
editsummAddOptionToDropdown(dropdown,"make link into plain text (dewikify)");
editsummAddOptionToDropdown(dropdown,"move section");
editsummAddOptionToDropdown(dropdown,"move unrefd material to talk page");
editsummAddOptionToDropdown(dropdown,"new article");
editsummAddOptionToDropdown(dropdown,"remove repetition");
editsummAddOptionToDropdown(dropdown,"reorder links");
editsummAddOptionToDropdown(dropdown,"sectioning");
editsummAddOptionToDropdown(dropdown,"start article");
var insertBeforeThis = document.forms.editform.wpSummary.nextSibling;
var theParent = insertBeforeThis.parentNode;
theParent.insertBefore(dropdown,insertBeforeThis);
// Store a global ref to it
editsummDropdown = dropdown;
}
function editsummAddOptionToDropdown(dropdown,optionText)
{
var option = document.createElement("option");
var optionTextNode = document.createTextNode(optionText);
option.appendChild(optionTextNode);
dropdown.appendChild(option);
}
// There's a cross-browser issue when accessing the selected text:
// *In Firefox you can use: selectObj.value
// *In IE, you have to use: selectObj.options[selectObj.selectedIndex].text
// *The latter method also works in Firefox
function editsummOnCannedSummarySelected()
{
var idx = editsummDropdown.selectedIndex;
var canned = editsummDropdown.options[idx].text;
var newSummary = editsummOriginalSummary;
if (newSummary.length!=0) newSummary += " - ";
newSummary += canned;
document.forms.editform.wpSummary.value = newSummary;
}
// Prefix the edit summary with "SW" or "CP"
// depending on whether it's a SourceWatch or Congresspedia page.
// To determine this, look for a link to "Template:Congresspedia"
// on the edit page.
function editsummAddSubProjectPrefix()
{
// Using the document.links array and the href prop seems to give
// the best cross-browser results.
var allAnchors = document.links;
if (allAnchors)
{
var prefix = "SW: ";
for (i = 0; i < allAnchors.length; i++)
{
var anchorHref = allAnchors[i].href;
if (anchorHref)
{
if (anchorHref.indexOf('Template:Congresspedia') != -1)
{
prefix = "CP: ";
}
}
}
document.forms.editform.wpSummary.value =
prefix + document.forms.editform.wpSummary.value;
}
}
|