User:Banana555A/common.js

importScript('User:Anchorvale/scripts/Sandbox2.js'); var myUserName = Banana555A

importScript( 'User:Equazcion/ScriptInstaller.js' ); // Backlink: User:Equazcion/ScriptInstaller.js

importScript( 'User:Enterprisey/CustomSummaryPresets.js' ); // Backlink: User:Enterprisey/CustomSummaryPresets.js

var editsummOriginalSummary = "";

function editsummAddOptionToDropdown(dropdown, optionText) { 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 = true; option.selected = true; var optionTextNode = document.createTextNode(catText); option.appendChild(optionTextNode); dropdown.appendChild(option); }

// Save the original value of the edit summary field function editsummOnCannedSummarySelected { editsummOriginalSummary = document.getElementById("wpSummary"); if (editsummOriginalSummary) { editsummOriginalSummary = editsummOriginalSummary.value; } else { editsummOriginalSummary = ""; }   var idx = this.selectedIndex; var canned = this.options[idx].text; var newSummary = editsummOriginalSummary;

// Append old edit summary with space, if exists, // and last character != space if (newSummary.length !== 0 && newSummary.charAt(newSummary.length - 1) !== " ") { newSummary += " "; }   newSummary += canned; document.getElementById("wpSummary").value = newSummary; }

// Loop through siblings, looking for editCheckboxes class $(function {    var insertBeforeThis = document.getElementById("wpSummary");    while (insertBeforeThis) {        if (insertBeforeThis.className === "editCheckboxes") {            break;        }        insertBeforeThis = insertBeforeThis.nextSibling;    }

// If we failed to find the editCheckboxes class, or insertBeforeThis is null if (!insertBeforeThis || 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 = "50%"; dropdown.style.margin = "0 4px 0 0"; dropdown.onchange = editsummOnCannedSummarySelected; editsummAddCatToDropdown(dropdown, "Summary presets");

for (var i=0; i<customSummaries.length; i++) { if (typeof customSummaries[i] !== 'undefined') { editsummAddOptionToDropdown(dropdown, customSummaries[i]); }   }

var theParent = insertBeforeThis.parentNode; theParent.insertBefore(dropdown, insertBeforeThis); theParent.insertBefore(document.createElement("br"), dropdown); });