diff --git a/frontend_tests/casper_lib/common.js b/frontend_tests/casper_lib/common.js index eae16a9338..d724259c5e 100644 --- a/frontend_tests/casper_lib/common.js +++ b/frontend_tests/casper_lib/common.js @@ -29,7 +29,7 @@ exports.init_viewport = function () { casper.options.viewportSize = {width: 1280, height: 1024}; }; -exports.initialize_casper = function (viewport) { +exports.initialize_casper = function () { if (casper.zulip_initialized !== undefined) { return; } diff --git a/frontend_tests/casper_tests/00-realm-creation.js b/frontend_tests/casper_tests/00-realm-creation.js index 4b3a361f66..f525415395 100644 --- a/frontend_tests/casper_tests/00-realm-creation.js +++ b/frontend_tests/casper_tests/00-realm-creation.js @@ -1,7 +1,6 @@ var common = require('../casper_lib/common.js').common; var email = 'alice@test.example.com'; -var domain = 'test.example.com'; var subdomain = 'testsubdomain'; var organization_name = 'Awesome Organization'; var REALMS_HAVE_SUBDOMAINS = casper.cli.get('subdomains'); diff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.js index 928e739649..d6f419edd9 100644 --- a/frontend_tests/node_tests/dispatch.js +++ b/frontend_tests/node_tests/dispatch.js @@ -435,7 +435,7 @@ var run = (function () { }()); -run(function (override, capture, args) { +run(function () { // alert_words var event = event_fixtures.alert_words; dispatch(event); @@ -443,7 +443,7 @@ run(function (override, capture, args) { }); -run(function (override, capture, args) { +run(function (override) { // default_streams var event = event_fixtures.default_streams; override('admin', 'update_default_streams_table', noop); @@ -471,7 +471,7 @@ run(function (override, capture, args) { }); -run(function (override, capture, args) { +run(function () { // pointer var event = event_fixtures.pointer; global.pointer.furthest_read = 0; @@ -492,7 +492,7 @@ run(function (override, capture, args) { }); -run(function (override, capture, args) { +run(function (override) { // realm function test_realm_boolean(event, parameter_name) { page_params[parameter_name] = true; @@ -565,7 +565,7 @@ run(function (override, capture, args) { }); -run(function (override, capture, args) { +run(function (override) { // realm_filters var event = event_fixtures.realm_filters; page_params.realm_filters = []; @@ -684,7 +684,7 @@ run(function (override, capture, args) { }); -run(function (override, capture, args) { +run(function () { // update_display_settings var event = event_fixtures.update_display_settings__default_language; page_params.default_language = 'en'; diff --git a/frontend_tests/node_tests/people.js b/frontend_tests/node_tests/people.js index 3a88f81baf..b9379349f4 100644 --- a/frontend_tests/node_tests/people.js +++ b/frontend_tests/node_tests/people.js @@ -201,10 +201,6 @@ var _ = global._; var search_term = 'a'; var users = people.get_rest_of_realm(); var filtered_people = people.filter_people_by_search_terms(users, [search_term]); - var expected = [ - { email: 'athens@example.com', full_name: 'Maria Athens' }, - { email: 'ashton@example.com', full_name: 'Ashton Smith' }, - ]; assert.equal(filtered_people["ashton@example.com"], true); assert.equal(filtered_people["athens@example.com"], true); assert.equal(_.keys(filtered_people).length, 2); diff --git a/frontend_tests/node_tests/unread.js b/frontend_tests/node_tests/unread.js index 38217f4935..bd845f750c 100644 --- a/frontend_tests/node_tests/unread.js +++ b/frontend_tests/node_tests/unread.js @@ -123,12 +123,6 @@ var zero_counts = { // Test defensive code. Trying to update a message we don't know // about should be a no-op. - var unknown_message = { - id: 18, - type: 'stream', - stream: 'social', - subject: 'lunch', - }; event = { subject: 'brunch', }; diff --git a/static/js/admin.js b/static/js/admin.js index 5af021ab6b..01a0f338ae 100644 --- a/static/js/admin.js +++ b/static/js/admin.js @@ -2,7 +2,6 @@ var admin = (function () { var exports = {}; var all_streams = []; -var user_row_to_deactivate; exports.show_or_hide_menu_item = function () { var item = $('.admin-menu-item').expectOne(); @@ -41,20 +40,16 @@ exports.update_user_full_name = function (email, new_full_name) { user_row.show(); }; -function failed_listing_users(xhr, error) { +function failed_listing_users(xhr) { loading.destroy_indicator($('#subs_page_loading_indicator')); ui.report_error(i18n.t("Error listing users or bots"), xhr, $("#administration-status")); } -function failed_listing_streams(xhr, error) { +function failed_listing_streams(xhr) { ui.report_error(i18n.t("Error listing streams"), xhr, $("#administration-status")); } -function failed_listing_emoji(xhr, error) { - ui.report_error(i18n.t("Error listing emoji"), xhr, $("#administration-status")); -} - -function failed_changing_name(xhr, error) { +function failed_changing_name(xhr) { ui.report_error(i18n.t("Error changing name"), xhr, $("#administration-status")); } @@ -144,12 +139,11 @@ function make_stream_default(stream_name) { var data = { stream_name: stream_name }; - var default_streams_table = $("#admin_default_streams_table").expectOne(); channel.put({ url: '/json/default_streams', data: data, - error: function (xhr, error_type) { + error: function (xhr) { if (xhr.status.toString().charAt(0) === "4") { $(".active_stream_row button").closest("td").html( $("

").addClass("text-error").text(JSON.parse(xhr.responseText).msg)); @@ -223,7 +217,7 @@ exports.populate_auth_methods = function (auth_methods) { }; exports.set_up_deactivate_user_modal = function (row) { - $("#do_deactivate_user_button").expectOne().click(function (e) { + $("#do_deactivate_user_button").expectOne().click(function () { var email = row.find(".email").text(); if ($("#deactivation_user_modal .email").html() !== email) { blueslip.error("User deactivation canceled due to non-matching fields."); @@ -234,7 +228,7 @@ exports.set_up_deactivate_user_modal = function (row) { row.find("button").prop("disabled", true).text("Working…"); channel.del({ url: '/json/users/' + email, - error: function (xhr, error_type) { + error: function (xhr) { if (xhr.status.toString().charAt(0) === "4") { row.find("button").closest("td").html( $("

").addClass("text-error").text(JSON.parse(xhr.responseText).msg) @@ -379,7 +373,7 @@ function _setup_page() { channel.del({ url: '/json/default_streams'+ '?' + $.param({stream_name: stream_name}), - error: function (xhr, error_type) { + error: function (xhr) { if (xhr.status.toString().charAt(0) === "4") { $(".active_default_stream_row button").closest("td").html( $("

").addClass("text-error").text(JSON.parse(xhr.responseText).msg)); @@ -404,7 +398,7 @@ function _setup_page() { $('.create_default_stream').typeahead({ items: 5, fixed: true, - source: function (query) { + source: function () { return get_non_default_streams_names(all_streams); }, highlight: true, @@ -419,12 +413,11 @@ function _setup_page() { var row = $(e.target).closest(".user_row"); - var user_name = row.find('.user_name').text(); var email = get_email_for_user_row(row); channel.del({ url: '/json/bots/' + email, - error: function (xhr, error_type) { + error: function (xhr) { if (xhr.status.toString().charAt(0) === "4") { row.find("button").closest("td").html( $("

").addClass("text-error").text(JSON.parse(xhr.responseText).msg) @@ -455,7 +448,7 @@ function _setup_page() { channel.post({ url: '/json/users/' + email + "/reactivate", - error: function (xhr, error_type) { + error: function (xhr) { var button = row.find("button"); if (xhr.status.toString().charAt(0) === "4") { button.closest("td").html( @@ -506,7 +499,6 @@ function _setup_page() { var create_stream_by_admins_only_status = $("#admin-realm-create-stream-by-admins-only-status").expectOne(); var message_editing_status = $("#admin-realm-message-editing-status").expectOne(); var default_language_status = $("#admin-realm-default-language-status").expectOne(); - var auth_methods_table = $('.admin_auth_methods_table'); name_status.hide(); restricted_to_domain_status.hide(); invite_required_status.hide(); @@ -626,7 +618,7 @@ function _setup_page() { } } }, - error: function (xhr, error) { + error: function (xhr) { var reason = $.parseJSON(xhr.responseText).reason; if (reason === "no authentication") { ui.report_error(i18n.t("Failed!"), xhr, authentication_methods_status); @@ -661,7 +653,7 @@ function _setup_page() { button.removeClass("make-admin"); button.text(i18n.t("Remove admin")); }, - error: function (xhr, error) { + error: function (xhr) { var status = row.find(".admin-user-status"); ui.report_error(i18n.t("Failed!"), xhr, status); } @@ -692,7 +684,7 @@ function _setup_page() { button.removeClass("remove-admin"); button.text(i18n.t("Make admin")); }, - error: function (xhr, error) { + error: function (xhr) { var status = row.find(".admin-user-status"); ui.report_error(i18n.t("Failed!"), xhr, status); } @@ -713,7 +705,7 @@ function _setup_page() { user_row.hide(); form_row.show(); - reset_button.on("click", function (e) { + reset_button.on("click", function () { form_row.hide(); user_row.show(); }); @@ -738,7 +730,7 @@ function _setup_page() { }); }); - $("#do_deactivate_stream_button").click(function (e) { + $("#do_deactivate_stream_button").click(function () { if ($("#deactivation_stream_modal .stream_name").text() !== $(".active_stream_row").find('.stream_name').text()) { blueslip.error("Stream deactivation canceled due to non-matching fields."); ui.report_message("Deactivation encountered an error. Please reload and try again.", @@ -748,7 +740,7 @@ function _setup_page() { $(".active_stream_row button").prop("disabled", true).text("Working…"); channel.del({ url: '/json/streams/' + encodeURIComponent($(".active_stream_row").find('.stream_name').text()), - error: function (xhr, error_type) { + error: function (xhr) { if (xhr.status.toString().charAt(0) === "4") { $(".active_stream_row button").closest("td").html( $("

").addClass("text-error").text(JSON.parse(xhr.responseText).msg) @@ -771,7 +763,7 @@ function _setup_page() { channel.del({ url: '/json/realm/emoji/' + encodeURIComponent(btn.attr('data-emoji-name')), - error: function (xhr, error_type) { + error: function (xhr) { if (xhr.status.toString().charAt(0) === "4") { btn.closest("td").html( $("

").addClass("text-error").text(JSON.parse(xhr.responseText).msg) @@ -804,7 +796,7 @@ function _setup_page() { ui.report_success(i18n.t("Custom emoji added!"), emoji_status); $("form.admin-emoji-form input[type='text']").val(""); }, - error: function (xhr, error) { + error: function (xhr) { $('#admin-emoji-status').hide(); var errors = JSON.parse(xhr.responseText).msg; xhr.responseText = JSON.stringify({msg: errors}); @@ -820,7 +812,7 @@ function _setup_page() { channel.del({ url: '/json/realm/filters/' + encodeURIComponent(btn.attr('data-filter-id')), - error: function (xhr, error_type) { + error: function (xhr) { if (xhr.status.toString().charAt(0) === "4") { btn.closest("td").html( $("

").addClass("text-error").text($.parseJSON(xhr.responseText).msg) @@ -857,7 +849,7 @@ function _setup_page() { filter.id = data.id; ui.report_success(i18n.t("Custom filter added!"), filter_status); }, - error: function (xhr, error) { + error: function (xhr) { var errors = $.parseJSON(xhr.responseText).errors; if (errors.pattern !== undefined) { xhr.responseText = JSON.stringify({msg: errors.pattern}); diff --git a/static/js/avatar.js b/static/js/avatar.js index dd36d58bdb..a61f16e926 100644 --- a/static/js/avatar.js +++ b/static/js/avatar.js @@ -162,7 +162,7 @@ exports.build_direct_upload_widget = function ( upload_function ) { - function accept(file) { + function accept() { input_error.hide(); upload_function(get_file_input()); } diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js index 5ab818095c..d2c78320bb 100644 --- a/static/js/click_handlers.js +++ b/static/js/click_handlers.js @@ -272,10 +272,10 @@ $(function () { popovers.register_click_handlers(); notifications.register_click_handlers(); - $('.logout_button').click(function (e) { + $('.logout_button').click(function () { $('#logout_form').submit(); }); - $('.restart_get_events_button').click(function (e) { + $('.restart_get_events_button').click(function () { server_events.restart_get_events({dont_block: true}); }); @@ -289,10 +289,10 @@ $(function () { ); - $('.compose_stream_button').click(function (e) { + $('.compose_stream_button').click(function () { compose.start('stream'); }); - $('.compose_private_button').click(function (e) { + $('.compose_private_button').click(function () { compose.start('private'); }); @@ -325,7 +325,7 @@ $(function () { $("#compose_buttons").click(handle_compose_click); $(".compose-content").click(handle_compose_click); - $("#compose_close").click(function (e) { + $("#compose_close").click(function () { compose.cancel(); }); @@ -333,7 +333,7 @@ $(function () { // Keep these 2 feedback bot triggers separate because they have to // propagate the event differently. - $('.feedback').click(function (e) { + $('.feedback').click(function () { compose.start('private', {private_message_recipient: 'feedback@zulip.com', trigger: 'feedback menu item'}); @@ -372,10 +372,10 @@ $(function () { channel.post({ url: "/accounts/webathena_kerberos_login/", data: {cred: JSON.stringify(r.session)}, - success: function (data, success) { + success: function () { $("#zephyr-mirror-error").hide(); }, - error: function (data, success) { + error: function () { $("#zephyr-mirror-error").show(); } }); @@ -388,11 +388,11 @@ $(function () { // BANKRUPTCY - $(".bankruptcy_button").click(function (e) { + $(".bankruptcy_button").click(function () { unread.enable(); }); - $('#yes-bankrupt').click(function (e) { + $('#yes-bankrupt').click(function () { pointer.fast_forward_pointer(); $("#yes-bankrupt").hide(); $("#no-bankrupt").hide(); @@ -432,7 +432,7 @@ $(function () { } }); - $("#overlay .download").click(function (e) { + $("#overlay .download").click(function () { this.blur(); }); }()); diff --git a/static/js/compose.js b/static/js/compose.js index ce8937f9b2..de924f5bca 100644 --- a/static/js/compose.js +++ b/static/js/compose.js @@ -403,8 +403,6 @@ function compose_error(error_text, bad_input) { } } -var send_options; - function send_message_ajax(request, success, error) { channel.post({ url: '/json/messages', diff --git a/static/js/compose_fade.js b/static/js/compose_fade.js index fb5a502216..e416096a4a 100644 --- a/static/js/compose_fade.js +++ b/static/js/compose_fade.js @@ -238,10 +238,10 @@ exports.update_rendered_message_groups = function (message_groups, get_element) }; $(function () { - $(document).on('peer_subscribe.zulip', function (e) { + $(document).on('peer_subscribe.zulip', function () { exports.update_faded_users(); }); - $(document).on('peer_unsubscribe.zulip', function (e) { + $(document).on('peer_unsubscribe.zulip', function () { exports.update_faded_users(); }); }); diff --git a/static/js/composebox_typeahead.js b/static/js/composebox_typeahead.js index fe876b5463..436e7e1cde 100644 --- a/static/js/composebox_typeahead.js +++ b/static/js/composebox_typeahead.js @@ -165,7 +165,7 @@ function select_on_focus(field_id) { // conditions in Chrome so we need to protect against infinite // recursion. var in_handler = false; - $("#" + field_id).focus(function (e) { + $("#" + field_id).focus(function () { if (in_handler) { return; } @@ -378,7 +378,7 @@ exports.initialize = function () { // limit number of items so the list doesn't fall off the screen $( "#stream" ).typeahead({ - source: function (query, process) { + source: function () { return stream_data.subscribed_streams(); }, items: 3, @@ -396,7 +396,7 @@ exports.initialize = function () { }); $( "#subject" ).typeahead({ - source: function (query, process) { + source: function () { var stream_name = $("#stream").val(); return exports.topics_seen_for(stream_name); }, @@ -450,7 +450,7 @@ exports.initialize = function () { exports.initialize_compose_typeahead("#new_message_content", {mention: true, emoji: true, stream: true}); - $( "#private_message_recipient" ).blur(function (event) { + $( "#private_message_recipient" ).blur(function () { var val = $(this).val(); var recipients = exports.get_cleaned_pm_recipients(val); $(this).val(recipients.join(", ")); diff --git a/static/js/condense.js b/static/js/condense.js index aa63e003da..481133500b 100644 --- a/static/js/condense.js +++ b/static/js/condense.js @@ -140,7 +140,7 @@ exports.condense_and_collapse = function (elems) { }; $(function () { - $("#home").on("click", ".message_expander", function (e) { + $("#home").on("click", ".message_expander", function () { // Expanding a message can mean either uncollapsing or // uncondensing it. var row = $(this).closest(".message_row"); @@ -158,7 +158,7 @@ $(function () { } }); - $("#home").on("click", ".message_condenser", function (e) { + $("#home").on("click", ".message_condenser", function () { var row = $(this).closest(".message_row"); current_msg_list.get(rows.id(row)).condensed = true; condense_row(row); diff --git a/static/js/copy_and_paste.js b/static/js/copy_and_paste.js index ece171d843..7b5952fd3c 100644 --- a/static/js/copy_and_paste.js +++ b/static/js/copy_and_paste.js @@ -36,7 +36,7 @@ function find_boundary_tr(initial_tr, iterate_row) { } -function copy_handler(e) { +function copy_handler() { var selection = window.getSelection(); var i; var range; diff --git a/static/js/custom_markdown.js b/static/js/custom_markdown.js index 612b80b091..5386ce8bd9 100644 --- a/static/js/custom_markdown.js +++ b/static/js/custom_markdown.js @@ -36,7 +36,7 @@ var exports = {}; subscriptions: JSON.stringify([stream_name]) } }).then( - function (data) { + function () { $status_message.hide(); }, function (xhr) { ui.report_error(i18n.t("Error removing subscription"), xhr, $status_message); diff --git a/static/js/echo.js b/static/js/echo.js index 42ba81e324..14a5b65304 100644 --- a/static/js/echo.js +++ b/static/js/echo.js @@ -415,7 +415,7 @@ exports.set_realm_filters = function set_realm_filters(realm_filters) { $(function () { function disable_markdown_regex(rules, name) { - rules[name] = {exec: function (_) { + rules[name] = {exec: function () { return false; } }; @@ -533,7 +533,7 @@ $(document).on('socket_loaded_requests.zulip', function (event, data) { var msgs_to_insert = []; var next_local_id = get_next_local_id(); - _.each(data.requests, function (socket_msg, key) { + _.each(data.requests, function (socket_msg) { var msg = socket_msg.msg; // Check for any message objects, then insert them locally if (msg.stream === undefined || msg.local_id === undefined) { diff --git a/static/js/invite.js b/static/js/invite.js index f9882dd0fb..cbbd8d7826 100644 --- a/static/js/invite.js +++ b/static/js/invite.js @@ -53,7 +53,7 @@ exports.initialize = function () { $("#invite_user_form").ajaxForm({ dataType: 'json', - beforeSubmit: function (arr, $form, options) { + beforeSubmit: function () { reset_error_messages(); // TODO: You could alternatively parse the textarea here, and return errors to // the user if they don't match certain constraints (i.e. not real email addresses, @@ -63,7 +63,7 @@ exports.initialize = function () { $('#submit-invitation').button('loading'); return true; }, - success: function (resp, statusText, xhr, form) { + success: function () { $('#submit-invitation').button('reset'); invite_status.text(i18n.t('User invited successfully.', {count: (invitee_emails.val().match(/@/g) || [] ).length})) .addClass('alert-success') @@ -77,7 +77,7 @@ exports.initialize = function () { } }, - error: function (xhr, error_type, xhn) { + error: function (xhr) { $('#submit-invitation').button('reset'); var arr = JSON.parse(xhr.responseText); if (arr.errors === undefined) { diff --git a/static/js/message_edit.js b/static/js/message_edit.js index 364b1c2fb2..731fa0f0c8 100644 --- a/static/js/message_edit.js +++ b/static/js/message_edit.js @@ -105,12 +105,12 @@ exports.save = function (row, from_topic_edited_only) { channel.post({ url: '/json/update_message', data: request, - success: function (data) { + success: function () { if (msg_list === current_msg_list) { row.find(".edit_error").text("Message successfully edited!").removeClass("alert-error").addClass("alert-success").show(); } }, - error: function (xhr, error_type, xhn) { + error: function (xhr) { if (msg_list === current_msg_list) { var message = channel.xhr_error_message("Error saving edit", xhr); row.find(".edit_error").text(message).show(); @@ -355,7 +355,7 @@ exports.maybe_show_edit = function (row, id) { } }; -$(document).on('narrow_deactivated.zulip', function (event) { +$(document).on('narrow_deactivated.zulip', function () { _.each(currently_editing_messages, function (elem, idx) { if (current_msg_list.get(idx) !== undefined) { var row = current_msg_list.get_row(idx); diff --git a/static/js/message_flags.js b/static/js/message_flags.js index 6b78a135e8..4909c0908b 100644 --- a/static/js/message_flags.js +++ b/static/js/message_flags.js @@ -41,7 +41,7 @@ function batched_updater(flag, op, immediate) { start = _.debounce(server_request, 1000); } - on_success = function on_success(data, status, jqXHR) { + on_success = function on_success(data) { if (data === undefined || data.messages === undefined) { return; } diff --git a/static/js/message_list.js b/static/js/message_list.js index e480018521..0e93fa6c6b 100644 --- a/static/js/message_list.js +++ b/static/js/message_list.js @@ -634,7 +634,7 @@ exports.all = new exports.MessageList( // doing something. Be careful, though, if you try to capture // mousemove, then you will have to contend with the autoscroll // itself generating mousemove events. -$(document).on('message_selected.zulip zuliphashchange.zulip mousewheel', function (event) { +$(document).on('message_selected.zulip zuliphashchange.zulip mousewheel', function () { viewport.stop_auto_scrolling(); }); diff --git a/static/js/message_list_view.js b/static/js/message_list_view.js index bc7f47d2b1..88ebaf5314 100644 --- a/static/js/message_list_view.js +++ b/static/js/message_list_view.js @@ -130,8 +130,7 @@ MessageListView.prototype = { } }, - build_message_groups: function MessageListView__build_message_groups(message_containers, - message_id_prefix) { + build_message_groups: function MessageListView__build_message_groups(message_containers) { function start_group() { return { message_containers: [], @@ -399,10 +398,7 @@ MessageListView.prototype = { // we we record if last_message_was_selected before updating the table var last_message_was_selected = rows.id(rows.last_visible()) === list.selected_id(); var orig_scrolltop_offset; - var last_message_id; var message_containers; - var first_msg; - var last_msg; var self = this; @@ -582,7 +578,6 @@ MessageListView.prototype = { // scroll up without moving the pointer out of the viewport, do so, by // up to the amount taken up by the new message. var new_messages_height = 0; - var distance_to_last_message_sent_by_me = 0; var id_of_last_message_sent_by_us = -1; // C++ iterators would have made this less painful @@ -593,14 +588,12 @@ MessageListView.prototype = { new_messages_height += elem.height(); // starting from the last message, ignore message heights that weren't sent by me. if (id_of_last_message_sent_by_us > -1) { - distance_to_last_message_sent_by_me += elem.height(); return; } var row_id = rows.id(elem); // check for `row_id` NaN in case we're looking at a date row or bookend row if (row_id > -1 && util.is_current_user(this.get_message(row_id).sender_email)) { - distance_to_last_message_sent_by_me += elem.height(); id_of_last_message_sent_by_us = rows.id(elem); } } @@ -803,13 +796,6 @@ MessageListView.prototype = { rerender_messages: function MessageListView__rerender_messages(messages) { var self = this; - // Only re-render the messages that are in this narrow - var own_messages = _.map(messages, function (message) { - return self.list.get(message.id); - }); - own_messages = _.reject(own_messages, function (message) { - return message === undefined; - }); // Convert messages to list messages var message_containers = _.map(messages, function (message) { return self.message_containers[message.id]; @@ -868,13 +854,10 @@ MessageListView.prototype = { } }, - rerender_the_whole_thing: function MessageListView__rerender_the_whole_thing(messages) { + rerender_the_whole_thing: function MessageListView__rerender_the_whole_thing() { // TODO: Figure out if we can unify this with this.list.rerender(). - this.clear_rendering_state(true); - this.update_render_window(this.list.selected_idx(), false); - this.render(this.list.all_messages().slice(this._render_win_start, this._render_win_end), 'bottom'); }, diff --git a/static/js/message_store.js b/static/js/message_store.js index 14f53212fb..561295b483 100644 --- a/static/js/message_store.js +++ b/static/js/message_store.js @@ -41,7 +41,7 @@ exports.get_private_message_recipient = function (message, attr, fallback_attr) }; exports.process_message_for_recent_private_messages = - function process_message_for_recent_private_messages(message, remove_message) { + function process_message_for_recent_private_messages(message) { var current_timestamp = 0; var user_ids_string = people.emails_strings_to_user_ids_string(message.reply_to); @@ -219,7 +219,7 @@ function maybe_add_narrowed_messages(messages, msg_list, messages_are_new) { notifications.possibly_notify_new_messages_outside_viewport(new_messages); notifications.notify_messages_outside_current_search(elsewhere_messages); }, - error: function (xhr) { + error: function () { // We might want to be more clever here setTimeout(function () { if (msg_list === current_msg_list) { @@ -496,7 +496,7 @@ exports.load_old_messages = function load_old_messages(opts) { success: function (data) { get_old_messages_success(data, opts); }, - error: function (xhr, error_type, exn) { + error: function (xhr) { if (opts.msg_list.narrowed && opts.msg_list !== current_msg_list) { // We unnarrowed before getting an error so don't // bother trying again or doing further processing. diff --git a/static/js/muting_ui.js b/static/js/muting_ui.js index 820ac2de1d..7e02aff6f6 100644 --- a/static/js/muting_ui.js +++ b/static/js/muting_ui.js @@ -17,7 +17,6 @@ exports.rerender = function () { }; exports.notify_with_undo_option = (function () { - var event_added = false; var meta = { stream: null, topic: null, @@ -26,12 +25,12 @@ exports.notify_with_undo_option = (function () { $mute: null }; var animate = { - fadeOut: function ($mute) { + fadeOut: function () { if (meta.$mute) { meta.$mute.fadeOut(500).removeClass("show"); } }, - fadeIn: function ($mute) { + fadeIn: function () { if (meta.$mute) { meta.$mute.fadeIn(500).addClass("show"); } diff --git a/static/js/notifications.js b/static/js/notifications.js index c4cac33e84..8d330563b4 100644 --- a/static/js/notifications.js +++ b/static/js/notifications.js @@ -9,7 +9,6 @@ var notice_memory = {}; var window_has_focus = document.hasFocus && document.hasFocus(); var asked_permission_already = false; -var names; var supports_sound; var unread_pms_favicon = '/static/images/favicon/favicon-pms.png'; diff --git a/static/js/popovers.js b/static/js/popovers.js index 5c4623e866..41ff2217ff 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -521,7 +521,6 @@ exports.register_click_handlers = function () { var stream = $(elt).parents('li').attr('data-name'); - var ypos = $(elt).offset().top - viewport.scrollTop(); $(elt).popover({ content: templates.render('stream_sidebar_actions', {stream: stream_data.get_sub(stream)}), trigger: "manual", @@ -566,7 +565,7 @@ exports.register_click_handlers = function () { $(e.target).hide(); }); - $('.streams_popover').on('click', 'a.sp-cancel', function (e) { + $('.streams_popover').on('click', 'a.sp-cancel', function () { popovers.hide_stream_sidebar_popover(); }); }); diff --git a/static/js/referral.js b/static/js/referral.js index 9b3e9b508b..87ba7737ff 100644 --- a/static/js/referral.js +++ b/static/js/referral.js @@ -93,7 +93,7 @@ $(function () { } }); - $("#referral-form input").on('blur', function (e) { + $("#referral-form input").on('blur', function () { if ($("#referral-form input").val() === '') { validator.resetForm(); resize.resize_page_components(); diff --git a/static/js/resize.js b/static/js/resize.js index e9d7212917..fe7f6e1450 100644 --- a/static/js/resize.js +++ b/static/js/resize.js @@ -15,8 +15,6 @@ function confine_to_range(lo, val, hi) { } function size_blocks(blocks, usable_height) { - var n = blocks.length; - var sum_height = 0; _.each(blocks, function (block) { sum_height += block.real_height; @@ -183,15 +181,6 @@ exports.resize_stream_filters_container = function (h) { }; exports.resize_page_components = function () { - var composebox = $("#compose"); - var floating_recipient_bar = $("#floating_recipient_bar"); - var desired_width; - if (ui.home_tab_obscured() === 'other_tab') { - desired_width = $("div.tab-pane.active").outerWidth(); - } else { - desired_width = $("#main_div").outerWidth(); - } - var h; var sidebar; @@ -238,7 +227,7 @@ exports.resize_page_components = function () { var _old_width = $(window).width(); -exports.handler = function (e) { +exports.handler = function () { var new_width = $(window).width(); if (new_width !== _old_width) { diff --git a/static/js/search.js b/static/js/search.js index 6db85ab53a..cffe305c60 100644 --- a/static/js/search.js +++ b/static/js/search.js @@ -60,7 +60,7 @@ exports.initialize = function () { var obj = search_object[item]; return obj.description; }, - matcher: function (item) { + matcher: function () { return true; }, updater: narrow_or_search_for_term, diff --git a/static/js/server_events.js b/static/js/server_events.js index a78d9d7d47..fc553261d9 100644 --- a/static/js/server_events.js +++ b/static/js/server_events.js @@ -356,7 +356,7 @@ function get_events(options) { } get_events_timeout = setTimeout(get_events, 0); }, - error: function (xhr, error_type, exn) { + error: function (xhr, error_type) { try { get_events_xhr = undefined; // If we are old enough to have messages outside of the @@ -458,7 +458,7 @@ exports.cleanup_event_queue = function cleanup_event_queue() { }); }; -window.addEventListener("beforeunload", function (event) { +window.addEventListener("beforeunload", function () { exports.cleanup_event_queue(); }); diff --git a/static/js/settings.js b/static/js/settings.js index d6cc08bc32..f6cbed4a8b 100644 --- a/static/js/settings.js +++ b/static/js/settings.js @@ -187,7 +187,7 @@ function _setup_page() { clear_password_change(); - $('#api_key_button').click(function (e) { + $('#api_key_button').click(function () { if (page_params.password_auth_enabled !== false) { $("#get_api_key_box").show(); } else { @@ -237,7 +237,7 @@ function _setup_page() { $("form.your-account-settings").ajaxForm({ dataType: 'json', // This seems to be ignored. We still get back an xhr. - beforeSubmit: function (arr, form, options) { + beforeSubmit: function () { if (page_params.password_auth_enabled !== false) { // FIXME: Check that the two password fields match // FIXME: Use the same jQuery validation plugin as the signup form? @@ -258,21 +258,20 @@ function _setup_page() { } return true; }, - success: function (resp, statusText, xhr, form) { + success: function () { settings_change_success("Updated settings!"); }, - error: function (xhr, error_type, xhn) { + error: function (xhr) { settings_change_error("Error changing settings", xhr); }, - complete: function (xhr, statusText) { + complete: function () { // Whether successful or not, clear the password boxes. // TODO: Clear these earlier, while the request is still pending. clear_password_change(); } }); - function update_notification_settings_success(resp, statusText, xhr, form) { - var message = "Updated notification settings!"; + function update_notification_settings_success(resp, statusText, xhr) { var result = JSON.parse(xhr.responseText); var notify_settings_status = $('#notify-settings-status').expectOne(); @@ -318,7 +317,7 @@ function _setup_page() { ui.report_success(i18n.t("Updated notification settings!"), notify_settings_status); } - function update_notification_settings_error(xhr, error_type, xhn) { + function update_notification_settings_error(xhr) { ui.report_error(i18n.t("Error changing settings"), xhr, $('#notify-settings-status').expectOne()); } @@ -376,22 +375,22 @@ function _setup_page() { var control_group = notification_checkbox.closest(".control-group"); var checkbox_status = notification_checkbox.is(":checked"); control_group.find(".propagate_stream_notifications_change").html(html); - control_group.find(".yes_propagate_notifications").on("click", function (e) { + control_group.find(".yes_propagate_notifications").on("click", function () { propagate_setting_function(checkbox_status); control_group.find(".propagate_stream_notifications_change").empty(); }); - control_group.find(".no_propagate_notifications").on("click", function (e) { + control_group.find(".no_propagate_notifications").on("click", function () { control_group.find(".propagate_stream_notifications_change").empty(); }); } - $("#enable_stream_desktop_notifications").on("click", function (e) { + $("#enable_stream_desktop_notifications").on("click", function () { var notification_checkbox = $("#enable_stream_desktop_notifications"); maybe_bulk_update_stream_notification_setting(notification_checkbox, update_desktop_notification_setting); }); - $("#enable_stream_sounds").on("click", function (e) { + $("#enable_stream_sounds").on("click", function () { var notification_checkbox = $("#enable_stream_sounds"); maybe_bulk_update_stream_notification_setting(notification_checkbox, update_audible_notification_setting); @@ -411,11 +410,11 @@ function _setup_page() { channel.patch({ url: '/json/left_side_userlist', data: data, - success: function (resp, statusText, xhr, form) { + success: function () { ui.report_success(i18n.t("User list will appear on the __side__ hand side! You will need to reload the window for your changes to take effect.", context), $('#display-settings-status').expectOne()); }, - error: function (xhr, error_type, xhn) { + error: function (xhr) { ui.report_error(i18n.t("Error updating user list placement setting"), xhr, $('#display-settings-status').expectOne()); } }); @@ -435,11 +434,11 @@ function _setup_page() { channel.patch({ url: '/json/time_setting', data: data, - success: function (resp, statusText, xhr, form) { + success: function () { ui.report_success(i18n.t("Time will be displayed in the __format__-hour format! You will need to reload the window for your changes to take effect", context), $('#display-settings-status').expectOne()); }, - error: function (xhr, error_type, xhn) { + error: function (xhr) { ui.report_error(i18n.t("Error updating time format setting"), xhr, $('#display-settings-status').expectOne()); } }); @@ -464,11 +463,11 @@ function _setup_page() { channel.patch({ url: '/json/language_setting', data: data, - success: function (resp, statusText, xhr, form) { + success: function () { ui.report_success(i18n.t("__lang__ is now the default language! You will need to reload the window for your changes to take effect", context), $('#display-settings-status').expectOne()); }, - error: function (xhr, error_type, xhn) { + error: function (xhr) { ui.report_error(i18n.t("Error updating default language setting"), xhr, $('#display-settings-status').expectOne()); } }); @@ -486,14 +485,14 @@ function _setup_page() { $("#deactivate_self_modal").modal("show"); }); - $("#do_deactivate_self_button").on('click',function (e) { + $("#do_deactivate_self_button").on('click',function () { $("#deactivate_self_modal").modal("hide"); channel.del({ url: '/json/users/me', success: function () { window.location.href = "/login"; }, - error: function (xhr, error_type) { + error: function (xhr) { ui.report_error(i18n.t("Error deactivating account"), xhr, $('#settings-status').expectOne()); } }); @@ -503,8 +502,7 @@ function _setup_page() { $("#show_api_key_box").hide(); $("#get_api_key_box form").ajaxForm({ dataType: 'json', // This seems to be ignored. We still get back an xhr. - success: function (resp, statusText, xhr, form) { - var message = "Updated settings!"; + success: function (resp, statusText, xhr) { var result = JSON.parse(xhr.responseText); var settings_status = $('#settings-status').expectOne(); @@ -514,7 +512,7 @@ function _setup_page() { $("#get_api_key_box").hide(); settings_status.hide(); }, - error: function (xhr, error_type, xhn) { + error: function (xhr) { ui.report_error(i18n.t("Error getting API key"), xhr, $('#settings-status').expectOne()); $("#show_api_key_box").hide(); $("#get_api_key_box").show(); @@ -595,17 +593,17 @@ function _setup_page() { cache: false, processData: false, contentType: false, - success: function (data) { + success: function () { $('#bot_table_error').hide(); $('#create_bot_name').val(''); $('#create_bot_short_name').val(''); $('#create_bot_button').show(); create_avatar_widget.clear(); }, - error: function (xhr, error_type, exn) { + error: function (xhr) { $('#bot_table_error').text(JSON.parse(xhr.responseText).msg).show(); }, - complete: function (xhr, status) { + complete: function () { $('#create_bot_button').val('Create bot').prop('disabled', false); } }); @@ -678,7 +676,7 @@ function _setup_page() { form.validate({ errorClass: 'text-error', - success: function (label) { + success: function () { errors.hide(); }, submitHandler: function () { @@ -720,7 +718,7 @@ function _setup_page() { image.find('img').attr('src', data.avatar_url+'&v='+image_version.toString()); } }, - error: function (xhr, error_type, exn) { + error: function (xhr) { loading.destroy_indicator(spinner); edit_button.show(); errors.text(JSON.parse(xhr.responseText).msg).show(); @@ -749,7 +747,7 @@ function _setup_page() { )); }); - $("#show_api_key_box").on("click", "button.regenerate_api_key", function (e) { + $("#show_api_key_box").on("click", "button.regenerate_api_key", function () { channel.post({ url: '/json/users/me/api_key/regenerate', idempotent: true, @@ -762,9 +760,7 @@ function _setup_page() { }); }); - $("#ui-settings").on("click", "input[name='change_settings']", function (e) { - e.preventDefault(); - + $("#ui-settings").on("click", "input[name='change_settings']", function () { var labs_updates = {}; _.each(["autoscroll_forever", "default_desktop_notifications"], function (setting) { @@ -774,7 +770,7 @@ function _setup_page() { channel.post({ url: '/json/ui_settings/change', data: labs_updates, - success: function (resp, statusText, xhr, form) { + success: function (resp, statusText, xhr) { var message = i18n.t("Updated __product_name__ Labs settings!", page_params); var result = JSON.parse(xhr.responseText); var ui_settings_status = $('#ui-settings-status').expectOne(); @@ -786,7 +782,7 @@ function _setup_page() { ui.report_success(message, ui_settings_status); }, - error: function (xhr, error_type, xhn) { + error: function (xhr) { ui.report_error(i18n.t("Error changing settings"), xhr, $('#ui-settings-status').expectOne()); } }); diff --git a/static/js/signup.js b/static/js/signup.js index 5123a74143..f22b3a2dc3 100644 --- a/static/js/signup.js +++ b/static/js/signup.js @@ -2,7 +2,7 @@ $(function () { // NB: this file is included on multiple pages. In each context, // some of the jQuery selectors below will return empty lists. - $.validator.addMethod('password_strength', function (value, element) { + $.validator.addMethod('password_strength', function (value) { return password_quality(value); }, 'Password is weak.'); @@ -38,7 +38,7 @@ $(function () { $("#send_confirm").validate({ errorElement: "p", - errorPlacement: function (error, element) { + errorPlacement: function (error) { $('#errors').empty(); error.appendTo("#errors") .addClass("text-error"); diff --git a/static/js/stream_list.js b/static/js/stream_list.js index a19b6064fb..13148ea971 100644 --- a/static/js/stream_list.js +++ b/static/js/stream_list.js @@ -370,9 +370,8 @@ exports.update_dom_with_unread_counts = function (counts) { counts.mentioned_message_count); }; -exports.rename_stream = function (sub, new_name) { - // TODO: we don't actually need new_name, since the sub - // will have been updated +exports.rename_stream = function (sub) { + // The sub object is expected to already have the updated name build_stream_sidebar_row(sub); exports.build_stream_list(); // big hammer }; diff --git a/static/js/subs.js b/static/js/subs.js index 73338804fd..63f7c5b62b 100644 --- a/static/js/subs.js +++ b/static/js/subs.js @@ -232,7 +232,6 @@ function stream_audible_notifications_clicked(e) { function stream_pin_clicked(e) { var stream = get_stream_name(e.target); - var sub = stream_data.get_sub(stream); exports.toggle_pin_to_top_stream(stream); } @@ -336,7 +335,7 @@ function show_subscription_settings(sub_row) { list.append(elem); }); }, - error: function (xhr) { + error: function () { loading.destroy_indicator(indicator_elem); error_elem.removeClass("hide").text("Could not fetch subscriber list"); } @@ -365,19 +364,8 @@ function show_subscription_settings(sub_row) { }); var colorpicker = sub_settings.find('.colorpicker'); - var color = stream_data.get_color(sub.name); stream_color.set_colorpicker_color(colorpicker, color); - - // To figure out the worst case for an expanded row's height, we do some math: - // .subscriber_list_container max-height, - // .subscriber_list_settings, - // .regular_subscription_settings - // .subscription_header line-height, - // .subscription_header padding - var expanded_row_size = 200 + 30 + 100 + 30 + 5; - var cover = sub_row.offset().top + expanded_row_size - - viewport.height() + viewport.scrollTop(); } exports.show_settings_for = function (stream_name) { @@ -692,7 +680,7 @@ function ajaxSubscribe(stream) { return channel.post({ url: "/json/users/me/subscriptions", data: {subscriptions: JSON.stringify([{name: stream}]) }, - success: function (resp, statusText, xhr, form) { + success: function (resp, statusText, xhr) { $("#create_stream_name").val(""); actually_filter_streams(); @@ -717,9 +705,7 @@ function ajaxUnsubscribe(stream) { return channel.post({ url: "/json/subscriptions/remove", data: {subscriptions: JSON.stringify([stream]) }, - success: function (resp, statusText, xhr, form) { - var name; - var res = JSON.parse(xhr.responseText); + success: function () { $("#subscriptions-status").hide(); // The rest of the work is done via the unsubscribe event we will get }, @@ -739,7 +725,7 @@ function ajaxSubscribeForCreation(stream, description, principals, invite_only, invite_only: JSON.stringify(invite_only), announce: JSON.stringify(announce) }, - success: function (data) { + success: function () { $("#create_stream_name").val(""); $("#create_stream_description").val(""); $("#subscriptions-status").hide(); @@ -808,7 +794,6 @@ exports.remove_user_from_stream = function (user_email, stream_name, success, fa }; $(function () { - var i; stream_data.initialize_from_page_params(); stream_list.create_initial_sidebar_rows(); @@ -963,11 +948,11 @@ $(function () { $(e.target).removeClass("btn-danger").text(i18n.t("Subscribed")); }); - $(".subscriptions").on("click", "#close-subscriptions-status", function (e) { + $(".subscriptions").on("click", "#close-subscriptions-status", function () { $("#subscriptions-status").hide(); }); - $("#subscriptions_table").on("click", ".email-address", function (e) { + $("#subscriptions_table").on("click", ".email-address", function () { selectText(this); }); @@ -1077,7 +1062,7 @@ $(function () { } } - function invite_failure(xhr) { + function invite_failure() { warning_elem.addClass("hide"); error_elem.removeClass("hide").text("Could not add user to this stream"); } @@ -1144,7 +1129,7 @@ $(function () { } } - function removal_failure(xhr) { + function removal_failure() { warning_elem.addClass("hide"); error_elem.removeClass("hide").text("Could not remove user from this stream"); } @@ -1167,7 +1152,7 @@ $(function () { // Stream names might contain unsafe characters so we must encode it first. url: "/json/streams/" + encodeURIComponent(sub.name), data: {new_name: JSON.stringify(new_name)}, - success: function (data) { + success: function () { new_name_box.val(''); ui.report_success(i18n.t("The stream has been renamed!"), $("#subscriptions-status "), 'subscriptions-status'); @@ -1181,8 +1166,6 @@ $(function () { $('#subscriptions_table').on('submit', '.change-stream-description form', function (e) { e.preventDefault(); - var form = $(e.target); - var sub_settings = $(e.target).closest('.subscription_settings'); var stream_name = get_stream_name(sub_settings); var description = sub_settings.find('input[name="description"]').val(); @@ -1247,7 +1230,7 @@ $(function () { channel.post({ url: url, data: data, - success: function (data) { + success: function () { sub = stream_data.get_sub_by_id(stream_id); var stream_settings = settings_for_sub(sub); var sub_row = $(".stream-row[data-stream-id='" + stream_id + "']"); diff --git a/static/js/tab_bar.js b/static/js/tab_bar.js index d5578ab4f9..76a2372d18 100644 --- a/static/js/tab_bar.js +++ b/static/js/tab_bar.js @@ -37,7 +37,6 @@ function make_tab_data() { if (narrow.active() && narrow.operators().length > 0) { var stream; var ops = narrow.operators(); - var hash = hashchange.operators_to_hash(ops); // Second breadcrumb item var hashed = hashchange.operators_to_hash(ops.slice(0, 1)); if (filter.has_operator("stream")) { @@ -150,10 +149,10 @@ function build_tab_bar() { } $(function () { - $(document).on('narrow_activated.zulip', function (event) { + $(document).on('narrow_activated.zulip', function () { build_tab_bar(); }); - $(document).on('narrow_deactivated.zulip', function (event) { + $(document).on('narrow_deactivated.zulip', function () { build_tab_bar(); }); diff --git a/static/js/typeahead_helper.js b/static/js/typeahead_helper.js index f639fd6ab7..829deddee9 100644 --- a/static/js/typeahead_helper.js +++ b/static/js/typeahead_helper.js @@ -131,10 +131,6 @@ exports.sort_by_pms = function (objs) { return objs; }; -function identity(item) { - return item; -} - exports.sort_recipients = function (matches, query) { var name_results = prefix_sort(query, matches, function (x) { return x.full_name; }); var email_results = prefix_sort(query, name_results.rest, function (x) { return x.email; }); diff --git a/static/js/ui.js b/static/js/ui.js index a470479d5c..2b378e4fbf 100644 --- a/static/js/ui.js +++ b/static/js/ui.js @@ -98,11 +98,9 @@ exports.replace_emoji_with_text = function (element) { var current_message_hover; function message_unhover() { - var message; if (current_message_hover === undefined) { return; } - message = current_msg_list.get(rows.id(current_message_hover)); current_message_hover.find('span.edit_content').html(""); current_message_hover.removeClass('message_hovered'); current_message_hover = undefined; @@ -172,15 +170,6 @@ exports.report_success = function (response, status_box, type) { ui.report_message(response, status_box, 'alert-success', type); }; -function need_skinny_mode() { - if (window.matchMedia !== undefined) { - return window.matchMedia("(max-width: 767px)").matches; - } - // IE<10 doesn't support window.matchMedia, so do this - // as best we can without it. - return window.innerWidth <= 767; -} - function update_message_in_all_views(message_id, callback) { _.each([message_list.all, home_msg_list, message_list.narrowed], function (list) { if (list === undefined) { @@ -315,7 +304,7 @@ exports.lightbox_photo = function (image, user) { $(".image-actions .open, .image-actions .download").attr("href", url); }; -exports.exit_lightbox_photo = function (image) { +exports.exit_lightbox_photo = function () { $("#overlay").removeClass("show"); $(".player-container iframe").remove(); document.activeElement.blur(); @@ -451,30 +440,30 @@ $(function () { $("#navbar-buttons").addClass("right-userlist"); } - $("#main_div").on("mouseover", ".message_row", function (e) { + $("#main_div").on("mouseover", ".message_row", function () { var row = $(this).closest(".message_row"); message_hover(row); }); - $("#main_div").on("mouseleave", ".message_row", function (e) { + $("#main_div").on("mouseleave", ".message_row", function () { message_unhover(); }); - $("#main_div").on("mouseover", ".message_sender", function (e) { + $("#main_div").on("mouseover", ".message_sender", function () { var row = $(this).closest(".message_row"); row.addClass("sender_name_hovered"); }); - $("#main_div").on("mouseout", ".message_sender", function (e) { + $("#main_div").on("mouseout", ".message_sender", function () { var row = $(this).closest(".message_row"); row.removeClass("sender_name_hovered"); }); - $("#subscriptions_table").on("mouseover", ".subscription_header", function (e) { + $("#subscriptions_table").on("mouseover", ".subscription_header", function () { $(this).addClass("active"); }); - $("#subscriptions_table").on("mouseout", ".subscription_header", function (e) { + $("#subscriptions_table").on("mouseout", ".subscription_header", function () { $(this).removeClass("active"); }); @@ -574,8 +563,6 @@ $(function () { }); -var scroll_start_message; - function scroll_finished() { actively_scrolling = false; @@ -613,7 +600,7 @@ function scroll_finish() { var saved_compose_cursor = 0; $(function () { - viewport.message_pane.scroll($.throttle(50, function (e) { + viewport.message_pane.scroll($.throttle(50, function () { unread.process_visible(); scroll_finish(); })); diff --git a/static/js/unread.js b/static/js/unread.js index 2091014221..6c7abf9c3f 100644 --- a/static/js/unread.js +++ b/static/js/unread.js @@ -327,7 +327,7 @@ exports.mark_message_as_read = function mark_message_as_read(message, options) { // If we ever materially change the algorithm for this function, we // may need to update notifications.received_messages as well. -exports.process_visible = function process_visible(update_cursor) { +exports.process_visible = function process_visible() { if (! notifications.window_has_focus()) { return; }