Usuario:Chixpy/scripts/funciones-full.js

De Inciclopedia
Ir a la navegación Ir a la búsqueda

Nota: Después de publicar, quizás necesite actualizar la caché de su navegador para ver los cambios.

  • Firefox/Safari: Mantenga presionada la tecla Shift mientras pulsa el botón Actualizar, o presiona Ctrl+F5 o Ctrl+R (⌘+R en Mac)
  • Google Chrome: presione Ctrl+Shift+R (⌘+Shift+R en Mac)
  • Internet Explorer/Edge: mantenga presionada Ctrl mientras pulsa Actualizar, o presione Ctrl+F5
  • Opera: Presiona Ctrl+F5.
/*
[http://inciclopedia.wikia.com/index.php?title=Usuario:Chixpy/scripts/funciones-full.js&action=raw&ctype=text/css&smaxage=18000 Para refrescar rápido]

Funciones de la Barra de herramientas del Monobook-Suite
Autor: Axxgreazz, para el [http://es.wikipedia.org/wiki/Usuario:Axxgreazz/Monobook-Suite Monobook-Suite]
* Modificada por Chixpy para su uso en [http://inciclopedia.wikia.com/wiki/User:Chixpy/IMBS2 Inciclopedia] (y otras wikis de wikia).

==Módulos auxiliares==
<pre><nowiki>*/


incluir ("","","tablas.js");       /*Módulo de Tablas */
incluir ("","","tildes.js");       /*Módulo de Tildes */
incluir ("","","titulos.js");      /*Módulo de Titulos */
incluir ("","","operadores.js");   /*Módulo de Operadores */
incluir ("","","searchbox.js");    /*Módulo de Busqueda y reemplazo */
incluir ("","","interface.js");    /*Funciones varias */

/*</nowiki></pre>

==Funciones de edición==
<pre><nowiki>*/

// Pone el texto seleccionado en negrita
function negrita () { insertTags("'''", "'''", 'Texto en negrita'); }

// Pone el texto seleccionado en cursiva
function cursiva () { insertTags("''", "''", 'Texto en cursiva'); }

// Hace un enlace interno con el texto seleccionado
function enlace_interno () { insertTags('[' + '[', ']' + ']', 'Título del enlace'); }   

// Hace un enlace externo con el texto seleccionado
function enlace_externo () { insertTags('[', ']', 'http://www.ejemplo.com Título del enlace');}      

// Convierte el texto seleccionado en un Título de 1er orden
function titular () { insertTags('\n==', '==', 'Texto de titular'); }

// Convierte el texto seleccionado en una imagen
function imagen () { insertTags('[' + '[Image:', ']' + ']', 'Ejemplo.jpg'); }       

// Convierte el texto seleccionado en un archivo de media (sonido)
function media (){ insertTags('[' + '[Image:', ']' + ']', 'Ejemplo.ogg'); }

// Convierte el texto seleccionado en una fórmula
function matematica (){insertTags('<' + 'math>', '<' + '/math>', 'Fórmula_Matemática(LaTeX)');}

// Quita el formato Wiki
function formatowiki() {insertTags('<' + 'nowiki>', '<' + '/nowiki>', 'Sin wikiformato'); }    

// Tacha el texto seleccionado
function tachar (){insertTags('<' + 's>', '<' + '/s>', 'Texto tachado'); }       

// Convierte en enlace a plantilla
function llaves () {insertTags('{' + '{', '}' + '}', 'Plantilla'); }       

// Añade una línea horizontal
// Además hace un salto de linea necesario para que no salgan 4 guiones
function linea () {insertTags('\n' + '----' + '\n', '', ''); }

//Crea un enlace a un usuario
function usuario(){insertTags('[' + '[User:', '|]' + ']', 'Nombre Usuario'); }

//Mensaje por defecto para la bienvenida del usuario
function bienvenido_usuario ()
{/* Para hacer que se detecte automáticamente si se saluda a una IP o un usuario registrado */
   var ip_re = /\d+\.\d+\.\d+\.\d+$/;
   if (ip_re.test(get_title())) 
   {
      insertTags('{' + '{bienvenido}}' +
      '{' + '{User:' + wgUserName +'/Bienvenida IP}}' + ' ', '', '');
      firma();
      sumario('Bienvenida a IP');
   }
   else 
   {
      insertTags('{' + '{bienvenido}}' +
      '{' + '{User:' + wgUserName + '/Bienvenida}}' + ' ', '', '');
      firma();
      sumario('Bienvenida al usuario');
   }
}

