Участник:Герман Мейстер/common.js
Замечание: Возможно, после публикации вам придётся очистить кэш своего браузера, чтобы увидеть изменения.
- Firefox / Safari: Удерживая клавишу Shift, нажмите на панели инструментов Обновить либо нажмите Ctrl+F5 или Ctrl+R (⌘+R на Mac)
- Google Chrome: Нажмите Ctrl+Shift+R (⌘+Shift+R на Mac)
- Internet Explorer / Edge: Удерживая Ctrl, нажмите Обновить либо нажмите Ctrl+F5
- Opera: Нажмите Ctrl+F5.
//Mass rollback function
//Written by John254 and modified/rewritten by Writ Keeper with modifications by TheDJ; original is at https://en.wikipedia.org/wiki/User:John254/mass_rollback.js
//Adapted from User:Mr.Z-man/rollbackSummary.js
//Instructions: Selecting the "rollback all" tab when viewing a user's contributions history
//will open all rollback links displayed there. (Use with caution)
//https://en.wikipedia.org/wiki/User:Writ_Keeper/Scripts/massRollback.js
function rollbackEverythingWKMR(editSummary)
{
if(editSummary === null)
{
return false;
}
var userName = mw.config.get("wgRelevantUserName");
var titleRegex = /title=([^&]+)/;
mw.loader.using( 'mediawiki.api' ).done( function()
{
var api = new mw.Api();
$("a[href*='action=rollback']").each(function(ind, el)
{
var params = {};
if( editSummary != '' )
{
params.summary = editSummary;
}
api.rollback( decodeURIComponent(titleRegex.exec(el.href)[1]), userName, params).done( function()
{
$(el).after("reverted");
$(el).remove();
} );
} );
} );
return false;
}
$(document).ready(function()
{
if(mw.config.get("wgCanonicalSpecialPageName") == "Contributions" && $("span.mw-rollback-link").length > 0)
{
mw.loader.using("mediawiki.util").done( function ()
{
mw.util.addPortletLink('p-cactions', '#', "rollback all", "ca-rollbackeverything", "rollback all edits displayed here");
$("#ca-rollbackeverything").click( function(event)
{
event.preventDefault();
mw.loader.load( 'mediawiki.api' ); //start loading, while the user is in the prompt
return rollbackEverythingWKMR(prompt("Enter an edit summary, or leave blank to use the default (or hit Cancel to cancel the rollback entirely)"));
});
});
}
});
/**
* Extra buttons in toolbar
* @stats [[File:Krinkle_InsertWikiEditorButton.js]]
*/
$.ajax({
url: 'https://meta.wikimedia.org/w/index.php?title=User:Krinkle/Scripts/InsertWikiEditorButton.js&action=raw&ctype=text/javascript',
dataType: 'script',
cache: true
}).done(function () {
krInsertWikiEditorButton({
id: "mw-customeditbutton-myspecialbutton0",
icon: "//upload.wikimedia.org/wikipedia/commons/thumb/7/76/Edit_add_nobg.svg/20px-Edit_add_nobg.svg.png",
label: 'сущ-ru',
insertBefore: '\{\{подст:У:Cinemantique/сущ|',
insertAfter: '|з=|def=|morf={{морфо-ru|}}|biblio=|cat=|}}',
sampleText: ''
});
krInsertWikiEditorButton({
id: "mw-customeditbutton-myspecialbutton01",
icon: "//upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Add.svg/20px-Add.svg.png",
label: '? ru',
insertBefore: '\{\{подст:У:Cinemantique/RU|',
insertAfter: '|p=|def=|morf={{морфо-ru|}}|biblio=|cat=|}}',
sampleText: ''
});
krInsertWikiEditorButton({
id: "mw-customeditbutton-myspecialbutton02",
icon: "//upload.wikimedia.org/wikipedia/commons/thumb/a/a8/Artsbuilderexecute.svg/20px-Artsbuilderexecute.svg.png",
label: 'ПОМЕТА',
insertBefore: '{{',
insertAfter: '.|ru}}',
sampleText: 'устар'
});
});
// Удобные обсуждения
//importScript('Участник:OlegCinema/common.js');
//
function wikify()
{
wpTextbox1 = document.editform.wpTextbox1;
var txt = wpTextbox1.value;
var words = wgTitle.split(/[ .,;:!?—]+/);
r(/\{\{сущ ru[^|]*(.+)(\|основа=)(\|основа1=)\|основа2=\}\}/gm, '{{сущ-ru||$1}}');
r(/\{\{сущ ru[^|]*\n\|основа=.*\n\|основа1=\n(.*)\n\}\}/gm, '{{сущ-ru||$1}}');
wpTextbox1.value = txt;
function r(regExp, replaceTo) {
txt = txt.replace(regExp, replaceTo);
}
function findall(regExp, func) {
var matches = txt.match(regExp);
if (matches) {
for (var i = 0; i < matches.length; i++) {
func(matches[i]);
}
}
}
}
var customizeToolbar = function() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'groups': {
'user' : {
'tools': {
'format': {
label: 'Format', // or use labelMsg for a localized label, see above
filters: [ 'body.ns-0' ],
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/a/a0/Toolbaricon_bold_F-1.png',
action: {
'type': 'callback',
'execute': wikify // FormatEdit
}
}
}
}
}
} );
};
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar . . . */
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', function () {
$(document).ready( customizeToolbar );
} );
} else {
$(document).ready( addMyButton );
}
} );
}
// Rollback confirmation using Echo thanking mechanism
mw.loader.using(['jquery.confirmable'],function(){
$('.mw-rollback-link > a').confirmable();
});