Użytkownik:PixelGGamer/monobook.js: Różnice pomiędzy wersjami

Z Nonsensopedii, polskiej encyklopedii humoru
(Expercie - pożyczam JS :v)
Znacznik: edytor źródłowy
 
Znacznik: edytor źródłowy
Linia 1: Linia 1:
importScript( "User:Expert3222/common.js" );
importScript( "User:Expert3222/common.js" );
/**
* Adds a rollback link which allows for the use of a custom rollback summary
* @author sactage <sactage@gmail.com>
* @version 1.3.0
*/
$(function customSummaryRollbackLink() {
window.furry = window.furry || {};
window.furry.rollback = window.furry.rollback || {allowNoSummary: false, addNewLink: false, useAjax: true, removeLinkClass: false};
var rollbackContainer = $("span.mw-rollback-link");
if (!rollbackContainer.length)
return false;
$.each(rollbackContainer, function (index, element) { // Iterate over each rollback container
var $link = $($(element).children("a")[0]);
if (!window.furry.rollback.addNewLink) { // Don't add a new link
$link.attr("id", "rollback-custom-summary").click(function(event) {
event.preventDefault();
var summary = prompt("Enter a custom rollback summary");
if (summary == null || (!summary && !window.furry.rollback.allowNoSummary))
return false;
$(this).attr('href', $(this).attr('href') + (summary ? '&summary=' + encodeURIComponent(summary) : ""));
if (window.furry.rollback.useAjax) {
$.ajax({type: "GET", url: this.href }).done(function() {
$link.css({color: "grey"}).text("gone!").removeAttr("href");
if (window.furry.rollback.removeLinkClass)
$link.addClass("rollback-gone").parent().removeClass("mw-rollback-link");
});
} else {
window.location = this.href;
}
});
} else { // Add a new link
var $newLink = $("<a id=\"rollback-custom-summary\">rollback (custom summary)</a>");
$newLink.attr('href', $link.attr('href')).insertAfter($link).before(" | ").click(function(event) {
event.preventDefault();
var summary = prompt("Enter a custom rollback summary");
if (summary == null || (!summary && !window.furry.rollback.allowNoSummary))
return false;
$(this).attr('href', $(this).attr('href') + (summary ? '&summary=' + encodeURIComponent(summary) : ""));
if (window.furry.rollback.useAjax) {
$.ajax({type: "GET", url: this.href }).done(function() {
$newLink.css({color: "grey"}).text("gone!").removeAttr("href");
if (window.furry.rollback.removeLinkClass)
$newLink.addClass("rollback-gone").parent().removeClass("mw-rollback-link");
});
} else {
window.location = this.href;
}
});
}
});
});

Wersja z 11:20, 15 lip 2016

importScript( "User:Expert3222/common.js" );
/**
 * Adds a rollback link which allows for the use of a custom rollback summary
 * @author sactage <sactage@gmail.com>
 * @version 1.3.0
 */
 
$(function customSummaryRollbackLink() {
	window.furry = window.furry || {};
	window.furry.rollback = window.furry.rollback || {allowNoSummary: false, addNewLink: false, useAjax: true, removeLinkClass: false};
	var rollbackContainer = $("span.mw-rollback-link");
	if (!rollbackContainer.length)
		return false;
	$.each(rollbackContainer, function (index, element) { // Iterate over each rollback container
		var $link = $($(element).children("a")[0]);
		if (!window.furry.rollback.addNewLink) { // Don't add a new link
			$link.attr("id", "rollback-custom-summary").click(function(event) {
				event.preventDefault();
				var summary = prompt("Enter a custom rollback summary");
				if (summary == null || (!summary && !window.furry.rollback.allowNoSummary))
					return false;
				$(this).attr('href', $(this).attr('href') + (summary ? '&summary=' + encodeURIComponent(summary) : ""));
				if (window.furry.rollback.useAjax) {
					$.ajax({type: "GET", url: this.href }).done(function() {
						$link.css({color: "grey"}).text("gone!").removeAttr("href");
						if (window.furry.rollback.removeLinkClass)
							$link.addClass("rollback-gone").parent().removeClass("mw-rollback-link");
					});
				} else {
					window.location = this.href;
				}
			});
 
		} else { // Add a new link
			var $newLink = $("<a id=\"rollback-custom-summary\">rollback (custom summary)</a>");
			$newLink.attr('href', $link.attr('href')).insertAfter($link).before(" | ").click(function(event) {
				event.preventDefault();
				var summary = prompt("Enter a custom rollback summary");
				if (summary == null || (!summary && !window.furry.rollback.allowNoSummary))
					return false;
				$(this).attr('href', $(this).attr('href') + (summary ? '&summary=' + encodeURIComponent(summary) : ""));
				if (window.furry.rollback.useAjax) {
					$.ajax({type: "GET", url: this.href }).done(function() {
						$newLink.css({color: "grey"}).text("gone!").removeAttr("href");
						if (window.furry.rollback.removeLinkClass)
							$newLink.addClass("rollback-gone").parent().removeClass("mw-rollback-link");
					});
				} else {
					window.location = this.href;
				}
			});
		}
	});
});