diff options
author | mluto <m@luto.at> | 2013-01-07 17:36:03 +0100 |
---|---|---|
committer | mluto <m@luto.at> | 2013-01-07 17:36:03 +0100 |
commit | 5f81daed0ae9b8e147d00724516b5002dc77f289 (patch) | |
tree | e6fcf69b7ae455654865a9154b16428348d90c79 /src/static | |
parent | 5592c4b0feb42082ab50e1c90753c28e5cd79334 (diff) | |
download | etherpad-lite-5f81daed0ae9b8e147d00724516b5002dc77f289.zip |
Added link to load more chat-messages using new GET_CHAT_MESSAGES
Diffstat (limited to 'src/static')
-rw-r--r-- | src/static/css/pad.css | 5 | ||||
-rw-r--r-- | src/static/js/chat.js | 16 | ||||
-rw-r--r-- | src/static/js/collab_client.js | 5 | ||||
-rw-r--r-- | src/static/js/pad.js | 13 |
4 files changed, 34 insertions, 5 deletions
diff --git a/src/static/css/pad.css b/src/static/css/pad.css index bb8da99b..a36a7ff9 100644 --- a/src/static/css/pad.css +++ b/src/static/css/pad.css @@ -488,6 +488,11 @@ table#otheruserstable { -ms-overflow-x: hidden; overflow-x: hidden; } +#chatloadmessages +{ + color: blue; + text-decoration: underline; +} #chatinputbox { padding: 3px 2px; position: absolute; diff --git a/src/static/js/chat.js b/src/static/js/chat.js index 19c4cba8..2136c56c 100644 --- a/src/static/js/chat.js +++ b/src/static/js/chat.js @@ -29,6 +29,7 @@ var chat = (function() { var isStuck = false; var gotInitialMessages = false; + var historyPointer = 0; var chatMentions = 0; var self = { show: function () @@ -114,7 +115,7 @@ var chat = (function() var html = "<p class='" + authorClass + "'><b>" + authorName + ":</b><span class='time " + authorClass + "'>" + timeStr + "</span> " + text + "</p>"; if(isHistoryAdd) - $("#chattext").prepend(html); + $(html).insertAfter('#chatloadmessages'); else $("#chattext").append(html); @@ -164,6 +165,19 @@ var chat = (function() // initial messages are loaded in pad.js' _afterHandshake $("#chatcounter").text(0); + $("#chatloadmessages").click(function() + { + var start = Math.max(self.historyPointer - 100, 0); + var end = self.historyPointer; + + if(start == end) // nothing to load + return; + if(start == 0) // reached the top + $("#chatloadmessages").css("display", "none"); + + pad.collabClient.sendMessage({"type": "GET_CHAT_MESSAGES", "start": start, "end": end}); + self.historyPointer = start; + }); } } diff --git a/src/static/js/collab_client.js b/src/static/js/collab_client.js index 29c40482..902301d5 100644 --- a/src/static/js/collab_client.js +++ b/src/static/js/collab_client.js @@ -411,7 +411,10 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) if(!chat.gotInitalMessages) { chat.scrollDown(); - chat.gotInitalMessages = true; + chat.gotInitalMessages = true; + chat.historyPointer = clientVars.chatHead - msg.messages.length; + if(chat.historyPointer == -1) // there are less than 100 messages + $("#chatloadmessages").css("display", "none"); } } else if (msg.type == "SERVER_MESSAGE") diff --git a/src/static/js/pad.js b/src/static/js/pad.js index 56a1dad7..57aa2834 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -556,9 +556,16 @@ var pad = { pad.collabClient.setOnInternalAction(pad.handleCollabAction); // load initial chat-messages - var chatHead = clientVars.chatHead; - var start = Math.max(chatHead - 100, 0); - pad.collabClient.sendMessage({"type": "GET_CHAT_MESSAGES", "start": start, "end": chatHead}); + if(clientVars.chatHead != -1) + { + var chatHead = clientVars.chatHead; + var start = Math.max(chatHead - 100, 0); + pad.collabClient.sendMessage({"type": "GET_CHAT_MESSAGES", "start": start, "end": chatHead}); + } + else // there are no messages + { + $("#chatloadmessages").css("display", "none"); + } function postAceInit() { |