improved the full diff view a bit more
This commit is contained in:
		| @ -131,6 +131,51 @@ $this->load->view ( | ||||
|  | ||||
| <div id="code_diff_mainarea_result"> | ||||
| <?php | ||||
| function format_diff ($a, $b, $css_class) | ||||
| { | ||||
| 	if ($b == '') return htmlspecialchars($a); | ||||
|  | ||||
| 	$cc = ''; | ||||
| 	$diffstart = -1; | ||||
| 	$aalen = strlen($a); | ||||
| 	$bblen = strlen($b); | ||||
|  | ||||
| 	for ($i = 0; $i < $aalen && $i < $bblen; $i++) | ||||
| 	{ | ||||
| 		if ($a[$i] == $b[$i]) | ||||
| 		{ | ||||
| 			if ($diffstart >= 0) | ||||
| 			{ | ||||
| 				$cc .= sprintf ('<span class="%s">', $css_class); | ||||
| 				$cc .= htmlspecialchars(substr($a, $diffstart, $i - $diffstart)); | ||||
| 				$cc .= '</span>'; | ||||
| 				$diffstart = -1; | ||||
| 			} | ||||
| 			$cc .= htmlspecialchars($a[$i]); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			if ($diffstart < 0) $diffstart = $i;	 | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if ($diffstart >= 0) | ||||
| 	{ | ||||
| 		$cc .= sprintf ('<span class="%s">', $css_class); | ||||
| 		$cc .= htmlspecialchars(substr($a, $diffstart, $aalen - $diffstart)); | ||||
| 		$cc .= '</span>'; | ||||
| 	}	 | ||||
| 	else | ||||
| 	{ | ||||
| 		if ($aalen > $bblen) | ||||
| 		{ | ||||
| 			$cc .= htmlspecialchars(substr ($a, $aalen, $aalen - $bblen)); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return $cc; | ||||
| } | ||||
|  | ||||
| if (!$fullview) | ||||
| { | ||||
| 	print '<table id="code_diff_mainarea_result_table">'; | ||||
| @ -289,20 +334,16 @@ else | ||||
| 		print "<pre class='prettyprint lang-{$fileext}' style='width: 100%' id='code_diff_mainarea_result_fulldiffold'>"; | ||||
|  | ||||
| 		foreach ($file['content'] as $x) | ||||
| 		{ | ||||
| 			if (array_key_exists('rev1line', $x))  | ||||
| 		{ | ||||
| 			$diffclass = array_key_exists('rev1diffclass', $x)? $x['rev1diffclass']: 'diff'; | ||||
| 			print "<span class='{$diffclass}'>"; | ||||
| 				if ($x['rev1line'] == '') print ' '; | ||||
| 				else print htmlspecialchars($x['rev1line']); | ||||
| 				print "</span>"; | ||||
| 			} | ||||
|  | ||||
| 			if ($diffclass == 'diffchanged') | ||||
| 				print format_diff ($x['rev1line'], $x['rev2line'], 'diffchangedold'); | ||||
| 			else  | ||||
| 			{ | ||||
| 				print $x['rev1lineno']; | ||||
| 			} | ||||
| 			print "\n"; | ||||
| 				print htmlspecialchars($x['rev1line']); | ||||
|  | ||||
| 			print "</span>\n"; | ||||
| 		} | ||||
| 		printf ("</div>"); | ||||
| 		print '</pre>'; | ||||
| @ -330,23 +371,17 @@ else | ||||
|  | ||||
| 		print "<pre class='prettyprint lang-{$fileext}' style='width: 100%' id='code_diff_mainarea_result_fulldiffnew'>"; | ||||
| 		foreach ($file['content'] as $x) | ||||
| 		{ | ||||
| 			if (array_key_exists('rev2line', $x))  | ||||
| 		{ | ||||
| 			$diffclass = array_key_exists('rev2diffclass', $x)? $x['rev2diffclass']: 'diff'; | ||||
|  | ||||
| 			print "<span class='{$diffclass}'>"; | ||||
|  | ||||
| 				if ($x['rev2line'] == '') print ' '; | ||||
| 				else print htmlspecialchars($x['rev2line']); | ||||
| 				 | ||||
| 				print "</span>"; | ||||
| 			} | ||||
| 			if ($diffclass == 'diffchanged') | ||||
| 				print format_diff ($x['rev2line'], $x['rev1line'], 'diffchangednew'); | ||||
| 			else  | ||||
| 			{ | ||||
| 				print $x['rev2lineno']; | ||||
| 			} | ||||
| 			print "\n"; | ||||
| 				print htmlspecialchars($x['rev2line']); | ||||
|  | ||||
| 			print "</span>\n"; | ||||
| 		} | ||||
|  | ||||
| 		print '</pre>'; | ||||
|  | ||||
| @ -374,3 +374,12 @@ | ||||
| 	padding-left:15px; | ||||
| 	margin: 0; | ||||
| } | ||||
|  | ||||
| #code_diff_mainarea_result_fullview .diffchangedold { | ||||
| 	text-decoration: line-through; | ||||
| } | ||||
|  | ||||
| #code_diff_mainarea_result_fullview .diffchangednew { | ||||
| 	//background-color:#ffff00; | ||||
| 	text-decoration: underline; | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user