Subversion Repositories DevTools

Rev

Rev 1295 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1293 dpurdie 1
[% USE AutomagicLinks %]
2
[% USE JavascriptEscape %]
3
[% USE StringObfuscator %]
4
 
5
<SCRIPT type="text/javascript">
6
 
7
// Store the form data in a browser cookie.
8
function save_form_data() {
9
   var form = document.add_comment;
10
   var contents = '';
11
   contents +=       escape(form.comments.value);
12
   contents += '&' + escape(form.email.value);
13
   contents += '&' + escape(form.comment_cc.value);
14
   setCookie('codestriker_add_comment_form_data', contents, 30);
15
}
16
 
17
// Load the form data from a browser cookie.
18
function load_form_data() {
19
   var cookie = getCookie('codestriker_add_comment_form_data');
20
   if (cookie == null || cookie == '') return null;
21
 
22
   // Delete the cookie (so that it doesn't persist between different
23
   // comment pages).
24
   setCookie('codestriker_add_comment_form_data', '', 1);
25
 
26
   return cookie.split('&');
27
}
28
 
29
// Set the form field from the values present in the cookie.
30
function set_form_fields() {
31
   var field_comments   = '';
32
   var field_email      = '[% email %]';
33
   var field_comment_cc = '';
34
 
35
   var fields = load_form_data();
36
   if (fields != null) {
37
      field_comments   = unescape(fields[0]);
38
      field_email      = unescape(fields[1]);
39
      field_comment_cc = unescape(fields[2]);
40
   }
41
 
42
   // Now set the form elements below if the values are available.
43
   if (field_comments != null) {
44
      document.add_comment.comments.value = field_comments;
45
   }
46
   if (field_email != null) {
47
      document.add_comment.email.value = field_email;
48
   }
49
   if (field_comment_cc != null) {
50
      document.add_comment.comment_cc.value = field_comment_cc;
51
   }
52
}
53
 
54
// Called when the form is submitted to ensure the metric dropdowns are set
55
// as well as the comment field.
56
function verify() {
57
  // Check the form field has a comment in it.
58
  if (document.add_comment.comments.value == '') {
59
      alert('No comment has been entered.');
60
      return false;
61
  }
62
 
63
  // Check the metrics have been set.
64
  var index;
65
  var value;
66
  [% FOREACH metric = metrics %]
67
      index = document.add_comment.comment_state_metric_[% metric.name %].options.selectedIndex;
68
      if (index == -1) {
69
          alert('Metric [% metric.name %] has not been specified.');
70
	  return false;
71
      }
72
      value = document.add_comment.comment_state_metric_[% metric.name %].options[index].value;
73
      if (value == 'Select Value') {
74
          alert('Metric [% metric.name %] has not been specified.');
75
	  return false;
76
      }
77
 
78
  [% END %]
79
 
80
  // If we reached here, then all metrics have been set.
81
  return true;
82
}
83
 
84
// Check if a specific reviewer can be added to the cc field, assuming
85
// it isn't present already.
86
function add_other_reviewer(reviewer) {
87
    if (document.add_comment.comment_cc.value != "") {
88
        var addresses = new Array();
89
        if (document.add_comment.comment_cc.value.split) {
90
            addresses = document.add_comment.comment_cc.value.split(/[\s,]+/);
91
        }
92
	var found = 0;
93
	for (var i = 0; i < addresses.length; i++) {
94
	  if (addresses[i] == reviewer) {
95
	    found = 1;
96
	    break;
97
	  }
98
	}
99
	if (reviewer == document.add_comment.email.value) {
100
          found = 1;
101
        }
102
	if (found == 0) {
103
            document.add_comment.comment_cc.value += ", " + reviewer;
104
        }
105
    } else {
106
        document.add_comment.comment_cc.value = reviewer;
107
    }
108
}
109
 
110
// Called when the "add other reviewers" link is pressed, which adds all
111
// reviewers to the Cc: field.
112
function add_other_reviewers() {
113
  [% FOREACH reviewer = reviewers %]
114
    add_other_reviewer("[% reviewer | $JavascriptEscape | $StringObfuscator %]");
115
  [% END %]
116
}
117
</Script>
118
 
