bgneal@12: $(document).ready(function() { bgneal@272: bgneal@272: var numShouts = $('#shoutbox-shout-container > p').size(); bgneal@296: var sbBox = $('#shoutbox-shout-container'); bgneal@296: bgneal@296: if (numShouts < 2) bgneal@296: { bgneal@296: sbBox.append('

Welcome to SurfGuitar101.com!

'); bgneal@296: ++numShouts; bgneal@296: } bgneal@296: if (numShouts < 2) bgneal@296: { bgneal@296: sbBox.append('

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

'); bgneal@296: ++numShouts; bgneal@296: } bgneal@296: bgneal@272: var sbCycleOpts = null; bgneal@296: var sbCycle = sbBox.cycle({ bgneal@272: fx: 'scrollUp', bgneal@272: timeout: 5000, bgneal@272: pause: 1, bgneal@272: next: '#shoutbox-next', bgneal@272: prev: '#shoutbox-prev', bgneal@272: before: function(curr, next, opts) { bgneal@272: if (!opts.addSlide || sbCycleOpts) return; bgneal@272: sbCycleOpts = opts; bgneal@272: } bgneal@272: }); bgneal@272: function addShout(shout) { bgneal@272: ++numShouts; bgneal@272: sbCycleOpts.addSlide(shout); bgneal@296: sbBox.cycle(numShouts - 1); bgneal@272: } bgneal@272: bgneal@12: var submit = $('#shoutbox-submit'); bgneal@12: submit.click(function () { bgneal@12: var input = $('#shoutbox-smiley-input'); bgneal@27: var msg = $.trim(input.val()); bgneal@12: if (msg.length == 0) { bgneal@12: return false; bgneal@12: } bgneal@12: submit.attr('disabled', 'disabled'); bgneal@150: $.ajax({ bgneal@150: url: '/shout/shout/', bgneal@150: type: 'POST', bgneal@150: data: { msg: msg }, bgneal@150: dataType: 'html', bgneal@150: success: function (data, textStatus) { bgneal@12: input.val(''); bgneal@12: if (data != '') { bgneal@272: addShout(data); bgneal@12: } bgneal@12: submit.removeAttr('disabled'); bgneal@12: }, bgneal@150: error: function (xhr, textStatus, ex) { bgneal@150: alert('Oops, an error occurred. ' + xhr.statusText + ' - ' + bgneal@150: xhr.responseText); bgneal@150: } bgneal@150: }); bgneal@12: return false; bgneal@12: }); bgneal@12: var smilies_loaded = false; bgneal@12: var smiley_frame = $('#shoutbox-smiley-frame'); bgneal@12: $('#shoutbox-smilies').click(function () { bgneal@12: smiley_frame.toggle(); bgneal@12: if (!smilies_loaded) { bgneal@12: smiley_frame.load('/smiley/farm/', function () { bgneal@12: $('#shoutbox-busy-icon').hide(); bgneal@123: var txt = $("#shoutbox-smiley-input")[0]; bgneal@123: $('#shoutbox-smiley-frame img').click(function() { bgneal@123: txt.value += ' ' + this.alt + ' '; bgneal@123: txt.focus(); bgneal@123: }); bgneal@12: smilies_loaded = true; bgneal@12: }); bgneal@12: } bgneal@12: }); bgneal@12: });