Frug / AJAX-Chat

A fully customizable web chat implemented in JavaScript, PHP and MySQL which integrates nicely with common forum systems like phpBB, MyBB, FluxBB, SMF and vBulletin. A Flash and Ruby based socket connection can be used to boost performance.
http://frug.github.io/AJAX-Chat/
548 stars 300 forks source link

Add custom command: User can change name color with /mecol #247

Closed zwiebus closed 4 years ago

zwiebus commented 8 years ago

Hello, first ecuse my "germanenglish" I use Standalone 0.8.3 with FaBrigde.js from 0.8.4 of your really nice chat. I made many changes most in css, per custom and templates.

Now i like to add a custom command in CustomAJAXChat.php like this:

// Add  change useName color
...............................................
                        case '/mecol':
                        if($this->getUserRole() == AJAX_CHAT_ADMIN || $this->getUserRole() == AJAX_CHAT_MODERATOR) || $this->getUserRole() == AJAX_CHAT_USER)  {
                        $users=$this->getCustomUsers();
                        $this->getuserName();
                        switch (ajaxChat.showHide('colorCodesContainer', 1)){
                        case userName: $col="";break;}
                        return true;
                        break;
                        default:
                        return false;
                }
        }
}

custom.js:

ajaxChat.replaceCustomCommands = function(text, textParts) {
        switch(textParts[0]) {
                case '/mecol':
                text=text.replace('/mecol', '$col');
                return '<span class="user">' + col + '</span>';
                default:
                return text;
        }
}