Merge branch 'master' of github.com:designcreateplay/NodeBB

v1.18.x
Julian Lam 11 years ago
commit da0793c011

@ -1,3 +1,7 @@
'use strict';
/* globals app, config, define, socket, translator, templates, utils */
define(['taskbar', 'string', 'sound'], function(taskbar, S, sound) {
var module = {};
@ -5,42 +9,45 @@ define(['taskbar', 'string', 'sound'], function(taskbar, S, sound) {
module.prepareDOM = function() {
// Chats Dropdown
var chatsToggleEl = $('#chat_dropdown'),
chatsListEl = $('#chat-list'),
chatDropdownEl = chatsToggleEl.parent();
chatsListEl = $('#chat-list');
chatsToggleEl.on('click', function() {
if (chatDropdownEl.hasClass('open')) {
if (chatsToggleEl.parent().hasClass('open')) {
return;
}
socket.emit('modules.chats.list', function(err, chats) {
var numChats = chats.length,
chatEl, x, userObj;
if (err) {
return app.alertError(err.message);
}
var userObj;
chatsListEl.empty();
if (!err && numChats > 0) {
for(x = 0;x < numChats; x++) {
userObj = chats[x];
chatEl = $('<li />')
.attr('data-uid', userObj.uid)
.html('<a href="javascript:app.openChat(\''
+ userObj.username
+ '\', ' + userObj.uid
+ ');"><img src="'
+ userObj.picture
+ '" title="'
+ userObj.username
+ '" />' + userObj.username + '</a>');
chatsListEl.append(chatEl);
}
} else {
if (!chats.length) {
translator.get('modules:chat.no_active', function(str) {
chatEl = $('<li />')
$('<li />')
.addClass('no_active')
.html('<a href="#">' + str + '</a>');
chatsListEl.append(chatEl);
.html('<a href="#">' + str + '</a>')
.appendTo(chatsListEl);
});
return;
}
for(var x = 0; x<chats.length; ++x) {
userObj = chats[x];
$('<li />')
.attr('data-uid', userObj.uid)
.html('<a href="javascript:app.openChat(\'' +
userObj.username +
'\', ' + userObj.uid +
');"><img src="' +
userObj.picture +
'" title="' +
userObj.username +
'" />' + userObj.username + '</a>')
.appendTo(chatsListEl);
}
});
});
@ -72,7 +79,7 @@ define(['taskbar', 'string', 'sound'], function(taskbar, S, sound) {
sound.play('chat-incoming');
});
}
};
module.bringModalToTop = function(chatModal) {
var topZ = 0;
@ -114,7 +121,7 @@ define(['taskbar', 'string', 'sound'], function(taskbar, S, sound) {
module.createModal = function(username, touid, callback) {
templates.preload_template('chat', function() {
translator.translate(templates['chat'].parse({}), function (chatTpl) {
translator.translate(templates.chat.parse({}), function (chatTpl) {
var chatModal = $(chatTpl),
uuid = utils.generateUUID();

@ -174,7 +174,7 @@
value = $(element).val();
break;
}
templates.set($(element).attr('template-variable'), value);
});
};

@ -257,11 +257,7 @@
var data = {};
field = fieldToString(field);
data[field] = value;
db.collection('objects').update({_key:key}, {$set:data}, {upsert:true, w: 1}, function(err, result) {
if(typeof callback === 'function') {
callback(err, result);
}
});
module.setObject(key, data, callback);
};
module.getObject = function(key, callback) {
@ -480,7 +476,7 @@
}
values = values.map(function(value) {
return items.members.indexOf(value) !== -1
return items.members.indexOf(value) !== -1;
});
callback(null, values);
@ -676,36 +672,24 @@
};
module.sortedSetRank = function(key, value, callback) {
value = toString(value);
module.getSortedSetRange(key, 0, -1, function(err, result) {
if(err) {
return callback(err);
}
var rank = result.indexOf(value);
if(rank === -1) {
return callback(null, null);
}
callback(null, rank);
});
getSortedSetRank(module.getSortedSetRange, key, value, callback);
};
module.sortedSetRevRank = function(key, value, callback) {
getSortedSetRank(module.getSortedSetRevRange, key, value, callback);
};
function getSortedSetRank(method, key, value, callback) {
value = toString(value);
module.getSortedSetRevRange(key, 0, -1, function(err, result) {
method(key, 0, -1, function(err, result) {
if(err) {
return callback(err);
}
var rank = result.indexOf(value);
if(rank === -1) {
return callback(null, null);
}
callback(null, rank);
callback(null, rank !== -1 ? rank : null);
});
};
}
module.sortedSetScore = function(key, value, callback) {
value = toString(value);

Loading…
Cancel
Save