Make compare more compact and add line numbers
This commit is contained in:
@ -187,6 +187,7 @@ class MyersDiff
|
|||||||
case DiffTypeEnum::KEEP->value:
|
case DiffTypeEnum::KEEP->value:
|
||||||
for ($i = 0; $i < $data; $i++) {
|
for ($i = 0; $i < $data; $i++) {
|
||||||
$lines[] = [
|
$lines[] = [
|
||||||
|
'line' => $x,
|
||||||
'type' => 'keep',
|
'type' => 'keep',
|
||||||
'from' => $a[$x],
|
'from' => $a[$x],
|
||||||
'to' => $a[$x],
|
'to' => $a[$x],
|
||||||
@ -197,6 +198,7 @@ class MyersDiff
|
|||||||
case DiffTypeEnum::DELETE->value:
|
case DiffTypeEnum::DELETE->value:
|
||||||
for ($i = 0; $i < $data; $i++) {
|
for ($i = 0; $i < $data; $i++) {
|
||||||
$lines[] = [
|
$lines[] = [
|
||||||
|
'line' => $x,
|
||||||
'type' => 'delete',
|
'type' => 'delete',
|
||||||
'from' => $a[$x],
|
'from' => $a[$x],
|
||||||
'to' => '',
|
'to' => '',
|
||||||
@ -207,6 +209,7 @@ class MyersDiff
|
|||||||
case DiffTypeEnum::INSERT->value:
|
case DiffTypeEnum::INSERT->value:
|
||||||
foreach ($data as $v) {
|
foreach ($data as $v) {
|
||||||
$lines[] = [
|
$lines[] = [
|
||||||
|
'line' => $x,
|
||||||
'type' => 'insert',
|
'type' => 'insert',
|
||||||
'from' => '',
|
'from' => '',
|
||||||
'to' => $v,
|
'to' => $v,
|
||||||
|
@ -7,10 +7,11 @@
|
|||||||
<i class="fa fa-arrow-left"></i> Back
|
<i class="fa fa-arrow-left"></i> Back
|
||||||
</a>
|
</a>
|
||||||
<br><br>
|
<br><br>
|
||||||
<table class="table table-condensed table-hover">
|
<table class="table table-sm table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Line</th>
|
<th>Line</th>
|
||||||
|
<th>Type</th>
|
||||||
<th>Old</th>
|
<th>Old</th>
|
||||||
<th>New</th>
|
<th>New</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -18,19 +19,12 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for line in diff %}
|
{% for line in diff %}
|
||||||
<tr>
|
<tr>
|
||||||
|
<td>{{ line.line }}.</td>
|
||||||
<td class="table-{{ line.type == 'insert' ? 'success' : (line.type == 'delete' ? 'danger' : 'info') }}">
|
<td class="table-{{ line.type == 'insert' ? 'success' : (line.type == 'delete' ? 'danger' : 'info') }}">
|
||||||
{{ line.type }}
|
{{ line.type }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>{{ line.from }}</td>
|
||||||
{% if line.from %}
|
<td>{{ line.to }}</td>
|
||||||
{{ line.from }}
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{% if line.to %}
|
|
||||||
{{ line.to }}
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
Reference in New Issue
Block a user