Commit 40e7ee1a authored by JC Brand's avatar JC Brand

Initial stab at using ES2015

Mostly replaced ``var`` with ``let`` and ``const``.
Also added a few arrow functions.
parent e1b745b7
{ {
"parserOptions": {
"ecmaVersion": 6
},
"env": { "env": {
"browser": true, "browser": true,
"jasmine": true "jasmine": true
......
...@@ -306,7 +306,7 @@ ...@@ -306,7 +306,7 @@
*/ */
var IQ_id; var IQ_id;
expect(_.filter(_converse.connection.send.calls.all(), function (call) { expect(_.filter(_converse.connection.send.calls.all(), function (call) {
var stanza = call.args[0] var stanza = call.args[0];
if (!(stanza instanceof Element) || stanza.nodeName !== 'iq') { if (!(stanza instanceof Element) || stanza.nodeName !== 'iq') {
return; return;
} }
...@@ -373,7 +373,7 @@ ...@@ -373,7 +373,7 @@
it("shows a list of bookmarks", mock.initConverseWithConnectionSpies(['send'], function (_converse) { it("shows a list of bookmarks", mock.initConverseWithConnectionSpies(['send'], function (_converse) {
var IQ_id; var IQ_id;
expect(_.filter(_converse.connection.send.calls.all(), function (call) { expect(_.filter(_converse.connection.send.calls.all(), function (call) {
var stanza = call.args[0] var stanza = call.args[0];
if (!(stanza instanceof Element) || stanza.nodeName !== 'iq') { if (!(stanza instanceof Element) || stanza.nodeName !== 'iq') {
return; return;
} }
...@@ -421,7 +421,7 @@ ...@@ -421,7 +421,7 @@
mock.initConverseWithConnectionSpies(['send'], function (_converse) { mock.initConverseWithConnectionSpies(['send'], function (_converse) {
var IQ_id; var IQ_id;
expect(_.filter(_converse.connection.send.calls.all(), function (call) { expect(_.filter(_converse.connection.send.calls.all(), function (call) {
var stanza = call.args[0] var stanza = call.args[0];
if (!(stanza instanceof Element) || stanza.nodeName !== 'iq') { if (!(stanza instanceof Element) || stanza.nodeName !== 'iq') {
return; return;
} }
......
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
} }
return test_utils.waitUntil(function () { return test_utils.waitUntil(function () {
return _converse.chatboxviews.keys().length > 1; return _converse.chatboxviews.keys().length > 1;
}, 500) }, 500);
}).then(function () { }).then(function () {
var key = _converse.chatboxviews.keys()[1]; var key = _converse.chatboxviews.keys()[1];
trimmedview = trimmed_chatboxes.get(key); trimmedview = trimmed_chatboxes.get(key);
...@@ -268,7 +268,7 @@ ...@@ -268,7 +268,7 @@
expect(_converse.emit).toHaveBeenCalledWith('chatBoxMaximized', jasmine.any(Object)); expect(_converse.emit).toHaveBeenCalledWith('chatBoxMaximized', jasmine.any(Object));
return test_utils.waitUntil(function () { return test_utils.waitUntil(function () {
return chatview.$el.find('.chat-body').is(':visible'); return chatview.$el.find('.chat-body').is(':visible');
}, 500) }, 500);
}).then(function () { }).then(function () {
expect(chatview.$el.find('.toggle-chatbox-button').hasClass('icon-minus')).toBeTruthy(); expect(chatview.$el.find('.toggle-chatbox-button').hasClass('icon-minus')).toBeTruthy();
expect(chatview.$el.find('.toggle-chatbox-button').hasClass('icon-plus')).toBeFalsy(); expect(chatview.$el.find('.toggle-chatbox-button').hasClass('icon-plus')).toBeFalsy();
...@@ -715,12 +715,12 @@ ...@@ -715,12 +715,12 @@
.then(function () { .then(function () {
return test_utils.waitUntil(function () { return test_utils.waitUntil(function () {
return !chatboxview.model.get('auto_scrolled'); return !chatboxview.model.get('auto_scrolled');
}, 300) }, 300);
}).then(function () { }).then(function () {
chatboxview.$content.scrollTop(0); chatboxview.$content.scrollTop(0);
return test_utils.waitUntil(function () { return test_utils.waitUntil(function () {
return chatboxview.model.get('scrolled'); return chatboxview.model.get('scrolled');
}, 900) }, 900);
}).then(function () { }).then(function () {
_converse.chatboxes.onMessage($msg({ _converse.chatboxes.onMessage($msg({
from: sender_jid, from: sender_jid,
...@@ -736,7 +736,7 @@ ...@@ -736,7 +736,7 @@
expect(msg_txt).toEqual(message); expect(msg_txt).toEqual(message);
return test_utils.waitUntil(function () { return test_utils.waitUntil(function () {
return chatboxview.$('.new-msgs-indicator').is(':visible'); return chatboxview.$('.new-msgs-indicator').is(':visible');
}, 300) }, 300);
}).then(function () { }).then(function () {
expect(chatboxview.model.get('scrolled')).toBe(true); expect(chatboxview.model.get('scrolled')).toBe(true);
expect(chatboxview.$content.scrollTop()).toBe(0); expect(chatboxview.$content.scrollTop()).toBe(0);
...@@ -745,7 +745,7 @@ ...@@ -745,7 +745,7 @@
chatboxview.$content.scrollTop(chatboxview.$content[0].scrollHeight); chatboxview.$content.scrollTop(chatboxview.$content[0].scrollHeight);
return test_utils.waitUntil(function () { return test_utils.waitUntil(function () {
return !chatboxview.$('.new-msgs-indicator').is(':visible'); return !chatboxview.$('.new-msgs-indicator').is(':visible');
}, 300) }, 300);
}).then(done); }).then(done);
})); }));
...@@ -1256,7 +1256,7 @@ ...@@ -1256,7 +1256,7 @@
test_utils.sendMessage(view, message); test_utils.sendMessage(view, message);
return test_utils.waitUntil(function () { return test_utils.waitUntil(function () {
return view.$el.find('.chat-content').find('.chat-message img').length === 2; return view.$el.find('.chat-content').find('.chat-message img').length === 2;
}, 500) }, 500);
}).then(function () { }).then(function () {
expect(view.sendMessage).toHaveBeenCalled(); expect(view.sendMessage).toHaveBeenCalled();
var msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-msg-content'); var msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-msg-content');
...@@ -1351,7 +1351,7 @@ ...@@ -1351,7 +1351,7 @@
view.model.maximize(); view.model.maximize();
return test_utils.waitUntil(function () { return test_utils.waitUntil(function () {
return view.model.get('chat_state') === 'active'; return view.model.get('chat_state') === 'active';
}, 300) }, 300);
}).then(function () { }).then(function () {
expect(_converse.connection.send).toHaveBeenCalled(); expect(_converse.connection.send).toHaveBeenCalled();
var $stanza = $(_converse.connection.send.calls.argsFor(0)[0].tree()); var $stanza = $(_converse.connection.send.calls.argsFor(0)[0].tree());
...@@ -1496,7 +1496,7 @@ ...@@ -1496,7 +1496,7 @@
expect($stanza.children().get(0).tagName).toBe('composing'); expect($stanza.children().get(0).tagName).toBe('composing');
return test_utils.waitUntil(function () { return test_utils.waitUntil(function () {
return view.model.get('chat_state') === 'paused'; return view.model.get('chat_state') === 'paused';
}, 500) }, 500);
}).then(function () { }).then(function () {
expect(_converse.connection.send).toHaveBeenCalled(); expect(_converse.connection.send).toHaveBeenCalled();
var $stanza = $(_converse.connection.send.calls.argsFor(1)[0].tree()); var $stanza = $(_converse.connection.send.calls.argsFor(1)[0].tree());
...@@ -1618,11 +1618,11 @@ ...@@ -1618,11 +1618,11 @@
return true; return true;
} }
return false; return false;
}, 250) }, 250);
}).then(function () { }).then(function () {
return test_utils.waitUntil(function () { return test_utils.waitUntil(function () {
return view.model.get('chat_state') === 'inactive'; return view.model.get('chat_state') === 'inactive';
}, 250) }, 250);
}).then(function () { }).then(function () {
expect(_converse.connection.send).toHaveBeenCalled(); expect(_converse.connection.send).toHaveBeenCalled();
var $stanza = $(_converse.connection.send.calls.first().args[0].tree()); var $stanza = $(_converse.connection.send.calls.first().args[0].tree());
......
...@@ -43,4 +43,4 @@ ...@@ -43,4 +43,4 @@
endFile: "end-no-dependencies.frag" endFile: "end-no-dependencies.frag"
}, },
mainConfigFile: "config.js" mainConfigFile: "config.js"
}) });
...@@ -6,4 +6,4 @@ ...@@ -6,4 +6,4 @@
startFile: "start.frag", startFile: "start.frag",
endFile: "end.frag" endFile: "end.frag"
} }
}) });
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
tpl_bookmarks_list tpl_bookmarks_list
) { ) {
var $ = converse.env.jQuery, const $ = converse.env.jQuery,
Backbone = converse.env.Backbone, Backbone = converse.env.Backbone,
Strophe = converse.env.Strophe, Strophe = converse.env.Strophe,
$iq = converse.env.$iq, $iq = converse.env.$iq,
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
}, },
generateHeadingHTML: function () { generateHeadingHTML: function () {
var _converse = this.__super__._converse, const _converse = this.__super__._converse,
__ = _converse.__, __ = _converse.__,
html = this.__super__.generateHeadingHTML.apply(this, arguments); html = this.__super__.generateHeadingHTML.apply(this, arguments);
if (_converse.allow_bookmarks) { if (_converse.allow_bookmarks) {
...@@ -92,11 +92,11 @@ ...@@ -92,11 +92,11 @@
* for this room, and if so use it. * for this room, and if so use it.
* Otherwise delegate to the super method. * Otherwise delegate to the super method.
*/ */
var _converse = this.__super__._converse; const _converse = this.__super__._converse;
if (_.isUndefined(_converse.bookmarks) || !_converse.allow_bookmarks) { if (_.isUndefined(_converse.bookmarks) || !_converse.allow_bookmarks) {
return this.__super__.checkForReservedNick.apply(this, arguments); return this.__super__.checkForReservedNick.apply(this, arguments);
} }
var model = _converse.bookmarks.findWhere({'jid': this.model.get('jid')}); const model = _converse.bookmarks.findWhere({'jid': this.model.get('jid')});
if (!_.isUndefined(model) && model.get('nick')) { if (!_.isUndefined(model) && model.get('nick')) {
this.join(model.get('nick')); this.join(model.get('nick'));
} else { } else {
......
This diff is collapsed.
...@@ -42,14 +42,14 @@ ...@@ -42,14 +42,14 @@
) { ) {
"use strict"; "use strict";
var USERS_PANEL_ID = 'users'; const USERS_PANEL_ID = 'users';
var CHATBOX_TYPE = 'chatbox'; const CHATBOX_TYPE = 'chatbox';
// Strophe methods for building stanzas // Strophe methods for building stanzas
var Strophe = converse.env.Strophe, const Strophe = converse.env.Strophe,
Backbone = converse.env.Backbone, Backbone = converse.env.Backbone,
utils = converse.env.utils; utils = converse.env.utils;
// Other necessary globals // Other necessary globals
var $ = converse.env.jQuery, const $ = converse.env.jQuery,
_ = converse.env._, _ = converse.env._,
fp = converse.env.fp, fp = converse.env.fp,
moment = converse.env.moment; moment = converse.env.moment;
...@@ -188,7 +188,7 @@ ...@@ -188,7 +188,7 @@
/* 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.
*/ */
var _converse = this._converse, const _converse = this._converse,
__ = _converse.__; __ = _converse.__;
_converse.api.settings.update({ _converse.api.settings.update({
...@@ -200,12 +200,13 @@ ...@@ -200,12 +200,13 @@
xhr_user_search_url: '' xhr_user_search_url: ''
}); });
var LABEL_CONTACTS = __('Contacts'); const LABEL_CONTACTS = __('Contacts');
_converse.addControlBox = function () { _converse.addControlBox = function () {
return _converse.chatboxes.add({ return _converse.chatboxes.add({
id: 'controlbox', id: 'controlbox',
box_id: 'controlbox', box_id: 'controlbox',
type: 'controlbox',
closed: !_converse.show_controlbox_by_default closed: !_converse.show_controlbox_by_default
}); });
}; };
......
This diff is collapsed.
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
], factory); ], factory);
}(this, function (converse, tpl_dragresize) { }(this, function (converse, tpl_dragresize) {
"use strict"; "use strict";
var $ = converse.env.jQuery, const $ = converse.env.jQuery,
_ = converse.env._; _ = converse.env._;
function renderDragResizeHandles (_converse, view) { function renderDragResizeHandles (_converse, view) {
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
], factory); ], factory);
}(this, function (converse, tpl_chatbox) { }(this, function (converse, tpl_chatbox) {
"use strict"; "use strict";
var _ = converse.env._, const _ = converse.env._,
utils = converse.env.utils; utils = converse.env.utils;
converse.plugins.add('converse-headline', { converse.plugins.add('converse-headline', {
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
ChatBoxViews: { ChatBoxViews: {
onChatBoxAdded: function (item) { onChatBoxAdded: function (item) {
var _converse = this.__super__._converse; const _converse = this.__super__._converse;
var view = this.get(item.get('id')); let view = this.get(item.get('id'));
if (!view && item.get('type') === 'headline') { if (!view && item.get('type') === 'headline') {
view = new _converse.HeadlinesBoxView({model: item}); view = new _converse.HeadlinesBoxView({model: item});
this.add(item.get('id'), view); this.add(item.get('id'), view);
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
/* 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.
*/ */
var _converse = this._converse, const _converse = this._converse,
__ = _converse.__; __ = _converse.__;
_converse.HeadlinesBoxView = _converse.ChatBoxView.extend({ _converse.HeadlinesBoxView = _converse.ChatBoxView.extend({
...@@ -89,14 +89,14 @@ ...@@ -89,14 +89,14 @@
} }
}); });
var onHeadlineMessage = function (message) { function onHeadlineMessage (message) {
/* Handler method for all incoming messages of type "headline". */ /* Handler method for all incoming messages of type "headline". */
var from_jid = message.getAttribute('from'); const from_jid = message.getAttribute('from');
if (utils.isHeadlineMessage(message)) { if (utils.isHeadlineMessage(message)) {
if (_.includes(from_jid, '@') && !_converse.allow_non_roster_messaging) { if (_.includes(from_jid, '@') && !_converse.allow_non_roster_messaging) {
return; return;
} }
var chatbox = _converse.chatboxes.create({ const chatbox = _converse.chatboxes.create({
'id': from_jid, 'id': from_jid,
'jid': from_jid, 'jid': from_jid,
'fullname': from_jid, 'fullname': from_jid,
...@@ -106,12 +106,12 @@ ...@@ -106,12 +106,12 @@
_converse.emit('message', {'chatbox': chatbox, 'stanza': message}); _converse.emit('message', {'chatbox': chatbox, 'stanza': message});
} }
return true; return true;
}; }
var registerHeadlineHandler = function () { function registerHeadlineHandler () {
_converse.connection.addHandler( _converse.connection.addHandler(
onHeadlineMessage, null, 'message'); onHeadlineMessage, null, 'message');
}; }
_converse.on('connected', registerHeadlineHandler); _converse.on('connected', registerHeadlineHandler);
_converse.on('reconnected', registerHeadlineHandler); _converse.on('reconnected', registerHeadlineHandler);
} }
......
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
tpl_chats_panel tpl_chats_panel
) { ) {
"use strict"; "use strict";
var $ = converse.env.jQuery,
const $ = converse.env.jQuery,
_ = converse.env._, _ = converse.env._,
utils = converse.env.utils, utils = converse.env.utils,
Backbone = converse.env.Backbone, Backbone = converse.env.Backbone,
...@@ -40,8 +41,8 @@ ...@@ -40,8 +41,8 @@
// New functions which don't exist yet can also be added. // New functions which don't exist yet can also be added.
initChatBoxes: function () { initChatBoxes: function () {
var _converse = this.__super__._converse; const _converse = this.__super__._converse;
var result = this.__super__.initChatBoxes.apply(this, arguments); const result = this.__super__.initChatBoxes.apply(this, arguments);
_converse.minimized_chats = new _converse.MinimizedChats({ _converse.minimized_chats = new _converse.MinimizedChats({
model: _converse.chatboxes model: _converse.chatboxes
}); });
...@@ -49,7 +50,7 @@ ...@@ -49,7 +50,7 @@
}, },
registerGlobalEventHandlers: function () { registerGlobalEventHandlers: function () {
var _converse = this.__super__._converse; const _converse = this.__super__._converse;
$(window).on("resize", _.debounce(function (ev) { $(window).on("resize", _.debounce(function (ev) {
if (_converse.connection.connected) { if (_converse.connection.connected) {
_converse.chatboxviews.trimChats(); _converse.chatboxviews.trimChats();
...@@ -96,7 +97,7 @@ ...@@ -96,7 +97,7 @@
}, },
_show: function () { _show: function () {
var _converse = this.__super__._converse; const _converse = this.__super__._converse;
if (!this.model.get('minimized')) { if (!this.model.get('minimized')) {
this.__super__._show.apply(this, arguments); this.__super__._show.apply(this, arguments);
_converse.chatboxviews.trimChats(this); _converse.chatboxviews.trimChats(this);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
define(["converse-core", "converse-muc"], factory); define(["converse-core", "converse-muc"], factory);
}(this, function (converse) { }(this, function (converse) {
"use strict"; "use strict";
var Backbone = converse.env.Backbone, const Backbone = converse.env.Backbone,
_ = converse.env._; _ = converse.env._;
converse.plugins.add('converse-muc-embedded', { converse.plugins.add('converse-muc-embedded', {
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
onConnected: function () { onConnected: function () {
// Override to avoid storing or fetching chat boxes from session // Override to avoid storing or fetching chat boxes from session
// storage. // storage.
var _converse = this.__super__._converse; const _converse = this.__super__._converse;
this.browserStorage = new Backbone.BrowserStorage[_converse.storage]( this.browserStorage = new Backbone.BrowserStorage[_converse.storage](
converse.env.b64_sha1('converse.chatboxes-'+_converse.bare_jid)); converse.env.b64_sha1('converse.chatboxes-'+_converse.bare_jid));
this.registerMessageHandler(); this.registerMessageHandler();
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
ChatRoomView: { ChatRoomView: {
insertIntoDOM: function () { insertIntoDOM: function () {
if (!document.body.contains(this.el)) { if (!document.body.contains(this.el)) {
var container = document.querySelector('#converse-embedded-chat'); const container = document.querySelector('#converse-embedded-chat');
container.innerHTML = ''; container.innerHTML = '';
container.appendChild(this.el); container.appendChild(this.el);
} }
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
/* 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.
*/ */
var _converse = this._converse; const _converse = this._converse;
if (!_.isArray(_converse.auto_join_rooms)) { if (!_.isArray(_converse.auto_join_rooms)) {
throw new Error("converse-muc-embedded: auto_join_rooms must be an Array"); throw new Error("converse-muc-embedded: auto_join_rooms must be an Array");
} }
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
throw new Error("converse-muc-embedded: It doesn't make "+ throw new Error("converse-muc-embedded: It doesn't make "+
"sense to have the auto_join_rooms setting to zero or "+ "sense to have the auto_join_rooms setting to zero or "+
"more then one, since only one chat room can be open "+ "more then one, since only one chat room can be open "+
"at any time.") "at any time.");
} }
} }
}); });
......
This diff is collapsed.
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
define(["converse-core"], factory); define(["converse-core"], factory);
}(this, function (converse) { }(this, function (converse) {
"use strict"; "use strict";
var utils = converse.env.utils, const utils = converse.env.utils,
Strophe = converse.env.Strophe, Strophe = converse.env.Strophe,
_ = converse.env._; _ = converse.env._;
...@@ -20,11 +20,11 @@ ...@@ -20,11 +20,11 @@
/* 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.
*/ */
var _converse = this._converse; const _converse = this._converse;
// For translations // For translations
var __ = _converse.__; const __ = _converse.__;
var ___ = _converse.___; const ___ = _converse.___;
_converse.supports_html5_notification = "Notification" in window; _converse.supports_html5_notification = "Notification" in window;
......
...@@ -19,29 +19,29 @@ ...@@ -19,29 +19,29 @@
"use strict"; "use strict";
// Strophe methods for building stanzas // Strophe methods for building stanzas
var Strophe = converse.env.Strophe, const Strophe = converse.env.Strophe,
utils = converse.env.utils, utils = converse.env.utils,
b64_sha1 = converse.env.b64_sha1; b64_sha1 = converse.env.b64_sha1;
// Other necessary globals // Other necessary globals
var $ = converse.env.jQuery, const $ = converse.env.jQuery,
_ = converse.env._; _ = converse.env._;
var HAS_CSPRNG = ((!_.isUndefined(crypto)) && const HAS_CSPRNG = ((!_.isUndefined(crypto)) &&
((_.isFunction(crypto.randomBytes)) || (_.isFunction(crypto.getRandomValues)) ((_.isFunction(crypto.randomBytes)) || (_.isFunction(crypto.getRandomValues))
)); ));
var HAS_CRYPTO = HAS_CSPRNG && ( const HAS_CRYPTO = HAS_CSPRNG && (
(!_.isUndefined(otr.OTR)) && (!_.isUndefined(otr.OTR)) &&
(!_.isUndefined(otr.DSA)) (!_.isUndefined(otr.DSA))
); );
var UNENCRYPTED = 0; const UNENCRYPTED = 0;
var UNVERIFIED= 1; const UNVERIFIED= 1;
var VERIFIED= 2; const VERIFIED= 2;
var FINISHED = 3; const FINISHED = 3;
var OTR_TRANSLATED_MAPPING = {}; // Populated in initialize const OTR_TRANSLATED_MAPPING = {}; // Populated in initialize
var OTR_CLASS_MAPPING = {}; const OTR_CLASS_MAPPING = {};
OTR_CLASS_MAPPING[UNENCRYPTED] = 'unencrypted'; OTR_CLASS_MAPPING[UNENCRYPTED] = 'unencrypted';
OTR_CLASS_MAPPING[UNVERIFIED] = 'unverified'; OTR_CLASS_MAPPING[UNVERIFIED] = 'unverified';
OTR_CLASS_MAPPING[VERIFIED] = 'verified'; OTR_CLASS_MAPPING[VERIFIED] = 'verified';
...@@ -132,7 +132,7 @@ ...@@ -132,7 +132,7 @@
encrypted_key = this.get('otr_priv_key'); encrypted_key = this.get('otr_priv_key');
if (_.isString(encrypted_key)) { if (_.isString(encrypted_key)) {
instance_tag = this.get('otr_instance_tag'); instance_tag = this.get('otr_instance_tag');
saved_key = otr.DSA.parsePrivate(encrypted_key) saved_key = otr.DSA.parsePrivate(encrypted_key);
if (saved_key && instance_tag) { if (saved_key && instance_tag) {
this.trigger('showHelpMessages', [__('Re-establishing encrypted session')]); this.trigger('showHelpMessages', [__('Re-establishing encrypted session')]);
callback({ callback({
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
}(this, function (converse) { }(this, function (converse) {
"use strict"; "use strict";
// Strophe methods for building stanzas // Strophe methods for building stanzas
var Strophe = converse.env.Strophe, const Strophe = converse.env.Strophe,
_ = converse.env._; _ = converse.env._;
converse.plugins.add('converse-ping', { converse.plugins.add('converse-ping', {
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* 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.
*/ */
var _converse = this._converse; const _converse = this._converse;
_converse.api.settings.update({ _converse.api.settings.update({
ping_interval: 180 //in seconds ping_interval: 180 //in seconds
......
...@@ -32,12 +32,12 @@ ...@@ -32,12 +32,12 @@
"use strict"; "use strict";
// Strophe methods for building stanzas // Strophe methods for building stanzas
var Strophe = converse.env.Strophe, const Strophe = converse.env.Strophe,
Backbone = converse.env.Backbone, Backbone = converse.env.Backbone,
utils = converse.env.utils, utils = converse.env.utils,
$iq = converse.env.$iq; $iq = converse.env.$iq;
// Other necessary globals // Other necessary globals
var $ = converse.env.jQuery, const $ = converse.env.jQuery,
_ = converse.env._; _ = converse.env._;
// Add Strophe Namespaces // Add Strophe Namespaces
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
'toggle_state': this.list_model.get('toggle-state'), 'toggle_state': this.list_model.get('toggle-state'),
'desc_rooms': __('Click to toggle the rooms list'), 'desc_rooms': __('Click to toggle the rooms list'),
'label_rooms': __('Open Rooms') 'label_rooms': __('Open Rooms')
}) });
this.hide(); this.hide();
if (this.list_model.get('toggle-state') !== _converse.OPENED) { if (this.list_model.get('toggle-state') !== _converse.OPENED) {
this.$('.open-rooms-list').hide(); this.$('.open-rooms-list').hide();
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
} }
this.removeRoomsListElement(item); this.removeRoomsListElement(item);
var name, bookmark var name, bookmark;
if (item.get('bookmarked')) { if (item.get('bookmarked')) {
bookmark = _.head(_converse.bookmarksview.model.where({'jid': item.get('jid')})); bookmark = _.head(_converse.bookmarksview.model.where({'jid': item.get('jid')}));
name = bookmark.get('name'); name = bookmark.get('name');
......
...@@ -590,7 +590,7 @@ ...@@ -590,7 +590,7 @@
)); ));
} else if (subscription === 'both' || subscription === 'to') { } else if (subscription === 'both' || subscription === 'to') {
this.el.classList.add('current-xmpp-contact'); this.el.classList.add('current-xmpp-contact');
this.el.classList.remove(_.without(['both', 'to'], subscription)[0]) this.el.classList.remove(_.without(['both', 'to'], subscription)[0]);
this.el.classList.add(subscription); this.el.classList.add(subscription);
this.renderRosterItem(item); this.renderRosterItem(item);
} }
......
...@@ -72,9 +72,9 @@ ...@@ -72,9 +72,9 @@
* time. So before opening a chat, we make sure all other * time. So before opening a chat, we make sure all other
* chats are hidden. * chats are hidden.
*/ */
var _converse = this.__super__._converse; const _converse = this.__super__._converse;
var chatbox = this.getChatBox(attrs, true); const chatbox = this.getChatBox(attrs, true);
var hidden = _.isUndefined(attrs.hidden) ? chatbox.get('hidden') : attrs.hidden; const hidden = _.isUndefined(attrs.hidden) ? chatbox.get('hidden') : attrs.hidden;
if ((force || !hidden) && _converse.connection.authenticated) { if ((force || !hidden) && _converse.connection.authenticated) {
_.each(_converse.chatboxviews.xget(chatbox.get('id')), hideChat); _.each(_converse.chatboxviews.xget(chatbox.get('id')), hideChat);
chatbox.save({'hidden': false}); chatbox.save({'hidden': false});
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
define(["converse-core", "strophe.vcard"], factory); define(["converse-core", "strophe.vcard"], factory);
}(this, function (converse) { }(this, function (converse) {
"use strict"; "use strict";
var Strophe = converse.env.Strophe, const Strophe = converse.env.Strophe,
$ = converse.env.jQuery, $ = converse.env.jQuery,
_ = converse.env._, _ = converse.env._,
moment = converse.env.moment; moment = converse.env.moment;
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
Features: { Features: {
addClientFeatures: function () { addClientFeatures: function () {
var _converse = this.__super__._converse; const _converse = this.__super__._converse;
this.__super__.addClientFeatures.apply(this, arguments); this.__super__.addClientFeatures.apply(this, arguments);
if (_converse.use_vcards) { if (_converse.use_vcards) {
_converse.connection.disco.addFeature(Strophe.NS.VCARD); _converse.connection.disco.addFeature(Strophe.NS.VCARD);
...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
RosterContacts: { RosterContacts: {
createRequestingContact: function (presence) { createRequestingContact: function (presence) {
var _converse = this.__super__._converse; const _converse = this.__super__._converse;
var bare_jid = Strophe.getBareJidFromJid(presence.getAttribute('from')); const bare_jid = Strophe.getBareJidFromJid(presence.getAttribute('from'));
_converse.getVCard( _converse.getVCard(
bare_jid, bare_jid,
_.partial(_converse.createRequestingContactFromVCard, presence), _.partial(_converse.createRequestingContactFromVCard, presence),
...@@ -58,15 +58,15 @@ ...@@ -58,15 +58,15 @@
/* 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.
*/ */
var _converse = this._converse; const _converse = this._converse;
_converse.api.settings.update({ _converse.api.settings.update({
use_vcards: true, use_vcards: true,
}); });
_converse.createRequestingContactFromVCard = function (presence, iq, jid, fullname, img, img_type, url) { _converse.createRequestingContactFromVCard = function (presence, iq, jid, fullname, img, img_type, url) {
var bare_jid = Strophe.getBareJidFromJid(jid); const bare_jid = Strophe.getBareJidFromJid(jid);
var nick = $(presence).children('nick[xmlns="'+Strophe.NS.NICK+'"]').text(); const nick = $(presence).children('nick[xmlns="'+Strophe.NS.NICK+'"]').text();
var user_data = { const user_data = {
jid: bare_jid, jid: bare_jid,
subscription: 'none', subscription: 'none',
ask: null, ask: null,
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
}; };
_converse.onVCardError = function (jid, iq, errback) { _converse.onVCardError = function (jid, iq, errback) {
var contact = _converse.roster.get(jid); const contact = _converse.roster.get(jid);
if (contact) { if (contact) {
contact.save({ 'vcard_updated': moment().format() }); contact.save({ 'vcard_updated': moment().format() });
} }
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
var div = document.createElement('div'); var div = document.createElement('div');
div.innerHTML = htmlEscapedText; div.innerHTML = htmlEscapedText;
return div.innerText; return div.innerText;
} };
var isImage = function (url) { var isImage = function (url) {
var deferred = new $.Deferred(); var deferred = new $.Deferred();
...@@ -467,13 +467,13 @@ ...@@ -467,13 +467,13 @@
utils.isConverseLocale = function (locale) { utils.isConverseLocale = function (locale) {
if (!_.isString(locale)) { return false; } if (!_.isString(locale)) { return false; }
return _.includes(_.keys(locales || {}), locale) return _.includes(_.keys(locales || {}), locale);
}; };
utils.isMomentLocale = function (locale) { utils.isMomentLocale = function (locale) {
if (!_.isString(locale)) { return false; } if (!_.isString(locale)) { return false; }
return moment.locale() !== moment.locale(locale); return moment.locale() !== moment.locale(locale);
} };
utils.getLocale = function (preferred_locale, isSupportedByLibrary) { utils.getLocale = function (preferred_locale, isSupportedByLibrary) {
if (_.isString(preferred_locale)) { if (_.isString(preferred_locale)) {
...@@ -492,7 +492,7 @@ ...@@ -492,7 +492,7 @@
utils.isOfType = function (type, item) { utils.isOfType = function (type, item) {
return item.get('type') == type; return item.get('type') == type;
} };
utils.isInstance = function (type, item) { utils.isInstance = function (type, item) {
return item instanceof type; return item instanceof type;
...@@ -520,7 +520,7 @@ ...@@ -520,7 +520,7 @@
} }
element.appendChild(frag); // Now, append all elements at once element.appendChild(frag); // Now, append all elements at once
frag = tmp = null; frag = tmp = null;
} };
utils.isPersistableModel = function (model) { utils.isPersistableModel = function (model) {
return model.collection && model.collection.browserStorage; return model.collection && model.collection.browserStorage;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment