merged latest develop

This commit is contained in:
mluto 2013-01-14 18:03:26 +01:00
commit e931769dd6
65 changed files with 3281 additions and 193 deletions

View file

@ -30,6 +30,8 @@ var lastDateStr = null;
var chat = (function()
{
var isStuck = false;
var gotInitialMessages = false;
var historyPointer = 0;
var chatMentions = 0;
var self = {
show: function ()
@ -78,7 +80,7 @@ var chat = (function()
this._pad.collabClient.sendMessage({"type": "CHAT_MESSAGE", "text": text});
$("#chatinput").val("");
},
addMessage: function(msg, increment)
addMessage: function(msg, increment, isHistoryAdd)
{
//correct the time
msg.time += this._pad.clientTimeOffset;
@ -122,11 +124,19 @@ var chat = (function()
var authorName = msg.userName == null ? _('pad.userlist.unnamed') : padutils.escapeHtml(msg.userName);
<<<<<<< HEAD
var html = "";
if(lastDateStr != null && lastDateStr != dateStr)
html = "<p class='chatDaySeperator'>" + dateStr + "</p>";
html += "<p class='" + authorClass + "'><b>" + authorName + ":</b><span class='time " + authorClass + "' title='" + dateStr + "'>" + timeStr + "</span> " + text + "</p>";
$("#chattext").append(html);
=======
var html = "<p class='" + authorClass + "'><b>" + authorName + ":</b><span class='time " + authorClass + "'>" + timeStr + "</span> " + text + "</p>";
if(isHistoryAdd)
$(html).insertAfter('#chatloadmessagesbutton');
else
$("#chattext").append(html);
>>>>>>> 025c92f3464516f63c942b0dcc9fe4a8dda8e414
lastDateStr = dateStr;
@ -141,7 +151,7 @@ var chat = (function()
$("#chatcounter").text(count);
// chat throb stuff -- Just make it throw for twice as long
if(wasMentioned && !alreadyFocused)
if(wasMentioned && !alreadyFocused && !isHistoryAdd)
{ // If the user was mentioned show for twice as long and flash the browser window
$('#chatthrob').html("<b>"+authorName+"</b>" + ": " + text).show().delay(4000).hide(400);
chatMentions++;
@ -157,8 +167,8 @@ var chat = (function()
chatMentions = 0;
Tinycon.setBubble(0);
});
self.scrollDown();
if(!isHistoryAdd)
self.scrollDown();
},
init: function(pad)
{
@ -173,12 +183,23 @@ var chat = (function()
}
});
var that = this;
$.each(clientVars.chatHistory, function(i, o){
that.addMessage(o, false);
})
// initial messages are loaded in pad.js' _afterHandshake
$("#chatcounter").text(0);
$("#chatloadmessagesbutton").click(function()
{
var start = Math.max(self.historyPointer - 20, 0);
var end = self.historyPointer;
$("#chatcounter").text(clientVars.chatHistory.length);
if(start == end) // nothing to load
return;
$("#chatloadmessagesbutton").css("display", "none");
$("#chatloadmessagesball").css("display", "block");
pad.collabClient.sendMessage({"type": "GET_CHAT_MESSAGES", "start": start, "end": end});
self.historyPointer = start;
});
}
}