WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. nitrous26
    Member
    Posted 2 years ago #

    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...

    http://wordpress.org/extend/plugins/javascript-chat-for-wordpress/

  2. nitrous26
    Member
    Posted 2 years ago #

    ...Too many lines of code, it got moderated out. Here's the date code again.

    In the submit function after these lines:

    jQuery('.wp_jschat_widget_form').submit(function(){
            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();

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic