16,874
个编辑
LLWiki正在建设中,欢迎加入我们!
小 |
标签:移动版网页编辑 移动版编辑 |
||
//<nowiki>
// 由ResourceLoader直接调用,不可使用ES6语法
/**
* @Function: 移动版渲染分类栏
* @Dependencies: mediawiki.util, user.options
* @OriginalVersion: [[wikipedia:mediawiki:gadget-MobileCategories.js]]
* @EditedBy: [[User:Bhsd]]
*/
"use strict";
$(function() {
if (mw.config.get( '
}▼
const showhiddencats = mw.user.options.get( 'showhiddencats' )
normal = categories.normal,
▲ var wgCategories = mw.config.get( 'wgConvertedCategories' ),
if (normal.length === 0 && hidden.length === 0) { return; }
▲ allCats = showhiddencats ? categories.concat( hiddenCats ) : categories;
if ( allCats.length === 0 ) {▼
const page = mw.msg( 'pagecategories' ) + cat;
return $('<a>', {href: mw.util.getUrl(
▲ function categoryHtmlGenerator(array) {
▲ return $( '<ul>', {html: array.map(function(cat) {
▲ return $('<a>', {href: mw.util.getUrl( 'Category:'+cat ), title: 'Category:'+cat, text: cat})
})});
▲ },
$catlinks = $('<div>', {class: 'catlinks', id: 'catlinks', 'data-mw': 'interface'}).insertAfter( '.printfooter' );
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' ),
}
mw.msg( 'hidden-categories' ) + mw.msg( 'colon-separator' ),
▲ if (categories.length) {
▲ .append( categoryHtmlGenerator( categories ) )
▲ .addClass(['mw-hidden-catlinks', 'mw-hidden-cats-user-shown'])
▲ .append( categoryHtmlGenerator( hiddenCats ) )
}
mw.hook( 'wikipage.categories' ).fire( $catlinks );▼
▲ .addClass( 'catlinks' )
//</nowiki>
// [[category:手机版小工具]] [[category:分类工具]] [[category:作为模块的小工具]]
// {{DEFAULTSORT:MobileCategories.js}}
▲ mw.hook( 'wikipage.categories' ).fire(catlinks);
▲} );
|