MediaWiki:Gadget-subpages.js: diferenças entre revisões
Conteúdo apagado Conteúdo adicionado
m →using [[mw:CodeEditor|CodeEditor]]: tradução |
m Migração: $j → $ |
||
Linha 12: | Linha 12: | ||
if (mw.config.get( 'wgAction' ) == 'delete') { |
if (mw.config.get( 'wgAction' ) == 'delete') { |
||
$( function() { |
$( function() { |
||
$ |
$.getJSON( |
||
mw.config.get( 'wgServer' )+mw.config.get( 'wgScriptPath' )+'/api.php?action=query&list=allpages&aplimit=500&apnamespace=' |
mw.config.get( 'wgServer' )+mw.config.get( 'wgScriptPath' )+'/api.php?action=query&list=allpages&aplimit=500&apnamespace=' |
||
+ mw.config.get( 'wgNamespaceNumber' ) + '&apprefix=' + encodeURIComponent(mw.config.get( 'wgTitle' ))+ '/' + '&format=json&callback=?', |
+ mw.config.get( 'wgNamespaceNumber' ) + '&apprefix=' + encodeURIComponent(mw.config.get( 'wgTitle' ))+ '/' + '&format=json&callback=?', |
Edição atual desde as 13h35min de 6 de abril de 2020
/* _____________________________________________________________________________
* | |
* | === AVISO: ARQUIVO DE GADGET GLOBAL === |
* | Alterações a esta página afetarão vários colaboradores |
* | Por favor discuta alterações na página de discussão ou |
* | em [[Wikilivros:Gadgets]] antes de editar. |
* |_____________________________________________________________________________|
*
* Mostra uma lista de subpáginas abaixo do formulário de eliminação
*/
if (mw.config.get( 'wgAction' ) == 'delete') {
$( function() {
$.getJSON(
mw.config.get( 'wgServer' )+mw.config.get( 'wgScriptPath' )+'/api.php?action=query&list=allpages&aplimit=500&apnamespace='
+ mw.config.get( 'wgNamespaceNumber' ) + '&apprefix=' + encodeURIComponent(mw.config.get( 'wgTitle' ))+ '/' + '&format=json&callback=?',
function( data ) { showSubpagesCB(data); }
);
});
}
function showSubpagesCB(obj) {
var pages = obj.query && obj.query.allpages;
if ( !pages || pages.length == 0) {
$('#deleteconfirm, #mw-img-eleteconfirm').append('<h2>Subpáginas</h2><p>Esta página não possui subpáginas.</p>');
return;
}
var subpages = '<ul>';
var cut = mw.config.get( 'wgPageName' ).length+1, parent;
for (var pg in pages) {
if ( !pages.hasOwnProperty(pg) ) {
continue;
}
subpages += '<li>'
+ '<a href="' + mw.config.get( 'wgArticlePath' ).replace('$1', pages[pg].title) + '">' + pages[pg].title.substr(cut) + '</a>'
+ ' (<a href="' + mw.config.get( 'wgScript' ) + '?title=' + encodeURIComponent(pages[pg].title)
.replace( /!/g, '%21' ).replace( /'/g, '%27' ).replace( /\(/g, '%28' )
.replace( /\)/g, '%29' ).replace( /\*/g, '%2A' ).replace( /~/g, '%7E' )
.replace( /%20/g, '_' ).replace( /%3A/g, ':' ).replace( /%2F/g, '/' )
+ '&action=delete">delete</a>)'
+ '</li>';
}
subpages += '</ul>';
$('#deleteconfirm, #mw-img-eleteconfirm').append('<h2>Subpages</h2>'+subpages);
return;
}
// [[Categoria:Gadgets|subpages.js]]
// [[Categoria:Scripts do Wikilivros|subpages.js]]