function superindice() { insertTags('<sup>','</sup>','Texto superindice'); }

function subindice() { insertTags('<sub>','</sub>','Texto subindice'); }

function code() { insertTags('<c'+'ode><'+'nowiki>','<'+'/nowiki>'+'<'+'/code>','Código fuente'); }


/*</nowiki></pre>

==Funciones de de asistentes y cuadros de diálogo==
<pre><nowiki>*/

// Añade una categoría al final de artículo
function category()
{
   Qr='';
   if(!Qr){void(Qr=prompt('Categoría:',''));}
   if(Qr)
   {
     document.getElementById("wpTextbox1").value =
        document.getElementById("wpTextbox1").value + '\n' + '[' +
        '[Category:'+ Qr+ '|{'+ '{PAGENAME}' + '}]' + ']';
     sumario('[' + '[Category:' + Qr+']] ');
   }
}

// Muestra un mensaje con el tamaño del artículo
function tamaño_articulo()
{  
   alert ("Tamaño: " + document.getElementById("wpTextbox1").value.length + " caracteres.");
} 

function redireccionar()
{
   Qr = '';
   if(!Qr){void(Qr = prompt('¿Redireccionar hacia?',''));}
   if(Qr)
     { document.getElementById("wpTextbox1").value = '#' + 'REDIRECT [' + '[' + Qr + ']]';
       document.editform.wpSummary.value = 'IMBS2: Redireccionando a [' + '[' + Qr + ']]'; 
     }
}

/*</nowiki></pre>

==Inserción de plantillas==
<pre><nowiki>*/

// Añade cualquier plantilla al principio del texto
function PonPlantilla (plantilla) {
   document.getElementById("wpTextbox1").value = '{' + '{'+ plantilla +'}' + '}' + '\n' + document.getElementById("wpTextbox1").value;
   sumario('{' + '{'+ plantilla +'}' + '}');
}

// Añade cualquier plantilla al final del texto
function PonPlantillaAbajo (plantilla) {
   document.getElementById("wpTextbox1").value = document.getElementById("wpTextbox1").value + '\n' +  '{' + '{'+ plantilla +'}' + '}';
   sumario('{' + '{'+ plantilla +'}' + '}');
}

// Añade la platilla Avisoborrado (Pregunta los minutos)
function avisoborrar()
{  
   Qr='';
   void(Qr=prompt('Minutos para la destrucción:','30'));
   if(Qr) {PonPlantilla ('Avisoborrado|' + Qr);}
}

function PlantillaArreglar()
{  
   Qr='';
   void(Qr=prompt('Cosas que arreglar:','Enmendando el formato'));
   if(Qr) {PonPlantilla ('Arreglar|' + Qr);}
}

function PlantillaFusionar()
{
   Qr='';
   void(Qr = prompt('Fusionar con:',''));
   if(Qr) {PonPlantilla ('Fusionar|' + Qr);}
}

function SinFirmar()
{
   Qr='';
   void(Qr = prompt('Usuario que no ha firmado:',''));
   if(Qr) {insertTags('{' + '{Firma|' + Qr + '}' + '}', '', '');}
}

function PonEmoticono (emoticono) {
    insertTags('{' + '{' + emoticono + '}' + '}', '', '');
}

/*</nowiki></pre>

==Otras funciones==
<pre><nowiki>*/
function guardar(){ document.editform.submit();}

function previsualizar() { document.editform.wpPreview.click(); }

// Añade la firma
function firma ()
{
    if (wpFirmaDinamica) {
     insertTags('', '{' + '{User:' + wgUserName +'/Firma}} ~~' + '~~' + '~', '');
    }
    else
    {
     insertTags('', '--'+'~~'+'~~', '');
    }   
}

/*</nowiki></pre>
==Funciones internas==
<pre><nowiki>*/
function sumario (texto)
{
    if (document.editform.wpSummary.value) { texto= ', ' + texto;}
    else {document.editform.wpSummary.value = 'IMBS2: ';}
    document.editform.wpSummary.value=document.editform.wpSummary.value + texto;
}
//</nowiki></pre>