Description:
[web] fixed javascript incompatiblity git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@146 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r69:7445fbf8d0c5 - - 1 file changed: 13 inserted, 6 deleted

@@ -1,67 +1,74
1 1 <h2>Test Interface</h2>
2 2
3 3 <% if @problems.length==0 %>
4 4 There is no submission
5 5 <% else %>
6 6
7 7 <script type="text/javascript">
8 - var submissionCount = {
8 + var submissionCount = new Array();
9 9 <% @submissions.each do |submission| %>
10 - <%= submission.problem_id %> : <%= submission.number %>,
10 + submissionCount[<%= submission.problem_id %>]=<%= submission.number %>;
11 11 <% end %>
12 - };
12 +
13 13 function updateSubmissionList() {
14 14 currentProb = document.getElementById("test_request_problem_id").value;
15 15 count = submissionCount[currentProb];
16 16 submissionSelect = document.getElementById("test_request_submission_number");
17 - submissionSelect.options.length = 0;
18 - for(i=0; i<count; i++) {
19 - submissionSelect.options[i] = new Option(""+(i+1),""+(i+1),false,false);
17 + old_len = submissionSelect.length;
18 + // clear the box
19 + for(i=0; i<old_len; i++)
20 + submissionSelect.remove(0);
21 + for(i=count; i>=1; i--) {
22 + try {
23 + submissionSelect.add(new Option(""+i,""+i,false,false),null);
24 + } catch(ex) {
25 + submissionSelect.add(new Option(""+i,""+i,false,false));
26 + }
20 27 }
21 28 }
22 29 </script>
23 30
24 31 <% form_for :test_request, nil,
25 32 :url => { :action => 'submit'},
26 33 :html => { :multipart => true } do |f| %>
27 34 <table>
28 35 <tr>
29 36 <td>Task:</td>
30 37 <td>
31 38 <%= select(:test_request,
32 39 :problem_id,
33 40 @problems.collect {|p| [p.name, p.id]}, {},
34 41 { :onclick => "updateSubmissionList();" }) %>
35 42 </td>
36 43 </tr>
37 44 <tr>
38 45 <td>Submission:</td>
39 46 <td>
40 47 <%= select(:test_request,
41 48 :submission_number,
42 49 ((1..@submissions[0].number).collect {|n| [n,n]}).reverse) %>
43 50 </td>
44 51 </tr>
45 52 <tr>
46 53 <td>Input data:</td>
47 54 <td><%= f.file_field :input_file %></td>
48 55 <tr>
49 56 <td colspan="2">
50 57 <%= submit_tag 'submit' %>
51 58 </td>
52 59 </tr>
53 60 </table>
54 61 <% end %>
55 62
56 63 <h3>Previous requests</h3>
57 64
58 65 <table class="info">
59 66 <tr class="info-head">
60 67 <th>at</th>
61 68 <th>problem</th>
62 69 <th>sub #</th>
63 70 <th>status</th>
64 71 <th>running stat</th>
65 72 <th>output (first 2kb)</th>
66 73 <th>grading comment</th>
67 74 <th>compiler message</th>
You need to be logged in to leave comments. Login now