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é.

//Fusión de varios "monobuques" fundamentalmente a partir del de Charlitos 
//(que es el de Comae tras pasar por varias manos, entre ellas, la mía)
//y el de Angus

//En [[:Categoría:Botones de edición]] están los botones de la barra de edición que aparece por defecto, 
//más los que he creado para mi barra particular.

// incluir mi Live Preview, modificado a partir del de Pilaf.

document.write('<script type="text/javascript" src="/w/index.php?title=Usuario:Sanbec/LivePreview.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');

function CargaLivePreview()
{
LivePreviewInstall();
}
$(CargaLivePreview);

var wpUserName = 'Sanbec';



/************ Módulo botonera flotante **************/


function botoneraFlotante()
{
//<nowiki>
  var botones='<style type="text/css">\n .botón {background-color:transparent; border:0px; float:left; font-size:80%; padding:.25px; line-height:1.5 }\n</style> <div class="botonera" style="position:fixed; bottom:6px; left:4px; z-index:3; font-size:13px; color:#000; font-weight:900; text-align:center; width:150px; float:right">';
//</nowiki>

  botones+=creaBotón("Tablón", "<img src=http://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Broom_icon.svg/32px-Broom_icon.svg.png>", "http://es.wikipedia.org/wiki/Wikipedia:Tablón de anuncios de los bibliotecarios/Portal/Todo el tablón actual", "");
  botones+=creaBotón("Café", "<img src=http://upload.wikimedia.org/wikipedia/commons/9/9e/Tacita.png>", "http://es.wikipedia.org/wiki/Wikipedia:Café (todos)", "");
  botones+=creaBotón("Cambios recientes", "<img src=http://upload.wikimedia.org/wikipedia/commons/0/00/Icono_recientes.png>", "http://es.wikipedia.org/wiki/Especial:CambiosRecientes", "");
  botones+=creaBotón("Lista de seguimiento", "<img src=http://upload.wikimedia.org/wikipedia/commons/2/24/Icono_seguimiento.png>", "http://es.wikipedia.org/wiki/Especial:Seguimiento", "");
 
  if (document.getElementById("editform")!=null) {
  //Estos botones no se muestran si no se está editando:
  }

  botones+='</div>';
  <!--var toolbox = document.getElementById("contentTop");-->
  var toolbox = document.getElementById("column-one");
  toolbox.innerHTML += botones;
} // fin botoneraFlotante
$(botoneraFlotante);

function creaBotón(title, texto, destino, estilo)
{
  return '<a href="'+destino+'" style="text-decoration:none"><div class="botón" style="'+estilo+'" title="'+title+'">'+texto+'</div></a>';
}
/************ Fin módulo botonera flotante **************/

/*** Módulo caja de herramientas personales ***/

function nuevaCaja() {
  var l = document.getElementById("column-one");
  if (l) {
    l.innerHTML = l.innerHTML
    + '<div class="portlet" id="p-nbx">'
    + ' <h5>Herramientas personales</h5>'
    + ' <div class="pBody">'
    + '   <ul>'
    + '     <li><a href="http://es.wikipedia.org/wiki/Usuario:Sanbec/monobook.js">monobook.js</a></li>'
    + '     <li><a href="http://es.wikipedia.org/wiki/Usuario:Sanbec/LivePreview.js">LivePreview.js</a></li>'
    + '     <li><a href="http://es.wikipedia.org/wiki/Usuario:Sanbec/monobook.css">monobook.css</a></li>'
    + '   </ul>'
    + ' </div>'
    + '</div> ';
  }
}
$(nuevaCaja);
/*** Fin módulo caja de herramientas personales ***/


/************      Módulo de búsqueda     **************/
function moduloBusqueda()
{
  var btSearch = '<div>';
  btSearch += buttonCode('onclick="goSearch(0)" value="EL" title="Enciclopedia Libre"');
  btSearch += buttonCode('onclick="goSearch(1)" value="Wikc"');
  btSearch += '</div>';
  
  var boxSearch = document.getElementById("searchform");
  if (boxSearch)
    boxSearch.innerHTML += btSearch;
}

