LLWiki正在建设中,欢迎加入我们!
“MediaWiki:Gadget-MobileCategories.js”的版本间差异
跳转到导航
跳转到搜索
小 |
标签:移动版网页编辑 移动版编辑 |
||
第1行: | 第1行: | ||
//<nowiki> |
|||
// 由ResourceLoader直接调用,不可使用ES6语法 |
|||
/** |
/** |
||
* @Function: 移动版渲染分类栏 |
|||
* @Dependencies: mediawiki.util, user.options |
|||
* @OriginalVersion: [[wikipedia:mediawiki:gadget-MobileCategories.js]] |
* @OriginalVersion: [[wikipedia:mediawiki:gadget-MobileCategories.js]] |
||
* @EditedBy: [[User:Bhsd]] |
* @EditedBy: [[User:Bhsd]] |
||
*/ |
*/ |
||
"use strict"; |
|||
$(function() { |
$(function() { |
||
if (mw.config.get( ' |
if (mw.config.get( 'wgAction' ) != 'view' || mw.config.get( 'wgArticleId' ) === 0) { return; } |
||
window.MobileCategoriesComplete = true; |
|||
return; |
|||
⚫ | |||
const showhiddencats = mw.user.options.get('showhiddencats') |
const showhiddencats = mw.user.options.get( 'showhiddencats' ), |
||
⚫ | |||
normal = categories.normal, |
|||
⚫ | |||
⚫ | |||
categories = wgCategories.normal, |
|||
if (normal.length === 0 && hidden.length === 0) { return; } |
|||
hiddenCats = wgCategories.hidden, |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
window.MobileCategoriesComplete = true; |
|||
const page = mw.msg( 'pagecategories' ) + cat; |
|||
return; |
|||
⚫ | |||
} |
|||
⚫ | |||
⚫ | |||
⚫ | |||
.wrap( '<li>' ).parent(); |
|||
})}); |
})}); |
||
⚫ | |||
$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' ), |
|||
⚫ | |||
⚫ | |||
} |
} |
||
⚫ | |||
⚫ | |||
var normalCatlinks, hiddenCatlinks; |
|||
mw.msg( 'hidden-categories' ) + mw.msg( 'colon-separator' ), |
|||
⚫ | |||
⚫ | |||
normalCatlinks = $( '<div>' ) |
|||
]}).appendTo( $catlinks ); |
|||
.addClass('mw-normal-catlinks') |
|||
⚫ | |||
.prepend( '<a href="/zh/Special:Categories" title="Special:页面分类">' + mw.message( 'pagecategories' ).escaped() + '</a>' + mw.message( 'colon-separator' ).escaped() ); |
|||
} |
|||
if (showhiddencats && hiddenCats.length) { |
|||
hiddenCatlinks = $( '<div>' ) |
|||
.attr( 'id', 'mw-hidden-catlinks' ) |
|||
⚫ | |||
⚫ | |||
.prepend( wgULS("隐藏分类", "隱藏分類") + mw.message( 'colon-separator' ).escaped() ); |
|||
} |
} |
||
⚫ | |||
var catlinks = $( '<div>' ) |
|||
⚫ | |||
⚫ | |||
//</nowiki> |
|||
.attr( 'id', 'catlinks' ) |
|||
// [[category:手机版小工具]] [[category:分类工具]] [[category:作为模块的小工具]] |
|||
.data( 'mw', 'interface' ); |
|||
// {{DEFAULTSORT:MobileCategories.js}} |
|||
if (normalCatlinks) { catlinks.append(normalCatlinks); } |
|||
if (hiddenCatlinks) { catlinks.append(hiddenCatlinks); } |
|||
$('.printfooter').after(catlinks); |
|||
window.MobileCategoriesComplete = true; |
|||
⚫ | |||
⚫ |
2021年10月11日 (一) 13:59的版本
//<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( 'wgAction' ) != 'view' || mw.config.get( 'wgArticleId' ) === 0) { return; } const showhiddencats = mw.user.options.get( 'showhiddencats' ), categories = mw.config.get( 'wgConvertedCategories' ), normal = categories.normal, hidden = showhiddencats ? categories.hidden : []; if (normal.length === 0 && hidden.length === 0) { return; } 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', 'data-mw': 'interface'}).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 ); } if (hidden.length) { $('<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> // [[category:手机版小工具]] [[category:分类工具]] [[category:作为模块的小工具]] // {{DEFAULTSORT:MobileCategories.js}}