Usuário(a):Sergiohlc/monobook.js2

Origem: Wikipédia, a enciclopédia livre.

//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 addLoadEvent(func) {

  if (window.addEventListener) {
      window.addEventListener("load", func, false);
  } else if (window.attachEvent) {
      window.attachEvent("onload", func);
  }

}

function CargaLivePreview() {

LivePreviewInstall();

} addLoadEvent(CargaLivePreview);

var wpUserName = 'Sanbec';


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


function botoneraFlotante() { // 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">'; //

 botones+=creaBotón("Mapa de la ayuda", "<img src=http://upload.wikimedia.org/wikipedia/commons/3/30/Question.png>", "http://es.wikipedia.org/wiki/Wikipedia:Mapa", "");
 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:Recentchanges", "");
 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:Watchlist", "");

 if (document.getElementById("editform")!=null) {
 //Estos botones no se muestran si no se está editando:
 }

botones+='';

 var toolbox = document.getElementById("column-one");
 toolbox.innerHTML += botones;

} // fin botoneraFlotante addLoadEvent(botoneraFlotante);

function creaBotón(title, texto, destino, estilo) {

return '<a href="'+destino+'" style="text-decoration:none">

'+texto+'

</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

+ '

' + '
Herramientas personales
' + '
' + ' ' + '
' + '

';

 }

} addLoadEvent(nuevaCaja); /*** Fin módulo caja de herramientas personales ***/

/*** subir al fondo - Desactivo, ya está en el monobuque general function agrega_enlace_para_subir_a_commons() {

   if (document.getElementById("enlace-subir-a-commons")) return;
   var li_subir = document.getElementById("t-upload");
   if (!li_subir) return;
   var siguiente = li_subir.nextSibling;
   var ul_herramientas = li_subir.parentNode;
   var li = document.createElement("li");
   li.id = "enlace-subir-a-commons";
   li.innerHTML = '<a href="http://commons.wikimedia.org/wiki/Special:Upload">Subir a Commons</a>';
   if (siguiente) ul_herramientas.insertBefore(li, siguiente);
   else ul_herramientas.appendChild(li);

} addLoadEvent(agrega_enlace_para_subir_a_commons); */

/*** fin subir al fondo */

/************ Módulo de búsqueda **************/ function moduloBusqueda() {

var btSearch = '

';
 btSearch += buttonCode('onclick="goSearch(0)" value="en:" title="Wikipedia en inglés"');
 btSearch += buttonCode('onclick="goSearch(1)" value="de:" title="Wikipedia en alemán"');
 btSearch += buttonCode('onclick="goSearch(2)" value="fr:" title="Wikipedia en francés"');
 btSearch += buttonCode('onclick="goSearch(3)" value="EL" title="Enciclopedia Libre"');
 btSearch += buttonCode('onclick="goSearch(4)" value="Wikc"');
 btSearch += buttonCode('onclick="goSearch(5)" value="FSF" title="Free Software Foundation"');
btSearch += '

';

 var boxSearch = document.getElementById("searchform");
 if (boxSearch)
   boxSearch.innerHTML += btSearch;

}

function goSearch(i) {

 urls = new Array(
   "http://en.wikipedia.org/wiki/", 
   "http://de.wikipedia.org/wiki/",
   "http://fr.wikipedia.org/wiki/",
   "http://enciclopedia.us.es/index.php/",
   "http://es.wiktionary.org/wiki/",
   "http://www.gnu.org/cgi-bin/htsearch?words="
 );

 var text = document.getElementById("searchInput");

 window.open(urls[i] + escape(text.value));

}

function buttonCode(strCode) {

 return ' <input type="button" class="searchButton" '+strCode+' />';

}

addLoadEvent(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 dobre la caja de edición
   for (i=0; i<mis_botones.length; i++)
   {
     InsertEditButton(toolbar, mis_botones[i], i)
   }
 }

} // fin toolbarExtendido addLoadEvent(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 Bienvenida(s) {return '{'+'{Bienvenido usuario}}';} otro_boton("http://upload.wikimedia.org/wikipedia/commons/e/e3/Button_bienvenido.png", "Bienvenida", Bienvenida);

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

