2014-06-29 06:05:33 -04:00
|
|
|
var message_url = sbRoot + '/ui/get_messages/';
|
|
|
|
$.pnotify.defaults.width = "400px";
|
|
|
|
$.pnotify.defaults.styling = "jqueryui";
|
|
|
|
$.pnotify.defaults.history = false;
|
|
|
|
$.pnotify.defaults.shadow = false;
|
|
|
|
$.pnotify.defaults.delay = 4000;
|
|
|
|
$.pnotify.defaults.maxonscreen = 5;
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
function check_notifications() {
|
2014-06-29 06:05:33 -04:00
|
|
|
var poll_interval = 5000;
|
|
|
|
$.ajax({
|
|
|
|
url: message_url,
|
|
|
|
success: function (data) {
|
|
|
|
poll_interval = 5000;
|
|
|
|
$.each(data, function (name, data) {
|
|
|
|
$.pnotify({
|
2014-06-29 23:58:34 -04:00
|
|
|
pnotify_type: data.type,
|
|
|
|
pnotify_hide: data.type == 'notice',
|
|
|
|
pnotify_title: data.title,
|
|
|
|
pnotify_text: data.message
|
2014-06-29 06:05:33 -04:00
|
|
|
});
|
2014-03-10 01:18:05 -04:00
|
|
|
});
|
2014-06-29 06:05:33 -04:00
|
|
|
},
|
|
|
|
error: function () {
|
|
|
|
poll_interval = 15000;
|
|
|
|
},
|
|
|
|
type: "GET",
|
|
|
|
dataType: "json",
|
|
|
|
complete: function () {
|
|
|
|
setTimeout(check_notifications, poll_interval);
|
|
|
|
},
|
|
|
|
timeout: 15000 // timeout every 15 secs
|
2014-03-10 01:18:05 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-06-29 06:05:33 -04:00
|
|
|
$(document).ready(function () {
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
check_notifications();
|
|
|
|
|
|
|
|
});
|