User:Gryllida/js/truncateEditSummaryWithClickableEllipsis.js

Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/*
Author : Svetlana Tkachenko svetlana@members.fsf.org
This file is a part of truncateEditSummaryWithClickableEllipsis.js.
Licence: GPLv3+
Version: 0.1.1
Release date: 2018-03-05
Description: truncates edit summary (not in diff views) with clickable ellipsis
*/ 

if($('.diff-otitle').length === 0){
	var n = 80;
	$('.comment').each(function(i){
		var original = $(this).text();
		if(original.length > n){
			var $a = $('<a></a>',{
				href: "javascript:void(0)", 
				text: "..."
			});
			$a.click(function(){
				$(this).parent().text(original);
			});
			var shortText = $.trim(original).substring(0, n).trim(this);
			shortText = shortText + " [";
			$(this).text(shortText);
			$(this).append($a);
			$(this).append('])');
		}
	});
}