Description:
Merge branch 'master' into codejom (announcement refresh bug fix)
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r244:72b95c87a51a - - 2 files changed: 5 inserted, 2 deleted
@@ -1,38 +1,39 | |||
|
1 | 1 | - content_for :head do |
|
2 | 2 | = javascript_include_tag :defaults |
|
3 | 3 | = javascript_include_tag 'announcement_refresh.js' |
|
4 | 4 | = javascript_include_tag 'codejom_timeout.js' |
|
5 | 5 | |
|
6 | 6 | = user_title_bar(@user) |
|
7 | 7 | |
|
8 | 8 | .announcementbox{:style => (@announcements.length==0 ? "display:none" : "")} |
|
9 | 9 | %span{:class => 'title'} |
|
10 | 10 | Announcements |
|
11 | 11 | #announcementbox-body |
|
12 | 12 | = render :partial => 'announcement', :collection => @announcements |
|
13 | 13 | |
|
14 | 14 | %hr/ |
|
15 | 15 | |
|
16 | 16 | - if (Configuration.contest_mode?) and (@user.site!=nil) and (@user.site.started!=true) |
|
17 | 17 | %p=t 'main.start_soon' |
|
18 | 18 | |
|
19 | 19 | - if Configuration.show_tasks_to?(@user) |
|
20 | 20 | .problem-list |
|
21 | 21 | = render :partial => 'problem_title', :collection => @problems, :as => :problem |
|
22 | 22 | .problem-content |
|
23 | 23 | %span{:id => "problem-panel-filler", :style => (@current_problem_id!=nil) ? "display:none" : ""} |
|
24 | 24 | %h2 |
|
25 | 25 | Welcome to Code Jom |
|
26 | 26 | %br/ |
|
27 | 27 | Choose problems from the list on the right. |
|
28 | 28 | = render :partial => 'problem', :collection => @problems |
|
29 | 29 | |
|
30 | 30 | %br{:clear=>'both'}/ |
|
31 | 31 | %hr/ |
|
32 | 32 | |
|
33 |
- %script{:type => |
|
|
33 | + %script{:type => 'text/javascript'} | |
|
34 | + = "Announcement.refreshUrl = '#{url_for :controller => 'main', :action => 'announcements'}';" | |
|
34 | 35 | Announcement.registerRefreshEventTimer(); |
|
35 | 36 | = render :partial => 'submission_timeouts' |
|
36 | 37 | CodejomTimeout.updateProblemMessages(); |
|
37 | 38 | CodejomTimeout.registerRefreshEvent(); |
|
38 | 39 |
@@ -1,38 +1,40 | |||
|
1 | 1 | |
|
2 | 2 | var Announcement = { |
|
3 | 3 | |
|
4 | 4 | mostRecentId: 0, |
|
5 | 5 | |
|
6 | + refreshUrl: '/main/announcements', | |
|
7 | + | |
|
6 | 8 | setMostRecentId: function(id) { |
|
7 | 9 | Announcement.mostRecentId = id; |
|
8 | 10 | }, |
|
9 | 11 | |
|
10 | 12 | updateRecentId: function(id) { |
|
11 | 13 | if(Announcement.mostRecentId < id) |
|
12 | 14 | Announcement.mostRecentId = id; |
|
13 | 15 | }, |
|
14 | 16 | |
|
15 | 17 | refreshAnnouncement: function() { |
|
16 |
- var url = |
|
|
18 | + var url = Announcement.refreshUrl; | |
|
17 | 19 | new Ajax.Request(url, { |
|
18 | 20 | method: 'get', |
|
19 | 21 | parameters: { recent: Announcement.mostRecentId }, |
|
20 | 22 | onSuccess: function(transport) { |
|
21 | 23 | if(transport.responseText.match(/\S/)!=null) { |
|
22 | 24 | var announcementBody = $("announcementbox-body"); |
|
23 | 25 | announcementBody.insert({ top: transport.responseText }); |
|
24 | 26 | var announcementBoxes = $$(".announcementbox"); |
|
25 | 27 | if(announcementBoxes.length!=0) |
|
26 | 28 | announcementBoxes[0].show(); |
|
27 | 29 | } |
|
28 | 30 | } |
|
29 | 31 | }); |
|
30 | 32 | Announcement.registerRefreshEventTimer(); |
|
31 | 33 | }, |
|
32 | 34 | |
|
33 | 35 | registerRefreshEventTimer: function() { |
|
34 | 36 | setTimeout(function () { |
|
35 | 37 | Announcement.refreshAnnouncement(); |
|
36 | 38 | }, 30000); |
|
37 | 39 | } |
|
38 | 40 | }; |
You need to be logged in to leave comments.
Login now