MediaWiki:Common.js: различия между версиями
Перейти к навигации
Перейти к поиску
Fritz (обсуждение | вклад) Нет описания правки |
Fritz (обсуждение | вклад) Нет описания правки |
||
| Строка 9: | Строка 9: | ||
mw.loader.using(['mediawiki.util', 'mediawiki.user'], function () { | mw.loader.using(['mediawiki.util', 'mediawiki.user'], function () { | ||
setTimeout(function() { | setTimeout(function() { | ||
var formatGroup = document.querySelector('.wikiEditor-ui-toolbar .group.group-format'); | var formatGroup = document.querySelector('.wikiEditor-ui-toolbar .group.group-format'); | ||
if (!formatGroup) { | if (!formatGroup) { | ||
| Строка 24: | Строка 23: | ||
'</a>'; | '</a>'; | ||
// Добавление обработчика клика | // Добавление обработчика клика для вызова функции decode_links | ||
button.onclick = function() { | button.onclick = function() { | ||
decode_links(); | |||
}; | }; | ||
// Добавление кнопки в группу форматирования | // Добавление кнопки в группу форматирования | ||
formatGroup.appendChild(button); | formatGroup.appendChild(button); | ||
}, 1000); | }, 1000); | ||
}); | }); | ||
/* */ | |||
/*WikiEditor/Викификатор*/ | /* WikiEditor/Викификатор */ | ||
/* */ | |||
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) { | if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) { | ||
mw.loader.load( '//ru.wikipedia.org/w/index.php?title=MediaWiki:Gadget-wikificator.js&action=raw&ctype=text/javascript' ); | mw.loader.load( '//ru.wikipedia.org/w/index.php?title=MediaWiki:Gadget-wikificator.js&action=raw&ctype=text/javascript' ); | ||
Версия от 21:11, 25 января 2024
/* Ссылкоправ */
// Исправляет ссылки типа #.D0.92.D0.BE
function decode_links() {
var editText = document.getElementById('wpTextbox1').value;
alert(editText);
}
// Вешает кнопку на панель инструментов
mw.loader.using(['mediawiki.util', 'mediawiki.user'], function () {
setTimeout(function() {
var formatGroup = document.querySelector('.wikiEditor-ui-toolbar .group.group-format');
if (!formatGroup) {
console.error('Format group not found');
return;
}
// Создание новой кнопки
var button = document.createElement('span');
button.className = 'tool oo-ui-widget oo-ui-widget-enabled oo-ui-buttonElement oo-ui-buttonElement-frameless oo-ui-iconElement oo-ui-buttonWidget';
button.innerHTML = '<a class="oo-ui-buttonElement-button" role="button" title="Ссылкоправ" tabindex="0" rel="nofollow">' +
'<span class="oo-ui-iconElement-icon" style="background-image: url(\'https://ruxpert.ru/images/7/72/Ссылкоправ.jpg\');"></span>' +
'<span class="oo-ui-labelElement-label"></span>' +
'</a>';
// Добавление обработчика клика для вызова функции decode_links
button.onclick = function() {
decode_links();
};
// Добавление кнопки в группу форматирования
formatGroup.appendChild(button);
}, 1000);
});
/* */
/* WikiEditor/Викификатор */
/* */
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
mw.loader.load( '//ru.wikipedia.org/w/index.php?title=MediaWiki:Gadget-wikificator.js&action=raw&ctype=text/javascript' );
}
var customizeToolbar = function() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'advanced',
'group': 'format',
'tools': {
'wikify': {
label: 'Викификатор',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/0/06/Wikify-toolbutton.png',
action: {
type: 'callback',
execute: function(context){
Wikify();
}
}
}
}
} );
};
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
mw.loader.using( 'user.options', function () {
if ( mw.user.options.get('usebetatoolbar') ) {
mw.loader.using( 'ext.wikiEditor.toolbar', function () {
$(document).ready( customizeToolbar );
} );
}
} );
};
/*************************/
/* Реклама Яндекс Директ */
/*************************/
/* Реклама Яндекса не должна показываться на страницах редактирования статей, обсуждения статей и участников, страницах участников, служебных страницах, страницах с историей правок. */
var path = decodeURIComponent(window.location.pathname);
if(path.indexOf("Участник:") === -1 && path.indexOf("Обсуждение") === -1 &&
path.indexOf("index.php") === -1 && path.indexOf("Служебная:") === -1 &&
path.indexOf("help.php") === -1 && path.indexOf("MediaWiki:") === -1) {
/* Блок 1 */
(function() {
$('#top').after('<div id="yandex_rtb_R-A-446933-1"></div>');
})();
(function(w, d, n, s, t) {
w[n] = w[n] || [];
w[n].push(function() {
Ya.Context.AdvManager.render({
blockId: "R-A-446933-1",
renderTo: "yandex_rtb_R-A-446933-1",
async: true
});
});
t = d.getElementsByTagName("script")[0];
s = d.createElement("script");
s.type = "text/javascript";
s.src = "//an.yandex.ru/system/context.js";
s.async = true;
t.parentNode.insertBefore(s, t);
})(this, this.document, "yandexContextAsyncCallbacks");
/* Блок 2 */
(function() {
$('#mw-content-text').after('<div id="yandex_rtb_R-A-446933-2"></div>');
})();
(function(w, d, n, s, t) {
w[n] = w[n] || [];
w[n].push(function() {
Ya.Context.AdvManager.render({
blockId: "R-A-446933-2",
renderTo: "yandex_rtb_R-A-446933-2",
async: true
});
});
t = d.getElementsByTagName("script")[0];
s = d.createElement("script");
s.type = "text/javascript";
s.src = "//an.yandex.ru/system/context.js";
s.async = true;
t.parentNode.insertBefore(s, t);
})(this, this.document, "yandexContextAsyncCallbacks");
}