" + dateStr + "
"; html += " "; $("#chattext").append(html); +======= + var html = " "; + 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(""+authorName+"" + ": " + 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; + }); } } diff --git a/src/static/js/chat.js.BACKUP.4938.js b/src/static/js/chat.js.BACKUP.4938.js new file mode 100644 index 000000000..3feb5808e --- /dev/null +++ b/src/static/js/chat.js.BACKUP.4938.js @@ -0,0 +1,210 @@ +/** + * This code is mostly from the old Etherpad. Please help us to comment this code. + * This helps other people to understand this code better and helps them to improve it. + * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED + */ + +/** + * Copyright 2009 Google Inc., 2011 Peter 'Pita' Martischka (Primary Technology Ltd) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var padutils = require('./pad_utils').padutils; +var padcookie = require('./pad_cookie').padcookie; + +var Tinycon = require('tinycon/tinycon'); + +var lastDateStr = null; + +var chat = (function() +{ + var isStuck = false; + var gotInitialMessages = false; + var historyPointer = 0; + var chatMentions = 0; + var self = { + show: function () + { + $("#chaticon").hide(); + $("#chatbox").show(); + self.scrollDown(); + chatMentions = 0; + Tinycon.setBubble(0); + }, + stickToScreen: function(fromInitialCall) // Make chat stick to right hand side of screen + { + chat.show(); + if(!isStuck || fromInitialCall) { // Stick it to + padcookie.setPref("chatAlwaysVisible", true); + $('#chatbox').addClass("stickyChat"); + $('#chattext').css({"top":"0px"}); + $('#editorcontainer').css({"right":"192px", "width":"auto"}); + isStuck = true; + } else { // Unstick it + padcookie.setPref("chatAlwaysVisible", false); + $('#chatbox').removeClass("stickyChat"); + $('#chattext').css({"top":"25px"}); + $('#editorcontainer').css({"right":"0px", "width":"100%"}); + isStuck = false; + } + }, + hide: function () + { + $("#chatcounter").text("0"); + $("#chaticon").show(); + $("#chatbox").hide(); + }, + scrollDown: function() + { + if($('#chatbox').css("display") != "none"){ + if(!self.lastMessage || !self.lastMessage.position() || self.lastMessage.position().top < $('#chattext').height()) { + $('#chattext').animate({scrollTop: $('#chattext')[0].scrollHeight}, "slow"); + self.lastMessage = $('#chattext > p').eq(-1); + } + } + }, + send: function() + { + var text = $("#chatinput").val(); + this._pad.collabClient.sendMessage({"type": "CHAT_MESSAGE", "text": text}); + $("#chatinput").val(""); + }, + addMessage: function(msg, increment, isHistoryAdd) + { + //correct the time + msg.time += this._pad.clientTimeOffset; + + //create the time string + var msgDate = new Date(msg.time); + var minutes = "" + msgDate.getMinutes(); + var hours = "" + msgDate.getHours(); + var month = "" + (msgDate.getMonth() + 1); + var day = "" + msgDate.getDate(); + var year = "" + (msgDate.getYear() + 1900); + if(minutes.length == 1) + minutes = "0" + minutes ; + if(hours.length == 1) + hours = "0" + hours ; + if(month.length == 1) + month = "0" + month ; + if(day.length == 1) + day = "0" + day ; + var timeStr = hours + ":" + minutes; + var dateStr = html10n.get('timeslider.dateonlyformat', {month: month, day: day, year: year}); + + //create the authorclass + var authorClass = "author-" + msg.userId.replace(/[^a-y0-9]/g, function(c) + { + if (c == ".") return "-"; + return 'z' + c.charCodeAt(0) + 'z'; + }); + + var text = padutils.escapeHtmlWithClickableLinks(msg.text, "_blank"); + + /* Performs an action if your name is mentioned */ + var myName = $('#myusernameedit').val(); + myName = myName.toLowerCase(); + var chatText = text.toLowerCase(); + var wasMentioned = false; + if (chatText.indexOf(myName) !== -1 && myName != "undefined"){ + wasMentioned = true; + } + /* End of new action */ + + var authorName = msg.userName == null ? _('pad.userlist.unnamed') : padutils.escapeHtml(msg.userName); + +<<<<<<< HEAD + var html = ""; + if(lastDateStr != null && lastDateStr != dateStr) + html = "" + dateStr + "
"; + html += " "; + $("#chattext").append(html); +======= + var html = " "; + if(isHistoryAdd) + $(html).insertAfter('#chatloadmessagesbutton'); + else + $("#chattext").append(html); +>>>>>>> 025c92f3464516f63c942b0dcc9fe4a8dda8e414 + + lastDateStr = dateStr; + + //should we increment the counter?? + if(increment) + { + var count = Number($("#chatcounter").text()); + count++; + + // is the users focus already in the chatbox? + var alreadyFocused = $("#chatinput").is(":focus"); + + $("#chatcounter").text(count); + // chat throb stuff -- Just make it throw for twice as long + if(wasMentioned && !alreadyFocused && !isHistoryAdd) + { // If the user was mentioned show for twice as long and flash the browser window + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(4000).hide(400); + chatMentions++; + Tinycon.setBubble(chatMentions); + } + else + { + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(2000).hide(400); + } + } + // Clear the chat mentions when the user clicks on the chat input box + $('#chatinput').click(function(){ + chatMentions = 0; + Tinycon.setBubble(0); + }); + if(!isHistoryAdd) + self.scrollDown(); + }, + init: function(pad) + { + this._pad = pad; + $("#chatinput").keypress(function(evt) + { + //if the user typed enter, fire the send + if(evt.which == 13 || evt.which == 10) + { + evt.preventDefault(); + self.send(); + } + }); + + // 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; + + 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; + }); + } + } + + return self; +}()); + +exports.chat = chat; + diff --git a/src/static/js/chat.js.BACKUP.5072.js b/src/static/js/chat.js.BACKUP.5072.js new file mode 100644 index 000000000..c676a03e2 --- /dev/null +++ b/src/static/js/chat.js.BACKUP.5072.js @@ -0,0 +1,205 @@ +/** + * This code is mostly from the old Etherpad. Please help us to comment this code. + * This helps other people to understand this code better and helps them to improve it. + * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED + */ + +/** + * Copyright 2009 Google Inc., 2011 Peter 'Pita' Martischka (Primary Technology Ltd) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var padutils = require('./pad_utils').padutils; +var padcookie = require('./pad_cookie').padcookie; + +var Tinycon = require('tinycon/tinycon'); + +var lastDateStr = null; + +var chat = (function() +{ + var isStuck = false; + var gotInitialMessages = false; + var historyPointer = 0; + var chatMentions = 0; + var self = { + show: function () + { + $("#chaticon").hide(); + $("#chatbox").show(); + self.scrollDown(); + chatMentions = 0; + Tinycon.setBubble(0); + }, + stickToScreen: function(fromInitialCall) // Make chat stick to right hand side of screen + { + chat.show(); + if(!isStuck || fromInitialCall) { // Stick it to + padcookie.setPref("chatAlwaysVisible", true); + $('#chatbox').addClass("stickyChat"); + $('#chattext').css({"top":"0px"}); + $('#editorcontainer').css({"right":"192px", "width":"auto"}); + isStuck = true; + } else { // Unstick it + padcookie.setPref("chatAlwaysVisible", false); + $('#chatbox').removeClass("stickyChat"); + $('#chattext').css({"top":"25px"}); + $('#editorcontainer').css({"right":"0px", "width":"100%"}); + isStuck = false; + } + }, + hide: function () + { + $("#chatcounter").text("0"); + $("#chaticon").show(); + $("#chatbox").hide(); + }, + scrollDown: function() + { + if($('#chatbox').css("display") != "none"){ + if(!self.lastMessage || !self.lastMessage.position() || self.lastMessage.position().top < $('#chattext').height()) { + $('#chattext').animate({scrollTop: $('#chattext')[0].scrollHeight}, "slow"); + self.lastMessage = $('#chattext > p').eq(-1); + } + } + }, + send: function() + { + var text = $("#chatinput").val(); + this._pad.collabClient.sendMessage({"type": "CHAT_MESSAGE", "text": text}); + $("#chatinput").val(""); + }, + addMessage: function(msg, increment, isHistoryAdd) + { + //correct the time + msg.time += this._pad.clientTimeOffset; + + //create the time string + var msgDate = new Date(msg.time); + var minutes = "" + msgDate.getMinutes(); + var hours = "" + msgDate.getHours(); + var month = "" + (msgDate.getMonth() + 1); + var day = "" + msgDate.getDate(); + var year = "" + (msgDate.getYear() + 1900); + if(minutes.length == 1) + minutes = "0" + minutes ; + if(hours.length == 1) + hours = "0" + hours ; + if(month.length == 1) + month = "0" + month ; + if(day.length == 1) + day = "0" + day ; + var timeStr = hours + ":" + minutes; + var dateStr = html10n.get('timeslider.dateonlyformat', {month: month, day: day, year: year}); + + //create the authorclass + var authorClass = "author-" + msg.userId.replace(/[^a-y0-9]/g, function(c) + { + if (c == ".") return "-"; + return 'z' + c.charCodeAt(0) + 'z'; + }); + + var text = padutils.escapeHtmlWithClickableLinks(msg.text, "_blank"); + + /* Performs an action if your name is mentioned */ + var myName = $('#myusernameedit').val(); + myName = myName.toLowerCase(); + var chatText = text.toLowerCase(); + var wasMentioned = false; + if (chatText.indexOf(myName) !== -1 && myName != "undefined"){ + wasMentioned = true; + } + /* End of new action */ + + var authorName = msg.userName == null ? _('pad.userlist.unnamed') : padutils.escapeHtml(msg.userName); + + var html = ""; + if(lastDateStr != null && lastDateStr != dateStr) + html = "" + dateStr + "
"; + html += " "; + if(isHistoryAdd) + $(html).insertAfter('#chatloadmessagesbutton'); + else + $("#chattext").append(html); + + lastDateStr = dateStr; + + //should we increment the counter?? + if(increment) + { + var count = Number($("#chatcounter").text()); + count++; + + // is the users focus already in the chatbox? + var alreadyFocused = $("#chatinput").is(":focus"); + + $("#chatcounter").text(count); + // chat throb stuff -- Just make it throw for twice as long + if(wasMentioned && !alreadyFocused && !isHistoryAdd) + { // If the user was mentioned show for twice as long and flash the browser window + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(4000).hide(400); + chatMentions++; + Tinycon.setBubble(chatMentions); + } + else + { + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(2000).hide(400); + } + } + // Clear the chat mentions when the user clicks on the chat input box + $('#chatinput').click(function(){ + chatMentions = 0; + Tinycon.setBubble(0); + }); + if(!isHistoryAdd) + self.scrollDown(); + }, + init: function(pad) + { + this._pad = pad; + $("#chatinput").keypress(function(evt) + { + //if the user typed enter, fire the send + if(evt.which == 13 || evt.which == 10) + { + evt.preventDefault(); + self.send(); + } + }); + + // 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; + + 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; + }); + } + } + + return self; +}()); + +exports.chat = chat; + diff --git a/src/static/js/chat.js.BACKUP.5167.js b/src/static/js/chat.js.BACKUP.5167.js new file mode 100644 index 000000000..3feb5808e --- /dev/null +++ b/src/static/js/chat.js.BACKUP.5167.js @@ -0,0 +1,210 @@ +/** + * This code is mostly from the old Etherpad. Please help us to comment this code. + * This helps other people to understand this code better and helps them to improve it. + * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED + */ + +/** + * Copyright 2009 Google Inc., 2011 Peter 'Pita' Martischka (Primary Technology Ltd) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var padutils = require('./pad_utils').padutils; +var padcookie = require('./pad_cookie').padcookie; + +var Tinycon = require('tinycon/tinycon'); + +var lastDateStr = null; + +var chat = (function() +{ + var isStuck = false; + var gotInitialMessages = false; + var historyPointer = 0; + var chatMentions = 0; + var self = { + show: function () + { + $("#chaticon").hide(); + $("#chatbox").show(); + self.scrollDown(); + chatMentions = 0; + Tinycon.setBubble(0); + }, + stickToScreen: function(fromInitialCall) // Make chat stick to right hand side of screen + { + chat.show(); + if(!isStuck || fromInitialCall) { // Stick it to + padcookie.setPref("chatAlwaysVisible", true); + $('#chatbox').addClass("stickyChat"); + $('#chattext').css({"top":"0px"}); + $('#editorcontainer').css({"right":"192px", "width":"auto"}); + isStuck = true; + } else { // Unstick it + padcookie.setPref("chatAlwaysVisible", false); + $('#chatbox').removeClass("stickyChat"); + $('#chattext').css({"top":"25px"}); + $('#editorcontainer').css({"right":"0px", "width":"100%"}); + isStuck = false; + } + }, + hide: function () + { + $("#chatcounter").text("0"); + $("#chaticon").show(); + $("#chatbox").hide(); + }, + scrollDown: function() + { + if($('#chatbox').css("display") != "none"){ + if(!self.lastMessage || !self.lastMessage.position() || self.lastMessage.position().top < $('#chattext').height()) { + $('#chattext').animate({scrollTop: $('#chattext')[0].scrollHeight}, "slow"); + self.lastMessage = $('#chattext > p').eq(-1); + } + } + }, + send: function() + { + var text = $("#chatinput").val(); + this._pad.collabClient.sendMessage({"type": "CHAT_MESSAGE", "text": text}); + $("#chatinput").val(""); + }, + addMessage: function(msg, increment, isHistoryAdd) + { + //correct the time + msg.time += this._pad.clientTimeOffset; + + //create the time string + var msgDate = new Date(msg.time); + var minutes = "" + msgDate.getMinutes(); + var hours = "" + msgDate.getHours(); + var month = "" + (msgDate.getMonth() + 1); + var day = "" + msgDate.getDate(); + var year = "" + (msgDate.getYear() + 1900); + if(minutes.length == 1) + minutes = "0" + minutes ; + if(hours.length == 1) + hours = "0" + hours ; + if(month.length == 1) + month = "0" + month ; + if(day.length == 1) + day = "0" + day ; + var timeStr = hours + ":" + minutes; + var dateStr = html10n.get('timeslider.dateonlyformat', {month: month, day: day, year: year}); + + //create the authorclass + var authorClass = "author-" + msg.userId.replace(/[^a-y0-9]/g, function(c) + { + if (c == ".") return "-"; + return 'z' + c.charCodeAt(0) + 'z'; + }); + + var text = padutils.escapeHtmlWithClickableLinks(msg.text, "_blank"); + + /* Performs an action if your name is mentioned */ + var myName = $('#myusernameedit').val(); + myName = myName.toLowerCase(); + var chatText = text.toLowerCase(); + var wasMentioned = false; + if (chatText.indexOf(myName) !== -1 && myName != "undefined"){ + wasMentioned = true; + } + /* End of new action */ + + var authorName = msg.userName == null ? _('pad.userlist.unnamed') : padutils.escapeHtml(msg.userName); + +<<<<<<< HEAD + var html = ""; + if(lastDateStr != null && lastDateStr != dateStr) + html = "" + dateStr + "
"; + html += " "; + $("#chattext").append(html); +======= + var html = " "; + if(isHistoryAdd) + $(html).insertAfter('#chatloadmessagesbutton'); + else + $("#chattext").append(html); +>>>>>>> 025c92f3464516f63c942b0dcc9fe4a8dda8e414 + + lastDateStr = dateStr; + + //should we increment the counter?? + if(increment) + { + var count = Number($("#chatcounter").text()); + count++; + + // is the users focus already in the chatbox? + var alreadyFocused = $("#chatinput").is(":focus"); + + $("#chatcounter").text(count); + // chat throb stuff -- Just make it throw for twice as long + if(wasMentioned && !alreadyFocused && !isHistoryAdd) + { // If the user was mentioned show for twice as long and flash the browser window + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(4000).hide(400); + chatMentions++; + Tinycon.setBubble(chatMentions); + } + else + { + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(2000).hide(400); + } + } + // Clear the chat mentions when the user clicks on the chat input box + $('#chatinput').click(function(){ + chatMentions = 0; + Tinycon.setBubble(0); + }); + if(!isHistoryAdd) + self.scrollDown(); + }, + init: function(pad) + { + this._pad = pad; + $("#chatinput").keypress(function(evt) + { + //if the user typed enter, fire the send + if(evt.which == 13 || evt.which == 10) + { + evt.preventDefault(); + self.send(); + } + }); + + // 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; + + 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; + }); + } + } + + return self; +}()); + +exports.chat = chat; + diff --git a/src/static/js/chat.js.BASE.4938.js b/src/static/js/chat.js.BASE.4938.js new file mode 100644 index 000000000..79224e80c --- /dev/null +++ b/src/static/js/chat.js.BASE.4938.js @@ -0,0 +1,173 @@ +/** + * This code is mostly from the old Etherpad. Please help us to comment this code. + * This helps other people to understand this code better and helps them to improve it. + * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED + */ + +/** + * Copyright 2009 Google Inc., 2011 Peter 'Pita' Martischka (Primary Technology Ltd) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var padutils = require('./pad_utils').padutils; +var padcookie = require('./pad_cookie').padcookie; + +var Tinycon = require('tinycon/tinycon'); + +var chat = (function() +{ + var isStuck = false; + var chatMentions = 0; + var self = { + show: function () + { + $("#chaticon").hide(); + $("#chatbox").show(); + self.scrollDown(); + chatMentions = 0; + Tinycon.setBubble(0); + }, + stickToScreen: function(fromInitialCall) // Make chat stick to right hand side of screen + { + chat.show(); + if(!isStuck || fromInitialCall) { // Stick it to + padcookie.setPref("chatAlwaysVisible", true); + $('#chatbox').addClass("stickyChat"); + $('#chattext').css({"top":"0px"}); + $('#editorcontainer').css({"right":"192px", "width":"auto"}); + isStuck = true; + } else { // Unstick it + padcookie.setPref("chatAlwaysVisible", false); + $('#chatbox').removeClass("stickyChat"); + $('#chattext').css({"top":"25px"}); + $('#editorcontainer').css({"right":"0px", "width":"100%"}); + isStuck = false; + } + }, + hide: function () + { + $("#chatcounter").text("0"); + $("#chaticon").show(); + $("#chatbox").hide(); + }, + scrollDown: function() + { + if($('#chatbox').css("display") != "none"){ + if(!self.lastMessage || !self.lastMessage.position() || self.lastMessage.position().top < $('#chattext').height()) { + $('#chattext').animate({scrollTop: $('#chattext')[0].scrollHeight}, "slow"); + self.lastMessage = $('#chattext > p').eq(-1); + } + } + }, + send: function() + { + var text = $("#chatinput").val(); + this._pad.collabClient.sendMessage({"type": "CHAT_MESSAGE", "text": text}); + $("#chatinput").val(""); + }, + addMessage: function(msg, increment) + { + //correct the time + msg.time += this._pad.clientTimeOffset; + + //create the time string + var minutes = "" + new Date(msg.time).getMinutes(); + var hours = "" + new Date(msg.time).getHours(); + if(minutes.length == 1) + minutes = "0" + minutes ; + if(hours.length == 1) + hours = "0" + hours ; + var timeStr = hours + ":" + minutes; + + //create the authorclass + var authorClass = "author-" + msg.userId.replace(/[^a-y0-9]/g, function(c) + { + if (c == ".") return "-"; + return 'z' + c.charCodeAt(0) + 'z'; + }); + + var text = padutils.escapeHtmlWithClickableLinks(msg.text, "_blank"); + + /* Performs an action if your name is mentioned */ + var myName = $('#myusernameedit').val(); + myName = myName.toLowerCase(); + var chatText = text.toLowerCase(); + var wasMentioned = false; + if (chatText.indexOf(myName) !== -1 && myName != "undefined"){ + wasMentioned = true; + } + /* End of new action */ + + var authorName = msg.userName == null ? _('pad.userlist.unnamed') : padutils.escapeHtml(msg.userName); + + var html = " "; + $("#chattext").append(html); + + //should we increment the counter?? + if(increment) + { + var count = Number($("#chatcounter").text()); + count++; + + // is the users focus already in the chatbox? + var alreadyFocused = $("#chatinput").is(":focus"); + + $("#chatcounter").text(count); + // chat throb stuff -- Just make it throw for twice as long + if(wasMentioned && !alreadyFocused) + { // If the user was mentioned show for twice as long and flash the browser window + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(4000).hide(400); + chatMentions++; + Tinycon.setBubble(chatMentions); + } + else + { + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(2000).hide(400); + } + } + // Clear the chat mentions when the user clicks on the chat input box + $('#chatinput').click(function(){ + chatMentions = 0; + Tinycon.setBubble(0); + }); + self.scrollDown(); + + }, + init: function(pad) + { + this._pad = pad; + $("#chatinput").keypress(function(evt) + { + //if the user typed enter, fire the send + if(evt.which == 13 || evt.which == 10) + { + evt.preventDefault(); + self.send(); + } + }); + + var that = this; + $.each(clientVars.chatHistory, function(i, o){ + that.addMessage(o, false); + }) + + $("#chatcounter").text(clientVars.chatHistory.length); + } + } + + return self; +}()); + +exports.chat = chat; + diff --git a/src/static/js/chat.js.BASE.5072.js b/src/static/js/chat.js.BASE.5072.js new file mode 100644 index 000000000..79224e80c --- /dev/null +++ b/src/static/js/chat.js.BASE.5072.js @@ -0,0 +1,173 @@ +/** + * This code is mostly from the old Etherpad. Please help us to comment this code. + * This helps other people to understand this code better and helps them to improve it. + * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED + */ + +/** + * Copyright 2009 Google Inc., 2011 Peter 'Pita' Martischka (Primary Technology Ltd) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var padutils = require('./pad_utils').padutils; +var padcookie = require('./pad_cookie').padcookie; + +var Tinycon = require('tinycon/tinycon'); + +var chat = (function() +{ + var isStuck = false; + var chatMentions = 0; + var self = { + show: function () + { + $("#chaticon").hide(); + $("#chatbox").show(); + self.scrollDown(); + chatMentions = 0; + Tinycon.setBubble(0); + }, + stickToScreen: function(fromInitialCall) // Make chat stick to right hand side of screen + { + chat.show(); + if(!isStuck || fromInitialCall) { // Stick it to + padcookie.setPref("chatAlwaysVisible", true); + $('#chatbox').addClass("stickyChat"); + $('#chattext').css({"top":"0px"}); + $('#editorcontainer').css({"right":"192px", "width":"auto"}); + isStuck = true; + } else { // Unstick it + padcookie.setPref("chatAlwaysVisible", false); + $('#chatbox').removeClass("stickyChat"); + $('#chattext').css({"top":"25px"}); + $('#editorcontainer').css({"right":"0px", "width":"100%"}); + isStuck = false; + } + }, + hide: function () + { + $("#chatcounter").text("0"); + $("#chaticon").show(); + $("#chatbox").hide(); + }, + scrollDown: function() + { + if($('#chatbox').css("display") != "none"){ + if(!self.lastMessage || !self.lastMessage.position() || self.lastMessage.position().top < $('#chattext').height()) { + $('#chattext').animate({scrollTop: $('#chattext')[0].scrollHeight}, "slow"); + self.lastMessage = $('#chattext > p').eq(-1); + } + } + }, + send: function() + { + var text = $("#chatinput").val(); + this._pad.collabClient.sendMessage({"type": "CHAT_MESSAGE", "text": text}); + $("#chatinput").val(""); + }, + addMessage: function(msg, increment) + { + //correct the time + msg.time += this._pad.clientTimeOffset; + + //create the time string + var minutes = "" + new Date(msg.time).getMinutes(); + var hours = "" + new Date(msg.time).getHours(); + if(minutes.length == 1) + minutes = "0" + minutes ; + if(hours.length == 1) + hours = "0" + hours ; + var timeStr = hours + ":" + minutes; + + //create the authorclass + var authorClass = "author-" + msg.userId.replace(/[^a-y0-9]/g, function(c) + { + if (c == ".") return "-"; + return 'z' + c.charCodeAt(0) + 'z'; + }); + + var text = padutils.escapeHtmlWithClickableLinks(msg.text, "_blank"); + + /* Performs an action if your name is mentioned */ + var myName = $('#myusernameedit').val(); + myName = myName.toLowerCase(); + var chatText = text.toLowerCase(); + var wasMentioned = false; + if (chatText.indexOf(myName) !== -1 && myName != "undefined"){ + wasMentioned = true; + } + /* End of new action */ + + var authorName = msg.userName == null ? _('pad.userlist.unnamed') : padutils.escapeHtml(msg.userName); + + var html = " "; + $("#chattext").append(html); + + //should we increment the counter?? + if(increment) + { + var count = Number($("#chatcounter").text()); + count++; + + // is the users focus already in the chatbox? + var alreadyFocused = $("#chatinput").is(":focus"); + + $("#chatcounter").text(count); + // chat throb stuff -- Just make it throw for twice as long + if(wasMentioned && !alreadyFocused) + { // If the user was mentioned show for twice as long and flash the browser window + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(4000).hide(400); + chatMentions++; + Tinycon.setBubble(chatMentions); + } + else + { + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(2000).hide(400); + } + } + // Clear the chat mentions when the user clicks on the chat input box + $('#chatinput').click(function(){ + chatMentions = 0; + Tinycon.setBubble(0); + }); + self.scrollDown(); + + }, + init: function(pad) + { + this._pad = pad; + $("#chatinput").keypress(function(evt) + { + //if the user typed enter, fire the send + if(evt.which == 13 || evt.which == 10) + { + evt.preventDefault(); + self.send(); + } + }); + + var that = this; + $.each(clientVars.chatHistory, function(i, o){ + that.addMessage(o, false); + }) + + $("#chatcounter").text(clientVars.chatHistory.length); + } + } + + return self; +}()); + +exports.chat = chat; + diff --git a/src/static/js/chat.js.BASE.5167.js b/src/static/js/chat.js.BASE.5167.js new file mode 100644 index 000000000..79224e80c --- /dev/null +++ b/src/static/js/chat.js.BASE.5167.js @@ -0,0 +1,173 @@ +/** + * This code is mostly from the old Etherpad. Please help us to comment this code. + * This helps other people to understand this code better and helps them to improve it. + * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED + */ + +/** + * Copyright 2009 Google Inc., 2011 Peter 'Pita' Martischka (Primary Technology Ltd) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var padutils = require('./pad_utils').padutils; +var padcookie = require('./pad_cookie').padcookie; + +var Tinycon = require('tinycon/tinycon'); + +var chat = (function() +{ + var isStuck = false; + var chatMentions = 0; + var self = { + show: function () + { + $("#chaticon").hide(); + $("#chatbox").show(); + self.scrollDown(); + chatMentions = 0; + Tinycon.setBubble(0); + }, + stickToScreen: function(fromInitialCall) // Make chat stick to right hand side of screen + { + chat.show(); + if(!isStuck || fromInitialCall) { // Stick it to + padcookie.setPref("chatAlwaysVisible", true); + $('#chatbox').addClass("stickyChat"); + $('#chattext').css({"top":"0px"}); + $('#editorcontainer').css({"right":"192px", "width":"auto"}); + isStuck = true; + } else { // Unstick it + padcookie.setPref("chatAlwaysVisible", false); + $('#chatbox').removeClass("stickyChat"); + $('#chattext').css({"top":"25px"}); + $('#editorcontainer').css({"right":"0px", "width":"100%"}); + isStuck = false; + } + }, + hide: function () + { + $("#chatcounter").text("0"); + $("#chaticon").show(); + $("#chatbox").hide(); + }, + scrollDown: function() + { + if($('#chatbox').css("display") != "none"){ + if(!self.lastMessage || !self.lastMessage.position() || self.lastMessage.position().top < $('#chattext').height()) { + $('#chattext').animate({scrollTop: $('#chattext')[0].scrollHeight}, "slow"); + self.lastMessage = $('#chattext > p').eq(-1); + } + } + }, + send: function() + { + var text = $("#chatinput").val(); + this._pad.collabClient.sendMessage({"type": "CHAT_MESSAGE", "text": text}); + $("#chatinput").val(""); + }, + addMessage: function(msg, increment) + { + //correct the time + msg.time += this._pad.clientTimeOffset; + + //create the time string + var minutes = "" + new Date(msg.time).getMinutes(); + var hours = "" + new Date(msg.time).getHours(); + if(minutes.length == 1) + minutes = "0" + minutes ; + if(hours.length == 1) + hours = "0" + hours ; + var timeStr = hours + ":" + minutes; + + //create the authorclass + var authorClass = "author-" + msg.userId.replace(/[^a-y0-9]/g, function(c) + { + if (c == ".") return "-"; + return 'z' + c.charCodeAt(0) + 'z'; + }); + + var text = padutils.escapeHtmlWithClickableLinks(msg.text, "_blank"); + + /* Performs an action if your name is mentioned */ + var myName = $('#myusernameedit').val(); + myName = myName.toLowerCase(); + var chatText = text.toLowerCase(); + var wasMentioned = false; + if (chatText.indexOf(myName) !== -1 && myName != "undefined"){ + wasMentioned = true; + } + /* End of new action */ + + var authorName = msg.userName == null ? _('pad.userlist.unnamed') : padutils.escapeHtml(msg.userName); + + var html = " "; + $("#chattext").append(html); + + //should we increment the counter?? + if(increment) + { + var count = Number($("#chatcounter").text()); + count++; + + // is the users focus already in the chatbox? + var alreadyFocused = $("#chatinput").is(":focus"); + + $("#chatcounter").text(count); + // chat throb stuff -- Just make it throw for twice as long + if(wasMentioned && !alreadyFocused) + { // If the user was mentioned show for twice as long and flash the browser window + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(4000).hide(400); + chatMentions++; + Tinycon.setBubble(chatMentions); + } + else + { + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(2000).hide(400); + } + } + // Clear the chat mentions when the user clicks on the chat input box + $('#chatinput').click(function(){ + chatMentions = 0; + Tinycon.setBubble(0); + }); + self.scrollDown(); + + }, + init: function(pad) + { + this._pad = pad; + $("#chatinput").keypress(function(evt) + { + //if the user typed enter, fire the send + if(evt.which == 13 || evt.which == 10) + { + evt.preventDefault(); + self.send(); + } + }); + + var that = this; + $.each(clientVars.chatHistory, function(i, o){ + that.addMessage(o, false); + }) + + $("#chatcounter").text(clientVars.chatHistory.length); + } + } + + return self; +}()); + +exports.chat = chat; + diff --git a/src/static/js/chat.js.LOCAL.4938.js b/src/static/js/chat.js.LOCAL.4938.js new file mode 100644 index 000000000..e070e324b --- /dev/null +++ b/src/static/js/chat.js.LOCAL.4938.js @@ -0,0 +1,189 @@ +/** + * This code is mostly from the old Etherpad. Please help us to comment this code. + * This helps other people to understand this code better and helps them to improve it. + * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED + */ + +/** + * Copyright 2009 Google Inc., 2011 Peter 'Pita' Martischka (Primary Technology Ltd) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var padutils = require('./pad_utils').padutils; +var padcookie = require('./pad_cookie').padcookie; + +var Tinycon = require('tinycon/tinycon'); + +var lastDateStr = null; + +var chat = (function() +{ + var isStuck = false; + var chatMentions = 0; + var self = { + show: function () + { + $("#chaticon").hide(); + $("#chatbox").show(); + self.scrollDown(); + chatMentions = 0; + Tinycon.setBubble(0); + }, + stickToScreen: function(fromInitialCall) // Make chat stick to right hand side of screen + { + chat.show(); + if(!isStuck || fromInitialCall) { // Stick it to + padcookie.setPref("chatAlwaysVisible", true); + $('#chatbox').addClass("stickyChat"); + $('#chattext').css({"top":"0px"}); + $('#editorcontainer').css({"right":"192px", "width":"auto"}); + isStuck = true; + } else { // Unstick it + padcookie.setPref("chatAlwaysVisible", false); + $('#chatbox').removeClass("stickyChat"); + $('#chattext').css({"top":"25px"}); + $('#editorcontainer').css({"right":"0px", "width":"100%"}); + isStuck = false; + } + }, + hide: function () + { + $("#chatcounter").text("0"); + $("#chaticon").show(); + $("#chatbox").hide(); + }, + scrollDown: function() + { + if($('#chatbox').css("display") != "none"){ + if(!self.lastMessage || !self.lastMessage.position() || self.lastMessage.position().top < $('#chattext').height()) { + $('#chattext').animate({scrollTop: $('#chattext')[0].scrollHeight}, "slow"); + self.lastMessage = $('#chattext > p').eq(-1); + } + } + }, + send: function() + { + var text = $("#chatinput").val(); + this._pad.collabClient.sendMessage({"type": "CHAT_MESSAGE", "text": text}); + $("#chatinput").val(""); + }, + addMessage: function(msg, increment) + { + //correct the time + msg.time += this._pad.clientTimeOffset; + + //create the time string + var msgDate = new Date(msg.time); + var minutes = "" + msgDate.getMinutes(); + var hours = "" + msgDate.getHours(); + var month = "" + (msgDate.getMonth() + 1); + var day = "" + msgDate.getDate(); + var year = "" + (msgDate.getYear() + 1900); + if(minutes.length == 1) + minutes = "0" + minutes ; + if(hours.length == 1) + hours = "0" + hours ; + if(month.length == 1) + month = "0" + month ; + if(day.length == 1) + day = "0" + day ; + var timeStr = hours + ":" + minutes; + var dateStr = html10n.get('timeslider.dateonlyformat', {month: month, day: day, year: year}); + + //create the authorclass + var authorClass = "author-" + msg.userId.replace(/[^a-y0-9]/g, function(c) + { + if (c == ".") return "-"; + return 'z' + c.charCodeAt(0) + 'z'; + }); + + var text = padutils.escapeHtmlWithClickableLinks(msg.text, "_blank"); + + /* Performs an action if your name is mentioned */ + var myName = $('#myusernameedit').val(); + myName = myName.toLowerCase(); + var chatText = text.toLowerCase(); + var wasMentioned = false; + if (chatText.indexOf(myName) !== -1 && myName != "undefined"){ + wasMentioned = true; + } + /* End of new action */ + + var authorName = msg.userName == null ? _('pad.userlist.unnamed') : padutils.escapeHtml(msg.userName); + + var html = ""; + if(lastDateStr != null && lastDateStr != dateStr) + html = "" + dateStr + "
"; + html += " "; + $("#chattext").append(html); + + lastDateStr = dateStr; + + //should we increment the counter?? + if(increment) + { + var count = Number($("#chatcounter").text()); + count++; + + // is the users focus already in the chatbox? + var alreadyFocused = $("#chatinput").is(":focus"); + + $("#chatcounter").text(count); + // chat throb stuff -- Just make it throw for twice as long + if(wasMentioned && !alreadyFocused) + { // If the user was mentioned show for twice as long and flash the browser window + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(4000).hide(400); + chatMentions++; + Tinycon.setBubble(chatMentions); + } + else + { + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(2000).hide(400); + } + } + // Clear the chat mentions when the user clicks on the chat input box + $('#chatinput').click(function(){ + chatMentions = 0; + Tinycon.setBubble(0); + }); + self.scrollDown(); + + }, + init: function(pad) + { + this._pad = pad; + $("#chatinput").keypress(function(evt) + { + //if the user typed enter, fire the send + if(evt.which == 13 || evt.which == 10) + { + evt.preventDefault(); + self.send(); + } + }); + + var that = this; + $.each(clientVars.chatHistory, function(i, o){ + that.addMessage(o, false); + }) + + $("#chatcounter").text(clientVars.chatHistory.length); + } + } + + return self; +}()); + +exports.chat = chat; + diff --git a/src/static/js/chat.js.LOCAL.5072.js b/src/static/js/chat.js.LOCAL.5072.js new file mode 100644 index 000000000..e070e324b --- /dev/null +++ b/src/static/js/chat.js.LOCAL.5072.js @@ -0,0 +1,189 @@ +/** + * This code is mostly from the old Etherpad. Please help us to comment this code. + * This helps other people to understand this code better and helps them to improve it. + * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED + */ + +/** + * Copyright 2009 Google Inc., 2011 Peter 'Pita' Martischka (Primary Technology Ltd) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var padutils = require('./pad_utils').padutils; +var padcookie = require('./pad_cookie').padcookie; + +var Tinycon = require('tinycon/tinycon'); + +var lastDateStr = null; + +var chat = (function() +{ + var isStuck = false; + var chatMentions = 0; + var self = { + show: function () + { + $("#chaticon").hide(); + $("#chatbox").show(); + self.scrollDown(); + chatMentions = 0; + Tinycon.setBubble(0); + }, + stickToScreen: function(fromInitialCall) // Make chat stick to right hand side of screen + { + chat.show(); + if(!isStuck || fromInitialCall) { // Stick it to + padcookie.setPref("chatAlwaysVisible", true); + $('#chatbox').addClass("stickyChat"); + $('#chattext').css({"top":"0px"}); + $('#editorcontainer').css({"right":"192px", "width":"auto"}); + isStuck = true; + } else { // Unstick it + padcookie.setPref("chatAlwaysVisible", false); + $('#chatbox').removeClass("stickyChat"); + $('#chattext').css({"top":"25px"}); + $('#editorcontainer').css({"right":"0px", "width":"100%"}); + isStuck = false; + } + }, + hide: function () + { + $("#chatcounter").text("0"); + $("#chaticon").show(); + $("#chatbox").hide(); + }, + scrollDown: function() + { + if($('#chatbox').css("display") != "none"){ + if(!self.lastMessage || !self.lastMessage.position() || self.lastMessage.position().top < $('#chattext').height()) { + $('#chattext').animate({scrollTop: $('#chattext')[0].scrollHeight}, "slow"); + self.lastMessage = $('#chattext > p').eq(-1); + } + } + }, + send: function() + { + var text = $("#chatinput").val(); + this._pad.collabClient.sendMessage({"type": "CHAT_MESSAGE", "text": text}); + $("#chatinput").val(""); + }, + addMessage: function(msg, increment) + { + //correct the time + msg.time += this._pad.clientTimeOffset; + + //create the time string + var msgDate = new Date(msg.time); + var minutes = "" + msgDate.getMinutes(); + var hours = "" + msgDate.getHours(); + var month = "" + (msgDate.getMonth() + 1); + var day = "" + msgDate.getDate(); + var year = "" + (msgDate.getYear() + 1900); + if(minutes.length == 1) + minutes = "0" + minutes ; + if(hours.length == 1) + hours = "0" + hours ; + if(month.length == 1) + month = "0" + month ; + if(day.length == 1) + day = "0" + day ; + var timeStr = hours + ":" + minutes; + var dateStr = html10n.get('timeslider.dateonlyformat', {month: month, day: day, year: year}); + + //create the authorclass + var authorClass = "author-" + msg.userId.replace(/[^a-y0-9]/g, function(c) + { + if (c == ".") return "-"; + return 'z' + c.charCodeAt(0) + 'z'; + }); + + var text = padutils.escapeHtmlWithClickableLinks(msg.text, "_blank"); + + /* Performs an action if your name is mentioned */ + var myName = $('#myusernameedit').val(); + myName = myName.toLowerCase(); + var chatText = text.toLowerCase(); + var wasMentioned = false; + if (chatText.indexOf(myName) !== -1 && myName != "undefined"){ + wasMentioned = true; + } + /* End of new action */ + + var authorName = msg.userName == null ? _('pad.userlist.unnamed') : padutils.escapeHtml(msg.userName); + + var html = ""; + if(lastDateStr != null && lastDateStr != dateStr) + html = "" + dateStr + "
"; + html += " "; + $("#chattext").append(html); + + lastDateStr = dateStr; + + //should we increment the counter?? + if(increment) + { + var count = Number($("#chatcounter").text()); + count++; + + // is the users focus already in the chatbox? + var alreadyFocused = $("#chatinput").is(":focus"); + + $("#chatcounter").text(count); + // chat throb stuff -- Just make it throw for twice as long + if(wasMentioned && !alreadyFocused) + { // If the user was mentioned show for twice as long and flash the browser window + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(4000).hide(400); + chatMentions++; + Tinycon.setBubble(chatMentions); + } + else + { + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(2000).hide(400); + } + } + // Clear the chat mentions when the user clicks on the chat input box + $('#chatinput').click(function(){ + chatMentions = 0; + Tinycon.setBubble(0); + }); + self.scrollDown(); + + }, + init: function(pad) + { + this._pad = pad; + $("#chatinput").keypress(function(evt) + { + //if the user typed enter, fire the send + if(evt.which == 13 || evt.which == 10) + { + evt.preventDefault(); + self.send(); + } + }); + + var that = this; + $.each(clientVars.chatHistory, function(i, o){ + that.addMessage(o, false); + }) + + $("#chatcounter").text(clientVars.chatHistory.length); + } + } + + return self; +}()); + +exports.chat = chat; + diff --git a/src/static/js/chat.js.LOCAL.5167.js b/src/static/js/chat.js.LOCAL.5167.js new file mode 100644 index 000000000..e070e324b --- /dev/null +++ b/src/static/js/chat.js.LOCAL.5167.js @@ -0,0 +1,189 @@ +/** + * This code is mostly from the old Etherpad. Please help us to comment this code. + * This helps other people to understand this code better and helps them to improve it. + * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED + */ + +/** + * Copyright 2009 Google Inc., 2011 Peter 'Pita' Martischka (Primary Technology Ltd) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var padutils = require('./pad_utils').padutils; +var padcookie = require('./pad_cookie').padcookie; + +var Tinycon = require('tinycon/tinycon'); + +var lastDateStr = null; + +var chat = (function() +{ + var isStuck = false; + var chatMentions = 0; + var self = { + show: function () + { + $("#chaticon").hide(); + $("#chatbox").show(); + self.scrollDown(); + chatMentions = 0; + Tinycon.setBubble(0); + }, + stickToScreen: function(fromInitialCall) // Make chat stick to right hand side of screen + { + chat.show(); + if(!isStuck || fromInitialCall) { // Stick it to + padcookie.setPref("chatAlwaysVisible", true); + $('#chatbox').addClass("stickyChat"); + $('#chattext').css({"top":"0px"}); + $('#editorcontainer').css({"right":"192px", "width":"auto"}); + isStuck = true; + } else { // Unstick it + padcookie.setPref("chatAlwaysVisible", false); + $('#chatbox').removeClass("stickyChat"); + $('#chattext').css({"top":"25px"}); + $('#editorcontainer').css({"right":"0px", "width":"100%"}); + isStuck = false; + } + }, + hide: function () + { + $("#chatcounter").text("0"); + $("#chaticon").show(); + $("#chatbox").hide(); + }, + scrollDown: function() + { + if($('#chatbox').css("display") != "none"){ + if(!self.lastMessage || !self.lastMessage.position() || self.lastMessage.position().top < $('#chattext').height()) { + $('#chattext').animate({scrollTop: $('#chattext')[0].scrollHeight}, "slow"); + self.lastMessage = $('#chattext > p').eq(-1); + } + } + }, + send: function() + { + var text = $("#chatinput").val(); + this._pad.collabClient.sendMessage({"type": "CHAT_MESSAGE", "text": text}); + $("#chatinput").val(""); + }, + addMessage: function(msg, increment) + { + //correct the time + msg.time += this._pad.clientTimeOffset; + + //create the time string + var msgDate = new Date(msg.time); + var minutes = "" + msgDate.getMinutes(); + var hours = "" + msgDate.getHours(); + var month = "" + (msgDate.getMonth() + 1); + var day = "" + msgDate.getDate(); + var year = "" + (msgDate.getYear() + 1900); + if(minutes.length == 1) + minutes = "0" + minutes ; + if(hours.length == 1) + hours = "0" + hours ; + if(month.length == 1) + month = "0" + month ; + if(day.length == 1) + day = "0" + day ; + var timeStr = hours + ":" + minutes; + var dateStr = html10n.get('timeslider.dateonlyformat', {month: month, day: day, year: year}); + + //create the authorclass + var authorClass = "author-" + msg.userId.replace(/[^a-y0-9]/g, function(c) + { + if (c == ".") return "-"; + return 'z' + c.charCodeAt(0) + 'z'; + }); + + var text = padutils.escapeHtmlWithClickableLinks(msg.text, "_blank"); + + /* Performs an action if your name is mentioned */ + var myName = $('#myusernameedit').val(); + myName = myName.toLowerCase(); + var chatText = text.toLowerCase(); + var wasMentioned = false; + if (chatText.indexOf(myName) !== -1 && myName != "undefined"){ + wasMentioned = true; + } + /* End of new action */ + + var authorName = msg.userName == null ? _('pad.userlist.unnamed') : padutils.escapeHtml(msg.userName); + + var html = ""; + if(lastDateStr != null && lastDateStr != dateStr) + html = "" + dateStr + "
"; + html += " "; + $("#chattext").append(html); + + lastDateStr = dateStr; + + //should we increment the counter?? + if(increment) + { + var count = Number($("#chatcounter").text()); + count++; + + // is the users focus already in the chatbox? + var alreadyFocused = $("#chatinput").is(":focus"); + + $("#chatcounter").text(count); + // chat throb stuff -- Just make it throw for twice as long + if(wasMentioned && !alreadyFocused) + { // If the user was mentioned show for twice as long and flash the browser window + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(4000).hide(400); + chatMentions++; + Tinycon.setBubble(chatMentions); + } + else + { + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(2000).hide(400); + } + } + // Clear the chat mentions when the user clicks on the chat input box + $('#chatinput').click(function(){ + chatMentions = 0; + Tinycon.setBubble(0); + }); + self.scrollDown(); + + }, + init: function(pad) + { + this._pad = pad; + $("#chatinput").keypress(function(evt) + { + //if the user typed enter, fire the send + if(evt.which == 13 || evt.which == 10) + { + evt.preventDefault(); + self.send(); + } + }); + + var that = this; + $.each(clientVars.chatHistory, function(i, o){ + that.addMessage(o, false); + }) + + $("#chatcounter").text(clientVars.chatHistory.length); + } + } + + return self; +}()); + +exports.chat = chat; + diff --git a/src/static/js/chat.js.REMOTE.4938.js b/src/static/js/chat.js.REMOTE.4938.js new file mode 100644 index 000000000..01adc34e8 --- /dev/null +++ b/src/static/js/chat.js.REMOTE.4938.js @@ -0,0 +1,189 @@ +/** + * This code is mostly from the old Etherpad. Please help us to comment this code. + * This helps other people to understand this code better and helps them to improve it. + * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED + */ + +/** + * Copyright 2009 Google Inc., 2011 Peter 'Pita' Martischka (Primary Technology Ltd) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var padutils = require('./pad_utils').padutils; +var padcookie = require('./pad_cookie').padcookie; + +var Tinycon = require('tinycon/tinycon'); + +var chat = (function() +{ + var isStuck = false; + var gotInitialMessages = false; + var historyPointer = 0; + var chatMentions = 0; + var self = { + show: function () + { + $("#chaticon").hide(); + $("#chatbox").show(); + self.scrollDown(); + chatMentions = 0; + Tinycon.setBubble(0); + }, + stickToScreen: function(fromInitialCall) // Make chat stick to right hand side of screen + { + chat.show(); + if(!isStuck || fromInitialCall) { // Stick it to + padcookie.setPref("chatAlwaysVisible", true); + $('#chatbox').addClass("stickyChat"); + $('#chattext').css({"top":"0px"}); + $('#editorcontainer').css({"right":"192px", "width":"auto"}); + isStuck = true; + } else { // Unstick it + padcookie.setPref("chatAlwaysVisible", false); + $('#chatbox').removeClass("stickyChat"); + $('#chattext').css({"top":"25px"}); + $('#editorcontainer').css({"right":"0px", "width":"100%"}); + isStuck = false; + } + }, + hide: function () + { + $("#chatcounter").text("0"); + $("#chaticon").show(); + $("#chatbox").hide(); + }, + scrollDown: function() + { + if($('#chatbox').css("display") != "none"){ + if(!self.lastMessage || !self.lastMessage.position() || self.lastMessage.position().top < $('#chattext').height()) { + $('#chattext').animate({scrollTop: $('#chattext')[0].scrollHeight}, "slow"); + self.lastMessage = $('#chattext > p').eq(-1); + } + } + }, + send: function() + { + var text = $("#chatinput").val(); + this._pad.collabClient.sendMessage({"type": "CHAT_MESSAGE", "text": text}); + $("#chatinput").val(""); + }, + addMessage: function(msg, increment, isHistoryAdd) + { + //correct the time + msg.time += this._pad.clientTimeOffset; + + //create the time string + var minutes = "" + new Date(msg.time).getMinutes(); + var hours = "" + new Date(msg.time).getHours(); + if(minutes.length == 1) + minutes = "0" + minutes ; + if(hours.length == 1) + hours = "0" + hours ; + var timeStr = hours + ":" + minutes; + + //create the authorclass + var authorClass = "author-" + msg.userId.replace(/[^a-y0-9]/g, function(c) + { + if (c == ".") return "-"; + return 'z' + c.charCodeAt(0) + 'z'; + }); + + var text = padutils.escapeHtmlWithClickableLinks(msg.text, "_blank"); + + /* Performs an action if your name is mentioned */ + var myName = $('#myusernameedit').val(); + myName = myName.toLowerCase(); + var chatText = text.toLowerCase(); + var wasMentioned = false; + if (chatText.indexOf(myName) !== -1 && myName != "undefined"){ + wasMentioned = true; + } + /* End of new action */ + + var authorName = msg.userName == null ? _('pad.userlist.unnamed') : padutils.escapeHtml(msg.userName); + + var html = " "; + if(isHistoryAdd) + $(html).insertAfter('#chatloadmessagesbutton'); + else + $("#chattext").append(html); + + //should we increment the counter?? + if(increment) + { + var count = Number($("#chatcounter").text()); + count++; + + // is the users focus already in the chatbox? + var alreadyFocused = $("#chatinput").is(":focus"); + + $("#chatcounter").text(count); + // chat throb stuff -- Just make it throw for twice as long + if(wasMentioned && !alreadyFocused && !isHistoryAdd) + { // If the user was mentioned show for twice as long and flash the browser window + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(4000).hide(400); + chatMentions++; + Tinycon.setBubble(chatMentions); + } + else + { + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(2000).hide(400); + } + } + // Clear the chat mentions when the user clicks on the chat input box + $('#chatinput').click(function(){ + chatMentions = 0; + Tinycon.setBubble(0); + }); + if(!isHistoryAdd) + self.scrollDown(); + }, + init: function(pad) + { + this._pad = pad; + $("#chatinput").keypress(function(evt) + { + //if the user typed enter, fire the send + if(evt.which == 13 || evt.which == 10) + { + evt.preventDefault(); + self.send(); + } + }); + + // 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; + + 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; + }); + } + } + + return self; +}()); + +exports.chat = chat; + diff --git a/src/static/js/chat.js.REMOTE.5072.js b/src/static/js/chat.js.REMOTE.5072.js new file mode 100644 index 000000000..01adc34e8 --- /dev/null +++ b/src/static/js/chat.js.REMOTE.5072.js @@ -0,0 +1,189 @@ +/** + * This code is mostly from the old Etherpad. Please help us to comment this code. + * This helps other people to understand this code better and helps them to improve it. + * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED + */ + +/** + * Copyright 2009 Google Inc., 2011 Peter 'Pita' Martischka (Primary Technology Ltd) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var padutils = require('./pad_utils').padutils; +var padcookie = require('./pad_cookie').padcookie; + +var Tinycon = require('tinycon/tinycon'); + +var chat = (function() +{ + var isStuck = false; + var gotInitialMessages = false; + var historyPointer = 0; + var chatMentions = 0; + var self = { + show: function () + { + $("#chaticon").hide(); + $("#chatbox").show(); + self.scrollDown(); + chatMentions = 0; + Tinycon.setBubble(0); + }, + stickToScreen: function(fromInitialCall) // Make chat stick to right hand side of screen + { + chat.show(); + if(!isStuck || fromInitialCall) { // Stick it to + padcookie.setPref("chatAlwaysVisible", true); + $('#chatbox').addClass("stickyChat"); + $('#chattext').css({"top":"0px"}); + $('#editorcontainer').css({"right":"192px", "width":"auto"}); + isStuck = true; + } else { // Unstick it + padcookie.setPref("chatAlwaysVisible", false); + $('#chatbox').removeClass("stickyChat"); + $('#chattext').css({"top":"25px"}); + $('#editorcontainer').css({"right":"0px", "width":"100%"}); + isStuck = false; + } + }, + hide: function () + { + $("#chatcounter").text("0"); + $("#chaticon").show(); + $("#chatbox").hide(); + }, + scrollDown: function() + { + if($('#chatbox').css("display") != "none"){ + if(!self.lastMessage || !self.lastMessage.position() || self.lastMessage.position().top < $('#chattext').height()) { + $('#chattext').animate({scrollTop: $('#chattext')[0].scrollHeight}, "slow"); + self.lastMessage = $('#chattext > p').eq(-1); + } + } + }, + send: function() + { + var text = $("#chatinput").val(); + this._pad.collabClient.sendMessage({"type": "CHAT_MESSAGE", "text": text}); + $("#chatinput").val(""); + }, + addMessage: function(msg, increment, isHistoryAdd) + { + //correct the time + msg.time += this._pad.clientTimeOffset; + + //create the time string + var minutes = "" + new Date(msg.time).getMinutes(); + var hours = "" + new Date(msg.time).getHours(); + if(minutes.length == 1) + minutes = "0" + minutes ; + if(hours.length == 1) + hours = "0" + hours ; + var timeStr = hours + ":" + minutes; + + //create the authorclass + var authorClass = "author-" + msg.userId.replace(/[^a-y0-9]/g, function(c) + { + if (c == ".") return "-"; + return 'z' + c.charCodeAt(0) + 'z'; + }); + + var text = padutils.escapeHtmlWithClickableLinks(msg.text, "_blank"); + + /* Performs an action if your name is mentioned */ + var myName = $('#myusernameedit').val(); + myName = myName.toLowerCase(); + var chatText = text.toLowerCase(); + var wasMentioned = false; + if (chatText.indexOf(myName) !== -1 && myName != "undefined"){ + wasMentioned = true; + } + /* End of new action */ + + var authorName = msg.userName == null ? _('pad.userlist.unnamed') : padutils.escapeHtml(msg.userName); + + var html = " "; + if(isHistoryAdd) + $(html).insertAfter('#chatloadmessagesbutton'); + else + $("#chattext").append(html); + + //should we increment the counter?? + if(increment) + { + var count = Number($("#chatcounter").text()); + count++; + + // is the users focus already in the chatbox? + var alreadyFocused = $("#chatinput").is(":focus"); + + $("#chatcounter").text(count); + // chat throb stuff -- Just make it throw for twice as long + if(wasMentioned && !alreadyFocused && !isHistoryAdd) + { // If the user was mentioned show for twice as long and flash the browser window + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(4000).hide(400); + chatMentions++; + Tinycon.setBubble(chatMentions); + } + else + { + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(2000).hide(400); + } + } + // Clear the chat mentions when the user clicks on the chat input box + $('#chatinput').click(function(){ + chatMentions = 0; + Tinycon.setBubble(0); + }); + if(!isHistoryAdd) + self.scrollDown(); + }, + init: function(pad) + { + this._pad = pad; + $("#chatinput").keypress(function(evt) + { + //if the user typed enter, fire the send + if(evt.which == 13 || evt.which == 10) + { + evt.preventDefault(); + self.send(); + } + }); + + // 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; + + 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; + }); + } + } + + return self; +}()); + +exports.chat = chat; + diff --git a/src/static/js/chat.js.REMOTE.5167.js b/src/static/js/chat.js.REMOTE.5167.js new file mode 100644 index 000000000..01adc34e8 --- /dev/null +++ b/src/static/js/chat.js.REMOTE.5167.js @@ -0,0 +1,189 @@ +/** + * This code is mostly from the old Etherpad. Please help us to comment this code. + * This helps other people to understand this code better and helps them to improve it. + * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED + */ + +/** + * Copyright 2009 Google Inc., 2011 Peter 'Pita' Martischka (Primary Technology Ltd) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var padutils = require('./pad_utils').padutils; +var padcookie = require('./pad_cookie').padcookie; + +var Tinycon = require('tinycon/tinycon'); + +var chat = (function() +{ + var isStuck = false; + var gotInitialMessages = false; + var historyPointer = 0; + var chatMentions = 0; + var self = { + show: function () + { + $("#chaticon").hide(); + $("#chatbox").show(); + self.scrollDown(); + chatMentions = 0; + Tinycon.setBubble(0); + }, + stickToScreen: function(fromInitialCall) // Make chat stick to right hand side of screen + { + chat.show(); + if(!isStuck || fromInitialCall) { // Stick it to + padcookie.setPref("chatAlwaysVisible", true); + $('#chatbox').addClass("stickyChat"); + $('#chattext').css({"top":"0px"}); + $('#editorcontainer').css({"right":"192px", "width":"auto"}); + isStuck = true; + } else { // Unstick it + padcookie.setPref("chatAlwaysVisible", false); + $('#chatbox').removeClass("stickyChat"); + $('#chattext').css({"top":"25px"}); + $('#editorcontainer').css({"right":"0px", "width":"100%"}); + isStuck = false; + } + }, + hide: function () + { + $("#chatcounter").text("0"); + $("#chaticon").show(); + $("#chatbox").hide(); + }, + scrollDown: function() + { + if($('#chatbox').css("display") != "none"){ + if(!self.lastMessage || !self.lastMessage.position() || self.lastMessage.position().top < $('#chattext').height()) { + $('#chattext').animate({scrollTop: $('#chattext')[0].scrollHeight}, "slow"); + self.lastMessage = $('#chattext > p').eq(-1); + } + } + }, + send: function() + { + var text = $("#chatinput").val(); + this._pad.collabClient.sendMessage({"type": "CHAT_MESSAGE", "text": text}); + $("#chatinput").val(""); + }, + addMessage: function(msg, increment, isHistoryAdd) + { + //correct the time + msg.time += this._pad.clientTimeOffset; + + //create the time string + var minutes = "" + new Date(msg.time).getMinutes(); + var hours = "" + new Date(msg.time).getHours(); + if(minutes.length == 1) + minutes = "0" + minutes ; + if(hours.length == 1) + hours = "0" + hours ; + var timeStr = hours + ":" + minutes; + + //create the authorclass + var authorClass = "author-" + msg.userId.replace(/[^a-y0-9]/g, function(c) + { + if (c == ".") return "-"; + return 'z' + c.charCodeAt(0) + 'z'; + }); + + var text = padutils.escapeHtmlWithClickableLinks(msg.text, "_blank"); + + /* Performs an action if your name is mentioned */ + var myName = $('#myusernameedit').val(); + myName = myName.toLowerCase(); + var chatText = text.toLowerCase(); + var wasMentioned = false; + if (chatText.indexOf(myName) !== -1 && myName != "undefined"){ + wasMentioned = true; + } + /* End of new action */ + + var authorName = msg.userName == null ? _('pad.userlist.unnamed') : padutils.escapeHtml(msg.userName); + + var html = " "; + if(isHistoryAdd) + $(html).insertAfter('#chatloadmessagesbutton'); + else + $("#chattext").append(html); + + //should we increment the counter?? + if(increment) + { + var count = Number($("#chatcounter").text()); + count++; + + // is the users focus already in the chatbox? + var alreadyFocused = $("#chatinput").is(":focus"); + + $("#chatcounter").text(count); + // chat throb stuff -- Just make it throw for twice as long + if(wasMentioned && !alreadyFocused && !isHistoryAdd) + { // If the user was mentioned show for twice as long and flash the browser window + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(4000).hide(400); + chatMentions++; + Tinycon.setBubble(chatMentions); + } + else + { + $('#chatthrob').html(""+authorName+"" + ": " + text).show().delay(2000).hide(400); + } + } + // Clear the chat mentions when the user clicks on the chat input box + $('#chatinput').click(function(){ + chatMentions = 0; + Tinycon.setBubble(0); + }); + if(!isHistoryAdd) + self.scrollDown(); + }, + init: function(pad) + { + this._pad = pad; + $("#chatinput").keypress(function(evt) + { + //if the user typed enter, fire the send + if(evt.which == 13 || evt.which == 10) + { + evt.preventDefault(); + self.send(); + } + }); + + // 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; + + 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; + }); + } + } + + return self; +}()); + +exports.chat = chat; + diff --git a/src/static/js/collab_client.js b/src/static/js/collab_client.js index b700fc490..7df0b7114 100644 --- a/src/static/js/collab_client.js +++ b/src/static/js/collab_client.js @@ -400,7 +400,29 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) } else if (msg.type == "CHAT_MESSAGE") { - chat.addMessage(msg, true); + chat.addMessage(msg, true, false); + } + else if (msg.type == "CHAT_MESSAGES") + { + for(var i = msg.messages.length - 1; i >= 0; i--) + { + chat.addMessage(msg.messages[i], true, true); + } + if(!chat.gotInitalMessages) + { + chat.scrollDown(); + chat.gotInitalMessages = true; + chat.historyPointer = clientVars.chatHead - msg.messages.length; + } + + // messages are loaded, so hide the loading-ball + $("#chatloadmessagesball").css("display", "none"); + + // there are less than 100 messages or we reached the top + if(chat.historyPointer <= 0) + $("#chatloadmessagesbutton").css("display", "none"); + else // there are still more messages, re-show the load-button + $("#chatloadmessagesbutton").css("display", "block"); } else if (msg.type == "SERVER_MESSAGE") { diff --git a/src/static/js/html10n.js b/src/static/js/html10n.js index bb4acf819..c45f4b31b 100644 --- a/src/static/js/html10n.js +++ b/src/static/js/html10n.js @@ -23,10 +23,10 @@ window.html10n = (function(window, document, undefined) { var console = window.console function interceptConsole(method){ - var original = console[method] - if (!console) return function() {} + var original = console[method] + // do sneaky stuff if (original.bind){ // Do this for normal browsers diff --git a/src/static/js/pad.js b/src/static/js/pad.js index a02d7abbc..64d8b42b8 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -555,6 +555,18 @@ var pad = { pad.collabClient.setOnChannelStateChange(pad.handleChannelStateChange); pad.collabClient.setOnInternalAction(pad.handleCollabAction); + // load initial chat-messages + 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 + { + $("#chatloadmessagesbutton").css("display", "none"); + } + function postAceInit() { padeditbar.init(); diff --git a/src/templates/index.html b/src/templates/index.html index 668b7abe2..f0e1beb3f 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -33,9 +33,9 @@ - - - + + + <% e.end_block(); %> + + + + <% e.begin_block("body"); %> @@ -368,7 +368,10 @@