LLWiki正在建设中,欢迎加入我们

“MediaWiki:Gadget-MobileCategories.js”的版本间差异

跳转到导航 跳转到搜索
撤销Func讨论)的版本57255
标签移动版网页编辑 移动版编辑
(撤销Func讨论)的版本57255)
标签撤销
 
(未显示2个用户的6个中间版本)
 
const showhiddencats = mw.user.options.get( 'showhiddencats' ),
categoriespageName = mw.config.get( 'wgConvertedCategorieswgPageName' ),
pageViewLang = mw.config.get( 'wgPageContentLanguage' ); // This variable was misnamed
normal = categories.normal,
if ( pageViewLang == 'en' ) { return; }
hidden = showhiddencats ? categories.hidden : [];
 
if (normal.length === 0 && hidden.length === 0) { return; }
function trimNamespace( title ) {
return title.slice( title.indexOf( ':' ) + 1 );
const categoryHtmlGenerator = function(array) {
return $('<ul>', {html: array.map(function(cat) {
const page = mw.msg( 'pagecategories' ) + cat;
return $('<a>', {href: mw.util.getUrl( page ), title: page, text: cat}).wrap( '<li>' ).parent();
})});
},
$catlinks = $('<div>', {class: 'catlinks', id: 'catlinks'}).insertAfter( '.printfooter' );
if (normal.length) {
const specialCategories = 'Special:' + mw.msg( 'categories' );
$('<div>', {id: 'mw-normal-catlinks', class: 'mw-normal-catlinks', html: [
$('<a>', {href: '/zh/Special:Categories', title: specialCategories, text: mw.msg( 'pagecategories' )}),
mw.msg( 'colon-separator' ),
categoryHtmlGenerator( normal )
]}).appendTo( $catlinks );
}
ifnew (hiddenmw.lengthApi().get( {
"action": "query",
$('<div>', {id: 'mw-hidden-catlinks', class: 'mw-hidden-catlinks mw-hidden-cats-user-shown', html: [
"format": "json",
mw.msg( 'hidden-categories' ) + mw.msg( 'colon-separator' ),
"formatversion": "2",
categoryHtmlGenerator( hidden )
"generator": "categories",
]}).appendTo( $catlinks );
"gcllimit": "max",
}
"prop": "info|categoryinfo",
mw.hook( 'wikipage.categories' ).fire( $catlinks );
"inprop": "varianttitles",
"titles": pageName,
} ).then( function ( res ) {
const categories = { 'normal': [], 'hidden': [] }, convertedCats = {};
if ( !res.query ) { return; }
res.query.pages.forEach( function ( ele ) {
const type = ele.categoryinfo.hidden ? 'hidden' : 'normal',
title = trimNamespace( ele.title );
categories[ type ].push( title );
convertedCats[ title ] = trimNamespace( ele.varianttitles[ pageViewLang ] );
});
mw.config.set( 'wgCategories', [].concat( categories.normal, categories.hidden ) );
if (!categories.normal.length === 0 && !categories.hidden.length === 0) { return; }
 
const categoryHtmlGenerator = function(arraytype) {
const cats = categories[ type ];
return $('<ul>', {html: arraycats.map(function(cat) {
const page = mw.msg( 'pagecategoriesCategory:' ) + cat;
return $('<a>', {href: mw.util.getUrl( page ), title: page, text: convertedCats[cat]}).wrap( '<li>' ).parent();
})});
},
$catlinks = $('<div>', {class: 'catlinks', id: 'catlinks'}).insertAfter( '.printfooter' );
normal =if (categories.normal,.length) {
$('<div>', {id: 'mw-normal-catlinks', class: 'mw-normal-catlinks', html: [
$('<a>', {href: '/zh/Special:Categories页面分类', title: specialCategories'Special:页面分类', text: mw.msg( 'pagecategories' )}),
mw.msg( 'colon-separator' ),
categoryHtmlGenerator( 'normal' )
]}).appendTo( $catlinks );
}
if (categories.hidden.length && showhiddencats) {
$('<div>', {id: 'mw-hidden-catlinks', class: 'mw-hidden-catlinks mw-hidden-cats-user-shown', html: [
mw.msg( 'hidden-categories' ) + mw.msg( 'colon-separator' ),
categoryHtmlGenerator( 'hidden' )
]}).appendTo( $catlinks );
}
mw.hook( 'wikipage.categories' ).fire( $catlinks );
} );
});
//</nowiki>
巡查豁免者、​界面管理员、​小部件编辑者
45

个编辑

导航菜单