User:Guradi/monobook.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | The accompanying .css page for this skin is at User:Guradi/monobook.css. |
/*
Monobook desarrollado por [[Usuario:Axxgreazz]]. (versión 2.0)
*Puedes ver el manual completo y las funcionalidades contenidas aquí en [[Usuario:Axxgreazz/Monobook-Suite|la página del Monobook-Suite]]
*Si necesitas mayores detalles sobre la configuración revisa el [[Usuario:Axxgreazz/Monobook-Suite/Configuración|Manual de configuración del Monobook-Suite]].
*Si quieres configurarlo de manera rápida usa el [[Usuario:Axxgreazz/Monobook-Suite/Panel de control|Panel de control]]. */
//<pre><nowiki>
/* Sección 1: Inicialización de monobook (No modificar) */
incluir ("","","init.js");
incluir ("","","funciones.js");
/* Sección 2: Personalización de Modulos */
/* Copia cualquiera de los archivos indicados a continuación a tu espacio de usuario */
/* y personaliza tus botones de la barra de herramientas, busqueda y enlaces wiki */
incluir ("","","misparametros-full.js");
incluir ("","","misfunciones.js");
incluir ("","","misbotones-full.js");
incluir ("","","misbuscadores-full.js");
incluir ("","","misenlaces-full.js");
incluir ("","","misflotantes-full.js");
/* Sección 3 : Modulos del monobook
/* Puedes incorporar un módulo de esta u otra wiki */
/* Tan sólo especifica el host de la wiki, el nombre del usuario y el nombre de archivo */
incluir ("","","toolbarextendido.js"); /*Módulo de Barra de herramientas */
incluir ("","","enlaceswiki.js"); /*Módulo de Enlaces Wiki */
incluir ("","","modulobusqueda.js"); /*Módulo de Búsqueda */
incluir ("","","popups.js"); /*Módulo de Popups */
incluir ("","","instaview.js"); /*Módulo de Instaview */
incluir ("","","recent.js"); /*Módulo Anti-vandalismo */
incluir ("","","reversion.js"); /*Módulo de Reversión */
incluir ("","","statuschanger.js"); /*Administración de estados */
incluir ("","","quickedit.js"); /*Edición rápida */
incluir ("","","panelcontrol.js"); /*Panel de control del Monobook */
incluir ("","","quickimgdelete.js"); /*Mantenimiento de imágenes */
incluir ("","","botoneraflotante.js"); /*Botonera flotante */
/* Sección 4: Función base (No modificar) */
function incluir(url,usuario,nombre)
{
if (url=="") {url = 'es.wikipedia.org'; }
if (usuario=="") {usuario = 'Axxgreazz/Monobook-Suite'; }; /*no cambiar */
document.write('<script type="text/javascript" src="'
+ 'http://' + url + '/w/index.php?title=User:' + usuario
+ '/' + nombre + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
}
//</nowiki></pre>
/*<pre>*/
/* * * * * * * * * * * * * * * * * *
* MediaWiki QuickEdit 2 by ASM
* Version: Mai 2007
* * * * * * * * * * * * * * * * * *
*
* How to use
*
* Insert into your monobook.js:
*
* document.write('<script src="'
* + 'http://de.wikipedia.org/w/index.php?title=Benutzer:ASM/quickedit.js'
* + '&action=raw&ctype=text/javascript"></script>');
*
* And (optionally) these variables:
*
* var qeEnabled = true; // Activate Script?
* var qeEnableSection0 = true; // Enable QuickEdit link for section 0 (introduction)?
* var qeEnableAccessKeys = true; // Activate access keys?
* var qeTextboxHeight = 20; // Height of the textbox
*
* * * * * * * * * * * * * * * * * */
/////////// Einstellungen ///////////
// -> Standardeinstellungen zuweisen
if (typeof(qeEnabled) == 'undefined') qeEnabled = true;
if (typeof(qeEnableSection0) == 'undefined') qeEnableSection0 = true;
if (typeof(qeTextboxHeight) == 'undefined') qeTextboxHeight = 20;
if (typeof(qeEnableAccessKeys) == 'undefined') qeEnableAccessKeys = true;
/*if (typeof(qeShowErrors) == 'undefined')*/ qeShowErrors = true;
//////// Ende Einstellungen ////////
var qeVersion = '2.1-2239';
// only initialize once
var qeIsInit = false;
// 2D-Array mit allen Sections und den jeweiligen Unterknoten
var qeSections = new Array();
// Aktuell bearbeitete Section
var qeEdit = -1;
// Aktuell im Vorschau-Modus?
var qePreviewMode = false;
var qePreviewDisabled = false;
// preferences mode
var qePref = null;
var qePrefMode = false;
// Link zum Bearbeiten der Abschnitte
var qeEditLink = false;
// Knoten
var qeParent = false;
var qeForm = false;
var qePreview = false;
// Form action
var qeFormAction = false;
// XmlHttpRequest
var qeRequest = false;
// 0 = idle 1 = receive 2 = submit
var qeRequestState = 0;
// ondblclick
var qeOnDoubleClick = null;
// special chars sticky?
var qeStickyMode = true;
// scroll mode?
var qeScrollMode = true;
var qeTextboxHeightPixel = false;
// Language stuff
// languages (in order of the phrase array)
var qeLanguages = [
['de', 'Deutsch'],
['en', 'English'],
['ca', 'Catalan'],
['es', 'Español']
];
var qePhrases = [
['quickedit', 'QuickEdit', 'QuickEdit', 'QuickEdit', 'QuickEdit'],
['submit', 'Speichern', 'Submit', 'Desa', 'Guardar'],
['preview', 'Vorschau', 'Preview', 'Previsualitza', 'Prev.'],
['cancel', 'Abbrechen', 'Cancel', 'Cancel·la', 'Cancelar'],
['k', 'Kleine Änderungen', 'minor', 'menor', 'Ed. menor'],
['b', 'Beobachten', 'watch', 'Vigila', 'Vigilar'],
['error', 'Fehler', 'error', 'error', 'Error'],
['nolinksfound', 'Keine Links gefunden', 'No links found', 'No s`ha trobat cap enllaç', 'No se han encontrado enlaces'],
['loading', 'Lade Daten', 'Loading data', 'Carregant dades', 'Espérate un momento, que no hay prisa. Que ahora te pongo el texto... mientras puede leer el periódico'],
['liveprev', 'Live Vorschau', 'Live Preview', 'Previsualització instantània', 'Prev. Rápida'],
['loadprev', 'Lade Vorschau', 'Loading preview', 'Carregant previsualització', '¿Seguro que quieres previsualizar esa chapuza de código? Estoy buscando un un especialista en criptógrafía para descifrarlo.'],
['sticky', 'Sonderzeichenleiste feststellen', 'Sticky', 'Sticky', 'Modo fijo, fijo que no sabes a que se refiere.'],
['noprev', 'Fehler: Vorschau nicht verfügbar (Seite konnte von JavaScript nicht gelesen werden)',
'Error: preview not available (page could not be read by JavaScript)',
'Error: Previsualització no disponible (la pàgina no es pot llegir amb JavaScript)', 'ERROR: Cagüen la leche, el criptógrafo no está disponible así que no te lo puedo previsualizar, pero puedes probar la otra previsualización'],
['header', 'MediaWiki QuickEdit 2.1',
'MediaWiki QuickEdit 2.1',
'MediaWiki QuickEdit 2.1',
'MediaWiki QuickEdit 2.1'],
['tQuickEdit', 'QuickEdit Ansicht (KEY:E)',
'QuickEdit view (KEY:E)',
'Visualitza amb QuickEdit (telca:E)',
'Ver el editor de QuickEdit (KEY:E)',],
['tLivePrev', 'Live Vorschau (KEY:P)',
'Live preview (KEY:P)',
'Previsualització (tela:P)',
'Previsualización rápida (KEY:P)'],
['tSubmit', 'Änderungen Speichern (KEY:S)',
'Submit changes (KEY:S)',
'Desa els canvis (KEY:S)',
'Guardar (KEY:S)'],
['tPreview', 'Normale Vorschau', 'Normal preview', 'Previsualització normal', 'Previsualización normal'],
['tCancel', 'Abbrechen (KEY:A)', 'Cancel (KEY:A)', 'Cancel·la (KEY:A)', 'Cancelar (KEY:A)'],
['tWatch', 'Beobachten (KEY:W)', 'Watch (KEY:W)', 'Vigila (KEY:W)', 'Vigilar (KEY:W)'],
['tMinor', 'Kleine Änderungen (KEY:I)',
'Minor edit (KEY:I)',
'Edició menor (KEY:I)',
'Edición menor (MOD+I)'],
['scrollon', 'Ansicht einklappen (feste Höhe)',
'collapse view (fixed height)',
'',
'Vista condensada (altura fija)'],
['scrolloff', 'Ansicht erweitern (volle Höhe)',
'expand view (full height)',
'',
'Vista expandida (tamaño completo)'],
['strg', 'Strg', 'Ctrl', 'Ctrl', 'CTRL'],
['shift', 'Umschalt', 'Shift', 'mayús', 'MAYS'],
['pref', 'Einstellungen', 'Preferences', '', 'Preferencias'],
['prefheading', 'QuickEdit Einstellungen',
'QuickEdit Preferences',
'',
'Preferencias QuickEdit'],
['oqeScrollMode', 'Scroll Modus aktivieren','','','Modo Scroll'],
['oqeStickyMode', 'Sticky Modus aktivieren','','','Modo Fijo']
];
var qeImages = [
['stickyon', 'c:d/d1/Snes9x_ledon.png'],
['stickyoff', 'c:d/dd/Snes9x_ledoff.png'],
['arrowup', 'c:1/13/WikEd_align_top.png'],
['arrowdown', 'c:a/a8/WikEd_align_down.png']
];
// array content: var name | var type | default value | user value
// phrase name describing the option is is "'o' + var name"
// the user value will be read by the script from a cookie
// if there is no value set, the default value will be used
var qeOptions = [
['qeScrollMode', 'bool', 'true', null],
['qeStickyMode', 'bool', 'false', null]
];
function qeGetBGColor()
{
var ret = qeGetStyle(document.getElementById('content'), 'background-color');
return ret?ret:'#fff';
}
function qeGetStyle(elem, style)
{
if (document.defaultView)
return document.defaultView.getComputedStyle(elem, null).getPropertyValue(style);
return null;
}
function qeSetLang()
{
// default: English
qeLang = 2;
for (var i = 0; i < qeLanguages.length; i++)
if (qeLanguages[i][0] == wgUserLanguage)
{
qeLang = i + 1;
break;
}
qeSetPrefix();
}
function qePhrase(name)
{
for (var i = 0; i < qePhrases.length; i++)
if (qePhrases[i][0] == name)
return qePhrases[i][qeLang];
return 'UNDEFINED PHRASE: ' + name;
}
function qeSetPrefix()
{
// ausgeliehen vom Wikipedia-Script
var pref = 'Alt';
if (is_safari || navigator.userAgent.toLowerCase().indexOf('mac') + 1
|| navigator.userAgent.toLowerCase().indexOf('konqueror') + 1 )
pref = qePhrase('strg');
else if (is_opera) pref = qePhrase('shift') + '-Esc';
else if (is_ff2_x11) pref = qePhrase('strg') + '-' + qePhrase('shift');
else if (is_ff2_win) pref = 'Alt-' + qePhrase('shift');
pref += '-';
var n = qePhrases[0].length;
for (var i = 0; i < qePhrases.length; i++)
{
// check for KEY:
if (qePhrases[i][0].charAt(0) == 't')
for (var j = 1; j < qePhrases[i].length; j++)
qePhrases[i][j] = qePhrases[i][j].replace(/KEY:(.)/, pref + '$1');
// check for completeness
var d = n - qePhrases[i].length,
p = (qePhrases[i].length >= 3) ? 2 : qePhrases[i].length-1;
while (d > 0) qePhrases[i][n-d--] = qePhrases[i][p] + '**';
}
}
function qeImage(name)
{
var commonsurl = 'http://upload.wikimedia.org/wikipedia/commons/';
for (var i = 0; i < qeImages.length; i++)
if (qeImages[i][0] == name)
{
if (qeImages[i][1].indexOf('c:') == 0)
return commonsurl + qeImages[i][1].substr(2);
return qeImages[i][1];
}
return '';
}
////// Start Script //////
$(qeInit);
function qeInit()
{
var qeEnabled = (document.location.search.indexOf("printable=yes") == -1);
if (!qeEnabled || qeIsInit) return;
qeIsInit = true;
// check if page is editable
if (!document.getElementById('ca-edit')) return;
// check if there is no other action than view
var pos = document.location.href.indexOf('action=');
if (pos != -1 && document.location.href.substr(pos+7, 4) != 'view') return;
qeSetLang();
if (!qeInitAjax()) return;
qeChangeSectionLinks();
}
function qeContentSub(text)
{
var cs = document.getElementById('contentSub');
if (cs.innerHTML)
cs.innerHTML += ' - ' + text;
else
cs.innerHTML = text;
}
function qeShowError(err)
{
if (qeShowErrors) qeContentSub(qePhrase('quickedit') + ' ' + qePhrase('error') + ': ' + err);
}
function qeAlert(err)
{
alert(qePhrase('quickedit') + ' ' + qePhrase('error') + ': ' + err);
}
function qeGetElementsByClassName(tagname, classname)
{
var ret = new Array();
var tags = document.getElementsByTagName(tagname);
for (i = 0; i < tags.length; i++)
if (tags[i].className == classname)
ret.push(tags[i]);
return ret;
}
function qeChangeSectionLinks()
{
qeEditLink = document.getElementById('ca-edit').firstChild.href + '§ion=';
// get all sections
var sections = qeGetElementsByClassName('span', 'editsection');
var jumptonav = document.getElementById('jump-to-nav');
// Hauptabschnitt
if (qeEnableSection0)
{
var heading = qeGetElementsByClassName('h1', 'firstHeading')[0];
if (!heading || !jumptonav)
qeShowError('Por favor habilite en preferencias, menu miscelánea, la opción "Habilitar enlaces de accesibilidad «saltar a»".');
else
{
// id verpassen
heading.id = 'section-0';
// Knoten ins Array packen
qeSections[0] = new Array();
var nosections = (sections.length == 0);
var node = jumptonav.nextSibling;
while (node != null && node.className != 'editsection'
&& node.className != 'printfooter' && (nosections|| !/^H[1-6]$/.test(node.nodeName)))
{
if (node.nodeName.charAt(0) != '#')
qeSections[0].push(node);
node = node.nextSibling;
}
// Link hinzufügen
var newspan = document.createElement('span');
newspan.style.fontSize = '8pt';
newspan.style.marginLeft = '10px';
newspan.appendChild(document.createTextNode('['));
var newlink = document.createElement('a');
newlink.href = 'javascript:qeEditSection(0)';
newlink.id = 'sectionlink-0';
newlink.className = 'sectionlink';
newlink.appendChild(document.createTextNode(qePhrase('quickedit')));
newspan.appendChild(newlink);
newspan.appendChild(document.createTextNode(']'));
heading.appendChild(newspan);
}
} // qeEnableSection0
// Abschnitte
for (i = 0; i < sections.length; i++)
{
// Section-Link suchen
var link = sections[i].childNodes[1].href;
var section = null, match = null;
if (match = /section=([0-9]+)/.exec(link))
var section = +match[1];
else break;
if (!section) continue;
sections[i].style.fontSize = '8pt';
// QuickEdit-Link erstellen
var newnode = document.createElement('a');
newnode.href = 'javascript:qeEditSection(' + section + ')';
newnode.title = 'QuickEdit Section ' + section;
newnode.id = 'sectionlink-' + section;
newnode.className = 'sectionlink';
newnode.appendChild(document.createTextNode(qePhrase('quickedit')));
var where = sections[i].childNodes[2];
sections[i].insertBefore(document.createTextNode('/'), where);
sections[i].insertBefore(newnode, where);
////
// dem div eine ID verpassen
sections[i].id = 'editsection-' + section;
// zugehörige hX Überschrift suchen
var hx = sections[i].parentNode;
hx.id = 'section-' + section;
////
// alle zu dieser Section gehörigen Knoten suchen und ins Array packen
qeSections[section] = new Array();
var node = hx.nextSibling;
while (node != null && node.className != 'editsection'
&& node.className != 'printfooter' && !/^H[1-6]$/.test(node.nodeName))
{
if (node.nodeType == 1)
qeSections[section].push(node);
node = node.nextSibling;
}
}
}
function qeEditSection(section)
{
if (qeRequestState || !qeEditLink) return;
section = parseInt(section);
// es wird bereits ein Abschnitt bearbeitet
// wenn es der aktuelle ist -> Bearbeiten abbrechen, sonst nichts tun
if (qeEdit != -1)
{
if (qeEdit == section) qeAbortEdit(section);
return;
}
qeEdit = section;
// save body.ondblclick
if (document.getElementsByTagName('body')[0].getAttribute('ondblclick'))
{
qeOnDoubleClick = document.getElementsByTagName('body')[0].getAttribute('ondblclick');
document.getElementsByTagName('body')[0].setAttribute('ondblclick', null);
}
// Inhalt des Abschnitts ausblenden
var nodes = qeSections[section];
for (i = 0; i < nodes.length; i++)
nodes[i].style.display = 'none';
////
// andere Links ändern
var links = qeGetElementsByClassName('a', 'sectionlink');
for (i = 0; i < links.length; i++)
{
if (links[i].id != 'sectionlink-' + qeEdit)
links[i].style.color = '#bfbfbf';
}
// Form anzeigen
qeMakeForm();
var hx = document.getElementById('section-' + section);
hx.parentNode.insertBefore(qeParent, hx.nextSibling);
qeForm.firstChild.childNodes[4].value = qePhrase('loading') + '...';
////
// save textboxheight
if (!qeTextboxHeightPixel)
qeTextboxHeightPixel = qeGetStyle(document.getElementById('wpTextbox1'), 'height') ||
Math.Round(qeTextboxHeight * 16.8) + 'px';
// make sure the QuickEdit tab is activated
qeSwitch(0);
qeGetSection();
}
function qeAbortEdit()
{
if (qeEdit == -1 || qeRequestState) return;
// Inhalt des Abschnitts wieder einblenden
var nodes = qeSections[qeEdit];
for (i = 0; i < nodes.length; i++)
nodes[i].style.display = is_gecko?null:'block';
var links = qeGetElementsByClassName('a', 'sectionlink');
for (i = 0; i < links.length; i++)
{
if (links[i].id != 'sectionlink-' + qeEdit)
links[i].style.color = null;
}
qeParent.parentNode.removeChild(qeParent);
qeForm.firstChild.childNodes[4].value = '';
qeEdit = -1;
qeRequest.abort();
// restore body.ondblclick
if (qeOnDoubleClick)
document.getElementsByTagName('body')[0].setAttribute('ondblclick', qeOnDoubleClick);
}
function qeMakeForm()
{
if (qeForm) return;
if (qeSections.length == 1) qeTextboxHeight += 5; // higher textbox for the main section only
// create parent div
qeParent = document.createElement('div');
qeParent.style.clear = 'both';
// create tabs
var ul = document.createElement('ul');
ul.style.listStyle = 'none';
ul.style.whiteSpace = 'nowrap';
ul.style.fontSize = '11.3px';
ul.style.position = 'relative';
ul.style.bottom = '0px';
ul.style.borderCollapse = 'collapse';
var li1 = document.createElement('li');
var a = document.createElement('a');
a.href = 'javascript:qeSwitch(0)';
a.style.textDecoration = 'none';
a.style.padding = '0 8px';
a.appendChild(document.createTextNode(qePhrase('quickedit')));
li1.appendChild(a);
li1.id = 'qeTabEdit';
li1.title = qePhrase('tQuickEdit');
li1.style.border = '1px solid #aaa';
li1.style.borderBottom = 'none';
li1.style.marginRight = '6px';
li1.style.display = 'inline';
li1.style.backgroundColor = '#fafafa';
li1.setAttribute('onmouseover', 'qeTabMouseOverOut(this, 0)');
li1.setAttribute('onmouseout', 'qeTabMouseOverOut(this, 1)');
var li2 = li1.cloneNode(true);
li2.id = 'qeTabPreview';
li2.title = qePhrase('tLivePrev');
li2.firstChild.href = 'javascript:qeSwitch(1)';
li2.firstChild.firstChild.nodeValue = qePhrase('liveprev');
// make li1 look selected
li1.style.borderColor = '#888';
li1.style.borderBottom = 'none';
li1.style.fontWeight = 'bold';
// tab 3
var li4 = li2.cloneNode(true);
li4.id = null;
li4.style.marginLeft = '16px';
li4.title = qePhrase('tSubmit');
li4.firstChild.href = 'javascript:qeSubmit(0)';
li4.firstChild.firstChild.nodeValue = qePhrase('submit');
if (qeEnableAccessKeys) li4.firstChild.accessKey = 's';
// tab 4
var li5 = li2.cloneNode(true);
li5.id = null;
li5.title = qePhrase('tPreview');
li5.firstChild.href = 'javascript:qeSubmit(1)';
li5.firstChild.firstChild.nodeValue = qePhrase('preview');
// tab 5
var li6 = li2.cloneNode(true);
li6.id = null;
li6.title = qePhrase('tCancel');
li6.firstChild.href = 'javascript:qeAbortEdit()';
li6.firstChild.firstChild.nodeValue = qePhrase('cancel');
if (qeEnableAccessKeys)
{
li6.firstChild.accessKey = 'a'; // cancel
li1.firstChild.accessKey = 'e'; // quickedit
li2.firstChild.accessKey = 'p'; // live prev
}
var li3 = document.createElement('li');
li3.style.cssFloat = 'right';
li3.style.marginRight = '10px';
li3.style.color = '#aaa';
li3.style.fontSize = '8pt';
li3.style.display = 'inline';
li3.style.cursor = 'default';
li3.title = 'MediaWiki QuickEdit ' + qeVersion;
li3.appendChild(document.createTextNode(qePhrase('header')));
// options tab
var li7 = li2.cloneNode(true);
li7.id = 'qeTabPref';
li7.title = qePhrase('pref');
li7.style.marginLeft = '16px';
li7.firstChild.href = 'javascript:qePreferences()';
li7.firstChild.firstChild.nodeValue = qePhrase('pref');
ul.appendChild(li3);
ul.appendChild(li1);
ul.appendChild(li2);
ul.appendChild(li4);
ul.appendChild(li5);
ul.appendChild(li6);
// ul.appendChild(li7); // new feature: wip. temporarily disabled
qeParent.appendChild(ul);
// create frame div
var framediv = document.createElement('div');
framediv.style.border = '1px solid #aaa';
framediv.style.padding = '6px';
framediv.style.overflow = 'hidden';
framediv.style.clear = 'both';
framediv.style.backgroundColor = '#fafafa';
qeParent.appendChild(framediv);
// create form
qeForm = document.createElement('form');
qeForm.method = 'post';
qeForm.onsubmit = qeSubmitByReturn;
// create preview div
qePreview = document.createElement('div');
qePreview.style.display = 'none';
qePreview.style.width = '98%';
qePreview.style.overflow = qeScrollMode ? 'scroll':'hidden';
qePreview.style.clear = 'both';
qePreview.style.padding = '5px';
qePreview.style.border = '1px dotted #aaa';
qePreview.style.backgroundColor = qeGetBGColor();
// preview message
var div = document.createElement('div');
div.style.padding = '100px 0';
div.style.textAlign = 'center';
div.style.color = '#aaa';
div.style.cursor = 'default';
div.appendChild(document.createTextNode(qePhrase('loadprev') + '...'));
qePreview.appendChild(div);
framediv.appendChild(qePreview);
framediv.appendChild(qeForm);
////
// add form div
qeForm.appendChild(document.createElement('div'));
var elements = new Array(
// subject type name
new Array('input', 'hidden', 'wpSection'),
new Array('input', 'hidden', 'wpStarttime'),
new Array('input', 'hidden', 'wpEdittime'),
new Array('input', 'hidden', 'wpSummary'),
new Array('textarea', 'wpTextbox1'),
new Array('input', 'hidden', 'wpEditToken'),
new Array('input', 'hidden', 'wpAutoSummary')
);
for (i = 0; i < elements.length; i++)
{
var e = elements[i];
var newnode = document.createElement(e[0]);
if (e[0] == 'input')
{
newnode.type = e[1];
newnode.name = e[2];
}
else if (e[0] == 'textarea')
{
newnode.id = e[1];
newnode.name = e[1];
newnode.appendChild(document.createTextNode(''));
newnode.rows = qeTextboxHeight;
newnode.style.width = '99%';
}
qeForm.firstChild.appendChild(newnode);
}
if (qeEnableAccessKeys) qeForm.firstChild.childNodes[4].accessKey = ',';
qeForm.firstChild.childNodes[4].tabIndex = 1;
var chars = document.createElement('div');
chars.id = 'specialchars-container';
chars.setAttribute('onmouseover', 'qeSpecialcharMouse(this, 0)');
chars.setAttribute('onmouseout', 'qeSpecialcharMouse(this, 1)');
chars.style.minHeight = '5px';
chars.style.overflow = 'hidden';
var img = document.createElement('img');
img.src = qeImage('stickyoff');
img.style.cssFloat = 'right';
img.style.display = 'none';
img.style.margin = '2px';
img.style.verticalAlign = 'middle';
img.style.cursor = 'pointer';
img.id = 'specialchars-sticky';
img.title = qePhrase('sticky');
img.setAttribute('onclick', 'qeToggleSticky()');
chars.appendChild(img);
qeForm.appendChild(chars);
newnode = document.createElement('div');
newnode.style.paddingTop = '5px';
newnode.style.borderTop = '1px dotted #aaa';
// scroll img
img = document.createElement('img');
// img.src = qeImage('arrowdown'); set this at qeSwitch
// img.title = qePhrase('scrollon'); ~
img.id = 'scrollimg';
img.style.marginTop = '3px';
img.style.verticalAlign = 'top';
img.style.cssFloat = 'right';
img.style.display = 'none';
img.style.cursor = 'pointer';
img.setAttribute('onclick', 'qeToggleScroll()');
newnode.appendChild(img);
// Speichern
var c = document.createElement('a');
c.href = 'javascript:qeSubmit(0)';
c.title = qePhrase('tSubmit');
c.style.cursor = 'pointer';
c.appendChild(document.createTextNode(qePhrase('submit')));
newnode.appendChild(c);
// Vorschau
newnode.appendChild(document.createTextNode(' '));
c = document.createElement('a');
c.href = 'javascript:qeSubmit(1)';
c.title = qePhrase('tPreview');
c.style.marginLeft = '5px';
c.style.cursor = 'pointer';
c.appendChild(document.createTextNode(qePhrase('preview')));
newnode.appendChild(c);
// Zusammenfassung
newnode.appendChild(document.createTextNode(' '));
c = document.createElement('input');
c.type = 'text';
c.size = '70';
c.id = 'qeSummary';
c.maxLength = '200';
c.style.marginLeft = '5px';
c.tabIndex = 2;
newnode.appendChild(c);
// Kleine Änderung
newnode.appendChild(document.createTextNode(' '));
var checkboxes = document.createElement('span');
checkboxes.style.whiteSpace = 'nowrap';
checkboxes.appendChild(document.createElement('input'));
checkboxes.childNodes[0].type = 'checkbox';
checkboxes.childNodes[0].id = 'wpMinoredit';
checkboxes.childNodes[0].name = 'wpMinoredit';
checkboxes.childNodes[0].value = '1';
checkboxes.childNodes[0].style.marginLeft = '5px';
checkboxes.childNodes[0].tabIndex = 3;
checkboxes.childNodes[0].title = qePhrase('tMinor');
if (qeEnableAccessKeys) checkboxes.childNodes[0].accessKey = 'i';
checkboxes.appendChild(document.createElement('label'));
checkboxes.childNodes[1].htmlFor = 'wpMinoredit';
checkboxes.childNodes[1].style.fontWeight = 'bold';
checkboxes.childNodes[1].style.fontSize = '8pt';
checkboxes.childNodes[1].style.position = 'relative';
checkboxes.childNodes[1].style.bottom = '2px';
checkboxes.childNodes[1].title = qePhrase('tMinor');
checkboxes.childNodes[1].appendChild(document.createTextNode(qePhrase('k')));
// Beobachten
checkboxes.appendChild(document.createTextNode(' '));
checkboxes.appendChild(document.createElement('input'));
checkboxes.childNodes[3].type = 'checkbox';
checkboxes.childNodes[3].id = 'wpWatchthis';
checkboxes.childNodes[3].name = 'wpWatchthis';
checkboxes.childNodes[3].value = '1';
checkboxes.childNodes[3].style.marginLeft = '5px';
checkboxes.childNodes[3].tabIndex = 4;
checkboxes.childNodes[3].title = qePhrase('tWatch');
if (qeEnableAccessKeys) checkboxes.childNodes[3].accessKey = 'w';
checkboxes.appendChild(document.createElement('label'));
checkboxes.childNodes[4].htmlFor = 'wpWatchthis';
checkboxes.childNodes[4].style.fontWeight = 'bold';
checkboxes.childNodes[4].style.fontSize = '8pt';
checkboxes.childNodes[4].style.position = 'relative';
checkboxes.childNodes[4].style.bottom = '2px';
checkboxes.childNodes[4].title = qePhrase('tWatch');
checkboxes.childNodes[4].appendChild(document.createTextNode(qePhrase('b')));
newnode.appendChild(checkboxes);
qeForm.appendChild(newnode);
}
function qeFillForm(formaction, wpStarttime, wpEdittime, wpSummary, wpTextbox1,
wpEditToken, wpAutoSummary, wpWatchthis)
{
if (!qeForm) return;
// save form action since we need it for preview
qeFormAction = formaction;
qeForm.firstChild.childNodes[0].value = qeEdit;
qeForm.firstChild.childNodes[1].value = wpStarttime;
qeForm.firstChild.childNodes[2].value = wpEdittime;
qeForm.firstChild.childNodes[3].value = wpSummary;
qeForm.firstChild.childNodes[4].value = wpTextbox1;
qeForm.firstChild.childNodes[5].value = wpEditToken;
qeForm.firstChild.childNodes[6].value = wpAutoSummary;
document.getElementById('wpWatchthis').checked = wpWatchthis;
qeForm.action = formaction;
document.getElementById('qeSummary').value = wpSummary;
}
function qeSpecialcharMouse(obj, type)
{
// prevent bar from: • being hidden when sticky is on
// • being shown in preview or preferences mode
// • doing anything if no special chars are available
//
if ((type == 0 && (qePreviewMode || qePrefMode)) ||
!document.getElementById('specialchars'))
return;
if (qeStickyMode) {
for (var i = 0; i < obj.childNodes.length; i++)
obj.childNodes[i].style.display ='inline';
return;
}
for (var i = 0; i < obj.childNodes.length; i++)
obj.childNodes[i].style.display = (type == 0)?'inline':'none';
obj.style.padding = (type == 0)?'4px 0px':'0px';
}
function qeToggleSticky()
{
qeStickyMode = !qeStickyMode;
var img = document.getElementById('specialchars-sticky');
img.src = qeStickyMode ? qeImage('stickyon') : qeImage('stickyoff');
}
function qeToggleScroll()
{
if (!qePreviewMode) return;
qeScrollMode = !qeScrollMode;
var img = document.getElementById('scrollimg');
img.src = qeScrollMode ? qeImage('arrowdown') : qeImage('arrowup');
img.title = qeScrollMode ? qePhrase('scrolloff'): qePhrase('scrollon');
qePreview.style.height = qeScrollMode ? qeTextboxHeightPixel : null;
qePreview.style.overflow = qeScrollMode ? 'scroll' : 'hidden';
}
// QuickEdit 2.1: Preferences stuff
function qePreferences()
{
if (qePrefMode)
{
qePrefMode = false;
qeDestroyPrefForm();
return;
}
qePrefMode = true;
qeMakePrefForm();
}
function qeMakePrefForm()
{
// set the style of the pref tab selected
var tab = document.getElementById('qeTabPref');
tab.style.border = '1px solid #888';
tab.style.borderBottom = 'none';
tab.style.fontWeight = 'bold';
tab.style.marginLeft = '0px';
// hide preview div, the form and the other tabs
qeForm.style.display = 'none';
qePreview.style.display = 'none';
var ul = qeParent.firstChild;
for (var i = 0; i < ul.childNodes.length && ul.childNodes[i] != tab; i++)
ul.childNodes[i].style.display = 'none';
// create pref div
qePref = document.createElement('div');
qePref.style.textAlign = 'center';
qePref.style.minHeight = '200px';
qePref.style.lineHeight = '2em';
qePref.style.border = '1px dotted #aaa';
qePref.style.backgroundColor = '#fff';
var h = document.createElement('div');
h.style.borderBottom = '1px solid #aaa';
h.style.textAlign = 'left';
h.style.fontSize = '14px';
h.style.fontWeight = 'bold';
h.style.paddingLeft = '10px';
h.style.margin = '20px 50px';
h.appendChild(document.createTextNode(qePhrase('prefheading')));
qePref.appendChild(h);
for (var i = 0; i < qeOptions.length; i++)
{
var name = qeOptions[i][0], type = qeOptions[i][1], defaultval = qeOptions[i][2],
userval = qeOptions[i][3];
if (!userval) userval = defaultval;
var e = document.createElement('input'), // input element
d = document.createElement('label'); // description
// set input element attributes
e.id = 'o-' + name;
e.name = e.id;
if (type == 'bool')
{
e.type = 'checkbox';
e.checked = (userval == 'true');
}
// set description attributes
d.htmlFor = e.id;
d.style.fontWeight = 'bold';
d.style.marginRight = '5px';
d.appendChild(document.createTextNode(qePhrase('o' + name)));
qePref.appendChild(d);
qePref.appendChild(e);
if (i != qeOptions.length - 1)
qePref.appendChild(document.createElement('br'));
}
// insert node before preview
qePreview.parentNode.insertBefore(qePref, qePreview);
}
function qeDestroyPrefForm()
{
qePref.parentNode.removeChild(qePref);
qePref = null;
// restore: form, tabs
qeForm.style.display = 'block';
var ul = qeParent.firstChild;
for (var i = 0; i < ul.childNodes.length; i++)
ul.childNodes[i].style.display = 'inline';
// reset tab style
var tab = document.getElementById('qeTabPref');
tab.style.border = '1px solid #aaa';
tab.style.borderBottom = 'none';
tab.style.fontWeight = 'normal';
tab.style.marginLeft = '16px';
qeSwitch(0); // make sure to get back into edit mode
}
// QuickEdit 2: Preview stuff
function qeSwitch(type)
{
if (qeEdit == -1 || qeRequestState || qePrefMode) return;
// apply tab styles (anyway)
var lia = (type == 1)?document.getElementById('qeTabEdit'):
document.getElementById('qeTabPreview');
var lid = (type == 1)?document.getElementById('qeTabPreview'):
document.getElementById('qeTabEdit');
lid.style.border = '1px solid #888';
lid.style.fontWeight = 'bold';
lia.style.border = '1px solid #aaa';
lia.style.fontWeight = 'normal';
lia.style.borderBottom = lid.style.borderBottom = 'none';
// now check if there is any change
type = parseInt(type);
if ((type == 0 && !qePreviewMode) || (type == 1 && qePreviewMode) ||
(qePreviewDisabled && type == 1)) return;
qePreviewMode = !qePreviewMode;
// switch to preview
if (qePreviewMode)
{
qeForm.firstChild.style.display = 'none';
qePreview.style.display = 'block';
qePreview.firstChild.style.display = 'block';
// set scroll mode image
var img = document.getElementById('scrollimg');
img.src = qeScrollMode ? qeImage('arrowdown') : qeImage('arrowup');
img.title = qeScrollMode ? qePhrase('scrolloff'): qePhrase('scrollon');
img.style.display = 'inline';
if (qeScrollMode) qePreview.style.height = qeTextboxHeightPixel;
// remove all child nodes from previous previews, if any
for (var i = 1; i < qePreview.childNodes.length; i++)
qePreview.removeChild(qePreview.childNodes[i]);
qeLoadPreview();
}
else
{
qePreview.style.display = 'none';
qeForm.firstChild.style.display = 'block';
document.getElementById('scrollimg').style.display = 'none';
}
}
function qeLoadPreview()
{
if (qeEdit == -1 || qeRequestState || !qeEditLink || !qePreviewMode || !qeFormAction)
return;
var link = qeEditLink + qeEdit;
qeRequestState = 2;
qeRequest.onreadystatechange = qeAjaxResponse;
qeRequest.open('POST', qeFormAction, true);
var send = qeMakeFormRequest();
qeRequest.overrideMimeType('text/xml');
qeRequest.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
qeRequest.setRequestHeader('Content-length', send.length);
qeRequest.setRequestHeader('Content', send.length);
qeRequest.send(send);
}
function qeMakeFormRequest()
{
if (!qeForm) return null;
var str = '';
var inputs = qeForm.getElementsByTagName('input');
for (var i = 0; i < inputs.length; i++)
if (inputs[i].value && inputs[i].value.length > 0)
str += '&' + inputs[i].name + '=' + encodeURIComponent(inputs[i].value);
str += '&wpPreview=Preview' +
'&wpTextbox1=' +
encodeURIComponent(document.getElementById('wpTextbox1').value);
return str.substr(1);
}
function qeTabMouseOverOut(obj, out)
{
var coloronly = false;
if (obj.id == 'qeTabEdit' || obj.id == 'qeTabPreview' || obj.id == 'qeTabPref')
{
if (qePrefMode)
{
if (obj.id == 'qeTabPref') coloronly = true;
}
else if ((qePreviewMode && obj.id == 'qeTabPreview') ||
(!qePreviewMode && obj.id == 'qeTabEdit'))
coloronly = true;
}
obj.style.backgroundColor = out?'#fafafa':'#fff';
if (!coloronly) obj.style.borderColor = out?'#aaa':'#888';
}
// Ajax stuff
function qeInitAjax()
{
try
{
if (window.XMLHttpRequest)
{
qeRequest = new XMLHttpRequest();
qeRequest.overrideMimeType('text/xml');
}
else if (window.ActiveXObject)
qeRequest = new ActiveXObject('Microsoft.XMLHTTP');
else throw 'Kein AJAX-Objekt vorhanden';
}
catch (e)
{
qeShowError(e);
return false;
}
if (!qeRequest)
{
qeShowError('El AJAX no funciona, vete a saber porqué.');
return false;
}
return true;
}
function qeGetSection()
{
if (qeEdit == -1 || !qeForm || !qeRequest || !qeEditLink || qeRequestState) return;
var link = qeEditLink + qeEdit;
qeRequestState = 1;
qeRequest.onreadystatechange = qeAjaxResponse;
qeRequest.open('GET', link, true);
qeRequest.send(null);
}
function qeAjaxResponse()
{
if (!qeRequestState)
{
alert('Error de QuickEdit: "qeAjaxResponse".\nSi has previsualizado de forma rápida y cancelado suele saltar este error... A saber porqué...');
return;
}
// receive
if (qeRequestState == 1 && qeEdit != -1)
{
if (qeRequest.readyState != 4 || qeRequest.status != 200)
return;
qeRequestState = 0;
var xml = qeRequest.responseXML;
try // MediaWiki bug 6986 workaround
{
var wpTextbox1 = xml.getElementById('wpTextbox1').value;
}
catch (e)
{
xml = qeFixXML(qeRequest.responseText);
if (!xml)
{
qeShowError('Hay algo que no cumple los estándares XML. Wikia seguro que ha añadido algo...');
return;
}
var wpTextbox1 = xml.getElementById('wpTextbox1').value;
}
var inputs = xml.getElementsByTagName('input');
for (i = 0; i < inputs.length; i++)
{
if (inputs[i].name == 'wpSection') wpSection = inputs[i].value;
else if (inputs[i].name == 'wpStarttime') wpStarttime = inputs[i].value;
else if (inputs[i].name == 'wpEdittime') wpEdittime = inputs[i].value;
else if (inputs[i].name == 'wpSummary') wpSummary = inputs[i].value;
else if (inputs[i].name == 'wpEditToken') wpEditToken = inputs[i].value;
else if (inputs[i].name == 'wpAutoSummary') wpAutoSummary = inputs[i].value;
else if (inputs[i].name == 'wpWatchthis') wpWatchthis = inputs[i].checked;
}
var formaction = xml.getElementById('editform').action;
var specialchars = document.getElementById('specialchars-container');
if (specialchars.childNodes.length <= 1 && xml.getElementById('specialchars'))
{
var node = xml.getElementById('specialchars').cloneNode(true);
node.style.display = 'none';
node.style.background = 'none';
node.style.border = 'none';
node.style.fontSize = '8pt';
for (var i = 0; i < node.childNodes.length; i++)
if (node.childNodes[i].nodeName == 'A')
{
node.removeChild(node.childNodes[i]);
node.removeChild(node.childNodes[i+1]);
break;
}
specialchars.appendChild(node);
addCharSubsetMenu(); // wikipedia script
}
// sollte nie passieren, wenn doch -> fatal error
if (wpSection != qeEdit)
{
qeAlert(qePhrase('varmismatch'));
qeRequestState = 0;
qeAbortEdit();
return;
}
qeFillForm(formaction, wpStarttime, wpEdittime, wpSummary, wpTextbox1,
wpEditToken, wpAutoSummary, wpWatchthis);
return;
}
// preview (submit)
if (qeRequestState == 2 && qeEdit != -1)
{
if (qeRequest.readyState != 4 || qeRequest.status != 200)
return;
qeRequestState = 0;
try
{
var xml = qeRequest.responseXML;
var prev = xml.getElementById('wikiPreview').cloneNode(true);
}
catch (e)
{
var xml = qeFixXMLPreview(qeRequest.responseText);
if (!xml)
{
qePreviewDisabled = true;
qePreview.firstChild.firstChild.nodeValue = qePhrase('noprev');
var tab = document.getElementById('qeTabPreview');
tab.firstChild.style.color = '#888';
return;
}
var prev = xml.getElementById('wikiPreview').cloneNode(true);
}
qePreview.firstChild.style.display = 'none';
while (prev.childNodes.length > 0 && prev.firstChild.className != 'previewnote')
prev.removeChild(prev.firstChild);
prev.removeChild(prev.firstChild);
qePreview.appendChild(prev);
return;
}
}
function qeSubmitByReturn()
{
qeSubmit(0);
return false;
}
function qeSubmit(preview)
{
if (qeEdit == -1 || !qeRequest || !qeForm || qeRequestState)
return;
qeForm.firstChild.childNodes[3].value = document.getElementById('qeSummary').value;
if (preview == 1)
{
var prev = document.createElement('input');
prev.name = 'wpPreview';
prev.value = 'Preview';
prev.type = 'hidden';
qeForm.appendChild(prev);
}
qeForm.submit();
}
// MediaWiki bug 6986 workaround
function qeFixXML(text)
{
var pos = text.indexOf('<h1 class="firstHeading">');
var pos2 = text.indexOf('</h1>');
if (pos == -1 || pos2 == -1) return null;
text = text.substring(0, pos) + text.substring(pos2+5);
//PARCHE: Añadido por Chixpy ya que eso está mal formado XHTML por Wikia
// Cogemos lo que interes que Wikia añade muchas cosas mal formadas...
pos = text.indexOf('<div id="column-one">');
if (pos == -1) return null;
text = text.substring(0, pos) + '</div></div></body></html>';
var parser = new DOMParser();
var newdoc = parser.parseFromString(text, "text/xml");
return newdoc;
}
// Workaround for JavaScript
// don't ask me why the hell JS throws an error at '/*'
function qeFixXMLPreview(text)
{
// another MediaWiki bug: backslashes are stripped out when saving a page...
regex = eval('/' + String.fromCharCode(92) + '/' + String.fromCharCode(92) + '*/g');
text = text.replace(regex, '/*');
//PARCHE: Añadido por Chixpy ya que eso está mal formado XHTML por Wikia
// Cogemos lo que interes que Wikia añade muchas cosas mal formadas...
var pos = text.indexOf('<div id="column-one">');
if (pos == -1) return null;
text = text.substring(0, pos) + '</div></div></body></html>';
var parser = new DOMParser();
var newdoc = parser.parseFromString(text, "text/xml");
return newdoc;
}
/*</pre>*/
/*<pre>*/
// from [[MediaWiki:Onlyifediting.js]]
function addCharSubsetMenu()
{
var specialchars = document.getElementById('specialchars');
if (specialchars)
{
switch(wgContentLanguage){
case "ca":
edittoolsOptions=
/*català*/
["matemàtiques","fonètica","diacrítiques","ciríl·lic","alt alemany antic",
"anglés antic","àrab","berber","bosni/serbocroata","castellà","escandinau",
"eslovac","esperanto","estonià","francés","gal·lés","grec","grec antic",
"hawaià","hebreu","holandés","hongarés","indoeuropeu","irlandés",
"islandés","italià","japonés (romanji)","jiddisch","letó","lituà","maltés",
"navajo i apatxe", "pinyin","polonés","portugués","romanés","serbi",
"turc i ll. turqueses", "txec","vietnamita"]; break;
case "de":
edittoolsOptions=
/*Deutsch*/
["Standard","WikiSyntax","IPA-Lautschrift","Lateinisch","AHD","Altenglisch",
"Altgriechisch","Arabisch","DMG-Umschrift","Esperanto","Estnisch",
"Französisch","Galicisch","Griechisch","Hawaiianisch","Isländisch",
"Italienisch","Jiddisch","Katalanisch","Kroatisch","Kyrillisch",
"Lettisch","Litauisch","Maltesisch","Pinyin","Polnisch","Portugiesisch",
"Romanisch","Rumänisch","Serbisch","Skandinavisch","Slowakisch","Spanisch",
"Tschechisch","Türkisch","Ungarisch","Vietnamesisch"
]; break;
case "es":
edittoolsOptions=
["Estándar", "Estilos", "Enlaces", "Especiales",
"E... Plantillas"
]; break;
default : edittoolsOptions=["Your Edittools are not defined"];
}
var menu = '<select style="display:inline" onChange="chooseCharSubset(selectedIndex)">';
for(index in edittoolsOptions){
menu += '<option>' + edittoolsOptions[index] + '</option>';
}
menu += '</select>';
specialchars.innerHTML = menu + specialchars.innerHTML;
// Standard-CharSubset
chooseCharSubset(0);
}
}
// CharSubset-Auswahl
function chooseCharSubset(s)
{
var l = document.getElementById('specialchars').getElementsByTagName('p');
for (var i = 0; i < l.length ; i++)
l[i].style.display = i == s ? 'inline' : 'none';
}
/*</pre>*/