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 melhor? |
m Versão do MediaWiki:Gadget-fastbuttons.js que agrupa as variáveis em um namespace próprio (fb), evitando a poluição do namespace global |
||
Linha 6: | Linha 6: | ||
* @source: [[es:Special:PrefixIndex/User:Racso/FB]] |
* @source: [[es:Special:PrefixIndex/User:Racso/FB]] |
||
*/ |
*/ |
||
window.fb = { |
|||
var fbsalve, |
|||
namespace: mw.config.get('wgNamespaceNumber'), |
|||
menu: document.createElement('div'), |
|||
submenu: document.createElement('div') |
|||
}; |
|||
/* Cria os links que ativam a função fb() |
/* Cria os links que ativam a função fb.run() |
||
* @param {string} |
* @param {string} func |
||
* @param {string} |
* @param {string} text Text for link |
||
* @param {string} |
* @param {string} title Title for link |
||
* @param {string=} lobs Text for prompt message (optional) |
* @param {string=} lobs Text for prompt message (optional) |
||
*/ |
*/ |
||
function |
fb.link = function (func, text, title, lobs) { |
||
if ( |
if (func.indexOf("ER") === 0) { |
||
func = 'var obs=prompt("Se necessário, coloque uma observação.");' |
|||
+ 'fb("' + |
+ 'fb.run("' + func + '",obs)'; |
||
} else if (lobs) { |
} else if (lobs) { |
||
func = "var obs=prompt(\"" + lobs + "\");fb.run(\"" + func + "\",obs)"; |
|||
} else { |
} else { |
||
func = "fb.run(\"" + func + "\")"; |
|||
} |
} |
||
return " <a onMouseOver='this.style.cursor=\"pointer\"' title='" |
return " <a onMouseOver='this.style.cursor=\"pointer\"' title='" |
||
+ |
+ title + "' onClick='" + func + "'>" + text + "</a> "; |
||
} |
}; |
||
/*** Menu [ER] ***/ |
/*** Menu [ER] ***/ |
||
fb.ER = "Regra:"; |
|||
fb.ER += " 1 " + [ |
|||
fb.link("ER|5", "5", "Aparecimento recorrente (se o conteúdo for igual" + |
|||
" ao eliminado por votação)"), |
" ao eliminado por votação)"), |
||
(($.inArray( |
(($.inArray(fb.namespace, [0, 102]) !== -1) ? |
||
fb.link("ER|6", "6", "Título é spam") : |
|||
" 6 "), |
" 6 "), |
||
fb.link("ER|7", "7", "Próprio criador reconhece que se enganou"), |
|||
(($.inArray('sysop', mw.config.get('wgUserGroups')) > -1) ? |
(($.inArray('sysop', mw.config.get('wgUserGroups')) > -1) ? |
||
fb.link("ER|8", "8", "Eliminações temporárias sem perda de histórico" + |
|||
" para resolver problemas técnicos") : |
" para resolver problemas técnicos") : |
||
" 8 "), |
" 8 "), |
||
fb.link("ER|9", "9", "Eliminar redirect, página sem histórico relevante" |
|||
+ " (mover página redirecionada para cá)"), |
+ " (mover página redirecionada para cá)"), |
||
(( |
((fb.namespace === 0) ? |
||
fb.link("ER|10", "10", "Namespaces que não existem (WikipÉdia, AjUda)") : |
|||
" 10 " ), |
" 10 " ), |
||
fb.link("ER|11", "11", "Má configuração do teclado (Página," + |
|||
" Usuário:Sicrano)"), |
" Usuário:Sicrano)"), |
||
( |
(fb.namespace == 6) ? |
||
fb.link("ER|12", "12", "Imagens, somente por quem a carregou") : |
|||
" 12 ", |
" 12 ", |
||
($.inArray( |
($.inArray(fb.namespace, [0, 102]) !== -1) ? |
||
fb.link("ER|13", "13", "Páginas sem histórico relevante que são" + |
|||
" violações flagrantes de direitos autorais de outras páginas" + |
" violações flagrantes de direitos autorais de outras páginas" + |
||
" na internet.") : |
" na internet.") : |
||
" 13 ", |
" 13 ", |
||
( |
(fb.namespace == 6) ? |
||
fb.link("ER|14", "14", "Ficheiros (arquivos) duplicados") : |
|||
" 14 ", |
" 14 ", |
||
fb.link("ER|17", "17", "Salto de domínio"), |
|||
( |
(fb.namespace == 1) ? |
||
fb.link("ER|18", "18", "Discussão cujos artigos não existem") : |
|||
" 18 ", |
" 18 ", |
||
( |
(fb.namespace == 6) ? |
||
fb.link("ER|19", "19", "Ficheiros (domínio Ficheiro:) que não são som," + |
|||
" imagem ou vídeo") : |
" imagem ou vídeo") : |
||
" 19 ", |
" 19 ", |
||
fb.link("ER|20", "20", "Impróprio"), |
|||
(mw.config.get('wgPageName').indexOf("Wikipédia:Páginas_para_eliminar/") === 0) ? |
(mw.config.get('wgPageName').indexOf("Wikipédia:Páginas_para_eliminar/") === 0) ? |
||
fb.link("ER|21", "21", "Página de eliminação de um artigo antes de" + |
|||
" passados 6 meses da última votação") : |
" passados 6 meses da última votação") : |
||
" 21 ", |
" 21 ", |
||
($.inArray( |
($.inArray(fb.namespace, [0, 102]) !== -1) ? |
||
fb.link("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" + |
" 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" + |
" do teclado, com codificação incorreta do sistema ou que expressem" + |
||
" domínios que não existem.") : |
" domínios que não existem.") : |
||
" A1 ", |
" A1 ", |
||
( |
(fb.namespace == 14) ? |
||
fb.link("ER|C1", "C1", "Categorias vazias, desnecessárias ou substituídas") : |
|||
" C1 ", |
" C1 ", |
||
( |
(fb.namespace % 2 == 1) ? |
||
fb.link("ER|D1", "D1", "Discussões de páginas inexistentes") : |
|||
" D1 ", |
" D1 ", |
||
( |
(fb.namespace % 2 == 1) ? |
||
fb.link("ER|D2", "D2", "Discussões de páginas para eliminação ou com" + |
|||
" histórico irrelevante") : |
" histórico irrelevante") : |
||
" D2 ", |
" D2 ", |
||
($.inArray( |
($.inArray(fb.namespace, [2, 3]) !== -1) ? |
||
fb.link("ER|U1", "U1", "Uso impróprio da página de usuário") : |
|||
" U1 ", |
" U1 ", |
||
( |
(fb.namespace == 2) ? |
||
fb.link("ER|U2", "U2", "PU criada por outro usuário") : |
|||
" U2 ", |
" U2 ", |
||
( |
(fb.namespace == 10) ? |
||
fb.link("ER|P1", "P1", "Predefinições vazias, desnecessárias ou" + |
|||
" substituídas") : |
" substituídas") : |
||
" P1 ", |
" P1 ", |
||
fb.link("ER|R1", "R1", "Redirecionamento indevido, desnecessário, sem" + |
|||
" afluentes, para páginas inexistente ou eliminadas"), |
" afluentes, para páginas inexistente ou eliminadas"), |
||
( |
(fb.namespace % 2 == 1) ? |
||
fb.link("ER|R2", "R2", "Redirecionamento de página de discussão") : |
|||
" R2 " |
" R2 " |
||
].join('|'); |
].join('|'); |
||
Linha 109: | Linha 110: | ||
/*** 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 |
||
fb.ESR = "<table cellspacing=0 style=\"color:#7D7D7D\"><tr><td valign=top>" |
|||
+ |
+ fb.link("subst:ESR-banda|1=~~" + "~~", "banda", "Artigo sobre banda sem fontes e sem notoriedade") |
||
+ "|" + |
+ "|" + fb.link("subst:ESR-bio|1=~~" + "~~", "biografia", "Biografia sem fontes e sem notoriedade") |
||
+ "|" + |
+ "|" + fb.link("subst:ESR-empresa|1=~~" + "~~", "empresa", "Empresa sem fontes e sem notoriedade") |
||
+ "| outra: </td><td><input type=\"text\" id=\"esrinput\" onKeyPress=\" |
+ "| outra: </td><td><input type=\"text\" id=\"esrinput\" onKeyPress=\"fb.ESRok(event)\" size=55/><input type=\"button\" onMouseDown='fb.ESRok(\"ok\")' value=\"OK\"/></td></tr></table>"; |
||
// TODO: Merge with function |
// TODO: Merge with function fb.esbOk() defined below, possibly using jQuery |
||
// $('#target').keypress() |
// $('#target').keypress() |
||
fb.ESRok = function(evt) { |
|||
if (window.event && window.event.keyCode == 13) { |
if (window.event && window.event.keyCode == 13) { |
||
evt = "ok"; |
evt = "ok"; |
||
Linha 124: | Linha 125: | ||
} |
} |
||
if (evt == "ok") { |
if (evt == "ok") { |
||
this.run("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 |
||
fb.esb = "<table cellspacing=0 style=\"color:#7D7D7D\">" + |
|||
"<tr><td valign=top>" + |
"<tr><td valign=top>" + |
||
fb.link("mínimo", "mínimo", "Artigo com apenas uma frase") + |
|||
"|" + |
"|" + fb.link("esboço", "esboço", "Artigo ainda pouco desenvolvido") + |
||
"| <span style=\"color:black;\">esboço-</span>" + |
"| <span style=\"color:black;\">esboço-</span>" + |
||
"</td><td>" + "<input id=\"esbinput\" onkeyup=' |
"</td><td>" + "<input id=\"esbinput\" onkeyup='fb.api(\"esb\")'" + |
||
" onKeyPress=\" |
" onKeyPress=\"fb.esbOk(event)\" size=14/>" + |
||
"<input type=\"button\" onMouseDown=' |
"<input type=\"button\" onMouseDown='fb.esbOk(\"ok\")' value=\"OK\"/>" + |
||
"</td></tr></table>"; |
"</td></tr></table>"; |
||
var |
var esbText = "", |
||
esbText2 = ""; |
|||
//TODO: Merge with function |
//TODO: Merge with function fb.ESRok() defined above, possibly using $('#target').keypress() |
||
fb.esbOk = function (evt) { |
|||
if (window.event && window.event.keyCode == 13) { |
if (window.event && window.event.keyCode == 13) { |
||
evt = "ok"; |
evt = "ok"; |
||
Linha 150: | Linha 151: | ||
} |
} |
||
if (evt == "ok") { |
if (evt == "ok") { |
||
fb.run("esboço-" + document.getElementById("esbinput").value); |
|||
} |
} |
||
}; |
}; |
||
/*** Menu [manuteção] ***/ |
/*** Menu [manuteção] ***/ |
||
fb.man = [ |
|||
fb.link("subst:wkf", "wikificar", "Não está formatado de acordo com o livro" + |
|||
" de estilo"), |
" de estilo"), |
||
fb.link("subst:s-fontes", "sem fontes", "Página não cita nenhuma fonte ou" + |
|||
" referência"), |
" referência"), |
||
fb.link("sem cat", "sem cat", "Página não está em nenhuma categoria"), |
|||
fb.link("subst:rec", "reciclagem", "Página precisa ser reciclada de acordo" + |
|||
" com o livro de estilo"), |
" com o livro de estilo"), |
||
fb.link("parcial", "parcial", "Artigo possui passagens que não respeitam o" + |
|||
" princípio da imparcialidade"), |
" princípio da imparcialidade"), |
||
fb.link("subst:ctx", "contexto", "Página carece de contexto"), |
|||
fb.link("controverso|artigo", "controverso", "controverso devido às disputas" + |
|||
" sobre o seu conteúdo"), |
" sobre o seu conteúdo"), |
||
fb.link("subst:f-referências", "formatar referências", "Artigo contém" + |
|||
" referências que necessitam de formatação"), |
" referências que necessitam de formatação"), |
||
fb.link("subst:m-notas", "mais notas", "Página cita fontes fiáveis, mas não" + |
|||
" cobre todo o texto"), |
" cobre todo o texto"), |
||
fb.link("subst:s-notas", "sem notas", "Existem fontes no final da página," + |
|||
" mas não são citadas no corpo do artigo"), |
" mas não são citadas no corpo do artigo"), |
||
fb.link("subst:s-fontes-bpv", "bpv sem fontes", "Biografia de pessoa viva" + |
|||
" que não cita nenhuma fonte"), |
" que não cita nenhuma fonte"), |
||
fb.link("subst:fpr", "fonte primária", "Artigo necessita de fontes" + |
|||
" secundárias fiáveis publicadas por terceiros") |
" secundárias fiáveis publicadas por terceiros") |
||
].join('|'); |
].join('|'); |
||
/*** Menu [busca] ***/ |
/*** Menu [busca] ***/ |
||
fb.title = mw.config.get('wgTitle'); |
|||
if ( |
if (fb.title.indexOf(" ") > -1){ |
||
fb.title = "\"" + fb.title + "\""; |
|||
} |
} |
||
fb.title = encodeURIComponent(fb.title); |
|||
fb.search = "<span class=\"plainlinks\"><a href=\"http://www.google.com/search?&as_eq=wikipedia&as_epq=" |
|||
+ |
+ fb.title + "\" class=\"external text\">Google</a> — <a href=\"http://news.google.com/archivesearch?&as_src=-newswire+-wire+-presswire+-PR+-press+-release&as_epq=" |
||
+ |
+ fb.title + "\" class=\"external text\">notícias</a>, <a href=\"http://books.google.com/books?&as_brr=0&as_epq=" |
||
+ |
+ fb.title + "\" class=\"external text\">livros</a>, <a href=\"http://scholar.google.com/scholar?as_epq=" |
||
+ |
+ fb.title + "\" class=\"external text\">acadêmico</a> — <a href=\"http://www.scirus.com/srsapp/search?q=" |
||
+ |
+ fb.title + "&t=all&sort=0&g=s\" class=\"external text\">Scirus</a></span>"; |
||
/*** Menu [aviso] ***/ |
/*** Menu [aviso] ***/ |
||
fb.warn = [fb.link("subst:bem-vindo IP", "BV-IP", |
|||
"Boas-vindas para usuário(a) não registrado(a)"), |
"Boas-vindas para usuário(a) não registrado(a)"), |
||
fb.link("subst:bem-vindo", "BV", "Bem-vindo(a) à Wikipédia"), |
|||
fb.link("subst:bem-vinda", "BVª", "Bem-vinda à Wikipédia"), |
|||
fb.link("subst:bv-av", "av-BV-IP", |
|||
"Aviso sobre erro em artigo e boas-vindas para usuário(a) não registrado(a)", |
"Aviso sobre erro em artigo e boas-vindas para usuário(a) não registrado(a)", |
||
"Aviso sobre qual artigo?"), |
"Aviso sobre qual artigo?"), |
||
fb.link("subst:bv-av-registrado", "av-BV", |
|||
"Aviso sobre erro em artigo e boas-vindas para usuário(a) registrado", |
"Aviso sobre erro em artigo e boas-vindas para usuário(a) registrado", |
||
"Aviso sobre qual artigo?"), |
"Aviso sobre qual artigo?"), |
||
fb.link("subst:aviso-ER", "av-ER", "Aviso sobre eliminação rápida", |
|||
"Qual página foi proposta para eliminação?"), |
"Qual página foi proposta para eliminação?"), |
||
fb.link("subst:av-bv-ER", "av-BV-ER", |
|||
"Aviso sobre eliminação rápida + boas-vindas", |
"Aviso sobre eliminação rápida + boas-vindas", |
||
"Qual página foi proposta para eliminação?"), |
"Qual página foi proposta para eliminação?"), |
||
fb.link("subst:aviso-ESR", "av-ESR", "Aviso sobre eliminação semirrápida", |
|||
"Qual página foi proposta para eliminação?"), |
"Qual página foi proposta para eliminação?"), |
||
fb.link("subst:aviso-PE", "av-PE", "Aviso sobre eliminação por votação", |
|||
"Qual página foi proposta para eliminação?"), |
"Qual página foi proposta para eliminação?"), |
||
fb.link("subst:aviso-PE-criador", "av-PE-criador", "Aviso ao criador sobre eliminação por votação", |
|||
"Qual página foi proposta para eliminação?"), |
"Qual página foi proposta para eliminação?"), |
||
fb.link("subst:bv-propaganda", "prop-BV", "Caro editor, por favor não faça" + |
|||
" propaganda, [...] Apesar disso, bem-vindo à Wikipédia"), |
" propaganda, [...] Apesar disso, bem-vindo à Wikipédia"), |
||
fb.link("subst:propaganda", "prop", |
|||
"Caro editor, por favor não faça propaganda...", |
"Caro editor, por favor não faça propaganda...", |
||
"Em que página foi feita propaganda?"), |
"Em que página foi feita propaganda?"), |
||
fb.link("subst:aviso", "av", "Aviso sobre erro em artigo", |
|||
"Aviso sobre qual artigo?"), |
"Aviso sobre qual artigo?"), |
||
fb.link("subst:aviso2", "av2", "Aviso sobre vandalismo", |
|||
"Qual página foi vandalizada?"), |
"Qual página foi vandalizada?"), |
||
fb.link("subst:BSRE", "BSRE", "Aviso de biografia sem relevo enciclopédico", |
|||
"Qual artigo?"), |
"Qual artigo?"), |
||
fb.link("subst:cópia", "cópia", |
|||
"Aviso sobre artigo copiado de fonte externa/VDA", |
"Aviso sobre artigo copiado de fonte externa/VDA", |
||
"Preencha usando \\\"|2=\\\" como separador: página da Wikipédia" + |
"Preencha usando \\\"|2=\\\" como separador: página da Wikipédia" + |
||
"|2=url da página copiada"), |
"|2=url da página copiada"), |
||
fb.link("subst:linguagem incorreta", "linguagem", |
|||
"Não insulte nem use linguagem inadequada em artigos ou discussões"), |
"Não insulte nem use linguagem inadequada em artigos ou discussões"), |
||
fb.link("subst:ortografia", "ortografia", "Não mude a versão da língua"), |
|||
fb.link("subst:mostrar previsão", "salvamento sucessivo", |
|||
"Não faça salvamentos sucessivos, utilize o botão\"Mostrar previsão\"", |
"Não faça salvamentos sucessivos, utilize o botão\"Mostrar previsão\"", |
||
"Em que artigo foram feitos salvamentos sucessivos?"), |
"Em que artigo foram feitos salvamentos sucessivos?"), |
||
fb.link("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"), |
" que não contribuíram com pelo menos uma edição válida"), |
||
fb.link("subst:Av-página de usuário", "av-PU", "Considere refazer a página de usuário(a)"), |
|||
fb.link("subst:Aviso/Página pessoal", "av-PU-outro", |
|||
"Não edite páginas de outros usuários", |
"Não edite páginas de outros usuários", |
||
"Qual página de outro(a) usuário(a) foi editada?"), |
"Qual página de outro(a) usuário(a) foi editada?"), |
||
fb.link("subst:não remova", "não remova", |
|||
"Não remova marcações de eliminação das páginas", |
"Não remova marcações de eliminação das páginas", |
||
"Qual página em que a marcação de eliminação foi removida?"), |
"Qual página em que a marcação de eliminação foi removida?"), |
||
fb.link("subst:autobiografia", "autobiografia", "Não crie autobiografias", |
|||
"Qual autobiografia foi criada?") |
"Qual autobiografia foi criada?") |
||
].join('|'); |
].join('|'); |
||
/** Menu [CatScan] **/ |
/** Menu [CatScan] **/ |
||
var |
var catScanUrl = '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='; |
|||
fb.cat = "Procurar nesta categoria: " + [ |
|||
"<a href='" + |
"<a href='" + catScanUrl + "ts&templates=Sem-fontes'>sem fontes</a>", |
||
"<a href='" + |
"<a href='" + catScanUrl + "ts&templates=Revis%C3%A3o&go='>revisão</a>", |
||
"<a href='" + |
"<a href='" + catScanUrl + "ts&templates=Wikifica%C3%A7%C3%A3o&go='>wikificação</a>", |
||
"<a href='" + |
"<a href='" + catScanUrl + "ss&size=1000&stubop=or&links=4&go='>menos de 1 000 bytes ou 4 links</a>", |
||
"<a href='" + |
"<a href='" + catScanUrl + "ss&size=500&stubop=or&links=2&go='>menos de 500 bytes ou 2 links</a>" |
||
].join(' | '); |
|||
/* |
/* |
||
Linha 267: | Linha 268: | ||
* TODO: Replace ocurrences of this function by something like $(...).html() |
* TODO: Replace ocurrences of this function by something like $(...).html() |
||
*/ |
*/ |
||
fb.open = function (menu) { |
|||
this.submenu.innerHTML = menu; |
|||
}; |
}; |
||
/* Função de edição |
/* Função de edição |
||
* @param: {string} |
* @param: {string} code A template name, possibly preceded by "subst:", |
||
* and optionally followed by "|" and some parameter(s) |
* and optionally followed by "|" and some parameter(s) |
||
* @param: {(string|null)=} |
* @param: {(string|null)=} extraText Extra text for templates and redirects (optional) |
||
* @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 |
||
*/ |
*/ |
||
fb.run = function (code, extraText) { |
|||
var |
var textBox = document.getElementById("wpTextbox1"); |
||
if ( |
if (extraText === null) { |
||
// Do nothing if the user canceled the prompt box |
// Do nothing if the user canceled the prompt box |
||
return false; |
return false; |
||
Linha 285: | Linha 286: | ||
if (mw.config.get('wgAction') == 'view') { |
if (mw.config.get('wgAction') == 'view') { |
||
var url = mw.util.wikiGetlink( mw.config.get('wgPageName') ) |
var url = mw.util.wikiGetlink( mw.config.get('wgPageName') ) |
||
+ '?action=edit&fastb=' + encodeURIComponent( |
+ '?action=edit&fastb=' + encodeURIComponent(code); |
||
if ( |
if (extraText) { |
||
location.href = url + '&fbtxt=' + encodeURIComponent( |
location.href = url + '&fbtxt=' + encodeURIComponent(extraText); |
||
} else { |
} else { |
||
location.href = url; |
location.href = url; |
||
} |
} |
||
} else if (mw.config.get('wgAction') == "edit") { |
} else if (mw.config.get('wgAction') == "edit") { |
||
var |
var value = textBox.value; |
||
var |
var summary = " (usando [[Wikipédia:FB|FastButtons]])"; |
||
if ( |
if ( value.match(/\{\{(?:ER|ESR2|Usuário\:Salebot\/Impróprio)\|/i) ) { |
||
alert("Já existe uma predefinição de eliminação nesta página."); |
alert("Já existe uma predefinição de eliminação nesta página."); |
||
return false; |
return false; |
||
} |
} |
||
if ( |
if (code.indexOf("ER") === 0) { |
||
if ( |
if (extraText) { |
||
extraText = "|3=" + extraText + "}}\n\n"; |
|||
} else { |
} else { |
||
extraText = "}}\n\n"; |
|||
} |
} |
||
extraText = "{{" + code + "|2=~~" + "~~" + extraText; |
|||
textBox.value = extraText + value; |
|||
if ( |
if (this.salve) { |
||
document.editform.wpSummary.value = "Página proposta para" + |
document.editform.wpSummary.value = "Página proposta para" + |
||
" [[WP:ER|eliminação rápida]] (regra " + |
" [[WP:ER|eliminação rápida]] (regra " + |
||
code.substring(3) + ")" + summary; |
|||
} |
} |
||
} else if ( |
} else if (code == "redirect") { |
||
if (mw.config.get('wgNamespaceNumber') == 14) { |
if (mw.config.get('wgNamespaceNumber') == 14) { |
||
if ( |
if (extraText) { |
||
textBox.value = "{{redirecionamento de categoria|" + |
|||
extraText + "}}"; |
|||
} |
} |
||
if ( |
if (this.salve) { |
||
document.editform.wpSummary.value = "Redirecionando para" + |
document.editform.wpSummary.value = "Redirecionando para" + |
||
" a [[categoria:" + |
" a [[categoria:" + extraText + "]]" + summary; |
||
} |
} |
||
} else { |
} else { |
||
if ( |
if (extraText) { |
||
textBox.value = "#Redirecionamento [[" + extraText + "]]"; |
|||
} |
} |
||
} |
} |
||
} else { |
} else { |
||
if ( |
if (extraText) { |
||
if ( |
if (code.indexOf("|") > -1) { |
||
extraText = "|1=" + extraText + "}}"; |
|||
} else { |
} else { |
||
extraText = "|1=" + extraText + "}}"; |
|||
} |
} |
||
} else { |
} else { |
||
extraText = "}}"; |
|||
} |
} |
||
extraText = "{{" + code + extraText; |
|||
if (mw.config.get('wgNamespaceNumber') == 3) { |
if (mw.config.get('wgNamespaceNumber') == 3) { |
||
value += "\n\n" + extraText + " ~~" + "~~"; |
|||
} else if ( |
} else if (code == "mínimo" || code.indexOf("esboço") === 0) { |
||
if ( |
if (value.match(/\n\n\[\[/)) { |
||
value = value.substring(0, value.search(/\n\n\[\[/)) + "\n\n" + |
|||
extraText + value.substring(value.search(/\n\n\[\[/)); |
|||
} else { |
} else { |
||
value += "\n\n" + extraText; |
|||
} |
} |
||
this.salve = (code == "mínimo") ? |
|||
"Página marcada como [[WP:M|mínimo]]" : |
"Página marcada como [[WP:M|mínimo]]" : |
||
"Página marcada como [[WP:EBC|esboço]]"; |
"Página marcada como [[WP:EBC|esboço]]"; |
||
} else if ( |
} else if (code == "subst:VDA" || code == "subst:matrad") { |
||
value = extraText; |
|||
} else { |
} else { |
||
value = extraText + "\n\n" + value; |
|||
} |
} |
||
textBox.value = value; |
|||
if ( |
if (this.salve) { |
||
if (mw.config.get('wgNamespaceNumber') == 3) { |
if (mw.config.get('wgNamespaceNumber') == 3) { |
||
this.salve = "Adicionando aviso"; |
|||
} else { |
} else { |
||
switch ( |
switch (code) { |
||
case "subst:VDA": |
case "subst:VDA": |
||
this.salve = "Página marcada como [[WP:VDA|VDA]]"; |
|||
break; |
break; |
||
case "subst:apagar": |
case "subst:apagar": |
||
this.salve = "Página proposta para [[Wikipedia:Eliminação" + |
|||
" por votação|eliminação por votação]]"; |
" por votação|eliminação por votação]]"; |
||
break; |
break; |
||
case "subst:s-fontes": |
case "subst:s-fontes": |
||
this.salve = "Página marcada como sem fontes"; |
|||
break; |
break; |
||
case "subst:wkf": |
case "subst:wkf": |
||
this.salve = "Página marcada para [[WP:WKF|wikificação]]"; |
|||
break; |
break; |
||
case "subst:rec": |
case "subst:rec": |
||
this.salve = "Página marcada para [[WP:RECI|reciclagem]]"; |
|||
break; |
break; |
||
case "parcial": |
case "parcial": |
||
this.salve = "Página marcada como parcial"; |
|||
break; |
break; |
||
case "subst:ctx": |
case "subst:ctx": |
||
this.salve = "Página marcada como sem contexto"; |
|||
break; |
break; |
||
case "controverso|artigo": |
case "controverso|artigo": |
||
this.salve = "Marcado como controverso"; |
|||
break; |
break; |
||
case "subst:f-referências": |
case "subst:f-referências": |
||
this.salve = "Marcado que existem referências sem formatação"; |
|||
break; |
break; |
||
case "subst:m-notas": |
case "subst:m-notas": |
||
this.salve = "Marcado que carece de mais fontes"; |
|||
break; |
break; |
||
case "subst:s-notas": |
case "subst:s-notas": |
||
this.salve = "Página marcada como sem notas"; |
|||
break; |
break; |
||
case "subst:s-fontes-bpv": |
case "subst:s-fontes-bpv": |
||
this.salve = "Marcado como [[WP:BPV|biografia de pessoa" + |
|||
" viva]] sem fontes"; |
" viva]] sem fontes"; |
||
break; |
break; |
||
case "subst:fpr": |
case "subst:fpr": |
||
this.salve = "Página marcada como sem fontes secundárias" + |
|||
" fiáveis"; |
" fiáveis"; |
||
break; |
break; |
||
default: |
default: |
||
if ( |
if (this.salve === true) { |
||
this.salve = "Adicionando marcação"; |
|||
} else if ( |
} else if (code.indexOf("subst:ESR") === 0) { |
||
this.salve = "Página proposta para [[WP:ESR|eliminação" + |
|||
" semirrápida]]"; |
" semirrápida]]"; |
||
} |
} |
||
} |
} |
||
} |
} |
||
document.editform.wpSummary.value = |
document.editform.wpSummary.value = this.salve + summary; |
||
} |
} |
||
} |
} |
||
if ( |
if (this.salve) { |
||
document.editform.submit(); |
document.editform.submit(); |
||
} |
} |
||
Linha 422: | Linha 423: | ||
/* Consulta a API do MediaWiki usando AJAX |
/* Consulta a API do MediaWiki usando AJAX |
||
* @param: {string} |
* @param: {string} code 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]] ) |
* FIXME: @deprecated Use jQuery AJAX functions (see [[mw:RL/JD#ajax.js]] ) |
||
*/ |
*/ |
||
function |
fb.ajax = function (code, url) { |
||
var |
var ajax = sajax_init_object(), |
||
that = this; |
|||
if (! |
if (!ajax) { |
||
return; |
return; |
||
} |
} |
||
ajax.open('GET', url, true); |
|||
ajax.send(''); |
|||
ajax.onreadystatechange = function () { |
|||
if ( |
if (ajax.readyState == 4 && ajax.status == 200) { |
||
that.api(code, ajax.responseXML); |
|||
} |
} |
||
}; |
}; |
||
} |
}; |
||
/* Callback function for API calls |
/* Callback function for API calls |
||
* @param {string} |
* @param {string} code An abreviation such as "esb", "afl", "PV", |
||
* @param {Object} api HTML code??? |
* @param {Object} api HTML code??? |
||
*/ |
*/ |
||
fb.api = function (code, api) { |
|||
var url, esb, i, pages = '', charnum = 0, title, |
var url, esb, i, pages = '', charnum = 0, title, length, comment, 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" |
// TODO: Criar um objeto { 'esb': ..., 'afl':... } com um item para cada "fabi" |
||
switch ( |
switch ( code ) { |
||
case 'esb': |
case 'esb': |
||
esb = document.getElementById("esbinput"); |
esb = document.getElementById("esbinput"); |
||
if ( |
if (esbText == esb.value || esbText2 == esb.value) { |
||
return; |
return; |
||
} |
} |
||
esbText = esb.value; |
|||
if ( |
if (esbText == esb.value.substr(0, (esb.value.length - 1))) { |
||
return; |
return; |
||
} |
} |
||
Linha 489: | Linha 491: | ||
break; |
break; |
||
} |
} |
||
this.ajax(code, url); |
|||
} else { |
} else { |
||
/** Processamento da resposta do API **/ |
/** Processamento da resposta do API **/ |
||
switch ( |
switch ( code ) { |
||
case 'afl': |
case 'afl': |
||
// Afluentes |
// Afluentes |
||
Linha 500: | Linha 502: | ||
"ref" : |
"ref" : |
||
"<span style=\"color:red\">ref</span>"; |
"<span style=\"color:red\">ref</span>"; |
||
var |
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 ( |
if (catLine && catLine.innerHTML.indexOf("><a href=\"" + mw.config.get('wgArticlePath').replace('$1', '')) > -1) { |
||
info += " · cat"; |
info += " · cat"; |
||
} else { |
} else { |
||
Linha 523: | Linha 525: | ||
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') ); |
||
this.submenu.innerHTML = info; |
|||
if (document.getElementById("ca-talk").className != "new") { |
if (document.getElementById("ca-talk").className != "new") { |
||
this.ajax("qualidade", url); |
|||
} else { |
} else { |
||
var |
var hiddenCats = document.getElementById("mw-hidden-catlinks"); |
||
if ( |
if (hiddenCats) { |
||
hiddenCats = hiddenCats.innerHTML; |
|||
if ( |
if (hiddenCats.indexOf("!Artigos de qualidade") > -1) { |
||
hiddenCats = hiddenCats.substr(hiddenCats.indexOf("!Artigos de qualidade") + 22, 1); |
|||
if ( |
if (hiddenCats == "d") { |
||
hiddenCats = "?"; |
|||
} |
} |
||
this.submenu.innerHTML += "<span title='Qualidade do artigo'> Q-<b>" + |
|||
hiddenCats + "</b></span>"; |
|||
} |
} |
||
} |
} |
||
Linha 545: | Linha 547: | ||
api = api.getElementsByTagName("cl"); |
api = api.getElementsByTagName("cl"); |
||
if (api) { |
if (api) { |
||
var |
var quality; |
||
for (i = 0; i < api.length; i++) { |
for (i = 0; i < api.length; i++) { |
||
if (!api[i]){ |
if (!api[i]){ |
||
continue; |
continue; |
||
} |
} |
||
quality = api[i].getAttribute("title"); |
|||
if ( |
if (quality.indexOf("!Artigos de qualidade") > -1) { |
||
quality = quality.substr(32, 1); |
|||
if ( |
if (quality == "d") { |
||
quality = "?"; |
|||
} |
} |
||
this.submenu.innerHTML += "<span title='Qualidade do artigo'> Q-<b>" + |
|||
quality + "</b></span>"; |
|||
break; |
break; |
||
} |
} |
||
Linha 582: | Linha 584: | ||
) { |
) { |
||
// Exibe sugestões. Baseado no script do HotCat |
// Exibe sugestões. Baseado no script do HotCat |
||
var |
var start = esb.value.length; |
||
esb.value = api; |
esb.value = api; |
||
esbText2 = api; |
|||
if (esb.setSelectionRange) { |
if (esb.setSelectionRange) { |
||
esb.setSelectionRange( |
esb.setSelectionRange(start, api.length); |
||
} else if (esb.createTextRange) { |
} else if (esb.createTextRange) { |
||
var sel = esb.createTextRange(); |
var sel = esb.createTextRange(); |
||
sel.move("character", |
sel.move("character", start); |
||
sel.moveEnd("character", api.length - |
sel.moveEnd("character", api.length - start); |
||
sel.select(); |
sel.select(); |
||
} else { |
} else { |
||
esb.selectionStart = |
esb.selectionStart = start; |
||
esb.selectionEnd = api.length; |
esb.selectionEnd = api.length; |
||
} |
} |
||
Linha 610: | Linha 612: | ||
break; |
break; |
||
} |
} |
||
length = (api[i].getAttribute("newlen") |
|||
- api[i].getAttribute("oldlen")); |
- api[i].getAttribute("oldlen")); |
||
if ( |
if (length > 0) { |
||
length = "+" + length; |
|||
} |
} |
||
comment = api[i].getAttribute("comment").replace("/*", "?"); |
|||
if ( |
if (comment) { |
||
comment = "(" + comment.replace("*/", ":") + ")"; |
|||
} |
} |
||
comment = comment.replace("[[Ajuda:Guia de edição/Menus e" + |
|||
" ferramentas/Sumário de edição|?]]", ""); |
" ferramentas/Sumário de edição|?]]", ""); |
||
if ( i > 0){ |
if ( i > 0){ |
||
Linha 625: | Linha 627: | ||
} |
} |
||
pages += "<a href=\"" + mw.util.wikiGetlink( title ) + |
pages += "<a href=\"" + mw.util.wikiGetlink( title ) + |
||
"?diff=last\" title=\"(" + |
"?diff=last\" title=\"(" + length + ") " + |
||
api[i].getAttribute("user") + " " + |
api[i].getAttribute("user") + " " + comment + "\">" + |
||
title + "</a>"; |
title + "</a>"; |
||
} |
} |
||
this.submenu.innerHTML = pages; |
|||
break; |
break; |
||
case 'PN': |
case 'PN': |
||
Linha 643: | Linha 645: | ||
break; |
break; |
||
} |
} |
||
length = "+" + api[i].getAttribute("newlen"); |
|||
comment = api[i].getAttribute("comment"); |
|||
if ( |
if (comment) { |
||
comment = "(" + comment.replace("[[Ajuda:SEA|?]] ", "") + ")"; |
|||
} |
} |
||
if ( i > 0){ |
if ( i > 0){ |
||
Linha 653: | Linha 655: | ||
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=\"(" + |
+ "\" title=\"(" + length + ") " + |
||
api[i].getAttribute("user") + " " + |
api[i].getAttribute("user") + " " + comment |
||
+ "\">" + title + "</a>"; |
+ "\">" + title + "</a>"; |
||
} |
} |
||
this.submenu.innerHTML = pages; |
|||
break; |
break; |
||
case 'MR': |
case 'MR': |
||
Linha 671: | Linha 673: | ||
break; |
break; |
||
} |
} |
||
length = (api[i].getAttribute("newlen") |
|||
- api[i].getAttribute("oldlen")); |
- api[i].getAttribute("oldlen")); |
||
if ( |
if (length > 0) { |
||
length = "+" + length; |
|||
} |
} |
||
comment = api[i].getAttribute("comment").replace("/*", "?"); |
|||
if ( |
if (comment) { |
||
comment = "(" + comment.replace("*/", ":") + ")"; |
|||
} |
} |
||
if ( i > 0){ |
if ( i > 0){ |
||
Linha 684: | Linha 686: | ||
} |
} |
||
pages += "<a href=\"" + mw.util.wikiGetlink( title ) |
pages += "<a href=\"" + mw.util.wikiGetlink( title ) |
||
+ "?diff=last\" title=\"(" + |
+ "?diff=last\" title=\"(" + length + ") " |
||
+ api[i].getAttribute("user") + " " |
+ api[i].getAttribute("user") + " " |
||
+ |
+ comment + "\">" + title + "</a>"; |
||
} |
} |
||
this.submenu.innerHTML = pages; |
|||
break; |
break; |
||
case 'usu': |
case 'usu': |
||
Linha 694: | Linha 696: | ||
api = api.getElementsByTagName("u"); |
api = api.getElementsByTagName("u"); |
||
if ( api && api.length ) { |
if ( api && api.length ) { |
||
var |
var regDate = api[0].getAttribute("registration"); |
||
regDate = regDate.substr(8, 2) + "/" + regDate.substr(5, 2) + |
|||
"/" + |
"/" + regDate.substr(0, 4); |
||
user = mw.config.get('wgTitle'); |
user = mw.config.get('wgTitle'); |
||
if (user.indexOf("/") > -1) { |
if (user.indexOf("/") > -1) { |
||
Linha 702: | Linha 704: | ||
} |
} |
||
var encUser = encodeURI(user); |
var encUser = encodeURI(user); |
||
this.submenu.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\">" + |
||
regDate + "</span> | <a href=\"" + |
|||
mw.util.wikiGetlink( 'Especial:Contribuições/' ) + |
mw.util.wikiGetlink( 'Especial:Contribuições/' ) + |
||
encUser + |
encUser + |
||
Linha 728: | Linha 730: | ||
}; |
}; |
||
/* |
/* Initialize the gadget */ |
||
fb.init = function () { |
|||
var inUserNS, contentSub = document.getElementById("contentSub"), |
|||
param = mw.util.getParamValue('fastb'); |
|||
contentSub.appendChild(fb.menu); |
|||
contentSub.appendChild(fb.submenu); |
|||
if ($.inArray(mw.config.get('wgAction'), ["view", "edit"]) !== -1) { |
|||
fb.submenu.innerHTML = ""; /*** Menu Principal ***/ |
|||
if (mw.config.get('wgNamespaceNumber') > -1) { |
|||
inUserNS = $.inArray(mw.config.get('wgNamespaceNumber'), [2, 3]) > -1 |
|||
&& mw.config.get('wgTitle').indexOf(mw.config.get('wgUserName')) === 0; |
&& mw.config.get('wgTitle').indexOf(mw.config.get('wgUserName')) === 0; |
||
if (inUserNS) { |
|||
fb.menu.innerHTML = "[" + |
|||
fb.link("ER|1", "ER1", "Eliminar subpágina do próprio usuário") + |
|||
"]"; |
|||
} else { |
|||
fb.menu.innerHTML = "[<a onMouseOver='this.style.cursor=\"default\"'" + |
|||
" onClick='fb.open(fb.ER)'>ER</a>]"; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
if ($.inArray(mw.config.get('wgNamespaceNumber'), [0, 102]) !== -1) { |
if ($.inArray(mw.config.get('wgNamespaceNumber'), [0, 102]) !== -1) { |
||
fb.menu.innerHTML += " [<a onMouseOver='this.style.cursor=\"default\"'" + |
|||
" onClick='fb.open(fb.ESR)'>ESR</a>] [" + |
|||
fb.link("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.run(\"subst:VDA\",obs)'>VDA</a>] [" + |
|||
fb.link("subst:suspeito", "susp", |
|||
"Suspeito de violação de direitos autorais") + |
|||
"] [" + fb.link("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)?") + |
|||
"] [" + fb.link("redirect", "#R", "Redirecionar", |
|||
"Redirecionar para qual página?") + |
|||
"] [<a onMouseOver='this.style.cursor=\"default\"'" + |
|||
" onClick='fb.open(fb.man)'>manutenção</a>]" + |
|||
" [<a onMouseOver='this.style.cursor=\"default\"'" + |
|||
" onClick='fb.open(fb.esb)'>esboço</a>]" + |
|||
" [<a onMouseOver='this.style.cursor=\"default\"'" + |
|||
" onClick='fb.open(fb.search)'>busca</a>]"; |
|||
if (mw.config.get('wgAction') === "view") { |
|||
fb.api("afl"); |
|||
} |
|||
} |
|||
} else { |
} else { |
||
if ($.inArray(mw.config.get('wgNamespaceNumber'), [2, 10]) !== -1) { |
|||
fb.menu.innerHTML += " [" + fb.link("subst:apagar", "PE", |
|||
"Marcar para eliminação por votação") + "]"; |
"Marcar para eliminação por votação") + "]"; |
||
} |
|||
} |
|||
if (mw.config.get('wgNamespaceNumber') % 2 === 0) { |
|||
fb.menu.innerHTML += " [" + fb.link("redirect", "#R", "Redirecionar", |
|||
"Redirecionar para qual página?") + "]"; |
"Redirecionar para qual página?") + "]"; |
||
} |
|||
} |
|||
if (mw.config.get('wgNamespaceNumber') === 14) { |
|||
fb.menu.innerHTML += " [<a onMouseOver='this.style.cursor=\"default\"'" + |
|||
" onClick=' |
" onClick='fb.open(fb.cat)'>CatScan</a>]"; |
||
} |
|||
} |
|||
} |
} |
||
if (mw.config.get('wgNamespaceNumber') === 3) { |
if (mw.config.get('wgNamespaceNumber') === 3) { |
||
fb.menu.innerHTML += " [<a onMouseOver='this.style.cursor=\"default\"'" + |
|||
" onClick=' |
" onClick='fb.open(fb.warn)'>aviso</a>]"; |
||
} |
|||
} |
|||
if ($.inArray(mw.config.get('wgNamespaceNumber'), [2, 3]) !== -1) { |
|||
fb.menu.innerHTML += " [<a onMouseOver='this.style.cursor=\"default\"'" + |
|||
" onClick=' |
" onClick='fb.api(\"usu\")'>sobre a conta</a>]"; |
||
} |
|||
} |
|||
} |
|||
} |
|||
fb.menu.innerHTML += " [<a onMouseOver='this.style.cursor=\"default\"'" + |
|||
" title=\"Páginas vigiadas\" onClick='fb.api(\"PV\")'>PV</a>]" + |
|||
" [<a onMouseOver='this.style.cursor=\"default\"'" + |
|||
" title=\"Páginas novas não patrulhadas\"" + |
|||
" onClick='fb.api(\"PN\")'>PN</a>]" + |
|||
" [<a onMouseOver='this.style.cursor=\"default\"'" + |
|||
" title=\"Mudanças recentes (IPs, domínio principal)\"" + |
|||
" onClick='fb.api(\"MR\")'>MR</a>]"; |
|||
switch (mw.config.get('wgAction')) { |
switch (mw.config.get('wgAction')) { |
||
case 'edit': |
case 'edit': |
||
fb.salve = (param !== null); |
|||
if ( |
if (fb.salve) { |
||
fb.run(param, mw.util.getParamValue('fbtxt') || ''); |
|||
} |
} |
||
break; |
break; |
||
case 'markpatrolled': |
case 'markpatrolled': |
||
if ( |
if (param !== null) { |
||
location.href = mw.util.wikiGetlink( mw.config.get('wgPageName') ) + |
location.href = mw.util.wikiGetlink( mw.config.get('wgPageName') ) + |
||
'?action=edit&fastb=' + |
'?action=edit&fastb=' + param; |
||
} |
} |
||
break; |
break; |
||
Linha 822: | Linha 823: | ||
// Não faz nada nas demais ações |
// Não faz nada nas demais ações |
||
} |
} |
||
} |
}; |
||
/* Executes the gadget when document is ready */ |
|||
$( fb.init ); |