Skip to content

Commit

Permalink
Add some alerts at the moment the activity starts
Browse files Browse the repository at this point in the history
  • Loading branch information
D Coetzee committed Dec 5, 2014
1 parent cd729a9 commit c43006f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions public/moocchat_global_notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ startSessionTime2 = Date.UTC(2014, 11, 6, 1, 30);
endSessionTime2 = Date.UTC(2014, 11, 6, 2, 30);

var interval;
var started = true; // Default to true so that the alert isn't shown repeatedly as they navigate between pages during the event

function update() {
$.ajax({
Expand All @@ -47,17 +48,24 @@ function update() {
var now = json.current_timestamp_utc * 1000; // Convert sec to ms
var divContent = divNowContent;
if (now <= startSessionTime1) {
started = false;
diff1 = startSessionTime1 - now;
diff2 = startSessionTime2 - now;
divContent = '<div style="width: 100%; background-color: #eeffee; bottom; padding-bottom: 3px; margin-left:auto; margin-right:auto; border: 1px solid #88dd88;">The two Interactive Quiz 3 Review Activity events are occurring in ' + timeIntervalToString(diff1) + ' and ' + timeIntervalToString(diff2) + '. Plan to attend one if you can!</div>';
} else if (now >= endSessionTime1 && now <= startSessionTime2) {
started = false;
diff2 = startSessionTime2 - now;
divContent = '<div style="width: 100%; background-color: #eeffee; bottom; padding-bottom: 3px; margin-left:auto; margin-right:auto; border: 1px solid #88dd88;">The only remaining Interactive Quiz 3 Review Activity is occurring in ' + timeIntervalToString(diff2) +'. Plan to be there if you can!</div>';
} else if (now > endSessionTime2) {
// All over now, hide and cancel notification
$("#moocchat_global_notification").hide();
clearInterval(interval);
return;
} else {
if (!started) {
alert("The Interactive Quiz 3 Review Activity has just started!\nClick the link in the green box at the top of\nthis page to join us now.");
}
started = true;
}
$("#moocchat_global_notification").html(divContent);
}
Expand Down

0 comments on commit c43006f

Please sign in to comment.