Event handling

The visitor's chat window in Netrox SC triggers events that can be handled in Javascript code on the site. Event handling allows for interfering with the chat window behavior and correcting standard actions or modifying them altogether.

There are two ways to connect your own handler to a Netrox SC widget event on your site. If you are using the jQuery library, you can bind handlers using this library's default methods. Otherwise you can bind handler functions via the nsc_API object.

Attention! You cannot combine two event handling methods described here. You have to select one of the two and stick to it within the document (site page). If nsc_API has been defined, jQuery events will not be triggered.

Handling events using the jQuery library

If a jQuery library is being used on your site, you can use the .on() method to connect the event listeners to the document object. Aside from the mostly regular entry, the advantage of this method is that you can bind several handlers for one event and use namespaces for flexible connection and disconnection of handlers. All events are named in the lower case with the prefix netrox instead of on. The first argument, passed to handler is the event object, while the following arguments are the Netrox SC event data in the order given in this manual.

Example

function newMessageHandler(event, messages) {
    alert("new message");
}
$(document).on("netroxnewmessage", newMessageHandler);
              

Handling events using the nsc_API object

Handlers can also be created by defining the nsc_API JavaScript object on the page. Each method of this object is a handler for a certain event. It is not obligatory to define methods for all events. Do only for those ones you are planning to handle.

Examples

  1. Simultaneous initialization of the API object with several event handlers:
    nsc_API = {
        onNewMessage: function() {
            // Your actions upon arrival of new message 
        },
        onOffline: function() {
            // Your actions upon going offline
        },
    
        /*
         *    More event handlers
         */
    
        onOnline: function() {
            // Your actions upon going online
        }
    };              
  2. Adding methods to an already-initialized API object
    nsc_API = { /* ... */ };
    
    nsc_API.onNewMessage = function() {
        // Your actions upon arrival of new message 
    };
    nsc_API.onOffline = function() {
        // Your actions upon going offline
    };
        /*
         *    More event handlers
         */              

Netrox SC events available for processing:

Имя событияОписание
onAfterClose

Minimization of the chat widget for the Pop-Up and Slider types. Activates upon the finishing of the closing process animation.

onAfterOpen

Following the opening of chat widget for Pop-Up and Slider types. Activates upon the finishing of the opening process animation.

onAfterTriggerFilter

Activates upon completion of the filter's automatic actions.

onBeforeInit

The event activates before the chat widget initializes.

onBeforeNewMessage

It activates before rendering a new chat message, offering the ability to modify it.

onBeforeTriggerFilter

Triggers prior to the starting of the automatic action filter.

onChatClear

The event is trigged after the visitor has cleared the chat using the corresponding chat widget tool.

onClose

The event of minimization of the chat widget for the Pop-Up and Slider types.

onEmailChatError

Is triggered when the visitor sends the chat to their own email address.

onEmailChatSend

The event of the visitor's sending of the chat to their own email address.

onInit

Is triggered after the chat widget initializes in one of the statuses (Online/Offline).

onMessageSend

The message sending event in the online chat widget window. This has to return the "true" or "false" value (and ether send or not send a message accordingly).

onNewMessage

You can perform some actions upon the event of arrival of new chat message.

onOffline

Triggers when the chat widget goes offline. This refers to when the last operator leaves the system.

onOfflineMessageSend

The event of sending a message in the offline form.

onOnline

Activates when the chat widget goes online. In other words, it activates when there are operators available to chat.

onOpen

The event of opening/advancement of the "Slider" and "Pop-up" chat widgets.

onSoundSwitch

Activates when the visitor turns the chat widget sounds on/off.

onVisitorInfoChange

The event of modification of visitor data input fields.

onWindowResize

The event enables you to additionally handle the visitor's changing of the chat widget dimensions.


All rights reserved. Copyright © 2017 Netrox SC
Host CMS