From cc03f9fb8ffbf9297a5612e45bd8721f1021a781 Mon Sep 17 00:00:00 2001 From: Shubham Dhama Date: Tue, 5 Jun 2018 00:43:07 +0530 Subject: [PATCH] eslint: Enable space-infix-ops rule. More about rule at https://eslint.org/docs/rules/space-infix-ops --- .eslintrc.json | 2 +- frontend_tests/casper_lib/common.js | 6 ++--- frontend_tests/casper_tests/03-narrow.js | 4 +-- frontend_tests/casper_tests/10-admin.js | 16 ++++++------ frontend_tests/node_tests/activity.js | 4 +-- frontend_tests/node_tests/compose.js | 6 ++--- frontend_tests/node_tests/compose_pm_pill.js | 2 +- .../node_tests/composebox_typeahead.js | 4 +-- frontend_tests/node_tests/message_edit.js | 2 +- frontend_tests/node_tests/message_list.js | 6 ++--- .../node_tests/settings_user_groups.js | 2 +- frontend_tests/node_tests/templates.js | 2 +- frontend_tests/node_tests/typeahead_helper.js | 2 +- frontend_tests/node_tests/unread.js | 2 +- frontend_tests/node_tests/upload.js | 2 +- frontend_tests/node_tests/util.js | 12 ++++----- frontend_tests/zjsunit/index.js | 2 +- frontend_tests/zjsunit/mdiff.js | 2 +- static/js/colorspace.js | 8 +++--- static/js/compose_actions.js | 6 ++--- static/js/compose_state.js | 2 +- static/js/composebox_typeahead.js | 8 +++--- static/js/drafts.js | 8 +++--- static/js/emoji_picker.js | 4 +-- static/js/filter.js | 4 +-- static/js/hashchange.js | 4 +-- static/js/integration_bot_widget.js | 2 +- static/js/message_events.js | 2 +- static/js/message_fetch.js | 4 +-- static/js/message_list_data.js | 2 +- static/js/message_viewport.js | 8 +++--- static/js/notifications.js | 2 +- static/js/popovers.js | 2 +- static/js/portico/help.js | 4 +-- static/js/reload.js | 8 +++--- static/js/server_events.js | 4 +-- static/js/settings_account.js | 2 +- static/js/settings_bots.js | 14 +++++----- static/js/settings_invites.js | 2 +- static/js/settings_org.js | 22 ++++++++-------- static/js/settings_users.js | 2 +- static/js/socket.js | 2 +- static/js/stats/stats.js | 26 +++++++++---------- static/js/stream_color.js | 4 +-- static/js/stream_edit.js | 2 +- static/js/topic_generator.js | 4 +-- 46 files changed, 120 insertions(+), 120 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 79e21a8b26..1adc90698f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -361,7 +361,7 @@ } ], "space-in-parens": 2, - "space-infix-ops": 0, + "space-infix-ops": 2, "spaced-comment": 0, "strict": 0, "template-curly-spacing": "error", diff --git a/frontend_tests/casper_lib/common.js b/frontend_tests/casper_lib/common.js index f95e837a9f..70d14b31b2 100644 --- a/frontend_tests/casper_lib/common.js +++ b/frontend_tests/casper_lib/common.js @@ -166,7 +166,7 @@ exports.select_item_via_typeahead = function (field_selector, str, item) { var tah = $(field_selector).data().typeahead; tah.mouseenter({ - currentTarget: $('.typeahead:visible li:contains("'+item+'")')[0], + currentTarget: $('.typeahead:visible li:contains("' + item + '")')[0], }); tah.select(); }, {field_selector:field_selector, str: str, item: item}); @@ -271,7 +271,7 @@ exports.then_send_message = function (type, params) { // 'table' here). exports.get_rendered_messages = function (table) { return casper.evaluate(function (table) { - var tbl = $('#'+table); + var tbl = $('#' + table); return { headings: $.map(tbl.find('.recipient_row .message-header-contents'), function (elem) { var $clone = $(elem).clone(true); @@ -349,7 +349,7 @@ exports.trim = function (str) { // Call get_rendered_messages and then check that the last few headings and // bodies match the specified arrays. exports.expected_messages = function (table, headings, bodies) { - casper.test.assertVisible('#'+table, table + ' is visible'); + casper.test.assertVisible('#' + table, table + ' is visible'); var msg = exports.get_rendered_messages(table); diff --git a/frontend_tests/casper_tests/03-narrow.js b/frontend_tests/casper_tests/03-narrow.js index 465f0bf1fb..224d6da305 100644 --- a/frontend_tests/casper_tests/03-narrow.js +++ b/frontend_tests/casper_tests/03-narrow.js @@ -179,7 +179,7 @@ function search_silent_user(str, item) { casper.then(function () { casper.waitUntilVisible('#silent_user', function () { casper.test.info("Empty feed for silent user visible."); - var expected_message = "\n You haven't received any messages sent by this user yet!"+ + var expected_message = "\n You haven't received any messages sent by this user yet!" + "\n "; this.test.assertEquals(casper.fetchText('#silent_user'), expected_message); }); @@ -192,7 +192,7 @@ function search_non_existing_user(str, item) { casper.then(function () { casper.waitUntilVisible('#non_existing_user', function () { casper.test.info("Empty feed for non existing user visible."); - var expected_message = "\n This user does not exist!"+ + var expected_message = "\n This user does not exist!" + "\n "; this.test.assertEquals(casper.fetchText('#non_existing_user'), expected_message); }); diff --git a/frontend_tests/casper_tests/10-admin.js b/frontend_tests/casper_tests/10-admin.js index 386338ee96..dd8b203d3f 100644 --- a/frontend_tests/casper_tests/10-admin.js +++ b/frontend_tests/casper_tests/10-admin.js @@ -299,7 +299,7 @@ function select_from_suggestions(item) { casper.evaluate(function (item) { var tah = $('.create_default_stream').data().typeahead; tah.mouseenter({ - currentTarget: $('.typeahead:visible li:contains("'+item+'")')[0], + currentTarget: $('.typeahead:visible li:contains("' + item + '")')[0], }); tah.select(); }, {item: item}); @@ -320,21 +320,21 @@ casper.then(function () { }); casper.then(function () { - casper.waitUntilVisible('.default_stream_row[id='+stream_name+']', function () { - casper.test.assertSelectorHasText('.default_stream_row[id='+stream_name+'] .default_stream_name', stream_name); + casper.waitUntilVisible('.default_stream_row[id=' + stream_name + ']', function () { + casper.test.assertSelectorHasText('.default_stream_row[id=' + stream_name + '] .default_stream_name', stream_name); }); }); casper.then(function () { - casper.waitUntilVisible('.default_stream_row[id='+stream_name+']', function () { - casper.test.assertSelectorHasText('.default_stream_row[id='+stream_name+'] .default_stream_name', stream_name); - casper.click('.default_stream_row[id='+stream_name+'] button.remove-default-stream'); + casper.waitUntilVisible('.default_stream_row[id=' + stream_name + ']', function () { + casper.test.assertSelectorHasText('.default_stream_row[id=' + stream_name + '] .default_stream_name', stream_name); + casper.click('.default_stream_row[id=' + stream_name + '] button.remove-default-stream'); }); }); casper.then(function () { - casper.waitWhileVisible('.default_stream_row[id='+stream_name+']', function () { - casper.test.assertDoesntExist('.default_stream_row[id='+stream_name+']'); + casper.waitWhileVisible('.default_stream_row[id=' + stream_name + ']', function () { + casper.test.assertDoesntExist('.default_stream_row[id=' + stream_name + ']'); }); }); diff --git a/frontend_tests/node_tests/activity.js b/frontend_tests/node_tests/activity.js index d968fec2e9..0793cc6021 100644 --- a/frontend_tests/node_tests/activity.js +++ b/frontend_tests/node_tests/activity.js @@ -387,8 +387,8 @@ function simulate_list_items(items) { $('#user_presences').set_find_results('li.user_sidebar_entry', list); _.each(items, (item, i) => { - item.next = () => items[i+1] || {length: 0}; - item.prev = () => items[i-1] || {length: 0}; + item.next = () => items[i + 1] || {length: 0}; + item.prev = () => items[i - 1] || {length: 0}; }); } diff --git a/frontend_tests/node_tests/compose.js b/frontend_tests/node_tests/compose.js index ff6c5c35c8..895d2c5762 100644 --- a/frontend_tests/node_tests/compose.js +++ b/frontend_tests/node_tests/compose.js @@ -349,8 +349,8 @@ run_test('markdown_shortcuts', () => { global.document.execCommand = function (cmd, bool, markdown) { var compose_textarea = $("#compose-textarea"); var value = compose_textarea.val(); - $("#compose-textarea").val(value.substring(0, compose_textarea.range().start)+ - markdown+value.substring(compose_textarea.range().end, value.length)); + $("#compose-textarea").val(value.substring(0, compose_textarea.range().start) + + markdown + value.substring(compose_textarea.range().end, value.length)); }; $("#compose-textarea").range = function () { @@ -359,7 +359,7 @@ run_test('markdown_shortcuts', () => { end: range_start + range_length, length: range_length, range: noop, - text: $("#compose-textarea").val().substring(range_start, range_length+range_start), + text: $("#compose-textarea").val().substring(range_start, range_length + range_start), }; }; $('#compose-textarea').caret = noop; diff --git a/frontend_tests/node_tests/compose_pm_pill.js b/frontend_tests/node_tests/compose_pm_pill.js index 47f6b97cb7..4a8d08ffc1 100644 --- a/frontend_tests/node_tests/compose_pm_pill.js +++ b/frontend_tests/node_tests/compose_pm_pill.js @@ -58,7 +58,7 @@ run_test('pills', () => { pills = { pill: {}, }; - all_pills= {}; + all_pills = {}; }; var appendValue_called; diff --git a/frontend_tests/node_tests/composebox_typeahead.js b/frontend_tests/node_tests/composebox_typeahead.js index 864acfea6e..4b9576ab8b 100644 --- a/frontend_tests/node_tests/composebox_typeahead.js +++ b/frontend_tests/node_tests/composebox_typeahead.js @@ -936,7 +936,7 @@ run_test('begins_typeahead', () => { var all_items = _.map(['all', 'everyone', 'stream'], function (mention) { return { - special_item_text: 'translated: ' + mention +" (Notify stream)", + special_item_text: 'translated: ' + mention + " (Notify stream)", email: mention, pm_recipient_count: Infinity, full_name: mention, @@ -1130,7 +1130,7 @@ run_test('content_highlighter', () => { run_test('typeahead_results', () => { var all_items = _.map(['all', 'everyone', 'stream'], function (mention) { return { - special_item_text: 'translated: ' + mention +" (Notify stream)", + special_item_text: 'translated: ' + mention + " (Notify stream)", email: mention, pm_recipient_count: Infinity, full_name: mention, diff --git a/frontend_tests/node_tests/message_edit.js b/frontend_tests/node_tests/message_edit.js index 9d28f8661f..bac8e18a34 100644 --- a/frontend_tests/node_tests/message_edit.js +++ b/frontend_tests/node_tests/message_edit.js @@ -54,7 +54,7 @@ run_test('get_editability', () => { realm_message_content_edit_limit_seconds: 10, }; var now = new Date(); - var current_timestamp = now/1000; + var current_timestamp = now / 1000; message.timestamp = current_timestamp - 60; // Have 55+10 > 60 seconds from message.timestamp to edit the message; we're good! assert.equal(get_editability(message, 55), editability_types.FULL); diff --git a/frontend_tests/node_tests/message_list.js b/frontend_tests/node_tests/message_list.js index d1e871a254..a8cb803d34 100644 --- a/frontend_tests/node_tests/message_list.js +++ b/frontend_tests/node_tests/message_list.js @@ -270,7 +270,7 @@ run_test('last_sent_by_me', () => { run_test('local_echo', () => { var list = new MessageList({}); list.append([{id:10}, {id:20}, {id:30}, {id:20.02}, {id:20.03}, {id:40}, {id:50}, {id:60}]); - list._local_only= {20.02: {id:20.02}, 20.03: {id:20.03}}; + list._local_only = {20.02: {id:20.02}, 20.03: {id:20.03}}; assert.equal(list.closest_id(10), 10); assert.equal(list.closest_id(20), 20); @@ -294,8 +294,8 @@ run_test('local_echo', () => { list.append([ {id:10}, {id:20}, {id:30}, {id:20.02}, {id:20.03}, {id:40}, {id:50}, {id: 50.01}, {id: 50.02}, {id:60}]); - list._local_only= {20.02: {id:20.02}, 20.03: {id:20.03}, - 50.01: {id: 50.01}, 50.02: {id: 50.02}}; + list._local_only = {20.02: {id:20.02}, 20.03: {id:20.03}, + 50.01: {id: 50.01}, 50.02: {id: 50.02}}; assert.equal(list.closest_id(10), 10); assert.equal(list.closest_id(20), 20); diff --git a/frontend_tests/node_tests/settings_user_groups.js b/frontend_tests/node_tests/settings_user_groups.js index f1f4eb82d5..ba6c5eeefc 100644 --- a/frontend_tests/node_tests/settings_user_groups.js +++ b/frontend_tests/node_tests/settings_user_groups.js @@ -398,7 +398,7 @@ run_test('with_external_user', () => { var exit_button = $.create('fake-pill-exit'); pill_stub.set_find_results('.exit', exit_button); - var exit_button_called=false; + var exit_button_called = false; exit_button.css = function (property, value) { exit_button_called = true; assert.equal(property, 'opacity'); diff --git a/frontend_tests/node_tests/templates.js b/frontend_tests/node_tests/templates.js index e95e05c2b0..68e2cd8d2a 100644 --- a/frontend_tests/node_tests/templates.js +++ b/frontend_tests/node_tests/templates.js @@ -1564,7 +1564,7 @@ run_test('embedded_bot_config_item', () => { }; var html = render('embedded_bot_config_item', args); assert.equal($(html).attr('name'), args.botname); - assert.equal($(html).attr('id'), args.botname+'_'+args.key); + assert.equal($(html).attr('id'), args.botname + '_' + args.key); assert.equal($(html).find('label').text(), args.key); assert.equal($(html).find('input').attr('placeholder'), args.value); }); diff --git a/frontend_tests/node_tests/typeahead_helper.js b/frontend_tests/node_tests/typeahead_helper.js index d77acd58f7..d1dbcccf2b 100644 --- a/frontend_tests/node_tests/typeahead_helper.js +++ b/frontend_tests/node_tests/typeahead_helper.js @@ -324,7 +324,7 @@ run_test('sort_recipients', () => { assert.deepEqual(recipients_email, expected); // Reset matches - matches.splice(matches.length-1, 1); + matches.splice(matches.length - 1, 1); // full_name starts with same character but emails are 'all' var small_matches = [ diff --git a/frontend_tests/node_tests/unread.js b/frontend_tests/node_tests/unread.js index b2f90b4ca1..8cbf8b08f7 100644 --- a/frontend_tests/node_tests/unread.js +++ b/frontend_tests/node_tests/unread.js @@ -286,7 +286,7 @@ run_test('num_unread_for_topic', () => { assert.deepEqual(missing_topics, []); for (i = 0; i < num_msgs; i += 1) { - message.id = i+1; + message.id = i + 1; unread.mark_as_read(message.id); } diff --git a/frontend_tests/node_tests/upload.js b/frontend_tests/node_tests/upload.js index 62da4b7940..1f7f4f8341 100644 --- a/frontend_tests/node_tests/upload.js +++ b/frontend_tests/node_tests/upload.js @@ -77,7 +77,7 @@ run_test('upload_error', () => { assert.equal($("#compose-error-msg").text(), msg); } - function test(err, msg, server_response=null, file={}) { + function test(err, msg, server_response = null, file = {}) { setup_test(); file.lastModified = 1549958107000; upload_opts.error(err, server_response, file); diff --git a/frontend_tests/node_tests/util.js b/frontend_tests/node_tests/util.js index 7ca03807ad..abc118de47 100644 --- a/frontend_tests/node_tests/util.js +++ b/frontend_tests/node_tests/util.js @@ -200,27 +200,27 @@ run_test('all_and_everyone_mentions_regexp', () => { ]; var i; - for (i=0; i 0) { - message_viewport.user_initiated_animate_scroll(cover+5); + message_viewport.user_initiated_animate_scroll(cover + 5); } }; @@ -391,9 +391,9 @@ exports.quote_and_reply = function (opts) { idempotent: true, success: function (data) { if (textarea.val() === "") { - textarea.val("```quote\n" + data.raw_content +"\n```\n"); + textarea.val("```quote\n" + data.raw_content + "\n```\n"); } else { - textarea.val(textarea.val() + "\n```quote\n" + data.raw_content +"\n```\n"); + textarea.val(textarea.val() + "\n```quote\n" + data.raw_content + "\n```\n"); } $("#compose-textarea").trigger("autosize.resize"); }, diff --git a/static/js/compose_state.js b/static/js/compose_state.js index 7db2c4fbc6..b44e234915 100644 --- a/static/js/compose_state.js +++ b/static/js/compose_state.js @@ -30,7 +30,7 @@ function get_or_set(fieldname, keep_leading_whitespace) { // because the DOM element might not exist yet when get_or_set // is called. return function (newval) { - var elem = $('#'+fieldname); + var elem = $('#' + fieldname); var oldval = elem.val(); if (newval !== undefined) { elem.val(newval); diff --git a/static/js/composebox_typeahead.js b/static/js/composebox_typeahead.js index f7cc32ff29..76482c7a30 100644 --- a/static/js/composebox_typeahead.js +++ b/static/js/composebox_typeahead.js @@ -281,8 +281,8 @@ exports.tokenize_compose_str = function (s) { // Code block must start on a new line if (i === 2) { return s.slice(0); - } else if (i > 2 && s[i-3] === "\n") { - return s.slice(i-2); + } else if (i > 2 && s[i - 3] === "\n") { + return s.slice(i - 2); } break; case '#': @@ -290,7 +290,7 @@ exports.tokenize_compose_str = function (s) { case ':': if (i === 0) { return s.slice(i); - } else if (/[\s(){}\[\]]/.test(s[i-1])) { + } else if (/[\s(){}\[\]]/.test(s[i - 1])) { return s.slice(i); } } @@ -446,7 +446,7 @@ exports.content_typeahead_selected = function (item) { if (beginning.lastIndexOf(":") === 0 || beginning.charAt(beginning.lastIndexOf(":") - 1) === " " || beginning.charAt(beginning.lastIndexOf(":") - 1) === "\n") { - beginning = (beginning.substring(0, beginning.length - this.token.length - 1)+ ":" + item.emoji_name + ": "); + beginning = (beginning.substring(0, beginning.length - this.token.length - 1) + ":" + item.emoji_name + ": "); } else { beginning = (beginning.substring(0, beginning.length - this.token.length - 1) + " :" + item.emoji_name + ": "); } diff --git a/static/js/drafts.js b/static/js/drafts.js index 6bf1335730..5b45ab13dd 100644 --- a/static/js/drafts.js +++ b/static/js/drafts.js @@ -207,7 +207,7 @@ exports.setup_page = function (callback) { data_array.push([id, data[id]]); }); var data_sorted = data_array.sort(function (draft_a,draft_b) { - return draft_a[1].updatedAt-draft_b[1].updatedAt; + return draft_a[1].updatedAt - draft_b[1].updatedAt; }); _.each(data_sorted, function (data_element) { var draft = data_element[1]; @@ -314,7 +314,7 @@ function drafts_initialize_focus(event_name) { var draft_element; if (event_name === "up_arrow") { - draft_element = document.querySelectorAll('[data-draft-id="' + draft_id_arrow[draft_id_arrow.length-1] + '"]'); + draft_element = document.querySelectorAll('[data-draft-id="' + draft_id_arrow[draft_id_arrow.length - 1] + '"]'); } else if (event_name === "down_arrow") { draft_element = document.querySelectorAll('[data-draft-id="' + draft_id_arrow[0] + '"]'); } @@ -410,7 +410,7 @@ exports.drafts_handle_events = function (e, event_key) { if (document.activeElement.parentElement.hasAttribute("data-draft-id")) { exports.restore_draft(focused_draft); } else { - var first_draft = draft_id_arrow[draft_id_arrow.length-1]; + var first_draft = draft_id_arrow[draft_id_arrow.length - 1]; exports.restore_draft(first_draft); } } @@ -429,7 +429,7 @@ exports.launch = function () { var draft_list = drafts.draft_model.get(); var draft_id_list = Object.getOwnPropertyNames(draft_list); if (draft_id_list.length > 0) { - var last_draft = draft_id_list[draft_id_list.length-1]; + var last_draft = draft_id_list[draft_id_list.length - 1]; var last_draft_element = document.querySelectorAll('[data-draft-id="' + last_draft + '"]'); var focus_element = last_draft_element[0].children[0]; focus_element.focus(); diff --git a/static/js/emoji_picker.js b/static/js/emoji_picker.js index a530e0a9ee..e1e28720ab 100644 --- a/static/js/emoji_picker.js +++ b/static/js/emoji_picker.js @@ -548,7 +548,7 @@ exports.emoji_select_tab = function (elt) { var elt_height = elt.height(); var currently_selected = ""; section_head_offsets.forEach(function (o) { - if (scrolltop + elt_height/2 >= o.position_y) { + if (scrolltop + elt_height / 2 >= o.position_y) { currently_selected = o.section; } }); @@ -563,7 +563,7 @@ exports.emoji_select_tab = function (elt) { } if (currently_selected) { $('.emoji-popover-tab-item.active').removeClass('active'); - $('.emoji-popover-tab-item[data-tab-name="'+currently_selected+'"]').addClass('active'); + $('.emoji-popover-tab-item[data-tab-name="' + currently_selected + '"]').addClass('active'); } }; diff --git a/static/js/filter.js b/static/js/filter.js index d5d614c8e3..7558552427 100644 --- a/static/js/filter.js +++ b/static/js/filter.js @@ -621,10 +621,10 @@ function describe_unescaped(operators) { var more_parts = _.map(operators, function (elem) { var operand = elem.operand; var canonicalized_operator = Filter.canonicalize_operator(elem.operator); - if (canonicalized_operator ==='is') { + if (canonicalized_operator === 'is') { return describe_is_operator(elem); } - if (canonicalized_operator ==='has') { + if (canonicalized_operator === 'has') { // search_suggestion.get_suggestions takes care that this message will // only be shown if the `has` operator is not at the last. var valid_has_operands = ['image', 'images', 'link', 'links', 'attachment', 'attachments']; diff --git a/static/js/hashchange.js b/static/js/hashchange.js index 9b1d3649c2..548b99a141 100644 --- a/static/js/hashchange.js +++ b/static/js/hashchange.js @@ -72,7 +72,7 @@ exports.save_narrow = function (operators) { exports.parse_narrow = function (hash) { var i; var operators = []; - for (i=1; i=0; i -= 1) { + for (i = messages.length - 1; i >= 0; i -= 1) { var id = messages[i].id; if (id <= selected_id) { break; diff --git a/static/js/message_fetch.js b/static/js/message_fetch.js index df02fe9a23..5e11b8db69 100644 --- a/static/js/message_fetch.js +++ b/static/js/message_fetch.js @@ -3,7 +3,7 @@ var message_fetch = (function () { var exports = {}; var consts = { - backfill_idle_time: 10*1000, + backfill_idle_time: 10 * 1000, error_retry_time: 5000, backfill_batch_size: 1000, narrow_before: 50, @@ -315,7 +315,7 @@ exports.initialize = function () { // If we fall through here, we need to keep fetching more data, and // we'll call back to the function we're in. var messages = data.messages; - var latest_id = messages[messages.length-1].id; + var latest_id = messages[messages.length - 1].id; exports.load_messages({ anchor: latest_id.toFixed(), diff --git a/static/js/message_list_data.js b/static/js/message_list_data.js index f8703e9c1b..e37f7676b0 100644 --- a/static/js/message_list_data.js +++ b/static/js/message_list_data.js @@ -89,7 +89,7 @@ MessageListData.prototype = { return false; } - var last_msg = this._items[n-1]; + var last_msg = this._items[n - 1]; return (last_msg.id === this._selected_id); }, diff --git a/static/js/message_viewport.js b/static/js/message_viewport.js index d14f4124da..993e75d647 100644 --- a/static/js/message_viewport.js +++ b/static/js/message_viewport.js @@ -312,9 +312,9 @@ exports.recenter_view = function (message, opts) { } if (is_above || opts.force_center) { - exports.set_message_position(message_top, message_height, viewport_info, 1/2); + exports.set_message_position(message_top, message_height, viewport_info, 1 / 2); } else if (is_below) { - exports.set_message_position(message_top, message_height, viewport_info, 1/7); + exports.set_message_position(message_top, message_height, viewport_info, 1 / 7); } }; @@ -334,8 +334,8 @@ exports.keep_pointer_in_view = function () { } var info = message_viewport.message_viewport_info(); - var top_threshold = info.visible_top + (1/10 * info.visible_height); - var bottom_threshold = info.visible_top + (9/10 * info.visible_height); + var top_threshold = info.visible_top + (1 / 10 * info.visible_height); + var bottom_threshold = info.visible_top + (9 / 10 * info.visible_height); function message_is_far_enough_down() { if (message_viewport.at_top()) { diff --git a/static/js/notifications.js b/static/js/notifications.js index 1249414e5b..42547e3475 100644 --- a/static/js/notifications.js +++ b/static/js/notifications.js @@ -144,7 +144,7 @@ exports.redraw_title = function () { n = 'infinite'; } - current_favicon = previous_favicon = '/static/images/favicon/favicon-'+n+'.png'; + current_favicon = previous_favicon = '/static/images/favicon/favicon-' + n + '.png'; } else { current_favicon = previous_favicon = '/static/favicon.ico?v=2'; } diff --git a/static/js/popovers.js b/static/js/popovers.js index fe561400ea..ac62c35938 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -373,7 +373,7 @@ exports.render_actions_remind_popover = function (element, id) { trigger: "manual", }); elt.popover("show"); - current_flatpickr_instance = $('.remind.custom[data-message-id="'+message.id+'"]').flatpickr({ + current_flatpickr_instance = $('.remind.custom[data-message-id="' + message.id + '"]').flatpickr({ enableTime: true, clickOpens: false, defaultDate: moment().format(), diff --git a/static/js/portico/help.js b/static/js/portico/help.js index f2c0e064b0..b88810784b 100644 --- a/static/js/portico/help.js +++ b/static/js/portico/help.js @@ -9,10 +9,10 @@ function registerCodeSection($codeSection) { const language = this.dataset.language; $li.removeClass("active"); - $li.filter("[data-language="+language+"]").addClass("active"); + $li.filter("[data-language=" + language + "]").addClass("active"); $blocks.removeClass("active"); - $blocks.filter("[data-language="+language+"]").addClass("active"); + $blocks.filter("[data-language=" + language + "]").addClass("active"); }); $li.eq(0).click(); diff --git a/static/js/reload.js b/static/js/reload.js index dcb41d316c..b13ec1f39f 100644 --- a/static/js/reload.js +++ b/static/js/reload.js @@ -95,7 +95,7 @@ function preserve_state(send_after_reload, save_pointer, save_narrow, save_compo // // TODO: Remove the now-unnecessary URL-encoding logic above and // just pass the actual data structures through local storage. - var token = util.random_int(0, 1024*1024*1024*1024); + var token = util.random_int(0, 1024 * 1024 * 1024 * 1024); ls.set("reload:" + token, url); window.location.replace("#reload:" + token); @@ -262,9 +262,9 @@ exports.initiate = function (options) { // while composing. If they finish or cancel the compose, wait // until they're idle again var idle_control; - var unconditional_timeout = 1000*60*30 + util.random_int(0, 1000*60*5); - var composing_timeout = 1000*60*5 + util.random_int(0, 1000*60); - var home_timeout = 1000*60 + util.random_int(0, 1000*60); + var unconditional_timeout = 1000 * 60 * 30 + util.random_int(0, 1000 * 60 * 5); + var composing_timeout = 1000 * 60 * 5 + util.random_int(0, 1000 * 60); + var home_timeout = 1000 * 60 + util.random_int(0, 1000 * 60); var compose_done_handler; var compose_started_handler; diff --git a/static/js/server_events.js b/static/js/server_events.js index faf43a4703..e7feb4cbf9 100644 --- a/static/js/server_events.js +++ b/static/js/server_events.js @@ -216,8 +216,8 @@ function get_events(options) { undefined, ex.stack); } - var retry_sec = Math.min(90, Math.exp(get_events_failures/2)); - get_events_timeout = setTimeout(get_events, retry_sec*1000); + var retry_sec = Math.min(90, Math.exp(get_events_failures / 2)); + get_events_timeout = setTimeout(get_events, retry_sec * 1000); }, }); } diff --git a/static/js/settings_account.js b/static/js/settings_account.js index bc2e7bf5be..5c5410b693 100644 --- a/static/js/settings_account.js +++ b/static/js/settings_account.js @@ -418,7 +418,7 @@ exports.set_up = function () { form_data.append('csrfmiddlewaretoken', csrf_token); jQuery.each(file_input[0].files, function (i, file) { - form_data.append('file-'+i, file); + form_data.append('file-' + i, file); }); $("#user-avatar-source").hide(); diff --git a/static/js/settings_bots.js b/static/js/settings_bots.js index 9d55c4d454..5b70fff273 100644 --- a/static/js/settings_bots.js +++ b/static/js/settings_bots.js @@ -184,7 +184,7 @@ exports.set_up = function () { var selected_embedded_bot = 'converter'; $('#select_service_name').val(selected_embedded_bot); // TODO: Use 'select a bot'. $('#config_inputbox').children().hide(); - $("[name*='"+selected_embedded_bot+"']").show(); + $("[name*='" + selected_embedded_bot + "']").show(); $('#download_botserverrc').click(function () { var OUTGOING_WEBHOOK_BOT_TYPE_INT = 3; @@ -243,13 +243,13 @@ exports.set_up = function () { } else if (bot_type === EMBEDDED_BOT_TYPE) { formData.append('service_name', service_name); var config_data = {}; - $("#config_inputbox [name*='"+service_name+"'] input").each(function () { + $("#config_inputbox [name*='" + service_name + "'] input").each(function () { config_data[$(this).attr('name')] = $(this).val(); }); formData.append('config_data', JSON.stringify(config_data)); } jQuery.each($('#bot_avatar_file_input')[0].files, function (i, file) { - formData.append('file-'+i, file); + formData.append('file-' + i, file); }); loading.make_indicator(spinner, {text: i18n.t('Creating bot')}); channel.post({ @@ -265,7 +265,7 @@ exports.set_up = function () { $('#create_payload_url').val(''); $('#payload_url_inputbox').hide(); $('#config_inputbox').hide(); - $("[name*='"+service_name+"'] input").each(function () { + $("[name*='" + service_name + "'] input").each(function () { $(this).val(''); }); $('#create_bot_type').val(GENERIC_BOT_TYPE); @@ -311,7 +311,7 @@ exports.set_up = function () { $("#select_service_name").on("change", function () { $('#config_inputbox').children().hide(); var selected_bot = $('#select_service_name :selected').val(); - $("[name*='"+selected_bot+"']").show(); + $("[name*='" + selected_bot + "']").show(); }); $("#active_bots_list").on("click", "button.delete_bot", function (e) { @@ -421,7 +421,7 @@ exports.set_up = function () { formData.append('config_data', JSON.stringify(config_data)); } jQuery.each(file_input[0].files, function (i, file) { - formData.append('file-'+i, file); + formData.append('file-' + i, file); }); loading.make_indicator(spinner, {text: 'Editing bot'}); edit_button.hide(); @@ -442,7 +442,7 @@ exports.set_up = function () { // when the user had a previous uploaded avatar. Only the content // changes, so we version it to get an uncached copy. image_version += 1; - image.find('img').attr('src', data.avatar_url+'&v='+image_version.toString()); + image.find('img').attr('src', data.avatar_url + '&v=' + image_version.toString()); } }, error: function (xhr) { diff --git a/static/js/settings_invites.js b/static/js/settings_invites.js index f692a1a1a0..13f65547f4 100644 --- a/static/js/settings_invites.js +++ b/static/js/settings_invites.js @@ -57,7 +57,7 @@ exports.set_up = function () { channel.get({ url: '/json/invites', idempotent: true, - timeout: 10*1000, + timeout: 10 * 1000, success: exports.on_load_success, error: failed_listing_invites, }); diff --git a/static/js/settings_org.js b/static/js/settings_org.js index 2604d603cd..c9162fe652 100644 --- a/static/js/settings_org.js +++ b/static/js/settings_org.js @@ -90,7 +90,7 @@ function get_subsection_property_types(subsection) { } exports.get_realm_time_limits_in_minutes = function (property) { - var val = (page_params[property]/ 60).toFixed(1); + var val = (page_params[property] / 60).toFixed(1); if (parseFloat(val, 10) === parseInt(val, 10)) { val = parseInt(val, 10); } @@ -200,23 +200,23 @@ var time_limit_dropdown_values = { }, upto_two_min: { text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("2 minutes")}), - seconds: 2*60, + seconds: 2 * 60, }, upto_ten_min: { text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("10 minutes")}), - seconds: 10*60, + seconds: 10 * 60, }, upto_one_hour: { text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 hour")}), - seconds: 60*60, + seconds: 60 * 60, }, upto_one_day: { text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 day")}), - seconds: 24*60*60, + seconds: 24 * 60 * 60, }, upto_one_week: { text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 week")}), - seconds: 7*24*60*60, + seconds: 7 * 24 * 60 * 60, }, custom_limit: { text: i18n.t("Up to N minutes after posting"), @@ -443,7 +443,7 @@ exports.sync_realm_settings = function (property) { } else if (property === 'invite_required' || property === 'invite_by_admins_only') { property = 'user_invite_restriction'; } - var element = $('#id_realm_'+property); + var element = $('#id_realm_' + property); if (element.length) { discard_property_element_changes(element); } @@ -515,15 +515,15 @@ exports.set_up = function () { _.each(changing_property_types, function (v, k) { var field = changing_property_types[k]; if (field.type === 'bool') { - data[k] = JSON.stringify($('#id_realm_'+k).prop('checked')); + data[k] = JSON.stringify($('#id_realm_' + k).prop('checked')); return; } if (field.type === 'text') { - data[k] = JSON.stringify($('#id_realm_'+k).val().trim()); + data[k] = JSON.stringify($('#id_realm_' + k).val().trim()); return; } if (field.type === 'integer') { - data[k] = JSON.stringify(parseInt($("#id_realm_"+k).val().trim(), 10)); + data[k] = JSON.stringify(parseInt($("#id_realm_" + k).val().trim(), 10)); } }); return data; @@ -989,7 +989,7 @@ exports.set_up = function () { form_data.append('csrfmiddlewaretoken', csrf_token); jQuery.each(file_input[0].files, function (i, file) { - form_data.append('file-'+i, file); + form_data.append('file-' + i, file); }); var spinner = $("#upload_icon_spinner").expectOne(); diff --git a/static/js/settings_users.js b/static/js/settings_users.js index f59d6de387..c3408bc216 100644 --- a/static/js/settings_users.js +++ b/static/js/settings_users.js @@ -211,7 +211,7 @@ exports.set_up = function () { channel.get({ url: '/json/users', idempotent: true, - timeout: 10*1000, + timeout: 10 * 1000, success: exports.on_load_success, error: failed_listing_users, }); diff --git a/static/js/socket.js b/static/js/socket.js index fc184f75d2..14f52709c7 100644 --- a/static/js/socket.js +++ b/static/js/socket.js @@ -287,7 +287,7 @@ Socket.prototype = { // immediately reconnect when the page is refreshing return 30; } - return Math.min(90, Math.exp(this._connection_failures/2)) * 1000; + return Math.min(90, Math.exp(this._connection_failures / 2)) * 1000; }, _try_to_reconnect: function Socket__try_to_reconnect(opts) { diff --git a/static/js/stats/stats.js b/static/js/stats/stats.js index 7c8504c513..36c92a2ecc 100644 --- a/static/js/stats/stats.js +++ b/static/js/stats/stats.js @@ -166,7 +166,7 @@ function populate_messages_sent_over_time(data) { var start_dates = data.end_times.map(function (timestamp) { // data.end_times are the ends of hour long intervals. - return new Date(timestamp*1000 - 60*60*1000); + return new Date(timestamp * 1000 - 60 * 60 * 1000); }); function aggregate_data(aggregation) { @@ -211,7 +211,7 @@ function populate_messages_sent_over_time(data) { return { dates: dates, values: values, last_value_is_partial: !is_boundary(new Date( - start_dates[start_dates.length-1].getTime() + 60*60*1000))}; + start_dates[start_dates.length - 1].getTime() + 60 * 60 * 1000))}; } // Generate traces @@ -235,7 +235,7 @@ function populate_messages_sent_over_time(data) { var weekly_traces = make_traces(info.dates, info.values, 'bar', date_formatter); var dates = data.end_times.map(function (timestamp) { - return new Date(timestamp*1000); + return new Date(timestamp * 1000); }); values = {human: partial_sums(data.everyone.human), bot: partial_sums(data.everyone.bot), me: partial_sums(data.user.human)}; @@ -314,7 +314,7 @@ function round_to_percentages(values, total) { if (x === 0) { return '0%'; } - var unrounded = x/total*100; + var unrounded = x / total * 100; var precision = Math.min( 6, // this is the max precision (two #, 4 decimal points; 99.9999%). @@ -340,8 +340,8 @@ function compute_summary_chart_data(time_series_data, num_steps, labels_) { num_steps = time_series_data[key].length; } var sum = 0; - for (var i=1; i<=num_steps; i+=1) { - sum += time_series_data[key][time_series_data[key].length-i]; + for (var i = 1; i <= num_steps; i += 1) { + sum += time_series_data[key][time_series_data[key].length - i]; } data[key] = sum; } @@ -356,10 +356,10 @@ function compute_summary_chart_data(time_series_data, num_steps, labels_) { } }); if (!$.isEmptyObject(data)) { - labels[labels.length-1] = "Other"; + labels[labels.length - 1] = "Other"; for (key in data) { if (data.hasOwnProperty(key)) { - values[labels.length-1] += data[key]; + values[labels.length - 1] += data[key]; } } } @@ -387,7 +387,7 @@ function populate_messages_sent_by_client(data) { var everyone_month = compute_summary_chart_data( data.everyone, 30, data.display_order.slice(0, 12)); var label_values = []; - for (var i=0; i 0) { annotations.values.push(plot_data.values[i]); annotations.labels.push(plot_data.labels[i]); @@ -515,7 +515,7 @@ function populate_messages_sent_by_client(data) { } // prevent standard hash navigation (avoid blinking in IE) e.preventDefault(); - var pos = $id.offset().top+$('.page-content')[0].scrollTop-50; + var pos = $id.offset().top + $('.page-content')[0].scrollTop - 50; $('.page-content').animate({scrollTop: pos + "px"}, 500); }); } @@ -531,7 +531,7 @@ function populate_messages_sent_by_message_type(data) { function make_plot_data(time_series_data, num_steps) { var plot_data = compute_summary_chart_data(time_series_data, num_steps, data.display_order); var labels = []; - for (var i=0; i