notifications socket callbacks

This commit is contained in:
Julian Lam
2014-01-16 20:29:11 -05:00
parent e95da77fe8
commit 111776d878
3 changed files with 7 additions and 9 deletions

View File

@@ -11,14 +11,14 @@ define(function() {
notifTrigger.addEventListener('click', function(e) {
e.preventDefault();
if (notifContainer.className.indexOf('open') === -1) {
socket.emit('notifications.get', null, function(data) {
socket.emit('notifications.get', null, function(err, data) {
var notifFrag = document.createDocumentFragment(),
notifEl = document.createElement('li'),
numRead = data.read.length,
numUnread = data.unread.length,
x;
notifList.innerHTML = '';
if ((data.read.length + data.unread.length) > 0) {
if (!err && (data.read.length + data.unread.length) > 0) {
for (x = 0; x < numUnread; x++) {
notifEl.setAttribute('data-nid', data.unread[x].nid);
notifEl.className = 'unread';