summaryrefslogtreecommitdiffstats
path: root/template/en/default/attachment/diff-file.html.tmpl
blob: 2c87188ad00e54e1e59520281effe73713953588 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
[%# This Source Code Form is subject to the terms of the Mozilla Public
  # License, v. 2.0. If a copy of the MPL was not distributed with this
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  #
  # This Source Code Form is "Incompatible With Secondary Licenses", as
  # defined by the Mozilla Public License, v. 2.0.
  #%]

[%# This line is really long for a reason: to get rid of any possible textnodes
  # between the elements.  This is necessary because DOM parent-child-sibling
  # relations can change and screw up the javascript for restoring, collapsing
  # and expanding.  Do not change without testing all three of those.
  # Also, the first empty row is required because 'table-layout: fixed' only
  # considers the first row to determine column widths. If a colspan is found,
  # it then share the width equally among all columns, which we don't want.
  #%]
<table class="file_table"><thead><tr><td class="num"></td><td></td><td class="num"></td><td></td></tr><tr><td class="file_head" colspan="4"><a href="#" onclick="return twisty_click(this)">[% collapsed ? '(+)' : '(-)' %]</a><input type="checkbox" name="[% file.filename FILTER html %]"[% collapsed ? '' : ' checked' %] style="display: none">
  [% IF lxr_prefix && !file.is_add %]
    <a href="[% lxr_prefix %]">[% file.filename FILTER html %]</a>
  [% ELSE %]
    [% file.filename FILTER html %]
  [% END %]
  [% IF file.plus_lines %]
    [% IF file.minus_lines %]
      (-[% file.minus_lines %]&nbsp;/&nbsp;+[% file.plus_lines %]&nbsp;lines)
    [% ELSE %]
      (+[% file.plus_lines %]&nbsp;lines)
    [% END %]
  [% ELSE %]
    [% IF file.minus_lines %]
      (-[% file.minus_lines %]&nbsp;lines)
    [% END %]
  [% END %]
</td></tr></thead><tbody class="[% collapsed ? 'file_collapse' : 'file' %]">
<script type="text/javascript">
incremental_restore()
</script>

[% section_num = 0 %]
[% FOREACH section = sections %]
  [% section_num = section_num + 1 %]
  <tr><th colspan="4" class="section_head">
    <table id="[% file.filename FILTER html %]_sec[% section_num %]" cellpadding="0" cellspacing="0">
    <tr><th width="95%" class="left">
  [% IF file.is_add %]
    Added
  [% ELSIF file.is_remove %]
    [% IF bonsai_prefix %]
      <a href="[% bonsai_prefix %]">Removed</a>
    [% ELSE %]
      Removed
    [% END %]
  [% ELSE %]
    [% IF bonsai_prefix %]
      <a href="[% bonsai_prefix %]#[% section.old_start %]">
    [% END %]
    [% IF section.old_lines > 1 %]
      &nbsp;Lines&nbsp;[% section.old_start %]-[% section.old_start + 
                                             section.old_lines - 1 %]
    [% ELSE %]
      Line&nbsp;[% section.old_start %]
    [% END %]
    [% IF bonsai_prefix %]
      </a>
    [% END %]
    &nbsp;&nbsp;[% section.func_info FILTER html IF section.func_info %]
  [% END %] 
    </th><th>
  <a href="#[% file.filename FILTER html %]_sec[% section_num %]">Link&nbsp;Here</a>&nbsp;
    </th></tr></table>
  </th></tr>
  [% current_line_old = section.old_start %]
  [% current_line_new = section.new_start %]
  [% FOREACH group = section.groups %]
    [% IF group.context %]
      [% FOREACH line = group.context %]
        <tr>
          <td class="num">[% current_line_old %]</td>
          <td><pre>[% line FILTER html %]</pre></td>
          <td class="num">[% current_line_new %]</td>
          <td><pre>[% line FILTER html %]</pre></td>
        </tr>
        [% current_line_old = current_line_old + 1 %]
        [% current_line_new = current_line_new + 1 %]
      [% END %]
    [% END %]
    [% IF group.plus.size %]
      [% IF group.minus.size %]
        [% i = 0 %]
        [% WHILE (i < group.plus.size || i < group.minus.size) %]
          [%# WHILE cannot loop more than 1000 times by default, so we break it every 500 times. %]
          [% currentloop = 0 %]
          [% WHILE currentloop < 500 && (i < group.plus.size || i < group.minus.size) %]
            <tr>
            [% IF i < group.minus.size %]
              <td class="num">[% current_line_old + i %]</td>
              <td class="changed"><pre>[% group.minus.$i FILTER html %]</pre></td>
            [% ELSIF i == group.minus.size %]
              [% rowspan = group.plus.size - group.minus.size %]
              <td class="num"[% IF rowspan > 1 %] rowspan="[% rowspan FILTER none %]"[% END %]></td>
              <td class="changed"[% IF rowspan > 1 %] rowspan="[% rowspan FILTER none %]"[% END %]></td>
            [% END %]

            [% IF i < group.plus.size %]
              <td class="num">[% current_line_new + i %]</td>
              <td class="changed"><pre>[% group.plus.$i FILTER html %]</pre></td>
            [% ELSIF i == group.plus.size %]
              [% rowspan = group.minus.size - group.plus.size %]
              <td class="num"[% IF rowspan > 1 %] rowspan="[% rowspan FILTER none %]"[% END %]></td>
              <td class="changed"[% IF rowspan > 1 %] rowspan="[% rowspan FILTER none %]"[% END %]></td>
            [% END %]
            </tr>
            [% currentloop = currentloop + 1 %]
            [% i = i + 1 %]
          [% END %]
        [% END %]
        [% current_line_old = current_line_old + group.minus.size %]
        [% current_line_new = current_line_new + group.plus.size %]
      [% ELSE %]
        [% FOREACH line = group.plus %]
          [% IF file.is_add %]
            <tr>
              <td class="num">[% current_line_new %]</td>
              <td class="added" colspan="3"><pre>[% line FILTER html %]</pre></td>
            </tr>
          [% ELSE %]
            <tr>
            [% IF loop.first %]
              <td class="num"[% IF group.plus.size > 1 %] rowspan="[% group.plus.size %]"[% END %]></td>
              <td[% IF group.plus.size > 1 %] rowspan="[% group.plus.size %]"[% END %]></td>
            [% END %]
              <td class="num">[% current_line_new %]</td>
              <td class="added"><pre>[% line FILTER html %]</pre></td>
            </tr>
          [% END %]
          [% current_line_new = current_line_new + 1 %]
        [% END %]
      [% END %]
    [% ELSE %]
      [% IF group.minus.size %]
        [% FOREACH line = group.minus %]
          [% IF file.is_remove %]
            <tr>
              <td class="num">[% current_line_old %]</td>
              <td class="removed" colspan="3"><pre>[% line FILTER html %]</pre></td>
            </tr>
          [% ELSE %]
            <tr>
              <td class="num">[% current_line_old %]</td>
              <td class="removed"><pre>[% line FILTER html %]</pre></td>
            [% IF loop.first %]
              <td class="num"[% IF group.minus.size > 1 %] rowspan="[% group.minus.size %]"[% END %]></td>
              <td[% IF group.minus.size > 1 %] rowspan="[% group.minus.size %]"[% END %]></td>
            [% END %]
            </tr>
          [% END %]
          [% current_line_old = current_line_old + 1 %]
        [% END %]
      [% END %]
    [% END %]
  [% END %]
[% END %]

</table>