User:Kerri Amber/customRollback.js

/** * Adds a rollback link which allows for the use of a custom rollback summary * @author sactage  * @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.removeLinkClass) $link.parent.removeClass("mw-rollback-link"); });				} else {					window.location = this.href;				}			}); } else { // Add a new link var $newLink = $("rollback (custom summary)"); $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.removeLinkClass) $newLink.parent.removeClass("mw-rollback-link"); });				} else {					window.location = this.href;				}			}); }	}); });