MediaWiki:Gadget-subpages.js
Chú ý: Sau khi lưu trang, có thể bạn sẽ phải xóa bộ nhớ đệm của trình duyệt để xem các thay đổi.
- Firefox / Safari: Nhấn giữ phím Shift trong khi nhấn Tải lại (Reload), hoặc nhấn tổ hợp Ctrl-F5 hay Ctrl-R (⌘R trên Mac)
- Google Chrome: Nhấn tổ hợp Ctrl-Shift-R (⇧⌘R trên Mac)
- Internet Explorer / Edge: Nhấn giữ phím Ctrl trong khi nhấn Làm tươi (Refresh), hoặc nhấn tổ hợp Ctrl-F5
- Opera: Nhấn tổ hợp Ctrl-F5.
// Show list of subpages below deletion form
function showSubpagesCB(obj) {
var pages = obj.query && obj.query.allpages;
if ( !pages || pages.length === 0) {
$('#mw-content-text').find('h2').before('<h2>Các trang con</h2>\n<p>Trang này không có trang con nào.</p>');
return;
}
var cut = mw.config.get('wgPageName').length+1;
var path = mw.config.get('wgArticlePath');
pages = '<ul>\n' + ($.map( pages, function(page, id) {
return '<li><a href="' + path.replace('$1', page.title) + '">' + page.title.substr(cut) + '</a>'
+ ' (<a href="' + mw.util.wikiScript('index') + '?title=' + mw.util.wikiUrlencode(page.title)
+ '&action=delete">xóa</a>)</li>';
})).join('\n') + '\n</ul>';
$('#mw-content-text').find('h2').before('<h2>Các trang con</h2>\n' + pages);
}
mw.hook( 'wikipage.content' ).add(function($content) {
if ( mw.config.get('wgAction') !== 'delete' ) {
return;
}
$.getJSON( mw.util.wikiScript( 'api' ), {
format: 'json',
action: 'query',
list: 'allpages',
aplimit: 500,
apnamespace: mw.config.get('wgNamespaceNumber'),
apprefix: mw.config.get('wgTitle') + '/'
}, showSubpagesCB );
});