Utilisateur:0x010C/script/PopupVandalism.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.
//Avertit du niveau de vandalisme à l'arrivée sur wikipédia
//Crédits : Créé par [[Utilisateur:0x010C]] (adapté d'un précédent code de [[Utilisateur:Dr Brains]])
//Documentation : [[Utilisateur:0x010C/script#PopupVandalism.js]]

function PopVand_GetVand()
{
    $.post(mw.config.get("wgScript"), { title: "Utilisateur:0x010C/script/PopupVandalism.js/box", action: "purge" }, function (Response)
    {
        if (PopVand_Mode == "text" || PopVand_Mode == "Text") {
            PopVand_DisplayVandText(Response);
        } else if (PopVand_Mode == "box" || PopVand_Mode == "Box") {
            PopVand_DisplayVandBox(Response);
        } else {
            PopVand_DisplayVandText(Response);
            PopVand_DisplayVandBox(Response);
        }
    });
}

function PopVand_DisplayVandBox(Response)
 {
    var Content = document.getElementById("content");
    var Div = document.createElement('div');
    Div.style.display = "none";
    Content.insertBefore(Div, Content.firstChild);
    Div.innerHTML = Response;
    var box = Div.getElementsByClassName("ModeleBUtilisateur")[0];
    Div.innerHTML = "";
    Div.appendChild(box);
    Div.style.display = "";
    Div.setAttribute("style", "float:right;");
}
function PopVand_DisplayVandText(Response){
	var li = document.createElement('li');
	li.innerHTML = Response;
	var lvl = li.getElementsByClassName("ModeleBUtilisateurImgTexte")[0].getElementsByTagName("b")[0].innerHTML;
    li.innerHTML = "";
    li.style.display = "";

	var spancolor;
	if(PopVand_Color === true)
	{
		switch(lvl)
		{
			case "1":
				spancolor = '<span style="color:white;background:red;">';
				break;
			case "2":
				spancolor = '<span style="color:red;">';
				break;
			case "3":
				spancolor = '<span style="color:orange;">';
				break;
			case "4":
				spancolor = '<span style="color:green;">';
				break;
			case "5":
				spancolor = '<span style="color:blue;">';
				break;
		}
	}
	else
		spancolor = '<span>';
    li.innerHTML = '<a href="/wiki/Modèle:Alerte_vandalisme" title="Alerte vandalisme">' + spancolor + 'Vandalisme ' + lvl + '</span></a>';

    var nav = document.getElementById("p-navigation");
    if(nav)nav.getElementsByTagName("ul")[0].appendChild(li);
}

if (typeof PopVand_Mode == "undefined") {
    var PopVand_Mode = "both";
}
if (typeof PopVand_Color == "undefined") {
    var PopVand_Color = true;
}

$(PopVand_GetVand);