Code Monkey home page Code Monkey logo

q2a-chat-room's People

Contributors

svivian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

q2a-chat-room's Issues

Add a class to the message send by me

I want to show the chat bubble in left and right(for me)
I'm only asking for just add the class to chat item which is send by me. I can do the rest css work by my self.

also can you change the order of the elements like order: name, message, time instead of name, time, message.

thank you

How to add a filter for swear words and insults?

I got one user calling another one 'stupid' within the chat.

That's why I like to add a chat filter to ******* blank out such words.

How/where would I implement the filter?

The words list can be within the chat.php file, no extra mysql entry necessary.

Tip: Add target="_blank" to all posted links in chat

Well, users complained that when opening links they lose the chat...

That's why I suggest changing line:

return qa_html_convert_urls($msg);

to:

return qa_html_convert_urls($msg,true);

which will open all posted links in a new window.

How to make the chat public (for reading, not posting)?

Hi Scott,

I am digging deeper into your work, very nice coding.

Issue I am stuck now: I would like to display the chat history even for anonymous users.

What I tried in qa-chat.php:

before line: $qa_content['error'] = qa_insert_login_links((...
I added: $qa_content['custom_form'] = '<ul id="qa-chat-list"></ul>';

from line: if ( $lastid !== null ) {
I added:

if ( $lastid !== null ) {
  $isAnonymous = false;`
  if ( !$this->user_perms_view() ) {
    // return;
    $isAnonymous = true;
  }

and line: $this->update_activity( $lastid==0 );
I enclosed with (to prevent mysql error due to activity update):

if(!$isAnonymous) {
    $this->update_activity( $lastid==0 );
}

But it is not working!
Could you help me please :)

Any way to let anonymous participate in chat?

Hi Scott, what has to be changed to allow anonymous participating in chat as well?

Basically, I am not sure if this is a good idea because of misuse, but would like to know.

Thanks.

Tip: Add Thumbnail to youtube link

Add to qa-chat.js:

/* YOUTUBE thumbnail */
$.extend({
  jYoutube: function( url, size ){
    if(url === null){ return ""; }

    size = (size === null) ? "big" : size;
    var vid;
    var results;

    results = url.match("[\\?&amp;]v=([^&amp;#]*)");

    vid = ( results === null ) ? url : results[1];

    if(size == "small"){
      return "http://img.youtube.com/vi/"+vid+"/2.jpg";
    }else {
      return "http://img.youtube.com/vi/"+vid+"/0.jpg";
    }
  }
});

add after:
$('#qa-chat-list').prepend($msg);
$msg.slideDown('fast');

the line:
add_youtube_thumbnail();

and also add these functions:

// add youtube-URL to thumbnail img
function add_youtube_thumbnail() {
    $('.qa-chat-item-data a').each( function() { 
        if( ytVidId($(this).attr('href')) && !$(this).find('img').length) {
            var ytThumbnail = $.jYoutube('http://www.youtube.com/watch?v='+ytVidId($(this).attr('href')), 'big'); // or 'small'
            $(this).prepend("<img src='" + ytThumbnail + "' /><br />Video: ");
        }

    });
}
function ytVidId(url) {
    var p = /^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/;
    return (url.match(p)) ? RegExp.$1 : false;
}

404 error

My chat room is not at forum.learningwithexperts,ml/chat

Chat Room Extended

A plugin for Question2Answer that allows users to live-chat. Original source by Scott, extended by q2apro.

Added features:

number of new messages in tab title
sound notification
clear chat button for each user
parsing/embed of youtube and soundcloud links
weekly chat history email to admin
manual chat history triggered by admin

โ†’ https://github.com/q2apro/q2a-chat-extended

Bug: Field 'lastposted' doesn't have a default value

Error with Mysql 8:

PHP Question2Answer MySQL query error 1364: Field 'lastposted' doesn't have a default value - Query: INSERT INTO qa_chat_users (userid, lastpolled) VALUES (36509, NOW()) ON DUPLICATE KEY UPDATE lastpolled=NOW()

Suggested fix: Give a default value NOW() to lastposted.

Multi Room

Hi,

it's is possbile to add a multi room with privileges, than we can switch the room including history

Ex: Multi Room change on same windows

tchat

Room User (reading only) : view by all
Room Members confirmed (Read and post) view by members, moderateur / admin
Room Moderator/Admin : (Read, post, delete, history, ban) view by moderateur / admin

Thank you
Very nice plugin

JS-Code for New Chat Message Counter

I implemented a counter that shows the number of new chat messages in the page title, i.e. in the tab of the browser is is displaying: "(2) Chat - My Forum"

Code you need:

// add a message to the list
function qa_chat_add_message( post )
{
    var $ex_post = $( '#qa-chat-id-'+post.postid );
    if ( $ex_post.length == 0 )
    {
        var $msg = $( Tmpl.message( post ) );
        $('.qa-chat-item-when', $msg).timeago();
        $('#qa-chat-list').prepend($msg);
        $msg.slideDown('fast');

        // write count of new chat messages in page title, do not regard if post is not by user himself
        if(!userPostsMessage) {
            var rowCount = $('ul#qa-chat-list li:visible').length - userPostsCount;
            if(startEventsVisible) { rowCount -= startEventsCount - userPostsCount; }
            $('title').text('('+rowCount+') '+ pagetitle);
        }
    }

    /*if ( $('.qa-chat-item').length > 80 )
        $('.qa-chat-item:nth-child(n+81)').remove();
    */
}

var startEventsVisible = true;
var startEventsCount = 0;
var firstLoad = true; 
var pagetitle = 'Mathe-Chat - Gute-Mathe-Fragen';
var userPostsMessage = false; 
var userPostsCount = 0;

// fetch all new messages
function qa_chat_fetch_messages()
{
    $.ajax({
        type: 'post',
        data: { ajax_get_messages: lastid },
        success: function(response) {
            var lines = response.split("\n");
            if ( lines[0] != 'QA_AJAX_RESPONSE' || lines[1] == 0 )
                return false;

            cUser.id = lines[1];

            var posts = $.parseJSON( lines[2] ).reverse();
            for ( var i in posts ) {
                qa_chat_add_message( posts[i] );
                lastid = posts[i].postid;
            }

            // update active users
            if ( lines[3] ) {
                var users = $.parseJSON( lines[3] );
                qa_chat_update_users( users );
            }

            if(firstLoad) {
                startEventsCount = $('ul#qa-chat-list li:visible').length;
                $('title').text('(0) '+ pagetitle);
                firstLoad = false;
            }

        }
    });

// adding a message to the chat
$('#qa-chat-form').submit( function() {
    var message = $('#message').val();
    if ( message.length == 0 )
        return false;

    $('#qa-chat-form input').attr({ disabled: 'disabled' });

    $.ajax({
        type: 'post',
        data: { ajax_add_message: message, ajax_add_lastid: '0' },
        success: function(response) {
            $('#qa-chat-form input').removeAttr('disabled');
            $('#message').val('').focus();

            var lines = response.split("\n");
            if ( lines[0] != 'QA_AJAX_RESPONSE' ) {
                alert("There was a server error, please try again in a few minutes");
                return false;
            }
            if ( lines[1] == 0 ) {
                alert("Error: "+lines[2]);
                return false;
            }

            userPostsMessage = true;
            userPostsCount++;
            var post = $.parseJSON( lines[2] );
            qa_chat_add_message( post );
            userPostsMessage = false;
            cUser.idle = false;
        }
    });

    return false;
} );

Cannot find the code where URL is parsed to <a href="..."></a>

I searched all the plugin's code but cannot find it.

Where do you parse a link like https://github.com/svivian/ to <a href="https://github.com/svivian/">https://github.com/svivian/</a> as it is done now.

I would like to add a target="_blank".

Thanks.

Plugin name missing in admin section

I followed your first step

Download and extract the files to your plugins folder (e.g. qa-plugins/chat).
But i cant find the Plugin name in Admin section
Go to Admin > Plugin and click the link to set up the database tables. ?? why !?

Request: Option for admin to "edit" or "delete" a post

I would like to see an option for admin only to "edit" or "delete" a post.

Scenario: I wrote something in chat and wanted to change it later on. It is a waste of time to go to phpmyadmin each time!

Any idea for a quick and clean implementation? Ajax? Extra div?

Chat

Seemed to be having problems setting the url for the chat. I followed the instructing to the letter. Chat is in the root/plugins/chat folder I used the url mysite.net/chat

Feature Request: Show user avatar in place of usernames or both

Currently only usernames show in chat and in sidebar but many users recognize each other with their avatars so it would be good if user avatars are shown.

I know this feature is already been requested before but there is no update on that feature so I thought to make a new issue for this.

Tip: Parse Image links to IMG tag

To convert image links to tag, just do the following in qa-chat.js:

After:
$('#qa-chat-list').prepend($msg);
$msg.slideDown('fast');
add line:
parse_url_to_img();

below function qa_chat_add_message( post )
add function:

// parse img-URL to img tag
function parse_url_to_img() {
    $('.qa-chat-item-data a').each( function() { 
        var regexr = "(https?:\/\/.*\.(?:png|jp?g|gif))";
        if( $(this).attr('href').match(regexr) != null ) {
            $(this).empty();
            $(this).append("<img src='" + $(this).attr('href') + "' />");
        }
    });
}

Why is 'posted' saved with gmdate() (Greenwich Mean Time)?

Hi Scott, could you tell me what your reason is to use GMT instead of server time (date())?

From qa-chat.php:

    // create dates for database
    $now = time();
    $this->dates = array(
        'posted' => gmdate( 'Y-m-d H:i:s', $now ),
        'posted_utc' => gmdate( 'Y-m-d\TH:i:s\Z', $now ),
    );

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.