Change live notification to polling
This commit is contained in:
parent
2539b3e071
commit
425354a2de
7 changed files with 70 additions and 58 deletions
|
@ -324,10 +324,34 @@ window.register_notify = function (type, options) {
|
|||
};
|
||||
|
||||
window.notify_clarification = function(msg) {
|
||||
var message = `Problem ${msg.problem_label} (${msg.problem_name}):\n` + msg.body;
|
||||
var message = `Problem ${msg.order} (${msg.problem__name}):\n` + msg.description;
|
||||
alert(message);
|
||||
}
|
||||
|
||||
window.register_contest_notification = function(url) {
|
||||
function get_clarifications() {
|
||||
$.get(url)
|
||||
.fail(function() {
|
||||
console.log("Fail to update clarification");
|
||||
})
|
||||
.done(function(data) {
|
||||
for (i of data) {
|
||||
window.notify_clarification(i);
|
||||
}
|
||||
if (data.status == 403) {
|
||||
console.log("Fail to retrieve data");
|
||||
}
|
||||
else {
|
||||
$('#chat-online-content').html(data).find('.toggle').each(function () {
|
||||
register_toggle($(this));
|
||||
});;
|
||||
}
|
||||
})
|
||||
}
|
||||
get_clarifications();
|
||||
setInterval(get_clarifications, 60 * 1000);
|
||||
}
|
||||
|
||||
$(function () {
|
||||
// Close dismissable boxes
|
||||
$("a.close").click(function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue