MediaWiki:Gadget-Adiutor-SUM.js

Dans l'article d'aujourd'hui, nous souhaitons aborder le sujet de MediaWiki:Gadget-Adiutor-SUM.js, un sujet qui a eu un grand impact sur la société actuelle. MediaWiki:Gadget-Adiutor-SUM.js est un problème qui touche des personnes de tous âges, sexes et cultures, il est donc important de l'analyser sous différents angles. Tout au long de cet article, nous explorerons les origines de MediaWiki:Gadget-Adiutor-SUM.js, son évolution au fil du temps et son influence sur divers aspects de la vie quotidienne. De plus, nous examinerons des solutions ou des approches possibles pour résoudre efficacement ce problème. Nous espérons que cet article suscitera réflexion et débat parmi nos lecteurs, et fournira des informations précieuses sur MediaWiki:Gadget-Adiutor-SUM.js.
/*
 * Adiutor: Adiutor enables versatile editing options and modules to assist a variety of user actions to enhance the Wikipedia editing experience.
 * Author: Vikipolimer
 * Learn more at: https://meta.wikimedia.orghttps://wikifreehand.com/fr/Adiutor
 * Licensing and Attribution: Licensed under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
 * Module: Edit summaries helper
 */
/* <nowiki> */
// Get essential configuration from MediaWiki
var mwConfig = mw.config.get();
// Create an API instance
var api = new mw.Api();
// Get user options from Adiutor configuration
var wikiId = mw.config.get('wgWikiID');
var adiutorUserOptions = JSON.parse(mw.user.options.get('userjs-adiutor-'+wikiId));
// Select the summary box and summary textarea
var $summaryBox, $summaryTextarea = $('#wpSummary');
// Different summary categories for different types of edits
var summaryCategories = {
    general: ,
    article: ,
    nonArticle: ,
    talkPage: ]', 'Évaluation ]']
};
// Assuming adiutorUserOptions.myCustomSummaries is an array of custom summaries
summaryCategories.general = summaryCategories.general.concat(adiutorUserOptions.myCustomSummaries);
// Function to add options to a dropdown menu
function addOptionsToDropdown(dropdown, optionTexts) {
	optionTexts.forEach(function(optionText) {
		dropdown.menu.addItems([new OO.ui.MenuOptionWidget({
			label: optionText
		})]);
	});
}
// Function to handle selection of a summary option
function onSummarySelect(option) {
	var originalSummary = $summaryTextarea.val(),
		cannedSummary = option.getLabel(),
		newSummary = originalSummary;
	if(newSummary.length !== 0 && newSummary.charAt(newSummary.length - 1) !== ' ') {
		newSummary += ' ';
	}
	newSummary += cannedSummary;
	$summaryTextarea.val(newSummary).trigger('change');
}
// Function to insert summary options into the editing interface
function insertSummaryOptions($insertBeforeElement) {
	var namespace = mw.config.get('wgNamespaceNumber'),
		$optionsContainer = $('<div>').css('display', 'flex');
	// Dropdown for article-related edits
	var dropdown = new OO.ui.DropdownWidget({
		label: mw.msg('namespace-edit-summaries')
	});
	dropdown.menu.on('select', onSummarySelect);
	addOptionsToDropdown(dropdown, namespace === 0 ? summaryCategories.article : summaryCategories.nonArticle);
	$optionsContainer.append(dropdown.$element);
	// Dropdown for general edits
	var generalDropdown = new OO.ui.DropdownWidget({
		label: mw.msg('common-edit-summaries')
	});
	generalDropdown.menu.on('select', onSummarySelect);
	addOptionsToDropdown(generalDropdown, summaryCategories.general);
	$optionsContainer.append(generalDropdown.$element);
	// Dropdown for talk page edits (if applicable)
	if(namespace !== 0 && (namespace % 2 !== 0 && namespace !== 3)) {
		var talkDropdown = new OO.ui.DropdownWidget({
			label: mw.msg('common-discussion-edit-summaries')
		});
		talkDropdown.menu.on('select', onSummarySelect);
		addOptionsToDropdown(talkDropdown, summaryCategories.talkPage);
		$optionsContainer.append(talkDropdown.$element);
	}
	$optionsContainer.css('margin-bottom', '10px'); // Add bottom margin
	$insertBeforeElement.before($optionsContainer);
}
// Hook into the save dialog state change event
mw.hook('ve.saveDialog.stateChanged').add(function() {
	var target, $saveOptions;
	if($('body').data('wppresent')) {
		return;
	}
	$('body').data('wppresent', 'true');
	target = ve.init.target;
	$saveOptions = target.saveDialog.$saveOptions;
	$summaryTextarea = target.saveDialog.editSummaryInput.$input;
	if(!$saveOptions.length) {
		return;
	}
	insertSummaryOptions($saveOptions);
});
// Wait for necessary libraries to load before adding options
$.when(mw.loader.using('oojs-ui-core'), $.ready).then(function() {
	var $editCheckboxes = $('.editCheckboxes');
	if(!$editCheckboxes.length) {
		return;
	}
	insertSummaryOptions($editCheckboxes, '50%');
});
/* </nowiki> */