###

``

## $sanitize(html)

#### Parameters

- `string` html :

  Html input.

#### Returns

``string`` :

Sanitized html.

#### Examples

    <example module="sanitizeExample" deps="angular-sanitize.js">
    <file name="index.html">
    <script>
    angular.module('sanitizeExample', ['ngSanitize'])
    .controller('ExampleController', ['$scope', '$sce', function($scope, $sce) {
    $scope.snippet =
    '<p style="color:blue">an html\n' +
    '<em onmouseover="this.textContent=\'PWN3D!\'">click here</em>\n' +
    'snippet</p>';
    $scope.deliberatelyTrustDangerousSnippet = function() {
    return $sce.trustAsHtml($scope.snippet);
    };
    }]);
    </script>
    <div ng-controller="ExampleController">
    Snippet: <textarea ng-model="snippet" cols="60" rows="3"></textarea>
    <table>
    <tr>
    <td>Directive</td>
    <td>How</td>
    <td>Source</td>
    <td>Rendered</td>
    </tr>
    <tr id="bind-html-with-sanitize">
    <td>ng-bind-html</td>
    <td>Automatically uses $sanitize</td>
    <td><pre>&lt;div ng-bind-html="snippet"&gt;<br/>&lt;/div&gt;</pre></td>
    <td><div ng-bind-html="snippet"></div></td>
    </tr>
    <tr id="bind-html-with-trust">
    <td>ng-bind-html</td>
    <td>Bypass $sanitize by explicitly trusting the dangerous value</td>
    <td>
    <pre>&lt;div ng-bind-html="deliberatelyTrustDangerousSnippet()"&gt;
    &lt;/div&gt;</pre>
    </td>
    <td><div ng-bind-html="deliberatelyTrustDangerousSnippet()"></div></td>
    </tr>
    <tr id="bind-default">
    <td>ng-bind</td>
    <td>Automatically escapes</td>
    <td><pre>&lt;div ng-bind="snippet"&gt;<br/>&lt;/div&gt;</pre></td>
    <td><div ng-bind="snippet"></div></td>
    </tr>
    </table>
    </div>
    </file>
    <file name="protractor.js" type="protractor">
    it('should sanitize the html snippet by default', function() {
    expect(element(by.css('#bind-html-with-sanitize div')).getInnerHtml()).
    toBe('<p>an html\n<em>click here</em>\nsnippet</p>');
    });

    it('should inline raw snippet if bound to a trusted value', function() {
    expect(element(by.css('#bind-html-with-trust div')).getInnerHtml()).
    toBe("<p style=\"color:blue\">an html\n" +
    "<em onmouseover=\"this.textContent='PWN3D!'\">click here</em>\n" +
    "snippet</p>");
    });

    it('should escape snippet without any filter', function() {
    expect(element(by.css('#bind-default div')).getInnerHtml()).
    toBe("&lt;p style=\"color:blue\"&gt;an html\n" +
    "&lt;em onmouseover=\"this.textContent='PWN3D!'\"&gt;click here&lt;/em&gt;\n" +
    "snippet&lt;/p&gt;");
    });

    it('should update', function() {
    element(by.model('snippet')).clear();
    element(by.model('snippet')).sendKeys('new <b onclick="alert(1)">text</b>');
    expect(element(by.css('#bind-html-with-sanitize div')).getInnerHtml()).
    toBe('new <b>text</b>');
    expect(element(by.css('#bind-html-with-trust div')).getInnerHtml()).toBe(
    'new <b onclick="alert(1)">text</b>');
    expect(element(by.css('#bind-default div')).getInnerHtml()).toBe(
    "new &lt;b onclick=\"alert(1)\"&gt;text&lt;/b&gt;");
    });
    </file>
    </example>

## addLostConnection(connectionId)

Add lost connections to localStorage variable last_connections

#### Parameters

- connectionId :

## addParticipantToGroup

Add a new contact to group

## confirmBlockContact(isBlocking)

Confirm block contact action

#### Parameters

- isBlocking :

## confirmDeleteConversation

Confirm action Delete group

## confirmLeaveGroup

Confirm sign out from group action

## createGroup

Create a room group

## editRoomName(name)

Edit room group information

#### Parameters

- name :

## isTyping(event)

Notify when someone is typing a message.

#### Parameters

- event :

## removeParticipantsFromGroup(participant)

Add a new contact to group

#### Parameters

- participant :

## setReadMessages

Set all messages on current popup as read

## toggleBlock(isBlocking)

Toggle block contact action

#### Parameters

- isBlocking :

## attrGetter(name, scope)

#### Parameters

- name :
- scope :

## attrGetter(name, scope)

#### Parameters

- name :
- scope :

## attrGetter(name, scope)

#### Parameters

- name :
- scope :

## attrGetter(name, scope)

