MediaWiki:JSScripts/BlocageDeluxe

Un article de Wikipèdia, l'enciclopèdia liura.

//

/*
 * BlocatgeDeluxe
 *
 * Ajust de botons predefinits per justificar un blocatge
 *
 * Autor : Pabix
 * Darrièra revision : 5 de novembre de 2006
 */

//////////////////////ZÒNA PERSONALISABLA//////////////////////
var blocatgedeluxeMessatges = new Array();
var blocatgedeluxeDurada = new Array();
var blocatgedeluxeInterdireInscripcion = new Array();
var blocatgedeluxeUnicamentIP = new Array();
var blocatgedeluxeBlocarIPsUtilizadas = new Array();

with (blocatgedeluxeMessatges) {
        push ("IP fixe - Pas d'inscripcion possibla");
        push ("IP fixe multi utilizaires (ex. escolar) - Creacion de compte autorizada");
        push ("IP variabla - Cap d'inscription novèla autorizada, comptes actuals utilizables");
        push ("Utilizaire enregistrat - Blocatge del compte");
        push ("Utilizaire enregistrat - Blocatge del compte e de las IPs associadas");
}
with (blocatgedeluxeInterdireInscripcion) {
        push(true);
        push(false);
        push(true);
        push(false);
        push(false);
}
with (blocatgedeluxeBlocarIPsUtilizadas) {
        push(false);
        push(false);
        push(false);
        push(false);
        push(true);
}
with (blocatgedeluxeUnicamentIP) {
        push(false);
        push(true);
        push(true);
        push(false);
        push(false);
}
with (blocatgedeluxeDurada) {
        push("1 hour");
        push("infinite");
        push("1 hour");
        push("1 hour");
        push("1 hour");
}
/////////////////FIN DE LA ZÒNA PERSONALISABLA/////////////////

function BlocatgeDeluxe() {
        if (document.title.indexOf("Blocar una adreça IP o un utilizaire - Wikipèdia")!=0) return;
        var mainNode = document.getElementsByTagName("form");
        var firstForm = mainNode[0];
        var table = document.createElement("table");
        var tr = document.createElement("tr");
        table.appendChild(tr);
        if (firstForm.getAttribute("id")=="blockip") {
                actionBlock = firstForm.getAttribute("action");
                var inputs = firstForm.getElementsByTagName("input");
                // inputs :
                // 0 -> wpBlockAddress        Lo nom de l'utilizaire o son IP
                // 1 -> wpBlockOther          Durada
                // 2 -> wpBlockReason         Rason invocada
                // 3 -> wpAnonOnly            Blocar pas los comptes existents
                // 4 -> wpCreateAccount       Empachar la creacion de compte
                // 5 -> wpEnableAutoblock     Blocar totas las IPs utilizadas per aqueste pseudonim
                // 6 -> (submit) wpBlock      Somission del formulari
                // 7 -> wpEditToken           (Variabla d'identificacion)
                var token = inputs[7].getAttribute("value");
                var lePauvre = inputs[0].getAttribute("value");
                for (var i=0;i<blocatgedeluxeMessatges.length;i++) {
                        //   if (i%3==0) {
                        tr = document.createElement("tr");
                        table.appendChild(tr);
                        //   }

                        // Crea lo formulari
                        var formElement = document.createElement("form");
                        with (formElement) {
                                setAttribute("id", "blockip");
                                setAttribute("method", "post");
                                setAttribute("action", actionBlock);
                        }

                        // Camp invisible : identificacion
                        var inputToken = document.createElement("input");
                        with (inputToken) {
                                setAttribute("name", "wpEditToken");
                                setAttribute("value", token);
                                setAttribute("type", "hidden");
                        }

                        // Camp invisible : nom de l'utilizaire
                        var ident = document.createElement("input");
                        with (ident) {
                                setAttribute("name", "wpBlockAddress");
                                setAttribute("value", loPaure);
                                setAttribute("type", "hidden");
                        }

                        // Camp invisible de rason
                        var inputReason = document.createElement("input");
                        with (inputReason) {
                                setAttribute("name", "wpBlockReason");
                                setAttribute("value", blocatgedeluxeMessatges[i]);
                                setAttribute("type", "hidden");
                        }

                        // Camp invisible de durada
                        var duradaC = document.createElement("input");
                        with (duradaC) {
                                setAttribute("name", "wpBlockExpiry");
                                setAttribute("value", "other");
                                setAttribute("type", "hidden");
                        }

                        // Camp modificable de durada
                        var duradaC2 = document.createElement("input");
                        with (duradaC2) {
                                setAttribute("name", "wpBlockOther");
                                setAttribute("value", blocatgedeluxeDurada[i]);
                                setAttribute("type", "text");
                        }

                        // Casa de marcar : blocar las IPs utilizadas per l'utilizaire
                        var blockIPs = document.createElement("input");
                        with (blockIPs) {
                                setAttribute("name", "wpEnableAutoblock");
                                setAttribute("type", "checkbox");
                                setAttribute("title", "blocagte automatic de las IPs utilizadas per aqueste pseudonim");
                                checked = blocatgedeluxeBlocarIPsUtilizadas[i];
                        }

                        // Casa de marcar : Blocar solament las IPs
                        var anonymousOnly = document.createElement("input");
                        with (anonymousOnly) {
                                setAttribute("name", "wpAnonOnly");
                                setAttribute("type", "checkbox");
                                setAttribute("title", "Blocar pas los comptes ja existents");
                                checked = blocatgedeluxeUnicamentIP[i];
                        }

                        // Casa de marcar : empachar la creacion de compte
                        var allowAccCreat = document.createElement("input");
                        with (allowAccCreat) {
                                setAttribute("name", "wpCreateAccount");
                                setAttribute("type", "checkbox");
                                setAttribute("title", "Empachar la creacion de compte");
                                checked = blocatgedeluxeInterdireInscripcion[i];
                        }

                        // Casa de marcar : empachar la creacion de compte
                        // Boton de somission amb rason
                        var inputConfirm = document.createElement("input");
                        with (inputConfirm) {
                                setAttribute("name", "wpBlock");
                                setAttribute("value", blocatgedeluxeMessatges[i]);
                                setAttribute("type", "submit");
                        }

                        with (formElement) {
                                appendChild(anonymousOnly);
                                appendChild(allowAccCreat);
                                appendChild(blockIPs);
                                appendChild(inputReason);
                                appendChild(duradaC);
                                appendChild(duradaC2);
                                appendChild(inputConfirm);
                                appendChild(inputToken);
                                appendChild(ident);
                        }
                        var td = document.createElement("td");
                        td.appendChild(formElement);
                        tr.appendChild(td);
                }
                var separation = document.createElement("p");
                separation.appendChild(document.createElement("hr"));
                insertAfter(firstForm.parentNode, separation, firstForm);
                insertAfter(firstForm.parentNode, table, separation);
        }
}
addLoadEvent(BlocatgeDeluxe);
//