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

添加697字节 、​ 2020年12月30日 (三) 06:55
无编辑摘要
inspect = gadgets.inspect || {},
rule = inspect.rule || true;
if (rule && id > 0 && (![10, 274].includes( mw.config.get( 'wgNamespaceNumber' ) ) || page.endsWith( '/doc' )) &&
mw.config.get('wgAction') == 'view' && mw.config.get( 'wgPageContentModel' ) == 'wikitext' &&
!mw.config.get( 'wgIsRedirect' ) && !mw.config.get( 'wgDiffNewIdwgRevisionId' ) == curRevid && !mw.util.getParamValue( 'oldid' )rule) {
const api = new mw.Api(),
getJSON = $.ajax({ dataType: 'json', cache: true,
lineWrapping: true, lineNumbers: true});
wrapper = $( editor.getWrapperElement() ).toggle();
const scroller = $( editor.getScrollerElement() );
$('<div>', {id: 'inspector-btns', html: btns.map(function(ele) { return ele.$element; })}).appendTo( outer );
$('.diff').click(function(e) {
const row = $( e.target ).closest('tr'),
isLineno = row.children( '.diff-lineno' ).length ? 1 : 0,
rowLineno = isLineno ? row : row.prevAll( ':has(.diff-lineno)' ).last(),
n = parseInt( rowLineno.children().last().text().match(/\d+/) ),
line = scroller.find( '.CodeMirror-linenumber' ).filter(function() {
return this.textContent == n + row.index() - rowLineno.index() - 1 + isLineno;
});
if (line.length) { scroller.animate({scrollTop: line.offset().top - scroller.offset().top - 4}); }
});
}, function(reason) { mw.apiFailure(reason, 'CodeMirror' + wgULS('设置或页面', '設置或頁面') + 'Wikitext'); });
}
16,874

个编辑