User:Bellezzasolo/Scripts/ajaxrollsum.js

/** * Ajax Undo links * * Adds an Ajax undo link next to the normal undo link on page histories * and on diff pages * Based on User:Abelmoschus Esculentus/AjaxRollback.js */ // //Modified from User:BenjaminWillJS/AjaxRollback.js jQuery(document).ready(function ($) {	function CreateUndoLink(parentObj) {		var rollbackLink = $( '' ).text( 'Rollback Summary' ).attr( 'href', '#' ).click(function(e) { e.preventDefault; var $rblink = $(parentObj); var href = parentObj.href; console.log(href); var summary = prompt("Enter optional summary", ""); if (summary === null) {				return; }			var summarystr = ""; if (summary !== "") {				summarystr = "&summary=" + summary; }			this.innerHTML = '';			$.ajax({				url: href + summarystr,				success: function {					$rblink.text(function (i, val) {return val + '[reverted]';});				},				error: function {					$rblink.text(function (i, val) {return val + '[rollback failed]';});				}			}); });		return rollbackLink;	}	function SetAjaxRollback {		$( '.mw-rollback-link > a' ).each( function { $ajaxUndoLink = CreateUndoLink( this ); $( this ).parent.after( ' | ', $ajaxUndoLink ); } );	}	mw.loader.using(['mediawiki.util', 'mediawiki.api', 'mediawiki.Title', 'mediawiki.RegExp'], function { SetAjaxRollback; }); }); //