LLWiki正在建设中,欢迎加入我们

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

跳转到导航 跳转到搜索
添加13字节 、​ 2021年1月17日 (日) 04:04
无编辑摘要
*/
"use strict";
/*global mw, $, OO, CodeMirror, wgULS*/
$(() => { // 避免全局变量
let nextid, list = mw.storage.getObject( 'inspect-category' ), flag;
const id = mw.config.get( 'wgArticleId' ),
curRevid = mw.config.get( 'wgCurRevisionId' ),
$original = $content.children('.mw-json, .mw-code, .mw-parser-output'),
$outer = $('<div>', {id: 'inspector', class: 'mw-ajax-loader'}).insertBefore( $original ),
api = new mw.Api(),;
initList = (pages, ctn) => {
console.info({pages: pages, ctn: ctn, id: id});
flag = pages[0] == id || (ctn && pages.includes(id));
list = [pages, flag ? pages.indexOf(id) + 1 : 0];
if (ctn && !flag) { mw.notify(wgULS('当前页面并不属于该分类或名字空间!', '當前頁面並不屬於該分類或名字空間!'),
{type: 'warn'}); }
mw.storage.setObject( 'inspect-category', [pages, list[1] - flag] );
btnGo.setHref( `/zh?redirect=no&curid=${pages[ list[1] ]}` ).setDisabled( false );
};
let nextid, list = mw.storage.getObject( 'inspect-category' ), flag;
if (!list) { nextid = id + 1; }
else {
flag = (list[0][ list[1] ] == id);
if (flag) { list[1]++; }
nextid = list[0][ list[1] ];
const btnGo = new OO.ui.ButtonWidget({flags: 'progressive', icon: 'next', href: `/zh?redirect=no&curid=${nextid}`,
disabled: !nextid}),
initList = (pages, ctn) => {
console.info({pages: pages, ctn: ctn, id: id});
flag = pages[0] == id || (ctn && pages.includes(id)); // &&的优先级高于||
list = [pages, flag ? pages.indexOf(id) + 1 : 0];
if (ctn && !flag) { mw.notify(wgULS('当前页面并不属于该分类或名字空间!', '當前頁面並不屬於該分類或名字空間!'),
{type: 'warn'}); }
mw.storage.setObject( 'inspect-category', [pages, list[1] - flag] );
btnGo.setHref( `/zh?redirect=no&curid=${pages[ list[1] ]}` ).setDisabled( false );
};,
dialog = new OO.ui.MessageDialog(),
actionC = new OO.ui.ActionWidget({label: '取消'}),
});
// 模板、JavaScript、CSS、Lua、JSON只需要箭头按钮
if ((mw.config.get( 'wgNamespaceNumber' ) == 10 && !page.endsWith( '/doc' )) || isCode) {
$outer.removeClass( 'mw-ajax-loader' ).append( $('<div>', {id: 'inspector-btns', html: btnGo.$element}) );
mw.loader.addStyleTag( '#inspector-btns { width:auto; }' );
// 生成通用的API请求
mw.standardQuery(api);
let text, editor, $wrapper, $replace, $charinsert, prefix, ns, section, secTitle,
lang = mw.config.get( 'wgUserVariant' );
$original.find( ':header:has(.mw-editsection)' ).dblclick(function() {
section = mw.util.getParamValue( 'section', $(this).find( '.mw-editsection > a' ).attr('href') );
#mw-content-text .mw-parser-output { display:flow-root; overflow-x:auto; word-wrap:break-word; }` );
css.disabled = true;
let text, editor, $wrapper, $replace, $charinsert, prefix, ns, section, secTitle,
lang = mw.config.get( 'wgUserVariant' );
// 也可以使用user.options,这里使用其他方法绕过
const isGadget = (name) => ['loaded', 'loading', 'ready'].includes( mw.loader.getState(`ext.gadget.${name}`) ),
if (![9, 27].includes( e.keyCode )) { return; } // tab和esc
let $cursor, before, sections, title;
const cursor = editor.getCursor(),
line = editor.getLine( cursor.line ),
after = line.slice( cursor.ch );
before = line.slice(0, cursor.ch);
const cursorActivity = () => {
const newCursor = editor.getCursor(),
}
editor.execCommand( 'delCharBefore' ); // 删掉新增的\t
const cursor = editor.getCursor(),
line = editor.getLine( cursor.line ),
after = line.slice( cursor.ch );
before = line.slice(0, cursor.ch);
$.each(regexps, (k, v) => { if (v.test(before)) { ns = k; } });
if (!ns) { return; }
16,874

个编辑

导航菜单