User:ErrantX/defaultsummaries.js: Difference between revisions

Content deleted Content added
test
m Maintenance: Replacing addOnloadHook with native jQuery (mw:ResourceLoader/Migration_guide_(users)#addOnloadHook - phab:T130879)
 
(28 intermediate revisions by 2 users not shown)
Line 8:
{
// Save the original value of the edit summary field
editsummOriginalSummary = document.forms.editform.getElementById("wpSummary.value");
if(editsummOriginalSummary == null)
{
{return;
}
 
var insertBeforeThis = document.forms.editform.getElementById("wpSummary").nextSibling;
if(insertBeforeThis.className != "editCheckboxes")
}{
{return;
}
 
editsummOriginalSummary = editsummOriginalSummary.value
// For convenience, add a dropdown box with some canned edit
// summaries to the form.
 
var dropdown = document.createElement("select");
dropdown.style.width = "38%";
dropdown.style.margin = "0px 4px 0px 0px";
dropdown.onchange = new Function("editsummOnCannedSummarySelected()");
 
var minorDropdown = document.createElement("select");
editsummAddOptionToDropdown(dropdown,"");
minorDropdown.style.width = "38%";
editsummAddOptionToDropdown(dropdown,"add categories");
minorDropdown.onchange = new Function("editsummOnCannedSummarySelected()");
editsummAddOptionToDropdown(dropdown,"add category");
 
editsummAddOptionToDropdown(dropdown,"add citation");
editsummAddCatToDropdown(minorDropdown,"Common minor edit summaries - click to use");
editsummAddOptionToDropdown(dropdown,"add external link");
editsummAddOptionToDropdowneditsummAddCatToDropdown(dropdown,"addCommon internaledit linksummaries - click to use");
editsummAddOptionToDropdown(dropdown,"add quotation");
editsummAddOptionToDropdown(dropdownminorDropdown,"addSpelling/grammar refcorrection");
editsummAddOptionToDropdown(dropdownminorDropdown,"addFixing sectionstyle/layout errors");
editsummAddOptionToDropdown(dropdownminorDropdown,"create[[Help:Reverting|Reverting]] redirect[[Wikipedia:Vandalism|Vandalism]] pageor test edit");
editsummAddOptionToDropdown(dropdownminorDropdown,"create[[Help:Reverting|Reverting]] stubunexplained articlecontent removal");
editsummAddOptionToDropdown(dropdownminorDropdown,"deleteCopyedit external link(minor)");
editsummAddOptionToDropdown(dropdown,"delete internal link");
if (mw.config.get('wgNamespaceNumber') == 0)
editsummAddOptionToDropdown(dropdown,"delete section");
{
editsummAddOptionToDropdown(dropdown,"fix broken link");
editsummAddOptionToDropdown(dropdown,"fixExpanding casearticle");
editsummAddOptionToDropdown(dropdown,"fixAdding/improving grammarreference(s)");
editsummAddOptionToDropdown(dropdown,"fixAdding/removing punctuationcategory/ies");
editsummAddOptionToDropdown(dropdown,"fixAdding/removing quoteexternal markslink(s)");
editsummAddOptionToDropdown(dropdown,"fixAdding/removing spellingwikilink(s)");
editsummAddOptionToDropdown(dropdown,"indentRemoving unsourced content");
editsummAddOptionToDropdown(dropdown,"makeClean existing text into link (wikify)up");
editsummAddOptionToDropdown(dropdown,"make link into plain textCopyedit (dewikifymajor)");
} else
editsummAddOptionToDropdown(dropdown,"move section");
editsummAddOptionToDropdown(dropdown,"move unrefd material to talk page");
editsummAddOptionToDropdown(dropdown,"new articleReply");
editsummAddOptionToDropdown(dropdown,"remove repetitionComment");
if ((mw.config.get('wgNamespaceNumber') % 2 != 0) & (mw.config.get('wgNamespaceNumber') != 3))
editsummAddOptionToDropdown(dropdown,"reorder links");
{
editsummAddOptionToDropdown(dropdown,"sectioning");
editsummAddOptionToDropdown(dropdown,"start[[Wikipedia:WikiProject|WikiProject]] articletagging");
editsummAddOptionToDropdown(dropdown,"[[Wikipedia:WikiProject|WikiProject]] assessment");
alert(document.forms.editform.wpSummary);
}
var insertBeforeThis = document.forms.editform.wpSummary.nextSibling;
}
 
var theParent = insertBeforeThis.parentNode;
theParent.insertBefore(dropdown,insertBeforeThis);
theParent.insertBefore(minorDropdown,insertBeforeThis);
theParent.insertBefore(document.createElement("br"),dropdown);
 
// Store a global ref to it
Line 59 ⟶ 76:
var option = document.createElement("option");
var optionTextNode = document.createTextNode(optionText);
option.appendChild(optionTextNode);
dropdown.appendChild(option);
}
 
function editsummAddCatToDropdown(dropdown,catText)
{
var option = document.createElement("option");
option.disabled = "disabled"
var optionTextNode = document.createTextNode(catText);
option.appendChild(optionTextNode);
dropdown.appendChild(option);
Line 78 ⟶ 104:
}
 
$(function (){
// Prefix the edit summary with "SW" or "CP"
editsummInitialize ();
// 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;
}