Usuario:Alvaro qc/prueba.js
Apariencia
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é.
if (wgNamespaceNumber >= 0)
$(function(){
var pCactions = document.getElementById('p-cactions');
if (!pCactions) return;
var caMain = pCactions.getElementsByTagName('li')[0];
var caTalk = document.getElementById('ca-talk');
var caEdit = document.getElementById('ca-edit');
if (!caEdit) caEdit = document.getElementById('ca-viewsource');
var caHistory = document.getElementById('ca-history');
if (!caMain || !caTalk || !caEdit || !caHistory) return;
var el_move, el_create, id2;
if (wgNamespaceNumber % 2) { //talk space
el_move = caTalk; el_create = caMain; id2 = '';
} else {
el_move = caMain; el_create = caTalk; id2 = 'discusión';
}
caEdit.firstChild.innerHTML = 'editar';
caHistory.firstChild.innerHTML = 'historial';
el_move.parentNode.insertBefore(caHistory, el_move.nextSibling);
el_move.parentNode.insertBefore(caEdit, el_move.nextSibling);
var href = el_create.firstChild.getAttribute('href', 2);
if (el_create.className.indexOf('new') < 0){
mw.util.addPortletLink('p-cactions', href + '?action=history', 'historial',
'ca-history-'+id2, id2+' history', '', el_create.nextSibling);
mw.util.addPortletLink('p-cactions', href + '?action=edit', 'editar',
'ca-edit-'+id2, 'Edit '+id2, '', el_create.nextSibling);
}
caMain.style.marginRight = '0.3em';
caTalk.style.marginRight = '0.3em';
caTalk.style.marginLeft = '1.6em';
})
//
var npp_http;
var npp_enabled;
var npp_num_pages;
var npp_refresh;
$( npp_init );
/* initalise */
function npp_init() {
// allow user settings through
if(npp_enabled == null) {
npp_enabled = false;
}
if(npp_num_pages == null) {
npp_num_pages = 10;
}
if(npp_refresh == null) {
npp_refresh = 5;
}
// A few limits to be nice to the servers
if (npp_num_pages > 50) {
npp_num_pages = 50;
}
if (npp_num_pages < 1) {
npp_num_pages = 1;
}
if (npp_refresh < 2) {
npp_refresh = 2;
}
// get our cookie
if (document.cookie.length > 0) {
var c_start = document.cookie.indexOf("npp_show_box=");
if (c_start != -1) {
c_start = c_start + 13;
var c_end = document.cookie.indexOf(";", c_start);
if (c_end == -1) {
c_end = document.cookie.length;
}
if (document.cookie.substring(c_start, c_end) == "yes") {
npp_enabled = true;
} else {
npp_enabled = false;
}
}
}
// Either make a request or show nothing
if (npp_enabled == true) {
npp_ajax_request();
} else {
npp_draw_disabled_box();
}
}
/* init ajax */
function npp_create_request() {
try {
npp_http = new XMLHttpRequest();
} catch (e) {
try {
npp_http = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
npp_http = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert("Your browser does not support AJAX!");
return false;
}
}
}
npp_http.onreadystatechange = function() {
if(npp_http.readyState == 4) npp_ajax_response();
}
return true;
}
/* make a request */
function npp_ajax_request() {
// check we are enabled
if (npp_enabled == false) return;
// firstly, inform the user
var cur_box = document.getElementById('p-newpages');
if (cur_box != null) {
cur_box.firstChild.firstChild.data = 'Actualizando...';
}
if (npp_create_request () == false) {
if (cur_box != null) {
cur_box.firstChild.firstChild.data = 'Páginas nuevas (Error)';
} else {
alert ("There seems to be a problem using the NewPagePatrol script. I can't make AJAX objects, so I'm just going to complain. God Bless!");
}
}
// Then make the request
npp_http.open("GET", "/w/api.php?action=query&format=xml&list=recentchanges&rcshow=!bot&rctype=new&rcnamespace=0&rclimit=" + npp_num_pages, true);
npp_http.send(null);
}
/* we have received a response */
function npp_ajax_response() {
var items = npp_http.responseXML.getElementsByTagName('rc');
// create the div that holds all the newpage links
var link_div = document.createElement('div');
link_div.className = 'pBody';
var list = document.createElement('ul');
link_div.appendChild(list);
// populate the list with 10 links.
for (var i = 0; i < items.length; i++) {
var item_name = items[i].getAttribute('title');
var rcid = items[i].getAttribute('rcid');
item_name = item_name.replace(/&/, "%26");
var item_url = 'http://es.wikipedia.org/w/index.php?title=' + item_name + '&rcid=' + rcid + '&redirect=no';
a = document.createElement('a');
a.setAttribute('href', item_url);
a.appendChild(document.createTextNode(item_name));
var li = document.createElement('li');
li.appendChild(a);
list.appendChild(li);
}
// Container div
var div = document.createElement('div');
div.setAttribute('id', 'p-newpages');
div.className = 'portlet';
var heading = document.createElement('h5');
heading.appendChild(document.createTextNode('Páginas nuevas'));
div.appendChild(heading);
div.appendChild(link_div);
// disable link
var p = document.createElement('p');
p.style.fontSize = 'x-small';
p.style.margin = '0px';
p.style.textAlign = 'right';
a = document.createElement('a');
a.appendChild(document.createTextNode('desactivar'));
a.onclick = npp_disable_box;
p.appendChild(a);
link_div.appendChild(p);
// now replace the div
var old_div = document.getElementById('p-newpages');
var side_col = document.getElementById('column-one');
if (old_div != null) {
side_col.replaceChild(div, old_div);
} else {
var node = document.getElementById('p-search');
side_col.insertBefore(div, node);
}
// and do it again in 5 secs
setTimeout("npp_ajax_request()", npp_refresh * 1000);
}
function npp_disable_box() {
npp_enabled = false;
npp_draw_disabled_box();
document.cookie = "npp_show_box=no; path=/";
}
function npp_enable_box() {
npp_enabled = true;
document.cookie = "npp_show_box=yes; path=/";
npp_ajax_request();
}
function npp_draw_disabled_box() {
// Container div
var link_div = document.createElement('div');
link_div.className = 'pBody';
var div = document.createElement('div');
div.setAttribute('id', 'p-newpages');
div.className = 'portlet';
var heading = document.createElement('h5');
heading.appendChild(document.createTextNode('Páginas nuevas'));
div.appendChild(heading);
div.appendChild(link_div);
// enable link
var p = document.createElement('p');
p.style.fontSize = 'x-small';
p.style.margin = '0px';
var a = document.createElement('a');
a.appendChild(document.createTextNode('activar'));
a.onclick = npp_enable_box;
p.appendChild(a);
link_div.appendChild(p);
// now replace the div
var old_div = document.getElementById('p-newpages');
var side_col = document.getElementById('column-one');
if (old_div != null) {
side_col.replaceChild(div, old_div);
} else {
var node = document.getElementById('p-search');
side_col.insertBefore(div, node);
}
}
// <nowiki>If you are editing a page, click the wikify button on your tab bar to add "{{Wikify|{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}}}" to the top, set "Marked for wikification" as the edit summary, mark it as a minor edit, and submit.</nowiki>
function doQwikify() {
document.editform.wpTextbox1.value = '{' + '{' + 'Wikificar}}\n\n' + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = 'Marcado para wikificar usando [[WP:TW|Friendly]]';
document.editform.wpMinoredit.checked = true;
document.editform.submit();
}
$(function() {
if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk") {
// wouldn't it make more sense to just check for wgCanonicalNamespace != "", or am I missing something?
return;
}
if (document.editform) {
mw.util.addPortletLink("p-cactions", "javascript:doQwikify()", "Wikificar", "ca-wikify", "Marcar para Wikificar", "");
}
});