User:NguoiDungKhongDinhDanh/LiveDiffLink.js

Today, User:NguoiDungKhongDinhDanh/LiveDiffLink.js is a topic of great relevance and interest to a wide variety of people around the world. With the advancement of technology and globalization, User:NguoiDungKhongDinhDanh/LiveDiffLink.js has become a key point of discussion in different areas, from politics to science, including culture and society. Opinions and perspectives on User:NguoiDungKhongDinhDanh/LiveDiffLink.js are diverse and changing, making it an exciting and constantly evolving topic. In this article, we will explore different aspects of User:NguoiDungKhongDinhDanh/LiveDiffLink.js, from its origins and influence today, to the possible future implications it may have. In addition, we will analyze different points of view and arguments on the matter, with the aim of offering a complete and enriching vision of User:NguoiDungKhongDinhDanh/LiveDiffLink.js.
// Globalized LiveDiffLink.
// For attribution: ]

$(function() {
	// Don't do anything unless we're on a History page.
	if (mw.config.get('wgAction') !== 'history') return;
	
	var sc = mw.config.get('wgScript');
	var pn = mw.config.get('wgPageName');
	var getlink = function(diff, oldid) {
		return (new mw.Uri(sc)).extend({
			title: pn,
			diff: diff,
			oldid: oldid,
			unhide: 1
		}).toString();
	};
	
	// Grab the Compare buttons, create an empty link after each, and grab the empty links
	$('.mw-history-compareselectedversions-button').after(
		$('<a>').attr({
			class: 'LDL-diffurl'
		}).css({
			border: '1px dashed #999999',
			padding: '2px 4px'
		})
	);        
	$('.LDL-diffurl').before($('<b>').text(' → '));
	
	// Event listener for copy buttons.
	$('#pagehistory').on('click', '.LDL-copybuttons', function(e) {
		e.preventDefault();
		navigator.clipboard.writeText($($('.LDL-diffurl')).text());
		mw.notify('Added diff wikilink to clipboard.', {
			title: 'Copied!',
			tag: 'livedifflinknotification',
		});
	});
	
	// Set the Click event function for radio buttons
	$('#pagehistory').on('click', ':radio, :radio', function() {
		
		// Clear existing revision size links
		$('.LDL-difflinks').remove();

		// Grab the revision selection, place in appropriate var
		var diff = $(':checked').val();
		var oldid = $(':checked').val();
		var link = getlink(diff, oldid);

		// Update the main diff link URL, text, & tooltip
		$('.LDL-diffurl').attr({
			href: link,
			title: link
		}).text(']');

		// Add diff link before revision sizes
		$(':checked, :checked').closest('li').find('.history-size').before(
			$('<span>').attr({
				'class': 'LDL-difflinks'
			}).append(
				'(',
				$('<a>').attr({
					href: link,
					title: link
				}).text('diff'),
				') ',
				$('<button>').attr({
					class: 'LDL-copybuttons'
				}).css({
					padding: '1px',
					'font-size': '0.75em'
				}).text('Copy'),
				' . . '
			)
		);
	});
	$(':radio, :radio').not('').first().trigger('click');
});