# HG changeset patch # User Brian Neal # Date 1294606380 0 # Node ID 0eed8161ca3994c9a19186958b2c14a449840453 # Parent 26fc9ac9a0eb565cb6704ced6b1c91a6e513774f 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. diff -r 26fc9ac9a0eb -r 0eed8161ca39 media/js/shoutbox.js --- 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('

Welcome to SurfGuitar101.com!

'); + ++numShouts; + } + if (numShouts < 2) + { + sbBox.append('

((((( More Reverb )))))

'); + ++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');