Support » Plugin: Javascript Chat for WordPress » [Plugin: Javascript Chat for WordPress] Javascript Chat Plutin Fixes (autoscroll, date/time)

  • This is really a great, lightweight chat plugin and it deserves more credit. I’ve modified it a bit to suit my site’s needs and I’ll share a couple of fixes.

    Autoscrolling the box was built in, but broke with newer versions of wordpress with jquery 1.6 and above. To fix this, edit the /javascript/wp_jschat.js file and change line 29 to:
    t.find('.wp_jschat_widget_text').prop({scrollTop: t.find('.wp_jschat_widget_text').prop('scrollHeight')});
    the “attr” tag is depreciated and “prop” replaces the functionality.

    To make it really fancy, you can stick in the animate function to make it slowly scroll and look like you paid money for the plugin or something by replacing line 29 with this:
    t.find('.wp_jschat_widget_text').animate({scrollTop: t.find('.wp_jschat_widget_text').prop('scrollHeight')}, 3000);

    To add in a time and date(just as part of the message, not grabbing from the db… cause I’m lazy), change the submit function on about line 49-78 to this:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Hope this helps…

Viewing 1 replies (of 1 total)
  • …Too many lines of code, it got moderated out. Here’s the date code again.

    In the submit function after these lines:

            var t = jQuery(this);
            var obj = {};

    add this:

    var currentDate = new Date();var day = currentDate.getDate();var month = currentDate.getMonth() + 1;var year = currentDate.getFullYear();var hours = currentDate.getHours();var minutes = currentDate.getMinutes();
    if(minutes<10){	obj.wp_jschat_text = ' '+month+'/'+day+'/'+year+' '+hours+":0"+minutes+' : '+t.find('.wp_jschat_text').val(); }
    else{ obj.wp_jschat_text = ' '+month+'/'+day+'/'+year+' '+hours+":"+minutes+' : '+t.find('.wp_jschat_text').val(); }

    and delete this line:
    obj.wp_jschat_text = t.find('.wp_jschat_text').val();

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Javascript Chat for WordPress] Javascript Chat Plutin Fixes (autoscroll, date/time)’ is closed to new replies.