LLWiki正在建设中,欢迎加入我们!
“User:Bhsd/edit.js”的版本间差异
跳转到导航
跳转到搜索
小 |
小 |
||
第1行: | 第1行: | ||
(function( |
$(function() { |
||
⚫ | |||
$(function() { |
|||
var editBox = $('#wpTextbox1'), |
|||
⚫ | |||
title = mw.config.get('wgPageName'), |
|||
⚫ | |||
title = mw.config.get('wgPageName'), |
|||
⚫ | |||
⚫ | |||
$('body').on('keydown', '#wpTextbox1, #Wikiplus-Quickedit', function(e){ |
|||
⚫ | |||
if(e.keyCode == 9){ |
|||
e.preventDefault(); |
|||
var position = this.selectionStart, |
|||
left = this.value.substring(0, position), |
|||
right = this.value.substring(position), |
|||
code = left + ' ' + right; |
|||
this.value = code; |
|||
this.selectionStart = this.selectionEnd = position + 4; |
|||
⚫ | |||
this.selectionStart = this.selectionEnd = position + 4; |
|||
}); |
|||
} |
|||
⚫ | |||
$( 'input[name=wpTemplateSandboxPage]' ).val(function() { return $(this).val() || mw.config.get('wgPageName') }); |
|||
$('#custom-editTools .mw-collapsible-toggle').click(); |
|||
// 由于以下代码的奇怪性质,本页面不应频繁修改,至少不能使用移动版皮肤修改 |
|||
btns.on('click', function() { |
|||
if(mw.config.get('wgPageContentModel') == 'javascript') { editBox.val(editBox.val().replace(/\t/g, " ")); } |
|||
if(mw.config.get('skin') == 'vector') { return; } |
|||
editBox.val(editBox.val().replace(/(‘|’)/g,"'")); |
|||
editBox.val(editBox.val().replace(/(“|”)/g,'"')); |
|||
}); |
|||
}); |
}); |
||
}); |
|||
})(jQuery, mediaWiki); |
2020年9月27日 (日) 01:34的版本
$(function() { /* JavaScript编辑界面按tab键空4格 */ var editBox = $('#wpTextbox1'), title = mw.config.get('wgPageName'), btns = $('#wpSaveWidget, #wpPreviewWidget, #wpDiffWidget, #wpTemplateSandboxPreview'); if(mw.config.get('wgPageContentModel') == 'javascript') { $('body').on('keydown', '#wpTextbox1, #Wikiplus-Quickedit', function(e){ if(e.keyCode == 9){ e.preventDefault(); var position = this.selectionStart, left = this.value.substring(0, position), right = this.value.substring(position), code = left + ' ' + right; this.value = code; this.selectionStart = this.selectionEnd = position + 4; } }); } $( 'input[name=wpTemplateSandboxPage]' ).val(function() { return $(this).val() || mw.config.get('wgPageName') }); $('#custom-editTools .mw-collapsible-toggle').click(); // 由于以下代码的奇怪性质,本页面不应频繁修改,至少不能使用移动版皮肤修改 btns.on('click', function() { if(mw.config.get('wgPageContentModel') == 'javascript') { editBox.val(editBox.val().replace(/\t/g, " ")); } if(mw.config.get('skin') == 'vector') { return; } editBox.val(editBox.val().replace(/(‘|’)/g,"'")); editBox.val(editBox.val().replace(/(“|”)/g,'"')); }); });