otro_boton("http://upload.wikimedia.org/wikipedia/commons/0/00/Button_dicc.png", "enlace al wikcionario", enlace_a_dicc);

function category(s) { return ""+"Categoría:" + s + ""; } otro_boton("http://upload.wikimedia.org/wikipedia/commons/b/b4/Button_category03.png", "Categoría", category);


function copyvio(s) { Qr=; if(!Qr){void(Qr=prompt('Copiada de:',));} if(Qr) return "{"+"{copyvio|1="+Qr+"|2=~~"+"~~|3="+"{"+"{subst:CURRENTDAY}}|4={"+"{subst:CURRENTMONTHNAME}}}}"; }

otro_boton("http://upload.wikimedia.org/wikipedia/commons/e/e5/Button_copyvio.png", "Alerta de copyright", copyvio);

function avisoborrar(s) {

 Qr=;
 if(!Qr){void(Qr=prompt('Motivo:',));}
 if(Qr)return "{"+"{aviso borrar|"+Qr+"|~~"+"~~}}";

}

otro_boton("http://upload.wikimedia.org/wikipedia/commons/e/ec/Button_aviso_borrado.png", "Aviso de borrado", avisoborrar);

function consultaborrar(s) {

 Qr=;
 Qr2 = get_subpage_title().replace(/_/g , ' ');  

 if(!Qr){void(Qr=prompt('Motivo:',));}
 if(Qr)return "{"+"{subst:Consulta borrar|"+Qr2+"|"+Qr+"|~~"+"~~|{"+"{subst:CURRENTDAY}}|{"+"{subst:CURRENTMONTHNAME}}}}";

} otro_boton("http://upload.wikimedia.org/wikipedia/commons/a/aa/Button_question.png", "Consulta de borrado", consultaborrar);

function desconocido(s) { return "{"+"{Sin origen ni licencia|{"+"{subst:CURRENTDAY}}|{"+"{subst:CURRENTMONTHNAME}}}}"; } otro_boton("http://upload.wikimedia.org/wikipedia/commons/2/2a/Button_examine.png", "Imagen sin origen ni licencia", desconocido);

function incompleta(s) { return "{"+"{Sin origen|{"+"{subst:CURRENTDAY}}|{"+"{subst:CURRENTMONTHNAME}}}}"; } otro_boton("http://upload.wikimedia.org/wikipedia/commons/0/01/Button_no_source.png", "Imagen sin origen", incompleta);

function Retirada(s) {

 return "{"+"{Imagen retirada|"+Firma(s)+"}}";

}

otro_boton("http://upload.wikimedia.org/wikipedia/commons/2/2d/Button_removed.png", "Imagen retirada", Retirada);

function gif(s) { return '{'+'{gif}}'; } otro_boton("http://upload.wikimedia.org/wikipedia/commons/d/da/Button_nogifs.png", "Quema los GIFs", gif);


function GFDL(s) {

 return "{"+"{GFDL}}";

} otro_boton("http://upload.wikimedia.org/wikipedia/commons/8/87/Button_gfdl.png", "Licencia GFDL", GFDL);

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 Tachar (s) { return "" + s + ""; } otro_boton("http://upload.wikimedia.org/wikipedia/commons/3/3d/Button_tachar.png", "Tachado", Tachar);


function fusionar(s) {

 return "{"+"{fusionar|" + s + "}}";

} otro_boton("http://upload.wikimedia.org/wikipedia/commons/b/be/Button_merge_articles.png", "Fusionar", fusionar);


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 ''+s+'';

}

otro_boton("http://upload.wikimedia.org/wikipedia/commons/e/e1/Button_smiley.png", "Emoticono", ponWEI);

function innecesaria(s) {

 return "{"+"{innecesaria}}";}

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


function Firma(s) {

 return "~"+"~~  ~~"+"~~"+"~";

} otro_boton("http://es.wikipedia.org/style/images/button_sig.png", "Mi firma", Firma);

// 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;