User:Liangent/Gadgets/Toolkit/summaryabbr.uncompressed.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
require('jquery', function() {
(function($) {
if (!$.isArray(window.summaryAbbreviations)) {
window.summaryAbbreviations = [];
}
$(function() {
$('#wpSummary').change(function(event) { // or blur?
$('#summaryabbr-cancel').remove();
var text = $('#wpSummary').val();
var oldtext = text;
$.each(summaryAbbreviations, function() {
text = text.replace(this[0], this[1]);
});
if (text == oldtext) return; // not replaced
$('#wpSummary').val(text).after(
'<span id="summaryabbr-cancel"> (<a href="#">Undo</a> replacing)</span>'
);
$('#summaryabbr-cancel a').click(function(event) {
event.preventDefault();
$('#summaryabbr-cancel').remove();
// setting text in code doesn't trigger change event
$('#wpSummary').val(oldtext);
});
});
});
})(jQuery);
});