MediaWiki:Gadget-fastbuttons.js: diferenças entre revisões
Conteúdo apagado Conteúdo adicionado
adicionando comentários conf solicitado em WP:PA |
|||
Linha 31: | Linha 31: | ||
/*** Menu [ER] ***/ |
/*** Menu [ER] ***/ |
||
window.fbEr = "Regra:"; |
|||
fbEr += " 1 " + [ |
window.fbEr += " 1 " + [ |
||
fbLink("ER|5", "5", "Aparecimento recorrente (se o conteúdo for igual" + |
fbLink("ER|5", "5", "Aparecimento recorrente (se o conteúdo for igual" + |
||
" ao eliminado por votação)"), |
" ao eliminado por votação)"), |
||
Linha 109: | Linha 109: | ||
/*** Menu [ESR] ***/ |
/*** Menu [ESR] ***/ |
||
// FIXME: Update deprecated attributes to CSS: cellspacing --> border-spacing, valign --> vertical-align |
// FIXME: Update deprecated attributes to CSS: cellspacing --> border-spacing, valign --> vertical-align |
||
window.fbEsr = "<table cellspacing=0 style=\"color:#7D7D7D\"><tr><td valign=top>" |
|||
+ fbLink("subst:ESR-banda|1=~~" + "~~", "banda", "Artigo sobre banda sem fontes e sem notoriedade") |
+ fbLink("subst:ESR-banda|1=~~" + "~~", "banda", "Artigo sobre banda sem fontes e sem notoriedade") |
||
+ "|" + fbLink("subst:ESR-bio|1=~~" + "~~", "biografia", "Biografia sem fontes e sem notoriedade") |
+ "|" + fbLink("subst:ESR-bio|1=~~" + "~~", "biografia", "Biografia sem fontes e sem notoriedade") |
||
Linha 117: | Linha 117: | ||
// TODO: Merge with function fbesbok() defined below, possibly using jQuery |
// TODO: Merge with function fbesbok() defined below, possibly using jQuery |
||
// $('#target').keypress() |
// $('#target').keypress() |
||
window.fbesrok = function(evt) { |
|||
if (window.event && window.event.keyCode == 13) { |
if (window.event && window.event.keyCode == 13) { |
||
evt = "ok"; |
evt = "ok"; |
||
Linha 124: | Linha 124: | ||
} |
} |
||
if (evt == "ok") { |
if (evt == "ok") { |
||
fb("subst:ESR", document.getElementById("esrinput").value + " ~~" + "~~"); |
window.fb("subst:ESR", document.getElementById("esrinput").value + " ~~" + "~~"); |
||
} |
} |
||
} |
}; |
||
/*** Menu [esboço] ***/ |
/*** Menu [esboço] ***/ |
||
//FIXME: Update deprecated attributes to CSS: cellspacing --> border-spacing, valign --> vertical-align |
//FIXME: Update deprecated attributes to CSS: cellspacing --> border-spacing, valign --> vertical-align |
||
window.fbEsb = "<table cellspacing=0 style=\"color:#7D7D7D\">" + |
|||
"<tr><td valign=top>" + |
"<tr><td valign=top>" + |
||
fbLink("mínimo", "mínimo", "Artigo com apenas uma frase") + |
fbLink("mínimo", "mínimo", "Artigo com apenas uma frase") + |
||
Linha 143: | Linha 143: | ||
//TODO: Merge with function fbesrok() defined above, possibly using $('#target').keypress() |
//TODO: Merge with function fbesrok() defined above, possibly using $('#target').keypress() |
||
function |
window.fbesbok = function (evt) { |
||
if (window.event && window.event.keyCode == 13) { |
if (window.event && window.event.keyCode == 13) { |
||
evt = "ok"; |
evt = "ok"; |
||
Linha 150: | Linha 150: | ||
} |
} |
||
if (evt == "ok") { |
if (evt == "ok") { |
||
fb("esboço-" + document.getElementById("esbinput").value); |
window.fb("esboço-" + document.getElementById("esbinput").value); |
||
} |
} |
||
} |
}; |
||
/*** Menu [manuteção] ***/ |
/*** Menu [manuteção] ***/ |
||
window.fbMan = [ |
|||
fbLink("subst:wkf", "wikificar", "Não está formatado de acordo com o livro" + |
fbLink("subst:wkf", "wikificar", "Não está formatado de acordo com o livro" + |
||
" de estilo"), |
" de estilo"), |
||
Linha 186: | Linha 186: | ||
} |
} |
||
fbtitulo = encodeURIComponent(fbtitulo); |
fbtitulo = encodeURIComponent(fbtitulo); |
||
window.fbbus = "<span class=\"plainlinks\"><a href=\"http://www.google.com/search?&as_eq=wikipedia&as_epq=" |
|||
+ fbtitulo + "\" class=\"external text\">Google</a> — <a href=\"http://news.google.com/archivesearch?&as_src=-newswire+-wire+-presswire+-PR+-press+-release&as_epq=" |
+ fbtitulo + "\" class=\"external text\">Google</a> — <a href=\"http://news.google.com/archivesearch?&as_src=-newswire+-wire+-presswire+-PR+-press+-release&as_epq=" |
||
+ fbtitulo + "\" class=\"external text\">notícias</a>, <a href=\"http://books.google.com/books?&as_brr=0&as_epq=" |
+ fbtitulo + "\" class=\"external text\">notícias</a>, <a href=\"http://books.google.com/books?&as_brr=0&as_epq=" |
||
Linha 267: | Linha 267: | ||
* TODO: Replace ocurrences of this function by something like $(...).html() |
* TODO: Replace ocurrences of this function by something like $(...).html() |
||
*/ |
*/ |
||
function |
window.fbabrir = function (menu) { |
||
fb2.innerHTML = menu; |
fb2.innerHTML = menu; |
||
} |
}; |
||
/* Função de edição |
/* Função de edição |
||
Linha 277: | Linha 277: | ||
* @return: {boolean} Returns false if the user canceled or the page already has a template |
* @return: {boolean} Returns false if the user canceled or the page already has a template |
||
*/ |
*/ |
||
function |
window.fb = function (fbedit, fbtxt) { |
||
var txtbox = document.getElementById("wpTextbox1"); |
var txtbox = document.getElementById("wpTextbox1"); |
||
if (fbtxt === null) { |
if (fbtxt === null) { |
||
Linha 418: | Linha 418: | ||
} |
} |
||
} |
} |
||
} |
}; |
||
/* Consulta a API do MediaWiki usando AJAX |
/* Consulta a API do MediaWiki usando AJAX |
||
* @param: {string} fapi An abreviation such as "esb", "afl", "PV", |
* @param: {string} fapi An abreviation such as "esb", "afl", "PV", |
||
* @param: {string} url The url of the API query |
* @param: {string} url The url of the API query |
||
* |
* FIXME: @deprecated Use jQuery AJAX functions (see [[mw:RL/JD#ajax.js]] ) |
||
*/ |
*/ |
||
function fbajax(fapi, url) { |
function fbajax(fapi, url) { |
||
Linha 435: | Linha 435: | ||
fajax.onreadystatechange = function () { |
fajax.onreadystatechange = function () { |
||
if (fajax.readyState == 4 && fajax.status == 200) { |
if (fajax.readyState == 4 && fajax.status == 200) { |
||
fbapi(fapi, fajax.responseXML); |
window.fbapi(fapi, fajax.responseXML); |
||
} |
} |
||
}; |
}; |
||
Linha 441: | Linha 441: | ||
/* Callback function for API calls |
/* Callback function for API calls |
||
* @param {string} fapi An abreviation such as "esb", "afl", "PV", |
* @param {string} fapi An abreviation such as "esb", "afl", "PV", |
||
* @param {Object} api |
* @param {Object} api HTML code??? |
||
*/ |
*/ |
||
function |
window.fbapi = function (fapi, api) { |
||
var url, esb, i, pages, charnum, title, tamanho, coment, user; |
var url, esb, i, pages = '', charnum = 0, title, tamanho, coment, user; |
||
if (!api) { |
if (!api) { |
||
url = mw.config.get('wgScriptPath') + "/api.php?format=xml&action=query&"; |
url = mw.config.get('wgScriptPath') + "/api.php?format=xml&action=query&"; |
||
// TODO: Criar um objeto { 'esb': ..., 'afl':... } com um item para cada "fabi" |
|||
if (fapi == "esb") { |
|||
switch ( fapi ) { |
|||
esb = document.getElementById("esbinput"); |
|||
case 'esb': |
|||
if (esbtxt == esb.value || esbtxt2 == esb.value) { |
|||
esb = document.getElementById("esbinput"); |
|||
return; |
|||
if (esbtxt == esb.value || esbtxt2 == esb.value) { |
|||
} |
|||
return; |
|||
esbtxt = esb.value; |
|||
} |
|||
if (esbtxt == esb.value.substr(0, (esb.value.length - 1))) { |
|||
esbtxt = esb.value; |
|||
return; |
|||
if (esbtxt == esb.value.substr(0, (esb.value.length - 1))) { |
|||
} |
|||
return; |
|||
url += "list=allpages&apnamespace=10&aplimit=1&apprefix=" + |
|||
} |
|||
url += "list=allpages&aplimit=1&apnamespace=10&apprefix=" + |
|||
encodeURI("Esboço-") + encodeURIComponent(esb.value); |
encodeURI("Esboço-") + encodeURIComponent(esb.value); |
||
break; |
|||
} else if (fapi == "afl") { |
|||
case 'afl': |
|||
url += "list=backlinks&bllimit=1&blfilterredir=nonredirects" + |
|||
url += "list=backlinks&bllimit=1&blfilterredir=nonredirects" + |
|||
"&blnamespace=0&bltitle=" + |
"&blnamespace=0&bltitle=" + |
||
encodeURIComponent(mw.config.get('wgPageName')); |
encodeURIComponent(mw.config.get('wgPageName')); |
||
break; |
|||
} else if (fapi == "PV") { |
|||
case 'PV': |
|||
url += "list=watchlist&wlexcludeuser=" + |
|||
url += "list=watchlist&wlexcludeuser=" + |
|||
encodeURIComponent(mw.config.get('wgUserName')) + |
encodeURIComponent(mw.config.get('wgUserName')) + |
||
"&wlprop=user|comment|title|sizes"; |
"&wlprop=user|comment|title|sizes"; |
||
break; |
|||
} else if (fapi == "PN") { |
|||
case 'PN': |
|||
url += "list=recentchanges&rctype=new&rcnamespace=0" + |
|||
url += "list=recentchanges&rctype=new&rcnamespace=0" + |
|||
"&rcshow=!patrolled&rcprop=user|comment|title|sizes|ids"; |
"&rcshow=!patrolled&rcprop=user|comment|title|sizes|ids"; |
||
break; |
|||
} else if (fapi == "MR") { |
|||
case 'MR': |
|||
url += "list=recentchanges&rctype=edit&rcnamespace=0" + |
|||
url += "list=recentchanges&rctype=edit&rcnamespace=0" + |
|||
"&rcshow=anon&rcprop=user|comment|title|sizes"; |
"&rcshow=anon&rcprop=user|comment|title|sizes"; |
||
break; |
|||
} else if (fapi == "usu") { |
|||
case 'usu': |
|||
user = mw.config.get('wgTitle'); |
|||
user = mw.config.get('wgTitle'); |
|||
if (user.indexOf('/') > -1) { |
|||
if (user.indexOf('/') > -1) { |
|||
user = user.substring(0, user.indexOf('/')); |
|||
} |
|||
} |
|||
url += "list=allusers&aulimit=1&aufrom=" + |
|||
url += "list=allusers&aulimit=1&aufrom=" + |
|||
encodeURIComponent(user) + "&auprop=editcount|registration"; |
encodeURIComponent(user) + "&auprop=editcount|registration"; |
||
break; |
|||
} |
|||
} |
|||
fbajax(fapi, url); |
fbajax(fapi, url); |
||
} else { |
} else { |
||
/** Processamento da resposta do API **/ |
/** Processamento da resposta do API **/ |
||
switch ( fapi ) { |
|||
case 'afl': |
|||
var info = "("; |
|||
// Afluentes |
|||
info += (document.getElementById("Refer.C3.AAncias") |
|||
var info = "("; |
|||
info += (document.getElementById("Refer.C3.AAncias") |
|||
|| document.getElementById("Notas_e_refer.C3.AAncias")) ? |
|| document.getElementById("Notas_e_refer.C3.AAncias")) ? |
||
"ref" : |
"ref" : |
||
"<span style=\"color:red\">ref</span>"; |
"<span style=\"color:red\">ref</span>"; |
||
var catline = document.getElementById("mw-normal-catlinks"); |
|||
// FIXME: Do not do screen scraping to get this info! |
// FIXME: Do not do screen scraping to get this info! |
||
if (catline && catline.innerHTML.indexOf("><a href=\"" + mw.config.get('wgArticlePath').replace('$1', '')) > -1) { |
|||
info += " · cat"; |
|||
} else { |
|||
info += " · <span style=\"color:red\" title=\"Esta página ainda não foi categorizada\">cat</span>"; |
|||
} |
|||
} |
|||
info += (document.getElementById("p-lang")) ? |
|||
" · iw" : |
" · iw" : |
||
" · <span style=\"color:red\" title=\"Esta página ainda não" + |
" · <span style=\"color:red\" title=\"Esta página ainda não" + |
||
" possui links para outros idiomas\">iw</span>"; |
" possui links para outros idiomas\">iw</span>"; |
||
api = api.getElementsByTagName("bl"); |
|||
if (api && api.length) { |
|||
info += " · <a href=\"" + |
|||
mw.util.wikiGetlink( 'Especial:Páginas afluentes/' + mw.config.get('wgPageName') ) + |
mw.util.wikiGetlink( 'Especial:Páginas afluentes/' + mw.config.get('wgPageName') ) + |
||
"\" title=\"afluentes\">afl</a>)"; |
"\" title=\"afluentes\">afl</a>)"; |
||
} else { |
|||
info += " · <span style=\"color:red\">afl</span>)"; |
|||
} |
|||
} |
|||
url = mw.config.get('wgScriptPath') + |
|||
"/api.php?format=xml&action=query&prop=categories&titles=" + |
"/api.php?format=xml&action=query&prop=categories&titles=" + |
||
mw.config.get('wgFormattedNamespaces')[ mw.config.get('wgNamespaceNumber') + 1 ] + |
mw.config.get('wgFormattedNamespaces')[ mw.config.get('wgNamespaceNumber') + 1 ] + |
||
encodeURIComponent( mw.config.get('wgTitle') ); |
encodeURIComponent( mw.config.get('wgTitle') ); |
||
fb2.innerHTML = info; |
|||
if (document.getElementById("ca-talk").className != "new") { |
|||
fbajax("qualidade", url); |
|||
} else { |
|||
var hidcat = document.getElementById("mw-hidden-catlinks"); |
|||
if (hidcat) { |
|||
hidcat = hidcat.innerHTML; |
|||
if (hidcat.indexOf("!Artigos de qualidade") > -1) { |
|||
hidcat = hidcat.substr(hidcat.indexOf("!Artigos de qualidade") + 22, 1); |
|||
if (hidcat == "d") { |
|||
hidcat = "?"; |
|||
} |
|||
} |
|||
fb2.innerHTML += "<span title='Qualidade do artigo'> Q-<b>" + |
|||
hidcat + "</b></span>"; |
hidcat + "</b></span>"; |
||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
break; |
|||
} else if (fapi == "qualidade") { // Qualidade do artigo |
|||
case 'qualidade': |
|||
// Qualidade do artigo |
|||
api = api.getElementsByTagName("cl"); |
api = api.getElementsByTagName("cl"); |
||
if (api) { |
if (api) { |
||
var apicat; |
var apicat; |
||
for (i = 0; i < api.length; i++) { |
for (i = 0; i < api.length; i++) { |
||
if (!api[i]){ |
|||
continue; |
|||
} |
|||
apicat = api[i].getAttribute("title"); |
apicat = api[i].getAttribute("title"); |
||
if (apicat.indexOf("!Artigos de qualidade") > -1) { |
if (apicat.indexOf("!Artigos de qualidade") > -1) { |
||
Linha 549: | Linha 564: | ||
return; |
return; |
||
} |
} |
||
break; |
|||
case 'esb': |
|||
// Esboço temático |
// Esboço temático |
||
api = api.getElementsByTagName("p"); |
api = api.getElementsByTagName("p"); |
||
if (api) { |
if (api && api.length) { |
||
api = api[0].getAttribute("title") |
api = api[0].getAttribute("title") |
||
.replace(/Predefinição:Esboço-/gi, ""); |
.replace(/Predefinição:Esboço-/gi, ""); |
||
Linha 581: | Linha 597: | ||
} |
} |
||
} |
} |
||
break; |
|||
case 'PV': |
|||
// Páginas vigiadas |
// Páginas vigiadas |
||
api = api.getElementsByTagName("item"); |
api = api.getElementsByTagName("item"); |
||
for (i = 0; i < api.length && i < 10; i++) { |
|||
if (!api[i]){ |
|||
for (i = 0; i < 10; i++) { |
|||
continue; |
|||
} |
|||
title = api[i].getAttribute("title"); |
title = api[i].getAttribute("title"); |
||
charnum += title.length; |
charnum += title.length; |
||
Linha 602: | Linha 621: | ||
coment = coment.replace("[[Ajuda:Guia de edição/Menus e" + |
coment = coment.replace("[[Ajuda:Guia de edição/Menus e" + |
||
" ferramentas/Sumário de edição|?]]", ""); |
" ferramentas/Sumário de edição|?]]", ""); |
||
if ( i > 0){ |
|||
pages += ' | '; |
|||
pages = ""; |
|||
} |
|||
} else { |
|||
pages += "<a href=\"" + mw.util.wikiGetlink( title ) + |
|||
} |
|||
pages += " <a href=\"" + mw.util.wikiGetlink( title ) + |
|||
"?diff=last\" title=\"(" + tamanho + ") " + |
"?diff=last\" title=\"(" + tamanho + ") " + |
||
api[i].getAttribute("user") + " " + coment + "\">" + |
api[i].getAttribute("user") + " " + coment + "\">" + |
||
Linha 613: | Linha 630: | ||
} |
} |
||
fb2.innerHTML = pages; |
fb2.innerHTML = pages; |
||
break; |
|||
} else if (fapi == "PN") { // Páginas novas |
|||
case 'PN': |
|||
// Páginas novas |
|||
api = api.getElementsByTagName("rc"); |
api = api.getElementsByTagName("rc"); |
||
for (i = 0; i < api.length && i < 10; i++) { |
|||
if (!api[i]){ |
|||
for (i = 0; i < 10; i++) { |
|||
continue; |
|||
} |
|||
title = api[i].getAttribute("title"); |
title = api[i].getAttribute("title"); |
||
charnum += title.length; |
charnum += title.length; |
||
Linha 627: | Linha 648: | ||
coment = "(" + coment.replace("[[Ajuda:SEA|?]] ", "") + ")"; |
coment = "(" + coment.replace("[[Ajuda:SEA|?]] ", "") + ")"; |
||
} |
} |
||
if (i |
if ( i > 0){ |
||
pages += ' | '; |
|||
pages = ""; |
|||
} |
|||
} else { |
|||
pages += "<a href=\"" + mw.util.wikiGetlink( title ) |
|||
} |
|||
pages += " <a href=\"" + mw.util.wikiGetlink( title ) |
|||
+ "?redirect=no&rcid=" + api[i].getAttribute("rcid") |
+ "?redirect=no&rcid=" + api[i].getAttribute("rcid") |
||
+ "\" title=\"(" + tamanho + ") " + |
+ "\" title=\"(" + tamanho + ") " + |
||
Linha 639: | Linha 658: | ||
} |
} |
||
fb2.innerHTML = pages; |
fb2.innerHTML = pages; |
||
break; |
|||
} else if (fapi == "MR") { // Mudanças recentes |
|||
case 'MR': |
|||
// Mudanças recentes |
|||
api = api.getElementsByTagName("rc"); |
api = api.getElementsByTagName("rc"); |
||
for (i = 0; i < api.length && i < 10; i++) { |
|||
if (!api[i]){ |
|||
for (i = 0; i < 10; i++) { |
|||
continue; |
|||
} |
|||
title = api[i].getAttribute("title"); |
title = api[i].getAttribute("title"); |
||
charnum += title.length; |
charnum += title.length; |
||
Linha 657: | Linha 680: | ||
coment = "(" + coment.replace("*/", ":") + ")"; |
coment = "(" + coment.replace("*/", ":") + ")"; |
||
} |
} |
||
if (i |
if ( i > 0){ |
||
pages += ' | '; |
|||
pages = ""; |
|||
} |
|||
} else { |
|||
pages += "<a href=\"" + mw.util.wikiGetlink( title ) |
|||
pages += " |"; |
|||
} |
|||
pages += " <a href=\"" + mw.util.wikiGetlink( title ) |
|||
+ "?diff=last\" title=\"(" + tamanho + ") " |
+ "?diff=last\" title=\"(" + tamanho + ") " |
||
+ api[i].getAttribute("user") + " " |
+ api[i].getAttribute("user") + " " |
||
Linha 668: | Linha 689: | ||
} |
} |
||
fb2.innerHTML = pages; |
fb2.innerHTML = pages; |
||
break; |
|||
} else if (fapi == "usu") { // Informações do usuário |
|||
case 'usu': |
|||
// Informações do usuário |
|||
api = api.getElementsByTagName("u"); |
api = api.getElementsByTagName("u"); |
||
if ( api && api.length ) { |
|||
var registro = api[0].getAttribute("registration"); |
|||
registro = registro.substr(8, 2) + "/" + registro.substr(5, 2) + |
|||
"/" + registro.substr(0, 4); |
"/" + registro.substr(0, 4); |
||
user = mw.config.get('wgTitle'); |
|||
if (user.indexOf("/") > -1) { |
|||
user = user.substring(0, user.indexOf("/")); |
|||
} |
|||
} |
|||
var encUser = encodeURI(user); |
|||
fb2.innerHTML = |
fb2.innerHTML = |
||
"<span style=\"color:black\">" + |
"<span style=\"color:black\">" + |
||
api[0].getAttribute("editcount") + |
api[0].getAttribute("editcount") + |
||
"</span> edições desde <span style=\"color:black\">" + |
"</span> edições desde <span style=\"color:black\">" + |
||
registro + "</span> | <a href=\"" + |
registro + "</span> | <a href=\"" + |
||
mw.util.wikiGetlink( 'Especial:Contribuições/' ) + |
mw.util.wikiGetlink( 'Especial:Contribuições/' ) + |
||
encUser + |
encUser + |
||
"\">contribuições</a> | <a href=\"" + |
"\">contribuições</a> | <a href=\"" + |
||
mw.util.wikiGetlink( 'Especial:Registo/' ) + |
mw.util.wikiGetlink( 'Especial:Registo/' ) + |
||
encUser + |
encUser + |
||
"\">registros</a> | <a href=\"" + |
"\">registros</a> | <a href=\"" + |
||
mw.util.wikiGetlink( 'Especial:Registo' ) + |
mw.util.wikiGetlink( 'Especial:Registo' ) + |
||
"?type=block&page=Usu%C3%A1rio%3A" + |
"?type=block&page=Usu%C3%A1rio%3A" + |
||
encUser + |
encUser + |
||
"\">registros de bloqueio</a> | <span class=\"plainlinks\">" + |
"\">registros de bloqueio</a> | <span class=\"plainlinks\">" + |
||
"<a href=\"http://toolserver.org/~river/cgi-bin/count_edits?user=" + |
"<a href=\"http://toolserver.org/~river/cgi-bin/count_edits?user=" + |
||
encUser + |
encUser + |
||
"&dbname=ptwiki_p\" class=\"external text\">contador de edições</a></span>"; |
"&dbname=ptwiki_p\" class=\"external text\">contador de edições</a></span>"; |
||
} else { |
|||
return; |
|||
} |
|||
break; |
|||
} |
} |
||
} |
} |
||
} |
}; |
||
/* Executes the gadget when document is ready */ |
/* Executes the gadget when document is ready */ |
||
Linha 745: | Linha 773: | ||
" onClick='fbabrir(fbbus)'>busca</a>]"; |
" onClick='fbabrir(fbbus)'>busca</a>]"; |
||
if (mw.config.get('wgAction') === "view") { |
if (mw.config.get('wgAction') === "view") { |
||
fbapi("afl"); |
window.fbapi("afl"); |
||
} |
} |
||
} else { |
} else { |
||
Linha 782: | Linha 810: | ||
fbsalve = (fbedit !== null); |
fbsalve = (fbedit !== null); |
||
if (fbsalve) { |
if (fbsalve) { |
||
fb(fbedit, mw.util.getParamValue('fbtxt') || ''); |
window.fb(fbedit, mw.util.getParamValue('fbtxt') || ''); |
||
} |
} |
||
break; |
break; |
Revisão das 02h29min de 5 de julho de 2011
/** FastButtons
* @author: [[es:User:Racso]] (versão original do script, na Wikipédia em Espanhol)
* @author: [[en:User:Macy]] (versão adaptada para a Wikipedia inglesa)
* @author: Outros editores que aparecem no histórico
* @source: [[en:User:Macy/FastButtons.js]] (https://secure.wikimedia.org/wikipedia/en/w/index.php?oldid=230473471)
* @source: [[es:Special:PrefixIndex/User:Racso/FB]]
*/
var fbsalve,
fbNS = mw.config.get('wgNamespaceNumber'),
fb1 = document.createElement('div'),
fb2 = document.createElement('div');
/* Cria os links que ativam a função fb()
* @param {string} fbf
* @param {string} ltxt Text for link
* @param {string} ltit Title for link
* @param {string=} lobs Text for prompt message (optional)
*/
function fbLink(fbf, ltxt, ltit, lobs) {
if (fbf.indexOf("ER") === 0) {
fbf = 'var obs=prompt("Se necessário, coloque uma observação.");'
+ 'fb("' + fbf + '",obs)';
} else if (lobs) {
fbf = "var obs=prompt(\"" + lobs + "\");fb(\"" + fbf + "\",obs)";
} else {
fbf = "fb(\"" + fbf + "\")";
}
return " <a onMouseOver='this.style.cursor=\"pointer\"' title='"
+ ltit + "' onClick='" + fbf + "'>" + ltxt + "</a> ";
}
/*** Menu [ER] ***/
window.fbEr = "Regra:";
window.fbEr += " 1 " + [
fbLink("ER|5", "5", "Aparecimento recorrente (se o conteúdo for igual" +
" ao eliminado por votação)"),
(($.inArray(fbNS, [0, 102]) !== -1) ?
fbLink("ER|6", "6", "Título é spam") :
" 6 "),
fbLink("ER|7", "7", "Próprio criador reconhece que se enganou"),
(($.inArray('sysop', mw.config.get('wgUserGroups')) > -1) ?
fbLink("ER|8", "8", "Eliminações temporárias sem perda de histórico" +
" para resolver problemas técnicos") :
" 8 "),
fbLink("ER|9", "9", "Eliminar redirect, página sem histórico relevante"
+ " (mover página redirecionada para cá)"),
((fbNS === 0) ?
fbLink("ER|10", "10", "Namespaces que não existem (WikipÉdia, AjUda)") :
" 10 " ),
fbLink("ER|11", "11", "Má configuração do teclado (Página," +
" Usuário:Sicrano)"),
(fbNS == 6) ?
fbLink("ER|12", "12", "Imagens, somente por quem a carregou") :
" 12 ",
($.inArray(fbNS, [0, 102]) !== -1) ?
fbLink("ER|13", "13", "Páginas sem histórico relevante que são" +
" violações flagrantes de direitos autorais de outras páginas" +
" na internet.") :
" 13 ",
(fbNS == 6) ?
fbLink("ER|14", "14", "Ficheiros (arquivos) duplicados") :
" 14 ",
fbLink("ER|17", "17", "Salto de domínio"),
(fbNS == 1) ?
fbLink("ER|18", "18", "Discussão cujos artigos não existem") :
" 18 ",
(fbNS == 6) ?
fbLink("ER|19", "19", "Ficheiros (domínio Ficheiro:) que não são som," +
" imagem ou vídeo") :
" 19 ",
fbLink("ER|20", "20", "Impróprio"),
(mw.config.get('wgPageName').indexOf("Wikipédia:Páginas_para_eliminar/") === 0) ?
fbLink("ER|21", "21", "Página de eliminação de um artigo antes de" +
" passados 6 meses da última votação") :
" 21 ",
($.inArray(fbNS, [0, 102]) !== -1) ?
fbLink("ER|A1", "A1", "Páginas com o título malformatado, absurdo," +
" com palavras que não o são, com erros devidos à má configuração" +
" do teclado, com codificação incorreta do sistema ou que expressem" +
" domínios que não existem.") :
" A1 ",
(fbNS == 14) ?
fbLink("ER|C1", "C1", "Categorias vazias, desnecessárias ou substituídas") :
" C1 ",
(fbNS % 2 == 1) ?
fbLink("ER|D1", "D1", "Discussões de páginas inexistentes") :
" D1 ",
(fbNS % 2 == 1) ?
fbLink("ER|D2", "D2", "Discussões de páginas para eliminação ou com" +
" histórico irrelevante") :
" D2 ",
($.inArray(fbNS, [2, 3]) !== -1) ?
fbLink("ER|U1", "U1", "Uso impróprio da página de usuário") :
" U1 ",
(fbNS == 2) ?
fbLink("ER|U2", "U2", "PU criada por outro usuário") :
" U2 ",
(fbNS == 10) ?
fbLink("ER|P1", "P1", "Predefinições vazias, desnecessárias ou" +
" substituídas") :
" P1 ",
fbLink("ER|R1", "R1", "Redirecionamento indevido, desnecessário, sem" +
" afluentes, para páginas inexistente ou eliminadas"),
(fbNS % 2 == 1) ?
fbLink("ER|R2", "R2", "Redirecionamento de página de discussão") :
" R2 "
].join('|');
/*** Menu [ESR] ***/
// FIXME: Update deprecated attributes to CSS: cellspacing --> border-spacing, valign --> vertical-align
window.fbEsr = "<table cellspacing=0 style=\"color:#7D7D7D\"><tr><td valign=top>"
+ fbLink("subst:ESR-banda|1=~~" + "~~", "banda", "Artigo sobre banda sem fontes e sem notoriedade")
+ "|" + fbLink("subst:ESR-bio|1=~~" + "~~", "biografia", "Biografia sem fontes e sem notoriedade")
+ "|" + fbLink("subst:ESR-empresa|1=~~" + "~~", "empresa", "Empresa sem fontes e sem notoriedade")
+ "| outra: </td><td><input type=\"text\" id=\"esrinput\" onKeyPress=\"fbesrok(event)\" size=55/><input type=\"button\" onMouseDown='fbesrok(\"ok\")' value=\"OK\"/></td></tr></table>";
// TODO: Merge with function fbesbok() defined below, possibly using jQuery
// $('#target').keypress()
window.fbesrok = function(evt) {
if (window.event && window.event.keyCode == 13) {
evt = "ok";
} else if (evt && evt.which == 13) {
evt = "ok";
}
if (evt == "ok") {
window.fb("subst:ESR", document.getElementById("esrinput").value + " ~~" + "~~");
}
};
/*** Menu [esboço] ***/
//FIXME: Update deprecated attributes to CSS: cellspacing --> border-spacing, valign --> vertical-align
window.fbEsb = "<table cellspacing=0 style=\"color:#7D7D7D\">" +
"<tr><td valign=top>" +
fbLink("mínimo", "mínimo", "Artigo com apenas uma frase") +
"|" + fbLink("esboço", "esboço", "Artigo ainda pouco desenvolvido") +
"| <span style=\"color:black;\">esboço-</span>" +
"</td><td>" + "<input id=\"esbinput\" onkeyup='fbapi(\"esb\")'" +
" onKeyPress=\"fbesbok(event)\" size=14/>" +
"<input type=\"button\" onMouseDown='fbesbok(\"ok\")' value=\"OK\"/>" +
"</td></tr></table>";
var esbtxt = "",
esbtxt2 = "";
//TODO: Merge with function fbesrok() defined above, possibly using $('#target').keypress()
window.fbesbok = function (evt) {
if (window.event && window.event.keyCode == 13) {
evt = "ok";
} else if (evt && evt.which == 13) {
evt = "ok";
}
if (evt == "ok") {
window.fb("esboço-" + document.getElementById("esbinput").value);
}
};
/*** Menu [manuteção] ***/
window.fbMan = [
fbLink("subst:wkf", "wikificar", "Não está formatado de acordo com o livro" +
" de estilo"),
fbLink("subst:s-fontes", "sem fontes", "Página não cita nenhuma fonte ou" +
" referência"),
fbLink("sem cat", "sem cat", "Página não está em nenhuma categoria"),
fbLink("subst:rec", "reciclagem", "Página precisa ser reciclada de acordo" +
" com o livro de estilo"),
fbLink("parcial", "parcial", "Artigo possui passagens que não respeitam o" +
" princípio da imparcialidade"),
fbLink("subst:ctx", "contexto", "Página carece de contexto"),
fbLink("controverso|artigo", "controverso", "controverso devido às disputas" +
" sobre o seu conteúdo"),
fbLink("subst:f-referências", "formatar referências", "Artigo contém" +
" referências que necessitam de formatação"),
fbLink("subst:m-notas", "mais notas", "Página cita fontes fiáveis, mas não" +
" cobre todo o texto"),
fbLink("subst:s-notas", "sem notas", "Existem fontes no final da página," +
" mas não são citadas no corpo do artigo"),
fbLink("subst:s-fontes-bpv", "bpv sem fontes", "Biografia de pessoa viva" +
" que não cita nenhuma fonte"),
fbLink("subst:fpr", "fonte primária", "Artigo necessita de fontes" +
" secundárias fiáveis publicadas por terceiros")
].join('|');
/*** Menu [busca] ***/
var fbtitulo = mw.config.get('wgTitle');
if (fbtitulo.indexOf(" ") > -1){
fbtitulo = "\"" + fbtitulo + "\"";
}
fbtitulo = encodeURIComponent(fbtitulo);
window.fbbus = "<span class=\"plainlinks\"><a href=\"http://www.google.com/search?&as_eq=wikipedia&as_epq="
+ fbtitulo + "\" class=\"external text\">Google</a> — <a href=\"http://news.google.com/archivesearch?&as_src=-newswire+-wire+-presswire+-PR+-press+-release&as_epq="
+ fbtitulo + "\" class=\"external text\">notícias</a>, <a href=\"http://books.google.com/books?&as_brr=0&as_epq="
+ fbtitulo + "\" class=\"external text\">livros</a>, <a href=\"http://scholar.google.com/scholar?as_epq="
+ fbtitulo + "\" class=\"external text\">acadêmico</a> — <a href=\"http://www.scirus.com/srsapp/search?q="
+ fbtitulo + "&t=all&sort=0&g=s\" class=\"external text\">Scirus</a></span>";
/*** Menu [aviso] ***/
var fbAv = [fbLink("subst:bem-vindo IP", "BV-IP",
"Boas-vindas para usuário não registrado"),
fbLink("subst:bem-vindo", "BV", "Bem-vindo à Wikipédia"),
fbLink("subst:bem-vinda", "BVª", "Bem-vinda à Wikipédia"),
fbLink("subst:bv-av", "av-BV-IP",
"Aviso sobre erro em artigo e boas vindas para usuário não registrado",
"Aviso sobre qual artigo?"),
fbLink("subst:bv-av-registrado", "av-BV",
"Aviso sobre erro em artigo e boas vindas para usuário registrado",
"Aviso sobre qual artigo?"),
fbLink("subst:aviso-ER", "av-ER", "Aviso sobre eliminação rápida",
"Qual página foi proposta para eliminação?"),
fbLink("subst:av-bv-ER", "av-bv-ER",
"Aviso sobre eliminação rápida + boas vindas.",
"Qual página foi proposta para eliminação?"),
fbLink("subst:aviso-ESR", "av-ESR", "Aviso sobre eliminação semirrápida",
"Qual página foi proposta para eliminação?"),
fbLink("subst:aviso-PE", "av-PE", "Aviso sobre eliminação por votação",
"Qual página foi proposta para eliminação?"),
fbLink("subst:aviso-PE-criador", "av-PE-criador", "Aviso ao criador sobre eliminação por votação",
"Qual página foi proposta para eliminação?"),
fbLink("subst:bv-propaganda", "prop-BV", "Caro editor, por favor não faça" +
" propaganda,[...] Apesar disso, bem vindo à Wikipédia"),
fbLink("subst:propaganda", "prop",
"Caro editor, por favor não faça propaganda...",
"Em que página foi feito propaganda?"),
fbLink("subst:aviso", "av", "Aviso sobre erro em artigo",
"Aviso sobre qual artigo?"),
fbLink("subst:aviso2", "av2", "Aviso sobre vandalismo",
"Qual página foi vandalizada?"),
fbLink("subst:BSRE", "BSRE", "Aviso de biografia sem relevo enciclopédico",
"Qual artigo?"),
fbLink("subst:cópia", "cópia",
"Aviso sobre artigo copiado de fonte externa/VDA",
"Preencha usando \\\"|2=\\\" como separador: página da Wikipédia" +
"|2=url da página copiada"),
fbLink("subst:linguagem incorreta", "linguagem",
"Não insulte nem use linguagem inadequada em artigos ou discussões"),
fbLink("subst:ortografia", "ortografia", "Não mude a versão da língua"),
fbLink("subst:mostrar previsão", "salvamento sucessivo",
"Não faça salvamentos sucessivos, utilize o botão\"Mostrar previsão\"",
"Em que artigo o usuário fez salvamentos sucessivos?"),
fbLink("subst:Av-boas vindas", "Aviso-Bv", "Não dê boas vindas a usuários" +
" que não contribuíram com pelo menos uma edição válida"),
fbLink("subst:Av-página de usuário", "Av-pu", "Considere refazer a página de usuário"),
fbLink("subst:Aviso/Página pessoal", "Av-pu-outro",
"Não edite páginas de outros usuários",
"Qual página de outro usuário foi editada?"),
fbLink("subst:não remova", "não remova",
"Não remova marcações de eliminação das páginas",
"Qual página em que a marcação de eliminação foi removida?"),
fbLink("subst:autobiografia", "autobiografia", "Não crie autobiografias",
"Qual autobiografia foi criada?")
].join('|');
/** Menu [CatScan] **/
var csurl = 'http://toolserver.org/~daniel/WikiSense/CategoryIntersect.php' +
'?wikilang=pt&wikifam=.wikipedia.org&userlang=pt' +
'&basecat=' + encodeURIComponent( mw.config.get('wgTitle') ) +
'&basedeep=1&go=Examinar&format=html&mode=',
fbCat = "Procurar nesta categoria: " + [
"<a href='" + csurl + "ts&templates=Sem-fontes'>sem fontes</a>",
"<a href='" + csurl + "ts&templates=Revis%C3%A3o&go='>revisão</a>",
"<a href='" + csurl + "ts&templates=Wikifica%C3%A7%C3%A3o&go='>wikificação</a>",
"<a href='" + csurl + "ss&size=1000&stubop=or&links=4&go='>menos de 1 000 bytes ou 4 links</a>",
"<a href='" + csurl + "ss&size=500&stubop=or&links=2&go='>menos de 500 bytes ou 2 links</a>"
].join(' | ');
/*
* Adds the content of the menu to the corresponding element
* @param: {string} A string containing the content to be added
* TODO: Replace ocurrences of this function by something like $(...).html()
*/
window.fbabrir = function (menu) {
fb2.innerHTML = menu;
};
/* Função de edição
* @param: {string} fbedit A template name, possibly preceded by "subst:",
* and optionally followed by "|" and some parameter(s)
* @param: {(string|null)=} fbtxt Extra text for templates and redirects (optional)
* @return: {boolean} Returns false if the user canceled or the page already has a template
*/
window.fb = function (fbedit, fbtxt) {
var txtbox = document.getElementById("wpTextbox1");
if (fbtxt === null) {
// Do nothing if the user canceled the prompt box
return false;
}
if (mw.config.get('wgAction') == 'view') {
var url = mw.util.wikiGetlink( mw.config.get('wgPageName') )
+ '?action=edit&fastb=' + encodeURIComponent(fbedit);
if (fbtxt) {
location.href = url + '&fbtxt=' + encodeURIComponent(fbtxt);
} else {
location.href = url;
}
} else if (mw.config.get('wgAction') == "edit") {
var txt = txtbox.value;
var ufb = " (usando [[Wikipédia:FB|FastButtons]])";
if ( txt.match(/\{\{(?:ER|ESR2|Usuário\:Salebot\/Impróprio)\|/i) ) {
alert("Já existe uma predefinição de eliminação nesta página.");
return false;
}
if (fbedit.indexOf("ER") === 0) {
if (fbtxt) {
fbtxt = "|3=" + fbtxt + "}}\n\n";
} else {
fbtxt = "}}\n\n";
}
fbtxt = "{{" + fbedit + "|2=~~" + "~~" + fbtxt;
txtbox.value = fbtxt + txt;
if (fbsalve) {
document.editform.wpSummary.value = "Página proposta para" +
" [[WP:ER|eliminação rápida]] (regra " +
fbedit.substring(3) + ")" + ufb;
}
} else if (fbedit == "redirect") {
if (mw.config.get('wgNamespaceNumber') == 14) {
if (fbtxt) {
txtbox.value = "{{redirecionamento de categoria|" +
fbtxt + "}}";
}
if (fbsalve) {
document.editform.wpSummary.value = "Redirecionando para" +
" a [[categoria:" + fbtxt + "]]" + ufb;
}
} else {
if (fbtxt) {
txtbox.value = "#Redirecionamento [[" + fbtxt + "]]";
}
}
} else {
if (fbtxt) {
if (fbedit.indexOf("|") > -1) {
fbtxt = "|1=" + fbtxt + "}}";
} else {
fbtxt = "|1=" + fbtxt + "}}";
}
} else {
fbtxt = "}}";
}
fbtxt = "{{" + fbedit + fbtxt;
if (mw.config.get('wgNamespaceNumber') == 3) {
txt += "\n\n" + fbtxt + " ~~" + "~~";
} else if (fbedit == "mínimo" || fbedit.indexOf("esboço") === 0) {
if (txt.match(/\n\n\[\[/)) {
txt = txt.substring(0, txt.search(/\n\n\[\[/)) + "\n\n" +
fbtxt + txt.substring(txt.search(/\n\n\[\[/));
} else {
txt += "\n\n" + fbtxt;
}
fbsalve = (fbedit == "mínimo") ?
"Página marcada como [[WP:M|mínimo]]" :
"Página marcada como [[WP:EBC|esboço]]";
} else if (fbedit == "subst:VDA" || fbedit == "subst:matrad") {
txt = fbtxt;
} else {
txt = fbtxt + "\n\n" + txt;
}
txtbox.value = txt;
if (fbsalve) {
if (mw.config.get('wgNamespaceNumber') == 3) {
fbsalve = "Adicionando aviso";
} else {
switch (fbedit) {
case "subst:VDA":
fbsalve = "Página marcada como [[WP:VDA|VDA]]";
break;
case "subst:apagar":
fbsalve = "Página proposta para [[Wikipedia:Eliminação" +
" por votação|eliminação por votação]]";
break;
case "subst:s-fontes":
fbsalve = "Página marcada como sem fontes";
break;
case "subst:wkf":
fbsalve = "Página marcada para [[WP:WKF|wikificação]]";
break;
case "subst:rec":
fbsalve = "Página marcada para [[WP:RECI|reciclagem]]";
break;
case "parcial":
fbsalve = "Página marcada como parcial";
break;
case "subst:ctx":
fbsalve = "Página marcada como sem contexto";
break;
case "controverso|artigo":
fbsalve = "Marcado como controverso";
break;
case "subst:f-referências":
fbsalve = "Marcado que existem referências sem formatação";
break;
case "subst:m-notas":
fbsalve = "Marcado que carece de mais fontes";
break;
case "subst:s-notas":
fbsalve = "Página marcada como sem notas";
break;
case "subst:s-fontes-bpv":
fbsalve = "Marcado como [[WP:BPV|biografia de pessoa" +
" viva]] sem fontes";
break;
case "subst:fpr":
fbsalve = "Página marcada como sem fontes secundárias" +
" fiáveis";
break;
default:
if (fbsalve === true) {
fbsalve = "Adicionando marcação";
} else if (fbedit.indexOf("subst:ESR") === 0) {
fbsalve = "Página proposta para [[WP:ESR|eliminação" +
" semirrápida]]";
}
}
}
document.editform.wpSummary.value = fbsalve + ufb;
}
}
if (fbsalve) {
document.editform.submit();
}
}
};
/* Consulta a API do MediaWiki usando AJAX
* @param: {string} fapi An abreviation such as "esb", "afl", "PV",
* @param: {string} url The url of the API query
* FIXME: @deprecated Use jQuery AJAX functions (see [[mw:RL/JD#ajax.js]] )
*/
function fbajax(fapi, url) {
var fajax = sajax_init_object();
if (!fajax) {
return;
}
fajax.open('GET', url, true);
fajax.send('');
fajax.onreadystatechange = function () {
if (fajax.readyState == 4 && fajax.status == 200) {
window.fbapi(fapi, fajax.responseXML);
}
};
}
/* Callback function for API calls
* @param {string} fapi An abreviation such as "esb", "afl", "PV",
* @param {Object} api HTML code???
*/
window.fbapi = function (fapi, api) {
var url, esb, i, pages = '', charnum = 0, title, tamanho, coment, user;
if (!api) {
url = mw.config.get('wgScriptPath') + "/api.php?format=xml&action=query&";
// TODO: Criar um objeto { 'esb': ..., 'afl':... } com um item para cada "fabi"
switch ( fapi ) {
case 'esb':
esb = document.getElementById("esbinput");
if (esbtxt == esb.value || esbtxt2 == esb.value) {
return;
}
esbtxt = esb.value;
if (esbtxt == esb.value.substr(0, (esb.value.length - 1))) {
return;
}
url += "list=allpages&aplimit=1&apnamespace=10&apprefix=" +
encodeURI("Esboço-") + encodeURIComponent(esb.value);
break;
case 'afl':
url += "list=backlinks&bllimit=1&blfilterredir=nonredirects" +
"&blnamespace=0&bltitle=" +
encodeURIComponent(mw.config.get('wgPageName'));
break;
case 'PV':
url += "list=watchlist&wlexcludeuser=" +
encodeURIComponent(mw.config.get('wgUserName')) +
"&wlprop=user|comment|title|sizes";
break;
case 'PN':
url += "list=recentchanges&rctype=new&rcnamespace=0" +
"&rcshow=!patrolled&rcprop=user|comment|title|sizes|ids";
break;
case 'MR':
url += "list=recentchanges&rctype=edit&rcnamespace=0" +
"&rcshow=anon&rcprop=user|comment|title|sizes";
break;
case 'usu':
user = mw.config.get('wgTitle');
if (user.indexOf('/') > -1) {
user = user.substring(0, user.indexOf('/'));
}
url += "list=allusers&aulimit=1&aufrom=" +
encodeURIComponent(user) + "&auprop=editcount|registration";
break;
}
fbajax(fapi, url);
} else {
/** Processamento da resposta do API **/
switch ( fapi ) {
case 'afl':
// Afluentes
var info = "(";
info += (document.getElementById("Refer.C3.AAncias")
|| document.getElementById("Notas_e_refer.C3.AAncias")) ?
"ref" :
"<span style=\"color:red\">ref</span>";
var catline = document.getElementById("mw-normal-catlinks");
// FIXME: Do not do screen scraping to get this info!
if (catline && catline.innerHTML.indexOf("><a href=\"" + mw.config.get('wgArticlePath').replace('$1', '')) > -1) {
info += " · cat";
} else {
info += " · <span style=\"color:red\" title=\"Esta página ainda não foi categorizada\">cat</span>";
}
info += (document.getElementById("p-lang")) ?
" · iw" :
" · <span style=\"color:red\" title=\"Esta página ainda não" +
" possui links para outros idiomas\">iw</span>";
api = api.getElementsByTagName("bl");
if (api && api.length) {
info += " · <a href=\"" +
mw.util.wikiGetlink( 'Especial:Páginas afluentes/' + mw.config.get('wgPageName') ) +
"\" title=\"afluentes\">afl</a>)";
} else {
info += " · <span style=\"color:red\">afl</span>)";
}
url = mw.config.get('wgScriptPath') +
"/api.php?format=xml&action=query&prop=categories&titles=" +
mw.config.get('wgFormattedNamespaces')[ mw.config.get('wgNamespaceNumber') + 1 ] +
encodeURIComponent( mw.config.get('wgTitle') );
fb2.innerHTML = info;
if (document.getElementById("ca-talk").className != "new") {
fbajax("qualidade", url);
} else {
var hidcat = document.getElementById("mw-hidden-catlinks");
if (hidcat) {
hidcat = hidcat.innerHTML;
if (hidcat.indexOf("!Artigos de qualidade") > -1) {
hidcat = hidcat.substr(hidcat.indexOf("!Artigos de qualidade") + 22, 1);
if (hidcat == "d") {
hidcat = "?";
}
fb2.innerHTML += "<span title='Qualidade do artigo'> Q-<b>" +
hidcat + "</b></span>";
}
}
}
break;
case 'qualidade':
// Qualidade do artigo
api = api.getElementsByTagName("cl");
if (api) {
var apicat;
for (i = 0; i < api.length; i++) {
if (!api[i]){
continue;
}
apicat = api[i].getAttribute("title");
if (apicat.indexOf("!Artigos de qualidade") > -1) {
apicat = apicat.substr(32, 1);
if (apicat == "d") {
apicat = "?";
}
fb2.innerHTML += "<span title='Qualidade do artigo'> Q-<b>" +
apicat + "</b></span>";
break;
}
}
} else {
return;
}
break;
case 'esb':
// Esboço temático
api = api.getElementsByTagName("p");
if (api && api.length) {
api = api[0].getAttribute("title")
.replace(/Predefinição:Esboço-/gi, "");
} else {
return;
}
if ((esb.setSelectionRange
|| esb.createTextRange
|| typeof (esb.selectionStart) != 'undefined'
&& typeof (esb.selectionEnd) != 'undefined'
)
&& esb.value == api.substr(0, esb.value.length)
) {
// Exibe sugestões. Baseado no script do HotCat
var inicio = esb.value.length;
esb.value = api;
esbtxt2 = api;
if (esb.setSelectionRange) {
esb.setSelectionRange(inicio, api.length);
} else if (esb.createTextRange) {
var sel = esb.createTextRange();
sel.move("character", inicio);
sel.moveEnd("character", api.length - inicio);
sel.select();
} else {
esb.selectionStart = inicio;
esb.selectionEnd = api.length;
}
}
break;
case 'PV':
// Páginas vigiadas
api = api.getElementsByTagName("item");
for (i = 0; i < api.length && i < 10; i++) {
if (!api[i]){
continue;
}
title = api[i].getAttribute("title");
charnum += title.length;
if (charnum > 180) {
break;
}
tamanho = (api[i].getAttribute("newlen")
- api[i].getAttribute("oldlen"));
if (tamanho > 0) {
tamanho = "+" + tamanho;
}
coment = api[i].getAttribute("comment").replace("/*", "?");
if (coment) {
coment = "(" + coment.replace("*/", ":") + ")";
}
coment = coment.replace("[[Ajuda:Guia de edição/Menus e" +
" ferramentas/Sumário de edição|?]]", "");
if ( i > 0){
pages += ' | ';
}
pages += "<a href=\"" + mw.util.wikiGetlink( title ) +
"?diff=last\" title=\"(" + tamanho + ") " +
api[i].getAttribute("user") + " " + coment + "\">" +
title + "</a>";
}
fb2.innerHTML = pages;
break;
case 'PN':
// Páginas novas
api = api.getElementsByTagName("rc");
for (i = 0; i < api.length && i < 10; i++) {
if (!api[i]){
continue;
}
title = api[i].getAttribute("title");
charnum += title.length;
if (charnum > 180) {
break;
}
tamanho = "+" + api[i].getAttribute("newlen");
coment = api[i].getAttribute("comment");
if (coment) {
coment = "(" + coment.replace("[[Ajuda:SEA|?]] ", "") + ")";
}
if ( i > 0){
pages += ' | ';
}
pages += "<a href=\"" + mw.util.wikiGetlink( title )
+ "?redirect=no&rcid=" + api[i].getAttribute("rcid")
+ "\" title=\"(" + tamanho + ") " +
api[i].getAttribute("user") + " " + coment
+ "\">" + title + "</a>";
}
fb2.innerHTML = pages;
break;
case 'MR':
// Mudanças recentes
api = api.getElementsByTagName("rc");
for (i = 0; i < api.length && i < 10; i++) {
if (!api[i]){
continue;
}
title = api[i].getAttribute("title");
charnum += title.length;
if (charnum > 180) {
break;
}
tamanho = (api[i].getAttribute("newlen")
- api[i].getAttribute("oldlen"));
if (tamanho > 0) {
tamanho = "+" + tamanho;
}
coment = api[i].getAttribute("comment").replace("/*", "?");
if (coment) {
coment = "(" + coment.replace("*/", ":") + ")";
}
if ( i > 0){
pages += ' | ';
}
pages += "<a href=\"" + mw.util.wikiGetlink( title )
+ "?diff=last\" title=\"(" + tamanho + ") "
+ api[i].getAttribute("user") + " "
+ coment + "\">" + title + "</a>";
}
fb2.innerHTML = pages;
break;
case 'usu':
// Informações do usuário
api = api.getElementsByTagName("u");
if ( api && api.length ) {
var registro = api[0].getAttribute("registration");
registro = registro.substr(8, 2) + "/" + registro.substr(5, 2) +
"/" + registro.substr(0, 4);
user = mw.config.get('wgTitle');
if (user.indexOf("/") > -1) {
user = user.substring(0, user.indexOf("/"));
}
var encUser = encodeURI(user);
fb2.innerHTML =
"<span style=\"color:black\">" +
api[0].getAttribute("editcount") +
"</span> edições desde <span style=\"color:black\">" +
registro + "</span> | <a href=\"" +
mw.util.wikiGetlink( 'Especial:Contribuições/' ) +
encUser +
"\">contribuições</a> | <a href=\"" +
mw.util.wikiGetlink( 'Especial:Registo/' ) +
encUser +
"\">registros</a> | <a href=\"" +
mw.util.wikiGetlink( 'Especial:Registo' ) +
"?type=block&page=Usu%C3%A1rio%3A" +
encUser +
"\">registros de bloqueio</a> | <span class=\"plainlinks\">" +
"<a href=\"http://toolserver.org/~river/cgi-bin/count_edits?user=" +
encUser +
"&dbname=ptwiki_p\" class=\"external text\">contador de edições</a></span>";
} else {
return;
}
break;
}
}
};
/* Executes the gadget when document is ready */
$(function () {
var fbUser, contentSub = document.getElementById("contentSub"),
fbedit = mw.util.getParamValue('fastb');
contentSub.appendChild(fb1);
contentSub.appendChild(fb2);
if ($.inArray(mw.config.get('wgAction'), ["view", "edit"]) !== -1) {
fb2.innerHTML = ""; /*** Menu Principal ***/
if (mw.config.get('wgNamespaceNumber') > -1) {
fbUser = $.inArray(mw.config.get('wgNamespaceNumber'), [2, 3]) !== -1
&& mw.config.get('wgTitle').indexOf(mw.config.get('wgUserName')) === 0;
if (fbUser) {
fb1.innerHTML = "[" +
fbLink("ER|1", "ER1", "Eliminar subpágina do próprio usuário") +
"]";
} else {
fb1.innerHTML = "[<a onMouseOver='this.style.cursor=\"default\"'" +
" onClick='fbabrir(fbEr)'>ER</a>]";
}
}
if ($.inArray(mw.config.get('wgNamespaceNumber'), [0, 102]) !== -1) {
fb1.innerHTML += " [<a onMouseOver='this.style.cursor=\"default\"'" +
" onClick='fbabrir(fbEsr)'>ESR</a>] [" +
fbLink("subst:apagar", "PE",
"Marcar para eliminação por votação") +
"] [<a onMouseOver='this.style.cursor=\"pointer\"'" +
" title='Cópia/Violação de direito autoral'" +
" onClick='obs=prompt(\"Informe o url da página copiada\"," +
" \"http://\");fb(\"subst:VDA\",obs)'>VDA</a>] [" +
fbLink("subst:suspeito", "susp",
"Suspeito de violação de direitos autorais") +
"] [" + fbLink("subst:matrad", "trad",
"Tradução de baixa qualidade",
"De qual língua a página foi maltraduzida (ca, de, en, es," +
" fr, it, ja, nl, no, pl, ru, sv, zh)?") +
"] [" + fbLink("redirect", "#R", "Redirecionar",
"Redirecionar para qual página?") +
"] [<a onMouseOver='this.style.cursor=\"default\"'" +
" onClick='fbabrir(fbMan)'>manutenção</a>]" +
" [<a onMouseOver='this.style.cursor=\"default\"'" +
" onClick='fbabrir(fbEsb)'>esboço</a>]" +
" [<a onMouseOver='this.style.cursor=\"default\"'" +
" onClick='fbabrir(fbbus)'>busca</a>]";
if (mw.config.get('wgAction') === "view") {
window.fbapi("afl");
}
} else {
if ($.inArray(mw.config.get('wgNamespaceNumber'), [2, 10]) !== -1) {
fb1.innerHTML += " [" + fbLink("subst:apagar", "PE",
"Marcar para eliminação por votação") + "]";
}
if (mw.config.get('wgNamespaceNumber') % 2 === 0) {
fb1.innerHTML += " [" + fbLink("redirect", "#R", "Redirecionar",
"Redirecionar para qual página?") + "]";
}
if (mw.config.get('wgNamespaceNumber') === 14) {
fb1.innerHTML += " [<a onMouseOver='this.style.cursor=\"default\"'" +
" onClick='fbabrir(fbCat)'>CatScan</a>]";
}
}
if (mw.config.get('wgNamespaceNumber') === 3) {
fb1.innerHTML += " [<a onMouseOver='this.style.cursor=\"default\"'" +
" onClick='fbabrir(fbAv)'>aviso</a>]";
}
if ($.inArray(mw.config.get('wgNamespaceNumber'), [2, 3]) !== -1) {
fb1.innerHTML += " [<a onMouseOver='this.style.cursor=\"default\"'" +
" onClick='fbapi(\"usu\")'>sobre o usuário</a>]";
}
}
fb1.innerHTML += " [<a onMouseOver='this.style.cursor=\"default\"'" +
" title=\"Páginas vigiadas\" onClick='fbapi(\"PV\")'>PV</a>]" +
" [<a onMouseOver='this.style.cursor=\"default\"'" +
" title=\"Páginas novas não patrulhadas\"" +
" onClick='fbapi(\"PN\")'>PN</a>]" +
" [<a onMouseOver='this.style.cursor=\"default\"'" +
" title=\"Mudanças recentes (IPs, domínio principal)\"" +
" onClick='fbapi(\"MR\")'>MR</a>]";
switch (mw.config.get('wgAction')) {
case 'edit':
fbsalve = (fbedit !== null);
if (fbsalve) {
window.fb(fbedit, mw.util.getParamValue('fbtxt') || '');
}
break;
case 'markpatrolled':
if (fbedit !== null) {
location.href = mw.util.wikiGetlink( mw.config.get('wgPageName') ) +
'?action=edit&fastb=' + fbedit;
}
break;
default:
// Não faz nada nas demais ações
}
});