2014-09-15 14:03:52 +04:00
|
|
|
var notification = {
|
|
|
|
init: function() {
|
2014-09-19 13:58:29 +04:00
|
|
|
$(".notification-count").click(function() {
|
|
|
|
wide.bottomWindowTab.setCurrent("notification");
|
|
|
|
$(".bottom-window-group .notification").focus();
|
|
|
|
$(this).hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
this._initWS();
|
|
|
|
},
|
|
|
|
_initWS: function() {
|
|
|
|
var notificationWS = new WebSocket(config.channel.shell + '/notification/ws?sid=' + config.wideSessionId);
|
2014-09-15 14:03:52 +04:00
|
|
|
|
2014-09-19 13:58:29 +04:00
|
|
|
notificationWS.onopen = function() {
|
|
|
|
console.log('[notification onopen] connected');
|
|
|
|
};
|
|
|
|
|
|
|
|
notificationWS.onmessage = function(e) {
|
|
|
|
var data = JSON.parse(e.data);
|
|
|
|
if ('init-notification' !== data.cmd) {
|
|
|
|
$(".notification-count").show();
|
|
|
|
$('.bottom-window-group .notification').text(
|
|
|
|
$('.bottom-window-group .notification').text() + data.output);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
notificationWS.onclose = function(e) {
|
|
|
|
console.log('[notification onclose] disconnected (' + e.code + ')');
|
|
|
|
delete notificationWS;
|
|
|
|
};
|
|
|
|
|
|
|
|
notificationWS.onerror = function(e) {
|
|
|
|
console.log('[notification onerror] ' + e);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|