function goSearch(i)
{
  urls = new Array(
    "http://enciclopedia.us.es/index.php/",
    "http://es.wiktionary.org/wiki/"
  );

  var text = document.getElementById("searchInput");
  
  window.open(urls[i] + escape(text.value));
}

function buttonCode(strCode)
{
  return '&nbsp;<input type="button" class="searchButton" '+strCode+' />';
}

$(moduloBusqueda);

/************     Fin módulo de búsqueda    **************/

/* Modulo barra de herramientas de la caja de edición */
function InsertEditButton(parent, item, i) {
	var image = document.createElement("img");
	image.width = 23;
	image.height = 22;
	image.src = item.img;
	image.border = 0;
	image.alt = item.st;
	image.title = item.st;
	image.style.cursor = "pointer";
	image.onclick = function() {
		hanApretadoUnBoton(i);
		return false;
	}
	
	parent.appendChild(image);
}

function toolbarExtendido()
{
  var toolbar = document.getElementById("toolbar")
  if (toolbar!=null) {
  //Estos botones se añaden a la barra de herramientas que hay sobre la caja de edición
    for (i=0; i<mis_botones.length; i++)
    {
      InsertEditButton(toolbar, mis_botones[i], i)
    }
  }

} // fin toolbarExtendido
//addOnloadHook(toolbarExtendido);
hookEvent("load",toolbarExtendido);
mis_botones = new Array();

// ¡han apretado un botón!
// esto es insertTags modificado, sólo que llama a una función para
// modificar el texto
function hanApretadoUnBoton (cual)
{
	if (!mis_botones[cual]) return;
	var fn = mis_botones[cual].fn;
	if (!fn) return;
	
	var txtarea = document.editform.wpTextbox1;
	// IE
	if(document.selection  && !is_gecko) {
		var theSelection = document.selection.createRange().text;
		if(!theSelection) { theSelection="";}
		txtarea.focus();
		if(theSelection.charAt(theSelection.length - 1) == " "){// exclude ending space char, if any
			theSelection = theSelection.substring(0, theSelection.length - 1);
			document.selection.createRange().text = fn(theSelection) + " ";
		} else {
			document.selection.createRange().text = fn(theSelection);
		}

	// Mozilla
	} else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
		var startPos = txtarea.selectionStart;
		var endPos = txtarea.selectionEnd;
		var scrollTop=txtarea.scrollTop;
		var myText = (txtarea.value).substring(startPos, endPos);
		if(!myText) { myText="";}
		if(myText.charAt(myText.length - 1) == " "){ // exclude ending space char, if any
			subst = fn(myText.substring(0, (myText.length - 1)))+" ";
		} else {
			subst = fn(myText);
		}
		txtarea.value = txtarea.value.substring(0, startPos) + subst +
		  txtarea.value.substring(endPos, txtarea.value.length);
		txtarea.focus();

		var cPos=startPos+subst.length;
		txtarea.selectionStart=cPos;
		txtarea.selectionEnd=cPos;
		txtarea.scrollTop=scrollTop;

	// All others
	} else {
		var copy_alertText=alertText;
		var re1=new RegExp("\\$1","g");
		var re2=new RegExp("\\$2","g");
		copy_alertText=copy_alertText.replace(re1,"xyz");
		copy_alertText=copy_alertText.replace(re2,fn("xyz"));
		var text;
		if (sampleText) {
			text=prompt(copy_alertText);
		} else {
			text="";
		}
		if(!text) { text="xyz";}
		text=fn(text);
		document.infoform.infobox.value=text;
		// in Safari this causes scrolling
		if(!is_safari) {
			txtarea.focus();
		}
		noOverwrite=true;
	}
	// reposition cursor if possible
	if (txtarea.createTextRange) txtarea.caretPos = document.selection.createRange().duplicate();
}


// Esta es una versión modificada de addButton.
// Parámetros:
// * la imagen para colocar en el botón,
// * el texto de ayuda (se muestra cuando el puntero del mouse
//   pasa sobre el botón,
// * una función a la que se llamará cuando se pulse el botón, con
//   un parámetro: el texto seleccionado, y que deberá devolver el
//   texto a poner en su lugar.           
//
// No funciona con el infobox
function otro_boton (imageFile, speedTip, funcion) {
	var btn = { img: imageFile, st: speedTip, fn: funcion };
	mis_botones[mis_botones.length] = btn;

}

