6100aaf114
API methods now consist of simple accessors and mutators that are logically grouped.
1546 lines
97 KiB
HTML
1546 lines
97 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<title>Quickstart (to get a demo up and running) — Converse.js 0.8.3 documentation</title>
|
|
|
|
<link rel="stylesheet" href="_static/stylesheet.css" type="text/css" />
|
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
|
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT: './',
|
|
VERSION: '0.8.3',
|
|
COLLAPSE_INDEX: false,
|
|
FILE_SUFFIX: '.html',
|
|
HAS_SOURCE: true
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="_static/jquery.js"></script>
|
|
<script type="text/javascript" src="_static/underscore.js"></script>
|
|
<script type="text/javascript" src="_static/doctools.js"></script>
|
|
<link rel="top" title="Converse.js 0.8.3 documentation" href="#" />
|
|
</head>
|
|
<body>
|
|
<div id="header_wrap" class="outer">
|
|
<header class="inner">
|
|
<h1 id="project_title"><a href="http://conversejs.org">Converse.js</a></h1>
|
|
<h2 id="project_tagline">Documentation</h2>
|
|
</header>
|
|
</div>
|
|
|
|
|
|
<div id="main_content_wrap" class="outer">
|
|
<div class="related">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="genindex.html" title="General Index"
|
|
accesskey="I">index</a></li>
|
|
<li><a href="#">Converse.js 0.8.3 documentation</a> »</li>
|
|
</ul>
|
|
</div>
|
|
<section id="main_content" class="inner">
|
|
|
|
<div class="document">
|
|
<div class="documentwrapper">
|
|
<div class="body">
|
|
|
|
<div class="toctree-wrapper compound">
|
|
<ul class="simple">
|
|
</ul>
|
|
</div>
|
|
<div class="contents local topic" id="table-of-contents">
|
|
<p class="topic-title first">Table of Contents</p>
|
|
<ul class="simple">
|
|
<li><a class="reference internal" href="#quickstart-to-get-a-demo-up-and-running" id="id8">Quickstart (to get a demo up and running)</a></li>
|
|
<li><a class="reference internal" href="#introduction" id="id9">Introduction</a></li>
|
|
<li><a class="reference internal" href="#features" id="id10">Features</a><ul>
|
|
<li><a class="reference internal" href="#off-the-record-encryption" id="id11">Off-the-record encryption</a></li>
|
|
<li><a class="reference internal" href="#sound-notifications" id="id12">Sound Notifications</a></li>
|
|
<li><a class="reference internal" href="#multilingual-support" id="id13">Multilingual Support</a></li>
|
|
<li><a class="reference internal" href="#chat-rooms" id="id14">Chat Rooms</a><ul>
|
|
<li><a class="reference internal" href="#commands" id="id15">Commands</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li><a class="reference internal" href="#what-you-will-need" id="id16">What you will need</a><ul>
|
|
<li><a class="reference internal" href="#an-xmpp-server" id="id17">An XMPP server</a></li>
|
|
<li><a class="reference internal" href="#a-bosh-connection-manager" id="id18">A BOSH Connection Manager</a><ul>
|
|
<li><a class="reference internal" href="#overcoming-cross-domain-request-restrictions" id="id19">Overcoming cross-domain request restrictions</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a class="reference internal" href="#server-side-authentication" id="id20">Server-side authentication</a><ul>
|
|
<li><a class="reference internal" href="#prebinding-and-single-session-support" id="id21">Prebinding and Single Session Support</a></li>
|
|
<li><a class="reference internal" href="#example-code-for-server-side-prebinding" id="id22">Example code for server-side prebinding</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li><a class="reference internal" href="#development" id="id23">Development</a><ul>
|
|
<li><a class="reference internal" href="#install-the-development-and-front-end-dependencies" id="id24">Install the development and front-end dependencies</a></li>
|
|
<li><a class="reference internal" href="#with-amd-and-require-js-recommended" id="id25">With AMD and require.js (recommended)</a></li>
|
|
<li><a class="reference internal" href="#without-amd-and-require-js" id="id26">Without AMD and require.js</a></li>
|
|
<li><a class="reference internal" href="#before-submitting-a-pull-request" id="id27">Before submitting a pull request</a><ul>
|
|
<li><a class="reference internal" href="#add-tests-for-your-bugfix-or-feature" id="id28">Add tests for your bugfix or feature</a></li>
|
|
<li><a class="reference internal" href="#check-that-the-tests-pass" id="id29">Check that the tests pass</a></li>
|
|
<li><a class="reference internal" href="#check-your-code-for-errors-or-bad-habits-by-running-jshint" id="id30">Check your code for errors or bad habits by running JSHint</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a class="reference internal" href="#developer-api" id="id31">Developer API</a><ul>
|
|
<li><a class="reference internal" href="#initialize" id="id32">initialize</a></li>
|
|
<li><a class="reference internal" href="#contacts-grouping" id="id33">“contacts” grouping</a></li>
|
|
<li><a class="reference internal" href="#chats-grouping" id="id34">“chats” grouping</a></li>
|
|
<li><a class="reference internal" href="#tokens-grouping" id="id35">“tokens” grouping</a></li>
|
|
<li><a class="reference internal" href="#listen-grouping" id="id36">“listen” grouping</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a class="reference internal" href="#events" id="id37">Events</a><ul>
|
|
<li><a class="reference internal" href="#event-types" id="id38">Event Types</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a class="reference internal" href="#minification" id="id39">Minification</a><ul>
|
|
<li><a class="reference internal" href="#minifying-javascript-and-css" id="id40">Minifying Javascript and CSS</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a class="reference internal" href="#translations" id="id41">Translations</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a class="reference internal" href="#troubleshooting" id="id42">Troubleshooting</a><ul>
|
|
<li><a class="reference internal" href="#conflicts-with-other-javascript-libraries" id="id43">Conflicts with other Javascript libraries</a><ul>
|
|
<li><a class="reference internal" href="#problem" id="id44">Problem:</a></li>
|
|
<li><a class="reference internal" href="#solution" id="id45">Solution:</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li><a class="reference internal" href="#configuration" id="id46">Configuration</a><ul>
|
|
<li><a class="reference internal" href="#configuration-variables" id="id47">Configuration variables</a><ul>
|
|
<li><a class="reference internal" href="#allow-contact-requests" id="id48">allow_contact_requests</a></li>
|
|
<li><a class="reference internal" href="#allow-muc" id="id49">allow_muc</a></li>
|
|
<li><a class="reference internal" href="#allow-otr" id="id50">allow_otr</a></li>
|
|
<li><a class="reference internal" href="#animate" id="id51">animate</a></li>
|
|
<li><a class="reference internal" href="#auto-list-rooms" id="id52">auto_list_rooms</a></li>
|
|
<li><a class="reference internal" href="#auto-reconnect" id="id53">auto_reconnect</a></li>
|
|
<li><a class="reference internal" href="#auto-subscribe" id="id54">auto_subscribe</a></li>
|
|
<li><a class="reference internal" href="#bosh-service-url" id="id55">bosh_service_url</a></li>
|
|
<li><a class="reference internal" href="#cache-otr-key" id="id56">cache_otr_key</a></li>
|
|
<li><a class="reference internal" href="#debug" id="id57">debug</a></li>
|
|
<li><a class="reference internal" href="#keepalive" id="id58">keepalive</a></li>
|
|
<li><a class="reference internal" href="#message-carbons" id="id59">message_carbons</a></li>
|
|
<li><a class="reference internal" href="#expose-rid-and-sid" id="id60">expose_rid_and_sid</a></li>
|
|
<li><a class="reference internal" href="#forward-messages" id="id61">forward_messages</a></li>
|
|
<li><a class="reference internal" href="#fullname" id="id62">fullname</a></li>
|
|
<li><a class="reference internal" href="#hide-muc-server" id="id63">hide_muc_server</a></li>
|
|
<li><a class="reference internal" href="#i18n" id="id64">i18n</a></li>
|
|
<li><a class="reference internal" href="#play-sounds" id="id65">play_sounds</a></li>
|
|
<li><a class="reference internal" href="#prebind" id="id66">prebind</a></li>
|
|
<li><a class="reference internal" href="#roster-groups" id="id67">roster_groups</a></li>
|
|
<li><a class="reference internal" href="#show-controlbox-by-default" id="id68">show_controlbox_by_default</a></li>
|
|
<li><a class="reference internal" href="#show-only-online-users" id="id69">show_only_online_users</a></li>
|
|
<li><a class="reference internal" href="#storage" id="id70">storage</a></li>
|
|
<li><a class="reference internal" href="#use-otr-by-default" id="id71">use_otr_by_default</a></li>
|
|
<li><a class="reference internal" href="#use-vcards" id="id72">use_vcards</a></li>
|
|
<li><a class="reference internal" href="#visible-toolbar-buttons" id="id73">visible_toolbar_buttons</a></li>
|
|
<li><a class="reference internal" href="#xhr-custom-status" id="id74">xhr_custom_status</a></li>
|
|
<li><a class="reference internal" href="#xhr-custom-status-url" id="id75">xhr_custom_status_url</a></li>
|
|
<li><a class="reference internal" href="#xhr-user-search" id="id76">xhr_user_search</a></li>
|
|
<li><a class="reference internal" href="#xhr-user-search-url" id="id77">xhr_user_search_url</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section" id="quickstart-to-get-a-demo-up-and-running">
|
|
<h1><a class="toc-backref" href="#id8">Quickstart (to get a demo up and running)</a><a class="headerlink" href="#quickstart-to-get-a-demo-up-and-running" title="Permalink to this headline">¶</a></h1>
|
|
<p>When you download a specific release of <em>Converse.js</em> there will be two minified files inside the zip file.</p>
|
|
<ul class="simple">
|
|
<li>builds/converse.min.js</li>
|
|
<li>css/converse.min.css</li>
|
|
</ul>
|
|
<p>You can include these two files inside the <em><head></em> element of your website via the <em>script</em> and <em>link</em>
|
|
tags:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre><link rel="stylesheet" type="text/css" media="screen" href="css/converse.min.css">
|
|
<script src="builds/converse.min.js"></script>
|
|
</pre></div>
|
|
</div>
|
|
<p>You need to initialize Converse.js with configuration settings according to
|
|
your requirements.</p>
|
|
<p>Please refer to the <a class="reference internal" href="#configuration-variables">Configuration variables</a> section further below for info on
|
|
all the available configuration settings.</p>
|
|
<p>To configure Converse.js, put the following inline Javascript code at the
|
|
bottom of your page (after the closing <em></body></em> element).</p>
|
|
<div class="highlight-python"><div class="highlight"><pre>require(['converse'], function (converse) {
|
|
converse.initialize({
|
|
auto_list_rooms: false,
|
|
auto_subscribe: false,
|
|
bosh_service_url: 'https://bind.conversejs.org', // Please use this connection manager only for testing purposes
|
|
hide_muc_server: false,
|
|
i18n: locales.en, // Refer to ./locale/locales.js to see which locales are supported
|
|
prebind: false,
|
|
show_controlbox_by_default: true,
|
|
roster_groups: true
|
|
});
|
|
});
|
|
</pre></div>
|
|
</div>
|
|
<p>The <a class="reference external" href="https://github.com/jcbrand/converse.js/blob/master/index.html">index.html</a> file inside the
|
|
Converse.js repository may serve as a nice usable example.</p>
|
|
<p>These minified files provide the same demo-like functionality as is available
|
|
on the <a class="reference external" href="http://conversejs.org">conversejs.org</a> website. Useful for testing or demoing.</p>
|
|
<p>You’ll most likely want to implement some kind of single persistent session solution for
|
|
your website, where users authenticate once in your website and then stay
|
|
logged in to their XMPP session upon the next page reload.</p>
|
|
<p>For more info on this, read: <a class="reference internal" href="#prebinding-and-single-session-support">Prebinding and Single Session Support</a>.</p>
|
|
<p>You might also want to have more fine-grained control of what gets included in
|
|
the minified Javascript file. Read <a class="reference internal" href="#configuration">Configuration</a> and <a class="reference internal" href="#minification">Minification</a> for more info on how to do
|
|
that.</p>
|
|
</div>
|
|
<div class="section" id="introduction">
|
|
<h1><a class="toc-backref" href="#id9">Introduction</a><a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h1>
|
|
<p>Even though you can connect to public XMPP servers on the <a class="reference external" href="http://conversejs.org">conversejs.org</a>
|
|
website, <em>Converse.js</em> is not really meant to be a “Software-as-a-service” (SaaS)
|
|
webchat.</p>
|
|
<p>Instead, its goal is to provide the means for website owners to add a tightly
|
|
integrated instant messaging service to their own websites.</p>
|
|
<p>As a website owner, you are expected to host <em>Converse.js</em> yourself, and to do some legwork to
|
|
properly configure and integrate it into your site.</p>
|
|
<p>The benefit in doing this, is that your users have a much more streamlined and integrated
|
|
webchat experience and that you have control over the data. The latter being a
|
|
requirement for many sites dealing with sensitive information.</p>
|
|
<p>You’ll need to set up your own XMPP server and in order to have
|
|
<a class="reference internal" href="#session-support">Session Support</a> (i.e. single-signon functionality whereby users are authenticated once and stay
|
|
logged in to XMPP upon page reload) you will likely also have to add some server-side
|
|
code.</p>
|
|
<p>The <a class="reference internal" href="#what-you-will-need">What you will need</a> section has more information on all these
|
|
requirements.</p>
|
|
</div>
|
|
<div class="section" id="features">
|
|
<h1><a class="toc-backref" href="#id10">Features</a><a class="headerlink" href="#features" title="Permalink to this headline">¶</a></h1>
|
|
<div class="section" id="off-the-record-encryption">
|
|
<h2><a class="toc-backref" href="#id11">Off-the-record encryption</a><a class="headerlink" href="#off-the-record-encryption" title="Permalink to this headline">¶</a></h2>
|
|
<p>Converse.js supports <a class="reference external" href="https://otr.cypherpunks.ca/">Off-the-record (OTR)</a>
|
|
encrypted messaging.</p>
|
|
<p>The OTR protocol not only <strong>encrypts your messages</strong>, it provides ways to
|
|
<strong>verify the identity</strong> of the person you are talking to,
|
|
<strong>plausible deniability</strong> and <strong>perfect forward secrecy</strong> by generating
|
|
new encryption keys for each conversation.</p>
|
|
<p>In its current state, Javascript cryptography is fraught with dangers and
|
|
challenges that make it impossible to reach the same standard of security that
|
|
is available with native “desktop” software.</p>
|
|
<p>This is due to its runtime malleability, the way it is “installed” (e.g.
|
|
served) and the browser’s lack of cryptographic primitives needed to implement
|
|
secure crypto.</p>
|
|
<p>For harsh but fairly valid criticism of Javascript cryptography, read:
|
|
<a class="reference external" href="http://www.matasano.com/articles/javascript-cryptography/">Javascript Cryptography Considered Harmful</a>.</p>
|
|
<p>To get an idea on how this applies to OTR support in Converse.js, please read
|
|
<a class="reference external" href="https://opkode.com/media/blog/2013/11/11/conversejs-otr-support">my thoughts on it</a>.</p>
|
|
<p>For now, suffice to say that although its useful to have OTR support in
|
|
Converse.js in order to avoid most eavesdroppers, if you need serious
|
|
communications privacy, then you’re much better off using native software.</p>
|
|
</div>
|
|
<div class="section" id="sound-notifications">
|
|
<h2><a class="toc-backref" href="#id12">Sound Notifications</a><a class="headerlink" href="#sound-notifications" title="Permalink to this headline">¶</a></h2>
|
|
<p>From version 0.8.1 Converse.js can play a sound notification when you receive a
|
|
message.</p>
|
|
<p>For more info, please see the <a class="reference internal" href="#play-sounds">play_sounds</a> configuration setting.</p>
|
|
</div>
|
|
<div class="section" id="multilingual-support">
|
|
<h2><a class="toc-backref" href="#id13">Multilingual Support</a><a class="headerlink" href="#multilingual-support" title="Permalink to this headline">¶</a></h2>
|
|
<p>Converse.js is translated into multiple languages. The default build,
|
|
<tt class="docutils literal"><span class="pre">converse.min.js</span></tt>, includes all languages.</p>
|
|
<p>Languages increase the size of the Converse.js significantly.</p>
|
|
<p>If you only need one, or a subset of the available languages, it’s better to
|
|
make a custom build which includes only those languages that you need.</p>
|
|
</div>
|
|
<div class="section" id="chat-rooms">
|
|
<h2><a class="toc-backref" href="#id14">Chat Rooms</a><a class="headerlink" href="#chat-rooms" title="Permalink to this headline">¶</a></h2>
|
|
<div class="section" id="commands">
|
|
<h3><a class="toc-backref" href="#id15">Commands</a><a class="headerlink" href="#commands" title="Permalink to this headline">¶</a></h3>
|
|
<p>Here are the different commands that may be used in a chat room:</p>
|
|
<table border="1" class="docutils">
|
|
<colgroup>
|
|
<col width="7%" />
|
|
<col width="56%" />
|
|
<col width="37%" />
|
|
</colgroup>
|
|
<thead valign="bottom">
|
|
<tr class="row-odd"><th class="head">Event Type</th>
|
|
<th class="head">When is it triggered?</th>
|
|
<th class="head">Example (substitue $nickname with an actual user’s nickname)</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody valign="top">
|
|
<tr class="row-even"><td><strong>ban</strong></td>
|
|
<td>Ban a user from the chat room. They will not be able to join again.</td>
|
|
<td>/ban $nickname</td>
|
|
</tr>
|
|
<tr class="row-odd"><td><strong>clear</strong></td>
|
|
<td>Clear the messages shown in the chat room.</td>
|
|
<td>/clear</td>
|
|
</tr>
|
|
<tr class="row-even"><td><strong>deop</strong></td>
|
|
<td>Make a moderator a normal participant.</td>
|
|
<td>/deop $nickname [$reason]</td>
|
|
</tr>
|
|
<tr class="row-odd"><td><strong>help</strong></td>
|
|
<td>Show the list of available commands.</td>
|
|
<td>/help</td>
|
|
</tr>
|
|
<tr class="row-even"><td><strong>kick</strong></td>
|
|
<td>Kick a user out of a room. They will be able to join again.</td>
|
|
<td>/kick $nickname [$reason]</td>
|
|
</tr>
|
|
<tr class="row-odd"><td><strong>me</strong></td>
|
|
<td>Speak in the 3rd person.</td>
|
|
<td>/me $message</td>
|
|
</tr>
|
|
<tr class="row-even"><td><strong>mute</strong></td>
|
|
<td>Remove a user’s ability to post messages to the room. They will still be able to observe.</td>
|
|
<td>/mute $nickname [$reason]</td>
|
|
</tr>
|
|
<tr class="row-odd"><td><strong>nick</strong></td>
|
|
<td>Change your nickname.</td>
|
|
<td>/nick $nickname</td>
|
|
</tr>
|
|
<tr class="row-even"><td><strong>op</strong></td>
|
|
<td>Make a normal participant a moderator.</td>
|
|
<td>/op $nickname [$reason]</td>
|
|
</tr>
|
|
<tr class="row-odd"><td><strong>topic</strong></td>
|
|
<td>Set the topic of the chat room.</td>
|
|
<td>/topic ${topic text}</td>
|
|
</tr>
|
|
<tr class="row-even"><td><strong>voice</strong></td>
|
|
<td>Allow a muted user to post messages to the room.</td>
|
|
<td>/voice $nickname [$reason]</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="what-you-will-need">
|
|
<h1><a class="toc-backref" href="#id16">What you will need</a><a class="headerlink" href="#what-you-will-need" title="Permalink to this headline">¶</a></h1>
|
|
<div class="section" id="an-xmpp-server">
|
|
<h2><a class="toc-backref" href="#id17">An XMPP server</a><a class="headerlink" href="#an-xmpp-server" title="Permalink to this headline">¶</a></h2>
|
|
<p><em>Converse.js</em> implements <a class="reference external" href="https://en.wikipedia.org/wiki/Xmpp">XMPP</a> as its messaging protocol, and therefore needs
|
|
to connect to an XMPP/Jabber server (Jabber is really just a synonym for XMPP).</p>
|
|
<p>You can connect to public XMPP servers like <tt class="docutils literal"><span class="pre">jabber.org</span></tt> but if you want to
|
|
have <a class="reference internal" href="#session-support">Session Support</a> you’ll have to set up your own XMPP server.</p>
|
|
<p>You can find a list of public XMPP servers/providers on <a class="reference external" href="http://xmpp.net">xmpp.net</a> and a list of
|
|
servers that you can set up yourself on <a class="reference external" href="http://xmpp.org/xmpp-software/servers/">xmpp.org</a>.</p>
|
|
</div>
|
|
<div class="section" id="a-bosh-connection-manager">
|
|
<h2><a class="toc-backref" href="#id18">A BOSH Connection Manager</a><a class="headerlink" href="#a-bosh-connection-manager" title="Permalink to this headline">¶</a></h2>
|
|
<p>Your website and <em>Converse.js</em> use <a class="reference external" href="https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol">HTTP</a> as protocol to communicate with
|
|
the webserver. HTTP connections are stateless and usually shortlived.</p>
|
|
<p><a class="reference external" href="https://en.wikipedia.org/wiki/Xmpp">XMPP</a> on the other hand, is the protocol that enables instant messaging, and
|
|
its connections are stateful and usually longer.</p>
|
|
<p>To enable a web application like <em>Converse.js</em> to communicate with an XMPP
|
|
server, we need a proxy in the middle that can act as a bridge between the two
|
|
protocols.</p>
|
|
<p>The <a class="reference external" href="https://github.com/jcbrand/converse.js/blob/master/index.html">index.html</a> file inside the</p>
|
|
<p>This is the job of a connection manager. A connection manager can be either a
|
|
standalone application or part of an XMPP server. Popular XMPP servers such as
|
|
<a class="reference external" href="http://www.ejabberd.im">ejabberd</a>, <a class="reference external" href="http://prosody.im/doc/setting_up_bosh">prosody</a> and
|
|
<a class="reference external" href="http://www.igniterealtime.org/projects/openfire/">openfire</a> all include their own connection managers
|
|
(but you usually have to enable them in the configuration).</p>
|
|
<p>Standalone connection managers also exist, see for example <a class="reference external" href="https://github.com/twonds/punjab">Punjab</a>.</p>
|
|
<p>The demo on the <a class="reference external" href="http://conversejs.org">Converse.js homepage</a> uses a connection manager located at <a class="reference external" href="https://bind.conversejs.org">https://bind.conversejs.org</a>.
|
|
This connection manager is available for testing purposes only, please don’t use it in production.</p>
|
|
<div class="section" id="overcoming-cross-domain-request-restrictions">
|
|
<h3><a class="toc-backref" href="#id19">Overcoming cross-domain request restrictions</a><a class="headerlink" href="#overcoming-cross-domain-request-restrictions" title="Permalink to this headline">¶</a></h3>
|
|
<p>Lets say your domain is <em>example.org</em>, but the domain of your connection
|
|
manager is <em>example.com</em>.</p>
|
|
<p>HTTP requests are made by <em>Converse.js</em> to the connection manager via XmlHttpRequests (XHR).
|
|
Until recently, it was not possible to make such requests to a different domain
|
|
than the one currently being served (to prevent XSS attacks).</p>
|
|
<p>Luckily there is now a standard called <a class="reference external" href="https://en.wikipedia.org/wiki/Cross-origin_resource_sharing">CORS</a> (Cross-origin resource sharing), which enables exactly that.
|
|
Modern browsers support CORS, but there are problems with Internet Explorer <
|
|
10.</p>
|
|
<p>IE 8 and 9 partially support CORS via a proprietary implementation called
|
|
XDomainRequest. There is a <a class="reference external" href="https://gist.github.com/1095825/6b4517276f26b66b01fa97b0a78c01275fdc6ff2">Strophe.js plugin</a> which you can use to enable
|
|
support for XDomainRequest when it is present.</p>
|
|
<p>In IE < 8, there is no support for CORS.</p>
|
|
<p>Instead of using CORS, you can add a reverse proxy in
|
|
Apache/Nginx which serves the connection manager under the same domain as your
|
|
website. This will remove the need for any cross-domain XHR support.</p>
|
|
<div class="section" id="for-example">
|
|
<h4>For example:<a class="headerlink" href="#for-example" title="Permalink to this headline">¶</a></h4>
|
|
<p>Assuming your site is accessible on port <tt class="docutils literal"><span class="pre">80</span></tt> for the domain <tt class="docutils literal"><span class="pre">mysite.com</span></tt>
|
|
and your connection manager manager is running at <tt class="docutils literal"><span class="pre">someothersite.com/http-bind</span></tt>.</p>
|
|
<p>The <em>bosh_service_url</em> value you want to give Converse.js to overcome
|
|
the cross-domain restriction is <tt class="docutils literal"><span class="pre">mysite.com/http-bind</span></tt> and not
|
|
<tt class="docutils literal"><span class="pre">someothersite.com/http-bind</span></tt>.</p>
|
|
<p>Your <tt class="docutils literal"><span class="pre">nginx</span></tt> or <tt class="docutils literal"><span class="pre">apache</span></tt> configuration will look as follows:</p>
|
|
</div>
|
|
<div class="section" id="nginx">
|
|
<h4>Nginx<a class="headerlink" href="#nginx" title="Permalink to this headline">¶</a></h4>
|
|
<div class="highlight-python"><div class="highlight"><pre>http {
|
|
server {
|
|
listen 80
|
|
server_name mysite.com;
|
|
location ~ ^/http-bind/ {
|
|
proxy_pass http://someothersite.com;
|
|
}
|
|
}
|
|
}
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="apache">
|
|
<h4>Apache<a class="headerlink" href="#apache" title="Permalink to this headline">¶</a></h4>
|
|
<div class="highlight-python"><div class="highlight"><pre><VirtualHost *:80>
|
|
ServerName mysite.com
|
|
RewriteEngine On
|
|
RewriteRule ^/http-bind(.*) http://someothersite.com/http-bind$1 [P,L]
|
|
</VirtualHost>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="server-side-authentication">
|
|
<h2><a class="toc-backref" href="#id20">Server-side authentication</a><a class="headerlink" href="#server-side-authentication" title="Permalink to this headline">¶</a></h2>
|
|
<div class="section" id="prebinding-and-single-session-support">
|
|
<span id="session-support"></span><h3><a class="toc-backref" href="#id21">Prebinding and Single Session Support</a><a class="headerlink" href="#prebinding-and-single-session-support" title="Permalink to this headline">¶</a></h3>
|
|
<p>It’s possible to enable single-site login, whereby users already
|
|
authenticated in your website will also automatically be logged in on the chat server,</p>
|
|
<p>This session should also persist across page loads. In other words, we don’t
|
|
want the user to have to give their chat credentials every time they reload the
|
|
page.</p>
|
|
<p>To do this you will require a <a class="reference external" href="http://xmpp.org/about-xmpp/technology-overview/bosh/">BOSH server</a>
|
|
for converse.js to connect to (see the <a class="reference internal" href="#bosh-service-url">bosh_service_url</a> under <a class="reference internal" href="#configuration-variables">Configuration variables</a>)
|
|
as well as a BOSH client on your own server (written for example in Python, Ruby or PHP) that will
|
|
do the pre-authentication before the web page loads.</p>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">A BOSH server acts as a bridge between HTTP, the protocol of the web, and
|
|
XMPP, the instant messaging protocol.
|
|
Converse.js can only communicate via HTTP, but we need to communicate with
|
|
an XMPP server in order to chat. So the BOSH server acts as a middle man,
|
|
translating our HTTP requests into XMPP stanzas and vice versa.</p>
|
|
</div>
|
|
<p>Jack Moffitt has a great <a class="reference external" href="http://metajack.im/2008/10/03/getting-attached-to-strophe">blogpost</a> about this and even provides an <a class="reference external" href="https://github.com/metajack/strophejs/tree/master/examples/attach">example Django application</a> to demonstrate it.</p>
|
|
<p>When you authenticate to the XMPP server on your backend application (for
|
|
example via a BOSH client in Django), you’ll receive two tokens, RID (request ID) and SID (session ID).</p>
|
|
<p>The <strong>Session ID (SID)</strong> is a unique identifier for the current <em>session</em>. This
|
|
number stays constant for the entire session.</p>
|
|
<p>The <strong>Request ID (RID)</strong> is a unique identifier for the current <em>request</em> (i.e.
|
|
page load). Each page load is a new request which requires a new unique RID.
|
|
The best way to achieve this is to simply increment the RID with each page
|
|
load.</p>
|
|
<p>When you initialize converse.js in your browser, you need to pass it these two
|
|
tokens. Converse.js will then use them to attach to the session you just
|
|
created.</p>
|
|
<p>You can embed the RID and SID tokens in your HTML markup or you can do an
|
|
XMLHttpRequest call to your server and ask it to return them for you.</p>
|
|
<p>Below is one example of how this could work. An Ajax call is made to the
|
|
relative URL <strong>/prebind</strong> and it expects to receive JSON data back.</p>
|
|
<div class="highlight-python"><div class="highlight"><pre>$.getJSON('/prebind', function (data) {
|
|
converse.initialize({
|
|
prebind: true,
|
|
bosh_service_url: data.bosh_service_url,
|
|
jid: data.jid,
|
|
sid: data.sid,
|
|
rid: data.rid
|
|
});
|
|
);
|
|
</pre></div>
|
|
</div>
|
|
<p><strong>Here’s what’s happening:</strong></p>
|
|
<p>The JSON data returned from the Ajax call to example.com/prebind contains the user’s JID (jabber ID), RID, SID and the URL to the
|
|
BOSH server (also called a <em>connection manager</em>).</p>
|
|
<p>These values are then passed to converse.js’s <tt class="docutils literal"><span class="pre">initialize</span></tt> method.</p>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">If you want to enable single session support, you need to set <strong>prebind: true</strong>
|
|
when calling <strong>converse.initialize</strong> (see ./index.html).
|
|
Additionally you need to pass in valid <strong>jid</strong>, <strong>sid</strong>, <strong>rid</strong> and
|
|
<strong>bosh_service_url</strong> values.</p>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="example-code-for-server-side-prebinding">
|
|
<h3><a class="toc-backref" href="#id22">Example code for server-side prebinding</a><a class="headerlink" href="#example-code-for-server-side-prebinding" title="Permalink to this headline">¶</a></h3>
|
|
<ul>
|
|
<li><dl class="first docutils">
|
|
<dt>PHP:</dt>
|
|
<dd><p class="first last">See <a class="reference external" href="https://github.com/candy-chat/xmpp-prebind-php">xmpp-prebind-php</a> by
|
|
Michael Weibel and the folks from Candy chat.</p>
|
|
</dd>
|
|
</dl>
|
|
</li>
|
|
<li><dl class="first docutils">
|
|
<dt>Python:</dt>
|
|
<dd><p class="first last">See this <a class="reference external" href="https://github.com/metajack/strophejs/tree/master/examples/attach">example Django application</a> by Jack Moffitt.</p>
|
|
</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="development">
|
|
<h1><a class="toc-backref" href="#id23">Development</a><a class="headerlink" href="#development" title="Permalink to this headline">¶</a></h1>
|
|
<p>If you want to work with the non-minified Javascript and CSS files you’ll soon
|
|
notice that there are references to a missing <em>components</em> folder. Please
|
|
follow the instructions below to create this folder and fetch Converse’s
|
|
3rd-party dependencies.</p>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">Users have reported that converse.js cannot be built on Windows. Patches to
|
|
fix this are welcome.</p>
|
|
</div>
|
|
<div class="section" id="install-the-development-and-front-end-dependencies">
|
|
<h2><a class="toc-backref" href="#id24">Install the development and front-end dependencies</a><a class="headerlink" href="#install-the-development-and-front-end-dependencies" title="Permalink to this headline">¶</a></h2>
|
|
<p>We use development tools (<a class="reference external" href="http://gruntjs.com">Grunt</a> and <a class="reference external" href="http://bower.io">Bower</a>)
|
|
which depend on Node.js and npm (the Node package manager).</p>
|
|
<p>If you don’t have Node.js installed, you can download and install the latest
|
|
version <a class="reference external" href="https://nodejs.org/download">here</a>.</p>
|
|
<p>Also make sure you have <tt class="docutils literal"><span class="pre">git</span></tt> installed. <a class="reference external" href="http://git-scm.com/book/en/Getting-Started-Installing-Git">Details</a>.</p>
|
|
<p>Once you have <em>Node.js</em> and <em>git</em> installed, run the following command inside the Converse.js
|
|
directory:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre>make dev
|
|
</pre></div>
|
|
</div>
|
|
<p>Or alternatively, if you don’t have GNU Make:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre>npm install
|
|
bower update
|
|
</pre></div>
|
|
</div>
|
|
<p>This will first install the Node.js development tools (like Grunt and Bower)
|
|
and then use Bower to install all of Converse.js’s front-end dependencies.</p>
|
|
<p>The front-end dependencies are those javascript files on which
|
|
Converse.js directly depends and which will be loaded in the browser.</p>
|
|
<p>If you are curious to know what the different dependencies are:</p>
|
|
<ul>
|
|
<li><dl class="first docutils">
|
|
<dt>Development dependencies:</dt>
|
|
<dd><p class="first last">Take a look at whats under the <em>devDependencies</em> key in
|
|
<a class="reference external" href="https://github.com/jcbrand/converse.js/blob/master/package.json">package.json</a>.</p>
|
|
</dd>
|
|
</dl>
|
|
</li>
|
|
<li><dl class="first docutils">
|
|
<dt>Front-end dependencies:</dt>
|
|
<dd><p class="first last">See <em>dependencies</em> in
|
|
<a class="reference external" href="https://github.com/jcbrand/converse.js/blob/master/bower.json">bower.json</a>.</p>
|
|
</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">After running <tt class="docutils literal"><span class="pre">`make</span> <span class="pre">dev`</span></tt>, you should now have a new directory <em>components</em>,
|
|
which contains all the front-end dependencies of Converse.js.
|
|
If this directory does NOT exist, something must have gone wrong.
|
|
Double-check the output of <tt class="docutils literal"><span class="pre">`make</span> <span class="pre">dev`</span></tt> to see if there are any errors
|
|
listed. For support, you can write to the mailing list: <a class="reference external" href="mailto:conversejs%40librelist.com">conversejs<span>@</span>librelist<span>.</span>com</a></p>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="with-amd-and-require-js-recommended">
|
|
<h2><a class="toc-backref" href="#id25">With AMD and require.js (recommended)</a><a class="headerlink" href="#with-amd-and-require-js-recommended" title="Permalink to this headline">¶</a></h2>
|
|
<p>Converse.js uses <a class="reference external" href="http://requirejs.org">require.js</a> to asynchronously load dependencies.</p>
|
|
<p>If you want to develop or customize converse.js, you’ll want to load the
|
|
non-minified javascript files.</p>
|
|
<p>Add the following two lines to the <em><head></em> section of your webpage:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre><link rel="stylesheet" type="text/css" media="screen" href="converse.css">
|
|
<script data-main="main" src="components/requirejs/require.js"></script>
|
|
</pre></div>
|
|
</div>
|
|
<p>require.js will then let the main.js file be parsed (because of the <em>data-main</em>
|
|
attribute on the <em>script</em> tag), which will in turn cause converse.js to be
|
|
parsed.</p>
|
|
</div>
|
|
<div class="section" id="without-amd-and-require-js">
|
|
<h2><a class="toc-backref" href="#id26">Without AMD and require.js</a><a class="headerlink" href="#without-amd-and-require-js" title="Permalink to this headline">¶</a></h2>
|
|
<p>Converse.js can also be used without require.js. If you for some reason prefer
|
|
to use it this way, please refer to
|
|
<a class="reference external" href="https://github.com/jcbrand/converse.js/blob/master/non_amd.html">non_amd.html</a>
|
|
for an example of how and in what order all the Javascript files that converse.js
|
|
depends on need to be loaded.</p>
|
|
</div>
|
|
<div class="section" id="before-submitting-a-pull-request">
|
|
<h2><a class="toc-backref" href="#id27">Before submitting a pull request</a><a class="headerlink" href="#before-submitting-a-pull-request" title="Permalink to this headline">¶</a></h2>
|
|
<div class="section" id="add-tests-for-your-bugfix-or-feature">
|
|
<h3><a class="toc-backref" href="#id28">Add tests for your bugfix or feature</a><a class="headerlink" href="#add-tests-for-your-bugfix-or-feature" title="Permalink to this headline">¶</a></h3>
|
|
<p>Add a test for any bug fixed or feature added. We use Jasmine
|
|
for testing.</p>
|
|
<p>Take a look at <tt class="docutils literal"><span class="pre">tests.html</span></tt> and <tt class="docutils literal"><span class="pre">spec/MainSpec.js</span></tt> to see how
|
|
the tests are implemented.</p>
|
|
<p>If you are unsure how to write tests, please
|
|
<a class="reference external" href="http://opkode.com/contact">contact me</a> and I’ll be happy to help.</p>
|
|
</div>
|
|
<div class="section" id="check-that-the-tests-pass">
|
|
<h3><a class="toc-backref" href="#id29">Check that the tests pass</a><a class="headerlink" href="#check-that-the-tests-pass" title="Permalink to this headline">¶</a></h3>
|
|
<p>Check that the Jasmine tests complete sucessfully. Open
|
|
<a class="reference external" href="https://github.com/jcbrand/converse.js/blob/master/tests.html">tests.html</a>
|
|
in your browser, and the tests will run automatically.</p>
|
|
<p>On the command line you can run:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre>grunt test
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="check-your-code-for-errors-or-bad-habits-by-running-jshint">
|
|
<h3><a class="toc-backref" href="#id30">Check your code for errors or bad habits by running JSHint</a><a class="headerlink" href="#check-your-code-for-errors-or-bad-habits-by-running-jshint" title="Permalink to this headline">¶</a></h3>
|
|
<p><a class="reference external" href="http://jshint.com">JSHint</a> will do a static analysis of your code and hightlight potential errors
|
|
and/or bad habits.</p>
|
|
<div class="highlight-python"><div class="highlight"><pre>grunt jshint
|
|
</pre></div>
|
|
</div>
|
|
<p>You can run both the tests and jshint in one go by calling:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre>grunt check
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="developer-api">
|
|
<h2><a class="toc-backref" href="#id31">Developer API</a><a class="headerlink" href="#developer-api" title="Permalink to this headline">¶</a></h2>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">The API documented here is available in Converse.js 0.8.4 and higher.
|
|
Earlier versions of Converse.js might have different API methods or none at all.</p>
|
|
</div>
|
|
<p>In the Converse.js API, you traverse towards a logical grouping, from
|
|
which you can then call certain standardised accessors and mutators, like:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre>.get
|
|
.set
|
|
.add
|
|
.all
|
|
.remove
|
|
</pre></div>
|
|
</div>
|
|
<p>This is done to increase readability and to allow intuitive method chaining.</p>
|
|
<p>For example, to get a contact, you would do the following:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre><span class="n">converse</span><span class="o">.</span><span class="n">contacts</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'jid@example.com'</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>To get multiple contacts, just pass in an array of jids:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre><span class="n">converse</span><span class="o">.</span><span class="n">contacts</span><span class="o">.</span><span class="n">get</span><span class="p">([</span><span class="s">'jid1@example.com'</span><span class="p">,</span> <span class="s">'jid2@example.com'</span><span class="p">]);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p><strong>Here follows now a breakdown of all API groupings and methods</strong>:</p>
|
|
<div class="section" id="initialize">
|
|
<h3><a class="toc-backref" href="#id32">initialize</a><a class="headerlink" href="#initialize" title="Permalink to this headline">¶</a></h3>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">This method is the one exception of a method which is not logically grouped
|
|
as explained above.</p>
|
|
</div>
|
|
<p>Initializes converse.js. This method must always be called when using
|
|
converse.js.</p>
|
|
<p>The <cite>initialize</cite> method takes a map (also called a hash or dictionary) of
|
|
<a class="reference internal" href="#configuration-variables">configuration variables</a>.</p>
|
|
<p>Example:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre><span class="n">converse</span><span class="o">.</span><span class="n">initialize</span><span class="p">({</span>
|
|
<span class="n">allow_otr</span><span class="p">:</span> <span class="n">true</span><span class="p">,</span>
|
|
<span class="n">auto_list_rooms</span><span class="p">:</span> <span class="n">false</span><span class="p">,</span>
|
|
<span class="n">auto_subscribe</span><span class="p">:</span> <span class="n">false</span><span class="p">,</span>
|
|
<span class="n">bosh_service_url</span><span class="p">:</span> <span class="s">'https://bind.example.com'</span><span class="p">,</span>
|
|
<span class="n">hide_muc_server</span><span class="p">:</span> <span class="n">false</span><span class="p">,</span>
|
|
<span class="n">i18n</span><span class="p">:</span> <span class="n">locales</span><span class="p">[</span><span class="s">'en'</span><span class="p">],</span>
|
|
<span class="n">keepalive</span><span class="p">:</span> <span class="n">true</span><span class="p">,</span>
|
|
<span class="n">play_sounds</span><span class="p">:</span> <span class="n">true</span><span class="p">,</span>
|
|
<span class="n">prebind</span><span class="p">:</span> <span class="n">false</span><span class="p">,</span>
|
|
<span class="n">show_controlbox_by_default</span><span class="p">:</span> <span class="n">true</span><span class="p">,</span>
|
|
<span class="n">debug</span><span class="p">:</span> <span class="n">false</span><span class="p">,</span>
|
|
<span class="n">roster_groups</span><span class="p">:</span> <span class="n">true</span>
|
|
<span class="p">});</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="contacts-grouping">
|
|
<h3><a class="toc-backref" href="#id33">“contacts” grouping</a><a class="headerlink" href="#contacts-grouping" title="Permalink to this headline">¶</a></h3>
|
|
<div class="section" id="get">
|
|
<h4>get<a class="headerlink" href="#get" title="Permalink to this headline">¶</a></h4>
|
|
<p>Returns a map of attributes for a given buddy (i.e. roster contact), specified
|
|
by JID (Jabber ID).</p>
|
|
<p>Example:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre><span class="n">converse</span><span class="o">.</span><span class="n">contacts</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'buddy@example.com'</span><span class="p">)</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>The map of attributes:</p>
|
|
<table border="1" class="docutils">
|
|
<colgroup>
|
|
<col width="11%" />
|
|
<col width="89%" />
|
|
</colgroup>
|
|
<thead valign="bottom">
|
|
<tr class="row-odd"><th class="head">Attribute</th>
|
|
<th class="head"> </th>
|
|
</tr>
|
|
</thead>
|
|
<tbody valign="top">
|
|
<tr class="row-even"><td>ask</td>
|
|
<td>If ask === ‘subscribe’, then we have asked this person to be our chat buddy.</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>fullname</td>
|
|
<td>The person’s full name.</td>
|
|
</tr>
|
|
<tr class="row-even"><td>jid</td>
|
|
<td>The person’s Jabber/XMPP username.</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>requesting</td>
|
|
<td>If true, then this person is asking to be our chat buddy.</td>
|
|
</tr>
|
|
<tr class="row-even"><td>subscription</td>
|
|
<td>The subscription state between the current user and this chat buddy. Can be <cite>none</cite>, <cite>to</cite>, <cite>from</cite> or <cite>both</cite>.</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>id</td>
|
|
<td>A unique id, same as the jid.</td>
|
|
</tr>
|
|
<tr class="row-even"><td>chat_status</td>
|
|
<td>The person’s chat status. Can be <cite>online</cite>, <cite>offline</cite>, <cite>busy</cite>, <cite>xa</cite> (extended away) or <cite>away</cite>.</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>user_id</td>
|
|
<td>The user id part of the JID (the part before the <cite>@</cite>).</td>
|
|
</tr>
|
|
<tr class="row-even"><td>resources</td>
|
|
<td>The known resources for this chat buddy. Each resource denotes a separate and connected chat client.</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>groups</td>
|
|
<td>The roster groups in which this chat buddy was placed.</td>
|
|
</tr>
|
|
<tr class="row-even"><td>status</td>
|
|
<td>Their human readable custom status message.</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>image_type</td>
|
|
<td>The image’s file type.</td>
|
|
</tr>
|
|
<tr class="row-even"><td>image</td>
|
|
<td>The Base64 encoded image data.</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>url</td>
|
|
<td>The buddy’s website URL, as specified in their VCard data.</td>
|
|
</tr>
|
|
<tr class="row-even"><td>vcard_updated</td>
|
|
<td>When last the buddy’s VCard was updated.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="chats-grouping">
|
|
<h3><a class="toc-backref" href="#id34">“chats” grouping</a><a class="headerlink" href="#chats-grouping" title="Permalink to this headline">¶</a></h3>
|
|
<div class="section" id="id2">
|
|
<h4>get<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h4>
|
|
<p>Returns an object/map representing a chat box (without opening or affecting that chat box).</p>
|
|
<p>Example:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre><span class="n">converse</span><span class="o">.</span><span class="n">chats</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'buddy@example.com'</span><span class="p">)</span>
|
|
</pre></div>
|
|
</div>
|
|
<p><em>The returned chat box contains the following methods:</em></p>
|
|
<table border="1" class="docutils">
|
|
<colgroup>
|
|
<col width="24%" />
|
|
<col width="76%" />
|
|
</colgroup>
|
|
<thead valign="bottom">
|
|
<tr class="row-odd"><th class="head">Method</th>
|
|
<th class="head">Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody valign="top">
|
|
<tr class="row-even"><td>endOTR</td>
|
|
<td>End an OTR (Off-the-record) session.</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>get</td>
|
|
<td>Get an attribute (i.e. accessor).</td>
|
|
</tr>
|
|
<tr class="row-even"><td>initiateOTR</td>
|
|
<td>Start an OTR (off-the-record) session.</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>maximize</td>
|
|
<td>Minimize the chat box.</td>
|
|
</tr>
|
|
<tr class="row-even"><td>minimize</td>
|
|
<td>Maximize the chat box.</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>set</td>
|
|
<td>Set an attribute (i.e. mutator).</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p><em>The get and set methods can be used to retrieve and change the following attributes:</em></p>
|
|
<table border="1" class="docutils">
|
|
<colgroup>
|
|
<col width="20%" />
|
|
<col width="80%" />
|
|
</colgroup>
|
|
<thead valign="bottom">
|
|
<tr class="row-odd"><th class="head">Attribute</th>
|
|
<th class="head">Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody valign="top">
|
|
<tr class="row-even"><td>height</td>
|
|
<td>The height of the chat box.</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>url</td>
|
|
<td>The URL of the chat box heading.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="tokens-grouping">
|
|
<h3><a class="toc-backref" href="#id35">“tokens” grouping</a><a class="headerlink" href="#tokens-grouping" title="Permalink to this headline">¶</a></h3>
|
|
<div class="section" id="id3">
|
|
<h4>get<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h4>
|
|
<p>Returns a token, either the RID or SID token depending on what’s asked for.</p>
|
|
<p>Example:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre><span class="n">converse</span><span class="o">.</span><span class="n">tokens</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'rid'</span><span class="p">)</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="listen-grouping">
|
|
<h3><a class="toc-backref" href="#id36">“listen” grouping</a><a class="headerlink" href="#listen-grouping" title="Permalink to this headline">¶</a></h3>
|
|
<p>Converse.js emits events to which you can subscribe from your own Javascript.</p>
|
|
<p>Concerning events, the following methods are available under the “listen”
|
|
grouping:</p>
|
|
<ul>
|
|
<li><p class="first"><strong>on(eventName, callback)</strong>:</p>
|
|
<blockquote>
|
|
<div><p>Calling the <tt class="docutils literal"><span class="pre">on</span></tt> method allows you to subscribe to an event.
|
|
Every time the event fires, the callback method specified by <tt class="docutils literal"><span class="pre">callback</span></tt> will be
|
|
called.</p>
|
|
<p>Parameters:</p>
|
|
<ul class="simple">
|
|
<li><tt class="docutils literal"><span class="pre">eventName</span></tt> is the event name as a string.</li>
|
|
<li><tt class="docutils literal"><span class="pre">callback</span></tt> is the callback method to be called when the event is emitted.</li>
|
|
</ul>
|
|
<p>For example:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre>converse.listen.on('message', function (messageXML) { ... });
|
|
</pre></div>
|
|
</div>
|
|
</div></blockquote>
|
|
</li>
|
|
<li><p class="first"><strong>once(eventName, callback)</strong>:</p>
|
|
<blockquote>
|
|
<div><p>Calling the <tt class="docutils literal"><span class="pre">once</span></tt> method allows you to listen to an event
|
|
exactly once.</p>
|
|
<p>Parameters:</p>
|
|
<ul class="simple">
|
|
<li><tt class="docutils literal"><span class="pre">eventName</span></tt> is the event name as a string.</li>
|
|
<li><tt class="docutils literal"><span class="pre">callback</span></tt> is the callback method to be called when the event is emitted.</li>
|
|
</ul>
|
|
<p>For example:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre>converse.listen.once('message', function (messageXML) { ... });
|
|
</pre></div>
|
|
</div>
|
|
</div></blockquote>
|
|
</li>
|
|
<li><p class="first"><strong>not(eventName, callback)</strong></p>
|
|
<blockquote>
|
|
<div><p>To stop listening to an event, you can use the <tt class="docutils literal"><span class="pre">not</span></tt> method.</p>
|
|
<p>Parameters:</p>
|
|
<ul class="simple">
|
|
<li><tt class="docutils literal"><span class="pre">eventName</span></tt> is the event name as a string.</li>
|
|
<li><tt class="docutils literal"><span class="pre">callback</span></tt> refers to the function that is to be no longer executed.</li>
|
|
</ul>
|
|
<p>For example:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre>converse.listen.not('message', function (messageXML) { ... });
|
|
</pre></div>
|
|
</div>
|
|
</div></blockquote>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="events">
|
|
<h2><a class="toc-backref" href="#id37">Events</a><a class="headerlink" href="#events" title="Permalink to this headline">¶</a></h2>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">see also the <a class="reference internal" href="#listen-grouping">“listen” grouping</a> API section above.</p>
|
|
</div>
|
|
<div class="section" id="event-types">
|
|
<h3><a class="toc-backref" href="#id38">Event Types</a><a class="headerlink" href="#event-types" title="Permalink to this headline">¶</a></h3>
|
|
<p>Here are the different events that are emitted:</p>
|
|
<table border="1" class="docutils">
|
|
<colgroup>
|
|
<col width="15%" />
|
|
<col width="45%" />
|
|
<col width="40%" />
|
|
</colgroup>
|
|
<thead valign="bottom">
|
|
<tr class="row-odd"><th class="head">Event Type</th>
|
|
<th class="head">When is it triggered?</th>
|
|
<th class="head">Example</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody valign="top">
|
|
<tr class="row-even"><td><strong>initialized</strong></td>
|
|
<td>Once converse.js has been initialized.</td>
|
|
<td><tt class="docutils literal"><span class="pre">converse.on('initialized',</span> <span class="pre">function</span> <span class="pre">()</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
|
|
</tr>
|
|
<tr class="row-odd"><td><strong>ready</strong></td>
|
|
<td>After connection has been established and converse.js has got all its ducks in a row.</td>
|
|
<td><tt class="docutils literal"><span class="pre">converse.on('ready',</span> <span class="pre">function</span> <span class="pre">()</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
|
|
</tr>
|
|
<tr class="row-even"><td><strong>reconnect</strong></td>
|
|
<td>After the connection has dropped. Converse.js will attempt to reconnect when not in prebind mode.</td>
|
|
<td><tt class="docutils literal"><span class="pre">converse.on('reconnect',</span> <span class="pre">function</span> <span class="pre">()</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
|
|
</tr>
|
|
<tr class="row-odd"><td><strong>message</strong></td>
|
|
<td>When a message is received.</td>
|
|
<td><tt class="docutils literal"><span class="pre">converse.on('message',</span> <span class="pre">function</span> <span class="pre">(messageXML)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
|
|
</tr>
|
|
<tr class="row-even"><td><strong>messageSend</strong></td>
|
|
<td>When a message will be sent out.</td>
|
|
<td><tt class="docutils literal"><span class="pre">converse.on('messageSend',</span> <span class="pre">function</span> <span class="pre">(messageText)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
|
|
</tr>
|
|
<tr class="row-odd"><td><strong>noResumeableSession</strong></td>
|
|
<td>When keepalive=true but there aren’t any stored prebind tokens.</td>
|
|
<td><tt class="docutils literal"><span class="pre">converse.on('noResumeableSession',</span> <span class="pre">function</span> <span class="pre">()</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
|
|
</tr>
|
|
<tr class="row-even"><td><strong>roster</strong></td>
|
|
<td>When the roster is updated.</td>
|
|
<td><tt class="docutils literal"><span class="pre">converse.on('roster',</span> <span class="pre">function</span> <span class="pre">(items)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
|
|
</tr>
|
|
<tr class="row-odd"><td><strong>callButtonClicked</strong></td>
|
|
<td>When a call button (i.e. with class .toggle-call) on a chat box has been clicked.</td>
|
|
<td><tt class="docutils literal"><span class="pre">converse.on('callButtonClicked',</span> <span class="pre">function</span> <span class="pre">(connection,</span> <span class="pre">model)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
|
|
</tr>
|
|
<tr class="row-even"><td><strong>chatBoxOpened</strong></td>
|
|
<td>When a chat box has been opened.</td>
|
|
<td><tt class="docutils literal"><span class="pre">converse.on('chatBoxOpened',</span> <span class="pre">function</span> <span class="pre">(chatbox)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
|
|
</tr>
|
|
<tr class="row-odd"><td><strong>chatRoomOpened</strong></td>
|
|
<td>When a chat room has been opened.</td>
|
|
<td><tt class="docutils literal"><span class="pre">converse.on('chatRoomOpened',</span> <span class="pre">function</span> <span class="pre">(chatbox)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
|
|
</tr>
|
|
<tr class="row-even"><td><strong>chatBoxClosed</strong></td>
|
|
<td>When a chat box has been closed.</td>
|
|
<td><tt class="docutils literal"><span class="pre">converse.on('chatBoxClosed',</span> <span class="pre">function</span> <span class="pre">(chatbox)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
|
|
</tr>
|
|
<tr class="row-odd"><td><strong>chatBoxFocused</strong></td>
|
|
<td>When the focus has been moved to a chat box.</td>
|
|
<td><tt class="docutils literal"><span class="pre">converse.on('chatBoxFocused',</span> <span class="pre">function</span> <span class="pre">(chatbox)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
|
|
</tr>
|
|
<tr class="row-even"><td><strong>chatBoxToggled</strong></td>
|
|
<td>When a chat box has been minimized or maximized.</td>
|
|
<td><tt class="docutils literal"><span class="pre">converse.on('chatBoxToggled',</span> <span class="pre">function</span> <span class="pre">(chatbox)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
|
|
</tr>
|
|
<tr class="row-odd"><td><strong>roomInviteSent</strong></td>
|
|
<td>After the user has sent out a direct invitation, to a roster contact, asking them to join a room.</td>
|
|
<td><tt class="docutils literal"><span class="pre">converse.on('roomInvite',</span> <span class="pre">function</span> <span class="pre">(roomview,</span> <span class="pre">invitee_jid,</span> <span class="pre">reason)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
|
|
</tr>
|
|
<tr class="row-even"><td><strong>roomInviteReceived</strong></td>
|
|
<td>After the user has sent out a direct invitation, to a roster contact, asking them to join a room.</td>
|
|
<td><tt class="docutils literal"><span class="pre">converse.on('roomInvite',</span> <span class="pre">function</span> <span class="pre">(roomview,</span> <span class="pre">invitee_jid,</span> <span class="pre">reason)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
|
|
</tr>
|
|
<tr class="row-odd"><td><strong>statusChanged</strong></td>
|
|
<td>When own chat status has changed.</td>
|
|
<td><tt class="docutils literal"><span class="pre">converse.on('statusChanged',</span> <span class="pre">function</span> <span class="pre">(status)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
|
|
</tr>
|
|
<tr class="row-even"><td><strong>statusMessageChanged</strong></td>
|
|
<td>When own custom status message has changed.</td>
|
|
<td><tt class="docutils literal"><span class="pre">converse.on('statusMessageChanged',</span> <span class="pre">function</span> <span class="pre">(message)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
|
|
</tr>
|
|
<tr class="row-odd"><td><strong>buddyStatusChanged</strong></td>
|
|
<td>When a chat buddy’s chat status has changed.</td>
|
|
<td><tt class="docutils literal"><span class="pre">converse.on('buddyStatusChanged',</span> <span class="pre">function</span> <span class="pre">(buddy,</span> <span class="pre">status)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
|
|
</tr>
|
|
<tr class="row-even"><td><strong>buddyStatusMessageChanged</strong></td>
|
|
<td>When a chat buddy’s custom status message has changed.</td>
|
|
<td><tt class="docutils literal"><span class="pre">converse.on('buddyStatusMessageChanged',</span> <span class="pre">function</span> <span class="pre">(buddy,</span> <span class="pre">messageText)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="minification">
|
|
<h2><a class="toc-backref" href="#id39">Minification</a><a class="headerlink" href="#minification" title="Permalink to this headline">¶</a></h2>
|
|
<div class="section" id="minifying-javascript-and-css">
|
|
<h3><a class="toc-backref" href="#id40">Minifying Javascript and CSS</a><a class="headerlink" href="#minifying-javascript-and-css" title="Permalink to this headline">¶</a></h3>
|
|
<p>Please make sure to read the section <a class="reference internal" href="#development">Development</a> and that you have installed
|
|
all development dependencies (long story short, you can run <tt class="docutils literal"><span class="pre">npm</span> <span class="pre">install</span></tt>
|
|
and then <tt class="docutils literal"><span class="pre">grunt</span> <span class="pre">fetch</span></tt>).</p>
|
|
<p>We use <a class="reference external" href="http://requirejs.org">require.js</a> to keep track of <em>Converse.js</em> and its dependencies and to
|
|
to bundle them together in a single minified file fit for deployment to a
|
|
production site.</p>
|
|
<p>To minify the Javascript and CSS, run the following command:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre>grunt minify
|
|
</pre></div>
|
|
</div>
|
|
<p>Javascript will be bundled and minified with <a class="reference external" href="http://requirejs.org">require.js</a>‘s optimization tool,
|
|
using <a class="reference external" href="https://github.com/jrburke/almond">almond</a>.</p>
|
|
<p>You can <a class="reference external" href="http://requirejs.org/docs/optimization.html">read more about require.js’s optimizer here</a>.</p>
|
|
<p>CSS is minified via <a class="reference external" href="https://github.com/gruntjs/grunt-contrib-cssmin">cssmin</a>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="translations">
|
|
<h2><a class="toc-backref" href="#id41">Translations</a><a class="headerlink" href="#translations" title="Permalink to this headline">¶</a></h2>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">Translations take up a lot of space and will bloat your minified file.
|
|
At the time of writing, all the translations add about 50KB of extra data to
|
|
the minified javascript file. Therefore, make sure to only
|
|
include those languages that you intend to support and remove from
|
|
./locale/locales.js those which you don’t need. Remember to rebuild the
|
|
minified file afterwards.</p>
|
|
</div>
|
|
<p>The gettext POT file located in ./locale/converse.pot is the template
|
|
containing all translations and from which for each language an individual PO
|
|
file is generated.</p>
|
|
<p>The POT file contains all translateable strings extracted from converse.js.</p>
|
|
<p>To make a user facing string translateable, wrap it in the double underscore helper
|
|
function like so:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre><span class="n">__</span><span class="p">(</span><span class="s">'This string will be translated at runtime'</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>After adding the string, you’ll need to regenerate the POT file, like so:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre>make pot
|
|
</pre></div>
|
|
</div>
|
|
<p>To create a new PO file for a language in which converse.js is not yet
|
|
translated into, do the following</p>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">In this example we use Polish (pl), you need to substitute ‘pl’ to your own language’s code.</p>
|
|
</div>
|
|
<div class="highlight-python"><div class="highlight"><pre>mkdir -p ./locale/pl/LC_MESSAGES
|
|
msginit -i ./locale/converse.pot -o ./locale/pl/LC_MESSAGES/converse.po -l pl
|
|
</pre></div>
|
|
</div>
|
|
<p>You can then create or update the PO file for a specific language by doing the following:</p>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">In this example we use German (de), you need to substitute ‘de’ to your own language’s code.</p>
|
|
</div>
|
|
<div class="highlight-python"><div class="highlight"><pre>msgmerge ./locale/de/LC_MESSAGES/converse.po ./locale/converse.pot -U
|
|
</pre></div>
|
|
</div>
|
|
<p>To do this for ALL languages, run:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre>make po
|
|
</pre></div>
|
|
</div>
|
|
<p>The resulting PO file is then what gets translated.</p>
|
|
<p>If you’ve created a new PO file, please make sure to add the following
|
|
attributes at the top of the file (under <em>Content-Transfer-Encoding</em>). They are
|
|
required as configuration settings for Jed, the Javascript translations library
|
|
that we’re using.</p>
|
|
<div class="highlight-python"><div class="highlight"><pre><span class="s">"domain: converse</span><span class="se">\n</span><span class="s">"</span>
|
|
<span class="s">"lang: de</span><span class="se">\n</span><span class="s">"</span>
|
|
<span class="s">"plural_forms: nplurals=2; plural=(n != 1);</span><span class="se">\n</span><span class="s">"</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>Unfortunately <a class="reference external" href="http://slexaxton.github.io/Jed">Jed</a> cannot use the PO files directly. We have to generate from it
|
|
a file in JSON format and then put that in a .js file for the specific
|
|
language.</p>
|
|
<p>To generate JSON from a PO file, you’ll need po2json for node.js. Run the
|
|
following command to install it (npm being the node.js package manager):</p>
|
|
<div class="highlight-python"><div class="highlight"><pre>npm install po2json
|
|
</pre></div>
|
|
</div>
|
|
<p>You can then convert the translations into JSON format:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre>po2json locale/de/LC_MESSAGES/converse.po locale/de/LC_MESSAGES/converse.json
|
|
</pre></div>
|
|
</div>
|
|
<p>Now from converse.json paste the data as a value for the “locale_data” key in the
|
|
object in the language’s .js file.</p>
|
|
<p>So, if you are for example translating into German (language code ‘de’), you’ll
|
|
create or update the file ./locale/LC_MESSAGES/de.js with the following code:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre>(function (root, factory) {
|
|
define("de", ['jed'], function () {
|
|
return factory(new Jed({
|
|
"domain": "converse",
|
|
"locale_data": {
|
|
// Paste the JSON data from converse.json here
|
|
}
|
|
})
|
|
}
|
|
}(this, function (i18n) {
|
|
return i18n;
|
|
}));
|
|
</pre></div>
|
|
</div>
|
|
<p>making sure to also paste the JSON data as value to the “locale_data” key.</p>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">If you are adding translations for a new language that is not already supported,
|
|
you’ll have to add the language path in main.js and make one more edit in ./locale/locales.js
|
|
to make sure the language is loaded by require.js.</p>
|
|
</div>
|
|
<p>Congratulations, you’ve now succesfully added your translations. Sorry for all
|
|
those hoops you had to jump through.</p>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="troubleshooting">
|
|
<h1><a class="toc-backref" href="#id42">Troubleshooting</a><a class="headerlink" href="#troubleshooting" title="Permalink to this headline">¶</a></h1>
|
|
<div class="section" id="conflicts-with-other-javascript-libraries">
|
|
<h2><a class="toc-backref" href="#id43">Conflicts with other Javascript libraries</a><a class="headerlink" href="#conflicts-with-other-javascript-libraries" title="Permalink to this headline">¶</a></h2>
|
|
<div class="section" id="problem">
|
|
<h3><a class="toc-backref" href="#id44">Problem:</a><a class="headerlink" href="#problem" title="Permalink to this headline">¶</a></h3>
|
|
<p>You are using other Javascript libraries (like JQuery plugins), and
|
|
get errors like these in your browser console:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre>Uncaught TypeError: Object [object Object] has no method 'xxx' from example.js
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="solution">
|
|
<h3><a class="toc-backref" href="#id45">Solution:</a><a class="headerlink" href="#solution" title="Permalink to this headline">¶</a></h3>
|
|
<p>First, find out which object is referred to by <tt class="docutils literal"><span class="pre">Object</span> <span class="pre">[object</span> <span class="pre">Object]</span></tt>.</p>
|
|
<p>It will probably be the jQuery object <tt class="docutils literal"><span class="pre">$</span></tt> or perhaps the underscore.js object <tt class="docutils literal"><span class="pre">_</span></tt>.</p>
|
|
<p>For the purpose of demonstration, I’m going to assume its <tt class="docutils literal"><span class="pre">$</span></tt>, but the same
|
|
rules apply if its something else.</p>
|
|
<p>The bundled and minified default build of converse.js, <tt class="docutils literal"><span class="pre">converse.min.js</span></tt>
|
|
includes within it all of converse.js’s dependencies, which include for example <em>jQuery</em>.</p>
|
|
<p>If you are having conflicts where attributes or methods aren’t available
|
|
on the jQuery object, you are probably loading <tt class="docutils literal"><span class="pre">converse.min.js</span></tt> (which
|
|
includes jQuery) as well as your own jQuery version separately.</p>
|
|
<p>What then happens is that there are two <tt class="docutils literal"><span class="pre">$</span></tt> objects (one from
|
|
converse.js and one from the jQuery version you included manually)
|
|
and only one of them has been extended to have the methods or attributes you require.</p>
|
|
<p>Which jQuery object you get depends on the order in which you load the libraries.</p>
|
|
<p>There are multiple ways to solve this issue.</p>
|
|
<p>Firstly, make sure whether you really need to include a separate version of
|
|
jQuery. Chances are that you don’t. If you can remove the separate
|
|
version, your problem should be solved, as long as your libraries are loaded in
|
|
the right order.</p>
|
|
<p>Either case, whether you need to keep two versions or not, the solution depends
|
|
on whether you’ll use require.js to manage your libraries or whether you’ll
|
|
load them manually.</p>
|
|
<div class="section" id="with-require-js">
|
|
<h4>With require.js<a class="headerlink" href="#with-require-js" title="Permalink to this headline">¶</a></h4>
|
|
<p>Instead of using <tt class="docutils literal"><span class="pre">converse.min.js</span></tt>, manage all the libraries in your project
|
|
(i.e. converse.js and its dependencies plus all other libraries you use) as one
|
|
require.js project, making sure everything is loaded in the correct order.</p>
|
|
<p>Then, before deployment, you make your own custom minified build that bundles everything
|
|
you need.</p>
|
|
</div>
|
|
<div class="section" id="with-script-tags">
|
|
<h4>With <script> tags<a class="headerlink" href="#with-script-tags" title="Permalink to this headline">¶</a></h4>
|
|
<p>Take a look at <a class="reference external" href="https://github.com/jcbrand/converse.js/blob/master/non_amd.html">non_amd.html</a>
|
|
in the converse.js repo.</p>
|
|
<p>It shows in which order the libraries must be loaded via <tt class="docutils literal"><span class="pre"><script></span></tt> tags. Add
|
|
your own libraries, making sure that they are loaded in the correct order (e.g.
|
|
jQuery plugins must load after jQuery).</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="configuration">
|
|
<h1><a class="toc-backref" href="#id46">Configuration</a><a class="headerlink" href="#configuration" title="Permalink to this headline">¶</a></h1>
|
|
<p>The included minified JS and CSS files can be used for demoing or testing, but
|
|
you’ll want to configure <em>Converse.js</em> to suit your needs before you deploy it
|
|
on your website.</p>
|
|
<p><em>Converse.js</em> is passed its configuration settings when you call its
|
|
<em>initialize</em> method.</p>
|
|
<p>You’ll most likely want to call the <em>initialize</em> method in your HTML page. For
|
|
an example of how this is done, please see the bottom of the <em>./index.html</em> page.</p>
|
|
<p>Please refer to the <a class="reference internal" href="#configuration-variables">Configuration variables</a> section below for info on
|
|
all the available configuration settings.</p>
|
|
<p>After you have configured <em>Converse.js</em>, you’ll have to regenerate the minified
|
|
JS file so that it will include the new settings. Please refer to the
|
|
<a class="reference internal" href="#minification">Minification</a> section for more info on how to do this.</p>
|
|
<div class="section" id="configuration-variables">
|
|
<h2><a class="toc-backref" href="#id47">Configuration variables</a><a class="headerlink" href="#configuration-variables" title="Permalink to this headline">¶</a></h2>
|
|
<div class="section" id="allow-contact-requests">
|
|
<h3><a class="toc-backref" href="#id48">allow_contact_requests</a><a class="headerlink" href="#allow-contact-requests" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">true</span></tt></p>
|
|
<p>Allow users to add one another as contacts. If this is set to false, the
|
|
<strong>Add a contact</strong> widget, <strong>Contact Requests</strong> and <strong>Pending Contacts</strong> roster
|
|
sections will all not appear. Additionally, all incoming contact requests will be
|
|
ignored.</p>
|
|
</div>
|
|
<div class="section" id="allow-muc">
|
|
<h3><a class="toc-backref" href="#id49">allow_muc</a><a class="headerlink" href="#allow-muc" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">true</span></tt></p>
|
|
<p>Allow multi-user chat (muc) in chatrooms. Setting this to <tt class="docutils literal"><span class="pre">false</span></tt> will remove
|
|
the <tt class="docutils literal"><span class="pre">Chatrooms</span></tt> tab from the control box.</p>
|
|
</div>
|
|
<div class="section" id="allow-otr">
|
|
<h3><a class="toc-backref" href="#id50">allow_otr</a><a class="headerlink" href="#allow-otr" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">true</span></tt></p>
|
|
<p>Allow Off-the-record encryption of single-user chat messages.</p>
|
|
</div>
|
|
<div class="section" id="animate">
|
|
<h3><a class="toc-backref" href="#id51">animate</a><a class="headerlink" href="#animate" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">true</span></tt></p>
|
|
<p>Show animations, for example when opening and closing chat boxes.</p>
|
|
</div>
|
|
<div class="section" id="auto-list-rooms">
|
|
<h3><a class="toc-backref" href="#id52">auto_list_rooms</a><a class="headerlink" href="#auto-list-rooms" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">false</span></tt></p>
|
|
<p>If true, and the XMPP server on which the current user is logged in supports
|
|
multi-user chat, then a list of rooms on that server will be fetched.</p>
|
|
<p>Not recommended for servers with lots of chat rooms.</p>
|
|
<p>For each room on the server a query is made to fetch further details (e.g.
|
|
features, number of occupants etc.), so on servers with many rooms this
|
|
option will create lots of extra connection traffic.</p>
|
|
</div>
|
|
<div class="section" id="auto-reconnect">
|
|
<h3><a class="toc-backref" href="#id53">auto_reconnect</a><a class="headerlink" href="#auto-reconnect" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">true</span></tt></p>
|
|
<p>Automatically reconnect to the XMPP server if the connection drops
|
|
unexpectedly.</p>
|
|
</div>
|
|
<div class="section" id="auto-subscribe">
|
|
<h3><a class="toc-backref" href="#id54">auto_subscribe</a><a class="headerlink" href="#auto-subscribe" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">false</span></tt></p>
|
|
<p>If true, the user will automatically subscribe back to any contact requests.</p>
|
|
</div>
|
|
<div class="section" id="bosh-service-url">
|
|
<h3><a class="toc-backref" href="#id55">bosh_service_url</a><a class="headerlink" href="#bosh-service-url" title="Permalink to this headline">¶</a></h3>
|
|
<p>Connections to an XMPP server depend on a BOSH connection manager which acts as
|
|
a middle man between HTTP and XMPP.</p>
|
|
<p>See <a class="reference external" href="http://metajack.im/2008/09/08/which-bosh-server-do-you-need">here</a> for more information.</p>
|
|
</div>
|
|
<div class="section" id="cache-otr-key">
|
|
<h3><a class="toc-backref" href="#id56">cache_otr_key</a><a class="headerlink" href="#cache-otr-key" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">false</span></tt></p>
|
|
<p>Let the <a class="reference external" href="https://otr.cypherpunks.ca">OTR (Off-the-record encryption)</a> private
|
|
key be cached in your browser’s session storage.</p>
|
|
<p>The browser’s session storage persists across page loads but is deleted once
|
|
the tab or window is closed.</p>
|
|
<p>If this option is set to <tt class="docutils literal"><span class="pre">false</span></tt>, a new OTR private key will be generated
|
|
for each page load. While more inconvenient, this is a much more secure option.</p>
|
|
<p>This setting can only be used together with <tt class="docutils literal"><span class="pre">allow_otr</span> <span class="pre">=</span> <span class="pre">true</span></tt>.</p>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">A browser window’s session storage is accessible by all javascript that
|
|
is served from the same domain. So if there is malicious javascript served by
|
|
the same server (or somehow injected via an attacker), then they will be able
|
|
to retrieve your private key and read your all the chat messages in your
|
|
current session. Previous sessions however cannot be decrypted.</p>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="debug">
|
|
<h3><a class="toc-backref" href="#id57">debug</a><a class="headerlink" href="#debug" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">false</span></tt></p>
|
|
<p>If set to true, debugging output will be logged to the browser console.</p>
|
|
</div>
|
|
<div class="section" id="keepalive">
|
|
<h3><a class="toc-backref" href="#id58">keepalive</a><a class="headerlink" href="#keepalive" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">true</span></tt></p>
|
|
<p>Determines whether Converse.js will maintain the chat session across page
|
|
loads.</p>
|
|
<p>See also:</p>
|
|
<ul class="simple">
|
|
<li><a class="reference internal" href="#prebinding-and-single-session-support">Prebinding and Single Session Support</a></li>
|
|
<li><a class="reference internal" href="#using-prebind-in-connection-with-keepalive">Using prebind in connection with keepalive</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="section" id="message-carbons">
|
|
<h3><a class="toc-backref" href="#id59">message_carbons</a><a class="headerlink" href="#message-carbons" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">false</span></tt></p>
|
|
<p>Support for <a class="reference external" href="https://xmpp.org/extensions/xep-0280.html">XEP-0280: Message Carbons</a></p>
|
|
<p>In order to keep all IM clients for a user engaged in a conversation,
|
|
outbound messages are carbon-copied to all interested resources.</p>
|
|
<p>This is especially important in webchat, like converse.js, where each browser
|
|
tab serves as a separate IM client.</p>
|
|
<p>Both message_carbons and <a class="reference internal" href="#forward-messages">forward_messages</a> try to solve the same problem
|
|
(showing sent messages in all connected chat clients aka resources), but go about it
|
|
in two different ways.</p>
|
|
<p>Message carbons is the XEP (Jabber protocol extension) specifically drafted to
|
|
solve this problem, while <a href="#id78"><span class="problematic" id="id79">`forwarded_messages`_</span></a> uses
|
|
<a class="reference external" href="http://www.xmpp.org/extensions/xep-0297.html">stanza forwarding</a></p>
|
|
</div>
|
|
<div class="section" id="expose-rid-and-sid">
|
|
<h3><a class="toc-backref" href="#id60">expose_rid_and_sid</a><a class="headerlink" href="#expose-rid-and-sid" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">false</span></tt></p>
|
|
<p>Allow the prebind tokens, RID (request ID) and SID (session ID), to be exposed
|
|
globally via the API. This allows other scripts served on the same page to use
|
|
these values.</p>
|
|
<p><em>Beware</em>: a malicious script could use these tokens to assume your identity
|
|
and inject fake chat messages.</p>
|
|
</div>
|
|
<div class="section" id="forward-messages">
|
|
<h3><a class="toc-backref" href="#id61">forward_messages</a><a class="headerlink" href="#forward-messages" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">false</span></tt></p>
|
|
<p>If set to <tt class="docutils literal"><span class="pre">true</span></tt>, sent messages will also be forwarded to the sending user’s
|
|
bare JID (their Jabber ID independent of any chat clients aka resources).</p>
|
|
<p>This means that sent messages are visible from all the user’s chat clients,
|
|
and not just the one from which it was actually sent.</p>
|
|
<p>This is especially important for web chat, such as converse.js, where each
|
|
browser tab functions as a separate chat client, with its own resource.</p>
|
|
<p>This feature uses Stanza forwarding, see also <a class="reference external" href="http://www.xmpp.org/extensions/xep-0297.html">XEP 0297: Stanza Forwarding</a></p>
|
|
<p>For an alternative approach, see also <a href="#id80"><span class="problematic" id="id81">`message carbons`_</span></a>.</p>
|
|
</div>
|
|
<div class="section" id="fullname">
|
|
<h3><a class="toc-backref" href="#id62">fullname</a><a class="headerlink" href="#fullname" title="Permalink to this headline">¶</a></h3>
|
|
<p>If you are using prebinding, can specify the fullname of the currently
|
|
logged in user, otherwise the user’s vCard will be fetched.</p>
|
|
</div>
|
|
<div class="section" id="hide-muc-server">
|
|
<h3><a class="toc-backref" href="#id63">hide_muc_server</a><a class="headerlink" href="#hide-muc-server" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">false</span></tt></p>
|
|
<p>Hide the <tt class="docutils literal"><span class="pre">server</span></tt> input field of the form inside the <tt class="docutils literal"><span class="pre">Room</span></tt> panel of the
|
|
controlbox. Useful if you want to restrict users to a specific XMPP server of
|
|
your choosing.</p>
|
|
</div>
|
|
<div class="section" id="i18n">
|
|
<h3><a class="toc-backref" href="#id64">i18n</a><a class="headerlink" href="#i18n" title="Permalink to this headline">¶</a></h3>
|
|
<p>Specify the locale/language. The language must be in the <tt class="docutils literal"><span class="pre">locales</span></tt> object. Refer to
|
|
<tt class="docutils literal"><span class="pre">./locale/locales.js</span></tt> to see which locales are supported.</p>
|
|
</div>
|
|
<div class="section" id="play-sounds">
|
|
<h3><a class="toc-backref" href="#id65">play_sounds</a><a class="headerlink" href="#play-sounds" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">false</span></tt></p>
|
|
<p>Plays a notification sound when you receive a personal message or when your
|
|
nickname is mentioned in a chat room.</p>
|
|
<p>Inside the <tt class="docutils literal"><span class="pre">./sounds</span></tt> directory of the Converse.js repo, you’ll see MP3 and Ogg
|
|
formatted sound files. We need both, because neither format is supported by all browsers.</p>
|
|
<p>For now, sound files are looked up by convention, not configuration. So to have
|
|
a sound play when a message is received, make sure that your webserver serves
|
|
it in both formats as <tt class="docutils literal"><span class="pre">http://yoursite.com/sounds/msg_received.mp3</span></tt> and
|
|
<tt class="docutils literal"><span class="pre">http://yoursite.com/sounds/msg_received.ogg</span></tt>.</p>
|
|
<p><tt class="docutils literal"><span class="pre">http://yoursite.com</span></tt> should of course be your site’s URL.</p>
|
|
</div>
|
|
<div class="section" id="prebind">
|
|
<h3><a class="toc-backref" href="#id66">prebind</a><a class="headerlink" href="#prebind" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">false</span></tt></p>
|
|
<p>See also: <a class="reference internal" href="#prebinding-and-single-session-support">Prebinding and Single Session Support</a></p>
|
|
<p>Use this option when you want to attach to an existing XMPP connection that was
|
|
already authenticated (usually on the backend before page load).</p>
|
|
<p>This is useful when you don’t want to render the login form on the chat control
|
|
box with each page load.</p>
|
|
<p>For prebinding to work, you must set up a pre-authenticated BOSH session,
|
|
for which you will receive a JID (jabber ID), SID (session ID) and RID
|
|
(Request ID).</p>
|
|
<p>These values (<tt class="docutils literal"><span class="pre">rid</span></tt>, <tt class="docutils literal"><span class="pre">sid</span></tt> and <tt class="docutils literal"><span class="pre">jid</span></tt>) need to be passed into
|
|
<tt class="docutils literal"><span class="pre">converse.initialize</span></tt> (with the exception of <tt class="docutils literal"><span class="pre">keepalive</span></tt>, see below).</p>
|
|
<p>Additionally, you also have to specify a <tt class="docutils literal"><span class="pre">bosh_service_url</span></tt>.</p>
|
|
<div class="section" id="using-prebind-in-connection-with-keepalive">
|
|
<h4>Using prebind in connection with keepalive<a class="headerlink" href="#using-prebind-in-connection-with-keepalive" title="Permalink to this headline">¶</a></h4>
|
|
<p>The <tt class="docutils literal"><span class="pre">prebind</span></tt> and <a class="reference internal" href="#keepalive">keepalive</a> options can be used together.</p>
|
|
<p>The <tt class="docutils literal"><span class="pre">keepalive</span></tt> option caches the <tt class="docutils literal"><span class="pre">rid</span></tt>, <tt class="docutils literal"><span class="pre">sid</span></tt> and <tt class="docutils literal"><span class="pre">jid</span></tt> values
|
|
(henceforth referred to as <em>session tokens</em>) one receives from a prebinded
|
|
BOSH session, in order to re-use them when the page reloads.</p>
|
|
<p>However, if besides setting <tt class="docutils literal"><span class="pre">keepalive</span></tt> to <tt class="docutils literal"><span class="pre">true</span></tt>, you also set <tt class="docutils literal"><span class="pre">prebind</span></tt>
|
|
to <tt class="docutils literal"><span class="pre">true</span></tt>, and you pass in valid session tokens to <tt class="docutils literal"><span class="pre">converse.initialize</span></tt>,
|
|
then those passed in session tokens will be used instead of any tokens cached by
|
|
<tt class="docutils literal"><span class="pre">keepalive</span></tt>.</p>
|
|
<p>If you set <tt class="docutils literal"><span class="pre">prebind</span></tt> to <tt class="docutils literal"><span class="pre">true</span></tt> and don’t pass in the session tokens to
|
|
<tt class="docutils literal"><span class="pre">converse.initialize</span></tt>, then converse.js will look for tokens cached by
|
|
<tt class="docutils literal"><span class="pre">keepalive</span></tt>.</p>
|
|
<p>If you’ve set <tt class="docutils literal"><span class="pre">keepalive</span></tt> and <tt class="docutils literal"><span class="pre">prebind</span></tt> to <tt class="docutils literal"><span class="pre">true</span></tt>, don’t pass in session
|
|
tokens and converse.js doesn’t find any cached session tokens, then
|
|
converse.js will emit an event <tt class="docutils literal"><span class="pre">noResumeableSession</span></tt> and exit.</p>
|
|
<p>This allows you to start a prebinded session with valid tokens, and then fall
|
|
back to <tt class="docutils literal"><span class="pre">keepalive</span></tt> for maintaining that session across page reloads. When
|
|
for some reason <tt class="docutils literal"><span class="pre">keepalive</span></tt> doesn’t have cached session tokens anymore, you
|
|
can listen for the <tt class="docutils literal"><span class="pre">noResumeableSession</span></tt> event and take that as a cue that
|
|
you should again prebind in order to get valid session tokens.</p>
|
|
<p>Here is a code example:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre>converse.on('noResumeableSession', function () {
|
|
$.getJSON('/prebind', function (data) {
|
|
converse.initialize({
|
|
prebind: true,
|
|
keepalive: true,
|
|
bosh_service_url: 'https://bind.example.com',
|
|
jid: data.jid,
|
|
sid: data.sid,
|
|
rid: data.rid
|
|
});
|
|
});
|
|
});
|
|
converse.initialize({
|
|
prebind: true,
|
|
keepalive: true,
|
|
bosh_service_url: 'https://bind.example.com'
|
|
}));
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="roster-groups">
|
|
<h3><a class="toc-backref" href="#id67">roster_groups</a><a class="headerlink" href="#roster-groups" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">false</span></tt></p>
|
|
<p>If set to <tt class="docutils literal"><span class="pre">true</span></tt>, converse.js will show any roster groups you might have
|
|
configured.</p>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">It’s currently not possible to use converse.js to assign contacts to groups.
|
|
Converse.js can only show users and groups that were previously configured
|
|
elsewhere.</p>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="show-controlbox-by-default">
|
|
<h3><a class="toc-backref" href="#id68">show_controlbox_by_default</a><a class="headerlink" href="#show-controlbox-by-default" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">false</span></tt></p>
|
|
<p>The “controlbox” refers to the special chatbox containing your contacts roster,
|
|
status widget, chatrooms and other controls.</p>
|
|
<p>By default this box is hidden and can be toggled by clicking on any element in
|
|
the page with class <em>toggle-controlbox</em>.</p>
|
|
<p>If this options is set to true, the controlbox will by default be shown upon
|
|
page load.</p>
|
|
</div>
|
|
<div class="section" id="show-only-online-users">
|
|
<h3><a class="toc-backref" href="#id69">show_only_online_users</a><a class="headerlink" href="#show-only-online-users" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">false</span></tt></p>
|
|
<p>If set to <tt class="docutils literal"><span class="pre">true</span></tt>, only online users will be shown in the contacts roster.
|
|
Users with any other status (e.g. away, busy etc.) will not be shown.</p>
|
|
</div>
|
|
<div class="section" id="storage">
|
|
<h3><a class="toc-backref" href="#id70">storage</a><a class="headerlink" href="#storage" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">session</span></tt></p>
|
|
<p>Valid options: <tt class="docutils literal"><span class="pre">session</span></tt>, <tt class="docutils literal"><span class="pre">local</span></tt>.</p>
|
|
<p>This option determines the type of <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage">storage</a>
|
|
(<tt class="docutils literal"><span class="pre">localStorage</span></tt> or <tt class="docutils literal"><span class="pre">sessionStorage</span></tt>) used by converse.js to cache user data.</p>
|
|
<p>Originally converse.js used only localStorage, however sessionStorage is from a
|
|
privacy perspective a better choice.</p>
|
|
<p>The main difference between the two is that sessionStorage only persists while
|
|
the current tab or window containing a converse.js instance is open. As soon as
|
|
it’s closed, the data is cleared.</p>
|
|
<p>Data in localStorage on the other hand is kept indefinitely.</p>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">Since version 0.8.0, the use of local storage is not recommended. The
|
|
statuses (online, away, busy etc.) of your roster contacts are cached in
|
|
the browser storage. If you use local storage, these values are stored for
|
|
multiple sessions, and they will likely become out of sync with your contacts’
|
|
actual statuses. The session storage doesn’t have this problem, because
|
|
roster contact statuses will not become out of sync in a single session,
|
|
only across more than one session.</p>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="use-otr-by-default">
|
|
<h3><a class="toc-backref" href="#id71">use_otr_by_default</a><a class="headerlink" href="#use-otr-by-default" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">false</span></tt></p>
|
|
<p>If set to <tt class="docutils literal"><span class="pre">true</span></tt>, Converse.js will automatically try to initiate an OTR (off-the-record)
|
|
encrypted chat session every time you open a chat box.</p>
|
|
</div>
|
|
<div class="section" id="use-vcards">
|
|
<h3><a class="toc-backref" href="#id72">use_vcards</a><a class="headerlink" href="#use-vcards" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">true</span></tt></p>
|
|
<p>Determines whether the XMPP server will be queried for roster contacts’ VCards
|
|
or not. VCards contain extra personal information such as your fullname and
|
|
avatar image.</p>
|
|
</div>
|
|
<div class="section" id="visible-toolbar-buttons">
|
|
<h3><a class="toc-backref" href="#id73">visible_toolbar_buttons</a><a class="headerlink" href="#visible-toolbar-buttons" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre><span class="p">{</span>
|
|
<span class="n">call</span><span class="p">:</span> <span class="n">false</span><span class="p">,</span>
|
|
<span class="n">clear</span><span class="p">:</span> <span class="n">true</span><span class="p">,</span>
|
|
<span class="n">emoticons</span><span class="p">:</span> <span class="n">true</span><span class="p">,</span>
|
|
<span class="n">toggle_participants</span><span class="p">:</span> <span class="n">true</span>
|
|
<span class="p">}</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>Allows you to show or hide buttons on the chat boxes’ toolbars.</p>
|
|
<ul>
|
|
<li><dl class="first docutils">
|
|
<dt><em>call</em>:</dt>
|
|
<dd><p class="first">Provides a button with a picture of a telephone on it.
|
|
When the call button is pressed, it will emit an event that can be used by a third-party library to initiate a call.:</p>
|
|
<div class="last highlight-python"><div class="highlight"><pre>converse.on('callButtonClicked', function(event, data) {
|
|
console.log('Strophe connection is', data.connection);
|
|
console.log('Bare buddy JID is', data.model.get('jid'));
|
|
// ... Third-party library code ...
|
|
});
|
|
</pre></div>
|
|
</div>
|
|
</dd>
|
|
</dl>
|
|
</li>
|
|
<li><dl class="first docutils">
|
|
<dt><em>clear</em>:</dt>
|
|
<dd><p class="first last">Provides a button for clearing messages from a chat box.</p>
|
|
</dd>
|
|
</dl>
|
|
</li>
|
|
<li><dl class="first docutils">
|
|
<dt><em>emoticons</em>:</dt>
|
|
<dd><p class="first last">Enables rendering of emoticons and provides a toolbar button for choosing them.</p>
|
|
</dd>
|
|
</dl>
|
|
</li>
|
|
<li><dl class="first docutils">
|
|
<dt>toggle_participants:</dt>
|
|
<dd><p class="first last">Shows a button for toggling (i.e. showing/hiding) the list of participants in a chat room.</p>
|
|
</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section" id="xhr-custom-status">
|
|
<h3><a class="toc-backref" href="#id74">xhr_custom_status</a><a class="headerlink" href="#xhr-custom-status" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">false</span></tt></p>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">XHR stands for XMLHTTPRequest, and is meant here in the AJAX sense (Asynchronous Javascript and XML).</p>
|
|
</div>
|
|
<p>This option will let converse.js make an AJAX POST with your changed custom chat status to a
|
|
remote server.</p>
|
|
</div>
|
|
<div class="section" id="xhr-custom-status-url">
|
|
<h3><a class="toc-backref" href="#id75">xhr_custom_status_url</a><a class="headerlink" href="#xhr-custom-status-url" title="Permalink to this headline">¶</a></h3>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">XHR stands for XMLHTTPRequest, and is meant here in the AJAX sense (Asynchronous Javascript and XML).</p>
|
|
</div>
|
|
<p>Default: Empty string</p>
|
|
<p>Used only in conjunction with <tt class="docutils literal"><span class="pre">xhr_custom_status</span></tt>.</p>
|
|
<p>This is the URL to which the AJAX POST request to set the user’s custom status
|
|
message will be made.</p>
|
|
<p>The message itself is sent in the request under the key <tt class="docutils literal"><span class="pre">msg</span></tt>.</p>
|
|
</div>
|
|
<div class="section" id="xhr-user-search">
|
|
<h3><a class="toc-backref" href="#id76">xhr_user_search</a><a class="headerlink" href="#xhr-user-search" title="Permalink to this headline">¶</a></h3>
|
|
<p>Default: <tt class="docutils literal"><span class="pre">false</span></tt></p>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">XHR stands for XMLHTTPRequest, and is meant here in the AJAX sense (Asynchronous Javascript and XML).</p>
|
|
</div>
|
|
<p>There are two ways to add users.</p>
|
|
<ul class="simple">
|
|
<li>The user inputs a valid JID (Jabber ID), and the user is added as a pending contact.</li>
|
|
<li>The user inputs some text (for example part of a firstname or lastname), an XHR (Ajax Request) will be made to a remote server, and a list of matches are returned. The user can then choose one of the matches to add as a contact.</li>
|
|
</ul>
|
|
<p>This setting enables the second mechanism, otherwise by default the first will be used.</p>
|
|
<p><em>What is expected from the remote server?</em></p>
|
|
<p>A default JSON encoded list of objects must be returned. Each object
|
|
corresponds to a matched user and needs the keys <tt class="docutils literal"><span class="pre">id</span></tt> and <tt class="docutils literal"><span class="pre">fullname</span></tt>.</p>
|
|
</div>
|
|
<div class="section" id="xhr-user-search-url">
|
|
<h3><a class="toc-backref" href="#id77">xhr_user_search_url</a><a class="headerlink" href="#xhr-user-search-url" title="Permalink to this headline">¶</a></h3>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">XHR stands for XMLHTTPRequest, and is meant here in the AJAX sense (Asynchronous Javascript and XML).</p>
|
|
</div>
|
|
<p>Default: Empty string</p>
|
|
<p>Used only in conjunction with <tt class="docutils literal"><span class="pre">xhr_user_search</span></tt>.</p>
|
|
<p>This is the URL to which an AJAX GET request will be made to fetch user data from your remote server.
|
|
The query string will be included in the request with <tt class="docutils literal"><span class="pre">q</span></tt> as its key.</p>
|
|
<p>The calendar can be configured through a <cite>data-pat-calendar</cite> attribute.
|
|
The available options are:</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
|
|
</section>
|
|
<div class="related">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="genindex.html" title="General Index"
|
|
>index</a></li>
|
|
<li><a href="#">Converse.js 0.8.3 documentation</a> »</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div id="footer_wrap" class="outer">
|
|
<footer class="inner">
|
|
© Copyright 2014, JC Brand.
|
|
<p class="copyright">Converse.js created by <a href="http://opkode.com" target="_blank">jcbrand</a></p>
|
|
</footer>
|
|
</div>
|
|
</body>
|
|
</html> |