Year of the Dragon: Through April 23rd, claim the adventure pack Slice of Life for free! Speak to Xatheral in the Hall of Heroes.

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/AjaxPatrolLinks.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 patrol links execute without an additional page load.
 * @author Krinkle
 * @documantation https://ddowiki.com/page/User:JJMC89/AjaxPatrolLinks
 * @source https://ddowiki.com/page/User:JJMC89/AjaxPatrolLinks.js
 * Note: MediaWiki 1.21 includes this functionality.
 */
function AjaxPatrolLinks() {
	var $patrollinks = $('.patrollink a');
	if ($patrollinks.length > 0) {
		$patrollinks.click(function (e) {
			e.preventDefault();
			var href = $(this).attr('href');
			$patrollinks.text('Marking as patrolled...');
			$patrollinks = $patrollinks.parent();
			$.get(
				href,
				null,
				function (data, status, request) {
					if (status == 'success') {
						$patrollinks.html('<span style="color: green;">Marked as patrolled</span>');
					} else {
						$patrollinks.html('<span style="color: red;">Cannot mark as patrolled</span>');
					}
				}
			);
			return false; // Prevent other handlers from firing.
		});
	}
}
$(AjaxPatrolLinks);