#### Parameters

- name :
- scope :

## attrGetter(name, scope)

#### Parameters

- name :
- scope :

## attrGetter(name, scope)

#### Parameters

- name :
- scope :

## attrGetter(name, scope)

#### Parameters

- name :
- scope :

## attrGetter(name, scope)

#### Parameters

- name :
- scope :

## block(blocked, onsuccess, onerror)

Block a contact.

#### Parameters

- blocked :
- onsuccess :
- onerror :

#### Returns

``Array``

## blockContact

Block a contact

## blockContact(data)

Add contact to the blocked list

#### Parameters

- data :

## calculateAspectRatioFit(srcWidth, srcHeight, maxWidth, maxHeight, centerCrop)

Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922

#### Parameters

- `Number` srcWidth :

  Source area width

- `Number` srcHeight :

  Source area height

- `Number` maxWidth :

  Nestable area maximum available width

- `Number` maxHeight :

  Nestable area maximum available height

- centerCrop :

#### Returns

``Object`` :

{ width, height }

## connectApi(user)

Connect to Chat API

#### Parameters

- user :

#### Returns

``Promise``

## connectHub(transp)

Connect to Chat Hub

#### Parameters

- transp :

#### Returns

``Promise``

## createGroup(groupName)

Create group

#### Parameters

- groupName :

## createGroup(groupName)

Create group

#### Parameters

- groupName :

## getMoreContacts

Return an Array of contacts passing a limit and offset (pagination).

#### Returns

``Array``

## getMoreContacts

Return an Array of contacts passing a limit and offset (pagination).

#### Returns

``Array``

## getMoreConversations

Fetch conversations list

#### Returns

``Array``

## getMoreConversations

Fetch conversations list

#### Returns

``Array``

## decodeEntities(value)

decodes all entities into regular string

#### Parameters

- value :

#### Returns

``string`` :

A string with decoded entities.

## deleteConversation

Delete a room group

## directive

## dropConnections(connections)

Drop lost connections

#### Parameters

- connections :

#### Returns

``Promise``

## encodeEntities(value)

Escapes all potentially dangerous characters, so that the resulting string can be safely inserted into attribute or element text.

#### Parameters

- value :

#### Returns

``string`` :

escaped text

## filterList(arr1, arr2, prop)

Return second array param without same objects from first array param

#### Parameters

- arr1 :
- arr2 :
- prop :

#### Returns

``Array``

## getAPIToken

Get API Token

#### Returns

``String``

## getAPIURL

Get API URL

#### Returns

``String``

## getBlockedList(callback)

Return an Array of blocked contacts.

#### Parameters

- callback :

#### Returns

``Array``

## getBlockedList

Return an Array of blocked contacts.

#### Returns

``Array``

## getBlockedList(params)

Get a list of blocked contacts

#### Parameters

- params :

#### Returns

``Array``

## getBlockedList(onsuccess, onerror)

Return an Array of blocked contacts.

#### Parameters

- onsuccess :
- onerror :

#### Returns

``Array``

## getContacts(url, options, onsuccess, onerror)

Return an Array of contacts from external API.

#### Parameters

- url :
- options :
- onsuccess :
- onerror :

#### Returns

``Array``

## getContacts(url, params)

Get user's contact list by endpoint

#### Parameters

- url :
- params :

#### Returns

``Array``

## getContacts(callback, options)

Return an Array of contacts.

#### Parameters

- callback :
- options :

#### Returns

``Array``

## getContacts(callback, options)

Return an Array of contacts.

#### Parameters

- callback :
- options :

#### Returns

``Array``

## getContactsURL

Get Contacts API URL

#### Returns

``String``

## getConversationByRoomId(roomId)

Get a conversation by room id

#### Parameters

- roomId :

## getConversationByRoomId(roomId)

Get a conversation by room id

#### Parameters

- roomId :

## getConversations(options, onsuccess, onerror)

Return an Array of conversations.

#### Parameters

- `Object` options :

  {id, limit, offset}

- onsuccess :
- onerror :

#### Returns

``Array``

## getConversations(callback, options)

Return an Array of conversations passing a limit and offset (pagination).

#### Parameters

- callback :
- options :

#### Returns

``Array``

## getConversations(params)

Get user's conversations

#### Parameters

- params :

#### Returns

``Array``

## getConversations(callback, options)

Return an Array of conversations passing a limit and offset (pagination).

#### Parameters

- callback :
- options :

#### Returns

``Array``

## getGaiaCoreToken

Get GaiaCore Token

#### Returns

``String``

## getGaiaCoreUrl

Get GaiaCore Token

#### Returns

``String``

## getMessages(roomId, params)

Get Room messages

#### Parameters

- roomId :
- params :

#### Returns

``Array``

## getNetworkContacts(url, params)

Get user's contact list from network

#### Parameters

