[Javascript] Little modification on Wordpress plugin

The problem

  • This is a chat javascript
  • When you receive a message and the chat is minimized, it turns to
  • blue (.addClass(‘notify’))
  • When you receive a message and the chat is active, you only receive a sound warning
  • When you are chatting to user A, and user B sends a message, you only receive a sound warning

I would like to have a notification (besides sound) when I receive a message, can someone try to help me in this one? ._.

I think the closed chat notification happens here:


if(needsNotify) {
	    		if(!$chatElements.container.hasClass('open')){
					if(_parseBoolean(data.settings.admin_bar)){
						$chatElements.adminTitleBar.parent().addClass('notify');
					} else {
						$chatElements.titleBar.addClass('notify');
					}

		    	}
	    	}

By removing the first “if” I got a notification when receiving a message, wich is good:


if(needsNotify) {

					if(_parseBoolean(data.settings.admin_bar)){
						$chatElements.adminTitleBar.parent().addClass('notify');
					} else {
						$chatElements.titleBar.addClass('notify');
					}

	    	}

Next steps:

  • Notify only when chat isn’t the active one
  • Change title, instead of “Chatting with: username”, it flashes a message like “username sent you a message”, with the blue notification class too

Can someone try to give me a light here? -

Thanks!

http://pastebin.com/38emXMZu