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