changeset 296:0eed8161ca39

Fixing #138. Shoutbox scroller breaks down if there aren't at least 2 things to scroll. Added some dummy shouts on the client side if the shout database is empty.
author Brian Neal <bgneal@gmail.com>
date Sun, 09 Jan 2011 20:53:00 +0000
parents 26fc9ac9a0eb
children 69498a43e636
files media/js/shoutbox.js
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/media/js/shoutbox.js	Sat Jan 08 22:04:54 2011 +0000
+++ b/media/js/shoutbox.js	Sun Jan 09 20:53:00 2011 +0000
@@ -1,8 +1,21 @@
 $(document).ready(function() {
 
    var numShouts = $('#shoutbox-shout-container > p').size(); 
+   var sbBox = $('#shoutbox-shout-container');
+
+   if (numShouts < 2)
+   {
+      sbBox.append('<p>Welcome to SurfGuitar101.com!</p>');
+      ++numShouts;
+   }
+   if (numShouts < 2)
+   {
+      sbBox.append('<p>((((( More Reverb )))))</p>');
+      ++numShouts;
+   }
+
    var sbCycleOpts = null;
-   var sbCycle = $('#shoutbox-shout-container').cycle({
+   var sbCycle = sbBox.cycle({
       fx: 'scrollUp',
       timeout: 5000,
       pause: 1,
@@ -16,7 +29,7 @@
    function addShout(shout) {
       ++numShouts;
       sbCycleOpts.addSlide(shout);
-      $('#shoutbox-shout-container').cycle(numShouts - 1);
+      sbBox.cycle(numShouts - 1);
    }
 
    var submit = $('#shoutbox-submit');