- url :
- params :

#### Returns

``Array``

## getProxy

Returns Hub connection instance

#### Returns

``Object``

## getSignalRURL

Get SignalR URL

#### Returns

``String``

## getTotalNotifications(params)

Get the total number of notifications (messages unread)

#### Parameters

- params :

#### Returns

``Number``

## htmlParser(html, handler)

#### Parameters

- `string` html :

  string

- `object` handler :

#### Examples

    htmlParser(htmlString, {
        start: function(tag, attrs, unary) {},
        end: function(tag) {},
        chars: function(text) {},
        comment: function(text) {}
    });

## htmlSanitizeWriter(buf, uriValidator)

create an HTML/XML writer which writes to buffer

#### Parameters

- `Array` buf :

  use buf.jain('') to get out sanitized html string

- uriValidator :

#### Returns

``object`` :

in the form of { start: function(tag, attrs, unary) {}, end: function(tag) {}, chars: function(text) {}, comment: function(text) {} }

## leaveGroup

Sign Out From Group

## linky(text, target)

#### Parameters

- `string` text :

  Input text.

- `string` target :

  Window (_blank|_self|_parent|_top) or named frame to open links in.

#### Returns

``string`` :

Html-linkified text.

#### Examples

    <example module="linkyExample" deps="angular-sanitize.js">
    <file name="index.html">
    <script>
    angular.module('linkyExample', ['ngSanitize'])
    .controller('ExampleController', ['$scope', function($scope) {
    $scope.snippet =
    'Pretty text with some links:\n'+
    'http://angularjs.org/,\n'+
    'mailto:us@somewhere.org,\n'+
    'another@somewhere.org,\n'+
    'and one more: ftp://127.0.0.1/.';
    $scope.snippetWithTarget = 'http://angularjs.org/';
    }]);
    </script>
    <div ng-controller="ExampleController">
    Snippet: <textarea ng-model="snippet" cols="60" rows="3"></textarea>
    <table>
    <tr>
    <td>Filter</td>
    <td>Source</td>
    <td>Rendered</td>
    </tr>
    <tr id="linky-filter">
    <td>linky filter</td>
    <td>
    <pre>&lt;div ng-bind-html="snippet | linky"&gt;<br>&lt;/div&gt;</pre>
    </td>
    <td>
    <div ng-bind-html="snippet | linky"></div>
    </td>
    </tr>
    <tr id="linky-target">
    <td>linky target</td>
    <td>
    <pre>&lt;div ng-bind-html="snippetWithTarget | linky:'_blank'"&gt;<br>&lt;/div&gt;</pre>
    </td>
    <td>
    <div ng-bind-html="snippetWithTarget | linky:'_blank'"></div>
    </td>
    </tr>
    <tr id="escaped-html">
    <td>no filter</td>
    <td><pre>&lt;div ng-bind="snippet"&gt;<br>&lt;/div&gt;</pre></td>
    <td><div ng-bind="snippet"></div></td>
    </tr>
    </table>
    </file>
    <file name="protractor.js" type="protractor">
    it('should linkify the snippet with urls', function() {
    expect(element(by.id('linky-filter')).element(by.binding('snippet | linky')).getText()).
    toBe('Pretty text with some links: http://angularjs.org/, us@somewhere.org, ' +
    'another@somewhere.org, and one more: ftp://127.0.0.1/.');
    expect(element.all(by.css('#linky-filter a')).count()).toEqual(4);
    });

    it('should not linkify snippet without the linky filter', function() {
    expect(element(by.id('escaped-html')).element(by.binding('snippet')).getText()).
    toBe('Pretty text with some links: http://angularjs.org/, mailto:us@somewhere.org, ' +
    'another@somewhere.org, and one more: ftp://127.0.0.1/.');
    expect(element.all(by.css('#escaped-html a')).count()).toEqual(0);
    });

    it('should update', function() {
    element(by.model('snippet')).clear();
    element(by.model('snippet')).sendKeys('new http://link.');
    expect(element(by.id('linky-filter')).element(by.binding('snippet | linky')).getText()).
    toBe('new http://link.');
    expect(element.all(by.css('#linky-filter a')).count()).toEqual(1);
    expect(element(by.id('escaped-html')).element(by.binding('snippet')).getText())
    .toBe('new http://link.');
    });

    it('should work with the target property', function() {
    expect(element(by.id('linky-target')).
    element(by.binding("snippetWithTarget | linky:'_blank'")).getText()).
    toBe('http://angularjs.org/');
    expect(element(by.css('#linky-target a')).getAttribute('target')).toEqual('_blank');
    });
    </file>
    </example>

## loadScript(str)

Load a script dynamically

#### Parameters

- str :

#### Returns

``Promise``

## loadSettings(params)

Load user's preferences

#### Parameters

- params :

