From 58bb110c9208ebf6a88a07c487ed9ba10b68e0ab Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Wed, 28 Jan 2015 02:52:29 +0000 Subject: [PATCH] improved the full diff view a bit more --- codepot/src/codepot/views/code_diff.php | 89 +++++++++++++++++-------- codepot/src/css/code.css | 9 +++ 2 files changed, 71 insertions(+), 27 deletions(-) diff --git a/codepot/src/codepot/views/code_diff.php b/codepot/src/codepot/views/code_diff.php index 460817f9..d343ef86 100644 --- a/codepot/src/codepot/views/code_diff.php +++ b/codepot/src/codepot/views/code_diff.php @@ -131,6 +131,51 @@ $this->load->view (
= 0) + { + $cc .= sprintf ('', $css_class); + $cc .= htmlspecialchars(substr($a, $diffstart, $i - $diffstart)); + $cc .= ''; + $diffstart = -1; + } + $cc .= htmlspecialchars($a[$i]); + } + else + { + if ($diffstart < 0) $diffstart = $i; + } + } + + if ($diffstart >= 0) + { + $cc .= sprintf ('', $css_class); + $cc .= htmlspecialchars(substr($a, $diffstart, $aalen - $diffstart)); + $cc .= ''; + } + else + { + if ($aalen > $bblen) + { + $cc .= htmlspecialchars(substr ($a, $aalen, $aalen - $bblen)); + } + } + + return $cc; +} + if (!$fullview) { print ''; @@ -290,19 +335,15 @@ else foreach ($file['content'] as $x) { - if (array_key_exists('rev1line', $x)) - { - $diffclass = array_key_exists('rev1diffclass', $x)? $x['rev1diffclass']: 'diff'; - print ""; - if ($x['rev1line'] == '') print ' '; - else print htmlspecialchars($x['rev1line']); - print ""; - } - else - { - print $x['rev1lineno']; - } - print "\n"; + $diffclass = array_key_exists('rev1diffclass', $x)? $x['rev1diffclass']: 'diff'; + print ""; + + if ($diffclass == 'diffchanged') + print format_diff ($x['rev1line'], $x['rev2line'], 'diffchangedold'); + else + print htmlspecialchars($x['rev1line']); + + print "\n"; } printf (""); print ''; @@ -331,22 +372,16 @@ else print "
";
 		foreach ($file['content'] as $x)
 		{
-			if (array_key_exists('rev2line', $x)) 
-			{
-				$diffclass = array_key_exists('rev2diffclass', $x)? $x['rev2diffclass']: 'diff';
+			$diffclass = array_key_exists('rev2diffclass', $x)? $x['rev2diffclass']: 'diff';
 
-				print "";
+			print "";
 
-				if ($x['rev2line'] == '') print ' ';
-				else print htmlspecialchars($x['rev2line']);
-				
-				print "";
-			}
-			else
-			{
-				print $x['rev2lineno'];
-			}
-			print "\n";
+			if ($diffclass == 'diffchanged')
+				print format_diff ($x['rev2line'], $x['rev1line'], 'diffchangednew');
+			else 
+				print htmlspecialchars($x['rev2line']);
+
+			print "\n";
 		}
 
 		print '
'; diff --git a/codepot/src/css/code.css b/codepot/src/css/code.css index b95c0f7e..c706a7c8 100644 --- a/codepot/src/css/code.css +++ b/codepot/src/css/code.css @@ -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; +}