diff --git a/sendOnEnter.js b/sendOnEnter.js index dca318d..f3b760c 100644 --- a/sendOnEnter.js +++ b/sendOnEnter.js @@ -7,4 +7,22 @@ jQuery(document).ready(function(){ jQuery('#send').click(); } }); -}) \ No newline at end of file +}) + +// We don't yet have an API to know when an element is updated, so we'll poll +// and if we find the content has changed, we'll scroll down to show the new +// comments. +var oldContent = null; +window.setInterval(function() { + var elem = document.getElementById('chat'); + if (oldContent != elem.innerHTML){ + scrollToBottom(); + } + oldContent = elem.innerHTML; +}, 300); + +// Scroll to the bottom of the chat window. +function scrollToBottom(){ + var elem = document.getElementById('chat'); + elem.scrollTop = elem.scrollHeight; +} \ No newline at end of file diff --git a/shinychat.css b/shinychat.css index 17a4116..2323890 100644 --- a/shinychat.css +++ b/shinychat.css @@ -1,6 +1,8 @@ #chat { padding: .5em; border: 1px solid #777; + height: 300px; + overflow: scroll; } .user-change, .user-exit, .user-enter { @@ -26,4 +28,13 @@ color: #AAA; text-align: right; padding: 30px 0; -} \ No newline at end of file +} + +html, body { + height: 100%; +} + +.fill { + min-height: 100%; + height: 100%; +}