Constructor
new Now4real()
You cannot use this constructor directly. An instance of this class is already available globally under window.now4real.
Members
(readonly) config :Now4real~Config
Configuration object that contains the configured values.
onerror :Now4real~onerrorCallback
Callback function called when the library has failed to load.
Example
window.now4real = window.now4real || {};
now4real.onerror = function (error) {
console.log('Now4real failed to load', error.code, error.message)
}
onload :function
The callback function called when the library is fully loaded, and it is possible to start calling API methods. Note that the library implements a lazy loading mechanism so that it waits for the visible state of the host page (see Page Visibility API) in order to load.
Example
window.now4real = window.now4real || {};
now4real.onload = function () {
console.log('Now4real loaded!')
}
(readonly) pageContext :string
A constant string containing the Page Context of the current page. It's configurable through the page_context
property of the config object, otherwise it is automatically computed by the library.
The Page Context (combined with the Site Context) allows Now4real to decide whether different users should be considered present on the same page. The term "page" means an actual web page or some logical context (group of pages, virtual place, etc.). This directly impacts page counters, pagechats, rankings, maps, etc.
The default Page Context corresponds to the window.location.pathname, with the following exceptions:
- If the pathname terminates with /index.*, /Index.*, /home.*, /Home.*, /default.* or /Default.*, the Page Context will be truncated to the last "/".
- If the page was loaded from the "file://" protocol, the Page Context will be "/" followed by the name of the file (including any extension).
Url | Page Context |
---|---|
https://example.com/path/page.html | /path/page.html |
https://example.com/path/page.html#hash | /path/page.html |
https://example.com/page5?par=val | /page5 |
https://example.com/page5/ | /page5/ |
http://example.com/path/index.html | /path/ |
file:///Users/integrator/Desktop/project/app.html | /app.html |
http://localhost/project/app.html | /project/app.html |
Url | Page Context |
---|---|
https://example.com/technology/ | /technology/ |
https://example.com/technology/index.html | /technology/ |
https://example.com/technology/index.htm | /technology/ |
https://example.com/technology/Home.aspx | /technology/ |
https://example.com/technology/?id=3 | /technology/ |
https://example.com/technology/index.html?id=4 | /technology/ |
page_context
property of the config object is used, the behavior of the examples above might be very different. For example, you may include some query parameters, or you may completely remap the actual page path to a different name. Please refer to the documentation of the page_context
property for a few examples.
(readonly) siteContext :string
A constant string containing the Site Context of the current page. It is automatically computed by the library and represents the website to which this page pertains. Generally, it corresponds to the window.location.host of the page. If a hierarchy of domain name aliases and subdomains has been configured in the Now4real Publisher Dashboard, the value may be different from window.location.host: for the top-level site, the configured "master" domain is returned; for a subdomain, the first subdomain name in the subdomain group is returned. Notice that the protocol ("http://" or "https://") is not considered for the Site Context. The TCP port is considered only if it's not 80 or 443. The Site Context allows Now4real to decide whether different users are on the same site. This directly impacts site counters, rankings, maps, etc. As a special case, a sandbox context is available, which allows you to test your Now4real code without mounting it on an actual domain. This context, named "shared-public-sandbox.test" automatically originates in these cases:
- If the page is loaded with the "file://" protocol (from the file system).
- If the hostname is "localhost".
- If the IP address is a loopback address (like 127.0.0.1).
Url | Site Context |
---|---|
http://example.com/path/page.html | example.com |
https://example.com/path/page2?par=val | example.com |
https://www.example.com/path/page3#abc | example.com (if example.com was configured in the Dashboard as the master for example.com and www.example.com domains) |
https://example.com:8443/path/page.html | example.com:8443 |
http://localhost:8080/project/app.html | shared-public-sandbox.test |
http://127.0.0.1:8080/project/dev | shared-public-sandbox.test |
file:///Users/integrator/Desktop/project/page.html | shared-public-sandbox.test |
(readonly) version :string
A constant string representing the version of the library.
Example
// returns "1.0.0"
now4real.version
Methods
deleteMessage(msgId) → {Promise}
Method that deletes the message with the passed msgId from the current pagechat. In order for the call to be successful, the client must be connected to the Now4real cloud, and a logged-in Now4real user must be present. Each user can only request the deletion of their own messages. Moderators can delete any messages. It returns a promise that resolves with an empty object payload or rejects with an instance of Now4realError, specifically one of the following: AbortedError, DisconnectedError, InvalidArgumentsError, NotAuthenticatedError, NotAuthorizedError or TechnicalProblemError.
Parameters:
Name | Type | Description |
---|---|---|
msgId |
string |
The id of the message to delete. |
Example
Example usage of deleteMessage().
now4real.deleteMessage('MSG_ID_000000042')
.then(_ => {
console.log('deleteMessage succedeed')
})
.catch(reason => {
console.log('deleteMessage error', reason.code, reason.message)
})
editUserProfile() → {Promise}
Method that opens a new browser tab in which the user has the possibility to edit some attributes of their profile, created previously with email signup. In order for the call to be successful, the client must be connected to the Now4real cloud, and a logged-in Now4real user, by means of email, must be present. The call is not supported on IE10 and IE11. After a successful update of the user profile, all the subjects that contain a reference to that user will receive an update. It returns a promise that resolves with an empty object payload or rejects with an instance of Now4realError, specifically one of the following: AbortedError, BlockedError, InvalidCallError, or TechnicalProblemError.
Example
Example usage of editUserProfile().
now4real.editUserProfile()
.then(_ => {
console.log('edit popup opened')
})
.catch(reason => {
console.log('error on opening edit popup', reason.code, reason.message)
})
flushChat() → {Promise}
Method that entirely flush the current pagechat. It can be called only by a logged in Moderator. If the call is successful, the "LIST_CHAT_MESSAGES" subject will receive a series of "REMOVE" updates which lead to empty the chat. It returns a promise that resolves with an empty object payload or rejects with an instance of Now4realError, specifically one of the following: AbortedError, DisconnectedError, InvalidCallError, NotAuthenticatedError, ServiceUnavailableError, or TechnicalProblemError.
Example
Example usage of flushChat().
now4real.flushChat()
.then(_ => {
console.log('flushChat succeeded')
})
.catch(reason => {
console.log('flushChat error', reason.code, reason.message)
})
get(subject) → {*}
Method that returns the current value of a subscribed subject. It can be the latest update data object for a counter subject or the latest snapshot object for the other subjects, such as a ranking or a heatmap. See: CounterUpdate, Heatmap, MessageList, Ranking, and TypingList. The same value can be retrieved as a property access on the Now4real instance.
Parameters:
Name | Type | Description |
---|---|---|
subject |
string |
The name of the subject (which must be already subscribed to).See subscribe for all the supported subjects. |
Throws:
Will throw an instance of Now4realError, specifically one of the following: InvalidArgumentsError if the argument is not a valid subject or InvalidCallError if the subject is valid but is not currently subscribed.
Examples
Example usage of get().
// returns {value: "1"}
Now4rea.get("COUNTER_PAGE_VIEWERS")
// returns [{ isCurrentPage: true, key: 'example.com/hello.html', title: "example page", url: "http://example.com/hello.html", users: "5" }]
Now4rea.get("RANKING_PAGE_VIEWERS")
Example usage as property access.
// returns {value: "1"}
now4real["COUNTER_PAGE_VIEWERS"]
getMute(userId) → {Promise}
Method that gets the configured mute period for the user, if any. It returns a promise that resolves with a mutePayload or null, depending on the presence of the mute for the user, or rejects with an instance of Now4realError, specifically one of the following: AbortedError, DisconnectedError, InvalidArgumentsError, NotAuthenticatedError, ServiceUnavailableError, or TechnicalProblemError.
Parameters:
Name | Type | Description |
---|---|---|
userId |
string |
The id of the user. |
Example
Example usage of getMute().
now4real.getMute('USER_ID_0000000099')
.then(response => {
console.log('getMute succeeded', response.expiration)
})
.catch(reason => {
console.log('getMute error', reason.code, reason.message)
})
login(provider) → {Promise}
Method that starts the OAuth authentication flow against the social provider or the Now4real email provider, depending on the passed one.
Login is required in order to be able to post messages to the chat.
In case of social authentication, a new browser tab is opened, through which the user can sign into the chosen social network (if they aren't already signed in) and is prompted to authorize Now4real to access some information on their profile.
In case of email authentication, instead, the new browser tab leads the user to the creation of a profile in our system (if it doesn't exist), in which they can choose their preferred email and a custom nickname. The flow is passwordless and based on the insertion of a 6-digit code sent to the chosen email.
At the end of a successful authorization flow, we store the login information in a localStorage object of our domain, in order to make it available to any other site that integrates Now4real opened in the same browser.
Accordingly, all the current browser tabs (including the one that has started the flow) will be notified through a call of the "LOGIN_STATUS" subject callback.
The email authentication is not supported on IE10 and IE11.
The method returns a promise that resolves with a loginPayload or rejects with an instance of Now4realError, specifically one of the following: AbortedError, BlockedError, InvalidArgumentsError, InvalidCallError, ServiceUnavailableError, or TechnicalProblemError.
Parameters:
Name | Type | Description |
---|---|---|
provider |
string |
The login provider to use for authentication. It can be |
Example
Example usage of login().
now4real.login('GOOGLE')
.then(response => {
console.log('login succedeed', response.user)
})
.catch(reason => {
console.log('login error', reason.code, reason.message)
})
logout() → {Promise}
Method that performs a logout of the currently signed in Now4real user from the current browser. If the call is successful, all the browser tabs (including the one that has requested the logout) will be notified through a call of the "LOGIN_STATUS" subject callback. It returns a promise that resolves with an empty object payload or rejects with an instance of Now4realError, specifically one of the following: AbortedError, InvalidCallError, ServiceUnavailableError, or TechnicalProblemError.
Example
Example usage of logout().
now4real.logout()
.then(_ => {
console.log('logout succeeded')
})
.catch(reason => {
console.log('logout error', reason.code, reason.message)
})
post(msg, optionsopt) → {Promise}
Method that posts the passed message to the current pagechat on behalf of the currently logged in Now4real user. In order for the call to be successful, the client must be connected to the Now4real cloud, and a logged-in Now4real user must be present. The maximum length of a message and the minimum interval required between two consecutive messages is obtained through the "PARAMETERS" subject. It returns a promise that resolves with an empty object payload or rejects with an instance of Now4realError, specifically one of the following: AbortedError, ChatDisabledError, DisconnectedError, InvalidArgumentsError, NotAuthenticatedError, NotAuthorizedError, ServiceUnavailableError, TechnicalProblemError, TooFrequentError, or UserMutedError.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
msg |
string |
The message that will be posted to the current pagechat. |
|
options |
Now4real~PostOptions |
<optional> |
The options for the current operation. |
Examples
Example usage of post().
now4real.post('Hello there!')
.then(_ => {
console.log('post succedeed')
})
.catch(reason => {
console.log('post error', reason.code, reason.message)
})
Example usage of post() with options.
now4real.post('Thanks for the code!!!', { replyTo: 'MSG_ID_000000037' })
.then(_ => {
console.log('post succedeed')
})
.catch(reason => {
console.log('post error', reason.code, reason.message)
})
registerUserConsent() → {Promise}
Method that notifies the Now4real cloud that the current logged-in JWT user has accepted Now4real's Terms of Service and Privacy Policy.
This method must be called, in case of custom authentication, before a user sends their first message. Otherwise, any call to the post method would throw an error.
A check of the consentGiven
attribute of the current user allows you to understand if the user has already provided their consent and therefore there is no need to call this method again.
In order for the call to be successful, the client must be connected to the Now4real cloud, and a logged-in JWT user must be present.
If the call is successful, the "LOGIN_STATUS" subject will receive an update with the updated consentGiven
attribute for the current user.
It returns a promise that resolves with an empty object payload or rejects with an instance of Now4realError, specifically one of the following: AbortedError, DisconnectedError, InvalidCallError, NotAuthenticatedError, ServiceUnavailableError, or TechnicalProblemError.
Example
Example usage of registerUserConsent() along with the post() method.
const currentUser = now4real.LOGIN_STATUS.user
if (!currentUser.consentGiven) {
// here the user has to explicitly accept Now4real's Terms of Service and Privacy Policy
// the consent must be stored on the Now4real cloud
await now4real.registerUserConsent()
}
await now4real.post('Hi!')
reload()
Method that requests Now4real reinitialization. Once the reloading process is complete, a call to the onload callback will be re-issued.
It is advisable to call the method only when there are no other calls awaiting resolution. If this happen, the calls would be aborted and their outcome would not be guaranteed.
It can be used to update the launch configuration without the need for a page refresh.
Developers that want to support their SPA sites, offering a different pagechat for each route, can call this method when navigation occurs, to update the Now4real widget context. In this case, the widget must be loaded with a page scope. Remember that, if the SPA is based on hashed URL paths, the page_context
parameter needs to be configured and updated accordingly.
Examples
Example usage of reload() to update the widget configuration.
// update widget configuration
now4real.config.widget.color_external_background = '#123456'
now4real.reload()
Example usage of reload() in a SPA using Vue Router.
// detect navigation
watch:{
$route (to, from) {
now4real.reload()
}
}
Example usage of reload() in a SPA based on hashed URL paths, using Vue Router.
// detect navigation
watch:{
$route (to, from) {
now4real.config.page_context = '/chat/' + location.hash
now4real.reload()
}
}
reportMessage(msgId, reason, commentopt) → {Promise}
Method that allows a user to report a message published by other users on the current pagechat, if he finds any issues with it.
Reports containing these messages will be sent to the email addresses configured in the "User Reporting" section of the Dashboard (according to the configured frequency), who can then decide whether to remove these from the pagechat.
In order for the call to be successful, the client must be connected to the Now4real cloud, and a logged-in Now4real user must be present.
It returns a promise that resolves with an empty object payload or rejects with an instance of Now4realError, specifically one of the following: AbortedError, AlreadyReportedError, DisconnectedError, InvalidArgumentsError, InvalidCallError, NotAuthenticatedError, ServiceUnavailableError, TechnicalProblemError, or UserMutedError.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
msgId |
string |
The id of the message to report. |
|||||||||||||||||
reason |
string |
The reason of the report. Must be one of the following:
|
|||||||||||||||||
comment |
string |
<optional> |
Additional information the user want to include in the report. The supplied string can contain up to 500 characters. |
setChatEnabled(enabled) → {Promise}
Method that allows to disable or re-enable the current pagechat. It can be called only by a logged in Moderator. If the call is successful, the "PARAMETERS" subject will be notified with the updated chatStatus value. It returns a promise that resolves with an empty object payload or rejects with an instance of Now4realError, specifically one of the following: AbortedError, DisconnectedError, InvalidArgumentsError, InvalidCallError, NotAuthenticatedError, ServiceUnavailableError, or TechnicalProblemError.
Parameters:
Name | Type | Description |
---|---|---|
enabled |
boolean |
false to disable to chat, true to re-enable it. |
Example
Example usage of setChatEnabled().
now4real.setChatEnabled(false)
.then(_ => {
console.log('setChatEnabled succeeded')
})
.catch(reason => {
console.log('setChatEnabled error', reason.code, reason.message)
})
setLoggerLevel(level) → {Promise}
Method that changes the logging level of the library. It returns a promise that resolves with an empty object payload or rejects with an instance of Now4realError, specifically one of the following: AbortedError, or InvalidArgumentsError.
Parameters:
Name | Type | Description |
---|---|---|
level |
string |
The new logging level of the library.see Now4real~Config |
setMute(userId, duration) → {Promise}
Method that allows to mute a user in the pagechat for a period of time. The user cannot post any messages until the mute expiration. In order for the call to be successful, the client must be connected to the Now4real cloud, and a logged-in Now4real Moderator must be present. It can be called multiple times on the same user, even before the expiration. The mute period will be recomputed and updated at each call. It returns a promise that resolves with a mutePayload or rejects with an instance of Now4realError, specifically one of the following: AbortedError, DisconnectedError, InvalidArgumentsError, InvalidCallError, NotAuthenticatedError, ServiceUnavailableError, or TechnicalProblemError.
Parameters:
Name | Type | Description |
---|---|---|
userId |
string |
The id of the user to mute. |
duration |
number |
The period of time, in seconds, in which the user will be muted and can't post messages. It is possible to pass null to mute the user forever. |
Example
Example usage of setMute().
now4real.setMute('USER_ID_0000000099', 60)
.then(response => {
console.log('setMute succeeded, the user is muted until: ' + new Date(response.expiration).toUTCString())
})
.catch(reason => {
console.log('setMute error', reason.code, reason.message)
})
startTyping() → {Promise}
Method that notifies the Now4real cloud that the current Now4real user has started typing a message for the current pagechat. It returns a promise that resolves with an empty object payload or rejects with an instance of Now4realError, specifically one of the following: AbortedError, InvalidCallError, NotAuthorizedError, or TechnicalProblemError.
stopTyping() → {Promise}
Method that notifies the Now4real cloud that the current Now4real user has stopped typing a message for the current pagechat. It returns a promise that resolves with an empty object payload or rejects with an instance of Now4realError, specifically one of the following: AbortedError, InvalidCallError or TechnicalProblemError.
subscribe(subject, callback) → {Promise}
Method that sets a listener for subject updates. The passed callback function is called each time an update pertaining to the subject has been received from the Now4real cloud with the corresponding instance of Now4realSubjectUpdate. For some subjects ["COUNTER_PAGE_VIEWERS", "COUNTER_PAGE_CHATTERS", and "COUNTER_CHAT_TYPING"] it is possible to choose a custom Page Context by appending a colon followed by the Page Context just after the subject name. [Premium Plan only] Due to performance optimizations, after some time the page is no more visibile (typically because it is gone in the background), the subscribed subjects may no longer receive updates. The normal behavior will be restored when the page becomes visible again. It returns a promise that resolves with an empty object payload or rejects with an instance of Now4realError, specifically one of the following: AbortedError, InvalidArgumentsError, InvalidCallError, NotAuthorizedError, or TechnicalProblemError.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
subject |
string |
The name of the subject to subscribe to. Must be one of the following:
|
||||||||||||||||||||||||||||||||||||||||||
callback |
Now4real~subjectUpdateCallback |
Callback function that is called each time an update pertaining to the subscribed subject has been received from the Now4real cloud. |
Examples
Example usage of subscribe().
now4real.subscribe('COUNTER_PAGE_VIEWERS', updObj => {
console.log('counter update received: ' + updObj.data.value)
})
.then(response => {
console.log('subscribe succeeded')
})
.catch(reason => {
console.log('subscribe error', reason.code, reason.message)
})
Example usage of subscribe() with a custom Page Context. [Premium Plan only]
now4real.subscribe('COUNTER_PAGE_VIEWERS:my-great-path/test.html', updObj => {
console.log('counter update received: ' + updObj.data.value)
})
.then(response => {
console.log('subscribe succeeded')
})
.catch(reason => {
console.log('subscribe error', reason.code, reason.message)
})
unsubscribe(subject) → {Promise}
Method that removes a registered listener from a subject. It returns a promise that resolves with an empty object payload or rejects with an instance of Now4realError, specifically one of the following: AbortedError, InvalidArgumentsError, InvalidCallError, or TechnicalProblemError.
Parameters:
Name | Type | Description |
---|---|---|
subject |
string |
The name of the subject to unsubscribe from.See subscribe for all the supported subjects. |
Example
Example usage of unsubscribe().
now4real.unsubscribe('COUNTER_PAGE_VIEWERS')
.then(response => {
console.log('unsubscribe succeeded')
})
.catch(reason => {
console.log('unsubscribe error', reason.code, reason.message)
})
Type Definitions
Config :object
Configuration object to be provided to the API, which contains the configuration settings.
Properties:
Name | Type | Default | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
target |
string | "widget" |
Defines what should be loaded.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
scope |
string | "site" |
Defines whether to create a single pagechat for the whole site or a different pagechat for every page of the site.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logger |
string | "warn" |
Defines the initial logging level of the library.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context_check |
string | boolean | false |
Should be the window.location.host of the page in which Now4real will be loaded. It is used to check whether the site was cloned and to automatically block Now4real loading.If false is supplied, the check will not be performed. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
param_overriding |
boolean | false |
Enables or disables the option to override the
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
page_context |
string | object | null |
Defines a custom Page Context for the current page. This gives you full control over how Now4real should treat each page of your site, allowing you to consider even query strings and fragments, or to override the page path completely. It accepts a string or a page context configurator object. If null, the default Page Context is used. Pass a string if you want to override the page path and assign your logical context. This is useful, for example, if you want to define groups of pages that should be treated as having the same context (thus counting all the users on those pages together and providing them with a shared pagechat). The string must always start with a "/" character. Pass a page context configurator object if you want to customize the page context by defining simple rules to be applied to the URL of your page. The object accepts the properties below: Properties
Examples: Current URL: https://example.com/shop/shoes?type=sneakers&sort=price_ascending#comments
url property of RankingUpdate). If you are displaying the PAGES section, ensure the resulting URLs are valid because users may click those links.
Defining a custom page_context may be useful even when the scope is set to "site", in case you want to alter the URLs displayed in the PAGES section of the widget.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
custom_auth |
object |
Defines custom authentication settings. [Premium Plan only]Check out Custom Auth documentation for full details and examples. Properties
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
widget |
object |
Defines widget configuration settings. Properties
|
Examples
Example of how to pass parameters to Now4real:
<script type="text/javascript">
window.now4real = window.now4real || {};
now4real.config = {
target: 'api+widget',
widget: {
align: 'right',
align_mobile: 'left',
color_external_background: '#da3f3f',
color_external_text: '#ece15d'
}
};
(function () { var n4r = document.createElement('script'); n4r.type = 'text/javascript'; n4r.async = true; n4r.src = 'https://cdn.now4real.com/now4real.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(n4r, s); })();
</script>
Example of how to override the target
and logger
parameters:
<script type="text/javascript">
// With the now4real.config below, the widget, the API, and the log will be disabled
// for everyone (even if presence is still silently collected). But setting
// param_overriding to true allows you to override such behavior for a given browser.
// To enable the widget on the fly, just call any page of the site once with this
// query string:
// https://example.com/?n4rTarget=widget
// Similarly, to set the log to debug, use this query string:
// https://example.com/?n4rLogger=debug
// You can use both the parameters together:
// https://example.com/?n4rTarget=widget&n4rLogger=debug
// That browser will remember the new settings for any future visits to any pages of
// that site. To switch back to the original settings, just call any page of the site
// once with this query string:
// https://example.com/?n4rTarget=default&n4rLogger=default
window.now4real = window.now4real || {};
now4real.config = {
target: 'none',
logger: 'off',
param_overriding: true
};
(function () { var n4r = document.createElement('script'); n4r.type = 'text/javascript'; n4r.async = true; n4r.src = 'https://cdn.now4real.com/now4real.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(n4r, s); })();
</script>
Heatmap :Object.<string, number>
A dictionary object that represents a Heatmap. It has string keys representing the country
and number values representing the intensity
.
loginPayload :object
Properties:
Name | Type | Description |
---|---|---|
user |
CurrentUser |
The authenticated user. |
persistent |
boolean |
false if the custom authentication is being used or, in case of social login, if there are restricted privacy settings on the user browser, which prevent the library from saving the authentication object into the local storage. In that case, the login will not be remembered across page navigations. true otherwise. |
MessageList :array
An array that represents the messages available in the current pagechat.
Properties:
Name | Type | Description |
---|---|---|
id |
string |
The unique identifier of the message. |
message |
string |
The message body. |
author |
User |
The user who sent the message. |
timestamp |
number |
The number of milliseconds from the Unix Epoch to the time the message was sent. |
isMine |
boolean |
Indicates whether the message was sent by the current Now4real user. |
mutePayload :object
Properties:
Name | Type | Description |
---|---|---|
expiration |
number |
The number of milliseconds from the Unix Epoch to the time the user can post messages again into the pagechat or null if the user was muted forever. |
onerrorCallback(error) → {void}
Parameters:
Name | Type | Description |
---|---|---|
error |
Now4realError |
The error encountered while loading. |
PostOptions :object
An object that contains the options for the post call.
Properties:
Name | Type | Description |
---|---|---|
replyTo |
string |
The id of the message to reply to. |
Ranking :array
An array that represents a ranking.
Properties:
Name | Type | Description |
---|---|---|
key |
string |
The context that uniquely identifies the page. |
url |
string |
The full url of the page. |
title |
string |
The page title, if available, otherwise the Page Context. |
users |
string |
The counter value, following the same rules of the CounterUpdate value. |
isCurrentPage |
boolean |
Indicates whether the page is the same as the one in which the library is working. |
subjectUpdateCallback(subjectUpdate) → {void}
Parameters:
Name | Type | Description |
---|---|---|
subjectUpdate |
Now4realSubjectUpdate |
The object that contains the update data. |
TypingList :Array.<User>
An array that represents the typing list.