diff --git a/static/js/buddy_list.js b/static/js/buddy_list.js index 6f704238d8..033955735e 100644 --- a/static/js/buddy_list.js +++ b/static/js/buddy_list.js @@ -28,8 +28,7 @@ function buddy_list_conf() { }; conf.get_key_from_li = function (opts) { - const str_user_id = opts.li.expectOne().attr('data-user-id'); - return parseInt(str_user_id, 10); + return parseInt(opts.li.expectOne().attr('data-user-id'), 10); }; conf.get_data_from_keys = function (opts) { diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js index afd4d5fcea..e10636c24f 100644 --- a/static/js/click_handlers.js +++ b/static/js/click_handlers.js @@ -499,8 +499,8 @@ exports.initialize = function () { $('#user_presences').on('mouseenter', '.user-presence-link, .user_sidebar_entry .user_circle, .user_sidebar_entry .selectable_sidebar_block', function (e) { e.stopPropagation(); const elem = $(e.currentTarget).closest(".user_sidebar_entry").find(".user-presence-link"); - const user_id = elem.attr('data-user-id'); - const title_data = buddy_data.get_title_data(user_id, false); + const user_id_string = elem.attr('data-user-id'); + const title_data = buddy_data.get_title_data(user_id_string, false); do_render_buddy_list_tooltip(elem, title_data); }); diff --git a/static/js/message_list_view.js b/static/js/message_list_view.js index 2a4da78af7..a7e30baeb0 100644 --- a/static/js/message_list_view.js +++ b/static/js/message_list_view.js @@ -20,17 +20,17 @@ function MessageListView(list, table_name, collapse_messages) { } function get_user_id_for_mention_button(elem) { - const user_id = $(elem).attr('data-user-id'); + const user_id_string = $(elem).attr('data-user-id'); // Handle legacy markdown that was rendered before we cut // over to using data-user-id. const email = $(elem).attr('data-user-email'); - if (user_id === "*" || email === "*") { + if (user_id_string === "*" || email === "*") { return "*"; } - if (user_id) { - return parseInt(user_id, 10); + if (user_id_string) { + return parseInt(user_id_string, 10); } if (email) { diff --git a/static/js/people.js b/static/js/people.js index 00916df56e..c030e9aaa6 100644 --- a/static/js/people.js +++ b/static/js/people.js @@ -245,7 +245,6 @@ exports.get_user_time = function (user_id) { }; exports.get_user_type = function (user_id) { - user_id = parseInt(user_id, 10); const user_profile = exports.get_person_from_user_id(user_id); if (user_profile.is_admin) { diff --git a/static/js/popovers.js b/static/js/popovers.js index b22bd9022a..bf597b5e41 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -720,19 +720,19 @@ exports.register_click_handlers = function () { }); $("#main_div").on("click", ".user-mention", function (e) { - const id = $(this).attr('data-user-id'); + const id_string = $(this).attr('data-user-id'); // We fallback to email to handle legacy markdown that was rendered // before we cut over to using data-user-id const email = $(this).attr('data-user-email'); - if (id === '*' || email === '*') { + if (id_string === '*' || email === '*') { return; } const row = $(this).closest(".message_row"); e.stopPropagation(); const message = current_msg_list.get(rows.id(row)); let user; - if (id) { - const user_id = parseInt(id, 10); + if (id_string) { + const user_id = parseInt(id_string, 10); user = people.get_person_from_user_id(user_id); } else { user = people.get_by_email(email); @@ -741,7 +741,7 @@ exports.register_click_handlers = function () { }); $("#main_div").on("click", ".user-group-mention", function (e) { - const id = $(this).attr('data-user-group-id'); + const id = parseInt($(this).attr('data-user-group-id'), 10); const row = $(this).closest(".message_row"); e.stopPropagation(); const message = current_msg_list.get(rows.id(row)); diff --git a/static/js/settings_bots.js b/static/js/settings_bots.js index b4e8c09ca5..aef9727871 100644 --- a/static/js/settings_bots.js +++ b/static/js/settings_bots.js @@ -341,7 +341,7 @@ exports.set_up = function () { }); $("#active_bots_list").on("click", "button.delete_bot", function (e) { - const bot_id = $(e.currentTarget).attr('data-user-id'); + const bot_id = parseInt($(e.currentTarget).attr('data-user-id'), 10); channel.del({ url: '/json/bots/' + encodeURIComponent(bot_id), @@ -356,7 +356,7 @@ exports.set_up = function () { }); $("#inactive_bots_list").on("click", "button.reactivate_bot", function (e) { - const user_id = $(e.currentTarget).attr('data-user-id'); + const user_id = parseInt($(e.currentTarget).attr('data-user-id'), 10); channel.post({ url: '/json/users/' + encodeURIComponent(user_id) + "/reactivate", @@ -367,7 +367,7 @@ exports.set_up = function () { }); $("#active_bots_list").on("click", "button.regenerate_bot_api_key", function (e) { - const bot_id = $(e.currentTarget).attr('data-user-id'); + const bot_id = parseInt($(e.currentTarget).attr('data-user-id'), 10); channel.post({ url: '/json/bots/' + encodeURIComponent(bot_id) + '/api_key/regenerate', idempotent: true, @@ -387,7 +387,7 @@ exports.set_up = function () { $("#active_bots_list").on("click", "button.open_edit_bot_form", function (e) { const li = $(e.currentTarget).closest('li'); - const bot_id = li.find('.bot_info').attr('data-user-id').valueOf(); + const bot_id = parseInt(li.find('.bot_info').attr('data-user-id'), 10); const bot = bot_data.get(bot_id); const users_list = people.get_active_human_persons(); $("#edit_bot").empty(); @@ -422,7 +422,7 @@ exports.set_up = function () { errors.hide(); }, submitHandler: function () { - const bot_id = form.attr('data-user-id'); + const bot_id = parseInt(form.attr('data-user-id'), 10); const type = form.attr('data-type'); const full_name = form.find('.edit_bot_name').val(); @@ -485,7 +485,7 @@ exports.set_up = function () { $("#active_bots_list").on("click", "a.download_bot_zuliprc", function () { const bot_info = $(this).closest(".bot-information-box").find(".bot_info"); - const bot_id = bot_info.attr("data-user-id"); + const bot_id = parseInt(bot_info.attr("data-user-id"), 10); $(this).attr("href", exports.generate_zuliprc_uri(bot_id)); }); diff --git a/static/js/settings_users.js b/static/js/settings_users.js index b0cb222d1e..f7ec099478 100644 --- a/static/js/settings_users.js +++ b/static/js/settings_users.js @@ -371,7 +371,7 @@ exports.on_load_success = function (realm_people_data) { const button_elem = $(e.target); const row = button_elem.closest(".user_row"); - const bot_id = row.attr("data-user-id"); + const bot_id = parseInt(row.attr("data-user-id"), 10); const url = '/json/bots/' + encodeURIComponent(bot_id); const opts = { @@ -393,7 +393,7 @@ exports.on_load_success = function (realm_people_data) { // Go up the tree until we find the user row, then grab the email element const button_elem = $(e.target); const row = button_elem.closest(".user_row"); - const user_id = row.attr("data-user-id"); + const user_id = parseInt(row.attr("data-user-id"), 10); const url = '/json/users/' + encodeURIComponent(user_id) + "/reactivate"; const data = {}; const status = get_status_field(); diff --git a/static/js/stream_create.js b/static/js/stream_create.js index d42afc714e..3388de25f3 100644 --- a/static/js/stream_create.js +++ b/static/js/stream_create.js @@ -288,8 +288,7 @@ exports.show_new_stream_modal = function () { $('#user-checkboxes label.checkbox').each(function () { const user_elem = $(this); - const str_user_id = user_elem.attr('data-user-id'); - const user_id = parseInt(str_user_id, 10); + const user_id = parseInt(user_elem.attr('data-user-id'), 10); if (subscriber_ids.has(user_id)) { user_elem.find('input').prop('checked', checked);