MediaWiki:Gadget-fastbuttons.js e Ajuda:Página de testes/1: diferenças entre as páginas
(Diferenças entre páginas)
Conteúdo apagado Conteúdo adicionado
m +carregamento do jquery.tipsy se estiver com FB escondido |
m atualização de MediaWiki:Gadget-fastbuttons.js |
||
Linha 1: | Linha 1: | ||
var fbsalve; |
|||
/*! |
|||
var fbNS = mw.config.get('wgNamespaceNumber'); |
|||
* FastButtons |
|||
var fb1 = document.createElement('div'), |
|||
* |
|||
fb2 = document.createElement('div'); |
|||
* @author [[es:User:Racso]] (versão original do script, na Wikipédia em espanhol) |
|||
* @author [[en:User:Macy]] (versão adaptada para a Wikipédia inglesa) |
|||
/* Cria os links que ativam a função fb() |
|||
* @author [[pt:User:Danilo.mac]] |
|||
* @param {string} fbf |
|||
* @author Helder (https://github.com/he7d3r) |
|||
* @param {string} ltxt Text for link |
|||
* @author [[pt:User:!Silent]] |
|||
* @param {string} ltit Title for link |
|||
* @source [[en:User:Macy/FastButtons.js]] ([[en:Special:PermaLink/230473471]]) |
|||
* @param {string=} lobs Text for prompt message (optional) |
|||
* @source [[es:Special:PrefixIndex/User:Racso/FB]] |
|||
* @see [[MediaWiki:Gadget-fastbuttons.css]] |
|||
* @see [[MediaWiki:Gadget-fastbuttons.js/buttonsList.js]] |
|||
* @see [[MediaWiki:Gadget-fastbuttons.js/core.js]] |
|||
* @help [[WP:Scripts/FastButtons]] |
|||
*/ |
*/ |
||
function fbLink(fbf, ltxt, ltit, lobs) { |
|||
/* global mw, $ */ |
|||
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] ***/ |
|||
( function () { |
|||
var fbEr = "Regra:"; |
|||
'use strict'; |
|||
fbEr += " 1 "; |
|||
fbEr += "|" + fbLink("ER|5", "5", "Aparecimento recorrente (se o conteúdo for igual ao eliminado por votação)"); |
|||
fbEr += ($.inArray(fbNS, [0, 102]) !== -1) ? "|" + fbLink("ER|6", "6", "Título é spam") : "| 6 "; |
|||
fbEr += "|" + fbLink("ER|7", "7", "Próprio criador reconhece que se enganou"); |
|||
fbEr += ($.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 "; |
|||
fbEr += "|" + fbLink("ER|9", "9", "Eliminar redirect, página sem histórico relevante (mover página redirecionada para cá)"); |
|||
fbEr += (fbNS === 0) ? "|" + fbLink("ER|10", "10", "Namespaces que não existem (WikipÉdia, AjUda)") : "| 10 "; |
|||
fbEr += "|" + fbLink("ER|11", "11", "Má configuração do teclado (Página, Usuário:Sicrano)"); |
|||
fbEr += (fbNS == 6) ? "|" + fbLink("ER|12", "12", "Imagens, somente por quem a carregou") : "| 12 "; |
|||
fbEr += ($.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 "; |
|||
fbEr += (fbNS == 6) ? "|" + fbLink("ER|14", "14", "Ficheiros (arquivos) duplicados") : "| 14 "; |
|||
fbEr += "|" + fbLink("ER|17", "17", "Salto de domínio"); |
|||
fbEr += (fbNS == 1) ? "|" + fbLink("ER|18", "18", "Discussão cujos artigos não existem") : "| 18 "; |
|||
fbEr += (fbNS == 6) ? "|" + fbLink("ER|19", "19", "Ficheiros (domínio Ficheiro:) que não são som, imagem ou vídeo") : "| 19 "; |
|||
fbEr += "|" + fbLink("ER|20", "20", "Impróprio"); |
|||
fbEr += (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 "; |
|||
fbEr += ($.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 "; |
|||
fbEr += (fbNS == 14) ? "|" + fbLink("ER|C1", "C1", "Categorias vazias, desnecessárias ou substituídas") : "| C1 "; |
|||
fbEr += (fbNS % 2 == 1) ? "|" + fbLink("ER|D1", "D1", "Discussões de páginas inexistentes") : "| D1 "; |
|||
fbEr += (fbNS % 2 == 1) ? "|" + fbLink("ER|D2", "D2", "Discussões de páginas para eliminação ou com histórico irrelevante") : "| D2 "; |
|||
fbEr += ($.inArray(fbNS, [2, 3]) !== -1) ? "|" + fbLink("ER|U1", "U1", "Uso impróprio da página de usuário") : "| U1 "; |
|||
fbEr += (fbNS == 2) ? "|" + fbLink("ER|U2", "U2", "PU criada por outro usuário") : "| U2 "; |
|||
fbEr += (fbNS == 10) ? "|" + fbLink("ER|P1", "P1", "Predefinições vazias, desnecessárias ou substituídas") : "| P1 "; |
|||
fbEr += "|" + fbLink("ER|R1", "R1", "Redirecionamento indevido, desnecessário, sem afluentes, para páginas inexistente ou eliminadas"); |
|||
fbEr += (fbNS % 2 == 1) ? "|" + fbLink("ER|R2", "R2", "Redirecionamento de página de discussão") : "| R2 "; |
|||
/*** Menu [ESR] ***/ |
|||
mw.messages.set( { |
|||
//FIXME: Update deprecated attributes to CSS: cellspacing --> border-spacing, valign --> vertical-align |
|||
'fastb-FastButtons': 'FastButtons', |
|||
var 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>"; |
|||
'fastb-showButton': 'exibir', |
|||
'fastb-hideButton': 'esconder', |
|||
'fastb-portletButton-title': 'Exibe/Esconde os botões do FastButtons' |
|||
} ); |
|||
//TODO: Merge with function fbesbok() defined below, possibly using $('#target').keypress() |
|||
var deferred, |
|||
function fbesrok(evt) { |
|||
portletLink = mw.util.addPortletLink( |
|||
if (window.event && window.event.keyCode == 13) { |
|||
'p-cactions', |
|||
evt = "ok"; |
|||
'#', |
|||
} else if (evt && evt.which == 13) { |
|||
mw.message( 'fastb-FastButtons' ) + ' (' + mw.message( 'fastb-' + ( localStorage.getItem( 'fastb-hidden' ) === 'true' ? 'show' : 'hide' ) + 'Button' ) + ')', |
|||
evt = "ok"; |
|||
'ca-fastbHideButton', |
|||
} |
|||
mw.message( 'fastb-portletButton-title' ) |
|||
if (evt == "ok") { |
|||
); |
|||
fb("subst:ESR", document.getElementById("esrinput").value + " ~~" + "~~"); |
|||
} |
|||
} |
|||
/*** Menu [esboço] ***/ |
|||
if ( localStorage.getItem( 'fastb-hidden' ) === 'true' ) { |
|||
//FIXME: Update deprecated attributes to CSS: cellspacing --> border-spacing, valign --> vertical-align |
|||
$( portletLink ).click( function( e ) { |
|||
var 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>"; |
|||
localStorage.setItem( 'fastb-hidden', false ); |
|||
var esbtxt = "", |
|||
$.getScript( '//pt.wikipedia.org/w/index.php?title=MediaWiki:Gadget-tipsyDeprecated.js&action=raw&ctype=text/javascript' ).done( function() { |
|||
esbtxt2 = ""; |
|||
mw.loader.load( 'ext.gadget.fastButtonsCore' ); |
|||
} ); |
|||
$( '#ca-fastbHideButton a' ).text( |
|||
mw.message( 'fastb-FastButtons' ) + ' (' + mw.message( 'fastb-' + ( localStorage.getItem( 'fastb-hidden' ) === 'true' ? 'show' : 'hide' ) + 'Button' ) + ')' |
|||
); |
|||
$( this ).off( 'click' ); |
|||
} ); |
|||
} else { |
|||
deferred = $.Deferred(); |
|||
//TODO: Merge with function fbesrok() defined above, possibly using $('#target').keypress() |
|||
$.getScript( '//pt.wikipedia.org/w/index.php?title=MediaWiki:Gadget-tipsyDeprecated.js&action=raw&ctype=text/javascript' ).done( function() { |
|||
function fbesbok(evt) { |
|||
mw.loader.load( 'ext.gadget.fastButtonsCore' ); |
|||
if (window.event && window.event.keyCode == 13) { |
|||
} ); |
|||
evt = "ok"; |
|||
} else if (evt && evt.which == 13) { |
|||
evt = "ok"; |
|||
} |
|||
if (evt == "ok") { |
|||
fb("esboço-" + document.getElementById("esbinput").value); |
|||
} |
|||
} |
} |
||
/*** Menu [manuteção] ***/ |
|||
var fbMan = fbLink("subst:wkf", "wikificar", "Não está formatado de acordo com o livro de estilo"); |
|||
fbMan += "|" + fbLink("subst:s-fontes", "sem fontes", "Página não cita nenhuma fonte ou referência"); |
|||
fbMan += "|" + fbLink("sem cat", "sem cat", "Página não está em nenhuma categoria"); |
|||
fbMan += "|" + fbLink("subst:rec", "reciclagem", "Página precisa ser reciclada de acordo com o livro de estilo"); |
|||
fbMan += "|" + fbLink("parcial", "parcial", "Artigo possui passagens que não respeitam o princípio da imparcialidade"); |
|||
fbMan += "|" + fbLink("subst:ctx", "contexto", "Página carece de contexto"); |
|||
fbMan += "|" + fbLink("controverso|artigo", "controverso", "controverso devido às disputas sobre o seu conteúdo"); |
|||
fbMan += "|" + fbLink("subst:f-referências", "formatar referências", "Artigo contém referências que necessitam de formatação"); |
|||
fbMan += "|" + fbLink("subst:m-notas", "mais notas", "Página cita fontes fiáveis, mas não cobre todo o texto"); |
|||
fbMan += "|" + fbLink("subst:s-notas", "sem notas", "Existem fontes no final da página, mas não são citadas no corpo do artigo"); |
|||
fbMan += "|" + fbLink("subst:s-fontes-bpv", "bpv sem fontes", "Biografia de pessoa viva que não cita nenhuma fonte"); |
|||
fbMan += "|" + fbLink("subst:fpr", "fonte primária", "Artigo necessita de fontes secundárias fiáveis publicadas por terceiros"); |
|||
/*** Menu [busca] ***/ |
|||
var fbtitulo = mw.config.get('wgTitle'); |
|||
if (fbtitulo.indexOf(" ") > -1){ |
|||
fbtitulo = "\"" + fbtitulo + "\""; |
|||
} |
|||
fbtitulo = encodeURIComponent(fbtitulo); |
|||
var 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"); |
|||
fbAv += "|" + fbLink("subst:bem-vindo", "BV", "Bem-vindo à Wikipédia"); |
|||
fbAv += "|" + fbLink("subst:bem-vinda", "BVª", "Bem-vinda à Wikipédia"); |
|||
fbAv += "|" + 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?"); |
|||
fbAv += "|" + fbLink("subst:bv-av-registrado", "av-BV", "Aviso sobre erro em artigo e boas vindas para usuário registrado", "Aviso sobre qual artigo?"); |
|||
fbAv += "|" + fbLink("subst:aviso-ER", "av-ER", "Aviso sobre eliminação rápida", "Qual página foi proposta para eliminação?"); |
|||
fbAv += "|" + fbLink("subst:av-bv-ER", "av-bv-ER", "Aviso sobre eliminação rápida + boas vindas.", "Qual página foi proposta para eliminação?"); |
|||
fbAv += "|" + fbLink("subst:bv-propaganda", "prop-BV", "Caro editor, por favor não faça propaganda,[...] Apesar disso, bem vindo à Wikipédia"); |
|||
fbAv += "|" + fbLink("subst:propaganda", "prop", "Caro editor, por favor não faça propaganda...", "Em que página foi feito propaganda?"); |
|||
fbAv += "|" + fbLink("subst:aviso", "av", "Aviso sobre erro em artigo", "Aviso sobre qual artigo?"); |
|||
fbAv += "|" + fbLink("subst:aviso2", "av2", "Aviso sobre vandalismo", "Qual página foi vandalizada?"); |
|||
fbAv += "|" + fbLink("subst:BSRE", "BSRE", "Aviso de biografia sem relevo enciclopédico", "Qual artigo?"); |
|||
fbAv += "|" + 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"); |
|||
fbAv += "|" + fbLink("subst:linguagem incorreta", "linguagem", "Não insulte nem use linguagem inadequada em artigos ou discussões"); |
|||
fbAv += "|" + fbLink("subst:ortografia", "ortografia", "Não mude a versão da língua"); |
|||
fbAv += "|" + 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?"); |
|||
fbAv += "|" + 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"); |
|||
fbAv += "|" + 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?"); |
|||
fbAv += "|" + fbLink("subst:autobiografia", "autobiografia", "Não crie autobiografias", "Qual autobiografia foi criada?"); |
|||
/** Menu [CatScan] **/ |
|||
var csurl = "http://toolserver.org/~daniel/WikiSense/CategoryIntersect.php?wikilang=pt&wikifam=.wikipedia.org&userlang=pt"; |
|||
var encTitle = encodeURIComponent(mw.config.get('wgTitle')); |
|||
var fbCat = "Procurar nesta categoria:"; |
|||
fbCat += " <a href='" + csurl + "&basecat=" + encTitle + "&basedeep=1&mode=ts&templates=Sem-fontes&go=Examinar&format=html'>sem fontes</a>"; |
|||
fbCat += " | <a href='" + csurl + "&basecat=" + encTitle + "&basedeep=1&mode=ts&templates=Revis%C3%A3o&go=Examinar&format=html'>revisão</a>"; |
|||
fbCat += " | <a href='" + csurl + "&basecat=" + encTitle + "&basedeep=1&mode=ts&templates=Wikifica%C3%A7%C3%A3o&go=Examinar&format=html'>wikificação</a>"; |
|||
fbCat += " | <a href='" + csurl + "&basecat=" + encTitle + "&basedeep=1&mode=ss&size=1000&stubop=or&links=4&go=Examinar&format=html'>menos de 1 000 bytes ou 4 links</a>"; |
|||
fbCat += " | <a href='" + csurl + "&basecat=" + encTitle + "&basedeep=1&mode=ss&size=500&stubop=or&links=2&go=Examinar&format=html'>menos de 500 bytes ou 2 links</a>"; |
|||
/* |
|||
* 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() |
|||
*/ |
|||
function fbabrir(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 |
|||
*/ |
|||
function fb(fbedit, fbtxt) { |
|||
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 = document.getElementById("wpTextbox1").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; |
|||
document.getElementById("wpTextbox1").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 (fbtxt) { |
|||
document.getElementById("wpTextbox1").value = (mw.config.get('wgNamespaceNumber') == 14) ? "{{redirecionamento de categoria|" + fbtxt + "}}" : "#Redirecionamento [[" + fbtxt + "]]"; |
|||
} |
|||
if (fbsalve && mw.config.get('wgNamespaceNumber') == 14) { |
|||
document.editform.wpSummary.value = "Redirecionando para a [[categoria:" + fbtxt + "]]" + ufb; |
|||
} |
|||
} 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; |
|||
} |
|||
document.getElementById("wpTextbox1").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 |
|||
* TODO: Use jQuery functions |
|||
*/ |
|||
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) { |
|||
fbapi(fapi, fajax.responseXML); |
|||
} |
|||
}; |
|||
} |
|||
/* Callback function for API calls |
|||
* @param {string} fapi An abreviation such as "esb", "afl", "PV", |
|||
* @param {Object} api |
|||
*/ |
|||
function fbapi(fapi, api) { |
|||
var url, esb, i, pages, charnum, title, tamanho, coment, user; |
|||
if (!api) { |
|||
url = mw.config.get('wgScriptPath') + "/api.php?format=xml&action=query&"; |
|||
if (fapi == "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&apnamespace=10&aplimit=1&apprefix=" + encodeURI("Esboço-") + encodeURIComponent(esb.value); |
|||
} else if (fapi == "afl") { |
|||
url += "list=backlinks&bllimit=1&blfilterredir=nonredirects&blnamespace=0&bltitle=" + encodeURIComponent(mw.config.get('wgPageName')); |
|||
} else if (fapi == "PV") { |
|||
url += "list=watchlist&wlexcludeuser=" + encodeURIComponent(mw.config.get('wgUserName')) + "&wlprop=user|comment|title|sizes"; |
|||
} else if (fapi == "PN") { |
|||
url += "list=recentchanges&rctype=new&rcnamespace=0&rcshow=!patrolled&rcprop=user|comment|title|sizes|ids"; |
|||
} else if (fapi == "MR") { |
|||
url += "list=recentchanges&rctype=edit&rcnamespace=0&rcshow=anon&rcprop=user|comment|title|sizes"; |
|||
} else if (fapi == "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"; |
|||
} |
|||
fbajax(fapi, url); |
|||
} else { |
|||
/** Processamento da resposta do API **/ |
|||
if (fapi == "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"); |
|||
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[0]) { |
|||
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>)"; |
|||
} |
|||
//mw.config.get('wgFormattedNamespaces')[ mw.config.get('wgNamespaceNumber') + 1 ] |
|||
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>"; |
|||
} |
|||
} |
|||
} |
|||
} else if (fapi == "qualidade") { // Qualidade do artigo |
|||
api = api.getElementsByTagName("cl"); |
|||
if (api) { |
|||
var apicat; |
|||
for (i = 0; i < api.length; i++) { |
|||
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; |
|||
} |
|||
} else if (fapi == "esb") { // Esboço temático |
|||
api = api.getElementsByTagName("p"); |
|||
if (api) { |
|||
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; |
|||
} |
|||
} |
|||
} else if (fapi == "PV") { // Páginas vigiadas |
|||
api = api.getElementsByTagName("item"); |
|||
charnum = 0; |
|||
for (i = 0; i < 10; i++) { |
|||
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 = ""; |
|||
} else { |
|||
pages += " |"; |
|||
} |
|||
pages += " <a href=\"" + mw.util.wikiGetlink( title ) + "?diff=last\" title=\"(" + tamanho + ") " + api[i].getAttribute("user") + " " + coment + "\">" + title + "</a>"; |
|||
} |
|||
fb2.innerHTML = pages; |
|||
} else if (fapi == "PN") { // Páginas novas |
|||
api = api.getElementsByTagName("rc"); |
|||
charnum = 0; |
|||
for (i = 0; i < 10; i++) { |
|||
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 = ""; |
|||
} else { |
|||
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; |
|||
} else if (fapi == "MR") { // Mudanças recentes |
|||
api = api.getElementsByTagName("rc"); |
|||
charnum = 0; |
|||
for (i = 0; i < 10; i++) { |
|||
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 = ""; |
|||
} else { |
|||
pages += " |"; |
|||
} |
|||
pages += " <a href=\"" + mw.util.wikiGetlink( title ) |
|||
+ "?diff=last\" title=\"(" + tamanho + ") " |
|||
+ api[i].getAttribute("user") + " " |
|||
+ coment + "\">" + title + "</a>"; |
|||
} |
|||
fb2.innerHTML = pages; |
|||
} else if (fapi == "usu") { // Informações do usuário |
|||
api = api.getElementsByTagName("u"); |
|||
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>"; |
|||
} |
|||
} |
|||
} |
|||
/* 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") { |
|||
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) { |
|||
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 |
|||
} |
|||
}); |