Użytkownik:Michał56/common.js: Różnice pomiędzy wersjami
Z Nonsensopedii, polskiej encyklopedii humoru
Znacznik: edytor źródłowy |
Znacznik: edytor źródłowy |
||
Linia 8: | Linia 8: | ||
//rollback all |
//rollback all |
||
// Charitwo's rollback, rewritten with jQuery and Ajax |
|||
importScript( "User:Expert3222/RollbackAll.js" ); |
|||
// A function to add a "Rollback all" button to the top of the page, if the page is Special:Contributions and |
|||
// if it shows any contributions that can be rolled back. |
|||
function RollbackAllButton () { |
|||
var Candidates = $("SPAN.mw-rollback-link").length; |
|||
if ((wgCanonicalSpecialPageName == 'Contributions') && (Candidates > 0)) { |
|||
addPortletLink('p-cactions', 'javascript:RollbackAll()', "Roll all " + Candidates, "ca-rollbackall", "Rollback all top edits displayed here"); |
|||
} |
|||
}; |
|||
// A function, called by that "Rollback all" button, to do the rollbacks. |
|||
function RollbackAll() { |
|||
var FailureCount = 0; |
|||
$("SPAN.mw-rollback-link A").each( function() { |
|||
var TheURI = $(this).prop("href") + "&bot=1"; |
|||
var TheSPAN = $(this).parent(); |
|||
// $(TheSPAN).text("Failed").css({"color": "red"}); // Assume failure |
|||
$.ajax({type: "GET", url: TheURI }) |
|||
.done(function(data) { |
|||
if (data.indexOf("<title>Rollback failed") == -1) { |
|||
$(TheSPAN).parent().css({"text-decoration": "line-through"}); |
|||
$(TheSPAN).parent().find(".mw-uctop").remove(); |
|||
$(TheSPAN).remove(); |
|||
} |
|||
else { |
|||
FailureCount++; |
|||
// alert("Debug: Got " + data + "--FailureCount=" + FailureCount); |
|||
}; |
|||
}) |
|||
.fail(function() { FailureCount++ }); |
|||
}); |
|||
if (FailureCount > 0) { |
|||
alert(FailureCount + " edycja(-e) nie może(-ą) być wycofane(-a)"); |
|||
}; |
|||
// End by removing the RollbackAll button. If you want to try again, reload the page. |
|||
$("#ca-rollbackall").remove(); |
|||
}; |
|||
$(document).ready(RollbackAllButton); |
Wersja z 22:51, 6 gru 2015
;(function($, mw){
if (mw.config.get('wgCanonicalSpecialPageName') !== 'Recentchanges') return;
if ($('#recentchanges-options').hasClass('collapsed')) {
$('#recentchanges-options').toggleClass('collapsed');
}
})(this.jQuery, this.mediaWiki);
//rollback all
// Charitwo's rollback, rewritten with jQuery and Ajax
// A function to add a "Rollback all" button to the top of the page, if the page is Special:Contributions and
// if it shows any contributions that can be rolled back.
function RollbackAllButton () {
var Candidates = $("SPAN.mw-rollback-link").length;
if ((wgCanonicalSpecialPageName == 'Contributions') && (Candidates > 0)) {
addPortletLink('p-cactions', 'javascript:RollbackAll()', "Roll all " + Candidates, "ca-rollbackall", "Rollback all top edits displayed here");
}
};
// A function, called by that "Rollback all" button, to do the rollbacks.
function RollbackAll() {
var FailureCount = 0;
$("SPAN.mw-rollback-link A").each( function() {
var TheURI = $(this).prop("href") + "&bot=1";
var TheSPAN = $(this).parent();
// $(TheSPAN).text("Failed").css({"color": "red"}); // Assume failure
$.ajax({type: "GET", url: TheURI })
.done(function(data) {
if (data.indexOf("<title>Rollback failed") == -1) {
$(TheSPAN).parent().css({"text-decoration": "line-through"});
$(TheSPAN).parent().find(".mw-uctop").remove();
$(TheSPAN).remove();
}
else {
FailureCount++;
// alert("Debug: Got " + data + "--FailureCount=" + FailureCount);
};
})
.fail(function() { FailureCount++ });
});
if (FailureCount > 0) {
alert(FailureCount + " edycja(-e) nie może(-ą) być wycofane(-a)");
};
// End by removing the RollbackAll button. If you want to try again, reload the page.
$("#ca-rollbackall").remove();
};
$(document).ready(RollbackAllButton);