view media/js/shoutbox.js @ 271:4746df47a538

Follow on to last rev (r292) for #126. Missed updating a shoutbox template. Also the repoze.timeago package uses UTC time by default. Change this to local time for now until we decide to switch over to UTC for everything.
author Brian Neal <bgneal@gmail.com>
date Sun, 26 Sep 2010 17:42:00 +0000
parents b43e1288ff80
children 4557974db0e0
line wrap: on
line source
$(document).ready(function() {
   var submit = $('#shoutbox-submit');
   submit.click(function () {
      var input = $('#shoutbox-smiley-input');
      var msg = $.trim(input.val());
      if (msg.length == 0) {
         return false;
      }
      submit.attr('disabled', 'disabled');
      $.ajax({
         url: '/shout/shout/', 
         type: 'POST',
         data: { msg: msg },
         dataType: 'html',
         success: function (data, textStatus) {
            input.val('');
            if (data != '') {
               $('#shoutbox-shout-container').prepend(data);
               $('#shoutbox-shout-container p:first').fadeIn(2500);
            }
            submit.removeAttr('disabled');
         },
         error: function (xhr, textStatus, ex) {
             alert('Oops, an error occurred. ' + xhr.statusText + ' - ' + 
                xhr.responseText);
         }
      });
      return false;
   });
   var smilies_loaded = false;
   var smiley_frame = $('#shoutbox-smiley-frame');
   $('#shoutbox-smilies').click(function () {
      smiley_frame.toggle();
      if (!smilies_loaded) {
         smiley_frame.load('/smiley/farm/', function () {
            $('#shoutbox-busy-icon').hide();
            var txt = $("#shoutbox-smiley-input")[0];
            $('#shoutbox-smiley-frame img').click(function() {
               txt.value += ' ' + this.alt + ' ';
               txt.focus();
            });
            smilies_loaded = true;
         });
      }
   });
});