Saturday, 27 July 2013

jQuery AJAX Chat Script

Do you need a jQuery chat on your website like you see on Facebook and Gmail? You're in the right place!
This powerful, ready-to-use AJAX chat is easy to insert and adjust ! Try it now ! Demo is very simple, some features is not inlcuded ! If you want the full version then purchase now !
  • - Based on AJAX, PHP and MySQL
  • - Detailed documentation, MySQL sample database and demo is included with full source
  • - Cross browser supported: IE 8+, Chrome 16+, FireFox 8+, Safari 5+, Opera 11+
  • - Commented, clean code, easy to integrate and adjust
  • - It works like in Gmail or Facebook:
    • - Chat with multiple user
    • - Displays if user is typing
    • - Header of chatbox flashing if new message arrived
    • - You hear a sound if new message arrived
    • - Converts string to link if starts with http://
    • - Easy to add smileys (80 emoticons inluded)
    • - If chat window is minimized, it displays if new message arrived
    • - Displays last message's sent time after 2 minutes
    • - Store the place of the chatboxes and his state (opened,minimized, maximized)
    • - Scrolls to bottom on new message
    • - If user close window or navigates away, then user goes offline automatically
    • - Chat partner instantly receives notification if other part goes offline

Embed instant messaging into your Web App!

ChatJS is a full-featured, lightweight, Facebook style jQuery plugin for instant messaging. ChatJS also comes with a server side implementation for ASP.NET/SignalR out of the box.
Download Leave demo chat
... or visit the project at GitHub.

How it works:

The client part is divided in two JavaScript files. The file jquery.chatjs.jscontains the main jQuery plugin $.chat() andjquery.chatjs.signalradapter.js contains the adapter function needed to tell the plug-in how to interact with the server.
Once the server is set up, the client code is quite simple. These are all the options:
    // your user information
    user: {
        Id: 3,
        Name: 'John Silver',
        ProfilePictureUrl: ''
    // text displayed when the other user is typing
    typingText: ' is typing...',
    // the title for the user's list window
    titleText: 'ChatJS demo chat',
    // text displayed when there's no other users in the room
    emptyRoomText: "There's no one around here.",
    // the adapter you are using
    adapter: new SignalRAdapter()


  • Real time message sharing (Oh really?).
  • Automatically parses URLs and emoticons .
  • Automatically remembers opened windows across diferent requests (through cookies).
  • Triggers a sound notification when the user receives a message.
  • Indicates when the other user is typing.
  • Supports multiple chat rooms. If you have a multi-tenancy app you can create a room for each tenancy, for instance.
  • Supports multiple browser windows opened with the same session. They all get properly sinchronized.
  • Customizable texts. You can easily translate it to your language.
  • Both client and server code ready to be used for ASP.NET with SignalR.

Find URLs in Text, Make Links

The basic function of this is to find any URLs in the block of text and turn them into hyperlinks. It will only find URLs if they are properly formatted, meaning they have a http, https, ftp or ftps.

function autolink($str, $attributes=array()) {
 $attrs = '';
 foreach ($attributes as $attribute => $value) {
  $attrs .= " {$attribute}=\"{$value}\"";

 $str = ' ' . $str;
 $str = preg_replace(
  '$1<a href="$2"'.$attrs.'>$2</a>',
 $str = substr($str, 1);
 return $str;



string autolink ( string $str [, array $attributes = array() ] )


  1. str - La chaîne d'entrée.
  2. attributes - Optionnel. Si spécifié, ce paramètre doit être un tableau associatif de format $arr['attribute'] = $value.

Valeurs de retour

Retourne une copie de la chaîne str dont les urls ont été encapsulées dans des balises <a>.


Exemple #1 Exemple avec autolink()
$str 'A link :';
$str = autolink($str);
echo $str// A link : <a href=""></a>.
Exemple #2 Exemple avec autolink()
$str '';
$str = autolink($strarray("target"=>"_blank","rel"=>"nofollow"));
echo $str// <a href="" target="_blank" rel="nofollow"></a>