From 62cb65a94fe4ada5864271b69c1da01926966241 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Sun, 5 Nov 2017 17:24:05 +0100 Subject: [PATCH 1/2] Update the pluggable.js 1.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 012836fea..3828ea646 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "moment": "~2.18.1", "npm": "^4.1.1", "otr": "0.2.16", - "pluggable.js": "https://github.com/jcbrand/pluggable.js.git#4677f759c270edda4ce987a8565b817a1d15973b", + "pluggable.js": "1.0.1", "po2json": "^0.4.4", "requirejs": "2.3.3", "run-headless-chromium": "^0.1.1", From 8a4aa4efddca360efbe2f78e0e48b723a8ee3ef7 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Sun, 5 Nov 2017 18:47:30 +0100 Subject: [PATCH 2/2] Use a named variable for _.template This removes the need for `switch (obj)` in the template which is not allowed in strict mode. Additionally using a named variable speeds up rendering. --- spec/chatroom.js | 2 +- src/config.js | 8 ++- src/converse-muc.js | 13 ++--- src/templates/action.html | 4 +- src/templates/add_contact_dropdown.html | 2 +- src/templates/add_contact_form.html | 12 ++--- src/templates/avatar.html | 2 +- src/templates/bookmark.html | 14 +++--- src/templates/bookmarks_list.html | 2 +- src/templates/change_status_message.html | 4 +- src/templates/chat_status.html | 6 +-- src/templates/chatarea.html | 14 +++--- src/templates/chatbox.html | 26 +++++----- src/templates/chatbox_minimize.html | 2 +- src/templates/chatroom_bookmark_form.html | 14 +++--- src/templates/chatroom_bookmark_toggle.html | 4 +- src/templates/chatroom_disconnect.html | 2 +- src/templates/chatroom_features.html | 56 ++++++++++----------- src/templates/chatroom_head.html | 16 +++--- src/templates/chatroom_invite.html | 6 +-- src/templates/chatroom_nickname_form.html | 8 +-- src/templates/chatroom_password_form.html | 6 +-- src/templates/chatroom_sidebar.html | 2 +- src/templates/chatroom_toolbar.html | 16 +++--- src/templates/chatrooms_tab.html | 10 ++-- src/templates/contacts_panel.html | 14 +++--- src/templates/contacts_tab.html | 10 ++-- src/templates/controlbox.html | 2 +- src/templates/controlbox_toggle.html | 2 +- src/templates/emojis.html | 22 ++++---- src/templates/field.html | 8 +-- src/templates/form_captcha.html | 8 +-- src/templates/form_checkbox.html | 2 +- src/templates/form_input.html | 10 ++-- src/templates/form_select.html | 4 +- src/templates/form_textarea.html | 4 +- src/templates/form_url.html | 4 +- src/templates/form_username.html | 12 ++--- src/templates/group_header.html | 2 +- src/templates/help_message.html | 2 +- src/templates/info.html | 2 +- src/templates/login_panel.html | 30 +++++------ src/templates/message.html | 4 +- src/templates/new_day.html | 2 +- src/templates/occupant.html | 20 ++++---- src/templates/pending_contact.html | 10 ++-- src/templates/register_link.html | 4 +- src/templates/register_panel.html | 20 ++++---- src/templates/registration_form.html | 12 ++--- src/templates/registration_request.html | 6 +-- src/templates/requesting_contact.html | 12 ++--- src/templates/room_description.html | 52 +++++++++---------- src/templates/room_item.html | 10 ++-- src/templates/room_panel.html | 14 +++--- src/templates/rooms_list.html | 2 +- src/templates/rooms_list_item.html | 28 +++++------ src/templates/roster_filter.html | 49 +++++++++--------- src/templates/roster_item.html | 18 +++---- src/templates/search_contact.html | 4 +- src/templates/select_option.html | 2 +- src/templates/status_option.html | 6 +-- src/templates/toggle_chats.html | 6 +-- src/templates/toolbar.html | 12 ++--- src/templates/toolbar_otr.html | 33 ++++++------ src/templates/trimmed_chat.html | 8 +-- 65 files changed, 365 insertions(+), 358 deletions(-) diff --git a/spec/chatroom.js b/spec/chatroom.js index 39e365dd2..1e9b7833d 100644 --- a/spec/chatroom.js +++ b/spec/chatroom.js @@ -808,7 +808,7 @@ expect($sent_stanza.find('field[var="muc#roomconfig_allowpm"] value').text()).toBe('moderators'); expect($sent_stanza.find('field[var="muc#roomconfig_presencebroadcast"] value').text()).toBe('moderator'); done(); - }); + }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)); })); it("shows users currently present in the room", diff --git a/src/config.js b/src/config.js index 249ae747a..d92c0f913 100644 --- a/src/config.js +++ b/src/config.js @@ -114,7 +114,13 @@ require.config({ templateSettings: { "escape": /\{\{\{([\s\S]+?)\}\}\}/g, "evaluate": /\{\[([\s\S]+?)\]\}/g, - "interpolate": /\{\{([\s\S]+?)\}\}/g + "interpolate": /\{\{([\s\S]+?)\}\}/g, + // By default, template places the values from your data in the + // local scope via the with statement. However, you can specify + // a single variable name with the variable setting. This can + // significantly improve the speed at which a template is able + // to render. + "variable": 'o' } }, diff --git a/src/converse-muc.js b/src/converse-muc.js index 0f1962e2d..594a5762f 100755 --- a/src/converse-muc.js +++ b/src/converse-muc.js @@ -78,15 +78,15 @@ const ROOM_FEATURES = [ 'passwordprotected', 'unsecured', 'hidden', - 'public', 'membersonly', 'open', 'persistent', + 'publicroom', 'membersonly', 'open', 'persistent', 'temporary', 'nonanonymous', 'semianonymous', 'moderated', 'unmoderated', 'mam_enabled' ]; const ROOM_FEATURES_MAP = { 'passwordprotected': 'unsecured', 'unsecured': 'passwordprotected', - 'hidden': 'public', - 'public': 'hidden', + 'hidden': 'publicroom', + 'publicroom': 'hidden', 'membersonly': 'open', 'open': 'membersonly', 'persistent': 'temporary', @@ -1526,8 +1526,9 @@ * the settings. */ this.showSpinner(); - this.fetchRoomConfiguration().then( - this.renderConfigurationForm.bind(this)); + this.fetchRoomConfiguration() + .then(this.renderConfigurationForm.bind(this)) + .catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR)); }, submitNickname (ev) { @@ -2147,7 +2148,7 @@ this.chatroomview.model.on('change:open', this.onFeatureChanged, this); this.chatroomview.model.on('change:passwordprotected', this.onFeatureChanged, this); this.chatroomview.model.on('change:persistent', this.onFeatureChanged, this); - this.chatroomview.model.on('change:public', this.onFeatureChanged, this); + this.chatroomview.model.on('change:publicroom', this.onFeatureChanged, this); this.chatroomview.model.on('change:semianonymous', this.onFeatureChanged, this); this.chatroomview.model.on('change:temporary', this.onFeatureChanged, this); this.chatroomview.model.on('change:unmoderated', this.onFeatureChanged, this); diff --git a/src/templates/action.html b/src/templates/action.html index fb077a302..c95432af8 100644 --- a/src/templates/action.html +++ b/src/templates/action.html @@ -1,4 +1,4 @@ -
- {{{time}}} **{{{username}}}  +
+ {{{o.time}}} **{{{o.username}}} 
diff --git a/src/templates/add_contact_dropdown.html b/src/templates/add_contact_dropdown.html index 90e545429..c8ff1766d 100644 --- a/src/templates/add_contact_dropdown.html +++ b/src/templates/add_contact_dropdown.html @@ -1,6 +1,6 @@