Utilisateur:Linedwell/quickoversight.js

Une page de Wikipédia, l'encyclopédie libre.
Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.

Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;

Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5.
//<source lang="javascript" line>
/*
*********************************************************************************************************************
**                                               <QuickOversight>                                                  **
** Script permettant de cocher rapidement tout un intervalle de versions à masquer depuis une page d'historique    **
** Destiné aux administrateurs pour qui la selection de tout un intervalle de checkboxes à l'aide de maj + clic    **
** ne fonctionne pas (que ce soit à cause du skin choisi, ou d'un script)                                          **
** Auteur: Linedwell                                                                                               **
*********************************************************************************************************************
*/

function checkRange() {
	var hist = document.getElementById('pagehistory').getElementsByTagName('input');
	var hist2 = new Array();
	var firstIndex = -1;
	var lastIndex = -1;
	
	for (var i = 0; i < hist.length; i++) {
		if(hist[i].getAttribute('type') == 'checkbox' ) {
			hist2.push(hist[i]);
		}
	}
	for( var i = 0; i < hist2.length; i++) {
		if(hist2[i].checked) {
			if (firstIndex < 0) firstIndex = i;
			else lastIndex = i;
		}
	}
	if(firstIndex >= 0 && lastIndex >=0) {
		for(var i = firstIndex; i < lastIndex; i++) {
			hist2[i].checked = true;
		}
	}
}


function quickOversight() {
	var main = document.getElementsByClassName("historysubmit mw-history-revisiondelete-button");
	if(!main[0] || !main[1]) return;
	var mainTop = main[0].parentNode;
	var mainBot = main[1].parentNode;

	var buTop = document.createElement('input');
	buTop.setAttribute('type','button');
	buTop.setAttribute('value','Cocher tous les intermédiaires');
	buTop.setAttribute('onclick','checkRange()');
	mainTop.appendChild(buTop);

	var buBot = buTop.cloneNode(true); //le bouton du bas est un clone de celui du haut
	mainBot.appendChild(buBot);
}

if(mw.config.get('wgAction') == 'history') addOnloadHook(quickOversight);

//</source>