_ _    _ _____  ___   __                       
 __      _(_) | _(_)___ / ( _ ) / /_   ___ ___  _ __ ___  
 \ \ /\ / / | |/ / | |_ \ / _ \| '_ \ / __/ _ \| '_ ` _ \ 
  \ V  V /| |   <| |___) | (_) | (_) | (_| (_) | | | | | |
   \_/\_/ |_|_|\_\_|____/ \___/ \___(_)___\___/|_| |_| |_|

User:BrandonXLF/CompareRevisions.js

In today's article we are going to talk about User:BrandonXLF/CompareRevisions.js, a topic of great importance today. User:BrandonXLF/CompareRevisions.js is a topic that has captured the attention of many people around the world, due to its relevance in different aspects of society. From its impact on the economy, politics, technology, culture, among others, User:BrandonXLF/CompareRevisions.js has proven to be a topic that does not go unnoticed. In this article we will analyze different perspectives on User:BrandonXLF/CompareRevisions.js, as well as its evolution over time and its influence on everyday life. Additionally, we will explore some concrete examples of how User:BrandonXLF/CompareRevisions.js has changed the way we face various challenges in our daily lives. Without a doubt, User:BrandonXLF/CompareRevisions.js is a topic that invites us to reflect and open our minds to new ideas and approaches. Don't miss this interesting article about User:BrandonXLF/CompareRevisions.js!
/*** Compare Revisions ***/

// Adds a button to the diff page to compare two revisions side-by-side
// Documentation at ]
// By ]

$.when(mw.loader.using('oojs-ui'), $.ready).then(function() {
	var cache = {};

	mw.hook('wikipage.diff').add(function() {
		var oldId = mw.config.get('wgDiffOldId'),
			newId = mw.config.get('wgDiffNewId'),
			bar = new OO.ui.ButtonSelectWidget({items: [
				new OO.ui.ButtonOptionWidget({
					label: 'Diff',
					data: 'diff'
				}),
				new OO.ui.ButtonOptionWidget({
					label: 'Compare',
					data: 'compare'
				}),
				new OO.ui.ButtonOptionWidget({
					label: 'Compare Wikitext',
					data: 'wikitext'
				})
			]}),
			compareArea = $('<div>').attr('id', 'comparerevisions-area');

		if (!oldId || !newId) return;

		function showComparison(cachePrefix, displayFunc, getFunc) {
			var compareOld = $('<div>').addClass('comparerevisions-side'),
				compareNew = $('<div>').addClass('comparerevisions-side');

			function showRevision(revId, el) {
				var cacheKey = cachePrefix + '-' + revId;

				compareArea.append(
					el.append(
						$('<div>').css('text-align', 'center').text('Loading...')
					)
				);

				if (cache) {
					displayFunc(el.empty(), cache, revId);
				} else {
					getFunc(revId).done(function(data) {
						cache = data;
						displayFunc(el.empty(), cache, revId);
					});
				}
			}

			showRevision(oldId, compareOld);
			showRevision(newId, compareNew);
		}

		$('.diff-title').after(
			$('<tr>').append(
				$('<td>').attr('colspan', '4').append(compareArea)
			)
		);

		bar.$element.css({
			float: 'left',
			margin: $('.ve-init-mw-diffPage-diffMode').length ? '0 0 0 8px' : '8px 0'
		});

		if ($('.ve-init-mw-diffPage-diffMode').length) {
			$('.ve-init-mw-diffPage-diffMode').append(bar.$element);
		} else if ($('.mw-revslider-container').length) {
			$('.mw-revslider-container').after(bar.$element);
		} else {
			$('#mw-content-text').prepend(bar.$element);
		}

		bar.on('select', function(e) {
			mw.storage.set('comparerevisions-lastview', e.data);

			compareArea.empty();

			if (e.data == 'compare') {
				showComparison(
					'compare',
					function(el, html, revId) {
						el.html(html);
						el.find('').attr('for', 'toctogglecheckbox-' + revId);
						el.find('#toctogglecheckbox').attr('id', 'toctogglecheckbox-' + revId);
					},
					function(revId) {
						return $.get(mw.config.get('wgScriptPath') + '/api.php', {
							action: 'parse',
							oldid: revId,
							prop: 'text',
							format: 'json'
						}).then(function(res) {
							return res.parse.text;
						});
					}
				);
			} else if (e.data == 'wikitext') {
				showComparison(
					'wikitext',
					function(el, text) {
						el.append(
							$('<pre></pre>').text(text)
						);
					},
					function(revId) {
						return $.get(mw.config.get('wgScript'), {
							action: 'raw',
							oldid: revId
						});
					}
				);
			}
		});

		bar.selectItemByData(mw.storage.get('comparerevisions-lastview') || 'diff');
	});

	mw.loader.addStyleTag(
		'#comparerevisions-area { border-spacing: 0; }' +
		'.comparerevisions-side { width: 50%; padding: 3px 10px; box-sizing: border-box; float: left; }'
	);
});