improved the full diff view a bit more
This commit is contained in:
parent
5fc888924c
commit
58bb110c92
@ -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">';
|
||||
@ -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 "<span class='{$diffclass}'>";
|
||||
if ($x['rev1line'] == '') print ' ';
|
||||
else print htmlspecialchars($x['rev1line']);
|
||||
print "</span>";
|
||||
}
|
||||
$diffclass = array_key_exists('rev1diffclass', $x)? $x['rev1diffclass']: 'diff';
|
||||
print "<span class='{$diffclass}'>";
|
||||
|
||||
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>';
|
||||
@ -331,22 +372,16 @@ 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';
|
||||
$diffclass = array_key_exists('rev2diffclass', $x)? $x['rev2diffclass']: 'diff';
|
||||
|
||||
print "<span class='{$diffclass}'>";
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user