मिडियाविकी:Gadget-DefaultSummaries.js

नोंद: साठवून ठेवल्यानंतर बदल पहाण्यासाठी कदाचित तुमच्या ब्राऊजरच्या कॅचेला बायपास करावे लागेल.

  • फ़ायरफ़ॉक्स / सफ़ारी: धरुन ठेवा Shift टिचकी मारताना Reload, किंवा हे दाबताना Ctrl-F5 किंवा Ctrl-R (⌘-R मॅकवर)
  • गुगल क्रोम: दाबा Ctrl-Shift-R (⌘-Shift-R मॅकसाठी)
  • ओपेरा: कडे जा Menu → Settings (ओपेरा → पसंतीक्रम on a Mac) आणि मग गोपनियता आणि सुरक्षा → ब्राउजिंग डाटा काढून टाका → कॅचे छायाचित्रे आणि धारिणी.
/*  _____________________________________________________________________________
 * |                                                                             |
 * |                    === WARNING: GLOBAL GADGET FILE ===                      |
 * |                  Changes to this page affect many users.                    |
 * | Please discuss changes on the talk page or on [[WT:Gadget]] before editing. |
 * |_____________________________________________________________________________|
 *
 * First import as of 09/06/2011 from [[User:ErrantX/defaultsummaries.js]]
 * Edited version from [[User:MC10/defaultsummaries.js]]
 * Implements default edit summary dropdown boxes
 */

(function ($) { // Wrap with anonymous function
	// The original value of the edit summary field is stored here
	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);
	}

	function editsummOnCannedSummarySelected() {
		// Save the original value of the edit summary field
		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;
	}

	$(function () {
		var insertBeforeThis = document.getElementById("wpSummary");

		// Loop through siblings, looking for editCheckboxes class
		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 = "39.5%";
		dropdown.style.margin = "0 1% 0 5.00em";
		dropdown.onchange = editsummOnCannedSummarySelected;

		var minorDropdown = document.createElement("select");
		minorDropdown.style.width = "39.5%";
		minorDropdown.onchange = editsummOnCannedSummarySelected;

		editsummAddCatToDropdown(minorDropdown, "Common minor edit summaries – click to use");
		editsummAddCatToDropdown(dropdown, "Common edit summaries – click to use");

		editsummAddOptionToDropdown(minorDropdown, "Spelling/grammar correction;");
		editsummAddOptionToDropdown(minorDropdown, "Fixing style/layout errors;");
		editsummAddOptionToDropdown(minorDropdown, "[[w:Help:Reverting|Reverting]] [[w:Wikipedia:Vandalism|vandalism]] or test edit;");
		editsummAddOptionToDropdown(minorDropdown, "[[w:Help:Reverting|Reverting]] unexplained content removal;");
		editsummAddOptionToDropdown(minorDropdown, "Copyedit (minor);");

		if (mw.config.get('wgNamespaceNumber') === 0) {
			editsummAddOptionToDropdown(dropdown, "Adding/improving content;");
			editsummAddOptionToDropdown(dropdown, "Adding/removing category/ies;");
			editsummAddOptionToDropdown(dropdown, "Adding/removing external link(s);");
			editsummAddOptionToDropdown(dropdown, "Adding/removing sisterlink(s);");
			editsummAddOptionToDropdown(dropdown, "Removing unsourced content;");
			editsummAddOptionToDropdown(dropdown, "Removing [[w:WP:SPAM|linkspam]] per [[w:WP:EL]];");
			editsummAddOptionToDropdown(dropdown, "Clean up;");
			editsummAddOptionToDropdown(dropdown, "Copyedit (major);");
		} else {
			editsummAddOptionToDropdown(dropdown, "Reply;");
			editsummAddOptionToDropdown(dropdown, "Comment;");
			editsummAddOptionToDropdown(dropdown, "Suggestion;");
			if ((mw.config.get('wgNamespaceNumber') % 2 !== 0) & (mw.config.get('wgNamespaceNumber') !== 3)) {
				editsummAddOptionToDropdown(dropdown, "[[w:Wikipedia:WikiProject|WikiProject]] tagging;");
				editsummAddOptionToDropdown(dropdown, "[[w:Wikipedia:WikiProject|WikiProject]] assessment;");
			}
		}

		var theParent = insertBeforeThis.parentNode;
		theParent.insertBefore(dropdown, insertBeforeThis);
		theParent.insertBefore(minorDropdown, insertBeforeThis);
		theParent.insertBefore(document.createElement("br"), dropdown);
	});
}(jQuery)); // End wrap with anonymous function