/* MediaWiki:Gadget-AllmessagesDeluxe.js */ /* ********************************************************************* ;Fonction : permet de rechercher dans les messages système ([[Special:Allmessages]]) par mot-clefs (Expressions régulières) ;Installation : obtenir('AllmessagesDeluxe'); {{Catégorisation JS|AllmessagesDeluxe}} ************************************************************************* */ //


/* globals mw, $, AllmessagesDeluxe */

////////////////////////////////////////// REQUÊTE DES MESSAGES SYSTÈME ///////////////////////////////////////////

window.AllmessagesDeluxe = {

	getMessages: function() {
		mw.loader.using('mediawiki.api', function () {
			new mw.Api()
				.get({action: 'query', meta: 'allmessages', formatversion: 2})
				.done(AllmessagesDeluxe.populateMessages);
		});
	},

	populateMessages: function( data ) {
		/* jshint sub: true */

		var AllMessages = data.query.allmessages;
		for(var a=0;a');
		var $row = $('');
		var $tdOne = $('');
		var $tdTwo = $('');

		$container.append($row);
		$row.append($tdOne);
		$row.append($tdTwo);

		$form.replaceWith($container);

		$tdOne.append($form);

		var newForm = document.createElement('form');
		newForm.id = "DeluxeSearchForm";
		newForm.method = "post";
		newForm.onsubmit = function () {
			AllmessagesDeluxe.checkPanel();
			return false;
		};

		newForm.innerHTML = ''
			+ ''
			+ ''

			+ ''
			+ ''
			+ ''

			+ ''
			+ ''
			+ ''
			+ ''

			+ ''
			+ ''
			+ ''
			+ ''

			+ ''
			+ ''
			+ ''
			+ ''

			+ ''
			+ '
' + '' + '
' + '' + '' + '' + '
' + '' + '' + '' + '
' + '' + '' + '
'; $tdTwo.append(newForm); AllmessagesDeluxe.CreatePanelOK = true; if(AllmessagesDeluxe.GetMessagesOK) AllmessagesDeluxe.enableForm(); }, ////////////////////////////////////////// VÉRIFICATION DU FORMULAIRE DE RECHERCHE /////////////////////////////////////////// checkPanel: function() { var MessageInput = document.getElementById('SearchInMessage').value; var TitleInput = document.getElementById('SearchInTitle').value; if((!MessageInput)&&(!TitleInput)) return; AllmessagesDeluxe.checkMessages(MessageInput, TitleInput); }, ////////////////////////////////////////// RECHERCHE DES MOT-CLEFS DANS LES MESSAGES /////////////////////////////////////////// checkMessages: function( MessageInput, TitleInput ) { var RegExpContent = false; var RegExpTitle = false; var TitleArray = []; var MatchedTitleArray = []; var ContentArray = []; if(MessageInput) RegExpContent = new RegExp(MessageInput, "g"); if(TitleInput) RegExpTitle = new RegExp(TitleInput, "g"); for(var a=0;a/g,">"); var Before = ""; var After = ""; if(Reg){ var Matches = Text.match(Reg); Text = Text.replace(Reg, "TRALALA"); for(var a=0;a'+MatchedTitles[a]+''; var TdContent = document.createElement('td'); TdContent.innerHTML = Contents[a]; NewTbody.appendChild(NewTR); NewTR.appendChild(TdTitle); NewTR.appendChild(TdContent); Table.appendChild(NewTbody); } } }; ////////////////////////////////////////// LANCEMENT /////////////////////////////////////////// if(mw.config.get('wgCanonicalSpecialPageName')=="Allmessages"){ AllmessagesDeluxe.GetMessagesOK = false; AllmessagesDeluxe.CreatePanelOK = false; AllmessagesDeluxe.messagesTitles = []; AllmessagesDeluxe.messagesContents = []; AllmessagesDeluxe.getMessages(); $(AllmessagesDeluxe.createPanel); } //
mw.loader.state({ "ext.gadget.AllmessagesDeluxe": "ready" });