Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

eslint: Fix unicorn/prefer-number-properties.

Anders Kaseorgfb233bd994f9
diff --git a/static/js/archive.js b/static/js/archive.js
index 993d78885c7..744c15ec718 100644
--- a/static/js/archive.js
+++ b/static/js/archive.js
@@ -13,7 +13,7 @@ function should_separate_into_groups(current_msg_time, next_msg_time) {
function all_message_timestamps_to_human_readable() {
$(".message_time").each(function () {
- const time = new XDate(parseInt($(this).text(), 10) * 1000);
+ const time = new XDate(Number.parseInt($(this).text(), 10) * 1000);
$(this).text(time.toString("h:mm TT"));
});
}
@@ -54,8 +54,11 @@ exports.initialize = function () {
$(".message_row").each(function () {
const current_message_row = $(this);
- const cur_msg_time = parseInt(current_message_row.find(".message_time").first().html(), 10);
- const next_msg_time = parseInt(
+ const cur_msg_time = Number.parseInt(
+ current_message_row.find(".message_time").first().html(),
+ 10,
+ );
+ const next_msg_time = Number.parseInt(
current_message_row.next().find(".message_time").first().html(),
10,
);
@@ -117,7 +120,7 @@ exports.rows = {
return $("div.message_row", message_group).first();
},
id(message_row) {
- return parseFloat(message_row.attr("zid"));
+ return Number.parseFloat(message_row.attr("zid"));
},
};
diff --git a/static/js/attachments_ui.js b/static/js/attachments_ui.js
index fca9190765c..f4d772068c1 100644
--- a/static/js/attachments_ui.js
+++ b/static/js/attachments_ui.js
@@ -17,7 +17,7 @@ exports.bytes_to_size = function (bytes, kb_with_1024_bytes) {
if (bytes === 0) {
return "0 B";
}
- const i = parseInt(Math.floor(Math.log(bytes) / Math.log(kb_size)), 10);
+ const i = Number.parseInt(Math.floor(Math.log(bytes) / Math.log(kb_size)), 10);
let size = Math.round(bytes / Math.pow(kb_size, i));
if (i > 0 && size < 10) {
size = Math.round((bytes / Math.pow(kb_size, i)) * 10) / 10;
diff --git a/static/js/buddy_data.js b/static/js/buddy_data.js
index e8863eb2028..ba15d8781f3 100644
--- a/static/js/buddy_data.js
+++ b/static/js/buddy_data.js
@@ -214,7 +214,7 @@ exports.get_title_data = function (user_ids_string, is_group) {
}
// Since it's not a group, user_ids_string is a single user ID.
- const user_id = parseInt(user_ids_string, 10);
+ const user_id = Number.parseInt(user_ids_string, 10);
const person = people.get_by_user_id(user_id);
if (person.is_bot) {
@@ -333,7 +333,7 @@ exports.get_items_for_users = function (user_ids) {
};
exports.huddle_fraction_present = function (huddle) {
- const user_ids = huddle.split(",").map((s) => parseInt(s, 10));
+ const user_ids = huddle.split(",").map((s) => Number.parseInt(s, 10));
let num_present = 0;
diff --git a/static/js/buddy_list.js b/static/js/buddy_list.js
index 6960bb2b417..3c231b6372e 100644
--- a/static/js/buddy_list.js
+++ b/static/js/buddy_list.js
@@ -28,7 +28,7 @@ class BuddyListConf {
}
get_key_from_li(opts) {
- return parseInt(opts.li.expectOne().attr("data-user-id"), 10);
+ return Number.parseInt(opts.li.expectOne().attr("data-user-id"), 10);
}
get_data_from_keys(opts) {
diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js
index 4e1358fda0e..c5e3cb4b19f 100644
--- a/static/js/click_handlers.js
+++ b/static/js/click_handlers.js
@@ -252,7 +252,7 @@ exports.initialize = function () {
e.preventDefault();
// Note that we may have an href here, but we trust the stream id more,
// so we re-encode the hash.
- const stream_id = parseInt($(this).attr("data-stream-id"), 10);
+ const stream_id = Number.parseInt($(this).attr("data-stream-id"), 10);
if (stream_id) {
hashchange.go_to_location(hash_util.by_stream_uri(stream_id));
return;
@@ -392,7 +392,7 @@ exports.initialize = function () {
$("body").on("click", ".on_hover_topic_mute", (e) => {
e.stopPropagation();
- const stream_id = parseInt($(e.currentTarget).attr("data-stream-id"), 10);
+ const stream_id = Number.parseInt($(e.currentTarget).attr("data-stream-id"), 10);
const topic = $(e.currentTarget).attr("data-topic-name");
muting_ui.mute(stream_id, topic);
});
@@ -401,7 +401,7 @@ exports.initialize = function () {
$("body").on("click", ".on_hover_topic_unmute", (e) => {
e.stopPropagation();
- const stream_id = parseInt($(e.currentTarget).attr("data-stream-id"), 10);
+ const stream_id = Number.parseInt($(e.currentTarget).attr("data-stream-id"), 10);
const topic = $(e.currentTarget).attr("data-topic-name");
muting_ui.unmute(stream_id, topic);
});
@@ -417,7 +417,7 @@ exports.initialize = function () {
$("body").on("click", ".on_hover_topic_read", (e) => {
e.stopPropagation();
- const stream_id = parseInt($(e.currentTarget).attr("data-stream-id"), 10);
+ const stream_id = Number.parseInt($(e.currentTarget).attr("data-stream-id"), 10);
const topic = $(e.currentTarget).attr("data-topic-name");
unread_ops.mark_topic_as_read(stream_id, topic);
});
diff --git a/static/js/colorspace.js b/static/js/colorspace.js
index 3096f46e624..5b2d6027ddd 100644
--- a/static/js/colorspace.js
+++ b/static/js/colorspace.js
@@ -35,9 +35,9 @@ exports.luminance_to_lightness = function (luminance) {
exports.getDecimalColor = function (hexcolor) {
return {
- r: parseInt(hexcolor.substr(1, 2), 16),
- g: parseInt(hexcolor.substr(3, 2), 16),
- b: parseInt(hexcolor.substr(5, 2), 16),
+ r: Number.parseInt(hexcolor.substr(1, 2), 16),
+ g: Number.parseInt(hexcolor.substr(3, 2), 16),
+ b: Number.parseInt(hexcolor.substr(5, 2), 16),
};
};
@@ -52,9 +52,9 @@ exports.getLighterColor = function (rgb, lightness) {
exports.getHexColor = function (rgb) {
return (
"#" +
- parseInt(rgb.r, 10).toString(16) +
- parseInt(rgb.g, 10).toString(16) +
- parseInt(rgb.b, 10).toString(16)
+ Number.parseInt(rgb.r, 10).toString(16) +
+ Number.parseInt(rgb.g, 10).toString(16) +
+ Number.parseInt(rgb.b, 10).toString(16)
);
};
diff --git a/static/js/compose.js b/static/js/compose.js
index 3e4aeaf2e76..be52cab0c98 100644
--- a/static/js/compose.js
+++ b/static/js/compose.js
@@ -972,7 +972,7 @@ exports.warn_if_mentioning_unsubscribed_user = function (mentioned) {
const existing_invites_area = $("#compose_invite_users .compose_invite_user");
const existing_invites = Array.from($(existing_invites_area), (user_row) =>
- parseInt($(user_row).data("user-id"), 10),
+ Number.parseInt($(user_row).data("user-id"), 10),
);
if (!existing_invites.includes(user_id)) {
@@ -1056,8 +1056,8 @@ exports.initialize = function () {
const invite_row = $(event.target).parents(".compose_invite_user");
- const user_id = parseInt($(invite_row).data("user-id"), 10);
- const stream_id = parseInt($(invite_row).data("stream-id"), 10);
+ const user_id = Number.parseInt($(invite_row).data("user-id"), 10);
+ const stream_id = Number.parseInt($(invite_row).data("stream-id"), 10);
function success() {
const all_invites = $("#compose_invite_users");
diff --git a/static/js/echo.js b/static/js/echo.js
index a66a90bade5..0d86406bb6a 100644
--- a/static/js/echo.js
+++ b/static/js/echo.js
@@ -276,7 +276,7 @@ exports.reify_message_id = function (local_id, server_id) {
message.id = server_id;
message.locally_echoed = false;
- const opts = {old_id: parseFloat(local_id), new_id: server_id};
+ const opts = {old_id: Number.parseFloat(local_id), new_id: server_id};
message_store.reify_message_id(opts);
notifications.reify_message_id(opts);
diff --git a/static/js/emoji_picker.js b/static/js/emoji_picker.js
index 2ee7a808b80..daf6f49a595 100644
--- a/static/js/emoji_picker.js
+++ b/static/js/emoji_picker.js
@@ -75,8 +75,8 @@ function get_emoji_coordinates(emoji_id) {
// See `get_emoji_id()`.
const emoji_info = emoji_id.split(",");
return {
- section: parseInt(emoji_info[1], 10),
- index: parseInt(emoji_info[2], 10),
+ section: Number.parseInt(emoji_info[1], 10),
+ index: Number.parseInt(emoji_info[2], 10),
};
}
diff --git a/static/js/invite.js b/static/js/invite.js
index 1099986a5a5..00c27e6b25b 100644
--- a/static/js/invite.js
+++ b/static/js/invite.js
@@ -18,10 +18,10 @@ function reset_error_messages() {
}
function get_common_invitation_data() {
- const invite_as = parseInt($("#invite_as").val(), 10);
+ const invite_as = Number.parseInt($("#invite_as").val(), 10);
const stream_ids = [];
$("#invite-stream-checkboxes input:checked").each(function () {
- const stream_id = parseInt($(this).val(), 10);
+ const stream_id = Number.parseInt($(this).val(), 10);
stream_ids.push(stream_id);
});
const data = {
diff --git a/static/js/lazy_set.js b/static/js/lazy_set.js
index 4b765f1dc3d..d0999482e29 100644
--- a/static/js/lazy_set.js
+++ b/static/js/lazy_set.js
@@ -74,7 +74,7 @@ export class LazySet {
_clean(v) {
if (typeof v !== "number") {
blueslip.error("not a number");
- return parseInt(v, 10);
+ return Number.parseInt(v, 10);
}
return v;
}
diff --git a/static/js/list_render.js b/static/js/list_render.js
index da22b6d6bbe..2600c0e0281 100644
--- a/static/js/list_render.js
+++ b/static/js/list_render.js
@@ -82,9 +82,9 @@ exports.alphabetic_sort = (prop) =>
exports.numeric_sort = (prop) =>
function (a, b) {
- if (parseFloat(a[prop]) > parseFloat(b[prop])) {
+ if (Number.parseFloat(a[prop]) > Number.parseFloat(b[prop])) {
return 1;
- } else if (parseFloat(a[prop]) === parseFloat(b[prop])) {
+ } else if (Number.parseFloat(a[prop]) === Number.parseFloat(b[prop])) {
return 0;
}
diff --git a/static/js/local_message.js b/static/js/local_message.js
index f984e908e25..1dc572a151b 100644
--- a/static/js/local_message.js
+++ b/static/js/local_message.js
@@ -3,7 +3,7 @@
const XDate = require("xdate");
function truncate_precision(float) {
- return parseFloat(float.toFixed(3));
+ return Number.parseFloat(float.toFixed(3));
}
exports.now = function () {
diff --git a/static/js/markdown.js b/static/js/markdown.js
index 7fabe754b70..945c3e97e5e 100644
--- a/static/js/markdown.js
+++ b/static/js/markdown.js
@@ -128,7 +128,7 @@ exports.apply_markdown = function (message) {
misfeature).
*/
full_name = match[1];
- user_id = parseInt(match[2], 10);
+ user_id = Number.parseInt(match[2], 10);
if (!helpers.is_valid_full_name_and_user_id(full_name, user_id)) {
user_id = undefined;
@@ -316,7 +316,7 @@ function handleEmoji(emoji_name) {
function handleTimestamp(time) {
let timeobject;
- if (isNaN(time)) {
+ if (Number.isNaN(Number(time))) {
// Moment throws a large deprecation warning when it has to fallback
// to the Date() constructor. We needn't worry here and can let backend
// Markdown handle any dates that moment misses.
diff --git a/static/js/message_edit.js b/static/js/message_edit.js
index ba755bdd210..c516b1b05ec 100644
--- a/static/js/message_edit.js
+++ b/static/js/message_edit.js
@@ -359,7 +359,7 @@ function edit_message(row, raw_content) {
ui_util.decorate_stream_bar(message.stream, stream_header_colorblock, false);
message_edit_stream.on("change", function () {
- const stream_name = stream_data.maybe_get_stream_name(parseInt(this.value, 10));
+ const stream_name = stream_data.maybe_get_stream_name(Number.parseInt(this.value, 10));
ui_util.decorate_stream_bar(stream_name, stream_header_colorblock, false);
});
@@ -483,7 +483,7 @@ function edit_message(row, raw_content) {
const original_topic = message.topic;
function set_propagate_selector_display() {
const new_topic = message_edit_topic.val();
- const new_stream_id = parseInt(message_edit_stream.val(), 10);
+ const new_stream_id = Number.parseInt(message_edit_stream.val(), 10);
const is_topic_edited = new_topic !== original_topic && new_topic !== "";
const is_stream_edited = new_stream_id !== original_stream_id;
message_edit_topic_propagate.toggle(is_topic_edited || is_stream_edited);
@@ -670,7 +670,7 @@ exports.save_message_row_edit = function (row) {
new_topic = row.find(".message_edit_topic").val();
topic_changed = new_topic !== old_topic && new_topic.trim() !== "";
- new_stream_id = parseInt($("#select_stream_id_" + message_id).val(), 10);
+ new_stream_id = Number.parseInt($("#select_stream_id_" + message_id).val(), 10);
stream_changed = new_stream_id !== old_stream_id;
}
// Editing a not-yet-acked message (because the original send attempt failed)
diff --git a/static/js/message_events.js b/static/js/message_events.js
index 5fc02004047..9e27bd32466 100644
--- a/static/js/message_events.js
+++ b/static/js/message_events.js
@@ -357,7 +357,7 @@ exports.update_messages = function update_messages(events) {
// Rerender "Message edit history" if it was open to the edited message.
if (
$("#message-edit-history").hasClass("in") &&
- msg.id === parseInt($("#message-history").attr("data-message-id"), 10)
+ msg.id === Number.parseInt($("#message-history").attr("data-message-id"), 10)
) {
message_edit_history.fetch_and_render_message_history(msg);
}
diff --git a/static/js/message_list.js b/static/js/message_list.js
index 4df7ef0ecce..8dee053a9e5 100644
--- a/static/js/message_list.js
+++ b/static/js/message_list.js
@@ -150,8 +150,8 @@ class MessageList {
};
const convert_id = (str_id) => {
- const id = parseFloat(str_id);
- if (isNaN(id)) {
+ const id = Number.parseFloat(str_id);
+ if (Number.isNaN(id)) {
throw new Error("Bad message id " + str_id);
}
return id;
diff --git a/static/js/message_list_data.js b/static/js/message_list_data.js
index 2c89c626211..410be073953 100644
--- a/static/js/message_list_data.js
+++ b/static/js/message_list_data.js
@@ -119,8 +119,8 @@ class MessageListData {
}
get(id) {
- id = parseFloat(id);
- if (isNaN(id)) {
+ id = Number.parseFloat(id);
+ if (Number.isNaN(id)) {
return undefined;
}
return this._hash.get(id);
@@ -342,7 +342,7 @@ class MessageListData {
const effective = this._next_nonlocal_message(this._items, a_idx, (idx) => idx - 1);
if (effective) {
// Turn the 10.02 in [11, 10.02, 12] into 11.02
- const decimal = parseFloat((msg.id % 1).toFixed(0.02));
+ const decimal = Number.parseFloat((msg.id % 1).toFixed(0.02));
const effective_id = effective.id + decimal;
return effective_id < ref_id;
}
@@ -440,8 +440,8 @@ class MessageListData {
_add_to_hash(messages) {
messages.forEach((elem) => {
- const id = parseFloat(elem.id);
- if (isNaN(id)) {
+ const id = Number.parseFloat(elem.id);
+ if (Number.isNaN(id)) {
throw new Error("Bad message id");
}
if (this._is_localonly_id(id)) {
diff --git a/static/js/message_store.js b/static/js/message_store.js
index eb4cf782e7f..09126785865 100644
--- a/static/js/message_store.js
+++ b/static/js/message_store.js
@@ -36,7 +36,7 @@ exports.get = function get(message_id) {
// Try to soldier on, assuming the caller treats message
// ids as strings.
- message_id = parseFloat(message_id);
+ message_id = Number.parseFloat(message_id);
}
return stored_messages.get(message_id);
diff --git a/static/js/message_view_header.js b/static/js/message_view_header.js
index a3b970b4952..1cfa59dcee1 100644
--- a/static/js/message_view_header.js
+++ b/static/js/message_view_header.js
@@ -13,7 +13,7 @@ function get_formatted_sub_count(current_stream) {
let sub_count = get_sub_count(current_stream);
if (sub_count >= 1000) {
// parseInt() is used to floor the value of division to an integer
- sub_count = parseInt(sub_count / 1000, 10) + "k";
+ sub_count = Number.parseInt(sub_count / 1000, 10) + "k";
}
return sub_count;
}
diff --git a/static/js/narrow.js b/static/js/narrow.js
index d174796e863..21116f68f61 100644
--- a/static/js/narrow.js
+++ b/static/js/narrow.js
@@ -190,10 +190,10 @@ exports.activate = function (raw_operators, opts) {
// These two narrowing operators specify what message should be
// selected and should be the center of the narrow.
if (filter.has_operator("near")) {
- id_info.target_id = parseInt(filter.operands("near")[0], 10);
+ id_info.target_id = Number.parseInt(filter.operands("near")[0], 10);
}
if (filter.has_operator("id")) {
- id_info.target_id = parseInt(filter.operands("id")[0], 10);
+ id_info.target_id = Number.parseInt(filter.operands("id")[0], 10);
}
if (opts.then_select_id > 0) {
diff --git a/static/js/panels.js b/static/js/panels.js
index 050ef6562f2..1d8fbfc0827 100644
--- a/static/js/panels.js
+++ b/static/js/panels.js
@@ -9,7 +9,9 @@ const resize_app = function () {
// the floating recipient bar is usually positioned right below
// the `.header` element (including padding).
const frb_top =
- panels_height + $(".header").height() + parseInt($(".header").css("paddingBottom"), 10);
+ panels_height +
+ $(".header").height() +
+ Number.parseInt($(".header").css("paddingBottom"), 10);
$("#floating_recipient_bar").css("top", frb_top + "px");
};
diff --git a/static/js/people.js b/static/js/people.js
index b0a52c7475a..5a0641af202 100644
--- a/static/js/people.js
+++ b/static/js/people.js
@@ -45,7 +45,7 @@ export function init() {
init();
function split_to_ints(lst) {
- return lst.split(",").map((s) => parseInt(s, 10));
+ return lst.split(",").map((s) => Number.parseInt(s, 10));
}
export function get_by_user_id(user_id, ignore_missing) {
@@ -1298,7 +1298,7 @@ export function is_my_user_id(user_id) {
if (typeof user_id !== "number") {
blueslip.error("user_id is a string in my_user_id: " + user_id);
- user_id = parseInt(user_id, 10);
+ user_id = Number.parseInt(user_id, 10);
}
return user_id === my_user_id;
diff --git a/static/js/pm_list.js b/static/js/pm_list.js
index 19f8ff90324..17d9b9cbe49 100644
--- a/static/js/pm_list.js
+++ b/static/js/pm_list.js
@@ -79,7 +79,7 @@ exports._get_convos = function () {
user_circle_class = "user_circle_fraction";
fraction_present = buddy_data.huddle_fraction_present(user_ids_string);
} else {
- const user_id = parseInt(user_ids_string, 10);
+ const user_id = Number.parseInt(user_ids_string, 10);
user_circle_class = buddy_data.get_user_circle_class(user_id);
const recipient_user_obj = people.get_by_user_id(user_id);
diff --git a/static/js/popovers.js b/static/js/popovers.js
index 088dc440992..980b1b12ae4 100644
--- a/static/js/popovers.js
+++ b/static/js/popovers.js
@@ -32,7 +32,7 @@ let userlist_placement = "right";
let list_of_popovers = [];
function elem_to_user_id(elem) {
- return parseInt(elem.attr("data-user-id"), 10);
+ return Number.parseInt(elem.attr("data-user-id"), 10);
}
// this utilizes the proxy pattern to intercept all calls to $.fn.popover
@@ -861,7 +861,7 @@ exports.register_click_handlers = function () {
const message = current_msg_list.get(rows.id(row));
let user;
if (id_string) {
- const user_id = parseInt(id_string, 10);
+ const user_id = Number.parseInt(id_string, 10);
user = people.get_by_user_id(user_id);
} else {
user = people.get_by_email(email);
@@ -870,7 +870,7 @@ exports.register_click_handlers = function () {
});
$("#main_div").on("click", ".user-group-mention", function (e) {
- const user_group_id = parseInt($(this).attr("data-user-group-id"), 10);
+ const user_group_id = Number.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));
@@ -983,7 +983,7 @@ exports.register_click_handlers = function () {
});
$("body").on("click", ".view_user_profile", (e) => {
- const user_id = parseInt($(e.target).attr("data-user-id"), 10);
+ const user_id = Number.parseInt($(e.target).attr("data-user-id"), 10);
const user = people.get_by_user_id(user_id);
exports.show_user_info_popover(e.target, user);
e.stopPropagation();
@@ -1195,7 +1195,7 @@ exports.register_click_handlers = function () {
});
$("body").on("click", ".popover_mute_topic", (e) => {
- const stream_id = parseInt($(e.currentTarget).attr("data-msg-stream-id"), 10);
+ const stream_id = Number.parseInt($(e.currentTarget).attr("data-msg-stream-id"), 10);
const topic = $(e.currentTarget).attr("data-msg-topic");
exports.hide_actions_popover();
@@ -1205,7 +1205,7 @@ exports.register_click_handlers = function () {
});
$("body").on("click", ".popover_unmute_topic", (e) => {
- const stream_id = parseInt($(e.currentTarget).attr("data-msg-stream-id"), 10);
+ const stream_id = Number.parseInt($(e.currentTarget).attr("data-msg-stream-id"), 10);
const topic = $(e.currentTarget).attr("data-msg-topic");
exports.hide_actions_popover();
diff --git a/static/js/portico/desktop-login.js b/static/js/portico/desktop-login.js
index 66dba54a347..a676733253f 100644
--- a/static/js/portico/desktop-login.js
+++ b/static/js/portico/desktop-login.js
@@ -16,7 +16,7 @@ async function decrypt_manual() {
document.querySelector("#submit").disabled = tokenElement.value === "";
try {
const data = new Uint8Array(
- tokenElement.value.match(/../g).map((b) => parseInt(b, 16)),
+ tokenElement.value.match(/../g).map((b) => Number.parseInt(b, 16)),
);
const iv = data.slice(0, 12);
const ciphertext = data.slice(12);
diff --git a/static/js/presence.js b/static/js/presence.js
index 7c632527189..07e229a92ea 100644
--- a/static/js/presence.js
+++ b/static/js/presence.js
@@ -157,7 +157,7 @@ exports.set_info = function (presences, server_timestamp) {
raw_info.clear();
exports.presence_info.clear();
for (const [user_id_str, info] of Object.entries(presences)) {
- const user_id = parseInt(user_id_str, 10);
+ const user_id = Number.parseInt(user_id_str, 10);
// Note: In contrast with all other state updates received
// receive from the server, presence data is updated via a
diff --git a/static/js/reload.js b/static/js/reload.js
index 837f3502d91..98f434ebbdc 100644
--- a/static/js/reload.js
+++ b/static/js/reload.js
@@ -126,7 +126,7 @@ exports.initialize = function () {
}
if (vars.msg !== undefined) {
- const send_now = parseInt(vars.send_after_reload, 10);
+ const send_now = Number.parseInt(vars.send_after_reload, 10);
try {
// TODO: preserve focus
@@ -148,21 +148,21 @@ exports.initialize = function () {
}
}
- const pointer = parseInt(vars.pointer, 10);
+ const pointer = Number.parseInt(vars.pointer, 10);
if (pointer) {
page_params.initial_pointer = pointer;
}
- const offset = parseInt(vars.offset, 10);
+ const offset = Number.parseInt(vars.offset, 10);
if (offset) {
page_params.initial_offset = offset;
}
- const narrow_pointer = parseInt(vars.narrow_pointer, 10);
+ const narrow_pointer = Number.parseInt(vars.narrow_pointer, 10);
if (narrow_pointer) {
page_params.initial_narrow_pointer = narrow_pointer;
}
- const narrow_offset = parseInt(vars.narrow_offset, 10);
+ const narrow_offset = Number.parseInt(vars.narrow_offset, 10);
if (narrow_offset) {
page_params.initial_narrow_offset = narrow_offset;
}
diff --git a/static/js/rendered_markdown.js b/static/js/rendered_markdown.js
index 40a70b7679c..6e17ddd3788 100644
--- a/static/js/rendered_markdown.js
+++ b/static/js/rendered_markdown.js
@@ -31,7 +31,7 @@ function get_user_id_for_mention_button(elem) {
}
if (user_id_string) {
- return parseInt(user_id_string, 10);
+ return Number.parseInt(user_id_string, 10);
}
if (email) {
@@ -48,7 +48,7 @@ function get_user_group_id_for_mention_button(elem) {
const user_group_id = $(elem).attr("data-user-group-id");
if (user_group_id) {
- return parseInt(user_group_id, 10);
+ return Number.parseInt(user_group_id, 10);
}
return undefined;
@@ -116,7 +116,7 @@ exports.update_elements = (content) => {
});
content.find("a.stream").each(function () {
- const stream_id = parseInt($(this).attr("data-stream-id"), 10);
+ const stream_id = Number.parseInt($(this).attr("data-stream-id"), 10);
if (stream_id && !$(this).find(".highlight").length) {
// Display the current name for stream if it is not
// being displayed in search highlight.
@@ -131,7 +131,7 @@ exports.update_elements = (content) => {
});
content.find("a.stream-topic").each(function () {
- const stream_id = parseInt($(this).attr("data-stream-id"), 10);
+ const stream_id = Number.parseInt($(this).attr("data-stream-id"), 10);
if (stream_id && !$(this).find(".highlight").length) {
// Display the current name for stream if it is not
// being displayed in search highlight.
diff --git a/static/js/resize.js b/static/js/resize.js
index 50c90331816..3a57ee87ac5 100644
--- a/static/js/resize.js
+++ b/static/js/resize.js
@@ -42,9 +42,9 @@ function get_new_heights() {
res.stream_filters_max_height =
viewport_height -
- parseInt($("#left-sidebar").css("marginTop"), 10) -
- parseInt($(".narrows_panel").css("marginTop"), 10) -
- parseInt($(".narrows_panel").css("marginBottom"), 10) -
+ Number.parseInt($("#left-sidebar").css("marginTop"), 10) -
+ Number.parseInt($(".narrows_panel").css("marginTop"), 10) -
+ Number.parseInt($(".narrows_panel").css("marginBottom"), 10) -
$("#global_filters").safeOuterHeight(true) -
$("#streams_header").safeOuterHeight(true);
@@ -55,7 +55,7 @@ function get_new_heights() {
const usable_height =
viewport_height -
- parseInt($("#right-sidebar").css("marginTop"), 10) -
+ Number.parseInt($("#right-sidebar").css("marginTop"), 10) -
$("#userlist-header").safeOuterHeight(true) -
$("#user_search_section").safeOuterHeight(true) -
invite_user_link_height -
@@ -87,14 +87,14 @@ function left_userlist_get_new_heights() {
res.total_leftlist_height =
viewport_height -
- parseInt($("#left-sidebar").css("marginTop"), 10) -
- parseInt($(".narrows_panel").css("marginTop"), 10) -
- parseInt($(".narrows_panel").css("marginBottom"), 10) -
+ Number.parseInt($("#left-sidebar").css("marginTop"), 10) -
+ Number.parseInt($(".narrows_panel").css("marginTop"), 10) -
+ Number.parseInt($(".narrows_panel").css("marginBottom"), 10) -
$("#global_filters").safeOuterHeight(true) -
$("#streams_header").safeOuterHeight(true) -
$("#userlist-header").safeOuterHeight(true) -
$("#user_search_section").safeOuterHeight(true) -
- parseInt(stream_filters.css("marginBottom"), 10);
+ Number.parseInt(stream_filters.css("marginBottom"), 10);
const blocks = [
{
diff --git a/static/js/rows.js b/static/js/rows.js
index ea7ac843f55..33808aac147 100644
--- a/static/js/rows.js
+++ b/static/js/rows.js
@@ -95,7 +95,7 @@ exports.id = function (message_row) {
blueslip.error("Calling code passed rows.id a row with no zid attr.");
}
- return parseFloat(zid);
+ return Number.parseFloat(zid);
};
exports.local_echo_id = function (message_row) {
diff --git a/static/js/settings_account.js b/static/js/settings_account.js
index 93d300c327e..ec2e064e6ee 100644
--- a/static/js/settings_account.js
+++ b/static/js/settings_account.js
@@ -554,14 +554,14 @@ exports.set_up = function () {
e.preventDefault();
e.stopPropagation();
const field = $(e.target).closest(".custom_user_field").expectOne();
- const field_id = parseInt($(field).attr("data-field-id"), 10);
+ const field_id = Number.parseInt($(field).attr("data-field-id"), 10);
update_user_custom_profile_fields([field_id], channel.del);
});
$("#account-settings").on("change", ".custom_user_field_value", function (e) {
const fields = [];
const value = $(this).val();
- const field_id = parseInt(
+ const field_id = Number.parseInt(
$(e.target).closest(".custom_user_field").attr("data-field-id"),
10,
);
diff --git a/static/js/settings_bots.js b/static/js/settings_bots.js
index 814accab0ab..6c4850ea0ec 100644
--- a/static/js/settings_bots.js
+++ b/static/js/settings_bots.js
@@ -368,7 +368,7 @@ exports.set_up = function () {
});
$("#active_bots_list").on("click", "button.delete_bot", (e) => {
- const bot_id = parseInt($(e.currentTarget).attr("data-user-id"), 10);
+ const bot_id = Number.parseInt($(e.currentTarget).attr("data-user-id"), 10);
channel.del({
url: "/json/bots/" + encodeURIComponent(bot_id),
@@ -385,7 +385,7 @@ exports.set_up = function () {
});
$("#inactive_bots_list").on("click", "button.reactivate_bot", (e) => {
- const user_id = parseInt($(e.currentTarget).attr("data-user-id"), 10);
+ const user_id = Number.parseInt($(e.currentTarget).attr("data-user-id"), 10);
channel.post({
url: "/json/users/" + encodeURIComponent(user_id) + "/reactivate",
@@ -396,7 +396,7 @@ exports.set_up = function () {
});
$("#active_bots_list").on("click", "button.regenerate_bot_api_key", (e) => {
- const bot_id = parseInt($(e.currentTarget).attr("data-user-id"), 10);
+ const bot_id = Number.parseInt($(e.currentTarget).attr("data-user-id"), 10);
channel.post({
url: "/json/bots/" + encodeURIComponent(bot_id) + "/api_key/regenerate",
idempotent: true,
@@ -419,7 +419,7 @@ exports.set_up = function () {
e.stopPropagation();
overlays.open_modal("#edit_bot_modal");
const li = $(e.currentTarget).closest("li");
- const bot_id = parseInt(li.find(".bot_info").attr("data-user-id"), 10);
+ const bot_id = Number.parseInt(li.find(".bot_info").attr("data-user-id"), 10);
const bot = bot_data.get(bot_id);
const user_ids = people.get_active_human_ids();
const users_list = user_ids.map((user_id) => ({
@@ -472,7 +472,7 @@ exports.set_up = function () {
errors.hide();
},
submitHandler() {
- const bot_id = parseInt(form.attr("data-user-id"), 10);
+ const bot_id = Number.parseInt(form.attr("data-user-id"), 10);
const type = form.attr("data-type");
const full_name = form.find(".edit_bot_name").val();
@@ -539,14 +539,14 @@ 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 = parseInt(bot_info.attr("data-user-id"), 10);
+ const bot_id = Number.parseInt(bot_info.attr("data-user-id"), 10);
$(this).attr("href", exports.generate_zuliprc_uri(bot_id));
});
new ClipboardJS("#copy_zuliprc", {
text(trigger) {
const bot_info = $(trigger).closest(".bot-information-box").find(".bot_info");
- const bot_id = parseInt(bot_info.attr("data-user-id"), 10);
+ const bot_id = Number.parseInt(bot_info.attr("data-user-id"), 10);
const bot = bot_data.get(bot_id);
const data = exports.generate_zuliprc_content(bot);
return data;
diff --git a/static/js/settings_muting.js b/static/js/settings_muting.js
index 8d9f39b270c..d1d00712a53 100644
--- a/static/js/settings_muting.js
+++ b/static/js/settings_muting.js
@@ -6,7 +6,7 @@ exports.set_up = function () {
exports.loaded = true;
$("body").on("click", ".settings-unmute-topic", function (e) {
const $row = $(this).closest("tr");
- const stream_id = parseInt($row.attr("data-stream-id"), 10);
+ const stream_id = Number.parseInt($row.attr("data-stream-id"), 10);
const topic = $row.attr("data-topic");
e.stopImmediatePropagation();
diff --git a/static/js/settings_org.js b/static/js/settings_org.js
index 7b5407bc39a..c15a5f115b2 100644
--- a/static/js/settings_org.js
+++ b/static/js/settings_org.js
@@ -92,8 +92,8 @@ exports.get_organization_settings_options = () => {
exports.get_realm_time_limits_in_minutes = function (property) {
let val = (page_params[property] / 60).toFixed(1);
- if (parseFloat(val, 10) === parseInt(val, 10)) {
- val = parseInt(val, 10);
+ if (Number.parseFloat(val, 10) === Number.parseInt(val, 10)) {
+ val = Number.parseInt(val, 10);
}
return val.toString();
};
@@ -511,7 +511,7 @@ exports.get_input_element_value = function (input_elem, input_type) {
return input_elem.val().trim();
}
if (input_type === "number") {
- return parseInt(input_elem.val().trim(), 10);
+ return Number.parseInt(input_elem.val().trim(), 10);
}
}
return undefined;
@@ -561,9 +561,9 @@ function check_property_changed(elem) {
changed_val = get_auth_method_table_data();
changed_val = JSON.stringify(changed_val);
} else if (property_name === "realm_notifications_stream_id") {
- changed_val = parseInt(exports.notifications_stream_widget.value(), 10);
+ changed_val = Number.parseInt(exports.notifications_stream_widget.value(), 10);
} else if (property_name === "realm_signup_notifications_stream_id") {
- changed_val = parseInt(exports.signup_notifications_stream_widget.value(), 10);
+ changed_val = Number.parseInt(exports.signup_notifications_stream_widget.value(), 10);
} else if (property_name === "realm_default_code_block_language") {
changed_val = exports.default_code_language_widget.value();
} else if (current_val !== undefined) {
@@ -718,7 +718,7 @@ exports.build_page = function () {
};
exports.parse_time_limit = function parse_time_limit(elem) {
- return Math.floor(parseFloat(elem.val(), 10).toFixed(1) * 60);
+ return Math.floor(Number.parseFloat(elem.val(), 10).toFixed(1) * 60);
};
function get_complete_data_for_subsection(subsection) {
@@ -757,10 +757,10 @@ exports.build_page = function () {
}
} else if (subsection === "notifications") {
data.notifications_stream_id = JSON.stringify(
- parseInt(exports.notifications_stream_widget.value(), 10),
+ Number.parseInt(exports.notifications_stream_widget.value(), 10),
);
data.signup_notifications_stream_id = JSON.stringify(
- parseInt(exports.signup_notifications_stream_widget.value(), 10),
+ Number.parseInt(exports.signup_notifications_stream_widget.value(), 10),
);
} else if (subsection === "message_retention") {
const message_retention_setting_value = $("#id_realm_message_retention_setting").val();
diff --git a/static/js/settings_profile_fields.js b/static/js/settings_profile_fields.js
index 8c9bbac0cf3..2518be4fae5 100644
--- a/static/js/settings_profile_fields.js
+++ b/static/js/settings_profile_fields.js
@@ -130,7 +130,7 @@ function set_up_create_field_form() {
const field_elem = $("#profile_field_external_accounts");
const field_url_pattern_elem = $("#custom_external_account_url_pattern");
- if (parseInt($("#profile_field_type").val(), 10) === field_types.EXTERNAL_ACCOUNT.id) {
+ if (Number.parseInt($("#profile_field_type").val(), 10) === field_types.EXTERNAL_ACCOUNT.id) {
field_elem.show();
if ($("#profile_field_external_accounts_type").val() === "custom") {
field_url_pattern_elem.show();
@@ -169,7 +169,10 @@ function create_profile_field(e) {
const opts = {
success_continuation: clear_form_data,
};
- field_data = read_field_data_from_form(parseInt(field_type, 10), $(".new-profile-field-form"));
+ field_data = read_field_data_from_form(
+ Number.parseInt(field_type, 10),
+ $(".new-profile-field-form"),
+ );
const form_data = {
name: $("#profile_field_name").val(),
@@ -274,7 +277,7 @@ function set_up_choices_field_edit_form(profile_field, field_data) {
}
function open_edit_form(e) {
- const field_id = parseInt($(e.currentTarget).attr("data-profile-field-id"), 10);
+ const field_id = Number.parseInt($(e.currentTarget).attr("data-profile-field-id"), 10);
const profile_field = get_profile_field_info(field_id);
profile_field.row.hide();
@@ -288,11 +291,11 @@ function open_edit_form(e) {
field_data = JSON.parse(field.field_data);
}
- if (parseInt(field.type, 10) === field_types.CHOICE.id) {
+ if (Number.parseInt(field.type, 10) === field_types.CHOICE.id) {
set_up_choices_field_edit_form(profile_field, field_data);
}
- if (parseInt(field.type, 10) === field_types.EXTERNAL_ACCOUNT.id) {
+ if (Number.parseInt(field.type, 10) === field_types.EXTERNAL_ACCOUNT.id) {
profile_field.form.find("select[name=external_acc_field_type]").val(field_data.subtype);
set_up_external_account_field_edit_form(profile_field, field_data.url_pattern);
}
@@ -315,7 +318,7 @@ function open_edit_form(e) {
data.name = profile_field.form.find("input[name=name]").val();
data.hint = profile_field.form.find("input[name=hint]").val();
data.field_data = JSON.stringify(
- read_field_data_from_form(parseInt(field.type, 10), profile_field.form),
+ read_field_data_from_form(Number.parseInt(field.type, 10), profile_field.form),
);
settings_ui.do_settings_change(
@@ -333,7 +336,7 @@ function open_edit_form(e) {
.find(".edit_profile_field_choices_container")
.on("click", "button.delete-choice", delete_choice_row);
$(".profile_field_external_accounts_edit select").on("change", (e) => {
- const field_id = parseInt(
+ const field_id = Number.parseInt(
$(e.target).closest(".profile-field-form").attr("data-profile-field-id"),
10,
);
@@ -349,7 +352,7 @@ exports.reset = function () {
function update_field_order() {
order = [];
$(".profile-field-row").each(function () {
- order.push(parseInt($(this).attr("data-profile-field-id"), 10));
+ order.push(Number.parseInt($(this).attr("data-profile-field-id"), 10));
});
settings_ui.do_settings_change(
channel.patch,
@@ -429,13 +432,13 @@ function set_up_choices_field() {
const field_type = $("#profile_field_type").val();
- if (parseInt(field_type, 10) !== field_types.CHOICE.id) {
+ if (Number.parseInt(field_type, 10) !== field_types.CHOICE.id) {
// If 'Choice' type is already selected, show choice row.
$("#profile_field_choices_row").hide();
}
$("#profile_field_type").on("change", (e) => {
- const selected_field_id = parseInt($(e.target).val(), 10);
+ const selected_field_id = Number.parseInt($(e.target).val(), 10);
if (selected_field_id === field_types.CHOICE.id) {
$("#profile_field_choices_row").show();
} else {
diff --git a/static/js/settings_streams.js b/static/js/settings_streams.js
index 4a2d5368e3c..233b181294b 100644
--- a/static/js/settings_streams.js
+++ b/static/js/settings_streams.js
@@ -133,7 +133,7 @@ exports.build_page = function () {
$("body").on("click", ".default_stream_row .remove-default-stream", function (e) {
const row = $(this).closest(".default_stream_row");
- const stream_id = parseInt(row.attr("data-stream-id"), 10);
+ const stream_id = Number.parseInt(row.attr("data-stream-id"), 10);
exports.delete_default_stream(stream_id, row, $(e.target));
});
};
diff --git a/static/js/settings_user_groups.js b/static/js/settings_user_groups.js
index 5e4c5861dcf..4d7f19ae1c0 100644
--- a/static/js/settings_user_groups.js
+++ b/static/js/settings_user_groups.js
@@ -327,7 +327,7 @@ exports.set_up = function () {
});
$("#user-groups").on("click", ".delete", function () {
- const group_id = parseInt($(this).parents(".user-group").attr("id"), 10);
+ const group_id = Number.parseInt($(this).parents(".user-group").attr("id"), 10);
if (!exports.can_edit(group_id)) {
return;
}
diff --git a/static/js/settings_users.js b/static/js/settings_users.js
index 02361c4a980..00799f72ffa 100644
--- a/static/js/settings_users.js
+++ b/static/js/settings_users.js
@@ -438,7 +438,10 @@ function get_human_profile_data(fields_user_pills) {
// Remove duplicate datepicker input element generated flatpicker library
if (!$(this).hasClass("form-control")) {
new_profile_data.push({
- id: parseInt($(this).closest(".custom_user_field").attr("data-field-id"), 10),
+ id: Number.parseInt(
+ $(this).closest(".custom_user_field").attr("data-field-id"),
+ 10,
+ ),
value: $(this).val(),
});
}
@@ -544,7 +547,7 @@ function handle_bot_deactivation(tbody, status_field) {
const button_elem = $(e.target);
const row = button_elem.closest(".user_row");
- const bot_id = parseInt(row.attr("data-user-id"), 10);
+ const bot_id = Number.parseInt(row.attr("data-user-id"), 10);
const url = "/json/bots/" + encodeURIComponent(bot_id);
const opts = {
@@ -566,7 +569,7 @@ function handle_reactivation(tbody, status_field) {
// 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 = parseInt(row.attr("data-user-id"), 10);
+ const user_id = Number.parseInt(row.attr("data-user-id"), 10);
const url = "/json/users/" + encodeURIComponent(user_id) + "/reactivate";
const data = {};
@@ -587,7 +590,7 @@ function handle_human_form(tbody, status_field) {
tbody.on("click", ".open-user-form", (e) => {
e.stopPropagation();
e.preventDefault();
- const user_id = parseInt($(e.currentTarget).attr("data-user-id"), 10);
+ const user_id = Number.parseInt($(e.currentTarget).attr("data-user-id"), 10);
const person = people.get_by_user_id(user_id);
if (!person) {
@@ -602,7 +605,7 @@ function handle_human_form(tbody, status_field) {
e.preventDefault();
e.stopPropagation();
- const role = parseInt(modal.find("#user-role-select").val().trim(), 10);
+ const role = Number.parseInt(modal.find("#user-role-select").val().trim(), 10);
const full_name = modal.find("input[name='full_name']");
const profile_data = get_human_profile_data(fields_user_pills);
@@ -623,7 +626,7 @@ function handle_bot_form(tbody, status_field) {
tbody.on("click", ".open-user-form", (e) => {
e.stopPropagation();
e.preventDefault();
- const user_id = parseInt($(e.currentTarget).attr("data-user-id"), 10);
+ const user_id = Number.parseInt($(e.currentTarget).attr("data-user-id"), 10);
const bot = people.get_by_user_id(user_id);
if (!bot) {
diff --git a/static/js/stream_color.js b/static/js/stream_color.js
index 5194671df32..01f04d5fe56 100644
--- a/static/js/stream_color.js
+++ b/static/js/stream_color.js
@@ -101,7 +101,7 @@ exports.update_stream_color = function (sub, color, opts) {
};
function picker_do_change_color(color) {
- const stream_id = parseInt($(this).attr("stream_id"), 10);
+ const stream_id = Number.parseInt($(this).attr("stream_id"), 10);
const hex_color = color.toHexString();
subs.set_color(stream_id, hex_color);
}
@@ -170,7 +170,7 @@ exports.get_color_class = _.memoize((color) => {
// CSS colors are specified in the sRGB color space.
// Convert to linear intensity values.
for (i = 0; i < 3; i += 1) {
- channel[i] = colorspace.sRGB_to_linear(mult * parseInt(match[i + 1], 16));
+ channel[i] = colorspace.sRGB_to_linear(mult * Number.parseInt(match[i + 1], 16));
}
// Compute perceived lightness as CIE L*.
diff --git a/static/js/stream_create.js b/static/js/stream_create.js
index bf0e551c416..ef47d7ed1a2 100644
--- a/static/js/stream_create.js
+++ b/static/js/stream_create.js
@@ -131,7 +131,7 @@ function update_announce_stream_state() {
function get_principals() {
return Array.from($("#stream_creation_form input:checkbox[name=user]:checked"), (elem) => {
const label = $(elem).closest(".add-user-label");
- return parseInt(label.attr("data-user-id"), 10);
+ return Number.parseInt(label.attr("data-user-id"), 10);
});
}
@@ -171,7 +171,7 @@ function create_stream() {
data.invite_only = JSON.stringify(invite_only);
data.history_public_to_subscribers = JSON.stringify(history_public_to_subscribers);
- const stream_post_policy = parseInt(
+ const stream_post_policy = Number.parseInt(
$("#stream_creation_form input[name=stream-post-policy]:checked").val(),
10,
);
@@ -182,7 +182,7 @@ function create_stream() {
"#stream_creation_form select[name=stream_message_retention_setting]",
).val();
if (message_retention_selection === "retain_for_period") {
- message_retention_selection = parseInt(
+ message_retention_selection = Number.parseInt(
$("#stream_creation_form input[name=stream-message-retention-days]").val(),
10,
);
@@ -297,13 +297,13 @@ exports.show_new_stream_modal = function () {
$("#stream-checkboxes label.checkbox").on("change", function (e) {
const elem = $(this);
- const stream_id = parseInt(elem.attr("data-stream-id"), 10);
+ const stream_id = Number.parseInt(elem.attr("data-stream-id"), 10);
const checked = elem.find("input").prop("checked");
const subscriber_ids = stream_data.get_sub_by_id(stream_id).subscribers;
$("#user-checkboxes label.checkbox").each(function () {
const user_elem = $(this);
- const user_id = parseInt(user_elem.attr("data-user-id"), 10);
+ const user_id = Number.parseInt(user_elem.attr("data-user-id"), 10);
if (subscriber_ids.has(user_id)) {
user_elem.find("input").prop("checked", checked);
@@ -379,7 +379,7 @@ exports.create_handlers_for_users = function (container) {
// implementation is merely sluggish.
user_labels.each(function () {
const elem = $(this);
- const user_id = parseInt(elem.attr("data-user-id"), 10);
+ const user_id = Number.parseInt(elem.attr("data-user-id"), 10);
const user_checked = filtered_users.has(user_id);
const display = user_checked ? "block" : "none";
elem.css({display});
diff --git a/static/js/stream_data.js b/static/js/stream_data.js
index c4255a640df..eaa7d33ddc6 100644
--- a/static/js/stream_data.js
+++ b/static/js/stream_data.js
@@ -317,7 +317,7 @@ exports.slug_to_name = function (slug) {
*/
const m = /^([\d]+)(-.*)?/.exec(slug);
if (m) {
- const stream_id = parseInt(m[1], 10);
+ const stream_id = Number.parseInt(m[1], 10);
const sub = subs_by_stream_id.get(stream_id);
if (sub) {
return sub.name;
diff --git a/static/js/stream_edit.js b/static/js/stream_edit.js
index 2f32d37ad0f..b7df7b8165a 100644
--- a/static/js/stream_edit.js
+++ b/static/js/stream_edit.js
@@ -120,7 +120,7 @@ function set_stream_message_retention_setting_dropdown(stream) {
function get_stream_id(target) {
const row = $(target).closest(".stream-row, .subscription_settings");
- return parseInt(row.attr("data-stream-id"), 10);
+ return Number.parseInt(row.attr("data-stream-id"), 10);
}
function get_sub_for_target(target) {
@@ -497,7 +497,7 @@ function change_stream_privacy(e) {
const data = {};
const privacy_setting = $("#stream_privacy_modal input[name=privacy]:checked").val();
- const stream_post_policy = parseInt(
+ const stream_post_policy = Number.parseInt(
$("#stream_privacy_modal input[name=stream-post-policy]:checked").val(),
10,
);
@@ -532,7 +532,7 @@ function change_stream_privacy(e) {
"#stream_privacy_modal select[name=stream_message_retention_setting]",
).val();
if (message_retention_days === "retain_for_period") {
- message_retention_days = parseInt(
+ message_retention_days = Number.parseInt(
$("#stream_privacy_modal input[name=stream-message-retention-days]").val(),
10,
);
@@ -752,7 +752,7 @@ exports.initialize = function () {
e.preventDefault();
const list_entry = $(e.target).closest("tr");
- const target_user_id = parseInt(list_entry.attr("data-subscriber-id"), 10);
+ const target_user_id = Number.parseInt(list_entry.attr("data-subscriber-id"), 10);
const sub = get_sub_for_target(e.target);
if (!sub) {
@@ -784,7 +784,7 @@ exports.initialize = function () {
});
$("#subscriptions_table").on("click", ".stream_subscription_info .view_user_profile", (e) => {
- const user_id = parseInt($(e.target).attr("data-id"), 10);
+ const user_id = Number.parseInt($(e.target).attr("data-id"), 10);
const user = people.get_by_user_id(user_id);
popovers.show_user_profile(user);
e.stopPropagation();
diff --git a/static/js/stream_list.js b/static/js/stream_list.js
index b38ff759b48..f68fd83ff6c 100644
--- a/static/js/stream_list.js
+++ b/static/js/stream_list.js
@@ -159,7 +159,7 @@ exports.get_stream_li = function (stream_id) {
};
function stream_id_for_elt(elt) {
- return parseInt(elt.attr("data-stream-id"), 10);
+ return Number.parseInt(elt.attr("data-stream-id"), 10);
}
exports.zoom_in_topics = function (options) {
diff --git a/static/js/stream_popover.js b/static/js/stream_popover.js
index 86459a247b9..36f936ecf43 100644
--- a/static/js/stream_popover.js
+++ b/static/js/stream_popover.js
@@ -50,7 +50,7 @@ exports.starred_messages_sidebar_menu_handle_keyboard = (key) => {
};
function elem_to_stream_id(elem) {
- const stream_id = parseInt(elem.attr("data-stream-id"), 10);
+ const stream_id = Number.parseInt(elem.attr("data-stream-id"), 10);
if (stream_id === undefined) {
blueslip.error("could not find stream id");
@@ -142,7 +142,7 @@ function update_spectrum(popover, update_func) {
const after_height = popover[0].offsetHeight;
const popover_root = popover.closest(".popover");
- const current_top_px = parseFloat(popover_root.css("top").replace("px", ""));
+ const current_top_px = Number.parseFloat(popover_root.css("top").replace("px", ""));
const height_delta = after_height - initial_height;
let top = current_top_px - height_delta / 2;
@@ -323,7 +323,7 @@ function build_move_topic_to_stream_popover(e, current_stream_id, topic_name) {
);
ui_util.decorate_stream_bar(current_stream_name, stream_header_colorblock, false);
$("#select_stream_id").on("change", function () {
- const stream_name = stream_data.maybe_get_stream_name(parseInt(this.value, 10));
+ const stream_name = stream_data.maybe_get_stream_name(Number.parseInt(this.value, 10));
ui_util.decorate_stream_bar(stream_name, stream_header_colorblock, false);
});
@@ -575,7 +575,7 @@ exports.register_topic_handlers = function () {
$("body").on("click", ".sidebar-popover-move-topic-messages", (e) => {
const topic_row = $(e.currentTarget);
- const stream_id = parseInt(topic_row.attr("data-stream-id"), 10);
+ const stream_id = Number.parseInt(topic_row.attr("data-stream-id"), 10);
const topic_name = topic_row.attr("data-topic-name");
build_move_topic_to_stream_popover(e, stream_id, topic_name);
e.stopPropagation();
@@ -611,10 +611,10 @@ exports.register_topic_handlers = function () {
new_topic_name = new_topic_name.trim();
send_notification_to_new_thread = send_notification_to_new_thread === "on";
send_notification_to_old_thread = send_notification_to_old_thread === "on";
- current_stream_id = parseInt(current_stream_id, 10);
+ current_stream_id = Number.parseInt(current_stream_id, 10);
if (
- current_stream_id === parseInt(select_stream_id, 10) &&
+ current_stream_id === Number.parseInt(select_stream_id, 10) &&
new_topic_name.toLowerCase() === old_topic_name.toLowerCase()
) {
show_error_msg("Please select a different stream or change topic name.");
diff --git a/static/js/stream_topic_history.js b/static/js/stream_topic_history.js
index 1c54303c1af..423a4880e1e 100644
--- a/static/js/stream_topic_history.js
+++ b/static/js/stream_topic_history.js
@@ -96,7 +96,7 @@ class PerStreamHistory {
const topic_name = opts.topic_name;
let message_id = opts.message_id || 0;
- message_id = parseInt(message_id, 10);
+ message_id = Number.parseInt(message_id, 10);
this.update_stream_max_message_id(message_id);
const existing = this.topics.get(topic_name);
diff --git a/static/js/submessage.js b/static/js/submessage.js
index 6672cb2768c..cd7ebac2260 100644
--- a/static/js/submessage.js
+++ b/static/js/submessage.js
@@ -13,7 +13,7 @@ exports.get_message_events = function (message) {
return undefined;
}
- message.submessages.sort((m1, m2) => parseInt(m1.id, 10) - parseInt(m2.id, 10));
+ message.submessages.sort((m1, m2) => Number.parseInt(m1.id, 10) - Number.parseInt(m2.id, 10));
const events = message.submessages.map((obj) => ({
sender_id: obj.sender_id,
diff --git a/static/js/subs.js b/static/js/subs.js
index df2deb80e70..d82e7e17ef9 100644
--- a/static/js/subs.js
+++ b/static/js/subs.js
@@ -40,7 +40,7 @@ exports.settings_button_for_sub = function (sub) {
};
function get_row_data(row) {
- const row_id = parseInt(row.attr("data-stream-id"), 10);
+ const row_id = Number.parseInt(row.attr("data-stream-id"), 10);
if (row_id) {
const row_object = stream_data.get_sub_by_id(row_id);
return {
@@ -53,7 +53,7 @@ function get_row_data(row) {
exports.get_active_data = function () {
const active_row = $("div.stream-row.active");
- const valid_active_id = parseInt(active_row.attr("data-stream-id"), 10);
+ const valid_active_id = Number.parseInt(active_row.attr("data-stream-id"), 10);
const active_tabs = $(".subscriptions-container").find("div.ind-tab.selected");
return {
row: active_row,
@@ -98,9 +98,9 @@ exports.active_stream = function () {
// if the string casted to a number is valid, and another component
// after exists then it's a stream name/id pair.
- if (typeof parseFloat(hash_components[1]) === "number" && hash_components[2]) {
+ if (typeof Number.parseFloat(hash_components[1]) === "number" && hash_components[2]) {
return {
- id: parseFloat(hash_components[1]),
+ id: Number.parseFloat(hash_components[1]),
name: hash_components[2],
};
}
@@ -306,7 +306,7 @@ exports.update_settings_for_subscribed = function (sub) {
exports.show_active_stream_in_left_panel = function () {
const selected_row = get_hash_safe().split(/\//)[1];
- if (parseFloat(selected_row)) {
+ if (Number.parseFloat(selected_row)) {
const sub_row = exports.row_for_stream_id(selected_row);
sub_row.addClass("active");
}
@@ -421,7 +421,7 @@ exports.filter_table = function (query) {
exports.show_active_stream_in_left_panel();
function stream_id_for_row(row) {
- return parseInt($(row).attr("data-stream-id"), 10);
+ return Number.parseInt($(row).attr("data-stream-id"), 10);
}
const widgets = new Map();
@@ -694,7 +694,7 @@ exports.change_state = function (section) {
// if the section is a valid number.
if (/\d+/.test(section)) {
- const stream_id = parseInt(section, 10);
+ const stream_id = Number.parseInt(section, 10);
// Guest users can not access unsubscribed streams
// So redirect guest users to 'subscribed' tab
// for any unsubscribed stream settings hash
diff --git a/static/js/tictactoe_widget.js b/static/js/tictactoe_widget.js
index 78d927a1c76..33fad6f9ec8 100644
--- a/static/js/tictactoe_widget.js
+++ b/static/js/tictactoe_widget.js
@@ -127,7 +127,7 @@ exports.activate = function (opts) {
elem.find("button.tictactoe-square").on("click", (e) => {
e.stopPropagation();
const str_idx = $(e.target).attr("data-idx");
- const idx = parseInt(str_idx, 10);
+ const idx = Number.parseInt(str_idx, 10);
const data = tictactoe_data.handle.square_click.outbound(idx);
callback(data);
diff --git a/static/js/topic_list.js b/static/js/topic_list.js
index 48d70481080..c2f57622793 100644
--- a/static/js/topic_list.js
+++ b/static/js/topic_list.js
@@ -262,7 +262,7 @@ exports.initialize = function () {
// of this stuff back up to our parents.
const stream_row = $(e.target).parents(".narrow-filter");
- const stream_id = parseInt(stream_row.attr("data-stream-id"), 10);
+ const stream_id = Number.parseInt(stream_row.attr("data-stream-id"), 10);
const sub = stream_data.get_sub_by_id(stream_id);
const topic = $(e.target).parents("li").attr("data-topic-name");
diff --git a/static/js/typing_data.js b/static/js/typing_data.js
index 73a50a17d0c..56561199122 100644
--- a/static/js/typing_data.js
+++ b/static/js/typing_data.js
@@ -9,7 +9,7 @@ const typist_dct = new Map();
const inbound_timer_dict = new Map();
function to_int(s) {
- return parseInt(s, 10);
+ return Number.parseInt(s, 10);
}
function get_key(group) {
diff --git a/static/js/typing_events.js b/static/js/typing_events.js
index 277efe5201d..84ca441d040 100644
--- a/static/js/typing_events.js
+++ b/static/js/typing_events.js
@@ -36,7 +36,7 @@ function get_users_typing_for_narrow() {
}
const narrow_user_ids = narrow_user_ids_string
.split(",")
- .map((user_id_string) => parseInt(user_id_string, 10));
+ .map((user_id_string) => Number.parseInt(user_id_string, 10));
const group = narrow_user_ids.concat([page_params.user_id]);
return typing_data.get_group_typists(group);
}
diff --git a/static/js/user_status.js b/static/js/user_status.js
index df35ab0ed35..28252a2626a 100644
--- a/static/js/user_status.js
+++ b/static/js/user_status.js
@@ -62,7 +62,7 @@ exports.initialize = function (params) {
for (const [str_user_id, dct] of Object.entries(params.user_status)) {
// JSON does not allow integer keys, so we
// convert them here.
- const user_id = parseInt(str_user_id, 10);
+ const user_id = Number.parseInt(str_user_id, 10);
if (dct.away) {
away_user_ids.add(user_id);
diff --git a/static/js/util.js b/static/js/util.js
index f570d446d7f..bd123006d1b 100644
--- a/static/js/util.js
+++ b/static/js/util.js
@@ -219,7 +219,7 @@ exports.is_mobile = function () {
};
function to_int(s) {
- return parseInt(s, 10);
+ return Number.parseInt(s, 10);
}
exports.sorted_ids = function (ids) {