Year of the Dragon: Through May 28th, claim free Expansion Pack (excluding Vecna Unleashed) or a Greater Elixir of Discovery! Speak to Xatheral in the Hall of Heroes.
(Please note: Due to bugs with the distribution system, this reward is temporarily unavailable.)edit

Game mechanicsNewbie guideIn developmentDDO StoreSocial Media


ChallengesClassesCollectablesCraftingEnhancementsEpic DestiniesFavorFeats

GlossaryItemsMapsMonstersPlacesQuestsRacesReincarnationSkillsSpells


Please create an account or log in to build a reputation and unlock more editing privileges, and then visit DDO wiki's IRC Chat/Discord if you need any help!

User:JJMC89/ajaxRollback.js

From DDO wiki
Jump to navigation Jump to search

Note: After saving, you may have to bypass your browser's cache to see the changes, you can click here or try one of the methods below..

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl+F5 or Ctrl+r ( Command+r on a Mac)
  • Google Chrome: Press Ctrl+ Shift+R ( Command+ Shift+R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl+F5
  • Konqueror: Click Reload or press F5
  • Opera: Clear the cache in Tools ‣ Preferences
/**
 * Makes rollback links for edits execute without an additional page load. Adds a link to allow the user change the edit summary.
 * @author JJMC89
 * @documantation https://ddowiki.com/page/User:JJMC89/ajaxRollback
 * @source https://ddowiki.com/page/User:JJMC89/ajaxRollback.js
 */
function ajaxRollback() {
	var	$rollbackLinks = $('.mw-rollback-link a'),
		prevUser,
		rollbackSummaryDefault;
	function useAJAX(e) {
		e.preventDefault();
		var $this = $(this);
		var href = $this.attr( 'href' ) + '&bot=1';
		$this.text('Rolling back...');
		$rollbackLinks = $this.parent();
		$.get(
			href,
			null,
			function( data, status, request ) {
				if ( status == 'success' ) {
					$this.html('<span style="color:green">Rolled back</span>');
				} else {
					$this.html('<span style="color:red">Rollback failed</span>');
				}
			}
		);
	}
	if ( $rollbackLinks.length > 0 ) {
		rollbackSummaryDefault = 'Reverted edits by [[Special:Contributions/$2|$2]] ([[User talk:$2|talk]]) to last version by [[User:$1|$1]]';
		$rollbackLinks.each(function(){
			var $this = $(this);
			$this.after(
				$this.clone()
				.text('rollback: edit summary')
				.attr( 'class', '')
				.click(function confirmRollback( e ) {
					var summary = prompt(
						"Enter an edit summary to use for the rollback:\n(Leave as provided to use the wiki default.)",
						"Reverted edits by [[Special:Contributions/$2|$2]] ([[User talk:$2|talk]]) to last version by [[User:$1|$1]]"
					);
					if (summary == null || summary == "") return false;
					else if (summary == "Reverted edits by [[Special:Contributions/$2|$2]] ([[User talk:$2|talk]]) to last version by [[User:$1|$1]]") return true;
					this.href = this.href.replace("?", "?summary=" + encodeURIComponent(summary) + "&");
					useAJAX.call(this, e);
				} )
			).after( ' | ' )
			.click( useAJAX );
		});
	}
}
$(ajaxRollback);