119
[%# Screen for the add comment form. #%]
120
 
121
[% PROCESS header.html.tmpl displaymenu = 0 version = version help = "x504.html#ADD-COMMENT" %]
122
 
123
<table border="0" cellpadding="5" cellspacing="0" width="100%">
124
<tr class="tlh">
125
    <td>Topic title: <b>[% topic_title | html_entity %]</b>.</td>
126
    <td align=right>[% document_creation_time | html_entity %]</td>
127
</tr>
128
</table>
129
 
130
<P>
131
 
132
<FORM NAME="add_comment" METHOD="POST" onSubmit="return verify();" ENCTYPE="application/x-www-form-urlencoded">
133
 <INPUT TYPE="hidden" NAME="action" VALUE="submit_comment">
134
 <INPUT TYPE="hidden" NAME="line" VALUE="[% line %]">
135
 <INPUT TYPE="hidden" NAME="topic" VALUE="[% topic %]">
136
 <INPUT TYPE="hidden" NAME="mode" VALUE="[% mode %]">
137
 <INPUT TYPE="hidden" NAME="a" VALUE="[% anchor %]">
138
 <INPUT TYPE="hidden" NAME="fn" VALUE="[% fn %]">
139
 <INPUT TYPE="hidden" NAME="new" VALUE="[% new %]">
140
 
141
 Enter new comment:<BR>
142
 <TEXTAREA NAME="comments" ROWS=13 COLS=75 WRAP="hard"></TEXTAREA>
143
 
144
 [% IF metrics != '' %]
145
   <P>
146
   <TABLE>
147
     [% FOREACH metric = metrics %]
148
     [% IF loop.index() % 4 == 0 %]
149
     <TR>
150
     [% END %]
151
       <TD ALIGN="right">[% metric.name %]:</TD>
152
       <TD ALIGN="left">
153
         <SELECT NAME="comment_state_metric_[% metric.name %]">
154
           [% IF metric.current_value == '' %]
155
 
156
	     [% IF metric.default_value == '' %]
157
               <OPTION VALUE="Select Value">&lt;Select Value&gt;</OPTION>
158
             [% END %]
159
	     [% FOREACH value = metric.values %]
160
	       <OPTION [% IF value == metric.default_value %]SELECTED[% END %] VALUE="[% value %]">[% value %]</OPTION>
161
             [% END %]
162
 
163
	   [% ELSE %]
164
 
165
             [% SET found_current_value = 0 %]
166
	     [% FOREACH value = metric.values %]
167
 
168
	       [% IF value == metric.current_value %]
169
	         <OPTION SELECTED VALUE="[% value %]">[% value %]</OPTION>
170
		 [% SET found_current_value = 1 %]
171
               [% ELSE %]
172
	         <OPTION VALUE="[% value %]">[% value %]</OPTION>
173
	       [% END %]
174
	     [% END %]
175
 
176
	     [% IF found_current_value == 0 %]
177
	       [%# Old metric data value no longer in config. #%]
178
 
179
	       <OPTION VALUE="[% metric.current_value %]">[% metric.current_value %]</OPTION>
180
	     [% END %]
181
 
182
	   [% END %]
183
	 </SELECT>
184
         &nbsp;&nbsp;&nbsp;&nbsp;
185
       </TD>
186
     [% IF loop.index() % 4 == 3 || loop.last() %]
187
     </TR>
188
     [% END %]
189
     [% END %]
190
   </TABLE>
191
 [% END %]
192
 
193
 <P>
194
 
195
 <TABLE>
196
 <TR>
197
  <TD>Your email address: </TD>
198
  <TD>
199
    <INPUT TYPE="text" NAME="email" SIZE=50 MAXLENGTH=100>
200
  </TD>
201
  <TD></TD>
202
 </TR>
203
 <TR>
204
  <TD>Cc: <FONT SIZE="-1"><A HREF="javascript:add_other_reviewers();">(add other reviewers)</A></FONT> </TD>
205
  <TD>
206
     <INPUT TYPE="text" NAME="comment_cc" SIZE=50 MAXLENGTH=150>
207
  </TD>
208
  <TD><INPUT TYPE="submit" NAME="submit" VALUE="Submit" ONCLICK="if (opener != null) opener.focus()"></TD>
209
 </TR>
210
 </TABLE>
211
 
212
 
213
</FORM>
214
 
215
[%# Display a list of comments #%]
216
 
217
<TABLE CELLPADDING="1" CELLSPACING="1" BORDER="0" width="100%">
218
[% FOREACH comment = comments %]
219
[% FLUSH IF loop.count() % 10 == 1 %]
220
 
221
[% IF loop.count() == 1 %]
222
<TR CLASS="comments"><TD><B>Comments:</B></TD></TR>
223
<TR CLASS="commentb"><TD>&nbsp;</TD></TR>
224
[% END %]
225
 
226
<TR CLASS="commenth">
227
<TD>
228
[% IF comment.line != '' %]
229
<A HREF="[% comment.lineurl %]" NAME="[% comment.linename %]">
230
[% comment.line %]</A>
231
[% END %]
232
 
233
[% comment.author | html_entity %]&nbsp;[% comment.date | html_entity %]
234
</TD>
235
</TR>
236
<TR CLASS="commentb">
237
<TD>
238
<PRE>[% comment.data | html_entity | $AutomagicLinks %]</PRE></TD>
239
</TR>
240
[% END %]
241
</TABLE>
242
 
243
[% IF context != '' %]
244
<hr>
245
<P>Context: (<A onClick="save_form_data()" HREF="[% inc_context_url %]">increase</A> | <A onClick="save_form_data()" HREF="[% dec_context_url %]">decrease)</A>
246
[% context %]
247
[% END %]
248
 
249
<SCRIPT type="text/javascript">
250
  // Now that the form has loaded, set the form fields.
251
  set_form_fields();
252
</SCRIPT>
253
 
254
[% PROCESS trailer.html.tmpl %]
255
 
256
</BODY>
257
</HTML>
258