Участник:Madness/BattleBike NoobEdition
//<source lang="javascript">
var cpsLoaderHtml = '
';
var cpsBarHtml = '\
\
<button id="cpsUp" onclick="cpsUp()" title="Переход к следующией ссылке на дифф.">▲ След. дифф</button>\
<button id="cpsDown" onclick="cpsDown()" title="Переход к предыдущей ссылке на дифф.">▼ Пред. дифф</button>\
\
<button id="cpsLeft" onclick="cpsLeft()" title="Переход к предыдущей правке в этой статье.">◄</button>\
<button id="cpsRight" onclick="cpsRight()" title="Переход к следующей правке в этой статье.">►</button>\
<button id="cpsKick" onclick="cpsKick()" title="Повторная загрузка этого диффа.">Обновить</button>\
\
<button id="cpsUndo" onclick="cpsUndo()" title="Будут откачены все изменения, внесённые после этой правки (кнопка желтого цвета)! Дождитесь зелёного цвета для завершения!">Откатить</button>\
<button id="cpsReport" onclick="cpsReport()" title="Занесение ссылки на эту правку в публичную баню. В качестве описания к жалобе будет указан текст из поля ниже. Дождитесь зелёного цвета для завершения!">Занести дифф в баню</button>\
<button id="cpsBlock" onclick="cpsBlock()" class="cpsSysop" title="Ссылка на эту правку будет указана в причине блокировки. Дождитесь зелёного цвета для завершения!">Покарать</button>\
<input id="wpSummary" type="text" style="width:90%">\ <button id="cpsClear" onclick="cpsClear()" title="Очистить поле для комментария.">Очистить</button>\
\<select id="wpBlockReasonList" class="cpsSysop"></select>\ <select id="wpBlockExpiry" class="cpsSysop"></select>\
\
\
';
var cpsEmbedHtml = '\
';
var cpsFrameHtml = '\
';
var cpsHeaderHtml = '\
<a id="cpsTitle"></a> (<a id="cpsDiffLink" title="Дифф">Дифф</a> | <a id="cpsHistory" title="История">История</a> | <a id="cpsEdit" title="Править">Править</a>)
\
: <a id="cpsUser" title="Страница участника"></a> (<a id="cpsTalk" title="Обсуждение участника">Обсуждение</a> | <a id="cpsContribution" title="Вклад участника">Вклад</a>)
\
';
var cpsWorkspace = /diff=\w+|=edit|=submit|=history|:ban|:contributions|:recentchanges|:watchlist|:checkuser/i; var cpsSummary = ; var cpsLinks = []; var cpsSysop = false; var cpsToken = undefined; var cpsHref = undefined; var cpsTitle; var cpsRevid; var cpsPrev; var cpsNext; var cpsUser; var cpsComment; var cpsTime; var cpsBlocked = true; var cpsLink; var vertoffset = 0;
function showmessage(html) {
var r = (Math.floor(Math.random() * 256)), g = (Math.floor(Math.random() * 256)),
b = (Math.floor(Math.random() * 256)), yiq = ((r*299)+(g*587)+(b*114))/1000,
bgcolor = 'rgb(' + r + ',' + g + ',' + b + ')',
color = ( (yiq >= 128) ? 'black' : 'white' );
var div = $('
')
.css({
position: 'fixed', top: vertoffset, right: 0, opacity: '0.9',
'background-color': bgcolor, color: color,
padding: '9px 16px', 'z-index': 9999
})
.html(html);
div.append(' [', $('<a href="#">X</a>').click(function() {$(this).parent().fadeOut('fast').remove();return false;}) ,']')
$('a', div).each(function() {$(this).css({color: 'red', 'background-color': '#676E50'})});
div.appendTo('body');
vertoffset = (vertoffset+div.height()+10);
return div; }
function cpsDisable(selector) { $(selector).attr('disabled', 'disabled'); } function cpsEnable(selector) { $(selector).removeAttr('disabled'); } function cpsSuccess(id) { return function (xml) { if ($('error', $(xml).text())[0]) $(id).css('background-color', 'red'); else $(id).css('background-color', 'lime'); } }
function cpsParseHref(href, name) {
if (href) {
var value = href.match(RegExp(name + '=([^&]+)'));
if (value) return value[1];
}
return undefined;
}
function cpsHideAll() { $('.cpsSummaryItem').toggle(); $('#cpsEmbed, .cpsOldLink, .cpsLink').toggle(); } function cpsHide() { $('#column-one, .portlet').show(); $('#cps').fadeOut(); } function cpsKick() { cpsQueryDiff(cpsHref); } function cpsClear() { $('#wpSummary').attr('value', ); $('.cpsSummaryItem').attr('class', 'cpsSummaryItem'); } function cpsUp() { cpsLinks[cpsLink - 1].click(); } function cpsDown() { cpsLinks[cpsLink + 1].click(); } function cpsLeft() { cpsQueryDiff(cpsPrev); } function cpsRight() { cpsQueryDiff(cpsNext); } function cpsUndo() {
cpsDisable('#cpsUndo');
$.get('/api.php', { titles: cpsTitle, action: 'query', prop: 'info', format: 'xmlfm' }, function (xml) {
$.post('/api.php', { action: 'edit', title: cpsTitle, token: cpsToken, summary: 'Отмена правки ' + cpsRevid + ': ' + $('#wpSummary').attr('value'), undo: cpsParseHref(cpsPrev, 'oldid'), undoafter: $('page', $(xml).text()).attr('lastrevid'), minor: '1' }, cpsSuccess('#cpsUndo'));
});
} function cpsReport() {
cpsDisable('#cpsReport');
$.post('/api.php', { action: 'edit', title: 'Lurkmore:Ban/public', token: cpsToken, summary: 'Auto', appendtext: '\n*+ cpsRevid + ' ' + cpsTitle + ' -- ' + $('#wpSummary').attr('value'), minor: '1' }, cpsSuccess('#cpsReport'));
} function cpsBlock() {
cpsDisable('#cpsBlock');
$.post('/api.php', { action: 'block', user: cpsUser, token: cpsToken, expiry: $('#wpBlockExpiry option:selected').attr('value'), reason: $('#wpBlockReasonList option:selected').attr('value') + ': конкретно: вот эта правка', nocreate: '1', autoblock: '1' }, cpsSuccess('#cpsBlock'));
}
function cpsQueryDiff(href) {
if (href) {
cpsHref = href;
$('.cpsLoader').html(cpsLoaderHtml);
$('#column-one, .portlet').hide();
$('#cps').fadeIn();
cpsDisable('#cps *:not(#cpsKick)');
$.get(href + '&action=render&diffonly=1', function (xml) {
$('#cpsHeader').html(cpsHeaderHtml);
$('#cpsDiff').html($('.diff, .firstrevisionheader', $('
')));
cpsParseDiff();
});
}
}
function cpsParseDiff() {
cpsTitle = decodeURIComponent(cpsParseHref($('#differences-nextlink, #differences-prevlink').attr('href'), 'title'));
cpsRevid = cpsParseHref($('#mw-diff-ntitle1 a:first, #differences-nextlink').attr('href'), 'oldid');
cpsPrev = $('#differences-prevlink').attr('href');
cpsNext = $('#differences-nextlink').attr('href');
cpsUser = $('.diff-ntitle .mw-userlink').text();
cpsComment = $('.diff-ntitle .comment').html();
cpsTime = $('#mw-diff-ntitle1 a:first')[0] ? $('#mw-diff-ntitle1 a:first').text().match(/(\d.+)/)[1] : '????';
$('#cpsDiff .diff tr:first, #cpsDiff .firstrevisionheader').remove();
if (cpsSysop) $.get('/Special:Block/' + cpsUser, function (xml) {
if ($('#mw-bi-reason', xml).attr('value').length == 0) cpsEnable('#cpsBlock');
$('#wpBlockReasonList').replaceWith($('#wpBlockReasonList', xml));
$('#wpBlockExpiry').replaceWith($('#wpBlockExpiry', xml));
$('#cpsList').html($('#bodyContent ul', xml));
$('#cpsList .mw-logevent-actionlink, #cpsList .mw-usertoollinks').remove();
});
cpsDisplay();
}
function cpsDisplay() {
cpsEnable('#cps *:not(#cpsBlock)');
if (cpsLinks[cpsLink]) cpsLinks[cpsLink].parent().addClass('cpsUsedLink');
$('#cps button').css('background-color', );
cpsClear();
if (!cpsPrev) cpsDisable('#cpsLeft, #cpsUndo');
if (!cpsNext) cpsDisable('#cpsRight'); else $('#cpsUndo').css('background-color', 'yellow');
if (!cpsLinks[cpsLink - 1]) cpsDisable('#cpsUp');
if (!cpsLinks[cpsLink + 1]) cpsDisable('#cpsDown');
$('#cpsTime').text(cpsTime);
$('#cpsTitle').text(cpsTitle).attr('href', '/' + encodeURI(cpsTitle));
$('#cpsDiffLink').attr('href', '/index.php?diff=' + cpsRevid);
$('#cpsHistory').attr('href', '/index.php?action=history&title=' + cpsTitle);
$('#cpsEdit').attr('href', '/index.php?action=edit&title=' + cpsTitle);
if (cpsUser) {
$('#cpsUser').text(cpsUser).attr('href', encodeURI('/User:' + cpsUser));
$('#cpsTalk').attr('href', encodeURI('/User_talk:' + cpsUser));
$('#cpsContribution').attr('href', '/Special:Contributions/' + cpsUser);
}
else $('#cpsUser').text('Анонимус');
$('#cpsComment').html(cpsComment);
$('#cpsContent').css('height', ($('#cpsBar').innerHeight() - $('#cpsHeader').outerHeight() - $('#cpsControl').outerHeight() - 25) + 'px');
}
function cpsStartup() {
var diff = false;
if (wgAction != 'edit' && wgAction != 'submit') {
importStylesheetURI('/skins/common/diff.css');
importStylesheetURI(encodeURI('/index.php?title=User:Хикки-задрот/cpscss&action=raw&ctype=text/css'));
if (/diff=\w+/.exec(location.href)) {
diff = true;
$(cpsEmbedHtml).insertBefore('.diff');
$('.cpsNoDiff').remove();
}
else {
function onclick(href, i) {
return function () {
cpsLink = i;
cpsQueryDiff(href);
}
}
$('#bodyContent').append(cpsFrameHtml);
$('#bodyContent a[href*="diff="]:not(:contains("текущ."), :contains("проверить"))').each(function (i) {
cpsLinks[i] = $('<a class="cpsLink">' + $(this).text() + '</a>').click(onclick(this.href, i)).appendTo($('').insertAfter(this));
$(this).addClass('cpsOldLink').hide();
});
}
}
cpsDisable('#cps *:not(#cpsKick)');
if (wgAction == 'history') $('#cpsLeft, #cpsRight').remove();
if (cpsSysop) $('#cpsReport').remove(); else { $('.cpsSysop').remove(); $('#cpsDiff').css('height', '100%'); };
if (cpsSummary) $('#userSummaryButtonsA').prepend(cpsSummary.replace(/#(.*)@(.*)/g, '<a class="cpsSummaryItem" title="$2">$1</a>'));
$('.cpsSummaryItem').click(function () {
if (!$(this).hasClass('cpsSummaryItemChosen')) {
var text = $('#wpSummary').val();
if(window.insertSummary) {
insertSummary(this.title);
} else {
$('#wpSummary').attr('value', text + (text.length?', ':) + this.title);
}
$(this).addClass('cpsSummaryItemChosen');
}
});
if (diff) cpsParseDiff();
} if (cpsWorkspace.exec(decodeURIComponent(location.href))) {
cpsSysop = (/sysop|moderator/).exec(wgUserGroups);
$.get('/api.php', { titles: 'User:' + wgUserName + '/cps', action: 'query', prop: 'info|revisions', intoken: 'edit', rvprop: 'content', rvexpandtemplates: '1', rvlimit: '1', format: 'xmlfm' }, function (xml) {
cpsToken = $('page', $(xml).text()).attr('edittoken');
cpsSummary = $('rev', $(xml).text()).html();
$('#p-tb ul').append('
'); cpsStartup(); }); } if(($.inArray('moderator', wgUserGroups) != -1) && (wgNamespaceNumber == 2 || wgNamespaceNumber == 104) && _is_localst_avail && localStorage.getItem('portaltomain') !== 'false') {importScript('Участник:T kns/portaltomain.js')} if(($.inArray('reviewer', wgUserGroups) != -1) && wgNamespaceNumber==-1 && (wgCanonicalSpecialPageName=="Contributions" | wgCanonicalSpecialPageName=="Unusedimages")) {$('#p-tb .pBody ul').append($('
').one('click', function() {importScript('Участник:T kns/revertall.js');$(this).remove();return false;}));} if(($.inArray('reviewer', wgUserGroups) != -1) && wgVersion=="1.16.5" && wgAction=="history" && window.wgStableRevisionId) {$('#p-tb .pBody ul').append($('
').one('click', function() {importScript('Участник:T kns/cleandosmot.js');$(this).remove();return false;}))} //</source>