Usuario:Racso/reversion.js

De Wikipedia, la enciclopedia libre

Nota: Después de guardar, debes refrescar la caché de tu navegador para ver los cambios. Internet Explorer: mantén presionada Ctrl mientras pulsas Actualizar. Firefox: mientras presionas Mayús pulsas el botón Actualizar, (o presiona Ctrl-Shift-R). Los usuarios de Google Chrome y Safari pueden simplemente pulsar el botón Recargar. Para más detalles e instrucciones acerca de otros exploradores, véase Ayuda:Cómo limpiar la caché.

//<pre>

//*********************************************************************
//Funciones de carga [por defecto] de los botones.
//*********************************************************************

//BOTONES PARA NO-SYSOP
function loadNoSysop()
{
	var tmp='';

	tmp += addButton('Pruebas de edición', "FBdest");
	tmp += addButton('No enciclopédico', "FBdest");
	tmp += addButton('Infraesbozo', "FBdest");
	tmp += addButton('Promocional', "FBdest");
	tmp+=addActionButton("Plagio","readInputButton('URL','FBplagio');");
	tmp+=addActionButton("Otro","readInputButton('Motivo','FBdest');");

	return tmp;
}

//BOTONES PARA SYSOP
function loadSysop()
{
	var tmp='';

	tmp+= addButton('Borrado rápido','FBdelete','default','delete');
	tmp+= addActionButton("Borrar","readInputButton('Motivo','FBdelete','delete');");

	return tmp;
}

//PLANTILLAS (BOTONES GENERALES)
function loadTemplates()
{
	var tmp='';

	tmp += addButton('SRA', 'FBplant', '{{sinrelevancia|{{subst:CURRENTDAY}}|{{subst:CURRENTMONTHNAME}}}}');
	tmp += addButton('Wikificar', 'FBplant', '{{wikificar|t={{subst:CURRENTTIMESTAMP}}}}');
	tmp += addButton('Wikcionario', 'FBplant', '{{wikci}}');

	return tmp;
}

//BOTONES DE VARIAS FUNCIONALIDADES (BOTONES GENERALES)
function loadMisc()
{
	var tmp='';
	var warnMenu = encodeURI("Aviso:\n(nada): Prueba\n0a: Etiqueta\n0b: Estilo\n0c: Spam\n2: Ediciones sin sentido\n2a: Blanqueo\n3: Detente\n4: Última advertencia\n5: Bloqueo");
	
	tmp+=addActionButton("Advertencia","readInputButton(\'"+warnMenu+"\','FBwarn');");
	return tmp;
}

//*********************************************************************
//Funciones generales
//*********************************************************************

//addTemplate: añade una plantilla a la página, y guarda.
function addTemplate(plantilla,resumen)
{
	document.getElementById("wpTextbox1").value = plantilla + '\n' + document.getElementById("wpTextbox1").value;
	document.editform.wpSummary.value = resumen + ufb;
	document.editform.submit();
}

//addButton: genera la cadena para añadir un botón, tomando ciertos parámetros.
function addButton(buttonLabel, buttonType, typeParam, wikiAction )
{
	if (!typeParam) var typeParam = buttonLabel;
	if (!wikiAction) var wikiAction = 'edit';
	return '[<a href='+wikiURL+ wikiAction + '&' + buttonType + '='+encodeURI(typeParam)+'>'+buttonLabel+'</a>] ';
}

//addActionButton: genera la cadena para añadir un botón de acción.
function addActionButton(buttonLabel, accion)
{
	return '[<a onclick='+accion+'>'+buttonLabel+'</a>]';
}

//readInputButton: ejecuta el código de un botón de acción que lee datos. Lee un dato del usuario.
function readInputButton(mensaje, buttonType, wikiAction)
{
	if (!wikiAction) var wikiAction='edit';
	var input = prompt(decodeURI(mensaje));
	location.href=wikiURL+wikiAction+'&'+buttonType+'='+encodeURI(input);
}

//*********************************************************************
//Añadir los botones
//*********************************************************************
var PAGENAME='';
var USERNAME='';
var FBList=''; 
var isSysop=false;
var ufb = ', usando [[Usuario:Racso/Fastbuttons|Fastbuttons]]';
var wikiURL="http://es.wikipedia.org/w/index.php?title=";


//Extraer datos de la página
for (i=0; i<wgUserGroups.length; i++)
   {  if (wgUserGroups[i] == "sysop") isSysop=true; }

PAGENAME=encodeURI(wgPageName);
if (PAGENAME.match("&"))
{
PAGENAME=PAGENAME.replace("&","%26");
}
wikiURL=wikiURL+PAGENAME+"&action=";
USERNAME=PAGENAME.split(":")[1];



//Botones de destruir. Sólo aparecen a no-bibliotecarios. TODO: poner el ! de nuevo
if (isSysop)
{
	if (typeof botonesNoSysop=='function') tmp = botonesNoSysop(); else tmp = loadNoSysop();
	if (tmp!='') FBList = FBList + 'Destruir: ' + tmp + '<br>';
}

//Botones para bibliotecarios.
if (isSysop)
{
	if (typeof botonesSysop=='function') tmp = botonesSysop(); else tmp = loadSysop();
	if (tmp!='') FBList = FBList + 'Sysop: ' +tmp+'<br>';
}

//Plantillas. Aparecen a todos los usuarios.
if (typeof botonesPlantillas=='function') tmp = botonesPlantillas(); else tmp = loadTemplates();
if (tmp!='') FBList = FBList + 'Plantillas: ' +tmp+'<br>';

//Otros. Aparecen a todos los usuarios.
if (typeof botonesOtros=='function') tmp = botonesOtros(); else tmp = loadMisc();
if (tmp!='')		FBList = FBList + 'Otros: ' +tmp+'<br>';


/* Mostrar los botones en la página */

$(function ()
{

	if (document.getElementById('contentSub').innerHTML!='') document.getElementById('contentSub').innerHTML += '<br>';
	document.getElementById('contentSub').innerHTML += FBList;

	if (location.href.match("FBdest=")) 
	{
		var plantilla = decodeURI(location.href.substring(location.href.indexOf("FBdest=")+7));
		addTemplate("{{destruir|"+plantilla+"}}" , "Destruir: "+plantilla);
	}

	if (location.href.match("FBplant=")) 
	{
		var plantilla = decodeURI(location.href.substring(location.href.indexOf("FBplant=")+8));
		addTemplate(plantilla , "Plantilla: "+plantilla);
	}
	 
	if (location.href.match("FBplagio=")) 
	{
		var url = decodeURI(location.href.substring(location.href.indexOf("FBplagio=")+9));
		addTemplate('{{plagio|1='+url+'|2=~~~~}}', "Plagio desde "+url);
	}

	else if (location.href.match("FBdelete=")) 
	{
		var motivo = decodeURI(location.href.substring(location.href.indexOf("FBdelete=")+9));
			if (motivo!='default')document.getElementById ("wpReason").value=motivo;
		document.getElementById ("wpConfirmB").click();
	}

	else if (location.href.match("FBwarn=")) 
	{
	var warning = decodeURI(location.href.substring(location.href.indexOf("FBwarn=")+7));
	addTemplate('{{subst:prueba'+decodeURI(warning)+'}} --~~~~','Aviso al usuario');
	}
	
});

//</pre>