#### Returns

``Array``

## mergeBlockeds(contacts, blockeds)

Merge isBlocked properties between contacts/blocked lists.

#### Parameters

- contacts :
- blockeds :

#### Returns

``Array``

## mergeBlockedWithContacts(list)

Return an Array of contacts merged with blocked list.

#### Parameters

- list :

#### Returns

``Array``

## mergeConversation(dest, source, userId)

Merge data from a contact

#### Parameters

- dest :
- source :
- userId :

## ngSanitize

## onAddParticipant(roomId, participants)

Add a participant to a conversation

#### Parameters

- roomId :
- participants :

## onAddParticipant(roomId, participants)

Add a participant to a conversation

#### Parameters

- roomId :
- participants :

## onDisconnected(error)

Display error message when disconnected and invoke reconnect method when chat is disconnected

#### Parameters

- error :

## onDisconnected(error)

Display error message when disconnected and invoke reconnect method when chat is disconnected

#### Parameters

- error :

## onFirstContactCustom(data)

Open a popup to confirm a partnership between incorp or community

#### Parameters

- data :

## onFirstContactCustom(data)

Open a popup to confirm a partnership between incorp or community

#### Parameters

- data :

## onMessageAsRead(roomId)

Emit an event to notify a popup when the messages were read

#### Parameters

- roomId :

## onMessageAsRead(roomId)

Emit an event to notify a popup when the messages were read

#### Parameters

- roomId :

## onReceiveMessage(data)

Append new message from contact to conversation

#### Parameters

- data :

## onReceiveMessage(data)

Append new message from contact to conversation

#### Parameters

- data :

## onReceiveTyping(data)

Add typing flag to conversation

#### Parameters

- data :

## onReceiveTyping(data)

Add typing flag to conversation

#### Parameters

- data :

## onRoomEdited(data)

Update the name of a conversation (Room)

#### Parameters

- data :

## onRoomEdited(data)

Update the name of a conversation (Room)

#### Parameters

- data :

## onSetReadMessages(roomId)

Clear unread messages from a conversation (Room)

#### Parameters

- roomId :

## onUserChangeStatus(data)

Watch for status change

#### Parameters

- data :

## onUserChangeStatus(data)

Watch for status change

#### Parameters

- data :

## Reconnect

Reconnect chat.

## Reconnect

Reconnect chat.

## removeConversationByRoomId(roomId, selfRemoved)

Remove conversation if user was removed and close popup (if it's open)

#### Parameters

- roomId :
- selfRemoved :

## removeConversationByRoomId(roomId, selfRemoved)

Remove conversation if user was removed and close popup (if it's open)

#### Parameters

- roomId :
- selfRemoved :

## removeLostConnection

Check for last connection id to send a request and delete it

## removeParticipants(roomId, participants, selfRemoved)

Remove a participant from a conversation

#### Parameters

- roomId :
- participants :
- selfRemoved :

## removeParticipants(roomId, participants, selfRemoved)

Remove a participant from a conversation

#### Parameters

- roomId :
- participants :
- selfRemoved :

## removeTyping(roomId)

Remove typing flag from conversation

#### Parameters

- roomId :

## removeTyping(roomId)

Remove typing flag from conversation

#### Parameters

- roomId :

## saveSettings(userId, productTag, data)

Save user's preferences

#### Parameters

- userId :
- productTag :
- data :

## search(name)

Search for conversations

#### Parameters

- name :

#### Returns

``Array``

## searchContact(params)

Search for contacts by name

#### Parameters

- params :

#### Returns

``Array``

## searchContacts(name)

Search for conversations

#### Parameters

- name :

#### Returns

``Array``

## searchContacts(name)

Search for conversations

#### Parameters

- name :

#### Returns

``Array``

## searchConversation(params)

Search for conversations by name

#### Parameters

- params :

#### Returns

``Array``

## sendMessage

Send message to room

## startConnection(data)

Start chat connection with Hub and API

#### Parameters

- data :

#### Returns

``Promise``

## unblock(blocked)

Unblock a contact.

#### Parameters

- blocked :

#### Returns

``Array``

## unblock(blocked, onsuccess, onerror)

Unblocked a contact.

#### Parameters

- blocked :
- onsuccess :
- onerror :

#### Returns

``Array``

## unblockContact(data)

Remove contact from the blocked list

#### Parameters

- data :

## unblockContact

Block a contact

## updateContactList(conversation)

Push new contact to the list

#### Parameters

- conversation :

## updateContactList(conversation)

Push new contact to the list

#### Parameters

- conversation :

## updateStatus(list, data)

Find contact in list and replace current status from response data.

#### Parameters

- list :
- data :

## updateStatus(list, data)

Find contact in list and replace current status from response data.

#### Parameters

- list :
- data :

## window

## XMLHttpRequest

! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS