Show More
Commit Description:
a cleaner, testable way to log out user after contest changed
Commit Description:
a cleaner, testable way to log out user after contest changed
References:
File last commit:
Show/Diff file:
Action:
public/javascripts/announcement_refresh.js
| 41 lines
| 1.0 KiB
| application/javascript
| JavascriptLexer
|
|
r192 | |||
var Announcement = { | ||||
mostRecentId: 0, | ||||
|
r243 | refreshUrl: '/main/announcements', | ||
|
r192 | setMostRecentId: function(id) { | ||
Announcement.mostRecentId = id; | ||||
}, | ||||
updateRecentId: function(id) { | ||||
if(Announcement.mostRecentId < id) | ||||
Announcement.mostRecentId = id; | ||||
}, | ||||
refreshAnnouncement: function() { | ||||
|
r243 | var url = Announcement.refreshUrl; | ||
|
r192 | new Ajax.Request(url, { | ||
method: 'get', | ||||
parameters: { recent: Announcement.mostRecentId }, | ||||
onSuccess: function(transport) { | ||||
|
r295 | if((transport.status == 200) && | ||
(transport.responseText.match(/\S/)!=null)) { | ||||
|
r226 | var announcementBody = $("announcementbox-body"); | ||
announcementBody.insert({ top: transport.responseText }); | ||||
var announcementBoxes = $$(".announcementbox"); | ||||
if(announcementBoxes.length!=0) | ||||
announcementBoxes[0].show(); | ||||
|
r295 | Announcement.registerRefreshEventTimer(); | ||
|
r226 | } | ||
|
r192 | } | ||
}); | ||||
}, | ||||
registerRefreshEventTimer: function() { | ||||
setTimeout(function () { | ||||
Announcement.refreshAnnouncement(); | ||||
}, 30000); | ||||
} | ||||
|
r226 | }; | ||