16,874
个编辑
LLWiki正在建设中,欢迎加入我们!
小 |
标签:移动版网页编辑 移动版编辑 |
||
// 由[[Special:Mypage/common.js]]调用,可以使用ES6语法
"use strict";
const
btns = $('#wpSaveWidget, #wpPreviewWidget, #wpDiffWidget, #wpTemplateSandboxPreview'),▼
action = mw.config.get('wgAction'),▼
contentmodel = mw.config.get( 'wgPageContentModel' ),
skin = mw.config.get('skin')
ns = mw.config.get( 'wgNamespaceNumber' );▼
// 修改WikiEditor的替换文本框
e.stopPropagation();
const text = ele.val(),
ele.val(
}
});
let backup = "";
const textarea = $('#Wikiplus-Quickedit');
dialog = $(`<div class="quickEdit-replace">
<label id="quickEdit-replace-regex"><input type="checkbox">正则</label>
<button id="quickEdit-replace_replaceBtn">替换</button>
<button id="quickEdit-replace_undoBtn" disabled="true">撤销</button>
<button id="quickEdit-replace_hideBtn">关闭</button>
</div>`).appendTo( '.Wikiplus-InterBox' )
.on('click', '#quickEdit-replace_hideBtn', () => { dialog.hide(); })
.on('click', '#quickEdit-replace_undoBtn', () => { textarea.val(backup); })
.on('click', '#quickEdit-replace_replaceBtn', () => {
const text = this.value,
position = this.selectionStart,
left = text.
right = text.
this.value = left + ' ' + right;
this.selectionStart = this.selectionEnd = position + 4;
}
if (['edit', 'submit'].includes( action )) {
// 修改templateSandbox的默认页面
$('body').on('click', '#wpTemplateSandboxPreview', () => {
const namespaces = mw.config.get( 'wgFormattedNamespaces' ),▼
▲ const namespaces = mw.config.get( 'wgFormattedNamespaces' ),
return $(this).val() || (namespaces[ns] + (ns === 0 ? '' : ':') + title);▼
});▼
▲ return $(this).val() || (namespaces[ns] + (ns === 0 ? '' : ':') + title);
});
});
btns.on('click', () => {▼
if (contentmodel == 'javascript') {
// JS统一使用4个空格缩进
editBox.val(function() { return $(this).val().replace(/\t/g, " "); });▼
});
}
}) ();▼
▲ });
▲});
|