MediaWiki:Gadget-presenceLatinLetter.js
Увага: Після публікування слід очистити кеш браузера, щоб побачити зміни.
- Firefox / Safari: тримайте Shift, коли натискаєте Оновити, або натисніть Ctrl-F5 чи Ctrl-Shift-R (⌘-R на Apple Mac)
- Google Chrome: натисніть Ctrl-Shift-R (⌘-Shift-R на Apple Mac)
- Internet Explorer / Edge: тримайте Ctrl, коли натискаєте Оновити, або натисніть Ctrl-F5
- Opera: натисніть Ctrl-F5
$( document ).ready( function() {
if( ! [0, 4, 102, 250].includes( mw.config.get( 'wgNamespaceNumber' ) ) ||
! [ 'edit', 'submit', 'view' ].includes( mw.config.get( 'wgAction' ) ) ) {
return;
}
mw.loader.using(['mediawiki.util']).done(function () {
jQuery.fn.highlight = function() {
var reg = /[A-Za-zÁáÀàÄäÉéÈèÊêËëÍíÌìÎîÏïÓóÒòÔôÖöÚúÙùÛûÜüҢңҚқӘәҮү]/g;
var rep = '<span class="gadget-latin-letter">$&</span>';
this.each(function() {
$(this).contents().each(function() {
if(this.nodeType === 3 && this.parentElement.localName !== 'style' && reg.test(this.nodeValue)) {
$(this).replaceWith(this.nodeValue.replace(reg, rep));
}
else if(!$(this).hasClass('gadget-latin-letter') && this.type !== 'textarea') {
$(this).highlight();
}
});
});
};
var highlightLatinLetter = function () {
$('body').highlight();
};
highlightLatinLetter();
// Qpreview gadget compatibility
$('body').on('DOMSubtreeModified', '#wikiPreview', function(){
highlightLatinLetter();
});
});
});