User:ErrantX/defaultsummaries.js: Difference between revisions

Content deleted Content added
hate js :(
m Maintenance: Replacing addOnloadHook with native jQuery (mw:ResourceLoader/Migration_guide_(users)#addOnloadHook - phab:T130879)
 
(23 intermediate revisions by 2 users not shown)
Line 12:
{
return;
}
 
var insertBeforeThis = document.getElementById("wpSummary").nextSibling;
if(insertBeforeThis.className != "editCheckboxes")
{
{return;
}
 
Line 19 ⟶ 25:
 
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,"Choose a Default Edit Summary");
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,"Choose[[Wikipedia:WikiProject|WikiProject]] a Default Edit Summaryassessment");
}
}
 
var insertBeforeThis = document.getElementById("wpSummary").nextSibling;
var theParent = insertBeforeThis.parentNode;
theParent.insertBefore(dropdown,insertBeforeThis);
theParent.insertBefore(minorDropdown,insertBeforeThis);
theParent.insertBefore(document.createElement("br"),dropdown);
 
Line 65 ⟶ 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 84 ⟶ 104:
}
 
addOnloadHook$(function (){
// 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;
}
// Hide refs
addOnloadHook(function (){
editsummInitialize ();