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

添加1,068字节 、​ 2021年2月22日 (一) 10:56
无编辑摘要
mw.loader.using( ['mediawiki.api', 'oojs-ui-windows', 'ext.gadget.site-lib'] ).then(() => {
mw.messages.set( wgULS({
'gadget-ma-summary': '使用Mainpage小工具快速编辑', 'gadget-ma-niji': '虹学会', 'gadget-ma-preview': '预览',
'gadget-ma-prompt': '请输入新的行号(从1开始计数)顺序,以空格分隔。未包括的行将被删除,不存在的空行将被创建。',
'gadget-ma-error': '输入内容错误!只接受以空格分隔的正整数。'
}, {
'gadget-ma-summary': '使用Mainpage小工具快速編輯', 'gadget-ma-niji': '虹學會', 'gadget-ma-preview': '預覽',
'gadget-ma-prompt': '請輸入新的行號(從1開始計數)順序,以空格分隔。未包括的行將被刪除,不存在的空行將被創建。',
'gadget-ma-error': '輸入內容錯誤!只接受以空格分割的正整數。'
}) );
let items = [], $table;
const $menu = mw.menu([ {text: "µ's", data: {color: '#e4007f', name: 'muse'}},
{text: 'Aqours', data: {color: '#32aaff'}}, {text: 'Saint Snow', data: {color: '#cb3935'}},
isMobile = mw.config.get( 'skin' ) == 'minerva',
width = $('#mw-content-text').width() * (isMobile ? 1 : 0.32) - (isMobile ? 68 : 36),
$newTr .html(= $('<tabletr>', {html: '<tbody>'}) );[
$('<td>', {html: $('<span>', {class: 'mainpage-tag'}).css('background-color', '#e4007f')}),
'<td>'
]}),
api = new mw.Api(),
btns = [ new OO.ui.ButtonWidget({label: '保存', flags: ['primary', 'progressive']}).on('click', () => {
location.reload();
}, reason => { if (reason != 'editConflict') { btns[0].setDisabled( false ); } });
}),
new OO.ui.ButtonWidget({label: '更多'}).on('click', () => {
mw.prompt( mw.msg( 'gadget-ma-prompt' ), 'progressive' ).then(result => {
if (/[^\d\s]/.test( result )) {
mw.notify( mw.msg( 'gadget-ma-error' ), {type: 'error', autoHideSeconds: 'long'} );
return;
}
const order = result.split(' ').filter(i => i).map(i => i - 1),
$tr = $table.find( 'tr' );
items = order.map(i => items[i] || ['muse', '']);
$table.children( 'tbody' ).html( order.map(i => $tr[i] || $newTr.clone()) );
});
}) ];
if (id === 0) {
$table = $('<table>', {html: '<tbody>'});
$('.noarticletext').toggleClass( 'noarticletext mw-parser-output mainpage-flex' ).html( );
.html( $('<table>', {html: '<tbody>'}) );
} else { $table = $('.mw-parser-output table'); }
}
mw.loader.addStyleTag( '.mainpage-flex td:last-child { width: calc(' + width + 'px - 1.2em); }' );
$menu.on('click', 'a', function() {
items[ $menu.closest( 'tr' ).index() ][0] = getName( this );
}).css('z-index', 2);
$('.mw-parser-output table').on('dblclick', 'td:first-child', function() {
$menu.appendTo( this );
$menu.setSelected( findSelected( items[ $(this).parent().index() ][0].toLowerCase() ) ).open();
16,874

个编辑