fixed indentation of comments
This commit is contained in:
parent
fa69bb1b0a
commit
8e18d736b4
@ -162,10 +162,10 @@
|
|||||||
|
|
||||||
fetchArchivedMessages: function (options) {
|
fetchArchivedMessages: function (options) {
|
||||||
/* Fetch archived chat messages from the XMPP server.
|
/* Fetch archived chat messages from the XMPP server.
|
||||||
*
|
*
|
||||||
* Then, upon receiving them, call onMessage on the chat box,
|
* Then, upon receiving them, call onMessage on the chat box,
|
||||||
* so that they are displayed inside it.
|
* so that they are displayed inside it.
|
||||||
*/
|
*/
|
||||||
if (!converse.features.findWhere({'var': Strophe.NS.MAM})) {
|
if (!converse.features.findWhere({'var': Strophe.NS.MAM})) {
|
||||||
converse.log("Attempted to fetch archived messages but this user's server doesn't support XEP-0313");
|
converse.log("Attempted to fetch archived messages but this user's server doesn't support XEP-0313");
|
||||||
return;
|
return;
|
||||||
@ -186,16 +186,16 @@
|
|||||||
|
|
||||||
insertIntoPage: function () {
|
insertIntoPage: function () {
|
||||||
/* This method gets overridden in src/converse-controlbox.js if
|
/* This method gets overridden in src/converse-controlbox.js if
|
||||||
* the controlbox plugin is active.
|
* the controlbox plugin is active.
|
||||||
*/
|
*/
|
||||||
$('#conversejs').prepend(this.$el);
|
$('#conversejs').prepend(this.$el);
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
adjustToViewport: function () {
|
adjustToViewport: function () {
|
||||||
/* Event handler called when viewport gets resized. We remove
|
/* Event handler called when viewport gets resized. We remove
|
||||||
* custom width/height from chat boxes.
|
* custom width/height from chat boxes.
|
||||||
*/
|
*/
|
||||||
var viewport_width = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
|
var viewport_width = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
|
||||||
var viewport_height = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
|
var viewport_height = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
|
||||||
if (viewport_width <= 480) {
|
if (viewport_width <= 480) {
|
||||||
@ -210,8 +210,8 @@
|
|||||||
|
|
||||||
initDragResize: function () {
|
initDragResize: function () {
|
||||||
/* Determine and store the default box size.
|
/* Determine and store the default box size.
|
||||||
* We need this information for the drag-resizing feature.
|
* We need this information for the drag-resizing feature.
|
||||||
*/
|
*/
|
||||||
var $flyout = this.$el.find('.box-flyout');
|
var $flyout = this.$el.find('.box-flyout');
|
||||||
if (typeof this.model.get('height') === 'undefined') {
|
if (typeof this.model.get('height') === 'undefined') {
|
||||||
var height = $flyout.height();
|
var height = $flyout.height();
|
||||||
@ -271,11 +271,11 @@
|
|||||||
|
|
||||||
prependDayIndicator: function (date) {
|
prependDayIndicator: function (date) {
|
||||||
/* Prepends an indicator into the chat area, showing the day as
|
/* Prepends an indicator into the chat area, showing the day as
|
||||||
* given by the passed in date.
|
* given by the passed in date.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (String) date - An ISO8601 date string.
|
* (String) date - An ISO8601 date string.
|
||||||
*/
|
*/
|
||||||
var day_date = moment(date).startOf('day');
|
var day_date = moment(date).startOf('day');
|
||||||
this.$content.prepend(converse.templates.new_day({
|
this.$content.prepend(converse.templates.new_day({
|
||||||
isodate: day_date.format(),
|
isodate: day_date.format(),
|
||||||
@ -285,11 +285,11 @@
|
|||||||
|
|
||||||
appendMessage: function (attrs) {
|
appendMessage: function (attrs) {
|
||||||
/* Helper method which appends a message to the end of the chat
|
/* Helper method which appends a message to the end of the chat
|
||||||
* box's content area.
|
* box's content area.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (Object) attrs: An object containing the message attributes.
|
* (Object) attrs: An object containing the message attributes.
|
||||||
*/
|
*/
|
||||||
_.compose(
|
_.compose(
|
||||||
_.debounce(this.scrollDown.bind(this), 50),
|
_.debounce(this.scrollDown.bind(this), 50),
|
||||||
this.$content.append.bind(this.$content)
|
this.$content.append.bind(this.$content)
|
||||||
@ -298,15 +298,15 @@
|
|||||||
|
|
||||||
showMessage: function (attrs) {
|
showMessage: function (attrs) {
|
||||||
/* Inserts a chat message into the content area of the chat box.
|
/* Inserts a chat message into the content area of the chat box.
|
||||||
* Will also insert a new day indicator if the message is on a
|
* Will also insert a new day indicator if the message is on a
|
||||||
* different day.
|
* different day.
|
||||||
*
|
*
|
||||||
* The message to show may either be newer than the newest
|
* The message to show may either be newer than the newest
|
||||||
* message, or older than the oldest message.
|
* message, or older than the oldest message.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (Object) attrs: An object containing the message attributes.
|
* (Object) attrs: An object containing the message attributes.
|
||||||
*/
|
*/
|
||||||
var $first_msg = this.$content.children('.chat-message:first'),
|
var $first_msg = this.$content.children('.chat-message:first'),
|
||||||
first_msg_date = $first_msg.data('isodate'),
|
first_msg_date = $first_msg.data('isodate'),
|
||||||
last_msg_date, current_msg_date, day_date, $msgs, msg_dates, idx;
|
last_msg_date, current_msg_date, day_date, $msgs, msg_dates, idx;
|
||||||
@ -384,13 +384,13 @@
|
|||||||
|
|
||||||
renderMessage: function (attrs) {
|
renderMessage: function (attrs) {
|
||||||
/* Renders a chat message based on the passed in attributes.
|
/* Renders a chat message based on the passed in attributes.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (Object) attrs: An object containing the message attributes.
|
* (Object) attrs: An object containing the message attributes.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* The DOM element representing the message.
|
* The DOM element representing the message.
|
||||||
*/
|
*/
|
||||||
var msg_time = moment(attrs.time) || moment,
|
var msg_time = moment(attrs.time) || moment,
|
||||||
text = attrs.message,
|
text = attrs.message,
|
||||||
match = text.match(/^\/(.*?)(?: (.*))?$/),
|
match = text.match(/^\/(.*?)(?: (.*))?$/),
|
||||||
@ -465,10 +465,10 @@
|
|||||||
|
|
||||||
onMessageAdded: function (message) {
|
onMessageAdded: function (message) {
|
||||||
/* Handler that gets called when a new message object is created.
|
/* Handler that gets called when a new message object is created.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (Object) message - The message Backbone object that was added.
|
* (Object) message - The message Backbone object that was added.
|
||||||
*/
|
*/
|
||||||
if (typeof this.clear_status_timeout !== 'undefined') {
|
if (typeof this.clear_status_timeout !== 'undefined') {
|
||||||
window.clearTimeout(this.clear_status_timeout);
|
window.clearTimeout(this.clear_status_timeout);
|
||||||
delete this.clear_status_timeout;
|
delete this.clear_status_timeout;
|
||||||
@ -492,10 +492,10 @@
|
|||||||
|
|
||||||
sendMessage: function (message) {
|
sendMessage: function (message) {
|
||||||
/* Responsible for sending off a text message.
|
/* Responsible for sending off a text message.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (Message) message - The chat message
|
* (Message) message - The chat message
|
||||||
*/
|
*/
|
||||||
// TODO: We might want to send to specfic resources.
|
// TODO: We might want to send to specfic resources.
|
||||||
// Especially in the OTR case.
|
// Especially in the OTR case.
|
||||||
var messageStanza = this.createMessageStanza(message);
|
var messageStanza = this.createMessageStanza(message);
|
||||||
@ -513,11 +513,11 @@
|
|||||||
|
|
||||||
onMessageSubmitted: function (text) {
|
onMessageSubmitted: function (text) {
|
||||||
/* This method gets called once the user has typed a message
|
/* This method gets called once the user has typed a message
|
||||||
* and then pressed enter in a chat box.
|
* and then pressed enter in a chat box.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (string) text - The chat message text.
|
* (string) text - The chat message text.
|
||||||
*/
|
*/
|
||||||
if (!converse.connection.authenticated) {
|
if (!converse.connection.authenticated) {
|
||||||
return this.showHelpMessages(
|
return this.showHelpMessages(
|
||||||
['Sorry, the connection has been lost, '+
|
['Sorry, the connection has been lost, '+
|
||||||
@ -553,9 +553,9 @@
|
|||||||
|
|
||||||
sendChatState: function () {
|
sendChatState: function () {
|
||||||
/* Sends a message with the status of the user in this chat session
|
/* Sends a message with the status of the user in this chat session
|
||||||
* as taken from the 'chat_state' attribute of the chat box.
|
* as taken from the 'chat_state' attribute of the chat box.
|
||||||
* See XEP-0085 Chat State Notifications.
|
* See XEP-0085 Chat State Notifications.
|
||||||
*/
|
*/
|
||||||
converse.connection.send(
|
converse.connection.send(
|
||||||
$msg({'to':this.model.get('jid'), 'type': 'chat'})
|
$msg({'to':this.model.get('jid'), 'type': 'chat'})
|
||||||
.c(this.model.get('chat_state'), {'xmlns': Strophe.NS.CHATSTATES})
|
.c(this.model.get('chat_state'), {'xmlns': Strophe.NS.CHATSTATES})
|
||||||
@ -564,16 +564,16 @@
|
|||||||
|
|
||||||
setChatState: function (state, no_save) {
|
setChatState: function (state, no_save) {
|
||||||
/* Mutator for setting the chat state of this chat session.
|
/* Mutator for setting the chat state of this chat session.
|
||||||
* Handles clearing of any chat state notification timeouts and
|
* Handles clearing of any chat state notification timeouts and
|
||||||
* setting new ones if necessary.
|
* setting new ones if necessary.
|
||||||
* Timeouts are set when the state being set is COMPOSING or PAUSED.
|
* Timeouts are set when the state being set is COMPOSING or PAUSED.
|
||||||
* After the timeout, COMPOSING will become PAUSED and PAUSED will become INACTIVE.
|
* After the timeout, COMPOSING will become PAUSED and PAUSED will become INACTIVE.
|
||||||
* See XEP-0085 Chat State Notifications.
|
* See XEP-0085 Chat State Notifications.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (string) state - The chat state (consts ACTIVE, COMPOSING, PAUSED, INACTIVE, GONE)
|
* (string) state - The chat state (consts ACTIVE, COMPOSING, PAUSED, INACTIVE, GONE)
|
||||||
* (Boolean) no_save - Just do the cleanup or setup but don't actually save the state.
|
* (Boolean) no_save - Just do the cleanup or setup but don't actually save the state.
|
||||||
*/
|
*/
|
||||||
if (typeof this.chat_state_timeout !== 'undefined') {
|
if (typeof this.chat_state_timeout !== 'undefined') {
|
||||||
window.clearTimeout(this.chat_state_timeout);
|
window.clearTimeout(this.chat_state_timeout);
|
||||||
delete this.chat_state_timeout;
|
delete this.chat_state_timeout;
|
||||||
@ -593,7 +593,7 @@
|
|||||||
|
|
||||||
keyPressed: function (ev) {
|
keyPressed: function (ev) {
|
||||||
/* Event handler for when a key is pressed in a chat box textarea.
|
/* Event handler for when a key is pressed in a chat box textarea.
|
||||||
*/
|
*/
|
||||||
var $textarea = $(ev.target), message;
|
var $textarea = $(ev.target), message;
|
||||||
if (ev.keyCode === KEY.ENTER) {
|
if (ev.keyCode === KEY.ENTER) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
@ -865,9 +865,9 @@
|
|||||||
show: function (focus) {
|
show: function (focus) {
|
||||||
if (typeof this.debouncedShow === 'undefined') {
|
if (typeof this.debouncedShow === 'undefined') {
|
||||||
/* We wrap the method in a debouncer and set it on the
|
/* We wrap the method in a debouncer and set it on the
|
||||||
* instance, so that we have it debounced per instance.
|
* instance, so that we have it debounced per instance.
|
||||||
* Debouncing it on the class-level is too broad.
|
* Debouncing it on the class-level is too broad.
|
||||||
*/
|
*/
|
||||||
this.debouncedShow = _.debounce(function (focus) {
|
this.debouncedShow = _.debounce(function (focus) {
|
||||||
if (this.$el.is(':visible') && this.$el.css('opacity') === "1") {
|
if (this.$el.is(':visible') && this.$el.css('opacity') === "1") {
|
||||||
if (focus) { this.focus(); }
|
if (focus) { this.focus(); }
|
||||||
|
@ -247,8 +247,8 @@
|
|||||||
|
|
||||||
initRoster: function () {
|
initRoster: function () {
|
||||||
/* We initialize the roster, which will appear inside the
|
/* We initialize the roster, which will appear inside the
|
||||||
* Contacts Panel.
|
* Contacts Panel.
|
||||||
*/
|
*/
|
||||||
var rostergroups = new converse.RosterGroups();
|
var rostergroups = new converse.RosterGroups();
|
||||||
rostergroups.browserStorage = new Backbone.BrowserStorage[converse.storage](
|
rostergroups.browserStorage = new Backbone.BrowserStorage[converse.storage](
|
||||||
b64_sha1('converse.roster.groups'+converse.bare_jid));
|
b64_sha1('converse.roster.groups'+converse.bare_jid));
|
||||||
|
@ -61,7 +61,6 @@
|
|||||||
/* The initialize function gets called as soon as the plugin is
|
/* The initialize function gets called as soon as the plugin is
|
||||||
* loaded by converse.js's plugin machinery.
|
* loaded by converse.js's plugin machinery.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
this.updateSettings({
|
this.updateSettings({
|
||||||
archived_messages_page_size: '20',
|
archived_messages_page_size: '20',
|
||||||
message_archiving: 'never', // Supported values are 'always', 'never', 'roster' (https://xmpp.org/extensions/xep-0313.html#prefs)
|
message_archiving: 'never', // Supported values are 'always', 'never', 'roster' (https://xmpp.org/extensions/xep-0313.html#prefs)
|
||||||
@ -70,22 +69,22 @@
|
|||||||
|
|
||||||
converse.queryForArchivedMessages = function (options, callback, errback) {
|
converse.queryForArchivedMessages = function (options, callback, errback) {
|
||||||
/* Do a MAM (XEP-0313) query for archived messages.
|
/* Do a MAM (XEP-0313) query for archived messages.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (Object) options - Query parameters, either MAM-specific or also for Result Set Management.
|
* (Object) options - Query parameters, either MAM-specific or also for Result Set Management.
|
||||||
* (Function) callback - A function to call whenever we receive query-relevant stanza.
|
* (Function) callback - A function to call whenever we receive query-relevant stanza.
|
||||||
* (Function) errback - A function to call when an error stanza is received.
|
* (Function) errback - A function to call when an error stanza is received.
|
||||||
*
|
*
|
||||||
* The options parameter can also be an instance of
|
* The options parameter can also be an instance of
|
||||||
* Strophe.RSM to enable easy querying between results pages.
|
* Strophe.RSM to enable easy querying between results pages.
|
||||||
*
|
*
|
||||||
* The callback function may be called multiple times, first
|
* The callback function may be called multiple times, first
|
||||||
* for the initial IQ result and then for each message
|
* for the initial IQ result and then for each message
|
||||||
* returned. The last time the callback is called, a
|
* returned. The last time the callback is called, a
|
||||||
* Strophe.RSM object is returned on which "next" or "previous"
|
* Strophe.RSM object is returned on which "next" or "previous"
|
||||||
* can be called before passing it in again to this method, to
|
* can be called before passing it in again to this method, to
|
||||||
* get the next or previous page in the result set.
|
* get the next or previous page in the result set.
|
||||||
*/
|
*/
|
||||||
var date, messages = [];
|
var date, messages = [];
|
||||||
if (typeof options === "function") {
|
if (typeof options === "function") {
|
||||||
callback = options;
|
callback = options;
|
||||||
@ -153,7 +152,7 @@
|
|||||||
|
|
||||||
_.extend(converse_api, {
|
_.extend(converse_api, {
|
||||||
/* Extend default converse.js API to add methods specific to MAM
|
/* Extend default converse.js API to add methods specific to MAM
|
||||||
*/
|
*/
|
||||||
'archive': {
|
'archive': {
|
||||||
'query': converse.queryForArchivedMessages.bind(converse)
|
'query': converse.queryForArchivedMessages.bind(converse)
|
||||||
}
|
}
|
||||||
|
@ -125,12 +125,12 @@
|
|||||||
|
|
||||||
trimChats: function (newchat) {
|
trimChats: function (newchat) {
|
||||||
/* This method is called when a newly created chat box will
|
/* This method is called when a newly created chat box will
|
||||||
* be shown.
|
* be shown.
|
||||||
*
|
*
|
||||||
* It checks whether there is enough space on the page to show
|
* It checks whether there is enough space on the page to show
|
||||||
* another chat box. Otherwise it minimizes the oldest chat box
|
* another chat box. Otherwise it minimizes the oldest chat box
|
||||||
* to create space.
|
* to create space.
|
||||||
*/
|
*/
|
||||||
if (converse.no_trimming || (this.model.length <= 1)) {
|
if (converse.no_trimming || (this.model.length <= 1)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -216,8 +216,8 @@
|
|||||||
|
|
||||||
converse.ChatRoomView = converse.ChatBoxView.extend({
|
converse.ChatRoomView = converse.ChatBoxView.extend({
|
||||||
/* Backbone View which renders a chat room, based upon the view
|
/* Backbone View which renders a chat room, based upon the view
|
||||||
* for normal one-on-one chat boxes.
|
* for normal one-on-one chat boxes.
|
||||||
*/
|
*/
|
||||||
length: 300,
|
length: 300,
|
||||||
tagName: 'div',
|
tagName: 'div',
|
||||||
className: 'chatbox chatroom',
|
className: 'chatbox chatroom',
|
||||||
@ -397,8 +397,8 @@
|
|||||||
|
|
||||||
validateRoleChangeCommand: function (command, args) {
|
validateRoleChangeCommand: function (command, args) {
|
||||||
/* Check that a command to change a chat room user's role or
|
/* Check that a command to change a chat room user's role or
|
||||||
* affiliation has anough arguments.
|
* affiliation has anough arguments.
|
||||||
*/
|
*/
|
||||||
// TODO check if first argument is valid
|
// TODO check if first argument is valid
|
||||||
if (args.length < 1 || args.length > 2) {
|
if (args.length < 1 || args.length > 2) {
|
||||||
this.showStatusNotification(
|
this.showStatusNotification(
|
||||||
@ -421,11 +421,11 @@
|
|||||||
|
|
||||||
onChatRoomMessageSubmitted: function (text) {
|
onChatRoomMessageSubmitted: function (text) {
|
||||||
/* Gets called when the user presses enter to send off a
|
/* Gets called when the user presses enter to send off a
|
||||||
* message in a chat room.
|
* message in a chat room.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (String) text - The message text.
|
* (String) text - The message text.
|
||||||
*/
|
*/
|
||||||
var match = text.replace(/^\s*/, "").match(/^\/(.*?)(?: (.*))?$/) || [false, '', ''],
|
var match = text.replace(/^\s*/, "").match(/^\/(.*?)(?: (.*))?$/) || [false, '', ''],
|
||||||
args = match[2] && match[2].splitOnce(' ') || [];
|
args = match[2] && match[2].splitOnce(' ') || [];
|
||||||
switch (match[1]) {
|
switch (match[1]) {
|
||||||
@ -723,27 +723,27 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
/* http://xmpp.org/extensions/xep-0045.html
|
/* http://xmpp.org/extensions/xep-0045.html
|
||||||
* ----------------------------------------
|
* ----------------------------------------
|
||||||
* 100 message Entering a room Inform user that any occupant is allowed to see the user's full JID
|
* 100 message Entering a room Inform user that any occupant is allowed to see the user's full JID
|
||||||
* 101 message (out of band) Affiliation change Inform user that his or her affiliation changed while not in the room
|
* 101 message (out of band) Affiliation change Inform user that his or her affiliation changed while not in the room
|
||||||
* 102 message Configuration change Inform occupants that room now shows unavailable members
|
* 102 message Configuration change Inform occupants that room now shows unavailable members
|
||||||
* 103 message Configuration change Inform occupants that room now does not show unavailable members
|
* 103 message Configuration change Inform occupants that room now does not show unavailable members
|
||||||
* 104 message Configuration change Inform occupants that a non-privacy-related room configuration change has occurred
|
* 104 message Configuration change Inform occupants that a non-privacy-related room configuration change has occurred
|
||||||
* 110 presence Any room presence Inform user that presence refers to one of its own room occupants
|
* 110 presence Any room presence Inform user that presence refers to one of its own room occupants
|
||||||
* 170 message or initial presence Configuration change Inform occupants that room logging is now enabled
|
* 170 message or initial presence Configuration change Inform occupants that room logging is now enabled
|
||||||
* 171 message Configuration change Inform occupants that room logging is now disabled
|
* 171 message Configuration change Inform occupants that room logging is now disabled
|
||||||
* 172 message Configuration change Inform occupants that the room is now non-anonymous
|
* 172 message Configuration change Inform occupants that the room is now non-anonymous
|
||||||
* 173 message Configuration change Inform occupants that the room is now semi-anonymous
|
* 173 message Configuration change Inform occupants that the room is now semi-anonymous
|
||||||
* 174 message Configuration change Inform occupants that the room is now fully-anonymous
|
* 174 message Configuration change Inform occupants that the room is now fully-anonymous
|
||||||
* 201 presence Entering a room Inform user that a new room has been created
|
* 201 presence Entering a room Inform user that a new room has been created
|
||||||
* 210 presence Entering a room Inform user that the service has assigned or modified the occupant's roomnick
|
* 210 presence Entering a room Inform user that the service has assigned or modified the occupant's roomnick
|
||||||
* 301 presence Removal from room Inform user that he or she has been banned from the room
|
* 301 presence Removal from room Inform user that he or she has been banned from the room
|
||||||
* 303 presence Exiting a room Inform all occupants of new room nickname
|
* 303 presence Exiting a room Inform all occupants of new room nickname
|
||||||
* 307 presence Removal from room Inform user that he or she has been kicked from the room
|
* 307 presence Removal from room Inform user that he or she has been kicked from the room
|
||||||
* 321 presence Removal from room Inform user that he or she is being removed from the room because of an affiliation change
|
* 321 presence Removal from room Inform user that he or she is being removed from the room because of an affiliation change
|
||||||
* 322 presence Removal from room Inform user that he or she is being removed from the room because the room has been changed to members-only and the user is not a member
|
* 322 presence Removal from room Inform user that he or she is being removed from the room because the room has been changed to members-only and the user is not a member
|
||||||
* 332 presence Removal from room Inform user that he or she is being removed from the room because of a system shutdown
|
* 332 presence Removal from room Inform user that he or she is being removed from the room because of a system shutdown
|
||||||
*/
|
*/
|
||||||
infoMessages: {
|
infoMessages: {
|
||||||
100: __('This room is not anonymous'),
|
100: __('This room is not anonymous'),
|
||||||
102: __('This room now shows unavailable members'),
|
102: __('This room now shows unavailable members'),
|
||||||
@ -767,15 +767,15 @@
|
|||||||
|
|
||||||
actionInfoMessages: {
|
actionInfoMessages: {
|
||||||
/* XXX: Note the triple underscore function and not double
|
/* XXX: Note the triple underscore function and not double
|
||||||
* underscore.
|
* underscore.
|
||||||
*
|
*
|
||||||
* This is a hack. We can't pass the strings to __ because we
|
* This is a hack. We can't pass the strings to __ because we
|
||||||
* don't yet know what the variable to interpolate is.
|
* don't yet know what the variable to interpolate is.
|
||||||
*
|
*
|
||||||
* Triple underscore will just return the string again, but we
|
* Triple underscore will just return the string again, but we
|
||||||
* can then at least tell gettext to scan for it so that these
|
* can then at least tell gettext to scan for it so that these
|
||||||
* strings are picked up by the translation machinery.
|
* strings are picked up by the translation machinery.
|
||||||
*/
|
*/
|
||||||
301: ___("<strong>%1$s</strong> has been banned"),
|
301: ___("<strong>%1$s</strong> has been banned"),
|
||||||
303: ___("<strong>%1$s</strong>'s nickname has changed"),
|
303: ___("<strong>%1$s</strong>'s nickname has changed"),
|
||||||
307: ___("<strong>%1$s</strong> has been kicked out"),
|
307: ___("<strong>%1$s</strong> has been kicked out"),
|
||||||
@ -790,9 +790,9 @@
|
|||||||
|
|
||||||
showStatusMessages: function (el, is_self) {
|
showStatusMessages: function (el, is_self) {
|
||||||
/* Check for status codes and communicate their purpose to the user.
|
/* Check for status codes and communicate their purpose to the user.
|
||||||
* Allow user to configure chat room if they are the owner.
|
* Allow user to configure chat room if they are the owner.
|
||||||
* See: http://xmpp.org/registrar/mucstatus.html
|
* See: http://xmpp.org/registrar/mucstatus.html
|
||||||
*/
|
*/
|
||||||
var $el = $(el),
|
var $el = $(el),
|
||||||
i, disconnect_msgs = [], msgs = [], reasons = [];
|
i, disconnect_msgs = [], msgs = [], reasons = [];
|
||||||
|
|
||||||
@ -935,10 +935,10 @@
|
|||||||
|
|
||||||
fetchArchivedMessages: function (options) {
|
fetchArchivedMessages: function (options) {
|
||||||
/* Fetch archived chat messages from the XMPP server.
|
/* Fetch archived chat messages from the XMPP server.
|
||||||
*
|
*
|
||||||
* Then, upon receiving them, call onChatRoomMessage
|
* Then, upon receiving them, call onChatRoomMessage
|
||||||
* so that they are displayed inside it.
|
* so that they are displayed inside it.
|
||||||
*/
|
*/
|
||||||
if (!converse.features.findWhere({'var': Strophe.NS.MAM})) {
|
if (!converse.features.findWhere({'var': Strophe.NS.MAM})) {
|
||||||
converse.log("Attempted to fetch archived messages but this user's server doesn't support XEP-0313");
|
converse.log("Attempted to fetch archived messages but this user's server doesn't support XEP-0313");
|
||||||
return;
|
return;
|
||||||
@ -1112,11 +1112,11 @@
|
|||||||
|
|
||||||
converse.RoomsPanel = Backbone.View.extend({
|
converse.RoomsPanel = Backbone.View.extend({
|
||||||
/* Backbone View which renders the "Rooms" tab and accompanying
|
/* Backbone View which renders the "Rooms" tab and accompanying
|
||||||
* panel in the control box.
|
* panel in the control box.
|
||||||
*
|
*
|
||||||
* In this panel, chat rooms can be listed, joined and new rooms
|
* In this panel, chat rooms can be listed, joined and new rooms
|
||||||
* can be created.
|
* can be created.
|
||||||
*/
|
*/
|
||||||
tagName: 'div',
|
tagName: 'div',
|
||||||
className: 'controlbox-pane',
|
className: 'controlbox-pane',
|
||||||
id: 'chatrooms',
|
id: 'chatrooms',
|
||||||
@ -1175,8 +1175,8 @@
|
|||||||
|
|
||||||
onRoomsFound: function (iq) {
|
onRoomsFound: function (iq) {
|
||||||
/* Handle the IQ stanza returned from the server, containing
|
/* Handle the IQ stanza returned from the server, containing
|
||||||
* all its public rooms.
|
* all its public rooms.
|
||||||
*/
|
*/
|
||||||
var name, jid, i, fragment,
|
var name, jid, i, fragment,
|
||||||
$available_chatrooms = this.$el.find('#available-chatrooms');
|
$available_chatrooms = this.$el.find('#available-chatrooms');
|
||||||
this.rooms = $(iq).find('query').find('item');
|
this.rooms = $(iq).find('query').find('item');
|
||||||
@ -1207,7 +1207,7 @@
|
|||||||
|
|
||||||
updateRoomsList: function () {
|
updateRoomsList: function () {
|
||||||
/* Send and IQ stanza to the server asking for all rooms
|
/* Send and IQ stanza to the server asking for all rooms
|
||||||
*/
|
*/
|
||||||
converse.connection.sendIQ(
|
converse.connection.sendIQ(
|
||||||
$iq({
|
$iq({
|
||||||
to: this.model.get('muc_domain'),
|
to: this.model.get('muc_domain'),
|
||||||
@ -1338,8 +1338,8 @@
|
|||||||
|
|
||||||
_.extend(converse_api, {
|
_.extend(converse_api, {
|
||||||
/* We extend the default converse.js API to add methods specific to MUC
|
/* We extend the default converse.js API to add methods specific to MUC
|
||||||
* chat rooms.
|
* chat rooms.
|
||||||
*/
|
*/
|
||||||
'rooms': {
|
'rooms': {
|
||||||
'open': function (jids, nick) {
|
'open': function (jids, nick) {
|
||||||
if (!nick) {
|
if (!nick) {
|
||||||
|
@ -120,8 +120,8 @@
|
|||||||
|
|
||||||
registerHooks: function () {
|
registerHooks: function () {
|
||||||
/* Hook into Strophe's _connect_cb, so that we can send an IQ
|
/* Hook into Strophe's _connect_cb, so that we can send an IQ
|
||||||
* requesting the registration fields.
|
* requesting the registration fields.
|
||||||
*/
|
*/
|
||||||
var conn = converse.connection;
|
var conn = converse.connection;
|
||||||
var connect_cb = conn._connect_cb.bind(conn);
|
var connect_cb = conn._connect_cb.bind(conn);
|
||||||
conn._connect_cb = function (req, callback, raw) {
|
conn._connect_cb = function (req, callback, raw) {
|
||||||
@ -137,11 +137,11 @@
|
|||||||
|
|
||||||
getRegistrationFields: function (req, _callback, raw) {
|
getRegistrationFields: function (req, _callback, raw) {
|
||||||
/* Send an IQ stanza to the XMPP server asking for the
|
/* Send an IQ stanza to the XMPP server asking for the
|
||||||
* registration fields.
|
* registration fields.
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (Strophe.Request) req - The current request
|
* (Strophe.Request) req - The current request
|
||||||
* (Function) callback
|
* (Function) callback
|
||||||
*/
|
*/
|
||||||
converse.log("sendQueryStanza was called");
|
converse.log("sendQueryStanza was called");
|
||||||
var conn = converse.connection;
|
var conn = converse.connection;
|
||||||
conn.connected = true;
|
conn.connected = true;
|
||||||
@ -172,10 +172,10 @@
|
|||||||
|
|
||||||
onRegistrationFields: function (stanza) {
|
onRegistrationFields: function (stanza) {
|
||||||
/* Handler for Registration Fields Request.
|
/* Handler for Registration Fields Request.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (XMLElement) elem - The query stanza.
|
* (XMLElement) elem - The query stanza.
|
||||||
*/
|
*/
|
||||||
if (stanza.getElementsByTagName("query").length !== 1) {
|
if (stanza.getElementsByTagName("query").length !== 1) {
|
||||||
converse.connection._changeConnectStatus(Strophe.Status.REGIFAIL, "unknown");
|
converse.connection._changeConnectStatus(Strophe.Status.REGIFAIL, "unknown");
|
||||||
return false;
|
return false;
|
||||||
@ -204,11 +204,11 @@
|
|||||||
|
|
||||||
onProviderChosen: function (ev) {
|
onProviderChosen: function (ev) {
|
||||||
/* Callback method that gets called when the user has chosen an
|
/* Callback method that gets called when the user has chosen an
|
||||||
* XMPP provider.
|
* XMPP provider.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (Submit Event) ev - Form submission event.
|
* (Submit Event) ev - Form submission event.
|
||||||
*/
|
*/
|
||||||
if (ev && ev.preventDefault) { ev.preventDefault(); }
|
if (ev && ev.preventDefault) { ev.preventDefault(); }
|
||||||
var $form = $(ev.target),
|
var $form = $(ev.target),
|
||||||
$domain_input = $form.find('input[name=domain]'),
|
$domain_input = $form.find('input[name=domain]'),
|
||||||
@ -287,11 +287,11 @@
|
|||||||
|
|
||||||
renderRegistrationForm: function (stanza) {
|
renderRegistrationForm: function (stanza) {
|
||||||
/* Renders the registration form based on the XForm fields
|
/* Renders the registration form based on the XForm fields
|
||||||
* received from the XMPP server.
|
* received from the XMPP server.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (XMLElement) stanza - The IQ stanza received from the XMPP server.
|
* (XMLElement) stanza - The IQ stanza received from the XMPP server.
|
||||||
*/
|
*/
|
||||||
var $form= this.$('form'),
|
var $form= this.$('form'),
|
||||||
$stanza = $(stanza),
|
$stanza = $(stanza),
|
||||||
$fields, $input;
|
$fields, $input;
|
||||||
@ -344,12 +344,12 @@
|
|||||||
|
|
||||||
reportErrors: function (stanza) {
|
reportErrors: function (stanza) {
|
||||||
/* Report back to the user any error messages received from the
|
/* Report back to the user any error messages received from the
|
||||||
* XMPP server after attempted registration.
|
* XMPP server after attempted registration.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (XMLElement) stanza - The IQ stanza received from the
|
* (XMLElement) stanza - The IQ stanza received from the
|
||||||
* XMPP server.
|
* XMPP server.
|
||||||
*/
|
*/
|
||||||
var $form= this.$('form'), flash;
|
var $form= this.$('form'), flash;
|
||||||
var $errmsgs = $(stanza).find('error text');
|
var $errmsgs = $(stanza).find('error text');
|
||||||
var $flash = $form.find('.form-errors');
|
var $flash = $form.find('.form-errors');
|
||||||
@ -377,7 +377,7 @@
|
|||||||
|
|
||||||
cancelRegistration: function (ev) {
|
cancelRegistration: function (ev) {
|
||||||
/* Handler, when the user cancels the registration form.
|
/* Handler, when the user cancels the registration form.
|
||||||
*/
|
*/
|
||||||
if (ev && ev.preventDefault) { ev.preventDefault(); }
|
if (ev && ev.preventDefault) { ev.preventDefault(); }
|
||||||
converse.connection.reset();
|
converse.connection.reset();
|
||||||
this.render();
|
this.render();
|
||||||
@ -385,12 +385,12 @@
|
|||||||
|
|
||||||
submitRegistrationForm : function (ev) {
|
submitRegistrationForm : function (ev) {
|
||||||
/* Handler, when the user submits the registration form.
|
/* Handler, when the user submits the registration form.
|
||||||
* Provides form error feedback or starts the registration
|
* Provides form error feedback or starts the registration
|
||||||
* process.
|
* process.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (Event) ev - the submit event.
|
* (Event) ev - the submit event.
|
||||||
*/
|
*/
|
||||||
if (ev && ev.preventDefault) { ev.preventDefault(); }
|
if (ev && ev.preventDefault) { ev.preventDefault(); }
|
||||||
var $empty_inputs = this.$('input.required:emptyVal');
|
var $empty_inputs = this.$('input.required:emptyVal');
|
||||||
if ($empty_inputs.length) {
|
if ($empty_inputs.length) {
|
||||||
@ -418,11 +418,11 @@
|
|||||||
|
|
||||||
setFields: function (stanza) {
|
setFields: function (stanza) {
|
||||||
/* Stores the values that will be sent to the XMPP server
|
/* Stores the values that will be sent to the XMPP server
|
||||||
* during attempted registration.
|
* during attempted registration.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (XMLElement) stanza - the IQ stanza that will be sent to the XMPP server.
|
* (XMLElement) stanza - the IQ stanza that will be sent to the XMPP server.
|
||||||
*/
|
*/
|
||||||
var $query = $(stanza).find('query'), $xform;
|
var $query = $(stanza).find('query'), $xform;
|
||||||
if ($query.length > 0) {
|
if ($query.length > 0) {
|
||||||
$xform = $query.find('x[xmlns="'+Strophe.NS.XFORM+'"]');
|
$xform = $query.find('x[xmlns="'+Strophe.NS.XFORM+'"]');
|
||||||
@ -470,12 +470,12 @@
|
|||||||
|
|
||||||
_onRegisterIQ: function (stanza) {
|
_onRegisterIQ: function (stanza) {
|
||||||
/* Callback method that gets called when a return IQ stanza
|
/* Callback method that gets called when a return IQ stanza
|
||||||
* is received from the XMPP server, after attempting to
|
* is received from the XMPP server, after attempting to
|
||||||
* register a new user.
|
* register a new user.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (XMLElement) stanza - The IQ stanza.
|
* (XMLElement) stanza - The IQ stanza.
|
||||||
*/
|
*/
|
||||||
var error = null,
|
var error = null,
|
||||||
query = stanza.getElementsByTagName("query");
|
query = stanza.getElementsByTagName("query");
|
||||||
if (query.length > 0) {
|
if (query.length > 0) {
|
||||||
|
@ -140,20 +140,20 @@
|
|||||||
success: function (collection) {
|
success: function (collection) {
|
||||||
if (collection.length === 0) {
|
if (collection.length === 0) {
|
||||||
/* We don't have any roster contacts stored in sessionStorage,
|
/* We don't have any roster contacts stored in sessionStorage,
|
||||||
* so lets fetch the roster from the XMPP server. We pass in
|
* so lets fetch the roster from the XMPP server. We pass in
|
||||||
* 'sendPresence' as callback method, because after initially
|
* 'sendPresence' as callback method, because after initially
|
||||||
* fetching the roster we are ready to receive presence
|
* fetching the roster we are ready to receive presence
|
||||||
* updates from our contacts.
|
* updates from our contacts.
|
||||||
*/
|
*/
|
||||||
converse.roster.fetchFromServer(function () {
|
converse.roster.fetchFromServer(function () {
|
||||||
converse.xmppstatus.sendPresence();
|
converse.xmppstatus.sendPresence();
|
||||||
});
|
});
|
||||||
} else if (converse.send_initial_presence) {
|
} else if (converse.send_initial_presence) {
|
||||||
/* We're not going to fetch the roster again because we have
|
/* We're not going to fetch the roster again because we have
|
||||||
* it already cached in sessionStorage, but we still need to
|
* it already cached in sessionStorage, but we still need to
|
||||||
* send out a presence stanza because this is a new session.
|
* send out a presence stanza because this is a new session.
|
||||||
* See: https://github.com/jcbrand/converse.js/issues/536
|
* See: https://github.com/jcbrand/converse.js/issues/536
|
||||||
*/
|
*/
|
||||||
converse.xmppstatus.sendPresence();
|
converse.xmppstatus.sendPresence();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -326,13 +326,13 @@
|
|||||||
|
|
||||||
positionFetchedGroups: function (model, resp, options) {
|
positionFetchedGroups: function (model, resp, options) {
|
||||||
/* Instead of throwing an add event for each group
|
/* Instead of throwing an add event for each group
|
||||||
* fetched, we wait until they're all fetched and then
|
* fetched, we wait until they're all fetched and then
|
||||||
* we position them.
|
* we position them.
|
||||||
* Works around the problem of positionGroup not
|
* Works around the problem of positionGroup not
|
||||||
* working when all groups besides the one being
|
* working when all groups besides the one being
|
||||||
* positioned aren't already in inserted into the
|
* positioned aren't already in inserted into the
|
||||||
* roster DOM element.
|
* roster DOM element.
|
||||||
*/
|
*/
|
||||||
model.sort();
|
model.sort();
|
||||||
model.each(function (group, idx) {
|
model.each(function (group, idx) {
|
||||||
var view = this.get(group.get('name'));
|
var view = this.get(group.get('name'));
|
||||||
@ -350,8 +350,8 @@
|
|||||||
|
|
||||||
positionGroup: function (view) {
|
positionGroup: function (view) {
|
||||||
/* Place the group's DOM element in the correct alphabetical
|
/* Place the group's DOM element in the correct alphabetical
|
||||||
* position amongst the other groups in the roster.
|
* position amongst the other groups in the roster.
|
||||||
*/
|
*/
|
||||||
var $groups = this.$roster.find('.roster-group'),
|
var $groups = this.$roster.find('.roster-group'),
|
||||||
index = $groups.length ? this.model.indexOf(view.model) : 0;
|
index = $groups.length ? this.model.indexOf(view.model) : 0;
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
@ -366,7 +366,7 @@
|
|||||||
|
|
||||||
appendGroup: function (view) {
|
appendGroup: function (view) {
|
||||||
/* Add the group at the bottom of the roster
|
/* Add the group at the bottom of the roster
|
||||||
*/
|
*/
|
||||||
var $last = this.$roster.find('.roster-group').last();
|
var $last = this.$roster.find('.roster-group').last();
|
||||||
var $siblings = $last.siblings('dd');
|
var $siblings = $last.siblings('dd');
|
||||||
if ($siblings.length > 0) {
|
if ($siblings.length > 0) {
|
||||||
@ -379,8 +379,8 @@
|
|||||||
|
|
||||||
getGroup: function (name) {
|
getGroup: function (name) {
|
||||||
/* Returns the group as specified by name.
|
/* Returns the group as specified by name.
|
||||||
* Creates the group if it doesn't exist.
|
* Creates the group if it doesn't exist.
|
||||||
*/
|
*/
|
||||||
var view = this.get(name);
|
var view = this.get(name);
|
||||||
if (view) {
|
if (view) {
|
||||||
return view.model;
|
return view.model;
|
||||||
@ -466,16 +466,16 @@
|
|||||||
|
|
||||||
if ((ask === 'subscribe') || (subscription === 'from')) {
|
if ((ask === 'subscribe') || (subscription === 'from')) {
|
||||||
/* ask === 'subscribe'
|
/* ask === 'subscribe'
|
||||||
* Means we have asked to subscribe to them.
|
* Means we have asked to subscribe to them.
|
||||||
*
|
*
|
||||||
* subscription === 'from'
|
* subscription === 'from'
|
||||||
* They are subscribed to use, but not vice versa.
|
* They are subscribed to use, but not vice versa.
|
||||||
* We assume that there is a pending subscription
|
* We assume that there is a pending subscription
|
||||||
* from us to them (otherwise we're in a state not
|
* from us to them (otherwise we're in a state not
|
||||||
* supported by converse.js).
|
* supported by converse.js).
|
||||||
*
|
*
|
||||||
* So in both cases the user is a "pending" contact.
|
* So in both cases the user is a "pending" contact.
|
||||||
*/
|
*/
|
||||||
this.$el.addClass('pending-xmpp-contact');
|
this.$el.addClass('pending-xmpp-contact');
|
||||||
this.$el.html(converse.templates.pending_contact(
|
this.$el.html(converse.templates.pending_contact(
|
||||||
_.extend(item.toJSON(), {
|
_.extend(item.toJSON(), {
|
||||||
@ -618,8 +618,8 @@
|
|||||||
|
|
||||||
positionContact: function (contact) {
|
positionContact: function (contact) {
|
||||||
/* Place the contact's DOM element in the correct alphabetical
|
/* Place the contact's DOM element in the correct alphabetical
|
||||||
* position amongst the other contacts in this group.
|
* position amongst the other contacts in this group.
|
||||||
*/
|
*/
|
||||||
var view = this.get(contact.get('id'));
|
var view = this.get(contact.get('id'));
|
||||||
var index = this.model.contacts.indexOf(contact);
|
var index = this.model.contacts.indexOf(contact);
|
||||||
view.$el.detach();
|
view.$el.detach();
|
||||||
@ -648,10 +648,10 @@
|
|||||||
|
|
||||||
filter: function (q) {
|
filter: function (q) {
|
||||||
/* Filter the group's contacts based on the query "q".
|
/* Filter the group's contacts based on the query "q".
|
||||||
* The query is matched against the contact's full name.
|
* The query is matched against the contact's full name.
|
||||||
* If all contacts are filtered out (i.e. hidden), then the
|
* If all contacts are filtered out (i.e. hidden), then the
|
||||||
* group must be filtered out as well.
|
* group must be filtered out as well.
|
||||||
*/
|
*/
|
||||||
var matches;
|
var matches;
|
||||||
if (q.length === 0) {
|
if (q.length === 0) {
|
||||||
if (this.model.get('state') === converse.OPENED) {
|
if (this.model.get('state') === converse.OPENED) {
|
||||||
@ -738,8 +738,8 @@
|
|||||||
model: converse.RosterGroup,
|
model: converse.RosterGroup,
|
||||||
comparator: function (a, b) {
|
comparator: function (a, b) {
|
||||||
/* Groups are sorted alphabetically, ignoring case.
|
/* Groups are sorted alphabetically, ignoring case.
|
||||||
* However, Ungrouped, Requesting Contacts and Pending Contacts
|
* However, Ungrouped, Requesting Contacts and Pending Contacts
|
||||||
* appear last and in that order. */
|
* appear last and in that order. */
|
||||||
a = a.get('name');
|
a = a.get('name');
|
||||||
b = b.get('name');
|
b = b.get('name');
|
||||||
var special_groups = _.keys(HEADER_WEIGHTS);
|
var special_groups = _.keys(HEADER_WEIGHTS);
|
||||||
|
Loading…
Reference in New Issue
Block a user