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

“User:Bhsd/edit.js”的版本间差异

跳转到导航 跳转到搜索
"use strict";
/*global mw, $*/
(function() => {
const action = mw.config.get( 'wgAction' ),
contentmodel = mw.config.get( 'wgPageContentModel' ),
skin = mw.config.get( 'skin' );,
$body = $(document.body);
 
// 引自[[moegirl:User:東東君/js/Wikiplus-replace.js]]
mw.loader.using( 'jquery.ui' ).then(() => { dialog.draggable(); });
}).insertAfter( '#Wikiplus-Quickedit-Jump' );
});
}
/* JavaScript编辑界面按tab键空4格 */
if (contentmodel == 'javascript' && skin == 'vector' && ['view', 'edit', 'submit'].includes(action)) {
mw.loader.using( 'jquery.textSelection' ).then(() => {
$('body').on('keydown', '#wpTextbox1, #Wikiplus-Quickedit', function(e) {
if (e.keyCode == 9) {
e.preventDefault();
$(this).textSelection( 'encapsulateSelection', {peri:' ', replace:true, selectPeri:false} );
}
});
});
}
// 修改WikiEditor的替换文本框
if (skin == 'vector') {
$('body').on('click', 'input#wikieditor-toolbar-replace-replace', function() {
$(this).replaceWith( $('<textarea>', {id: "wikieditor-toolbar-replace-replace", tabindex:10})
.onkeydown('keydown keypress', e => { if (e.keyCodekey == '13Enter') { e.stopPropagation(); } }) );
});
}
 
// 修改templateSandbox的默认页面
$('body').on('click', '#wpTemplateSandboxPreview', () => {
$( 'input[name = wpTemplateSandboxPage]' ).val(function() {
const namespaces = mw.config.get( 'wgFormattedNamespaces' ),
ns = mw.config.get( 'wgNamespaceNumber' );
return $(this).val() || (namespaces[ns] + (ns === 0 ? '' : ':') + mw.config.get( 'wgTitle') );
});
});
 
// JS代码统一使用4个空格Tab缩进
if (contentmodel['javascript', =='css', 'javascriptScribunto'].includes( contentmodel )) {
$('body').on('submit', '#editform', () => {
$( '#wpTextbox1' ).val(function() { return $(this).val().replacereplaceAll(/\t/g' ', "' "'); });
});
}