function Usuario(s)
{
	if (s == "") s = wpUserName;
	// si no tiene '|' duplicamos el término
	if (s.indexOf("|") == -1) s = s + "|" + s;
	
	return "[[Usuario:" + s + "]]";
}

otro_boton("http://upload.wikimedia.org/wikipedia/commons/2/29/Button_user.png",
	"Enlace a usuario", Usuario);


function Discusion(s)
{
	if (s == "") s = wpUserName;
	// si no tiene '|' duplicamos el término
	if (s.indexOf("|") == -1) s = s + "|" + s;
	
	return "[[Usuario Discusión:" + s + "]]";
}
otro_boton("http://upload.wikimedia.org/wikipedia/commons/f/fc/Button_user_talk.png",
	"Enlace a discusión de usuario", Discusion);

function category(s)
{
return "[["+"Categoría:" + s + "]]";
}

otro_boton("http://upload.wikimedia.org/wikipedia/commons/b/b4/Button_category03.png","Categoría", category);

function Latinas (s)
{
	return "«" + s + "»";
}
otro_boton("http://upload.wikimedia.org/wikipedia/commons/2/26/Button_latinas.png",
	"Comillas latinas", Latinas);

function Llaves (s)
{
	return "{"+"{" + s + "))";
}
otro_boton("http://upload.wikimedia.org/wikipedia/commons/e/eb/Button_plantilla.png",
	"Llaves para plantillas", Llaves);

function ponRedirect(s)
{
  return "#REDIRECT [[" + s + "]]";
}
otro_boton("http://upload.wikimedia.org/wikipedia/commons/4/47/Button_redir.png",
	"Redirect", ponRedirect);


function ponWEI(s)
{
  if (s == "") s = ";-)";
  return '<tt style="background:yellow">'+s+'</tt>';
}
    
otro_boton("http://upload.wikimedia.org/wikipedia/commons/e/e1/Button_smiley.png",
	"Emoticono", ponWEI);

function innecesaria(s)
{
  return "{"+"{innecesaria|{"+"{subst:CURRENTDAY))|{"+"{subst:CURRENTMONTHNAME))))";}

    
otro_boton("http://upload.wikimedia.org/wikipedia/commons/2/21/Button_invalid_template.png",
	"Aviso de plantilla innecesaria", innecesaria);

// Gets the article lemma with the namespace
function get_title()
{
  // get the article link from the label 'ca-edit' out of the document text.
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
  // cut everything up to "title=" from the start and everything past "&" from the end
  // Note if the page has & in its title, that is represented here as %26, so it
  // doesn't cause a problem
  editlk = editlk.substring(editlk.indexOf('title=') + 6, editlk.indexOf('&'));
  return editlk;
}

// Gets the article lemma, with the namespace but without sub pages.
function get_tidy_title()
{
  var editlk = get_title()
  editlk = editlk.replace(/\/.*$/, ''); //removing subpages from the link
  return editlk;
}
// Gets the subpage lemma, with the namespace but without sub pages.
function get_subpage_title()
{
  var editlk = get_title()
  editlk = editlk.substring(editlk.indexOf('/') + 1); // strip off 
  return editlk;
}


function add_pt_tab()
{
  global_append_tab('http://es.wikipedia.org/w/index.php?title=' + get_title() + '&diff', 'uldiff', 'ca-uldiff');
  if (document.getElementById("pt-mylog")) return;
  var li_logout = document.getElementById("pt-logout");
    if (!li_logout) return;
    var ul_personal = li_logout.parentNode;
    var li = document.createElement("li");
    li.id = "pt-mylog";
    li.innerHTML = '<a href="http://es.wikipedia.org/w/index.php?title=Especial:Log&user='+ wpUserName +'">mi registro</a>';
    ul_personal.insertBefore(li, li_logout);
}
 
$( add_pt_tab );
More