diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index c2a0a30479..2edf4659e6 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -287,12 +287,14 @@ var username = $(this).parents('li').attr('data-username'); var touid = $(this).parents('li').attr('data-uid'); - require(['chat'], function(chat){ + if(username === app.username || !app.username) + return; + + require(['chat'], function(chat) { var chatModal = chat.createModalIfDoesntExist(username, touid); chatModal.show(); chat.bringModalToTop(chatModal); }); - }); ajaxify.register_events([ diff --git a/public/src/modules/chat.js b/public/src/modules/chat.js index 7c866fcce4..3a5decb4bc 100644 --- a/public/src/modules/chat.js +++ b/public/src/modules/chat.js @@ -1,8 +1,7 @@ define(['taskbar'], function(taskbar) { - + var module = {}; - module.bringModalToTop = function(chatModal) { var topZ = 0; $('.modal').each(function() { @@ -11,7 +10,7 @@ define(['taskbar'], function(taskbar) { topZ = thisZ; } }); - chatModal.css('zIndex', topZ+1); + chatModal.css('zIndex', topZ + 1); } module.createModalIfDoesntExist = function(username, touid) { @@ -39,7 +38,9 @@ define(['taskbar'], function(taskbar) { module.bringModalToTop(chatModal); }); - addSendHandler(chatModal, touid); + addSendHandler(chatModal, touid); + + getChatMessages(chatModal, touid); } taskbar.push('chat', chatModal.attr('UUID'), {title:'chat with '+username}); @@ -58,6 +59,15 @@ define(['taskbar'], function(taskbar) { taskbar.minimize('chat', uuid); } + function getChatMessages(chatModal, touid) { + socket.emit('getChatMessages', {touid:touid}, function(messages) { + console.log(messages); + for(var i = 0; i