Description:
Merge branch 'master' into codejom (announcement refresh bug fix)
Commit status:
[Not Reviewed]
References:
merge default
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r244:72b95c87a51a - - 2 files changed: 5 inserted, 2 deleted

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