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.

js: Reformat with Prettier.

Anders Kaseorgb65d2e063d6c
diff --git a/frontend_tests/casper_lib/common.js b/frontend_tests/casper_lib/common.js
index a3b043ac519..87dd064c956 100644
--- a/frontend_tests/casper_lib/common.js
+++ b/frontend_tests/casper_lib/common.js
@@ -15,13 +15,16 @@ function log_in() {
var credentials = test_credentials.default_user;
casper.test.info("Logging in");
- casper.fill('form[action^="/accounts/login/"]', {
- username: credentials.username,
- password: credentials.password,
- }, true /* submit form */);
+ casper.fill(
+ 'form[action^="/accounts/login/"]',
+ {
+ username: credentials.username,
+ password: credentials.password,
+ },
+ true /* submit form */
+ );
}
-
exports.init_viewport = function () {
casper.options.viewportSize = {width: 1280, height: 1024};
};
@@ -29,15 +32,25 @@ exports.init_viewport = function () {
// This function should always be enclosed within a then() otherwise
// it might not exist on casper object.
exports.wait_for_text = function (selector, text, then, onTimeout, timeout) {
- casper.waitForSelector(selector, function _then() {
- casper.waitFor(function _check() {
- var content = casper.fetchText(selector);
- if (util.isRegExp(text)) {
- return text.test(content);
- }
- return content.indexOf(text) !== -1;
- }, then, onTimeout, timeout);
- }, onTimeout, timeout);
+ casper.waitForSelector(
+ selector,
+ function _then() {
+ casper.waitFor(
+ function _check() {
+ var content = casper.fetchText(selector);
+ if (util.isRegExp(text)) {
+ return text.test(content);
+ }
+ return content.indexOf(text) !== -1;
+ },
+ then,
+ onTimeout,
+ timeout
+ );
+ },
+ onTimeout,
+ timeout
+ );
};
exports.initialize_casper = function () {
@@ -125,9 +138,7 @@ exports.then_log_out = function () {
casper.waitUntilVisible(logout_selector, function () {
casper.test.info("Logging out");
casper.click(logout_selector);
-
});
-
});
casper.waitUntilVisible(".login-page-container", function () {
casper.test.assertUrlMatch(/accounts\/login\/$/);
@@ -141,28 +152,31 @@ exports.select_item_via_typeahead = function (field_selector, str, item) {
casper.then(function () {
casper.test.info("Looking in " + field_selector + " to select " + str + ", " + item);
- casper.evaluate(function (field_selector, str, item) {
- // Set the value and then send a bogus keyup event to trigger
- // the typeahead.
- $(field_selector)
- .focus()
- .val(str)
- .trigger($.Event("keyup", {which: 0}));
-
- // You might think these steps should be split by casper.then,
- // but apparently that's enough to make the typeahead close (??),
- // but not the first time.
-
- // Trigger the typeahead.
- // Reaching into the guts of Bootstrap Typeahead like this is not
- // great, but I found it very hard to do it any other way.
-
- var tah = $(field_selector).data().typeahead;
- tah.mouseenter({
- currentTarget: $('.typeahead:visible li:contains("' + item + '")')[0],
- });
- tah.select();
- }, {field_selector: field_selector, str: str, item: item});
+ casper.evaluate(
+ function (field_selector, str, item) {
+ // Set the value and then send a bogus keyup event to trigger
+ // the typeahead.
+ $(field_selector)
+ .focus()
+ .val(str)
+ .trigger($.Event("keyup", {which: 0}));
+
+ // You might think these steps should be split by casper.then,
+ // but apparently that's enough to make the typeahead close (??),
+ // but not the first time.
+
+ // Trigger the typeahead.
+ // Reaching into the guts of Bootstrap Typeahead like this is not
+ // great, but I found it very hard to do it any other way.
+
+ var tah = $(field_selector).data().typeahead;
+ tah.mouseenter({
+ currentTarget: $('.typeahead:visible li:contains("' + item + '")')[0],
+ });
+ tah.select();
+ },
+ {field_selector: field_selector, str: str, item: item}
+ );
});
};
@@ -171,16 +185,20 @@ exports.check_form = function (form_selector, expected, test_name) {
var k;
for (k in expected) {
if (Object.prototype.hasOwnProperty.call(expected, k)) {
- casper.test.assertEqual(values[k], expected[k],
- test_name ? test_name + ": " + k : undefined);
+ casper.test.assertEqual(
+ values[k],
+ expected[k],
+ test_name ? test_name + ": " + k : undefined
+ );
}
}
};
exports.wait_for_message_fully_processed = function (content) {
casper.waitFor(function () {
- return casper.evaluate(function (content) {
- /*
+ return casper.evaluate(
+ function (content) {
+ /*
The tricky part about making sure that
a message has actually been fully processed
is that we'll "locally echo" the message
@@ -204,31 +222,33 @@ exports.wait_for_message_fully_processed = function (content) {
- does it look to have been
re-rendered based on server info?
*/
- const last_msg = current_msg_list.last();
+ const last_msg = current_msg_list.last();
- if (last_msg.raw_content !== content) {
- return false;
- }
+ if (last_msg.raw_content !== content) {
+ return false;
+ }
- if (last_msg.locally_echoed) {
- return false;
- }
+ if (last_msg.locally_echoed) {
+ return false;
+ }
- var row = rows.last_visible();
+ var row = rows.last_visible();
- if (rows.id(row) !== last_msg.id) {
- return false;
- }
+ if (rows.id(row) !== last_msg.id) {
+ return false;
+ }
- /*
+ /*
Make sure the message is completely
re-rendered from its original "local echo"
version by looking for the star icon. We
don't add the star icon until the server
responds.
*/
- return row.find(".star").length === 1;
- }, {content: content});
+ return row.find(".star").length === 1;
+ },
+ {content: content}
+ );
});
};
@@ -247,10 +267,14 @@ exports.turn_off_press_enter_to_send = function () {
exports.pm_recipient = {
set: function (recip) {
- casper.evaluate(function (recipient) {
- $("#private_message_recipient").text(recipient)
- .trigger({type: "keydown", keyCode: 13});
- }, {recipient: recip});
+ casper.evaluate(
+ function (recipient) {
+ $("#private_message_recipient")
+ .text(recipient)
+ .trigger({type: "keydown", keyCode: 13});
+ },
+ {recipient: recip}
+ );
},
expect: function (expected_value) {
@@ -327,23 +351,28 @@ exports.then_send_message = function (type, params) {
// script's context is awkward (c.f. the various appearances of
// 'table' here).
exports.get_rendered_messages = function (table) {
- return casper.evaluate(function (table) {
- var tbl = $("#" + table);
- return {
- headings: $.map(tbl.find(".recipient_row .message-header-contents"), function (elem) {
- var $clone = $(elem).clone(true);
- $clone.find(".recipient_row_date").remove();
-
- return $clone.text().trim().replace(/\s+/g, " ");
- }),
-
- bodies: $.map(tbl.find(".message_content"), function (elem) {
- return elem.innerHTML;
- }),
- };
- }, {
- table: table,
- });
+ return casper.evaluate(
+ function (table) {
+ var tbl = $("#" + table);
+ return {
+ headings: $.map(tbl.find(".recipient_row .message-header-contents"), function (
+ elem
+ ) {
+ var $clone = $(elem).clone(true);
+ $clone.find(".recipient_row_date").remove();
+
+ return $clone.text().trim().replace(/\s+/g, " ");
+ }),
+
+ bodies: $.map(tbl.find(".message_content"), function (elem) {
+ return elem.innerHTML;
+ }),
+ };
+ },
+ {
+ table: table,
+ }
+ );
};
exports.get_form_field_value = function (selector) {
@@ -353,37 +382,44 @@ exports.get_form_field_value = function (selector) {
};
exports.get_user_id = function (email) {
- return casper.evaluate(function (email) {
- return people.get_user_id(email);
- }, {
- email: email,
- });
+ return casper.evaluate(
+ function (email) {
+ return people.get_user_id(email);
+ },
+ {
+ email: email,
+ }
+ );
};
exports.get_stream_id = function (stream_name) {
- return casper.evaluate(function (stream_name) {
- return stream_data.get_stream_id(stream_name);
- }, {
- stream_name: stream_name,
- });
+ return casper.evaluate(
+ function (stream_name) {
+ return stream_data.get_stream_id(stream_name);
+ },
+ {
+ stream_name: stream_name,
+ }
+ );
};
// Inject key presses by running some jQuery code in page context.
// PhantomJS and CasperJS don't provide a clean way to insert key
// presses by code, only strings of printable characters.
exports.keypress = function (code) {
- casper.evaluate(function (code) {
- $("body").trigger($.Event("keydown", {which: code}));
- }, {
- code: code,
- });
+ casper.evaluate(
+ function (code) {
+ $("body").trigger($.Event("keydown", {which: code}));
+ },
+ {
+ code: code,
+ }
+ );
};
exports.then_send_many = function (msgs) {
msgs.forEach(function (msg) {
- exports.then_send_message(
- msg.stream !== undefined ? "stream" : "private",
- msg);
+ exports.then_send_message(msg.stream !== undefined ? "stream" : "private", msg);
});
};
@@ -428,12 +464,14 @@ exports.expected_messages = function (table, headings, bodies) {
casper.test.assertEquals(
msg.headings.slice(-headings.length),
headings.map(exports.trim),
- "Got expected message headings");
+ "Got expected message headings"
+ );
casper.test.assertEquals(
msg.bodies.slice(-bodies.length),
bodies,
- "Got expected message bodies");
+ "Got expected message bodies"
+ );
};
exports.un_narrow = function () {
@@ -460,7 +498,10 @@ exports.manage_organization = function () {
casper.waitForSelector("#settings_overlay_container.show", function () {
casper.test.info("Organization page is active");
- casper.test.assertUrlMatch(/^http:\/\/[^/]+\/#organization/, "URL suggests we are on organization page");
+ casper.test.assertUrlMatch(
+ /^http:\/\/[^/]+\/#organization/,
+ "URL suggests we are on organization page"
+ );
});
casper.then(function () {
diff --git a/frontend_tests/casper_tests/00-realm-creation.js b/frontend_tests/casper_tests/00-realm-creation.js
index 2f62e97b632..130395992d5 100644
--- a/frontend_tests/casper_tests/00-realm-creation.js
+++ b/frontend_tests/casper_tests/00-realm-creation.js
@@ -11,9 +11,13 @@ casper.start("http://" + host + "/new/");
casper.then(function () {
// Submit the email for realm creation
this.waitUntilVisible('form[name="email_form"]', function () {
- this.fill('form[name="email_form"]', {
- email: email,
- }, true);
+ this.fill(
+ 'form[name="email_form"]',
+ {
+ email: email,
+ },
+ true
+ );
});
// Make sure confirmation email is send
this.waitWhileVisible('form[name="email_form"]', function () {
@@ -51,14 +55,18 @@ casper.then(function () {
casper.then(function () {
this.waitUntilVisible('form[action^="/accounts/register/"]', function () {
- this.fill('form[action^="/accounts/register/"]', {
- full_name: "Alice",
- realm_name: organization_name,
- realm_subdomain: subdomain,
- password: "passwordwhichisreallyreallyreallycomplexandnotguessable",
- terms: true,
- realm_in_root_domain: false,
- }, true);
+ this.fill(
+ 'form[action^="/accounts/register/"]',
+ {
+ full_name: "Alice",
+ realm_name: organization_name,
+ realm_subdomain: subdomain,
+ password: "passwordwhichisreallyreallyreallycomplexandnotguessable",
+ terms: true,
+ realm_in_root_domain: false,
+ },
+ true
+ );
});
this.waitWhileVisible('form[action^="/accounts/register/"]', function () {
@@ -68,9 +76,14 @@ casper.then(function () {
casper.then(function () {
// The user is logged in to the newly created realm and the app is loaded
- casper.waitUntilVisible(".message_row", function () {
- this.test.assertTitleMatch(/ - Zulip$/, "Successfully logged into Zulip webapp");
- }, null, 20000);
+ casper.waitUntilVisible(
+ ".message_row",
+ function () {
+ this.test.assertTitleMatch(/ - Zulip$/, "Successfully logged into Zulip webapp");
+ },
+ null,
+ 20000
+ );
});
common.then_log_out();
diff --git a/frontend_tests/casper_tests/02-site.js b/frontend_tests/casper_tests/02-site.js
index cedc20dbd27..37510c14cd7 100644
--- a/frontend_tests/casper_tests/02-site.js
+++ b/frontend_tests/casper_tests/02-site.js
@@ -18,9 +18,11 @@ casper.then(function () {
var msg = common.get_rendered_messages("zhome");
msg.headings.forEach(function (heading) {
- casper.test.assertMatch(common.normalize_spaces(heading),
- /(^You and )|( )/,
- "Heading is well-formed");
+ casper.test.assertMatch(
+ common.normalize_spaces(heading),
+ /(^You and )|( )/,
+ "Heading is well-formed"
+ );
});
casper.test.info("Sending messages");
@@ -29,48 +31,45 @@ casper.then(function () {
// Send some messages.
common.then_send_many([
- {stream: "Verona", subject: "frontend test",
- content: "test verona A"},
+ {stream: "Verona", subject: "frontend test", content: "test verona A"},
- {stream: "Verona", subject: "frontend test",
- content: "test verona B"},
+ {stream: "Verona", subject: "frontend test", content: "test verona B"},
- {stream: "Verona", subject: "other subject",
- content: "test verona C"},
+ {stream: "Verona", subject: "other subject", content: "test verona C"},
- content: "personal A"},
+ {recipient: "[email protected], [email protected]", content: "personal A"},
- content: "personal B"},
+ {recipient: "[email protected], [email protected]", content: "personal B"},
- {recipient: "[email protected]",
- content: "personal C"}]);
+ {recipient: "[email protected]", content: "personal C"},
+]);
common.wait_for_receive(function () {
- common.expected_messages("zhome", [
- "Verona > frontend test",
- "Verona > other subject",
- "You and Cordelia Lear, King Hamlet",
- "You and Cordelia Lear",
- ], [
- "<p>test verona A</p>",
- "<p>test verona B</p>",
- "<p>test verona C</p>",
- "<p>personal A</p>",
- "<p>personal B</p>",
- "<p>personal C</p>",
- ]);
+ common.expected_messages(
+ "zhome",
+ [
+ "Verona > frontend test",
+ "Verona > other subject",
+ "You and Cordelia Lear, King Hamlet",
+ "You and Cordelia Lear",
+ ],
+ [
+ "<p>test verona A</p>",
+ "<p>test verona B</p>",
+ "<p>test verona C</p>",
+ "<p>personal A</p>",
+ "<p>personal B</p>",
+ "<p>personal C</p>",
+ ]
+ );
casper.test.info("Sending more messages");
});
common.then_send_many([
- {stream: "Verona", subject: "frontend test",
- content: "test verona D"},
+ {stream: "Verona", subject: "frontend test", content: "test verona D"},
- content: "personal D"},
+ {recipient: "[email protected], [email protected]", content: "personal D"},
]);
common.then_log_out();
diff --git a/frontend_tests/casper_tests/03-narrow.js b/frontend_tests/casper_tests/03-narrow.js
index 34bffb28625..0201e864363 100644
--- a/frontend_tests/casper_tests/03-narrow.js
+++ b/frontend_tests/casper_tests/03-narrow.js
@@ -16,52 +16,41 @@ casper.then(function () {
});
common.then_send_many([
- {stream: "Verona", subject: "frontend test",
- content: "test message A"},
+ {stream: "Verona", subject: "frontend test", content: "test message A"},
- {stream: "Verona", subject: "frontend test",
- content: "test message B"},
+ {stream: "Verona", subject: "frontend test", content: "test message B"},
- {stream: "Verona", subject: "other subject",
- content: "test message C"},
+ {stream: "Verona", subject: "other subject", content: "test message C"},
- {stream: "Denmark", subject: "frontend test",
- content: "other message"},
+ {stream: "Denmark", subject: "frontend test", content: "other message"},
- content: "personal A"},
+ {recipient: "[email protected], [email protected]", content: "personal A"},
- content: "personal B"},
+ {recipient: "[email protected], [email protected]", content: "personal B"},
- {recipient: "[email protected]",
- content: "personal C"},
+ {recipient: "[email protected]", content: "personal C"},
- {stream: "Verona", subject: "frontend test",
- content: "test message D"},
+ {stream: "Verona", subject: "frontend test", content: "test message D"},
- content: "personal D"},
+ {recipient: "[email protected], [email protected]", content: "personal D"},
- {recipient: "[email protected]",
- content: "personal E"},
+ {recipient: "[email protected]", content: "personal E"},
]);
-
// Define the messages we expect to see when narrowed.
function expect_home() {
casper.then(function () {
casper.waitUntilVisible("#zhome", function () {
- common.expected_messages("zhome", [
- "Verona > frontend test",
- "You and Cordelia Lear, King Hamlet",
- "You and Cordelia Lear",
- ], [
- "<p>test message D</p>",
- "<p>personal D</p>",
- "<p>personal E</p>",
- ]);
+ common.expected_messages(
+ "zhome",
+ [
+ "Verona > frontend test",
+ "You and Cordelia Lear, King Hamlet",
+ "You and Cordelia Lear",
+ ],
+ ["<p>test message D</p>", "<p>personal D</p>", "<p>personal E</p>"]
+ );
});
});
}
@@ -69,16 +58,16 @@ function expect_home() {
function expect_stream() {
casper.then(function () {
casper.waitUntilVisible("#zfilt", function () {
- common.expected_messages("zfilt", [
- "Verona > frontend test",
- "Verona > other subject",
- "Verona > frontend test",
- ], [
- "<p>test message A</p>",
- "<p>test message B</p>",
- "<p>test message C</p>",
- "<p>test message D</p>",
- ]);
+ common.expected_messages(
+ "zfilt",
+ ["Verona > frontend test", "Verona > other subject", "Verona > frontend test"],
+ [
+ "<p>test message A</p>",
+ "<p>test message B</p>",
+ "<p>test message C</p>",
+ "<p>test message D</p>",
+ ]
+ );
});
});
}
@@ -86,15 +75,16 @@ function expect_stream() {
function expect_stream_subject() {
casper.then(function () {
casper.waitUntilVisible("#zfilt", function () {
- common.expected_messages("zfilt", [
- "Verona > frontend test",
- ], [
- "<p>test message A</p>",
- "<p>test message B</p>",
- "<p>test message D</p>",
- ]);
-
- casper.test.assertEquals(casper.fetchText("#left_bar_compose_stream_button_big"), "New topic");
+ common.expected_messages(
+ "zfilt",
+ ["Verona > frontend test"],
+ ["<p>test message A</p>", "<p>test message B</p>", "<p>test message D</p>"]
+ );
+
+ casper.test.assertEquals(
+ casper.fetchText("#left_bar_compose_stream_button_big"),
+ "New topic"
+ );
});
});
}
@@ -102,16 +92,16 @@ function expect_stream_subject() {
function expect_subject() {
casper.then(function () {
casper.waitUntilVisible("#zfilt", function () {
- common.expected_messages("zfilt", [
- "Verona > frontend test",
- "Denmark > frontend test",
- "Verona > frontend test",
- ], [
- "<p>test message A</p>",
- "<p>test message B</p>",
- "<p>other message</p>",
- "<p>test message D</p>",
- ]);
+ common.expected_messages(
+ "zfilt",
+ ["Verona > frontend test", "Denmark > frontend test", "Verona > frontend test"],
+ [
+ "<p>test message A</p>",
+ "<p>test message B</p>",
+ "<p>other message</p>",
+ "<p>test message D</p>",
+ ]
+ );
});
});
}
@@ -119,13 +109,11 @@ function expect_subject() {
function expect_huddle() {
casper.then(function () {
casper.waitUntilVisible("#zfilt", function () {
- common.expected_messages("zfilt", [
- "You and Cordelia Lear, King Hamlet",
- ], [
- "<p>personal A</p>",
- "<p>personal B</p>",
- "<p>personal D</p>",
- ]);
+ common.expected_messages(
+ "zfilt",
+ ["You and Cordelia Lear, King Hamlet"],
+ ["<p>personal A</p>", "<p>personal B</p>", "<p>personal D</p>"]
+ );
});
});
}
@@ -133,12 +121,11 @@ function expect_huddle() {
function expect_1on1() {
casper.then(function () {
casper.waitUntilVisible("#zfilt", function () {
- common.expected_messages("zfilt", [
- "You and Cordelia Lear",
- ], [
- "<p>personal C</p>",
- "<p>personal E</p>",
- ]);
+ common.expected_messages(
+ "zfilt",
+ ["You and Cordelia Lear"],
+ ["<p>personal C</p>", "<p>personal E</p>"]
+ );
});
});
}
@@ -146,18 +133,22 @@ function expect_1on1() {
function expect_all_pm() {
casper.then(function () {
casper.waitUntilVisible("#zfilt", function () {
- common.expected_messages("zfilt", [
- "You and Cordelia Lear, King Hamlet",
- "You and Cordelia Lear",
- ], [
- "<p>personal A</p>",
- "<p>personal B</p>",
- "<p>personal C</p>",
- "<p>personal D</p>",
- "<p>personal E</p>",
- ]);
-
- casper.test.assertEquals(casper.fetchText("#left_bar_compose_stream_button_big"), "New stream message");
+ common.expected_messages(
+ "zfilt",
+ ["You and Cordelia Lear, King Hamlet", "You and Cordelia Lear"],
+ [
+ "<p>personal A</p>",
+ "<p>personal B</p>",
+ "<p>personal C</p>",
+ "<p>personal D</p>",
+ "<p>personal E</p>",
+ ]
+ );
+
+ casper.test.assertEquals(
+ casper.fetchText("#left_bar_compose_stream_button_big"),
+ "New stream message"
+ );
});
});
}
@@ -166,8 +157,7 @@ function expect_non_existing_user() {
casper.then(function () {
casper.waitUntilVisible("#non_existing_user", function () {
casper.test.info("Empty feed for non existing user visible.");
- var expected_message = "\n This user does not exist!" +
- "\n ";
+ var expected_message = "\n This user does not exist!" + "\n ";
this.test.assertEquals(casper.fetchText("#non_existing_user"), expected_message);
});
});
@@ -177,8 +167,7 @@ function expect_non_existing_users() {
casper.then(function () {
casper.waitUntilVisible("#non_existing_users", function () {
casper.test.info("Empty feed for non existing user visible.");
- var expected_message = "\n One or more of these users do not exist!" +
- "\n ";
+ var expected_message = "\n One or more of these users do not exist!" + "\n ";
this.test.assertEquals(casper.fetchText("#non_existing_users"), expected_message);
});
});
@@ -210,8 +199,8 @@ function search_silent_user(str, item) {
casper.then(function () {
casper.waitUntilVisible("#silent_user", function () {
casper.test.info("Empty feed for silent user visible.");
- var expected_message = "\n You haven't received any messages sent by this user yet!" +
- "\n ";
+ var expected_message =
+ "\n You haven't received any messages sent by this user yet!" + "\n ";
this.test.assertEquals(casper.fetchText("#silent_user"), expected_message);
});
});
@@ -277,24 +266,28 @@ expect_home();
// Narrow by typing in search strings or operators.
// Test stream / recipient autocomplete in the search bar
-search_and_check("Verona", "Stream", expect_stream,
- "Verona - Zulip Dev - Zulip");
+search_and_check("Verona", "Stream", expect_stream, "Verona - Zulip Dev - Zulip");
-search_and_check("Cordelia", "Private", expect_1on1,
- "Cordelia Lear - Zulip Dev - Zulip");
+search_and_check("Cordelia", "Private", expect_1on1, "Cordelia Lear - Zulip Dev - Zulip");
// Test operators
-search_and_check("stream:Verona", "", expect_stream,
- "Verona - Zulip Dev - Zulip");
+search_and_check("stream:Verona", "", expect_stream, "Verona - Zulip Dev - Zulip");
-search_and_check("stream:Verona subject:frontend+test", "", expect_stream_subject,
- "frontend test - Zulip Dev - Zulip");
+search_and_check(
+ "stream:Verona subject:frontend+test",
+ "",
+ expect_stream_subject,
+ "frontend test - Zulip Dev - Zulip"
+);
-search_and_check("stream:Verona topic:frontend+test", "", expect_stream_subject,
- "frontend test - Zulip Dev - Zulip");
+search_and_check(
+ "stream:Verona topic:frontend+test",
+ "",
+ expect_stream_subject,
+ "frontend test - Zulip Dev - Zulip"
+);
-search_and_check("subject:frontend+test", "", expect_subject,
- "home - Zulip Dev - Zulip");
+search_and_check("subject:frontend+test", "", expect_subject, "home - Zulip Dev - Zulip");
search_silent_user("sender:[email protected]", "");
@@ -302,8 +295,12 @@ search_non_existing_user("sender:[email protected]", "");
search_and_check("pm-with:[email protected]", "", expect_non_existing_user, "Invalid user");
-search_and_check("pm-with:[email protected],[email protected]", "", expect_non_existing_users,
- "Invalid users");
+search_and_check(
+ "",
+ expect_non_existing_users,
+ "Invalid users"
+);
// Narrow by clicking the left sidebar.
casper.then(function () {
@@ -332,44 +329,46 @@ un_narrow();
// Make sure stream search filters the stream list
casper.then(function () {
casper.test.info("Search streams using left sidebar");
- casper.test.assertExists(".input-append.notdisplayed", "Stream filter box not visible initially");
+ casper.test.assertExists(
+ ".input-append.notdisplayed",
+ "Stream filter box not visible initially"
+ );
casper.click("#streams_header .sidebar-title");
});
casper.waitWhileSelector("#streams_list .input-append.notdisplayed", function () {
- casper.test.assertExists(get_stream_li("Denmark"),
- "Original stream list contains Denmark");
- casper.test.assertExists(get_stream_li("Scotland"),
- "Original stream list contains Scotland");
- casper.test.assertExists(get_stream_li("Verona"),
- "Original stream list contains Verona");
+ casper.test.assertExists(get_stream_li("Denmark"), "Original stream list contains Denmark");
+ casper.test.assertExists(get_stream_li("Scotland"), "Original stream list contains Scotland");
+ casper.test.assertExists(get_stream_li("Verona"), "Original stream list contains Verona");
});
// Enter the search box and test highlighted suggestion navigation
casper.then(function () {
casper.evaluate(function () {
- $(".stream-list-filter").expectOne()
- .focus()
- .trigger($.Event("click"));
+ $(".stream-list-filter").expectOne().focus().trigger($.Event("click"));
});
});
casper.waitForSelector("#stream_filters .highlighted_stream", function () {
casper.test.info("Suggestion highlighting - initial situation");
- casper.test.assertExist(get_stream_li("Denmark") + ".highlighted_stream",
- "Stream Denmark is highlighted");
- casper.test.assertDoesntExist(get_stream_li("Scotland") + ".highlighted_stream",
- "Stream Scotland is not highlighted");
- casper.test.assertDoesntExist(get_stream_li("Verona") + ".highlighted_stream",
- "Stream Verona is not highlighted");
+ casper.test.assertExist(
+ get_stream_li("Denmark") + ".highlighted_stream",
+ "Stream Denmark is highlighted"
+ );
+ casper.test.assertDoesntExist(
+ get_stream_li("Scotland") + ".highlighted_stream",
+ "Stream Scotland is not highlighted"
+ );
+ casper.test.assertDoesntExist(
+ get_stream_li("Verona") + ".highlighted_stream",
+ "Stream Verona is not highlighted"
+ );
});
// Use arrow keys to navigate through suggestions
casper.then(function () {
function arrow(key) {
- casper.sendKeys(".stream-list-filter",
- casper.page.event.key[key],
- {keepFocus: true});
+ casper.sendKeys(".stream-list-filter", casper.page.event.key[key], {keepFocus: true});
}
arrow("Down"); // Denmark -> Scotland
arrow("Up"); // Scotland -> Denmark
@@ -382,20 +381,24 @@ casper.then(function () {
casper.test.info("Suggestion highlighting - after arrow key navigation");
casper.test.assertDoesntExist(
get_stream_li("Denmark") + ".highlighted_stream",
- "Stream Denmark is not highlighted");
+ "Stream Denmark is not highlighted"
+ );
casper.test.assertExist(
get_stream_li("Scotland") + ".highlighted_stream",
- "Stream Scotland is highlighted");
+ "Stream Scotland is highlighted"
+ );
casper.test.assertDoesntExist(
get_stream_li("Verona") + ".highlighted_stream",
- "Stream Verona is not highlighted");
+ "Stream Verona is not highlighted"
+ );
});
});
// We search for the beginning of "Scotland", not case sensitive
casper.then(function () {
casper.evaluate(function () {
- $(".stream-list-filter").expectOne()
+ $(".stream-list-filter")
+ .expectOne()
.focus()
.val("sCoT")
.trigger($.Event("input"))
@@ -407,61 +410,64 @@ casper.then(function () {
// expect them to happen in parallel.
casper.waitWhileVisible(get_stream_li("Denmark"), function () {
casper.test.info("Search term entered");
- casper.test.assertDoesntExist(get_stream_li("Denmark"),
- "Filtered stream list does not contain Denmark");
+ casper.test.assertDoesntExist(
+ get_stream_li("Denmark"),
+ "Filtered stream list does not contain Denmark"
+ );
});
casper.waitWhileVisible(get_stream_li("Verona"), function () {
- casper.test.assertDoesntExist(get_stream_li("Verona"),
- "Filtered stream list does not contain Verona");
+ casper.test.assertDoesntExist(
+ get_stream_li("Verona"),
+ "Filtered stream list does not contain Verona"
+ );
});
casper.then(function () {
- casper.test.assertExists(get_stream_li("Scotland"),
- "Filtered stream list does contain Scotland");
- casper.test.assertExists(get_stream_li("Scotland") + ".highlighted_stream",
- "Stream Scotland is highlighted");
+ casper.test.assertExists(
+ get_stream_li("Scotland"),
+ "Filtered stream list does contain Scotland"
+ );
+ casper.test.assertExists(
+ get_stream_li("Scotland") + ".highlighted_stream",
+ "Stream Scotland is highlighted"
+ );
});
// Clearing the list should give us back all the streams in the list
casper.then(function () {
casper.evaluate(function () {
- $(".stream-list-filter").expectOne()
- .focus()
- .val("")
- .trigger($.Event("input"));
+ $(".stream-list-filter").expectOne().focus().val("").trigger($.Event("input"));
});
});
casper.then(function () {
casper.waitUntilVisible(get_stream_li("Denmark"), function () {
- casper.test.assertExists(get_stream_li("Denmark"),
- "Restored stream list contains Denmark");
+ casper.test.assertExists(get_stream_li("Denmark"), "Restored stream list contains Denmark");
});
casper.waitUntilVisible(get_stream_li("Scotland"), function () {
- casper.test.assertExists(get_stream_li("Denmark"),
- "Restored stream list contains Scotland");
+ casper.test.assertExists(
+ get_stream_li("Denmark"),
+ "Restored stream list contains Scotland"
+ );
});
casper.waitUntilVisible(get_stream_li("Verona"), function () {
- casper.test.assertExists(get_stream_li("Denmark"),
- "Restored stream list contains Verona");
+ casper.test.assertExists(get_stream_li("Denmark"), "Restored stream list contains Verona");
});
});
-
casper.thenClick("#streams_header .sidebar-title");
casper.waitForSelector(".input-append.notdisplayed", function () {
- casper.test.assertExists(".input-append.notdisplayed",
- "Stream filter box not visible after second click");
+ casper.test.assertExists(
+ ".input-append.notdisplayed",
+ "Stream filter box not visible after second click"
+ );
});
// We search for the beginning of "Verona", not case sensitive
casper.then(function () {
casper.evaluate(function () {
- $(".stream-list-filter").expectOne()
- .focus()
- .val("ver")
- .trigger($.Event("input"));
+ $(".stream-list-filter").expectOne().focus().val("ver").trigger($.Event("input"));
});
});
@@ -469,7 +475,11 @@ casper.waitWhileVisible(get_stream_li("Denmark"), function () {
// Clicking the narrowed list should clear the search
casper.click(get_stream_li("Verona") + " a");
expect_stream();
- casper.test.assertEquals(casper.fetchText(".stream-list-filter"), "", "Clicking on a stream clears the search");
+ casper.test.assertEquals(
+ casper.fetchText(".stream-list-filter"),
+ "",
+ "Clicking on a stream clears the search"
+ );
});
un_narrow();
@@ -496,7 +506,6 @@ function assert_not_selected(name) {
);
}
-
// User search at the right sidebar
casper.then(function () {
casper.test.info("Search users using right sidebar");
@@ -510,9 +519,7 @@ casper.then(function () {
// Click on search icon
casper.then(function () {
casper.evaluate(function () {
- $("#user_filter_icon").expectOne()
- .focus()
- .trigger($.Event("click"));
+ $("#user_filter_icon").expectOne().focus().trigger($.Event("click"));
});
});
@@ -527,9 +534,7 @@ casper.waitForSelector("#user_presences .highlighted_user", function () {
// Use arrow keys to navigate through suggestions
casper.then(function () {
function arrow(key) {
- casper.sendKeys(".user-list-filter",
- casper.page.event.key[key],
- {keepFocus: true});
+ casper.sendKeys(".user-list-filter", casper.page.event.key[key], {keepFocus: true});
}
// go down 2, up 3 (which is really 2), then down 3
@@ -547,12 +552,15 @@ casper.then(function () {
arrow("Down");
});
-casper.waitForSelector('#user_presences li.highlighted_user [data-name="King Hamlet"]', function () {
- casper.test.info("Suggestion highlighting - after arrow key navigation");
- assert_not_selected("Iago");
- assert_not_selected("Cordelia Lear");
- assert_selected("King Hamlet");
-});
+casper.waitForSelector(
+ '#user_presences li.highlighted_user [data-name="King Hamlet"]',
+ function () {
+ casper.test.info("Suggestion highlighting - after arrow key navigation");
+ assert_not_selected("Iago");
+ assert_not_selected("Cordelia Lear");
+ assert_selected("King Hamlet");
+ }
+);
common.then_log_out();
diff --git a/frontend_tests/casper_tests/04-compose.js b/frontend_tests/casper_tests/04-compose.js
index c2b649e1876..3ffb1d51d7e 100644
--- a/frontend_tests/casper_tests/04-compose.js
+++ b/frontend_tests/casper_tests/04-compose.js
@@ -16,13 +16,8 @@ casper.then(function () {
// Send a message to try replying to
common.then_send_many([
- {stream: "Verona",
- subject: "Reply test",
- content: "We reply to this message",
- },
- {recipient: "[email protected]",
- content: "And reply to this message",
- },
+ {stream: "Verona", subject: "Reply test", content: "We reply to this message"},
+ {recipient: "[email protected]", content: "And reply to this message"},
]);
casper.then(function () {
@@ -39,7 +34,6 @@ casper.then(function () {
casper.page.sendEvent("keypress", "c");
});
-
function check_compose_is_cleared() {
common.check_form(
"#send_message_form",
@@ -146,7 +140,10 @@ casper.then(function () {
casper.then(function () {
var cordelia_user_id = common.get_user_id("[email protected]");
- var pm_li = 'li[data-user-ids-string="' + cordelia_user_id + '"].expanded_private_message.active-sub-filter';
+ var pm_li =
+ 'li[data-user-ids-string="' +
+ cordelia_user_id +
+ '"].expanded_private_message.active-sub-filter';
casper.waitUntilVisible(pm_li, function () {
casper.page.sendEvent("keypress", "c");
@@ -156,7 +153,9 @@ casper.then(function () {
casper.then(function () {
casper.waitUntilVisible("#compose", function () {
casper.test.assertEval(function () {
- return document.activeElement === $(".compose_table #stream_message_recipient_stream")[0];
+ return (
+ document.activeElement === $(".compose_table #stream_message_recipient_stream")[0]
+ );
}, "Stream box focused after narrowing to PMs with a user and pressing `c`");
});
});
@@ -173,7 +172,6 @@ common.then_send_message("private", {
content: "A huddle to check spaces",
});
-
casper.then(function () {
common.keypress(27); // escape to dismiss compose box
});
@@ -200,7 +198,11 @@ casper.then(function () {
casper.then(function () {
casper.waitWhileVisible("#markdown_preview", function () {
casper.test.assertVisible("#undo_markdown_preview", "Write button is visible");
- casper.test.assertEquals(casper.getHTML("#preview_content"), "Nothing to preview", "Nothing to preview");
+ casper.test.assertEquals(
+ casper.getHTML("#preview_content"),
+ "Nothing to preview",
+ "Nothing to preview"
+ );
casper.click("#undo_markdown_preview");
});
});
@@ -209,11 +211,19 @@ casper.then(function () {
casper.waitWhileVisible("#undo_markdown_preview", function () {
casper.test.assertVisible("#markdown_preview", "Preview button is visible.");
casper.test.assertNotVisible("#undo_markdown_preview", "Write button is hidden.");
- casper.test.assertEquals(casper.getHTML("#preview_content"), "", "Markdown preview area is empty");
+ casper.test.assertEquals(
+ casper.getHTML("#preview_content"),
+ "",
+ "Markdown preview area is empty"
+ );
- casper.fill('form[action^="/json/messages"]', {
- content: "**Markdown Preview** >> Test for markdown preview",
- }, false);
+ casper.fill(
+ 'form[action^="/json/messages"]',
+ {
+ content: "**Markdown Preview** >> Test for markdown preview",
+ },
+ false
+ );
casper.click("#markdown_preview");
});
@@ -221,7 +231,11 @@ casper.then(function () {
casper.then(function () {
casper.waitForSelectorTextChange("#preview_content", function () {
- casper.test.assertEquals(casper.getHTML("#preview_content"), "<p><strong>Markdown Preview</strong> &gt;&gt; Test for markdown preview</p>", "Check markdown is previewed properly");
+ casper.test.assertEquals(
+ casper.getHTML("#preview_content"),
+ "<p><strong>Markdown Preview</strong> &gt;&gt; Test for markdown preview</p>",
+ "Check markdown is previewed properly"
+ );
});
});
diff --git a/frontend_tests/casper_tests/05-subscriptions.js b/frontend_tests/casper_tests/05-subscriptions.js
index 361479dd0e0..6fc9ce486f5 100644
--- a/frontend_tests/casper_tests/05-subscriptions.js
+++ b/frontend_tests/casper_tests/05-subscriptions.js
@@ -20,11 +20,14 @@ function user_span(email) {
function is_checked(email) {
var sel = user_checkbox(email);
- return casper.evaluate(function (sel) {
- return $(sel).find("input")[0].checked;
- }, {
- sel: sel,
- });
+ return casper.evaluate(
+ function (sel) {
+ return $(sel).find("input")[0].checked;
+ },
+ {
+ sel: sel,
+ }
+ );
}
common.start_and_log_in();
@@ -40,9 +43,13 @@ casper.then(function () {
casper.click('a[href^="#streams"]');
casper.test.assertUrlMatch(
/^http:\/\/[^/]+\/#streams/,
- "URL suggests we are on streams page");
+ "URL suggests we are on streams page"
+ );
casper.waitUntilVisible("#subscription_overlay.new-style", function () {
- casper.test.assertExists("#subscription_overlay.new-style", "Streams page is active");
+ casper.test.assertExists(
+ "#subscription_overlay.new-style",
+ "Streams page is active"
+ );
});
});
});
@@ -54,8 +61,14 @@ casper.waitUntilVisible(".sub_unsub_button.checked", function () {
});
casper.then(function () {
- casper.test.assertExists(user_checkbox("[email protected]"), "Original user list contains Cordelia");
- casper.test.assertExists(user_checkbox("[email protected]"), "Original user list contains Othello");
+ casper.test.assertExists(
+ user_checkbox("[email protected]"),
+ "Original user list contains Cordelia"
+ );
+ casper.test.assertExists(
+ user_checkbox("[email protected]"),
+ "Original user list contains Othello"
+ );
});
casper.waitUntilVisible("#copy-from-stream-expand-collapse", function () {
@@ -72,40 +85,38 @@ casper.waitUntilVisible("form#stream_creation_form", function () {
casper.fill("form#stream_creation_form", {user_list_filter: "ot"});
});
casper.waitUntilVisible("#user-checkboxes", function () {
- casper.test.assertEquals(casper.visible(user_checkbox("[email protected]")),
- false,
- "Cordelia is not visible");
- casper.test.assertEquals(casper.visible(user_checkbox("[email protected]")),
- true,
- "Othello is visible");
+ casper.test.assertEquals(
+ casper.visible(user_checkbox("[email protected]")),
+ false,
+ "Cordelia is not visible"
+ );
+ casper.test.assertEquals(
+ casper.visible(user_checkbox("[email protected]")),
+ true,
+ "Othello is visible"
+ );
/* The filter should not impact streams */
- casper.test.assertEquals(casper.visible(stream_checkbox("Scotland")),
- true,
- "Scotland is visible");
- casper.test.assertEquals(casper.visible(stream_checkbox("Rome")),
- true,
- "Rome is visible");
+ casper.test.assertEquals(
+ casper.visible(stream_checkbox("Scotland")),
+ true,
+ "Scotland is visible"
+ );
+ casper.test.assertEquals(casper.visible(stream_checkbox("Rome")), true, "Rome is visible");
});
casper.then(function () {
casper.test.info("Check Uncheck only visible users for new stream");
casper.click(".subs_set_all_users");
casper.wait(100, function () {
- casper.test.assert(
- !is_checked("[email protected]"),
- "Cordelia is unchecked");
- casper.test.assert(
- is_checked("[email protected]"),
- "Othello is checked");
+ casper.test.assert(!is_checked("[email protected]"), "Cordelia is unchecked");
+ casper.test.assert(is_checked("[email protected]"), "Othello is checked");
});
});
casper.then(function () {
casper.test.info("Check Uncheck only visible users for new stream");
casper.click(".subs_unset_all_users");
casper.wait(100, function () {
- casper.test.assert(
- !is_checked("[email protected]"),
- "Othello is unchecked");
+ casper.test.assert(!is_checked("[email protected]"), "Othello is unchecked");
});
});
casper.then(function () {
@@ -113,23 +124,34 @@ casper.then(function () {
casper.fill("form#stream_creation_form", {user_list_filter: ""});
});
casper.then(function () {
- casper.test.assertEquals(casper.visible(user_checkbox("[email protected]")),
- true,
- "Cordelia is visible again");
- casper.test.assertEquals(casper.visible(user_checkbox("[email protected]")),
- true,
- "Othello is visible again");
- casper.test.assertEquals(casper.visible(stream_checkbox("Scotland")),
- true,
- "Scotland is visible again");
- casper.test.assertEquals(casper.visible(stream_checkbox("Rome")),
- true,
- "Rome is visible again");
+ casper.test.assertEquals(
+ casper.visible(user_checkbox("[email protected]")),
+ true,
+ "Cordelia is visible again"
+ );
+ casper.test.assertEquals(
+ casper.visible(user_checkbox("[email protected]")),
+ true,
+ "Othello is visible again"
+ );
+ casper.test.assertEquals(
+ casper.visible(stream_checkbox("Scotland")),
+ true,
+ "Scotland is visible again"
+ );
+ casper.test.assertEquals(
+ casper.visible(stream_checkbox("Rome")),
+ true,
+ "Rome is visible again"
+ );
});
casper.then(function () {
casper.waitUntilVisible("#stream_creation_form", function () {
casper.test.assertTextExists("Create stream", "New stream creation panel");
- casper.fill("form#stream_creation_form", {stream_name: "Waseemio", stream_description: "Oimeesaw"});
+ casper.fill("form#stream_creation_form", {
+ stream_name: "Waseemio",
+ stream_description: "Oimeesaw",
+ });
casper.click(stream_span("Scotland"));
casper.click(user_span("[email protected]"));
casper.click(user_span("[email protected]"));
@@ -159,37 +181,64 @@ casper.then(function () {
});
casper.then(function () {
common.wait_for_text("#stream_name_error", "A stream needs to have a name", function () {
- casper.test.assertTextExists("A stream needs to have a name", "Can't create a stream with an empty name");
+ casper.test.assertTextExists(
+ "A stream needs to have a name",
+ "Can't create a stream with an empty name"
+ );
casper.click("form#stream_creation_form button.button.white");
casper.fill("form#stream_creation_form", {stream_name: "Waseemio"});
casper.click("form#stream_creation_form button.button.sea-green");
});
});
casper.then(function () {
- common.wait_for_text("#stream_name_error", "A stream with this name already exists", function () {
- casper.test.assertTextExists("A stream with this name already exists", "Can't create a stream with a duplicate name");
- casper.test.info("Streams should be filtered when typing in the create box");
- casper.click("form#stream_creation_form button.button.white");
- });
+ common.wait_for_text(
+ "#stream_name_error",
+ "A stream with this name already exists",
+ function () {
+ casper.test.assertTextExists(
+ "A stream with this name already exists",
+ "Can't create a stream with a duplicate name"
+ );
+ casper.test.info("Streams should be filtered when typing in the create box");
+ casper.click("form#stream_creation_form button.button.white");
+ }
+ );
});
casper.then(function () {
common.wait_for_text("#search_stream_name", "", function () {
- casper.test.assertSelectorHasText('.stream-row[data-stream-name="Verona"] .stream-name', "Verona", "Verona stream exists before filtering");
- casper.test.assertSelectorDoesntHaveText(".stream-row.notdisplayed .stream-name", "Verona", "Verona stream shown before filtering");
+ casper.test.assertSelectorHasText(
+ '.stream-row[data-stream-name="Verona"] .stream-name',
+ "Verona",
+ "Verona stream exists before filtering"
+ );
+ casper.test.assertSelectorDoesntHaveText(
+ ".stream-row.notdisplayed .stream-name",
+ "Verona",
+ "Verona stream shown before filtering"
+ );
});
});
casper.then(function () {
casper.evaluate(function () {
- $('#stream_filter input[type="text"]')
- .expectOne()
- .val("waseem")
- .trigger($.Event("input"));
+ $('#stream_filter input[type="text"]').expectOne().val("waseem").trigger($.Event("input"));
});
});
casper.waitForSelectorTextChange(".streams-list", function () {
- casper.test.assertSelectorHasText(".stream-row .stream-name", "Waseemio", "Waseemio stream exists after filtering");
- casper.test.assertSelectorHasText(".stream-row.notdisplayed .stream-name", "Verona", "Verona stream not shown after filtering");
- casper.test.assertSelectorDoesntHaveText(".stream-row.notdisplayed .stream-name", "Waseemio", "Waseemio stream shown after filtering");
+ casper.test.assertSelectorHasText(
+ ".stream-row .stream-name",
+ "Waseemio",
+ "Waseemio stream exists after filtering"
+ );
+ casper.test.assertSelectorHasText(
+ ".stream-row.notdisplayed .stream-name",
+ "Verona",
+ "Verona stream not shown after filtering"
+ );
+ casper.test.assertSelectorDoesntHaveText(
+ ".stream-row.notdisplayed .stream-name",
+ "Waseemio",
+ "Waseemio stream shown after filtering"
+ );
});
common.then_log_out();
diff --git a/frontend_tests/casper_tests/06-settings.js b/frontend_tests/casper_tests/06-settings.js
index b9e71bd49d0..d5123ea0bdc 100644
--- a/frontend_tests/casper_tests/06-settings.js
+++ b/frontend_tests/casper_tests/06-settings.js
@@ -28,7 +28,10 @@ casper.then(function () {
casper.then(function () {
casper.waitUntilVisible("#settings_content .account-settings-form", function () {
- casper.test.assertUrlMatch(/^http:\/\/[^/]+\/#settings/, "URL suggests we are on settings page");
+ casper.test.assertUrlMatch(
+ /^http:\/\/[^/]+\/#settings/,
+ "URL suggests we are on settings page"
+ );
casper.test.assertVisible(".account-settings-form", "Settings page is active");
casper.test.assertNotVisible("#pw_change_controls");
@@ -75,7 +78,11 @@ casper.then(function () {
casper.then(function () {
casper.waitUntilVisible("#show_api_key", function () {
- casper.test.assertMatch(casper.fetchText("#api_key_value"), /[a-zA-Z0-9]{32}/, "Looks like an API key");
+ casper.test.assertMatch(
+ casper.fetchText("#api_key_value"),
+ /[a-zA-Z0-9]{32}/,
+ "Looks like an API key"
+ );
/*
// Change it all back so the next test can still log in
@@ -101,7 +108,8 @@ casper.then(function () {
casper.test.assertMatch(
decodeURIComponent(casper.getElementsAttribute("#download_zuliprc", "href")),
regex_zuliprc,
- "Looks like a zuliprc file");
+ "Looks like a zuliprc file"
+ );
});
});
@@ -141,7 +149,8 @@ casper.then(function () {
casper.test.assertMatch(
decodeURIComponent(casper.getElementsAttribute(button_sel, "href")),
regex_outgoing_webhook_zuliprc,
- "Looks like an outgoing webhook bot ~/.zuliprc file");
+ "Looks like an outgoing webhook bot ~/.zuliprc file"
+ );
});
});
@@ -172,7 +181,8 @@ casper.then(function () {
casper.test.assertMatch(
decodeURIComponent(casper.getElementsAttribute(second_button_sel, "href")),
regex_zuliprc,
- "Looks like a bot ~/.zuliprc file");
+ "Looks like a bot ~/.zuliprc file"
+ );
});
});
@@ -184,36 +194,44 @@ casper.then(function () {
casper.test.assertMatch(
decodeURIComponent(casper.getElementsAttribute("#download_botserverrc", "href")),
regex_botserverrc,
- "Looks like a botserverrc file");
+ "Looks like a botserverrc file"
+ );
});
});
});
casper.then(function () {
- casper.waitUntilVisible('.open_edit_bot_form[data-email="' + bot_email + '"]', function open_edit_bot_form() {
- casper.test.info("Opening edit bot form");
- casper.click('.open_edit_bot_form[data-email="' + bot_email + '"]');
- });
+ casper.waitUntilVisible(
+ '.open_edit_bot_form[data-email="' + bot_email + '"]',
+ function open_edit_bot_form() {
+ casper.test.info("Opening edit bot form");
+ casper.click('.open_edit_bot_form[data-email="' + bot_email + '"]');
+ }
+ );
});
casper.then(function () {
- casper.waitUntilVisible('.edit_bot_form[data-email="' + bot_email + '"]', function test_edit_bot_form_values() {
- var form_sel = '.edit_bot_form[data-email="' + bot_email + '"]';
- casper.test.info("Testing edit bot form values");
-
- // casper.test.assertEqual(
- // common.get_form_field_value(form_sel + ' [name=bot_name]'),
- // 'Bot 1');
- // casper.test.assertEqual(
- // common.get_form_field_value(form_sel + ' [name=bot_default_sending_stream]'),
- // 'Denmark');
- // casper.test.assertEqual(
- // common.get_form_field_value(form_sel + ' [name=bot_default_events_register_stream]'),
- // 'Rome');
- casper.test.assertEqual(
- common.get_form_field_value(form_sel + " [name=bot_name]"),
- "Bot 1");
- });
+ casper.waitUntilVisible(
+ '.edit_bot_form[data-email="' + bot_email + '"]',
+ function test_edit_bot_form_values() {
+ var form_sel = '.edit_bot_form[data-email="' + bot_email + '"]';
+ casper.test.info("Testing edit bot form values");
+
+ // casper.test.assertEqual(
+ // common.get_form_field_value(form_sel + ' [name=bot_name]'),
+ // 'Bot 1');
+ // casper.test.assertEqual(
+ // common.get_form_field_value(form_sel + ' [name=bot_default_sending_stream]'),
+ // 'Denmark');
+ // casper.test.assertEqual(
+ // common.get_form_field_value(form_sel + ' [name=bot_default_events_register_stream]'),
+ // 'Rome');
+ casper.test.assertEqual(
+ common.get_form_field_value(form_sel + " [name=bot_name]"),
+ "Bot 1"
+ );
+ }
+ );
});
casper.then(function () {
@@ -223,7 +241,10 @@ casper.then(function () {
casper.click("#create_alert_word_button");
casper.waitUntilVisible("#alert_word_status", function () {
casper.test.info("Checking that an error is displayed");
- casper.test.assertSelectorHasText(".alert_word_status_text", "Alert word can't be empty!");
+ casper.test.assertSelectorHasText(
+ ".alert_word_status_text",
+ "Alert word can't be empty!"
+ );
casper.test.info("Closing the error message");
casper.click(".close-alert-word-status");
casper.test.info("Checking the error is hidden");
@@ -238,7 +259,10 @@ casper.then(function () {
casper.click("#create_alert_word_button");
casper.test.info("Checking that a success message is displayed");
casper.waitUntilVisible("#alert_word_status", function () {
- casper.test.assertSelectorHasText(".alert_word_status_text", 'Alert word "some phrase" added successfully!');
+ casper.test.assertSelectorHasText(
+ ".alert_word_status_text",
+ 'Alert word "some phrase" added successfully!'
+ );
casper.test.info("Closing the status message");
casper.click(".close-alert-word-status");
casper.test.info("Checking the status message is hidden");
@@ -273,7 +297,10 @@ casper.then(function () {
casper.click("button.remove-alert-word");
casper.test.info("Checking that a success message is displayed");
casper.waitUntilVisible("#alert_word_status", function () {
- casper.test.assertSelectorHasText(".alert_word_status_text", "Alert word removed successfully!");
+ casper.test.assertSelectorHasText(
+ ".alert_word_status_text",
+ "Alert word removed successfully!"
+ );
casper.test.info("Closing the status message");
casper.click(".close-alert-word-status");
casper.test.info("Checking the status message is hidden");
@@ -299,7 +326,10 @@ casper.waitUntilVisible("#default_language_modal");
casper.thenClick('a[data-code="zh-hans"]');
casper.waitUntilVisible("#language-settings-status a", function () {
- casper.test.assertSelectorHasText("#language-settings-status", "Saved. Please reload for the change to take effect.");
+ casper.test.assertSelectorHasText(
+ "#language-settings-status",
+ "Saved. Please reload for the change to take effect."
+ );
casper.test.info("Reloading the page.");
casper.reload();
});
@@ -337,7 +367,10 @@ casper.thenClick('a[data-code="en"]');
* Changing the language back to English so that subsequent tests pass.
*/
casper.waitUntilVisible("#language-settings-status a", function () {
- casper.test.assertSelectorHasText("#language-settings-status", "Gespeichert. Bitte lade die Seite neu um die Änderungen zu aktivieren.");
+ casper.test.assertSelectorHasText(
+ "#language-settings-status",
+ "Gespeichert. Bitte lade die Seite neu um die Änderungen zu aktivieren."
+ );
});
casper.then(function () {
@@ -350,16 +383,28 @@ casper.then(function () {
casper.then(function () {
// At the beginning, `#enable_sounds` will be on and `#enable_stream_audible_notifications`
// will be off by default.
- casper.test.assertVisible("#notification_sound:enabled", "Notification sound selector is enabled");
+ casper.test.assertVisible(
+ "#notification_sound:enabled",
+ "Notification sound selector is enabled"
+ );
casper.click("#enable_stream_audible_notifications");
- casper.test.assertVisible("#notification_sound:enabled", "Notification sound selector is enabled");
+ casper.test.assertVisible(
+ "#notification_sound:enabled",
+ "Notification sound selector is enabled"
+ );
casper.click("#enable_sounds");
- casper.test.assertVisible("#notification_sound:enabled", "Notification sound selector is enabled");
+ casper.test.assertVisible(
+ "#notification_sound:enabled",
+ "Notification sound selector is enabled"
+ );
casper.click("#enable_stream_audible_notifications");
- casper.test.assertVisible("#notification_sound:disabled", "Notification sound selector is disabled");
+ casper.test.assertVisible(
+ "#notification_sound:disabled",
+ "Notification sound selector is disabled"
+ );
});
casper.thenOpen("http://zulip.zulipdev.com:9981/");
diff --git a/frontend_tests/casper_tests/07-stars.js b/frontend_tests/casper_tests/07-stars.js
index bf33c624a06..c19067f4418 100644
--- a/frontend_tests/casper_tests/07-stars.js
+++ b/frontend_tests/casper_tests/07-stars.js
@@ -14,9 +14,7 @@ function toggle_test_star_message() {
return "cannot find test star message";
}
- var star_icon = msg
- .closest(".messagebox")
- .find(".star");
+ var star_icon = msg.closest(".messagebox").find(".star");
if (star_icon.length !== 1) {
return "cannot find star icon";
@@ -52,8 +50,7 @@ casper.then(function () {
casper.test.info("Checking star counts");
// Initially, no messages are starred.
- casper.test.assertEquals(star_count(), 0,
- "Got expected empty star count.");
+ casper.test.assertEquals(star_count(), 0, "Got expected empty star count.");
// Clicking on a message star stars it.
toggle_test_star_message();
@@ -61,8 +58,7 @@ casper.then(function () {
casper.then(function () {
casper.waitUntilVisible("#zhome .fa-star", function () {
- casper.test.assertEquals(star_count(), 1,
- "Got expected single star count.");
+ casper.test.assertEquals(star_count(), 1, "Got expected single star count.");
casper.click('a[href^="#narrow/is/starred"]');
});
@@ -77,8 +73,7 @@ casper.waitUntilVisible("#zfilt", function () {
casper.then(function () {
// Clicking on a starred message unstars it.
toggle_test_star_message();
- casper.test.assertEquals(star_count(), 0,
- "Got expected re-empty star count.");
+ casper.test.assertEquals(star_count(), 0, "Got expected re-empty star count.");
});
common.then_log_out();
diff --git a/frontend_tests/casper_tests/08-edit.js b/frontend_tests/casper_tests/08-edit.js
index 4f11b07274e..bc85149013c 100644
--- a/frontend_tests/casper_tests/08-edit.js
+++ b/frontend_tests/casper_tests/08-edit.js
@@ -59,7 +59,10 @@ casper.then(function () {
});
casper.waitWhileVisible("textarea.message_edit_content", function () {
- casper.test.assertSelectorHasText(".last_message .sender-status", "test edited one line with me");
+ casper.test.assertSelectorHasText(
+ ".last_message .sender-status",
+ "test edited one line with me"
+ );
});
common.then_send_message("private", {
diff --git a/frontend_tests/casper_tests/09-navigation.js b/frontend_tests/casper_tests/09-navigation.js
index 41b43912706..700f0638a00 100644
--- a/frontend_tests/casper_tests/09-navigation.js
+++ b/frontend_tests/casper_tests/09-navigation.js
@@ -98,16 +98,19 @@ casper.then(function () {
casper.then(function () {
// Confirm that's we've actually reloaded using the page load timestamp.
- casper.waitFor(function () {
- return casper.evaluate(function (input) {
- return page_params.page_load_time > input;
- }, initial_page_load_time);
- }, function () {
- // Verify the hash was preserved
- hash = casper.evaluate(function () {
- return window.location.hash;
- });
- });
+ casper.waitFor(
+ function () {
+ return casper.evaluate(function (input) {
+ return page_params.page_load_time > input;
+ }, initial_page_load_time);
+ },
+ function () {
+ // Verify the hash was preserved
+ hash = casper.evaluate(function () {
+ return window.location.hash;
+ });
+ }
+ );
});
casper.then(function () {
diff --git a/frontend_tests/casper_tests/10-admin.js b/frontend_tests/casper_tests/10-admin.js
index 958025cdad5..3fc3da12d52 100644
--- a/frontend_tests/casper_tests/10-admin.js
+++ b/frontend_tests/casper_tests/10-admin.js
@@ -20,8 +20,13 @@ casper.then(function () {
casper.test.info('Changing notifications stream to Verona by filtering with "verona"');
casper.click("#realm_notifications_stream_id_widget button.dropdown-toggle");
casper.waitUntilVisible("#realm_notifications_stream_id_widget ul.dropdown-menu", function () {
- casper.sendKeys("#realm_notifications_stream_id_widget .dropdown-search > input[type=text]", "verona");
- casper.click("#realm_notifications_stream_id_widget .dropdown-list-body > li:nth-of-type(1)");
+ casper.sendKeys(
+ "#realm_notifications_stream_id_widget .dropdown-search > input[type=text]",
+ "verona"
+ );
+ casper.click(
+ "#realm_notifications_stream_id_widget .dropdown-list-body > li:nth-of-type(1)"
+ );
});
});
@@ -51,10 +56,18 @@ casper.then(function () {
casper.then(function () {
casper.test.info('Changing signup notifications stream to Verona by filtering with "verona"');
casper.click("#id_realm_signup_notifications_stream_id > button.dropdown-toggle");
- casper.waitUntilVisible("#realm_signup_notifications_stream_id_widget ul.dropdown-menu", function () {
- casper.sendKeys("#realm_signup_notifications_stream_id_widget .dropdown-search > input[type=text]", "verona");
- casper.click("#realm_signup_notifications_stream_id_widget .dropdown-list-body li.list_item");
- });
+ casper.waitUntilVisible(
+ "#realm_signup_notifications_stream_id_widget ul.dropdown-menu",
+ function () {
+ casper.sendKeys(
+ "#realm_signup_notifications_stream_id_widget .dropdown-search > input[type=text]",
+ "verona"
+ );
+ casper.click(
+ "#realm_signup_notifications_stream_id_widget .dropdown-list-body li.list_item"
+ );
+ }
+ );
});
submit_notifications_stream_settings();
@@ -253,10 +266,14 @@ casper.then(function () {
// Test custom realm emoji
casper.click("li[data-section='emoji-settings']");
casper.waitUntilVisible(".admin-emoji-form", function () {
- casper.fill("form.admin-emoji-form", {
- name: "new mouse face",
- emoji_file_input: "static/images/logo/zulip-icon-128x128.png",
- }, true);
+ casper.fill(
+ "form.admin-emoji-form",
+ {
+ name: "new mouse face",
+ emoji_file_input: "static/images/logo/zulip-icon-128x128.png",
+ },
+ true
+ );
});
});
@@ -294,13 +311,16 @@ function get_suggestions(str) {
function select_from_suggestions(item) {
casper.then(function () {
- casper.evaluate(function (item) {
- var tah = $(".create_default_stream").data().typeahead;
- tah.mouseenter({
- currentTarget: $('.typeahead:visible li:contains("' + item + '")')[0],
- });
- tah.select();
- }, {item: item});
+ casper.evaluate(
+ function (item) {
+ var tah = $(".create_default_stream").data().typeahead;
+ tah.mouseenter({
+ currentTarget: $('.typeahead:visible li:contains("' + item + '")')[0],
+ });
+ tah.select();
+ },
+ {item: item}
+ );
casper.click(".default-stream-form #do_submit_stream");
});
}
@@ -335,19 +355,35 @@ casper.then(function () {
// Test uploading realm icon image
casper.then(function () {
casper.click("li[data-section='organization-profile']");
- var selector = '#realm-icon-upload-widget .image-block[src^="https://secure.gravatar.com/avatar/"]';
+ var selector =
+ '#realm-icon-upload-widget .image-block[src^="https://secure.gravatar.com/avatar/"]';
casper.waitUntilVisible(selector, function () {
- casper.test.assertEqual(casper.visible("#realm-icon-upload-widget .settings-page-delete-button"), false);
+ casper.test.assertEqual(
+ casper.visible("#realm-icon-upload-widget .settings-page-delete-button"),
+ false
+ );
// Hack: Rather than submitting the form, we just fill the
// form and then trigger a click event by clicking the button.
- casper.fill("form.admin-realm-form", {
- file_input: "static/images/logo/zulip-icon-128x128.png",
- }, false);
+ casper.fill(
+ "form.admin-realm-form",
+ {
+ file_input: "static/images/logo/zulip-icon-128x128.png",
+ },
+ false
+ );
casper.click("#realm-icon-upload-widget .image_upload_button");
- casper.waitWhileVisible("#realm-icon-upload-widget .upload-spinner-background", function () {
- casper.test.assertExists('#realm-icon-upload-widget .image-block[src^="/user_avatars/2/realm/icon.png?version=2"]');
- casper.test.assertEqual(casper.visible("#realm-icon-upload-widget .settings-page-delete-button"), true);
- });
+ casper.waitWhileVisible(
+ "#realm-icon-upload-widget .upload-spinner-background",
+ function () {
+ casper.test.assertExists(
+ '#realm-icon-upload-widget .image-block[src^="/user_avatars/2/realm/icon.png?version=2"]'
+ );
+ casper.test.assertEqual(
+ casper.visible("#realm-icon-upload-widget .settings-page-delete-button"),
+ true
+ );
+ }
+ );
});
});
@@ -355,14 +391,21 @@ casper.then(function () {
casper.then(function () {
casper.click("li[data-section='organization-profile']");
casper.click("#realm-icon-upload-widget .settings-page-delete-button");
- casper.test.assertEqual(casper.visible("#realm-icon-upload-widget .settings-page-delete-button"), true);
+ casper.test.assertEqual(
+ casper.visible("#realm-icon-upload-widget .settings-page-delete-button"),
+ true
+ );
casper.waitWhileVisible("#realm-icon-upload-widget .settings-page-delete-button", function () {
- casper.test.assertExists('#realm-icon-upload-widget .image-block[src^="https://secure.gravatar.com/avatar/"]');
- casper.test.assertEqual(casper.visible("#realm-icon-upload-widget .settings-page-delete-button"), false);
+ casper.test.assertExists(
+ '#realm-icon-upload-widget .image-block[src^="https://secure.gravatar.com/avatar/"]'
+ );
+ casper.test.assertEqual(
+ casper.visible("#realm-icon-upload-widget .settings-page-delete-button"),
+ false
+ );
});
});
-
casper.then(function () {
casper.click("li[data-section='organization-settings']");
casper.waitUntilVisible("#id_realm_default_language", function () {
@@ -377,19 +420,21 @@ casper.then(function () {
casper.then(function () {
casper.waitUntilVisible('#org-submit-user-defaults[data-status="saved"]', function () {
- casper.test.assertSelectorHasText("#org-submit-user-defaults",
- "Saved");
+ casper.test.assertSelectorHasText("#org-submit-user-defaults", "Saved");
});
});
// Test authentication methods setting
casper.then(function () {
casper.click("li[data-section='auth-methods']");
- casper.waitUntilVisible(".method_row[data-method='Google'] input[type='checkbox'] + span", function () {
- casper.click(".method_row[data-method='Google'] input[type='checkbox'] + span");
- casper.test.assertSelectorHasText("#org-submit-auth_settings", "Save");
- casper.click("#org-submit-auth_settings");
- });
+ casper.waitUntilVisible(
+ ".method_row[data-method='Google'] input[type='checkbox'] + span",
+ function () {
+ casper.click(".method_row[data-method='Google'] input[type='checkbox'] + span");
+ casper.test.assertSelectorHasText("#org-submit-auth_settings", "Save");
+ casper.click("#org-submit-auth_settings");
+ }
+ );
});
casper.then(function () {
@@ -400,12 +445,17 @@ casper.then(function () {
casper.click('a[href^="#organization"]');
casper.click("li[data-section='auth-methods']");
- casper.waitUntilVisible(".method_row[data-method='Google'] input[type='checkbox'] + span", function () {
- // Test Setting was saved
- casper.test.assertEval(function () {
- return !document.querySelector(".method_row[data-method='Google'] input[type='checkbox']").checked;
- });
- });
+ casper.waitUntilVisible(
+ ".method_row[data-method='Google'] input[type='checkbox'] + span",
+ function () {
+ // Test Setting was saved
+ casper.test.assertEval(function () {
+ return !document.querySelector(
+ ".method_row[data-method='Google'] input[type='checkbox']"
+ ).checked;
+ });
+ }
+ );
});
common.then_log_out();
diff --git a/frontend_tests/casper_tests/11-mention.js b/frontend_tests/casper_tests/11-mention.js
index 094aa8b1417..57a848f1167 100644
--- a/frontend_tests/casper_tests/11-mention.js
+++ b/frontend_tests/casper_tests/11-mention.js
@@ -32,11 +32,18 @@ casper.then(function () {
});
casper.then(function () {
- common.wait_for_text(".compose-all-everyone-msg", "Are you sure you want to mention all", function () {
- casper.test.info("Warning message appears when mentioning @**all**");
- casper.test.assertSelectorHasText(".compose-all-everyone-msg", "Are you sure you want to mention all");
- casper.click(".compose-all-everyone-confirm");
- });
+ common.wait_for_text(
+ ".compose-all-everyone-msg",
+ "Are you sure you want to mention all",
+ function () {
+ casper.test.info("Warning message appears when mentioning @**all**");
+ casper.test.assertSelectorHasText(
+ ".compose-all-everyone-msg",
+ "Are you sure you want to mention all"
+ );
+ casper.click(".compose-all-everyone-confirm");
+ }
+ );
casper.waitWhileVisible(".compose-all-everyone-confirm", function () {
casper.test.info("Check that error messages are gone.");
@@ -46,12 +53,13 @@ casper.then(function () {
});
casper.then(function () {
- common.expected_messages("zhome", ["Verona > Test mention all"],
- ["<p><span class=\"user-mention user-mention-me\" " +
- "data-user-id=\"*\">@all</span></p>"]);
+ common.expected_messages(
+ "zhome",
+ ["Verona > Test mention all"],
+ ['<p><span class="user-mention user-mention-me" ' + 'data-user-id="*">@all</span></p>']
+ );
});
-
common.then_log_out();
casper.run(function () {
diff --git a/frontend_tests/casper_tests/12-custom-profile.js b/frontend_tests/casper_tests/12-custom-profile.js
index 75d120ab6fa..659888d96b6 100644
--- a/frontend_tests/casper_tests/12-custom-profile.js
+++ b/frontend_tests/casper_tests/12-custom-profile.js
@@ -21,8 +21,14 @@ casper.then(function () {
casper.waitUntilVisible("#admin-add-profile-field-status img", function () {
casper.test.assertSelectorHasText("div#admin-add-profile-field-status", "Saved");
common.wait_for_text(".profile-field-row span.profile_field_name", "Teams", function () {
- casper.test.assertSelectorHasText(".profile-field-row span.profile_field_name", "Teams");
- casper.test.assertSelectorHasText(".profile-field-row span.profile_field_type", "Short text");
+ casper.test.assertSelectorHasText(
+ ".profile-field-row span.profile_field_name",
+ "Teams"
+ );
+ casper.test.assertSelectorHasText(
+ ".profile-field-row span.profile_field_type",
+ "Short text"
+ );
casper.click(".profile-field-row button.open-edit-form");
});
});
@@ -43,7 +49,10 @@ casper.then(function () {
});
casper.waitForSelectorTextChange(".profile-field-row span.profile_field_name", function () {
casper.test.assertSelectorHasText(".profile-field-row span.profile_field_name", "team");
- casper.test.assertSelectorHasText(".profile-field-row span.profile_field_type", "Short text");
+ casper.test.assertSelectorHasText(
+ ".profile-field-row span.profile_field_type",
+ "Short text"
+ );
casper.click(".profile-field-row button.delete");
});
});
@@ -54,7 +63,6 @@ casper.then(function () {
});
});
-
common.then_log_out();
casper.run(function () {
diff --git a/frontend_tests/casper_tests/13-user-deactivation.js b/frontend_tests/casper_tests/13-user-deactivation.js
index c66ec15985a..cdb15ccd485 100644
--- a/frontend_tests/casper_tests/13-user-deactivation.js
+++ b/frontend_tests/casper_tests/13-user-deactivation.js
@@ -27,7 +27,10 @@ casper.then(function () {
casper.waitUntilVisible(user_row("cordelia"), function () {
casper.test.assertExists(".fa-user-times", "Deactivate icon available");
casper.click(user_row("cordelia") + " .deactivate");
- casper.test.assertTextExists("Deactivate [email protected]", "Deactivate modal has right user");
+ casper.test.assertTextExists(
+ "Deactivate [email protected]",
+ "Deactivate modal has right user"
+ );
casper.test.assertTextExists("Deactivate now", "Deactivate now button available");
casper.click("#deactivation_user_modal .do_deactivate_button");
});
@@ -51,7 +54,10 @@ casper.then(function () {
casper.waitUntilVisible(user_row("cordelia"), function () {
casper.test.assertExists(".fa-user-times", "Deactivate icon available");
casper.click(user_row("cordelia") + " .deactivate");
- casper.test.assertTextExists("Deactivate [email protected]", "Deactivate modal has right user");
+ casper.test.assertTextExists(
+ "Deactivate [email protected]",
+ "Deactivate modal has right user"
+ );
casper.test.assertTextExists("Deactivate now", "Deactivate now button available");
casper.click("#deactivation_user_modal .do_deactivate_button");
});
@@ -61,25 +67,36 @@ casper.then(function () {
// Leave the page and return
casper.reload();
- casper.test.assertSelectorHasText("li[data-section='deactivated-users-admin']", "Deactivated users");
+ casper.test.assertSelectorHasText(
+ "li[data-section='deactivated-users-admin']",
+ "Deactivated users"
+ );
casper.click("li[data-section='deactivated-users-admin']");
-
- casper.waitUntilVisible("#admin_deactivated_users_table " + user_row("cordelia") + " .reactivate", function () {
- casper.test.assertExists(".fa-user-plus", "Reactive icon available");
- casper.click("#admin_deactivated_users_table " + user_row("cordelia") + " .reactivate");
- });
+ casper.waitUntilVisible(
+ "#admin_deactivated_users_table " + user_row("cordelia") + " .reactivate",
+ function () {
+ casper.test.assertExists(".fa-user-plus", "Reactive icon available");
+ casper.click("#admin_deactivated_users_table " + user_row("cordelia") + " .reactivate");
+ }
+ );
});
casper.then(function () {
- casper.waitUntilVisible("#admin_deactivated_users_table " + user_row("cordelia") + " button:not(.reactivate)", function () {
- casper.test.assertExists(".fa-user-times", "Deactivate icon available");
- });
+ casper.waitUntilVisible(
+ "#admin_deactivated_users_table " + user_row("cordelia") + " button:not(.reactivate)",
+ function () {
+ casper.test.assertExists(".fa-user-times", "Deactivate icon available");
+ }
+ );
});
// Test bot deactivation and reactivation
casper.then(function () {
- casper.test.assertSelectorHasText("li[data-section='organization-settings']", "Organization settings");
+ casper.test.assertSelectorHasText(
+ "li[data-section='organization-settings']",
+ "Organization settings"
+ );
casper.click("li[data-section='bot-list-admin']");
});
diff --git a/frontend_tests/casper_tests/14-drafts.js b/frontend_tests/casper_tests/14-drafts.js
index f524ee493ad..46aed73317d 100644
--- a/frontend_tests/casper_tests/14-drafts.js
+++ b/frontend_tests/casper_tests/14-drafts.js
@@ -3,8 +3,7 @@ var common = require("../casper_lib/common.js");
function waitWhileDraftsVisible(then) {
casper.waitFor(function () {
return casper.evaluate(function () {
- return $("#draft_overlay").length === 0 ||
- $("#draft_overlay").css("opacity") === "0";
+ return $("#draft_overlay").length === 0 || $("#draft_overlay").css("opacity") === "0";
});
}, then);
}
@@ -12,8 +11,7 @@ function waitWhileDraftsVisible(then) {
function waitUntilDraftsVisible(then) {
casper.waitFor(function () {
return casper.evaluate(function () {
- return $("#draft_overlay").length === 1 &&
- $("#draft_overlay").css("opacity") === "1";
+ return $("#draft_overlay").length === 1 && $("#draft_overlay").css("opacity") === "1";
});
}, then);
}
@@ -29,15 +27,13 @@ casper.then(function () {
});
casper.then(function () {
- casper.test.assertUrlMatch(/^http:\/\/[^/]+\/#drafts/,
- "URL suggests we are on drafts page");
+ casper.test.assertUrlMatch(/^http:\/\/[^/]+\/#drafts/, "URL suggests we are on drafts page");
waitUntilDraftsVisible(function () {
casper.test.assertExists("#draft_overlay", "Drafts page is active");
casper.test.assertSelectorHasText(".no-drafts", "No drafts.");
});
});
-
casper.then(function () {
casper.click("#draft_overlay .exit");
waitWhileDraftsVisible();
@@ -48,11 +44,15 @@ casper.then(function () {
casper.click("body");
casper.page.sendEvent("keypress", "c");
casper.waitUntilVisible("#stream-message", function () {
- casper.fill("form#send_message_form", {
- stream_message_recipient_stream: "all",
- stream_message_recipient_topic: "tests",
- content: "Test Stream Message",
- }, false);
+ casper.fill(
+ "form#send_message_form",
+ {
+ stream_message_recipient_stream: "all",
+ stream_message_recipient_topic: "tests",
+ content: "Test Stream Message",
+ },
+ false
+ );
casper.click("#compose_close");
});
});
@@ -62,9 +62,13 @@ casper.then(function () {
casper.click("body");
casper.page.sendEvent("keypress", "x");
casper.waitUntilVisible("#private-message", function () {
- casper.fill("form#send_message_form", {
- content: "Test Private Message",
- }, false);
+ casper.fill(
+ "form#send_message_form",
+ {
+ content: "Test Private Message",
+ },
+ false
+ );
common.pm_recipient.set("[email protected], [email protected]");
casper.click("#compose_close");
});
@@ -91,12 +95,23 @@ casper.then(function () {
casper.test.assertElementCount(".draft-row", 2, "Drafts loaded");
casper.test.assertSelectorHasText(".draft-row .message_header_stream .stream_label", "all");
- casper.test.assertSelectorHasText(".draft-row .message_header_stream .stream_topic", "tests");
- casper.test.assertTextExists("Test Stream Message", "Stream draft contains message content");
+ casper.test.assertSelectorHasText(
+ ".draft-row .message_header_stream .stream_topic",
+ "tests"
+ );
+ casper.test.assertTextExists(
+ "Test Stream Message",
+ "Stream draft contains message content"
+ );
- casper.test.assertSelectorHasText(".draft-row .message_header_private_message .stream_label",
- "You and Cordelia Lear, King Hamlet");
- casper.test.assertTextExists("Test Private Message", "Private draft contains message content");
+ casper.test.assertSelectorHasText(
+ ".draft-row .message_header_private_message .stream_label",
+ "You and Cordelia Lear, King Hamlet"
+ );
+ casper.test.assertTextExists(
+ "Test Private Message",
+ "Private draft contains message content"
+ );
});
});
@@ -106,22 +121,34 @@ casper.then(function () {
waitWhileDraftsVisible(function () {
casper.test.assertVisible("#stream-message", "Stream Message Box Restored");
casper.test.assertNotVisible("#preview_message_area", "Preview Was Hidden");
- common.check_form("form#send_message_form", {
- stream_message_recipient_stream: "all",
- stream_message_recipient_topic: "tests",
- content: "Test Stream Message",
- }, "Stream message box filled with draft content");
- casper.test.assertSelectorHasText("title", "tests - Zulip Dev - Zulip", "Narrowed to topic");
+ common.check_form(
+ "form#send_message_form",
+ {
+ stream_message_recipient_stream: "all",
+ stream_message_recipient_topic: "tests",
+ content: "Test Stream Message",
+ },
+ "Stream message box filled with draft content"
+ );
+ casper.test.assertSelectorHasText(
+ "title",
+ "tests - Zulip Dev - Zulip",
+ "Narrowed to topic"
+ );
});
});
casper.then(function () {
casper.test.info("Editing Stream Message Draft");
- casper.fill("form#send_message_form", {
- stream_message_recipient_stream: "all",
- stream_message_recipient_topic: "tests",
- content: "Updated Stream Message",
- }, false);
+ casper.fill(
+ "form#send_message_form",
+ {
+ stream_message_recipient_stream: "all",
+ stream_message_recipient_topic: "tests",
+ content: "Updated Stream Message",
+ },
+ false
+ );
casper.click("#compose_close");
});
@@ -134,8 +161,14 @@ casper.then(function () {
casper.then(function () {
waitUntilDraftsVisible(function () {
casper.test.assertSelectorHasText(".draft-row .message_header_stream .stream_label", "all");
- casper.test.assertSelectorHasText(".draft-row .message_header_stream .stream_topic", "tests");
- casper.test.assertTextExists("Updated Stream Message", "Stream draft contains message content");
+ casper.test.assertSelectorHasText(
+ ".draft-row .message_header_stream .stream_topic",
+ "tests"
+ );
+ casper.test.assertTextExists(
+ "Updated Stream Message",
+ "Stream draft contains message content"
+ );
});
});
@@ -144,11 +177,19 @@ casper.then(function () {
casper.click("#drafts_table .message_row.private-message .restore-draft");
waitWhileDraftsVisible(function () {
casper.test.assertVisible("#private-message", "Private Message Box Restored");
- common.check_form("form#send_message_form", {
- content: "Test Private Message",
- }, "Private message box filled with draft content");
+ common.check_form(
+ "form#send_message_form",
+ {
+ content: "Test Private Message",
+ },
+ "Private message box filled with draft content"
+ );
common.pm_recipient.expect("[email protected],[email protected]");
- casper.test.assertSelectorHasText("title", "Cordelia Lear, King Hamlet - Zulip Dev - Zulip", "Narrowed to huddle");
+ casper.test.assertSelectorHasText(
+ "title",
+ "Cordelia Lear, King Hamlet - Zulip Dev - Zulip",
+ "Narrowed to huddle"
+ );
});
});
@@ -177,9 +218,13 @@ casper.then(function () {
casper.then(function () {
casper.waitUntilVisible("#private-message", function () {
- casper.fill("form#send_message_form", {
- content: "Test Private Message",
- }, false);
+ casper.fill(
+ "form#send_message_form",
+ {
+ content: "Test Private Message",
+ },
+ false
+ );
common.pm_recipient.set("[email protected]");
});
casper.reload();
@@ -201,8 +246,10 @@ casper.then(function () {
casper.test.info("Checking drafts survived the reload");
waitUntilDraftsVisible(function () {
casper.test.assertElementCount(".draft-row", 2, "Drafts loaded");
- casper.test.assertSelectorHasText(".draft-row .message_header_private_message .stream_label",
- "You and Cordelia Lear");
+ casper.test.assertSelectorHasText(
+ ".draft-row .message_header_private_message .stream_label",
+ "You and Cordelia Lear"
+ );
casper.test.assertTextExists("Test Private Message");
});
});
diff --git a/frontend_tests/casper_tests/15-delete-message.js b/frontend_tests/casper_tests/15-delete-message.js
index e0f60200cb7..7d26d37830f 100644
--- a/frontend_tests/casper_tests/15-delete-message.js
+++ b/frontend_tests/casper_tests/15-delete-message.js
@@ -5,7 +5,6 @@ common.start_and_log_in();
var last_message_id;
var msgs_qty;
-
casper.then(function () {
casper.waitUntilVisible("#zhome");
});
diff --git a/frontend_tests/casper_tests/16-copy-and-paste.js b/frontend_tests/casper_tests/16-copy-and-paste.js
index 774552ba7a1..eb666528ac9 100644
--- a/frontend_tests/casper_tests/16-copy-and-paste.js
+++ b/frontend_tests/casper_tests/16-copy-and-paste.js
@@ -8,42 +8,39 @@ casper.then(function () {
// setup environment: several messages to different topics
common.then_send_many([
- {stream: "Verona", subject: "copy-paste-subject #1",
- content: "copy paste test A"},
+ {stream: "Verona", subject: "copy-paste-subject #1", content: "copy paste test A"},
- {stream: "Verona", subject: "copy-paste-subject #1",
- content: "copy paste test B"},
+ {stream: "Verona", subject: "copy-paste-subject #1", content: "copy paste test B"},
- {stream: "Verona", subject: "copy-paste-subject #2",
- content: "copy paste test C"},
+ {stream: "Verona", subject: "copy-paste-subject #2", content: "copy paste test C"},
- {stream: "Verona", subject: "copy-paste-subject #2",
- content: "copy paste test D"},
+ {stream: "Verona", subject: "copy-paste-subject #2", content: "copy paste test D"},
- {stream: "Verona", subject: "copy-paste-subject #2",
- content: "copy paste test E"},
+ {stream: "Verona", subject: "copy-paste-subject #2", content: "copy paste test E"},
- {stream: "Verona", subject: "copy-paste-subject #3",
- content: "copy paste test F"},
+ {stream: "Verona", subject: "copy-paste-subject #3", content: "copy paste test F"},
- {stream: "Verona", subject: "copy-paste-subject #3",
- content: "copy paste test G"},
+ {stream: "Verona", subject: "copy-paste-subject #3", content: "copy paste test G"},
]);
common.wait_for_receive(function () {
- common.expected_messages("zhome", [
- "Verona > copy-paste-subject #1",
- "Verona > copy-paste-subject #2",
- "Verona > copy-paste-subject #3",
- ], [
- "<p>copy paste test A</p>",
- "<p>copy paste test B</p>",
- "<p>copy paste test C</p>",
- "<p>copy paste test D</p>",
- "<p>copy paste test E</p>",
- "<p>copy paste test F</p>",
- "<p>copy paste test G</p>",
- ]);
+ common.expected_messages(
+ "zhome",
+ [
+ "Verona > copy-paste-subject #1",
+ "Verona > copy-paste-subject #2",
+ "Verona > copy-paste-subject #3",
+ ],
+ [
+ "<p>copy paste test A</p>",
+ "<p>copy paste test B</p>",
+ "<p>copy paste test C</p>",
+ "<p>copy paste test D</p>",
+ "<p>copy paste test E</p>",
+ "<p>copy paste test F</p>",
+ "<p>copy paste test G</p>",
+ ]
+ );
});
casper.then(function () {
@@ -55,58 +52,86 @@ function get_message_node(message) {
}
function copy_messages(start_message, end_message) {
- return casper.evaluate(function (get_message_node, start_message, end_message) {
- // select messages from start_message to end_message
- var selectedRange = document.createRange();
- selectedRange.setStart(get_message_node(start_message));
- selectedRange.setEnd(get_message_node(end_message));
- window.getSelection().removeAllRanges();
- window.getSelection().addRange(selectedRange);
-
- // Remove existing copy/paste divs, which may linger from the previous
- // example. (The code clears these out with a zero-second timeout, which
- // is probably sufficient for human users, but which causes problems here.)
- $("#copytempdiv").remove();
-
- // emulate copy event
- $("body").trigger($.Event("keydown", {which: 67, ctrlKey: true}));
-
- // find temp div with copied text
- var temp_div = $("#copytempdiv");
- return temp_div.children("p").get().map(function (p) { return p.textContent; });
- }, {
- get_message_node: get_message_node,
- start_message: start_message,
- end_message: end_message,
- });
+ return casper.evaluate(
+ function (get_message_node, start_message, end_message) {
+ // select messages from start_message to end_message
+ var selectedRange = document.createRange();
+ selectedRange.setStart(get_message_node(start_message));
+ selectedRange.setEnd(get_message_node(end_message));
+ window.getSelection().removeAllRanges();
+ window.getSelection().addRange(selectedRange);
+
+ // Remove existing copy/paste divs, which may linger from the previous
+ // example. (The code clears these out with a zero-second timeout, which
+ // is probably sufficient for human users, but which causes problems here.)
+ $("#copytempdiv").remove();
+
+ // emulate copy event
+ $("body").trigger($.Event("keydown", {which: 67, ctrlKey: true}));
+
+ // find temp div with copied text
+ var temp_div = $("#copytempdiv");
+ return temp_div
+ .children("p")
+ .get()
+ .map(function (p) {
+ return p.textContent;
+ });
+ },
+ {
+ get_message_node: get_message_node,
+ start_message: start_message,
+ end_message: end_message,
+ }
+ );
}
// test copying first message from topic
casper.then(function () {
var actual_copied_lines = copy_messages("copy paste test C", "copy paste test C");
var expected_copied_lines = [];
- casper.test.assertEquals(actual_copied_lines, expected_copied_lines, "Copying was handled by browser");
+ casper.test.assertEquals(
+ actual_copied_lines,
+ expected_copied_lines,
+ "Copying was handled by browser"
+ );
});
// test copying last message from topic
casper.then(function () {
var actual_copied_lines = copy_messages("copy paste test E", "copy paste test E");
var expected_copied_lines = [];
- casper.test.assertEquals(actual_copied_lines, expected_copied_lines, "Copying was handled by browser");
+ casper.test.assertEquals(
+ actual_copied_lines,
+ expected_copied_lines,
+ "Copying was handled by browser"
+ );
});
// test copying two first messages from topic
casper.then(function () {
var actual_copied_lines = copy_messages("copy paste test C", "copy paste test D");
var expected_copied_lines = ["Iago: copy paste test C", "Iago: copy paste test D"];
- casper.test.assertEquals(actual_copied_lines, expected_copied_lines, "Copying was handled by custom handler");
+ casper.test.assertEquals(
+ actual_copied_lines,
+ expected_copied_lines,
+ "Copying was handled by custom handler"
+ );
});
// test copying all messages from topic
casper.then(function () {
var actual_copied_lines = copy_messages("copy paste test C", "copy paste test E");
- var expected_copied_lines = ["Iago: copy paste test C", "Iago: copy paste test D", "Iago: copy paste test E"];
- casper.test.assertEquals(actual_copied_lines, expected_copied_lines, "Copying was handled by custom handler");
+ var expected_copied_lines = [
+ "Iago: copy paste test C",
+ "Iago: copy paste test D",
+ "Iago: copy paste test E",
+ ];
+ casper.test.assertEquals(
+ actual_copied_lines,
+ expected_copied_lines,
+ "Copying was handled by custom handler"
+ );
});
// test copying last message from previous topic and first message from next topic
@@ -118,7 +143,11 @@ casper.then(function () {
"Verona > copy-paste-subject #2 Today",
"Iago: copy paste test C",
];
- casper.test.assertEquals(actual_copied_lines, expected_copied_lines, "Copying was handled by custom handler");
+ casper.test.assertEquals(
+ actual_copied_lines,
+ expected_copied_lines,
+ "Copying was handled by custom handler"
+ );
});
// test copying last message from previous topic and all messages from next topic
@@ -132,7 +161,11 @@ casper.then(function () {
"Iago: copy paste test D",
"Iago: copy paste test E",
];
- casper.test.assertEquals(actual_copied_lines, expected_copied_lines, "Copying was handled by custom handler");
+ casper.test.assertEquals(
+ actual_copied_lines,
+ expected_copied_lines,
+ "Copying was handled by custom handler"
+ );
});
// test copying all messages from previous topic and first message from next topic
@@ -145,7 +178,11 @@ casper.then(function () {
"Verona > copy-paste-subject #2 Today",
"Iago: copy paste test C",
];
- casper.test.assertEquals(actual_copied_lines, expected_copied_lines, "Copying was handled by custom handler");
+ casper.test.assertEquals(
+ actual_copied_lines,
+ expected_copied_lines,
+ "Copying was handled by custom handler"
+ );
});
// test copying message from several topics
@@ -161,7 +198,11 @@ casper.then(function () {
"Verona > copy-paste-subject #3 Today",
"Iago: copy paste test F",
];
- casper.test.assertEquals(actual_copied_lines, expected_copied_lines, "Copying was handled by custom handler");
+ casper.test.assertEquals(
+ actual_copied_lines,
+ expected_copied_lines,
+ "Copying was handled by custom handler"
+ );
});
// Run the above queued actions.
diff --git a/frontend_tests/casper_tests/17-realm-linkifier.js b/frontend_tests/casper_tests/17-realm-linkifier.js
index 1a4a8411df1..a2d5f452735 100644
--- a/frontend_tests/casper_tests/17-realm-linkifier.js
+++ b/frontend_tests/casper_tests/17-realm-linkifier.js
@@ -25,7 +25,10 @@ casper.then(function () {
casper.then(function () {
casper.waitUntilVisible(".filter_row", function () {
casper.test.assertSelectorHasText(".filter_row span.filter_pattern", "#(?P<id>[0-9]+)");
- casper.test.assertSelectorHasText(".filter_row span.filter_url_format_string", "https://trac.example.com/ticket/%(id)s");
+ casper.test.assertSelectorHasText(
+ ".filter_row span.filter_url_format_string",
+ "https://trac.example.com/ticket/%(id)s"
+ );
casper.click(".filter_row button");
});
});
@@ -48,7 +51,10 @@ casper.then(function () {
casper.then(function () {
casper.waitUntilVisible("div#admin-filter-pattern-status", function () {
- casper.test.assertSelectorHasText("div#admin-filter-pattern-status", "Failed: Invalid filter pattern");
+ casper.test.assertSelectorHasText(
+ "div#admin-filter-pattern-status",
+ "Failed: Invalid filter pattern"
+ );
});
});
diff --git a/frontend_tests/node_tests/activity.js b/frontend_tests/node_tests/activity.js
index 56721b68f59..068002376ec 100644
--- a/frontend_tests/node_tests/activity.js
+++ b/frontend_tests/node_tests/activity.js
@@ -166,11 +166,7 @@ run_test("sort_users", () => {
buddy_data.sort_users(user_ids);
- assert.deepEqual(user_ids, [
- fred.user_id,
- jill.user_id,
- alice.user_id,
- ]);
+ assert.deepEqual(user_ids, [fred.user_id, jill.user_id, alice.user_id]);
});
run_test("huddle_data.process_loaded_messages", () => {
diff --git a/frontend_tests/node_tests/alert_words.js b/frontend_tests/node_tests/alert_words.js
index 5fbdac320b0..1ddd1a2bc73 100644
--- a/frontend_tests/node_tests/alert_words.js
+++ b/frontend_tests/node_tests/alert_words.js
@@ -62,13 +62,15 @@ const question_word_message = {
const alert_domain_message = {
sender_email: "[email protected]",
- content: '<p>now with link <a href="http://www.alerttwo.us/foo/bar" target="_blank" title="http://www.alerttwo.us/foo/bar">www.alerttwo.us/foo/bar</a></p>',
+ content:
+ '<p>now with link <a href="http://www.alerttwo.us/foo/bar" target="_blank" title="http://www.alerttwo.us/foo/bar">www.alerttwo.us/foo/bar</a></p>',
alerted: true,
};
// This test ensure we are not mucking up rendered HTML content.
const message_with_emoji = {
sender_email: "[email protected]",
- content: '<p>I <img alt=":heart:" class="emoji" src="/static/generated/emoji/images/emoji/unicode/2764.png" title="heart"> emoji!</p>',
+ content:
+ '<p>I <img alt=":heart:" class="emoji" src="/static/generated/emoji/images/emoji/unicode/2764.png" title="heart"> emoji!</p>',
alerted: true,
};
@@ -94,27 +96,48 @@ run_test("munging", () => {
assert.equal(alertwordboundary_message.content, saved_content);
alert_words.process_message(other_message);
- assert.equal(other_message.content, "<p>another <span class='alert-word'>alertone</span> message</p>");
+ assert.equal(
+ other_message.content,
+ "<p>another <span class='alert-word'>alertone</span> message</p>",
+ );
alert_words.process_message(caps_message);
- assert.equal(caps_message.content, "<p>another <span class='alert-word'>ALERTtwo</span> message</p>");
+ assert.equal(
+ caps_message.content,
+ "<p>another <span class='alert-word'>ALERTtwo</span> message</p>",
+ );
alert_words.process_message(multialert_message);
- assert.equal(multialert_message.content, "<p>another alertthreemessage <span class='alert-word'>alertone</span> and then <span class='alert-word'>alerttwo</span></p>");
+ assert.equal(
+ multialert_message.content,
+ "<p>another alertthreemessage <span class='alert-word'>alertone</span> and then <span class='alert-word'>alerttwo</span></p>",
+ );
alert_words.process_message(unsafe_word_message);
- assert.equal(unsafe_word_message.content, "<p>gotta <span class='alert-word'>al*rt.*s</span> all</p>");
+ assert.equal(
+ unsafe_word_message.content,
+ "<p>gotta <span class='alert-word'>al*rt.*s</span> all</p>",
+ );
alert_words.process_message(alert_in_url_message);
assert.equal(alert_in_url_message.content, "<p>http://www.google.com/alertone/me</p>");
alert_words.process_message(question_word_message);
- assert.equal(question_word_message.content, "<p>still <span class='alert-word'>alertone</span>? me</p>");
+ assert.equal(
+ question_word_message.content,
+ "<p>still <span class='alert-word'>alertone</span>? me</p>",
+ );
alert_words.process_message(alert_domain_message);
- assert.equal(alert_domain_message.content, "<p>now with link <a href=\"http://www.alerttwo.us/foo/bar\" target=\"_blank\" title=\"http://www.alerttwo.us/foo/bar\">www.<span class='alert-word'>alerttwo</span>.us/foo/bar</a></p>");
+ assert.equal(
+ alert_domain_message.content,
+ '<p>now with link <a href="http://www.alerttwo.us/foo/bar" target="_blank" title="http://www.alerttwo.us/foo/bar">www.<span class=\'alert-word\'>alerttwo</span>.us/foo/bar</a></p>',
+ );
alert_words.process_message(message_with_emoji);
- assert.equal(message_with_emoji.content, "<p>I <img alt=\":heart:\" class=\"emoji\" src=\"/static/generated/emoji/images/emoji/unicode/2764.png\" title=\"heart\"> <span class='alert-word'>emoji</span>!</p>");
+ assert.equal(
+ message_with_emoji.content,
+ '<p>I <img alt=":heart:" class="emoji" src="/static/generated/emoji/images/emoji/unicode/2764.png" title="heart"> <span class=\'alert-word\'>emoji</span>!</p>',
+ );
});
run_test("basic get/set operations", () => {
diff --git a/frontend_tests/node_tests/alert_words_ui.js b/frontend_tests/node_tests/alert_words_ui.js
index 0d54c2c8ab5..6993dae0ae7 100644
--- a/frontend_tests/node_tests/alert_words_ui.js
+++ b/frontend_tests/node_tests/alert_words_ui.js
@@ -29,10 +29,7 @@ run_test("render_alert_words_ui", () => {
alert_words_ui.render_alert_words_ui();
- assert.deepEqual(appended, [
- "stub-bar",
- "stub-foo",
- ]);
+ assert.deepEqual(appended, ["stub-bar", "stub-foo"]);
assert(new_alert_word.is_focused());
});
@@ -87,7 +84,7 @@ run_test("add_alert_word", () => {
// test success
success_func();
assert(alert_word_status.hasClass("alert-success"));
- assert.equal(alert_word_status_text.text(), "translated: Alert word \"zot\" added successfully!");
+ assert.equal(alert_word_status_text.text(), 'translated: Alert word "zot" added successfully!');
assert(alert_word_status.visible());
});
diff --git a/frontend_tests/node_tests/billing.js b/frontend_tests/node_tests/billing.js
index ef62f034330..a2971bbb914 100644
--- a/frontend_tests/node_tests/billing.js
+++ b/frontend_tests/node_tests/billing.js
@@ -7,7 +7,9 @@ const dom = new JSDOM(template, {pretendToBeVisual: true});
const document = dom.window.document;
let jquery_init;
-global.$ = (f) => {jquery_init = f;};
+global.$ = (f) => {
+ jquery_init = f;
+};
set_global("helpers", {
set_tab: noop,
});
@@ -62,7 +64,8 @@ run_test("initialize", () => {
};
};
- $("#payment-method").data = (key) => document.querySelector("#payment-method").getAttribute("data-" + key);
+ $("#payment-method").data = (key) =>
+ document.querySelector("#payment-method").getAttribute("data-" + key);
jquery_init();
diff --git a/frontend_tests/node_tests/billing_helpers.js b/frontend_tests/node_tests/billing_helpers.js
index bcef890007b..71f71f64076 100644
--- a/frontend_tests/node_tests/billing_helpers.js
+++ b/frontend_tests/node_tests/billing_helpers.js
@@ -101,7 +101,6 @@ run_test("create_ajax_request", () => {
state.free_trial_alert_message_hide += 1;
};
-
$("#autopay-form").serializeArray = () => jquery("#autopay-form").serializeArray();
$.post = ({url, data, success, error}) => {
@@ -164,8 +163,9 @@ run_test("create_ajax_request", () => {
assert.equal(state.free_trial_alert_message_show, 1);
};
- helpers.create_ajax_request("/json/billing/upgrade", "autopay", {id: "stripe_token_id"}, ["licenses"]);
-
+ helpers.create_ajax_request("/json/billing/upgrade", "autopay", {id: "stripe_token_id"}, [
+ "licenses",
+ ]);
});
run_test("format_money", () => {
diff --git a/frontend_tests/node_tests/bot_data.js b/frontend_tests/node_tests/bot_data.js
index 26509d4360f..4d058208c33 100644
--- a/frontend_tests/node_tests/bot_data.js
+++ b/frontend_tests/node_tests/bot_data.js
@@ -24,13 +24,17 @@ people.add_active_user(fred);
people.initialize_current_user(me.user_id);
const bot_data_params = {
- realm_bots: [{email: "[email protected]", user_id: 42, full_name: "Bot 0",
- services: []},
- {email: "[email protected]", user_id: 314, full_name: "Outgoing webhook",
- services: [{base_url: "http://foo.com", interface: 1}]}],
+ realm_bots: [
+ {email: "[email protected]", user_id: 42, full_name: "Bot 0", services: []},
+ {
+ email: "[email protected]",
+ user_id: 314,
+ full_name: "Outgoing webhook",
+ services: [{base_url: "http://foo.com", interface: 1}],
+ },
+ ],
};
-
bot_data.initialize(bot_data_params);
// Our startup logic should have added Bot 0 from page_params.
assert.equal(bot_data.get(42).full_name, "Bot 0");
@@ -51,8 +55,7 @@ run_test("test_basics", () => {
user_id: 143,
avatar_url: "",
full_name: "Embedded bot 1",
- services: [{config_data: {key: "12345678"},
- service_name: "giphy"}],
+ services: [{config_data: {key: "12345678"}, service_name: "giphy"}],
};
@@ -72,9 +75,10 @@ run_test("test_basics", () => {
let bot = bot_data.get(43);
assert.equal("Bot 1", bot.full_name);
- bot_data.update(43, {full_name: "New Bot 1",
- services: [{interface: 2,
- base_url: "http://baz.com"}]});
+ bot_data.update(43, {
+ full_name: "New Bot 1",
+ services: [{interface: 2, base_url: "http://baz.com"}],
+ });
bot = bot_data.get(43);
const services = bot_data.get_services(43);
assert.equal("New Bot 1", bot.full_name);
@@ -132,10 +136,21 @@ run_test("test_basics", () => {
})();
(function test_get_editable() {
-
bot_data.add({...test_bot, user_id: 44, owner_id: me.user_id, is_active: true});
- bot_data.add({...test_bot, user_id: 45, email: "[email protected]", owner_id: me.user_id, is_active: true});
- bot_data.add({...test_bot, user_id: 46, email: "[email protected]", owner_id: fred.user_id, is_active: true});
+ bot_data.add({
+ ...test_bot,
+ user_id: 45,
+ email: "[email protected]",
+ owner_id: me.user_id,
+ is_active: true,
+ });
+ bot_data.add({
+ ...test_bot,
+ user_id: 46,
+ email: "[email protected]",
+ owner_id: fred.user_id,
+ is_active: true,
+ });
const editable_bots = bot_data.get_editable().map((bot) => bot.email);
assert.deepEqual(["[email protected]", "[email protected]"], editable_bots);
diff --git a/frontend_tests/node_tests/buddy_data.js b/frontend_tests/node_tests/buddy_data.js
index f6cdb6ef411..2c9101f5ff8 100644
--- a/frontend_tests/node_tests/buddy_data.js
+++ b/frontend_tests/node_tests/buddy_data.js
@@ -111,9 +111,7 @@ run_test("huddle_fraction_present", () => {
presence_info.set(mark.user_id, {status: "offline"}); // does not count
presence.presence_info = presence_info;
- assert.equal(
- buddy_data.huddle_fraction_present(huddle),
- 0.5);
+ assert.equal(buddy_data.huddle_fraction_present(huddle), 0.5);
presence_info = new Map();
for (const user of [alice, fred, jill, mark]) {
@@ -121,9 +119,7 @@ run_test("huddle_fraction_present", () => {
}
presence.presence_info = presence_info;
- assert.equal(
- buddy_data.huddle_fraction_present(huddle),
- 1);
+ assert.equal(buddy_data.huddle_fraction_present(huddle), 1);
huddle = people.emails_strings_to_user_ids_string(huddle);
@@ -134,9 +130,7 @@ run_test("huddle_fraction_present", () => {
presence_info.set(mark.user_id, {status: "offline"}); // does not count
presence.presence_info = presence_info;
- assert.equal(
- buddy_data.huddle_fraction_present(huddle),
- undefined);
+ assert.equal(buddy_data.huddle_fraction_present(huddle), undefined);
});
function activate_people() {
@@ -212,8 +206,10 @@ run_test("title_data", () => {
second_line: "translated: Owner: Human Myself",
third_line: "",
};
- assert.deepEqual(buddy_data.get_title_data(bot_with_owner.user_id, is_group),
- expected_group_data);
+ assert.deepEqual(
+ buddy_data.get_title_data(bot_with_owner.user_id, is_group),
+ expected_group_data,
+ );
// Bots without owners.
expected_group_data = {
@@ -233,7 +229,6 @@ run_test("title_data", () => {
first_line: "Human Myself",
second_line: "out to lunch",
third_line: "translated: Active now",
-
};
assert.deepEqual(buddy_data.get_title_data(me.user_id, is_group), expected_data);
@@ -320,15 +315,15 @@ run_test("level", () => {
});
run_test("user_last_seen_time_status", () => {
- assert.equal(buddy_data.user_last_seen_time_status(selma.user_id),
- "translated: Active now");
+ assert.equal(buddy_data.user_last_seen_time_status(selma.user_id), "translated: Active now");
page_params.realm_is_zephyr_mirror_realm = true;
- assert.equal(buddy_data.user_last_seen_time_status(old_user.user_id),
- "translated: Unknown");
+ assert.equal(buddy_data.user_last_seen_time_status(old_user.user_id), "translated: Unknown");
page_params.realm_is_zephyr_mirror_realm = false;
- assert.equal(buddy_data.user_last_seen_time_status(old_user.user_id),
- "translated: More than 2 weeks ago");
+ assert.equal(
+ buddy_data.user_last_seen_time_status(old_user.user_id),
+ "translated: More than 2 weeks ago",
+ );
presence.last_active_date = (user_id) => {
assert.equal(user_id, old_user.user_id);
@@ -343,9 +338,7 @@ run_test("user_last_seen_time_status", () => {
return "May 12";
};
- assert.equal(buddy_data.user_last_seen_time_status(old_user.user_id),
- "May 12");
-
+ assert.equal(buddy_data.user_last_seen_time_status(old_user.user_id), "May 12");
});
run_test("error handling", () => {
diff --git a/frontend_tests/node_tests/buddy_list.js b/frontend_tests/node_tests/buddy_list.js
index b34f26d2d32..cdad62b8148 100644
--- a/frontend_tests/node_tests/buddy_list.js
+++ b/frontend_tests/node_tests/buddy_list.js
@@ -158,9 +158,7 @@ run_test("find_li w/force_render", () => {
return stub_li;
};
- buddy_list.keys = [
- "foo", "bar", key, "baz",
- ];
+ buddy_list.keys = ["foo", "bar", key, "baz"];
let shown;
diff --git a/frontend_tests/node_tests/channel.js b/frontend_tests/node_tests/channel.js
index b5db9d688cc..e2fdda23c96 100644
--- a/frontend_tests/node_tests/channel.js
+++ b/frontend_tests/node_tests/channel.js
@@ -7,11 +7,7 @@ zrequire("channel");
const default_stub_xhr = "default-stub-xhr";
function test_with_mock_ajax(test_params) {
- const {
- xhr = default_stub_xhr,
- run_code,
- check_ajax_options,
- } = test_params;
+ const {xhr = default_stub_xhr, run_code, check_ajax_options} = test_params;
let ajax_called;
let ajax_options;
@@ -112,7 +108,6 @@ run_test("basics", () => {
options.simulate_error();
},
});
-
});
run_test("normal_post", () => {
@@ -273,9 +268,11 @@ run_test("too_many_pending", () => {
return xhr;
};
- blueslip.expect("warn",
- "The length of pending_requests is over 50. " +
- "Most likely they are not being correctly removed.");
+ blueslip.expect(
+ "warn",
+ "The length of pending_requests is over 50. " +
+ "Most likely they are not being correctly removed.",
+ );
_.times(50, () => {
channel.post({});
});
diff --git a/frontend_tests/node_tests/color_data.js b/frontend_tests/node_tests/color_data.js
index dc3183eeda1..e5e484d7b5b 100644
--- a/frontend_tests/node_tests/color_data.js
+++ b/frontend_tests/node_tests/color_data.js
@@ -1,12 +1,7 @@
zrequire("color_data");
run_test("pick_color", () => {
- color_data.colors = [
- "blue",
- "orange",
- "red",
- "yellow",
- ];
+ color_data.colors = ["blue", "orange", "red", "yellow"];
color_data.reset();
diff --git a/frontend_tests/node_tests/colorspace.js b/frontend_tests/node_tests/colorspace.js
index ed1f0bc5635..b8d1c5a930d 100644
--- a/frontend_tests/node_tests/colorspace.js
+++ b/frontend_tests/node_tests/colorspace.js
@@ -21,7 +21,7 @@ run_test("rgb_luminance", () => {
run_test("luminance_to_lightness", () => {
let luminance = 0;
- let expected_value = 116 * 4 / 29 - 16;
+ let expected_value = (116 * 4) / 29 - 16;
let actual_value = colorspace.luminance_to_lightness(luminance);
assert.equal(actual_value, expected_value);
diff --git a/frontend_tests/node_tests/common.js b/frontend_tests/node_tests/common.js
index 7700ce98ec9..9f181eb3484 100644
--- a/frontend_tests/node_tests/common.js
+++ b/frontend_tests/node_tests/common.js
@@ -89,7 +89,9 @@ run_test("adjust_mac_shortcuts", () => {
let key_no;
let keys_elem_list = [];
- common.has_mac_keyboard = function () { return false; };
+ common.has_mac_keyboard = function () {
+ return false;
+ };
key_no = 1;
keys_to_test_non_mac.forEach((value, key) => {
keys_elem_list.push(get_key_stub_html(key, value, "hotkey_non_mac_" + key_no));
@@ -103,7 +105,9 @@ run_test("adjust_mac_shortcuts", () => {
keys_elem_list = [];
key_no = 1;
- common.has_mac_keyboard = function () { return true; };
+ common.has_mac_keyboard = function () {
+ return true;
+ };
keys_to_test_mac.forEach((value, key) => {
keys_elem_list.push(get_key_stub_html(key, value, "hotkey_" + key_no));
key_no += 1;
@@ -119,7 +123,11 @@ run_test("adjust_mac_shortcuts", () => {
assert.equal(key_elem.text(), key_elem.expected_key());
});
- const markdown_hotkey_1 = get_key_stub_html("Ctrl + Backspace", "⌘ + Delete", "markdown_hotkey_1");
+ const markdown_hotkey_1 = get_key_stub_html(
+ "Ctrl + Backspace",
+ "⌘ + Delete",
+ "markdown_hotkey_1",
+ );
$(".markdown_content").each = (f) => {
f.call(markdown_hotkey_1);
};
diff --git a/frontend_tests/node_tests/components.js b/frontend_tests/node_tests/components.js
index cb5c3848d28..6447ac0921b 100644
--- a/frontend_tests/node_tests/components.js
+++ b/frontend_tests/node_tests/components.js
@@ -1,4 +1,3 @@
-
zrequire("keydown_util");
zrequire("components");
@@ -98,10 +97,10 @@ run_test("basics", () => {
self.find = function (sel) {
switch (sel) {
- case ".ind-tab":
- return ind_tab;
- default:
- throw Error("unknown selector: " + sel);
+ case ".ind-tab":
+ return ind_tab;
+ default:
+ throw Error("unknown selector: " + sel);
}
};
@@ -115,18 +114,18 @@ run_test("basics", () => {
}
switch (sel) {
- case "<div class='tab-switcher'></div>":
- return switcher;
- case "<div class='tab-switcher stream_sorter_toggle'></div>":
- return switcher;
- case "<div class='ind-tab' data-tab-key='keyboard-shortcuts' data-tab-id='0' tabindex='0'>translated: Keyboard shortcuts</div>":
- return make_tab(0);
- case "<div class='ind-tab' data-tab-key='message-formatting' data-tab-id='1' tabindex='0'>translated: Message formatting</div>":
- return make_tab(1);
- case "<div class='ind-tab' data-tab-key='search-operators' data-tab-id='2' tabindex='0'>translated: Search operators</div>":
- return make_tab(2);
- default:
- throw Error("unknown selector: " + sel);
+ case "<div class='tab-switcher'></div>":
+ return switcher;
+ case "<div class='tab-switcher stream_sorter_toggle'></div>":
+ return switcher;
+ case "<div class='ind-tab' data-tab-key='keyboard-shortcuts' data-tab-id='0' tabindex='0'>translated: Keyboard shortcuts</div>":
+ return make_tab(0);
+ case "<div class='ind-tab' data-tab-key='message-formatting' data-tab-id='1' tabindex='0'>translated: Message formatting</div>":
+ return make_tab(1);
+ case "<div class='ind-tab' data-tab-key='search-operators' data-tab-id='2' tabindex='0'>translated: Search operators</div>":
+ return make_tab(2);
+ default:
+ throw Error("unknown selector: " + sel);
}
});
diff --git a/frontend_tests/node_tests/compose.js b/frontend_tests/node_tests/compose.js
index b1b798e1908..cf5442e2675 100644
--- a/frontend_tests/node_tests/compose.js
+++ b/frontend_tests/node_tests/compose.js
@@ -15,8 +15,12 @@ const _navigator = {
};
const _document = {
- getElementById: function () { return $("#compose-textarea"); },
- execCommand: function () { return false; },
+ getElementById: function () {
+ return $("#compose-textarea");
+ },
+ execCommand: function () {
+ return false;
+ },
location: {},
};
@@ -176,7 +180,10 @@ run_test("validate_stream_message_address_info", () => {
payload.error({status: 404});
};
assert(!compose.validate_stream_message_address_info("Frontend"));
- assert.equal($("#compose-error-msg").html(), "translated: <p>The stream <b>Frontend</b> does not exist.</p><p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>");
+ assert.equal(
+ $("#compose-error-msg").html(),
+ "translated: <p>The stream <b>Frontend</b> does not exist.</p><p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>",
+ );
channel.post = function (payload) {
assert.equal(payload.data.stream, "social");
@@ -240,7 +247,10 @@ run_test("validate", () => {
};
assert(!compose.validate());
assert(zephyr_checked);
- assert.equal($("#compose-error-msg").html(), i18n.t("You need to be running Zephyr mirroring in order to send messages!"));
+ assert.equal(
+ $("#compose-error-msg").html(),
+ i18n.t("You need to be running Zephyr mirroring in order to send messages!"),
+ );
initialize_pm_pill();
add_content_to_compose_box();
@@ -250,7 +260,10 @@ run_test("validate", () => {
compose_state.private_message_recipient("");
assert(!compose.validate());
- assert.equal($("#compose-error-msg").html(), i18n.t("Please specify at least one valid recipient"));
+ assert.equal(
+ $("#compose-error-msg").html(),
+ i18n.t("Please specify at least one valid recipient"),
+ );
initialize_pm_pill();
add_content_to_compose_box();
@@ -258,12 +271,18 @@ run_test("validate", () => {
assert(!compose.validate());
- assert.equal($("#compose-error-msg").html(), i18n.t("Please specify at least one valid recipient", {}));
+ assert.equal(
+ $("#compose-error-msg").html(),
+ i18n.t("Please specify at least one valid recipient", {}),
+ );
compose_state.private_message_recipient("[email protected],[email protected]");
assert(!compose.validate());
- assert.equal($("#compose-error-msg").html(), i18n.t("Please specify at least one valid recipient", {}));
+ assert.equal(
+ $("#compose-error-msg").html(),
+ i18n.t("Please specify at least one valid recipient", {}),
+ );
people.add_active_user(bob);
compose_state.private_message_recipient("[email protected]");
@@ -362,7 +381,10 @@ run_test("test_validate_stream_message_post_policy", () => {
compose_state.stream_name("stream102");
stream_data.add_sub(sub);
assert(!compose.validate());
- assert.equal($("#compose-error-msg").html(), i18n.t("Only organization admins are allowed to post to this stream."));
+ assert.equal(
+ $("#compose-error-msg").html(),
+ i18n.t("Only organization admins are allowed to post to this stream."),
+ );
// reset compose_state.stream_name to 'social' again so that any tests occurung after this
// do not reproduce this error.
@@ -429,8 +451,11 @@ run_test("markdown_shortcuts", () => {
global.document.execCommand = function (cmd, bool, markdown) {
const compose_textarea = $("#compose-textarea");
const value = compose_textarea.val();
- $("#compose-textarea").val(value.substring(0, compose_textarea.range().start) +
- markdown + value.substring(compose_textarea.range().end, value.length));
+ $("#compose-textarea").val(
+ value.substring(0, compose_textarea.range().start) +
+ markdown +
+ value.substring(compose_textarea.range().end, value.length),
+ );
};
$("#compose-textarea").range = function () {
@@ -439,7 +464,9 @@ run_test("markdown_shortcuts", () => {
end: range_start + range_length,
length: range_length,
range: noop,
- text: $("#compose-textarea").val().substring(range_start, range_length + range_start),
+ text: $("#compose-textarea")
+ .val()
+ .substring(range_start, range_length + range_start),
};
};
$("#compose-textarea").caret = noop;
@@ -664,8 +691,7 @@ run_test("send_message", () => {
// Setting message content with a host server link and we will assert
// later that this has been converted to a relative link.
- $("#compose-textarea").val("[foobar]" +
- "(https://foo.com/user_uploads/123456)");
+ $("#compose-textarea").val("[foobar]" + "(https://foo.com/user_uploads/123456)");
$("#compose-textarea").blur();
$("#compose-send-status").show();
$("#compose-send-button").attr("disabled", "disabled");
@@ -742,8 +768,7 @@ run_test("send_message", () => {
assert.deepEqual(stub_state, state);
assert(!echo_error_msg_checked);
assert.equal($("#compose-send-button").prop("disabled"), false);
- assert.equal($("#compose-error-msg").html(),
- "Error sending message: Server says 408");
+ assert.equal($("#compose-error-msg").html(), "Error sending message: Server says 408");
assert.equal($("#compose-textarea").val(), "foobarfoobar");
assert($("#compose-textarea").is_focused());
assert($("#compose-send-status").visible());
@@ -874,7 +899,9 @@ run_test("warn_if_private_stream_is_linked", () => {
assert.equal(context.stream_name, "Denmark");
return "fake-compose_private_stream_alert-template";
});
- return function () { assert(called); };
+ return function () {
+ assert(called);
+ };
})(),
(function () {
@@ -883,7 +910,9 @@ run_test("warn_if_private_stream_is_linked", () => {
called = true;
assert.equal(html, "fake-compose_private_stream_alert-template");
};
- return function () { assert(called); };
+ return function () {
+ assert(called);
+ };
})(),
];
@@ -896,7 +925,9 @@ run_test("warn_if_private_stream_is_linked", () => {
compose.warn_if_private_stream_is_linked(denmark);
assert.equal($("#compose_private_stream_alert").visible(), true);
- for (const f of checks) { f(); }
+ for (const f of checks) {
+ f();
+ }
});
run_test("initialize", () => {
@@ -1017,7 +1048,8 @@ run_test("initialize", () => {
});
run_test("update_fade", () => {
- const selector = "#stream_message_recipient_stream,#stream_message_recipient_topic,#private_message_recipient";
+ const selector =
+ "#stream_message_recipient_stream,#stream_message_recipient_topic,#private_message_recipient";
const keyup_handler_func = $(selector).get_on_handler("keyup");
let set_focused_recipient_checked = false;
@@ -1149,7 +1181,9 @@ run_test("warn_if_mentioning_unsubscribed_user", () => {
assert.equal(stream_id, 111);
return true;
};
- return function () { assert(called); };
+ return function () {
+ assert(called);
+ };
})(),
(function () {
@@ -1162,7 +1196,9 @@ run_test("warn_if_mentioning_unsubscribed_user", () => {
assert.equal(context.name, "Foo Barson");
return "fake-compose-invite-user-template";
});
- return function () { assert(called); };
+ return function () {
+ assert(called);
+ };
})(),
(function () {
@@ -1171,7 +1207,9 @@ run_test("warn_if_mentioning_unsubscribed_user", () => {
called = true;
assert.equal(html, "fake-compose-invite-user-template");
};
- return function () { assert(called); };
+ return function () {
+ assert(called);
+ };
})(),
];
@@ -1185,7 +1223,9 @@ run_test("warn_if_mentioning_unsubscribed_user", () => {
compose.warn_if_mentioning_unsubscribed_user(mentioned);
assert.equal($("#compose_invite_users").visible(), true);
- for (const f of checks) { f(); }
+ for (const f of checks) {
+ f();
+ }
// Simulate that the row was added to the DOM.
const warning_row = $("<warning row>");
@@ -1243,8 +1283,10 @@ run_test("on_events", () => {
}
(function test_compose_all_everyone_confirm_clicked() {
- const handler = $("#compose-all-everyone")
- .get_on_handler("click", ".compose-all-everyone-confirm");
+ const handler = $("#compose-all-everyone").get_on_handler(
+ "click",
+ ".compose-all-everyone-confirm",
+ );
const helper = setup_parents_and_mock_remove(
"compose-all-everyone",
@@ -1269,8 +1311,7 @@ run_test("on_events", () => {
})();
(function test_compose_invite_users_clicked() {
- const handler = $("#compose_invite_users")
- .get_on_handler("click", ".compose_invite_link");
+ const handler = $("#compose_invite_users").get_on_handler("click", ".compose_invite_link");
const subscription = {
stream_id: 102,
name: "test",
@@ -1326,8 +1367,7 @@ run_test("on_events", () => {
})();
(function test_compose_invite_close_clicked() {
- const handler = $("#compose_invite_users")
- .get_on_handler("click", ".compose_invite_close");
+ const handler = $("#compose_invite_users").get_on_handler("click", ".compose_invite_close");
const helper = setup_parents_and_mock_remove(
"compose_invite_users_close",
@@ -1350,8 +1390,7 @@ run_test("on_events", () => {
})();
(function test_compose_not_subscribed_clicked() {
- const handler = $("#compose-send-status")
- .get_on_handler("click", ".sub_unsub_button");
+ const handler = $("#compose-send-status").get_on_handler("click", ".sub_unsub_button");
const subscription = {
stream_id: 102,
name: "test",
@@ -1382,8 +1421,10 @@ run_test("on_events", () => {
})();
(function test_compose_not_subscribed_close_clicked() {
- const handler = $("#compose-send-status")
- .get_on_handler("click", "#compose_not_subscribed_close");
+ const handler = $("#compose-send-status").get_on_handler(
+ "click",
+ "#compose_not_subscribed_close",
+ );
const helper = setup_parents_and_mock_remove(
"compose_user_not_subscribed_close",
@@ -1399,8 +1440,7 @@ run_test("on_events", () => {
})();
(function test_attach_files_compose_clicked() {
- const handler = $("#compose")
- .get_on_handler("click", "#attach_files");
+ const handler = $("#compose").get_on_handler("click", "#attach_files");
$("#file_input").clone = function (param) {
assert(param);
};
@@ -1482,13 +1522,15 @@ run_test("on_events", () => {
channel.get = function (options) {
assert(options.url === "/json/calls/bigbluebutton/create");
- options.success({url: "/calls/bigbluebutton/join?meeting_id=%22zulip-1%22&password=%22AAAAAAAAAA%22&checksum=%2232702220bff2a22a44aee72e96cfdb4c4091752e%22"});
+ options.success({
+ url:
+ "/calls/bigbluebutton/join?meeting_id=%22zulip-1%22&password=%22AAAAAAAAAA%22&checksum=%2232702220bff2a22a44aee72e96cfdb4c4091752e%22",
+ });
};
handler(ev);
video_link_regex = /\[Click to join video call\]\(\/calls\/bigbluebutton\/join\?meeting_id=%22zulip-1%22&password=%22AAAAAAAAAA%22&checksum=%2232702220bff2a22a44aee72e96cfdb4c4091752e%22\)/;
assert(video_link_regex.test(syntax_to_insert));
-
})();
(function test_markdown_preview_compose_clicked() {
@@ -1531,8 +1573,7 @@ run_test("on_events", () => {
function test_post_error(error_callback) {
error_callback();
- assert.equal($("#preview_content").html(),
- "translated: Failed to generate preview");
+ assert.equal($("#preview_content").html(), "translated: Failed to generate preview");
}
function mock_channel_post(msg) {
@@ -1557,12 +1598,10 @@ run_test("on_events", () => {
test(test_post_error, payload.error);
test(test_post_success, payload.success);
-
};
}
- const handler = $("#compose")
- .get_on_handler("click", "#markdown_preview");
+ const handler = $("#compose").get_on_handler("click", "#markdown_preview");
// Tests start here
$("#compose-textarea").val("");
@@ -1574,8 +1613,7 @@ run_test("on_events", () => {
handler(event);
- assert.equal($("#preview_content").html(),
- "translated: Nothing to preview");
+ assert.equal($("#preview_content").html(), "translated: Nothing to preview");
assert_visibilities();
let make_indicator_called = false;
@@ -1610,13 +1648,11 @@ run_test("on_events", () => {
assert(apply_markdown_called);
assert_visibilities();
- assert.equal($("#preview_content").html(),
- "Server: foobarfoobar");
+ assert.equal($("#preview_content").html(), "Server: foobarfoobar");
})();
(function test_undo_markdown_preview_clicked() {
- const handler = $("#compose")
- .get_on_handler("click", "#undo_markdown_preview");
+ const handler = $("#compose").get_on_handler("click", "#undo_markdown_preview");
$("#compose-textarea").hide();
$("#undo_markdown_preview").show();
@@ -1634,7 +1670,6 @@ run_test("on_events", () => {
assert(!$("#preview_message_area").visible());
assert($("#markdown_preview").visible());
})();
-
});
run_test("create_message_object", () => {
diff --git a/frontend_tests/node_tests/compose_actions.js b/frontend_tests/node_tests/compose_actions.js
index 8337924dc80..d107536871c 100644
--- a/frontend_tests/node_tests/compose_actions.js
+++ b/frontend_tests/node_tests/compose_actions.js
@@ -1,6 +1,10 @@
const noop = function () {};
-const return_false = function () { return false; };
-const return_true = function () { return true; };
+const return_false = function () {
+ return false;
+};
+const return_true = function () {
+ return true;
+};
set_global("document", {
location: {}, // we need this to load compose.js
@@ -10,11 +14,9 @@ set_global("page_params", {});
set_global("$", global.make_zjquery());
-set_global("compose_pm_pill", {
-});
+set_global("compose_pm_pill", {});
-set_global("hash_util", {
-});
+set_global("hash_util", {});
zrequire("people");
zrequire("compose_ui");
@@ -254,8 +256,7 @@ run_test("respond_to_message", () => {
};
stub_selected_message(msg);
- opts = {
- };
+ opts = {};
respond_to_message(opts);
assert.equal($("#stream_message_recipient_stream").val(), "devel");
@@ -277,8 +278,7 @@ run_test("reply_with_mention", () => {
syntax_to_insert = syntax;
};
- const opts = {
- };
+ const opts = {};
reply_with_mention(opts);
assert.equal($("#stream_message_recipient_stream").val(), "devel");
@@ -330,7 +330,10 @@ run_test("quote_and_reply", () => {
compose_ui.replace_syntax = function (syntax, replacement) {
assert.equal(syntax, "[Quoting…]");
- assert.equal(replacement, "@_**Bob Roberts|40** [said](link_to_message):\n```quote\nTesting.\n```");
+ assert.equal(
+ replacement,
+ "@_**Bob Roberts|40** [said](link_to_message):\n```quote\nTesting.\n```",
+ );
};
const opts = {
@@ -374,25 +377,29 @@ run_test("quote_and_reply", () => {
};
compose_ui.replace_syntax = function (syntax, replacement) {
assert.equal(syntax, "[Quoting…]");
- assert.equal(replacement, "@_**Bob Roberts|40** [said](link_to_message):\n````quote\n```\nmultiline code block\nshoudln't mess with quotes\n```\n````");
+ assert.equal(
+ replacement,
+ "@_**Bob Roberts|40** [said](link_to_message):\n````quote\n```\nmultiline code block\nshoudln't mess with quotes\n```\n````",
+ );
};
quote_and_reply(opts);
});
run_test("get_focus_area", () => {
assert.equal(get_focus_area("private", {}), "#private_message_recipient");
- assert.equal(get_focus_area("private", {
- private_message_recipient: "[email protected]"}), "#compose-textarea");
+ assert.equal(
+ get_focus_area("private", {
+ private_message_recipient: "[email protected]",
+ }),
+ "#compose-textarea",
+ );
assert.equal(get_focus_area("stream", {}), "#stream_message_recipient_stream");
- assert.equal(get_focus_area("stream", {stream: "fun"}),
- "#stream_message_recipient_topic");
- assert.equal(get_focus_area("stream", {stream: "fun",
- topic: "more"}),
- "#compose-textarea");
- assert.equal(get_focus_area("stream", {stream: "fun",
- topic: "more",
- trigger: "new topic button"}),
- "#stream_message_recipient_topic");
+ assert.equal(get_focus_area("stream", {stream: "fun"}), "#stream_message_recipient_topic");
+ assert.equal(get_focus_area("stream", {stream: "fun", topic: "more"}), "#compose-textarea");
+ assert.equal(
+ get_focus_area("stream", {stream: "fun", topic: "more", trigger: "new topic button"}),
+ "#stream_message_recipient_topic",
+ );
});
run_test("focus_in_empty_compose", () => {
diff --git a/frontend_tests/node_tests/compose_fade.js b/frontend_tests/node_tests/compose_fade.js
index f2be64d36fb..12025a9e455 100644
--- a/frontend_tests/node_tests/compose_fade.js
+++ b/frontend_tests/node_tests/compose_fade.js
@@ -38,18 +38,18 @@ run_test("set_focused_recipient", () => {
global.$ = function (selector) {
switch (selector) {
- case "#stream_message_recipient_stream":
- return {
- val: function () {
- return "social";
- },
- };
- case "#stream_message_recipient_topic":
- return {
- val: function () {
- return "lunch";
- },
- };
+ case "#stream_message_recipient_stream":
+ return {
+ val: function () {
+ return "social";
+ },
+ };
+ case "#stream_message_recipient_topic":
+ return {
+ val: function () {
+ return "lunch";
+ },
+ };
}
};
diff --git a/frontend_tests/node_tests/compose_ui.js b/frontend_tests/node_tests/compose_ui.js
index 0fdb30b92a6..9ad7ac9cb31 100644
--- a/frontend_tests/node_tests/compose_ui.js
+++ b/frontend_tests/node_tests/compose_ui.js
@@ -3,7 +3,9 @@ zrequire("people");
zrequire("user_status");
set_global("document", {
- execCommand: function () { return false; },
+ execCommand: function () {
+ return false;
+ },
});
set_global("$", global.make_zjquery());
@@ -84,7 +86,6 @@ run_test("insert_syntax_and_focus", () => {
assert.equal($("#compose-textarea").caret(), 4);
assert.equal($("#compose-textarea").val(), "xyz :octopus: ");
assert($("#compose-textarea").is_focused());
-
});
run_test("smart_insert", () => {
diff --git a/frontend_tests/node_tests/composebox_typeahead.js b/frontend_tests/node_tests/composebox_typeahead.js
index 6ae2cfb50df..ba95bc68611 100644
--- a/frontend_tests/node_tests/composebox_typeahead.js
+++ b/frontend_tests/node_tests/composebox_typeahead.js
@@ -20,8 +20,7 @@ set_global("md5", (s) => "md5-" + s);
stream_data.update_calculated_fields = () => {};
stream_data.set_filter_out_inactives = () => false;
-set_global("stream_topic_history", {
-});
+set_global("stream_topic_history", {});
set_global("message_store", {
user_ids: () => [],
@@ -100,18 +99,20 @@ const emoji_headphones = {
emoji_code: "1f3a7",
};
-const emojis_by_name = new Map(Object.entries({
- tada: emoji_tada,
- moneybag: emoji_moneybag,
- stadium: emoji_stadium,
- japanese_post_office: emoji_japanese_post_office,
- panda_face: emoji_panda_face,
- see_no_evil: emoji_see_no_evil,
- thumbs_up: emoji_thumbs_up,
- thermometer: emoji_thermometer,
- heart: emoji_heart,
- headphones: emoji_headphones,
-}));
+const emojis_by_name = new Map(
+ Object.entries({
+ tada: emoji_tada,
+ moneybag: emoji_moneybag,
+ stadium: emoji_stadium,
+ japanese_post_office: emoji_japanese_post_office,
+ panda_face: emoji_panda_face,
+ see_no_evil: emoji_see_no_evil,
+ thumbs_up: emoji_thumbs_up,
+ thermometer: emoji_thermometer,
+ heart: emoji_heart,
+ headphones: emoji_headphones,
+ }),
+);
const emoji_list = Array.from(emojis_by_name.values(), (emoji_dict) => {
if (emoji_dict.is_realm_emoji === true) {
return {
@@ -285,10 +286,11 @@ run_test("topics_seen_for", () => {
return ["With Twisted Metal", "acceptance", "civil fears"];
};
- assert.deepEqual(
- ct.topics_seen_for("Denmark"),
- ["With Twisted Metal", "acceptance", "civil fears"],
- );
+ assert.deepEqual(ct.topics_seen_for("Denmark"), [
+ "With Twisted Metal",
+ "acceptance",
+ "civil fears",
+ ]);
// Test when the stream doesn't exist (there are no topics)
assert.deepEqual(ct.topics_seen_for("non-existing-stream"), []);
@@ -302,7 +304,8 @@ run_test("content_typeahead_selected", () => {
let caret_called1 = false;
let caret_called2 = false;
fake_this.$element.caret = function (...args) {
- if (args.length === 0) { // .caret() used in split_at_cursor
+ if (args.length === 0) {
+ // .caret() used in split_at_cursor
caret_called1 = true;
return fake_this.query.length;
}
@@ -633,9 +636,21 @@ run_test("initialize", () => {
// This should match the users added at the beginning of this test file.
let actual_value = options.source("");
- let expected_value = [alice, cordelia, hal, gael, harry,
- hamlet, lear, twin1, twin2, othello,
- hamletcharacters, backend, call_center];
+ let expected_value = [
+ alice,
+ cordelia,
+ hal,
+ gael,
+ harry,
+ hamlet,
+ lear,
+ twin1,
+ twin2,
+ othello,
+ hamletcharacters,
+ backend,
+ call_center,
+ ];
assert.deepEqual(actual_value, expected_value);
// Even though the items passed to .highlighter() are the full
@@ -817,10 +832,7 @@ run_test("initialize", () => {
fake_this.$element.closest = () => [];
fake_this.options = options;
let actual_value = options.source.call(fake_this, "test #s");
- assert.deepEqual(
- sorted_names_from(actual_value),
- ["Denmark", "Sweden", "The Netherlands"],
- );
+ assert.deepEqual(sorted_names_from(actual_value), ["Denmark", "Sweden", "The Netherlands"]);
assert(caret_called);
// options.highlighter()
@@ -834,7 +846,8 @@ run_test("initialize", () => {
fake_this = {completing: "mention", token: "hamletcharacters"};
actual_value = options.highlighter.call(fake_this, hamletcharacters);
- expected_value = ' <i class="typeahead-image icon fa fa-group" aria-hidden="true"></i>\n<strong>hamletcharacters</strong>&nbsp;&nbsp;\n<small class="autocomplete_secondary">Characters of Hamlet</small>\n';
+ expected_value =
+ ' <i class="typeahead-image icon fa fa-group" aria-hidden="true"></i>\n<strong>hamletcharacters</strong>&nbsp;&nbsp;\n<small class="autocomplete_secondary">Characters of Hamlet</small>\n';
assert.equal(actual_value, expected_value);
// matching
@@ -870,20 +883,23 @@ run_test("initialize", () => {
// options.sorter()
fake_this = {completing: "emoji", token: "ta"};
- actual_value = sort_items(fake_this, [make_emoji(emoji_stadium),
- make_emoji(emoji_tada)]);
+ actual_value = sort_items(fake_this, [make_emoji(emoji_stadium), make_emoji(emoji_tada)]);
expected_value = [make_emoji(emoji_tada), make_emoji(emoji_stadium)];
assert.deepEqual(actual_value, expected_value);
fake_this = {completing: "emoji", token: "th"};
- actual_value = sort_items(fake_this, [make_emoji(emoji_thermometer),
- make_emoji(emoji_thumbs_up)]);
+ actual_value = sort_items(fake_this, [
+ make_emoji(emoji_thermometer),
+ make_emoji(emoji_thumbs_up),
+ ]);
expected_value = [make_emoji(emoji_thumbs_up), make_emoji(emoji_thermometer)];
assert.deepEqual(actual_value, expected_value);
fake_this = {completing: "emoji", token: "he"};
- actual_value = sort_items(fake_this, [make_emoji(emoji_headphones),
- make_emoji(emoji_heart)]);
+ actual_value = sort_items(fake_this, [
+ make_emoji(emoji_headphones),
+ make_emoji(emoji_heart),
+ ]);
expected_value = [make_emoji(emoji_heart), make_emoji(emoji_headphones)];
assert.deepEqual(actual_value, expected_value);
@@ -946,13 +962,15 @@ run_test("initialize", () => {
let pm_recipient_blur_called = false;
const old_pm_recipient_blur = $("#private_message_recipient").blur;
$("#private_message_recipient").blur = function (handler) {
- if (handler) { // The blur handler is being set.
+ if (handler) {
+ // The blur handler is being set.
this.val("[email protected], ");
handler.call(this);
const actual_value = this.val();
const expected_value = "[email protected]";
assert.equal(actual_value, expected_value);
- } else { // The element is simply losing the focus.
+ } else {
+ // The element is simply losing the focus.
old_pm_recipient_blur();
}
pm_recipient_blur_called = true;
@@ -1093,12 +1111,16 @@ run_test("initialize", () => {
channel_post_called = true;
};
- $("#enter_sends").is = function () { return false; };
+ $("#enter_sends").is = function () {
+ return false;
+ };
$("#enter_sends").click();
// Now we re-run both .initialize() and the click handler, this time
// with enter_sends: page_params.enter_sends being true
- $("#enter_sends").is = function () { return true; };
+ $("#enter_sends").is = function () {
+ return true;
+ };
$("#enter_sends").click();
ct.initialize();
@@ -1115,26 +1137,27 @@ run_test("initialize", () => {
});
run_test("begins_typeahead", () => {
-
- const begin_typehead_this = {options: {completions: {
- emoji: true,
- mention: true,
- silent_mention: true,
- slash: true,
- stream: true,
- syntax: true,
- topic: true,
- timestamp: true,
- }}};
+ const begin_typehead_this = {
+ options: {
+ completions: {
+ emoji: true,
+ mention: true,
+ silent_mention: true,
+ slash: true,
+ stream: true,
+ syntax: true,
+ topic: true,
+ timestamp: true,
+ },
+ },
+ };
function get_values(input, rest) {
// Stub out split_at_cursor that uses $(':focus')
ct.split_at_cursor = function () {
return [input, rest];
};
- const values = ct.get_candidates.call(
- begin_typehead_this, input,
- );
+ const values = ct.get_candidates.call(begin_typehead_this, input);
return values;
}
@@ -1156,10 +1179,7 @@ run_test("begins_typeahead", () => {
rest = "";
}
const values = get_values(input, rest);
- assert.deepEqual(
- sorted_names_from(values),
- ["Denmark", "Sweden", "The Netherlands"],
- );
+ assert.deepEqual(sorted_names_from(values), ["Denmark", "Sweden", "The Netherlands"]);
}
const people_only = {is_silent: true};
@@ -1317,7 +1337,7 @@ run_test("begins_typeahead", () => {
assert_typeahead_equals(":test", "ing", false);
assert_typeahead_equals("```test", "ing", false);
assert_typeahead_equals("~~~test", "ing", false);
- const terminal_symbols = ',.;?!()[]> "\'\n\t';
+ const terminal_symbols = ",.;?!()[]> \"'\n\t";
terminal_symbols.split().forEach((symbol) => {
assert_stream_list("#test", symbol);
assert_typeahead_equals("@test", symbol, all_mentions);
@@ -1345,8 +1365,7 @@ run_test("tokenizing", () => {
assert.equal(ct.tokenize_compose_str("foo ~~~why = why_not\n~~~"), "~~~");
// The following cases are kinda judgment calls...
- assert.equal(ct.tokenize_compose_str(
- "foo @toomanycharactersisridiculoustocomplete"), "");
+ assert.equal(ct.tokenize_compose_str("foo @toomanycharactersisridiculoustocomplete"), "");
assert.equal(ct.tokenize_compose_str("foo #streams@foo"), "#streams@foo");
});
@@ -1420,22 +1439,15 @@ run_test("content_highlighter", () => {
run_test("filter_and_sort_mentions (normal)", () => {
const is_silent = false;
- const suggestions = ct.filter_and_sort_mentions(
- is_silent, "al");
+ const suggestions = ct.filter_and_sort_mentions(is_silent, "al");
- assert.deepEqual(suggestions, [
- mention_all,
- alice,
- hal,
- call_center,
- ]);
+ assert.deepEqual(suggestions, [mention_all, alice, hal, call_center]);
});
run_test("filter_and_sort_mentions (silent)", () => {
const is_silent = true;
- const suggestions = ct.filter_and_sort_mentions(
- is_silent, "al");
+ const suggestions = ct.filter_and_sort_mentions(is_silent, "al");
assert.deepEqual(suggestions, [alice, hal]);
});
@@ -1462,17 +1474,27 @@ run_test("typeahead_results", () => {
}
function assert_slash_matches(input, expected) {
- const returned = compose_typeahead_results("slash", composebox_typeahead.slash_commands, input);
+ const returned = compose_typeahead_results(
+ "slash",
+ composebox_typeahead.slash_commands,
+ input,
+ );
assert.deepEqual(returned, expected);
}
- assert_emoji_matches("da", [{emoji_name: "tada", emoji_code: "1f389"},
- {emoji_name: "panda_face", emoji_code: "1f43c"}]);
+ assert_emoji_matches("da", [
+ {emoji_name: "tada", emoji_code: "1f389"},
+ {emoji_name: "panda_face", emoji_code: "1f43c"},
+ ]);
assert_emoji_matches("da_", []);
assert_emoji_matches("da ", []);
assert_emoji_matches("panda ", [{emoji_name: "panda_face", emoji_code: "1f43c"}]);
assert_emoji_matches("panda_", [{emoji_name: "panda_face", emoji_code: "1f43c"}]);
- assert_emoji_matches("japanese_post_", [{emoji_name: "japanese_post_office", emoji_code: "1f3e3"}]);
- assert_emoji_matches("japanese post ", [{emoji_name: "japanese_post_office", emoji_code: "1f3e3"}]);
+ assert_emoji_matches("japanese_post_", [
+ {emoji_name: "japanese_post_office", emoji_code: "1f3e3"},
+ ]);
+ assert_emoji_matches("japanese post ", [
+ {emoji_name: "japanese_post_office", emoji_code: "1f3e3"},
+ ]);
assert_emoji_matches("notaemoji", []);
// Autocomplete user mentions by user name.
assert_mentions_matches("cordelia", [cordelia]);
diff --git a/frontend_tests/node_tests/copy_and_paste.js b/frontend_tests/node_tests/copy_and_paste.js
index 3cb2b6d0a50..f40b8c04b13 100644
--- a/frontend_tests/node_tests/copy_and_paste.js
+++ b/frontend_tests/node_tests/copy_and_paste.js
@@ -34,42 +34,56 @@ const createPasteEvent = function () {
};
run_test("paste_handler", () => {
-
- let input = '<meta http-equiv="content-type" content="text/html; charset=utf-8"><span style="color: hsl(0, 0%, 13%); font-family: arial, sans-serif; font-size: 12.8px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial;"><span> </span>love the<span> </span><b>Zulip</b><b> </b></span><b style="color: hsl(0, 0%, 13%); font-family: arial, sans-serif; font-size: 12.8px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial;">Organization</b><span style="color: hsl(0, 0%, 13%); font-family: arial, sans-serif; font-size: 12.8px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial;">.</span>';
- assert.equal(copy_and_paste.paste_handler_converter(input),
- " love the **Zulip** **Organization**.");
-
- input = '<meta http-equiv="content-type" content="text/html; charset=utf-8"><span style="color: hsl(210, 12%, 16%); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">The<span> </span></span><code style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0.4em; margin: 0px; background-color: hsla(210, 13%, 12%, 0.05); border-radius: 3px; color: hsl(210, 12%, 16%); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">JSDOM</code><span style="color: hsl(210, 12%, 16%); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><span> </span>constructor</span>';
- assert.equal(copy_and_paste.paste_handler_converter(input),
- "The `JSDOM` constructor");
-
- input = '<meta http-equiv="content-type" content="text/html; charset=utf-8"><a href="https://zulip.readthedocs.io/en/latest/subsystems/logging.html" target="_blank" title="https://zulip.readthedocs.io/en/latest/subsystems/logging.html" style="color: hsl(200, 100%, 40%); text-decoration: none; cursor: pointer; font-family: &quot;Source Sans Pro&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%);">https://zulip.readthedocs.io/en/latest/subsystems/logging.html</a>';
- assert.equal(copy_and_paste.paste_handler_converter(input),
- "https://zulip.readthedocs.io/en/latest/subsystems/logging.html");
-
- input = '<meta http-equiv="content-type" content="text/html; charset=utf-8"><a class="reference external" href="https://zulip.readthedocs.io/en/latest/overview/contributing.html" style="box-sizing: border-box; color: hsl(283, 39%, 53%); text-decoration: none; cursor: pointer; outline: 0px; font-family: Lato, proxima-nova, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 99%);">Contributing to Zulip</a>';
- assert.equal(copy_and_paste.paste_handler_converter(input),
- "[Contributing to Zulip](https://zulip.readthedocs.io/en/latest/overview/contributing.html)");
-
- input = '<meta http-equiv="content-type" content="text/html; charset=utf-8"><span style="color: hsl(0, 0%, 0%); font-family: &quot;Helvetica Neue&quot;, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">1. text</span>';
- assert.equal(copy_and_paste.paste_handler_converter(input),
- "1. text");
-
- input = '<meta http-equiv="content-type" content="text/html; charset=utf-8"><h1 style="box-sizing: border-box; font-size: 2em; margin-top: 0px !important; margin-right: 0px; margin-bottom: 16px; margin-left: 0px; font-weight: 600; line-height: 1.25; padding-bottom: 0.3em; border-bottom: 1px solid hsl(216, 14%, 93%); color: hsl(210, 12%, 16%); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">Zulip overview</h1>';
- assert.equal(copy_and_paste.paste_handler_converter(input),
- "Zulip overview");
-
- input = '<meta http-equiv="content-type" content="text/html; charset=utf-8"><i style="box-sizing: inherit; color: hsl(0, 0%, 0%); font-family: Verdana, sans-serif; font-size: 15px; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial;">This text is italic</i>';
- assert.equal(copy_and_paste.paste_handler_converter(input),
- "*This text is italic*");
-
- input = '<div class="preview-content"><div class="comment"><div class="comment-body markdown-body js-preview-body" style="min-height: 131px;"><p>Test List:</p><ul><li>Item 1</li><li>Item 2</li></ul></div></div></div>';
- assert.equal(copy_and_paste.paste_handler_converter(input),
- "Test List:\n* Item 1\n* Item 2");
-
- input = '<div class="ace-line gutter-author-d-iz88z86z86za0dz67zz78zz78zz74zz68zjz80zz71z9iz90za3z66zs0z65zz65zq8z75zlaz81zcz66zj6g2mz78zz76zmz66z22z75zfcz69zz66z ace-ltr focused-line" dir="auto" id="editor-3-ace-line-41"><span>Test List:</span></div><div class="ace-line gutter-author-d-iz88z86z86za0dz67zz78zz78zz74zz68zjz80zz71z9iz90za3z66zs0z65zz65zq8z75zlaz81zcz66zj6g2mz78zz76zmz66z22z75zfcz69zz66z line-list-type-bullet ace-ltr" dir="auto" id="editor-3-ace-line-42"><ul class="listtype-bullet listindent1 list-bullet1"><li><span class="ace-line-pocket-zws" data-faketext="" data-contentcollector-ignore-space-at="end"></span><span class="ace-line-pocket" data-faketext="" contenteditable="false"></span><span class="ace-line-pocket-zws" data-faketext="" data-contentcollector-ignore-space-at="start"></span><span>Item 1</span></li></ul></div><div class="ace-line gutter-author-d-iz88z86z86za0dz67zz78zz78zz74zz68zjz80zz71z9iz90za3z66zs0z65zz65zq8z75zlaz81zcz66zj6g2mz78zz76zmz66z22z75zfcz69zz66z line-list-type-bullet ace-ltr" dir="auto" id="editor-3-ace-line-43"><ul class="listtype-bullet listindent1 list-bullet1"><li><span class="ace-line-pocket-zws" data-faketext="" data-contentcollector-ignore-space-at="end"></span><span class="ace-line-pocket" data-faketext="" contenteditable="false"></span><span class="ace-line-pocket-zws" data-faketext="" data-contentcollector-ignore-space-at="start"></span><span>Item 2</span></li></ul></div>';
- assert.equal(copy_and_paste.paste_handler_converter(input),
- "Test List:\n* Item 1\n* Item 2");
+ let input =
+ '<meta http-equiv="content-type" content="text/html; charset=utf-8"><span style="color: hsl(0, 0%, 13%); font-family: arial, sans-serif; font-size: 12.8px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial;"><span> </span>love the<span> </span><b>Zulip</b><b> </b></span><b style="color: hsl(0, 0%, 13%); font-family: arial, sans-serif; font-size: 12.8px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial;">Organization</b><span style="color: hsl(0, 0%, 13%); font-family: arial, sans-serif; font-size: 12.8px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial;">.</span>';
+ assert.equal(
+ copy_and_paste.paste_handler_converter(input),
+ " love the **Zulip** **Organization**.",
+ );
+
+ input =
+ '<meta http-equiv="content-type" content="text/html; charset=utf-8"><span style="color: hsl(210, 12%, 16%); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">The<span> </span></span><code style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0.4em; margin: 0px; background-color: hsla(210, 13%, 12%, 0.05); border-radius: 3px; color: hsl(210, 12%, 16%); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">JSDOM</code><span style="color: hsl(210, 12%, 16%); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><span> </span>constructor</span>';
+ assert.equal(copy_and_paste.paste_handler_converter(input), "The `JSDOM` constructor");
+
+ input =
+ '<meta http-equiv="content-type" content="text/html; charset=utf-8"><a href="https://zulip.readthedocs.io/en/latest/subsystems/logging.html" target="_blank" title="https://zulip.readthedocs.io/en/latest/subsystems/logging.html" style="color: hsl(200, 100%, 40%); text-decoration: none; cursor: pointer; font-family: &quot;Source Sans Pro&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%);">https://zulip.readthedocs.io/en/latest/subsystems/logging.html</a>';
+ assert.equal(
+ copy_and_paste.paste_handler_converter(input),
+ "https://zulip.readthedocs.io/en/latest/subsystems/logging.html",
+ );
+
+ input =
+ '<meta http-equiv="content-type" content="text/html; charset=utf-8"><a class="reference external" href="https://zulip.readthedocs.io/en/latest/overview/contributing.html" style="box-sizing: border-box; color: hsl(283, 39%, 53%); text-decoration: none; cursor: pointer; outline: 0px; font-family: Lato, proxima-nova, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 99%);">Contributing to Zulip</a>';
+ assert.equal(
+ copy_and_paste.paste_handler_converter(input),
+ "[Contributing to Zulip](https://zulip.readthedocs.io/en/latest/overview/contributing.html)",
+ );
+
+ input =
+ '<meta http-equiv="content-type" content="text/html; charset=utf-8"><span style="color: hsl(0, 0%, 0%); font-family: &quot;Helvetica Neue&quot;, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">1. text</span>';
+ assert.equal(copy_and_paste.paste_handler_converter(input), "1. text");
+
+ input =
+ '<meta http-equiv="content-type" content="text/html; charset=utf-8"><h1 style="box-sizing: border-box; font-size: 2em; margin-top: 0px !important; margin-right: 0px; margin-bottom: 16px; margin-left: 0px; font-weight: 600; line-height: 1.25; padding-bottom: 0.3em; border-bottom: 1px solid hsl(216, 14%, 93%); color: hsl(210, 12%, 16%); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">Zulip overview</h1>';
+ assert.equal(copy_and_paste.paste_handler_converter(input), "Zulip overview");
+
+ input =
+ '<meta http-equiv="content-type" content="text/html; charset=utf-8"><i style="box-sizing: inherit; color: hsl(0, 0%, 0%); font-family: Verdana, sans-serif; font-size: 15px; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial;">This text is italic</i>';
+ assert.equal(copy_and_paste.paste_handler_converter(input), "*This text is italic*");
+
+ input =
+ '<div class="preview-content"><div class="comment"><div class="comment-body markdown-body js-preview-body" style="min-height: 131px;"><p>Test List:</p><ul><li>Item 1</li><li>Item 2</li></ul></div></div></div>';
+ assert.equal(
+ copy_and_paste.paste_handler_converter(input),
+ "Test List:\n* Item 1\n* Item 2",
+ );
+
+ input =
+ '<div class="ace-line gutter-author-d-iz88z86z86za0dz67zz78zz78zz74zz68zjz80zz71z9iz90za3z66zs0z65zz65zq8z75zlaz81zcz66zj6g2mz78zz76zmz66z22z75zfcz69zz66z ace-ltr focused-line" dir="auto" id="editor-3-ace-line-41"><span>Test List:</span></div><div class="ace-line gutter-author-d-iz88z86z86za0dz67zz78zz78zz74zz68zjz80zz71z9iz90za3z66zs0z65zz65zq8z75zlaz81zcz66zj6g2mz78zz76zmz66z22z75zfcz69zz66z line-list-type-bullet ace-ltr" dir="auto" id="editor-3-ace-line-42"><ul class="listtype-bullet listindent1 list-bullet1"><li><span class="ace-line-pocket-zws" data-faketext="" data-contentcollector-ignore-space-at="end"></span><span class="ace-line-pocket" data-faketext="" contenteditable="false"></span><span class="ace-line-pocket-zws" data-faketext="" data-contentcollector-ignore-space-at="start"></span><span>Item 1</span></li></ul></div><div class="ace-line gutter-author-d-iz88z86z86za0dz67zz78zz78zz74zz68zjz80zz71z9iz90za3z66zs0z65zz65zq8z75zlaz81zcz66zj6g2mz78zz76zmz66z22z75zfcz69zz66z line-list-type-bullet ace-ltr" dir="auto" id="editor-3-ace-line-43"><ul class="listtype-bullet listindent1 list-bullet1"><li><span class="ace-line-pocket-zws" data-faketext="" data-contentcollector-ignore-space-at="end"></span><span class="ace-line-pocket" data-faketext="" contenteditable="false"></span><span class="ace-line-pocket-zws" data-faketext="" data-contentcollector-ignore-space-at="start"></span><span>Item 2</span></li></ul></div>';
+ assert.equal(
+ copy_and_paste.paste_handler_converter(input),
+ "Test List:\n* Item 1\n* Item 2",
+ );
let data = "<p>text</p>";
let event = createPasteEvent();
@@ -81,11 +95,11 @@ run_test("paste_handler", () => {
copy_and_paste.paste_handler(event);
assert(insert_syntax_and_focus_called);
- data = '<meta http-equiv="content-type" content="text/html; charset=utf-8"><img src="http://localhost:9991/thumbnail?url=user_uploads%2F1%2Fe2%2FHPMCcGWOG9rS2M4ybHN8sEzh%2Fpasted_image.png&amp;size=full"/>';
+ data =
+ '<meta http-equiv="content-type" content="text/html; charset=utf-8"><img src="http://localhost:9991/thumbnail?url=user_uploads%2F1%2Fe2%2FHPMCcGWOG9rS2M4ybHN8sEzh%2Fpasted_image.png&amp;size=full"/>';
event = createPasteEvent();
event.originalEvent.clipboardData.setData("text/html", data);
insert_syntax_and_focus_called = false;
copy_and_paste.paste_handler(event);
assert(!insert_syntax_and_focus_called);
-
});
diff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.js
index d2e2c82c284..4ab4bdd7dd4 100644
--- a/frontend_tests/node_tests/dispatch.js
+++ b/frontend_tests/node_tests/dispatch.js
@@ -15,7 +15,9 @@ global.patch_builtin("setTimeout", (func) => func());
set_global("home_msg_list", {
rerender: noop,
select_id: noop,
- selected_id: function () {return 1;},
+ selected_id: function () {
+ return 1;
+ },
});
set_global("markdown", {
@@ -138,10 +140,7 @@ with_overrides((override) => {
const event = event_fixtures.alert_words;
dispatch(event);
- assert.deepEqual(
- alert_words.get_word_list(),
- ["fire", "lunch"],
- );
+ assert.deepEqual(alert_words.get_word_list(), ["fire", "lunch"]);
assert(alert_words.has_alert_word("fire"));
assert(alert_words.has_alert_word("lunch"));
});
@@ -203,7 +202,6 @@ with_overrides((override) => {
override("settings_profile_fields.report_success", noop);
dispatch(event);
assert_same(global.page_params.custom_profile_fields, event.fields);
-
});
with_overrides((override) => {
@@ -216,7 +214,6 @@ with_overrides((override) => {
const args = stub.get_args("realm_default_streams");
assert_same(args.realm_default_streams, event.default_streams);
});
-
});
with_overrides((override) => {
@@ -489,7 +486,6 @@ with_overrides((override) => {
override("settings_linkifiers.populate_filters", noop);
dispatch(event);
assert_same(page_params.realm_filters, event.realm_filters);
-
});
with_overrides((override) => {
@@ -570,7 +566,10 @@ with_overrides((override) => {
override("subs.add_sub_to_table", noop);
dispatch(event);
const args = stub.get_args("streams");
- assert_same(args.streams.map((stream) => stream.stream_id), [42, 99]);
+ assert_same(
+ args.streams.map((stream) => stream.stream_id),
+ [42, 99],
+ );
});
// stream delete
@@ -581,7 +580,9 @@ with_overrides((override) => {
override("settings_streams.update_default_streams_table", noop);
override("stream_data.remove_default_stream", noop);
- override("stream_data.get_sub_by_id", (id) => id === 42 ? {subscribed: true} : {subscribed: false});
+ override("stream_data.get_sub_by_id", (id) =>
+ id === 42 ? {subscribed: true} : {subscribed: false},
+ );
override("stream_list.remove_sidebar_row", stub.f);
dispatch(event);
const args = stub.get_args("stream_id");
@@ -686,8 +687,12 @@ with_overrides((override) => {
assert_same(page_params.dense_mode, true);
assert_same(toggled, ["less_dense_mode", "more_dense_mode"]);
- $("body").fadeOut = (secs) => { assert_same(secs, 300); };
- $("body").fadeIn = (secs) => { assert_same(secs, 300); };
+ $("body").fadeOut = (secs) => {
+ assert_same(secs, 300);
+ };
+ $("body").fadeIn = (secs) => {
+ assert_same(secs, 300);
+ };
global.with_stub((stub) => {
event = event_fixtures.update_display_settings__color_scheme_dark;
diff --git a/frontend_tests/node_tests/dispatch_subs.js b/frontend_tests/node_tests/dispatch_subs.js
index 169676c7dc8..41297774632 100644
--- a/frontend_tests/node_tests/dispatch_subs.js
+++ b/frontend_tests/node_tests/dispatch_subs.js
@@ -1,4 +1,3 @@
-
const events = require("./lib/events.js");
const event_fixtures = events.fixtures;
const test_user = events.test_user;
@@ -105,7 +104,6 @@ test("add error handling", (override) => {
dispatch(event);
assert.deepEqual(stub.get_args("param").param, "Subscribing to unknown stream with ID 42");
});
-
});
test("peer event error handling (bad stream_ids)", (override) => {
@@ -162,4 +160,3 @@ test("peer event error handling (add_subscriber)", (override) => {
blueslip.expect("warn", "Cannot process peer_remove event.");
dispatch(remove_event);
});
-
diff --git a/frontend_tests/node_tests/drafts.js b/frontend_tests/node_tests/drafts.js
index 89f1263f14e..a72620f2625 100644
--- a/frontend_tests/node_tests/drafts.js
+++ b/frontend_tests/node_tests/drafts.js
@@ -9,7 +9,9 @@ zrequire("stream_color");
zrequire("colorspace");
const ls_container = new Map();
-const noop = function () { return; };
+const noop = function () {
+ return;
+};
set_global("localStorage", {
getItem: function (key) {
@@ -91,10 +93,7 @@ const short_msg = {
};
run_test("legacy", () => {
- assert.deepEqual(
- drafts.restore_message(legacy_draft),
- compose_args_for_legacy_draft,
- );
+ assert.deepEqual(drafts.restore_message(legacy_draft), compose_args_for_legacy_draft);
});
run_test("draft_model", () => {
@@ -194,7 +193,9 @@ run_test("initialize", () => {
global.window.addEventListener = function (event_name, f) {
assert.equal(event_name, "beforeunload");
let called = false;
- drafts.update_draft = function () { called = true; };
+ drafts.update_draft = function () {
+ called = true;
+ };
f();
assert(called);
};
diff --git a/frontend_tests/node_tests/dropdown_list_widget.js b/frontend_tests/node_tests/dropdown_list_widget.js
index d988869e6c8..36d1d3e8bc4 100644
--- a/frontend_tests/node_tests/dropdown_list_widget.js
+++ b/frontend_tests/node_tests/dropdown_list_widget.js
@@ -24,7 +24,9 @@ run_test("basic_functions", () => {
widget_name: "my_setting",
data: ["one", "two", "three"].map((x) => ({name: x, value: x})),
value: "one",
- on_update: (val) => { updated_value = val; },
+ on_update: (val) => {
+ updated_value = val;
+ },
default_text: i18n.t("not set"),
render_text: (text) => `rendered: ${text}`,
};
@@ -59,7 +61,10 @@ run_test("no_default_value", () => {
null_value: "null-value",
};
- blueslip.expect("warn", "dropdown-list-widget: Called without a default value; using null value");
+ blueslip.expect(
+ "warn",
+ "dropdown-list-widget: Called without a default value; using null value",
+ );
setup_zjquery_data(opts.widget_name);
const widget = dropdown_list_widget(opts);
assert.equal(widget.value(), "null-value");
diff --git a/frontend_tests/node_tests/echo.js b/frontend_tests/node_tests/echo.js
index 2a44eebf4ec..22f1ceaf1c4 100644
--- a/frontend_tests/node_tests/echo.js
+++ b/frontend_tests/node_tests/echo.js
@@ -60,13 +60,16 @@ run_test("process_from_server for differently rendered messages", () => {
const old_value = "old_value";
const new_value = "new_value";
const waiting_for_ack = new Map([
- ["100.1", {
- content: "<p>A client rendered message</p>",
- timestamp: old_value,
- is_me_message: old_value,
- submessages: old_value,
- topic_links: old_value,
- }],
+ [
+ "100.1",
+ {
+ content: "<p>A client rendered message</p>",
+ timestamp: old_value,
+ is_me_message: old_value,
+ submessages: old_value,
+ topic_links: old_value,
+ },
+ ],
]);
const server_messages = [
{
@@ -84,13 +87,15 @@ run_test("process_from_server for differently rendered messages", () => {
const non_echo_messages = echo.process_from_server(server_messages);
assert.deepEqual(non_echo_messages, []);
assert.equal(disparities.length, 1);
- assert.deepEqual(messages_to_rerender, [{
- content: server_messages[0].content,
- timestamp: new_value,
- is_me_message: new_value,
- submessages: new_value,
- topic_links: new_value,
- }]);
+ assert.deepEqual(messages_to_rerender, [
+ {
+ content: server_messages[0].content,
+ timestamp: new_value,
+ is_me_message: new_value,
+ submessages: new_value,
+ topic_links: new_value,
+ },
+ ]);
});
run_test("build_display_recipient", () => {
@@ -137,7 +142,9 @@ run_test("build_display_recipient", () => {
assert.equal(iago.full_name, "Iago");
assert.equal(iago.id, 123);
- const cordelia = display_recipient.find((recipient) => recipient.email === "[email protected]");
+ const cordelia = display_recipient.find(
+ (recipient) => recipient.email === "[email protected]",
+ );
assert.equal(cordelia.full_name, "Cordelia");
assert.equal(cordelia.id, 21);
@@ -159,7 +166,6 @@ run_test("build_display_recipient", () => {
iago = display_recipient.find((recipient) => recipient.email === "[email protected]");
assert.equal(iago.full_name, "Iago");
assert.equal(iago.id, 123);
-
});
run_test("insert_local_message", () => {
@@ -233,5 +239,4 @@ run_test("insert_local_message", () => {
assert(add_topic_links_called);
assert(apply_markdown_called);
assert(insert_message_called);
-
});
diff --git a/frontend_tests/node_tests/emoji.js b/frontend_tests/node_tests/emoji.js
index 908f36a772a..d423927af60 100644
--- a/frontend_tests/node_tests/emoji.js
+++ b/frontend_tests/node_tests/emoji.js
@@ -29,9 +29,11 @@ run_test("build_emoji_upload_widget", () => {
});
run_test("get_canonical_name", () => {
- emoji.active_realm_emojis = new Map(Object.entries({
- realm_emoji: "TBD",
- }));
+ emoji.active_realm_emojis = new Map(
+ Object.entries({
+ realm_emoji: "TBD",
+ }),
+ );
let canonical_name = emoji.get_canonical_name("realm_emoji");
assert.equal(canonical_name, "realm_emoji");
diff --git a/frontend_tests/node_tests/emoji_picker.js b/frontend_tests/node_tests/emoji_picker.js
index 497f028c31b..5ad5551d908 100644
--- a/frontend_tests/node_tests/emoji_picker.js
+++ b/frontend_tests/node_tests/emoji_picker.js
@@ -41,6 +41,8 @@ run_test("initialize", () => {
assert_emoji_category(complete_emoji_catalog.pop(), "fa-soccer-ball-o", 63);
// The popular emoji appear twice in the picker, and the zulip emoji is special
- assert.equal(emoji.emojis_by_name.size,
- total_emoji_in_categories - popular_emoji_count + zulip_emoji_count);
+ assert.equal(
+ emoji.emojis_by_name.size,
+ total_emoji_in_categories - popular_emoji_count + zulip_emoji_count,
+ );
});
diff --git a/frontend_tests/node_tests/fenced_code.js b/frontend_tests/node_tests/fenced_code.js
index 8ad856d496f..3f1cadb6941 100644
--- a/frontend_tests/node_tests/fenced_code.js
+++ b/frontend_tests/node_tests/fenced_code.js
@@ -5,8 +5,14 @@ run_test("get_unused_fence", () => {
assert.equal(fenced_code.get_unused_fence("````\nsomething\n````"), "`".repeat(5));
assert.equal(fenced_code.get_unused_fence("```\n````\n``````"), "`".repeat(7));
assert.equal(fenced_code.get_unused_fence("~~~\nsomething\n~~~"), "`".repeat(3));
- assert.equal(fenced_code.get_unused_fence("```code\nterminating fence is indented and longer\n ````"), "`".repeat(5));
- assert.equal(fenced_code.get_unused_fence("```code\nterminating fence is extra indented\n ````"), "`".repeat(4));
+ assert.equal(
+ fenced_code.get_unused_fence("```code\nterminating fence is indented and longer\n ````"),
+ "`".repeat(5),
+ );
+ assert.equal(
+ fenced_code.get_unused_fence("```code\nterminating fence is extra indented\n ````"),
+ "`".repeat(4),
+ );
let large_testcase = "";
// ```
// ````
diff --git a/frontend_tests/node_tests/filter.js b/frontend_tests/node_tests/filter.js
index 3514049c21a..687c7fe35c6 100644
--- a/frontend_tests/node_tests/filter.js
+++ b/frontend_tests/node_tests/filter.js
@@ -1,4 +1,3 @@
-
zrequire("unread");
zrequire("stream_data");
zrequire("people");
@@ -96,9 +95,7 @@ run_test("basics", () => {
// If our only stream operator is negated, then for all intents and purposes,
// we don't consider ourselves to have a stream operator, because we don't
// want to have the stream in the tab bar or unsubscribe messaging, etc.
- operators = [
- {operator: "stream", operand: "exclude", negated: true},
- ];
+ operators = [{operator: "stream", operand: "exclude", negated: true}];
filter = new Filter(operators);
assert(!filter.contains_only_private_messages());
assert(!filter.has_operator("stream"));
@@ -108,9 +105,7 @@ run_test("basics", () => {
// Negated searches are just like positive searches for our purposes, since
// the search logic happens on the back end and we need to have can_apply_locally()
// be false, and we want "Search results" in the tab bar.
- operators = [
- {operator: "search", operand: "stop_word", negated: true},
- ];
+ operators = [{operator: "search", operand: "stop_word", negated: true}];
filter = new Filter(operators);
assert(!filter.contains_only_private_messages());
assert(filter.has_operator("search"));
@@ -119,9 +114,7 @@ run_test("basics", () => {
assert(!filter.is_personal_filter());
// Similar logic applies to negated "has" searches.
- operators = [
- {operator: "has", operand: "images", negated: true},
- ];
+ operators = [{operator: "has", operand: "images", negated: true}];
filter = new Filter(operators);
assert(filter.has_operator("has"));
assert(filter.can_apply_locally());
@@ -130,9 +123,7 @@ run_test("basics", () => {
assert(!filter.can_mark_messages_read());
assert(!filter.is_personal_filter());
- operators = [
- {operator: "streams", operand: "public", negated: true},
- ];
+ operators = [{operator: "streams", operand: "public", negated: true}];
filter = new Filter(operators);
assert(!filter.contains_only_private_messages());
assert(!filter.has_operator("streams"));
@@ -141,9 +132,7 @@ run_test("basics", () => {
assert(!filter.can_apply_locally());
assert(!filter.is_personal_filter());
- operators = [
- {operator: "streams", operand: "public"},
- ];
+ operators = [{operator: "streams", operand: "public"}];
filter = new Filter(operators);
assert(!filter.contains_only_private_messages());
assert(filter.has_operator("streams"));
@@ -153,9 +142,7 @@ run_test("basics", () => {
assert(filter.includes_full_stream_history());
assert(!filter.is_personal_filter());
- operators = [
- {operator: "is", operand: "private"},
- ];
+ operators = [{operator: "is", operand: "private"}];
filter = new Filter(operators);
assert(filter.contains_only_private_messages());
assert(filter.can_mark_messages_read());
@@ -163,9 +150,7 @@ run_test("basics", () => {
assert(filter.can_apply_locally());
assert(!filter.is_personal_filter());
- operators = [
- {operator: "is", operand: "mentioned"},
- ];
+ operators = [{operator: "is", operand: "mentioned"}];
filter = new Filter(operators);
assert(!filter.contains_only_private_messages());
assert(filter.can_mark_messages_read());
@@ -173,9 +158,7 @@ run_test("basics", () => {
assert(filter.can_apply_locally());
assert(filter.is_personal_filter());
- operators = [
- {operator: "is", operand: "starred"},
- ];
+ operators = [{operator: "is", operand: "starred"}];
filter = new Filter(operators);
assert(!filter.contains_only_private_messages());
assert(!filter.can_mark_messages_read());
@@ -183,18 +166,14 @@ run_test("basics", () => {
assert(filter.can_apply_locally());
assert(filter.is_personal_filter());
- operators = [
- {operator: "pm-with", operand: "[email protected]"},
- ];
+ operators = [{operator: "pm-with", operand: "[email protected]"}];
filter = new Filter(operators);
assert(filter.contains_only_private_messages());
assert(!filter.has_operator("search"));
assert(filter.can_apply_locally());
assert(!filter.is_personal_filter());
- operators = [
- {operator: "group-pm-with", operand: "[email protected]"},
- ];
+ operators = [{operator: "group-pm-with", operand: "[email protected]"}];
filter = new Filter(operators);
assert(filter.contains_only_private_messages());
assert(!filter.has_operator("search"));
@@ -282,18 +261,14 @@ run_test("can_mark_messages_read", () => {
assert_not_mark_read_with_is_operands();
assert_not_mark_read_when_searching();
- const stream_operator = [
- {operator: "stream", operand: "foo"},
- ];
+ const stream_operator = [{operator: "stream", operand: "foo"}];
let filter = new Filter(stream_operator);
assert(filter.can_mark_messages_read());
assert_not_mark_read_with_has_operands(stream_operator);
assert_not_mark_read_with_is_operands(stream_operator);
assert_not_mark_read_when_searching(stream_operator);
- const stream_negated_operator = [
- {operator: "stream", operand: "foo", negated: true},
- ];
+ const stream_negated_operator = [{operator: "stream", operand: "foo", negated: true}];
filter = new Filter(stream_negated_operator);
assert(!filter.can_mark_messages_read());
@@ -314,17 +289,11 @@ run_test("can_mark_messages_read", () => {
filter = new Filter(stream_negated_topic_operators);
assert(!filter.can_mark_messages_read());
- const pm_with = [
- {operator: "pm-with", operand: "[email protected],"},
- ];
+ const pm_with = [{operator: "pm-with", operand: "[email protected],"}];
- const pm_with_negated = [
- {operator: "pm-with", operand: "[email protected],", negated: true},
- ];
+ const pm_with_negated = [{operator: "pm-with", operand: "[email protected],", negated: true}];
- const group_pm = [
- {operator: "pm-with", operand: "[email protected],[email protected]"},
- ];
+ const group_pm = [{operator: "pm-with", operand: "[email protected],[email protected]"}];
filter = new Filter(pm_with);
assert(filter.can_mark_messages_read());
filter = new Filter(pm_with_negated);
@@ -338,30 +307,22 @@ run_test("can_mark_messages_read", () => {
assert_not_mark_read_when_searching(group_pm);
assert_not_mark_read_when_searching(pm_with);
- const is_private = [
- {operator: "is", operand: "private"},
- ];
+ const is_private = [{operator: "is", operand: "private"}];
filter = new Filter(is_private);
assert(filter.can_mark_messages_read());
assert_not_mark_read_with_is_operands(is_private);
assert_not_mark_read_with_has_operands(is_private);
assert_not_mark_read_when_searching(is_private);
- const in_all = [
- {operator: "in", operand: "all"},
- ];
+ const in_all = [{operator: "in", operand: "all"}];
filter = new Filter(in_all);
assert(filter.can_mark_messages_read());
assert_not_mark_read_with_is_operands(in_all);
assert_not_mark_read_with_has_operands(in_all);
assert_not_mark_read_when_searching(in_all);
- const in_home = [
- {operator: "in", operand: "home"},
- ];
- const in_home_negated = [
- {operator: "in", operand: "home", negated: true},
- ];
+ const in_home = [{operator: "in", operand: "home"}];
+ const in_home_negated = [{operator: "in", operand: "home", negated: true}];
filter = new Filter(in_home);
assert(filter.can_mark_messages_read());
assert_not_mark_read_with_is_operands(in_home);
@@ -371,12 +332,8 @@ run_test("can_mark_messages_read", () => {
assert(!filter.can_mark_messages_read());
// Do not mark messages as read when in an unsupported 'in:*' filter.
- const in_random = [
- {operator: "in", operand: "xxxxxxxxx"},
- ];
- const in_random_negated = [
- {operator: "in", operand: "xxxxxxxxx", negated: true},
- ];
+ const in_random = [{operator: "in", operand: "xxxxxxxxx"}];
+ const in_random_negated = [{operator: "in", operand: "xxxxxxxxx", negated: true}];
filter = new Filter(in_random);
assert(!filter.can_mark_messages_read());
filter = new Filter(in_random_negated);
@@ -403,15 +360,11 @@ run_test("can_mark_messages_read", () => {
});
run_test("show_first_unread", () => {
- let operators = [
- {operator: "is", operand: "any"},
- ];
+ let operators = [{operator: "is", operand: "any"}];
let filter = new Filter(operators);
assert(filter.allow_use_first_unread_when_narrowing());
- operators = [
- {operator: "search", operand: "query to search"},
- ];
+ operators = [{operator: "search", operand: "query to search"}];
filter = new Filter(operators);
assert(!filter.allow_use_first_unread_when_narrowing());
@@ -420,13 +373,10 @@ run_test("show_first_unread", () => {
assert(filter.allow_use_first_unread_when_narrowing());
// Side case
- operators = [
- {operator: "is", operand: "any"},
- ];
+ operators = [{operator: "is", operand: "any"}];
filter = new Filter(operators);
filter.can_mark_messages_read = () => false;
assert(filter.allow_use_first_unread_when_narrowing());
-
});
run_test("filter_with_new_params_topic", () => {
const operators = [
@@ -492,9 +442,7 @@ run_test("public_operators", () => {
assert(filter.can_bucket_by("stream"));
global.page_params.narrow_stream = "default";
- operators = [
- {operator: "stream", operand: "default"},
- ];
+ operators = [{operator: "stream", operand: "default"}];
filter = new Filter(operators);
assert_same_operators(filter.public_operators(), []);
});
@@ -511,10 +459,7 @@ run_test("redundancies", () => {
assert(filter.can_bucket_by("pm-with"));
terms = [
- {operator: "pm-with",
- operand: "[email protected],",
- negated: true,
- },
+ {operator: "pm-with", operand: "[email protected],", negated: true},
{operator: "is", operand: "private"},
];
filter = new Filter(terms);
@@ -567,7 +512,6 @@ run_test("canonicalizations", () => {
term = Filter.canonicalize_term({operator: "has", operand: "links"});
assert.equal(term.operator, "has");
assert.equal(term.operand, "link");
-
});
function get_predicate(operators) {
@@ -597,7 +541,10 @@ run_test("predicate_basics", () => {
const stream_id = 42;
make_sub("Foo", stream_id);
- let predicate = get_predicate([["stream", "Foo"], ["topic", "Bar"]]);
+ let predicate = get_predicate([
+ ["stream", "Foo"],
+ ["topic", "Bar"],
+ ]);
assert(predicate({type: "stream", stream_id: stream_id, topic: "bar"}));
assert(!predicate({type: "stream", stream_id: stream_id, topic: "whatever"}));
@@ -606,7 +553,10 @@ run_test("predicate_basics", () => {
// For old streams that we are no longer subscribed to, we may not have
// a sub, but these should still match by stream name.
- predicate = get_predicate([["stream", "old-Stream"], ["topic", "Bar"]]);
+ predicate = get_predicate([
+ ["stream", "old-Stream"],
+ ["topic", "Bar"],
+ ]);
assert(predicate({type: "stream", stream: "Old-stream", topic: "bar"}));
assert(!predicate({type: "stream", stream: "no-match", topic: "whatever"}));
@@ -657,7 +607,10 @@ run_test("predicate_basics", () => {
assert(predicate({id: 5}));
assert(!predicate({id: 6}));
- predicate = get_predicate([["id", 5], ["topic", "lunch"]]);
+ predicate = get_predicate([
+ ["id", 5],
+ ["topic", "lunch"],
+ ]);
assert(predicate({type: "stream", id: 5, topic: "lunch"}));
assert(!predicate({type: "stream", id: 5, topic: "dinner"}));
@@ -666,70 +619,92 @@ run_test("predicate_basics", () => {
assert(!predicate({sender_email: steve.user_id}));
predicate = get_predicate([["pm-with", "[email protected]"]]);
- assert(predicate({
- type: "private",
- display_recipient: [{id: joe.user_id}],
- }));
- assert(!predicate({
- type: "private",
- display_recipient: [{id: steve.user_id}],
- }));
- assert(!predicate({
- type: "private",
- display_recipient: [{id: 999999}],
- }));
+ assert(
+ predicate({
+ type: "private",
+ display_recipient: [{id: joe.user_id}],
+ }),
+ );
+ assert(
+ !predicate({
+ type: "private",
+ display_recipient: [{id: steve.user_id}],
+ }),
+ );
+ assert(
+ !predicate({
+ type: "private",
+ display_recipient: [{id: 999999}],
+ }),
+ );
assert(!predicate({type: "stream"}));
predicate = get_predicate([["pm-with", "[email protected],[email protected]"]]);
- assert(predicate({
- type: "private",
- display_recipient: [{id: joe.user_id}, {id: steve.user_id}],
- }));
+ assert(
+ predicate({
+ type: "private",
+ display_recipient: [{id: joe.user_id}, {id: steve.user_id}],
+ }),
+ );
// Make sure your own email is ignored
predicate = get_predicate([["pm-with", "[email protected],[email protected],[email protected]"]]);
- assert(predicate({
- type: "private",
- display_recipient: [{id: joe.user_id}, {id: steve.user_id}],
- }));
+ assert(
+ predicate({
+ type: "private",
+ display_recipient: [{id: joe.user_id}, {id: steve.user_id}],
+ }),
+ );
predicate = get_predicate([["pm-with", "[email protected]"]]);
- assert(!predicate({
- type: "private",
- display_recipient: [{id: joe.user_id}],
- }));
+ assert(
+ !predicate({
+ type: "private",
+ display_recipient: [{id: joe.user_id}],
+ }),
+ );
predicate = get_predicate([["group-pm-with", "[email protected]"]]);
- assert(!predicate({
- type: "private",
- display_recipient: [{id: joe.user_id}],
- }));
+ assert(
+ !predicate({
+ type: "private",
+ display_recipient: [{id: joe.user_id}],
+ }),
+ );
predicate = get_predicate([["group-pm-with", "[email protected]"]]);
- assert(predicate({
- type: "private",
- display_recipient: [{id: joe.user_id}, {id: steve.user_id}, {id: me.user_id}],
- }));
- assert(!predicate({ // you must be a part of the group pm
- type: "private",
- display_recipient: [{id: joe.user_id}, {id: steve.user_id}],
- }));
- assert(!predicate({
- type: "private",
- display_recipient: [{id: steve.user_id}, {id: me.user_id}],
- }));
+ assert(
+ predicate({
+ type: "private",
+ display_recipient: [{id: joe.user_id}, {id: steve.user_id}, {id: me.user_id}],
+ }),
+ );
+ assert(
+ !predicate({
+ // you must be a part of the group pm
+ type: "private",
+ display_recipient: [{id: joe.user_id}, {id: steve.user_id}],
+ }),
+ );
+ assert(
+ !predicate({
+ type: "private",
+ display_recipient: [{id: steve.user_id}, {id: me.user_id}],
+ }),
+ );
assert(!predicate({type: "stream"}));
const img_msg = {
- content: "<p><a href=\"/user_uploads/randompath/test.jpeg\">test.jpeg</a></p><div class=\"message_inline_image\"><a href=\"/user_uploads/randompath/test.jpeg\" title=\"test.jpeg\"><img src=\"/user_uploads/randompath/test.jpeg\"></a></div>",
+ content:
+ '<p><a href="/user_uploads/randompath/test.jpeg">test.jpeg</a></p><div class="message_inline_image"><a href="/user_uploads/randompath/test.jpeg" title="test.jpeg"><img src="/user_uploads/randompath/test.jpeg"></a></div>',
};
const link_msg = {
- content: "<p><a href=\"http://chat.zulip.org\">chat.zulip.org</a></p>",
+ content: '<p><a href="http://chat.zulip.org">chat.zulip.org</a></p>',
};
const non_img_attachment_msg = {
- content: "<p><a href=\"/user_uploads/randompath/attachment.ext\">attachment.ext</a></p>",
+ content: '<p><a href="/user_uploads/randompath/attachment.ext">attachment.ext</a></p>',
};
const no_has_filter_matching_msg = {
@@ -774,7 +749,6 @@ run_test("predicate_basics", () => {
assert(!has_image(link_msg));
$(no_has_filter_matching_msg.content).set_find_results(".message_inline_image", false);
assert(!has_image(no_has_filter_matching_msg));
-
});
run_test("negated_predicates", () => {
@@ -784,25 +758,23 @@ run_test("negated_predicates", () => {
const social_stream_id = 555;
make_sub("social", social_stream_id);
- narrow = [
- {operator: "stream", operand: "social", negated: true},
- ];
+ narrow = [{operator: "stream", operand: "social", negated: true}];
predicate = new Filter(narrow).predicate();
assert(predicate({type: "stream", stream_id: 999999}));
assert(!predicate({type: "stream", stream_id: social_stream_id}));
- narrow = [
- {operator: "streams", operand: "public", negated: true},
- ];
+ narrow = [{operator: "streams", operand: "public", negated: true}];
predicate = new Filter(narrow).predicate();
assert(predicate({}));
-
});
run_test("mit_exceptions", () => {
global.page_params.realm_is_zephyr_mirror_realm = true;
- let predicate = get_predicate([["stream", "Foo"], ["topic", "personal"]]);
+ let predicate = get_predicate([
+ ["stream", "Foo"],
+ ["topic", "personal"],
+ ]);
assert(predicate({type: "stream", stream: "foo", topic: "personal"}));
assert(predicate({type: "stream", stream: "foo.d", topic: "personal"}));
assert(predicate({type: "stream", stream: "foo.d", topic: ""}));
@@ -810,7 +782,10 @@ run_test("mit_exceptions", () => {
assert(!predicate({type: "stream", stream: "foo", topic: "whatever"}));
assert(!predicate({type: "private"}));
- predicate = get_predicate([["stream", "Foo"], ["topic", "bar"]]);
+ predicate = get_predicate([
+ ["stream", "Foo"],
+ ["topic", "bar"],
+ ]);
assert(predicate({type: "stream", stream: "foo", topic: "bar.d"}));
// Try to get the MIT regex to explode for an empty stream.
@@ -858,7 +833,6 @@ run_test("predicate_edge_cases", () => {
filter.predicate();
predicate = filter.predicate(); // get cached version
assert(predicate({type: "stream", stream: "foo", topic: "bar"}));
-
});
run_test("parse", () => {
@@ -879,21 +853,15 @@ run_test("parse", () => {
_test();
string = "pm-with:[email protected]";
- operators = [
- {operator: "pm-with", operand: "[email protected]"},
- ];
+ operators = [{operator: "pm-with", operand: "[email protected]"}];
_test();
string = "sender:[email protected]";
- operators = [
- {operator: "sender", operand: "[email protected]"},
- ];
+ operators = [{operator: "sender", operand: "[email protected]"}];
_test();
string = "stream:With+Space";
- operators = [
- {operator: "stream", operand: "With Space"},
- ];
+ operators = [{operator: "stream", operand: "With Space"}];
_test();
string = 'stream:"with quoted space" topic:and separate';
@@ -905,21 +873,15 @@ run_test("parse", () => {
_test();
string = 'stream:"unclosed quote';
- operators = [
- {operator: "stream", operand: "unclosed quote"},
- ];
+ operators = [{operator: "stream", operand: "unclosed quote"}];
_test();
string = 'stream:""';
- operators = [
- {operator: "stream", operand: ""},
- ];
+ operators = [{operator: "stream", operand: ""}];
_test();
string = "https://www.google.com";
- operators = [
- {operator: "search", operand: "https://www.google.com"},
- ];
+ operators = [{operator: "search", operand: "https://www.google.com"}];
_test();
string = "stream:foo -stream:exclude";
@@ -944,15 +906,11 @@ run_test("parse", () => {
_test();
string = "streams:public";
- operators = [
- {operator: "streams", operand: "public"},
- ];
+ operators = [{operator: "streams", operand: "public"}];
_test();
string = "-streams:public";
- operators = [
- {operator: "streams", operand: "public", negated: true},
- ];
+ operators = [{operator: "streams", operand: "public", negated: true}];
_test();
string = "stream:foo :emoji: are cool";
@@ -1008,33 +966,23 @@ run_test("unparse", () => {
string = "streams:public text";
assert.deepEqual(Filter.unparse(operators), string);
- operators = [
- {operator: "streams", operand: "public"},
- ];
+ operators = [{operator: "streams", operand: "public"}];
string = "streams:public";
assert.deepEqual(Filter.unparse(operators), string);
- operators = [
- {operator: "streams", operand: "public", negated: true},
- ];
+ operators = [{operator: "streams", operand: "public", negated: true}];
string = "-streams:public";
assert.deepEqual(Filter.unparse(operators), string);
- operators = [
- {operator: "id", operand: 50},
- ];
+ operators = [{operator: "id", operand: 50}];
string = "id:50";
assert.deepEqual(Filter.unparse(operators), string);
- operators = [
- {operator: "near", operand: 150},
- ];
+ operators = [{operator: "near", operand: 150}];
string = "near:150";
assert.deepEqual(Filter.unparse(operators), string);
- operators = [
- {operator: "", operand: ""},
- ];
+ operators = [{operator: "", operand: ""}];
string = "";
assert.deepEqual(Filter.unparse(operators), string);
});
@@ -1043,15 +991,11 @@ run_test("describe", () => {
let narrow;
let string;
- narrow = [
- {operator: "streams", operand: "public"},
- ];
+ narrow = [{operator: "streams", operand: "public"}];
string = "streams public";
assert.equal(Filter.describe(narrow), string);
- narrow = [
- {operator: "streams", operand: "public", negated: true},
- ];
+ narrow = [{operator: "streams", operand: "public", negated: true}];
string = "exclude streams public";
assert.equal(Filter.describe(narrow), string);
@@ -1083,40 +1027,28 @@ run_test("describe", () => {
string = "private messages, search for lunch";
assert.equal(Filter.describe(narrow), string);
- narrow = [
- {operator: "id", operand: 99},
- ];
+ narrow = [{operator: "id", operand: 99}];
string = "message ID 99";
assert.equal(Filter.describe(narrow), string);
- narrow = [
- {operator: "in", operand: "home"},
- ];
+ narrow = [{operator: "in", operand: "home"}];
string = "messages in home";
assert.equal(Filter.describe(narrow), string);
- narrow = [
- {operator: "is", operand: "mentioned"},
- ];
+ narrow = [{operator: "is", operand: "mentioned"}];
string = "@-mentions";
assert.equal(Filter.describe(narrow), string);
- narrow = [
- {operator: "is", operand: "alerted"},
- ];
+ narrow = [{operator: "is", operand: "alerted"}];
string = "alerted messages";
assert.equal(Filter.describe(narrow), string);
- narrow = [
- {operator: "is", operand: "something_we_do_not_support"},
- ];
+ narrow = [{operator: "is", operand: "something_we_do_not_support"}];
string = "invalid something_we_do_not_support operand for is operator";
assert.equal(Filter.describe(narrow), string);
// this should be unreachable, but just in case
- narrow = [
- {operator: "bogus", operand: "foo"},
- ];
+ narrow = [{operator: "bogus", operand: "foo"}];
string = "unknown operator";
assert.equal(Filter.describe(narrow), string);
@@ -1168,9 +1100,7 @@ run_test("describe", () => {
});
run_test("can_bucket_by", () => {
- let terms = [
- {operator: "stream", operand: "My Stream"},
- ];
+ let terms = [{operator: "stream", operand: "My Stream"}];
let filter = new Filter(terms);
assert.equal(filter.can_bucket_by("stream"), true);
assert.equal(filter.can_bucket_by("stream", "topic"), false);
@@ -1195,17 +1125,13 @@ run_test("can_bucket_by", () => {
assert.equal(filter.can_bucket_by("stream", "topic"), false);
assert.equal(filter.can_bucket_by("pm-with"), false);
- terms = [
- {operator: "pm-with", operand: "[email protected]", negated: true},
- ];
+ terms = [{operator: "pm-with", operand: "[email protected]", negated: true}];
filter = new Filter(terms);
assert.equal(filter.can_bucket_by("stream"), false);
assert.equal(filter.can_bucket_by("stream", "topic"), false);
assert.equal(filter.can_bucket_by("pm-with"), false);
- terms = [
- {operator: "pm-with", operand: "[email protected],[email protected]"},
- ];
+ terms = [{operator: "pm-with", operand: "[email protected],[email protected]"}];
filter = new Filter(terms);
assert.equal(filter.can_bucket_by("stream"), false);
assert.equal(filter.can_bucket_by("stream", "topic"), false);
@@ -1213,16 +1139,12 @@ run_test("can_bucket_by", () => {
assert.equal(filter.can_bucket_by("is-mentioned"), false);
assert.equal(filter.can_bucket_by("is-private"), false);
- terms = [
- {operator: "is", operand: "private"},
- ];
+ terms = [{operator: "is", operand: "private"}];
filter = new Filter(terms);
assert.equal(filter.can_bucket_by("is-mentioned"), false);
assert.equal(filter.can_bucket_by("is-private"), true);
- terms = [
- {operator: "is", operand: "mentioned"},
- ];
+ terms = [{operator: "is", operand: "mentioned"}];
filter = new Filter(terms);
assert.equal(filter.can_bucket_by("is-mentioned"), true);
assert.equal(filter.can_bucket_by("is-private"), false);
@@ -1240,9 +1162,7 @@ run_test("can_bucket_by", () => {
// is-starred.
assert.equal(filter.can_bucket_by("is-starred"), false);
- terms = [
- {operator: "is", operand: "mentioned", negated: true},
- ];
+ terms = [{operator: "is", operand: "mentioned", negated: true}];
filter = new Filter(terms);
assert.equal(filter.can_bucket_by("is-mentioned"), false);
assert.equal(filter.can_bucket_by("is-private"), false);
@@ -1274,29 +1194,17 @@ run_test("term_type", () => {
assert.deepEqual(sorted_terms, expected);
}
- assert_term_sort(
- ["topic", "stream", "sender"],
- ["stream", "topic", "sender"],
- );
+ assert_term_sort(["topic", "stream", "sender"], ["stream", "topic", "sender"]);
assert_term_sort(
["has-link", "near", "is-unread", "pm-with"],
["pm-with", "near", "is-unread", "has-link"],
);
- assert_term_sort(
- ["bogus", "stream", "topic"],
- ["stream", "topic", "bogus"],
- );
- assert_term_sort(
- ["stream", "topic", "stream"],
- ["stream", "stream", "topic"],
- );
+ assert_term_sort(["bogus", "stream", "topic"], ["stream", "topic", "bogus"]);
+ assert_term_sort(["stream", "topic", "stream"], ["stream", "stream", "topic"]);
- assert_term_sort(
- ["search", "streams-public"],
- ["streams-public", "search"],
- );
+ assert_term_sort(["search", "streams-public"], ["streams-public", "search"]);
const terms = [
{operator: "topic", operand: "lunch"},
@@ -1331,9 +1239,7 @@ run_test("term_type", () => {
});
run_test("first_valid_id_from", () => {
- const terms = [
- {operator: "is", operand: "alerted"},
- ];
+ const terms = [{operator: "is", operand: "alerted"}];
const filter = new Filter(terms);
@@ -1396,10 +1302,7 @@ run_test("navbar_helpers", () => {
function test_redirect_url_with_search(test_case) {
test_case.operator.push({operator: "search", operand: "fizzbuzz"});
const filter = new Filter(test_case.operator);
- assert.equal(
- filter.generate_redirect_url(),
- test_case.redirect_url_with_search,
- );
+ assert.equal(filter.generate_redirect_url(), test_case.redirect_url_with_search);
}
function test_common_narrow(test_case) {
@@ -1448,7 +1351,9 @@ run_test("navbar_helpers", () => {
];
const pm_with = [{operator: "pm-with", operand: "[email protected]"}];
const group_pm = [{operator: "pm-with", operand: "[email protected],[email protected]"}];
- const group_pm_including_missing_person = [{operator: "pm-with", operand: "[email protected],[email protected],[email protected]"}];
+ const group_pm_including_missing_person = [
+ {operator: "pm-with", operand: "[email protected],[email protected],[email protected]"},
+ ];
const test_cases = [
{
@@ -1540,20 +1445,26 @@ run_test("navbar_helpers", () => {
is_common_narrow: true,
icon: "envelope",
title: properly_separated_names([joe.full_name]),
- redirect_url_with_search: "/#narrow/pm-with/" + joe.user_id + "-" + joe.email.split("@")[0],
+ redirect_url_with_search:
+ "/#narrow/pm-with/" + joe.user_id + "-" + joe.email.split("@")[0],
},
{
operator: group_pm,
is_common_narrow: true,
icon: "envelope",
title: properly_separated_names([joe.full_name, steve.full_name]),
- redirect_url_with_search: "/#narrow/pm-with/" + joe.user_id + "," + steve.user_id + "-group",
+ redirect_url_with_search:
+ "/#narrow/pm-with/" + joe.user_id + "," + steve.user_id + "-group",
},
{
operator: group_pm_including_missing_person,
is_common_narrow: true,
icon: "envelope",
- title: properly_separated_names([joe.full_name, steve.full_name, "[email protected]"]),
+ title: properly_separated_names([
+ joe.full_name,
+ steve.full_name,
+ ]),
redirect_url_with_search: "/#narrow/pm-with/undefined",
},
];
@@ -1569,12 +1480,14 @@ run_test("navbar_helpers", () => {
const redirect_edge_cases = [
{
operator: sender_me,
- redirect_url_with_search: "/#narrow/sender/" + me.user_id + "-" + me.email.split("@")[0],
+ redirect_url_with_search:
+ "/#narrow/sender/" + me.user_id + "-" + me.email.split("@")[0],
is_common_narrow: false,
},
{
operator: sender_joe,
- redirect_url_with_search: "/#narrow/sender/" + joe.user_id + "-" + joe.email.split("@")[0],
+ redirect_url_with_search:
+ "/#narrow/sender/" + joe.user_id + "-" + joe.email.split("@")[0],
is_common_narrow: false,
},
];
@@ -1598,10 +1511,7 @@ run_test("navbar_helpers", () => {
};
let filter = new Filter(complex_operators_test_case.operator);
- assert.equal(
- filter.generate_redirect_url(),
- complex_operators_test_case.redirect_url,
- );
+ assert.equal(filter.generate_redirect_url(), complex_operators_test_case.redirect_url);
assert.equal(filter.is_common_narrow(), false);
const stream_topic_search_operator = [
@@ -1625,10 +1535,7 @@ run_test("navbar_helpers", () => {
};
filter = new Filter(default_redirect.operator);
- assert.equal(
- filter.generate_redirect_url(),
- default_redirect.redirect_url,
- );
+ assert.equal(filter.generate_redirect_url(), default_redirect.redirect_url);
});
run_test("error_cases", () => {
diff --git a/frontend_tests/node_tests/fold_dict.js b/frontend_tests/node_tests/fold_dict.js
index ed1c6c18974..dfcef4ab78b 100644
--- a/frontend_tests/node_tests/fold_dict.js
+++ b/frontend_tests/node_tests/fold_dict.js
@@ -25,7 +25,10 @@ run_test("basic", () => {
assert.deepEqual(Array.from(d.keys()), ["foo", "bar"]);
assert.deepEqual(Array.from(d.values()), ["baz", "qux"]);
- assert.deepEqual(Array.from(d), [["foo", "baz"], ["bar", "qux"]]);
+ assert.deepEqual(Array.from(d), [
+ ["foo", "baz"],
+ ["bar", "qux"],
+ ]);
d.delete("bar");
assert.equal(d.has("bar"), false);
@@ -89,4 +92,3 @@ run_test("undefined_keys", () => {
assert.equal(d.has(undefined), false);
assert.strictEqual(d.get(undefined), undefined);
});
-
diff --git a/frontend_tests/node_tests/general.js b/frontend_tests/node_tests/general.js
index c10a721de32..4c811578615 100644
--- a/frontend_tests/node_tests/general.js
+++ b/frontend_tests/node_tests/general.js
@@ -164,17 +164,23 @@ run_test("filter", () => {
// your test, you should not feel guilty about removing them.
assert.equal(predicate({type: "personal"}), false);
- assert.equal(predicate({
- type: "stream",
- stream_id: denmark_stream.stream_id,
- topic: "does not match filter",
- }), false);
-
- assert.equal(predicate({
- type: "stream",
- stream_id: denmark_stream.stream_id,
- topic: "copenhagen",
- }), true);
+ assert.equal(
+ predicate({
+ type: "stream",
+ stream_id: denmark_stream.stream_id,
+ topic: "does not match filter",
+ }),
+ false,
+ );
+
+ assert.equal(
+ predicate({
+ type: "stream",
+ stream_id: denmark_stream.stream_id,
+ topic: "copenhagen",
+ }),
+ true,
+ );
});
// We have a "narrow" abstraction that sits roughly on top of the
@@ -557,7 +563,6 @@ run_test("unread_ops", () => {
data: {messages: "[50]", op: "add", flag: "read"},
success: channel_post_opts.success,
});
-
});
/*
@@ -625,14 +630,14 @@ function make_jquery_helper() {
function fake_jquery(selector) {
switch (selector) {
- case ".stream-list-filter":
- return stream_list_filter;
- case "ul#stream_filters li":
- return jquery_elem();
- case "#stream_filters":
- return stream_filters;
- default:
- throw Error("unknown selector: " + selector);
+ case ".stream-list-filter":
+ return stream_list_filter;
+ case "ul#stream_filters li":
+ return jquery_elem();
+ case "#stream_filters":
+ return stream_filters;
+ default:
+ throw Error("unknown selector: " + selector);
}
}
@@ -640,14 +645,9 @@ function make_jquery_helper() {
return {
verify_actions: () => {
- const expected_data_to_append = [
- [
- "stream stub",
- ],
- ];
-
- assert.deepEqual(appended_data,
- expected_data_to_append);
+ const expected_data_to_append = [["stream stub"]];
+
+ assert.deepEqual(appended_data, expected_data_to_append);
},
};
}
@@ -704,7 +704,6 @@ function make_sidebar_helper() {
return {
verify_actions: () => {
assert(updated_whether_active);
-
},
};
}
diff --git a/frontend_tests/node_tests/hash_util.js b/frontend_tests/node_tests/hash_util.js
index 4539b4e70f2..b0e3dd3264e 100644
--- a/frontend_tests/node_tests/hash_util.js
+++ b/frontend_tests/node_tests/hash_util.js
@@ -4,9 +4,12 @@ zrequire("people");
zrequire("Filter", "js/filter");
zrequire("narrow_state");
-set_global("$", global.make_zjquery({
- silent: true,
-}));
+set_global(
+ "$",
+ global.make_zjquery({
+ silent: true,
+ }),
+);
set_global("ui_report", {
displayed_error: false,
error: () => {
@@ -76,71 +79,38 @@ run_test("hash_util", () => {
});
run_test("test_get_hash_category", () => {
- assert.deepEqual(
- hash_util.get_hash_category("streams/subscribed"),
- "streams",
- );
- assert.deepEqual(
- hash_util.get_hash_category("#settings/display-settings"),
- "settings",
- );
- assert.deepEqual(
- hash_util.get_hash_category("#drafts"),
- "drafts",
- );
- assert.deepEqual(
- hash_util.get_hash_category("invites"),
- "invites",
- );
+ assert.deepEqual(hash_util.get_hash_category("streams/subscribed"), "streams");
+ assert.deepEqual(hash_util.get_hash_category("#settings/display-settings"), "settings");
+ assert.deepEqual(hash_util.get_hash_category("#drafts"), "drafts");
+ assert.deepEqual(hash_util.get_hash_category("invites"), "invites");
});
run_test("test_get_hash_section", () => {
- assert.equal(
- hash_util.get_hash_section("streams/subscribed"),
- "subscribed",
- );
- assert.equal(
- hash_util.get_hash_section("#settings/your-account"),
- "your-account",
- );
+ assert.equal(hash_util.get_hash_section("streams/subscribed"), "subscribed");
+ assert.equal(hash_util.get_hash_section("#settings/your-account"), "your-account");
- assert.equal(
- hash_util.get_hash_section("settings/10/general/"),
- "10",
- );
+ assert.equal(hash_util.get_hash_section("settings/10/general/"), "10");
- assert.equal(
- hash_util.get_hash_section("#drafts"),
- "",
- );
- assert.equal(
- hash_util.get_hash_section(""),
- "",
- );
+ assert.equal(hash_util.get_hash_section("#drafts"), "");
+ assert.equal(hash_util.get_hash_section(""), "");
});
run_test("test_parse_narrow", () => {
- assert.deepEqual(
- hash_util.parse_narrow(["narrow", "stream", "99-frontend"]),
- [{negated: false, operator: "stream", operand: "frontend"}],
- );
+ assert.deepEqual(hash_util.parse_narrow(["narrow", "stream", "99-frontend"]), [
+ {negated: false, operator: "stream", operand: "frontend"},
+ ]);
- assert.deepEqual(
- hash_util.parse_narrow(["narrow", "-stream", "99-frontend"]),
- [{negated: true, operator: "stream", operand: "frontend"}],
- );
+ assert.deepEqual(hash_util.parse_narrow(["narrow", "-stream", "99-frontend"]), [
+ {negated: true, operator: "stream", operand: "frontend"},
+ ]);
- assert.equal(
- hash_util.parse_narrow(["narrow", "BOGUS"]),
- undefined,
- );
+ assert.equal(hash_util.parse_narrow(["narrow", "BOGUS"]), undefined);
// For nonexistent streams, we get the full slug.
// We possibly should remove the prefix and fix this test.
- assert.deepEqual(
- hash_util.parse_narrow(["narrow", "stream", "42-bogus"]),
- [{negated: false, operator: "stream", operand: "42-bogus"}],
- );
+ assert.deepEqual(hash_util.parse_narrow(["narrow", "stream", "42-bogus"]), [
+ {negated: false, operator: "stream", operand: "42-bogus"},
+ ]);
});
run_test("test_stream_edit_uri", () => {
@@ -148,8 +118,7 @@ run_test("test_stream_edit_uri", () => {
name: "research & development",
stream_id: 42,
};
- assert.equal(hash_util.stream_edit_uri(sub),
- "#streams/42/research.20.26.20development");
+ assert.equal(hash_util.stream_edit_uri(sub), "#streams/42/research.20.26.20development");
});
run_test("test_by_conversation_and_time_uri", () => {
@@ -160,8 +129,10 @@ run_test("test_by_conversation_and_time_uri", () => {
id: 42,
};
- assert.equal(hash_util.by_conversation_and_time_uri(message),
- "https://example.com/#narrow/stream/99-frontend/topic/testing/near/42");
+ assert.equal(
+ hash_util.by_conversation_and_time_uri(message),
+ "https://example.com/#narrow/stream/99-frontend/topic/testing/near/42",
+ );
message = {
type: "private",
@@ -173,8 +144,10 @@ run_test("test_by_conversation_and_time_uri", () => {
id: 43,
};
- assert.equal(hash_util.by_conversation_and_time_uri(message),
- "https://example.com/#narrow/pm-with/15-pm/near/43");
+ assert.equal(
+ hash_util.by_conversation_and_time_uri(message),
+ "https://example.com/#narrow/pm-with/15-pm/near/43",
+ );
});
run_test("test_search_public_streams_notice_url", () => {
@@ -184,15 +157,17 @@ run_test("test_search_public_streams_notice_url", () => {
}
set_uri("#narrow/search/abc");
- assert.equal(hash_util.search_public_streams_notice_url(),
- "#narrow/streams/public/search/abc");
-
+ assert.equal(hash_util.search_public_streams_notice_url(), "#narrow/streams/public/search/abc");
set_uri("#narrow/has/link/has/image/has/attachment");
- assert.equal(hash_util.search_public_streams_notice_url(),
- "#narrow/streams/public/has/link/has/image/has/attachment");
+ assert.equal(
+ hash_util.search_public_streams_notice_url(),
+ "#narrow/streams/public/has/link/has/image/has/attachment",
+ );
set_uri("#narrow/sender/15");
- assert.equal(hash_util.search_public_streams_notice_url(),
- "#narrow/streams/public/sender/15-hamlet");
+ assert.equal(
+ hash_util.search_public_streams_notice_url(),
+ "#narrow/streams/public/sender/15-hamlet",
+ );
});
diff --git a/frontend_tests/node_tests/hashchange.js b/frontend_tests/node_tests/hashchange.js
index 90bf3585595..2b38bb682ad 100644
--- a/frontend_tests/node_tests/hashchange.js
+++ b/frontend_tests/node_tests/hashchange.js
@@ -63,15 +63,11 @@ run_test("operators_round_trip", () => {
stream_id: 987,
};
stream_data.add_sub(florida_stream);
- operators = [
- {operator: "stream", operand: "Florida, USA"},
- ];
+ operators = [{operator: "stream", operand: "Florida, USA"}];
hash = hash_util.operators_to_hash(operators);
assert.equal(hash, "#narrow/stream/987-Florida.2C-USA");
narrow = hash_util.parse_narrow(hash.split("/"));
- assert.deepEqual(narrow, [
- {operator: "stream", operand: "Florida, USA", negated: false},
- ]);
+ assert.deepEqual(narrow, [{operator: "stream", operand: "Florida, USA", negated: false}]);
});
run_test("operators_trailing_slash", () => {
@@ -94,19 +90,13 @@ run_test("people_slugs", () => {
};
people.add_active_user(alice);
- operators = [
- {operator: "sender", operand: "[email protected]"},
- ];
+ operators = [{operator: "sender", operand: "[email protected]"}];
hash = hash_util.operators_to_hash(operators);
assert.equal(hash, "#narrow/sender/42-alice");
const narrow = hash_util.parse_narrow(hash.split("/"));
- assert.deepEqual(narrow, [
- {operator: "sender", operand: "[email protected]", negated: false},
- ]);
+ assert.deepEqual(narrow, [{operator: "sender", operand: "[email protected]", negated: false}]);
- operators = [
- {operator: "pm-with", operand: "[email protected]"},
- ];
+ operators = [{operator: "pm-with", operand: "[email protected]"}];
hash = hash_util.operators_to_hash(operators);
assert.equal(hash, "#narrow/pm-with/42-alice");
});
@@ -212,10 +202,7 @@ run_test("hash_interactions", () => {
helper.clear_events();
$(window).trigger($.Event("hashchange", {}));
- helper.assert_events([
- "overlays.close_for_hash_change",
- "subs.launch",
- ]);
+ helper.assert_events(["overlays.close_for_hash_change", "subs.launch"]);
window.location.hash = "#keyboard-shortcuts/whatever";
@@ -251,28 +238,19 @@ run_test("hash_interactions", () => {
helper.clear_events();
$(window).trigger($.Event("hashchange", {}));
- helper.assert_events([
- "overlays.close_for_hash_change",
- "drafts.launch",
- ]);
+ helper.assert_events(["overlays.close_for_hash_change", "drafts.launch"]);
window.location.hash = "#settings/alert-words";
helper.clear_events();
$(window).trigger($.Event("hashchange", {}));
- helper.assert_events([
- "overlays.close_for_hash_change",
- "settings.launch",
- ]);
+ helper.assert_events(["overlays.close_for_hash_change", "settings.launch"]);
window.location.hash = "#organization/user-list-admin";
helper.clear_events();
$(window).trigger($.Event("hashchange", {}));
- helper.assert_events([
- "overlays.close_for_hash_change",
- "admin.launch",
- ]);
+ helper.assert_events(["overlays.close_for_hash_change", "admin.launch"]);
let called_back;
@@ -281,26 +259,19 @@ run_test("hash_interactions", () => {
called_back = true;
});
- helper.assert_events([
- "ui_util.blur_active_element",
- ]);
+ helper.assert_events(["ui_util.blur_active_element"]);
assert(called_back);
-
});
run_test("save_narrow", () => {
const helper = test_helper();
- let operators = [
- {operator: "is", operand: "private"},
- ];
+ let operators = [{operator: "is", operand: "private"}];
blueslip.expect("warn", "browser does not support pushState");
hashchange.save_narrow(operators);
- helper.assert_events([
- "message_viewport.stop_auto_scrolling",
- ]);
+ helper.assert_events(["message_viewport.stop_auto_scrolling"]);
assert.equal(window.location.hash, "#narrow/is/private");
let url_pushed;
@@ -308,14 +279,10 @@ run_test("save_narrow", () => {
url_pushed = url;
};
- operators = [
- {operator: "is", operand: "starred"},
- ];
+ operators = [{operator: "is", operand: "starred"}];
helper.clear_events();
hashchange.save_narrow(operators);
- helper.assert_events([
- "message_viewport.stop_auto_scrolling",
- ]);
+ helper.assert_events(["message_viewport.stop_auto_scrolling"]);
assert.equal(url_pushed, "http://example.com/#narrow/is/starred");
});
diff --git a/frontend_tests/node_tests/hotkey.js b/frontend_tests/node_tests/hotkey.js
index bffacff53cb..cdd6cb22066 100644
--- a/frontend_tests/node_tests/hotkey.js
+++ b/frontend_tests/node_tests/hotkey.js
@@ -11,18 +11,15 @@
// it calls any external module other than `ui.foo`, it'll crash.
// Future work includes making sure it actually does call `ui.foo()`.
-set_global("activity", {
-});
+set_global("activity", {});
set_global("navigator", {
platform: "",
});
-set_global("page_params", {
-});
+set_global("page_params", {});
-set_global("overlays", {
-});
+set_global("overlays", {});
const noop = () => {};
@@ -36,8 +33,7 @@ zrequire("emoji");
const hotkey = zrequire("hotkey");
zrequire("common");
-set_global("list_util", {
-});
+set_global("list_util", {});
set_global("current_msg_list", {
selected_id: function () {
@@ -55,8 +51,12 @@ set_global("current_msg_list", {
},
});
-function return_true() { return true; }
-function return_false() { return false; }
+function return_true() {
+ return true;
+}
+function return_false() {
+ return false;
+}
function stubbing(func_name_to_stub, test_function) {
global.with_overrides((override) => {
@@ -265,7 +265,6 @@ run_test("basic_chars", () => {
overlays.is_active = return_false;
assert_mapping("d", "drafts.launch");
-
// Test opening and closing of Recent Topics
overlays.is_active = return_true;
overlays.recent_topics_open = return_true;
diff --git a/frontend_tests/node_tests/input_pill.js b/frontend_tests/node_tests/input_pill.js
index af8233bee75..72124bc6d81 100644
--- a/frontend_tests/node_tests/input_pill.js
+++ b/frontend_tests/node_tests/input_pill.js
@@ -201,10 +201,7 @@ run_test("paste to input", () => {
paste_handler(e);
- assert.deepEqual(widget.items(), [
- items.blue,
- items.yellow,
- ]);
+ assert.deepEqual(widget.items(), [items.blue, items.yellow]);
let entered = false;
widget.createPillonPaste(() => {
@@ -300,10 +297,7 @@ run_test("comma", () => {
const widget = input_pill.create(config);
widget.appendValue("blue,red");
- assert.deepEqual(widget.items(), [
- items.blue,
- items.red,
- ]);
+ assert.deepEqual(widget.items(), [items.blue, items.red]);
const COMMA = 188;
const key_handler = container.get_on_handler("keydown", ".input");
@@ -315,10 +309,7 @@ run_test("comma", () => {
preventDefault: noop,
});
- assert.deepEqual(widget.items(), [
- items.blue,
- items.red,
- ]);
+ assert.deepEqual(widget.items(), [items.blue, items.red]);
pill_input.text = () => " yellow";
@@ -327,11 +318,7 @@ run_test("comma", () => {
preventDefault: noop,
});
- assert.deepEqual(widget.items(), [
- items.blue,
- items.red,
- items.yellow,
- ]);
+ assert.deepEqual(widget.items(), [items.blue, items.red, items.yellow]);
});
run_test("enter key with text", () => {
@@ -343,10 +330,7 @@ run_test("enter key with text", () => {
const widget = input_pill.create(config);
widget.appendValue("blue,red");
- assert.deepEqual(widget.items(), [
- items.blue,
- items.red,
- ]);
+ assert.deepEqual(widget.items(), [items.blue, items.red]);
const ENTER = 13;
const key_handler = container.get_on_handler("keydown", ".input");
@@ -360,11 +344,7 @@ run_test("enter key with text", () => {
},
});
- assert.deepEqual(widget.items(), [
- items.blue,
- items.red,
- items.yellow,
- ]);
+ assert.deepEqual(widget.items(), [items.blue, items.red, items.yellow]);
});
run_test("insert_remove", () => {
@@ -404,11 +384,7 @@ run_test("insert_remove", () => {
pill_html("YELLOW", "some_id3"),
]);
- assert.deepEqual(widget.items(), [
- items.blue,
- items.red,
- items.yellow,
- ]);
+ assert.deepEqual(widget.items(), [items.blue, items.red, items.yellow]);
assert.equal(pill_input.text(), "chartreuse, mauve");
@@ -430,10 +406,7 @@ run_test("insert_remove", () => {
assert(removed);
- assert.deepEqual(widget.items(), [
- items.blue,
- items.red,
- ]);
+ assert.deepEqual(widget.items(), [items.blue, items.red]);
let next_pill_focused = false;
@@ -507,10 +480,7 @@ run_test("exit button on pill", () => {
assert(next_pill_focused);
- assert.deepEqual(widget.items(), [
- items.red,
- ]);
-
+ assert.deepEqual(widget.items(), [items.red]);
});
run_test("misc things", () => {
diff --git a/frontend_tests/node_tests/lib/events.js b/frontend_tests/node_tests/lib/events.js
index 9a762ec0285..f66c13ec9bd 100644
--- a/frontend_tests/node_tests/lib/events.js
+++ b/frontend_tests/node_tests/lib/events.js
@@ -56,7 +56,10 @@ exports.fixtures = {
muted_topics: {
type: "muted_topics",
- muted_topics: [["devel", "js"], ["lunch", "burritos"]],
+ muted_topics: [
+ ["devel", "js"],
+ ["lunch", "burritos"],
+ ],
},
presence: {
@@ -277,9 +280,7 @@ exports.fixtures = {
realm_filters: {
type: "realm_filters",
- realm_filters: [
- ["#[123]", "ticket %(id)s"],
- ],
+ realm_filters: [["#[123]", "ticket %(id)s"]],
},
realm_domains__add: {
@@ -352,19 +353,13 @@ exports.fixtures = {
stream__create: {
type: "stream",
op: "create",
- streams: [
- {stream_id: 42},
- {stream_id: 99},
- ],
+ streams: [{stream_id: 42}, {stream_id: 99}],
},
stream__delete: {
type: "stream",
op: "delete",
- streams: [
- {stream_id: 42},
- {stream_id: 99},
- ],
+ streams: [{stream_id: 42}, {stream_id: 99}],
},
submessage: {
diff --git a/frontend_tests/node_tests/list_render.js b/frontend_tests/node_tests/list_render.js
index 8a91beef2a2..bb612ea7412 100644
--- a/frontend_tests/node_tests/list_render.js
+++ b/frontend_tests/node_tests/list_render.js
@@ -6,7 +6,7 @@ zrequire("list_render");
// strings. We initially test with raw strings.
set_global("jQuery", "stub");
function Element() {
- return { };
+ return {};
}
set_global("Element", Element);
set_global("ui", {});
@@ -158,13 +158,12 @@ run_test("scrolling", () => {
simplebar_container: scroll_container,
};
- container.html = (html) => { assert.equal(html, ""); };
+ container.html = (html) => {
+ assert.equal(html, "");
+ };
list_render.create(container, items, opts);
- assert.deepEqual(
- container.appended_data.html(),
- items.slice(0, 80).join(""),
- );
+ assert.deepEqual(container.appended_data.html(), items.slice(0, 80).join(""));
assert.equal(get_scroll_element_called, true);
// Set up our fake geometry so it forces a scroll action.
@@ -175,10 +174,7 @@ run_test("scrolling", () => {
// Scrolling gets the next two elements from the list into
// our widget.
scroll_container.call_scroll();
- assert.deepEqual(
- container.appended_data.html(),
- items.slice(80, 100).join(""),
- );
+ assert.deepEqual(container.appended_data.html(), items.slice(80, 100).join(""));
});
run_test("filtering", () => {
@@ -187,15 +183,7 @@ run_test("filtering", () => {
const search_input = make_search_input();
- const list = [
- "apple",
- "banana",
- "carrot",
- "dog",
- "egg",
- "fence",
- "grape",
- ];
+ const list = ["apple", "banana", "carrot", "dog", "egg", "fence", "grape"];
const opts = {
filter: {
element: search_input,
@@ -205,7 +193,9 @@ run_test("filtering", () => {
simplebar_container: scroll_container,
};
- container.html = (html) => { assert.equal(html, ""); };
+ container.html = (html) => {
+ assert.equal(html, "");
+ };
const widget = list_render.create(container, list, opts);
let expected_html =
@@ -228,20 +218,10 @@ run_test("filtering", () => {
assert.deepEqual(container.appended_data.html(), expected_html);
// We can insert new data into the widget.
- const new_data = [
- "greta",
- "faye",
- "gary",
- "frank",
- "giraffe",
- "fox",
- ];
+ const new_data = ["greta", "faye", "gary", "frank", "giraffe", "fox"];
widget.replace_list_data(new_data);
- expected_html =
- "<div>greta</div>" +
- "<div>gary</div>" +
- "<div>giraffe</div>";
+ expected_html = "<div>greta</div>" + "<div>gary</div>" + "<div>giraffe</div>";
assert.deepEqual(container.appended_data.html(), expected_html);
});
@@ -258,9 +238,7 @@ run_test("no filtering", () => {
const widget = list_render.create(container, ["apple", "banana"], opts);
widget.render();
- const expected_html =
- "<div>apple</div>" +
- "<div>banana</div>";
+ const expected_html = "<div>apple</div>" + "<div>banana</div>";
assert.deepEqual(container.appended_data.html(), expected_html);
});
@@ -272,9 +250,12 @@ function sort_button(opts) {
function data(sel) {
switch (sel) {
- case "sort": return opts.sort_type;
- case "sort-prop": return opts.prop_name;
- default: throw Error("unknown selector: " + sel);
+ case "sort":
+ return opts.sort_type;
+ case "sort-prop":
+ return opts.prop_name;
+ default:
+ throw Error("unknown selector: " + sel);
}
}
@@ -313,14 +294,7 @@ function sort_button(opts) {
}
run_test("wire up filter element", () => {
- const lst = [
- "alice",
- "JESSE",
- "moses",
- "scott",
- "Sean",
- "Xavier",
- ];
+ const lst = ["alice", "JESSE", "moses", "scott", "Sean", "Xavier"];
const container = make_container();
const scroll_container = make_scroll_container();
@@ -340,10 +314,7 @@ run_test("wire up filter element", () => {
list_render.create(container, lst, opts);
filter_element.f.apply({value: "se"});
- assert.equal(
- container.appended_data.html(),
- "(JESSE)(moses)(Sean)",
- );
+ assert.equal(container.appended_data.html(), "(JESSE)(moses)(Sean)");
});
run_test("sorting", () => {
@@ -399,26 +370,14 @@ run_test("sorting", () => {
assert(cleared);
assert(button.siblings_deactivated);
- expected_html = html_for([
- alice,
- bob,
- cal,
- dave,
- ellen,
- ]);
+ expected_html = html_for([alice, bob, cal, dave, ellen]);
assert.deepEqual(container.appended_data.html(), expected_html);
// Hit same button again to reverse the data.
cleared = false;
sort_container.f.apply(button);
assert(cleared);
- expected_html = html_for([
- ellen,
- dave,
- cal,
- bob,
- alice,
- ]);
+ expected_html = html_for([ellen, dave, cal, bob, alice]);
assert.deepEqual(container.appended_data.html(), expected_html);
assert(button.hasClass("descend"));
@@ -426,13 +385,7 @@ run_test("sorting", () => {
cleared = false;
sort_container.f.apply(button);
assert(cleared);
- expected_html = html_for([
- alice,
- bob,
- cal,
- dave,
- ellen,
- ]);
+ expected_html = html_for([alice, bob, cal, dave, ellen]);
assert.deepEqual(container.appended_data.html(), expected_html);
assert(!button.hasClass("descend"));
@@ -454,26 +407,14 @@ run_test("sorting", () => {
assert(cleared);
assert(button.siblings_deactivated);
- expected_html = html_for([
- dave,
- cal,
- bob,
- alice,
- ellen,
- ]);
+ expected_html = html_for([dave, cal, bob, alice, ellen]);
assert.deepEqual(container.appended_data.html(), expected_html);
// Hit same button again to reverse the numeric sort.
cleared = false;
sort_container.f.apply(button);
assert(cleared);
- expected_html = html_for([
- ellen,
- alice,
- bob,
- cal,
- dave,
- ]);
+ expected_html = html_for([ellen, alice, bob, cal, dave]);
assert.deepEqual(container.appended_data.html(), expected_html);
assert(button.hasClass("descend"));
});
@@ -508,18 +449,12 @@ run_test("custom sort", () => {
simplebar_container: scroll_container,
});
- assert.deepEqual(
- container.appended_data.html(),
- "(6, 7)(1, 43)(4, 11)",
- );
+ assert.deepEqual(container.appended_data.html(), "(6, 7)(1, 43)(4, 11)");
const widget = list_render.get("custom-sort-list");
widget.sort("x_value");
- assert.deepEqual(
- container.appended_data.html(),
- "(1, 43)(4, 11)(6, 7)",
- );
+ assert.deepEqual(container.appended_data.html(), "(1, 43)(4, 11)(6, 7)");
// We can sort without registering the function, too.
function sort_by_y(a, b) {
@@ -527,10 +462,7 @@ run_test("custom sort", () => {
}
widget.sort(sort_by_y);
- assert.deepEqual(
- container.appended_data.html(),
- "(6, 7)(4, 11)(1, 43)",
- );
+ assert.deepEqual(container.appended_data.html(), "(6, 7)(4, 11)(1, 43)");
});
run_test("clear_event_handlers", () => {
@@ -611,8 +543,7 @@ run_test("errors", () => {
blueslip.expect("error", "Filter filterer is not a function (or missing).");
list_render.create(container, list, {
- filter: {
- },
+ filter: {},
simplebar_container: scroll_container,
});
blueslip.reset();
@@ -670,20 +601,14 @@ run_test("replace_list_data w/filter update", () => {
assert.equal(num_updates, 0);
- assert.deepEqual(
- container.appended_data.html(),
- "(2)(4)",
- );
+ assert.deepEqual(container.appended_data.html(), "(2)(4)");
const widget = list_render.get("replace-list");
widget.replace_list_data([5, 6, 7, 8]);
assert.equal(num_updates, 1);
- assert.deepEqual(
- container.appended_data.html(),
- "(6)(8)",
- );
+ assert.deepEqual(container.appended_data.html(), "(6)(8)");
});
run_test("opts.get_item", () => {
@@ -700,12 +625,12 @@ run_test("opts.get_item", () => {
get_item: (n) => items[n],
};
- assert.deepEqual(
- list_render.get_filtered_items(
- "whatever", list, boring_opts,
- ),
- ["one", "two", "three", "four"],
- );
+ assert.deepEqual(list_render.get_filtered_items("whatever", list, boring_opts), [
+ "one",
+ "two",
+ "three",
+ "four",
+ ]);
const predicate = (item, value) => item.startsWith(value);
@@ -716,12 +641,7 @@ run_test("opts.get_item", () => {
},
};
- assert.deepEqual(
- list_render.get_filtered_items(
- "t", list, predicate_opts,
- ),
- ["two", "three"],
- );
+ assert.deepEqual(list_render.get_filtered_items("t", list, predicate_opts), ["two", "three"]);
const filterer_opts = {
get_item: (n) => items[n],
@@ -730,12 +650,7 @@ run_test("opts.get_item", () => {
},
};
- assert.deepEqual(
- list_render.get_filtered_items(
- "t", list, filterer_opts,
- ),
- ["two", "three"],
- );
+ assert.deepEqual(list_render.get_filtered_items("t", list, filterer_opts), ["two", "three"]);
});
run_test("render item", () => {
@@ -745,8 +660,10 @@ run_test("render item", () => {
container.html = () => {};
let called = false;
scroll_container.find = (query) => {
- const expected_queries = [`tr[data-item='${INITIAL_RENDER_COUNT}']`,
- `tr[data-item='${INITIAL_RENDER_COUNT - 1}']`];
+ const expected_queries = [
+ `tr[data-item='${INITIAL_RENDER_COUNT}']`,
+ `tr[data-item='${INITIAL_RENDER_COUNT - 1}']`,
+ ];
const item = INITIAL_RENDER_COUNT - 1;
const new_html = `<tr data-item=${item}>updated: ${item}</tr>\n`;
const regex = new RegExp(`\\<tr data-item=${item}\\>.*?<\\/tr\\>`);
@@ -790,7 +707,13 @@ run_test("render item", () => {
assert(container.appended_data.html().includes(`<tr data-item=${item}>updated: ${item}</tr>`));
// Item 80 should not be in the rendered list. (0 indexed)
- assert(!container.appended_data.html().includes(`<tr data-item=${INITIAL_RENDER_COUNT}>initial: ${INITIAL_RENDER_COUNT}</tr>`));
+ assert(
+ !container.appended_data
+ .html()
+ .includes(
+ `<tr data-item=${INITIAL_RENDER_COUNT}>initial: ${INITIAL_RENDER_COUNT}</tr>`,
+ ),
+ );
called = false;
widget.render_item(INITIAL_RENDER_COUNT);
assert(!called);
@@ -827,7 +750,7 @@ run_test("render item", () => {
let rendering_item = false;
const widget_3 = list_render.create(container, list, {
name: "replace-list",
- modifier: (item) => rendering_item ? undefined : `${item}\n`,
+ modifier: (item) => (rendering_item ? undefined : `${item}\n`),
get_item: get_item,
html_selector: (item) => `tr[data-item='${item}']`,
simplebar_container: scroll_container,
diff --git a/frontend_tests/node_tests/markdown.js b/frontend_tests/node_tests/markdown.js
index da1f3dddfcc..605486774a0 100644
--- a/frontend_tests/node_tests/markdown.js
+++ b/frontend_tests/node_tests/markdown.js
@@ -21,21 +21,16 @@ set_global("moment", require("moment-timezone"));
set_global("page_params", {
realm_users: [],
realm_emoji: {
- 1: {id: 1,
+ 1: {
+ id: 1,
name: "burrito",
source_url: "/static/generated/emoji/images/emoji/burrito.png",
deactivated: false,
},
},
realm_filters: [
- [
- "#(?P<id>[0-9]{2,8})",
- "https://trac.example.com/ticket/%(id)s",
- ],
- [
- "ZBUG_(?P<id>[0-9]{2,8})",
- "https://trac2.zulip.net/ticket/%(id)s",
- ],
+ ["#(?P<id>[0-9]{2,8})", "https://trac.example.com/ticket/%(id)s"],
+ ["ZBUG_(?P<id>[0-9]{2,8})", "https://trac2.zulip.net/ticket/%(id)s"],
[
"ZGROUP_(?P<id>[0-9]{2,8}):(?P<zone>[0-9]{1,8})",
"https://zone_%(zone)s.zulip.net/ticket/%(id)s",
@@ -182,15 +177,13 @@ stream_data.add_sub(amp_stream);
// works properly before markdown is initialized.
run_test("fenced_block_defaults", () => {
const input = "\n```\nfenced code\n```\n\nand then after\n";
- const expected = '\n\n<div class="codehilite"><pre><span></span><code>fenced code\n</code></pre></div>\n\n\n\nand then after\n\n';
+ const expected =
+ '\n\n<div class="codehilite"><pre><span></span><code>fenced code\n</code></pre></div>\n\n\n\nand then after\n\n';
const output = fenced_code.process_fenced_code(input);
assert.equal(output, expected);
});
-markdown.initialize(
- page_params.realm_filters,
- markdown_config.get_helpers(),
-);
+markdown.initialize(page_params.realm_filters, markdown_config.get_helpers());
const markdown_data = global.read_fixture_data("markdown_test_cases.json");
@@ -206,7 +199,7 @@ run_test("markdown_detection", () => {
"No user mention **leo**",
"No user mention @what there",
"No group mention *hamletcharacters*",
- "We like to code\n~~~\ndef code():\n we = \"like to do\"\n~~~",
+ 'We like to code\n~~~\ndef code():\n we = "like to do"\n~~~',
"This is a\nmultiline :emoji: here\n message",
"This is an :emoji: message",
"User Mention @**leo**",
@@ -244,7 +237,6 @@ run_test("marked_shared", () => {
const tests = markdown_data.regular_tests;
tests.forEach((test) => {
-
// Ignore tests if specified
if (test.ignore === true) {
return;
@@ -288,126 +280,245 @@ run_test("marked", () => {
{input: "hello", expected: "<p>hello</p>"},
{input: "hello there", expected: "<p>hello there</p>"},
{input: "hello **bold** for you", expected: "<p>hello <strong>bold</strong> for you</p>"},
- {input: "hello ***foo*** for you", expected: "<p>hello <strong><em>foo</em></strong> for you</p>"},
+ {
+ input: "hello ***foo*** for you",
+ expected: "<p>hello <strong><em>foo</em></strong> for you</p>",
+ },
{input: "__hello__", expected: "<p>__hello__</p>"},
- {input: "\n```\nfenced code\n```\n\nand then after\n",
- expected: '<div class="codehilite"><pre><span></span><code>fenced code\n</code></pre></div>\n\n\n<p>and then after</p>'},
- {input: "\n```\n fenced code trailing whitespace \n```\n\nand then after\n",
- expected: '<div class="codehilite"><pre><span></span><code> fenced code trailing whitespace\n</code></pre></div>\n\n\n<p>and then after</p>'},
- {input: "* a\n* list \n* here",
- expected: "<ul>\n<li>a</li>\n<li>list </li>\n<li>here</li>\n</ul>"},
- {input: "\n```c#\nfenced code special\n```\n\nand then after\n",
- expected: '<div class="codehilite"><pre><span></span><code>fenced code special\n</code></pre></div>\n\n\n<p>and then after</p>'},
- {input: "\n```vb.net\nfenced code dot\n```\n\nand then after\n",
- expected: '<div class="codehilite"><pre><span></span><code>fenced code dot\n</code></pre></div>\n\n\n<p>and then after</p>'},
- {input: "Some text first\n* a\n* list \n* here\n\nand then after",
- expected: "<p>Some text first</p>\n<ul>\n<li>a</li>\n<li>list </li>\n<li>here</li>\n</ul>\n<p>and then after</p>"},
- {input: "1. an\n2. ordered \n3. list",
- expected: "<ol>\n<li>an</li>\n<li>ordered </li>\n<li>list</li>\n</ol>"},
- {input: "\n~~~quote\nquote this for me\n~~~\nthanks\n",
- expected: "<blockquote>\n<p>quote this for me</p>\n</blockquote>\n<p>thanks</p>"},
- {input: "This is a @**CordeLIA Lear** mention",
- expected: '<p>This is a <span class="user-mention" data-user-id="101">@Cordelia Lear</span> mention</p>'},
- {input: "These @ @**** are not mentions",
- expected: "<p>These @ @<em>**</em> are not mentions</p>"},
- {input: "These # #**** are not mentions",
- expected: "<p>These # #<em>**</em> are not mentions</p>"},
- {input: "These @* are not mentions",
- expected: "<p>These @* are not mentions</p>"},
- {input: "These #* #*** are also not mentions",
- expected: "<p>These #* #*** are also not mentions</p>"},
- {input: "This is a #**Denmark** stream link",
- expected: '<p>This is a <a class="stream" data-stream-id="1" href="/#narrow/stream/1-Denmark">#Denmark</a> stream link</p>'},
- {input: "This is #**Denmark** and #**social** stream links",
- expected: '<p>This is <a class="stream" data-stream-id="1" href="/#narrow/stream/1-Denmark">#Denmark</a> and <a class="stream" data-stream-id="2" href="/#narrow/stream/2-social">#social</a> stream links</p>'},
- {input: "And this is a #**wrong** stream link",
- expected: "<p>And this is a #**wrong** stream link</p>"},
- {input: "This is a #**Denmark>some topic** stream_topic link",
- expected: '<p>This is a <a class="stream-topic" data-stream-id="1" href="/#narrow/stream/1-Denmark/topic/some.20topic">#Denmark > some topic</a> stream_topic link</p>'},
- {input: "This has two links: #**Denmark>some topic** and #**social>other topic**.",
- expected: '<p>This has two links: <a class="stream-topic" data-stream-id="1" href="/#narrow/stream/1-Denmark/topic/some.20topic">#Denmark > some topic</a> and <a class="stream-topic" data-stream-id="2" href="/#narrow/stream/2-social/topic/other.20topic">#social > other topic</a>.</p>'},
- {input: "This is not a #**Denmark>** stream_topic link",
- expected: "<p>This is not a #**Denmark&gt;** stream_topic link</p>"},
- {input: "mmm...:burrito:s",
- expected: '<p>mmm...<img alt=":burrito:" class="emoji" src="/static/generated/emoji/images/emoji/burrito.png" title="burrito">s</p>'},
- {input: "This is an :poop: message",
- expected: '<p>This is an <span aria-label="poop" class="emoji emoji-1f4a9" role="img" title="poop">:poop:</span> message</p>'},
- {input: "\ud83d\udca9",
- expected: '<p><span aria-label="poop" class="emoji emoji-1f4a9" role="img" title="poop">:poop:</span></p>'},
- {input: "\u{1f6b2}",
- expected: "<p>\u{1f6b2}</p>"},
- {input: "Silent mention: @_**Cordelia Lear**",
- expected: '<p>Silent mention: <span class="user-mention silent" data-user-id="101">Cordelia Lear</span></p>'},
- {input: "> Mention in quote: @**Cordelia Lear**\n\nMention outside quote: @**Cordelia Lear**",
- expected: '<blockquote>\n<p>Mention in quote: <span class="user-mention silent" data-user-id="101">Cordelia Lear</span></p>\n</blockquote>\n<p>Mention outside quote: <span class="user-mention" data-user-id="101">@Cordelia Lear</span></p>'},
+ {
+ input: "\n```\nfenced code\n```\n\nand then after\n",
+ expected:
+ '<div class="codehilite"><pre><span></span><code>fenced code\n</code></pre></div>\n\n\n<p>and then after</p>',
+ },
+ {
+ input:
+ "\n```\n fenced code trailing whitespace \n```\n\nand then after\n",
+ expected:
+ '<div class="codehilite"><pre><span></span><code> fenced code trailing whitespace\n</code></pre></div>\n\n\n<p>and then after</p>',
+ },
+ {
+ input: "* a\n* list \n* here",
+ expected: "<ul>\n<li>a</li>\n<li>list </li>\n<li>here</li>\n</ul>",
+ },
+ {
+ input: "\n```c#\nfenced code special\n```\n\nand then after\n",
+ expected:
+ '<div class="codehilite"><pre><span></span><code>fenced code special\n</code></pre></div>\n\n\n<p>and then after</p>',
+ },
+ {
+ input: "\n```vb.net\nfenced code dot\n```\n\nand then after\n",
+ expected:
+ '<div class="codehilite"><pre><span></span><code>fenced code dot\n</code></pre></div>\n\n\n<p>and then after</p>',
+ },
+ {
+ input: "Some text first\n* a\n* list \n* here\n\nand then after",
+ expected:
+ "<p>Some text first</p>\n<ul>\n<li>a</li>\n<li>list </li>\n<li>here</li>\n</ul>\n<p>and then after</p>",
+ },
+ {
+ input: "1. an\n2. ordered \n3. list",
+ expected: "<ol>\n<li>an</li>\n<li>ordered </li>\n<li>list</li>\n</ol>",
+ },
+ {
+ input: "\n~~~quote\nquote this for me\n~~~\nthanks\n",
+ expected: "<blockquote>\n<p>quote this for me</p>\n</blockquote>\n<p>thanks</p>",
+ },
+ {
+ input: "This is a @**CordeLIA Lear** mention",
+ expected:
+ '<p>This is a <span class="user-mention" data-user-id="101">@Cordelia Lear</span> mention</p>',
+ },
+ {
+ input: "These @ @**** are not mentions",
+ expected: "<p>These @ @<em>**</em> are not mentions</p>",
+ },
+ {
+ input: "These # #**** are not mentions",
+ expected: "<p>These # #<em>**</em> are not mentions</p>",
+ },
+ {input: "These @* are not mentions", expected: "<p>These @* are not mentions</p>"},
+ {
+ input: "These #* #*** are also not mentions",
+ expected: "<p>These #* #*** are also not mentions</p>",
+ },
+ {
+ input: "This is a #**Denmark** stream link",
+ expected:
+ '<p>This is a <a class="stream" data-stream-id="1" href="/#narrow/stream/1-Denmark">#Denmark</a> stream link</p>',
+ },
+ {
+ input: "This is #**Denmark** and #**social** stream links",
+ expected:
+ '<p>This is <a class="stream" data-stream-id="1" href="/#narrow/stream/1-Denmark">#Denmark</a> and <a class="stream" data-stream-id="2" href="/#narrow/stream/2-social">#social</a> stream links</p>',
+ },
+ {
+ input: "And this is a #**wrong** stream link",
+ expected: "<p>And this is a #**wrong** stream link</p>",
+ },
+ {
+ input: "This is a #**Denmark>some topic** stream_topic link",
+ expected:
+ '<p>This is a <a class="stream-topic" data-stream-id="1" href="/#narrow/stream/1-Denmark/topic/some.20topic">#Denmark > some topic</a> stream_topic link</p>',
+ },
+ {
+ input: "This has two links: #**Denmark>some topic** and #**social>other topic**.",
+ expected:
+ '<p>This has two links: <a class="stream-topic" data-stream-id="1" href="/#narrow/stream/1-Denmark/topic/some.20topic">#Denmark > some topic</a> and <a class="stream-topic" data-stream-id="2" href="/#narrow/stream/2-social/topic/other.20topic">#social > other topic</a>.</p>',
+ },
+ {
+ input: "This is not a #**Denmark>** stream_topic link",
+ expected: "<p>This is not a #**Denmark&gt;** stream_topic link</p>",
+ },
+ {
+ input: "mmm...:burrito:s",
+ expected:
+ '<p>mmm...<img alt=":burrito:" class="emoji" src="/static/generated/emoji/images/emoji/burrito.png" title="burrito">s</p>',
+ },
+ {
+ input: "This is an :poop: message",
+ expected:
+ '<p>This is an <span aria-label="poop" class="emoji emoji-1f4a9" role="img" title="poop">:poop:</span> message</p>',
+ },
+ {
+ input: "\ud83d\udca9",
+ expected:
+ '<p><span aria-label="poop" class="emoji emoji-1f4a9" role="img" title="poop">:poop:</span></p>',
+ },
+ {input: "\u{1f6b2}", expected: "<p>\u{1f6b2}</p>"},
+ {
+ input: "Silent mention: @_**Cordelia Lear**",
+ expected:
+ '<p>Silent mention: <span class="user-mention silent" data-user-id="101">Cordelia Lear</span></p>',
+ },
+ {
+ input:
+ "> Mention in quote: @**Cordelia Lear**\n\nMention outside quote: @**Cordelia Lear**",
+ expected:
+ '<blockquote>\n<p>Mention in quote: <span class="user-mention silent" data-user-id="101">Cordelia Lear</span></p>\n</blockquote>\n<p>Mention outside quote: <span class="user-mention" data-user-id="101">@Cordelia Lear</span></p>',
+ },
// Test only those realm filters which don't return True for
// `contains_backend_only_syntax()`. Those which return True
// are tested separately.
- {input: "This is a realm filter #1234 with text after it",
- expected: '<p>This is a realm filter <a href="https://trac.example.com/ticket/1234" title="https://trac.example.com/ticket/1234">#1234</a> with text after it</p>'},
- {input: "#1234is not a realm filter.",
- expected: "<p>#1234is not a realm filter.</p>"},
- {input: "A pattern written as #1234is not a realm filter.",
- expected: "<p>A pattern written as #1234is not a realm filter.</p>"},
- {input: "This is a realm filter with ZGROUP_123:45 groups",
- expected: '<p>This is a realm filter with <a href="https://zone_45.zulip.net/ticket/123" title="https://zone_45.zulip.net/ticket/123">ZGROUP_123:45</a> groups</p>'},
- {input: "Test *italic*",
- expected: "<p>Test <em>italic</em></p>"},
- {input: "T\n#**Denmark**",
- expected: '<p>T<br>\n<a class="stream" data-stream-id="1" href="/#narrow/stream/1-Denmark">#Denmark</a></p>'},
- {input: "T\n@**Cordelia Lear**",
- expected: '<p>T<br>\n<span class="user-mention" data-user-id="101">@Cordelia Lear</span></p>'},
- {input: "@**Mark Twin|104** and @**Mark Twin|105** are out to confuse you.",
- expected: '<p><span class="user-mention" data-user-id="104">@Mark Twin</span> and <span class="user-mention" data-user-id="105">@Mark Twin</span> are out to confuse you.</p>'},
- {input: "@**Invalid User|1234**",
- expected: "<p>@**Invalid User|1234**</p>"},
- {input: "@**Cordelia LeAR|103** has a wrong user_id.",
- expected: "<p>@**Cordelia LeAR|103** has a wrong user_id.</p>"},
- {input: "@**Brother of Bobby|123** is really the full name.",
- expected: '<p><span class="user-mention" data-user-id="106">@Brother of Bobby|123</span> is really the full name.</p>'},
- {input: "@**Brother of Bobby|123|106**",
- expected: '<p><span class="user-mention" data-user-id="106">@Brother of Bobby|123</span></p>'},
- {input: "T\n@hamletcharacters",
- expected: "<p>T<br>\n@hamletcharacters</p>"},
- {input: "T\n@*hamletcharacters*",
- expected: '<p>T<br>\n<span class="user-group-mention" data-user-group-id="1">@hamletcharacters</span></p>'},
- {input: "T\n@*notagroup*",
- expected: "<p>T<br>\n@*notagroup*</p>"},
- {input: "T\n@*backend*",
- expected: '<p>T<br>\n<span class="user-group-mention" data-user-group-id="2">@Backend</span></p>'},
- {input: "@*notagroup*",
- expected: "<p>@*notagroup*</p>"},
- {input: "This is a realm filter `hello` with text after it",
- expected: "<p>This is a realm filter <code>hello</code> with text after it</p>"},
+ {
+ input: "This is a realm filter #1234 with text after it",
+ expected:
+ '<p>This is a realm filter <a href="https://trac.example.com/ticket/1234" title="https://trac.example.com/ticket/1234">#1234</a> with text after it</p>',
+ },
+ {input: "#1234is not a realm filter.", expected: "<p>#1234is not a realm filter.</p>"},
+ {
+ input: "A pattern written as #1234is not a realm filter.",
+ expected: "<p>A pattern written as #1234is not a realm filter.</p>",
+ },
+ {
+ input: "This is a realm filter with ZGROUP_123:45 groups",
+ expected:
+ '<p>This is a realm filter with <a href="https://zone_45.zulip.net/ticket/123" title="https://zone_45.zulip.net/ticket/123">ZGROUP_123:45</a> groups</p>',
+ },
+ {input: "Test *italic*", expected: "<p>Test <em>italic</em></p>"},
+ {
+ input: "T\n#**Denmark**",
+ expected:
+ '<p>T<br>\n<a class="stream" data-stream-id="1" href="/#narrow/stream/1-Denmark">#Denmark</a></p>',
+ },
+ {
+ input: "T\n@**Cordelia Lear**",
+ expected:
+ '<p>T<br>\n<span class="user-mention" data-user-id="101">@Cordelia Lear</span></p>',
+ },
+ {
+ input: "@**Mark Twin|104** and @**Mark Twin|105** are out to confuse you.",
+ expected:
+ '<p><span class="user-mention" data-user-id="104">@Mark Twin</span> and <span class="user-mention" data-user-id="105">@Mark Twin</span> are out to confuse you.</p>',
+ },
+ {input: "@**Invalid User|1234**", expected: "<p>@**Invalid User|1234**</p>"},
+ {
+ input: "@**Cordelia LeAR|103** has a wrong user_id.",
+ expected: "<p>@**Cordelia LeAR|103** has a wrong user_id.</p>",
+ },
+ {
+ input: "@**Brother of Bobby|123** is really the full name.",
+ expected:
+ '<p><span class="user-mention" data-user-id="106">@Brother of Bobby|123</span> is really the full name.</p>',
+ },
+ {
+ input: "@**Brother of Bobby|123|106**",
+ expected:
+ '<p><span class="user-mention" data-user-id="106">@Brother of Bobby|123</span></p>',
+ },
+ {input: "T\n@hamletcharacters", expected: "<p>T<br>\n@hamletcharacters</p>"},
+ {
+ input: "T\n@*hamletcharacters*",
+ expected:
+ '<p>T<br>\n<span class="user-group-mention" data-user-group-id="1">@hamletcharacters</span></p>',
+ },
+ {input: "T\n@*notagroup*", expected: "<p>T<br>\n@*notagroup*</p>"},
+ {
+ input: "T\n@*backend*",
+ expected:
+ '<p>T<br>\n<span class="user-group-mention" data-user-group-id="2">@Backend</span></p>',
+ },
+ {input: "@*notagroup*", expected: "<p>@*notagroup*</p>"},
+ {
+ input: "This is a realm filter `hello` with text after it",
+ expected: "<p>This is a realm filter <code>hello</code> with text after it</p>",
+ },
// Test the emoticon conversion
- {input: ":)",
- expected: "<p>:)</p>"},
- {input: ":)",
- expected: '<p><span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>',
- translate_emoticons: true},
+ {input: ":)", expected: "<p>:)</p>"},
+ {
+ input: ":)",
+ expected:
+ '<p><span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>',
+ translate_emoticons: true,
+ },
// Test HTML Escape in Custom Zulip Rules
- {input: "@**<h1>The Rogue One</h1>**",
- expected: "<p>@**&lt;h1&gt;The Rogue One&lt;/h1&gt;**</p>"},
- {input: "#**<h1>The Rogue One</h1>**",
- expected: "<p>#**&lt;h1&gt;The Rogue One&lt;/h1&gt;**</p>"},
- {input: ":<h1>The Rogue One</h1>:",
- expected: "<p>:&lt;h1&gt;The Rogue One&lt;/h1&gt;:</p>"},
- {input: "@**O'Connell**",
- expected: "<p>@**O&#39;Connell**</p>"},
- {input: "@*Bobby <h1>Tables</h1>*",
- expected: '<p><span class="user-group-mention" data-user-group-id="3">@Bobby &lt;h1&gt;Tables&lt;/h1&gt;</span></p>'},
- {input: "@*& &amp; &amp;amp;*",
- expected: '<p><span class="user-group-mention" data-user-group-id="4">@&amp; &amp; &amp;amp;</span></p>'},
- {input: "@**Bobby <h1>Tables</h1>**",
- expected: '<p><span class="user-mention" data-user-id="103">@Bobby &lt;h1&gt;Tables&lt;/h1&gt;</span></p>'},
- {input: "@**& &amp; &amp;amp;**",
- expected: '<p><span class="user-mention" data-user-id="107">@&amp; &amp; &amp;amp;</span></p>'},
- {input: "#**Bobby <h1>Tables</h1>**",
- expected: '<p><a class="stream-topic" data-stream-id="4" href="/#narrow/stream/4-Bobby-.3Ch1/topic/Tables.3C.2Fh1.3E">#Bobby &lt;h1 > Tables&lt;/h1&gt;</a></p>'},
- {input: "#**& &amp; &amp;amp;**",
- expected: '<p><a class="stream" data-stream-id="5" href="/#narrow/stream/5-.26-.26.20.26amp.3B">#&amp; &amp; &amp;amp;</a></p>'},
- {input: "#**& &amp; &amp;amp;>& &amp; &amp;amp;**",
- expected: '<p><a class="stream-topic" data-stream-id="5" href="/#narrow/stream/5-.26-.26.20.26amp.3B/topic/.26.20.26.20.26amp.3B">#&amp; &amp; &amp;amp; > &amp; &amp; &amp;amp;</a></p>'},
+ {
+ input: "@**<h1>The Rogue One</h1>**",
+ expected: "<p>@**&lt;h1&gt;The Rogue One&lt;/h1&gt;**</p>",
+ },
+ {
+ input: "#**<h1>The Rogue One</h1>**",
+ expected: "<p>#**&lt;h1&gt;The Rogue One&lt;/h1&gt;**</p>",
+ },
+ {
+ input: ":<h1>The Rogue One</h1>:",
+ expected: "<p>:&lt;h1&gt;The Rogue One&lt;/h1&gt;:</p>",
+ },
+ {input: "@**O'Connell**", expected: "<p>@**O&#39;Connell**</p>"},
+ {
+ input: "@*Bobby <h1>Tables</h1>*",
+ expected:
+ '<p><span class="user-group-mention" data-user-group-id="3">@Bobby &lt;h1&gt;Tables&lt;/h1&gt;</span></p>',
+ },
+ {
+ input: "@*& &amp; &amp;amp;*",
+ expected:
+ '<p><span class="user-group-mention" data-user-group-id="4">@&amp; &amp; &amp;amp;</span></p>',
+ },
+ {
+ input: "@**Bobby <h1>Tables</h1>**",
+ expected:
+ '<p><span class="user-mention" data-user-id="103">@Bobby &lt;h1&gt;Tables&lt;/h1&gt;</span></p>',
+ },
+ {
+ input: "@**& &amp; &amp;amp;**",
+ expected:
+ '<p><span class="user-mention" data-user-id="107">@&amp; &amp; &amp;amp;</span></p>',
+ },
+ {
+ input: "#**Bobby <h1>Tables</h1>**",
+ expected:
+ '<p><a class="stream-topic" data-stream-id="4" href="/#narrow/stream/4-Bobby-.3Ch1/topic/Tables.3C.2Fh1.3E">#Bobby &lt;h1 > Tables&lt;/h1&gt;</a></p>',
+ },
+ {
+ input: "#**& &amp; &amp;amp;**",
+ expected:
+ '<p><a class="stream" data-stream-id="5" href="/#narrow/stream/5-.26-.26.20.26amp.3B">#&amp; &amp; &amp;amp;</a></p>',
+ },
+ {
+ input: "#**& &amp; &amp;amp;>& &amp; &amp;amp;**",
+ expected:
+ '<p><a class="stream-topic" data-stream-id="5" href="/#narrow/stream/5-.26-.26.20.26amp.3B/topic/.26.20.26.20.26amp.3B">#&amp; &amp; &amp;amp; > &amp; &amp; &amp;amp;</a></p>',
+ },
];
// We remove one of the unicode emoji we put as input in one of the test
@@ -568,12 +679,17 @@ run_test("python_to_js_filter", () => {
let expected_value = [/\/aa\/g(?![\w])/gim, /\/aa\/g(?![\w])/g];
assert.deepEqual(actual_value, expected_value);
// Test case with multiple replacements.
- markdown.update_realm_filter_rules([["#cf(?P<contest>[0-9]+)(?P<problem>[A-Z][0-9A-Z]*)", "http://google.com"]]);
+ markdown.update_realm_filter_rules([
+ ["#cf(?P<contest>[0-9]+)(?P<problem>[A-Z][0-9A-Z]*)", "http://google.com"],
+ ]);
actual_value = marked.InlineLexer.rules.zulip.realm_filters;
expected_value = [/#cf([0-9]+)([A-Z][0-9A-Z]*)(?![\w])/g];
assert.deepEqual(actual_value, expected_value);
// Test incorrect syntax.
- blueslip.expect("error", "python_to_js_filter: Invalid regular expression: /!@#@(!#&((!&(@#((?![\\w])/: Unterminated group");
+ blueslip.expect(
+ "error",
+ "python_to_js_filter: Invalid regular expression: /!@#@(!#&((!&(@#((?![\\w])/: Unterminated group",
+ );
markdown.update_realm_filter_rules([["!@#@(!#&((!&(@#(", "http://google.com"]]);
actual_value = marked.InlineLexer.rules.zulip.realm_filters;
expected_value = [];
@@ -581,7 +697,9 @@ run_test("python_to_js_filter", () => {
});
run_test("katex_throws_unexpected_exceptions", () => {
- katex.renderToString = function () { throw new Error("some-exception"); };
+ katex.renderToString = function () {
+ throw new Error("some-exception");
+ };
blueslip.expect("error", "Error: some-exception");
const message = {raw_content: "$$a$$"};
markdown.apply_markdown(message);
@@ -605,9 +723,21 @@ run_test("translate_emoticons_to_names", () => {
{name: "symbol at start", original: "Hello,<original>", expected: "Hello,<converted>"},
{name: "after a word", original: "Hello<original>", expected: "Hello<original>"},
{name: "between words", original: "Hello<original>World", expected: "Hello<original>World"},
- {name: "end of sentence", original: "End of sentence. <original>", expected: "End of sentence. <converted>"},
- {name: "between symbols", original: "Hello.<original>! World.", expected: "Hello.<original>! World."},
- {name: "before end of sentence", original: "Hello <original>!", expected: "Hello <converted>!"},
+ {
+ name: "end of sentence",
+ original: "End of sentence. <original>",
+ expected: "End of sentence. <converted>",
+ },
+ {
+ name: "between symbols",
+ original: "Hello.<original>! World.",
+ expected: "Hello.<original>! World.",
+ },
+ {
+ name: "before end of sentence",
+ original: "Hello <original>!",
+ expected: "Hello <converted>!",
+ },
];
for (const [shortcut, full_name] of Object.entries(emoji_codes.emoticon_conversions)) {
for (const t of testcases) {
@@ -615,7 +745,8 @@ run_test("translate_emoticons_to_names", () => {
let original = t.original;
let expected = t.expected;
original = original.replace(/(<original>)/g, shortcut);
- expected = expected.replace(/(<original>)/g, shortcut)
+ expected = expected
+ .replace(/(<original>)/g, shortcut)
.replace(/(<converted>)/g, converted_value);
const result = markdown.translate_emoticons_to_names(original);
assert.equal(result, expected);
diff --git a/frontend_tests/node_tests/message_edit.js b/frontend_tests/node_tests/message_edit.js
index c2ab1c6f0d9..1e2a82c8dae 100644
--- a/frontend_tests/node_tests/message_edit.js
+++ b/frontend_tests/node_tests/message_edit.js
@@ -15,23 +15,32 @@ run_test("get_editability", () => {
// You can't edit a null message
assert.equal(get_editability(null), editability_types.NO);
// You can't edit a message you didn't send
- assert.equal(get_editability({
- sent_by_me: false,
- }), editability_types.NO);
+ assert.equal(
+ get_editability({
+ sent_by_me: false,
+ }),
+ editability_types.NO,
+ );
// Failed request are currently not editable (though we want to
// change this back).
- assert.equal(get_editability({
- sent_by_me: true,
- failed_request: true,
- }), editability_types.NO);
+ assert.equal(
+ get_editability({
+ sent_by_me: true,
+ failed_request: true,
+ }),
+ editability_types.NO,
+ );
// Locally echoed messages are not editable, since the message hasn't
// finished being sent yet.
- assert.equal(get_editability({
- sent_by_me: true,
- local_id: "25",
- }), editability_types.NO);
+ assert.equal(
+ get_editability({
+ sent_by_me: true,
+ local_id: "25",
+ }),
+ editability_types.NO,
+ );
// For the rest of these tests, we only consider messages sent by the
// user, and that were successfully sent (i.e. no failed_request or local_id)
diff --git a/frontend_tests/node_tests/message_events.js b/frontend_tests/node_tests/message_events.js
index a3684da8f3d..4b867b1bc24 100644
--- a/frontend_tests/node_tests/message_events.js
+++ b/frontend_tests/node_tests/message_events.js
@@ -75,10 +75,7 @@ run_test("update_messages", () => {
assert.equal(original_message.mentioned, true);
assert.equal(original_message.unread, true);
- assert.deepEqual(
- stream_topic_history.get_recent_topic_names(denmark.stream_id),
- ["lunch"],
- );
+ assert.deepEqual(stream_topic_history.get_recent_topic_names(denmark.stream_id), ["lunch"]);
unread.update_message_for_mention(original_message);
assert(unread.unread_mentions_counter.has(original_message.id));
@@ -154,5 +151,4 @@ run_test("update_messages", () => {
unread: true,
},
]);
-
});
diff --git a/frontend_tests/node_tests/message_fetch.js b/frontend_tests/node_tests/message_fetch.js
index 194d54200d8..91a51a56073 100644
--- a/frontend_tests/node_tests/message_fetch.js
+++ b/frontend_tests/node_tests/message_fetch.js
@@ -282,7 +282,9 @@ function simulate_narrow() {
predicate: () => () => false,
};
- narrow_state.active = function () { return true; };
+ narrow_state.active = function () {
+ return true;
+ };
narrow_state.public_operators = function () {
return [{operator: "pm-with", operand: alice.email}];
};
@@ -454,7 +456,5 @@ run_test("loading_newer", () => {
});
assert.equal(msg_list.data.fetch_status.can_load_newer_messages(), false);
-
})();
-
});
diff --git a/frontend_tests/node_tests/message_list.js b/frontend_tests/node_tests/message_list.js
index c136eea1650..ab60d82efa7 100644
--- a/frontend_tests/node_tests/message_list.js
+++ b/frontend_tests/node_tests/message_list.js
@@ -220,7 +220,10 @@ run_test("nth_most_recent_id", () => {
run_test("change_message_id", () => {
const list = new MessageList({});
- list.data._add_to_hash([{id: 10.5, content: "good job"}, {id: 20.5, content: "ok!"}]);
+ list.data._add_to_hash([
+ {id: 10.5, content: "good job"},
+ {id: 20.5, content: "ok!"},
+ ]);
// local to local
list.change_message_id(10.5, 11.5);
@@ -261,8 +264,16 @@ run_test("last_sent_by_me", () => {
run_test("local_echo", () => {
let list = new MessageList({});
- list.append([{id: 10}, {id: 20}, {id: 30}, {id: 20.02},
- {id: 20.03}, {id: 40}, {id: 50}, {id: 60}]);
+ list.append([
+ {id: 10},
+ {id: 20},
+ {id: 30},
+ {id: 20.02},
+ {id: 20.03},
+ {id: 40},
+ {id: 50},
+ {id: 60},
+ ]);
list._local_only = {20.02: {id: 20.02}, 20.03: {id: 20.03}};
assert.equal(list.closest_id(10), 10);
@@ -284,10 +295,23 @@ run_test("local_echo", () => {
list = new MessageList({});
list.append([
- {id: 10}, {id: 20}, {id: 30}, {id: 20.02}, {id: 20.03}, {id: 40},
- {id: 50}, {id: 50.01}, {id: 50.02}, {id: 60}]);
- list._local_only = {20.02: {id: 20.02}, 20.03: {id: 20.03},
- 50.01: {id: 50.01}, 50.02: {id: 50.02}};
+ {id: 10},
+ {id: 20},
+ {id: 30},
+ {id: 20.02},
+ {id: 20.03},
+ {id: 40},
+ {id: 50},
+ {id: 50.01},
+ {id: 50.02},
+ {id: 60},
+ ]);
+ list._local_only = {
+ 20.02: {id: 20.02},
+ 20.03: {id: 20.03},
+ 50.01: {id: 50.01},
+ 50.02: {id: 50.02},
+ };
assert.equal(list.closest_id(10), 10);
assert.equal(list.closest_id(20), 20);
@@ -418,7 +442,9 @@ run_test("add_remove_rerender", () => {
const messages = [{id: 1}, {id: 2}, {id: 3}];
- list.data.unmuted_messages = function (msgs) { return msgs; };
+ list.data.unmuted_messages = function (msgs) {
+ return msgs;
+ };
list.add_messages(messages);
assert.equal(list.num_items(), 3);
diff --git a/frontend_tests/node_tests/message_list_data.js b/frontend_tests/node_tests/message_list_data.js
index 9936a19e08c..27e89fe9849 100644
--- a/frontend_tests/node_tests/message_list_data.js
+++ b/frontend_tests/node_tests/message_list_data.js
@@ -104,7 +104,9 @@ run_test("muting enabled", () => {
filter: undefined,
});
- muting.is_topic_muted = function () { return true; };
+ muting.is_topic_muted = function () {
+ return true;
+ };
mld.add_anywhere(make_msgs([35, 25, 15, 45]));
assert_contents(mld, []);
@@ -187,17 +189,10 @@ run_test("more muting", () => {
);
assert.deepEqual(more_info, {
- top_messages: [
- {id: 2, topic: "whatever"},
- ],
- interior_messages: [
- {id: 6, topic: "whatever"},
- ],
- bottom_messages: [
- {id: 10, topic: "whatever"},
- ],
+ top_messages: [{id: 2, topic: "whatever"}],
+ interior_messages: [{id: 6, topic: "whatever"}],
+ bottom_messages: [{id: 10, topic: "whatever"}],
});
-
});
run_test("errors", () => {
@@ -207,9 +202,12 @@ run_test("errors", () => {
});
assert.equal(mld.get("bogus-id"), undefined);
- assert.throws(() => {
- mld._add_to_hash(["asdf"]);
- }, {message: "Bad message id"});
+ assert.throws(
+ () => {
+ mld._add_to_hash(["asdf"]);
+ },
+ {message: "Bad message id"},
+ );
blueslip.expect("error", "Duplicate message added to MessageListData");
mld._hash.set(1, "taken");
diff --git a/frontend_tests/node_tests/message_list_view.js b/frontend_tests/node_tests/message_list_view.js
index 08fdad7c408..b9430807523 100644
--- a/frontend_tests/node_tests/message_list_view.js
+++ b/frontend_tests/node_tests/message_list_view.js
@@ -14,7 +14,11 @@ set_global("page_params", {
twenty_four_hour_time: false,
});
set_global("home_msg_list", null);
-set_global("people", {small_avatar_url: function () { return ""; }});
+set_global("people", {
+ small_avatar_url: function () {
+ return "";
+ },
+});
set_global("unread", {message_unread: function () {}});
// timerender calls setInterval when imported
set_global("timerender", {
@@ -67,7 +71,7 @@ run_test("msg_edited_vars", () => {
};
message_context.msg = {
is_me_message: false,
- last_edit_timestamp: next_timestamp += 1,
+ last_edit_timestamp: (next_timestamp += 1),
...message,
};
return message_context;
@@ -145,7 +149,7 @@ run_test("merge_message_groups", () => {
stream: "Test Stream 1",
topic: "Test Subject 1",
sender_email: "[email protected]",
- timestamp: next_timestamp += 1,
+ timestamp: (next_timestamp += 1),
...message,
};
return message_context;
@@ -192,9 +196,7 @@ run_test("merge_message_groups", () => {
(function test_empty_list_bottom() {
const list = build_list([]);
- const message_group = build_message_group([
- build_message_context(),
- ]);
+ const message_group = build_message_group([build_message_context()]);
const result = list.merge_message_groups([message_group], "bottom");
@@ -207,23 +209,18 @@ run_test("merge_message_groups", () => {
})();
(function test_append_message_same_subject() {
-
const message1 = build_message_context();
- const message_group1 = build_message_group([
- message1,
- ]);
+ const message_group1 = build_message_group([message1]);
const message2 = build_message_context();
- const message_group2 = build_message_group([
- message2,
- ]);
+ const message_group2 = build_message_group([message2]);
const list = build_list([message_group1]);
const result = list.merge_message_groups([message_group2], "bottom");
- assert_message_groups_list_equal(
- list._message_groups,
- [build_message_group([message1, message2])]);
+ assert_message_groups_list_equal(list._message_groups, [
+ build_message_group([message1, message2]),
+ ]);
assert.deepEqual(result.append_groups, []);
assert.deepEqual(result.prepend_groups, []);
assert.deepEqual(result.rerender_groups, []);
@@ -232,24 +229,17 @@ run_test("merge_message_groups", () => {
})();
(function test_append_message_different_subject() {
-
const message1 = build_message_context();
- const message_group1 = build_message_group([
- message1,
- ]);
+ const message_group1 = build_message_group([message1]);
const message2 = build_message_context({topic: "Test subject 2"});
- const message_group2 = build_message_group([
- message2,
- ]);
+ const message_group2 = build_message_group([message2]);
const list = build_list([message_group1]);
const result = list.merge_message_groups([message_group2], "bottom");
assert(!message_group2.group_date_divider_html);
- assert_message_groups_list_equal(
- list._message_groups,
- [message_group1, message_group2]);
+ assert_message_groups_list_equal(list._message_groups, [message_group1, message_group2]);
assert_message_groups_list_equal(result.append_groups, [message_group2]);
assert.deepEqual(result.prepend_groups, []);
assert.deepEqual(result.rerender_groups, []);
@@ -258,45 +248,30 @@ run_test("merge_message_groups", () => {
})();
(function test_append_message_different_subject_and_days() {
-
const message1 = build_message_context({timestamp: 1000});
- const message_group1 = build_message_group([
- message1,
- ]);
+ const message_group1 = build_message_group([message1]);
- const message2 = build_message_context({topic: "Test subject 2",
- timestamp: 900000});
- const message_group2 = build_message_group([
- message2,
- ]);
+ const message2 = build_message_context({topic: "Test subject 2", timestamp: 900000});
+ const message_group2 = build_message_group([message2]);
const list = build_list([message_group1]);
const result = list.merge_message_groups([message_group2], "bottom");
- assert_message_groups_list_equal(
- list._message_groups,
- [message_group1, message_group2]);
+ assert_message_groups_list_equal(list._message_groups, [message_group1, message_group2]);
assert_message_groups_list_equal(result.append_groups, [message_group2]);
assert.deepEqual(result.prepend_groups, []);
assert.deepEqual(result.rerender_groups, []);
assert.deepEqual(result.append_messages, []);
assert.deepEqual(result.rerender_messages_next_same_sender, []);
- assert.equal(
- message_group2.group_date_divider_html,
- "900000000 - 1000000");
+ assert.equal(message_group2.group_date_divider_html, "900000000 - 1000000");
})();
(function test_append_message_different_day() {
-
const message1 = build_message_context({timestamp: 1000});
- const message_group1 = build_message_group([
- message1,
- ]);
+ const message_group1 = build_message_group([message1]);
const message2 = build_message_context({timestamp: 900000});
- const message_group2 = build_message_group([
- message2,
- ]);
+ const message_group2 = build_message_group([message2]);
const list = build_list([message_group1]);
const result = list.merge_message_groups([message_group2], "bottom");
@@ -311,24 +286,17 @@ run_test("merge_message_groups", () => {
})();
(function test_append_message_historical() {
-
const message1 = build_message_context({historical: false});
- const message_group1 = build_message_group([
- message1,
- ]);
+ const message_group1 = build_message_group([message1]);
const message2 = build_message_context({historical: true});
- const message_group2 = build_message_group([
- message2,
- ]);
+ const message_group2 = build_message_group([message2]);
const list = build_list([message_group1]);
const result = list.merge_message_groups([message_group2], "bottom");
assert(message_group2.bookend_top);
- assert_message_groups_list_equal(
- list._message_groups,
- [message_group1, message_group2]);
+ assert_message_groups_list_equal(list._message_groups, [message_group1, message_group2]);
assert_message_groups_list_equal(result.append_groups, [message_group2]);
assert.deepEqual(result.prepend_groups, []);
assert.deepEqual(result.rerender_groups, []);
@@ -337,24 +305,19 @@ run_test("merge_message_groups", () => {
})();
(function test_append_message_same_subject_me_message() {
-
const message1 = build_message_context();
- const message_group1 = build_message_group([
- message1,
- ]);
+ const message_group1 = build_message_group([message1]);
const message2 = build_message_context({is_me_message: true});
- const message_group2 = build_message_group([
- message2,
- ]);
+ const message_group2 = build_message_group([message2]);
const list = build_list([message_group1]);
const result = list.merge_message_groups([message_group2], "bottom");
assert(message2.include_sender);
- assert_message_groups_list_equal(
- list._message_groups,
- [build_message_group([message1, message2])]);
+ assert_message_groups_list_equal(list._message_groups, [
+ build_message_group([message1, message2]),
+ ]);
assert.deepEqual(result.append_groups, []);
assert.deepEqual(result.prepend_groups, []);
assert.deepEqual(result.rerender_groups, []);
@@ -363,49 +326,38 @@ run_test("merge_message_groups", () => {
})();
(function test_prepend_message_same_subject() {
-
const message1 = build_message_context();
- const message_group1 = build_message_group([
- message1,
- ]);
+ const message_group1 = build_message_group([message1]);
const message2 = build_message_context();
- const message_group2 = build_message_group([
- message2,
- ]);
+ const message_group2 = build_message_group([message2]);
const list = build_list([message_group1]);
const result = list.merge_message_groups([message_group2], "top");
- assert_message_groups_list_equal(
- list._message_groups,
- [build_message_group([message2, message1])]);
+ assert_message_groups_list_equal(list._message_groups, [
+ build_message_group([message2, message1]),
+ ]);
assert.deepEqual(result.append_groups, []);
assert.deepEqual(result.prepend_groups, []);
- assert_message_groups_list_equal(result.rerender_groups,
- [build_message_group([message2, message1])]);
+ assert_message_groups_list_equal(result.rerender_groups, [
+ build_message_group([message2, message1]),
+ ]);
assert.deepEqual(result.append_messages, []);
assert.deepEqual(result.rerender_messages_next_same_sender, []);
})();
(function test_prepend_message_different_subject() {
-
const message1 = build_message_context();
- const message_group1 = build_message_group([
- message1,
- ]);
+ const message_group1 = build_message_group([message1]);
const message2 = build_message_context({topic: "Test Subject 2"});
- const message_group2 = build_message_group([
- message2,
- ]);
+ const message_group2 = build_message_group([message2]);
const list = build_list([message_group1]);
const result = list.merge_message_groups([message_group2], "top");
- assert_message_groups_list_equal(
- list._message_groups,
- [message_group2, message_group1]);
+ assert_message_groups_list_equal(list._message_groups, [message_group2, message_group1]);
assert.deepEqual(result.append_groups, []);
assert_message_groups_list_equal(result.prepend_groups, [message_group2]);
assert.deepEqual(result.rerender_groups, []);
@@ -414,28 +366,18 @@ run_test("merge_message_groups", () => {
})();
(function test_prepend_message_different_subject_and_day() {
-
const message1 = build_message_context({timestamp: 900000});
- const message_group1 = build_message_group([
- message1,
- ]);
+ const message_group1 = build_message_group([message1]);
- const message2 = build_message_context({topic: "Test Subject 2",
- timestamp: 1000});
- const message_group2 = build_message_group([
- message2,
- ]);
+ const message2 = build_message_context({topic: "Test Subject 2", timestamp: 1000});
+ const message_group2 = build_message_group([message2]);
const list = build_list([message_group1]);
const result = list.merge_message_groups([message_group2], "top");
// We should have a group date divider between the recipient blocks.
- assert.equal(
- message_group1.group_date_divider_html,
- "900000000 - 1000000");
- assert_message_groups_list_equal(
- list._message_groups,
- [message_group2, message_group1]);
+ assert.equal(message_group1.group_date_divider_html, "900000000 - 1000000");
+ assert_message_groups_list_equal(list._message_groups, [message_group2, message_group1]);
assert.deepEqual(result.append_groups, []);
assert_message_groups_list_equal(result.prepend_groups, [message_group2]);
assert.deepEqual(result.rerender_groups, [message_group1]);
@@ -444,27 +386,18 @@ run_test("merge_message_groups", () => {
})();
(function test_prepend_message_different_day() {
-
const message1 = build_message_context({timestamp: 900000});
- const message_group1 = build_message_group([
- message1,
- ]);
+ const message_group1 = build_message_group([message1]);
const message2 = build_message_context({timestamp: 1000});
- const message_group2 = build_message_group([
- message2,
- ]);
+ const message_group2 = build_message_group([message2]);
const list = build_list([message_group1]);
const result = list.merge_message_groups([message_group2], "top");
// We should have a group date divider within the single recipient block.
- assert.equal(
- message_group2.message_containers[1].date_divider_html,
- "900000000 - 1000000");
- assert_message_groups_list_equal(
- list._message_groups,
- [message_group2]);
+ assert.equal(message_group2.message_containers[1].date_divider_html, "900000000 - 1000000");
+ assert_message_groups_list_equal(list._message_groups, [message_group2]);
assert.deepEqual(result.append_groups, []);
assert.deepEqual(result.prepend_groups, []);
assert_message_groups_list_equal(result.rerender_groups, [message_group2]);
@@ -473,31 +406,23 @@ run_test("merge_message_groups", () => {
})();
(function test_prepend_message_historical() {
-
const message1 = build_message_context({historical: false});
- const message_group1 = build_message_group([
- message1,
- ]);
+ const message_group1 = build_message_group([message1]);
const message2 = build_message_context({historical: true});
- const message_group2 = build_message_group([
- message2,
- ]);
+ const message_group2 = build_message_group([message2]);
const list = build_list([message_group1]);
const result = list.merge_message_groups([message_group2], "top");
assert(message_group1.bookend_top);
- assert_message_groups_list_equal(
- list._message_groups,
- [message_group2, message_group1]);
+ assert_message_groups_list_equal(list._message_groups, [message_group2, message_group1]);
assert.deepEqual(result.append_groups, []);
assert_message_groups_list_equal(result.prepend_groups, [message_group2]);
assert.deepEqual(result.rerender_groups, []);
assert.deepEqual(result.append_messages, []);
assert.deepEqual(result.rerender_messages_next_same_sender, []);
})();
-
});
// TODO: Add a test suite for rerender_messages_next_same_sender() that includes cases
@@ -549,7 +474,9 @@ run_test("render_windows", () => {
messages = _.range(opts.count).map((i) => ({
id: i,
}));
- list.selected_idx = function () { return 0; };
+ list.selected_idx = function () {
+ return 0;
+ };
list.clear();
list.add_messages(messages, {});
@@ -561,7 +488,9 @@ run_test("render_windows", () => {
// a re-render. The code avoids hasty re-renders for
// performance reasons.
for (const idx of _.range(start, end)) {
- list.selected_idx = function () { return idx; };
+ list.selected_idx = function () {
+ return idx;
+ };
const rendered = view.maybe_rerender();
assert.equal(rendered, false);
}
@@ -571,7 +500,9 @@ run_test("render_windows", () => {
const start = range[0];
const end = range[1];
- list.selected_idx = function () { return idx; };
+ list.selected_idx = function () {
+ return idx;
+ };
const rendered = view.maybe_rerender();
assert.equal(rendered, true);
assert.equal(view._render_win_start, start);
diff --git a/frontend_tests/node_tests/message_store.js b/frontend_tests/node_tests/message_store.js
index 97606d11835..3275b023796 100644
--- a/frontend_tests/node_tests/message_store.js
+++ b/frontend_tests/node_tests/message_store.js
@@ -85,9 +85,7 @@ run_test("add_message_metadata", () => {
message_store.set_message_booleans(message);
message_store.add_message_metadata(message);
- assert.deepEqual(
- message_store.user_ids().sort(),
- [me.user_id, bob.user_id, cindy.user_id]);
+ assert.deepEqual(message_store.user_ids().sort(), [me.user_id, bob.user_id, cindy.user_id]);
assert.equal(message.is_private, true);
assert.equal(message.reply_to, "[email protected],[email protected]");
@@ -134,9 +132,12 @@ run_test("add_message_metadata", () => {
assert.deepEqual(message.flags, undefined);
assert.equal(message.alerted, false);
- assert.deepEqual(
- message_store.user_ids().sort(),
- [me.user_id, bob.user_id, cindy.user_id, denise.user_id]);
+ assert.deepEqual(message_store.user_ids().sort(), [
+ me.user_id,
+ bob.user_id,
+ cindy.user_id,
+ denise.user_id,
+ ]);
});
run_test("message_booleans_parity", () => {
@@ -149,33 +150,34 @@ run_test("message_booleans_parity", () => {
message_store.set_message_booleans(set_message);
message_store.update_booleans(update_message, flags);
Object.keys(expected_message).forEach((key) => {
- assert.equal(set_message[key], expected_message[key], `'${key}' != ${expected_message[key]}`);
+ assert.equal(
+ set_message[key],
+ expected_message[key],
+ `'${key}' != ${expected_message[key]}`,
+ );
assert.equal(update_message[key], expected_message[key]);
});
assert.equal(set_message.topic, "set_message_booleans");
assert.equal(update_message.topic, "update_booleans");
};
- assert_bool_match(["wildcard_mentioned"],
- {
- mentioned: true,
- mentioned_me_directly: false,
- alerted: false,
- });
-
- assert_bool_match(["mentioned"],
- {
- mentioned: true,
- mentioned_me_directly: true,
- alerted: false,
- });
-
- assert_bool_match(["has_alert_word"],
- {
- mentioned: false,
- mentioned_me_directly: false,
- alerted: true,
- });
+ assert_bool_match(["wildcard_mentioned"], {
+ mentioned: true,
+ mentioned_me_directly: false,
+ alerted: false,
+ });
+
+ assert_bool_match(["mentioned"], {
+ mentioned: true,
+ mentioned_me_directly: true,
+ alerted: false,
+ });
+
+ assert_bool_match(["has_alert_word"], {
+ mentioned: false,
+ mentioned_me_directly: false,
+ alerted: true,
+ });
});
run_test("errors", () => {
@@ -268,7 +270,9 @@ run_test("message_id_change", () => {
set_global("pointer", {
furthest_read: 401,
- set_furthest_read: function (value) { this.furthest_read = value; },
+ set_furthest_read: function (value) {
+ this.furthest_read = value;
+ },
});
set_global("message_list", {});
@@ -295,7 +299,6 @@ run_test("message_id_change", () => {
assert.equal(msg_id.old, 401);
assert.equal(msg_id.new, 402);
});
-
});
run_test("errors", () => {
diff --git a/frontend_tests/node_tests/muting.js b/frontend_tests/node_tests/muting.js
index fb5ba3c0a6d..d2e32f25b68 100644
--- a/frontend_tests/node_tests/muting.js
+++ b/frontend_tests/node_tests/muting.js
@@ -1,4 +1,3 @@
-
zrequire("timerender");
zrequire("muting");
zrequire("stream_data");
@@ -79,7 +78,8 @@ run_test("get_and_set_muted_topics", () => {
stream: office.name,
stream_id: office.stream_id,
topic: "gossip",
- }]);
+ },
+ ]);
blueslip.expect("warn", "Unknown stream in set_muted_topics: BOGUS STREAM");
@@ -90,7 +90,6 @@ run_test("get_and_set_muted_topics", () => {
];
muting.initialize();
-
assert.deepEqual(muting.get_muted_topics().sort(), [
{
date_muted: 1577836800000,
@@ -105,15 +104,14 @@ run_test("get_and_set_muted_topics", () => {
stream: design.name,
stream_id: design.stream_id,
topic: "typography",
- }]);
+ },
+ ]);
});
run_test("case_insensitivity", () => {
muting.set_muted_topics([]);
assert(!muting.is_topic_muted(social.stream_id, "breakfast"));
- muting.set_muted_topics([
- ["SOCial", "breakfast"],
- ]);
+ muting.set_muted_topics([["SOCial", "breakfast"]]);
assert(muting.is_topic_muted(social.stream_id, "breakfast"));
assert(muting.is_topic_muted(social.stream_id, "breakFAST"));
});
diff --git a/frontend_tests/node_tests/narrow.js b/frontend_tests/node_tests/narrow.js
index 6d96a16eb80..ac79e42cd3b 100644
--- a/frontend_tests/node_tests/narrow.js
+++ b/frontend_tests/node_tests/narrow.js
@@ -13,7 +13,6 @@ set_global("resize", {
resize_stream_filters_container: () => {},
});
-
zrequire("narrow");
function set_filter(operators) {
@@ -168,7 +167,10 @@ run_test("show_search_stopwords", () => {
assert.equal(items[2], "<span>grail");
items = [];
- set_filter([["stream", "streamA"], ["search", "what about grail"]]);
+ set_filter([
+ ["stream", "streamA"],
+ ["search", "what about grail"],
+ ]);
narrow.show_empty_narrow_message();
assert($("#empty_search_narrow_message").visible());
@@ -179,7 +181,11 @@ run_test("show_search_stopwords", () => {
assert.equal(items[3], "<span>grail");
items = [];
- set_filter([["stream", "streamA"], ["topic", "topicA"], ["search", "what about grail"]]);
+ set_filter([
+ ["stream", "streamA"],
+ ["topic", "topicA"],
+ ["search", "what about grail"],
+ ]);
narrow.show_empty_narrow_message();
assert($("#empty_search_narrow_message").visible());
@@ -197,23 +203,41 @@ run_test("show_invalid_narrow_message", () => {
stream_data.add_sub({name: "streamA", stream_id: 88});
stream_data.add_sub({name: "streamB", stream_id: 77});
- set_filter([["stream", "streamA"], ["stream", "streamB"]]);
+ set_filter([
+ ["stream", "streamA"],
+ ["stream", "streamB"],
+ ]);
narrow.show_empty_narrow_message();
assert($("#empty_search_narrow_message").visible());
- assert.equal(display.text(), "translated: You are searching for messages that belong to more than one stream, which is not possible.");
+ assert.equal(
+ display.text(),
+ "translated: You are searching for messages that belong to more than one stream, which is not possible.",
+ );
- set_filter([["topic", "topicA"], ["topic", "topicB"]]);
+ set_filter([
+ ["topic", "topicA"],
+ ["topic", "topicB"],
+ ]);
narrow.show_empty_narrow_message();
assert($("#empty_search_narrow_message").visible());
- assert.equal(display.text(), "translated: You are searching for messages that belong to more than one topic, which is not possible.");
+ assert.equal(
+ display.text(),
+ "translated: You are searching for messages that belong to more than one topic, which is not possible.",
+ );
people.add_active_user(ray);
people.add_active_user(alice);
- set_filter([["sender", "[email protected]"], ["sender", "[email protected]"]]);
+ set_filter([
+ ["sender", "[email protected]"],
+ ["sender", "[email protected]"],
+ ]);
narrow.show_empty_narrow_message();
assert($("#empty_search_narrow_message").visible());
- assert.equal(display.text(), "translated: You are searching for messages that are sent by more than one person, which is not possible.");
+ assert.equal(
+ display.text(),
+ "translated: You are searching for messages that are sent by more than one person, which is not possible.",
+ );
});
run_test("narrow_to_compose_target", () => {
@@ -262,27 +286,21 @@ run_test("narrow_to_compose_target", () => {
args.called = false;
narrow.to_compose_target();
assert.equal(args.called, true);
- assert.deepEqual(args.operators, [
- {operator: "stream", operand: "ROME"},
- ]);
+ assert.deepEqual(args.operators, [{operator: "stream", operand: "ROME"}]);
// Test with blank topic
global.compose_state.topic = () => "";
args.called = false;
narrow.to_compose_target();
assert.equal(args.called, true);
- assert.deepEqual(args.operators, [
- {operator: "stream", operand: "ROME"},
- ]);
+ assert.deepEqual(args.operators, [{operator: "stream", operand: "ROME"}]);
// Test with no topic
global.compose_state.topic = () => {};
args.called = false;
narrow.to_compose_target();
assert.equal(args.called, true);
- assert.deepEqual(args.operators, [
- {operator: "stream", operand: "ROME"},
- ]);
+ assert.deepEqual(args.operators, [{operator: "stream", operand: "ROME"}]);
// --- Tests for PMs ---
global.compose_state.get_message_type = () => "private";
@@ -295,9 +313,7 @@ run_test("narrow_to_compose_target", () => {
args.called = false;
narrow.to_compose_target();
assert.equal(args.called, true);
- assert.deepEqual(args.operators, [
- {operator: "pm-with", operand: "[email protected]"},
- ]);
+ assert.deepEqual(args.operators, [{operator: "pm-with", operand: "[email protected]"}]);
// Test with valid persons
global.compose_state.private_message_recipient = () => "[email protected],[email protected]";
@@ -309,31 +325,26 @@ run_test("narrow_to_compose_target", () => {
]);
// Test with some invalid persons
- global.compose_state.private_message_recipient = () => "[email protected],random,[email protected]";
+ global.compose_state.private_message_recipient = () =>
args.called = false;
narrow.to_compose_target();
assert.equal(args.called, true);
- assert.deepEqual(args.operators, [
- {operator: "is", operand: "private"},
- ]);
+ assert.deepEqual(args.operators, [{operator: "is", operand: "private"}]);
// Test with all invalid persons
global.compose_state.private_message_recipient = () => "alice,random,ray";
args.called = false;
narrow.to_compose_target();
assert.equal(args.called, true);
- assert.deepEqual(args.operators, [
- {operator: "is", operand: "private"},
- ]);
+ assert.deepEqual(args.operators, [{operator: "is", operand: "private"}]);
// Test with no persons
global.compose_state.private_message_recipient = () => "";
args.called = false;
narrow.to_compose_target();
assert.equal(args.called, true);
- assert.deepEqual(args.operators, [
- {operator: "is", operand: "private"},
- ]);
+ assert.deepEqual(args.operators, [{operator: "is", operand: "private"}]);
narrow.activate = activate_backup;
});
diff --git a/frontend_tests/node_tests/narrow_activate.js b/frontend_tests/node_tests/narrow_activate.js
index 79655fff36d..738538c1c86 100644
--- a/frontend_tests/node_tests/narrow_activate.js
+++ b/frontend_tests/node_tests/narrow_activate.js
@@ -21,7 +21,9 @@ set_global("hashchange", {});
set_global("home_msg_list", {});
set_global("message_fetch", {});
set_global("message_list", {
- set_narrowed: function (value) { this.narrowed = value; },
+ set_narrowed: function (value) {
+ this.narrowed = value;
+ },
});
set_global("message_scroll", {});
set_global("message_util", {});
@@ -36,8 +38,12 @@ set_global("ui_util", {});
set_global("unread_ops", {});
set_global("search_pill_widget", {
widget: {
- clear: function () {return true;},
- appendValue: function () {return true;},
+ clear: function () {
+ return true;
+ },
+ appendValue: function () {
+ return true;
+ },
},
});
@@ -133,9 +139,7 @@ run_test("basics", () => {
stub_message_list();
const helper = test_helper();
- const terms = [
- {operator: "stream", operand: "Denmark"},
- ];
+ const terms = [{operator: "stream", operand: "Denmark"}];
const selected_id = 1000;
@@ -225,8 +229,5 @@ run_test("basics", () => {
helper.clear();
cont();
- helper.assert_events([
- "report narrow times",
- ]);
-
+ helper.assert_events(["report narrow times"]);
});
diff --git a/frontend_tests/node_tests/narrow_local.js b/frontend_tests/node_tests/narrow_local.js
index 54d9ec8e391..2ae2643a260 100644
--- a/frontend_tests/node_tests/narrow_local.js
+++ b/frontend_tests/node_tests/narrow_local.js
@@ -1,4 +1,3 @@
-
zrequire("Filter", "js/filter");
zrequire("FetchStatus", "js/fetch_status");
zrequire("MessageListData", "js/message_list_data");
@@ -76,9 +75,7 @@ run_test("near after unreads", () => {
// Current near: behavior is to ignore the unreads and take you
// to the target message, with reading disabled.
const fixture = {
- filter_terms: [
- {operator: "near", operand: 42},
- ],
+ filter_terms: [{operator: "near", operand: 42}],
target_id: 42,
unread_info: {
flavor: "found",
@@ -105,9 +102,7 @@ run_test("near not in message list", () => {
// Current behavior is to ignore the unreads and take you
// to the closest messages, with reading disabled.
const fixture = {
- filter_terms: [
- {operator: "near", operand: 42},
- ],
+ filter_terms: [{operator: "near", operand: 42}],
target_id: 42,
unread_info: {
flavor: "found",
@@ -132,9 +127,7 @@ run_test("near not in message list", () => {
run_test("near before unreads", () => {
const fixture = {
- filter_terms: [
- {operator: "near", operand: 42},
- ],
+ filter_terms: [{operator: "near", operand: 42}],
target_id: 42,
unread_info: {
flavor: "found",
@@ -159,9 +152,7 @@ run_test("near before unreads", () => {
run_test("near with no unreads", () => {
const fixture = {
- filter_terms: [
- {operator: "near", operand: 42},
- ],
+ filter_terms: [{operator: "near", operand: 42}],
target_id: 42,
unread_info: {
flavor: "not_found",
@@ -181,9 +172,7 @@ run_test("near with no unreads", () => {
run_test("is private with no target", () => {
const fixture = {
- filter_terms: [
- {operator: "is", operand: "private"},
- ],
+ filter_terms: [{operator: "is", operand: "private"}],
unread_info: {
flavor: "found",
msg_id: 550,
@@ -207,17 +196,13 @@ run_test("is private with no target", () => {
run_test("pm-with with target outside of range", () => {
const fixture = {
- filter_terms: [
- {operator: "pm-with", operand: "[email protected]"},
- ],
+ filter_terms: [{operator: "pm-with", operand: "[email protected]"}],
target_id: 5,
unread_info: {
flavor: "not_found",
},
has_found_newest: false,
- all_messages: [
- {id: 999},
- ],
+ all_messages: [{id: 999}],
expected_id_info: {
target_id: 5,
final_select_id: 5,
@@ -231,9 +216,7 @@ run_test("pm-with with target outside of range", () => {
run_test("is:private with no unreads before fetch", () => {
const fixture = {
- filter_terms: [
- {operator: "is", operand: "private"},
- ],
+ filter_terms: [{operator: "is", operand: "private"}],
unread_info: {
flavor: "not_found",
},
@@ -252,9 +235,7 @@ run_test("is:private with no unreads before fetch", () => {
run_test("is:private with target and no unreads", () => {
const fixture = {
- filter_terms: [
- {operator: "is", operand: "private"},
- ],
+ filter_terms: [{operator: "is", operand: "private"}],
target_id: 450,
unread_info: {
flavor: "not_found",
@@ -280,9 +261,7 @@ run_test("is:private with target and no unreads", () => {
run_test("is:mentioned with no unreads and no matches", () => {
const fixture = {
- filter_terms: [
- {operator: "is", operand: "mentioned"},
- ],
+ filter_terms: [{operator: "is", operand: "mentioned"}],
unread_info: {
flavor: "not_found",
},
@@ -301,9 +280,7 @@ run_test("is:mentioned with no unreads and no matches", () => {
run_test("is:alerted with no unreads and one match", () => {
const fixture = {
- filter_terms: [
- {operator: "is", operand: "alerted"},
- ],
+ filter_terms: [{operator: "is", operand: "alerted"}],
unread_info: {
flavor: "not_found",
},
@@ -325,9 +302,7 @@ run_test("is:alerted with no unreads and one match", () => {
run_test("search", () => {
const fixture = {
- filter_terms: [
- {operator: "search", operand: "whatever"},
- ],
+ filter_terms: [{operator: "search", operand: "whatever"}],
unread_info: {
flavor: "cannot_compute",
},
@@ -371,19 +346,14 @@ run_test("stream, no unread, not in all_messages", () => {
// our new message list. Note that our target_id is within
// the range of all_messages.
const fixture = {
- filter_terms: [
- {operator: "stream", operand: "whatever"},
- ],
+ filter_terms: [{operator: "stream", operand: "whatever"}],
target_id: 450,
unread_info: {
flavor: "not_found",
},
has_found_newest: true,
empty: false,
- all_messages: [
- {id: 400},
- {id: 500},
- ],
+ all_messages: [{id: 400}, {id: 500}],
expected_id_info: {
target_id: 450,
final_select_id: 450,
@@ -406,10 +376,7 @@ run_test("search, stream, not in all_messages", () => {
},
has_found_newest: true,
empty: false,
- all_messages: [
- {id: 400},
- {id: 500},
- ],
+ all_messages: [{id: 400}, {id: 500}],
expected_id_info: {
target_id: undefined,
final_select_id: 10000000000000000,
@@ -437,10 +404,7 @@ run_test("stream/topic not in all_messages", () => {
msg_id: 2,
},
has_found_newest: true,
- all_messages: [
- {id: 900},
- {id: 1100},
- ],
+ all_messages: [{id: 900}, {id: 1100}],
expected_id_info: {
target_id: 1000,
final_select_id: 2,
@@ -457,9 +421,7 @@ run_test("final corner case", () => {
// the function (as written now). The data here
// may be completely contrived.
const fixture = {
- filter_terms: [
- {operator: "is", operand: "starred"},
- ],
+ filter_terms: [{operator: "is", operand: "starred"}],
target_id: 450,
unread_info: {
flavor: "not_found",
diff --git a/frontend_tests/node_tests/narrow_state.js b/frontend_tests/node_tests/narrow_state.js
index 3c3c8302101..a8b0adcf6d2 100644
--- a/frontend_tests/node_tests/narrow_state.js
+++ b/frontend_tests/node_tests/narrow_state.js
@@ -1,4 +1,3 @@
-
zrequire("people");
zrequire("Filter", "js/filter");
zrequire("stream_data");
@@ -78,7 +77,10 @@ run_test("narrowed", () => {
assert(!narrow_state.narrowed_by_stream_reply());
assert(!narrow_state.narrowed_to_starred());
- set_filter([["stream", "Foo"], ["topic", "bar"]]);
+ set_filter([
+ ["stream", "Foo"],
+ ["topic", "bar"],
+ ]);
assert(!narrow_state.narrowed_to_pms());
assert(narrow_state.narrowed_by_reply());
assert(!narrow_state.narrowed_by_pm_reply());
@@ -110,7 +112,11 @@ run_test("narrowed", () => {
});
run_test("operators", () => {
- set_filter([["stream", "Foo"], ["topic", "Bar"], ["search", "Yo"]]);
+ set_filter([
+ ["stream", "Foo"],
+ ["topic", "Bar"],
+ ["search", "Yo"],
+ ]);
let result = narrow_state.operators();
assert.equal(result.length, 3);
assert.equal(result[0].operator, "stream");
@@ -134,7 +140,10 @@ run_test("muting_enabled", () => {
narrow_state.reset_current_filter(); // not narrowed, basically
assert(narrow_state.muting_enabled());
- set_filter([["stream", "devel"], ["topic", "mac"]]);
+ set_filter([
+ ["stream", "devel"],
+ ["topic", "mac"],
+ ]);
assert(!narrow_state.muting_enabled());
set_filter([["search", "whatever"]]);
@@ -148,7 +157,10 @@ run_test("muting_enabled", () => {
});
run_test("set_compose_defaults", () => {
- set_filter([["stream", "Foo"], ["topic", "Bar"]]);
+ set_filter([
+ ["stream", "Foo"],
+ ["topic", "Bar"],
+ ]);
const stream_and_subject = narrow_state.set_compose_defaults();
assert.equal(stream_and_subject.stream, "Foo");
@@ -170,7 +182,10 @@ run_test("set_compose_defaults", () => {
pm_test = narrow_state.set_compose_defaults();
assert.equal(pm_test.private_message_recipient, "[email protected]");
- set_filter([["topic", "duplicate"], ["topic", "duplicate"]]);
+ set_filter([
+ ["topic", "duplicate"],
+ ["topic", "duplicate"],
+ ]);
assert.deepEqual(narrow_state.set_compose_defaults(), {});
stream_data.add_sub({name: "ROME", stream_id: 99});
@@ -201,10 +216,16 @@ run_test("update_email", () => {
});
run_test("topic", () => {
- set_filter([["stream", "Foo"], ["topic", "Bar"]]);
+ set_filter([
+ ["stream", "Foo"],
+ ["topic", "Bar"],
+ ]);
assert.equal(narrow_state.topic(), "Bar");
- set_filter([["stream", "release"], ["topic", "@#$$^test"]]);
+ set_filter([
+ ["stream", "release"],
+ ["topic", "@#$$^test"],
+ ]);
assert.equal(narrow_state.topic(), "@#$$^test");
set_filter([]);
@@ -225,7 +246,10 @@ run_test("stream", () => {
assert.equal(narrow_state.stream(), undefined);
assert.equal(narrow_state.stream_id(), undefined);
- set_filter([["stream", "Foo"], ["topic", "Bar"]]);
+ set_filter([
+ ["stream", "Foo"],
+ ["topic", "Bar"],
+ ]);
assert.equal(narrow_state.stream(), "Foo");
assert.equal(narrow_state.stream_sub(), undefined);
assert.equal(narrow_state.stream_id(), undefined);
@@ -235,7 +259,10 @@ run_test("stream", () => {
assert.equal(narrow_state.stream_id(), 55);
assert.deepEqual(narrow_state.stream_sub(), sub);
- set_filter([["sender", "someone"], ["topic", "random"]]);
+ set_filter([
+ ["sender", "someone"],
+ ["topic", "random"],
+ ]);
assert.equal(narrow_state.stream(), undefined);
});
@@ -246,7 +273,10 @@ run_test("pm_string", () => {
narrow_state.set_current_filter(undefined);
assert.equal(narrow_state.pm_string(), undefined);
- set_filter([["stream", "Foo"], ["topic", "Bar"]]);
+ set_filter([
+ ["stream", "Foo"],
+ ["topic", "Bar"],
+ ]);
assert.equal(narrow_state.pm_string(), undefined);
set_filter([["pm-with", ""]]);
diff --git a/frontend_tests/node_tests/narrow_unread.js b/frontend_tests/node_tests/narrow_unread.js
index e9e7939b478..e82f20bd06c 100644
--- a/frontend_tests/node_tests/narrow_unread.js
+++ b/frontend_tests/node_tests/narrow_unread.js
@@ -1,4 +1,3 @@
-
zrequire("Filter", "js/filter");
zrequire("people");
zrequire("stream_data");
@@ -60,9 +59,7 @@ run_test("get_unread_ids", () => {
id: 102,
type: "private",
unread: true,
- display_recipient: [
- {id: alice.user_id},
- ],
+ display_recipient: [{id: alice.user_id}],
};
stream_data.add_sub(sub);
@@ -70,32 +67,24 @@ run_test("get_unread_ids", () => {
unread_ids = candidate_ids();
assert.equal(unread_ids, undefined);
- terms = [
- {operator: "search", operand: "whatever"},
- ];
+ terms = [{operator: "search", operand: "whatever"}];
set_filter(terms);
unread_ids = candidate_ids();
assert.equal(unread_ids, undefined);
assert_unread_info({flavor: "cannot_compute"});
- terms = [
- {operator: "bogus_operator", operand: "[email protected]"},
- ];
+ terms = [{operator: "bogus_operator", operand: "[email protected]"}];
set_filter(terms);
unread_ids = candidate_ids();
assert.deepEqual(unread_ids, []);
assert_unread_info({flavor: "not_found"});
- terms = [
- {operator: "stream", operand: "bogus"},
- ];
+ terms = [{operator: "stream", operand: "bogus"}];
set_filter(terms);
unread_ids = candidate_ids();
assert.deepEqual(unread_ids, []);
- terms = [
- {operator: "stream", operand: sub.name},
- ];
+ terms = [{operator: "stream", operand: sub.name}];
set_filter(terms);
unread_ids = candidate_ids();
assert.deepEqual(unread_ids, []);
@@ -130,16 +119,12 @@ run_test("get_unread_ids", () => {
unread_ids = candidate_ids();
assert.deepEqual(unread_ids, [stream_msg.id]);
- terms = [
- {operator: "is", operand: "mentioned"},
- ];
+ terms = [{operator: "is", operand: "mentioned"}];
set_filter(terms);
unread_ids = candidate_ids();
assert.deepEqual(unread_ids, [stream_msg.id]);
- terms = [
- {operator: "sender", operand: "[email protected]"},
- ];
+ terms = [{operator: "sender", operand: "[email protected]"}];
set_filter(terms);
// note that our candidate ids are just "all" ids now
unread_ids = candidate_ids();
@@ -148,9 +133,7 @@ run_test("get_unread_ids", () => {
// this actually does filtering
assert_unread_info({flavor: "not_found"});
- terms = [
- {operator: "pm-with", operand: "[email protected]"},
- ];
+ terms = [{operator: "pm-with", operand: "[email protected]"}];
set_filter(terms);
unread_ids = candidate_ids();
assert.deepEqual(unread_ids, []);
@@ -170,40 +153,30 @@ run_test("get_unread_ids", () => {
msg_id: private_msg.id,
});
- terms = [
- {operator: "is", operand: "private"},
- ];
+ terms = [{operator: "is", operand: "private"}];
set_filter(terms);
unread_ids = candidate_ids();
assert.deepEqual(unread_ids, [private_msg.id]);
// For a negated search, our candidate ids will be all
// unread messages, even ones that don't pass the filter.
- terms = [
- {operator: "is", operand: "private", negated: true},
- ];
+ terms = [{operator: "is", operand: "private", negated: true}];
set_filter(terms);
unread_ids = candidate_ids();
assert.deepEqual(unread_ids, [stream_msg.id, private_msg.id]);
- terms = [
- {operator: "pm-with", operand: "[email protected]"},
- ];
+ terms = [{operator: "pm-with", operand: "[email protected]"}];
set_filter(terms);
unread_ids = candidate_ids();
assert.deepEqual(unread_ids, []);
- terms = [
- {operator: "is", operand: "starred"},
- ];
+ terms = [{operator: "is", operand: "starred"}];
set_filter(terms);
unread_ids = candidate_ids();
assert.deepEqual(unread_ids, []);
- terms = [
- {operator: "search", operand: "needle"},
- ];
+ terms = [{operator: "search", operand: "needle"}];
set_filter(terms);
assert_unread_info({
@@ -223,9 +196,7 @@ run_test("defensive code", () => {
// couldn't compute the unread message ids, but that
// invariant is hard to future-proof.
narrow_state._possible_unread_message_ids = () => undefined;
- const terms = [
- {operator: "some-unhandled-case", operand: "whatever"},
- ];
+ const terms = [{operator: "some-unhandled-case", operand: "whatever"}];
set_filter(terms);
assert_unread_info({
flavor: "cannot_compute",
diff --git a/frontend_tests/node_tests/notifications.js b/frontend_tests/node_tests/notifications.js
index 6ea54ec4957..b8907d1822a 100644
--- a/frontend_tests/node_tests/notifications.js
+++ b/frontend_tests/node_tests/notifications.js
@@ -1,7 +1,10 @@
// Dependencies
-set_global("$", global.make_zjquery({
- silent: true,
-}));
+set_global(
+ "$",
+ global.make_zjquery({
+ silent: true,
+ }),
+);
set_global("document", {
hasFocus: function () {
return true;
@@ -250,7 +253,6 @@ run_test("message_is_notifiable", () => {
});
run_test("basic_notifications", () => {
-
let n; // Object for storing all notification data for assertions.
let last_closed_message_id = null;
let last_shown_message_id = null;
diff --git a/frontend_tests/node_tests/people.js b/frontend_tests/node_tests/people.js
index 53a8d5280c6..0ab8ed1456e 100644
--- a/frontend_tests/node_tests/people.js
+++ b/frontend_tests/node_tests/people.js
@@ -232,10 +232,7 @@ run_test("basics", () => {
people.add_active_user(isaac);
- assert.equal(
- people.get_actual_name_from_user_id(32),
- full_name,
- );
+ assert.equal(people.get_actual_name_from_user_id(32), full_name);
assert(people.is_valid_full_name_and_user_id(full_name, 32));
assert(people.is_known_user_id(32));
@@ -264,29 +261,23 @@ run_test("basics", () => {
people.add_active_user(bot_botson);
assert.equal(people.is_active_user_for_popover(bot_botson.user_id), true);
- assert.equal(
- people.get_bot_owner_user(bot_botson).full_name,
- "Isaac Newton",
- );
+ assert.equal(people.get_bot_owner_user(bot_botson).full_name, "Isaac Newton");
// Add our cross-realm bot. It won't add to our human
// count, and it has no owner.
people.add_cross_realm_user(welcome_bot);
assert.equal(people.get_bot_owner_user(welcome_bot), undefined);
assert.equal(people.get_active_human_count(), 1);
- assert.equal(
- people.get_by_email(welcome_bot.email).full_name,
- "Welcome Bot",
- );
+ assert.equal(people.get_by_email(welcome_bot.email).full_name, "Welcome Bot");
// get_realm_users() will include our active bot,
// but will exclude isaac (who is deactivated)
assert.deepEqual(
- people.get_realm_users().map((u) => u.user_id).sort(),
- [
- me.user_id,
- bot_botson.user_id,
- ],
+ people
+ .get_realm_users()
+ .map((u) => u.user_id)
+ .sort(),
+ [me.user_id, bot_botson.user_id],
);
// The bot doesn't add to our human count.
@@ -318,7 +309,8 @@ run_test("basics", () => {
assert.equal(active_humans.length, 2);
assert.deepEqual(
active_humans.sort((p) => p.user_id),
- [me.user_id, isaac.user_id]);
+ [me.user_id, isaac.user_id],
+ );
});
run_test("check_active_non_active_users", () => {
@@ -461,7 +453,13 @@ initialize();
run_test("set_custom_profile_field_data", () => {
const person = people.get_by_email(me.email);
me.profile_data = {};
- const field = {id: 3, name: "Custom long field", type: "text", value: "Field value", rendered_value: "<p>Field value</p>"};
+ const field = {
+ id: 3,
+ name: "Custom long field",
+ type: "text",
+ value: "Field value",
+ rendered_value: "<p>Field value</p>",
+ };
people.set_custom_profile_field_data(person.user_id, field);
assert.equal(person.profile_data[field.id].value, "Field value");
assert.equal(person.profile_data[field.id].rendered_value, "<p>Field value</p>");
@@ -482,7 +480,6 @@ run_test("get_people_for_stream_create", () => {
{email: "[email protected]", user_id: bob.user_id, full_name: "Bob van Roberts"},
];
assert.deepEqual(others, expected);
-
});
initialize();
@@ -591,17 +588,11 @@ run_test("concat_huddle", () => {
const user_ids = [303, 301, 302];
- assert.equal(
- people.concat_huddle(user_ids, 304),
- "301,302,303,304",
- );
+ assert.equal(people.concat_huddle(user_ids, 304), "301,302,303,304");
// IMPORTANT: we always want to sort
// ids numerically to create huddle strings.
- assert.equal(
- people.concat_huddle(user_ids, 99),
- "99,301,302,303",
- );
+ assert.equal(people.concat_huddle(user_ids, 99), "99,301,302,303");
});
initialize();
@@ -615,8 +606,10 @@ run_test("message_methods", () => {
// undefined values are just treated as falsy.
assert.equal(maria.is_guest, undefined);
- assert.equal(people.small_avatar_url_for_person(maria),
- "https://secure.gravatar.com/avatar/[email protected]?d=identicon&s=50");
+ assert.equal(
+ people.small_avatar_url_for_person(maria),
+ "https://secure.gravatar.com/avatar/[email protected]?d=identicon&s=50",
+ );
assert.deepEqual(people.sender_info_with_small_avatar_urls_for_sender_ids([30]), [
{
@@ -639,41 +632,31 @@ run_test("message_methods", () => {
let message = {
type: "private",
- display_recipient: [
- {id: maria.user_id},
- {id: me.user_id},
- {id: charles.user_id},
- ],
+ display_recipient: [{id: maria.user_id}, {id: me.user_id}, {id: charles.user_id}],
sender_id: charles.user_id,
};
assert.equal(people.pm_with_url(message), "#narrow/pm-with/301,302-group");
assert.equal(people.pm_perma_link(message), "#narrow/pm-with/30,301,302-group");
- assert.equal(people.pm_reply_to(message),
- assert.equal(people.small_avatar_url(message),
- "charles.com/foo.png&s=50");
+ assert.equal(people.pm_reply_to(message), "[email protected],[email protected]");
+ assert.equal(people.small_avatar_url(message), "charles.com/foo.png&s=50");
message = {
type: "private",
- display_recipient: [
- {id: maria.user_id},
- {id: me.user_id},
- ],
+ display_recipient: [{id: maria.user_id}, {id: me.user_id}],
avatar_url: "legacy.png",
};
assert.equal(people.pm_with_url(message), "#narrow/pm-with/302-athens");
assert.equal(people.pm_perma_link(message), "#narrow/pm-with/30,302-pm");
- assert.equal(people.pm_reply_to(message),
- assert.equal(people.small_avatar_url(message),
- "legacy.png&s=50");
+ assert.equal(people.pm_reply_to(message), "[email protected]");
+ assert.equal(people.small_avatar_url(message), "legacy.png&s=50");
message = {
avatar_url: undefined,
sender_id: maria.user_id,
};
- assert.equal(people.small_avatar_url(message),
- "https://secure.gravatar.com/avatar/[email protected]?d=identicon&s=50",
+ assert.equal(
+ people.small_avatar_url(message),
+ "https://secure.gravatar.com/avatar/[email protected]?d=identicon&s=50",
);
blueslip.expect("error", "Unknown user_id in get_by_user_id: 9999999");
@@ -682,22 +665,19 @@ run_test("message_methods", () => {
sender_email: "[email protected]",
sender_id: 9999999,
};
- assert.equal(people.small_avatar_url(message),
- "https://secure.gravatar.com/avatar/[email protected]?d=identicon&s=50",
+ assert.equal(
+ people.small_avatar_url(message),
+ "https://secure.gravatar.com/avatar/[email protected]?d=identicon&s=50",
);
message = {
sender_id: ashton.user_id,
};
- assert.equal(people.small_avatar_url(message),
- `/avatar/${ashton.user_id}&s=50`,
- );
+ assert.equal(people.small_avatar_url(message), `/avatar/${ashton.user_id}&s=50`);
message = {
type: "private",
- display_recipient: [
- {id: me.user_id},
- ],
+ display_recipient: [{id: me.user_id}],
};
assert.equal(people.pm_with_url(message), "#narrow/pm-with/30-me");
assert.equal(people.pm_perma_link(message), "#narrow/pm-with/30-pm");
@@ -879,7 +859,7 @@ run_test("updates", () => {
// Do sanity checks on our data.
assert.equal(people.get_by_email(old_email).user_id, user_id);
- assert (!people.is_cross_realm_email(old_email));
+ assert(!people.is_cross_realm_email(old_email));
assert.equal(people.get_by_email(new_email), undefined);
@@ -888,7 +868,7 @@ run_test("updates", () => {
// Now look up using the new email.
assert.equal(people.get_by_email(new_email).user_id, user_id);
- assert (!people.is_cross_realm_email(new_email));
+ assert(!people.is_cross_realm_email(new_email));
const all_people = get_all_persons();
assert.equal(all_people.length, 2);
@@ -898,9 +878,10 @@ run_test("updates", () => {
// Test shim where we can still retrieve user info using the
// old email.
- blueslip.expect("warn",
- "Obsolete email passed to get_by_email: " +
+ blueslip.expect(
+ "warn",
+ "Obsolete email passed to get_by_email: " + "[email protected] new email = [email protected]",
+ );
person = people.get_by_email(old_email);
assert.equal(person.user_id, user_id);
});
@@ -912,20 +893,14 @@ run_test("update_email_in_reply_to", () => {
people.add_active_user(maria);
- assert.equal(
- people.update_email_in_reply_to(reply_to, 9999, "whatever"),
- reply_to,
- );
+ assert.equal(people.update_email_in_reply_to(reply_to, 9999, "whatever"), reply_to);
assert.equal(
people.update_email_in_reply_to(reply_to, maria.user_id, "[email protected]"),
);
- assert.equal(
- people.update_email_in_reply_to(reply_to, 9999, "whatever"),
- reply_to,
- );
+ assert.equal(people.update_email_in_reply_to(reply_to, 9999, "whatever"), reply_to);
});
initialize();
@@ -935,10 +910,7 @@ run_test("track_duplicate_full_names", () => {
people.add_active_user(stephen1);
assert(!people.is_duplicate_full_name("Stephen King"));
- assert.equal(
- people.get_user_id_from_name("Stephen King"),
- stephen1.user_id,
- );
+ assert.equal(people.get_user_id_from_name("Stephen King"), stephen1.user_id);
// Now duplicate the Stephen King name.
people.add_active_user({...stephen2});
@@ -946,10 +918,7 @@ run_test("track_duplicate_full_names", () => {
// For duplicate names we won't try to guess which
// user_id the person means; the UI should use
// other codepaths for disambiguation.
- assert.equal(
- people.get_user_id_from_name("Stephen King"),
- undefined,
- );
+ assert.equal(people.get_user_id_from_name("Stephen King"), undefined);
assert(people.is_duplicate_full_name("Stephen King"));
assert(!people.is_duplicate_full_name("Maria Athens"));
@@ -1044,13 +1013,12 @@ run_test("filter_for_user_settings_search", () => {
const persons = [fred_smith, alice_lee, jenny_franklin];
- assert.deepEqual(
- people.filter_for_user_settings_search(persons, "fr"),
- [fred_smith, jenny_franklin]);
+ assert.deepEqual(people.filter_for_user_settings_search(persons, "fr"), [
+ fred_smith,
+ jenny_franklin,
+ ]);
- assert.deepEqual(
- people.filter_for_user_settings_search(persons, "le"),
- [alice_lee]);
+ assert.deepEqual(people.filter_for_user_settings_search(persons, "le"), [alice_lee]);
});
run_test("matches_user_settings_search", () => {
@@ -1064,9 +1032,7 @@ run_test("matches_user_settings_search", () => {
page_params.is_admin = true;
assert.equal(match({delivery_email: "[email protected]"}, "fr"), true);
- assert.equal(
- match({delivery_email: "bogus", email: "[email protected]"}, "fr"),
- false);
+ assert.equal(match({delivery_email: "bogus", email: "[email protected]"}, "fr"), false);
set_email_visibility(everyone);
page_params.is_admin = false;
@@ -1122,11 +1088,7 @@ run_test("get_visible_email", () => {
});
run_test("get_active_message_people", () => {
- message_store.user_ids = () => [
- steven.user_id,
- maria.user_id,
- alice1.user_id,
- ];
+ message_store.user_ids = () => [steven.user_id, maria.user_id, alice1.user_id];
people.add_active_user(steven);
people.add_active_user(maria);
diff --git a/frontend_tests/node_tests/people_errors.js b/frontend_tests/node_tests/people_errors.js
index 446eff00dd3..f66f2ce0c3b 100644
--- a/frontend_tests/node_tests/people_errors.js
+++ b/frontend_tests/node_tests/people_errors.js
@@ -1,7 +1,11 @@
zrequire("people");
-const return_false = function () { return false; };
-const return_true = function () { return true; };
+const return_false = function () {
+ return false;
+};
+const return_true = function () {
+ return true;
+};
set_global("reload_state", {
is_in_progress: return_false,
});
@@ -91,19 +95,19 @@ run_test("blueslip", () => {
message = {
type: "private",
- display_recipient: [
- {id: maria.user_id},
- {id: 42},
- {id: charles.user_id},
- ],
+ display_recipient: [{id: maria.user_id}, {id: 42}, {id: charles.user_id}],
sender_id: charles.user_id,
};
blueslip.expect("error", "Unknown user id in message: 42");
const reply_to = people.pm_reply_to(message);
assert(reply_to.includes("?"));
- people.pm_with_user_ids = function () { return [42]; };
- people.get_by_user_id = function () { return; };
+ people.pm_with_user_ids = function () {
+ return [42];
+ };
+ people.get_by_user_id = function () {
+ return;
+ };
blueslip.expect("error", "Unknown people in message");
const uri = people.pm_with_url({});
assert.equal(uri.indexOf("unk"), uri.length - 3);
diff --git a/frontend_tests/node_tests/pm_conversations.js b/frontend_tests/node_tests/pm_conversations.js
index 2821e3ef5a5..02546dc9447 100644
--- a/frontend_tests/node_tests/pm_conversations.js
+++ b/frontend_tests/node_tests/pm_conversations.js
@@ -18,15 +18,9 @@ zrequire("people");
run_test("insert_recent_private_message", () => {
const params = {
recent_private_conversations: [
- {user_ids: [11, 2],
- max_message_id: 150,
- },
- {user_ids: [1],
- max_message_id: 111,
- },
- {user_ids: [],
- max_message_id: 7,
- },
+ {user_ids: [11, 2], max_message_id: 150},
+ {user_ids: [1], max_message_id: 111},
+ {user_ids: [], max_message_id: 7},
],
};
people.initialize_current_user(15);
diff --git a/frontend_tests/node_tests/pm_list.js b/frontend_tests/node_tests/pm_list.js
index 76be9f8150e..fa55d711e1b 100644
--- a/frontend_tests/node_tests/pm_list.js
+++ b/frontend_tests/node_tests/pm_list.js
@@ -189,9 +189,7 @@ run_test("update_dom_with_unread_counts", () => {
run_test("get_active_user_ids_string", () => {
narrow_state.filter = () => {};
- assert.equal(
- pm_list.get_active_user_ids_string(),
- undefined);
+ assert.equal(pm_list.get_active_user_ids_string(), undefined);
function set_filter_result(emails) {
narrow_state.filter = () => ({
@@ -203,22 +201,16 @@ run_test("get_active_user_ids_string", () => {
}
set_filter_result([]);
- assert.equal(
- pm_list.get_active_user_ids_string(),
- undefined);
+ assert.equal(pm_list.get_active_user_ids_string(), undefined);
set_filter_result(["[email protected],[email protected]"]);
- assert.equal(
- pm_list.get_active_user_ids_string(),
- "101,102");
+ assert.equal(pm_list.get_active_user_ids_string(), "101,102");
});
run_test("is_all_privates", () => {
narrow_state.filter = () => {};
- assert.equal(
- pm_list.is_all_privates(),
- false);
+ assert.equal(pm_list.is_all_privates(), false);
narrow_state.filter = () => ({
operands: (operand) => {
@@ -227,9 +219,7 @@ run_test("is_all_privates", () => {
},
});
- assert.equal(
- pm_list.is_all_privates(),
- true);
+ assert.equal(pm_list.is_all_privates(), true);
});
function with_fake_list(f) {
diff --git a/frontend_tests/node_tests/popovers.js b/frontend_tests/node_tests/popovers.js
index cefada4dd45..f698fcad6c8 100644
--- a/frontend_tests/node_tests/popovers.js
+++ b/frontend_tests/node_tests/popovers.js
@@ -137,45 +137,45 @@ run_test("sender_hover", () => {
global.stub_templates((fn, opts) => {
switch (fn) {
- case "no_arrow_popover":
- assert.deepEqual(opts, {
- class: "message-info-popover",
- });
- return "popover-html";
-
- case "user_info_popover_title":
- assert.deepEqual(opts, {
- user_avatar: "avatar/[email protected]",
- user_is_guest: false,
- });
- return "title-html";
-
- case "user_info_popover_content":
- assert.deepEqual(opts, {
- can_set_away: false,
- can_revoke_away: false,
- user_full_name: "Alice Smith",
- user_email: "[email protected]",
- user_id: 42,
- user_time: undefined,
- user_type: i18n.t("Member"),
- user_circle_class: "user_circle_empty",
- user_last_seen_time_status: "translated: More than 2 weeks ago",
- pm_with_uri: "#narrow/pm-with/42-alice",
- sent_by_uri: "#narrow/sender/42-alice",
- private_message_class: "respond_personal_button",
- show_email: false,
- show_user_profile: false,
- is_me: false,
- is_active: true,
- is_bot: undefined,
- is_sender_popover: true,
- status_text: "on the beach",
- });
- return "content-html";
-
- default:
- throw Error("unrecognized template: " + fn);
+ case "no_arrow_popover":
+ assert.deepEqual(opts, {
+ class: "message-info-popover",
+ });
+ return "popover-html";
+
+ case "user_info_popover_title":
+ assert.deepEqual(opts, {
+ user_avatar: "avatar/[email protected]",
+ user_is_guest: false,
+ });
+ return "title-html";
+
+ case "user_info_popover_content":
+ assert.deepEqual(opts, {
+ can_set_away: false,
+ can_revoke_away: false,
+ user_full_name: "Alice Smith",
+ user_email: "[email protected]",
+ user_id: 42,
+ user_time: undefined,
+ user_type: i18n.t("Member"),
+ user_circle_class: "user_circle_empty",
+ user_last_seen_time_status: "translated: More than 2 weeks ago",
+ pm_with_uri: "#narrow/pm-with/42-alice",
+ sent_by_uri: "#narrow/sender/42-alice",
+ private_message_class: "respond_personal_button",
+ show_email: false,
+ show_user_profile: false,
+ is_me: false,
+ is_active: true,
+ is_bot: undefined,
+ is_sender_popover: true,
+ status_text: "on the beach",
+ });
+ return "content-html";
+
+ default:
+ throw Error("unrecognized template: " + fn);
}
});
@@ -232,13 +232,14 @@ run_test("actions_popover", () => {
global.stub_templates((fn, opts) => {
// TODO: Test all the properties of the popover
switch (fn) {
- case "actions_popover_content":
- assert.equal(
- opts.conversation_time_uri,
- "http://chat.zulip.org/#narrow/stream/Bracket.20%28.20stream/topic/Actions.20%281%29/near/999");
- return "actions-content";
- default:
- throw Error("unrecognized template: " + fn);
+ case "actions_popover_content":
+ assert.equal(
+ opts.conversation_time_uri,
+ "http://chat.zulip.org/#narrow/stream/Bracket.20%28.20stream/topic/Actions.20%281%29/near/999",
+ );
+ return "actions-content";
+ default:
+ throw Error("unrecognized template: " + fn);
}
});
diff --git a/frontend_tests/node_tests/presence.js b/frontend_tests/node_tests/presence.js
index 753ef015101..d6097d2aa47 100644
--- a/frontend_tests/node_tests/presence.js
+++ b/frontend_tests/node_tests/presence.js
@@ -1,7 +1,9 @@
zrequire("people");
zrequire("presence");
-const return_false = function () { return false; };
+const return_false = function () {
+ return false;
+};
set_global("server_events", {});
set_global("reload_state", {
@@ -109,39 +111,30 @@ run_test("status_from_raw", () => {
active_timestamp: now - OFFLINE_THRESHOLD_SECS / 2,
};
- assert.deepEqual(
- status_from_raw(raw),
- {
- status: "active",
- last_active: raw.active_timestamp,
- },
- );
+ assert.deepEqual(status_from_raw(raw), {
+ status: "active",
+ last_active: raw.active_timestamp,
+ });
raw = {
server_timestamp: now,
active_timestamp: now - OFFLINE_THRESHOLD_SECS * 2,
};
- assert.deepEqual(
- status_from_raw(raw),
- {
- status: "offline",
- last_active: raw.active_timestamp,
- },
- );
+ assert.deepEqual(status_from_raw(raw), {
+ status: "offline",
+ last_active: raw.active_timestamp,
+ });
raw = {
server_timestamp: now,
idle_timestamp: now - OFFLINE_THRESHOLD_SECS / 2,
};
- assert.deepEqual(
- status_from_raw(raw),
- {
- status: "idle",
- last_active: raw.idle_timestamp,
- },
- );
+ assert.deepEqual(status_from_raw(raw), {
+ status: "idle",
+ last_active: raw.idle_timestamp,
+ });
});
run_test("set_presence_info", () => {
@@ -180,49 +173,43 @@ run_test("set_presence_info", () => {
params.initial_servertime = now;
presence.initialize(params);
- assert.deepEqual(presence.presence_info.get(alice.user_id),
- {status: "active", last_active: recent},
- );
+ assert.deepEqual(presence.presence_info.get(alice.user_id), {
+ status: "active",
+ last_active: recent,
+ });
assert.equal(presence.get_status(alice.user_id), "active");
- assert.deepEqual(
- presence.last_active_date(alice.user_id),
- {seconds: recent * 1000},
- );
-
- assert.deepEqual(presence.presence_info.get(fred.user_id),
- {status: "idle", last_active: now},
- );
+ assert.deepEqual(presence.last_active_date(alice.user_id), {seconds: recent * 1000});
+
+ assert.deepEqual(presence.presence_info.get(fred.user_id), {status: "idle", last_active: now});
assert.equal(presence.get_status(fred.user_id), "idle");
- assert.deepEqual(presence.presence_info.get(me.user_id),
- {status: "active", last_active: now},
- );
+ assert.deepEqual(presence.presence_info.get(me.user_id), {status: "active", last_active: now});
assert.equal(presence.get_status(me.user_id), "active");
- assert.deepEqual(presence.presence_info.get(sally.user_id),
- {status: "offline", last_active: a_while_ago},
- );
+ assert.deepEqual(presence.presence_info.get(sally.user_id), {
+ status: "offline",
+ last_active: a_while_ago,
+ });
assert.equal(presence.get_status(sally.user_id), "offline");
- assert.deepEqual(presence.presence_info.get(zoe.user_id),
- {status: "offline", last_active: undefined},
- );
+ assert.deepEqual(presence.presence_info.get(zoe.user_id), {
+ status: "offline",
+ last_active: undefined,
+ });
assert.equal(presence.get_status(zoe.user_id), "offline");
assert.equal(presence.last_active_date(zoe.user_id), undefined);
assert(!presence.presence_info.has(bot.user_id));
assert.equal(presence.get_status(bot.user_id), "offline");
- assert.deepEqual(presence.presence_info.get(john.user_id),
- {status: "offline", last_active: a_while_ago},
- );
+ assert.deepEqual(presence.presence_info.get(john.user_id), {
+ status: "offline",
+ last_active: a_while_ago,
+ });
assert.equal(presence.get_status(john.user_id), "offline");
- assert.deepEqual(presence.presence_info.get(jane.user_id),
- {status: "idle", last_active: now},
- );
+ assert.deepEqual(presence.presence_info.get(jane.user_id), {status: "idle", last_active: now});
assert.equal(presence.get_status(jane.user_id), "idle");
-
});
run_test("falsy values", () => {
@@ -248,10 +235,10 @@ run_test("falsy values", () => {
presence.set_info(presences, now);
- assert.deepEqual(
- presence.presence_info.get(zoe.user_id),
- {status: "idle", last_active: a_bit_ago},
- );
+ assert.deepEqual(presence.presence_info.get(zoe.user_id), {
+ status: "idle",
+ last_active: a_bit_ago,
+ });
presences[zoe.user_id.toString()] = {
active_timestamp: falsy_value,
@@ -260,10 +247,10 @@ run_test("falsy values", () => {
presence.set_info(presences, now);
- assert.deepEqual(
- presence.presence_info.get(zoe.user_id),
- {status: "offline", last_active: undefined},
- );
+ assert.deepEqual(presence.presence_info.get(zoe.user_id), {
+ status: "offline",
+ last_active: undefined,
+ });
}
});
@@ -279,7 +266,9 @@ run_test("big realms", () => {
// which case we will not provide default values for
// users that aren't in our presences payload.
const get_active_human_count = people.get_active_human_count;
- people.get_active_human_count = function () { return 1000; };
+ people.get_active_human_count = function () {
+ return 1000;
+ };
presence.set_info(presences, now);
assert(presence.presence_info.has(sally.user_id));
assert(!presence.presence_info.has(zoe.user_id));
@@ -310,10 +299,10 @@ run_test("update_info_from_event", () => {
presence.presence_info.delete(alice.user_id);
presence.update_info_from_event(alice.user_id, info, 500);
- assert.deepEqual(
- presence.presence_info.get(alice.user_id),
- {status: "active", last_active: 500},
- );
+ assert.deepEqual(presence.presence_info.get(alice.user_id), {
+ status: "active",
+ last_active: 500,
+ });
info = {
mobile: {
@@ -323,10 +312,10 @@ run_test("update_info_from_event", () => {
};
presence.update_info_from_event(alice.user_id, info, 510);
- assert.deepEqual(
- presence.presence_info.get(alice.user_id),
- {status: "active", last_active: 510},
- );
+ assert.deepEqual(presence.presence_info.get(alice.user_id), {
+ status: "active",
+ last_active: 510,
+ });
info = {
mobile: {
@@ -336,8 +325,8 @@ run_test("update_info_from_event", () => {
};
presence.update_info_from_event(alice.user_id, info, 1000);
- assert.deepEqual(
- presence.presence_info.get(alice.user_id),
- {status: "idle", last_active: 1000},
- );
+ assert.deepEqual(presence.presence_info.get(alice.user_id), {
+ status: "idle",
+ last_active: 1000,
+ });
});
diff --git a/frontend_tests/node_tests/reactions.js b/frontend_tests/node_tests/reactions.js
index aceb8486973..0261f7f2a4f 100644
--- a/frontend_tests/node_tests/reactions.js
+++ b/frontend_tests/node_tests/reactions.js
@@ -61,8 +61,12 @@ const message = {
{emoji_name: "smile", user_id: 5, reaction_type: "unicode_emoji", emoji_code: "263a"},
{emoji_name: "smile", user_id: 6, reaction_type: "unicode_emoji", emoji_code: "263a"},
{emoji_name: "frown", user_id: 7, reaction_type: "unicode_emoji", emoji_code: "1f641"},
- {emoji_name: "inactive_realm_emoji", user_id: 5, reaction_type: "realm_emoji",
- emoji_code: "992"},
+ {
+ emoji_name: "inactive_realm_emoji",
+ user_id: 5,
+ reaction_type: "realm_emoji",
+ emoji_code: "992",
+ },
// add some bogus user_ids
{emoji_name: "octopus", user_id: 8888, reaction_type: "unicode_emoji", emoji_code: "1f419"},
@@ -103,7 +107,9 @@ run_test("open_reactions_popover", () => {
assert(reactions.open_reactions_popover());
assert(called);
- current_msg_list.selected_message = function () { return {sent_by_me: false}; };
+ current_msg_list.selected_message = function () {
+ return {sent_by_me: false};
+ };
called = false;
emoji_picker.toggle_emoji_popover = function (target, id) {
@@ -190,7 +196,9 @@ run_test("sending", () => {
// similarly, we only exercise the failure codepath
// Since this path calls blueslip.warn, we need to handle it.
blueslip.expect("warn", "XHR Error Message.");
- global.channel.xhr_error_message = function () {return "XHR Error Message.";};
+ global.channel.xhr_error_message = function () {
+ return "XHR Error Message.";
+ };
args.error();
});
emoji_name = "alien"; // not set yet
@@ -271,8 +279,10 @@ run_test("emoji_reaction_title", () => {
const message_id = 1001;
const local_id = "unicode_emoji,263a";
- assert.equal(reactions.get_reaction_title_data(message_id, local_id),
- "You (click to remove) and Bob van Roberts reacted with :smile:");
+ assert.equal(
+ reactions.get_reaction_title_data(message_id, local_id),
+ "You (click to remove) and Bob van Roberts reacted with :smile:",
+ );
});
run_test("add_and_remove_reaction", () => {
@@ -320,8 +330,10 @@ run_test("add_and_remove_reaction", () => {
// Testing tooltip title data for added reaction.
const local_id = "unicode_emoji,1f3b1";
- assert.equal(reactions.get_reaction_title_data(alice_event.message_id, local_id),
- "You (click to remove) reacted with :8ball:");
+ assert.equal(
+ reactions.get_reaction_title_data(alice_event.message_id, local_id),
+ "You (click to remove) reacted with :8ball:",
+ );
// Running add_reaction again should not result in any changes
template_called = false;
@@ -582,7 +594,6 @@ run_test("with_view_stubs", () => {
},
],
});
-
});
run_test("error_handling", () => {
@@ -601,7 +612,9 @@ run_test("error_handling", () => {
};
const original_func = reactions.current_user_has_reacted_to_emoji;
- reactions.current_user_has_reacted_to_emoji = function () { return true; };
+ reactions.current_user_has_reacted_to_emoji = function () {
+ return true;
+ };
reactions.toggle_emoji_reaction(55, bogus_event.emoji_name);
reactions.current_user_has_reacted_to_emoji = original_func;
@@ -722,9 +735,7 @@ run_test("duplicates", () => {
],
};
- blueslip.expect(
- "error",
- "server sent duplicate reactions for user 5 (key=unicode_emoji,263a)");
+ blueslip.expect("error", "server sent duplicate reactions for user 5 (key=unicode_emoji,263a)");
reactions.set_clean_reactions(dup_reaction_message);
});
@@ -735,6 +746,9 @@ run_test("process_reaction_click errors", () => {
reactions.process_reaction_click(55, "whatever");
global.message_store.get = () => message;
- blueslip.expect("error", "Data integrity problem for reaction bad-local-id (message some-msg-id)");
+ blueslip.expect(
+ "error",
+ "Data integrity problem for reaction bad-local-id (message some-msg-id)",
+ );
reactions.process_reaction_click("some-msg-id", "bad-local-id");
});
diff --git a/frontend_tests/node_tests/recent_senders.js b/frontend_tests/node_tests/recent_senders.js
index b4f2c4d04ec..4f745205b0c 100644
--- a/frontend_tests/node_tests/recent_senders.js
+++ b/frontend_tests/node_tests/recent_senders.js
@@ -4,8 +4,10 @@ let next_id = 0;
const messages = [];
set_global("message_util", {
- get_messages_in_topic: (stream_id, topic) => messages.filter((x) => x.stream_id === stream_id &&
- x.topic.toLowerCase() === topic.toLowerCase()),
+ get_messages_in_topic: (stream_id, topic) =>
+ messages.filter(
+ (x) => x.stream_id === stream_id && x.topic.toLowerCase() === topic.toLowerCase(),
+ ),
});
run_test("process_message_for_senders", () => {
@@ -27,13 +29,13 @@ run_test("process_message_for_senders", () => {
// New stream
const message1 = {
stream_id: stream1,
- id: next_id += 1,
+ id: (next_id += 1),
topic: topic1,
sender_id: sender1,
};
const message2 = {
stream_id: stream2,
- id: next_id += 1,
+ id: (next_id += 1),
topic: topic1,
sender_id: sender2,
};
@@ -45,20 +47,23 @@ run_test("process_message_for_senders", () => {
// Users have posted in only one of the streams
assert.equal(
rs.compare_by_recency({user_id: sender1}, {user_id: sender2}, stream1, topic1) < 0,
- true);
+ true,
+ );
assert.equal(
rs.compare_by_recency({user_id: sender1}, {user_id: sender2}, stream2, topic1) > 0,
- true);
+ true,
+ );
// Users haven't posted in this stream, return zero
assert.equal(
rs.compare_by_recency({user_id: sender1}, {user_id: sender2}, stream3, undefined) === 0,
- true);
+ true,
+ );
// New topic
const message3 = {
stream_id: stream1,
- id: next_id += 1,
+ id: (next_id += 1),
topic: topic2,
sender_id: sender3,
};
@@ -67,12 +72,13 @@ run_test("process_message_for_senders", () => {
rs.process_message_for_senders(message3);
assert.equal(
rs.compare_by_recency({user_id: sender3}, {user_id: sender2}, stream1, topic2) < 0,
- true);
+ true,
+ );
// New sender
const message4 = {
stream_id: stream1,
- id: next_id += 1,
+ id: (next_id += 1),
topic: topic1,
sender_id: sender2,
};
@@ -81,12 +87,13 @@ run_test("process_message_for_senders", () => {
rs.process_message_for_senders(message4);
assert.equal(
rs.compare_by_recency({user_id: sender1}, {user_id: sender2}, stream1, topic1) > 0,
- true);
+ true,
+ );
// More recent message
const message5 = {
stream_id: stream1,
- id: next_id += 1,
+ id: (next_id += 1),
topic: topic1,
sender_id: sender1,
};
@@ -95,24 +102,25 @@ run_test("process_message_for_senders", () => {
rs.process_message_for_senders(message5);
assert.equal(
rs.compare_by_recency({user_id: sender1}, {user_id: sender2}, stream1, topic1) < 0,
- true);
+ true,
+ );
// Same stream, but different topics
const message6 = {
stream_id: stream3,
- id: next_id += 1,
+ id: (next_id += 1),
topic: topic1,
sender_id: sender1,
};
const message7 = {
stream_id: stream3,
- id: next_id += 1,
+ id: (next_id += 1),
topic: topic2,
sender_id: sender2,
};
const message8 = {
stream_id: stream3,
- id: next_id += 1,
+ id: (next_id += 1),
topic: topic3,
sender_id: sender3,
};
@@ -125,17 +133,19 @@ run_test("process_message_for_senders", () => {
// topic3 has a message in it, but sender1 nor sender2 have participated, so sort by stream
assert.equal(
rs.compare_by_recency({user_id: sender1}, {user_id: sender2}, stream3, topic3) > 0,
- true);
+ true,
+ );
assert.equal(
rs.compare_by_recency({user_id: sender2}, {user_id: sender1}, stream3, topic3) < 0,
- true);
+ true,
+ );
- assert.equal(rs.compare_by_recency({}, {}, next_id += 1, ""), 0);
+ assert.equal(rs.compare_by_recency({}, {}, (next_id += 1), ""), 0);
// new message in topic2
const message9 = {
stream_id: stream3,
- id: next_id += 1,
+ id: (next_id += 1),
topic: topic2,
sender_id: sender3,
};
@@ -144,74 +154,46 @@ run_test("process_message_for_senders", () => {
rs.process_message_for_senders(message9);
// Test topic change
- assert.equal(
- rs.get_topic_recent_senders(stream3, topic3).toString(), "3",
- );
- assert.equal(
- rs.get_topic_recent_senders(stream3, topic2).toString(), "2,3",
- );
+ assert.equal(rs.get_topic_recent_senders(stream3, topic3).toString(), "3");
+ assert.equal(rs.get_topic_recent_senders(stream3, topic2).toString(), "2,3");
// message7's topic was changed by user
messages[6].topic = topic3;
rs.process_topic_edit(stream3, topic2, topic3);
- assert.equal(
- rs.get_topic_recent_senders(stream3, topic3).toString(), "2,3",
- );
- assert.equal(
- rs.get_topic_recent_senders(stream3, topic2).toString(), "3",
- );
+ assert.equal(rs.get_topic_recent_senders(stream3, topic3).toString(), "2,3");
+ assert.equal(rs.get_topic_recent_senders(stream3, topic2).toString(), "3");
// Test stream change
- assert.equal(
- rs.get_topic_recent_senders(stream3, topic3).toString(), "2,3",
- );
- assert.equal(
- rs.get_topic_recent_senders(stream4, topic3).toString(), "",
- );
+ assert.equal(rs.get_topic_recent_senders(stream3, topic3).toString(), "2,3");
+ assert.equal(rs.get_topic_recent_senders(stream4, topic3).toString(), "");
// stream of topic3 was changed to stream4.
messages[6].stream_id = stream4; // message7's topic is topic3
messages[7].stream_id = stream4;
rs.process_topic_edit(stream3, topic3, topic3, stream4);
- assert.equal(
- rs.get_topic_recent_senders(stream3, topic3).toString(), "",
- );
- assert.equal(
- rs.get_topic_recent_senders(stream4, topic3).toString(), "2,3",
- );
+ assert.equal(rs.get_topic_recent_senders(stream3, topic3).toString(), "");
+ assert.equal(rs.get_topic_recent_senders(stream4, topic3).toString(), "2,3");
// Test stream & topic change
- assert.equal(
- rs.get_topic_recent_senders(stream4, topic3).toString(), "2,3",
- );
- assert.equal(
- rs.get_topic_recent_senders(stream5, topic4).toString(), "",
- );
+ assert.equal(rs.get_topic_recent_senders(stream4, topic3).toString(), "2,3");
+ assert.equal(rs.get_topic_recent_senders(stream5, topic4).toString(), "");
// stream of topic3 was changed to stream5 and topic was changed to topic4.
messages[6].stream_id = stream5;
messages[7].stream_id = stream5;
messages[6].topic = topic4;
messages[7].topic = topic4;
rs.process_topic_edit(stream4, topic3, topic4, stream5);
- assert.equal(
- rs.get_topic_recent_senders(stream4, topic3).toString(), "",
- );
- assert.equal(
- rs.get_topic_recent_senders(stream5, topic4).toString(), "2,3",
- );
+ assert.equal(rs.get_topic_recent_senders(stream4, topic3).toString(), "");
+ assert.equal(rs.get_topic_recent_senders(stream5, topic4).toString(), "2,3");
set_global("message_store", {
get: () => message1,
});
- assert.equal(
- rs.get_topic_recent_senders(stream1, topic1).toString(), "2,1",
- );
+ assert.equal(rs.get_topic_recent_senders(stream1, topic1).toString(), "2,1");
// delete message1 and message5 sent by sender1
messages.splice(4, 1);
messages.splice(0, 1);
rs.update_topics_of_message_ids([message1.id, message5.id]);
- assert.equal(
- rs.get_topic_recent_senders(stream1, topic1).toString(), "2",
- );
+ assert.equal(rs.get_topic_recent_senders(stream1, topic1).toString(), "2");
});
diff --git a/frontend_tests/node_tests/recent_topics.js b/frontend_tests/node_tests/recent_topics.js
index 650878f4aff..062606b00ed 100644
--- a/frontend_tests/node_tests/recent_topics.js
+++ b/frontend_tests/node_tests/recent_topics.js
@@ -1,9 +1,12 @@
zrequire("message_util");
const noop = () => {};
-set_global("$", global.make_zjquery({
- silent: true,
-}));
+set_global(
+ "$",
+ global.make_zjquery({
+ silent: true,
+ }),
+);
set_global("hashchange", {
exit_overlay: noop,
});
@@ -133,8 +136,7 @@ set_global("stream_data", {
is_muted: () =>
// We only test via muted topics for now.
// TODO: Make muted streams and test them.
- false
- ,
+ false,
});
let id = 0;
@@ -142,7 +144,7 @@ let id = 0;
messages[0] = {
stream_id: stream1,
stream: "stream1",
- id: id += 1,
+ id: (id += 1),
topic: topic1,
sender_id: sender1,
type: "stream",
@@ -151,7 +153,7 @@ messages[0] = {
messages[1] = {
stream_id: stream1,
stream: "stream1",
- id: id += 1,
+ id: (id += 1),
topic: topic2,
sender_id: sender1,
type: "stream",
@@ -160,7 +162,7 @@ messages[1] = {
messages[2] = {
stream_id: stream1,
stream: "stream1",
- id: id += 1,
+ id: (id += 1),
topic: topic2,
sender_id: sender2,
type: "stream",
@@ -169,7 +171,7 @@ messages[2] = {
messages[3] = {
stream_id: stream1,
stream: "stream1",
- id: id += 1,
+ id: (id += 1),
topic: topic3,
sender_id: sender2,
type: "stream",
@@ -178,7 +180,7 @@ messages[3] = {
messages[4] = {
stream_id: stream1,
stream: "stream1",
- id: id += 1,
+ id: (id += 1),
topic: topic4,
sender_id: sender2,
type: "stream",
@@ -187,7 +189,7 @@ messages[4] = {
messages[5] = {
stream_id: stream1,
stream: "stream1",
- id: id += 1,
+ id: (id += 1),
topic: topic5,
sender_id: sender1,
type: "stream",
@@ -196,7 +198,7 @@ messages[5] = {
messages[6] = {
stream_id: stream1,
stream: "stream1",
- id: id += 1,
+ id: (id += 1),
topic: topic5,
sender_id: sender2,
type: "stream",
@@ -205,7 +207,7 @@ messages[6] = {
messages[7] = {
stream_id: stream1,
stream: "stream1",
- id: id += 1,
+ id: (id += 1),
topic: topic6,
sender_id: sender1,
type: "stream",
@@ -214,7 +216,7 @@ messages[7] = {
messages[8] = {
stream_id: stream1,
stream: "stream1",
- id: id += 1,
+ id: (id += 1),
topic: topic6,
sender_id: sender2,
type: "stream",
@@ -223,7 +225,7 @@ messages[8] = {
messages[9] = {
stream_id: stream1,
stream: "stream1",
- id: id += 1,
+ id: (id += 1),
topic: topic7,
sender_id: sender1,
type: "stream",
@@ -233,7 +235,7 @@ messages[9] = {
messages[10] = {
stream_id: stream4,
stream: "stream4",
- id: id += 1,
+ id: (id += 1),
topic: topic10,
sender_id: sender1,
type: "stream",
@@ -267,10 +269,7 @@ function generate_topic_data(topic_info_array) {
is_web_public: true,
last_msg_time: "Just now",
full_last_msg_date_time: "date time",
- senders: [
- 1,
- 2,
- ],
+ senders: [1, 2],
stream: "stream" + stream_id,
stream_color: "",
stream_id: stream_id,
@@ -287,8 +286,7 @@ function generate_topic_data(topic_info_array) {
return data;
}
-function verify_topic_data(all_topics, stream, topic, last_msg_id,
- participated) {
+function verify_topic_data(all_topics, stream, topic, last_msg_id, participated) {
const topic_data = all_topics.get(stream + ":" + topic);
assert.equal(topic_data.last_msg_id, last_msg_id);
assert.equal(topic_data.participated, participated);
@@ -479,7 +477,6 @@ run_test("test_filter_participated", () => {
rt.set_filter("participated");
rt.update_filters_view();
-
global.stub_templates((template_name, data) => {
if (template_name === "recent_topic_row") {
// All the row will be processed.
@@ -522,8 +519,10 @@ run_test("basic assertions", () => {
// Check for expected lengths.
// total 8 topics, 1 muted
assert.equal(all_topics.size, 8);
- assert.equal(Array.from(all_topics.keys()).toString(),
- "4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1");
+ assert.equal(
+ Array.from(all_topics.keys()).toString(),
+ "4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1",
+ );
rt.process_message({
type: "private",
@@ -531,8 +530,10 @@ run_test("basic assertions", () => {
// Private msgs are not processed.
assert.equal(all_topics.size, 8);
- assert.equal(Array.from(all_topics.keys()).toString(),
- "4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1");
+ assert.equal(
+ Array.from(all_topics.keys()).toString(),
+ "4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1",
+ );
// participated
verify_topic_data(all_topics, stream1, topic1, messages[0].id, true);
@@ -546,30 +547,34 @@ run_test("basic assertions", () => {
// topic3 now participated
rt.process_message({
stream_id: stream1,
- id: id += 1,
+ id: (id += 1),
topic: topic3,
sender_id: sender1,
type: "stream",
});
all_topics = rt.get();
- assert.equal(Array.from(all_topics.keys()).toString(),
- "1:topic-3,4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-2,1:topic-1");
+ assert.equal(
+ Array.from(all_topics.keys()).toString(),
+ "1:topic-3,4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-2,1:topic-1",
+ );
verify_topic_data(all_topics, stream1, topic3, id, true);
// Send new message to topic7 (muted)
// The topic will be hidden when displayed
rt.process_message({
stream_id: stream1,
- id: id += 1,
+ id: (id += 1),
topic: topic7,
sender_id: sender1,
type: "stream",
});
all_topics = rt.get();
- assert.equal(Array.from(all_topics.keys()).toString(),
- "1:topic-7,1:topic-3,4:topic-10,1:topic-6,1:topic-5,1:topic-4,1:topic-2,1:topic-1");
+ assert.equal(
+ Array.from(all_topics.keys()).toString(),
+ "1:topic-7,1:topic-3,4:topic-10,1:topic-6,1:topic-5,1:topic-4,1:topic-2,1:topic-1",
+ );
// update_topic_is_muted now relies on external libraries completely
// so we don't need to check anythere here.
@@ -592,10 +597,13 @@ run_test("test_reify_local_echo_message", () => {
type: "stream",
});
- assert.equal(rt.reify_message_id_if_available({
- old_id: 1000.01,
- new_id: 1001,
- }), true);
+ assert.equal(
+ rt.reify_message_id_if_available({
+ old_id: 1000.01,
+ new_id: 1001,
+ }),
+ true,
+ );
rt.process_message({
stream_id: stream1,
@@ -614,13 +622,15 @@ run_test("test_reify_local_echo_message", () => {
type: "stream",
});
- assert.equal(rt.reify_message_id_if_available({
- old_id: 1000.01,
- new_id: 1001,
- }), false);
+ assert.equal(
+ rt.reify_message_id_if_available({
+ old_id: 1000.01,
+ new_id: 1001,
+ }),
+ false,
+ );
});
-
run_test("test_delete_messages", () => {
const rt = zrequire("recent_topics");
rt.set_filter("all");
@@ -638,13 +648,17 @@ run_test("test_delete_messages", () => {
});
let all_topics = rt.get();
- assert.equal(Array.from(all_topics.keys()).toString(),
- "4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1");
+ assert.equal(
+ Array.from(all_topics.keys()).toString(),
+ "4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1",
+ );
rt.update_topics_of_message_ids([messages[0].id]);
all_topics = rt.get();
- assert.equal(Array.from(all_topics.keys()).toString(),
- "4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2");
+ assert.equal(
+ Array.from(all_topics.keys()).toString(),
+ "4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2",
+ );
set_global("message_list", {
all: {
@@ -660,8 +674,10 @@ run_test("test_delete_messages", () => {
rt.update_topics_of_message_ids([messages[1].id, messages[2].id]);
all_topics = rt.get();
- assert.equal(Array.from(all_topics.keys()).toString(),
- "4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3");
+ assert.equal(
+ Array.from(all_topics.keys()).toString(),
+ "4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3",
+ );
});
run_test("test_topic_edit", () => {
@@ -678,8 +694,10 @@ run_test("test_topic_edit", () => {
rt.process_messages(messages);
let all_topics = rt.get();
- assert.equal(Array.from(all_topics.keys()).toString(),
- "4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1");
+ assert.equal(
+ Array.from(all_topics.keys()).toString(),
+ "4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1",
+ );
////////////////// test change topic //////////////////
verify_topic_data(all_topics, stream1, topic6, messages[8].id, true);
diff --git a/frontend_tests/node_tests/rendered_markdown.js b/frontend_tests/node_tests/rendered_markdown.js
index 228595aeeaf..0bfba9ab642 100644
--- a/frontend_tests/node_tests/rendered_markdown.js
+++ b/frontend_tests/node_tests/rendered_markdown.js
@@ -108,7 +108,6 @@ run_test("user-mention", () => {
assert.equal($cordelia.text(), `@${cordelia.full_name}`);
});
-
run_test("user-group-mention", () => {
// Setup
const $content = get_content_element();
@@ -175,7 +174,10 @@ run_test("timestamp", () => {
// Final asserts
assert.equal($timestamp.text(), "Thu, Jan 1 1970, 12:00 AM");
- assert.equal($timestamp.attr("title"), "This time is in your timezone. Original text was 'never-been-set'.");
+ assert.equal(
+ $timestamp.attr("title"),
+ "This time is in your timezone. Original text was 'never-been-set'.",
+ );
assert.equal($timestamp_invalid.text(), "never-been-set");
});
@@ -246,7 +248,8 @@ run_test("spoiler-header", () => {
// Test that the show/hide button gets added to a spoiler header.
const label = "My Spoiler Header";
- const toggle_button_html = '<span class="spoiler-button" aria-expanded="false"><span class="spoiler-arrow"></span></span>';
+ const toggle_button_html =
+ '<span class="spoiler-button" aria-expanded="false"><span class="spoiler-arrow"></span></span>';
$header.html(label);
rm.update_elements($content);
assert.equal(toggle_button_html + label, $header.html());
@@ -259,7 +262,8 @@ run_test("spoiler-header-empty-fill", () => {
$content.set_find_results("div.spoiler-header", $array([$header]));
// Test that an empty header gets the default text applied (through i18n filter).
- const toggle_button_html = '<span class="spoiler-button" aria-expanded="false"><span class="spoiler-arrow"></span></span>';
+ const toggle_button_html =
+ '<span class="spoiler-button" aria-expanded="false"><span class="spoiler-arrow"></span></span>';
$header.html("");
rm.update_elements($content);
assert.equal(toggle_button_html + "<p>translated: Spoiler</p>", $header.html());
diff --git a/frontend_tests/node_tests/rtl.js b/frontend_tests/node_tests/rtl.js
index dedfb024445..74e6e061cc3 100644
--- a/frontend_tests/node_tests/rtl.js
+++ b/frontend_tests/node_tests/rtl.js
@@ -62,11 +62,30 @@ run_test("get_direction", () => {
assert.equal(rtl.get_direction("aa" + i_chars.charAt(0) + "ج؛ج"), "ltr");
assert.equal(rtl.get_direction("12" + i_chars.charAt(0) + "ج؛ج"), "ltr");
assert.equal(rtl.get_direction("۱۲" + i_chars.charAt(0) + "aaa"), "ltr");
- assert.equal(rtl.get_direction(",," + i_chars.charAt(0) + "bb" + i_chars.charAt(0) + "جج" + pdi + "ضض" + pdi + ".."), "ltr");
- assert.equal(rtl.get_direction(",," + i_chars.charAt(0) + "bb" + i_chars.charAt(0) + "جج" + pdi + "ضض" + pdi + "وو"), "rtl");
- assert.equal(rtl.get_direction(",," + i_chars.charAt(0) + "bb" + pdi + "33" + pdi + ".."), "ltr");
- assert.equal(rtl.get_direction(",," + i_chars.charAt(0) + "bb" + pdi + "12" + pdi + "وو"), "rtl");
- assert.equal(rtl.get_direction(",," + i_chars.charAt(0) + "ضج" + pdi + "12" + pdi + "ff"), "ltr");
+ assert.equal(
+ rtl.get_direction(
+ ",," + i_chars.charAt(0) + "bb" + i_chars.charAt(0) + "جج" + pdi + "ضض" + pdi + "..",
+ ),
+ "ltr",
+ );
+ assert.equal(
+ rtl.get_direction(
+ ",," + i_chars.charAt(0) + "bb" + i_chars.charAt(0) + "جج" + pdi + "ضض" + pdi + "وو",
+ ),
+ "rtl",
+ );
+ assert.equal(
+ rtl.get_direction(",," + i_chars.charAt(0) + "bb" + pdi + "33" + pdi + ".."),
+ "ltr",
+ );
+ assert.equal(
+ rtl.get_direction(",," + i_chars.charAt(0) + "bb" + pdi + "12" + pdi + "وو"),
+ "rtl",
+ );
+ assert.equal(
+ rtl.get_direction(",," + i_chars.charAt(0) + "ضج" + pdi + "12" + pdi + "ff"),
+ "ltr",
+ );
assert.equal(rtl.get_direction("aa" + i_chars.charAt(1) + "bb" + pdi + "cc"), "ltr");
assert.equal(rtl.get_direction("دد" + i_chars.charAt(2) + "bb" + pdi + "cc"), "rtl");
@@ -75,9 +94,28 @@ run_test("get_direction", () => {
assert.equal(rtl.get_direction("aa" + i_chars.charAt(1) + "ججج"), "ltr");
assert.equal(rtl.get_direction("12" + i_chars.charAt(2) + "ججج"), "ltr");
assert.equal(rtl.get_direction("۱۲" + i_chars.charAt(1) + "aaa"), "ltr");
- assert.equal(rtl.get_direction(",," + i_chars.charAt(1) + "bb" + i_chars.charAt(2) + "جج" + pdi + "ضض" + pdi + ".."), "ltr");
- assert.equal(rtl.get_direction(",," + i_chars.charAt(2) + "bb" + i_chars.charAt(1) + "؛ج" + pdi + "ضض" + pdi + "وو"), "rtl");
- assert.equal(rtl.get_direction(",," + i_chars.charAt(1) + "bb" + pdi + "33" + pdi + ".."), "ltr");
- assert.equal(rtl.get_direction(",," + i_chars.charAt(2) + "bb" + pdi + "12" + pdi + "وو"), "rtl");
- assert.equal(rtl.get_direction(",," + i_chars.charAt(1) + "ضج" + pdi + "12" + pdi + "ff"), "ltr");
+ assert.equal(
+ rtl.get_direction(
+ ",," + i_chars.charAt(1) + "bb" + i_chars.charAt(2) + "جج" + pdi + "ضض" + pdi + "..",
+ ),
+ "ltr",
+ );
+ assert.equal(
+ rtl.get_direction(
+ ",," + i_chars.charAt(2) + "bb" + i_chars.charAt(1) + "؛ج" + pdi + "ضض" + pdi + "وو",
+ ),
+ "rtl",
+ );
+ assert.equal(
+ rtl.get_direction(",," + i_chars.charAt(1) + "bb" + pdi + "33" + pdi + ".."),
+ "ltr",
+ );
+ assert.equal(
+ rtl.get_direction(",," + i_chars.charAt(2) + "bb" + pdi + "12" + pdi + "وو"),
+ "rtl",
+ );
+ assert.equal(
+ rtl.get_direction(",," + i_chars.charAt(1) + "ضج" + pdi + "12" + pdi + "ff"),
+ "ltr",
+ );
});
diff --git a/frontend_tests/node_tests/schema.js b/frontend_tests/node_tests/schema.js
index 46cf06dc05c..98c803110aa 100644
--- a/frontend_tests/node_tests/schema.js
+++ b/frontend_tests/node_tests/schema.js
@@ -11,45 +11,21 @@ run_test("basics", () => {
const check_rec = (val) => schema.check_record("my_rec", val, fields);
- assert.equal(
- check_rec({foo: "apple", bar: "banana"}),
- undefined,
- );
-
- assert.equal(
- check_rec("bogus"),
- "my_rec is not a record",
- );
-
- assert.equal(
- check_rec({foo: "apple"}),
- "in my_rec bar is missing",
- );
-
- assert.equal(
- check_rec({}),
- "in my_rec bar is missing, foo is missing",
- );
-
- assert.equal(
- check_rec({foo: "apple", bar: 42}),
- "in my_rec bar is not a string",
- );
+ assert.equal(check_rec({foo: "apple", bar: "banana"}), undefined);
+
+ assert.equal(check_rec("bogus"), "my_rec is not a record");
+
+ assert.equal(check_rec({foo: "apple"}), "in my_rec bar is missing");
+
+ assert.equal(check_rec({}), "in my_rec bar is missing, foo is missing");
+
+ assert.equal(check_rec({foo: "apple", bar: 42}), "in my_rec bar is not a string");
const check_array = (val) => schema.check_array("lst", val, schema.check_string);
- assert.equal(
- check_array(["foo", "bar"]),
- undefined,
- );
+ assert.equal(check_array(["foo", "bar"]), undefined);
- assert.equal(
- check_array("foo"),
- "lst is not an array",
- );
+ assert.equal(check_array("foo"), "lst is not an array");
- assert.equal(
- check_array(["foo", 3]),
- "in lst we found an item where item is not a string",
- );
+ assert.equal(check_array(["foo", 3]), "in lst we found an item where item is not a string");
});
diff --git a/frontend_tests/node_tests/scroll_util.js b/frontend_tests/node_tests/scroll_util.js
index 45eb700df54..1e3ad161e6d 100644
--- a/frontend_tests/node_tests/scroll_util.js
+++ b/frontend_tests/node_tests/scroll_util.js
@@ -5,56 +5,79 @@ set_global("ui", {
run_test("scroll_delta", () => {
// If we are entirely on-screen, don't scroll
- assert.equal(0, scroll_util.scroll_delta({
- elem_top: 1,
- elem_bottom: 9,
- container_height: 10,
- }));
+ assert.equal(
+ 0,
+ scroll_util.scroll_delta({
+ elem_top: 1,
+ elem_bottom: 9,
+ container_height: 10,
+ }),
+ );
- assert.equal(0, scroll_util.scroll_delta({
- elem_top: -5,
- elem_bottom: 15,
- container_height: 10,
- }));
+ assert.equal(
+ 0,
+ scroll_util.scroll_delta({
+ elem_top: -5,
+ elem_bottom: 15,
+ container_height: 10,
+ }),
+ );
// The top is offscreen.
- assert.equal(-3, scroll_util.scroll_delta({
- elem_top: -3,
- elem_bottom: 5,
- container_height: 10,
- }));
+ assert.equal(
+ -3,
+ scroll_util.scroll_delta({
+ elem_top: -3,
+ elem_bottom: 5,
+ container_height: 10,
+ }),
+ );
- assert.equal(-3, scroll_util.scroll_delta({
- elem_top: -3,
- elem_bottom: -1,
- container_height: 10,
- }));
+ assert.equal(
+ -3,
+ scroll_util.scroll_delta({
+ elem_top: -3,
+ elem_bottom: -1,
+ container_height: 10,
+ }),
+ );
- assert.equal(-11, scroll_util.scroll_delta({
- elem_top: -150,
- elem_bottom: -1,
- container_height: 10,
- }));
+ assert.equal(
+ -11,
+ scroll_util.scroll_delta({
+ elem_top: -150,
+ elem_bottom: -1,
+ container_height: 10,
+ }),
+ );
// The bottom is offscreen.
- assert.equal(3, scroll_util.scroll_delta({
- elem_top: 7,
- elem_bottom: 13,
- container_height: 10,
- }));
-
- assert.equal(3, scroll_util.scroll_delta({
- elem_top: 11,
- elem_bottom: 13,
- container_height: 10,
- }));
+ assert.equal(
+ 3,
+ scroll_util.scroll_delta({
+ elem_top: 7,
+ elem_bottom: 13,
+ container_height: 10,
+ }),
+ );
- assert.equal(11, scroll_util.scroll_delta({
- elem_top: 11,
- elem_bottom: 99,
- container_height: 10,
- }));
+ assert.equal(
+ 3,
+ scroll_util.scroll_delta({
+ elem_top: 11,
+ elem_bottom: 13,
+ container_height: 10,
+ }),
+ );
+ assert.equal(
+ 11,
+ scroll_util.scroll_delta({
+ elem_top: 11,
+ elem_bottom: 99,
+ container_height: 10,
+ }),
+ );
});
run_test("scroll_element_into_container", () => {
diff --git a/frontend_tests/node_tests/search.js b/frontend_tests/node_tests/search.js
index fa3411f5c66..792d6291acf 100644
--- a/frontend_tests/node_tests/search.js
+++ b/frontend_tests/node_tests/search.js
@@ -93,7 +93,6 @@ run_test("initialize", () => {
search_suggestion.max_num_of_search_results = 99;
search_query_box.typeahead = (opts) => {
-
assert.equal(opts.fixed, true);
assert.equal(opts.items, 99);
assert.equal(opts.naturalSearch, true);
@@ -104,14 +103,20 @@ run_test("initialize", () => {
{
const search_suggestions = {
lookup_table: new Map([
- ["stream:Verona", {
- description: "Stream <strong>Ver</strong>ona",
- search_string: "stream:Verona",
- }],
- ["ver", {
- description: "Search for ver",
- search_string: "ver",
- }],
+ [
+ "stream:Verona",
+ {
+ description: "Stream <strong>Ver</strong>ona",
+ search_string: "stream:Verona",
+ },
+ ],
+ [
+ "ver",
+ {
+ description: "Search for ver",
+ search_string: "ver",
+ },
+ ],
]),
strings: ["ver", "stream:Verona"],
};
@@ -159,22 +164,26 @@ run_test("initialize", () => {
search_pill.get_search_string_for_current_filter = () => search_box_val;
};
- operators = [{
- negated: false,
- operator: "search",
- operand: "ver",
- }];
+ operators = [
+ {
+ negated: false,
+ operator: "search",
+ operand: "ver",
+ },
+ ];
_setup("ver");
assert.equal(opts.updater("ver"), "ver");
assert(!is_blurred);
assert(is_append_search_string_called);
- operators = [{
- negated: false,
- operator: "stream",
- operand: "Verona",
- }];
+ operators = [
+ {
+ negated: false,
+ operator: "stream",
+ operand: "Verona",
+ },
+ ];
_setup("stream:Verona");
assert.equal(opts.updater("stream:Verona"), "stream:Verona");
@@ -231,11 +240,13 @@ run_test("initialize", () => {
search_pill.get_search_string_for_current_filter = () => search_box_val;
};
- operators = [{
- negated: false,
- operator: "search",
- operand: "",
- }];
+ operators = [
+ {
+ negated: false,
+ operator: "search",
+ operand: "",
+ },
+ ];
_setup("");
ev.which = 15;
@@ -294,7 +305,9 @@ run_test("initialize", () => {
if (event === "focusin") {
searchbox.css({"box-shadow": "unset"});
callback();
- assert.deepEqual(searchbox.css(), {"box-shadow": "inset 0px 0px 0px 2px hsl(204, 20%, 74%)"});
+ assert.deepEqual(searchbox.css(), {
+ "box-shadow": "inset 0px 0px 0px 2px hsl(204, 20%, 74%)",
+ });
} else if (event === "focusout") {
searchbox.css({"box-shadow": "inset 0px 0px 0px 2px hsl(204, 20%, 74%)"});
callback();
diff --git a/frontend_tests/node_tests/search_legacy.js b/frontend_tests/node_tests/search_legacy.js
index 766cd672993..b64327215dc 100644
--- a/frontend_tests/node_tests/search_legacy.js
+++ b/frontend_tests/node_tests/search_legacy.js
@@ -75,14 +75,20 @@ run_test("initialize", () => {
{
const search_suggestions = {
lookup_table: new Map([
- ["stream:Verona", {
- description: "Stream <strong>Ver</strong>ona",
- search_string: "stream:Verona",
- }],
- ["ver", {
- description: "Search for ver",
- search_string: "ver",
- }],
+ [
+ "stream:Verona",
+ {
+ description: "Stream <strong>Ver</strong>ona",
+ search_string: "stream:Verona",
+ },
+ ],
+ [
+ "ver",
+ {
+ description: "Search for ver",
+ search_string: "ver",
+ },
+ ],
]),
strings: ["ver", "stream:Verona"],
};
@@ -124,20 +130,24 @@ run_test("initialize", () => {
};
};
- operators = [{
- negated: false,
- operator: "search",
- operand: "ver",
- }];
+ operators = [
+ {
+ negated: false,
+ operator: "search",
+ operand: "ver",
+ },
+ ];
_setup("ver");
assert.equal(opts.updater("ver"), "ver");
assert(is_blurred);
- operators = [{
- negated: false,
- operator: "stream",
- operand: "Verona",
- }];
+ operators = [
+ {
+ negated: false,
+ operator: "stream",
+ operand: "Verona",
+ },
+ ];
_setup("stream:Verona");
assert.equal(opts.updater("stream:Verona"), "stream:Verona");
assert(is_blurred);
@@ -189,11 +199,13 @@ run_test("initialize", () => {
};
};
- operators = [{
- negated: false,
- operator: "search",
- operand: "",
- }];
+ operators = [
+ {
+ negated: false,
+ operator: "search",
+ operand: "",
+ },
+ ];
_setup("");
ev.which = 15;
diff --git a/frontend_tests/node_tests/search_pill.js b/frontend_tests/node_tests/search_pill.js
index d1c1e0b17e0..fb406b3318c 100644
--- a/frontend_tests/node_tests/search_pill.js
+++ b/frontend_tests/node_tests/search_pill.js
@@ -14,7 +14,6 @@ const is_private_item = {
};
run_test("create_item", () => {
-
function test_create_item(search_string, current_items, expected_item) {
const item = search_pill.create_item_from_search_string(search_string, current_items);
assert.deepEqual(item, expected_item);
@@ -55,11 +54,15 @@ run_test("get_items", () => {
const items = [is_starred_item, is_private_item];
const pill_widget = {
- items: function () { return items; },
+ items: function () {
+ return items;
+ },
};
- assert.deepEqual(search_pill.get_search_string_for_current_filter(pill_widget),
- is_starred_item.display_value + " " + is_private_item.display_value);
+ assert.deepEqual(
+ search_pill.get_search_string_for_current_filter(pill_widget),
+ is_starred_item.display_value + " " + is_private_item.display_value,
+ );
});
run_test("create_pills", () => {
diff --git a/frontend_tests/node_tests/search_suggestion.js b/frontend_tests/node_tests/search_suggestion.js
index b9aff116934..331d90f2a4b 100644
--- a/frontend_tests/node_tests/search_suggestion.js
+++ b/frontend_tests/node_tests/search_suggestion.js
@@ -37,22 +37,19 @@ const bob = {
user_id: 42,
};
-const ted =
-{
+const ted = {
user_id: 101,
full_name: "Ted Smith",
};
-const alice =
-{
+const alice = {
user_id: 102,
full_name: "Alice Ignore",
};
-const jeff =
-{
+const jeff = {
user_id: 103,
full_name: "Jeff Zoolipson",
@@ -94,9 +91,7 @@ run_test("basic_get_suggestions", () => {
const suggestions = get_suggestions("", query);
- const expected = [
- "fred",
- ];
+ const expected = ["fred"];
assert.deepEqual(suggestions.strings, expected);
});
@@ -114,9 +109,7 @@ run_test("subset_suggestions", () => {
const suggestions = get_suggestions(base_query, query);
- const expected = [
- "shakespeare",
- ];
+ const expected = ["shakespeare"];
assert.deepEqual(suggestions.strings, expected);
});
@@ -156,65 +149,43 @@ run_test("private_suggestions", () => {
query = "pm-with:t";
suggestions = get_suggestions("", query);
- expected = [
- "pm-with:t",
- "pm-with:[email protected]",
- ];
+ expected = ["pm-with:t", "pm-with:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "-pm-with:t";
suggestions = get_suggestions("", query);
- expected = [
- "-pm-with:t",
- "is:private -pm-with:[email protected]",
- ];
+ expected = ["-pm-with:t", "is:private -pm-with:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "pm-with:[email protected]";
suggestions = get_suggestions("", query);
- expected = [
- "pm-with:[email protected]",
- ];
+ expected = ["pm-with:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "sender:ted";
suggestions = get_suggestions("", query);
- expected = [
- "sender:ted",
- "sender:[email protected]",
- ];
+ expected = ["sender:ted", "sender:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "sender:te";
suggestions = get_suggestions("", query);
- expected = [
- "sender:te",
- "sender:[email protected]",
- ];
+ expected = ["sender:te", "sender:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "-sender:te";
suggestions = get_suggestions("", query);
- expected = [
- "-sender:te",
- "-sender:[email protected]",
- ];
+ expected = ["-sender:te", "-sender:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "sender:[email protected]";
suggestions = get_suggestions("", query);
- expected = [
- "sender:[email protected]",
- ];
+ expected = ["sender:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "from:ted";
base_query = "is:unread";
suggestions = get_suggestions(base_query, query);
- expected = [
- "from:ted",
- ];
+ expected = ["from:ted", "from:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
// Users can enter bizarre queries, and if they do, we want to
@@ -222,26 +193,20 @@ run_test("private_suggestions", () => {
query = "near:3";
base_query = "is:private";
suggestions = get_suggestions(base_query, query);
- expected = [
- "near:3",
- ];
+ expected = ["near:3"];
assert.deepEqual(suggestions.strings, expected);
query = "near:3";
base_query = "pm-with:[email protected]";
suggestions = get_suggestions(base_query, query);
- expected = [
- "near:3",
- ];
+ expected = ["near:3"];
assert.deepEqual(suggestions.strings, expected);
// Make sure suggestions still work if preceding tokens
query = "sender:[email protected]";
base_query = "is:alerted";
suggestions = get_suggestions(base_query, query);
- expected = [
- "sender:[email protected]",
- ];
+ expected = ["sender:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "al";
@@ -260,17 +225,13 @@ run_test("private_suggestions", () => {
query = "pm-with:";
base_query = "stream:Denmark";
suggestions = get_suggestions(base_query, query);
- expected = [
- "pm-with:",
- ];
+ expected = ["pm-with:"];
assert.deepEqual(suggestions.strings, expected);
query = "sender:";
base_query = "sender:[email protected]";
suggestions = get_suggestions(base_query, query);
- expected = [
- "sender:",
- ];
+ expected = ["sender:"];
assert.deepEqual(suggestions.strings, expected);
});
@@ -299,35 +260,25 @@ run_test("group_suggestions", () => {
// generate suggestions.
query = "pm-with:[email protected],t";
suggestions = get_suggestions("", query);
- expected = [
- "pm-with:[email protected],t",
- ];
+ expected = ["pm-with:[email protected],t", "pm-with:[email protected],[email protected]"];
assert.deepEqual(suggestions.strings, expected);
// Smit should also generate [email protected] (Ted Smith) as a suggestion.
query = "pm-with:[email protected],Smit";
suggestions = get_suggestions("", query);
- expected = [
- "pm-with:[email protected],Smit",
- ];
+ expected = ["pm-with:[email protected],Smit", "pm-with:[email protected],[email protected]"];
assert.deepEqual(suggestions.strings, expected);
// Do not suggest "[email protected]" (the name of the current user)
query = "pm-with:[email protected],mys";
suggestions = get_suggestions("", query);
- expected = [
- "pm-with:[email protected],mys",
- ];
+ expected = ["pm-with:[email protected],mys"];
assert.deepEqual(suggestions.strings, expected);
// No superfluous suggestions should be generated.
query = "pm-with:[email protected],red";
suggestions = get_suggestions("", query);
- expected = [
- "pm-with:[email protected],red",
- ];
+ expected = ["pm-with:[email protected],red"];
assert.deepEqual(suggestions.strings, expected);
// is:private should be properly prepended to each suggestion if the pm-with
@@ -345,43 +296,30 @@ run_test("group_suggestions", () => {
query = "-pm-with:[email protected],t";
suggestions = get_suggestions("", query);
- expected = [
- "-pm-with:[email protected],t",
- "is:private -pm-with:[email protected],[email protected]",
- ];
+ expected = ["-pm-with:[email protected],t", "is:private -pm-with:[email protected],[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "-pm-with:[email protected],Smit";
suggestions = get_suggestions("", query);
- expected = [
- "-pm-with:[email protected],Smit",
- "is:private -pm-with:[email protected],[email protected]",
- ];
+ expected = ["-pm-with:[email protected],Smit", "is:private -pm-with:[email protected],[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "-pm-with:[email protected],red";
suggestions = get_suggestions("", query);
- expected = [
- "-pm-with:[email protected],red",
- ];
+ expected = ["-pm-with:[email protected],red"];
assert.deepEqual(suggestions.strings, expected);
// Test multiple operators
query = "pm-with:[email protected],Smit";
let base_query = "is:starred has:link";
suggestions = get_suggestions(base_query, query);
- expected = [
- "pm-with:[email protected],Smit",
- ];
+ expected = ["pm-with:[email protected],Smit", "pm-with:[email protected],[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "pm-with:[email protected],Smit";
base_query = "stream:Denmark has:link";
suggestions = get_suggestions(base_query, query);
- expected = [
- "pm-with:[email protected],Smit",
- ];
+ expected = ["pm-with:[email protected],Smit"];
assert.deepEqual(suggestions.strings, expected);
function message(user_ids, timestamp) {
@@ -434,9 +372,7 @@ run_test("group_suggestions", () => {
query = "pm-with:[email protected],[email protected] hi";
suggestions = get_suggestions("", query);
- expected = [
- ];
+ expected = ["pm-with:[email protected],[email protected] hi"];
assert.deepEqual(suggestions.strings, expected);
});
@@ -499,12 +435,7 @@ run_test("has_suggestions", () => {
};
let suggestions = get_suggestions("", query);
- let expected = [
- "h",
- "has:link",
- "has:image",
- "has:attachment",
- ];
+ let expected = ["h", "has:link", "has:image", "has:attachment"];
assert.deepEqual(suggestions.strings, expected);
function describe(q) {
@@ -517,12 +448,7 @@ run_test("has_suggestions", () => {
query = "-h";
suggestions = get_suggestions("", query);
- expected = [
- "-h",
- "-has:link",
- "-has:image",
- "-has:attachment",
- ];
+ expected = ["-h", "-has:link", "-has:image", "-has:attachment"];
assert.deepEqual(suggestions.strings, expected);
assert.equal(describe("-has:link"), "Exclude messages with one or more link");
assert.equal(describe("-has:image"), "Exclude messages with one or more image");
@@ -532,41 +458,28 @@ run_test("has_suggestions", () => {
query = "has:";
suggestions = get_suggestions("", query);
- expected = [
- "has:link",
- "has:image",
- "has:attachment",
- ];
+ expected = ["has:link", "has:image", "has:attachment"];
assert.deepEqual(suggestions.strings, expected);
query = "has:im";
suggestions = get_suggestions("", query);
- expected = [
- "has:image",
- ];
+ expected = ["has:image"];
assert.deepEqual(suggestions.strings, expected);
query = "-has:im";
suggestions = get_suggestions("", query);
- expected = [
- "-has:image",
- ];
+ expected = ["-has:image"];
assert.deepEqual(suggestions.strings, expected);
query = "att";
suggestions = get_suggestions("", query);
- expected = [
- "att",
- "has:attachment",
- ];
+ expected = ["att", "has:attachment"];
assert.deepEqual(suggestions.strings, expected);
query = "has:lin";
const base_query = "stream:Denmark is:alerted";
suggestions = get_suggestions(base_query, query);
- expected = [
- "has:link",
- ];
+ expected = ["has:link"];
assert.deepEqual(suggestions.strings, expected);
});
@@ -606,14 +519,7 @@ run_test("check_is_suggestions", () => {
query = "-i";
suggestions = get_suggestions("", query);
- expected = [
- "-i",
- "-is:private",
- "-is:starred",
- "-is:mentioned",
- "-is:alerted",
- "-is:unread",
- ];
+ expected = ["-i", "-is:private", "-is:starred", "-is:mentioned", "-is:alerted", "-is:unread"];
assert.deepEqual(suggestions.strings, expected);
assert.equal(describe("-is:private"), "Exclude private messages");
@@ -660,45 +566,28 @@ run_test("check_is_suggestions", () => {
query = "is:";
suggestions = get_suggestions("", query);
- expected = [
- "is:private",
- "is:starred",
- "is:mentioned",
- "is:alerted",
- "is:unread",
- ];
+ expected = ["is:private", "is:starred", "is:mentioned", "is:alerted", "is:unread"];
assert.deepEqual(suggestions.strings, expected);
query = "is:st";
suggestions = get_suggestions("", query);
- expected = [
- "is:starred",
- ];
+ expected = ["is:starred"];
assert.deepEqual(suggestions.strings, expected);
query = "-is:st";
suggestions = get_suggestions("", query);
- expected = [
- "-is:starred",
- ];
+ expected = ["-is:starred"];
assert.deepEqual(suggestions.strings, expected);
query = "st";
suggestions = get_suggestions("", query);
- expected = [
- "st",
- "streams:public",
- "is:starred",
- "stream:",
- ];
+ expected = ["st", "streams:public", "is:starred", "stream:"];
assert.deepEqual(suggestions.strings, expected);
query = "is:sta";
base_query = "stream:Denmark has:link";
suggestions = get_suggestions(base_query, query);
- expected = [
- "is:starred",
- ];
+ expected = ["is:starred"];
assert.deepEqual(suggestions.strings, expected);
});
@@ -714,91 +603,58 @@ run_test("sent_by_me_suggestions", () => {
let query = "";
let suggestions = get_suggestions("", query);
assert(suggestions.strings.includes("sender:[email protected]"));
- assert.equal(suggestions.lookup_table.get("sender:[email protected]").description,
- "Sent by me");
+ assert.equal(suggestions.lookup_table.get("sender:[email protected]").description, "Sent by me");
query = "sender";
suggestions = get_suggestions("", query);
- let expected = [
- "sender",
- "sender:[email protected]",
- "sender:",
- ];
+ let expected = ["sender", "sender:[email protected]", "sender:"];
assert.deepEqual(suggestions.strings, expected);
query = "-sender";
suggestions = get_suggestions("", query);
- expected = [
- "-sender",
- "-sender:[email protected]",
- "-sender:",
- ];
+ expected = ["-sender", "-sender:[email protected]", "-sender:"];
assert.deepEqual(suggestions.strings, expected);
query = "from";
suggestions = get_suggestions("", query);
- expected = [
- "from",
- "from:",
- ];
+ expected = ["from", "from:[email protected]", "from:"];
assert.deepEqual(suggestions.strings, expected);
query = "-from";
suggestions = get_suggestions("", query);
- expected = [
- "-from",
- "-from:",
- ];
+ expected = ["-from", "-from:[email protected]", "-from:"];
assert.deepEqual(suggestions.strings, expected);
query = "sender:[email protected]";
suggestions = get_suggestions("", query);
- expected = [
- "sender:[email protected]",
- ];
+ expected = ["sender:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "from:[email protected]";
suggestions = get_suggestions("", query);
- expected = [
- ];
+ expected = ["from:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "sent";
suggestions = get_suggestions("", query);
- expected = [
- "sent",
- "sender:[email protected]",
- ];
+ expected = ["sent", "sender:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "-sent";
suggestions = get_suggestions("", query);
- expected = [
- "-sent",
- "-sender:[email protected]",
- ];
+ expected = ["-sent", "-sender:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "sent";
let base_query = "stream:Denmark topic:Denmark1";
suggestions = get_suggestions(base_query, query);
- expected = [
- "sent",
- "sender:[email protected]",
- ];
+ expected = ["sent", "sender:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "sender:m";
base_query = "is:starred";
suggestions = get_suggestions(base_query, query);
- expected = [
- "sender:m",
- "sender:[email protected]",
- ];
+ expected = ["sender:m", "sender:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "sender:";
@@ -832,8 +688,10 @@ run_test("topic_suggestions", () => {
global.stream_data.get_stream_id = function (stream_name) {
switch (stream_name) {
- case "office": return office_id;
- case "devel": return devel_id;
+ case "office":
+ return office_id;
+ case "devel":
+ return devel_id;
}
};
@@ -877,50 +735,31 @@ run_test("topic_suggestions", () => {
assert.equal(describe("stream:office topic:team"), "Stream office &gt; team");
suggestions = get_suggestions("topic:staplers", "stream:office");
- expected = [
- "stream:office",
- ];
+ expected = ["stream:office"];
assert.deepEqual(suggestions.strings, expected);
suggestions = get_suggestions("stream:devel", "topic:");
- expected = [
- "topic:",
- "topic:REXX",
- ];
+ expected = ["topic:", "topic:REXX"];
assert.deepEqual(suggestions.strings, expected);
suggestions = get_suggestions("stream:devel", "-topic:");
- expected = [
- "-topic:",
- "-topic:REXX",
- ];
+ expected = ["-topic:", "-topic:REXX"];
assert.deepEqual(suggestions.strings, expected);
suggestions = get_suggestions("", "-topic:te");
- expected = [
- "-topic:te",
- "stream:office -topic:team",
- "stream:office -topic:test",
- ];
+ expected = ["-topic:te", "stream:office -topic:team", "stream:office -topic:test"];
assert.deepEqual(suggestions.strings, expected);
suggestions = get_suggestions("is:alerted stream:devel is:starred", "topic:");
- expected = [
- "topic:",
- "topic:REXX",
- ];
+ expected = ["topic:", "topic:REXX"];
assert.deepEqual(suggestions.strings, expected);
suggestions = get_suggestions("is:private stream:devel", "topic:");
- expected = [
- "topic:",
- ];
+ expected = ["topic:"];
assert.deepEqual(suggestions.strings, expected);
suggestions = get_suggestions("topic:REXX stream:devel", "topic:");
- expected = [
- "topic:",
- ];
+ expected = ["topic:"];
assert.deepEqual(suggestions.strings, expected);
});
@@ -939,9 +778,7 @@ run_test("whitespace_glitch", () => {
const suggestions = get_suggestions("", query);
- const expected = [
- "stream:office",
- ];
+ const expected = ["stream:office"];
assert.deepEqual(suggestions.strings, expected);
});
@@ -959,26 +796,17 @@ run_test("stream_completion", () => {
let query = "stream:of";
let suggestions = get_suggestions("", query);
- let expected = [
- "stream:of",
- "stream:office",
- ];
+ let expected = ["stream:of", "stream:office"];
assert.deepEqual(suggestions.strings, expected);
query = "-stream:of";
suggestions = get_suggestions("", query);
- expected = [
- "-stream:of",
- "-stream:office",
- ];
+ expected = ["-stream:of", "-stream:office"];
assert.deepEqual(suggestions.strings, expected);
query = "hel";
suggestions = get_suggestions("", query);
- expected = [
- "hel",
- "stream:dev+help",
- ];
+ expected = ["hel", "stream:dev+help"];
assert.deepEqual(suggestions.strings, expected);
});
@@ -1028,10 +856,14 @@ run_test("people_suggestions", () => {
const describe = (q) => suggestions.lookup_table.get(q).description;
- assert.equal(describe("pm-with:[email protected]"),
- "Private messages with <strong>Te</strong>d Smith &lt;<strong>te</strong>[email protected]&gt;");
- assert.equal(describe("sender:[email protected]"),
- "Sent by <strong>Te</strong>d Smith &lt;<strong>te</strong>[email protected]&gt;");
+ assert.equal(
+ describe("pm-with:[email protected]"),
+ "Private messages with <strong>Te</strong>d Smith &lt;<strong>te</strong>[email protected]&gt;",
+ );
+ assert.equal(
+ describe("sender:[email protected]"),
+ "Sent by <strong>Te</strong>d Smith &lt;<strong>te</strong>[email protected]&gt;",
+ );
suggestions = get_suggestions("", "Ted "); // note space
expected = [
@@ -1045,34 +877,25 @@ run_test("people_suggestions", () => {
query = "sender:ted sm";
let base_query = "";
- expected = [
- "sender:ted+sm",
- "sender:[email protected]",
- ];
+ expected = ["sender:ted+sm", "sender:[email protected]"];
suggestions = get_suggestions(base_query, query);
assert.deepEqual(suggestions.strings, expected);
query = "new";
base_query = "sender:[email protected]";
- expected = [
- "new",
- ];
+ expected = ["new"];
suggestions = get_suggestions(base_query, query);
assert.deepEqual(suggestions.strings, expected);
query = "sender:[email protected] new";
base_query = "";
- expected = [
- "sender:[email protected]+new",
- ];
+ expected = ["sender:[email protected]+new"];
suggestions = get_suggestions(base_query, query);
assert.deepEqual(suggestions.strings, expected);
query = "new";
base_query = "sender:[email protected]";
- expected = [
- "new",
- ];
+ expected = ["new"];
suggestions = get_suggestions(base_query, query);
assert.deepEqual(suggestions.strings, expected);
});
@@ -1098,58 +921,39 @@ run_test("people_suggestion (Admin only email visibility)", () => {
const describe = (q) => suggestions.lookup_table.get(q).description;
- assert.equal(describe("pm-with:[email protected]"),
- "Private messages with <strong>Te</strong>d Smith");
- assert.equal(describe("sender:[email protected]"),
- "Sent by <strong>Te</strong>d Smith");
+ assert.equal(
+ describe("pm-with:[email protected]"),
+ "Private messages with <strong>Te</strong>d Smith",
+ );
+ assert.equal(describe("sender:[email protected]"), "Sent by <strong>Te</strong>d Smith");
});
run_test("operator_suggestions", () => {
// Completed operator should return nothing
let query = "stream:";
let suggestions = get_suggestions("", query);
- let expected = [
- "stream:",
- ];
+ let expected = ["stream:"];
assert.deepEqual(suggestions.strings, expected);
query = "st";
suggestions = get_suggestions("", query);
- expected = [
- "st",
- "streams:public",
- "is:starred",
- "stream:",
- ];
+ expected = ["st", "streams:public", "is:starred", "stream:"];
assert.deepEqual(suggestions.strings, expected);
query = "group-";
suggestions = get_suggestions("", query);
- expected = [
- "group-",
- "group-pm-with:",
- ];
+ expected = ["group-", "group-pm-with:"];
assert.deepEqual(suggestions.strings, expected);
query = "-s";
suggestions = get_suggestions("", query);
- expected = [
- "-s",
- "-streams:public",
- "-sender:[email protected]",
- "-stream:",
- "-sender:",
- ];
+ expected = ["-s", "-streams:public", "-sender:[email protected]", "-stream:", "-sender:"];
assert.deepEqual(suggestions.strings, expected);
query = "-f";
const base_query = "stream:Denmark is:alerted";
suggestions = get_suggestions(base_query, query);
- expected = [
- "-f",
- "-from:",
- ];
+ expected = ["-f", "-from:[email protected]", "-from:"];
assert.deepEqual(suggestions.strings, expected);
});
@@ -1167,28 +971,19 @@ run_test("queries_with_spaces", () => {
// test allowing spaces with quotes surrounding operand
let query = 'stream:"dev he"';
let suggestions = get_suggestions("", query);
- let expected = [
- "stream:dev+he",
- "stream:dev+help",
- ];
+ let expected = ["stream:dev+he", "stream:dev+help"];
assert.deepEqual(suggestions.strings, expected);
// test mismatched quote
query = 'stream:"dev h';
suggestions = get_suggestions("", query);
- expected = [
- "stream:dev+h",
- "stream:dev+help",
- ];
+ expected = ["stream:dev+h", "stream:dev+help"];
assert.deepEqual(suggestions.strings, expected);
// test extra space after operator still works
query = "stream: offi";
suggestions = get_suggestions("", query);
- expected = [
- "stream:offi",
- "stream:office",
- ];
+ expected = ["stream:offi", "stream:office"];
assert.deepEqual(suggestions.strings, expected);
});
@@ -1210,8 +1005,6 @@ run_test("multiple_operators_without_pills", () => {
query = "abc is:alerted sender:[email protected]";
base_query = "";
suggestions = get_suggestions(base_query, query);
- expected = [
- "is:alerted sender:[email protected] abc",
- ];
+ expected = ["is:alerted sender:[email protected] abc"];
assert.deepEqual(suggestions.strings, expected);
});
diff --git a/frontend_tests/node_tests/search_suggestion_legacy.js b/frontend_tests/node_tests/search_suggestion_legacy.js
index d94a57568d7..e909ca9845f 100644
--- a/frontend_tests/node_tests/search_suggestion_legacy.js
+++ b/frontend_tests/node_tests/search_suggestion_legacy.js
@@ -36,22 +36,19 @@ const bob = {
user_id: 42,
};
-const ted =
-{
+const ted = {
user_id: 101,
full_name: "Ted Smith",
};
-const alice =
-{
+const alice = {
user_id: 102,
full_name: "Alice Ignore",
};
-const jeff =
-{
+const jeff = {
user_id: 103,
full_name: "Jeff Zoolipson",
@@ -92,9 +89,7 @@ run_test("basic_get_suggestions", () => {
const suggestions = get_suggestions("", query);
- const expected = [
- "fred",
- ];
+ const expected = ["fred"];
assert.deepEqual(suggestions.strings, expected);
});
@@ -155,92 +150,60 @@ run_test("private_suggestions", () => {
query = "pm-with:t";
suggestions = get_suggestions("", query);
- expected = [
- "pm-with:t",
- "pm-with:[email protected]",
- ];
+ expected = ["pm-with:t", "pm-with:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "-pm-with:t";
suggestions = get_suggestions("", query);
- expected = [
- "-pm-with:t",
- "is:private -pm-with:[email protected]",
- ];
+ expected = ["-pm-with:t", "is:private -pm-with:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "pm-with:[email protected]";
suggestions = get_suggestions("", query);
- expected = [
- "pm-with:[email protected]",
- ];
+ expected = ["pm-with:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "sender:ted";
suggestions = get_suggestions("", query);
- expected = [
- "sender:ted",
- "sender:[email protected]",
- ];
+ expected = ["sender:ted", "sender:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "sender:te";
suggestions = get_suggestions("", query);
- expected = [
- "sender:te",
- "sender:[email protected]",
- ];
+ expected = ["sender:te", "sender:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "-sender:te";
suggestions = get_suggestions("", query);
- expected = [
- "-sender:te",
- "-sender:[email protected]",
- ];
+ expected = ["-sender:te", "-sender:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "sender:[email protected]";
suggestions = get_suggestions("", query);
- expected = [
- "sender:[email protected]",
- ];
+ expected = ["sender:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "is:unread from:ted";
suggestions = get_suggestions("", query);
- expected = [
- "is:unread from:ted",
- "is:unread from:[email protected]",
- "is:unread",
- ];
+ expected = ["is:unread from:ted", "is:unread from:[email protected]", "is:unread"];
assert.deepEqual(suggestions.strings, expected);
// Users can enter bizarre queries, and if they do, we want to
// be conservative with suggestions.
query = "is:private near:3";
suggestions = get_suggestions("", query);
- expected = [
- "is:private near:3",
- "is:private",
- ];
+ expected = ["is:private near:3", "is:private"];
assert.deepEqual(suggestions.strings, expected);
query = "pm-with:[email protected] near:3";
suggestions = get_suggestions("", query);
- expected = [
- "pm-with:[email protected] near:3",
- "pm-with:[email protected]",
- ];
+ expected = ["pm-with:[email protected] near:3", "pm-with:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
// Make sure suggestions still work if preceding tokens
query = "is:alerted sender:[email protected]";
suggestions = get_suggestions("", query);
- expected = [
- "is:alerted sender:[email protected]",
- "is:alerted",
- ];
+ expected = ["is:alerted sender:[email protected]", "is:alerted"];
assert.deepEqual(suggestions.strings, expected);
query = "is:starred has:link is:private al";
@@ -260,18 +223,12 @@ run_test("private_suggestions", () => {
// Make sure it handles past context correctly
query = "stream:Denmark pm-with:";
suggestions = get_suggestions("", query);
- expected = [
- "stream:Denmark pm-with:",
- "stream:Denmark",
- ];
+ expected = ["stream:Denmark pm-with:", "stream:Denmark"];
assert.deepEqual(suggestions.strings, expected);
query = "sender:[email protected] sender:";
suggestions = get_suggestions("", query);
- expected = [
- "sender:[email protected] sender:",
- "sender:[email protected]",
- ];
+ expected = ["sender:[email protected] sender:", "sender:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
});
@@ -300,35 +257,25 @@ run_test("group_suggestions", () => {
// generate suggestions.
query = "pm-with:[email protected],t";
suggestions = get_suggestions("", query);
- expected = [
- "pm-with:[email protected],t",
- ];
+ expected = ["pm-with:[email protected],t", "pm-with:[email protected],[email protected]"];
assert.deepEqual(suggestions.strings, expected);
// Smit should also generate [email protected] (Ted Smith) as a suggestion.
query = "pm-with:[email protected],Smit";
suggestions = get_suggestions("", query);
- expected = [
- "pm-with:[email protected],Smit",
- ];
+ expected = ["pm-with:[email protected],Smit", "pm-with:[email protected],[email protected]"];
assert.deepEqual(suggestions.strings, expected);
// Do not suggest "[email protected]" (the name of the current user)
query = "pm-with:[email protected],my";
suggestions = get_suggestions("", query);
- expected = [
- "pm-with:[email protected],my",
- ];
+ expected = ["pm-with:[email protected],my"];
assert.deepEqual(suggestions.strings, expected);
// No superfluous suggestions should be generated.
query = "pm-with:[email protected],red";
suggestions = get_suggestions("", query);
- expected = [
- "pm-with:[email protected],red",
- ];
+ expected = ["pm-with:[email protected],red"];
assert.deepEqual(suggestions.strings, expected);
// is:private should be properly prepended to each suggestion if the pm-with
@@ -346,25 +293,17 @@ run_test("group_suggestions", () => {
query = "-pm-with:[email protected],t";
suggestions = get_suggestions("", query);
- expected = [
- "-pm-with:[email protected],t",
- "is:private -pm-with:[email protected],[email protected]",
- ];
+ expected = ["-pm-with:[email protected],t", "is:private -pm-with:[email protected],[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "-pm-with:[email protected],Smit";
suggestions = get_suggestions("", query);
- expected = [
- "-pm-with:[email protected],Smit",
- "is:private -pm-with:[email protected],[email protected]",
- ];
+ expected = ["-pm-with:[email protected],Smit", "is:private -pm-with:[email protected],[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "-pm-with:[email protected],red";
suggestions = get_suggestions("", query);
- expected = [
- "-pm-with:[email protected],red",
- ];
+ expected = ["-pm-with:[email protected],red"];
assert.deepEqual(suggestions.strings, expected);
// Test multiple operators
@@ -437,12 +376,8 @@ run_test("group_suggestions", () => {
query = "pm-with:[email protected],[email protected] hi";
suggestions = get_suggestions("", query);
- expected = [
- ];
assert.deepEqual(suggestions.strings, expected);
-
});
init();
@@ -504,12 +439,7 @@ run_test("has_suggestions", () => {
};
let suggestions = get_suggestions("", query);
- let expected = [
- "h",
- "has:link",
- "has:image",
- "has:attachment",
- ];
+ let expected = ["h", "has:link", "has:image", "has:attachment"];
assert.deepEqual(suggestions.strings, expected);
function describe(q) {
@@ -522,12 +452,7 @@ run_test("has_suggestions", () => {
query = "-h";
suggestions = get_suggestions("", query);
- expected = [
- "-h",
- "-has:link",
- "-has:image",
- "-has:attachment",
- ];
+ expected = ["-h", "-has:link", "-has:image", "-has:attachment"];
assert.deepEqual(suggestions.strings, expected);
assert.equal(describe("-has:link"), "Exclude messages with one or more link");
assert.equal(describe("-has:image"), "Exclude messages with one or more image");
@@ -537,33 +462,22 @@ run_test("has_suggestions", () => {
query = "has:";
suggestions = get_suggestions("", query);
- expected = [
- "has:link",
- "has:image",
- "has:attachment",
- ];
+ expected = ["has:link", "has:image", "has:attachment"];
assert.deepEqual(suggestions.strings, expected);
query = "has:im";
suggestions = get_suggestions("", query);
- expected = [
- "has:image",
- ];
+ expected = ["has:image"];
assert.deepEqual(suggestions.strings, expected);
query = "-has:im";
suggestions = get_suggestions("", query);
- expected = [
- "-has:image",
- ];
+ expected = ["-has:image"];
assert.deepEqual(suggestions.strings, expected);
query = "att";
suggestions = get_suggestions("", query);
- expected = [
- "att",
- "has:attachment",
- ];
+ expected = ["att", "has:attachment"];
assert.deepEqual(suggestions.strings, expected);
query = "stream:Denmark is:alerted has:lin";
@@ -612,14 +526,7 @@ run_test("check_is_suggestions", () => {
query = "-i";
suggestions = get_suggestions("", query);
- expected = [
- "-i",
- "-is:private",
- "-is:starred",
- "-is:mentioned",
- "-is:alerted",
- "-is:unread",
- ];
+ expected = ["-i", "-is:private", "-is:starred", "-is:mentioned", "-is:alerted", "-is:unread"];
assert.deepEqual(suggestions.strings, expected);
assert.equal(describe("-is:private"), "Exclude private messages");
@@ -632,46 +539,27 @@ run_test("check_is_suggestions", () => {
query = "is:";
suggestions = get_suggestions("", query);
- expected = [
- "is:private",
- "is:starred",
- "is:mentioned",
- "is:alerted",
- "is:unread",
- ];
+ expected = ["is:private", "is:starred", "is:mentioned", "is:alerted", "is:unread"];
assert.deepEqual(suggestions.strings, expected);
query = "is:st";
suggestions = get_suggestions("", query);
- expected = [
- "is:starred",
- ];
+ expected = ["is:starred"];
assert.deepEqual(suggestions.strings, expected);
query = "-is:st";
suggestions = get_suggestions("", query);
- expected = [
- "-is:starred",
- ];
+ expected = ["-is:starred"];
assert.deepEqual(suggestions.strings, expected);
query = "st";
suggestions = get_suggestions("", query);
- expected = [
- "st",
- "streams:public",
- "is:starred",
- "stream:",
- ];
+ expected = ["st", "streams:public", "is:starred", "stream:"];
assert.deepEqual(suggestions.strings, expected);
query = "stream:Denmark has:link is:sta";
suggestions = get_suggestions("", query);
- expected = [
- "stream:Denmark has:link is:starred",
- "stream:Denmark has:link",
- "stream:Denmark",
- ];
+ expected = ["stream:Denmark has:link is:starred", "stream:Denmark has:link", "stream:Denmark"];
assert.deepEqual(suggestions.strings, expected);
});
@@ -687,73 +575,46 @@ run_test("sent_by_me_suggestions", () => {
let query = "";
let suggestions = get_suggestions("", query);
assert(suggestions.strings.includes("sender:[email protected]"));
- assert.equal(suggestions.lookup_table.get("sender:[email protected]").description,
- "Sent by me");
+ assert.equal(suggestions.lookup_table.get("sender:[email protected]").description, "Sent by me");
query = "sender";
suggestions = get_suggestions("", query);
- let expected = [
- "sender",
- "sender:[email protected]",
- "sender:",
- ];
+ let expected = ["sender", "sender:[email protected]", "sender:"];
assert.deepEqual(suggestions.strings, expected);
query = "-sender";
suggestions = get_suggestions("", query);
- expected = [
- "-sender",
- "-sender:[email protected]",
- "-sender:",
- ];
+ expected = ["-sender", "-sender:[email protected]", "-sender:"];
assert.deepEqual(suggestions.strings, expected);
query = "from";
suggestions = get_suggestions("", query);
- expected = [
- "from",
- "from:",
- ];
+ expected = ["from", "from:[email protected]", "from:"];
assert.deepEqual(suggestions.strings, expected);
query = "-from";
suggestions = get_suggestions("", query);
- expected = [
- "-from",
- "-from:",
- ];
+ expected = ["-from", "-from:[email protected]", "-from:"];
assert.deepEqual(suggestions.strings, expected);
query = "sender:[email protected]";
suggestions = get_suggestions("", query);
- expected = [
- "sender:[email protected]",
- ];
+ expected = ["sender:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "from:[email protected]";
suggestions = get_suggestions("", query);
- expected = [
- ];
+ expected = ["from:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "sent";
suggestions = get_suggestions("", query);
- expected = [
- "sent",
- "sender:[email protected]",
- ];
+ expected = ["sent", "sender:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "-sent";
suggestions = get_suggestions("", query);
- expected = [
- "-sent",
- "-sender:[email protected]",
- ];
+ expected = ["-sent", "-sender:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
query = "stream:Denmark topic:Denmark1 sent";
@@ -768,19 +629,12 @@ run_test("sent_by_me_suggestions", () => {
query = "is:starred sender:m";
suggestions = get_suggestions("", query);
- expected = [
- "is:starred sender:m",
- "is:starred sender:[email protected]",
- "is:starred",
- ];
+ expected = ["is:starred sender:m", "is:starred sender:[email protected]", "is:starred"];
assert.deepEqual(suggestions.strings, expected);
query = "sender:[email protected] sender:";
suggestions = get_suggestions("", query);
- expected = [
- "sender:[email protected] sender:",
- "sender:[email protected]",
- ];
+ expected = ["sender:[email protected] sender:", "sender:[email protected]"];
assert.deepEqual(suggestions.strings, expected);
});
@@ -801,8 +655,10 @@ run_test("topic_suggestions", () => {
global.stream_data.get_stream_id = function (stream_name) {
switch (stream_name) {
- case "office": return office_id;
- case "devel": return devel_id;
+ case "office":
+ return office_id;
+ case "devel":
+ return devel_id;
}
};
@@ -846,34 +702,19 @@ run_test("topic_suggestions", () => {
assert.equal(describe("stream:office topic:team"), "Stream office &gt; team");
suggestions = get_suggestions("", "topic:staplers stream:office");
- expected = [
- "topic:staplers stream:office",
- "topic:staplers",
- ];
+ expected = ["topic:staplers stream:office", "topic:staplers"];
assert.deepEqual(suggestions.strings, expected);
suggestions = get_suggestions("", "stream:devel topic:");
- expected = [
- "stream:devel topic:",
- "stream:devel topic:REXX",
- "stream:devel",
- ];
+ expected = ["stream:devel topic:", "stream:devel topic:REXX", "stream:devel"];
assert.deepEqual(suggestions.strings, expected);
suggestions = get_suggestions("", "stream:devel -topic:");
- expected = [
- "stream:devel -topic:",
- "stream:devel -topic:REXX",
- "stream:devel",
- ];
+ expected = ["stream:devel -topic:", "stream:devel -topic:REXX", "stream:devel"];
assert.deepEqual(suggestions.strings, expected);
suggestions = get_suggestions("", "-topic:te");
- expected = [
- "-topic:te",
- "stream:office -topic:team",
- "stream:office -topic:test",
- ];
+ expected = ["-topic:te", "stream:office -topic:team", "stream:office -topic:test"];
assert.deepEqual(suggestions.strings, expected);
suggestions = get_suggestions("", "is:alerted stream:devel is:starred topic:");
@@ -887,19 +728,11 @@ run_test("topic_suggestions", () => {
assert.deepEqual(suggestions.strings, expected);
suggestions = get_suggestions("", "is:private stream:devel topic:");
- expected = [
- "is:private stream:devel topic:",
- "is:private stream:devel",
- "is:private",
- ];
+ expected = ["is:private stream:devel topic:", "is:private stream:devel", "is:private"];
assert.deepEqual(suggestions.strings, expected);
suggestions = get_suggestions("", "topic:REXX stream:devel topic:");
- expected = [
- "topic:REXX stream:devel topic:",
- "topic:REXX stream:devel",
- "topic:REXX",
- ];
+ expected = ["topic:REXX stream:devel topic:", "topic:REXX stream:devel", "topic:REXX"];
assert.deepEqual(suggestions.strings, expected);
});
@@ -918,9 +751,7 @@ run_test("whitespace_glitch", () => {
const suggestions = get_suggestions("", query);
- const expected = [
- "stream:office",
- ];
+ const expected = ["stream:office"];
assert.deepEqual(suggestions.strings, expected);
});
@@ -938,26 +769,17 @@ run_test("stream_completion", () => {
let query = "stream:of";
let suggestions = get_suggestions("", query);
- let expected = [
- "stream:of",
- "stream:office",
- ];
+ let expected = ["stream:of", "stream:office"];
assert.deepEqual(suggestions.strings, expected);
query = "-stream:of";
suggestions = get_suggestions("", query);
- expected = [
- "-stream:of",
- "-stream:office",
- ];
+ expected = ["-stream:of", "-stream:office"];
assert.deepEqual(suggestions.strings, expected);
query = "hel";
suggestions = get_suggestions("", query);
- expected = [
- "hel",
- "stream:dev+help",
- ];
+ expected = ["hel", "stream:dev+help"];
assert.deepEqual(suggestions.strings, expected);
});
@@ -993,7 +815,6 @@ run_test("people_suggestions", () => {
people.add_active_user(bob);
people.add_active_user(alice);
-
stream_topic_history.reset();
let suggestions = get_suggestions("", query);
@@ -1012,10 +833,14 @@ run_test("people_suggestions", () => {
function describe(q) {
return suggestions.lookup_table.get(q).description;
}
- assert.equal(describe("pm-with:[email protected]"),
- "Private messages with <strong>Te</strong>d Smith &lt;<strong>te</strong>[email protected]&gt;");
- assert.equal(describe("sender:[email protected]"),
- "Sent by <strong>Te</strong>d Smith &lt;<strong>te</strong>[email protected]&gt;");
+ assert.equal(
+ describe("pm-with:[email protected]"),
+ "Private messages with <strong>Te</strong>d Smith &lt;<strong>te</strong>[email protected]&gt;",
+ );
+ assert.equal(
+ describe("sender:[email protected]"),
+ "Sent by <strong>Te</strong>d Smith &lt;<strong>te</strong>[email protected]&gt;",
+ );
suggestions = get_suggestions("", "Ted "); // note space
@@ -1029,25 +854,17 @@ run_test("people_suggestions", () => {
assert.deepEqual(suggestions.strings, expected);
query = "sender:ted sm";
- expected = [
- "sender:ted+sm",
- "sender:[email protected]",
- ];
+ expected = ["sender:ted+sm", "sender:[email protected]"];
suggestions = get_suggestions("", query);
assert.deepEqual(suggestions.strings, expected);
query = "sender:[email protected] new";
- expected = [
- "sender:[email protected] new",
- "sender:[email protected]",
- ];
+ expected = ["sender:[email protected] new", "sender:[email protected]"];
suggestions = get_suggestions("", query);
assert.deepEqual(suggestions.strings, expected);
query = "sender:[email protected] new";
- expected = [
- "sender:[email protected]+new",
- ];
+ expected = ["sender:[email protected]+new"];
suggestions = get_suggestions("", query);
assert.deepEqual(suggestions.strings, expected);
});
@@ -1056,38 +873,22 @@ run_test("operator_suggestions", () => {
// Completed operator should return nothing
let query = "stream:";
let suggestions = get_suggestions("", query);
- let expected = [
- "stream:",
- ];
+ let expected = ["stream:"];
assert.deepEqual(suggestions.strings, expected);
query = "st";
suggestions = get_suggestions("", query);
- expected = [
- "st",
- "streams:public",
- "is:starred",
- "stream:",
- ];
+ expected = ["st", "streams:public", "is:starred", "stream:"];
assert.deepEqual(suggestions.strings, expected);
query = "group-";
suggestions = get_suggestions("", query);
- expected = [
- "group-",
- "group-pm-with:",
- ];
+ expected = ["group-", "group-pm-with:"];
assert.deepEqual(suggestions.strings, expected);
query = "-s";
suggestions = get_suggestions("", query);
- expected = [
- "-s",
- "-streams:public",
- "-sender:[email protected]",
- "-stream:",
- "-sender:",
- ];
+ expected = ["-s", "-streams:public", "-sender:[email protected]", "-stream:", "-sender:"];
assert.deepEqual(suggestions.strings, expected);
query = "stream:Denmark is:alerted -f";
@@ -1116,27 +917,18 @@ run_test("queries_with_spaces", () => {
// test allowing spaces with quotes surrounding operand
let query = 'stream:"dev he"';
let suggestions = get_suggestions("", query);
- let expected = [
- "stream:dev+he",
- "stream:dev+help",
- ];
+ let expected = ["stream:dev+he", "stream:dev+help"];
assert.deepEqual(suggestions.strings, expected);
// test mismatched quote
query = 'stream:"dev h';
suggestions = get_suggestions("", query);
- expected = [
- "stream:dev+h",
- "stream:dev+help",
- ];
+ expected = ["stream:dev+h", "stream:dev+help"];
assert.deepEqual(suggestions.strings, expected);
// test extra space after operator still works
query = "stream: offi";
suggestions = get_suggestions("", query);
- expected = [
- "stream:offi",
- "stream:office",
- ];
+ expected = ["stream:offi", "stream:office"];
assert.deepEqual(suggestions.strings, expected);
});
diff --git a/frontend_tests/node_tests/server_events.js b/frontend_tests/node_tests/server_events.js
index 3c81b64a31d..0b652385aad 100644
--- a/frontend_tests/node_tests/server_events.js
+++ b/frontend_tests/node_tests/server_events.js
@@ -12,11 +12,15 @@ zrequire("sent_messages");
set_global("channel", {});
set_global("home_msg_list", {
select_id: noop,
- selected_id: function () {return 1;},
+ selected_id: function () {
+ return 1;
+ },
});
set_global("page_params", {test_suite: false});
set_global("reload_state", {
- is_in_progress: function () {return false;},
+ is_in_progress: function () {
+ return false;
+ },
});
// we also directly write to pointer
@@ -29,8 +33,12 @@ set_global("echo", {
update_realm_filter_rules: noop,
});
set_global("ui_report", {
- hide_error: function () { return false; },
- show_error: function () { return false; },
+ hide_error: function () {
+ return false;
+ },
+ show_error: function () {
+ return false;
+ },
});
server_events.home_view_loaded();
diff --git a/frontend_tests/node_tests/settings_bots.js b/frontend_tests/node_tests/settings_bots.js
index 2d22a01b3d6..e0eff847db9 100644
--- a/frontend_tests/node_tests/settings_bots.js
+++ b/frontend_tests/node_tests/settings_bots.js
@@ -8,11 +8,14 @@ set_global("page_params", {
});
const bot_data_params = {
- realm_bots: [{api_key: "QadL788EkiottHmukyhHgePUFHREiu8b",
- email: "[email protected]",
- full_name: "Error bot",
- user_id: 1,
- services: []},
+ realm_bots: [
+ {
+ api_key: "QadL788EkiottHmukyhHgePUFHREiu8b",
+ email: "[email protected]",
+ full_name: "Error bot",
+ user_id: 1,
+ services: [],
+ },
],
};
@@ -33,11 +36,13 @@ bot_data.initialize(bot_data_params);
run_test("generate_zuliprc_uri", () => {
const uri = settings_bots.generate_zuliprc_uri(1);
- const expected = "data:application/octet-stream;charset=utf-8," + encodeURIComponent(
- "[api]\[email protected]\n" +
- "key=QadL788EkiottHmukyhHgePUFHREiu8b\n" +
- "site=https://chat.example.com\n",
- );
+ const expected =
+ "data:application/octet-stream;charset=utf-8," +
+ encodeURIComponent(
+ "[api]\[email protected]\n" +
+ "key=QadL788EkiottHmukyhHgePUFHREiu8b\n" +
+ "site=https://chat.example.com\n",
+ );
assert.equal(uri, expected);
});
@@ -45,9 +50,10 @@ run_test("generate_zuliprc_uri", () => {
run_test("generate_zuliprc_content", () => {
const bot_user = bot_data.get(1);
const content = settings_bots.generate_zuliprc_content(bot_user);
- const expected = "[api]\[email protected]\n" +
- "key=QadL788EkiottHmukyhHgePUFHREiu8b\n" +
- "site=https://chat.example.com\n";
+ const expected =
+ "[api]\[email protected]\n" +
+ "key=QadL788EkiottHmukyhHgePUFHREiu8b\n" +
+ "site=https://chat.example.com\n";
assert.equal(content, expected);
});
@@ -60,13 +66,16 @@ run_test("generate_botserverrc_content", () => {
const service = {
token: "abcd1234",
};
- const content = settings_bots.generate_botserverrc_content(user.email,
- user.api_key,
- service.token);
- const expected = "[]\[email protected]\n" +
- "key=nSlA0mUm7G42LP85lMv7syqFTzDE2q34\n" +
- "site=https://chat.example.com\n" +
- "token=abcd1234\n";
+ const content = settings_bots.generate_botserverrc_content(
+ user.email,
+ user.api_key,
+ service.token,
+ );
+ const expected =
+ "key=nSlA0mUm7G42LP85lMv7syqFTzDE2q34\n" +
+ "site=https://chat.example.com\n" +
+ "token=abcd1234\n";
assert.equal(content, expected);
});
diff --git a/frontend_tests/node_tests/settings_data.js b/frontend_tests/node_tests/settings_data.js
index cd513655531..bf04298ee20 100644
--- a/frontend_tests/node_tests/settings_data.js
+++ b/frontend_tests/node_tests/settings_data.js
@@ -18,22 +18,22 @@ const isaac = {
run_test("email_for_user_settings", () => {
const email = settings_data.email_for_user_settings;
- page_params.realm_email_address_visibility = settings_config.email_address_visibility_values
- .admins_only.code;
+ page_params.realm_email_address_visibility =
+ settings_config.email_address_visibility_values.admins_only.code;
assert.equal(email(isaac), undefined);
page_params.is_admin = true;
assert.equal(email(isaac), isaac.delivery_email);
- page_params.realm_email_address_visibility = settings_config.email_address_visibility_values
- .nobody.code;
+ page_params.realm_email_address_visibility =
+ settings_config.email_address_visibility_values.nobody.code;
assert.equal(email(isaac), undefined);
page_params.is_admin = false;
assert.equal(email(isaac), undefined);
- page_params.realm_email_address_visibility = settings_config.email_address_visibility_values
- .everyone.code;
+ page_params.realm_email_address_visibility =
+ settings_config.email_address_visibility_values.everyone.code;
assert.equal(email(isaac), isaac.email);
});
diff --git a/frontend_tests/node_tests/settings_muting.js b/frontend_tests/node_tests/settings_muting.js
index 5aff013e194..c0a980dd6b5 100644
--- a/frontend_tests/node_tests/settings_muting.js
+++ b/frontend_tests/node_tests/settings_muting.js
@@ -16,7 +16,6 @@ const frontend = {
stream_data.add_sub(frontend);
run_test("settings", () => {
-
muting.add_muted_topic(frontend.stream_id, "js", 1577836800);
let set_up_ui_called = false;
muting_ui.set_up_muted_topics_ui = function () {
@@ -28,7 +27,8 @@ run_test("settings", () => {
stream: frontend.name,
stream_id: frontend.stream_id,
topic: "js",
- }]);
+ },
+ ]);
set_up_ui_called = true;
};
diff --git a/frontend_tests/node_tests/settings_org.js b/frontend_tests/node_tests/settings_org.js
index 30e44a9ebfe..3a447c9f52a 100644
--- a/frontend_tests/node_tests/settings_org.js
+++ b/frontend_tests/node_tests/settings_org.js
@@ -90,10 +90,7 @@ run_test("unloaded", () => {
});
function simulate_realm_domains_table() {
- $("#realm_domains_table tbody").set_find_results(
- "tr",
- $.create("realm-tr-stub"),
- );
+ $("#realm_domains_table tbody").set_find_results("tr", $.create("realm-tr-stub"));
let appended;
$("#realm_domains_table tbody").append = function (html) {
@@ -147,24 +144,18 @@ function createSaveButtons(subsection) {
const stub_discard_button = $(`#org-discard-${subsection}`);
const stub_save_button_text = $(".icon-button-text");
stub_save_button_header.set_find_results(
- ".subsection-failed-status p", $("<failed status element>"),
+ ".subsection-failed-status p",
+ $("<failed status element>"),
);
stub_save_button.closest = () => stub_save_button_header;
- save_button_controls.set_find_results(
- ".save-button", stub_save_button,
- );
- stub_save_button.set_find_results(
- ".icon-button-text", stub_save_button_text,
- );
+ save_button_controls.set_find_results(".save-button", stub_save_button);
+ stub_save_button.set_find_results(".icon-button-text", stub_save_button_text);
+ stub_save_button_header.set_find_results(".save-button-controls", save_button_controls);
stub_save_button_header.set_find_results(
- ".save-button-controls", save_button_controls,
- );
- stub_save_button_header.set_find_results(
- ".subsection-changes-discard .button", $(`#org-discard-${subsection}`),
- );
- save_button_controls.set_find_results(
- ".discard-button", stub_discard_button,
+ ".subsection-changes-discard .button",
+ $(`#org-discard-${subsection}`),
);
+ save_button_controls.set_find_results(".discard-button", stub_discard_button);
const props = {};
props.hidden = false;
save_button_controls.fadeIn = () => {
@@ -187,14 +178,14 @@ function test_submit_settings_form(submit_form) {
Object.assign(page_params, {
realm_bot_creation_policy: settings_bots.bot_creation_policy_values.restricted.code,
realm_email_address_visibility:
- settings_config.email_address_visibility_values.admins_only.code,
+ settings_config.email_address_visibility_values.admins_only.code,
realm_add_emoji_by_admins_only: true,
realm_create_stream_by_admins_only: true,
realm_waiting_period_threshold: 1,
realm_default_language: '"es"',
realm_default_twenty_four_hour_time: false,
realm_invite_to_stream_policy:
- settings_config.invite_to_stream_policy_values.by_admins_only.code,
+ settings_config.invite_to_stream_policy_values.by_admins_only.code,
realm_create_stream_policy: settings_config.create_stream_policy_values.by_members.code,
});
@@ -362,9 +353,7 @@ function test_upload_realm_icon(upload_realm_logo_or_icon) {
},
};
- const file_input = [
- {files: ["image1.png", "image2.png"]},
- ];
+ const file_input = [{files: ["image1.png", "image2.png"]}];
let posted;
channel.post = function (req) {
@@ -411,8 +400,7 @@ function test_change_allow_subdomains(change_allow_subdomains) {
change_allow_subdomains.call(elem_obj, ev);
success_callback();
- assert.equal(info.val(),
- "translated: Update successful: Subdomains allowed for example.com");
+ assert.equal(info.val(), "translated: Update successful: Subdomains allowed for example.com");
error_callback({});
assert.equal(info.val(), "translated: Failed");
@@ -421,8 +409,10 @@ function test_change_allow_subdomains(change_allow_subdomains) {
elem_obj.prop("checked", allow);
change_allow_subdomains.call(elem_obj, ev);
success_callback();
- assert.equal(info.val(),
- "translated: Update successful: Subdomains no longer allowed for example.com");
+ assert.equal(
+ info.val(),
+ "translated: Update successful: Subdomains no longer allowed for example.com",
+ );
}
function test_extract_property_name() {
@@ -433,14 +423,15 @@ function test_extract_property_name() {
);
$("#id_realm_message_content_edit_limit_minutes_label").attr(
- "id", "id_realm_message_content_edit_limit_minutes_label");
+ "id",
+ "id_realm_message_content_edit_limit_minutes_label",
+ );
assert.equal(
settings_org.extract_property_name($("#id_realm_message_content_edit_limit_minutes_label")),
"realm_message_content_edit_limit_minutes_label",
);
- $("#id-realm-allow-message-deleting").attr(
- "id", "id-realm-allow-message-deleting");
+ $("#id-realm-allow-message-deleting").attr("id", "id-realm-allow-message-deleting");
assert.equal(
settings_org.extract_property_name($("#id-realm-allow-message-deleting")),
"realm_allow_message_deleting",
@@ -456,7 +447,10 @@ function test_sync_realm_settings() {
property_elem.attr("id", "id_realm_invalid_settings_property");
property_elem.length = 1;
- blueslip.expect("error", "Element refers to unknown property realm_invalid_settings_property");
+ blueslip.expect(
+ "error",
+ "Element refers to unknown property realm_invalid_settings_property",
+ );
settings_org.sync_realm_settings("invalid_settings_property");
}
@@ -472,8 +466,10 @@ function test_sync_realm_settings() {
page_params.realm_create_stream_policy = 3;
settings_org.sync_realm_settings("create_stream_policy");
- assert.equal($("#id_realm_create_stream_policy").val(),
- settings_config.create_stream_policy_values.by_full_members.code);
+ assert.equal(
+ $("#id_realm_create_stream_policy").val(),
+ settings_config.create_stream_policy_values.by_full_members.code,
+ );
}
{
@@ -488,8 +484,10 @@ function test_sync_realm_settings() {
page_params.realm_create_stream_policy = 1;
settings_org.sync_realm_settings("create_stream_policy");
- assert.equal($("#id_realm_create_stream_policy").val(),
- settings_config.create_stream_policy_values.by_members.code);
+ assert.equal(
+ $("#id_realm_create_stream_policy").val(),
+ settings_config.create_stream_policy_values.by_members.code,
+ );
}
{
@@ -504,8 +502,10 @@ function test_sync_realm_settings() {
page_params.realm_create_stream_policy = 2;
settings_org.sync_realm_settings("create_stream_policy");
- assert.equal($("#id_realm_create_stream_policy").val(),
- settings_config.create_stream_policy_values.by_admins_only.code);
+ assert.equal(
+ $("#id_realm_create_stream_policy").val(),
+ settings_config.create_stream_policy_values.by_admins_only.code,
+ );
}
{
@@ -520,8 +520,10 @@ function test_sync_realm_settings() {
page_params.realm_invite_to_stream_policy = 3;
settings_org.sync_realm_settings("invite_to_stream_policy");
- assert.equal($("#id_realm_invite_to_stream_policy").val(),
- settings_config.create_stream_policy_values.by_full_members.code);
+ assert.equal(
+ $("#id_realm_invite_to_stream_policy").val(),
+ settings_config.create_stream_policy_values.by_full_members.code,
+ );
}
{
@@ -536,8 +538,10 @@ function test_sync_realm_settings() {
page_params.realm_invite_to_stream_policy = 1;
settings_org.sync_realm_settings("invite_to_stream_policy");
- assert.equal($("#id_realm_invite_to_stream_policy").val(),
- settings_config.create_stream_policy_values.by_members.code);
+ assert.equal(
+ $("#id_realm_invite_to_stream_policy").val(),
+ settings_config.create_stream_policy_values.by_members.code,
+ );
}
{
@@ -552,8 +556,10 @@ function test_sync_realm_settings() {
page_params.realm_invite_to_stream_policy = 2;
settings_org.sync_realm_settings("invite_to_stream_policy");
- assert.equal($("#id_realm_invite_to_stream_policy").val(),
- settings_config.create_stream_policy_values.by_admins_only.code);
+ assert.equal(
+ $("#id_realm_invite_to_stream_policy").val(),
+ settings_config.create_stream_policy_values.by_admins_only.code,
+ );
}
{
@@ -631,11 +637,15 @@ function test_parse_time_limit() {
const elem = $("#id_realm_message_content_edit_limit_minutes");
const test_function = (value, expected_value = value) => {
elem.val(value);
- global.page_params.realm_message_content_edit_limit_seconds =
- settings_org.parse_time_limit(elem);
- assert.equal(expected_value,
- settings_org.get_realm_time_limits_in_minutes(
- "realm_message_content_edit_limit_seconds"));
+ global.page_params.realm_message_content_edit_limit_seconds = settings_org.parse_time_limit(
+ elem,
+ );
+ assert.equal(
+ expected_value,
+ settings_org.get_realm_time_limits_in_minutes(
+ "realm_message_content_edit_limit_seconds",
+ ),
+ );
};
test_function("0.01", "0");
@@ -671,18 +681,28 @@ function test_discard_changes_button(discard_changes) {
page_params.realm_message_content_delete_limit_seconds = 120;
const allow_edit_history = $("#id_realm_allow_edit_history").prop("checked", false);
- const allow_community_topic_editing = $("#id_realm_allow_community_topic_editing").prop("checked", true);
+ const allow_community_topic_editing = $("#id_realm_allow_community_topic_editing").prop(
+ "checked",
+ true,
+ );
const msg_edit_limit_setting = $("#id_realm_msg_edit_limit_setting").val("custom_limit");
- const message_content_edit_limit_minutes = $("#id_realm_message_content_edit_limit_minutes").val(130);
+ const message_content_edit_limit_minutes = $(
+ "#id_realm_message_content_edit_limit_minutes",
+ ).val(130);
const msg_delete_limit_setting = $("#id_realm_msg_delete_limit_setting").val("custom_limit");
- const message_content_delete_limit_minutes = $("#id_realm_message_content_delete_limit_minutes").val(130);
+ const message_content_delete_limit_minutes = $(
+ "#id_realm_message_content_delete_limit_minutes",
+ ).val(130);
allow_edit_history.attr("id", "id_realm_allow_edit_history");
msg_edit_limit_setting.attr("id", "id_realm_msg_edit_limit_setting");
msg_delete_limit_setting.attr("id", "id_realm_msg_delete_limit_setting");
allow_community_topic_editing.attr("id", "id_realm_allow_community_topic_editing");
message_content_edit_limit_minutes.attr("id", "id_realm_message_content_edit_limit_minutes");
- message_content_delete_limit_minutes.attr("id", "id_realm_message_content_delete_limit_minutes");
+ message_content_delete_limit_minutes.attr(
+ "id",
+ "id_realm_message_content_delete_limit_minutes",
+ );
const discard_button_parent = $(".org-subsection-parent");
discard_button_parent.find = () => [
@@ -770,11 +790,17 @@ run_test("set_up", () => {
render: noop,
update: noop,
});
- $("#id_realm_message_content_edit_limit_minutes").set_parent($.create("<stub edit limit parent>"));
- $("#id_realm_message_content_delete_limit_minutes").set_parent($.create("<stub delete limit parent>"));
+ $("#id_realm_message_content_edit_limit_minutes").set_parent(
+ $.create("<stub edit limit parent>"),
+ );
+ $("#id_realm_message_content_delete_limit_minutes").set_parent(
+ $.create("<stub delete limit parent>"),
+ );
$("#id_realm_message_retention_days").set_parent($.create("<stub retention period parent>"));
$("#id_realm_message_retention_setting").change = noop;
- $("#message_content_in_email_notifications_label").set_parent($.create("<stub in-content setting checkbox>"));
+ $("#message_content_in_email_notifications_label").set_parent(
+ $.create("<stub in-content setting checkbox>"),
+ );
$("#enable_digest_emails_label").set_parent($.create("<stub digest setting checkbox>"));
$("#id_realm_digest_weekday").set_parent($.create("<stub digest weekday setting dropdown>"));
$("#id_realm_msg_edit_limit_setting").change = noop;
@@ -915,8 +941,10 @@ run_test("misc", () => {
page_params.is_admin = false;
const stub_notification_disable_parent = $.create("<stub notification_disable parent");
- stub_notification_disable_parent.set_find_results(".dropdown_list_reset_button:not([disabled])",
- $.create("<disable link>"));
+ stub_notification_disable_parent.set_find_results(
+ ".dropdown_list_reset_button:not([disabled])",
+ $.create("<disable link>"),
+ );
page_params.realm_name_changes_disabled = false;
page_params.server_name_changes_disabled = false;
@@ -954,25 +982,37 @@ run_test("misc", () => {
page_params.server_avatar_changes_disabled = false;
settings_account.update_avatar_change_display();
assert.equal($("#user-avatar-upload-widget .image_upload_button").attr("disabled"), false);
- assert.equal($("#user-avatar-upload-widget .settings-page-delete-button .button").attr("disabled"), false);
+ assert.equal(
+ $("#user-avatar-upload-widget .settings-page-delete-button .button").attr("disabled"),
+ false,
+ );
page_params.realm_avatar_changes_disabled = true;
page_params.server_avatar_changes_disabled = false;
settings_account.update_avatar_change_display();
assert.equal($("#user-avatar-upload-widget .image_upload_button").attr("disabled"), "disabled");
- assert.equal($("#user-avatar-upload-widget .settings-page-delete-button .button").attr("disabled"), "disabled");
+ assert.equal(
+ $("#user-avatar-upload-widget .settings-page-delete-button .button").attr("disabled"),
+ "disabled",
+ );
page_params.realm_avatar_changes_disabled = false;
page_params.server_avatar_changes_disabled = true;
settings_account.update_avatar_change_display();
assert.equal($("#user-avatar-upload-widget .image_upload_button").attr("disabled"), "disabled");
- assert.equal($("#user-avatar-upload-widget .settings-page-delete-button .button").attr("disabled"), "disabled");
+ assert.equal(
+ $("#user-avatar-upload-widget .settings-page-delete-button .button").attr("disabled"),
+ "disabled",
+ );
page_params.realm_avatar_changes_disabled = true;
page_params.server_avatar_changes_disabled = true;
settings_account.update_avatar_change_display();
assert.equal($("#user-avatar-upload-widget .image_upload_button").attr("disabled"), "disabled");
- assert.equal($("#user-avatar-upload-widget .settings-page-delete-button .button").attr("disabled"), "disabled");
+ assert.equal(
+ $("#user-avatar-upload-widget .settings-page-delete-button .button").attr("disabled"),
+ "disabled",
+ );
// If organization admin, these UI elements are never disabled.
page_params.is_admin = true;
@@ -991,18 +1031,27 @@ run_test("misc", () => {
};
// Set stubs for dropdown_list_widget:
- const widget_settings = ["realm_notifications_stream_id",
- "realm_signup_notifications_stream_id",
- "realm_default_code_block_language"];
+ const widget_settings = [
+ "realm_notifications_stream_id",
+ "realm_signup_notifications_stream_id",
+ "realm_default_code_block_language",
+ ];
const dropdown_list_parent = $.create("<list parent>");
- dropdown_list_parent.set_find_results(".dropdown_list_reset_button:not([disabled])", $.create("<disable button>"));
+ dropdown_list_parent.set_find_results(
+ ".dropdown_list_reset_button:not([disabled])",
+ $.create("<disable button>"),
+ );
widget_settings.forEach((name) => {
const elem = $.create(`#${name}_widget #${name}_name`);
elem.closest = () => dropdown_list_parent;
});
// We do not define any settings we need in page_params yet, but we don't need to for this test.
- blueslip.expect("warn", "dropdown-list-widget: Called without a default value; using null value", 3);
+ blueslip.expect(
+ "warn",
+ "dropdown-list-widget: Called without a default value; using null value",
+ 3,
+ );
settings_org.init_dropdown_widgets();
let setting_name = "realm_notifications_stream_id";
@@ -1040,5 +1089,4 @@ run_test("misc", () => {
settings_org.signup_notifications_stream_widget.render(undefined);
assert.equal(elem.text(), "translated: Disabled");
assert(elem.hasClass("text-warning"));
-
});
diff --git a/frontend_tests/node_tests/settings_profile_fields.js b/frontend_tests/node_tests/settings_profile_fields.js
index 152467d1694..56db51ff4d0 100644
--- a/frontend_tests/node_tests/settings_profile_fields.js
+++ b/frontend_tests/node_tests/settings_profile_fields.js
@@ -118,8 +118,7 @@ run_test("populate_profile_fields", () => {
is_external_account_field: false,
},
can_modify: true,
- realm_default_external_accounts:
- page_params.realm_default_external_accounts,
+ realm_default_external_accounts: page_params.realm_default_external_accounts,
},
{
profile_field: {
@@ -135,8 +134,7 @@ run_test("populate_profile_fields", () => {
is_external_account_field: false,
},
can_modify: true,
- realm_default_external_accounts:
- page_params.realm_default_external_accounts,
+ realm_default_external_accounts: page_params.realm_default_external_accounts,
},
{
profile_field: {
@@ -149,8 +147,7 @@ run_test("populate_profile_fields", () => {
is_external_account_field: true,
},
can_modify: true,
- realm_default_external_accounts:
- page_params.realm_default_external_accounts,
+ realm_default_external_accounts: page_params.realm_default_external_accounts,
},
{
profile_field: {
@@ -163,8 +160,7 @@ run_test("populate_profile_fields", () => {
is_external_account_field: true,
},
can_modify: true,
- realm_default_external_accounts:
- page_params.realm_default_external_accounts,
+ realm_default_external_accounts: page_params.realm_default_external_accounts,
},
];
diff --git a/frontend_tests/node_tests/settings_user_groups.js b/frontend_tests/node_tests/settings_user_groups.js
index 16bb2c2e8d3..b6772453421 100644
--- a/frontend_tests/node_tests/settings_user_groups.js
+++ b/frontend_tests/node_tests/settings_user_groups.js
@@ -79,7 +79,6 @@ run_test("can_edit", () => {
return true;
};
assert(settings_user_groups.can_edit(1));
-
});
const user_group_selector = "#user-groups #1";
@@ -300,8 +299,7 @@ run_test("populate_user_groups", () => {
if (user_email === bob.email) {
return bob;
}
- assert.equal(user_email,
- "Expected user email to be of Alice or Iago here.");
+ assert.equal(user_email, "Expected user email to be of Alice or Iago here.");
};
pills.onPillCreate = function (handler) {
assert.equal(typeof handler, "function");
@@ -342,12 +340,17 @@ run_test("populate_user_groups", () => {
test_create_item(create_item_handler);
// Tests for settings_user_groups.set_up workflow.
- assert.equal(typeof $(".organization form.admin-user-group-form").get_on_handler("submit"), "function");
+ assert.equal(
+ typeof $(".organization form.admin-user-group-form").get_on_handler("submit"),
+ "function",
+ );
assert.equal(typeof $("#user-groups").get_on_handler("click", ".delete"), "function");
- assert.equal(typeof $("#user-groups").get_on_handler("keypress", ".user-group h4 > span"), "function");
+ assert.equal(
+ typeof $("#user-groups").get_on_handler("keypress", ".user-group h4 > span"),
+ "function",
+ );
});
run_test("with_external_user", () => {
-
const realm_user_group = {
id: 1,
name: "Mobile",
@@ -530,7 +533,6 @@ run_test("reset", () => {
});
run_test("on_events", () => {
-
settings_user_groups.can_edit = function () {
return true;
};
@@ -542,13 +544,16 @@ run_test("on_events", () => {
preventDefault: noop,
};
const fake_this = $.create("fake-form.admin-user-group-form");
- const fake_object_array = [{
- name: "fake-name",
- value: "",
- }, {
- name: "fake-name",
- value: "fake-value",
- }];
+ const fake_object_array = [
+ {
+ name: "fake-name",
+ value: "",
+ },
+ {
+ name: "fake-name",
+ value: "fake-value",
+ },
+ ];
fake_this.serializeArray = function () {
return fake_object_array;
};
@@ -656,8 +661,10 @@ run_test("on_events", () => {
// Any of the blur_exceptions trigger blur event.
for (const class_name of blur_event_classes) {
const handler = $(user_group_selector).get_on_handler("blur", class_name);
- const blur_exceptions = _.without([".pill-container", ".name", ".description", ".input", ".delete"],
- class_name);
+ const blur_exceptions = _.without(
+ [".pill-container", ".name", ".description", ".input", ".delete"],
+ class_name,
+ );
for (const blur_exception of blur_exceptions) {
api_endpoint_called = false;
@@ -688,7 +695,10 @@ run_test("on_events", () => {
};
api_endpoint_called = false;
fake_this.closest = function (class_name) {
- if (class_name === ".save-status.btn-danger" || class_name === user_group_selector) {
+ if (
+ class_name === ".save-status.btn-danger" ||
+ class_name === user_group_selector
+ ) {
return [1];
}
return [];
@@ -710,7 +720,8 @@ run_test("on_events", () => {
const group_data = {
name: "translated: mobile",
description: "translated: All mobile members",
- members: new Set([2, 31])};
+ members: new Set([2, 31]),
+ };
user_groups.get_user_group_from_id = function () {
return group_data;
};
diff --git a/frontend_tests/node_tests/stream_data.js b/frontend_tests/node_tests/stream_data.js
index 12ecec876d0..532a5d2351c 100644
--- a/frontend_tests/node_tests/stream_data.js
+++ b/frontend_tests/node_tests/stream_data.js
@@ -4,8 +4,7 @@ set_global("page_params", {
is_guest: false,
});
-set_global("$", () => {
-});
+set_global("$", () => {});
set_global("document", null);
global.stub_out_jquery();
@@ -194,15 +193,12 @@ run_test("subscribers", () => {
return users.map((u) => u.user_id).sort();
}
- assert.deepEqual(
- potential_subscriber_ids(),
- [
- me.user_id,
- fred.user_id,
- not_fred.user_id,
- george.user_id,
- ],
- );
+ assert.deepEqual(potential_subscriber_ids(), [
+ me.user_id,
+ fred.user_id,
+ not_fred.user_id,
+ george.user_id,
+ ]);
stream_data.set_subscribers(sub, [me.user_id, fred.user_id, george.user_id]);
stream_data.update_calculated_fields(sub);
@@ -211,12 +207,7 @@ run_test("subscribers", () => {
assert(stream_data.is_user_subscribed(sub.stream_id, george.user_id));
assert(!stream_data.is_user_subscribed(sub.stream_id, not_fred.user_id));
- assert.deepEqual(
- potential_subscriber_ids(),
- [
- not_fred.user_id,
- ],
- );
+ assert.deepEqual(potential_subscriber_ids(), [not_fred.user_id]);
stream_data.set_subscribers(sub, []);
@@ -261,7 +252,10 @@ run_test("subscribers", () => {
// Verify noop for bad stream when removing subscriber
const bad_stream_id = 999999;
- blueslip.expect("warn", "We got a remove_subscriber call for a non-existent stream " + bad_stream_id);
+ blueslip.expect(
+ "warn",
+ "We got a remove_subscriber call for a non-existent stream " + bad_stream_id,
+ );
ok = stream_data.remove_subscriber(bad_stream_id, brutus.user_id);
assert(!ok);
@@ -295,7 +289,9 @@ run_test("subscribers", () => {
blueslip.expect(
"warn",
- "We got a is_user_subscribed call for a non-existent or inaccessible stream.", 2);
+ "We got a is_user_subscribed call for a non-existent or inaccessible stream.",
+ 2,
+ );
sub.invite_only = true;
stream_data.update_calculated_fields(sub);
assert.equal(stream_data.is_user_subscribed(sub.stream_id, brutus.user_id), undefined);
@@ -303,9 +299,7 @@ run_test("subscribers", () => {
assert.equal(stream_data.is_user_subscribed(sub.stream_id, brutus.user_id), undefined);
// Verify that we don't crash and return false for a bad stream.
- blueslip.expect(
- "warn",
- "We got an add_subscriber call for a non-existent stream.");
+ blueslip.expect("warn", "We got an add_subscriber call for a non-existent stream.");
ok = stream_data.add_subscriber(9999999, brutus.user_id);
assert(!ok);
@@ -380,8 +374,7 @@ run_test("is_active", () => {
assert(stream_data.is_active(sub));
- page_params.demote_inactive_streams =
- settings_config.demote_inactive_streams_values.never.code;
+ page_params.demote_inactive_streams = settings_config.demote_inactive_streams_values.never.code;
stream_data.set_filter_out_inactives();
sub = {name: "pets", subscribed: false, stream_id: 111};
@@ -499,8 +492,10 @@ run_test("stream_settings", () => {
assert.equal(sub_rows[2].invite_only, false);
assert.equal(sub_rows[0].history_public_to_subscribers, true);
- assert.equal(sub_rows[0].stream_post_policy ===
- stream_data.stream_post_policy_values.admins.code, true);
+ assert.equal(
+ sub_rows[0].stream_post_policy === stream_data.stream_post_policy_values.admins.code,
+ true,
+ );
assert.equal(sub_rows[0].message_retention_days, 10);
const sub = stream_data.get_sub("a");
@@ -513,8 +508,7 @@ run_test("stream_settings", () => {
stream_data.update_calculated_fields(sub);
assert.equal(sub.invite_only, false);
assert.equal(sub.history_public_to_subscribers, false);
- assert.equal(sub.stream_post_policy,
- stream_data.stream_post_policy_values.everyone.code);
+ assert.equal(sub.stream_post_policy, stream_data.stream_post_policy_values.everyone.code);
assert.equal(sub.message_retention_days, -1);
// For guest user only retrieve subscribed streams
@@ -565,13 +559,7 @@ run_test("default_stream_names", () => {
assert.deepEqual(names.sort(), ["private", "public"]);
const default_stream_ids = stream_data.get_default_stream_ids();
- assert.deepEqual(
- default_stream_ids.sort(),
- [
- announce.stream_id,
- general.stream_id,
- ],
- );
+ assert.deepEqual(default_stream_ids.sort(), [announce.stream_id, general.stream_id]);
});
run_test("delete_sub", () => {
@@ -838,10 +826,7 @@ run_test("remove_default_stream", () => {
});
run_test("canonicalized_name", () => {
- assert.deepStrictEqual(
- stream_data.canonicalized_name("Stream_Bar"),
- "stream_bar",
- );
+ assert.deepStrictEqual(stream_data.canonicalized_name("Stream_Bar"), "stream_bar");
});
run_test("create_sub", () => {
@@ -875,9 +860,12 @@ run_test("create_sub", () => {
// make sure sub doesn't get created twice
assert.equal(india_sub, new_sub);
- assert.throws(() => {
- stream_data.create_sub_from_server_data("Canada", canada);
- }, {message: "We cannot create a sub without a stream_id"});
+ assert.throws(
+ () => {
+ stream_data.create_sub_from_server_data("Canada", canada);
+ },
+ {message: "We cannot create a sub without a stream_id"},
+ );
const antarctica_sub = stream_data.create_sub_from_server_data(antarctica);
assert(antarctica_sub);
@@ -888,24 +876,29 @@ run_test("initialize", () => {
function get_params() {
const params = {};
- params.subscriptions = [{
- name: "subscriptions",
- stream_id: 2001,
- }];
-
- params.unsubscribed = [{
- name: "unsubscribed",
- stream_id: 2002,
- }];
+ params.subscriptions = [
+ {
+ name: "subscriptions",
+ stream_id: 2001,
+ },
+ ];
- params.never_subscribed = [{
- name: "never_subscribed",
- stream_id: 2003,
- }];
+ params.unsubscribed = [
+ {
+ name: "unsubscribed",
+ stream_id: 2002,
+ },
+ ];
- params.realm_default_streams = [
+ params.never_subscribed = [
+ {
+ name: "never_subscribed",
+ stream_id: 2003,
+ },
];
+ params.realm_default_streams = [];
+
return params;
}
@@ -1000,10 +993,7 @@ run_test("is_subscriber_subset", () => {
];
for (const row of matrix) {
- assert.equal(
- stream_data.is_subscriber_subset(row[0], row[1]),
- row[2],
- );
+ assert.equal(stream_data.is_subscriber_subset(row[0], row[1]), row[2]);
}
});
@@ -1030,12 +1020,14 @@ run_test("get_invite_stream_data", () => {
stream_data.add_sub(orie);
stream_data.set_realm_default_streams([orie]);
- const expected_list = [{
- name: "Orie",
- stream_id: 320,
- invite_only: false,
- default_stream: true,
- }];
+ const expected_list = [
+ {
+ name: "Orie",
+ stream_id: 320,
+ invite_only: false,
+ default_stream: true,
+ },
+ ];
assert.deepEqual(stream_data.get_invite_stream_data(), expected_list);
const inviter = {
diff --git a/frontend_tests/node_tests/stream_events.js b/frontend_tests/node_tests/stream_events.js
index 8d019f0f843..674912ab909 100644
--- a/frontend_tests/node_tests/stream_events.js
+++ b/frontend_tests/node_tests/stream_events.js
@@ -1,5 +1,7 @@
const noop = function () {};
-const return_true = function () { return true; };
+const return_true = function () {
+ return true;
+};
set_global("$", global.make_zjquery());
const _settings_notifications = {
update_page: () => {},
@@ -33,10 +35,7 @@ const frontend = {
stream_data.add_sub(frontend);
-
-const frontend_filter_terms = [
- {operator: "stream", operand: "frontend"},
-];
+const frontend_filter_terms = [{operator: "stream", operand: "frontend"}];
const frontend_filter = new Filter(frontend_filter_terms);
@@ -122,7 +121,9 @@ run_test("update_property", () => {
with_overrides((override) => {
global.with_stub((stub) => {
override("subs.update_stream_description", stub.f);
- stream_events.update_property(1, "description", "we write code", {rendered_description: "we write code"});
+ stream_events.update_property(1, "description", "we write code", {
+ rendered_description: "we write code",
+ });
const args = stub.get_args("sub", "val");
assert.equal(args.sub.stream_id, 1);
assert.equal(args.val, "we write code");
@@ -161,7 +162,11 @@ run_test("update_property", () => {
with_overrides((override) => {
global.with_stub((stub) => {
override("subs.update_stream_post_policy", stub.f);
- stream_events.update_property(1, "stream_post_policy", stream_data.stream_post_policy_values.admins.code);
+ stream_events.update_property(
+ 1,
+ "stream_post_policy",
+ stream_data.stream_post_policy_values.admins.code,
+ );
const args = stub.get_args("sub", "val");
assert.equal(args.sub.stream_id, 1);
assert.equal(args.val, stream_data.stream_post_policy_values.admins.code);
@@ -205,7 +210,9 @@ run_test("marked_subscribed", () => {
set_global("message_list", {
all: {
- all_messages: function () { return ["msg"]; },
+ all_messages: function () {
+ return ["msg"];
+ },
},
});
diff --git a/frontend_tests/node_tests/stream_list.js b/frontend_tests/node_tests/stream_list.js
index 66861cfd0e2..08c76fffaad 100644
--- a/frontend_tests/node_tests/stream_list.js
+++ b/frontend_tests/node_tests/stream_list.js
@@ -22,8 +22,12 @@ set_global("page_params", {
stream_color.initialize();
const noop = function () {};
-const return_false = function () { return false; };
-const return_true = function () { return true; };
+const return_false = function () {
+ return false;
+};
+const return_true = function () {
+ return true;
+};
set_global("topic_list", {});
set_global("overlays", {});
@@ -379,7 +383,9 @@ run_test("narrowing", () => {
initialize_stream_data();
set_global("narrow_state", {
- stream: function () { return "devel"; },
+ stream: function () {
+ return "devel";
+ },
topic: noop,
});
@@ -399,9 +405,7 @@ run_test("narrowing", () => {
let filter;
- filter = new Filter([
- {operator: "stream", operand: "devel"},
- ]);
+ filter = new Filter([{operator: "stream", operand: "devel"}]);
stream_list.handle_narrow_activated(filter);
assert($("<devel sidebar row html>").hasClass("active-filter"));
@@ -413,9 +417,7 @@ run_test("narrowing", () => {
assert(!$("ul.filters li").hasClass("active-filter"));
assert(!$("<cars sidebar row html>").hasClass("active-filter")); // false because of topic
- filter = new Filter([
- {operator: "stream", operand: "cars"},
- ]);
+ filter = new Filter([{operator: "stream", operand: "cars"}]);
stream_list.handle_narrow_activated(filter);
assert(!$("ul.filters li").hasClass("active-filter"));
assert($("<cars sidebar row html>").hasClass("active-filter"));
@@ -436,7 +438,7 @@ run_test("narrowing", () => {
});
run_test("focusout_user_filter", () => {
- const e = { };
+ const e = {};
const click_handler = $(".stream-list-filter").get_on_handler("focusout");
click_handler(e);
});
@@ -504,7 +506,6 @@ run_test("sort_streams", () => {
});
run_test("separators_only_pinned_and_dormant", () => {
-
// Test only pinned and dormant streams
stream_data.clear_subscriptions();
@@ -562,11 +563,9 @@ run_test("separators_only_pinned_and_dormant", () => {
];
assert.deepEqual(appended_elems, expected_elems);
-
});
run_test("separators_only_pinned", () => {
-
// Test only pinned streams
stream_data.clear_subscriptions();
@@ -608,7 +607,6 @@ run_test("separators_only_pinned", () => {
];
assert.deepEqual(appended_elems, expected_elems);
-
});
run_test("update_count_in_dom", () => {
@@ -622,11 +620,7 @@ run_test("update_count_in_dom", () => {
return elem;
}
- const stream_li = make_elem(
- $("<stream li>"),
- "<stream-count>",
- "<stream-value>",
- );
+ const stream_li = make_elem($("<stream li>"), "<stream-count>", "<stream-value>");
$("<stream li>").length = 0;
stream_li.addClass("subscription_block");
@@ -637,7 +631,9 @@ run_test("update_count_in_dom", () => {
const stream_id = 11;
const stream_row = {
- get_li: function () { return stream_li; },
+ get_li: function () {
+ return stream_li;
+ },
};
stream_list.stream_sidebar.set_row(stream_id, stream_row);
diff --git a/frontend_tests/node_tests/stream_search.js b/frontend_tests/node_tests/stream_search.js
index e107abd47d3..0761b1eec30 100644
--- a/frontend_tests/node_tests/stream_search.js
+++ b/frontend_tests/node_tests/stream_search.js
@@ -164,7 +164,6 @@ run_test("basics", () => {
input.val("");
stream_list.escape_search();
verify_collapsed();
-
});
run_test("expanding_sidebar", () => {
@@ -180,8 +179,5 @@ run_test("expanding_sidebar", () => {
stream_list.initiate_search();
- assert.deepEqual(events, [
- "popovers.hide_all",
- "stream_popover.show_streamlist_sidebar",
- ]);
+ assert.deepEqual(events, ["popovers.hide_all", "stream_popover.show_streamlist_sidebar"]);
});
diff --git a/frontend_tests/node_tests/stream_sort.js b/frontend_tests/node_tests/stream_sort.js
index 4a8463f5820..feb73275e16 100644
--- a/frontend_tests/node_tests/stream_sort.js
+++ b/frontend_tests/node_tests/stream_sort.js
@@ -1,4 +1,3 @@
-
zrequire("stream_data");
zrequire("stream_sort");
const with_overrides = global.with_overrides;
diff --git a/frontend_tests/node_tests/stream_topic_history.js b/frontend_tests/node_tests/stream_topic_history.js
index c82230cf42f..67b3795879c 100644
--- a/frontend_tests/node_tests/stream_topic_history.js
+++ b/frontend_tests/node_tests/stream_topic_history.js
@@ -1,4 +1,3 @@
-
zrequire("unread");
zrequire("stream_data");
zrequire("stream_topic_history");
@@ -95,26 +94,20 @@ run_test("is_complete_for_stream_id", () => {
first: () => ({id: 5}),
};
- assert.equal(
- stream_topic_history.is_complete_for_stream_id(sub.stream_id),
- true);
+ assert.equal(stream_topic_history.is_complete_for_stream_id(sub.stream_id), true);
// Now simulate a more recent message id.
message_list.all.first = () => ({id: sub.first_message_id + 1});
// Note that we'll return `true` here due to
// fetched_stream_ids having the stream_id now.
- assert.equal(
- stream_topic_history.is_complete_for_stream_id(sub.stream_id),
- true);
+ assert.equal(stream_topic_history.is_complete_for_stream_id(sub.stream_id), true);
// But now clear the data to see what we'd have without
// the previous call.
stream_topic_history.reset();
- assert.equal(
- stream_topic_history.is_complete_for_stream_id(sub.stream_id),
- false);
+ assert.equal(stream_topic_history.is_complete_for_stream_id(sub.stream_id), false);
});
run_test("server_history", () => {
@@ -127,9 +120,7 @@ run_test("server_history", () => {
message_list.all.data.fetch_status.has_found_newest = () => false;
- assert.equal(
- stream_topic_history.is_complete_for_stream_id(stream_id),
- false);
+ assert.equal(stream_topic_history.is_complete_for_stream_id(stream_id), false);
stream_topic_history.add_message({
stream_id: stream_id,
@@ -149,9 +140,7 @@ run_test("server_history", () => {
// Since we added history, now subsequent calls
// to is_complete_for_stream_id will return true.
- assert.equal(
- stream_topic_history.is_complete_for_stream_id(stream_id),
- true);
+ assert.equal(stream_topic_history.is_complete_for_stream_id(stream_id), true);
let history = stream_topic_history.get_recent_topic_names(stream_id);
assert.deepEqual(history, ["local", "hist2", "hist1"]);
@@ -302,5 +291,4 @@ run_test("server_history_end_to_end", () => {
on_success_called = true;
});
assert(on_success_called);
-
});
diff --git a/frontend_tests/node_tests/subs.js b/frontend_tests/node_tests/subs.js
index 460a05b9380..d92e46c7695 100644
--- a/frontend_tests/node_tests/subs.js
+++ b/frontend_tests/node_tests/subs.js
@@ -100,7 +100,10 @@ run_test("filter_table", () => {
sub_stubs.push(sub_row);
$(sub_row).attr("data-stream-id", data.stream_id);
- $(sub_row).set_find_results('.sub-info-box [class$="-bar"] [class$="-count"]', $(".tooltip"));
+ $(sub_row).set_find_results(
+ '.sub-info-box [class$="-bar"] [class$="-count"]',
+ $(".tooltip"),
+ );
$(sub_row).detach = function () {
return sub_row;
};
diff --git a/frontend_tests/node_tests/support.js b/frontend_tests/node_tests/support.js
index 8f4cb119c5e..636f9299fb6 100644
--- a/frontend_tests/node_tests/support.js
+++ b/frontend_tests/node_tests/support.js
@@ -5,7 +5,9 @@ const dom = new JSDOM(template, {pretendToBeVisual: true});
const document = dom.window.document;
let jquery_init;
-global.$ = (f) => {jquery_init = f;};
+global.$ = (f) => {
+ jquery_init = f;
+};
zrequire("support", "js/analytics/support");
set_global("$", global.make_zjquery());
diff --git a/frontend_tests/node_tests/timerender.js b/frontend_tests/node_tests/timerender.js
index 11ee2b38017..2c94452acf6 100644
--- a/frontend_tests/node_tests/timerender.js
+++ b/frontend_tests/node_tests/timerender.js
@@ -244,51 +244,36 @@ run_test("last_seen_status_from_date", () => {
assert.equal(actual_status, expected_status);
}
- assert_same((d) => d.addSeconds(-20),
- i18n.t("Just now"));
+ assert_same((d) => d.addSeconds(-20), i18n.t("Just now"));
- assert_same((d) => d.addMinutes(-1),
- i18n.t("Just now"));
+ assert_same((d) => d.addMinutes(-1), i18n.t("Just now"));
- assert_same((d) => d.addMinutes(-2),
- i18n.t("Just now"));
+ assert_same((d) => d.addMinutes(-2), i18n.t("Just now"));
- assert_same((d) => d.addMinutes(-30),
- i18n.t("30 minutes ago"));
+ assert_same((d) => d.addMinutes(-30), i18n.t("30 minutes ago"));
- assert_same((d) => d.addHours(-1),
- i18n.t("An hour ago"));
+ assert_same((d) => d.addHours(-1), i18n.t("An hour ago"));
- assert_same((d) => d.addHours(-2),
- i18n.t("2 hours ago"));
+ assert_same((d) => d.addHours(-2), i18n.t("2 hours ago"));
- assert_same((d) => d.addHours(-20),
- i18n.t("20 hours ago"));
+ assert_same((d) => d.addHours(-20), i18n.t("20 hours ago"));
- assert_same((d) => d.addDays(-1),
- i18n.t("Yesterday"));
+ assert_same((d) => d.addDays(-1), i18n.t("Yesterday"));
- assert_same((d) => d.addDays(-2),
- i18n.t("2 days ago"));
+ assert_same((d) => d.addDays(-2), i18n.t("2 days ago"));
- assert_same((d) => d.addDays(-61),
- i18n.t("61 days ago"));
+ assert_same((d) => d.addDays(-61), i18n.t("61 days ago"));
- assert_same((d) => d.addDays(-300),
- i18n.t("May 06,\xa02015"));
+ assert_same((d) => d.addDays(-300), i18n.t("May 06,\xa02015"));
- assert_same((d) => d.addDays(-366),
- i18n.t("Mar 01,\xa02015"));
+ assert_same((d) => d.addDays(-366), i18n.t("Mar 01,\xa02015"));
- assert_same((d) => d.addYears(-3),
- i18n.t("Mar 01,\xa02013"));
+ assert_same((d) => d.addYears(-3), i18n.t("Mar 01,\xa02013"));
// Set base_dateto to May 1 2016 12.30 AM (months are zero based)
base_date = new XDate(2016, 4, 1, 0, 30);
- assert_same((d) => d.addDays(-91),
- i18n.t("Jan\xa031"));
-
+ assert_same((d) => d.addDays(-91), i18n.t("Jan\xa031"));
});
run_test("set_full_datetime", () => {
diff --git a/frontend_tests/node_tests/top_left_corner.js b/frontend_tests/node_tests/top_left_corner.js
index bddc5b9c9d4..2a1c513b175 100644
--- a/frontend_tests/node_tests/top_left_corner.js
+++ b/frontend_tests/node_tests/top_left_corner.js
@@ -13,14 +13,16 @@ run_test("narrowing", () => {
let pm_closed;
set_global("pm_list", {
- close: function () { pm_closed = true; },
- expand: function () { pm_expanded = true; },
+ close: function () {
+ pm_closed = true;
+ },
+ expand: function () {
+ pm_expanded = true;
+ },
});
assert(!pm_expanded);
- let filter = new Filter([
- {operator: "is", operand: "private"},
- ]);
+ let filter = new Filter([{operator: "is", operand: "private"}]);
top_left_corner.handle_narrow_activated(filter);
assert(pm_expanded);
@@ -39,41 +41,29 @@ run_test("narrowing", () => {
people.add_active_user(bob);
pm_expanded = false;
- filter = new Filter([
- {operator: "pm-with", operand: "[email protected]"},
- ]);
+ filter = new Filter([{operator: "pm-with", operand: "[email protected]"}]);
top_left_corner.handle_narrow_activated(filter);
assert(pm_expanded);
pm_expanded = false;
- filter = new Filter([
- {operator: "pm-with", operand: "[email protected],[email protected]"},
- ]);
+ filter = new Filter([{operator: "pm-with", operand: "[email protected],[email protected]"}]);
top_left_corner.handle_narrow_activated(filter);
assert(pm_expanded);
pm_expanded = false;
- filter = new Filter([
- {operator: "pm-with", operand: "[email protected]"},
- ]);
+ filter = new Filter([{operator: "pm-with", operand: "[email protected]"}]);
top_left_corner.handle_narrow_activated(filter);
assert(!pm_expanded);
- filter = new Filter([
- {operator: "is", operand: "mentioned"},
- ]);
+ filter = new Filter([{operator: "is", operand: "mentioned"}]);
top_left_corner.handle_narrow_activated(filter);
assert($(".top_left_mentions").hasClass("active-filter"));
- filter = new Filter([
- {operator: "is", operand: "starred"},
- ]);
+ filter = new Filter([{operator: "is", operand: "starred"}]);
top_left_corner.handle_narrow_activated(filter);
assert($(".top_left_starred_messages").hasClass("active-filter"));
- filter = new Filter([
- {operator: "in", operand: "home"},
- ]);
+ filter = new Filter([{operator: "in", operand: "home"}]);
top_left_corner.handle_narrow_activated(filter);
assert($(".top_left_all_messages").hasClass("active-filter"));
@@ -105,23 +95,11 @@ run_test("update_count_in_dom", () => {
home_unread_messages: 333,
};
- make_elem(
- $(".top_left_mentions"),
- "<mentioned-count>",
- "<mentioned-value>",
- );
-
- make_elem(
- $(".top_left_all_messages"),
- "<home-count>",
- "<home-value>",
- );
-
- make_elem(
- $(".top_left_starred_messages"),
- "<starred-count>",
- "<starred-value>",
- );
+ make_elem($(".top_left_mentions"), "<mentioned-count>", "<mentioned-value>");
+
+ make_elem($(".top_left_all_messages"), "<home-count>", "<home-value>");
+
+ make_elem($(".top_left_starred_messages"), "<starred-count>", "<starred-value>");
top_left_corner.update_dom_with_unread_counts(counts);
top_left_corner.update_starred_count(444);
diff --git a/frontend_tests/node_tests/topic_generator.js b/frontend_tests/node_tests/topic_generator.js
index 3eb79145909..48213f8a3c5 100644
--- a/frontend_tests/node_tests/topic_generator.js
+++ b/frontend_tests/node_tests/topic_generator.js
@@ -9,8 +9,12 @@ zrequire("stream_topic_history");
zrequire("stream_sort");
const tg = zrequire("topic_generator");
-function is_even(i) { return i % 2 === 0; }
-function is_odd(i) { return i % 2 === 1; }
+function is_even(i) {
+ return i % 2 === 0;
+}
+function is_odd(i) {
+ return i % 2 === 1;
+}
run_test("basics", () => {
let gen = tg.list_generator([10, 20, 30]);
@@ -72,7 +76,9 @@ run_test("basics", () => {
ints = tg.list_generator([10, 20, 30]);
- function mult10(x) { return x * 10; }
+ function mult10(x) {
+ return x * 10;
+ }
gen = tg.map(ints, mult10);
assert.equal(gen.next(), 100);
@@ -206,7 +212,6 @@ run_test("streams", () => {
assert_prev_stream(undefined, "test here");
assert_prev_stream("test here", "devel");
assert_prev_stream("announce", "test here");
-
});
run_test("topics", () => {
@@ -227,26 +232,15 @@ run_test("topics", () => {
}
function next_topic(curr_stream, curr_topic) {
- return tg.next_topic(
- streams,
- get_topics,
- has_unread_messages,
- curr_stream,
- curr_topic);
+ return tg.next_topic(streams, get_topics, has_unread_messages, curr_stream, curr_topic);
}
- assert.deepEqual(next_topic(1, "1a"),
- {stream: 1, topic: "1b"});
- assert.deepEqual(next_topic(1, undefined),
- {stream: 1, topic: "1a"});
- assert.deepEqual(next_topic(2, "bogus"),
- {stream: 3, topic: "3a"});
- assert.deepEqual(next_topic(3, "3b"),
- {stream: 3, topic: "3a"});
- assert.deepEqual(next_topic(4, "4a"),
- {stream: 1, topic: "1a"});
- assert.deepEqual(next_topic(undefined, undefined),
- {stream: 1, topic: "1a"});
+ assert.deepEqual(next_topic(1, "1a"), {stream: 1, topic: "1b"});
+ assert.deepEqual(next_topic(1, undefined), {stream: 1, topic: "1a"});
+ assert.deepEqual(next_topic(2, "bogus"), {stream: 3, topic: "3a"});
+ assert.deepEqual(next_topic(3, "3b"), {stream: 3, topic: "3a"});
+ assert.deepEqual(next_topic(4, "4a"), {stream: 1, topic: "1a"});
+ assert.deepEqual(next_topic(undefined, undefined), {stream: 1, topic: "1a"});
// Now test the deeper function that is wired up to
// real functions stream_data/stream_sort/unread.
@@ -265,10 +259,10 @@ run_test("topics", () => {
stream_topic_history.get_recent_topic_names = function (stream_id) {
switch (stream_id) {
- case muted_stream_id:
- return ["ms-topic1", "ms-topic2"];
- case devel_stream_id:
- return ["muted", "python"];
+ case muted_stream_id:
+ return ["ms-topic1", "ms-topic2"];
+ case devel_stream_id:
+ return ["muted", "python"];
}
return [];
diff --git a/frontend_tests/node_tests/topic_list_data.js b/frontend_tests/node_tests/topic_list_data.js
index 8cc0f5819e3..1cf8cf174e2 100644
--- a/frontend_tests/node_tests/topic_list_data.js
+++ b/frontend_tests/node_tests/topic_list_data.js
@@ -24,8 +24,7 @@ function clear() {
function get_list_info(zoomed) {
const stream_id = general.stream_id;
- return topic_list_data.get_list_info(
- stream_id, zoomed);
+ return topic_list_data.get_list_info(stream_id, zoomed);
}
run_test("get_list_info w/real stream_topic_history", () => {
@@ -107,15 +106,8 @@ run_test("get_list_info unreads", () => {
assert.deepEqual(
list_info.items.map((li) => li.topic_name),
- [
- "topic 0",
- "topic 1",
- "topic 2",
- "topic 3",
- "topic 4",
- "topic 8",
- "topic 9",
- ]);
+ ["topic 0", "topic 1", "topic 2", "topic 3", "topic 4", "topic 8", "topic 9"],
+ );
unread_cnt.set("topic 6", 6);
unread_cnt.set("topic 7", 7);
@@ -127,16 +119,8 @@ run_test("get_list_info unreads", () => {
assert.deepEqual(
list_info.items.map((li) => li.topic_name),
- [
- "topic 0",
- "topic 1",
- "topic 2",
- "topic 3",
- "topic 4",
- "topic 6",
- "topic 7",
- "topic 8",
- ]);
+ ["topic 0", "topic 1", "topic 2", "topic 3", "topic 4", "topic 6", "topic 7", "topic 8"],
+ );
unread_cnt.set("topic 4", 4);
unread_cnt.set("topic 5", 5);
@@ -154,14 +138,6 @@ run_test("get_list_info unreads", () => {
assert.deepEqual(
list_info.items.map((li) => li.topic_name),
- [
- "topic 0",
- "topic 1",
- "topic 2",
- "topic 3",
- "topic 5",
- "topic 6",
- "topic 7",
- "topic 8",
- ]);
+ ["topic 0", "topic 1", "topic 2", "topic 3", "topic 5", "topic 6", "topic 7", "topic 8"],
+ );
});
diff --git a/frontend_tests/node_tests/transmit.js b/frontend_tests/node_tests/transmit.js
index 36b0180d98c..776d828f81a 100644
--- a/frontend_tests/node_tests/transmit.js
+++ b/frontend_tests/node_tests/transmit.js
@@ -14,7 +14,6 @@ zrequire("people");
zrequire("transmit");
run_test("transmit_message_ajax", () => {
-
let success_func_called;
const success = function () {
success_func_called = true;
@@ -54,7 +53,9 @@ run_test("transmit_message_ajax", () => {
});
run_test("transmit_message_ajax_reload_pending", () => {
- const success = function () { throw "unexpected success"; };
+ const success = function () {
+ throw "unexpected success";
+ };
reload_state.is_pending = function () {
return true;
@@ -141,9 +142,7 @@ run_test("reply_message_private", () => {
const pm_message = {
type: "private",
- display_recipient: [
- {id: fred.user_id},
- ],
+ display_recipient: [{id: fred.user_id}],
};
const content = "hello";
@@ -183,5 +182,4 @@ run_test("reply_message_errors", () => {
transmit.reply_message({
message: bogus_message,
});
-
});
diff --git a/frontend_tests/node_tests/typeahead.js b/frontend_tests/node_tests/typeahead.js
index b903c94346e..301a44c0bc9 100644
--- a/frontend_tests/node_tests/typeahead.js
+++ b/frontend_tests/node_tests/typeahead.js
@@ -23,20 +23,12 @@ const emoji_tada = {
random_field: "whatever",
};
-const emojis = [
- emoji_japanese_post_office,
- emoji_panda_face,
- emoji_smile,
- emoji_tada,
-];
+const emojis = [emoji_japanese_post_office, emoji_panda_face, emoji_smile, emoji_tada];
run_test("get_emoji_matcher", () => {
function assert_matches(query, expected) {
const matcher = typeahead.get_emoji_matcher(query);
- assert.deepEqual(
- emojis.filter(matcher),
- expected,
- );
+ assert.deepEqual(emojis.filter(matcher), expected);
}
assert_matches("notaemoji", []);
@@ -48,10 +40,8 @@ run_test("get_emoji_matcher", () => {
assert_matches("smil", [emoji_smile]);
assert_matches("mile", [emoji_smile]);
- assert_matches(
- "japanese_post_", [emoji_japanese_post_office]);
- assert_matches(
- "japanese post ", [emoji_japanese_post_office]);
+ assert_matches("japanese_post_", [emoji_japanese_post_office]);
+ assert_matches("japanese post ", [emoji_japanese_post_office]);
});
run_test("triage", () => {
@@ -97,53 +87,46 @@ run_test("triage", () => {
run_test("sort_emojis th", () => {
const thumbs_up = {
- emoji_name: "thumbs_up", emoji_code: "1f44d"};
+ emoji_name: "thumbs_up",
+ emoji_code: "1f44d",
+ };
const thumbs_down = {
- emoji_name: "thumbs_down"};
+ emoji_name: "thumbs_down",
+ };
const thermometer = {
- emoji_name: "thermometer"};
+ emoji_name: "thermometer",
+ };
const mother_nature = {
- emoji_name: "mother_nature"};
+ emoji_name: "mother_nature",
+ };
- const emoji_list = [
- mother_nature,
+ const emoji_list = [mother_nature, thermometer, thumbs_down, thumbs_up];
+
+ assert.deepEqual(typeahead.sort_emojis(emoji_list, "th"), [
+ thumbs_up,
thermometer,
thumbs_down,
- thumbs_up,
- ];
-
- assert.deepEqual(
- typeahead.sort_emojis(emoji_list, "th"),
- [
- thumbs_up,
- thermometer,
- thumbs_down,
- mother_nature,
- ],
- );
+ mother_nature,
+ ]);
});
run_test("sort_emojis sm", () => {
const big_smile = {
- emoji_name: "big_smile"};
+ emoji_name: "big_smile",
+ };
const slight_smile = {
- emoji_name: "slight_smile", emoji_code: "1f642"};
+ emoji_name: "slight_smile",
+ emoji_code: "1f642",
+ };
const small_airplane = {
- emoji_name: "small_airplane"};
+ emoji_name: "small_airplane",
+ };
- const emoji_list = [
- big_smile,
+ const emoji_list = [big_smile, slight_smile, small_airplane];
+
+ assert.deepEqual(typeahead.sort_emojis(emoji_list, "sm"), [
slight_smile,
small_airplane,
- ];
-
- assert.deepEqual(
- typeahead.sort_emojis(emoji_list, "sm"),
- [
- slight_smile,
- small_airplane,
- big_smile,
- ],
- );
+ big_smile,
+ ]);
});
-
diff --git a/frontend_tests/node_tests/typeahead_helper.js b/frontend_tests/node_tests/typeahead_helper.js
index e8f0b7e00f9..3ed606a2943 100644
--- a/frontend_tests/node_tests/typeahead_helper.js
+++ b/frontend_tests/node_tests/typeahead_helper.js
@@ -96,8 +96,8 @@ run_test("sort_streams", () => {
});
run_test("sort_languages", () => {
- Object.assign(pygments_data, {langs:
- {python: 40, javscript: 50, php: 38, pascal: 29, perl: 22, css: 0},
+ Object.assign(pygments_data, {
+ langs: {python: 40, javscript: 50, php: 38, pascal: 29, perl: 22, css: 0},
});
let test_langs = ["pascal", "perl", "php", "python", "javascript"];
@@ -188,15 +188,7 @@ const zman = {
user_id: 7,
};
-const matches = [
- a_bot,
- a_user,
- b_user_1,
- b_user_2,
- b_user_3,
- b_bot,
- zman,
-];
+const matches = [a_bot, a_user, b_user_1, b_user_2, b_user_3, b_bot, zman];
for (const person of matches) {
people.add_active_user(person);
@@ -258,19 +250,19 @@ run_test("sort_recipients", () => {
sender_id: 7,
stream_id: 1,
topic: "Dev Topic",
- id: next_id += 1,
+ id: (next_id += 1),
});
global.recent_senders.process_message_for_senders({
sender_id: 5,
stream_id: 1,
topic: "Dev Topic",
- id: next_id += 1,
+ id: (next_id += 1),
});
global.recent_senders.process_message_for_senders({
sender_id: 6,
stream_id: 1,
topic: "Dev Topic",
- id: next_id += 1,
+ id: (next_id += 1),
});
// Typeahead for stream message [query, stream-name, topic-name]
@@ -288,13 +280,13 @@ run_test("sort_recipients", () => {
sender_id: 5,
stream_id: 2,
topic: "Linux Topic",
- id: next_id += 1,
+ id: (next_id += 1),
});
global.recent_senders.process_message_for_senders({
sender_id: 7,
stream_id: 2,
topic: "Linux Topic",
- id: next_id += 1,
+ id: (next_id += 1),
});
// No match
@@ -318,23 +310,9 @@ run_test("sort_recipients all mention", () => {
// Test person email is "all" or "everyone"
const test_objs = matches.concat([all_obj]);
- const results = th.sort_recipients(
- test_objs,
- "a",
- "Linux",
- "Linux Topic",
- );
+ const results = th.sort_recipients(test_objs, "a", "Linux", "Linux Topic");
- assertSameEmails(results, [
- all_obj,
- a_user,
- a_bot,
- zman,
- b_user_3,
- b_bot,
- b_user_1,
- b_user_2,
- ]);
+ assertSameEmails(results, [all_obj, a_user, a_bot, zman, b_user_3, b_bot, b_user_1, b_user_2]);
});
run_test("sort_recipients pm counts", () => {
@@ -377,20 +355,11 @@ run_test("sort_recipients dup bots", () => {
run_test("sort_recipients dup alls", () => {
// full_name starts with same character but emails are 'all'
- const test_objs = [
- all_obj,
- a_user,
- all_obj,
- ];
+ const test_objs = [all_obj, a_user, all_obj];
- const recipients = th.sort_recipients(
- test_objs, "a", "Linux", "Linux Topic");
+ const recipients = th.sort_recipients(test_objs, "a", "Linux", "Linux Topic");
- const expected = [
- all_obj,
- all_obj,
- a_user,
- ];
+ const expected = [all_obj, all_obj, a_user];
assertSameEmails(recipients, expected);
});
@@ -399,10 +368,7 @@ run_test("sort_recipients subscribers", () => {
const small_matches = [b_user_2, b_user_1];
const recipients = th.sort_recipients(small_matches, "b", "Dev", "Dev Topic");
const recipients_email = recipients.map((person) => person.email);
- const expected = [
- ];
+ const expected = ["[email protected]", "[email protected]"];
assert.deepEqual(recipients_email, expected);
});
@@ -412,10 +378,7 @@ run_test("sort_recipients pm partners", () => {
const small_matches = [b_user_3, b_user_2];
const recipients = th.sort_recipients(small_matches, "b", "Linux", "Linux Topic");
const recipients_email = recipients.map((person) => person.email);
- const expected = [
- ];
+ const expected = ["[email protected]", "[email protected]"];
assert.deepEqual(recipients_email, expected);
});
@@ -424,10 +387,7 @@ run_test("sort broadcast mentions", () => {
// broadcast mentions are already sorted (we
// actually had a bug where the sort would
// randomly rearrange them)
- const results = th.sort_people_for_relevance(
- ct.broadcast_mentions().reverse(),
- "",
- "");
+ const results = th.sort_people_for_relevance(ct.broadcast_mentions().reverse(), "", "");
assert.deepEqual(
results.map((r) => r.email),
@@ -441,18 +401,11 @@ run_test("sort broadcast mentions", () => {
test_objs.unshift(zman);
test_objs.push(a_user);
- const results2 = th.sort_people_for_relevance(
- test_objs,
- "",
- "");
+ const results2 = th.sort_people_for_relevance(test_objs, "", "");
assert.deepEqual(
results2.map((r) => r.email),
- ["all",
- "everyone",
- "stream",
- a_user.email,
- zman.email],
+ ["all", "everyone", "stream", a_user.email, zman.email],
);
});
@@ -460,17 +413,11 @@ run_test("test compare directly", () => {
// This is important for ensuring test coverage.
// We don't technically need it now, but our test
// coverage is subject to the whims of how JS sorts.
- assert.equal(
- th.compare_people_for_relevance(all_obj, all_obj),
- 0);
+ assert.equal(th.compare_people_for_relevance(all_obj, all_obj), 0);
- assert.equal(
- th.compare_people_for_relevance(all_obj, zman),
- -1);
+ assert.equal(th.compare_people_for_relevance(all_obj, zman), -1);
- assert.equal(
- th.compare_people_for_relevance(zman, all_obj),
- 1);
+ assert.equal(th.compare_people_for_relevance(zman, all_obj), 1);
});
run_test("highlight_with_escaping", () => {
@@ -570,7 +517,6 @@ run_test("clear_rendered_person", () => {
th.clear_rendered_person(b_bot.user_id);
assert.equal(th.render_person(b_bot), "typeahead-item-stub");
assert(rendered);
-
});
run_test("render_stream", () => {
@@ -644,9 +590,11 @@ run_test("render_emoji", () => {
emoji_name: "thumbs_up",
emoji_code: "1f44d",
};
- emoji.active_realm_emojis = new Map(Object.entries({
- realm_emoji: "TBD",
- }));
+ emoji.active_realm_emojis = new Map(
+ Object.entries({
+ realm_emoji: "TBD",
+ }),
+ );
global.stub_templates((template_name, args) => {
assert.equal(template_name, "typeahead_list_item");
diff --git a/frontend_tests/node_tests/typing_data.js b/frontend_tests/node_tests/typing_data.js
index ff05b448e8e..7b5f09f8910 100644
--- a/frontend_tests/node_tests/typing_data.js
+++ b/frontend_tests/node_tests/typing_data.js
@@ -115,5 +115,4 @@ run_test("timers", () => {
timer_cleared: false,
timer_set: false,
});
-
});
diff --git a/frontend_tests/node_tests/typing_status.js b/frontend_tests/node_tests/typing_status.js
index 8e5cd7879f0..a6b9c139544 100644
--- a/frontend_tests/node_tests/typing_status.js
+++ b/frontend_tests/node_tests/typing_status.js
@@ -9,11 +9,12 @@ function make_time(secs) {
}
function returns_time(secs) {
- return function () { return make_time(secs); };
+ return function () {
+ return make_time(secs);
+ };
}
run_test("basics", () => {
-
// invalid conversation basically does nothing
let worker = {};
typing_status.update(worker, null);
diff --git a/frontend_tests/node_tests/ui.js b/frontend_tests/node_tests/ui.js
index 70ade4cb5c2..d16525d25a7 100644
--- a/frontend_tests/node_tests/ui.js
+++ b/frontend_tests/node_tests/ui.js
@@ -5,14 +5,17 @@ set_global("navigator", {
});
run_test("get_hotkey_deprecation_notice", () => {
- const expected = 'translated: We\'ve replaced the "*" hotkey with "Ctrl + s" to make this common shortcut easier to trigger.';
+ const expected =
+ 'translated: We\'ve replaced the "*" hotkey with "Ctrl + s" to make this common shortcut easier to trigger.';
const actual = ui.get_hotkey_deprecation_notice("*", "Ctrl + s");
assert.equal(expected, actual);
});
run_test("get_hotkey_deprecation_notice_mac", () => {
- global.navigator.userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36";
- const expected = 'translated: We\'ve replaced the "*" hotkey with "Cmd + s" to make this common shortcut easier to trigger.';
+ global.navigator.userAgent =
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36";
+ const expected =
+ 'translated: We\'ve replaced the "*" hotkey with "Cmd + s" to make this common shortcut easier to trigger.';
const actual = ui.get_hotkey_deprecation_notice("*", "Cmd + s");
assert.equal(expected, actual);
// Reset userAgent
diff --git a/frontend_tests/node_tests/ui_init.js b/frontend_tests/node_tests/ui_init.js
index fe0a163d277..bc92237c8ab 100644
--- a/frontend_tests/node_tests/ui_init.js
+++ b/frontend_tests/node_tests/ui_init.js
@@ -122,14 +122,11 @@ zrequire("starred_messages");
zrequire("user_status");
zrequire("user_status_ui");
-const ui_init = rewiremock.proxy(
- () => zrequire("ui_init"),
- {
- "../../static/js/emojisets": {
- initialize: () => {},
- },
+const ui_init = rewiremock.proxy(() => zrequire("ui_init"), {
+ "../../static/js/emojisets": {
+ initialize: () => {},
},
-);
+});
set_global("$", global.make_zjquery());
diff --git a/frontend_tests/node_tests/unread.js b/frontend_tests/node_tests/unread.js
index e60eaa724a0..f05b779ebe5 100644
--- a/frontend_tests/node_tests/unread.js
+++ b/frontend_tests/node_tests/unread.js
@@ -107,10 +107,10 @@ run_test("changing_topics", () => {
assert.deepEqual(unread.get_all_msg_ids(), [15, 16]);
assert.deepEqual(unread.get_unread_message_ids([15, 16]), [15, 16]);
- assert.deepEqual(
- unread.get_unread_messages([message, other_message]),
- [message, other_message],
- );
+ assert.deepEqual(unread.get_unread_messages([message, other_message]), [
+ message,
+ other_message,
+ ]);
count = unread.num_unread_for_topic(stream_id, "Lunch");
assert.equal(count, 2);
@@ -292,9 +292,7 @@ run_test("num_unread_for_topic", () => {
topic_dict: topic_dict,
});
- assert.deepEqual(missing_topics, [
- {pretty_name: "LuncH", message_id: 500},
- ]);
+ assert.deepEqual(missing_topics, [{pretty_name: "LuncH", message_id: 500}]);
topic_dict.set("lUNCh", "whatever");
@@ -371,7 +369,6 @@ run_test("home_messages", () => {
counts = unread.get_counts();
assert.equal(counts.home_unread_messages, 0);
test_notifiable_count(counts.home_unread_messages, 0);
-
});
run_test("phantom_messages", () => {
@@ -382,7 +379,9 @@ run_test("phantom_messages", () => {
topic: "phantom",
};
- stream_data.get_sub_by_id = function () { return; };
+ stream_data.get_sub_by_id = function () {
+ return;
+ };
unread.mark_as_read(message.id);
const counts = unread.get_counts();
@@ -404,10 +403,7 @@ run_test("private_messages", () => {
const message = {
id: 15,
type: "private",
- display_recipient: [
- {id: anybody.user_id},
- {id: me.user_id},
- ],
+ display_recipient: [{id: anybody.user_id}, {id: me.user_id}],
unread: true,
};
@@ -538,11 +534,15 @@ run_test("mentions", () => {
counts = unread.get_counts();
assert.equal(counts.mentioned_message_count, 2);
- assert.deepEqual(unread.get_msg_ids_for_mentions(), [mention_me_message.id,
- mention_all_message.id]);
- assert.deepEqual(unread.get_all_msg_ids(), [mention_me_message.id,
- mention_all_message.id,
- muted_mention_all_message.id]);
+ assert.deepEqual(unread.get_msg_ids_for_mentions(), [
+ mention_me_message.id,
+ mention_all_message.id,
+ ]);
+ assert.deepEqual(unread.get_all_msg_ids(), [
+ mention_me_message.id,
+ mention_all_message.id,
+ muted_mention_all_message.id,
+ ]);
test_notifiable_count(counts.home_unread_messages, 2);
unread.mark_as_read(mention_me_message.id);
@@ -561,10 +561,7 @@ run_test("mention updates", () => {
function test_counted(counted) {
unread.update_message_for_mention(message);
- assert.equal(
- unread.unread_mentions_counter.has(message.id),
- counted,
- );
+ assert.equal(unread.unread_mentions_counter.has(message.id), counted);
}
test_counted(false);
@@ -624,26 +621,20 @@ run_test("server_counts", () => {
pms: [
{
sender_id: 101,
- unread_message_ids: [
- 31, 32, 60, 61, 62, 63,
- ],
+ unread_message_ids: [31, 32, 60, 61, 62, 63],
},
],
huddles: [
{
user_ids_string: "4,6,30,101",
- unread_message_ids: [
- 34, 50,
- ],
+ unread_message_ids: [34, 50],
},
],
streams: [
{
stream_id: 1,
topic: "test",
- unread_message_ids: [
- 33, 35, 36,
- ],
+ unread_message_ids: [33, 35, 36],
},
],
mentions: [31, 34, 40, 41],
@@ -688,7 +679,6 @@ run_test("empty_cases", () => {
topic_dict: "should-never-be-referenced",
});
assert.deepEqual(missing_topics, []);
-
});
run_test("errors", () => {
diff --git a/frontend_tests/node_tests/upgrade.js b/frontend_tests/node_tests/upgrade.js
index 5764fa6cfc2..5d42336ed3e 100644
--- a/frontend_tests/node_tests/upgrade.js
+++ b/frontend_tests/node_tests/upgrade.js
@@ -7,7 +7,9 @@ const dom = new JSDOM(template, {pretendToBeVisual: true});
const document = dom.window.document;
let jquery_init;
-global.$ = (f) => {jquery_init = f;};
+global.$ = (f) => {
+ jquery_init = f;
+};
set_global("helpers", {
set_tab: noop,
@@ -88,11 +90,14 @@ run_test("initialize", () => {
assert.equal(schedule, "monthly");
};
- $("input[type=radio][name=license_management]:checked").val = () => document.querySelector("input[type=radio][name=license_management]:checked").value;
+ $("input[type=radio][name=license_management]:checked").val = () =>
+ document.querySelector("input[type=radio][name=license_management]:checked").value;
- $("input[type=radio][name=schedule]:checked").val = () => document.querySelector("input[type=radio][name=schedule]:checked").value;
+ $("input[type=radio][name=schedule]:checked").val = () =>
+ document.querySelector("input[type=radio][name=schedule]:checked").value;
- $("#autopay-form").data = (key) => document.querySelector("#autopay-form").getAttribute("data-" + key);
+ $("#autopay-form").data = (key) =>
+ document.querySelector("#autopay-form").getAttribute("data-" + key);
jquery_init();
@@ -118,7 +123,9 @@ run_test("initialize", () => {
helpers.show_license_section = (section) => {
assert.equal(section, "manual");
};
- const license_change_handler = $("input[type=radio][name=license_management]").get_on_handler("change");
+ const license_change_handler = $("input[type=radio][name=license_management]").get_on_handler(
+ "change",
+ );
license_change_handler.call({value: "manual"});
helpers.update_charged_amount = (prices, schedule) => {
@@ -135,43 +142,76 @@ run_test("initialize", () => {
assert.equal($("#invoice_annual_price").text(), "64");
assert.equal($("#invoice_annual_price_per_month").text(), "5.34");
- const organization_type_change_handler = $("select[name=organization-type]").get_on_handler("change");
+ const organization_type_change_handler = $("select[name=organization-type]").get_on_handler(
+ "change",
+ );
organization_type_change_handler.call({value: "open_source"});
- assert.equal($("#sponsorship-discount-details").text(),
- "Open source projects are eligible for fully sponsored (free) Zulip Standard.");
+ assert.equal(
+ $("#sponsorship-discount-details").text(),
+ "Open source projects are eligible for fully sponsored (free) Zulip Standard.",
+ );
organization_type_change_handler.call({value: "research"});
- assert.equal($("#sponsorship-discount-details").text(),
- "Academic research organizations are eligible for fully sponsored (free) Zulip Standard.");
+ assert.equal(
+ $("#sponsorship-discount-details").text(),
+ "Academic research organizations are eligible for fully sponsored (free) Zulip Standard.",
+ );
organization_type_change_handler.call({value: "event"});
- assert.equal($("#sponsorship-discount-details").text(),
- "Events are eligible for fully sponsored (free) Zulip Standard.");
+ assert.equal(
+ $("#sponsorship-discount-details").text(),
+ "Events are eligible for fully sponsored (free) Zulip Standard.",
+ );
organization_type_change_handler.call({value: "education"});
- assert.equal($("#sponsorship-discount-details").text(),
- "Education use is eligible for an 85%-100% discount.");
+ assert.equal(
+ $("#sponsorship-discount-details").text(),
+ "Education use is eligible for an 85%-100% discount.",
+ );
organization_type_change_handler.call({value: "non_profit"});
- assert.equal($("#sponsorship-discount-details").text(),
- "Nonprofits are eligible for an 85%-100% discount.");
+ assert.equal(
+ $("#sponsorship-discount-details").text(),
+ "Nonprofits are eligible for an 85%-100% discount.",
+ );
organization_type_change_handler.call({value: "other"});
- assert.equal($("#sponsorship-discount-details").text(),
- "Your organization might be eligible for a discount or sponsorship.");
+ assert.equal(
+ $("#sponsorship-discount-details").text(),
+ "Your organization might be eligible for a discount or sponsorship.",
+ );
});
run_test("autopay_form_fields", () => {
assert.equal(document.querySelector("#autopay-form").dataset.key, "{{ publishable_key }}");
assert.equal(document.querySelector("#autopay-form").dataset.email, "{{ email }}");
- assert.equal(document.querySelector("#autopay-form [name=seat_count]").value, "{{ seat_count }}");
- assert.equal(document.querySelector("#autopay-form [name=signed_seat_count]").value, "{{ signed_seat_count }}");
+ assert.equal(
+ document.querySelector("#autopay-form [name=seat_count]").value,
+ "{{ seat_count }}",
+ );
+ assert.equal(
+ document.querySelector("#autopay-form [name=signed_seat_count]").value,
+ "{{ signed_seat_count }}",
+ );
assert.equal(document.querySelector("#autopay-form [name=salt]").value, "{{ salt }}");
- assert.equal(document.querySelector("#autopay-form [name=billing_modality]").value, "charge_automatically");
- assert.equal(document.querySelector("#autopay-form #automatic_license_count").value, "{{ seat_count }}");
- assert.equal(document.querySelector("#autopay-form #manual_license_count").min, "{{ seat_count }}");
-
- const license_options = document.querySelectorAll("#autopay-form input[type=radio][name=license_management]");
+ assert.equal(
+ document.querySelector("#autopay-form [name=billing_modality]").value,
+ "charge_automatically",
+ );
+ assert.equal(
+ document.querySelector("#autopay-form #automatic_license_count").value,
+ "{{ seat_count }}",
+ );
+ assert.equal(
+ document.querySelector("#autopay-form #manual_license_count").min,
+ "{{ seat_count }}",
+ );
+
+ const license_options = document.querySelectorAll(
+ "#autopay-form input[type=radio][name=license_management]",
+ );
assert.equal(license_options.length, 2);
assert.equal(license_options[0].value, "automatic");
assert.equal(license_options[1].value, "manual");
- const schedule_options = document.querySelectorAll("#autopay-form input[type=radio][name=schedule]");
+ const schedule_options = document.querySelectorAll(
+ "#autopay-form input[type=radio][name=schedule]",
+ );
assert.equal(schedule_options.length, 2);
assert.equal(schedule_options[0].value, "monthly");
assert.equal(schedule_options[1].value, "annual");
@@ -188,12 +228,23 @@ run_test("autopay_form_fields", () => {
});
run_test("invoice_form_fields", () => {
- assert.equal(document.querySelector("#invoice-form [name=signed_seat_count]").value, "{{ signed_seat_count }}");
+ assert.equal(
+ document.querySelector("#invoice-form [name=signed_seat_count]").value,
+ "{{ signed_seat_count }}",
+ );
assert.equal(document.querySelector("#invoice-form [name=salt]").value, "{{ salt }}");
- assert.equal(document.querySelector("#invoice-form [name=billing_modality]").value, "send_invoice");
- assert.equal(document.querySelector("#invoice-form [name=licenses]").min, "{{ min_invoiced_licenses }}");
-
- const schedule_options = document.querySelectorAll("#invoice-form input[type=radio][name=schedule]");
+ assert.equal(
+ document.querySelector("#invoice-form [name=billing_modality]").value,
+ "send_invoice",
+ );
+ assert.equal(
+ document.querySelector("#invoice-form [name=licenses]").min,
+ "{{ min_invoiced_licenses }}",
+ );
+
+ const schedule_options = document.querySelectorAll(
+ "#invoice-form input[type=radio][name=schedule]",
+ );
assert.equal(schedule_options.length, 1);
assert.equal(schedule_options[0].value, "annual");
diff --git a/frontend_tests/node_tests/upload.js b/frontend_tests/node_tests/upload.js
index 319a0eb0627..cfb371858fb 100644
--- a/frontend_tests/node_tests/upload.js
+++ b/frontend_tests/node_tests/upload.js
@@ -2,7 +2,7 @@ const rewiremock = require("rewiremock/node");
set_global("$", global.make_zjquery());
set_global("document", {
- location: { },
+ location: {},
});
set_global("navigator", {
userAgent: "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
@@ -42,7 +42,10 @@ run_test("make_upload_absolute", () => {
run_test("get_item", () => {
assert.equal(upload.get_item("textarea", {mode: "compose"}), $("#compose-textarea"));
- assert.equal(upload.get_item("send_status_message", {mode: "compose"}), $("#compose-error-msg"));
+ assert.equal(
+ upload.get_item("send_status_message", {mode: "compose"}),
+ $("#compose-error-msg"),
+ );
assert.equal(upload.get_item("file_input_identifier", {mode: "compose"}), "#file_input");
assert.equal(upload.get_item("source", {mode: "compose"}), "compose-file-input");
assert.equal(upload.get_item("drag_drop_container", {mode: "compose"}), $("#compose"));
@@ -55,18 +58,36 @@ run_test("get_item", () => {
};
assert.equal(upload.get_item("send_button", {mode: "edit", row: 2}), $(".message_edit_save"));
- assert.equal(upload.get_item("send_status_identifier", {mode: "edit", row: 11}), "#message-edit-send-status-11");
- assert.equal(upload.get_item("send_status", {mode: "edit", row: 75}), $("#message-edit-send-status-75"));
+ assert.equal(
+ upload.get_item("send_status_identifier", {mode: "edit", row: 11}),
+ "#message-edit-send-status-11",
+ );
+ assert.equal(
+ upload.get_item("send_status", {mode: "edit", row: 75}),
+ $("#message-edit-send-status-75"),
+ );
- $("#message-edit-send-status-2").set_find_results(".send-status-close", $(".send-status-close"));
- assert.equal(upload.get_item("send_status_close_button", {mode: "edit", row: 2}), $(".send-status-close"));
+ $("#message-edit-send-status-2").set_find_results(
+ ".send-status-close",
+ $(".send-status-close"),
+ );
+ assert.equal(
+ upload.get_item("send_status_close_button", {mode: "edit", row: 2}),
+ $(".send-status-close"),
+ );
$("#message-edit-send-status-22").set_find_results(".error-msg", $(".error-msg"));
assert.equal(upload.get_item("send_status_message", {mode: "edit", row: 22}), $(".error-msg"));
- assert.equal(upload.get_item("file_input_identifier", {mode: "edit", row: 123}), "#message_edit_file_input_123");
+ assert.equal(
+ upload.get_item("file_input_identifier", {mode: "edit", row: 123}),
+ "#message_edit_file_input_123",
+ );
assert.equal(upload.get_item("source", {mode: "edit", row: 123}), "message-edit-file-input");
- assert.equal(upload.get_item("drag_drop_container", {mode: "edit", row: 1}), $("#message_edit_form"));
+ assert.equal(
+ upload.get_item("drag_drop_container", {mode: "edit", row: 1}),
+ $("#message_edit_form"),
+ );
assert.throws(
() => {
@@ -141,7 +162,6 @@ run_test("show_error_message", () => {
upload.show_error_message({mode: "compose"});
assert.equal($("#compose-error-msg").text(), "translated: An unknown error occurred.");
-
});
run_test("upload_files", () => {
@@ -181,7 +201,10 @@ run_test("upload_files", () => {
upload.show_error_message = (config, message) => {
show_error_message_called = true;
assert.equal(config.mode, "compose");
- assert.equal(message, "translated: File and image uploads have been disabled for this organization.");
+ assert.equal(
+ message,
+ "translated: File and image uploads have been disabled for this organization.",
+ );
};
upload.upload_files(uppy, config, files);
assert(show_error_message_called);
@@ -314,7 +337,6 @@ run_test("uppy_config", () => {
assert.equal(uppy_set_meta_called, true);
assert.equal(uppy_used_xhrupload, true);
assert.equal(uppy_used_progressbar, true);
-
});
run_test("file_input", () => {
@@ -372,7 +394,9 @@ run_test("file_drop", () => {
};
const drop_handler = $("#compose").get_on_handler("drop");
let upload_files_called = false;
- upload.upload_files = () => {upload_files_called = true;};
+ upload.upload_files = () => {
+ upload_files_called = true;
+ };
drop_handler(drop_event);
assert.equal(prevent_default_counter, 3);
assert.equal(upload_files_called, true);
@@ -471,7 +495,10 @@ run_test("uppy_events", () => {
compose_ui.replace_syntax = (old_syntax, new_syntax, textarea) => {
compose_ui_replace_syntax_called = true;
assert.equal(old_syntax, "[translated: Uploading copenhagen.png…]()");
- assert.equal(new_syntax, "[copenhagen.png](https://foo.com/user_uploads/4/cb/rue1c-MlMUjDAUdkRrEM4BTJ/copenhagen.png)");
+ assert.equal(
+ new_syntax,
+ "[copenhagen.png](https://foo.com/user_uploads/4/cb/rue1c-MlMUjDAUdkRrEM4BTJ/copenhagen.png)",
+ );
assert.equal(textarea, $("#compose-textarea"));
};
let compose_ui_autosize_textarea_called = false;
@@ -632,6 +659,4 @@ run_test("uppy_events", () => {
assert(show_error_message_called);
assert(compose_ui_replace_syntax_called);
assert.equal($("#comepose-textarea").val(), "user modified text");
-
-
});
diff --git a/frontend_tests/node_tests/user_events.js b/frontend_tests/node_tests/user_events.js
index d7c04cd0004..1ec4d91f37b 100644
--- a/frontend_tests/node_tests/user_events.js
+++ b/frontend_tests/node_tests/user_events.js
@@ -48,8 +48,7 @@ set_global("settings_account", {
update_full_name: function () {},
});
-set_global("message_live_update", {
-});
+set_global("message_live_update", {});
const me = {
@@ -76,23 +75,31 @@ run_test("updates", () => {
};
people.add_active_user(isaac);
- user_events.update_person({user_id: isaac.user_id,
- role: settings_config.user_role_values.guest.code});
+ user_events.update_person({
+ user_id: isaac.user_id,
+ role: settings_config.user_role_values.guest.code,
+ });
person = people.get_by_email(isaac.email);
assert(person.is_guest);
- user_events.update_person({user_id: isaac.user_id,
- role: settings_config.user_role_values.member.code});
+ user_events.update_person({
+ user_id: isaac.user_id,
+ role: settings_config.user_role_values.member.code,
+ });
person = people.get_by_email(isaac.email);
assert(!person.is_guest);
- user_events.update_person({user_id: isaac.user_id,
- role: settings_config.user_role_values.admin.code});
+ user_events.update_person({
+ user_id: isaac.user_id,
+ role: settings_config.user_role_values.admin.code,
+ });
person = people.get_by_email(isaac.email);
assert.equal(person.full_name, "Isaac Newton");
assert.equal(person.is_admin, true);
- user_events.update_person({user_id: isaac.user_id,
- role: settings_config.user_role_values.owner.code});
+ user_events.update_person({
+ user_id: isaac.user_id,
+ role: settings_config.user_role_values.owner.code,
+ });
assert.equal(person.is_admin, true);
assert.equal(person.is_owner, true);
@@ -110,8 +117,10 @@ run_test("updates", () => {
assert.equal(user_id, isaac.user_id);
assert.equal(full_name, "Sir Isaac");
- user_events.update_person({user_id: me.user_id,
- role: settings_config.user_role_values.member.code});
+ user_events.update_person({
+ user_id: me.user_id,
+ role: settings_config.user_role_values.member.code,
+ });
assert(!global.page_params.is_admin);
user_events.update_person({user_id: me.user_id, full_name: "Me V2"});
@@ -163,7 +172,10 @@ run_test("updates", () => {
assert(!user_events.update_person({user_id: 29, full_name: "Sir Isaac Newton"}));
me.profile_data = {};
- user_events.update_person({user_id: me.user_id, custom_profile_field: {id: 3, value: "Value", rendered_value: "<p>Value</p>"}});
+ user_events.update_person({
+ user_id: me.user_id,
+ custom_profile_field: {id: 3, value: "Value", rendered_value: "<p>Value</p>"},
+ });
person = people.get_by_email(me.email);
assert.equal(person.profile_data[3].value, "Value");
assert.equal(person.profile_data[3].rendered_value, "<p>Value</p>");
diff --git a/frontend_tests/node_tests/user_groups.js b/frontend_tests/node_tests/user_groups.js
index eb264240a86..78eb697135a 100644
--- a/frontend_tests/node_tests/user_groups.js
+++ b/frontend_tests/node_tests/user_groups.js
@@ -1,4 +1,3 @@
-
zrequire("user_groups");
run_test("user_groups", () => {
@@ -68,12 +67,10 @@ run_test("user_groups", () => {
assert(user_groups.is_member_of(admins.id, 3));
user_groups.add_members(all.id, [5, 4]);
- assert.deepEqual(user_groups.get_user_group_from_id(all.id).members,
- new Set([1, 2, 3, 5, 4]));
+ assert.deepEqual(user_groups.get_user_group_from_id(all.id).members, new Set([1, 2, 3, 5, 4]));
user_groups.remove_members(all.id, [1, 4]);
- assert.deepEqual(user_groups.get_user_group_from_id(all.id).members,
- new Set([2, 3, 5]));
+ assert.deepEqual(user_groups.get_user_group_from_id(all.id).members, new Set([2, 3, 5]));
assert(user_groups.is_user_group(admins));
const object = {
diff --git a/frontend_tests/node_tests/user_pill.js b/frontend_tests/node_tests/user_pill.js
index 5383e1c8652..779fc71185c 100644
--- a/frontend_tests/node_tests/user_pill.js
+++ b/frontend_tests/node_tests/user_pill.js
@@ -2,8 +2,7 @@ zrequire("people");
set_global("md5", (s) => "md5-" + s);
zrequire("user_pill");
-set_global("page_params", {
-});
+set_global("page_params", {});
const alice = {
@@ -35,7 +34,6 @@ run_test("setup", () => {
});
run_test("create_item", () => {
-
function test_create_item(email, current_items, expected_item) {
const item = user_pill.create_item_from_email(email, current_items);
assert.deepEqual(item, expected_item);
@@ -94,7 +92,9 @@ run_test("get_items", () => {
const items = [isaac_item, bogus_item];
const pill_widget = {
- items: function () { return items; },
+ items: function () {
+ return items;
+ },
};
assert.deepEqual(user_pill.get_user_ids(pill_widget), [isaac.user_id]);
@@ -104,7 +104,9 @@ run_test("typeahead", () => {
const items = [isaac_item, bogus_item];
const pill_widget = {
- items: function () { return items; },
+ items: function () {
+ return items;
+ },
};
// Both alice and isaac are in our realm, but isaac will be
diff --git a/frontend_tests/node_tests/util.js b/frontend_tests/node_tests/util.js
index 3aea656bca7..3df03dc0791 100644
--- a/frontend_tests/node_tests/util.js
+++ b/frontend_tests/node_tests/util.js
@@ -20,7 +20,6 @@ run_test("CachedValue", () => {
assert.equal(cv.get(), 10);
cv.reset();
assert.equal(cv.get(), 12);
-
});
run_test("get_reload_topic", () => {
@@ -58,41 +57,44 @@ run_test("lower_bound", () => {
assert.equal(util.lower_bound(arr, 5, compare), 0);
assert.equal(util.lower_bound(arr, 10, compare), 0);
assert.equal(util.lower_bound(arr, 15, compare), 1);
-
});
run_test("same_recipient", () => {
- assert(util.same_recipient(
- {type: "stream", stream_id: 101, topic: "Bar"},
- {type: "stream", stream_id: 101, topic: "bar"}));
+ assert(
+ util.same_recipient(
+ {type: "stream", stream_id: 101, topic: "Bar"},
+ {type: "stream", stream_id: 101, topic: "bar"},
+ ),
+ );
- assert(!util.same_recipient(
- {type: "stream", stream_id: 101, topic: "Bar"},
- {type: "stream", stream_id: 102, topic: "whatever"}));
+ assert(
+ !util.same_recipient(
+ {type: "stream", stream_id: 101, topic: "Bar"},
+ {type: "stream", stream_id: 102, topic: "whatever"},
+ ),
+ );
- assert(util.same_recipient(
- {type: "private", to_user_ids: "101,102"},
- {type: "private", to_user_ids: "101,102"}));
+ assert(
+ util.same_recipient(
+ {type: "private", to_user_ids: "101,102"},
+ {type: "private", to_user_ids: "101,102"},
+ ),
+ );
- assert(!util.same_recipient(
- {type: "private", to_user_ids: "101,102"},
- {type: "private", to_user_ids: "103"}));
+ assert(
+ !util.same_recipient(
+ {type: "private", to_user_ids: "101,102"},
+ {type: "private", to_user_ids: "103"},
+ ),
+ );
- assert(!util.same_recipient(
- {type: "stream", stream_id: 101, topic: "Bar"},
- {type: "private"}));
+ assert(!util.same_recipient({type: "stream", stream_id: 101, topic: "Bar"}, {type: "private"}));
- assert(!util.same_recipient(
- {type: "private", to_user_ids: undefined},
- {type: "private"}));
+ assert(!util.same_recipient({type: "private", to_user_ids: undefined}, {type: "private"}));
- assert(!util.same_recipient(
- {type: "unknown type"},
- {type: "unknown type"}));
+ assert(!util.same_recipient({type: "unknown type"}, {type: "unknown type"}));
- assert(!util.same_recipient(
- undefined,
- {type: "private"}));
+ assert(!util.same_recipient(undefined, {type: "private"}));
assert(!util.same_recipient(undefined, undefined));
});
@@ -101,7 +103,9 @@ run_test("robust_uri_decode", () => {
assert.equal(util.robust_uri_decode("xxx%3Ayyy"), "xxx:yyy");
assert.equal(util.robust_uri_decode("xxx%3"), "xxx");
- set_global("decodeURIComponent", () => { throw "foo"; });
+ set_global("decodeURIComponent", () => {
+ throw "foo";
+ });
try {
util.robust_uri_decode("%E0%A4%A");
} catch (e) {
@@ -144,7 +148,8 @@ run_test("array_compare", () => {
run_test("normalize_recipients", () => {
assert.equal(
+ );
});
run_test("random_int", () => {
@@ -235,22 +240,9 @@ run_test("all_and_everyone_mentions_regexp", () => {
});
run_test("move_array_elements_to_front", () => {
- const strings = [
- "string1",
- "string3",
- "string2",
- "string4",
- ];
- const strings_selection = [
- "string4",
- "string1",
- ];
- const strings_expected = [
- "string1",
- "string4",
- "string3",
- "string2",
- ];
+ const strings = ["string1", "string3", "string2", "string4"];
+ const strings_selection = ["string4", "string1"];
+ const strings_expected = ["string1", "string4", "string3", "string2"];
const strings_no_selection = util.move_array_elements_to_front(strings, []);
const strings_no_array = util.move_array_elements_to_front([], strings_selection);
const strings_actual = util.move_array_elements_to_front(strings, strings_selection);
@@ -261,11 +253,7 @@ run_test("move_array_elements_to_front", () => {
"test@invalid@email",
];
- const emails_selection = [
- "test@localhost",
- "test@invalid@email",
- ];
+ const emails_selection = ["[email protected]", "test@localhost", "test@invalid@email"];
const emails_expected = [
"test@localhost",
@@ -296,15 +284,15 @@ run_test("clean_user_content_links", () => {
assert.equal(
util.clean_user_content_links(
'<a href="http://example.com">good</a> ' +
- '<a href="http://zulip.zulipdev.com/user_uploads/w/ha/tever/file.png">upload</a> ' +
- '<a href="http://localhost:NNNN">invalid</a> ' +
- '<a href="javascript:alert(1)">unsafe</a> ' +
- '<a href="/#fragment" target="_blank">fragment</a>',
+ '<a href="http://zulip.zulipdev.com/user_uploads/w/ha/tever/file.png">upload</a> ' +
+ '<a href="http://localhost:NNNN">invalid</a> ' +
+ '<a href="javascript:alert(1)">unsafe</a> ' +
+ '<a href="/#fragment" target="_blank">fragment</a>',
),
'<a href="http://example.com" target="_blank" rel="noopener noreferrer" title="http://example.com/">good</a> ' +
- '<a href="http://zulip.zulipdev.com/user_uploads/w/ha/tever/file.png" target="_blank" rel="noopener noreferrer" title="file.png">upload</a> ' +
- "<a>invalid</a> " +
- "<a>unsafe</a> " +
- '<a href="/#fragment" title="http://zulip.zulipdev.com/#fragment">fragment</a>',
+ '<a href="http://zulip.zulipdev.com/user_uploads/w/ha/tever/file.png" target="_blank" rel="noopener noreferrer" title="file.png">upload</a> ' +
+ "<a>invalid</a> " +
+ "<a>unsafe</a> " +
+ '<a href="/#fragment" title="http://zulip.zulipdev.com/#fragment">fragment</a>',
);
});
diff --git a/frontend_tests/node_tests/vdom.js b/frontend_tests/node_tests/vdom.js
index 3d1d730b05f..0e373854742 100644
--- a/frontend_tests/node_tests/vdom.js
+++ b/frontend_tests/node_tests/vdom.js
@@ -15,8 +15,7 @@ run_test("basics", () => {
assert.equal(
html,
- '<ul class="foo" title="cats &amp; &lt;&quot;dogs&quot;&gt;">\n\n' +
- "</ul>",
+ '<ul class="foo" title="cats &amp; &lt;&quot;dogs&quot;&gt;">\n\n' + "</ul>",
);
});
@@ -40,7 +39,7 @@ run_test("attribute escaping", () => {
assert.equal(
html,
'<ul class="&quot;&gt;something evil&lt;div class=&quot;" ' +
- 'title="apples &amp; oranges">\n\n</ul>',
+ 'title="apples &amp; oranges">\n\n</ul>',
);
});
@@ -58,11 +57,7 @@ run_test("attribute updates", () => {
const html = vdom.render_tag(ul);
- assert.equal(
- html,
- '<ul class="same" color="blue" id="101">\n\n' +
- "</ul>",
- );
+ assert.equal(html, '<ul class="same" color="blue" id="101">\n\n' + "</ul>");
let updated;
let removed;
@@ -140,20 +135,14 @@ run_test("children", () => {
assert.equal(
rendered_html,
- "<ul>\n" +
- "<li>foo1</li>\n" +
- "<li>foo2</li>\n" +
- "<li>foo3</li>\n" +
- "</ul>",
+ "<ul>\n" + "<li>foo1</li>\n" + "<li>foo2</li>\n" + "<li>foo3</li>\n" + "</ul>",
);
// Force a complete redraw.
const new_nodes = make_children([4, 5]);
const new_opts = {
keyed_nodes: new_nodes,
- attrs: [
- ["class", "main"],
- ],
+ attrs: [["class", "main"]],
};
const new_ul = vdom.ul(new_opts);
@@ -161,10 +150,7 @@ run_test("children", () => {
assert.equal(
rendered_html,
- '<ul class="main">\n' +
- "<li>foo4</li>\n" +
- "<li>foo5</li>\n" +
- "</ul>",
+ '<ul class="main">\n' + "<li>foo4</li>\n" + "<li>foo5</li>\n" + "</ul>",
);
});
@@ -190,11 +176,7 @@ run_test("partial updates", () => {
assert.equal(
rendered_html,
- "<ul>\n" +
- "<li>foo1</li>\n" +
- "<li>foo2</li>\n" +
- "<li>foo3</li>\n" +
- "</ul>",
+ "<ul>\n" + "<li>foo1</li>\n" + "<li>foo2</li>\n" + "<li>foo3</li>\n" + "</ul>",
);
replace_content = () => {
@@ -235,18 +217,12 @@ run_test("eq_array easy cases", () => {
throw Error("we should not be comparing elements");
};
- assert.equal(
- vdom.eq_array(undefined, undefined, bogus_eq),
- true);
+ assert.equal(vdom.eq_array(undefined, undefined, bogus_eq), true);
const x = [1, 2, 3];
- assert.equal(
- vdom.eq_array(x, undefined, bogus_eq),
- false);
+ assert.equal(vdom.eq_array(x, undefined, bogus_eq), false);
- assert.equal(
- vdom.eq_array(undefined, x, bogus_eq),
- false);
+ assert.equal(vdom.eq_array(undefined, x, bogus_eq), false);
assert.equal(vdom.eq_array(x, x, bogus_eq), true);
@@ -268,9 +244,7 @@ run_test("eq_array elementwise", () => {
});
run_test("error checking", () => {
- blueslip.expect(
- "error",
- "We need keyed_nodes for updates.");
+ blueslip.expect("error", "We need keyed_nodes for updates.");
const replace_content = "whatever";
const find = "whatever";
@@ -278,9 +252,6 @@ run_test("error checking", () => {
vdom.update(replace_content, find, ul, ul);
- blueslip.expect(
- "error",
- "We need keyed_nodes to render innards.");
+ blueslip.expect("error", "We need keyed_nodes to render innards.");
vdom.render_tag(ul);
-
});
diff --git a/frontend_tests/node_tests/zjquery.js b/frontend_tests/node_tests/zjquery.js
index 8dad11de3e9..7984d4e26bb 100644
--- a/frontend_tests/node_tests/zjquery.js
+++ b/frontend_tests/node_tests/zjquery.js
@@ -108,7 +108,6 @@ run_test("finding_related_objects", () => {
elem.set_parents_result(".folder", my_parents);
elem.parents(".folder").addClass("active");
assert(my_parents.hasClass("active"));
-
});
run_test("clicks", () => {
@@ -138,7 +137,6 @@ run_test("clicks", () => {
// and keydown
$(".some-class").keydown();
assert.equal(state.keydown, true);
-
});
run_test("events", () => {
diff --git a/frontend_tests/puppeteer_lib/common.js b/frontend_tests/puppeteer_lib/common.js
index 5c8de6678b9..8de68277373 100644
--- a/frontend_tests/puppeteer_lib/common.js
+++ b/frontend_tests/puppeteer_lib/common.js
@@ -13,10 +13,7 @@ class CommonUtils {
async ensure_browser() {
if (this.browser === null) {
this.browser = await puppeteer.launch({
- args: [
- "--window-size=1400,1024",
- "--no-sandbox", "--disable-setuid-sandbox",
- ],
+ args: ["--window-size=1400,1024", "--no-sandbox", "--disable-setuid-sandbox"],
defaultViewport: {width: 1280, height: 1024},
headless: true,
});
@@ -134,8 +131,9 @@ class CommonUtils {
}
async wait_for_fully_processed_message(page, content) {
- await page.waitFor((content) => {
- /*
+ await page.waitFor(
+ (content) => {
+ /*
The tricky part about making sure that
a message has actually been fully processed
is that we'll "locally echo" the message
@@ -156,33 +154,36 @@ class CommonUtils {
- does it look to have been
re-rendered based on server info?
*/
- const last_msg = current_msg_list.last();
- if (last_msg === undefined) {
- return false;
- }
+ const last_msg = current_msg_list.last();
+ if (last_msg === undefined) {
+ return false;
+ }
- if (last_msg.raw_content !== content) {
- return false;
- }
+ if (last_msg.raw_content !== content) {
+ return false;
+ }
- if (last_msg.locally_echoed) {
- return false;
- }
+ if (last_msg.locally_echoed) {
+ return false;
+ }
- const row = rows.last_visible();
- if (rows.id(row) !== last_msg.id) {
- return false;
- }
+ const row = rows.last_visible();
+ if (rows.id(row) !== last_msg.id) {
+ return false;
+ }
- /*
+ /*
Make sure the message is completely
re-rendered from its original "local echo"
version by looking for the star icon. We
don't add the star icon until the server
responds.
*/
- return row.find(".star").length === 1;
- }, {}, content);
+ return row.find(".star").length === 1;
+ },
+ {},
+ content,
+ );
}
// Wait for any previous send to finish, then send a message.
@@ -224,8 +225,10 @@ class CommonUtils {
// confirm if compose box is empty.
const compose_box_element = await page.$("#compose-textarea");
- const compose_box_content = await page.evaluate((element) => element.textContent,
- compose_box_element);
+ const compose_box_content = await page.evaluate(
+ (element) => element.textContent,
+ compose_box_element,
+ );
assert.equal(compose_box_content, "", "Compose box not empty after message sent");
if (!outside_view) {
@@ -241,11 +244,7 @@ class CommonUtils {
async send_multiple_messages(page, msgs) {
for (let msg_index = 0; msg_index < msgs.length; msg_index += 1) {
const msg = msgs[msg_index];
- await this.send_message(
- page,
- msg.stream !== undefined ? "stream" : "private",
- msg,
- );
+ await this.send_message(page, msg.stream !== undefined ? "stream" : "private", msg);
}
}
diff --git a/frontend_tests/zjsunit/finder.js b/frontend_tests/zjsunit/finder.js
index e7f83840d12..bfda0b605f2 100644
--- a/frontend_tests/zjsunit/finder.js
+++ b/frontend_tests/zjsunit/finder.js
@@ -8,7 +8,7 @@ exports.find_files_to_run = function () {
if (process.argv[2]) {
oneFileFilter = process.argv
.slice(2)
- .filter((filename) => (/[.]js$/).test(filename))
+ .filter((filename) => /[.]js$/.test(filename))
.map((filename) => filename.replace(/\.js$/i, ""));
}
@@ -16,9 +16,10 @@ exports.find_files_to_run = function () {
// to framework code)
const tests_dir = __dirname.replace(/zjsunit/, "node_tests");
- let tests = fs.readdirSync(tests_dir)
- .filter((filename) => !(/^\./i).test(filename))
- .filter((filename) => (/\.js$/i).test(filename))
+ let tests = fs
+ .readdirSync(tests_dir)
+ .filter((filename) => !/^\./i.test(filename))
+ .filter((filename) => /\.js$/i.test(filename))
.map((filename) => filename.replace(/\.js$/i, ""));
if (oneFileFilter.length > 0) {
diff --git a/frontend_tests/zjsunit/i18n.js b/frontend_tests/zjsunit/i18n.js
index 37137dd2fc7..956a559efa0 100644
--- a/frontend_tests/zjsunit/i18n.js
+++ b/frontend_tests/zjsunit/i18n.js
@@ -32,8 +32,7 @@ exports.t = function (str, context) {
});
for (const item of substitutions) {
- str = str.replace(item.prefix + item.keyword + item.suffix,
- context[item.keyword]);
+ str = str.replace(item.prefix + item.keyword + item.suffix, context[item.keyword]);
}
return "translated: " + str;
diff --git a/frontend_tests/zjsunit/index.js b/frontend_tests/zjsunit/index.js
index ba2670dc35e..a83d063aac5 100644
--- a/frontend_tests/zjsunit/index.js
+++ b/frontend_tests/zjsunit/index.js
@@ -6,7 +6,9 @@ require("@babel/register")({
extensions: [".es6", ".es", ".jsx", ".js", ".mjs", ".ts"],
only: [
new RegExp("^" + escapeRegExp(path.resolve(__dirname, "../../static/js")) + path.sep),
- new RegExp("^" + escapeRegExp(path.resolve(__dirname, "../../static/shared/js")) + path.sep),
+ new RegExp(
+ "^" + escapeRegExp(path.resolve(__dirname, "../../static/shared/js")) + path.sep,
+ ),
],
plugins: ["rewire-ts"],
});
@@ -77,7 +79,9 @@ global.read_fixture_data = (fn) => {
function short_tb(tb) {
const lines = tb.split("\n");
- const i = lines.findIndex((line) => line.includes("run_test") || line.includes("run_one_module"));
+ const i = lines.findIndex(
+ (line) => line.includes("run_test") || line.includes("run_one_module"),
+ );
if (i === -1) {
return tb;
diff --git a/frontend_tests/zjsunit/markdown_assert.js b/frontend_tests/zjsunit/markdown_assert.js
index cac1dccd658..fff9fa5dbdc 100644
--- a/frontend_tests/zjsunit/markdown_assert.js
+++ b/frontend_tests/zjsunit/markdown_assert.js
@@ -30,14 +30,13 @@ let _markdownComparerInstance = null;
class MarkdownComparer {
constructor(output_formatter) {
- this._output_formatter = output_formatter || function (actual, expected) {
- return [
- "Actual and expected output do not match.",
- actual,
- "!=",
- expected,
- ].join("\n");
- };
+ this._output_formatter =
+ output_formatter ||
+ function (actual, expected) {
+ return ["Actual and expected output do not match.", actual, "!=", expected].join(
+ "\n",
+ );
+ };
this._document = new JSDOM().window.document;
}
@@ -73,7 +72,9 @@ class MarkdownComparer {
}
// If put in above forEach loop, causes issues (possible nodes.attribute invalidation?)
- attributeList.forEach((attr) => {node.removeAttribute(attr.name);});
+ attributeList.forEach((attr) => {
+ node.removeAttribute(attr.name);
+ });
attributeList.sort((a, b) => {
const name_a = a.name;
@@ -136,10 +137,12 @@ class MarkdownComparer {
if (comparison_results.are_equivalent === false) {
throw new assert.AssertionError({
- message: message + this._output_formatter(
- comparison_results.html.actual,
- comparison_results.html.expected,
- ),
+ message:
+ message +
+ this._output_formatter(
+ comparison_results.html.actual,
+ comparison_results.html.expected,
+ ),
});
}
}
@@ -152,12 +155,14 @@ class MarkdownComparer {
if (comparison_results.are_equivalent) {
throw new assert.AssertionError({
- message: message + [
- "actual and expected output produce semantially identical HTML",
- actual,
- "==",
- expected,
- ].join("\n"),
+ message:
+ message +
+ [
+ "actual and expected output produce semantially identical HTML",
+ actual,
+ "==",
+ expected,
+ ].join("\n"),
});
}
}
@@ -165,10 +170,12 @@ class MarkdownComparer {
function returnComparer() {
if (!_markdownComparerInstance) {
- _markdownComparerInstance = new MarkdownComparer((actual, expected) => [
- "Actual and expected output do not match. Showing diff",
- mdiff.diff_strings(actual, expected),
- ].join("\n"));
+ _markdownComparerInstance = new MarkdownComparer((actual, expected) =>
+ [
+ "Actual and expected output do not match. Showing diff",
+ mdiff.diff_strings(actual, expected),
+ ].join("\n"),
+ );
}
return _markdownComparerInstance;
}
diff --git a/frontend_tests/zjsunit/mdiff.js b/frontend_tests/zjsunit/mdiff.js
index 29d8de18cca..36b8ed0c443 100644
--- a/frontend_tests/zjsunit/mdiff.js
+++ b/frontend_tests/zjsunit/mdiff.js
@@ -108,13 +108,16 @@ function diff_strings(string_0, string_1) {
} else if (line.startsWith("?")) {
changes_list = parse_questionmark_line(line);
output_lines[output_lines.length - 1] = apply_color(
- output_lines[output_lines.length - 1], changes_list);
+ output_lines[output_lines.length - 1],
+ changes_list,
+ );
} else {
output_lines.push(line);
}
});
- const emphasize_codes = (string) => "\u001b[34m" + string.slice(0, 1) + "\u001b[0m" + string.slice(1);
+ const emphasize_codes = (string) =>
+ "\u001b[34m" + string.slice(0, 1) + "\u001b[0m" + string.slice(1);
output_lines = output_lines.map(emphasize_codes);
return output_lines.join("\n");
@@ -129,12 +132,15 @@ if (require.main === module) {
const argv = require("minimist")(process.argv.slice(2));
if (Object.prototype.hasOwnProperty.call(argv, "help")) {
- console.log(process.argv[0] + " " + process.argv[1] +
- " [ --help ]" +
- " string_0" +
- " string_1" +
- "\n" +
- "Where string_0 and string_1 are the strings to be diffed",
+ console.log(
+ process.argv[0] +
+ " " +
+ process.argv[1] +
+ " [ --help ]" +
+ " string_0" +
+ " string_1" +
+ "\n" +
+ "Where string_0 and string_1 are the strings to be diffed",
);
}
diff --git a/frontend_tests/zjsunit/namespace.js b/frontend_tests/zjsunit/namespace.js
index 85724fc0f71..03908bd0b5c 100644
--- a/frontend_tests/zjsunit/namespace.js
+++ b/frontend_tests/zjsunit/namespace.js
@@ -88,8 +88,7 @@ exports.with_overrides = function (test_function) {
// If you get a failure from this, you probably just
// need to have your test do its own overrides and
// not cherry-pick off of the prior test's setup.
- global[module][func_name] =
- "ATTEMPTED TO REUSE OVERRIDDEN VALUE FROM PRIOR TEST";
+ global[module][func_name] = "ATTEMPTED TO REUSE OVERRIDDEN VALUE FROM PRIOR TEST";
});
};
diff --git a/frontend_tests/zjsunit/zblueslip.js b/frontend_tests/zjsunit/zblueslip.js
index 8309afa6ca4..b7f8fa9dab7 100644
--- a/frontend_tests/zjsunit/zblueslip.js
+++ b/frontend_tests/zjsunit/zblueslip.js
@@ -46,7 +46,7 @@ exports.make_zblueslip = function () {
// Only throw this for message types we want to explicitly track.
// For example, we do not want to throw here for debug messages.
if (opts[name]) {
- throw Error (`Unexpected '${name}' message: ${message}`);
+ throw Error(`Unexpected '${name}' message: ${message}`);
}
continue;
}
@@ -56,9 +56,15 @@ exports.make_zblueslip = function () {
for (const obj of lib.test_data[name]) {
const message = obj.message;
if (obj.count > 0) {
- throw Error(`We did not see expected ${obj.expected_count} of '${name}': ${message}`);
+ throw Error(
+ `We did not see expected ${obj.expected_count} of '${name}': ${message}`,
+ );
} else if (obj.count < 0) {
- throw Error(`We saw ${obj.expected_count - obj.count} (expected ${obj.expected_count}) of '${name}': ${message}`);
+ throw Error(
+ `We saw ${obj.expected_count - obj.count} (expected ${
+ obj.expected_count
+ }) of '${name}': ${message}`,
+ );
}
}
}
diff --git a/frontend_tests/zjsunit/zjquery.js b/frontend_tests/zjsunit/zjquery.js
index 7d3888887bb..a9416a78b61 100644
--- a/frontend_tests/zjsunit/zjquery.js
+++ b/frontend_tests/zjsunit/zjquery.js
@@ -284,8 +284,10 @@ exports.make_new_elem = function (selector, opts) {
},
parents: function (parents_selector) {
const result = parents_result.get(parents_selector);
- assert(result, "You need to call set_parents_result for " +
- parents_selector + " in " + selector);
+ assert(
+ result,
+ "You need to call set_parents_result for " + parents_selector + " in " + selector,
+ );
return result;
},
prepend: function (arg) {
@@ -416,7 +418,8 @@ exports.make_zjquery = function (opts) {
// we can infer by assert.equal trying to access the
// "stack" key.
if (key === "stack") {
- const error = "\nInstead of doing equality checks on a full object, " +
+ const error =
+ "\nInstead of doing equality checks on a full object, " +
'do `assert_equal(foo.selector, ".some_class")\n';
throw Error(error);
}
@@ -493,12 +496,9 @@ exports.make_zjquery = function (opts) {
selector.location ||
selector.includes("#") ||
selector.includes(".") ||
- selector.includes("[") && selector.indexOf("]") >= selector.indexOf("[");
-
- assert(valid_selector,
- "Invalid selector: " + selector +
- " Use $.create() maybe?");
+ (selector.includes("[") && selector.indexOf("]") >= selector.indexOf("["));
+ assert(valid_selector, "Invalid selector: " + selector + " Use $.create() maybe?");
if (!elems.has(selector)) {
const elem = new_elem(selector);
@@ -508,8 +508,7 @@ exports.make_zjquery = function (opts) {
};
zjquery.create = function (name) {
- assert(!elems.has(name),
- "You already created an object with this name!!");
+ assert(!elems.has(name), "You already created an object with this name!!");
const elem = new_elem(name);
elems.set(name, elem);
return elem;
@@ -519,7 +518,9 @@ exports.make_zjquery = function (opts) {
elems.set(selector, stub);
};
- zjquery.trim = function (s) { return s; };
+ zjquery.trim = function (s) {
+ return s;
+ };
zjquery.state = function () {
// useful for debugging
diff --git a/static/js/activity.js b/static/js/activity.js
index ba6e4f8b9fc..19353f50df0 100644
--- a/static/js/activity.js
+++ b/static/js/activity.js
@@ -134,8 +134,10 @@ exports.compute_active_status = function () {
//
// The check for `get_idle_on_system === undefined` is feature
// detection; older desktop app releases never set that property.
- if (window.electron_bridge !== undefined
- && window.electron_bridge.get_idle_on_system !== undefined) {
+ if (
+ window.electron_bridge !== undefined &&
+ window.electron_bridge.get_idle_on_system !== undefined
+ ) {
if (window.electron_bridge.get_idle_on_system()) {
return exports.IDLE;
}
@@ -207,10 +209,12 @@ exports.initialize = function () {
});
$(window).focus(mark_client_active);
- $(window).idle({idle: DEFAULT_IDLE_TIMEOUT_MS,
- onIdle: mark_client_idle,
- onActive: mark_client_active,
- keepTracking: true});
+ $(window).idle({
+ idle: DEFAULT_IDLE_TIMEOUT_MS,
+ onIdle: mark_client_idle,
+ onActive: mark_client_active,
+ keepTracking: true,
+ });
exports.set_cursor_and_filter();
diff --git a/static/js/admin.js b/static/js/admin.js
index 822c899799b..1266ce4a118 100644
--- a/static/js/admin.js
+++ b/static/js/admin.js
@@ -14,8 +14,9 @@ const admin_settings_label = {
realm_inline_url_embed_preview: i18n.t("Show previews of linked websites"),
realm_default_twenty_four_hour_time: i18n.t("Time format"),
realm_send_welcome_emails: i18n.t("Send emails introducing Zulip to new users"),
- realm_message_content_allowed_in_email_notifications:
- i18n.t("Allow message content in missed message emails"),
+ realm_message_content_allowed_in_email_notifications: i18n.t(
+ "Allow message content in missed message emails",
+ ),
realm_digest_emails_enabled: i18n.t("Send weekly digest emails to inactive users"),
realm_default_code_block_language: i18n.t("Default language for code blocks:"),
@@ -30,7 +31,8 @@ function insert_tip_box() {
return;
}
const tip_box = render_settings_organization_settings_tip({is_admin: page_params.is_admin});
- $(".organization-box").find(".settings-section")
+ $(".organization-box")
+ .find(".settings-section")
.not("#emoji-settings")
.not("#user-groups-admin")
.not("#organization-auth-settings")
@@ -60,10 +62,12 @@ exports.build_page = function () {
realm_add_emoji_by_admins_only: page_params.realm_add_emoji_by_admins_only,
can_add_emojis: settings_emoji.can_add_emoji(),
realm_allow_community_topic_editing: page_params.realm_allow_community_topic_editing,
- realm_message_content_edit_limit_minutes:
- settings_org.get_realm_time_limits_in_minutes("realm_message_content_edit_limit_seconds"),
- realm_message_content_delete_limit_minutes:
- settings_org.get_realm_time_limits_in_minutes("realm_message_content_delete_limit_seconds"),
+ realm_message_content_edit_limit_minutes: settings_org.get_realm_time_limits_in_minutes(
+ "realm_message_content_edit_limit_seconds",
+ ),
+ realm_message_content_delete_limit_minutes: settings_org.get_realm_time_limits_in_minutes(
+ "realm_message_content_delete_limit_seconds",
+ ),
realm_message_retention_days: page_params.realm_message_retention_days,
realm_allow_edit_history: page_params.realm_allow_edit_history,
language_list: page_params.language_list,
@@ -125,11 +129,11 @@ exports.build_page = function () {
// default_twenty_four_hour time is a boolean in the API but a
// dropdown, so we need to convert the value to a string for
// storage in the browser's DOM.
- $("#id_realm_default_twenty_four_hour_time").val(JSON.stringify(
- page_params.realm_default_twenty_four_hour_time));
+ $("#id_realm_default_twenty_four_hour_time").val(
+ JSON.stringify(page_params.realm_default_twenty_four_hour_time),
+ );
};
-
exports.launch = function (section) {
settings.build_page();
exports.build_page();
diff --git a/static/js/alert_words.js b/static/js/alert_words.js
index 2d8ccfaf7b3..48a65897e2e 100644
--- a/static/js/alert_words.js
+++ b/static/js/alert_words.js
@@ -34,29 +34,31 @@ exports.process_message = function (message) {
for (const word of my_alert_words) {
const clean = escape_user_regex(word);
- const before_punctuation = '\\s|^|>|[\\(\\".,\';\\[]';
- const after_punctuation = '\\s|$|<|[\\)\\"\\?!:.,\';\\]!]';
+ const before_punctuation = "\\s|^|>|[\\(\\\".,';\\[]";
+ const after_punctuation = "\\s|$|<|[\\)\\\"\\?!:.,';\\]!]";
-
- const regex = new RegExp("(" + before_punctuation + ")" +
- "(" + clean + ")" +
- "(" + after_punctuation + ")", "ig");
- message.content = message.content.replace(regex, (match, before, word,
- after, offset, content) => {
- // Logic for ensuring that we don't muck up rendered HTML.
- const pre_match = content.substring(0, offset);
- // We want to find the position of the `<` and `>` only in the
- // match and the string before it. So, don't include the last
- // character of match in `check_string`. This covers the corner
- // case when there is an alert word just before `<` or `>`.
- const check_string = pre_match + match.substring(0, match.length - 1);
- const in_tag = check_string.lastIndexOf("<") > check_string.lastIndexOf(">");
- // Matched word is inside a HTML tag so don't perform any highlighting.
- if (in_tag === true) {
- return before + word + after;
- }
- return before + "<span class='alert-word'>" + word + "</span>" + after;
- });
+ const regex = new RegExp(
+ "(" + before_punctuation + ")" + "(" + clean + ")" + "(" + after_punctuation + ")",
+ "ig",
+ );
+ message.content = message.content.replace(
+ regex,
+ (match, before, word, after, offset, content) => {
+ // Logic for ensuring that we don't muck up rendered HTML.
+ const pre_match = content.substring(0, offset);
+ // We want to find the position of the `<` and `>` only in the
+ // match and the string before it. So, don't include the last
+ // character of match in `check_string`. This covers the corner
+ // case when there is an alert word just before `<` or `>`.
+ const check_string = pre_match + match.substring(0, match.length - 1);
+ const in_tag = check_string.lastIndexOf("<") > check_string.lastIndexOf(">");
+ // Matched word is inside a HTML tag so don't perform any highlighting.
+ if (in_tag === true) {
+ return before + word + after;
+ }
+ return before + "<span class='alert-word'>" + word + "</span>" + after;
+ },
+ );
}
};
diff --git a/static/js/alert_words_ui.js b/static/js/alert_words_ui.js
index c32f1869766..f2f53b9a0a3 100644
--- a/static/js/alert_words_ui.js
+++ b/static/js/alert_words_ui.js
@@ -45,8 +45,9 @@ function add_alert_word(alert_word) {
url: "/json/users/me/alert_words",
data: {alert_words: JSON.stringify(words_to_be_added)},
success: function () {
- const message = i18n.t('Alert word "__word__" added successfully!',
- {word: words_to_be_added[0]});
+ const message = i18n.t('Alert word "__word__" added successfully!', {
+ word: words_to_be_added[0],
+ });
update_alert_word_status(message, false);
$("#create_alert_word_name").val("");
},
diff --git a/static/js/analytics/support.js b/static/js/analytics/support.js
index 840e303a18d..f93f2202cf4 100644
--- a/static/js/analytics/support.js
+++ b/static/js/analytics/support.js
@@ -2,7 +2,10 @@ $(() => {
$("body").on("click", ".scrub-realm-button", function (e) {
e.preventDefault();
const string_id = $(this).data("string-id");
- const message = 'Do you really want to scrub the realm "' + string_id + '"? This action is irreversible.';
+ const message =
+ 'Do you really want to scrub the realm "' +
+ string_id +
+ '"? This action is irreversible.';
// eslint-disable-next-line no-alert
if (confirm(message)) {
this.form.submit();
diff --git a/static/js/archive.js b/static/js/archive.js
index 69c134d9f4d..c8acb1d79f5 100644
--- a/static/js/archive.js
+++ b/static/js/archive.js
@@ -13,7 +13,6 @@ function all_message_timestamps_to_human_readable() {
});
}
-
exports.initialize = function () {
const all_message_groups = [];
let current_message_group = {};
@@ -37,8 +36,11 @@ exports.initialize = function () {
all_message_groups.push(current_message_group);
current_message_group = {};
current_message_group.message_containers = [];
- current_message_group.group_date_divider_html =
- timerender.render_date(time, prev_time, today)[0].outerHTML;
+ current_message_group.group_date_divider_html = timerender.render_date(
+ time,
+ prev_time,
+ today,
+ )[0].outerHTML;
current_message_group.show_group_date_divider = true;
current_message_group.display_recipient = stream_name;
current_message_group.topic = topic;
@@ -48,7 +50,10 @@ 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(current_message_row.next().find(".message_time").first().html(), 10);
+ const next_msg_time = parseInt(
+ current_message_row.next().find(".message_time").first().html(),
+ 10,
+ );
if (current_message_row.next().length === 0) {
separate_into_groups(current_message_row, cur_msg_time);
@@ -124,8 +129,10 @@ $(() => {
$.fn.safeOuterWidth = function (...args) {
return this.outerWidth(...args) || 0;
};
- $(".app").scroll(_.throttle(() => {
- scroll_finish();
- }, 50));
+ $(".app").scroll(
+ _.throttle(() => {
+ scroll_finish();
+ }, 50),
+ );
exports.initialize();
});
diff --git a/static/js/attachments_ui.js b/static/js/attachments_ui.js
index 1347116f214..8b678528dab 100644
--- a/static/js/attachments_ui.js
+++ b/static/js/attachments_ui.js
@@ -16,7 +16,7 @@ exports.bytes_to_size = function (bytes, kb_with_1024_bytes) {
const i = 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;
+ size = Math.round((bytes / Math.pow(kb_size, i)) * 10) / 10;
}
return size + " " + sizes[i];
};
@@ -25,7 +25,7 @@ exports.percentage_used_space = function (uploads_size) {
if (page_params.realm_upload_quota === null) {
return null;
}
- return (100 * uploads_size / page_params.realm_upload_quota).toFixed(1);
+ return ((100 * uploads_size) / page_params.realm_upload_quota).toFixed(1);
};
function set_upload_space_stats() {
@@ -59,8 +59,12 @@ function sort_mentioned_in(a, b) {
const a_m = a.messages[0];
const b_m = b.messages[0];
- if (!a_m) { return 1; }
- if (!b_m) { return -1; }
+ if (!a_m) {
+ return 1;
+ }
+ if (!b_m) {
+ return -1;
+ }
if (a_m.id > b_m.id) {
return 1;
diff --git a/static/js/avatar.js b/static/js/avatar.js
index 4f4bc195d0c..7ccbbc1939c 100644
--- a/static/js/avatar.js
+++ b/static/js/avatar.js
@@ -1,5 +1,4 @@
exports.build_bot_create_widget = function () {
-
// We have to do strange gyrations with the file input to clear it,
// where we replace it wholesale, so we generalize the file input with
// a callback function.
diff --git a/static/js/billing/billing.js b/static/js/billing/billing.js
index 7d188962e68..e1017009632 100644
--- a/static/js/billing/billing.js
+++ b/static/js/billing/billing.js
@@ -2,7 +2,8 @@ exports.initialize = function () {
helpers.set_tab("billing");
const stripe_key = $("#payment-method").data("key");
- const card_change_handler = StripeCheckout.configure({ // eslint-disable-line no-undef
+ const card_change_handler = StripeCheckout.configure({
+ // eslint-disable-line no-undef
key: stripe_key,
image: "/static/images/logo/zulip-icon-128x128.png",
locale: "auto",
@@ -26,7 +27,9 @@ exports.initialize = function () {
});
$("#change-plan-status").on("click", (e) => {
- helpers.create_ajax_request("/json/billing/plan/change", "planchange", undefined, ["status"]);
+ helpers.create_ajax_request("/json/billing/plan/change", "planchange", undefined, [
+ "status",
+ ]);
e.preventDefault();
});
};
diff --git a/static/js/billing/helpers.js b/static/js/billing/helpers.js
index 33a1cb68d79..b3669025910 100644
--- a/static/js/billing/helpers.js
+++ b/static/js/billing/helpers.js
@@ -1,4 +1,10 @@
-exports.create_ajax_request = function (url, form_name, stripe_token = null, numeric_inputs = [], redirect_to = "/billing") {
+exports.create_ajax_request = function (
+ url,
+ form_name,
+ stripe_token = null,
+ numeric_inputs = [],
+ redirect_to = "/billing",
+) {
const form = $("#" + form_name + "-form");
const form_loading_indicator = "#" + form_name + "_loading_indicator";
const form_input_section = "#" + form_name + "-input-section";
@@ -9,8 +15,10 @@ exports.create_ajax_request = function (url, form_name, stripe_token = null, num
const zulip_limited_section = "#zulip-limited-section";
const free_trial_alert_message = "#free-trial-alert-message";
- loading.make_indicator($(form_loading_indicator),
- {text: "Processing ...", abs_positioned: true});
+ loading.make_indicator($(form_loading_indicator), {
+ text: "Processing ...",
+ abs_positioned: true,
+ });
$(form_input_section).hide();
$(form_error).hide();
$(form_loading).show();
@@ -70,15 +78,14 @@ exports.format_money = function (cents) {
};
exports.update_charged_amount = function (prices, schedule) {
- $("#charged_amount").text(
- exports.format_money(page_params.seat_count * prices[schedule]),
- );
+ $("#charged_amount").text(exports.format_money(page_params.seat_count * prices[schedule]));
};
exports.update_discount_details = function (organization_type) {
const discount_details = {
open_source: "Open source projects are eligible for fully sponsored (free) Zulip Standard.",
- research: "Academic research organizations are eligible for fully sponsored (free) Zulip Standard.",
+ research:
+ "Academic research organizations are eligible for fully sponsored (free) Zulip Standard.",
non_profit: "Nonprofits are eligible for an 85%-100% discount.",
event: "Events are eligible for fully sponsored (free) Zulip Standard.",
education: "Education use is eligible for an 85%-100% discount.",
diff --git a/static/js/billing/upgrade.js b/static/js/billing/upgrade.js
index 6eea0122797..d28161b607f 100644
--- a/static/js/billing/upgrade.js
+++ b/static/js/billing/upgrade.js
@@ -1,12 +1,15 @@
exports.initialize = () => {
helpers.set_tab("upgrade");
- const add_card_handler = StripeCheckout.configure({ // eslint-disable-line no-undef
+ const add_card_handler = StripeCheckout.configure({
+ // eslint-disable-line no-undef
key: $("#autopay-form").data("key"),
image: "/static/images/logo/zulip-icon-128x128.png",
locale: "auto",
token: function (stripe_token) {
- helpers.create_ajax_request("/json/billing/upgrade", "autopay", stripe_token, ["licenses"]);
+ helpers.create_ajax_request("/json/billing/upgrade", "autopay", stripe_token, [
+ "licenses",
+ ]);
},
});
@@ -38,7 +41,13 @@ exports.initialize = () => {
$("#sponsorship-button").on("click", (e) => {
e.preventDefault();
- helpers.create_ajax_request("/json/billing/sponsorship", "sponsorship", undefined, undefined, "/");
+ helpers.create_ajax_request(
+ "/json/billing/sponsorship",
+ "sponsorship",
+ undefined,
+ undefined,
+ "/",
+ );
});
const prices = {};
diff --git a/static/js/blueslip.js b/static/js/blueslip.js
index 57d733f87fc..b13e11925c7 100644
--- a/static/js/blueslip.js
+++ b/static/js/blueslip.js
@@ -29,18 +29,24 @@ Logger.prototype = (function () {
return function Logger_func(...args) {
const now = new Date();
const date_str =
- now.getUTCFullYear() + "-" +
- pad(now.getUTCMonth() + 1, 2) + "-" +
- pad(now.getUTCDate(), 2) + " " +
- pad(now.getUTCHours(), 2) + ":" +
- pad(now.getUTCMinutes(), 2) + ":" +
- pad(now.getUTCSeconds(), 2) + "." +
- pad(now.getUTCMilliseconds(), 3) + " UTC";
-
- const str_args = args.map((x) => typeof x === "object" ? JSON.stringify(x) : x);
-
- const log_entry = date_str + " " + name.toUpperCase() +
- ": " + str_args.join("");
+ now.getUTCFullYear() +
+ "-" +
+ pad(now.getUTCMonth() + 1, 2) +
+ "-" +
+ pad(now.getUTCDate(), 2) +
+ " " +
+ pad(now.getUTCHours(), 2) +
+ ":" +
+ pad(now.getUTCMinutes(), 2) +
+ ":" +
+ pad(now.getUTCSeconds(), 2) +
+ "." +
+ pad(now.getUTCMilliseconds(), 3) +
+ " UTC";
+
+ const str_args = args.map((x) => (typeof x === "object" ? JSON.stringify(x) : x));
+
+ const log_entry = date_str + " " + name.toUpperCase() + ": " + str_args.join("");
this._memory_log.push(log_entry);
// Don't let the log grow without bound
@@ -93,10 +99,12 @@ function report_error(msg, stack, opts) {
}
const key = ":" + msg + stack;
- if (reported_errors.has(key)
- || last_report_attempt.has(key)
+ if (
+ reported_errors.has(key) ||
+ (last_report_attempt.has(key) &&
// Only try to report a given error once every 5 minutes
- && Date.now() - last_report_attempt.get(key) <= 60 * 5 * 1000) {
+ Date.now() - last_report_attempt.get(key) <= 60 * 5 * 1000)
+ ) {
return;
}
@@ -145,18 +153,23 @@ function report_error(msg, stack, opts) {
// invoked). In any case, it will pretty clear that
// something is wrong with the page and the user will
// probably try to reload anyway.
- ui_report.message("Oops. It seems something has gone wrong. " +
- "The error has been reported to the fine " +
- "folks at Zulip, but, in the mean time, " +
- "please try reloading the page.",
- $("#home-error"), "alert-error");
+ ui_report.message(
+ "Oops. It seems something has gone wrong. " +
+ "The error has been reported to the fine " +
+ "folks at Zulip, but, in the mean time, " +
+ "please try reloading the page.",
+ $("#home-error"),
+ "alert-error",
+ );
}
},
error: function () {
if (opts.show_ui_msg && ui_report !== undefined) {
- ui_report.message("Oops. It seems something has gone wrong. " +
- "Please try reloading the page.",
- $("#home-error"), "alert-error");
+ ui_report.message(
+ "Oops. It seems something has gone wrong. " + "Please try reloading the page.",
+ $("#home-error"),
+ "alert-error",
+ );
}
},
});
@@ -283,10 +296,14 @@ exports.preview_node = function (node) {
const className = node.className.length ? node.className : false;
const id = node.id.length ? node.id : false;
- const node_preview = "<" + tag +
- (id ? " id='" + id + "'" : "") +
- (className ? " class='" + className + "'" : "") +
- "></" + tag + ">";
+ const node_preview =
+ "<" +
+ tag +
+ (id ? " id='" + id + "'" : "") +
+ (className ? " class='" + className + "'" : "") +
+ "></" +
+ tag +
+ ">";
return node_preview;
};
diff --git a/static/js/blueslip_stacktrace.ts b/static/js/blueslip_stacktrace.ts
index e7a48e44c73..7b4aa7f970d 100644
--- a/static/js/blueslip_stacktrace.ts
+++ b/static/js/blueslip_stacktrace.ts
@@ -38,7 +38,7 @@ export function clean_path(full_path: string): string {
export function clean_function_name(
function_name: string | undefined,
-): { scope: string; name: string } | undefined {
+): {scope: string; name: string} | undefined {
if (function_name === undefined) {
return undefined;
}
@@ -49,7 +49,7 @@ export function clean_function_name(
};
}
-const sourceCache: { [source: string]: string | Promise<string> } = {};
+const sourceCache: {[source: string]: string | Promise<string>} = {};
const stack_trace_gps = new StackTraceGPS({sourceCache});
diff --git a/static/js/bot_data.js b/static/js/bot_data.js
index b3f6e5094c3..98263ff9da1 100644
--- a/static/js/bot_data.js
+++ b/static/js/bot_data.js
@@ -16,8 +16,7 @@ const bot_fields = [
];
const services = new Map();
-const services_fields = ["base_url", "interface",
- "config_data", "service_name", "token"];
+const services_fields = ["base_url", "interface", "config_data", "service_name", "token"];
const send_change_event = _.debounce(() => {
settings_bots.render_bots();
diff --git a/static/js/buddy_data.js b/static/js/buddy_data.js
index e69aec82986..4824c37a40a 100644
--- a/static/js/buddy_data.js
+++ b/static/js/buddy_data.js
@@ -218,10 +218,7 @@ exports.get_title_data = function (user_ids_string, is_group) {
const bot_owner = people.get_bot_owner_user(person);
if (bot_owner) {
- const bot_owner_name = i18n.t(
- "Owner: __name__",
- {name: bot_owner.full_name},
- );
+ const bot_owner_name = i18n.t("Owner: __name__", {name: bot_owner.full_name});
return {
first_line: person.full_name,
@@ -236,7 +233,6 @@ exports.get_title_data = function (user_ids_string, is_group) {
second_line: "",
third_line: "",
};
-
}
// For buddy list and individual PMS. Since is_group=False, it's
diff --git a/static/js/channel.js b/static/js/channel.js
index ae56eda6b47..788844452d7 100644
--- a/static/js/channel.js
+++ b/static/js/channel.js
@@ -3,8 +3,10 @@ const pending_requests = [];
function add_pending_request(jqXHR) {
pending_requests.push(jqXHR);
if (pending_requests.length > 50) {
- blueslip.warn("The length of pending_requests is over 50. Most likely " +
- "they are not being correctly removed.");
+ blueslip.warn(
+ "The length of pending_requests is over 50. Most likely " +
+ "they are not being correctly removed.",
+ );
}
}
@@ -44,16 +46,19 @@ function call(args, idempotent) {
if (xhr.status === 403) {
try {
if (JSON.parse(xhr.responseText).code === "CSRF_FAILED") {
- reload.initiate({immediate: true,
- save_pointer: true,
- save_narrow: true,
- save_compose: true});
+ reload.initiate({
+ immediate: true,
+ save_pointer: true,
+ save_narrow: true,
+ save_compose: true,
+ });
}
} catch (ex) {
- blueslip.error("Unexpected 403 response from server",
- {xhr: xhr.responseText,
- args: args},
- ex.stack);
+ blueslip.error(
+ "Unexpected 403 response from server",
+ {xhr: xhr.responseText, args: args},
+ ex.stack,
+ );
}
}
return orig_error(xhr, error_type, xhn);
diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js
index a2d8a5f4546..9360d885ea0 100644
--- a/static/js/click_handlers.js
+++ b/static/js/click_handlers.js
@@ -7,13 +7,13 @@ const render_buddy_list_tooltip_content = require("../templates/buddy_list_toolt
function convert_enter_to_click(e) {
const key = e.which;
- if (key === 13) { // enter
+ if (key === 13) {
+ // enter
$(e.currentTarget).click();
}
}
exports.initialize = function () {
-
// MESSAGE CLICKING
function initialize_long_tap() {
@@ -142,7 +142,7 @@ exports.initialize = function () {
// selection function which will open the compose box and select the message.
if (!util.is_mobile()) {
$("#main_div").on("click", ".messagebox", select_message_function);
- // on the other hand, on mobile it should be done with a long tap.
+ // on the other hand, on mobile it should be done with a long tap.
} else {
$("#main_div").on("longtap", ".messagebox", function (e) {
// find the correct selection API for the browser.
@@ -354,7 +354,11 @@ exports.initialize = function () {
$_("#undo_markdown_preview").show();
$_("#preview_message_area").show();
- compose.render_and_show_preview($_("#markdown_preview_spinner"), $_("#preview_content"), content);
+ compose.render_and_show_preview(
+ $_("#markdown_preview_spinner"),
+ $_("#preview_content"),
+ content,
+ );
});
$("body").on("click", "#message_edit_form [id^='undo_markdown_preview_']", function (e) {
@@ -415,10 +419,14 @@ exports.initialize = function () {
});
// Search for all table rows (this combines stream & topic names)
- $("body").on("keyup", "#recent_topics_search", _.debounce(() => {
- recent_topics.update_filters_view();
- // Wait for user to go idle before initiating search.
- }, 300));
+ $("body").on(
+ "keyup",
+ "#recent_topics_search",
+ _.debounce(() => {
+ recent_topics.update_filters_view();
+ // Wait for user to go idle before initiating search.
+ }, 300),
+ );
$("body").on("click", "#recent_topics_search_clear", (e) => {
e.stopPropagation();
@@ -482,16 +490,18 @@ exports.initialize = function () {
}
});
- $("#user_presences").expectOne().on("click", ".selectable_sidebar_block", (e) => {
- const li = $(e.target).parents("li");
+ $("#user_presences")
+ .expectOne()
+ .on("click", ".selectable_sidebar_block", (e) => {
+ const li = $(e.target).parents("li");
- activity.narrow_for_user({li: li});
+ activity.narrow_for_user({li: li});
- e.preventDefault();
- e.stopPropagation();
- popovers.hide_all();
- $(".tooltip").remove();
- });
+ e.preventDefault();
+ e.stopPropagation();
+ popovers.hide_all();
+ $(".tooltip").remove();
+ });
function do_render_buddy_list_tooltip(elem, title_data) {
elem.tooltip({
@@ -509,19 +519,31 @@ exports.initialize = function () {
}
// BUDDY LIST TOOLTIPS
- $("#user_presences").on("mouseenter", ".user-presence-link, .user_sidebar_entry .user_circle, .user_sidebar_entry .selectable_sidebar_block", (e) => {
- e.stopPropagation();
- const elem = $(e.currentTarget).closest(".user_sidebar_entry").find(".user-presence-link");
- 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);
- });
+ $("#user_presences").on(
+ "mouseenter",
+ ".user-presence-link, .user_sidebar_entry .user_circle, .user_sidebar_entry .selectable_sidebar_block",
+ (e) => {
+ e.stopPropagation();
+ const elem = $(e.currentTarget)
+ .closest(".user_sidebar_entry")
+ .find(".user-presence-link");
+ 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);
+ },
+ );
- $("#user_presences").on("mouseleave click", ".user-presence-link, .user_sidebar_entry .user_circle, .user_sidebar_entry .selectable_sidebar_block", (e) => {
- e.stopPropagation();
- const elem = $(e.currentTarget).closest(".user_sidebar_entry").find(".user-presence-link");
- $(elem).tooltip("destroy");
- });
+ $("#user_presences").on(
+ "mouseleave click",
+ ".user-presence-link, .user_sidebar_entry .user_circle, .user_sidebar_entry .selectable_sidebar_block",
+ (e) => {
+ e.stopPropagation();
+ const elem = $(e.currentTarget)
+ .closest(".user_sidebar_entry")
+ .find(".user-presence-link");
+ $(elem).tooltip("destroy");
+ },
+ );
// PM LIST TOOLTIPS
$("body").on("mouseenter", "#pm_user_status", (e) => {
@@ -607,13 +629,12 @@ exports.initialize = function () {
// NB: This just binds to current elements, and won't bind to elements
// created after ready() is called.
- $("#compose-send-status .compose-send-status-close").click(
- () => { $("#compose-send-status").stop(true).fadeOut(500); },
- );
- $("#nonexistent_stream_reply_error .compose-send-status-close").click(
- () => { $("#nonexistent_stream_reply_error").stop(true).fadeOut(500); },
- );
-
+ $("#compose-send-status .compose-send-status-close").click(() => {
+ $("#compose-send-status").stop(true).fadeOut(500);
+ });
+ $("#nonexistent_stream_reply_error .compose-send-status-close").click(() => {
+ $("#nonexistent_stream_reply_error").stop(true).fadeOut(500);
+ });
$(".compose_stream_button").click(() => {
popovers.hide_mobile_message_buttons_popover();
@@ -697,34 +718,37 @@ exports.initialize = function () {
$("body").on("click", ".webathena_login", (e) => {
$("#zephyr-mirror-error").removeClass("show");
const principal = ["zephyr", "zephyr"];
- WinChan.open({
- url: "https://webathena.mit.edu/#!request_ticket_v1",
- relay_url: "https://webathena.mit.edu/relay.html",
- params: {
- realm: "ATHENA.MIT.EDU",
- principal: principal,
+ WinChan.open(
+ {
+ url: "https://webathena.mit.edu/#!request_ticket_v1",
+ relay_url: "https://webathena.mit.edu/relay.html",
+ params: {
+ realm: "ATHENA.MIT.EDU",
+ principal: principal,
+ },
},
- }, (err, r) => {
- if (err) {
- blueslip.warn(err);
- return;
- }
- if (r.status !== "OK") {
- blueslip.warn(r);
- return;
- }
+ (err, r) => {
+ if (err) {
+ blueslip.warn(err);
+ return;
+ }
+ if (r.status !== "OK") {
+ blueslip.warn(r);
+ return;
+ }
- channel.post({
- url: "/accounts/webathena_kerberos_login/",
- data: {cred: JSON.stringify(r.session)},
- success: function () {
- $("#zephyr-mirror-error").removeClass("show");
- },
- error: function () {
- $("#zephyr-mirror-error").addClass("show");
- },
- });
- });
+ channel.post({
+ url: "/accounts/webathena_kerberos_login/",
+ data: {cred: JSON.stringify(r.session)},
+ success: function () {
+ $("#zephyr-mirror-error").removeClass("show");
+ },
+ error: function () {
+ $("#zephyr-mirror-error").addClass("show");
+ },
+ });
+ },
+ );
$("#settings-dropdown").dropdown("toggle");
e.preventDefault();
e.stopPropagation();
@@ -743,7 +767,8 @@ exports.initialize = function () {
// Don't focus links on middle click.
$("body").on("mouseup", "a", (e) => {
- if (e.which === 2) { // middle click
+ if (e.which === 2) {
+ // middle click
e.target.blur();
}
});
@@ -803,7 +828,8 @@ exports.initialize = function () {
$("[data-finish-editing='" + selector + "']").show();
$(selector).addClass("stream-name-edit-box");
- edit_area.attr("data-prev-text", edit_area.text().trim())
+ edit_area
+ .attr("data-prev-text", edit_area.text().trim())
.attr("contenteditable", true);
if (map[selector].on_start) {
@@ -828,7 +854,6 @@ exports.initialize = function () {
});
})();
-
// HOTSPOTS
// open
@@ -837,7 +862,8 @@ exports.initialize = function () {
hotspots.close_hotspot_icon(this);
// show popover
- const hotspot_name = $(e.target).closest(".hotspot-icon")
+ const hotspot_name = $(e.target)
+ .closest(".hotspot-icon")
.attr("id")
.replace("hotspot_", "")
.replace("_icon", "");
@@ -849,9 +875,12 @@ exports.initialize = function () {
on_close: function () {
// close popover
$(this).css({display: "block"});
- $(this).animate({opacity: 1}, {
- duration: 300,
- });
+ $(this).animate(
+ {opacity: 1},
+ {
+ duration: 300,
+ },
+ );
}.bind(this),
});
@@ -866,9 +895,7 @@ exports.initialize = function () {
const overlay_name = $(this).closest(".hotspot.overlay").attr("id");
- const hotspot_name = overlay_name
- .replace("hotspot_", "")
- .replace("_overlay", "");
+ const hotspot_name = overlay_name.replace("hotspot_", "").replace("_overlay", "");
// Comment below to disable marking hotspots as read in production
hotspots.post_hotspot_as_read(hotspot_name);
@@ -890,7 +917,6 @@ exports.initialize = function () {
e.stopPropagation();
});
-
// MAIN CLICK HANDLER
$(document).on("click", (e) => {
@@ -902,7 +928,11 @@ exports.initialize = function () {
}
// Dismiss popovers if the user has clicked outside them
- if ($('.popover-inner, #user-profile-modal, .emoji-info-popover, .app-main [class^="column-"].expanded').has(e.target).length === 0) {
+ if (
+ $(
+ '.popover-inner, #user-profile-modal, .emoji-info-popover, .app-main [class^="column-"].expanded',
+ ).has(e.target).length === 0
+ ) {
popovers.hide_all();
}
@@ -917,16 +947,18 @@ exports.initialize = function () {
// Refocus compose message text box if link is clicked
$("#compose-textarea").focus();
return;
- } else if (!window.getSelection().toString() &&
- // Clicks inside an overlay, popover, custom
- // modal, or backdrop of one of the above
- // should not have any effect on the compose
- // state.
- !$(e.target).closest(".overlay").length &&
- !$(e.target).closest(".popover").length &&
- !$(e.target).closest(".modal").length &&
- !$(e.target).closest(".modal-backdrop").length &&
- $(e.target).closest("body").length) {
+ } else if (
+ !window.getSelection().toString() &&
+ // Clicks inside an overlay, popover, custom
+ // modal, or backdrop of one of the above
+ // should not have any effect on the compose
+ // state.
+ !$(e.target).closest(".overlay").length &&
+ !$(e.target).closest(".popover").length &&
+ !$(e.target).closest(".modal").length &&
+ !$(e.target).closest(".modal-backdrop").length &&
+ $(e.target).closest("body").length
+ ) {
// Unfocus our compose area if we click out of it. Don't let exits out
// of overlays or selecting text (for copy+paste) trigger cancelling.
// Check if the click is within the body to prevent extensions from
diff --git a/static/js/color_data.js b/static/js/color_data.js
index 55990f29b5e..80a04753f87 100644
--- a/static/js/color_data.js
+++ b/static/js/color_data.js
@@ -1,11 +1,29 @@
// These colors are used now for streams.
const stream_colors = [
- "#76ce90", "#fae589", "#a6c7e5", "#e79ab5",
- "#bfd56f", "#f4ae55", "#b0a5fd", "#addfe5",
- "#f5ce6e", "#c2726a", "#94c849", "#bd86e5",
- "#ee7e4a", "#a6dcbf", "#95a5fd", "#53a063",
- "#9987e1", "#e4523d", "#c2c2c2", "#4f8de4",
- "#c6a8ad", "#e7cc4d", "#c8bebf", "#a47462",
+ "#76ce90",
+ "#fae589",
+ "#a6c7e5",
+ "#e79ab5",
+ "#bfd56f",
+ "#f4ae55",
+ "#b0a5fd",
+ "#addfe5",
+ "#f5ce6e",
+ "#c2726a",
+ "#94c849",
+ "#bd86e5",
+ "#ee7e4a",
+ "#a6dcbf",
+ "#95a5fd",
+ "#53a063",
+ "#9987e1",
+ "#e4523d",
+ "#c2c2c2",
+ "#4f8de4",
+ "#c6a8ad",
+ "#e7cc4d",
+ "#c8bebf",
+ "#a47462",
];
// Shuffle our colors on page load to prevent
diff --git a/static/js/colorspace.js b/static/js/colorspace.js
index 5c5738e647b..8fb5f1b797f 100644
--- a/static/js/colorspace.js
+++ b/static/js/colorspace.js
@@ -23,7 +23,7 @@ exports.rgb_luminance = function (channel) {
exports.luminance_to_lightness = function (luminance) {
let v;
if (luminance <= 216 / 24389) {
- v = 841 / 108 * luminance + 4 / 29;
+ v = (841 / 108) * luminance + 4 / 29;
} else {
v = Math.pow(luminance, 1 / 3);
}
@@ -32,21 +32,28 @@ 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)};
+ return {
+ r: parseInt(hexcolor.substr(1, 2), 16),
+ g: parseInt(hexcolor.substr(3, 2), 16),
+ b: parseInt(hexcolor.substr(5, 2), 16),
+ };
};
exports.getLighterColor = function (rgb, lightness) {
- return {r: Math.round(lightness * 255 + (1 - lightness) * rgb.r),
- g: Math.round(lightness * 255 + (1 - lightness) * rgb.g),
- b: Math.round(lightness * 255 + (1 - lightness) * rgb.b)};
+ return {
+ r: Math.round(lightness * 255 + (1 - lightness) * rgb.r),
+ g: Math.round(lightness * 255 + (1 - lightness) * rgb.g),
+ b: Math.round(lightness * 255 + (1 - lightness) * rgb.b),
+ };
};
exports.getHexColor = function (rgb) {
- return "#" + parseInt(rgb.r, 10).toString(16) +
- parseInt(rgb.g, 10).toString(16) +
- parseInt(rgb.b, 10).toString(16);
+ return (
+ "#" +
+ parseInt(rgb.r, 10).toString(16) +
+ parseInt(rgb.g, 10).toString(16) +
+ parseInt(rgb.b, 10).toString(16)
+ );
};
window.colorspace = exports;
diff --git a/static/js/common.js b/static/js/common.js
index dcc94b758ef..bdb8bc1de1a 100644
--- a/static/js/common.js
+++ b/static/js/common.js
@@ -29,8 +29,7 @@ exports.password_quality = function (password, bar, password_field) {
const min_guesses = password_field.data("minGuesses");
const result = zxcvbn(password);
- const acceptable = password.length >= min_length
- && result.guesses >= min_guesses;
+ const acceptable = password.length >= min_length && result.guesses >= min_guesses;
if (bar !== undefined) {
const t = result.crack_times_seconds.offline_slow_hashing_1e4_per_second;
@@ -60,7 +59,9 @@ exports.password_warning = function (password, password_field) {
const min_length = password_field.data("minLength");
if (password.length < min_length) {
- return i18n.t("Password should be at least __length__ characters long", {length: min_length});
+ return i18n.t("Password should be at least __length__ characters long", {
+ length: min_length,
+ });
}
return zxcvbn(password).feedback.warning || i18n.t("Password is too weak");
};
diff --git a/static/js/components.js b/static/js/components.js
index 86f86dbdf35..6ee0121e455 100644
--- a/static/js/components.js
+++ b/static/js/components.js
@@ -21,7 +21,15 @@ exports.toggle = function (opts) {
opts.values.forEach((value, i) => {
// create a tab with a tab-id so they don't have to be referenced
// by text value which can be inconsistent.
- const tab = $("<div class='ind-tab' data-tab-key='" + value.key + "' data-tab-id='" + i + "' tabindex='0'>" + value.label + "</div>");
+ const tab = $(
+ "<div class='ind-tab' data-tab-key='" +
+ value.key +
+ "' data-tab-id='" +
+ i +
+ "' tabindex='0'>" +
+ value.label +
+ "</div>",
+ );
// add proper classes for styling in CSS.
if (i === 0) {
@@ -53,10 +61,7 @@ exports.toggle = function (opts) {
meta.idx = idx;
if (opts.callback) {
- opts.callback(
- opts.values[idx].label,
- opts.values[idx].key,
- );
+ opts.callback(opts.values[idx].label, opts.values[idx].key);
}
if (!opts.child_wants_focus) {
diff --git a/static/js/compose.js b/static/js/compose.js
index 222ef924400..bf05acf353c 100644
--- a/static/js/compose.js
+++ b/static/js/compose.js
@@ -26,7 +26,10 @@ exports.announce_warn_threshold = 60;
exports.uploads_domain = document.location.protocol + "//" + document.location.host;
exports.uploads_path = "/user_uploads";
-exports.uploads_re = new RegExp("\\]\\(" + exports.uploads_domain + "(" + exports.uploads_path + "[^\\)]+)\\)", "g");
+exports.uploads_re = new RegExp(
+ "\\]\\(" + exports.uploads_domain + "(" + exports.uploads_path + "[^\\)]+)\\)",
+ "g",
+);
function make_uploads_relative(content) {
// Rewrite uploads in markdown links back to domain-relative form
@@ -36,8 +39,10 @@ function make_uploads_relative(content) {
function show_all_everyone_warnings(stream_id) {
const stream_count = stream_data.get_subscriber_count(stream_id) || 0;
- const all_everyone_template = render_compose_all_everyone({count: stream_count,
- mention: wildcard_mention});
+ const all_everyone_template = render_compose_all_everyone({
+ count: stream_count,
+ mention: wildcard_mention,
+ });
const error_area_all_everyone = $("#compose-all-everyone");
// only show one error for any number of @all or @everyone mentions
@@ -55,8 +60,10 @@ exports.compute_show_video_chat_button = function () {
return false;
}
- if (page_params.realm_video_chat_provider === available_providers.jitsi_meet.id &&
- !page_params.jitsi_server_url) {
+ if (
+ page_params.realm_video_chat_provider === available_providers.jitsi_meet.id &&
+ !page_params.jitsi_server_url
+ ) {
return false;
}
@@ -219,7 +226,6 @@ function create_message_object() {
if (message.to_user_ids !== undefined) {
message.to = people.user_ids_string_to_ids_array(message.to_user_ids);
}
-
} else {
const stream_name = compose_state.stream_name();
message.stream = stream_name;
@@ -244,9 +250,11 @@ function create_message_object() {
exports.create_message_object = create_message_object;
function compose_error(error_text, bad_input) {
- $("#compose-send-status").removeClass(common.status_classes)
+ $("#compose-send-status")
+ .removeClass(common.status_classes)
.addClass("alert-error")
- .stop(true).fadeTo(0, 1);
+ .stop(true)
+ .fadeTo(0, 1);
$("#compose-error-msg").html(error_text);
$("#compose-send-button").prop("disabled", false);
$("#sending-indicator").hide();
@@ -266,9 +274,11 @@ function nonexistent_stream_reply_error() {
}
function compose_not_subscribed_error(error_text, bad_input) {
- $("#compose-send-status").removeClass(common.status_classes)
+ $("#compose-send-status")
+ .removeClass(common.status_classes)
.addClass("home-error-bar")
- .stop(true).fadeTo(0, 1);
+ .stop(true)
+ .fadeTo(0, 1);
$("#compose-error-msg").html(error_text);
$("#compose-send-button").prop("disabled", false);
$("#sending-indicator").hide();
@@ -354,7 +364,9 @@ exports.send_message = function send_message(request) {
}
transmit.send_message(request, success, error);
- server_events.assert_get_events_running("Restarting get_events because it was not running during send");
+ server_events.assert_get_events_running(
+ "Restarting get_events because it was not running during send",
+ );
if (locally_echoed) {
clear_compose_box();
@@ -422,7 +434,8 @@ exports.update_email = function (user_id, new_email) {
exports.get_invalid_recipient_emails = function () {
const private_recipients = util.extract_pm_recipients(
- compose_state.private_message_recipient());
+ compose_state.private_message_recipient(),
+ );
const invalid_recipients = private_recipients.filter(
(email) => !people.is_valid_email_for_compose(email),
);
@@ -467,8 +480,10 @@ function validate_stream_message_mentions(stream_id) {
// check if wildcard_mention has any mention and henceforth execute the warning message.
if (wildcard_mention !== null && stream_count > exports.all_everyone_warn_threshold) {
- if (user_acknowledged_all_everyone === undefined ||
- user_acknowledged_all_everyone === false) {
+ if (
+ user_acknowledged_all_everyone === undefined ||
+ user_acknowledged_all_everyone === false
+ ) {
// user has not seen a warning message yet if undefined
show_all_everyone_warnings(stream_id);
@@ -489,10 +504,8 @@ function validate_stream_message_mentions(stream_id) {
function validate_stream_message_announce(sub) {
const stream_count = stream_data.get_subscriber_count(sub.stream_id) || 0;
- if (sub.name === "announce" &&
- stream_count > exports.announce_warn_threshold) {
- if (user_acknowledged_announce === undefined ||
- user_acknowledged_announce === false) {
+ if (sub.name === "announce" && stream_count > exports.announce_warn_threshold) {
+ if (user_acknowledged_announce === undefined || user_acknowledged_announce === false) {
// user has not seen a warning message yet if undefined
show_announce_warnings(sub.stream_id);
@@ -527,9 +540,14 @@ function validate_stream_message_post_policy(sub) {
const person_date_joined = new Date(person.date_joined);
const days = new Date(current_datetime - person_date_joined).getDate();
let error_text;
- if (stream_post_policy === stream_post_permission_type.non_new_members.code &&
- days < page_params.realm_waiting_period_threshold) {
- error_text = i18n.t("New members are not allowed to post to this stream.<br>Permission will be granted in __days__ days.", {days: days});
+ if (
+ stream_post_policy === stream_post_permission_type.non_new_members.code &&
+ days < page_params.realm_waiting_period_threshold
+ ) {
+ error_text = i18n.t(
+ "New members are not allowed to post to this stream.<br>Permission will be granted in __days__ days.",
+ {days: days},
+ );
compose_error(error_text);
return false;
}
@@ -544,17 +562,23 @@ exports.validation_error = function (error_type, stream_name) {
switch (error_type) {
case "does-not-exist":
- response = i18n.t("<p>The stream <b>__stream_name__</b> does not exist.</p><p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>", context);
+ response = i18n.t(
+ "<p>The stream <b>__stream_name__</b> does not exist.</p><p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>",
+ context,
+ );
compose_error(response, $("#stream_message_recipient_stream"));
return false;
case "error":
- compose_error(i18n.t("Error checking subscription"),
- $("#stream_message_recipient_stream"));
+ compose_error(
+ i18n.t("Error checking subscription"),
+ $("#stream_message_recipient_stream"),
+ );
return false;
case "not-subscribed": {
const sub = stream_data.get_sub(stream_name);
const new_row = render_compose_not_subscribed({
- should_display_sub_button: sub.should_display_subscription_button});
+ should_display_sub_button: sub.should_display_subscription_button,
+ });
compose_not_subscribed_error(new_row, $("#stream_message_recipient_stream"));
return false;
}
@@ -603,15 +627,19 @@ function validate_stream_message() {
// If both `@all` is mentioned and it's in `#announce`, just validate
// for `@all`. Users shouldn't have to hit "yes" more than once.
if (wildcard_mention !== null && stream_name === "announce") {
- if (!exports.validate_stream_message_address_info(stream_name) ||
- !validate_stream_message_mentions(sub.stream_id)) {
+ if (
+ !exports.validate_stream_message_address_info(stream_name) ||
+ !validate_stream_message_mentions(sub.stream_id)
+ ) {
return false;
}
- // If either criteria isn't met, just do the normal validation.
+ // If either criteria isn't met, just do the normal validation.
} else {
- if (!exports.validate_stream_message_address_info(stream_name) ||
+ if (
+ !exports.validate_stream_message_address_info(stream_name) ||
!validate_stream_message_mentions(sub.stream_id) ||
- !validate_stream_message_announce(sub)) {
+ !validate_stream_message_announce(sub)
+ ) {
return false;
}
}
@@ -627,14 +655,19 @@ function validate_private_message() {
const user_ids = compose_pm_pill.get_user_ids();
if (user_ids.length !== 1 || !people.get_by_user_id(user_ids[0]).is_bot) {
// Unless we're composing to a bot
- compose_error(i18n.t("Private messages are disabled in this organization."),
- $("#private_message_recipient"));
+ compose_error(
+ i18n.t("Private messages are disabled in this organization."),
+ $("#private_message_recipient"),
+ );
return false;
}
}
if (compose_state.private_message_recipient().length === 0) {
- compose_error(i18n.t("Please specify at least one valid recipient"), $("#private_message_recipient"));
+ compose_error(
+ i18n.t("Please specify at least one valid recipient"),
+ $("#private_message_recipient"),
+ );
return false;
} else if (page_params.realm_is_zephyr_mirror_realm) {
// For Zephyr mirroring realms, the frontend doesn't know which users exist
@@ -646,11 +679,17 @@ function validate_private_message() {
let context = {};
if (invalid_recipients.length === 1) {
context = {recipient: invalid_recipients.join()};
- compose_error(i18n.t("The recipient __recipient__ is not valid", context), $("#private_message_recipient"));
+ compose_error(
+ i18n.t("The recipient __recipient__ is not valid", context),
+ $("#private_message_recipient"),
+ );
return false;
} else if (invalid_recipients.length > 1) {
context = {recipients: invalid_recipients.join()};
- compose_error(i18n.t("The recipients __recipients__ are not valid", context), $("#private_message_recipient"));
+ compose_error(
+ i18n.t("The recipients __recipients__ are not valid", context),
+ $("#private_message_recipient"),
+ );
return false;
}
return true;
@@ -786,15 +825,17 @@ function insert_video_call_url(url, target_textarea) {
}
exports.render_and_show_preview = function (preview_spinner, preview_content_box, content) {
-
function show_preview(rendered_content, raw_content) {
// content is passed to check for status messages ("/me ...")
// and will be undefined in case of errors
let rendered_preview_html;
- if (raw_content !== undefined &&
- markdown.is_status_message(raw_content)) {
+ if (raw_content !== undefined && markdown.is_status_message(raw_content)) {
// Handle previews of /me messages
- rendered_preview_html = "<p><strong>" + page_params.full_name + "</strong>" + rendered_content.slice("<p>/me".length);
+ rendered_preview_html =
+ "<p><strong>" +
+ page_params.full_name +
+ "</strong>" +
+ rendered_content.slice("<p>/me".length);
} else {
rendered_preview_html = rendered_content;
}
@@ -921,7 +962,9 @@ exports.warn_if_mentioning_unsubscribed_user = function (mentioned) {
const error_area = $("#compose_invite_users");
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));
+ const existing_invites = Array.from($(existing_invites_area), (user_row) =>
+ parseInt($(user_row).data("user-id"), 10),
+ );
if (!existing_invites.includes(user_id)) {
const context = {
@@ -941,8 +984,12 @@ exports.warn_if_mentioning_unsubscribed_user = function (mentioned) {
exports.initialize = function () {
$("#below-compose-content .video_link").toggle(exports.compute_show_video_chat_button());
- $("#stream_message_recipient_stream,#stream_message_recipient_topic,#private_message_recipient").on("keyup", update_fade);
- $("#stream_message_recipient_stream,#stream_message_recipient_topic,#private_message_recipient").on("change", update_fade);
+ $(
+ "#stream_message_recipient_stream,#stream_message_recipient_topic,#private_message_recipient",
+ ).on("keyup", update_fade);
+ $(
+ "#stream_message_recipient_stream,#stream_message_recipient_topic,#private_message_recipient",
+ ).on("change", update_fade);
$("#compose-textarea").on("keydown", (event) => {
exports.handle_keydown(event, $("#compose-textarea").expectOne());
});
@@ -1039,16 +1086,20 @@ exports.initialize = function () {
}
});
- $("#compose_private_stream_alert").on("click", ".compose_private_stream_alert_close", (event) => {
- const stream_alert_row = $(event.target).parents(".compose_private_stream_alert");
- const stream_alert = $("#compose_private_stream_alert");
+ $("#compose_private_stream_alert").on(
+ "click",
+ ".compose_private_stream_alert_close",
+ (event) => {
+ const stream_alert_row = $(event.target).parents(".compose_private_stream_alert");
+ const stream_alert = $("#compose_private_stream_alert");
- stream_alert_row.remove();
+ stream_alert_row.remove();
- if (stream_alert.children().length === 0) {
- stream_alert.hide();
- }
- });
+ if (stream_alert.children().length === 0) {
+ stream_alert.hide();
+ }
+ },
+ );
// Click event binding for "Attach files" button
// Triggers a click on a hidden file input field
@@ -1080,30 +1131,39 @@ exports.initialize = function () {
return;
}
- if (available_providers.zoom
- && page_params.realm_video_chat_provider === available_providers.zoom.id) {
+ if (
+ available_providers.zoom &&
+ page_params.realm_video_chat_provider === available_providers.zoom.id
+ ) {
exports.abort_zoom(edit_message_id);
const key = edit_message_id || "";
const make_zoom_call = () => {
- exports.zoom_xhrs.set(key, channel.post({
- url: "/json/calls/zoom/create",
- success(res) {
- exports.zoom_xhrs.delete(key);
- insert_video_call_url(res.url, target_textarea);
- },
- error(xhr, status) {
- exports.zoom_xhrs.delete(key);
- if (status === "error" &&
- xhr.responseJSON &&
- xhr.responseJSON.code === "INVALID_ZOOM_TOKEN") {
- page_params.has_zoom_token = false;
- }
- if (status !== "abort") {
- ui_report.generic_embed_error(i18n.t("Failed to create video call."));
- }
- },
- }));
+ exports.zoom_xhrs.set(
+ key,
+ channel.post({
+ url: "/json/calls/zoom/create",
+ success(res) {
+ exports.zoom_xhrs.delete(key);
+ insert_video_call_url(res.url, target_textarea);
+ },
+ error(xhr, status) {
+ exports.zoom_xhrs.delete(key);
+ if (
+ status === "error" &&
+ xhr.responseJSON &&
+ xhr.responseJSON.code === "INVALID_ZOOM_TOKEN"
+ ) {
+ page_params.has_zoom_token = false;
+ }
+ if (status !== "abort") {
+ ui_report.generic_embed_error(
+ i18n.t("Failed to create video call."),
+ );
+ }
+ },
+ }),
+ );
};
if (page_params.has_zoom_token) {
@@ -1111,19 +1171,15 @@ exports.initialize = function () {
} else {
exports.zoom_token_callbacks.set(key, make_zoom_call);
window.open(
- window.location.protocol +
- "//" +
- window.location.host +
- "/calls/zoom/register",
+ window.location.protocol + "//" + window.location.host + "/calls/zoom/register",
"_blank",
"width=800,height=500,noopener,noreferrer",
);
}
} else if (
- available_providers.big_blue_button
- && page_params.realm_video_chat_provider === available_providers.big_blue_button.id
+ available_providers.big_blue_button &&
+ page_params.realm_video_chat_provider === available_providers.big_blue_button.id
) {
-
channel.get({
url: "/json/calls/bigbluebutton/create",
success: function (response) {
@@ -1144,7 +1200,11 @@ exports.initialize = function () {
$("#undo_markdown_preview").show();
$("#preview_message_area").show();
- exports.render_and_show_preview($("#markdown_preview_spinner"), $("#preview_content"), content);
+ exports.render_and_show_preview(
+ $("#markdown_preview_spinner"),
+ $("#preview_content"),
+ content,
+ );
});
$("#compose").on("click", "#undo_markdown_preview", (e) => {
diff --git a/static/js/compose_actions.js b/static/js/compose_actions.js
index c3a5c6d7044..19b3a80d55b 100644
--- a/static/js/compose_actions.js
+++ b/static/js/compose_actions.js
@@ -19,8 +19,10 @@ function get_focus_area(msg_type, opts) {
// Set focus to "Topic" when narrowed to a stream+topic and "New topic" button clicked.
if (msg_type === "stream" && opts.stream && !opts.topic) {
return "#stream_message_recipient_topic";
- } else if (msg_type === "stream" && opts.stream
- || msg_type === "private" && opts.private_message_recipient) {
+ } else if (
+ (msg_type === "stream" && opts.stream) ||
+ (msg_type === "private" && opts.private_message_recipient)
+ ) {
if (opts.trigger === "new topic button") {
return "#stream_message_recipient_topic";
}
@@ -41,14 +43,12 @@ exports.set_focus = function (msg_type, opts) {
return;
}
- if (window.getSelection().toString() === "" ||
- opts.trigger !== "message click") {
+ if (window.getSelection().toString() === "" || opts.trigger !== "message click") {
const elt = $(focus_area);
elt.focus().select();
}
};
-
// Show the compose box.
function show_box(msg_type, opts) {
if (msg_type === "stream") {
@@ -135,8 +135,7 @@ exports.maybe_scroll_up_selected_message = function () {
return;
}
- const cover = selected_row.offset().top + selected_row.height()
- - $("#compose").offset().top;
+ const cover = selected_row.offset().top + selected_row.height() - $("#compose").offset().top;
if (cover > 0) {
message_viewport.user_initiated_animate_scroll(cover + 20);
}
@@ -158,12 +157,14 @@ function fill_in_opts_from_current_narrowed_view(msg_type, opts) {
}
function same_recipient_as_before(msg_type, opts) {
- return compose_state.get_message_type() === msg_type &&
- (msg_type === "stream" &&
- opts.stream === compose_state.stream_name() &&
- opts.topic === compose_state.topic() ||
- msg_type === "private" &&
- opts.private_message_recipient === compose_state.private_message_recipient());
+ return (
+ compose_state.get_message_type() === msg_type &&
+ ((msg_type === "stream" &&
+ opts.stream === compose_state.stream_name() &&
+ opts.topic === compose_state.topic()) ||
+ (msg_type === "private" &&
+ opts.private_message_recipient === compose_state.private_message_recipient()))
+ );
}
exports.update_placeholder_text = function (opts) {
@@ -184,14 +185,17 @@ exports.start = function (msg_type, opts) {
// If we are invoked by a compose hotkey (c or x) or new topic
// button, do not assume that we know what the message's topic or
// PM recipient should be.
- if (opts.trigger === "compose_hotkey" ||
- opts.trigger === "new topic button") {
+ if (opts.trigger === "compose_hotkey" || opts.trigger === "new topic button") {
opts.topic = "";
opts.private_message_recipient = "";
}
const subbed_streams = stream_data.subscribed_subs();
- if (subbed_streams.length === 1 && (opts.trigger === "new topic button" || opts.trigger === "compose_hotkey" && msg_type === "stream")) {
+ if (
+ subbed_streams.length === 1 &&
+ (opts.trigger === "new topic button" ||
+ (opts.trigger === "compose_hotkey" && msg_type === "stream"))
+ ) {
opts.stream = subbed_streams[0].name;
}
@@ -260,10 +264,13 @@ exports.respond_to_message = function (opts) {
const message = current_msg_list.selected_message();
- if (message === undefined) { // empty narrow implementation
- if (!narrow_state.narrowed_by_pm_reply() &&
+ if (message === undefined) {
+ // empty narrow implementation
+ if (
+ !narrow_state.narrowed_by_pm_reply() &&
!narrow_state.narrowed_by_stream_reply() &&
- !narrow_state.narrowed_by_topic_reply()) {
+ !narrow_state.narrowed_by_topic_reply()
+ ) {
compose.nonexistent_stream_reply_error();
return;
}
@@ -320,10 +327,12 @@ exports.respond_to_message = function (opts) {
}
}
- exports.start(msg_type, {stream: stream, topic: topic,
- private_message_recipient: pm_recipient,
- trigger: opts.trigger});
-
+ exports.start(msg_type, {
+ stream: stream,
+ topic: topic,
+ private_message_recipient: pm_recipient,
+ trigger: opts.trigger,
+ });
};
exports.reply_with_mention = function (opts) {
diff --git a/static/js/compose_fade.js b/static/js/compose_fade.js
index 946a3ffe227..f5b4feae14a 100644
--- a/static/js/compose_fade.js
+++ b/static/js/compose_fade.js
@@ -69,27 +69,36 @@ function fade_messages() {
}
// Defer updating all message groups so that the compose box can open sooner
- setTimeout((expected_msg_list, expected_recipient) => {
- const all_groups = rows.get_table(current_msg_list.table_name).find(".recipient_row");
-
- if (current_msg_list !== expected_msg_list ||
- !compose_state.composing() ||
- compose_state.private_message_recipient() !== expected_recipient) {
- return;
- }
-
- should_fade_group = false;
-
- // Note: The below algorithm relies on the fact that all_elts is
- // sorted as it would be displayed in the message view
- for (i = 0; i < all_groups.length; i += 1) {
- const group_elt = $(all_groups[i]);
- should_fade_group = exports.should_fade_message(rows.recipient_from_group(group_elt));
- change_fade_state(group_elt, should_fade_group);
- }
-
- floating_recipient_bar.update();
- }, 0, current_msg_list, compose_state.private_message_recipient());
+ setTimeout(
+ (expected_msg_list, expected_recipient) => {
+ const all_groups = rows.get_table(current_msg_list.table_name).find(".recipient_row");
+
+ if (
+ current_msg_list !== expected_msg_list ||
+ !compose_state.composing() ||
+ compose_state.private_message_recipient() !== expected_recipient
+ ) {
+ return;
+ }
+
+ should_fade_group = false;
+
+ // Note: The below algorithm relies on the fact that all_elts is
+ // sorted as it would be displayed in the message view
+ for (i = 0; i < all_groups.length; i += 1) {
+ const group_elt = $(all_groups[i]);
+ should_fade_group = exports.should_fade_message(
+ rows.recipient_from_group(group_elt),
+ );
+ change_fade_state(group_elt, should_fade_group);
+ }
+
+ floating_recipient_bar.update();
+ },
+ 0,
+ current_msg_list,
+ compose_state.private_message_recipient(),
+ );
}
exports.would_receive_message = function (user_id) {
diff --git a/static/js/compose_state.js b/static/js/compose_state.js
index 66dd2b150bc..b42eca74a8e 100644
--- a/static/js/compose_state.js
+++ b/static/js/compose_state.js
@@ -18,7 +18,8 @@ exports.focus_in_empty_compose = function () {
return (
exports.composing() &&
exports.message_content() === "" &&
- $("#compose-textarea").is(":focus"));
+ $("#compose-textarea").is(":focus")
+ );
};
function get_or_set(fieldname, keep_leading_whitespace) {
diff --git a/static/js/compose_ui.js b/static/js/compose_ui.js
index d56fd112727..9fa35f8da19 100644
--- a/static/js/compose_ui.js
+++ b/static/js/compose_ui.js
@@ -24,8 +24,12 @@ exports.smart_insert = function (textarea, syntax) {
// If there isn't whitespace either at the end of the syntax or the
// start of the content after the syntax, add one.
- if (!(after_str.length > 0 && is_space(after_str[0]) ||
- syntax.length > 0 && is_space(syntax.slice(-1)))) {
+ if (
+ !(
+ (after_str.length > 0 && is_space(after_str[0])) ||
+ (syntax.length > 0 && is_space(syntax.slice(-1)))
+ )
+ ) {
syntax += " ";
}
@@ -63,13 +67,17 @@ exports.replace_syntax = function (old_syntax, new_syntax, textarea) {
textarea = $("#compose-textarea");
}
- textarea.val(textarea.val().replace(old_syntax, () =>
- // We need this anonymous function to avoid JavaScript's
- // replace() function treating `$`s in new_syntax as special syntax. See
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Description
- // for details.
- new_syntax,
- ));
+ textarea.val(
+ textarea.val().replace(
+ old_syntax,
+ () =>
+ // We need this anonymous function to avoid JavaScript's
+ // replace() function treating `$`s in new_syntax as special syntax. See
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Description
+ // for details.
+ new_syntax,
+ ),
+ );
};
exports.compute_placeholder_text = function (opts) {
@@ -81,9 +89,10 @@ exports.compute_placeholder_text = function (opts) {
// placeholder field in a way that does HTML escaping.
if (opts.message_type === "stream") {
if (opts.topic) {
- return i18n.t("Message #__- stream_name__ > __- topic_name__",
- {stream_name: opts.stream,
- topic_name: opts.topic});
+ return i18n.t("Message #__- stream_name__ > __- topic_name__", {
+ stream_name: opts.stream,
+ topic_name: opts.topic,
+ });
} else if (opts.stream) {
return i18n.t("Message #__- stream_name__", {stream_name: opts.stream});
}
@@ -92,19 +101,22 @@ exports.compute_placeholder_text = function (opts) {
// For Private Messages
if (opts.private_message_recipient) {
const recipient_list = opts.private_message_recipient.split(",");
- const recipient_names = recipient_list.map((recipient) => {
- const user = people.get_by_email(recipient);
- return user.full_name;
- }).join(", ");
+ const recipient_names = recipient_list
+ .map((recipient) => {
+ const user = people.get_by_email(recipient);
+ return user.full_name;
+ })
+ .join(", ");
if (recipient_list.length === 1) {
// If it's a single user, display status text if available
const user = people.get_by_email(recipient_list[0]);
const status = user_status.get_status_text(user.user_id);
if (status) {
- return i18n.t("Message __- recipient_name__ (__- recipient_status__)",
- {recipient_name: recipient_names,
- recipient_status: status});
+ return i18n.t("Message __- recipient_name__ (__- recipient_status__)", {
+ recipient_name: recipient_names,
+ recipient_status: status,
+ });
}
}
return i18n.t("Message __- recipient_names__", {recipient_names: recipient_names});
diff --git a/static/js/composebox_typeahead.js b/static/js/composebox_typeahead.js
index e7be251ef31..61e7e3a11ee 100644
--- a/static/js/composebox_typeahead.js
+++ b/static/js/composebox_typeahead.js
@@ -69,7 +69,12 @@ exports.query_matches_person = function (query, person) {
};
function query_matches_name_description(query, user_group_or_stream) {
- return typeahead.query_matches_source_attrs(query, user_group_or_stream, ["name", "description"], " ");
+ return typeahead.query_matches_source_attrs(
+ query,
+ user_group_or_stream,
+ ["name", "description"],
+ " ",
+ );
}
function get_stream_or_user_group_matcher(query) {
@@ -144,7 +149,6 @@ exports.handle_enter = function (textarea, e) {
// We do this using caret and range from jquery-caret.
const has_non_shift_modifier_key = e.ctrlKey || e.metaKey || e.altKey;
if (has_non_shift_modifier_key) {
-
// To properly emulate browser "enter", if the
// user had selected something in the textarea,
// we need those characters to be cleared.
@@ -166,7 +170,8 @@ exports.handle_enter = function (textarea, e) {
function handle_keydown(e) {
const code = e.keyCode || e.which;
- if (code === 13 || code === 9 && !e.shiftKey) { // Enter key or tab key
+ if (code === 13 || (code === 9 && !e.shiftKey)) {
+ // Enter key or tab key
let target_sel;
if (e.target.id) {
@@ -209,11 +214,14 @@ function handle_keydown(e) {
}
// If no typeaheads are shown...
- if (!($("#stream_message_recipient_topic").data().typeahead.shown ||
- $("#stream_message_recipient_stream").data().typeahead.shown ||
- $("#private_message_recipient").data().typeahead.shown ||
- $("#compose-textarea").data().typeahead.shown)) {
-
+ if (
+ !(
+ $("#stream_message_recipient_topic").data().typeahead.shown ||
+ $("#stream_message_recipient_stream").data().typeahead.shown ||
+ $("#private_message_recipient").data().typeahead.shown ||
+ $("#compose-textarea").data().typeahead.shown
+ )
+ ) {
// If no typeaheads are shown and the user is tabbing from the message content box,
// then there's no need to wait and we can change the focus right away.
// Without this code to change the focus right away, if the user presses enter
@@ -243,7 +251,8 @@ function handle_keydown(e) {
function handle_keyup(e) {
const code = e.keyCode || e.which;
- if (code === 13 || code === 9 && !e.shiftKey) { // Enter key or tab key
+ if (code === 13 || (code === 9 && !e.shiftKey)) {
+ // Enter key or tab key
if (nextFocus) {
$(nextFocus).focus();
nextFocus = false;
@@ -262,9 +271,11 @@ function select_on_focus(field_id) {
return;
}
in_handler = true;
- $("#" + field_id).select().one("mouseup", (e) => {
- e.preventDefault();
- });
+ $("#" + field_id)
+ .select()
+ .one("mouseup", (e) => {
+ e.preventDefault();
+ });
in_handler = false;
});
}
@@ -293,7 +304,7 @@ exports.tokenize_compose_str = function (s) {
switch (s[i]) {
case "`":
case "~":
- // Code block must start on a new line
+ // Code block must start on a new line
if (i === 2) {
return s;
} else if (i > 2 && s[i - 3] === "\n") {
@@ -316,14 +327,14 @@ exports.tokenize_compose_str = function (s) {
}
break;
case ">":
- // topic_jump
- //
- // If you hit `>` immediately after completing the typeahead for mentioning a stream,
- // this will reposition the user from. If | is the cursor, implements:
- //
- // `#**stream name** >|` => `#**stream name>|`.
+ // topic_jump
+ //
+ // If you hit `>` immediately after completing the typeahead for mentioning a stream,
+ // this will reposition the user from. If | is the cursor, implements:
+ //
+ // `#**stream name** >|` => `#**stream name>|`.
if (s.substring(i - 2, i) === "**" || s.substring(i - 3, i) === "** ") {
- // return any string as long as its not ''.
+ // return any string as long as its not ''.
return ">topic_jump";
}
// maybe topic_list; let's let the stream_topic_regex decide later.
@@ -341,8 +352,9 @@ exports.tokenize_compose_str = function (s) {
exports.broadcast_mentions = function () {
return ["all", "everyone", "stream"].map((mention, idx) => ({
- special_item_text: i18n.t("__wildcard_mention_token__ (Notify stream)",
- {wildcard_mention_token: mention}),
+ special_item_text: i18n.t("__wildcard_mention_token__ (Notify stream)", {
+ wildcard_mention_token: mention,
+ }),
email: mention,
@@ -495,18 +507,14 @@ exports.get_person_suggestions = function (query, opts) {
*/
const cutoff_length = exports.max_num_items;
- const filtered_message_persons = filter_persons(
- people.get_active_message_people(),
- );
+ const filtered_message_persons = filter_persons(people.get_active_message_people());
let filtered_persons;
if (filtered_message_persons.length >= cutoff_length) {
filtered_persons = filtered_message_persons;
} else {
- filtered_persons = filter_persons(
- people.get_realm_users(),
- );
+ filtered_persons = filter_persons(people.get_realm_users());
}
return typeahead_helper.sort_recipients(
@@ -576,8 +584,7 @@ exports.get_sorted_filtered_items = function (query) {
const opts = exports.get_stream_topic_data(hacky_this);
if (completing === "mention" || completing === "silent_mention") {
- return exports.filter_and_sort_mentions(
- big_results.is_silent, token, opts);
+ return exports.filter_and_sort_mentions(big_results.is_silent, token, opts);
}
return exports.filter_and_sort_candidates(completing, big_results, token);
@@ -607,7 +614,7 @@ exports.get_candidates = function (query) {
// already-completed object.
// We will likely want to extend this list to be more i18n-friendly.
- const terminal_symbols = ',.;?!()[]> "\'\n\t';
+ const terminal_symbols = ",.;?!()[]> \"'\n\t";
if (rest !== "" && !terminal_symbols.includes(rest[0])) {
return false;
}
@@ -807,12 +814,22 @@ exports.content_typeahead_selected = function (item, event) {
if (this.completing === "emoji") {
// leading and trailing spaces are required for emoji,
// except if it begins a message or a new line.
- if (beginning.lastIndexOf(":") === 0 ||
+ if (
+ beginning.lastIndexOf(":") === 0 ||
beginning.charAt(beginning.lastIndexOf(":") - 1) === " " ||
- beginning.charAt(beginning.lastIndexOf(":") - 1) === "\n") {
- beginning = beginning.substring(0, beginning.length - this.token.length - 1) + ":" + item.emoji_name + ": ";
+ beginning.charAt(beginning.lastIndexOf(":") - 1) === "\n"
+ ) {
+ beginning =
+ beginning.substring(0, beginning.length - this.token.length - 1) +
+ ":" +
+ item.emoji_name +
+ ": ";
} else {
- beginning = beginning.substring(0, beginning.length - this.token.length - 1) + " :" + item.emoji_name + ": ";
+ beginning =
+ beginning.substring(0, beginning.length - this.token.length - 1) +
+ " :" +
+ item.emoji_name +
+ ": ";
}
} else if (this.completing === "mention" || this.completing === "silent_mention") {
const is_silent = this.completing === "silent_mention";
@@ -839,7 +856,11 @@ exports.content_typeahead_selected = function (item, event) {
}
}
} else if (this.completing === "slash") {
- beginning = beginning.substring(0, beginning.length - this.token.length - 1) + "/" + item.name + " ";
+ beginning =
+ beginning.substring(0, beginning.length - this.token.length - 1) +
+ "/" +
+ item.name +
+ " ";
} else if (this.completing === "stream") {
beginning = beginning.substring(0, beginning.length - this.token.length - 1);
if (beginning.endsWith("#*")) {
@@ -892,7 +913,8 @@ exports.content_typeahead_selected = function (item, event) {
const on_timestamp_selection = (val) => {
const datestr = val;
- beginning = beginning.substring(0, beginning.lastIndexOf("<time")) + `<time:${datestr}> `;
+ beginning =
+ beginning.substring(0, beginning.lastIndexOf("<time")) + `<time:${datestr}> `;
if (rest.startsWith(">")) {
rest = rest.slice(1);
}
@@ -932,7 +954,7 @@ exports.compose_content_matcher = function (completing, token) {
switch (completing) {
case "topic_jump":
case "time_jump":
- // these don't actually have a typeahead popover, so we return quickly here.
+ // these don't actually have a typeahead popover, so we return quickly here.
return true;
}
};
@@ -950,7 +972,7 @@ exports.sort_results = function (completing, matches, token) {
return typeahead_helper.sort_languages(matches, token);
case "topic_jump":
case "time_jump":
- // topic_jump doesn't actually have a typeahead popover, so we return quickly here.
+ // topic_jump doesn't actually have a typeahead popover, so we return quickly here.
return matches;
case "topic_list":
return typeahead_helper.sorter(token, matches, (x) => x);
@@ -985,8 +1007,9 @@ function get_header_text() {
break;
case "syntax":
if (page_params.realm_default_code_block_language !== null) {
- tip_text = i18n.t("Default is __language__. Use 'text' to disable highlighting.",
- {language: page_params.realm_default_code_block_language});
+ tip_text = i18n.t("Default is __language__. Use 'text' to disable highlighting.", {
+ language: page_params.realm_default_code_block_language,
+ });
break;
}
return false;
diff --git a/static/js/condense.js b/static/js/condense.js
index 4771d57d606..3a216ed2b3a 100644
--- a/static/js/condense.js
+++ b/static/js/condense.js
@@ -10,7 +10,6 @@ This library implements two related, similar concepts:
*/
-
const _message_content_height_cache = new Map();
function show_more_link(row) {
diff --git a/static/js/copy_and_paste.js b/static/js/copy_and_paste.js
index 876a7019678..8707e2f5662 100644
--- a/static/js/copy_and_paste.js
+++ b/static/js/copy_and_paste.js
@@ -34,10 +34,12 @@ function find_boundary_tr(initial_tr, iterate_row) {
}
function construct_recipient_header(message_row) {
- const message_header_content = rows.get_message_recipient_header(message_row)
+ const message_header_content = rows
+ .get_message_recipient_header(message_row)
.text()
.replace(/\s+/g, " ")
- .replace(/^\s/, "").replace(/\s$/, "");
+ .replace(/^\s/, "")
+ .replace(/\s$/, "");
return $("<p>").append($("<strong>").text(message_header_content));
}
@@ -101,8 +103,7 @@ function select_div(div, selection) {
// inside another parent such as `.message_content`.
color: "#333",
background: "#FFF",
- })
- .attr("id", "copytempdiv");
+ }).attr("id", "copytempdiv");
$("body").append(div);
selection.selectAllChildren(div[0]);
}
@@ -210,7 +211,10 @@ exports.analyze_selection = function (selection) {
ranges.push(range);
startc = $(range.startContainer);
- start_data = find_boundary_tr($(startc.parents(".selectable_row, .message_header")[0]), (row) => row.next());
+ start_data = find_boundary_tr(
+ $(startc.parents(".selectable_row, .message_header")[0]),
+ (row) => row.next(),
+ );
if (start_data === undefined) {
// Skip any selection sections that don't intersect a message.
continue;
@@ -277,9 +281,9 @@ exports.paste_handler_converter = function (paste_html) {
// Checks for raw links without custom text or title.
turndownService.addRule("links", {
filter: function (node) {
- return node.nodeName === "A" &&
- node.href === node.innerHTML &&
- node.href === node.title;
+ return (
+ node.nodeName === "A" && node.href === node.innerHTML && node.href === node.title
+ );
},
replacement: function (content) {
return content;
diff --git a/static/js/debug.js b/static/js/debug.js
index 0215547109f..69be7ee8ba4 100644
--- a/static/js/debug.js
+++ b/static/js/debug.js
@@ -42,8 +42,17 @@ export function check_duplicate_ids() {
collisions.push({
id: o.id,
count: 1,
- node: "<" + tag + " className='" + o.className + "' id='" + o.id + "'>" +
- "</" + tag + ">",
+ node:
+ "<" +
+ tag +
+ " className='" +
+ o.className +
+ "' id='" +
+ o.id +
+ "'>" +
+ "</" +
+ tag +
+ ">",
});
} else {
el.count += 1;
diff --git a/static/js/drafts.js b/static/js/drafts.js
index c578f03d511..f99b58113df 100644
--- a/static/js/drafts.js
+++ b/static/js/drafts.js
@@ -106,7 +106,6 @@ exports.restore_message = function (draft) {
topic: util.get_draft_topic(draft),
content: draft.content,
};
-
} else {
compose_args = {
type: draft.type,
@@ -181,9 +180,7 @@ exports.restore_draft = function (draft_id) {
} else {
if (compose_args.private_message_recipient !== "") {
narrow.activate(
- [
- {operator: "pm-with", operand: compose_args.private_message_recipient},
- ],
+ [{operator: "pm-with", operand: compose_args.private_message_recipient}],
{trigger: "restore draft"},
);
}
@@ -245,14 +242,16 @@ exports.format_draft = function (draft) {
};
} else {
const emails = util.extract_pm_recipients(draft.private_message_recipient);
- const recipients = emails.map((email) => {
- email = email.trim();
- const person = people.get_by_email(email);
- if (person !== undefined) {
- return person.full_name;
- }
- return email;
- }).join(", ");
+ const recipients = emails
+ .map((email) => {
+ email = email.trim();
+ const person = people.get_by_email(email);
+ if (person !== undefined) {
+ return person.full_name;
+ }
+ return email;
+ })
+ .join(", ");
formatted = {
draft_id: draft.id,
@@ -273,9 +272,13 @@ exports.format_draft = function (draft) {
// We also report the exception to the server so that
// the bug can be fixed.
draft_model.deleteDraft(id);
- blueslip.error("Error in rendering draft.", {
- draft_content: draft.content,
- }, error.stack);
+ blueslip.error(
+ "Error in rendering draft.",
+ {
+ draft_content: draft.content,
+ },
+ error.stack,
+ );
return;
}
@@ -381,19 +384,25 @@ function activate_element(elem) {
function drafts_initialize_focus(event_name) {
// If a draft is not focused in draft modal, then focus the last draft
// if up_arrow is clicked or the first draft if down_arrow is clicked.
- if (event_name !== "up_arrow" && event_name !== "down_arrow" || $(".draft-info-box:focus")[0]) {
+ if (
+ (event_name !== "up_arrow" && event_name !== "down_arrow") ||
+ $(".draft-info-box:focus")[0]
+ ) {
return;
}
const draft_arrow = draft_model.get();
const draft_id_arrow = Object.getOwnPropertyNames(draft_arrow);
- if (draft_id_arrow.length === 0) { // empty drafts modal
+ if (draft_id_arrow.length === 0) {
+ // empty drafts modal
return;
}
let draft_element;
if (event_name === "up_arrow") {
- draft_element = document.querySelectorAll('[data-draft-id="' + draft_id_arrow[draft_id_arrow.length - 1] + '"]');
+ draft_element = document.querySelectorAll(
+ '[data-draft-id="' + draft_id_arrow[draft_id_arrow.length - 1] + '"]',
+ );
} else if (event_name === "down_arrow") {
draft_element = document.querySelectorAll('[data-draft-id="' + draft_id_arrow[0] + '"]');
}
@@ -418,7 +427,8 @@ function drafts_scroll(next_focus_draft_row) {
// If focused draft is the last draft, scroll to the bottom.
if ($(".draft-info-box").last()[0].parentElement === next_focus_draft_row[0]) {
- $(".drafts-list")[0].scrollTop = $(".drafts-list")[0].scrollHeight - $(".drafts-list").height();
+ $(".drafts-list")[0].scrollTop =
+ $(".drafts-list")[0].scrollHeight - $(".drafts-list").height();
}
// If focused draft is cut off from the top, scroll up halfway in draft modal.
@@ -471,7 +481,9 @@ exports.drafts_handle_events = function (e, event_key) {
draft_to_be_focused_id = prev_draft_row.data("draft-id");
}
- const new_focus_element = document.querySelectorAll('[data-draft-id="' + draft_to_be_focused_id + '"]');
+ const new_focus_element = document.querySelectorAll(
+ '[data-draft-id="' + draft_to_be_focused_id + '"]',
+ );
if (new_focus_element[0] !== undefined) {
activate_element(new_focus_element[0].children[0]);
}
diff --git a/static/js/dropdown_list_widget.js b/static/js/dropdown_list_widget.js
index 9d520cffede..d5058643e66 100644
--- a/static/js/dropdown_list_widget.js
+++ b/static/js/dropdown_list_widget.js
@@ -1,11 +1,14 @@
const DropdownListWidget = function (opts) {
const init = () => {
// Run basic sanity checks on opts, and set up sane defaults.
- opts = Object.assign({
- null_value: null,
- render_text: (item_name) => item_name,
- on_update: () => {},
- }, opts);
+ opts = Object.assign(
+ {
+ null_value: null,
+ render_text: (item_name) => item_name,
+ on_update: () => {},
+ },
+ opts,
+ );
opts.container_id = `${opts.widget_name}_widget`;
opts.value_id = `id_${opts.widget_name}`;
if (opts.value === undefined) {
@@ -43,7 +46,9 @@ const DropdownListWidget = function (opts) {
};
const register_event_handlers = () => {
- $(`#${opts.container_id} .dropdown-list-body`).on("click keypress", ".list_item", function (e) {
+ $(`#${opts.container_id} .dropdown-list-body`).on("click keypress", ".list_item", function (
+ e,
+ ) {
const setting_elem = $(this).closest(`.${opts.widget_name}_setting`);
if (e.type === "keypress") {
if (e.which === 13) {
diff --git a/static/js/echo.js b/static/js/echo.js
index 6e07fa5b44b..db6c6de03ac 100644
--- a/static/js/echo.js
+++ b/static/js/echo.js
@@ -144,7 +144,6 @@ exports.is_slash_command = function (content) {
return !content.startsWith("/me") && content.startsWith("/");
};
-
exports.try_deliver_locally = function (message_request) {
if (markdown.contains_backend_only_syntax(message_request.content)) {
return;
@@ -374,7 +373,10 @@ exports.initialize = function () {
// otherwise send would not have failed
const message = waiting_for_ack.get(local_id);
if (message === undefined) {
- blueslip.warn("Got resend or retry on failure request but did not find message in ack list " + local_id);
+ blueslip.warn(
+ "Got resend or retry on failure request but did not find message in ack list " +
+ local_id,
+ );
return;
}
callback(message, row);
diff --git a/static/js/emoji_picker.js b/static/js/emoji_picker.js
index 2211878872a..21a29d8326e 100644
--- a/static/js/emoji_picker.js
+++ b/static/js/emoji_picker.js
@@ -101,9 +101,12 @@ function show_emoji_catalog() {
exports.generate_emoji_picker_data = function (realm_emojis) {
const catalog = new Map();
- catalog.set("Custom", Array.from(realm_emojis.keys(), (realm_emoji_name) =>
- emoji.emojis_by_name.get(realm_emoji_name),
- ));
+ catalog.set(
+ "Custom",
+ Array.from(realm_emojis.keys(), (realm_emoji_name) =>
+ emoji.emojis_by_name.get(realm_emoji_name),
+ ),
+ );
for (const [category, codepoints] of Object.entries(emoji_codes.emoji_catalog)) {
const emojis = [];
@@ -256,7 +259,8 @@ function is_composition(emoji) {
}
function process_enter_while_filtering(e) {
- if (e.keyCode === 13) { // enter key
+ if (e.keyCode === 13) {
+ // enter key
e.preventDefault();
const first_emoji = get_rendered_emoji(0, 0);
if (first_emoji) {
@@ -283,7 +287,7 @@ function toggle_selected_emoji(e) {
}
function round_off_to_previous_multiple(number_to_round, multiple) {
- return number_to_round - number_to_round % multiple;
+ return number_to_round - (number_to_round % multiple);
}
function reset_emoji_showcase() {
@@ -354,9 +358,7 @@ function get_next_emoji_coordinates(move_by) {
max_len = get_max_index(next_section);
const prev_multiple = round_off_to_previous_multiple(max_len, 6);
next_index = prev_multiple + current_index;
- next_index = next_index >= max_len
- ? prev_multiple + current_index - 6
- : next_index;
+ next_index = next_index >= max_len ? prev_multiple + current_index - 6 : next_index;
}
}
} else if (next_index >= get_max_index(next_section)) {
@@ -388,8 +390,11 @@ function change_focus_to_filter() {
}
exports.navigate = function (event_name, e) {
- if (event_name === "toggle_reactions_popover" && exports.reactions_popped() &&
- (search_is_active === false || search_results.length === 0)) {
+ if (
+ event_name === "toggle_reactions_popover" &&
+ exports.reactions_popped() &&
+ (search_is_active === false || search_results.length === 0)
+ ) {
exports.hide_emoji_popover();
return true;
}
@@ -420,8 +425,7 @@ exports.navigate = function (event_name, e) {
// Move down into emoji map.
const filter_text = $(".emoji-popover-filter").val();
const is_cursor_at_end = $(".emoji-popover-filter").caret() === filter_text.length;
- if (event_name === "down_arrow" ||
- is_cursor_at_end && event_name === "right_arrow") {
+ if (event_name === "down_arrow" || (is_cursor_at_end && event_name === "right_arrow")) {
selected_emoji.focus();
if (current_section === 0 && current_index < 6) {
ui.get_scroll_element($emoji_map).scrollTop(0);
@@ -435,8 +439,10 @@ exports.navigate = function (event_name, e) {
return true;
}
return false;
- } else if (current_section === 0 && current_index < 6 && event_name === "up_arrow" ||
- current_section === 0 && current_index === 0 && event_name === "left_arrow") {
+ } else if (
+ (current_section === 0 && current_index < 6 && event_name === "up_arrow") ||
+ (current_section === 0 && current_index === 0 && event_name === "left_arrow")
+ ) {
if (selected_emoji) {
// In this case, we're move up into the reaction
// filter. Here, we override the default browser
@@ -496,7 +502,7 @@ function process_keypress(e) {
const pressed_key = e.which;
if (!is_filter_focused && pressed_key !== 58) {
// ':' => 58, is a hotkey for toggling reactions popover.
- if (pressed_key >= 32 && pressed_key <= 126 || pressed_key === 8) {
+ if ((pressed_key >= 32 && pressed_key <= 126) || pressed_key === 8) {
// Handle only printable characters or backspace.
e.preventDefault();
e.stopPropagation();
@@ -505,9 +511,11 @@ function process_keypress(e) {
const old_query = emoji_filter.val();
let new_query = "";
- if (pressed_key === 8) { // Handles backspace.
+ if (pressed_key === 8) {
+ // Handles backspace.
new_query = old_query.slice(0, -1);
- } else { // Handles any printable character.
+ } else {
+ // Handles any printable character.
const key_str = String.fromCharCode(e.which);
new_query = old_query + key_str;
}
@@ -616,8 +624,7 @@ exports.render_emoji_popover = function (elt, id) {
exports.toggle_emoji_popover = function (element, id) {
const last_popover_elem = current_message_emoji_popover_elem;
popovers.hide_all();
- if (last_popover_elem !== undefined
- && last_popover_elem.get()[0] === element) {
+ if (last_popover_elem !== undefined && last_popover_elem.get()[0] === element) {
// We want it to be the case that a user can dismiss a popover
// by clicking on the same element that caused the popover.
return;
@@ -638,7 +645,6 @@ exports.toggle_emoji_popover = function (element, id) {
};
exports.register_click_handlers = function () {
-
$(document).on("click", ".emoji-popover-emoji.reaction", function (e) {
// When an emoji is clicked in the popover,
// if the user has reacted to this message with this emoji
@@ -729,7 +735,9 @@ exports.register_click_handlers = function () {
const $popover = $(e.currentTarget).closest(".emoji-info-popover").expectOne();
const $emoji_map = $popover.find(".emoji-popover-emoji-map");
- const offset = section_head_offsets.find((o) => o.section === $(this).attr("data-tab-name"));
+ const offset = section_head_offsets.find(
+ (o) => o.section === $(this).attr("data-tab-name"),
+ );
if (offset) {
ui.get_scroll_element($emoji_map).scrollTop(offset.position_y);
@@ -744,7 +752,10 @@ exports.register_click_handlers = function () {
const emoji_id = $(e.currentTarget).data("emoji-id");
const emoji_coordinates = get_emoji_coordinates(emoji_id);
- const $emoji_map = $(e.currentTarget).closest(".emoji-popover").expectOne().find(".emoji-popover-emoji-map");
+ const $emoji_map = $(e.currentTarget)
+ .closest(".emoji-popover")
+ .expectOne()
+ .find(".emoji-popover-emoji-map");
maybe_change_focused_emoji(
$emoji_map,
emoji_coordinates.section,
diff --git a/static/js/favicon.js b/static/js/favicon.js
index de9dc3056a2..773fdfa6b0a 100644
--- a/static/js/favicon.js
+++ b/static/js/favicon.js
@@ -2,5 +2,4 @@ exports.set = function (url) {
$("#favicon").attr("href", url);
};
-
window.favicon = exports;
diff --git a/static/js/feedback_widget.js b/static/js/feedback_widget.js
index df045be17bb..3e8f52ea685 100644
--- a/static/js/feedback_widget.js
+++ b/static/js/feedback_widget.js
@@ -18,7 +18,6 @@ Codewise it's a singleton widget that controls the DOM inside
*/
-
const meta = {
hide_me_time: null,
alert_hover_state: false,
diff --git a/static/js/fenced_code.js b/static/js/fenced_code.js
index 7fc978df93b..bb47e9ddccd 100644
--- a/static/js/fenced_code.js
+++ b/static/js/fenced_code.js
@@ -5,20 +5,21 @@
// auto-completing code blocks missing a trailing close.
// See backend fenced_code.py:71 for associated regexp
-const fencestr = "^(~{3,}|`{3,})" + // Opening Fence
- "[ ]*" + // Spaces
- "(" +
- "\\{?\\.?" +
- "([a-zA-Z0-9_+-./#]*)" + // Language
- "\\}?" +
- ")" +
- "[ ]*" + // Spaces
- "(" +
- "\\{?\\.?" +
- "([^~`]*)" + // Header (see fenced_code.py)
- "\\}?" +
- ")" +
- "$";
+const fencestr =
+ "^(~{3,}|`{3,})" + // Opening Fence
+ "[ ]*" + // Spaces
+ "(" +
+ "\\{?\\.?" +
+ "([a-zA-Z0-9_+-./#]*)" + // Language
+ "\\}?" +
+ ")" +
+ "[ ]*" + // Spaces
+ "(" +
+ "\\{?\\.?" +
+ "([^~`]*)" + // Header (see fenced_code.py)
+ "\\}?" +
+ ")" +
+ "$";
const fence_re = new RegExp(fencestr);
// Default stashing function does nothing
@@ -29,9 +30,11 @@ let stash_func = function (text) {
exports.wrap_code = function (code) {
// Trim trailing \n until there's just one left
// This mirrors how pygments handles code input
- return '<div class="codehilite"><pre><span></span><code>' +
+ return (
+ '<div class="codehilite"><pre><span></span><code>' +
_.escape(code.replace(/^\n+|\n+$/g, "")) +
- "\n</code></pre></div>\n";
+ "\n</code></pre></div>\n"
+ );
};
function wrap_quote(text) {
@@ -42,7 +45,12 @@ function wrap_quote(text) {
// beginning of each line
for (const paragraph of paragraphs) {
const lines = paragraph.split("\n");
- quoted_paragraphs.push(lines.filter((line) => line !== "").map((line) => "> " + line).join("\n"));
+ quoted_paragraphs.push(
+ lines
+ .filter((line) => line !== "")
+ .map((line) => "> " + line)
+ .join("\n"),
+ );
}
return quoted_paragraphs.join("\n\n");
diff --git a/static/js/fetch_status.js b/static/js/fetch_status.js
index a528d397763..2253e651c29 100644
--- a/static/js/fetch_status.js
+++ b/static/js/fetch_status.js
@@ -1,5 +1,4 @@
const FetchStatus = function () {
-
const self = {};
// The FetchStatus object tracks tracks the state of a
@@ -129,12 +128,10 @@ const FetchStatus = function () {
};
self.update_expected_max_message_id = function (messages) {
- expected_max_message_id = Math.max(expected_max_message_id,
- max_id_for_messages(messages));
+ expected_max_message_id = Math.max(expected_max_message_id, max_id_for_messages(messages));
};
return self;
-
};
module.exports = FetchStatus;
window.FetchStatus = FetchStatus;
diff --git a/static/js/filter.js b/static/js/filter.js
index e5af1cbbd3a..e5a68be623a 100644
--- a/static/js/filter.js
+++ b/static/js/filter.js
@@ -8,7 +8,10 @@ function zephyr_stream_name_match(message, operand) {
if (m !== null && m[1] !== undefined) {
base_stream_name = m[1];
}
- const related_regexp = new RegExp(/^(un)*/.source + util.escape_regexp(base_stream_name) + /(\.d)*$/.source, "i");
+ const related_regexp = new RegExp(
+ /^(un)*/.source + util.escape_regexp(base_stream_name) + /(\.d)*$/.source,
+ "i",
+ );
return related_regexp.test(message.stream);
}
@@ -22,21 +25,29 @@ function zephyr_topic_name_match(message, operand) {
// Additionally, Zephyr users expect the empty instance and
// instance "personal" to be the same.
- if (base_topic === ""
- || base_topic.toLowerCase() === "personal"
- || base_topic.toLowerCase() === '(instance "")') {
+ if (
+ base_topic === "" ||
+ base_topic.toLowerCase() === "personal" ||
+ base_topic.toLowerCase() === '(instance "")'
+ ) {
related_regexp = /^(|personal|\(instance ""\))(\.d)*$/i;
} else {
- related_regexp = new RegExp(/^/.source + util.escape_regexp(base_topic) + /(\.d)*$/.source, "i");
+ related_regexp = new RegExp(
+ /^/.source + util.escape_regexp(base_topic) + /(\.d)*$/.source,
+ "i",
+ );
}
return related_regexp.test(message.topic);
}
function message_in_home(message) {
- if (message.type === "private" || message.mentioned ||
- page_params.narrow_stream !== undefined &&
- message.stream.toLowerCase() === page_params.narrow_stream.toLowerCase()) {
+ if (
+ message.type === "private" ||
+ message.mentioned ||
+ (page_params.narrow_stream !== undefined &&
+ message.stream.toLowerCase() === page_params.narrow_stream.toLowerCase())
+ ) {
return true;
}
@@ -78,7 +89,7 @@ function message_matches_search_term(message, operator, operand) {
return true; // in:whatever returns true
case "near":
- // this is all handled server side
+ // this is all handled server side
return true;
case "id":
@@ -118,7 +129,6 @@ function message_matches_search_term(message, operator, operand) {
}
return message.topic.toLowerCase() === operand;
-
case "sender":
return people.id_matches_email_operand(message.sender_id, operand);
@@ -132,12 +142,12 @@ function message_matches_search_term(message, operator, operand) {
return false;
}
return user_ids.includes(operand_ids[0]);
- // We should also check if the current user is in the recipient list (user_ids) of the
- // message, but it is implicit by the fact that the current user has access to the message.
+ // We should also check if the current user is in the recipient list (user_ids) of the
+ // message, but it is implicit by the fact that the current user has access to the message.
}
case "pm-with": {
- // TODO: use user_ids, not emails here
+ // TODO: use user_ids, not emails here
if (message.type !== "private") {
return false;
}
@@ -197,7 +207,7 @@ Filter.canonicalize_term = function (opts) {
switch (operator) {
case "has":
- // images -> image, etc.
+ // images -> image, etc.
operand = operand.replace(/s$/, "");
break;
@@ -217,12 +227,15 @@ Filter.canonicalize_term = function (opts) {
operand = operand.toString().toLowerCase();
break;
case "search":
- // The mac app automatically substitutes regular quotes with curly
- // quotes when typing in the search bar. Curly quotes don't trigger our
- // phrase search behavior, however. So, we replace all instances of
- // curly quotes with regular quotes when doing a search. This is
- // unlikely to cause any problems and is probably what the user wants.
- operand = operand.toString().toLowerCase().replace(/[\u201c\u201d]/g, '"');
+ // The mac app automatically substitutes regular quotes with curly
+ // quotes when typing in the search bar. Curly quotes don't trigger our
+ // phrase search behavior, however. So, we replace all instances of
+ // curly quotes with regular quotes when doing a search. This is
+ // unlikely to cause any problems and is probably what the user wants.
+ operand = operand
+ .toString()
+ .toLowerCase()
+ .replace(/[\u201c\u201d]/g, '"');
break;
default:
operand = operand.toString().toLowerCase();
@@ -244,7 +257,8 @@ Filter.canonicalize_term = function (opts) {
narrow in the URL fragment. There we do use full
URI encoding to avoid problematic characters. */
function encodeOperand(operand) {
- return operand.replace(/%/g, "%25")
+ return operand
+ .replace(/%/g, "%25")
.replace(/\+/g, "%2B")
.replace(/ /g, "+")
.replace(/"/g, "%22");
@@ -324,7 +338,6 @@ Filter.parse = function (str) {
*/
Filter.unparse = function (operators) {
const parts = operators.map((elem) => {
-
if (elem.operator === "search") {
// Search terms are the catch-all case.
// All tokens that don't start with a known operator and
@@ -340,8 +353,6 @@ Filter.unparse = function (operators) {
return parts.join(" ");
};
-
-
Filter.prototype = {
predicate: function () {
if (this._predicate === undefined) {
@@ -376,13 +387,13 @@ Filter.prototype = {
has_negated_operand: function (operator, operand) {
return this._operators.some(
- (elem) => elem.negated && (elem.operator === operator && elem.operand === operand),
+ (elem) => elem.negated && elem.operator === operator && elem.operand === operand,
);
},
has_operand: function (operator, operand) {
return this._operators.some(
- (elem) => !elem.negated && (elem.operator === operator && elem.operand === operand),
+ (elem) => !elem.negated && elem.operator === operator && elem.operand === operand,
);
},
@@ -494,7 +505,12 @@ Filter.prototype = {
if (!this._sub) {
return "#";
}
- return "/#narrow/stream/" + stream_data.name_to_slug(this.operands("stream")[0]) + "/topic/" + this.operands("topic")[0];
+ return (
+ "/#narrow/stream/" +
+ stream_data.name_to_slug(this.operands("stream")[0]) +
+ "/topic/" +
+ this.operands("topic")[0]
+ );
}
// eliminate "complex filters"
@@ -505,11 +521,13 @@ Filter.prototype = {
if (term_types[1] === "search") {
switch (term_types[0]) {
case "stream":
- // if stream does not exist, redirect to All
+ // if stream does not exist, redirect to All
if (!this._sub) {
return "#";
}
- return "/#narrow/stream/" + stream_data.name_to_slug(this.operands("stream")[0]);
+ return (
+ "/#narrow/stream/" + stream_data.name_to_slug(this.operands("stream")[0])
+ );
case "is-private":
return "/#narrow/is/private";
case "is-starred":
@@ -519,8 +537,10 @@ Filter.prototype = {
case "streams-public":
return "/#narrow/streams/public";
case "pm-with":
- // join is used to transform the array to a comma separated string
- return "/#narrow/pm-with/" + people.emails_to_slug(this.operands("pm-with").join());
+ // join is used to transform the array to a comma separated string
+ return (
+ "/#narrow/pm-with/" + people.emails_to_slug(this.operands("pm-with").join())
+ );
// TODO: It is ambiguous how we want to handle the 'sender' case,
// we may remove it in the future based on design decisions
case "sender":
@@ -563,14 +583,16 @@ Filter.prototype = {
get_title: function () {
// Nice explanatory titles for common views.
const term_types = this.sorted_term_types();
- if (term_types.length === 3 && _.isEqual(term_types, ["stream", "topic", "search"]) ||
- term_types.length === 2 && _.isEqual(term_types, ["stream", "topic"])) {
+ if (
+ (term_types.length === 3 && _.isEqual(term_types, ["stream", "topic", "search"])) ||
+ (term_types.length === 2 && _.isEqual(term_types, ["stream", "topic"]))
+ ) {
if (!this._sub) {
return i18n.t("Unknown stream");
}
return this._sub.name;
}
- if (term_types.length === 1 || term_types.length === 2 && term_types[1] === "search") {
+ if (term_types.length === 1 || (term_types.length === 2 && term_types[1] === "search")) {
switch (term_types[0]) {
case "in-home":
return i18n.t("All messages");
@@ -612,8 +634,11 @@ Filter.prototype = {
},
contains_only_private_messages: function () {
- return this.has_operator("is") && this.operands("is")[0] === "private" ||
- this.has_operator("pm-with") || this.has_operator("group-pm-with");
+ return (
+ (this.has_operator("is") && this.operands("is")[0] === "private") ||
+ this.has_operator("pm-with") ||
+ this.has_operator("group-pm-with")
+ );
},
includes_full_stream_history: function () {
@@ -649,8 +674,7 @@ Filter.prototype = {
return false;
}
- if (this.has_operator("streams") ||
- this.has_negated_operand("streams", "public")) {
+ if (this.has_operator("streams") || this.has_negated_operand("streams", "public")) {
return false;
}
@@ -761,7 +785,9 @@ Filter.prototype = {
const operators = this._operators;
if (!this.can_apply_locally()) {
- return function () { return true; };
+ return function () {
+ return true;
+ };
}
// FIXME: This is probably pretty slow.
@@ -800,12 +826,21 @@ Filter.sorted_term_types = function (term_types) {
const levels = [
"in",
"streams-public",
- "stream", "topic",
- "pm-with", "group-pm-with", "sender",
- "near", "id",
- "is-alerted", "is-mentioned", "is-private",
- "is-starred", "is-unread",
- "has-link", "has-image", "has-attachment",
+ "stream",
+ "topic",
+ "pm-with",
+ "group-pm-with",
+ "sender",
+ "near",
+ "id",
+ "is-alerted",
+ "is-mentioned",
+ "is-private",
+ "is-starred",
+ "is-unread",
+ "has-link",
+ "has-image",
+ "has-attachment",
"search",
];
@@ -845,7 +880,7 @@ Filter.operator_to_prefix = function (operator, negated) {
case "near":
return verb + "messages around";
- // Note: We hack around using this in "describe" below.
+ // Note: We hack around using this in "describe" below.
case "has":
return verb + "messages with one or more";
@@ -864,7 +899,7 @@ Filter.operator_to_prefix = function (operator, negated) {
case "in":
return verb + "messages in";
- // Note: We hack around using this in "describe" below.
+ // Note: We hack around using this in "describe" below.
case "is":
return verb + "messages that are";
@@ -917,13 +952,19 @@ function describe_unescaped(operators) {
if (canonicalized_operator === "has") {
// search_suggestion.get_suggestions takes care that this message will
// only be shown if the `has` operator is not at the last.
- const valid_has_operands = ["image", "images", "link", "links", "attachment", "attachments"];
+ const valid_has_operands = [
+ "image",
+ "images",
+ "link",
+ "links",
+ "attachment",
+ "attachments",
+ ];
if (!valid_has_operands.includes(operand)) {
return "invalid " + operand + " operand for has operator";
}
}
- const prefix_for_operator = Filter.operator_to_prefix(canonicalized_operator,
- elem.negated);
+ const prefix_for_operator = Filter.operator_to_prefix(canonicalized_operator, elem.negated);
if (prefix_for_operator !== "") {
return prefix_for_operator + " " + operand;
}
diff --git a/static/js/floating_recipient_bar.js b/static/js/floating_recipient_bar.js
index 69d9c164abf..13ad251bb05 100644
--- a/static/js/floating_recipient_bar.js
+++ b/static/js/floating_recipient_bar.js
@@ -148,7 +148,6 @@ exports.relevant_recipient_bars = function () {
let elem = next(first_elem);
while (elem.length) {
-
if (top_offset(elem) < header_height) {
// If we are close to the top, then the prior
// elements we found are no longer relevant,
@@ -242,7 +241,6 @@ exports.candidate_recipient_bar = function () {
}
while (candidate.length) {
-
if (candidate.hasClass("recipient_row") && top_offset(candidate) < 0) {
return candidate;
}
@@ -262,7 +260,6 @@ function show_floating_recipient_bar() {
let old_source;
function replace_floating_recipient_bar(source_info) {
-
const source_recipient_bar = source_info.elem;
let new_label;
@@ -326,5 +323,4 @@ exports.update = function () {
replace_floating_recipient_bar(items[0]);
};
-
window.floating_recipient_bar = exports;
diff --git a/static/js/fold_dict.ts b/static/js/fold_dict.ts
index 51b87623169..9fec7fdb529 100644
--- a/static/js/fold_dict.ts
+++ b/static/js/fold_dict.ts
@@ -12,7 +12,7 @@
- topics
- etc.
*/
-type KeyValue<V> = { k: string; v: V };
+type KeyValue<V> = {k: string; v: V};
export class FoldDict<V> {
private _items: Map<string, KeyValue<V>> = new Map();
diff --git a/static/js/hash_util.js b/static/js/hash_util.js
index 80e8db961b5..0c85d9a5e98 100644
--- a/static/js/hash_util.js
+++ b/static/js/hash_util.js
@@ -19,9 +19,7 @@ exports.get_hash_section = function (hash) {
// window.location.hash. So we hide our URI-encoding
// by replacing % with . (like MediaWiki).
exports.encodeHashComponent = function (str) {
- return encodeURIComponent(str)
- .replace(/\./g, "%2E")
- .replace(/%/g, ".");
+ return encodeURIComponent(str).replace(/\./g, "%2E").replace(/%/g, ".");
};
exports.encode_operand = function (operator, operand) {
@@ -92,8 +90,12 @@ exports.by_stream_uri = function (stream_id) {
};
exports.by_stream_topic_uri = function (stream_id, topic) {
- return "#narrow/stream/" + exports.encode_stream_id(stream_id) +
- "/topic/" + exports.encodeHashComponent(topic);
+ return (
+ "#narrow/stream/" +
+ exports.encode_stream_id(stream_id) +
+ "/topic/" +
+ exports.encodeHashComponent(topic)
+ );
};
// Encodes an operator list into the
@@ -111,8 +113,12 @@ exports.operators_to_hash = function (operators) {
const operand = elem.operand;
const sign = elem.negated ? "-" : "";
- hash += "/" + sign + exports.encodeHashComponent(operator)
- + "/" + exports.encode_operand(operator, operand);
+ hash +=
+ "/" +
+ sign +
+ exports.encodeHashComponent(operator) +
+ "/" +
+ exports.encode_operand(operator, operand);
}
}
@@ -120,9 +126,7 @@ exports.operators_to_hash = function (operators) {
};
exports.by_sender_uri = function (reply_to) {
- return exports.operators_to_hash([
- {operator: "sender", operand: reply_to},
- ]);
+ return exports.operators_to_hash([{operator: "sender", operand: reply_to}]);
};
exports.pm_with_uri = function (reply_to) {
@@ -139,16 +143,19 @@ exports.huddle_with_uri = function (user_ids_string) {
};
exports.by_conversation_and_time_uri = function (message) {
- const absolute_url = window.location.protocol + "//" +
- window.location.host + "/" +
+ const absolute_url =
+ window.location.protocol +
+ "//" +
+ window.location.host +
+ "/" +
window.location.pathname.split("/")[1];
const suffix = "/near/" + exports.encodeHashComponent(message.id);
if (message.type === "stream") {
- return absolute_url +
- exports.by_stream_topic_uri(message.stream_id, message.topic) +
- suffix;
+ return (
+ absolute_url + exports.by_stream_topic_uri(message.stream_id, message.topic) + suffix
+ );
}
return absolute_url + people.pm_perma_link(message) + suffix;
diff --git a/static/js/hashchange.js b/static/js/hashchange.js
index 60690e5f1c9..68e64fc23fb 100644
--- a/static/js/hashchange.js
+++ b/static/js/hashchange.js
@@ -62,7 +62,14 @@ const state = {
function is_overlay_hash(hash) {
// Hash changes within this list are overlays and should not unnarrow (etc.)
- const overlay_list = ["streams", "drafts", "settings", "organization", "invite", "recent_topics"];
+ const overlay_list = [
+ "streams",
+ "drafts",
+ "settings",
+ "organization",
+ "invite",
+ "recent_topics",
+ ];
const main_hash = hash_util.get_hash_category(hash);
return overlay_list.includes(main_hash);
@@ -81,8 +88,8 @@ function do_hashchange_normal(from_reload) {
ui_util.change_tab_to("#home");
const operators = hash_util.parse_narrow(hash);
if (operators === undefined) {
- // If the narrow URL didn't parse, clear
- // window.location.hash and send them to the home tab
+ // If the narrow URL didn't parse, clear
+ // window.location.hash and send them to the home tab
set_hash("");
activate_home_tab();
return false;
@@ -294,7 +301,6 @@ exports.exit_overlay = function (callback) {
if (typeof callback === "function") {
callback();
}
-
}
};
diff --git a/static/js/hotkey.js b/static/js/hotkey.js
index 5d5743f6b6b..c742e32c6ef 100644
--- a/static/js/hotkey.js
+++ b/static/js/hotkey.js
@@ -4,13 +4,7 @@ function do_narrow_action(action) {
}
// For message actions and user profile menu.
-const menu_dropdown_hotkeys = [
- "down_arrow",
- "up_arrow",
- "vim_up",
- "vim_down",
- "enter",
-];
+const menu_dropdown_hotkeys = ["down_arrow", "up_arrow", "vim_up", "vim_down", "enter"];
// Note that multiple keys can map to the same event_name, which
// we'll do in cases where they have the exact same semantics.
@@ -167,12 +161,14 @@ exports.get_keypress_hotkey = function (e) {
exports.processing_text = function () {
const $focused_elt = $(":focus");
- return $focused_elt.is("input") ||
+ return (
+ $focused_elt.is("input") ||
$focused_elt.is("select") ||
$focused_elt.is("textarea") ||
$focused_elt.hasClass("editable-section") ||
$focused_elt.parents(".pill-container").length >= 1 ||
- $focused_elt.attr("id") === "compose-send-button";
+ $focused_elt.attr("id") === "compose-send-button"
+ );
};
exports.in_content_editable_widget = function (e) {
@@ -402,8 +398,10 @@ exports.process_shift_tab_key = function () {
// Shift-tabbing from the edit message save button takes you to the content.
const focused_message_edit_save = $(".message_edit_save").filter(":focus");
if (focused_message_edit_save.length > 0) {
- focused_message_edit_save.closest(".message_edit_form")
- .find(".message_edit_content").focus();
+ focused_message_edit_save
+ .closest(".message_edit_form")
+ .find(".message_edit_content")
+ .focus();
return true;
}
@@ -567,7 +565,10 @@ exports.process_hotkey = function (e, hotkey) {
return true;
}
- if ((event_name === "up_arrow" || event_name === "down_arrow") && compose_state.focus_in_empty_compose()) {
+ if (
+ (event_name === "up_arrow" || event_name === "down_arrow") &&
+ compose_state.focus_in_empty_compose()
+ ) {
compose_actions.cancel();
// don't return, as we still want it to be picked up by the code below
} else if (event_name === "page_up") {
@@ -668,8 +669,8 @@ exports.process_hotkey = function (e, hotkey) {
drafts.launch();
return true;
case "reply_message": // 'r': respond to message
- // Note that you can "enter" to respond to messages as well,
- // but that is handled in process_enter_key().
+ // Note that you can "enter" to respond to messages as well,
+ // but that is handled in process_enter_key().
compose_actions.respond_to_message({trigger: "hotkey"});
return true;
case "C_deprecated":
@@ -746,8 +747,9 @@ exports.process_hotkey = function (e, hotkey) {
case "toggle_reactions_popover": // ':': open reactions to message
reactions.open_reactions_popover();
return true;
- case "thumbs_up_emoji": { // '+': reacts with thumbs up emoji on selected message
- // Use canonical name.
+ case "thumbs_up_emoji": {
+ // '+': reacts with thumbs up emoji on selected message
+ // Use canonical name.
const thumbs_up_emoji_code = "1f44d";
const canonical_name = emoji.get_emoji_name(thumbs_up_emoji_code);
reactions.toggle_emoji_reaction(msg.id, canonical_name);
diff --git a/static/js/hotspots.js b/static/js/hotspots.js
index 7e155dfc3bb..75b0558ae70 100644
--- a/static/js/hotspots.js
+++ b/static/js/hotspots.js
@@ -12,33 +12,48 @@ const VIEWPORT_CENTER = "viewport_center";
// popover orientation can optionally be fixed here (property: popover),
// otherwise popovers.compute_placement is used to compute orientation
const HOTSPOT_LOCATIONS = new Map([
- ["intro_reply", {
- element: ".selected_message .messagebox-content",
- offset_x: 0.85,
- offset_y: 0.7,
- popover: BOTTOM,
- }],
- ["intro_streams", {
- element: "#streams_header .sidebar-title",
- offset_x: 1.35,
- offset_y: 0.39,
- }],
- ["intro_topics", {
- element: ".topic-name",
- offset_x: 0.8,
- offset_y: 0.39,
- }],
- ["intro_gear", {
- element: "#settings-dropdown",
- offset_x: -0.4,
- offset_y: 1.2,
- popover: LEFT_BOTTOM,
- }],
- ["intro_compose", {
- element: "#left_bar_compose_stream_button_big",
- offset_x: 0,
- offset_y: 0,
- }],
+ [
+ "intro_reply",
+ {
+ element: ".selected_message .messagebox-content",
+ offset_x: 0.85,
+ offset_y: 0.7,
+ popover: BOTTOM,
+ },
+ ],
+ [
+ "intro_streams",
+ {
+ element: "#streams_header .sidebar-title",
+ offset_x: 1.35,
+ offset_y: 0.39,
+ },
+ ],
+ [
+ "intro_topics",
+ {
+ element: ".topic-name",
+ offset_x: 0.8,
+ offset_y: 0.39,
+ },
+ ],
+ [
+ "intro_gear",
+ {
+ element: "#settings-dropdown",
+ offset_x: -0.4,
+ offset_y: 1.2,
+ popover: LEFT_BOTTOM,
+ },
+ ],
+ [
+ "intro_compose",
+ {
+ element: "#left_bar_compose_stream_button_big",
+ offset_x: 0,
+ offset_y: 0,
+ },
+ ],
]);
// popover illustration url(s)
@@ -58,8 +73,12 @@ function place_icon(hotspot) {
const element = $(hotspot.location.element);
const icon = $("#hotspot_" + hotspot.name + "_icon");
- if (element.length === 0 || element.css("display") === "none" ||
- !element.is(":visible") || element.is(":hidden")) {
+ if (
+ element.length === 0 ||
+ element.css("display") === "none" ||
+ !element.is(":visible") ||
+ element.is(":hidden")
+ ) {
icon.css("display", "none");
return false;
}
@@ -84,14 +103,17 @@ function place_popover(hotspot) {
}
const popover_width = $("#hotspot_" + hotspot.name + "_overlay .hotspot-popover").outerWidth();
- const popover_height = $("#hotspot_" + hotspot.name + "_overlay .hotspot-popover").outerHeight();
+ const popover_height = $(
+ "#hotspot_" + hotspot.name + "_overlay .hotspot-popover",
+ ).outerHeight();
const el_width = $(hotspot.location.element).outerWidth();
const el_height = $(hotspot.location.element).outerHeight();
const arrow_offset = 20;
let popover_offset;
let arrow_placement;
- const orientation = hotspot.location.popover ||
+ const orientation =
+ hotspot.location.popover ||
popovers.compute_placement(
$(hotspot.location.element),
popover_height,
@@ -149,10 +171,7 @@ function place_popover(hotspot) {
break;
default:
- blueslip.error(
- "Invalid popover placement value for hotspot '" +
- hotspot.name + "'",
- );
+ blueslip.error("Invalid popover placement value for hotspot '" + hotspot.name + "'");
break;
}
@@ -179,8 +198,7 @@ function place_popover(hotspot) {
};
}
- $("#hotspot_" + hotspot.name + "_overlay .hotspot-popover")
- .css(popover_placement);
+ $("#hotspot_" + hotspot.name + "_overlay .hotspot-popover").css(popover_placement);
}
function insert_hotspot_into_DOM(hotspot) {
@@ -197,10 +215,12 @@ function insert_hotspot_into_DOM(hotspot) {
});
const hotspot_icon_HTML =
- '<div class="hotspot-icon" id="hotspot_' + hotspot.name + '_icon">' +
- '<span class="dot"></span>' +
- '<span class="pulse"></span>' +
- '<div class="bounce"><span class="bounce-icon">?</span></div>' +
+ '<div class="hotspot-icon" id="hotspot_' +
+ hotspot.name +
+ '_icon">' +
+ '<span class="dot"></span>' +
+ '<span class="pulse"></span>' +
+ '<div class="bounce"><span class="bounce-icon">?</span></div>' +
"</div>";
setTimeout(() => {
@@ -212,11 +232,15 @@ function insert_hotspot_into_DOM(hotspot) {
// reposition on any event that might update the UI
["resize", "scroll", "onkeydown", "click"].forEach((event_name) => {
- window.addEventListener(event_name, _.debounce(() => {
- if (place_icon(hotspot)) {
- place_popover(hotspot);
- }
- }, 10), true);
+ window.addEventListener(
+ event_name,
+ _.debounce(() => {
+ if (place_icon(hotspot)) {
+ place_popover(hotspot);
+ }
+ }, 10),
+ true,
+ );
});
}, hotspot.delay * 1000);
}
@@ -226,12 +250,15 @@ exports.is_open = function () {
};
exports.close_hotspot_icon = function (elem) {
- $(elem).animate({opacity: 0}, {
- duration: 300,
- done: function () {
- $(elem).css({display: "none"});
- }.bind(elem),
- });
+ $(elem).animate(
+ {opacity: 0},
+ {
+ duration: 300,
+ done: function () {
+ $(elem).css({display: "none"});
+ }.bind(elem),
+ },
+ );
};
function close_read_hotspots(new_hotspots) {
diff --git a/static/js/input_pill.js b/static/js/input_pill.js
index 14ddef37e26..44a6b9ac458 100644
--- a/static/js/input_pill.js
+++ b/static/js/input_pill.js
@@ -264,8 +264,10 @@ exports.create = function (opts) {
// if the user backspaces and there is input, just do normal char
// deletion, otherwise delete the last pill in the sequence.
- if (char === KEY.BACKSPACE && (
- funcs.value(e.target).length === 0 || window.getSelection().anchorOffset === 0)) {
+ if (
+ char === KEY.BACKSPACE &&
+ (funcs.value(e.target).length === 0 || window.getSelection().anchorOffset === 0)
+ ) {
e.preventDefault();
funcs.removeLastPill();
@@ -361,7 +363,10 @@ exports.create = function (opts) {
store.$parent.on("copy", ".pill", (e) => {
const id = store.$parent.find(":focus").data("id");
const data = funcs.getByID(id);
- e.originalEvent.clipboardData.setData("text/plain", store.get_text_from_item(data.item));
+ e.originalEvent.clipboardData.setData(
+ "text/plain",
+ store.get_text_from_item(data.item),
+ );
e.preventDefault();
});
})();
diff --git a/static/js/invite.js b/static/js/invite.js
index 9bad326f660..cf69f82169a 100644
--- a/static/js/invite.js
+++ b/static/js/invite.js
@@ -61,7 +61,6 @@ function submit_invitation_form() {
const rendered_email_msg = render_settings_dev_env_email_access();
$("#dev_env_msg").html(rendered_email_msg).addClass("alert-info").show();
}
-
},
error: function (xhr) {
const arr = JSON.parse(xhr.responseText);
@@ -110,8 +109,12 @@ function generate_multiuse_invite() {
data: data,
beforeSend: beforeSend,
success: function (data) {
- ui_report.success(i18n.t('Invitation link: <a href="__link__">__link__</a>',
- {link: data.invite_link}), invite_status);
+ ui_report.success(
+ i18n.t('Invitation link: <a href="__link__">__link__</a>', {
+ link: data.invite_link,
+ }),
+ invite_status,
+ );
},
error: function (xhr) {
ui_report.error("", xhr, invite_status);
diff --git a/static/js/lightbox.js b/static/js/lightbox.js
index 05723bd6dd7..c22b2154a9b 100644
--- a/static/js/lightbox.js
+++ b/static/js/lightbox.js
@@ -59,7 +59,9 @@ function display_image(payload) {
function display_video(payload) {
render_lightbox_list_images(payload.preview);
- $("#lightbox_overlay .image-preview, .image-description, .download, .lightbox-canvas-trigger").hide();
+ $(
+ "#lightbox_overlay .image-preview, .image-description, .download, .lightbox-canvas-trigger",
+ ).hide();
let source;
if (payload.type === "youtube-video") {
@@ -68,14 +70,19 @@ function display_video(payload) {
source = "https://player.vimeo.com/video/" + payload.source;
} else if (payload.type === "embed-video") {
// Use data: to load the player in a unique origin for security.
- source = "data:text/html," + window.encodeURIComponent(
- "<!DOCTYPE html><style>iframe{position:absolute;left:0;top:0;width:100%;height:100%;box-sizing:border-box}</style>" +
- payload.source,
- );
+ source =
+ "data:text/html," +
+ window.encodeURIComponent(
+ "<!DOCTYPE html><style>iframe{position:absolute;left:0;top:0;width:100%;height:100%;box-sizing:border-box}</style>" +
+ payload.source,
+ );
}
const iframe = $("<iframe></iframe>");
- iframe.attr("sandbox", "allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts");
+ iframe.attr(
+ "sandbox",
+ "allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts",
+ );
iframe.attr("src", source);
iframe.attr("frameborder", 0);
iframe.attr("allowfullscreen", true);
@@ -286,9 +293,12 @@ exports.initialize = function () {
if (coords.right > parentOffset) {
// add 2px margin
- $image_list.animate({
- scrollLeft: coords.right - this.parentNode.clientWidth + 2,
- }, 100);
+ $image_list.animate(
+ {
+ scrollLeft: coords.right - this.parentNode.clientWidth + 2,
+ },
+ 100,
+ );
} else if (coords.left < this.parentNode.scrollLeft) {
// subtract 2px margin
$image_list.animate({scrollLeft: coords.left - 2}, 100);
diff --git a/static/js/lightbox_canvas.js b/static/js/lightbox_canvas.js
index e20710abf1a..64478fe3eac 100644
--- a/static/js/lightbox_canvas.js
+++ b/static/js/lightbox_canvas.js
@@ -99,9 +99,8 @@ const funcs = {
// delta = 8
// normalizedDelta = delta * (1 / 20) * 1 = 0.4
// zoom = zoom * (0.4 / 100) + 1
- const zoom = meta.zoom * (
- meta.speed * meta.internalSpeedMultiplier * delta / 100 + 1
- );
+ const zoom =
+ meta.zoom * ((meta.speed * meta.internalSpeedMultiplier * delta) / 100 + 1);
funcs.setZoom(meta, zoom);
funcs.displayImage(canvas, context, meta);
@@ -130,8 +129,8 @@ const funcs = {
// add the percentMovement to the meta coordinates but divide
// out by the zoom ratio because when zoomed in 10x for example
// moving the photo by 1% will appear like 10% on the <canvas>.
- meta.coords.x += percentMovement.x * 2 / meta.zoom;
- meta.coords.y += percentMovement.y * 2 / meta.zoom;
+ meta.coords.x += (percentMovement.x * 2) / meta.zoom;
+ meta.coords.y += (percentMovement.y * 2) / meta.zoom;
// redraw the image.
funcs.displayImage(canvas, context, meta);
@@ -162,7 +161,6 @@ const funcs = {
e.stopPropagation();
});
-
// make sure that when the mousedown is lifted on <canvas>to prevent
// panning events.
canvas.addEventListener("mouseup", () => {
@@ -172,7 +170,6 @@ const funcs = {
lastPosition = {};
});
-
// do so on the document.body as well, though depending on the infra,
// these are less reliable as preventDefault may prevent these events
// from propagating all the way to the <body>.
@@ -246,8 +243,7 @@ const funcs = {
canvas.width = parent.width * 2;
canvas.style.width = parent.width + "px";
-
- canvas.height = parent.width / meta.ratio * 2;
+ canvas.height = (parent.width / meta.ratio) * 2;
canvas.style.height = parent.width / meta.ratio + "px";
} else {
canvas.height = parent.height * 2;
diff --git a/static/js/list_cursor.js b/static/js/list_cursor.js
index 465ceab5066..9df3e4e19fc 100644
--- a/static/js/list_cursor.js
+++ b/static/js/list_cursor.js
@@ -8,9 +8,7 @@ const list_cursor = function (opts) {
opts.list.find_li &&
opts.list.first_key &&
opts.list.prev_key &&
- opts.list.next_key
- ;
-
+ opts.list.next_key;
if (!config_ok) {
blueslip.error("Programming error");
return;
diff --git a/static/js/list_render.js b/static/js/list_render.js
index eda81d9b9b6..dbc6b134aeb 100644
--- a/static/js/list_render.js
+++ b/static/js/list_render.js
@@ -4,7 +4,6 @@ const DEFAULTS = {
instances: new Map(),
};
-
// ----------------------------------------------------
// This function describes (programatically) how to use
// the list_render widget.
@@ -41,10 +40,7 @@ exports.get_filtered_items = (value, list, opts) => {
if (opts.filter.filterer) {
if (get_item) {
- return opts.filter.filterer(
- list.map(get_item),
- value,
- );
+ return opts.filter.filterer(list.map(get_item), value);
}
return opts.filter.filterer(list, value);
}
@@ -67,29 +63,31 @@ exports.get_filtered_items = (value, list, opts) => {
return list.filter(predicate);
};
-exports.alphabetic_sort = (prop) => function (a, b) {
- // The conversion to uppercase helps make the sorting case insensitive.
- const str1 = a[prop].toUpperCase();
- const str2 = b[prop].toUpperCase();
+exports.alphabetic_sort = (prop) =>
+ function (a, b) {
+ // The conversion to uppercase helps make the sorting case insensitive.
+ const str1 = a[prop].toUpperCase();
+ const str2 = b[prop].toUpperCase();
- if (str1 === str2) {
- return 0;
- } else if (str1 > str2) {
- return 1;
- }
+ if (str1 === str2) {
+ return 0;
+ } else if (str1 > str2) {
+ return 1;
+ }
- return -1;
-};
+ return -1;
+ };
-exports.numeric_sort = (prop) => function (a, b) {
- if (parseFloat(a[prop]) > parseFloat(b[prop])) {
- return 1;
- } else if (parseFloat(a[prop]) === parseFloat(b[prop])) {
- return 0;
- }
+exports.numeric_sort = (prop) =>
+ function (a, b) {
+ if (parseFloat(a[prop]) > parseFloat(b[prop])) {
+ return 1;
+ } else if (parseFloat(a[prop]) === parseFloat(b[prop])) {
+ return 0;
+ }
- return -1;
-};
+ return -1;
+ };
exports.valid_filter_opts = (opts) => {
if (!opts.filter) {
@@ -160,16 +158,10 @@ exports.create = function ($container, list, opts) {
const widget = {};
widget.filter_and_sort = function () {
- meta.filtered_list = exports.get_filtered_items(
- meta.filter_value,
- meta.list,
- opts,
- );
+ meta.filtered_list = exports.get_filtered_items(meta.filter_value, meta.list, opts);
if (meta.sorting_function) {
- meta.filtered_list.sort(
- meta.sorting_function,
- );
+ meta.filtered_list.sort(meta.sorting_function);
}
if (meta.reverse_mode) {
diff --git a/static/js/loading.js b/static/js/loading.js
index 41c99fe5ebb..f3788c5a4bf 100644
--- a/static/js/loading.js
+++ b/static/js/loading.js
@@ -42,8 +42,7 @@ exports.make_indicator = function (outer_container, opts) {
// These width calculations are tied to the spinner width and
// margins defined via CSS
- container.css({width: 38 + text_width,
- height: 0});
+ container.css({width: 38 + text_width, height: 0});
outer_container.data("destroying", false);
};
@@ -63,5 +62,4 @@ exports.destroy_indicator = function (container) {
container.css({width: 0, height: 0, display: "none"});
};
-
window.loading = exports;
diff --git a/static/js/local_message.js b/static/js/local_message.js
index 3d1b1d8a60d..ca7187dad01 100644
--- a/static/js/local_message.js
+++ b/static/js/local_message.js
@@ -16,7 +16,6 @@ exports.insert_message = function (message) {
};
exports.get_next_id_float = (function () {
-
const already_used = new Set();
return function () {
diff --git a/static/js/localstorage.js b/static/js/localstorage.js
index 2aaf5408e38..1efd1f74769 100644
--- a/static/js/localstorage.js
+++ b/static/js/localstorage.js
@@ -163,7 +163,9 @@ localstorage.supported = function supports_localstorage() {
return window.localStorage !== undefined && window.localStorage !== null;
} catch (e) {
if (!warned_of_localstorage) {
- blueslip.error("Client browser does not support local storage, will lose socket message on reload");
+ blueslip.error(
+ "Client browser does not support local storage, will lose socket message on reload",
+ );
warned_of_localstorage = true;
}
return false;
diff --git a/static/js/markdown.js b/static/js/markdown.js
index 38b51fd108a..16634fe8e72 100644
--- a/static/js/markdown.js
+++ b/static/js/markdown.js
@@ -32,7 +32,7 @@ exports.translate_emoticons_to_names = (text) => {
// Translates emoticons in a string to their colon syntax.
let translated = text;
let replacement_text;
- const terminal_symbols = ',.;?!()[] "\'\n\t'; // From composebox_typeahead
+ const terminal_symbols = ",.;?!()[] \"'\n\t"; // From composebox_typeahead
const symbols_except_space = terminal_symbols.replace(" ", "");
const emoticon_replacer = function (match, g1, offset, str) {
@@ -46,7 +46,8 @@ exports.translate_emoticons_to_names = (text) => {
const valid_start = symbol_at_start || offset === 0;
const valid_end = symbol_at_end || offset === str.length - match.length;
- if (non_space_at_start && non_space_at_end) { // Hello!:)?
+ if (non_space_at_start && non_space_at_end) {
+ // Hello!:)?
return match;
}
if (valid_start && valid_end) {
@@ -91,9 +92,7 @@ exports.apply_markdown = function (message) {
userMentionHandler: function (mention, silently) {
if (mention === "all" || mention === "everyone" || mention === "stream") {
message.mentioned = true;
- return '<span class="user-mention" data-user-id="*">' +
- "@" + mention +
- "</span>";
+ return '<span class="user-mention" data-user-id="*">' + "@" + mention + "</span>";
}
let full_name;
@@ -167,9 +166,14 @@ exports.apply_markdown = function (message) {
if (helpers.is_member_of_user_group(group.id, helpers.my_user_id())) {
message.mentioned = true;
}
- return '<span class="user-group-mention" data-user-group-id="' + group.id + '">' +
- "@" + _.escape(group.name) +
- "</span>";
+ return (
+ '<span class="user-group-mention" data-user-group-id="' +
+ group.id +
+ '">' +
+ "@" +
+ _.escape(group.name) +
+ "</span>"
+ );
}
return;
},
@@ -237,10 +241,19 @@ exports.is_status_message = function (raw_content) {
};
function make_emoji_span(codepoint, title, alt_text) {
- return '<span aria-label="' + title + '"' +
- ' class="emoji emoji-' + codepoint + '"' +
- ' role="img" title="' + title + '">' + alt_text +
- "</span>";
+ return (
+ '<span aria-label="' +
+ title +
+ '"' +
+ ' class="emoji emoji-' +
+ codepoint +
+ '"' +
+ ' role="img" title="' +
+ title +
+ '">' +
+ alt_text +
+ "</span>"
+ );
}
function handleUnicodeEmoji(unicode_emoji) {
@@ -270,9 +283,17 @@ function handleEmoji(emoji_name) {
const emoji_url = helpers.get_realm_emoji_url(emoji_name);
if (emoji_url) {
- return '<img alt="' + alt_text + '"' +
- ' class="emoji" src="' + emoji_url + '"' +
- ' title="' + title + '">';
+ return (
+ '<img alt="' +
+ alt_text +
+ '"' +
+ ' class="emoji" src="' +
+ emoji_url +
+ '"' +
+ ' title="' +
+ title +
+ '">'
+ );
}
const codepoint = helpers.get_emoji_codepoint(emoji_name);
@@ -319,9 +340,18 @@ function handleStream(stream_name) {
return;
}
const href = helpers.stream_hash(stream.stream_id);
- return '<a class="stream" data-stream-id="' + stream.stream_id + '" ' +
- 'href="/' + href + '"' +
- ">" + "#" + _.escape(stream.name) + "</a>";
+ return (
+ '<a class="stream" data-stream-id="' +
+ stream.stream_id +
+ '" ' +
+ 'href="/' +
+ href +
+ '"' +
+ ">" +
+ "#" +
+ _.escape(stream.name) +
+ "</a>"
+ );
}
function handleStreamTopic(stream_name, topic) {
@@ -331,8 +361,17 @@ function handleStreamTopic(stream_name, topic) {
}
const href = helpers.stream_topic_hash(stream.stream_id, topic);
const text = "#" + _.escape(stream.name) + " > " + _.escape(topic);
- return '<a class="stream-topic" data-stream-id="' + stream.stream_id + '" ' +
- 'href="/' + href + '"' + ">" + text + "</a>";
+ return (
+ '<a class="stream-topic" data-stream-id="' +
+ stream.stream_id +
+ '" ' +
+ 'href="/' +
+ href +
+ '"' +
+ ">" +
+ text +
+ "</a>"
+ );
}
function handleRealmFilter(pattern, matches) {
@@ -353,7 +392,8 @@ function handleTex(tex, fullmatch) {
try {
return katex.renderToString(tex);
} catch (ex) {
- if (ex.message.startsWith("KaTeX parse error")) { // TeX syntax error
+ if (ex.message.startsWith("KaTeX parse error")) {
+ // TeX syntax error
return '<span class="tex-error">' + _.escape(fullmatch) + "</span>";
}
blueslip.error(ex);
@@ -444,9 +484,11 @@ exports.initialize = function (realm_filters, helper_config) {
helpers = helper_config;
function disable_markdown_regex(rules, name) {
- rules[name] = {exec: function () {
- return false;
- }};
+ rules[name] = {
+ exec: function () {
+ return false;
+ },
+ };
}
// Configure the marked markdown parser for our usage
@@ -520,12 +562,8 @@ exports.initialize = function (realm_filters, helper_config) {
texHandler: handleTex,
timestampHandler: handleTimestamp,
renderer: r,
- preprocessors: [
- preprocess_code_blocks,
- preprocess_translate_emoticons,
- ],
+ preprocessors: [preprocess_code_blocks, preprocess_translate_emoticons],
});
-
};
window.markdown = exports;
diff --git a/static/js/message_edit.js b/static/js/message_edit.js
index 84dff3007a0..e059f4364e2 100644
--- a/static/js/message_edit.js
+++ b/static/js/message_edit.js
@@ -47,9 +47,12 @@ function is_topic_editable(message, edit_limit_seconds_buffer) {
}
// If you're using community topic editing, there's a deadline.
- return page_params.realm_community_topic_editing_limit_seconds
- + edit_limit_seconds_buffer
- + now.diffSeconds(message.timestamp * 1000) > 0;
+ return (
+ page_params.realm_community_topic_editing_limit_seconds +
+ edit_limit_seconds_buffer +
+ now.diffSeconds(message.timestamp * 1000) >
+ 0
+ );
}
function get_editability(message, edit_limit_seconds_buffer) {
@@ -88,8 +91,13 @@ function get_editability(message, edit_limit_seconds_buffer) {
}
const now = new XDate();
- if (page_params.realm_message_content_edit_limit_seconds + edit_limit_seconds_buffer +
- now.diffSeconds(message.timestamp * 1000) > 0 && message.sent_by_me) {
+ if (
+ page_params.realm_message_content_edit_limit_seconds +
+ edit_limit_seconds_buffer +
+ now.diffSeconds(message.timestamp * 1000) >
+ 0 &&
+ message.sent_by_me
+ ) {
return editability_types.FULL;
}
@@ -124,8 +132,11 @@ exports.get_deletability = function (message) {
if (page_params.realm_allow_message_deleting) {
const now = new XDate();
- if (page_params.realm_message_content_delete_limit_seconds +
- now.diffSeconds(message.timestamp * 1000) > 0) {
+ if (
+ page_params.realm_message_content_delete_limit_seconds +
+ now.diffSeconds(message.timestamp * 1000) >
+ 0
+ ) {
return true;
}
}
@@ -171,15 +182,15 @@ function handle_message_row_edit_keydown(e) {
switch (code) {
case 13:
if ($(e.target).hasClass("message_edit_content")) {
- // Pressing enter to save edits is coupled with enter to send
+ // Pressing enter to save edits is coupled with enter to send
if (composebox_typeahead.should_enter_send(e)) {
const row = $(".message_edit_content").filter(":focus").closest(".message_row");
const message_edit_save_button = row.find(".message_edit_save");
if (message_edit_save_button.attr("disabled") === "disabled") {
- // In cases when the save button is disabled
- // we need to disable save on pressing enter
- // Prevent default to avoid new-line on pressing
- // enter inside the textarea in this case
+ // In cases when the save button is disabled
+ // we need to disable save on pressing enter
+ // Prevent default to avoid new-line on pressing
+ // enter inside the textarea in this case
e.preventDefault();
return;
}
@@ -190,8 +201,10 @@ function handle_message_row_edit_keydown(e) {
composebox_typeahead.handle_enter($(e.target), e);
return;
}
- } else if ($(e.target).hasClass("message_edit_topic") ||
- $(e.target).hasClass("message_edit_topic_propagate")) {
+ } else if (
+ $(e.target).hasClass("message_edit_topic") ||
+ $(e.target).hasClass("message_edit_topic_propagate")
+ ) {
const row = $(e.target).closest(".message_row");
exports.save_message_row_edit(row);
e.stopPropagation();
@@ -234,7 +247,7 @@ function timer_text(seconds_left) {
if (minutes >= 1) {
return i18n.t("__minutes__ min to edit", {minutes: minutes.toString()});
} else if (seconds_left >= 10) {
- return i18n.t("__seconds__ sec to edit", {seconds: (seconds - seconds % 5).toString()});
+ return i18n.t("__seconds__ sec to edit", {seconds: (seconds - (seconds % 5)).toString()});
}
return i18n.t("__seconds__ sec to edit", {seconds: seconds.toString()});
}
@@ -242,8 +255,7 @@ function timer_text(seconds_left) {
function edit_message(row, raw_content) {
row.find(".message_reactions").hide();
condense.hide_message_expander(row);
- const content_top = row.find(".message_top_line")[0]
- .getBoundingClientRect().top;
+ const content_top = row.find(".message_top_line")[0].getBoundingClientRect().top;
const message = current_msg_list.get(rows.id(row));
@@ -257,8 +269,9 @@ function edit_message(row, raw_content) {
// zerver.views.message_edit.update_message_backend
const seconds_left_buffer = 5;
const editability = get_editability(message, seconds_left_buffer);
- const is_editable = editability === exports.editability_types.TOPIC_ONLY ||
- editability === exports.editability_types.FULL;
+ const is_editable =
+ editability === exports.editability_types.TOPIC_ONLY ||
+ editability === exports.editability_types.FULL;
const max_file_upload_size = page_params.max_file_upload_size_mib;
let file_upload_enabled = false;
@@ -270,27 +283,30 @@ function edit_message(row, raw_content) {
const show_edit_stream = message.is_stream && page_params.is_admin;
// current message's stream has been already been added and selected in handlebar
- const available_streams = show_edit_stream ? stream_data.subscribed_subs()
- .filter((s) => s.stream_id !== message.stream_id) : null;
-
- const form = $(render_message_edit_form({
- is_stream: message.type === "stream",
- message_id: message.id,
- is_editable: is_editable,
- is_content_editable: editability === exports.editability_types.FULL,
- has_been_editable: editability !== editability_types.NO,
- topic: message.topic,
- content: raw_content,
- file_upload_enabled: file_upload_enabled,
- show_video_chat_button: show_video_chat_button,
- minutes_to_edit: Math.floor(page_params.realm_message_content_edit_limit_seconds / 60),
- show_edit_stream: show_edit_stream,
- available_streams: available_streams,
- stream_id: message.stream_id,
- stream_name: message.stream,
- notify_new_thread: exports.notify_new_thread_default,
- notify_old_thread: exports.notify_old_thread_default,
- }));
+ const available_streams = show_edit_stream
+ ? stream_data.subscribed_subs().filter((s) => s.stream_id !== message.stream_id)
+ : null;
+
+ const form = $(
+ render_message_edit_form({
+ is_stream: message.type === "stream",
+ message_id: message.id,
+ is_editable: is_editable,
+ is_content_editable: editability === exports.editability_types.FULL,
+ has_been_editable: editability !== editability_types.NO,
+ topic: message.topic,
+ content: raw_content,
+ file_upload_enabled: file_upload_enabled,
+ show_video_chat_button: show_video_chat_button,
+ minutes_to_edit: Math.floor(page_params.realm_message_content_edit_limit_seconds / 60),
+ show_edit_stream: show_edit_stream,
+ available_streams: available_streams,
+ stream_id: message.stream_id,
+ stream_name: message.stream,
+ notify_new_thread: exports.notify_new_thread_default,
+ notify_old_thread: exports.notify_old_thread_default,
+ }),
+ );
const edit_obj = {form: form, raw_content: raw_content};
currently_editing_messages.set(message.id, edit_obj);
@@ -350,26 +366,32 @@ function edit_message(row, raw_content) {
}
// Add tooltip
- if (editability !== editability_types.NO &&
- page_params.realm_message_content_edit_limit_seconds > 0) {
+ if (
+ editability !== editability_types.NO &&
+ page_params.realm_message_content_edit_limit_seconds > 0
+ ) {
row.find(".message-edit-timer-control-group").show();
row.find("#message_edit_tooltip").tooltip({
animation: false,
placement: "left",
- template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div>' +
+ template:
+ '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div>' +
'<div class="tooltip-inner message-edit-tooltip-inner"></div></div>',
});
}
// add timer
- if (editability === editability_types.FULL &&
- page_params.realm_message_content_edit_limit_seconds > 0) {
+ if (
+ editability === editability_types.FULL &&
+ page_params.realm_message_content_edit_limit_seconds > 0
+ ) {
// Give them at least 10 seconds.
// If you change this number also change edit_limit_buffer in
// zerver.views.message_edit.update_message_backend
const min_seconds_to_edit = 10;
const now = new XDate();
- let seconds_left = page_params.realm_message_content_edit_limit_seconds +
+ let seconds_left =
+ page_params.realm_message_content_edit_limit_seconds +
now.diffSeconds(message.timestamp * 1000);
seconds_left = Math.floor(Math.max(seconds_left, min_seconds_to_edit));
@@ -516,8 +538,7 @@ exports.end_inline_topic_edit = function (row) {
exports.end_message_row_edit = function (row) {
const message = current_msg_list.get(rows.id(row));
- if (message !== undefined &&
- currently_editing_messages.has(message.id)) {
+ if (message !== undefined && currently_editing_messages.has(message.id)) {
const scroll_by = currently_editing_messages.get(message.id).scrolled_by;
message_viewport.scrollTop(message_viewport.scrollTop() - scroll_by);
@@ -637,9 +658,14 @@ exports.save_message_row_edit = function (row) {
const request = {message_id: message.id};
if (topic_changed || stream_changed) {
- const selected_topic_propagation = row.find("select.message_edit_topic_propagate").val() || "change_later";
- const send_notification_to_old_thread = row.find(".send_notification_to_old_thread").is(":checked");
- const send_notification_to_new_thread = row.find(".send_notification_to_new_thread").is(":checked");
+ const selected_topic_propagation =
+ row.find("select.message_edit_topic_propagate").val() || "change_later";
+ const send_notification_to_old_thread = row
+ .find(".send_notification_to_old_thread")
+ .is(":checked");
+ const send_notification_to_new_thread = row
+ .find(".send_notification_to_new_thread")
+ .is(":checked");
request.propagate_mode = selected_topic_propagation;
request.send_notification_to_old_thread = send_notification_to_old_thread;
request.send_notification_to_new_thread = send_notification_to_new_thread;
@@ -665,8 +691,12 @@ exports.save_message_row_edit = function (row) {
return;
}
- if (changed && !topic_changed && !stream_changed &&
- !markdown.contains_backend_only_syntax(new_content)) {
+ if (
+ changed &&
+ !topic_changed &&
+ !stream_changed &&
+ !markdown.contains_backend_only_syntax(new_content)
+ ) {
// If the topic isn't changed, and the new message content
// could have been locally echoed, than we can locally echo
// the edit.
@@ -807,31 +837,35 @@ exports.delete_message = function (msg_id) {
} else {
hide_delete_btn_show_spinner(false);
}
- $("#do_delete_message_button").off().on("click", (e) => {
- e.stopPropagation();
- e.preventDefault();
- currently_deleting_messages.push(msg_id);
- hide_delete_btn_show_spinner(true);
- channel.del({
- url: "/json/messages/" + msg_id,
- success: function () {
- $("#delete_message_modal").modal("hide");
- currently_deleting_messages = currently_deleting_messages.filter(
- (id) => id !== msg_id,
- );
- hide_delete_btn_show_spinner(false);
- },
- error: function (xhr) {
- currently_deleting_messages = currently_deleting_messages.filter(
- (id) => id !== msg_id,
- );
- hide_delete_btn_show_spinner(false);
- ui_report.error(i18n.t("Error deleting message"), xhr,
- $("#delete-message-error"));
- },
+ $("#do_delete_message_button")
+ .off()
+ .on("click", (e) => {
+ e.stopPropagation();
+ e.preventDefault();
+ currently_deleting_messages.push(msg_id);
+ hide_delete_btn_show_spinner(true);
+ channel.del({
+ url: "/json/messages/" + msg_id,
+ success: function () {
+ $("#delete_message_modal").modal("hide");
+ currently_deleting_messages = currently_deleting_messages.filter(
+ (id) => id !== msg_id,
+ );
+ hide_delete_btn_show_spinner(false);
+ },
+ error: function (xhr) {
+ currently_deleting_messages = currently_deleting_messages.filter(
+ (id) => id !== msg_id,
+ );
+ hide_delete_btn_show_spinner(false);
+ ui_report.error(
+ i18n.t("Error deleting message"),
+ xhr,
+ $("#delete-message-error"),
+ );
+ },
+ });
});
-
- });
};
exports.delete_topic = function (stream_id, topic_name) {
@@ -855,32 +889,35 @@ exports.handle_narrow_deactivated = function () {
}
};
-exports.move_topic_containing_message_to_stream =
- function (message_id, new_stream_id, new_topic_name, send_notification_to_new_thread,
- send_notification_to_old_thread) {
- const request = {
- stream_id: new_stream_id,
- propagate_mode: "change_all",
- topic: new_topic_name,
- send_notification_to_old_thread: send_notification_to_old_thread,
- send_notification_to_new_thread: send_notification_to_new_thread,
- };
- exports.notify_old_thread_default = send_notification_to_old_thread;
- exports.notify_new_thread_default = send_notification_to_new_thread;
- channel.patch({
- url: "/json/messages/" + message_id,
- data: request,
- success: function () {
- // The main UI will update via receiving the event
- // from server_events.js.
- // TODO: This should probably remove a spinner and
- // close the modal.
- },
- error: function (xhr) {
- ui_report.error(i18n.t("Error moving the topic"), xhr,
- $("#home-error"), 4000);
- },
- });
+exports.move_topic_containing_message_to_stream = function (
+ message_id,
+ new_stream_id,
+ new_topic_name,
+ send_notification_to_new_thread,
+ send_notification_to_old_thread,
+) {
+ const request = {
+ stream_id: new_stream_id,
+ propagate_mode: "change_all",
+ topic: new_topic_name,
+ send_notification_to_old_thread: send_notification_to_old_thread,
+ send_notification_to_new_thread: send_notification_to_new_thread,
};
+ exports.notify_old_thread_default = send_notification_to_old_thread;
+ exports.notify_new_thread_default = send_notification_to_new_thread;
+ channel.patch({
+ url: "/json/messages/" + message_id,
+ data: request,
+ success: function () {
+ // The main UI will update via receiving the event
+ // from server_events.js.
+ // TODO: This should probably remove a spinner and
+ // close the modal.
+ },
+ error: function (xhr) {
+ ui_report.error(i18n.t("Error moving the topic"), xhr, $("#home-error"), 4000);
+ },
+ });
+};
window.message_edit = exports;
diff --git a/static/js/message_edit_history.js b/static/js/message_edit_history.js
index 636c32a1c13..89e6af8a172 100644
--- a/static/js/message_edit_history.js
+++ b/static/js/message_edit_history.js
@@ -48,13 +48,18 @@ exports.fetch_and_render_message_history = function (message) {
prev_datestamp = datestamp;
}
$("#message-history").attr("data-message-id", message.id);
- $("#message-history").html(render_message_edit_history({
- edited_messages: content_edit_history,
- }));
+ $("#message-history").html(
+ render_message_edit_history({
+ edited_messages: content_edit_history,
+ }),
+ );
},
error: function (xhr) {
- ui_report.error(i18n.t("Error fetching message edit history"), xhr,
- $("#message-history-error"));
+ ui_report.error(
+ i18n.t("Error fetching message edit history"),
+ xhr,
+ $("#message-history-error"),
+ );
},
});
};
diff --git a/static/js/message_events.js b/static/js/message_events.js
index b3caa318f9f..0e609abc584 100644
--- a/static/js/message_events.js
+++ b/static/js/message_events.js
@@ -10,8 +10,10 @@ function maybe_add_narrowed_messages(messages, msg_list) {
channel.get({
url: "/json/messages/matches_narrow",
- data: {msg_ids: JSON.stringify(ids),
- narrow: JSON.stringify(narrow_state.public_operators())},
+ data: {
+ msg_ids: JSON.stringify(ids),
+ narrow: JSON.stringify(narrow_state.public_operators()),
+ },
timeout: 5000,
success: function (data) {
if (msg_list !== current_msg_list) {
@@ -52,10 +54,10 @@ function maybe_add_narrowed_messages(messages, msg_list) {
maybe_add_narrowed_messages(messages, msg_list);
}
}, 5000);
- }});
+ },
+ });
}
-
exports.insert_new_messages = function insert_new_messages(messages, sent_by_this_client) {
messages = messages.map(message_store.add_message_metadata);
@@ -84,7 +86,6 @@ exports.insert_new_messages = function insert_new_messages(messages, sent_by_thi
render_info = message_util.add_new_messages(messages, home_msg_list);
}
-
if (sent_by_this_client) {
const need_user_to_scroll = render_info && render_info.need_user_to_scroll;
// sent_by_this_client will be true if ANY of the messages
@@ -150,7 +151,9 @@ exports.update_messages = function update_messages(events) {
topic_edited = new_topic !== undefined;
stream_changed = new_stream_id !== undefined;
if (topic_edited || stream_changed) {
- const going_forward_change = ["change_later", "change_all"].includes(event.propagate_mode);
+ const going_forward_change = ["change_later", "change_all"].includes(
+ event.propagate_mode,
+ );
const stream_name = stream_data.get_sub_by_id(event.stream_id).name;
const compose_stream_name = compose_state.stream_name();
@@ -216,8 +219,11 @@ exports.update_messages = function update_messages(events) {
message_id: msg.id,
});
- if (current_filter && current_filter.can_apply_locally() &&
- !current_filter.predicate()(msg)) {
+ if (
+ current_filter &&
+ current_filter.can_apply_locally() &&
+ !current_filter.predicate()(msg)
+ ) {
// This topic edit makes this message leave the
// current narrow, which is not being changed as
// part of processing this event. So we should
@@ -346,8 +352,10 @@ 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)) {
+ if (
+ $("#message-edit-history").hasClass("in") &&
+ msg.id === parseInt($("#message-history").attr("data-message-id"), 10)
+ ) {
message_edit_history.fetch_and_render_message_history(msg);
}
}
diff --git a/static/js/message_fetch.js b/static/js/message_fetch.js
index 7e5d0beaa40..615e8e682d8 100644
--- a/static/js/message_fetch.js
+++ b/static/js/message_fetch.js
@@ -20,8 +20,11 @@ function process_result(data, opts) {
ui_report.hide_error($("#connection-error"));
}
- if (messages.length === 0 && current_msg_list === message_list.narrowed &&
- message_list.narrowed.empty()) {
+ if (
+ messages.length === 0 &&
+ current_msg_list === message_list.narrowed &&
+ message_list.narrowed.empty()
+ ) {
// Even after trying to load more messages, we have no
// messages to display in this narrow.
narrow.show_empty_narrow_message();
@@ -83,21 +86,22 @@ function get_messages_success(data, opts) {
}
if (opts.num_after > 0) {
- opts.fetch_again = opts.msg_list.data.fetch_status.finish_newer_batch(
- data.messages, {
- update_loading_indicator: update_loading_indicator,
- found_newest: data.found_newest,
- });
+ opts.fetch_again = opts.msg_list.data.fetch_status.finish_newer_batch(data.messages, {
+ update_loading_indicator: update_loading_indicator,
+ found_newest: data.found_newest,
+ });
if (opts.msg_list === home_msg_list) {
// When we update home_msg_list, we need to also update
// the fetch_status data structure for message_list.all,
// which is never rendered (and just used for
// prepopulating narrowed views).
opts.fetch_again = message_list.all.data.fetch_status.finish_newer_batch(
- data.messages, {
+ data.messages,
+ {
update_loading_indicator: false,
found_newest: data.found_newest,
- });
+ },
+ );
}
}
@@ -168,9 +172,7 @@ exports.load_messages = function (opts) {
// the nearest integer before sending a request to the server.
opts.anchor = opts.anchor.toFixed();
}
- let data = {anchor: opts.anchor,
- num_before: opts.num_before,
- num_after: opts.num_after};
+ let data = {anchor: opts.anchor, num_before: opts.num_before, num_after: opts.num_after};
if (opts.msg_list.narrowed && narrow_state.active()) {
let operators = narrow_state.public_operators();
@@ -359,13 +361,15 @@ exports.maybe_load_newer_messages = function (opts) {
exports.start_backfilling_messages = function () {
// backfill more messages after the user is idle
- $(document).idle({idle: consts.backfill_idle_time,
- onIdle: function () {
- exports.do_backfill({
- num_before: consts.backfill_batch_size,
- msg_list: home_msg_list,
- });
- }});
+ $(document).idle({
+ idle: consts.backfill_idle_time,
+ onIdle: function () {
+ exports.do_backfill({
+ num_before: consts.backfill_batch_size,
+ msg_list: home_msg_list,
+ });
+ },
+ });
};
exports.initialize = function () {
@@ -377,9 +381,11 @@ exports.initialize = function () {
// We fall back to the closest selected id, as the user
// may have removed a stream from the home view while we
// were loading data.
- home_msg_list.select_id(data.anchor,
- {then_scroll: true, use_closest: true,
- target_scroll_offset: page_params.initial_offset});
+ home_msg_list.select_id(data.anchor, {
+ then_scroll: true,
+ use_closest: true,
+ target_scroll_offset: page_params.initial_offset,
+ });
}
if (data.found_newest) {
@@ -400,7 +406,6 @@ exports.initialize = function () {
msg_list: home_msg_list,
cont: load_more,
});
-
}
let anchor;
diff --git a/static/js/message_flags.js b/static/js/message_flags.js
index 70b4323f230..bc07e7de449 100644
--- a/static/js/message_flags.js
+++ b/static/js/message_flags.js
@@ -32,9 +32,7 @@ exports.send_read = (function () {
channel.post({
url: "/json/messages/flags",
idempotent: true,
- data: {messages: JSON.stringify(real_msg_ids_batch),
- op: "add",
- flag: "read"},
+ data: {messages: JSON.stringify(real_msg_ids_batch), op: "add", flag: "read"},
success: on_success,
});
}
diff --git a/static/js/message_list.js b/static/js/message_list.js
index 8d284ce9f1b..93d3d03791c 100644
--- a/static/js/message_list.js
+++ b/static/js/message_list.js
@@ -68,8 +68,7 @@ exports.MessageList.prototype = {
narrow.hide_empty_narrow_message();
}
- if (self === exports.narrowed && !self.empty() &&
- self.selected_id() === -1) {
+ if (self === exports.narrowed && !self.empty() && self.selected_id() === -1) {
// And also select the newly arrived message.
self.select_id(self.selected_id(), {then_scroll: true, use_closest: true});
}
@@ -176,8 +175,7 @@ exports.MessageList.prototype = {
id: id,
closest_id: closest_id,
};
- blueslip.error("Selected message id not in MessageList",
- error_data);
+ blueslip.error("Selected message id not in MessageList", error_data);
}
if (closest_id === -1 && !opts.empty_ok) {
@@ -227,18 +225,15 @@ exports.MessageList.prototype = {
},
subscribed_bookend_content: function (stream_name) {
- return i18n.t("You subscribed to stream __stream__",
- {stream: stream_name});
+ return i18n.t("You subscribed to stream __stream__", {stream: stream_name});
},
unsubscribed_bookend_content: function (stream_name) {
- return i18n.t("You unsubscribed from stream __stream__",
- {stream: stream_name});
+ return i18n.t("You unsubscribed from stream __stream__", {stream: stream_name});
},
not_subscribed_bookend_content: function (stream_name) {
- return i18n.t("You are not subscribed to stream __stream__",
- {stream: stream_name});
+ return i18n.t("You are not subscribed to stream __stream__", {stream: stream_name});
},
// Maintains a trailing bookend element explaining any changes in
diff --git a/static/js/message_list_data.js b/static/js/message_list_data.js
index 1c657628c53..00b08eeab72 100644
--- a/static/js/message_list_data.js
+++ b/static/js/message_list_data.js
@@ -169,8 +169,7 @@ MessageListData.prototype = {
unmuted_messages: function (messages) {
return messages.filter(
(message) =>
- !muting.is_topic_muted(message.stream_id, message.topic) ||
- message.mentioned,
+ !muting.is_topic_muted(message.stream_id, message.topic) || message.mentioned,
);
},
@@ -286,7 +285,6 @@ MessageListData.prototype = {
viewable_messages = this.unmuted_messages(messages);
this._items = viewable_messages.concat(this._items);
-
} else {
viewable_messages = messages;
this._items = messages.concat(this._items);
@@ -370,8 +368,7 @@ MessageListData.prototype = {
function less_func(msg, ref_id, a_idx) {
if (self._is_localonly_id(msg.id)) {
// First non-local message before this one
- const effective = self._next_nonlocal_message(self._items, a_idx,
- (idx) => idx - 1);
+ const effective = self._next_nonlocal_message(self._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));
@@ -525,7 +522,9 @@ MessageListData.prototype = {
},
reorder_messages: function (new_id, opts) {
- function message_sort_func(a, b) {return a.id - b.id;}
+ function message_sort_func(a, b) {
+ return a.id - b.id;
+ }
// If this message is now out of order, re-order and re-render
const self = this;
const current_message = self._hash.get(new_id);
@@ -533,18 +532,20 @@ MessageListData.prototype = {
if (index === -1) {
if (!self.muting_enabled && opts.is_current_list()) {
- blueslip.error("Trying to re-order message but can't find message with new_id in _items!");
+ blueslip.error(
+ "Trying to re-order message but can't find message with new_id in _items!",
+ );
}
return;
}
- const next = self._next_nonlocal_message(self._items, index,
- (idx) => idx + 1);
- const prev = self._next_nonlocal_message(self._items, index,
- (idx) => idx - 1);
+ const next = self._next_nonlocal_message(self._items, index, (idx) => idx + 1);
+ const prev = self._next_nonlocal_message(self._items, index, (idx) => idx - 1);
- if (next !== undefined && current_message.id > next.id ||
- prev !== undefined && current_message.id < prev.id) {
+ if (
+ (next !== undefined && current_message.id > next.id) ||
+ (prev !== undefined && current_message.id < prev.id)
+ ) {
blueslip.debug("Changed message ID from server caused out-of-order list, reordering");
self._items.sort(message_sort_func);
if (self.muting_enabled) {
diff --git a/static/js/message_list_view.js b/static/js/message_list_view.js
index 8470357f2ad..ef5e558fbd5 100644
--- a/static/js/message_list_view.js
+++ b/static/js/message_list_view.js
@@ -61,8 +61,11 @@ function update_group_date_divider(group, message_container, prev) {
const prev_time = new XDate(prev.msg.timestamp * 1000);
if (time.toDateString() !== prev_time.toDateString()) {
// NB: group_date_divider_html is HTML, inserted into the document without escaping.
- group.group_date_divider_html = timerender.render_date(time, prev_time,
- today)[0].outerHTML;
+ group.group_date_divider_html = timerender.render_date(
+ time,
+ prev_time,
+ today,
+ )[0].outerHTML;
group.show_group_date_divider = true;
}
} else {
@@ -98,8 +101,11 @@ function update_message_date_divider(opts) {
const today = new XDate();
curr_msg_container.want_date_divider = true;
- curr_msg_container.date_divider_html =
- timerender.render_date(curr_time, prev_time, today)[0].outerHTML;
+ curr_msg_container.date_divider_html = timerender.render_date(
+ curr_time,
+ prev_time,
+ today,
+ )[0].outerHTML;
}
function set_timestr(message_container) {
@@ -171,8 +177,11 @@ MessageListView.prototype = {
if (last_edit_timestamp !== undefined) {
const last_edit_time = new XDate(last_edit_timestamp * 1000);
const today = new XDate();
- return timerender.render_date(last_edit_time, undefined, today)[0].textContent +
- " at " + timerender.stringify_time(last_edit_time);
+ return (
+ timerender.render_date(last_edit_time, undefined, today)[0].textContent +
+ " at " +
+ timerender.stringify_time(last_edit_time)
+ );
}
},
@@ -246,11 +255,13 @@ MessageListView.prototype = {
function finish_group() {
if (current_group.message_containers.length > 0) {
- populate_group_from_message_container(current_group,
- current_group.message_containers[0]);
- current_group
- .message_containers[current_group.message_containers.length - 1]
- .include_footer = true;
+ populate_group_from_message_container(
+ current_group,
+ current_group.message_containers[0],
+ );
+ current_group.message_containers[
+ current_group.message_containers.length - 1
+ ].include_footer = true;
new_message_groups.push(current_group);
}
}
@@ -261,8 +272,11 @@ MessageListView.prototype = {
message_container.include_recipient = false;
message_container.include_footer = false;
- if (same_recipient(prev, message_container) && self.collapse_messages &&
- prev.msg.historical === message_container.msg.historical) {
+ if (
+ same_recipient(prev, message_container) &&
+ self.collapse_messages &&
+ prev.msg.historical === message_container.msg.historical
+ ) {
add_message_container_to_group(message_container);
update_message_date_divider({
prev_msg_container: prev,
@@ -289,25 +303,27 @@ MessageListView.prototype = {
}
if (message_container.msg.stream) {
- message_container.stream_url =
- hash_util.by_stream_uri(message_container.msg.stream_id);
- message_container.topic_url =
- hash_util.by_stream_topic_uri(
- message_container.msg.stream_id,
- message_container.msg.topic);
+ message_container.stream_url = hash_util.by_stream_uri(
+ message_container.msg.stream_id,
+ );
+ message_container.topic_url = hash_util.by_stream_topic_uri(
+ message_container.msg.stream_id,
+ message_container.msg.topic,
+ );
} else {
- message_container.pm_with_url =
- message_container.msg.pm_with_url;
+ message_container.pm_with_url = message_container.msg.pm_with_url;
}
}
set_timestr(message_container);
message_container.include_sender = true;
- if (!message_container.include_recipient &&
+ if (
+ !message_container.include_recipient &&
!prev.status_message &&
same_day(prev, message_container) &&
- same_sender(prev, message_container)) {
+ same_sender(prev, message_container)
+ ) {
message_container.include_sender = false;
}
@@ -316,8 +332,9 @@ MessageListView.prototype = {
message_container.small_avatar_url = people.small_avatar_url(message_container.msg);
if (message_container.msg.stream) {
- message_container.background_color =
- stream_data.get_color(message_container.msg.stream);
+ message_container.background_color = stream_data.get_color(
+ message_container.msg.stream,
+ );
}
message_container.contains_mention = message_container.msg.mentioned;
@@ -346,22 +363,31 @@ MessageListView.prototype = {
const first_msg_container = _.first(second_group.message_containers);
// Join two groups into one.
- if (this.collapse_messages && same_recipient(last_msg_container, first_msg_container) &&
- last_msg_container.msg.historical === first_msg_container.msg.historical) {
- if (!last_msg_container.status_message && !first_msg_container.msg.is_me_message
- && same_day(last_msg_container, first_msg_container)
- && same_sender(last_msg_container, first_msg_container)) {
+ if (
+ this.collapse_messages &&
+ same_recipient(last_msg_container, first_msg_container) &&
+ last_msg_container.msg.historical === first_msg_container.msg.historical
+ ) {
+ if (
+ !last_msg_container.status_message &&
+ !first_msg_container.msg.is_me_message &&
+ same_day(last_msg_container, first_msg_container) &&
+ same_sender(last_msg_container, first_msg_container)
+ ) {
first_msg_container.include_sender = false;
}
if (same_sender(last_msg_container, first_msg_container)) {
last_msg_container.next_is_same_sender = true;
}
- first_group.message_containers =
- first_group.message_containers.concat(second_group.message_containers);
+ first_group.message_containers = first_group.message_containers.concat(
+ second_group.message_containers,
+ );
return true;
- // Add a subscription marker
- } else if (this.list !== home_msg_list &&
- last_msg_container.msg.historical !== first_msg_container.msg.historical) {
+ // Add a subscription marker
+ } else if (
+ this.list !== home_msg_list &&
+ last_msg_container.msg.historical !== first_msg_container.msg.historical
+ ) {
second_group.bookend_top = true;
this.add_subscription_marker(second_group, last_msg_container, first_msg_container);
}
@@ -433,8 +459,9 @@ MessageListView.prototype = {
this._message_groups.unshift(first_group);
new_message_groups = _.initial(new_message_groups);
- } else if (!same_day(second_group.message_containers[0],
- first_group.message_containers[0])) {
+ } else if (
+ !same_day(second_group.message_containers[0], first_group.message_containers[0])
+ ) {
// The groups did not merge, so we need up update the date row for the old group
update_group_date_divider(second_group, curr_msg_container, prev_msg_container);
// We could add an action to update the date row, but for now rerender the group.
@@ -528,11 +555,13 @@ MessageListView.prototype = {
const use_match_properties = opts.use_match_properties;
const table_name = opts.table_name;
- return $(render_message_group({
- message_groups: message_groups,
- use_match_properties: use_match_properties,
- table_name: table_name,
- }));
+ return $(
+ render_message_group({
+ message_groups: message_groups,
+ use_match_properties: use_match_properties,
+ table_name: table_name,
+ }),
+ );
},
render: function (messages, where, messages_are_new) {
@@ -662,8 +691,9 @@ MessageListView.prototype = {
for (const message_container of targets) {
const row = self.get_row(message_container.msg.id);
- $(row).find("div.messagebox").toggleClass("next_is_same_sender",
- message_container.next_is_same_sender);
+ $(row)
+ .find("div.messagebox")
+ .toggleClass("next_is_same_sender", message_container.next_is_same_sender);
}
}
@@ -671,7 +701,11 @@ MessageListView.prototype = {
if (message_actions.append_messages.length > 0) {
last_message_row = table.find(".message_row").last().expectOne();
last_group_row = rows.get_message_recipient_row(last_message_row);
- dom_messages = $(message_actions.append_messages.map((message_container) => self._get_message_template(message_container)).join("")).filter(".message_row");
+ dom_messages = $(
+ message_actions.append_messages
+ .map((message_container) => self._get_message_template(message_container))
+ .join(""),
+ ).filter(".message_row");
self._post_process(dom_messages);
last_group_row.append(dom_messages);
@@ -718,8 +752,9 @@ MessageListView.prototype = {
const last_message_group = _.last(self._message_groups);
if (last_message_group !== undefined) {
- list.last_message_historical =
- _.last(last_message_group.message_containers).msg.historical;
+ list.last_message_historical = _.last(
+ last_message_group.message_containers,
+ ).msg.historical;
}
const stream_name = narrow_state.stream();
@@ -916,7 +951,6 @@ MessageListView.prototype = {
return need_user_to_scroll;
},
-
clear_rendering_state: function (clear_table) {
if (clear_table) {
this.clear_table();
@@ -934,12 +968,13 @@ MessageListView.prototype = {
}
this._render_win_start = new_start;
- this._render_win_end = Math.min(this._render_win_start + this._RENDER_WINDOW_SIZE,
- this.list.num_items());
+ this._render_win_end = Math.min(
+ this._render_win_start + this._RENDER_WINDOW_SIZE,
+ this.list.num_items(),
+ );
return true;
},
-
maybe_rerender: function () {
if (this.table_name === undefined) {
return false;
@@ -956,10 +991,14 @@ MessageListView.prototype = {
// of the bottom of the currently rendered window and the
// bottom of the window does not abut the end of the
// message list
- if (!(selected_idx - this._render_win_start < this._RENDER_THRESHOLD
- && this._render_win_start !== 0 ||
- this._render_win_end - selected_idx <= this._RENDER_THRESHOLD
- && this._render_win_end !== this.list.num_items())) {
+ if (
+ !(
+ (selected_idx - this._render_win_start < this._RENDER_THRESHOLD &&
+ this._render_win_start !== 0) ||
+ (this._render_win_end - selected_idx <= this._RENDER_THRESHOLD &&
+ this._render_win_end !== this.list.num_items())
+ )
+ ) {
return false;
}
@@ -999,8 +1038,10 @@ MessageListView.prototype = {
// target_offset is the target number of pixels between the top of the
// viewable window and the selected message
this.clear_table();
- this.render(this.list.all_messages().slice(this._render_win_start,
- this._render_win_end), "bottom");
+ this.render(
+ this.list.all_messages().slice(this._render_win_start, this._render_win_end),
+ "bottom",
+ );
// If we could see the newly selected message, scroll the
// window such that the newly selected message is at the
@@ -1107,8 +1148,10 @@ MessageListView.prototype = {
let current_group = [];
for (const message_container of message_containers) {
- if (current_group.length === 0 ||
- same_recipient(current_group[current_group.length - 1], message_container)) {
+ if (
+ current_group.length === 0 ||
+ same_recipient(current_group[current_group.length - 1], message_container)
+ ) {
current_group.push(message_container);
} else {
message_groups.push(current_group);
@@ -1194,11 +1237,13 @@ MessageListView.prototype = {
},
render_trailing_bookend: function (trailing_bookend_content, subscribed, show_button) {
- const rendered_trailing_bookend = $(render_bookend({
- bookend_content: trailing_bookend_content,
- trailing: show_button,
- subscribed: subscribed,
- }));
+ const rendered_trailing_bookend = $(
+ render_bookend({
+ bookend_content: trailing_bookend_content,
+ trailing: show_button,
+ subscribed: subscribed,
+ }),
+ );
rows.get_table(this.table_name).append(rendered_trailing_bookend);
},
@@ -1226,7 +1271,6 @@ MessageListView.prototype = {
this.message_containers.delete(old_id);
this.message_containers.set(new_id, message_container);
}
-
},
_maybe_format_me_message: function (message_container) {
@@ -1236,8 +1280,9 @@ MessageListView.prototype = {
// first line of the message
const msg_content = message_container.msg.content;
const p_index = msg_content.indexOf("</p>");
- message_container.status_message = msg_content.slice("<p>/me ".length, p_index) +
- msg_content.slice(p_index + "</p>".length);
+ message_container.status_message =
+ msg_content.slice("<p>/me ".length, p_index) +
+ msg_content.slice(p_index + "</p>".length);
message_container.include_sender = true;
} else {
message_container.status_message = false;
diff --git a/static/js/message_scroll.js b/static/js/message_scroll.js
index d8298084045..2c3f89b94eb 100644
--- a/static/js/message_scroll.js
+++ b/static/js/message_scroll.js
@@ -12,8 +12,7 @@ let loading_older_messages_indicator_showing = false;
let loading_newer_messages_indicator_showing = false;
exports.show_loading_older = function () {
if (!loading_older_messages_indicator_showing) {
- loading.make_indicator($("#loading_older_messages_indicator"),
- {abs_positioned: true});
+ loading.make_indicator($("#loading_older_messages_indicator"), {abs_positioned: true});
loading_older_messages_indicator_showing = true;
floating_recipient_bar.hide();
}
@@ -29,8 +28,7 @@ exports.hide_loading_older = function () {
exports.show_loading_newer = function () {
if (!loading_newer_messages_indicator_showing) {
$(".bottom-messages-logo").show();
- loading.make_indicator($("#loading_newer_messages_indicator"),
- {abs_positioned: true});
+ loading.make_indicator($("#loading_newer_messages_indicator"), {abs_positioned: true});
loading_newer_messages_indicator_showing = true;
floating_recipient_bar.hide();
}
@@ -81,8 +79,7 @@ exports.update_top_of_narrow_notices = function (msg_list) {
return;
}
- if (msg_list.data.fetch_status.has_found_oldest() &&
- current_msg_list !== home_msg_list) {
+ if (msg_list.data.fetch_status.has_found_oldest() && current_msg_list !== home_msg_list) {
const filter = narrow_state.filter();
// Potentially display the notice that lets users know
// that not all messages were searched. One could
@@ -90,9 +87,11 @@ exports.update_top_of_narrow_notices = function (msg_list) {
// conditions, but there's a very legitimate use case
// for moderation of searching for all messages sent
// by a potential spammer user.
- if (!filter.contains_only_private_messages() &&
+ if (
+ !filter.contains_only_private_messages() &&
!filter.includes_full_stream_history() &&
- !filter.is_personal_filter()) {
+ !filter.is_personal_filter()
+ ) {
exports.show_end_of_results_notice();
}
}
@@ -153,10 +152,12 @@ function scroll_finish() {
}
exports.initialize = function () {
- message_viewport.message_pane.scroll(_.throttle(() => {
- unread_ops.process_visible();
- scroll_finish();
- }, 50));
+ message_viewport.message_pane.scroll(
+ _.throttle(() => {
+ unread_ops.process_visible();
+ scroll_finish();
+ }, 50),
+ );
// Scroll handler that marks messages as read when you scroll past them.
$(document).on("message_selected.zulip", (event) => {
@@ -179,5 +180,4 @@ exports.initialize = function () {
});
};
-
window.message_scroll = exports;
diff --git a/static/js/message_store.js b/static/js/message_store.js
index 73db317dab0..a83c07138ee 100644
--- a/static/js/message_store.js
+++ b/static/js/message_store.js
@@ -42,7 +42,6 @@ exports.each = function (f) {
};
exports.get_pm_emails = function (message) {
-
function email(user_id) {
const person = people.get_by_user_id(user_id);
if (!person) {
@@ -59,7 +58,6 @@ exports.get_pm_emails = function (message) {
};
exports.get_pm_full_names = function (message) {
-
function name(user_id) {
const person = people.get_by_user_id(user_id);
if (!person) {
@@ -107,7 +105,6 @@ exports.set_message_booleans = function (message) {
// just a distraction, so we delete it. (All the downstream code
// uses booleans.)
delete message.flags;
-
};
exports.init_booleans = function (message) {
@@ -181,8 +178,7 @@ exports.add_message_metadata = function (message) {
case "private":
message.is_private = true;
- message.reply_to = util.normalize_recipients(
- exports.get_pm_emails(message));
+ message.reply_to = util.normalize_recipients(exports.get_pm_emails(message));
message.display_reply_to = exports.get_pm_full_names(message);
message.pm_with_url = people.pm_with_url(message);
message.to_user_ids = people.pm_reply_user_string(message);
diff --git a/static/js/message_util.js b/static/js/message_util.js
index 7192c252961..b57eb3a849a 100644
--- a/static/js/message_util.js
+++ b/static/js/message_util.js
@@ -49,9 +49,14 @@ exports.get_messages_in_topic = function (stream_id, topic) {
// all the messages. Please only use it in case of
// very rare events like topic edits. Its primary
// use case is the new experimental Recent Topics UI.
- return message_list.all.all_messages().filter((x) => x.type === "stream" &&
- x.stream_id === stream_id &&
- x.topic.toLowerCase() === topic.toLowerCase());
+ return message_list.all
+ .all_messages()
+ .filter(
+ (x) =>
+ x.type === "stream" &&
+ x.stream_id === stream_id &&
+ x.topic.toLowerCase() === topic.toLowerCase(),
+ );
};
window.message_util = exports;
diff --git a/static/js/message_viewport.js b/static/js/message_viewport.js
index 380870ceb6c..c2627225751 100644
--- a/static/js/message_viewport.js
+++ b/static/js/message_viewport.js
@@ -3,7 +3,6 @@ let jwindow;
const dimensions = {};
let in_stoppable_autoscroll = false;
-
// Includes both scroll and arrow events. Negative means scroll up,
// positive means scroll down.
exports.last_movement_direction = 1;
@@ -29,8 +28,7 @@ exports.message_viewport_info = function () {
const element_just_above_us = $(".floating_recipient");
const element_just_below_us = $("#compose");
- res.visible_top = element_just_above_us.offset().top
- + element_just_above_us.safeOuterHeight();
+ res.visible_top = element_just_above_us.offset().top + element_just_above_us.safeOuterHeight();
res.visible_bottom = element_just_below_us.position().top;
@@ -111,42 +109,39 @@ exports.set_message_position = function (message_top, message_height, viewport_i
}
}
- const hidden_top =
- viewport_info.visible_top
- - exports.scrollTop();
+ const hidden_top = viewport_info.visible_top - exports.scrollTop();
- const message_offset =
- how_far_down_in_visible_page
- + hidden_top;
+ const message_offset = how_far_down_in_visible_page + hidden_top;
- const new_scroll_top =
- message_top
- - message_offset;
+ const new_scroll_top = message_top - message_offset;
message_scroll.suppress_selection_update_on_next_scroll();
exports.scrollTop(new_scroll_top);
};
-function in_viewport_or_tall(rect, top_of_feed, bottom_of_feed,
- require_fully_visible) {
+function in_viewport_or_tall(rect, top_of_feed, bottom_of_feed, require_fully_visible) {
if (require_fully_visible) {
- return rect.top > top_of_feed && // Message top is in view and
- (rect.bottom < bottom_of_feed || // message is fully in view or
- rect.height > bottom_of_feed - top_of_feed &&
- rect.top < bottom_of_feed); // message is tall.
+ return (
+ rect.top > top_of_feed && // Message top is in view and
+ (rect.bottom < bottom_of_feed || // message is fully in view or
+ (rect.height > bottom_of_feed - top_of_feed && rect.top < bottom_of_feed))
+ ); // message is tall.
}
return rect.bottom > top_of_feed && rect.top < bottom_of_feed;
}
-function add_to_visible(candidates, visible,
- top_of_feed, bottom_of_feed,
- require_fully_visible,
- row_to_id) {
+function add_to_visible(
+ candidates,
+ visible,
+ top_of_feed,
+ bottom_of_feed,
+ require_fully_visible,
+ row_to_id,
+) {
for (const row of candidates) {
const row_rect = row.getBoundingClientRect();
// Mark very tall messages as read once we've gotten past them
- if (in_viewport_or_tall(row_rect, top_of_feed, bottom_of_feed,
- require_fully_visible)) {
+ if (in_viewport_or_tall(row_rect, top_of_feed, bottom_of_feed, require_fully_visible)) {
visible.push(row_to_id(row));
} else {
break;
@@ -166,8 +161,13 @@ const bottom_of_feed = new util.CachedValue({
},
});
-function _visible_divs(selected_row, row_min_height, row_to_output, div_class,
- require_fully_visible) {
+function _visible_divs(
+ selected_row,
+ row_min_height,
+ row_to_output,
+ div_class,
+ require_fully_visible,
+) {
// Note that when using getBoundingClientRect() we are getting offsets
// relative to the visible window, but when using jQuery's offset() we are
// getting offsets relative to the full scrollable window. You can't try to
@@ -180,12 +180,30 @@ function _visible_divs(selected_row, row_min_height, row_to_output, div_class,
const visible = [];
const above_pointer = selected_row.prevAll("div." + div_class).slice(0, num_neighbors);
const below_pointer = selected_row.nextAll("div." + div_class).slice(0, num_neighbors);
- add_to_visible(selected_row, visible, top_of_feed.get(), bottom_of_feed.get(),
- require_fully_visible, row_to_output);
- add_to_visible(above_pointer, visible, top_of_feed.get(), bottom_of_feed.get(),
- require_fully_visible, row_to_output);
- add_to_visible(below_pointer, visible, top_of_feed.get(), bottom_of_feed.get(),
- require_fully_visible, row_to_output);
+ add_to_visible(
+ selected_row,
+ visible,
+ top_of_feed.get(),
+ bottom_of_feed.get(),
+ require_fully_visible,
+ row_to_output,
+ );
+ add_to_visible(
+ above_pointer,
+ visible,
+ top_of_feed.get(),
+ bottom_of_feed.get(),
+ require_fully_visible,
+ row_to_output,
+ );
+ add_to_visible(
+ below_pointer,
+ visible,
+ top_of_feed.get(),
+ bottom_of_feed.get(),
+ require_fully_visible,
+ row_to_output,
+ );
return visible;
}
@@ -227,21 +245,31 @@ exports.scrollTop = function viewport_scrollTop(target_scrollTop) {
const space_to_scroll = $("#bottom_whitespace").offset().top - exports.height();
// Check whether our scrollTop didn't move even though one could have scrolled down
- if (space_to_scroll > 0 && target_scrollTop > 0 &&
- orig_scrollTop === 0 && new_scrollTop === 0) {
+ if (
+ space_to_scroll > 0 &&
+ target_scrollTop > 0 &&
+ orig_scrollTop === 0 &&
+ new_scrollTop === 0
+ ) {
// Chrome has a bug where sometimes calling
// window.scrollTop(x) has no effect, resulting in the browser
// staying at 0 -- and afterwards if you call
// window.scrollTop(x) again, it will still do nothing. To
// fix this, we need to first scroll to some other place.
- blueslip.info("ScrollTop did nothing when scrolling to " + target_scrollTop + ", fixing...");
+ blueslip.info(
+ "ScrollTop did nothing when scrolling to " + target_scrollTop + ", fixing...",
+ );
// First scroll to 1 in order to clear the stuck state
exports.message_pane.scrollTop(1);
// And then scroll where we intended to scroll to
ret = exports.message_pane.scrollTop(target_scrollTop);
if (exports.message_pane.scrollTop() === 0) {
- blueslip.info("ScrollTop fix did not work when scrolling to " + target_scrollTop +
- "! space_to_scroll was " + space_to_scroll);
+ blueslip.info(
+ "ScrollTop fix did not work when scrolling to " +
+ target_scrollTop +
+ "! space_to_scroll was " +
+ space_to_scroll,
+ );
}
}
return ret;
@@ -342,7 +370,6 @@ exports.recenter_view = function (message, opts) {
}
};
-
exports.keep_pointer_in_view = function () {
// See message_viewport.recenter_view() for related logic to keep the pointer onscreen.
// This function mostly comes into place for mouse scrollers, and it
@@ -358,8 +385,8 @@ exports.keep_pointer_in_view = function () {
}
const info = exports.message_viewport_info();
- const top_threshold = info.visible_top + 1 / 10 * info.visible_height;
- const bottom_threshold = info.visible_top + 9 / 10 * info.visible_height;
+ const top_threshold = info.visible_top + (1 / 10) * info.visible_height;
+ const bottom_threshold = info.visible_top + (9 / 10) * info.visible_height;
function message_is_far_enough_down() {
if (exports.at_top()) {
@@ -375,7 +402,6 @@ exports.keep_pointer_in_view = function () {
return true;
}
-
// If at least part of the message is below top_threshold (10% from
// the top), then we also leave it alone.
const bottom_offset = message_top + next_row.safeOuterHeight(true);
@@ -388,8 +414,7 @@ exports.keep_pointer_in_view = function () {
}
function message_is_far_enough_up() {
- return exports.at_bottom() ||
- next_row.offset().top <= bottom_threshold;
+ return exports.at_bottom() || next_row.offset().top <= bottom_threshold;
}
function adjust(in_view, get_next_row) {
diff --git a/static/js/narrow.js b/static/js/narrow.js
index b543579288a..33bbb3a74c0 100644
--- a/static/js/narrow.js
+++ b/static/js/narrow.js
@@ -6,28 +6,36 @@ const LARGER_THAN_MAX_MESSAGE_ID = 10000000000000000;
function report_narrow_time(initial_core_time, initial_free_time, network_time) {
channel.post({
url: "/json/report/narrow_times",
- data: {initial_core: initial_core_time.toString(),
- initial_free: initial_free_time.toString(),
- network: network_time.toString()},
+ data: {
+ initial_core: initial_core_time.toString(),
+ initial_free: initial_free_time.toString(),
+ network: network_time.toString(),
+ },
});
}
function maybe_report_narrow_time(msg_list) {
- if (msg_list.network_time === undefined || msg_list.initial_core_time === undefined ||
- msg_list.initial_free_time === undefined) {
+ if (
+ msg_list.network_time === undefined ||
+ msg_list.initial_core_time === undefined ||
+ msg_list.initial_free_time === undefined
+ ) {
return;
}
- report_narrow_time(msg_list.initial_core_time - msg_list.start_time,
- msg_list.initial_free_time - msg_list.start_time,
- msg_list.network_time - msg_list.start_time);
-
+ report_narrow_time(
+ msg_list.initial_core_time - msg_list.start_time,
+ msg_list.initial_free_time - msg_list.start_time,
+ msg_list.network_time - msg_list.start_time,
+ );
}
function report_unnarrow_time() {
- if (unnarrow_times === undefined ||
+ if (
+ unnarrow_times === undefined ||
unnarrow_times.start_time === undefined ||
unnarrow_times.initial_core_time === undefined ||
- unnarrow_times.initial_free_time === undefined) {
+ unnarrow_times.initial_free_time === undefined
+ ) {
return;
}
@@ -36,8 +44,10 @@ function report_unnarrow_time() {
channel.post({
url: "/json/report/unnarrow_times",
- data: {initial_core: initial_core_time.toString(),
- initial_free: initial_free_time.toString()},
+ data: {
+ initial_core: initial_core_time.toString(),
+ initial_free: initial_free_time.toString(),
+ },
});
unnarrow_times = {};
@@ -49,8 +59,9 @@ exports.save_pre_narrow_offset_for_reload = function () {
blueslip.debug("narrow.activate missing selected row", {
selected_id: current_msg_list.selected_id(),
selected_idx: current_msg_list.selected_idx(),
- selected_idx_exact: current_msg_list.all_messages().indexOf(
- current_msg_list.get(current_msg_list.selected_id())),
+ selected_idx_exact: current_msg_list
+ .all_messages()
+ .indexOf(current_msg_list.get(current_msg_list.selected_id())),
render_start: current_msg_list.view._render_win_start,
render_end: current_msg_list.view._render_win_end,
});
@@ -151,9 +162,11 @@ exports.activate = function (raw_operators, opts) {
message_scroll.hide_top_of_narrow_notices();
message_scroll.hide_indicators();
- blueslip.debug("Narrowed", {operators: operators.map((e) => e.operator),
- trigger: opts ? opts.trigger : undefined,
- previous_id: current_msg_list.selected_id()});
+ blueslip.debug("Narrowed", {
+ operators: operators.map((e) => e.operator),
+ trigger: opts ? opts.trigger : undefined,
+ previous_id: current_msg_list.selected_id(),
+ });
opts = {
then_select_id: -1,
@@ -425,18 +438,17 @@ exports.maybe_add_local_messages = function (opts) {
// We can now assume narrow_state.filter().can_apply_locally(),
// because !can_apply_locally => cannot_compute
- if (unread_info.flavor === "found" &&
- narrow_state.filter().allow_use_first_unread_when_narrowing()) {
+ if (
+ unread_info.flavor === "found" &&
+ narrow_state.filter().allow_use_first_unread_when_narrowing()
+ ) {
// We have at least one unread message in this narrow, and the
// narrow is one where we use the first unread message in
// narrowing positioning decisions. So either we aim for the
// first unread message, or the target_id (if any), whichever
// is earlier. See #2091 for a detailed explanation of why we
// need to look at unread here.
- id_info.final_select_id = min_defined(
- id_info.target_id,
- unread_info.msg_id,
- );
+ id_info.final_select_id = min_defined(id_info.target_id, unread_info.msg_id);
if (!load_local_messages(msg_data)) {
return;
@@ -493,9 +505,11 @@ exports.maybe_add_local_messages = function (opts) {
// come up with e.g. `near: 0` in a small organization.
//
// And similarly for `near: max_int` with has_found_newest.
- if (message_list.all.empty() ||
+ if (
+ message_list.all.empty() ||
id_info.target_id < message_list.all.first().id ||
- id_info.target_id > message_list.all.last().id) {
+ id_info.target_id > message_list.all.last().id
+ ) {
// If the target message is outside the range that we had
// available for local population, we must go to the server.
return;
@@ -532,8 +546,7 @@ exports.update_selection = function (opts) {
}
const preserve_pre_narrowing_screen_position =
- message_list.narrowed.get(msg_id) !== undefined &&
- select_offset !== undefined;
+ message_list.narrowed.get(msg_id) !== undefined && select_offset !== undefined;
const then_scroll = !preserve_pre_narrowing_screen_position;
@@ -554,13 +567,10 @@ exports.update_selection = function (opts) {
exports.activate_stream_for_cycle_hotkey = function (stream_name) {
// This is the common code for A/D hotkeys.
- const filter_expr = [
- {operator: "stream", operand: stream_name},
- ];
+ const filter_expr = [{operator: "stream", operand: stream_name}];
exports.activate(filter_expr, {});
};
-
exports.stream_cycle_backward = function () {
const curr_stream = narrow_state.stream();
@@ -599,10 +609,7 @@ exports.narrow_to_next_topic = function () {
topic: narrow_state.topic(),
};
- const next_narrow = topic_generator.get_next_topic(
- curr_info.stream,
- curr_info.topic,
- );
+ const next_narrow = topic_generator.get_next_topic(curr_info.stream, curr_info.topic);
if (!next_narrow) {
return;
@@ -617,7 +624,6 @@ exports.narrow_to_next_topic = function () {
};
exports.narrow_to_next_pm_string = function () {
-
const curr_pm = narrow_state.pm_string();
const next_pm = topic_generator.get_next_unread_pm_string(curr_pm);
@@ -630,9 +636,7 @@ exports.narrow_to_next_pm_string = function () {
// mapping back to emails.
const pm_with = people.user_ids_string_to_emails_string(next_pm);
- const filter_expr = [
- {operator: "pm-with", operand: pm_with},
- ];
+ const filter_expr = [{operator: "pm-with", operand: pm_with}];
// force_close parameter is true to not auto open compose_box
const opts = {
@@ -642,7 +646,6 @@ exports.narrow_to_next_pm_string = function () {
exports.activate(filter_expr, opts);
};
-
// Activate narrowing with a single operator.
// This is just for syntactic convenience.
exports.by = function (operator, operand, opts) {
@@ -906,8 +909,11 @@ function show_search_query() {
}
if (query_contains_stop_words) {
- search_string_display.html(i18n.t(
- "Some common words were excluded from your search.") + "<br/>" + search_string_display.html());
+ search_string_display.html(
+ i18n.t("Some common words were excluded from your search.") +
+ "<br/>" +
+ search_string_display.html(),
+ );
}
}
@@ -932,15 +938,21 @@ function pick_empty_narrow_banner() {
let invalid_narrow_message = "";
// No message can have multiple streams
if (streams.length > 1) {
- invalid_narrow_message = i18n.t("You are searching for messages that belong to more than one stream, which is not possible.");
+ invalid_narrow_message = i18n.t(
+ "You are searching for messages that belong to more than one stream, which is not possible.",
+ );
}
// No message can have multiple topics
if (current_filter.operands("topic").length > 1) {
- invalid_narrow_message = i18n.t("You are searching for messages that belong to more than one topic, which is not possible.");
+ invalid_narrow_message = i18n.t(
+ "You are searching for messages that belong to more than one topic, which is not possible.",
+ );
}
// No message can have multiple senders
if (current_filter.operands("sender").length > 1) {
- invalid_narrow_message = i18n.t("You are searching for messages that are sent by more than one person, which is not possible.");
+ invalid_narrow_message = i18n.t(
+ "You are searching for messages that are sent by more than one person, which is not possible.",
+ );
}
if (invalid_narrow_message !== "") {
set_invalid_narrow_message(invalid_narrow_message);
@@ -1020,7 +1032,10 @@ function pick_empty_narrow_banner() {
exports.show_empty_narrow_message = function () {
$(".empty_feed_notice").hide();
pick_empty_narrow_banner().show();
- $("#left_bar_compose_reply_button_big").attr("title", i18n.t("There are no messages to reply to."));
+ $("#left_bar_compose_reply_button_big").attr(
+ "title",
+ i18n.t("There are no messages to reply to."),
+ );
$("#left_bar_compose_reply_button_big").attr("disabled", "disabled");
};
diff --git a/static/js/narrow_state.js b/static/js/narrow_state.js
index 68da784f210..e244df99f2b 100644
--- a/static/js/narrow_state.js
+++ b/static/js/narrow_state.js
@@ -29,7 +29,6 @@ exports.update_email = function (user_id, new_email) {
}
};
-
/* Operators we should send to the server. */
exports.public_operators = function () {
if (current_filter === undefined) {
@@ -202,7 +201,6 @@ exports.get_first_unread_info = function () {
};
}
-
return {
flavor: "found",
msg_id: unread_ids[0],
@@ -274,14 +272,12 @@ exports._possible_unread_message_ids = function () {
return;
};
-
// Are we narrowed to PMs: all PMs or PMs with particular people.
exports.narrowed_to_pms = function () {
if (current_filter === undefined) {
return false;
}
- return current_filter.has_operator("pm-with") ||
- current_filter.has_operand("is", "private");
+ return current_filter.has_operator("pm-with") || current_filter.has_operand("is", "private");
};
exports.narrowed_by_pm_reply = function () {
@@ -289,8 +285,7 @@ exports.narrowed_by_pm_reply = function () {
return false;
}
const operators = current_filter.operators();
- return operators.length === 1 &&
- current_filter.has_operator("pm-with");
+ return operators.length === 1 && current_filter.has_operator("pm-with");
};
exports.narrowed_by_topic_reply = function () {
@@ -298,16 +293,17 @@ exports.narrowed_by_topic_reply = function () {
return false;
}
const operators = current_filter.operators();
- return operators.length === 2 &&
- current_filter.operands("stream").length === 1 &&
- current_filter.operands("topic").length === 1;
+ return (
+ operators.length === 2 &&
+ current_filter.operands("stream").length === 1 &&
+ current_filter.operands("topic").length === 1
+ );
};
// We auto-reply under certain conditions, namely when you're narrowed
// to a PM (or huddle), and when you're narrowed to some stream/topic pair
exports.narrowed_by_reply = function () {
- return exports.narrowed_by_pm_reply() ||
- exports.narrowed_by_topic_reply();
+ return exports.narrowed_by_pm_reply() || exports.narrowed_by_topic_reply();
};
exports.narrowed_by_stream_reply = function () {
@@ -315,16 +311,14 @@ exports.narrowed_by_stream_reply = function () {
return false;
}
const operators = current_filter.operators();
- return operators.length === 1 &&
- current_filter.operands("stream").length === 1;
+ return operators.length === 1 && current_filter.operands("stream").length === 1;
};
exports.narrowed_to_topic = function () {
if (current_filter === undefined) {
return false;
}
- return current_filter.has_operator("stream") &&
- current_filter.has_operator("topic");
+ return current_filter.has_operator("stream") && current_filter.has_operator("topic");
};
exports.narrowed_to_search = function () {
@@ -339,8 +333,12 @@ exports.narrowed_to_starred = function () {
};
exports.muting_enabled = function () {
- return !exports.narrowed_to_topic() && !exports.narrowed_to_search() &&
- !exports.narrowed_to_pms() && !exports.narrowed_to_starred();
+ return (
+ !exports.narrowed_to_topic() &&
+ !exports.narrowed_to_search() &&
+ !exports.narrowed_to_pms() &&
+ !exports.narrowed_to_starred()
+ );
};
exports.is_for_stream_id = function (stream_id) {
diff --git a/static/js/navigate.js b/static/js/navigate.js
index cb1c8ca618d..f353202dd04 100644
--- a/static/js/navigate.js
+++ b/static/js/navigate.js
@@ -1,7 +1,5 @@
function go_to_row(msg_id) {
- current_msg_list.select_id(msg_id,
- {then_scroll: true,
- from_scroll: true});
+ current_msg_list.select_id(msg_id, {then_scroll: true, from_scroll: true});
}
exports.up = function () {
@@ -21,8 +19,9 @@ exports.down = function (with_centering) {
// At the last message, scroll to the bottom so we have
// lots of nice whitespace for new messages coming in.
const current_msg_table = rows.get_table(current_msg_list.table_name);
- message_viewport.scrollTop(current_msg_table.safeOuterHeight(true) -
- message_viewport.height() * 0.1);
+ message_viewport.scrollTop(
+ current_msg_table.safeOuterHeight(true) - message_viewport.height() * 0.1,
+ );
if (current_msg_list.can_mark_messages_read()) {
unread_ops.mark_current_list_as_read();
}
@@ -42,15 +41,13 @@ exports.down = function (with_centering) {
exports.to_home = function () {
message_viewport.set_last_movement_direction(-1);
const first_id = current_msg_list.first().id;
- current_msg_list.select_id(first_id, {then_scroll: true,
- from_scroll: true});
+ current_msg_list.select_id(first_id, {then_scroll: true, from_scroll: true});
};
exports.to_end = function () {
const next_id = current_msg_list.last().id;
message_viewport.set_last_movement_direction(1);
- current_msg_list.select_id(next_id, {then_scroll: true,
- from_scroll: true});
+ current_msg_list.select_id(next_id, {then_scroll: true, from_scroll: true});
if (current_msg_list.can_mark_messages_read()) {
unread_ops.mark_current_list_as_read();
}
@@ -142,7 +139,4 @@ exports.maybe_scroll_to_selected = function () {
}
};
-
-
-
window.navigate = exports;
diff --git a/static/js/notifications.js b/static/js/notifications.js
index 16adf7359a7..eeed7d799e3 100644
--- a/static/js/notifications.js
+++ b/static/js/notifications.js
@@ -63,21 +63,22 @@ function get_audio_file_path(audio_element, audio_file_without_extension) {
}
exports.initialize = function () {
- $(window).focus(() => {
- window_has_focus = true;
+ $(window)
+ .focus(() => {
+ window_has_focus = true;
- for (const notice_mem_entry of notice_memory.values()) {
- notice_mem_entry.obj.close();
- }
- notice_memory.clear();
-
- // Update many places on the DOM to reflect unread
- // counts.
- unread_ops.process_visible();
-
- }).blur(() => {
- window_has_focus = false;
- });
+ for (const notice_mem_entry of notice_memory.values()) {
+ notice_mem_entry.obj.close();
+ }
+ notice_memory.clear();
+
+ // Update many places on the DOM to reflect unread
+ // counts.
+ unread_ops.process_visible();
+ })
+ .blur(() => {
+ window_has_focus = false;
+ });
const audio = $("<audio>");
if (audio[0].canPlayType === undefined) {
@@ -95,8 +96,8 @@ exports.initialize = function () {
source.attr("type", "audio/mpeg");
}
- const audio_file_without_extension
- = "/static/audio/notification_sounds/" + page_params.notification_sound;
+ const audio_file_without_extension =
+ "/static/audio/notification_sounds/" + page_params.notification_sound;
source.attr("src", get_audio_file_path(audio[0], audio_file_without_extension));
}
};
@@ -106,8 +107,8 @@ function update_notification_sound_source() {
// updating the source instead of creating it for the first time.
const audio = $("#notifications-area audio");
const source = $("#notifications-area audio source");
- const audio_file_without_extension
- = "/static/audio/notification_sounds/" + page_params.notification_sound;
+ const audio_file_without_extension =
+ "/static/audio/notification_sounds/" + page_params.notification_sound;
source.attr("src", get_audio_file_path(audio[0], audio_file_without_extension));
// Load it so that it is ready to be played; without this the old sound
@@ -135,10 +136,13 @@ exports.redraw_title = function () {
// Update window title and favicon to reflect unread messages in current view
let n;
- const new_title = (new_message_count ? "(" + new_message_count + ") " : "")
- + narrow.narrow_title + " - "
- + page_params.realm_name + " - "
- + "Zulip";
+ const new_title =
+ (new_message_count ? "(" + new_message_count + ") " : "") +
+ narrow.narrow_title +
+ " - " +
+ page_params.realm_name +
+ " - " +
+ "Zulip";
if (document.title === new_title) {
return;
@@ -207,36 +211,44 @@ exports.window_has_focus = function () {
};
function in_browser_notify(message, title, content, raw_operators, opts) {
- const notification_html = $(render_notification({
- gravatar_url: people.small_avatar_url(message),
- title: title,
- content: content,
- message_id: message.id,
- }));
-
- $(".top-right").notify({
- message: {
- html: notification_html,
- },
- fadeOut: {
- enabled: true,
- delay: 4000,
- },
- }).show();
-
- $(".notification[data-message-id='" + message.id + "']").expectOne().data("narrow", {
- raw_operators: raw_operators,
- opts_notif: opts,
- });
+ const notification_html = $(
+ render_notification({
+ gravatar_url: people.small_avatar_url(message),
+ title: title,
+ content: content,
+ message_id: message.id,
+ }),
+ );
+
+ $(".top-right")
+ .notify({
+ message: {
+ html: notification_html,
+ },
+ fadeOut: {
+ enabled: true,
+ delay: 4000,
+ },
+ })
+ .show();
+
+ $(".notification[data-message-id='" + message.id + "']")
+ .expectOne()
+ .data("narrow", {
+ raw_operators: raw_operators,
+ opts_notif: opts,
+ });
}
exports.notify_above_composebox = function (note, link_class, link_msg_id, link_text) {
- const notification_html = $(render_compose_notification({
- note: note,
- link_class: link_class,
- link_msg_id: link_msg_id,
- link_text: link_text,
- }));
+ const notification_html = $(
+ render_compose_notification({
+ note: note,
+ link_class: link_class,
+ link_msg_id: link_msg_id,
+ link_text: link_text,
+ }),
+ );
exports.clear_compose_notifications();
$("#out-of-view-notification").append(notification_html);
$("#out-of-view-notification").show();
@@ -309,8 +321,10 @@ function process_notification(notification) {
}
if (message.type === "private" || message.type === "test-notification") {
- if (page_params.pm_content_in_desktop_notifications !== undefined
- && !page_params.pm_content_in_desktop_notifications) {
+ if (
+ page_params.pm_content_in_desktop_notifications !== undefined &&
+ !page_params.pm_content_in_desktop_notifications
+ ) {
content = "New private message from " + message.sender_full_name;
}
key = message.display_reply_to;
@@ -320,8 +334,7 @@ function process_notification(notification) {
other_recipients = other_recipients.replace(message.sender_full_name + ", ", "");
notification_source = "pm";
} else {
- key = message.sender_full_name + " to " +
- message.stream + " > " + topic;
+ key = message.sender_full_name + " to " + message.stream + " > " + topic;
if (message.mentioned) {
notification_source = "mention";
} else if (message.alerted) {
@@ -356,8 +369,7 @@ function process_notification(notification) {
if (content.length + title.length + other_recipients.length > 230) {
// Then count how many people are in the conversation and summarize
// by saying the conversation is with "you and [number] other people"
- other_recipients = other_recipients.replace(/[^,]/g, "").length +
- " other people";
+ other_recipients = other_recipients.replace(/[^,]/g, "").length + " other people";
}
title += " (to you and " + other_recipients + ")";
@@ -444,13 +456,11 @@ exports.message_is_notifiable = function (message) {
// Messages to muted streams that don't mention us specifically
// are not notifiable.
- if (message.type === "stream" &&
- stream_data.is_muted(message.stream_id)) {
+ if (message.type === "stream" && stream_data.is_muted(message.stream_id)) {
return false;
}
- if (message.type === "stream" &&
- muting.is_topic_muted(message.stream_id, message.topic)) {
+ if (message.type === "stream" && muting.is_topic_muted(message.stream_id, message.topic)) {
return false;
}
@@ -467,8 +477,10 @@ exports.should_send_desktop_notification = function (message) {
// For streams, send if desktop notifications are enabled for all
// message on this stream.
- if (message.type === "stream" &&
- stream_data.receives_notifications(message.stream_id, "desktop_notifications")) {
+ if (
+ message.type === "stream" &&
+ stream_data.receives_notifications(message.stream_id, "desktop_notifications")
+ ) {
return true;
}
@@ -493,8 +505,10 @@ exports.should_send_desktop_notification = function (message) {
}
// wildcard mentions
- if (message.mentioned &&
- stream_data.receives_notifications(message.stream_id, "wildcard_mentions_notify")) {
+ if (
+ message.mentioned &&
+ stream_data.receives_notifications(message.stream_id, "wildcard_mentions_notify")
+ ) {
return true;
}
@@ -504,8 +518,10 @@ exports.should_send_desktop_notification = function (message) {
exports.should_send_audible_notification = function (message) {
// For streams, ding if sounds are enabled for all messages on
// this stream.
- if (message.type === "stream" &&
- stream_data.receives_notifications(message.stream_id, "audible_notifications")) {
+ if (
+ message.type === "stream" &&
+ stream_data.receives_notifications(message.stream_id, "audible_notifications")
+ ) {
return true;
}
@@ -529,8 +545,10 @@ exports.should_send_audible_notification = function (message) {
}
// wildcard mentions
- if (message.mentioned &&
- stream_data.receives_notifications(message.stream_id, "wildcard_mentions_notify")) {
+ if (
+ message.mentioned &&
+ stream_data.receives_notifications(message.stream_id, "wildcard_mentions_notify")
+ ) {
return true;
}
@@ -538,11 +556,9 @@ exports.should_send_audible_notification = function (message) {
};
exports.granted_desktop_notifications_permission = function () {
- return NotificationAPI &&
- NotificationAPI.permission === "granted";
+ return NotificationAPI && NotificationAPI.permission === "granted";
};
-
exports.request_desktop_notifications_permission = function () {
if (NotificationAPI) {
return NotificationAPI.requestPermission();
@@ -574,15 +590,17 @@ exports.received_messages = function (messages) {
};
exports.send_test_notification = function (content) {
- exports.received_messages([{
- id: Math.random(),
- type: "test-notification",
- sender_email: "[email protected]",
- sender_full_name: "Notification Bot",
- display_reply_to: "Notification Bot",
- content,
- unread: true,
- }]);
+ exports.received_messages([
+ {
+ id: Math.random(),
+ type: "test-notification",
+ sender_email: "[email protected]",
+ sender_full_name: "Notification Bot",
+ display_reply_to: "Notification Bot",
+ content,
+ unread: true,
+ },
+ ]);
};
function get_message_header(message) {
@@ -590,14 +608,14 @@ function get_message_header(message) {
return message.stream + " > " + message.topic;
}
if (message.display_recipient.length > 2) {
- return i18n.t("group private messages with __recipient__",
- {recipient: message.display_reply_to});
+ return i18n.t("group private messages with __recipient__", {
+ recipient: message.display_reply_to,
+ });
}
if (people.is_current_user(message.reply_to)) {
return i18n.t("private messages with yourself");
}
- return i18n.t("private messages with __recipient__",
- {recipient: message.display_reply_to});
+ return i18n.t("private messages with __recipient__", {recipient: message.display_reply_to});
}
exports.get_local_notify_mix_reason = function (message) {
@@ -620,8 +638,11 @@ exports.get_local_notify_mix_reason = function (message) {
// we can only look for these on non-search (can_apply_locally) messages
// see also: exports.notify_messages_outside_current_search
const current_filter = narrow_state.filter();
- if (current_filter && current_filter.can_apply_locally() &&
- !current_filter.predicate()(message)) {
+ if (
+ current_filter &&
+ current_filter.can_apply_locally() &&
+ !current_filter.predicate()(message)
+ ) {
return i18n.t("Sent! Your message is outside your current narrow.");
}
};
@@ -649,7 +670,9 @@ exports.notify_local_mixes = function (messages, need_user_to_scroll) {
// This can happen if the client is offline for a while
// around the time this client sends a message; see the
// caller of message_events.insert_new_messages.
- blueslip.info("Slightly unexpected: A message not sent by us batches with those that were.");
+ blueslip.info(
+ "Slightly unexpected: A message not sent by us batches with those that were.",
+ );
continue;
}
@@ -671,8 +694,9 @@ exports.notify_local_mixes = function (messages, need_user_to_scroll) {
const link_msg_id = message.id;
const link_class = "compose_notification_narrow_by_topic";
- const link_text = i18n.t("Narrow to __- message_recipient__",
- {message_recipient: get_message_header(message)});
+ const link_text = i18n.t("Narrow to __- message_recipient__", {
+ message_recipient: get_message_header(message),
+ });
exports.notify_above_composebox(reason, link_class, link_msg_id, link_text);
}
@@ -685,12 +709,15 @@ exports.notify_messages_outside_current_search = function (messages) {
if (!people.is_current_user(message.sender_email)) {
continue;
}
- const link_text = i18n.t("Narrow to __- message_recipient__",
- {message_recipient: get_message_header(message)});
- exports.notify_above_composebox(i18n.t("Sent! Your recent message is outside the current search."),
- "compose_notification_narrow_by_topic",
- message.id,
- link_text);
+ const link_text = i18n.t("Narrow to __- message_recipient__", {
+ message_recipient: get_message_header(message),
+ });
+ exports.notify_above_composebox(
+ i18n.t("Sent! Your recent message is outside the current search."),
+ "compose_notification_narrow_by_topic",
+ message.id,
+ link_text,
+ );
}
};
diff --git a/static/js/overlays.js b/static/js/overlays.js
index dc47a521f4c..bb6b2dfb163 100644
--- a/static/js/overlays.js
+++ b/static/js/overlays.js
@@ -75,8 +75,12 @@ exports.open_overlay = function (opts) {
}
if (active_overlay || open_overlay_name || close_handler) {
- blueslip.error("Programming error — trying to open " + opts.name +
- " before closing " + open_overlay_name);
+ blueslip.error(
+ "Programming error — trying to open " +
+ opts.name +
+ " before closing " +
+ open_overlay_name,
+ );
return;
}
@@ -117,8 +121,9 @@ exports.open_modal = function (selector) {
}
if (exports.is_modal_open()) {
- blueslip.error("open_modal() was called while " + exports.active_modal() +
- " modal was open.");
+ blueslip.error(
+ "open_modal() was called while " + exports.active_modal() + " modal was open.",
+ );
return;
}
@@ -182,8 +187,9 @@ exports.close_modal = function (selector) {
}
if (exports.active_modal() !== selector) {
- blueslip.error("Trying to close " + selector +
- " modal when " + exports.active_modal() + " is open.");
+ blueslip.error(
+ "Trying to close " + selector + " modal when " + exports.active_modal() + " is open.",
+ );
return;
}
@@ -193,7 +199,6 @@ exports.close_modal = function (selector) {
elem.modal("hide").attr("aria-hidden", true);
// Enable mouse events for the background as the modal closes.
exports.enable_background_mouse_events();
-
};
exports.close_active_modal = function () {
diff --git a/static/js/padded_widget.js b/static/js/padded_widget.js
index e06b58a441b..ee4611bd6e4 100644
--- a/static/js/padded_widget.js
+++ b/static/js/padded_widget.js
@@ -19,5 +19,4 @@ exports.update_padding = function (opts) {
padding.width(1);
};
-
window.padded_widget = exports;
diff --git a/static/js/panels.js b/static/js/panels.js
index 158d0592f0f..56d540c71e4 100644
--- a/static/js/panels.js
+++ b/static/js/panels.js
@@ -5,16 +5,19 @@ 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);
+ const frb_top =
+ panels_height + $(".header").height() + parseInt($(".header").css("paddingBottom"), 10);
$("#floating_recipient_bar").css("top", frb_top + "px");
};
exports.resize_app = resize_app;
const show_step = function ($process, step) {
- $process.find("[data-step]").hide().filter("[data-step=" + step + "]").show();
+ $process
+ .find("[data-step]")
+ .hide()
+ .filter("[data-step=" + step + "]")
+ .show();
};
const get_step = function ($process) {
@@ -50,8 +53,10 @@ exports.check_profile_incomplete = function () {
// Eventually, we might also check page_params.realm_icon_source,
// but it feels too aggressive to ask users to do change that
// since their organization might not have a logo yet.
- if (page_params.realm_description === "" ||
- page_params.realm_description.startsWith("Organization imported from")) {
+ if (
+ page_params.realm_description === "" ||
+ page_params.realm_description.startsWith("Organization imported from")
+ ) {
$("[data-process='profile-incomplete']").show();
} else {
$("[data-process='profile-incomplete']").hide();
diff --git a/static/js/people.js b/static/js/people.js
index 00dde2b7151..5014384c5bc 100644
--- a/static/js/people.js
+++ b/static/js/people.js
@@ -44,7 +44,6 @@ function split_to_ints(lst) {
return lst.split(",").map((s) => parseInt(s, 10));
}
-
exports.get_by_user_id = function (user_id, ignore_missing) {
if (!people_by_user_id_dict.has(user_id) && !ignore_missing) {
blueslip.error("Unknown user_id in get_by_user_id: " + user_id);
@@ -62,8 +61,7 @@ exports.get_by_email = function (email) {
if (person.email.toLowerCase() !== email.toLowerCase()) {
blueslip.warn(
- "Obsolete email passed to get_by_email: " + email +
- " new email = " + person.email,
+ "Obsolete email passed to get_by_email: " + email + " new email = " + person.email,
);
}
@@ -152,9 +150,7 @@ exports.huddle_string = function (message) {
let user_ids = message.display_recipient.map((recip) => recip.id);
function is_huddle_recip(user_id) {
- return user_id &&
- people_by_user_id_dict.has(user_id) &&
- !exports.is_my_user_id(user_id);
+ return user_id && people_by_user_id_dict.has(user_id) && !exports.is_my_user_id(user_id);
}
user_ids = user_ids.filter(is_huddle_recip);
@@ -848,9 +844,10 @@ exports.get_message_people = function () {
at the message_store code to see the precise
semantics
*/
- const message_people = message_store.user_ids().map(
- (user_id) => people_by_user_id_dict.get(user_id),
- ).filter(Boolean);
+ const message_people = message_store
+ .user_ids()
+ .map((user_id) => people_by_user_id_dict.get(user_id))
+ .filter(Boolean);
return message_people;
};
@@ -1018,9 +1015,11 @@ exports.get_people_for_stream_create = function () {
const people_minus_you = [];
for (const person of active_user_dict.values()) {
if (!exports.is_my_user_id(person.user_id)) {
- people_minus_you.push({email: person.email,
- user_id: person.user_id,
- full_name: person.full_name});
+ people_minus_you.push({
+ email: person.email,
+ user_id: person.user_id,
+ full_name: person.full_name,
+ });
}
}
return people_minus_you.sort(people_cmp);
@@ -1136,9 +1135,13 @@ exports.extract_people_from_message = function (message) {
switch (message.type) {
case "stream":
- involved_people = [{full_name: message.sender_full_name,
- user_id: message.sender_id,
- email: message.sender_email}];
+ involved_people = [
+ {
+ full_name: message.sender_full_name,
+ user_id: message.sender_id,
+ email: message.sender_email,
+ },
+ ];
break;
case "private":
@@ -1180,8 +1183,7 @@ function safe_lower(s) {
exports.matches_user_settings_search = function (person, value) {
const email = settings_data.email_for_user_settings(person);
- return safe_lower(person.full_name).includes(value) ||
- safe_lower(email).includes(value);
+ return safe_lower(person.full_name).includes(value) || safe_lower(email).includes(value);
};
exports.filter_for_user_settings_search = function (persons, query) {
@@ -1210,7 +1212,6 @@ exports.maybe_incr_recipient_count = function (message) {
// Track the number of PMs we've sent to this person to improve autocomplete
for (const recip of message.display_recipient) {
-
if (recip.unknown_local_echo_user) {
continue;
}
diff --git a/static/js/pm_list.js b/static/js/pm_list.js
index 6552b0bd9c5..2f3cd960515 100644
--- a/static/js/pm_list.js
+++ b/static/js/pm_list.js
@@ -152,12 +152,12 @@ exports.expand = function () {
exports.update_dom_with_unread_counts = function (counts) {
exports.update_private_messages();
set_count(counts.private_message_count);
- unread_ui.set_count_toggle_button($("#userlist-toggle-unreadcount"),
- counts.private_message_count);
+ unread_ui.set_count_toggle_button(
+ $("#userlist-toggle-unreadcount"),
+ counts.private_message_count,
+ );
};
-
-exports.initialize = function () {
-};
+exports.initialize = function () {};
window.pm_list = exports;
diff --git a/static/js/poll_widget.js b/static/js/poll_widget.js
index 6561fcb0703..4491c59dd26 100644
--- a/static/js/poll_widget.js
+++ b/static/js/poll_widget.js
@@ -106,7 +106,6 @@ exports.poll_data_holder = function (is_my_poll, question, options) {
return event;
}
return;
-
},
inbound: function (sender_id, data) {
@@ -336,7 +335,6 @@ exports.activate = function (opts) {
return;
}
});
-
}
function render_results() {
@@ -345,11 +343,13 @@ exports.activate = function (opts) {
const html = render_widgets_poll_widget_results(widget_data);
elem.find("ul.poll-widget").html(html);
- elem.find("button.poll-vote").off("click").on("click", (e) => {
- e.stopPropagation();
- const key = $(e.target).attr("data-key");
- submit_vote(key);
- });
+ elem.find("button.poll-vote")
+ .off("click")
+ .on("click", (e) => {
+ e.stopPropagation();
+ const key = $(e.target).attr("data-key");
+ submit_vote(key);
+ });
}
elem.handle_events = function (events) {
diff --git a/static/js/popovers.js b/static/js/popovers.js
index 9302331701c..3d1625bfbe7 100644
--- a/static/js/popovers.js
+++ b/static/js/popovers.js
@@ -29,7 +29,6 @@ function elem_to_user_id(elem) {
// this is needed so that when we try to unload popovers, we can kill all dead
// ones that no longer have valid parents in the DOM.
(function (popover) {
-
$.fn.popover = function (...args) {
// apply the jQuery object as `this`, and popover function arguments.
popover.apply(this, args);
@@ -103,8 +102,7 @@ function load_medium_avatar(user, elt) {
function calculate_info_popover_placement(size, elt) {
const ypos = elt.offset().top;
- if (!(ypos + size / 2 < message_viewport.height() &&
- ypos > size / 2)) {
+ if (!(ypos + size / 2 < message_viewport.height() && ypos > size / 2)) {
if (ypos + size < message_viewport.height()) {
return "bottom";
} else if (ypos > size) {
@@ -160,8 +158,14 @@ function get_custom_profile_field_data(user, field, field_types, dateFormat) {
return profile_field;
}
-function render_user_info_popover(user, popover_element, is_sender_popover, private_msg_class,
- template_class, popover_placement) {
+function render_user_info_popover(
+ user,
+ popover_element,
+ is_sender_popover,
+ private_msg_class,
+ template_class,
+ popover_placement,
+) {
const is_me = people.is_my_user_id(user.user_id);
let can_set_away = false;
@@ -240,8 +244,7 @@ exports._test_calculate_info_popover_placement = calculate_info_popover_placemen
function show_user_info_popover(element, user, message) {
const last_popover_elem = current_message_info_popover_elem;
exports.hide_all();
- if (last_popover_elem !== undefined
- && last_popover_elem.get()[0] === element) {
+ if (last_popover_elem !== undefined && last_popover_elem.get()[0] === element) {
// We want it to be the case that a user can dismiss a popover
// by clicking on the same element that caused the popover.
return;
@@ -257,8 +260,14 @@ function show_user_info_popover(element, user, message) {
}
const is_sender_popover = message.sender_id === user.user_id;
- render_user_info_popover(user, elt, is_sender_popover, "respond_personal_button",
- "message-info-popover", "right");
+ render_user_info_popover(
+ user,
+ elt,
+ is_sender_popover,
+ "respond_personal_button",
+ "message-info-popover",
+ "right",
+ );
current_message_info_popover_elem = elt;
}
@@ -267,8 +276,7 @@ function show_user_info_popover(element, user, message) {
function show_mobile_message_buttons_popover(element) {
const last_popover_elem = current_mobile_message_buttons_popover_elem;
exports.hide_all();
- if (last_popover_elem !== undefined
- && last_popover_elem.get()[0] === element) {
+ if (last_popover_elem !== undefined && last_popover_elem.get()[0] === element) {
// We want it to be the case that a user can dismiss a popover
// by clicking on the same element that caused the popover.
return;
@@ -326,7 +334,12 @@ exports.show_user_profile = function (user) {
$("#user-profile-modal-holder").html(render_user_profile_modal(args));
$("#user-profile-modal").modal("show");
- settings_account.initialize_custom_user_type_fields("#user-profile-modal #content", user.user_id, false, false);
+ settings_account.initialize_custom_user_type_fields(
+ "#user-profile-modal #content",
+ user.user_id,
+ false,
+ false,
+ );
};
function get_user_info_popover_items() {
@@ -348,16 +361,17 @@ function fetch_group_members(member_ids) {
return member_ids
.map((m) => people.get_by_user_id(m))
.filter((m) => m !== undefined)
- .map((p) => Object.assign({}, p, {
- user_circle_class: buddy_data.get_user_circle_class(p.user_id),
- is_active: people.is_active_user_for_popover(p.user_id),
- user_last_seen_time_status: buddy_data.user_last_seen_time_status(p.user_id),
- }));
+ .map((p) =>
+ Object.assign({}, p, {
+ user_circle_class: buddy_data.get_user_circle_class(p.user_id),
+ is_active: people.is_active_user_for_popover(p.user_id),
+ user_last_seen_time_status: buddy_data.user_last_seen_time_status(p.user_id),
+ }),
+ );
}
function sort_group_members(members) {
- return members
- .sort((a, b) => a.full_name.localeCompare(b.full_name));
+ return members.sort((a, b) => a.full_name.localeCompare(b.full_name));
}
// exporting these functions for testing purposes
@@ -373,8 +387,7 @@ function show_user_group_info_popover(element, group, message) {
// note that the actual size varies (in group size), but this is about as big as it gets
const popover_size = 390;
exports.hide_all();
- if (last_popover_elem !== undefined
- && last_popover_elem.get()[0] === element) {
+ if (last_popover_elem !== undefined && last_popover_elem.get()[0] === element) {
// We want it to be the case that a user can dismiss a popover
// by clicking on the same element that caused the popover.
return;
@@ -402,8 +415,7 @@ function show_user_group_info_popover(element, group, message) {
exports.toggle_actions_popover = function (element, id) {
const last_popover_elem = current_actions_popover_elem;
exports.hide_all();
- if (last_popover_elem !== undefined
- && last_popover_elem.get()[0] === element) {
+ if (last_popover_elem !== undefined && last_popover_elem.get()[0] === element) {
// We want it to be the case that a user can dismiss a popover
// by clicking on the same element that caused the popover.
return;
@@ -429,37 +441,35 @@ exports.toggle_actions_popover = function (element, id) {
}
const topic = message.topic;
const can_mute_topic =
- message.stream &&
- topic &&
- !muting.is_topic_muted(message.stream_id, topic);
+ message.stream && topic && !muting.is_topic_muted(message.stream_id, topic);
const can_unmute_topic =
- message.stream &&
- topic &&
- muting.is_topic_muted(message.stream_id, topic);
+ message.stream && topic && muting.is_topic_muted(message.stream_id, topic);
const should_display_edit_history_option =
message.edit_history &&
- message.edit_history.some((entry) => entry.prev_content !== undefined ||
- util.get_edit_event_prev_topic(entry) !== undefined) &&
+ message.edit_history.some(
+ (entry) =>
+ entry.prev_content !== undefined ||
+ util.get_edit_event_prev_topic(entry) !== undefined,
+ ) &&
page_params.realm_allow_edit_history;
// Disabling this for /me messages is a temporary workaround
// for the fact that we don't have a styling for how that
// should look. See also condense.js.
- const should_display_collapse = !message.locally_echoed &&
- !message.is_me_message &&
- !message.collapsed;
- const should_display_uncollapse = !message.locally_echoed &&
- !message.is_me_message &&
- message.collapsed;
+ const should_display_collapse =
+ !message.locally_echoed && !message.is_me_message && !message.collapsed;
+ const should_display_uncollapse =
+ !message.locally_echoed && !message.is_me_message && message.collapsed;
const should_display_edit_and_view_source =
- message.content !== "<p>(deleted)</p>" ||
- editability === message_edit.editability_types.FULL ||
- editability === message_edit.editability_types.TOPIC_ONLY;
+ message.content !== "<p>(deleted)</p>" ||
+ editability === message_edit.editability_types.FULL ||
+ editability === message_edit.editability_types.TOPIC_ONLY;
const should_display_quote_and_reply = message.content !== "<p>(deleted)</p>";
- const conversation_time_uri = hash_util.by_conversation_and_time_uri(message)
+ const conversation_time_uri = hash_util
+ .by_conversation_and_time_uri(message)
.replace(/\(/g, "%28")
.replace(/\)/g, "%29");
@@ -519,7 +529,9 @@ exports.render_actions_remind_popover = function (element, id) {
trigger: "manual",
});
elt.popover("show");
- current_flatpickr_instance = $('.remind.custom[data-message-id="' + message.id + '"]').flatpickr({
+ current_flatpickr_instance = $(
+ '.remind.custom[data-message-id="' + message.id + '"]',
+ ).flatpickr({
enableTime: true,
clickOpens: false,
defaultDate: moment().format(),
@@ -709,14 +721,18 @@ exports.register_click_handlers = function () {
exports.toggle_actions_popover(this, rows.id(row));
});
- $("#main_div").on("click", ".sender_name, .sender_name-in-status, .inline_profile_picture", function (e) {
- const row = $(this).closest(".message_row");
- e.stopPropagation();
- const message = current_msg_list.get(rows.id(row));
- const user = people.get_by_user_id(message.sender_id);
+ $("#main_div").on(
+ "click",
+ ".sender_name, .sender_name-in-status, .inline_profile_picture",
+ function (e) {
+ const row = $(this).closest(".message_row");
+ e.stopPropagation();
+ const message = current_msg_list.get(rows.id(row));
+ const user = people.get_by_user_id(message.sender_id);
- show_user_info_popover(this, user, message);
- });
+ show_user_info_popover(this, user, message);
+ },
+ );
$("#main_div").on("click", ".user-mention", function (e) {
const id_string = $(this).attr("data-user-id");
@@ -753,7 +769,6 @@ exports.register_click_handlers = function () {
}
});
-
$("body").on("click", ".info_popover_actions .narrow_to_private_messages", (e) => {
const user_id = elem_to_user_id($(e.target).parents("ul"));
const email = people.get_by_user_id(user_id).email;
@@ -884,8 +899,14 @@ exports.register_click_handlers = function () {
const user = people.get_by_user_id(user_id);
const popover_placement = userlist_placement === "left" ? "right" : "left";
- render_user_info_popover(user, target, false, "compose_private_message",
- "user_popover", popover_placement);
+ render_user_info_popover(
+ user,
+ target,
+ false,
+ "compose_private_message",
+ "user_popover",
+ popover_placement,
+ );
current_user_sidebar_user_id = user.user_id;
current_user_sidebar_popover = target.data("popover");
@@ -974,7 +995,8 @@ exports.register_click_handlers = function () {
const email = people.get_by_user_id(user_id).email;
compose_actions.start("private", {
trigger: "popover send private",
- private_message_recipient: email});
+ private_message_recipient: email,
+ });
exports.hide_all();
e.stopPropagation();
e.preventDefault();
@@ -1055,7 +1077,8 @@ exports.register_click_handlers = function () {
row.find(".alert-msg")
.text(i18n.t("Copied!"))
.css("display", "block")
- .delay(1000).fadeOut(300);
+ .delay(1000)
+ .fadeOut(300);
setTimeout(() => {
// The Cliboard library works by focusing to a hidden textarea.
@@ -1094,10 +1117,15 @@ exports.register_click_handlers = function () {
exports.any_active = function () {
// True if any popover (that this module manages) is currently shown.
// Expanded sidebars on mobile view count as popovers as well.
- return exports.actions_popped() || user_sidebar_popped() ||
- stream_popover.stream_popped() || stream_popover.topic_popped() ||
- exports.message_info_popped() || emoji_picker.reactions_popped() ||
- $("[class^='column-'].expanded").length;
+ return (
+ exports.actions_popped() ||
+ user_sidebar_popped() ||
+ stream_popover.stream_popped() ||
+ stream_popover.topic_popped() ||
+ exports.message_info_popped() ||
+ emoji_picker.reactions_popped() ||
+ $("[class^='column-'].expanded").length
+ );
};
// This function will hide all true popovers (the streamlist and
@@ -1137,8 +1165,12 @@ exports.set_userlist_placement = function (placement) {
userlist_placement = placement || "right";
};
-exports.compute_placement = function (elt, popover_height, popover_width,
- prefer_vertical_positioning) {
+exports.compute_placement = function (
+ elt,
+ popover_height,
+ popover_width,
+ prefer_vertical_positioning,
+) {
const client_rect = elt.get(0).getBoundingClientRect();
const distance_from_top = client_rect.top;
const distance_from_bottom = message_viewport.height() - client_rect.bottom;
diff --git a/static/js/portico/desktop-login.js b/static/js/portico/desktop-login.js
index d8e7fe9ecaa..52da6cba969 100644
--- a/static/js/portico/desktop-login.js
+++ b/static/js/portico/desktop-login.js
@@ -4,9 +4,7 @@ document.querySelector("#form").addEventListener("submit", () => {
document.querySelector("#token").focus();
async function decrypt_manual() {
- const key = await crypto.subtle.generateKey({name: "AES-GCM", length: 256}, true, [
- "decrypt",
- ]);
+ const key = await crypto.subtle.generateKey({name: "AES-GCM", length: 256}, true, ["decrypt"]);
return {
key: new Uint8Array(await crypto.subtle.exportKey("raw", key)),
pasted: new Promise((resolve) => {
diff --git a/static/js/portico/email_log.js b/static/js/portico/email_log.js
index 52551ba7039..19edb1abaef 100644
--- a/static/js/portico/email_log.js
+++ b/static/js/portico/email_log.js
@@ -26,7 +26,8 @@ $(() => {
}
});
$("#save_smptp_details").on("click", () => {
- const address = $("input[name=forward]:checked").val() === "enabled" ? $("#address").val() : "";
+ const address =
+ $("input[name=forward]:checked").val() === "enabled" ? $("#address").val() : "";
const csrf_token = $('input[name="csrfmiddlewaretoken"]').attr("value");
const data = {forward_address: address, csrfmiddlewaretoken: csrf_token};
diff --git a/static/js/portico/header.js b/static/js/portico/header.js
index b2570f9cebb..1329b4215d1 100644
--- a/static/js/portico/header.js
+++ b/static/js/portico/header.js
@@ -7,7 +7,10 @@ $(() => {
$("body").click((e) => {
const $this = $(e.target);
- if ($this.closest(".dropdown .dropdown-pill").length > 0 && !$(".dropdown").hasClass("show")) {
+ if (
+ $this.closest(".dropdown .dropdown-pill").length > 0 &&
+ !$(".dropdown").hasClass("show")
+ ) {
$(".dropdown").addClass("show");
} else if (!$this.is(".dropdown ul") && $this.closest(".dropdown ul").length === 0) {
$(".dropdown").removeClass("show");
diff --git a/static/js/portico/help.js b/static/js/portico/help.js
index b08530fb82f..6c65df6f3c0 100644
--- a/static/js/portico/help.js
+++ b/static/js/portico/help.js
@@ -141,10 +141,14 @@ if (window.location.pathname === "/help/") {
$(".help .sidebar h1, .help .sidebar h2, .help .sidebar h3").removeAttr("id");
// Scroll to anchor link when clicked
-$(document).on("click", ".markdown .content h1, .markdown .content h2, .markdown .content h3", function () {
- window.location.hash = $(this).attr("id");
- scrollToHash(markdownSB);
-});
+$(document).on(
+ "click",
+ ".markdown .content h1, .markdown .content h2, .markdown .content h3",
+ function () {
+ window.location.hash = $(this).attr("id");
+ scrollToHash(markdownSB);
+ },
+);
$(".hamburger").click(() => {
$(".sidebar").toggleClass("show");
diff --git a/static/js/portico/integrations.js b/static/js/portico/integrations.js
index ee258d11f80..bbf61db1dfc 100644
--- a/static/js/portico/integrations.js
+++ b/static/js/portico/integrations.js
@@ -3,30 +3,33 @@ import blueslip from "./../blueslip";
import {path_parts} from "./landing-page";
-
// these constants are populated immediately with data from the DOM on page load
// name -> display name
const INTEGRATIONS = new Map();
const CATEGORIES = new Map();
function load_data() {
- $(".integration-lozenge").toArray().forEach((integration) => {
- const name = $(integration).data("name");
- const display_name = $(integration).find(".integration-name").text().trim();
-
- if (display_name && name) {
- INTEGRATIONS.set(name, display_name);
- }
- });
+ $(".integration-lozenge")
+ .toArray()
+ .forEach((integration) => {
+ const name = $(integration).data("name");
+ const display_name = $(integration).find(".integration-name").text().trim();
+
+ if (display_name && name) {
+ INTEGRATIONS.set(name, display_name);
+ }
+ });
- $(".integration-category").toArray().forEach((category) => {
- const name = $(category).data("category");
- const display_name = $(category).text().trim();
+ $(".integration-category")
+ .toArray()
+ .forEach((category) => {
+ const name = $(category).data("category");
+ const display_name = $(category).text().trim();
- if (display_name && name) {
- CATEGORIES.set(name, display_name);
- }
- });
+ if (display_name && name) {
+ CATEGORIES.set(name, display_name);
+ }
+ });
}
const INITIAL_STATE = {
@@ -37,37 +40,40 @@ const INITIAL_STATE = {
let state = Object.assign({}, INITIAL_STATE);
-
function adjust_font_sizing() {
- $(".integration-lozenge").toArray().forEach((integration) => {
- const $integration_name = $(integration).find(".integration-name");
- const $integration_category = $(integration).find(".integration-category");
+ $(".integration-lozenge")
+ .toArray()
+ .forEach((integration) => {
+ const $integration_name = $(integration).find(".integration-name");
+ const $integration_category = $(integration).find(".integration-category");
- // if the text has wrapped to two lines, decrease font-size
- if ($integration_name.height() > 30) {
- $integration_name.css("font-size", "1em");
+ // if the text has wrapped to two lines, decrease font-size
if ($integration_name.height() > 30) {
- $integration_name.css("font-size", ".95em");
+ $integration_name.css("font-size", "1em");
+ if ($integration_name.height() > 30) {
+ $integration_name.css("font-size", ".95em");
+ }
}
- }
- if ($integration_category.height() > 30) {
- $integration_category.css("font-size", ".8em");
if ($integration_category.height() > 30) {
- $integration_category.css("font-size", ".75em");
+ $integration_category.css("font-size", ".8em");
+ if ($integration_category.height() > 30) {
+ $integration_category.css("font-size", ".75em");
+ }
}
- }
- });
+ });
}
function update_path() {
let next_path;
if (state.integration) {
next_path = $('.integration-lozenge[data-name="' + state.integration + '"]')
- .closest("a").attr("href");
+ .closest("a")
+ .attr("href");
} else if (state.category) {
next_path = $('.integration-category[data-category="' + state.category + '"]')
- .closest("a").attr("href");
+ .closest("a")
+ .attr("href");
} else {
next_path = "/";
}
@@ -89,10 +95,7 @@ function update_categories() {
$dropdown_label.text(CATEGORIES.get(state.category));
}
- $(".integration-lozenges").animate(
- {opacity: 1},
- {duration: 400},
- );
+ $(".integration-lozenges").animate({opacity: 1}, {duration: 400});
adjust_font_sizing();
}
@@ -118,7 +121,7 @@ const update_integrations = _.debounce(() => {
const display =
common.phrase_match(state.query, display_name) &&
($integration.data("categories").includes(CATEGORIES.get(state.category)) ||
- state.category === "all");
+ state.category === "all");
if (display) {
$integration.css("display", "inline-block");
@@ -137,7 +140,8 @@ function hide_catalog_show_integration() {
const $lozenge_icon = $(".integration-lozenge.integration-" + state.integration).clone(false);
$lozenge_icon.removeClass("legacy");
- const categories = $(".integration-" + state.integration).data("categories")
+ const categories = $(".integration-" + state.integration)
+ .data("categories")
.slice(1, -1)
.split(",")
.map((category) => category.trim().slice(1, -1));
@@ -155,9 +159,7 @@ function hide_catalog_show_integration() {
const category_el = $("<a></a>")
.attr("href", "/integrations/" + link)
.append('<h3 class="integration-category"></h3>');
- category_el.find(".integration-category")
- .attr("data-category", link)
- .text(category);
+ category_el.find(".integration-category").attr("data-category", link).text(category);
$("#integration-instructions-group .categories").append(category_el);
});
$("#integration-instructions-group").css({
@@ -167,19 +169,11 @@ function hide_catalog_show_integration() {
$(".integration-instructions").css("display", "none");
$("#" + state.integration + ".integration-instructions .help-content").html(doc);
$("#integration-instruction-block .integration-lozenge").remove();
- $("#integration-instruction-block")
- .append($lozenge_icon)
- .css("display", "flex");
+ $("#integration-instruction-block").append($lozenge_icon).css("display", "flex");
$(".integration-instructions#" + state.integration).css("display", "block");
- $("html, body").animate(
- {scrollTop: 0},
- {duration: 200},
- );
- $("#integration-instructions-group").animate(
- {opacity: 1},
- {duration: 300},
- );
+ $("html, body").animate({scrollTop: 0}, {duration: 200});
+ $("#integration-instructions-group").animate({opacity: 1}, {duration: 300});
adjust_font_sizing();
}
@@ -198,17 +192,17 @@ function hide_catalog_show_integration() {
dataType: "html",
success: hide_catalog,
error: function (err) {
- blueslip.error("Integration documentation for '" + state.integration + "' not found.", err);
+ blueslip.error(
+ "Integration documentation for '" + state.integration + "' not found.",
+ err,
+ );
},
});
}
function hide_integration_show_catalog() {
function show_catalog() {
- $("html, body").animate(
- {scrollTop: 0},
- {duration: 200},
- );
+ $("html, body").animate({scrollTop: 0}, {duration: 200});
$(".integration-categories-dropdown").css("display", "");
$(".integrations .catalog").removeClass("hide");
@@ -245,8 +239,7 @@ function render(next_state) {
const previous_state = Object.assign({}, state);
state = next_state;
- if (previous_state.integration !== next_state.integration &&
- next_state.integration !== null) {
+ if (previous_state.integration !== next_state.integration && next_state.integration !== null) {
hide_catalog_show_integration();
} else {
if (previous_state.integration !== next_state.integration) {
@@ -264,44 +257,53 @@ function render(next_state) {
$(".main").css("visibility", "visible");
}
-
}
function dispatch(action, payload) {
switch (action) {
case "CHANGE_CATEGORY":
- render(Object.assign({}, state, {
- category: payload.category,
- }));
+ render(
+ Object.assign({}, state, {
+ category: payload.category,
+ }),
+ );
update_path();
break;
case "SHOW_INTEGRATION":
- render(Object.assign({}, state, {
- integration: payload.integration,
- }));
+ render(
+ Object.assign({}, state, {
+ integration: payload.integration,
+ }),
+ );
update_path();
break;
case "HIDE_INTEGRATION":
- render(Object.assign({}, state, {
- integration: null,
- }));
+ render(
+ Object.assign({}, state, {
+ integration: null,
+ }),
+ );
update_path();
break;
case "SHOW_CATEGORY":
- render(Object.assign({}, state, {
- integration: null,
- category: payload.category,
- }));
+ render(
+ Object.assign({}, state, {
+ integration: null,
+ category: payload.category,
+ }),
+ );
update_path();
break;
case "UPDATE_QUERY":
- render(Object.assign({}, state, {
- query: payload.query,
- }));
+ render(
+ Object.assign({}, state, {
+ query: payload.query,
+ }),
+ );
break;
case "LOAD_PATH":
diff --git a/static/js/portico/integrations_dev_panel.js b/static/js/portico/integrations_dev_panel.js
index 1a836973010..419b902761d 100644
--- a/static/js/portico/integrations_dev_panel.js
+++ b/static/js/portico/integrations_dev_panel.js
@@ -13,12 +13,24 @@ const clear_handlers = {
topic_name: "#topic_name",
URL: "#URL",
results_notice: "#results_notice",
- bot_name: function () { $("#bot_name").children()[0].selected = true; },
- integration_name: function () { $("#integration_name").children()[0].selected = true; },
- fixture_name: function () { $("#fixture_name").empty(); },
- fixture_body: function () { $("#fixture_body")[0].value = ""; },
- custom_http_headers: function () { $("#custom_http_headers")[0].value = "{}"; },
- results: function () { $("#idp-results")[0].value = ""; },
+ bot_name: function () {
+ $("#bot_name").children()[0].selected = true;
+ },
+ integration_name: function () {
+ $("#integration_name").children()[0].selected = true;
+ },
+ fixture_name: function () {
+ $("#fixture_name").empty();
+ },
+ fixture_body: function () {
+ $("#fixture_body")[0].value = "";
+ },
+ custom_http_headers: function () {
+ $("#custom_http_headers")[0].value = "{}";
+ },
+ results: function () {
+ $("#idp-results")[0].value = "";
+ },
};
function clear_elements(elements) {
@@ -189,7 +201,13 @@ function get_fixtures(integration_name) {
/* Request fixtures from the backend for any integrations that we
don't already have fixtures cached in loaded_fixtures). */
if (integration_name === "") {
- clear_elements(["custom_http_headers", "fixture_body", "fixture_name", "URL", "results_notice"]);
+ clear_elements([
+ "custom_http_headers",
+ "fixture_body",
+ "fixture_name",
+ "URL",
+ "results_notice",
+ ]);
return;
}
@@ -253,7 +271,9 @@ function send_webhook_fixture_message() {
channel.post({
url: "/devtools/integrations/check_send_webhook_fixture_message",
data: {url: url, body: body, custom_headers: custom_headers, is_json: is_json},
- beforeSend: function (xhr) {xhr.setRequestHeader("X-CSRFToken", csrftoken);},
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader("X-CSRFToken", csrftoken);
+ },
success: function (response) {
// If the previous fixture body was sent successfully,
// then we should change the success message up a bit to
@@ -286,8 +306,12 @@ function send_all_fixture_messages() {
channel.post({
url: "/devtools/integrations/send_all_webhook_fixture_messages",
data: {url: url, integration_name: integration},
- beforeSend: function (xhr) {xhr.setRequestHeader("X-CSRFToken", csrftoken);},
- success: function (response) {set_results(response);},
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader("X-CSRFToken", csrftoken);
+ },
+ success: function (response) {
+ set_results(response);
+ },
error: handle_unsuccessful_response,
});
@@ -296,9 +320,18 @@ function send_all_fixture_messages() {
// Initialization
$(() => {
- clear_elements(["stream_name", "topic_name", "URL", "bot_name", "integration_name",
- "fixture_name", "custom_http_headers", "fixture_body", "results_notice",
- "results"]);
+ clear_elements([
+ "stream_name",
+ "topic_name",
+ "URL",
+ "bot_name",
+ "integration_name",
+ "fixture_name",
+ "custom_http_headers",
+ "fixture_body",
+ "results_notice",
+ "results",
+ ]);
$("#stream_name")[0].value = "Denmark";
$("#topic_name")[0].value = "Integrations Testing";
@@ -339,5 +372,4 @@ $(() => {
$("#stream_name").change(update_url);
$("#topic_name").change(update_url);
-
});
diff --git a/static/js/portico/landing-page.js b/static/js/portico/landing-page.js
index 5d34b8e8e2f..a26aa2f1ac0 100644
--- a/static/js/portico/landing-page.js
+++ b/static/js/portico/landing-page.js
@@ -10,7 +10,10 @@ const hello_events = function () {
let counter = 0;
$(window).scroll(function () {
if (counter % 2 === 0) {
- $(".screen.hero-screen .message-feed").css("transform", "translateY(-" + $(this).scrollTop() / 5 + "px)");
+ $(".screen.hero-screen .message-feed").css(
+ "transform",
+ "translateY(-" + $(this).scrollTop() / 5 + "px)",
+ );
}
counter += 1;
});
@@ -20,15 +23,31 @@ const hello_events = function () {
const apps_events = function () {
const ELECTRON_APP_VERSION = page_params.electron_app_version;
- const ELECTRON_APP_URL_LINUX = "https://github.com/zulip/zulip-desktop/releases/download/v" + ELECTRON_APP_VERSION + "/Zulip-" + ELECTRON_APP_VERSION + "-x86_64.AppImage";
- const ELECTRON_APP_URL_MAC = "https://github.com/zulip/zulip-desktop/releases/download/v" + ELECTRON_APP_VERSION + "/Zulip-" + ELECTRON_APP_VERSION + ".dmg";
- const ELECTRON_APP_URL_WINDOWS = "https://github.com/zulip/zulip-desktop/releases/download/v" + ELECTRON_APP_VERSION + "/Zulip-Web-Setup-" + ELECTRON_APP_VERSION + ".exe";
+ const ELECTRON_APP_URL_LINUX =
+ "https://github.com/zulip/zulip-desktop/releases/download/v" +
+ ELECTRON_APP_VERSION +
+ "/Zulip-" +
+ ELECTRON_APP_VERSION +
+ "-x86_64.AppImage";
+ const ELECTRON_APP_URL_MAC =
+ "https://github.com/zulip/zulip-desktop/releases/download/v" +
+ ELECTRON_APP_VERSION +
+ "/Zulip-" +
+ ELECTRON_APP_VERSION +
+ ".dmg";
+ const ELECTRON_APP_URL_WINDOWS =
+ "https://github.com/zulip/zulip-desktop/releases/download/v" +
+ ELECTRON_APP_VERSION +
+ "/Zulip-Web-Setup-" +
+ ELECTRON_APP_VERSION +
+ ".exe";
const info = {
windows: {
image: "/static/images/landing-page/microsoft.png",
alt: "Windows",
- description: "Zulip for Windows is even better than Zulip on the web, with a cleaner look, tray integration, native notifications, and support for multiple Zulip accounts.",
+ description:
+ "Zulip for Windows is even better than Zulip on the web, with a cleaner look, tray integration, native notifications, and support for multiple Zulip accounts.",
link: ELECTRON_APP_URL_WINDOWS,
show_instructions: true,
install_guide: "/help/desktop-app-install-guide",
@@ -37,7 +56,8 @@ const apps_events = function () {
mac: {
image: "/static/images/landing-page/macbook.png",
alt: "macOS",
- description: "Zulip on macOS is even better than Zulip on the web, with a cleaner look, tray integration, native notifications, and support for multiple Zulip accounts.",
+ description:
+ "Zulip on macOS is even better than Zulip on the web, with a cleaner look, tray integration, native notifications, and support for multiple Zulip accounts.",
link: ELECTRON_APP_URL_MAC,
show_instructions: true,
install_guide: "/help/desktop-app-install-guide",
@@ -62,7 +82,8 @@ const apps_events = function () {
linux: {
image: "/static/images/landing-page/ubuntu.png",
alt: "Linux",
- description: "Zulip on the Linux desktop is even better than Zulip on the web, with a cleaner look, tray integration, native notifications, and support for multiple Zulip accounts.",
+ description:
+ "Zulip on the Linux desktop is even better than Zulip on the web, with a cleaner look, tray integration, native notifications, and support for multiple Zulip accounts.",
link: ELECTRON_APP_URL_LINUX,
show_instructions: true,
install_guide: "/help/desktop-app-install-guide",
@@ -129,9 +150,7 @@ const apps_events = function () {
});
$(".apps a .icon").click((e) => {
- const next_version = $(e.target).closest("a")
- .attr("href")
- .replace("/apps/", "");
+ const next_version = $(e.target).closest("a").attr("href").replace("/apps/", "");
version = next_version;
update_path();
@@ -182,10 +201,8 @@ const events = function () {
}
};
-
// run this callback when the page is determined to have loaded.
const load = function () {
-
// Initiate the bootstrap carousel logic
$(".carousel").carousel({
interval: false,
@@ -196,7 +213,9 @@ const load = function () {
const get_tag_name = e.target.tagName.toLowerCase();
const is_button = get_tag_name === "button";
const is_link = get_tag_name === "a";
- const is_last_slide = $("#tour-carousel .carousel-inner .item:last-child").hasClass("active");
+ const is_last_slide = $("#tour-carousel .carousel-inner .item:last-child").hasClass(
+ "active",
+ );
// Do not trigger this event if user clicks on a button, link
// or if it's the last slide
diff --git a/static/js/portico/signup.js b/static/js/portico/signup.js
index 4b8a191a1c2..8126b2ec049 100644
--- a/static/js/portico/signup.js
+++ b/static/js/portico/signup.js
@@ -4,7 +4,11 @@ $(() => {
const password_field = $("#id_password, #id_new_password1");
if (password_field.length > 0) {
- $.validator.addMethod("password_strength", (value) => common.password_quality(value, undefined, password_field), () => common.password_warning(password_field.val(), password_field));
+ $.validator.addMethod(
+ "password_strength",
+ (value) => common.password_quality(value, undefined, password_field),
+ () => common.password_warning(password_field.val(), password_field),
+ );
// Reset the state of the password strength bar if the page
// was just reloaded due to a validation failure on the backend.
common.password_quality(password_field.val(), $("#pw_strength .bar"), password_field);
@@ -19,7 +23,8 @@ $(() => {
function highlight(class_to_add) {
// Set a class on the enclosing control group.
return function (element) {
- $(element).closest(".control-group")
+ $(element)
+ .closest(".control-group")
.removeClass("success error")
.addClass(class_to_add);
};
@@ -53,9 +58,13 @@ $(() => {
const firstInputElement = $("input:not(:hidden, :disabled)").first();
// Focus on the first input field in the form.
common.autofocus(firstInputElement);
- } else { // If input field with errors is present.
+ } else {
+ // If input field with errors is present.
// Find the input field having errors and stores it in a variable.
- const inputElementWithError = $(".help-inline:not(:empty)").first().parent().find("input");
+ const inputElementWithError = $(".help-inline:not(:empty)")
+ .first()
+ .parent()
+ .find("input");
// Focus on the input field having errors.
common.autofocus(inputElementWithError);
}
@@ -110,7 +119,9 @@ $(() => {
},
});
- $(".register-page #email, .login-page-container #id_username").on("focusout keydown", function (e) {
+ $(".register-page #email, .login-page-container #id_username").on("focusout keydown", function (
+ e,
+ ) {
// check if it is the "focusout" or if it is a keydown, then check if
// the keycode was the one for "enter" (13).
if (e.type === "focusout" || e.which === 13) {
@@ -160,7 +171,10 @@ $(() => {
}
function update_full_name_section() {
- if ($("#source_realm_select").length && $("#source_realm_select").find(":selected").val() !== "on") {
+ if (
+ $("#source_realm_select").length &&
+ $("#source_realm_select").find(":selected").val() !== "on"
+ ) {
$("#full_name_input_section").hide();
$("#profile_info_section").show();
const avatar_url = $("#source_realm_select").find(":selected").attr("data-avatar");
diff --git a/static/js/portico/team.js b/static/js/portico/team.js
index 5c83cbae328..146a505eec5 100644
--- a/static/js/portico/team.js
+++ b/static/js/portico/team.js
@@ -2,7 +2,15 @@ const contributors_list = page_params.contrib;
// `repos` are repositories to be shown as tabs, whereas `hidden_repos` are
// repositories that should count towards the total but not have tabs.
-const repos = ["server", "desktop", "mobile", "python-zulip-api", "zulip-js", "zulipbot", "terminal"];
+const repos = [
+ "server",
+ "desktop",
+ "mobile",
+ "python-zulip-api",
+ "zulip-js",
+ "zulipbot",
+ "terminal",
+];
const hidden_repos = ["zulip-android", "zulip-ios-legacy"];
// Remember the loaded repositories so that HTML is not redundantly edited
@@ -56,11 +64,13 @@ export default function render_tabs() {
.filter(repo)
.sortBy(repo)
.reverse()
- .map((c) => template({
- name: c.name,
- avatar: c.avatar,
- commits: c[repo],
- }))
+ .map((c) =>
+ template({
+ name: c.name,
+ avatar: c.avatar,
+ commits: c[repo],
+ }),
+ )
.value()
.join("");
diff --git a/static/js/reactions.js b/static/js/reactions.js
index 5d8de48e478..962fbc0e24e 100644
--- a/static/js/reactions.js
+++ b/static/js/reactions.js
@@ -3,10 +3,7 @@ const render_message_reaction = require("../templates/message_reaction.hbs");
exports.view = {}; // function namespace
exports.get_local_reaction_id = function (reaction_info) {
- return [
- reaction_info.reaction_type,
- reaction_info.emoji_code,
- ].join(",");
+ return [reaction_info.reaction_type, reaction_info.emoji_code].join(",");
};
exports.open_reactions_popover = function () {
@@ -51,10 +48,7 @@ function create_reaction(message_id, reaction_info) {
function update_ui_and_send_reaction_ajax(message_id, reaction_info) {
const message = get_message(message_id);
const local_id = exports.get_local_reaction_id(reaction_info);
- const has_reacted = exports.current_user_has_reacted_to_emoji(
- message,
- local_id,
- );
+ const has_reacted = exports.current_user_has_reacted_to_emoji(message, local_id);
const operation = has_reacted ? "remove" : "add";
const reaction = create_reaction(message_id, reaction_info);
@@ -127,8 +121,8 @@ exports.process_reaction_click = function (message_id, local_id) {
if (!r) {
blueslip.error(
- "Data integrity problem for reaction " + local_id +
- " (message " + message_id + ")");
+ "Data integrity problem for reaction " + local_id + " (message " + message_id + ")",
+ );
return;
}
@@ -361,7 +355,6 @@ exports.remove_reaction = function (event) {
};
exports.view.remove_reaction = function (opts) {
-
const message_id = opts.message_id;
const emoji_name = opts.emoji_name;
const user_list = opts.user_list;
@@ -438,8 +431,7 @@ exports.set_clean_reactions = function (message) {
const user_id = reaction.user_id;
if (!people.is_known_user_id(user_id)) {
- blueslip.warn("Unknown user_id " + user_id +
- " in reaction for message " + message.id);
+ blueslip.warn("Unknown user_id " + user_id + " in reaction for message " + message.id);
continue;
}
@@ -451,8 +443,9 @@ exports.set_clean_reactions = function (message) {
const user_ids = user_map.get(local_id);
if (user_ids.includes(user_id)) {
- blueslip.error("server sent duplicate reactions for user " +
- user_id + " (key=" + local_id + ")");
+ blueslip.error(
+ "server sent duplicate reactions for user " + user_id + " (key=" + local_id + ")",
+ );
continue;
}
diff --git a/static/js/realm_logo.js b/static/js/realm_logo.js
index 71d17b94a5d..10576c8adf8 100644
--- a/static/js/realm_logo.js
+++ b/static/js/realm_logo.js
@@ -63,8 +63,7 @@ exports.rerender = function () {
const night_file_input = $("#realm-night-logo-upload-widget .realm-logo-file-input");
$("#realm-day-logo-upload-widget .image-block").attr("src", page_params.realm_logo_url);
- if (page_params.realm_night_logo_source === "D" &&
- page_params.realm_logo_source !== "D") {
+ if (page_params.realm_night_logo_source === "D" && page_params.realm_logo_source !== "D") {
// If no night mode logo is uploaded but a day mode one
// is, use the day mode one; this handles the common case
// of transparent background logos that look good on both
@@ -72,25 +71,35 @@ exports.rerender = function () {
$("#realm-night-logo-upload-widget .image-block").attr("src", page_params.realm_logo_url);
} else {
- $("#realm-night-logo-upload-widget .image-block").attr("src", page_params.realm_night_logo_url);
+ $("#realm-night-logo-upload-widget .image-block").attr(
+ "src",
+ page_params.realm_night_logo_url,
+ );
}
- if (page_params.color_scheme === settings_config.color_scheme_values.night.code &&
- page_params.realm_night_logo_source !== "D" ||
- page_params.color_scheme === settings_config.color_scheme_values.automatic.code &&
- page_params.realm_night_logo_source !== "D" &&
- (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches)) {
+ if (
+ (page_params.color_scheme === settings_config.color_scheme_values.night.code &&
+ page_params.realm_night_logo_source !== "D") ||
+ (page_params.color_scheme === settings_config.color_scheme_values.automatic.code &&
+ page_params.realm_night_logo_source !== "D" &&
+ window.matchMedia &&
+ window.matchMedia("(prefers-color-scheme: dark)").matches)
+ ) {
$("#realm-logo").attr("src", page_params.realm_night_logo_url);
} else {
$("#realm-logo").attr("src", page_params.realm_logo_url);
}
- change_logo_delete_button(page_params.realm_logo_source,
- $("#realm-day-logo-upload-widget .settings-page-delete-button"),
- file_input);
- change_logo_delete_button(page_params.realm_night_logo_source,
- $("#realm-night-logo-upload-widget .settings-page-delete-button"),
- night_file_input);
+ change_logo_delete_button(
+ page_params.realm_logo_source,
+ $("#realm-day-logo-upload-widget .settings-page-delete-button"),
+ file_input,
+ );
+ change_logo_delete_button(
+ page_params.realm_night_logo_source,
+ $("#realm-night-logo-upload-widget .settings-page-delete-button"),
+ night_file_input,
+ );
};
window.realm_logo = exports;
diff --git a/static/js/recent_senders.js b/static/js/recent_senders.js
index 92a005481d1..f55e794044b 100644
--- a/static/js/recent_senders.js
+++ b/static/js/recent_senders.js
@@ -133,9 +133,7 @@ exports.get_topic_recent_senders = function (stream_id, topic) {
return [];
}
- const sorted_senders = Array.from(sender_message_ids.entries()).sort(
- (s1, s2) => s1[1] - s2[1],
- );
+ const sorted_senders = Array.from(sender_message_ids.entries()).sort((s1, s2) => s1[1] - s2[1]);
const recent_senders = [];
for (const item of sorted_senders) {
recent_senders.push(item[0]);
diff --git a/static/js/recent_topics.js b/static/js/recent_topics.js
index 593ceff0829..710ff00b761 100644
--- a/static/js/recent_topics.js
+++ b/static/js/recent_topics.js
@@ -69,7 +69,9 @@ function revive_current_focus() {
if (!filter_button) {
set_default_focus();
} else {
- current_focus_elem = $("#recent_topics_filter_buttons").find("[data-filter='" + filter_button + "']");
+ current_focus_elem = $("#recent_topics_filter_buttons").find(
+ "[data-filter='" + filter_button + "']",
+ );
current_focus_elem.focus();
}
return true;
@@ -148,7 +150,6 @@ exports.get = function () {
return get_sorted_topics();
};
-
function format_topic(topic_data) {
const last_msg = message_store.get(topic_data.last_msg_id);
const stream = last_msg.stream;
@@ -331,16 +332,15 @@ exports.set_filter = function (filter) {
// set `filters`.
// Get the button which was clicked.
- const filter_elem = $("#recent_topics_filter_buttons")
- .find('[data-filter="' + filter + '"]');
+ const filter_elem = $("#recent_topics_filter_buttons").find('[data-filter="' + filter + '"]');
// If user clicks `All`, we clear all filters.
if (filter === "all" && filters.size !== 0) {
filters = new Set();
- // If the button was already selected, remove the filter.
+ // If the button was already selected, remove the filter.
} else if (filter_elem.hasClass("btn-recent-selected")) {
filters.delete(filter);
- // If the button was not selected, we add the filter.
+ // If the button was not selected, we add the filter.
} else {
filters.add(filter);
}
@@ -504,12 +504,12 @@ exports.change_focused_element = function (e, input_key) {
set_table_focus(row_focus, col_focus);
return true;
case "click":
- // Note: current_focus_elem can be different here, so we just
- // set current_focus_elem to the input box, we don't want .focus() on
- // it since it is already focused.
- // We only do this for search beacuse we don't want the focus to
- // go away from the input box when `revive_current_focus` is called
- // on rerender when user is typing.
+ // Note: current_focus_elem can be different here, so we just
+ // set current_focus_elem to the input box, we don't want .focus() on
+ // it since it is already focused.
+ // We only do this for search beacuse we don't want the focus to
+ // go away from the input box when `revive_current_focus` is called
+ // on rerender when user is typing.
current_focus_elem = $("#recent_topics_search");
return true;
}
diff --git a/static/js/reload.js b/static/js/reload.js
index 7ddea92a40c..62567557b3d 100644
--- a/static/js/reload.js
+++ b/static/js/reload.js
@@ -87,7 +87,6 @@ function preserve_state(send_after_reload, save_pointer, save_narrow, save_compo
window.location.replace("#reload:" + token);
}
-
// Check if we're doing a compose-preserving reload. This must be
// done before the first call to get_events
exports.initialize = function () {
@@ -131,10 +130,12 @@ exports.initialize = function () {
// TODO: preserve focus
const topic = util.get_reload_topic(vars);
- compose_actions.start(vars.msg_type, {stream: vars.stream || "",
- topic: topic || "",
- private_message_recipient: vars.recipient || "",
- content: vars.msg || ""});
+ compose_actions.start(vars.msg_type, {
+ stream: vars.stream || "",
+ topic: topic || "",
+ private_message_recipient: vars.recipient || "",
+ content: vars.msg || "",
+ });
if (send_now) {
compose.finish();
}
@@ -179,8 +180,7 @@ function do_reload_app(send_after_reload, save_pointer, save_narrow, save_compos
try {
preserve_state(send_after_reload, save_pointer, save_narrow, save_compose);
} catch (ex) {
- blueslip.error("Failed to preserve state",
- undefined, ex.stack);
+ blueslip.error("Failed to preserve state", undefined, ex.stack);
}
}
@@ -211,8 +211,7 @@ function do_reload_app(send_after_reload, save_pointer, save_narrow, save_compos
try {
server_events.cleanup_event_queue();
} catch (ex) {
- blueslip.error("Failed to cleanup before reloading",
- undefined, ex.stack);
+ blueslip.error("Failed to cleanup before reloading", undefined, ex.stack);
}
window.location.reload(true);
@@ -228,18 +227,22 @@ exports.initiate = function (options) {
...options,
};
- if (options.save_pointer === undefined ||
+ if (
+ options.save_pointer === undefined ||
options.save_narrow === undefined ||
- options.save_compose === undefined) {
+ options.save_compose === undefined
+ ) {
blueslip.error("reload.initiate() called without explicit save options.");
}
if (options.immediate) {
- do_reload_app(options.send_after_reload,
- options.save_pointer,
- options.save_narrow,
- options.save_compose,
- options.message);
+ do_reload_app(
+ options.send_after_reload,
+ options.save_pointer,
+ options.save_narrow,
+ options.save_compose,
+ options.message,
+ );
}
if (reload_state.is_pending()) {
@@ -276,11 +279,13 @@ exports.initiate = function (options) {
let compose_started_handler;
function reload_from_idle() {
- do_reload_app(false,
- options.save_pointer,
- options.save_narrow,
- options.save_compose,
- options.message);
+ do_reload_app(
+ false,
+ options.save_pointer,
+ options.save_narrow,
+ options.save_compose,
+ options.message,
+ );
}
// Make sure we always do a reload eventually after
@@ -293,31 +298,24 @@ exports.initiate = function (options) {
// If the user sends their message or otherwise closes
// compose, we return them to the not-composing timeouts.
idle_control.cancel();
- idle_control = $(document).idle({idle: basic_idle_timeout,
- onIdle: reload_from_idle});
- $(document).off("compose_canceled.zulip compose_finished.zulip",
- compose_done_handler);
+ idle_control = $(document).idle({idle: basic_idle_timeout, onIdle: reload_from_idle});
+ $(document).off("compose_canceled.zulip compose_finished.zulip", compose_done_handler);
$(document).on("compose_started.zulip", compose_started_handler);
};
compose_started_handler = function () {
// If the user stops being idle and starts composing a
// message, switch to the compose-open timeouts.
idle_control.cancel();
- idle_control = $(document).idle({idle: composing_idle_timeout,
- onIdle: reload_from_idle});
+ idle_control = $(document).idle({idle: composing_idle_timeout, onIdle: reload_from_idle});
$(document).off("compose_started.zulip", compose_started_handler);
- $(document).on("compose_canceled.zulip compose_finished.zulip",
- compose_done_handler);
+ $(document).on("compose_canceled.zulip compose_finished.zulip", compose_done_handler);
};
if (compose_state.composing()) {
- idle_control = $(document).idle({idle: composing_idle_timeout,
- onIdle: reload_from_idle});
- $(document).on("compose_canceled.zulip compose_finished.zulip",
- compose_done_handler);
+ idle_control = $(document).idle({idle: composing_idle_timeout, onIdle: reload_from_idle});
+ $(document).on("compose_canceled.zulip compose_finished.zulip", compose_done_handler);
} else {
- idle_control = $(document).idle({idle: basic_idle_timeout,
- onIdle: reload_from_idle});
+ idle_control = $(document).idle({idle: basic_idle_timeout, onIdle: reload_from_idle});
$(document).on("compose_started.zulip", compose_started_handler);
}
};
@@ -332,5 +330,4 @@ window.addEventListener("beforeunload", () => {
reload_state.set_state_to_in_progress();
});
-
window.reload = exports;
diff --git a/static/js/reload_state.js b/static/js/reload_state.js
index c0871993e87..33ce867228a 100644
--- a/static/js/reload_state.js
+++ b/static/js/reload_state.js
@@ -29,5 +29,4 @@ exports.set_state_to_in_progress = function () {
reload_in_progress = true;
};
-
window.reload_state = exports;
diff --git a/static/js/reminder.js b/static/js/reminder.js
index 1b38cf65419..6a19af89fc5 100644
--- a/static/js/reminder.js
+++ b/static/js/reminder.js
@@ -17,8 +17,7 @@ exports.deferred_message_types = deferred_message_types;
exports.is_deferred_delivery = function (message_content) {
const reminders_test = deferred_message_types.reminders.test;
const scheduled_test = deferred_message_types.scheduled.test;
- return reminders_test.test(message_content) ||
- scheduled_test.test(message_content);
+ return reminders_test.test(message_content) || scheduled_test.test(message_content);
};
function patch_request_for_scheduling(request, message_content, deliver_at, delivery_type) {
@@ -52,12 +51,19 @@ exports.schedule_message = function (request) {
const deliver_at = command_line.slice(command.length + 1);
- if (message.trim() === "" || deliver_at.trim() === "" ||
- command_line.slice(command.length, command.length + 1) !== " ") {
-
+ if (
+ message.trim() === "" ||
+ deliver_at.trim() === "" ||
+ command_line.slice(command.length, command.length + 1) !== " "
+ ) {
$("#compose-textarea").attr("disabled", false);
if (command_line.slice(command.length, command.length + 1) !== " ") {
- compose.compose_error(i18n.t("Invalid slash command. Check if you are missing a space after the command."), $("#compose-textarea"));
+ compose.compose_error(
+ i18n.t(
+ "Invalid slash command. Check if you are missing a space after the command.",
+ ),
+ $("#compose-textarea"),
+ );
} else if (deliver_at.trim() === "") {
compose.compose_error(i18n.t("Please specify a date or time"), $("#compose-textarea"));
} else {
@@ -67,12 +73,17 @@ exports.schedule_message = function (request) {
}
request = patch_request_for_scheduling(
- request, message, deliver_at, deferred_message_type.delivery_type,
+ request,
+ message,
+ deliver_at,
+ deferred_message_type.delivery_type,
);
const success = function (data) {
if (request.delivery_type === deferred_message_types.scheduled.delivery_type) {
- notifications.notify_above_composebox("Scheduled your Message to be delivered at: " + data.deliver_at);
+ notifications.notify_above_composebox(
+ "Scheduled your Message to be delivered at: " + data.deliver_at,
+ );
}
$("#compose-textarea").attr("disabled", false);
compose.clear_compose_box();
@@ -95,7 +106,8 @@ exports.do_set_reminder_for_message = function (message_id, timestamp) {
.text(i18n.t("Reminder not set!"))
.css("display", "block")
.css("color", "#b94a48")
- .delay(1000).fadeOut(300, function () {
+ .delay(1000)
+ .fadeOut(300, function () {
$(this).css("color", "");
});
}
@@ -119,7 +131,8 @@ exports.do_set_reminder_for_message = function (message_id, timestamp) {
}
const link_to_msg = hash_util.by_conversation_and_time_uri(message);
- const reminder_msg_content = message.raw_content + "\n\n[Link to conversation](" + link_to_msg + ")";
+ const reminder_msg_content =
+ message.raw_content + "\n\n[Link to conversation](" + link_to_msg + ")";
let reminder_message = {
type: "private",
sender_id: page_params.user_id,
@@ -138,11 +151,14 @@ exports.do_set_reminder_for_message = function (message_id, timestamp) {
row.find(".alert-msg")
.text(i18n.t("Reminder set!"))
.css("display", "block")
- .delay(1000).fadeOut(300);
+ .delay(1000)
+ .fadeOut(300);
}
reminder_message = patch_request_for_scheduling(
- reminder_message, reminder_msg_content, timestamp,
+ reminder_message,
+ reminder_msg_content,
+ timestamp,
deferred_message_types.reminders.delivery_type,
);
transmit.send_message(reminder_message, success, error);
diff --git a/static/js/rendered_markdown.js b/static/js/rendered_markdown.js
index ed68572cd64..2f7eb157dbc 100644
--- a/static/js/rendered_markdown.js
+++ b/static/js/rendered_markdown.js
@@ -176,11 +176,11 @@ exports.update_elements = (content) => {
}
// Add the expand/collapse button to spoiler blocks
- const toggle_button_html = '<span class="spoiler-button" aria-expanded="false"><span class="spoiler-arrow"></span></span>';
+ const toggle_button_html =
+ '<span class="spoiler-button" aria-expanded="false"><span class="spoiler-arrow"></span></span>';
$(this).prepend(toggle_button_html);
});
-
// Display emoji (including realm emoji) as text if
// page_params.emojiset is 'text'.
if (page_params.emojiset === "text") {
diff --git a/static/js/resize.js b/static/js/resize.js
index ab0295bf247..8204ff8210c 100644
--- a/static/js/resize.js
+++ b/static/js/resize.js
@@ -37,24 +37,26 @@ function get_new_heights() {
res.main_div_min_height = viewport_height - top_navbar_height;
- 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)
- - $("#global_filters").safeOuterHeight(true)
- - $("#streams_header").safeOuterHeight(true);
+ 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) -
+ $("#global_filters").safeOuterHeight(true) -
+ $("#streams_header").safeOuterHeight(true);
// Don't let us crush the stream sidebar completely out of view
res.stream_filters_max_height = Math.max(80, res.stream_filters_max_height);
// RIGHT SIDEBAR
- const usable_height = viewport_height
- - parseInt($("#right-sidebar").css("marginTop"), 10)
- - $("#userlist-header").safeOuterHeight(true)
- - $("#user_search_section").safeOuterHeight(true)
- - invite_user_link_height
- - $("#sidebar-keyboard-shortcuts").safeOuterHeight(true);
+ const usable_height =
+ viewport_height -
+ parseInt($("#right-sidebar").css("marginTop"), 10) -
+ $("#userlist-header").safeOuterHeight(true) -
+ $("#user_search_section").safeOuterHeight(true) -
+ invite_user_link_height -
+ $("#sidebar-keyboard-shortcuts").safeOuterHeight(true);
res.buddy_list_wrapper_max_height = Math.max(80, usable_height);
@@ -62,7 +64,6 @@ function get_new_heights() {
}
function left_userlist_get_new_heights() {
-
const res = {};
const viewport_height = message_viewport.height();
const viewport_width = message_viewport.width();
@@ -74,7 +75,6 @@ function left_userlist_get_new_heights() {
res.bottom_whitespace_height = viewport_height * 0.4;
res.main_div_min_height = viewport_height - top_navbar_height;
-
// left sidebar
const stream_filters = $("#stream_filters").expectOne();
const buddy_list_wrapper = $("#buddy_list_wrapper").expectOne();
@@ -82,15 +82,16 @@ function left_userlist_get_new_heights() {
const stream_filters_real_height = stream_filters.prop("scrollHeight");
const user_list_real_height = ui.get_scroll_element(buddy_list_wrapper).prop("scrollHeight");
- res.total_leftlist_height = viewport_height
- - parseInt($("#left-sidebar").css("marginTop"), 10)
- - parseInt($(".narrows_panel").css("marginTop"), 10)
- - 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);
+ res.total_leftlist_height =
+ viewport_height -
+ parseInt($("#left-sidebar").css("marginTop"), 10) -
+ parseInt($(".narrows_panel").css("marginTop"), 10) -
+ 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);
const blocks = [
{
@@ -147,8 +148,7 @@ exports.watch_manual_resize = function (element) {
})((height) => {
// This callback disables autosize on the textarea. It
// will be re-enabled when this component is next opened.
- autosize.destroy($(element))
- .height(height + "px");
+ autosize.destroy($(element)).height(height + "px");
});
};
diff --git a/static/js/rows.js b/static/js/rows.js
index 7aec1429ed9..01b67f4c270 100644
--- a/static/js/rows.js
+++ b/static/js/rows.js
@@ -111,10 +111,7 @@ exports.local_echo_id = function (message_row) {
return zid;
};
-const valid_table_names = new Set([
- "zhome",
- "zfilt",
-]);
+const valid_table_names = new Set(["zhome", "zfilt"]);
exports.get_table = function (table_name) {
if (!valid_table_names.has(table_name)) {
@@ -153,7 +150,9 @@ exports.get_message_recipient_header = function (message_row) {
};
exports.recipient_from_group = function (message_group) {
- return message_store.get(exports.id($(message_group).children(".message_row").first().expectOne()));
+ return message_store.get(
+ exports.id($(message_group).children(".message_row").first().expectOne()),
+ );
};
exports.id_for_recipient_row = function (recipient_row) {
diff --git a/static/js/rtl.js b/static/js/rtl.js
index dbbfe6d358c..6058928b5c9 100644
--- a/static/js/rtl.js
+++ b/static/js/rtl.js
@@ -11,7 +11,6 @@ const util = require("./util");
// https://www.unicode.org/Public/9.0.0/ucd/UnicodeData.txt
// https://www.unicode.org/Public/9.0.0/ucd/extracted/DerivedBidiClass.txt
-
/**
* Splits {@link raw} into parts of length {@link part_length},
* and then converts each part to a character using simple base
@@ -23,7 +22,7 @@ const util = require("./util");
*/
function convert_from_raw(digits, part_length, raw) {
const result = [];
- for (let i = 0; i < raw.length;) {
+ for (let i = 0; i < raw.length; ) {
let t = 0;
for (let j = 0; j < part_length; j += 1) {
t = t * digits.length + digits.indexOf(raw.charAt(i));
@@ -39,7 +38,8 @@ const i_chars = [0x2066, 0x2067, 0x2068];
/** Pop directional isolate character. */
const pdi_chars = [0x2069];
/** The digits that are used for base conversions from base 92. */
-const digits = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&()*+,-./:;<=>?@[]^_`{|}~';
+const digits =
+ '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&()*+,-./:;<=>?@[]^_`{|}~';
/**
* Ranges of strong non-left-to-right characters (right-to-left, and arabic-letter).
*
@@ -47,8 +47,17 @@ const digits = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"
* character of the range, and the last character of the range.
* All ranges are concatenated together and stored here.
*/
-const rl_ranges = convert_from_raw(digits, 2, 'fIfIf}f}g0g0g3g3g6g6g8g"g,g,g/g/g;g;g~hKh?h[h^j1jhjijqjrjCjYj!j~krlplBm2mcmdmimJmOmOmYmYm#m#m*nknooP|j|j')
- .concat(convert_from_raw(digits, 3, '7S)7S)7S+7S>7S@7YZ7Y#7!n7!U7!(7!*7!+7#07$O7}U81%81(84g84k84k84n84r84w84+84/84<84>86Y86"87Q87Y8gv8g"8k=e)]e,fe,ne-De-Le|je|mf0f'));
+const rl_ranges = convert_from_raw(
+ digits,
+ 2,
+ 'fIfIf}f}g0g0g3g3g6g6g8g"g,g,g/g/g;g;g~hKh?h[h^j1jhjijqjrjCjYj!j~krlplBm2mcmdmimJmOmOmYmYm#m#m*nknooP|j|j',
+).concat(
+ convert_from_raw(
+ digits,
+ 3,
+ '7S)7S)7S+7S>7S@7YZ7Y#7!n7!U7!(7!*7!+7#07$O7}U81%81(84g84k84k84n84r84w84+84/84<84>86Y86"87Q87Y8gv8g"8k=e)]e,fe,ne-De-Le|je|mf0f',
+ ),
+);
/**
* Ranges of strong left-to-right characters.
*
@@ -56,9 +65,18 @@ const rl_ranges = convert_from_raw(digits, 2, 'fIfIf}f}g0g0g3g3g6g6g8g"g,g,g/g/g
* character of the range, and the last character of the range.
* All ranges are concatenated together and stored here.
*/
-const lr_ranges = convert_from_raw(digits, 2, '0$0}151u1<1<1|1|2222282u2w2!2#7Q7T7Z7:7;80848e8e9Q9T9W9$9&9+9.9.9:b1b3cOcWfBfDfEp7pZp"p"p$p(p;p>p@p]q0q9qcqEqGr7r9rcrhrorqrJrMrZr#r*r,r:r=sHsJsMsPsSsVsWs!s#s%t3t6t8tatktnt=t?t]t}t}u1u4u6upusuEuGuUuWvnvpvqvsvsvxvEvGvNvPvZv#w1w3w"w$w:w<xmxvxzxBy5y9ydyhyhymysyvyFyIy"y+y,y.zDzFzTzWz;z>AgAiA>A^B0B2BlBoCxCzCFCJCJCLDIDKDLDTDWDYD%D/E>E@E[E}E}F1FbFiF~G2GsGuGuGwGwGCG{HbHbHhHhHkHoHAHAH-H?H[J0J5J5JcJcJfJgJjJHJKJNJRJ(J-J^J`J{J~K4K6KkKmR>R]SDSOTXTZ!T!V!@!^#h#l#N#R#?#]$l$o$`$}$}%6%d%f%g%s%y%A%A%C%T%%%+%`(k(n(U(W)[)`)}*1*9*b*g*k*n*p*r*u+|,w,S,V,W,Y-p-r-r-z-z-B-B-D-E-N-S-$-%-(.n.D/b/g/"/$/$/+/+/-/;/=:q:A:L:O:?:_:`:}:};2;V;X;X;!;#;%;%;*<z<I<J<M>f>j>j>x>x>F>I>K>P>R>T>W@+[y[C[I{s{u{u{y{I{M{Y{#{:{>|0|3|3|i|i}p}r}D}D}T}+~Z~/~<~<~[~[')
- .concat(convert_from_raw(digits, 3, '0~_10310510510910d10k10k10m10m10o10o10q10t10v10F10I10L10R10V10!10"10>11s11w11z15}16%17117118f18f18T18=18~19j19>1a$1fU1fU1js1m71s]1s^1tq1tr1t!1t#1t;1t;1t_1uj1uo1w]1w~1x21x61xc1xk1yS1yU1zX1A)1Bz1B!1B!1CY1C+1Fa1Fz1FM1FP1FV1FX1F^1G11G61G71G91Gd1Gg1Gk1Go1Hk1Hp1Hr1Ht1Iq1Is1KD1K:1LE1LH1L~1Mg1MH1ML1N41Nk1Nv1NA1Pi1Pn1Qt1Qw1Q!1Q#2wv2x44|[4}L52452853a53s53V53Y54L54O54"55656f56h57J57L57N57P57S57U57>57[57[57{58758a58&58,59T59W59[5aa5aZ5a*5b25be5bX5b"5ci5ck5cl5cq5cr5ct5c(5c*5dI5dP5dQ5dT5dU5dX5d*5d,5d=5d?5ez5eB5e`5e|5e|5f15f25f55f95fc5fc5fe5fT5fW5f$5f&5is5iu5iv5ix5iA5iC7S(7"67"b7""7""7"[7"[7"{7"~7$Q7$Q7$^7%i7%p7%O7%!7&~7(77(77(f7(f7(w7+c7+e7+/7,Z7,"7,:7,=7,?7->7-@7:v7:Y7;|7<37}T8k>8k>8k@8lH8lX8l)8l}8mm8mq8m.8m=8m>8m[8nX8n"8o68oc8oc8ol8o@8o]8p38p68pV8p&8p;8p?8q_8q}8q~8r18r18r48r98rb8s<8s>8s@8s~8tj8tm8t=8t?8t[8t^8ut8uB8uD8uJ8wT8w#8w$8w)8w)8w+8x_8y18y18y38y68y98y98yc8A$8A*8A/8A<8A<8A?8Bf8Bi8Ca8Cj8Ck8Cm8Cm8Cp8CT8C)8DC8DE8DE8DG8DH8DO8DO8DQ8EY8E#8E$8E*8E*8E:8S+8S=8S=8S_8T;8U88U98Uh8Uh8Uk8Uk8Una|[a||a}Ta}"ba*ba/dFgdFjdFjdFoe72e76e7ee7ve7we7Ee7)e7.e8"e9GebHecDemiemkem:em<enGenIeo8eoaeo%eo(eo;epAeu`evPevSewdewkewmewzewBewWew#ew#ew>eLXeL&eL&eL^eL_eM2eM2eM5eM5eMbe)[f0Yf0"f1,f1[f27f28f2of2of2Ef2Ef2<f2`f39f49f4cf8LfjffjrfjFfjHfjPfjXfk]fl3fl|fmDfmQfmTfnkfnrfnCfnHfn]fn~foufpzfpPfpPfpYfp&fp)fp*fp[fp[fq4fq7fqnfqTfq.frrfrtfIZfI#nl1nl4u|xu|AC$$C$(KG5KG8SiBSiEZ_)Z_,)"9)"c;DF;DI^f-'),
- convert_from_raw(digits, 4, "0^f:10]d10]g18YJ18YM1gA;1g?A1odh1odk1v?N1v?Q1DV?1DV]1DV]"));
+const lr_ranges = convert_from_raw(
+ digits,
+ 2,
+ '0$0}151u1<1<1|1|2222282u2w2!2#7Q7T7Z7:7;80848e8e9Q9T9W9$9&9+9.9.9:b1b3cOcWfBfDfEp7pZp"p"p$p(p;p>p@p]q0q9qcqEqGr7r9rcrhrorqrJrMrZr#r*r,r:r=sHsJsMsPsSsVsWs!s#s%t3t6t8tatktnt=t?t]t}t}u1u4u6upusuEuGuUuWvnvpvqvsvsvxvEvGvNvPvZv#w1w3w"w$w:w<xmxvxzxBy5y9ydyhyhymysyvyFyIy"y+y,y.zDzFzTzWz;z>AgAiA>A^B0B2BlBoCxCzCFCJCJCLDIDKDLDTDWDYD%D/E>E@E[E}E}F1FbFiF~G2GsGuGuGwGwGCG{HbHbHhHhHkHoHAHAH-H?H[J0J5J5JcJcJfJgJjJHJKJNJRJ(J-J^J`J{J~K4K6KkKmR>R]SDSOTXTZ!T!V!@!^#h#l#N#R#?#]$l$o$`$}$}%6%d%f%g%s%y%A%A%C%T%%%+%`(k(n(U(W)[)`)}*1*9*b*g*k*n*p*r*u+|,w,S,V,W,Y-p-r-r-z-z-B-B-D-E-N-S-$-%-(.n.D/b/g/"/$/$/+/+/-/;/=:q:A:L:O:?:_:`:}:};2;V;X;X;!;#;%;%;*<z<I<J<M>f>j>j>x>x>F>I>K>P>R>T>W@+[y[C[I{s{u{u{y{I{M{Y{#{:{>|0|3|3|i|i}p}r}D}D}T}+~Z~/~<~<~[~[',
+).concat(
+ convert_from_raw(
+ digits,
+ 3,
+ '0~_10310510510910d10k10k10m10m10o10o10q10t10v10F10I10L10R10V10!10"10>11s11w11z15}16%17117118f18f18T18=18~19j19>1a$1fU1fU1js1m71s]1s^1tq1tr1t!1t#1t;1t;1t_1uj1uo1w]1w~1x21x61xc1xk1yS1yU1zX1A)1Bz1B!1B!1CY1C+1Fa1Fz1FM1FP1FV1FX1F^1G11G61G71G91Gd1Gg1Gk1Go1Hk1Hp1Hr1Ht1Iq1Is1KD1K:1LE1LH1L~1Mg1MH1ML1N41Nk1Nv1NA1Pi1Pn1Qt1Qw1Q!1Q#2wv2x44|[4}L52452853a53s53V53Y54L54O54"55656f56h57J57L57N57P57S57U57>57[57[57{58758a58&58,59T59W59[5aa5aZ5a*5b25be5bX5b"5ci5ck5cl5cq5cr5ct5c(5c*5dI5dP5dQ5dT5dU5dX5d*5d,5d=5d?5ez5eB5e`5e|5e|5f15f25f55f95fc5fc5fe5fT5fW5f$5f&5is5iu5iv5ix5iA5iC7S(7"67"b7""7""7"[7"[7"{7"~7$Q7$Q7$^7%i7%p7%O7%!7&~7(77(77(f7(f7(w7+c7+e7+/7,Z7,"7,:7,=7,?7->7-@7:v7:Y7;|7<37}T8k>8k>8k@8lH8lX8l)8l}8mm8mq8m.8m=8m>8m[8nX8n"8o68oc8oc8ol8o@8o]8p38p68pV8p&8p;8p?8q_8q}8q~8r18r18r48r98rb8s<8s>8s@8s~8tj8tm8t=8t?8t[8t^8ut8uB8uD8uJ8wT8w#8w$8w)8w)8w+8x_8y18y18y38y68y98y98yc8A$8A*8A/8A<8A<8A?8Bf8Bi8Ca8Cj8Ck8Cm8Cm8Cp8CT8C)8DC8DE8DE8DG8DH8DO8DO8DQ8EY8E#8E$8E*8E*8E:8S+8S=8S=8S_8T;8U88U98Uh8Uh8Uk8Uk8Una|[a||a}Ta}"ba*ba/dFgdFjdFjdFoe72e76e7ee7ve7we7Ee7)e7.e8"e9GebHecDemiemkem:em<enGenIeo8eoaeo%eo(eo;epAeu`evPevSewdewkewmewzewBewWew#ew#ew>eLXeL&eL&eL^eL_eM2eM2eM5eM5eMbe)[f0Yf0"f1,f1[f27f28f2of2of2Ef2Ef2<f2`f39f49f4cf8LfjffjrfjFfjHfjPfjXfk]fl3fl|fmDfmQfmTfnkfnrfnCfnHfn]fn~foufpzfpPfpPfpYfp&fp)fp*fp[fp[fq4fq7fqnfqTfq.frrfrtfIZfI#nl1nl4u|xu|AC$$C$(KG5KG8SiBSiEZ_)Z_,)"9)"c;DF;DI^f-',
+ ),
+ convert_from_raw(digits, 4, "0^f:10]d10]g18YJ18YM1gA;1g?A1odh1odk1v?N1v?Q1DV?1DV]1DV]"),
+);
/**
* Gets a character and returns a simplified version of its bidirectional class.
@@ -94,13 +112,15 @@ exports.get_direction = function (str) {
// Extracting high and low surrogates and putting them together.
// See https://en.wikipedia.org/wiki/UTF-16#Description or section 3 of https://tools.ietf.org/html/rfc2781.
let ch = str.charCodeAt(i);
- if (ch >= 0xd800 && ch < 0xe000) { // 0xd800 <= ch < 0xe000
+ if (ch >= 0xd800 && ch < 0xe000) {
+ // 0xd800 <= ch < 0xe000
// ch is inside surrogate range.
// If it made a surrogate pair with the next character, put them together.
// Otherwise, ignore the encoding error and leave it as it is.
if (ch < 0xdc00) {
const ch2 = i + 1 < str.length ? str.charCodeAt(i + 1) : 0;
- if (ch2 >= 0xdc00 && ch2 < 0xe000) { // 0xdc00 <= ch2 < 0xe000
+ if (ch2 >= 0xdc00 && ch2 < 0xe000) {
+ // 0xdc00 <= ch2 < 0xe000
// ch = ch & 0x3ff;
ch -= 0xd800;
// ch = 0x10000 | (ch << 10) | (ch2 & 0x3ff);
@@ -111,13 +131,15 @@ exports.get_direction = function (str) {
}
const bidi_class = get_bidi_class(ch);
- if (bidi_class === "I") { // LRI, RLI, FSI
+ if (bidi_class === "I") {
+ // LRI, RLI, FSI
isolations += 1;
} else if (bidi_class === "PDI") {
if (isolations > 0) {
isolations -= 1;
}
- } else if (bidi_class === "R") { // R, AL
+ } else if (bidi_class === "R") {
+ // R, AL
if (isolations === 0) {
return "rtl";
}
diff --git a/static/js/scroll_bar.js b/static/js/scroll_bar.js
index 2f1f29d0719..613898f5554 100644
--- a/static/js/scroll_bar.js
+++ b/static/js/scroll_bar.js
@@ -33,7 +33,7 @@ function getScrollbarWidth() {
let sbWidth;
exports.initialize = function () {
-// Workaround for browsers with fixed scrollbars
+ // Workaround for browsers with fixed scrollbars
sbWidth = getScrollbarWidth();
if (sbWidth > 0) {
@@ -45,17 +45,24 @@ exports.initialize = function () {
$(".fixed-app .column-middle").css("margin-left", 250 + sbWidth + "px");
$(".column-right").css("right", sbWidth + "px");
- $(".app-main .right-sidebar").css({"margin-left": sbWidth + "px",
- width: 250 - sbWidth + "px"});
+ $(".app-main .right-sidebar").css({
+ "margin-left": sbWidth + "px",
+ width: 250 - sbWidth + "px",
+ });
$("#compose").css("left", "-" + sbWidth + "px");
- $(".compose-content").css({left: sbWidth + "px",
- "margin-right": 250 + sbWidth + "px"});
+ $(".compose-content").css({left: sbWidth + "px", "margin-right": 250 + sbWidth + "px"});
$("#keyboard-icon").css({right: sbWidth + 35 + "px"});
- $("head").append("<style> @media (max-width: 1165px) { .compose-content, .header-main .column-middle { margin-right: " + (7 + sbWidth) + "px !important; } } " +
- "@media (max-width: 775px) { .fixed-app .column-middle { margin-left: " + (7 + sbWidth) + "px !important; } } " +
- "</style>");
+ $("head").append(
+ "<style> @media (max-width: 1165px) { .compose-content, .header-main .column-middle { margin-right: " +
+ (7 + sbWidth) +
+ "px !important; } } " +
+ "@media (max-width: 775px) { .fixed-app .column-middle { margin-left: " +
+ (7 + sbWidth) +
+ "px !important; } } " +
+ "</style>",
+ );
}
exports.set_layout_width();
};
diff --git a/static/js/scroll_util.js b/static/js/scroll_util.js
index 37cdd9f2367..cbed746c2d5 100644
--- a/static/js/scroll_util.js
+++ b/static/js/scroll_util.js
@@ -6,17 +6,11 @@ exports.scroll_delta = function (opts) {
let delta = 0;
if (elem_top < 0) {
- delta = Math.max(
- elem_top,
- elem_bottom - container_height,
- );
+ delta = Math.max(elem_top, elem_bottom - container_height);
delta = Math.min(0, delta);
} else {
if (elem_bottom > container_height) {
- delta = Math.min(
- elem_top,
- elem_bottom - container_height,
- );
+ delta = Math.min(elem_top, elem_bottom - container_height);
delta = Math.max(0, delta);
}
}
diff --git a/static/js/search.js b/static/js/search.js
index ed2ebb3434e..93111f52dca 100644
--- a/static/js/search.js
+++ b/static/js/search.js
@@ -17,7 +17,8 @@ exports.narrow_or_search_for_term = function (search_string) {
// function, so that the base_query includes the suggestion selected
// along with query corresponding to the existing pills.
const base_query = search_pill.get_search_string_for_current_filter(
- search_pill_widget.widget);
+ search_pill_widget.widget,
+ );
operators = Filter.parse(base_query);
} else {
operators = Filter.parse(search_string);
@@ -41,9 +42,7 @@ function update_buttons_with_focus(focused) {
// Show buttons iff the search input is focused, or has non-empty contents,
// or we are narrowed.
- if (focused
- || search_query_box.val()
- || narrow_state.active()) {
+ if (focused || search_query_box.val() || narrow_state.active()) {
$(".search_button").prop("disabled", false);
}
}
@@ -69,7 +68,8 @@ exports.initialize = function () {
let base_query = "";
if (page_params.search_pills_enabled) {
base_query = search_pill.get_search_string_for_current_filter(
- search_pill_widget.widget);
+ search_pill_widget.widget,
+ );
}
const suggestions = search_suggestion.get_suggestions(base_query, query);
// Update our global search_map hash
@@ -89,8 +89,7 @@ exports.initialize = function () {
},
updater: function (search_string) {
if (page_params.search_pills_enabled) {
- search_pill.append_search_string(search_string,
- search_pill_widget.widget);
+ search_pill.append_search_string(search_string, search_pill_widget.widget);
return search_query_box.val();
}
return exports.narrow_or_search_for_term(search_string);
@@ -121,35 +120,37 @@ exports.initialize = function () {
exports.is_using_input_method = true;
});
- searchbox_form.keydown((e) => {
- exports.update_button_visibility();
- const code = e.which;
- if (code === 13 && search_query_box.is(":focus")) {
- // Don't submit the form so that the typeahead can instead
- // handle our Enter keypress. Any searching that needs
- // to be done will be handled in the keyup.
- return false;
- }
- }).keyup((e) => {
- if (exports.is_using_input_method) {
- exports.is_using_input_method = false;
- return;
- }
- const code = e.which;
- if (code === 13 && search_query_box.is(":focus")) {
- // We just pressed enter and the box had focus, which
- // means we didn't use the typeahead at all. In that
- // case, we should act as though we're searching by
- // operators. (The reason the other actions don't call
- // this codepath is that they first all blur the box to
- // indicate that they've done what they need to do)
-
- // Pill is already added during keydown event of input pills.
- exports.narrow_or_search_for_term(search_query_box.val());
- search_query_box.blur();
- update_buttons_with_focus(false);
- }
- });
+ searchbox_form
+ .keydown((e) => {
+ exports.update_button_visibility();
+ const code = e.which;
+ if (code === 13 && search_query_box.is(":focus")) {
+ // Don't submit the form so that the typeahead can instead
+ // handle our Enter keypress. Any searching that needs
+ // to be done will be handled in the keyup.
+ return false;
+ }
+ })
+ .keyup((e) => {
+ if (exports.is_using_input_method) {
+ exports.is_using_input_method = false;
+ return;
+ }
+ const code = e.which;
+ if (code === 13 && search_query_box.is(":focus")) {
+ // We just pressed enter and the box had focus, which
+ // means we didn't use the typeahead at all. In that
+ // case, we should act as though we're searching by
+ // operators. (The reason the other actions don't call
+ // this codepath is that they first all blur the box to
+ // indicate that they've done what they need to do)
+
+ // Pill is already added during keydown event of input pills.
+ exports.narrow_or_search_for_term(search_query_box.val());
+ search_query_box.blur();
+ update_buttons_with_focus(false);
+ }
+ });
// Some of these functions don't actually need to be exported,
// but the code was moved here from elsewhere, and it would be
diff --git a/static/js/search_suggestion.js b/static/js/search_suggestion.js
index 155d468d5d2..d7588c90cc2 100644
--- a/static/js/search_suggestion.js
+++ b/static/js/search_suggestion.js
@@ -166,7 +166,8 @@ function get_group_suggestions(last, operators) {
negated: negated,
};
const name = highlight_person(person);
- const description = prefix + " " + Handlebars.Utils.escapeExpression(all_but_last_part) + "," + name;
+ const description =
+ prefix + " " + Handlebars.Utils.escapeExpression(all_but_last_part) + "," + name;
let terms = [term];
if (negated) {
terms = [{operator: "is", operand: "private"}, term];
@@ -242,11 +243,13 @@ function get_person_suggestions(people_getter, last, operators, autocomplete_ope
const objs = persons.map((person) => {
const name = highlight_person(person);
const description = prefix + " " + name;
- const terms = [{
- operator: autocomplete_operator,
- operand: person.email,
- negated: last.negated,
- }];
+ const terms = [
+ {
+ operator: autocomplete_operator,
+ operand: person.email,
+ negated: last.negated,
+ },
+ ];
if (autocomplete_operator === "pm-with" && last.negated) {
// In the special case of '-pm-with', add 'is:private' before it
// because we assume the user still wants to narrow to PMs
@@ -323,7 +326,6 @@ function get_topic_suggestions(last, operators) {
return [];
}
-
const stream_id = stream_data.get_stream_id(stream);
if (!stream_id) {
return [];
@@ -401,11 +403,13 @@ function get_special_filter_suggestions(last, operators, suggestions) {
// returns the substring after the ":" symbol.
const suggestion_operand = s.search_string.substring(s.search_string.indexOf(":") + 1);
// e.g for `att` search query, `has:attachment` should be suggested.
- const show_operator_suggestions = last.operator === "search" &&
- suggestion_operand.toLowerCase().startsWith(last_string);
- return s.search_string.toLowerCase().startsWith(last_string) ||
- show_operator_suggestions ||
- s.description.toLowerCase().startsWith(last_string);
+ const show_operator_suggestions =
+ last.operator === "search" && suggestion_operand.toLowerCase().startsWith(last_string);
+ return (
+ s.search_string.toLowerCase().startsWith(last_string) ||
+ show_operator_suggestions ||
+ s.description.toLowerCase().startsWith(last_string)
+ );
});
// Only show home if there's an empty bar
@@ -428,7 +432,6 @@ function get_streams_filter_suggestions(last, operators) {
{operator: "in"},
{operator: "streams"},
],
-
},
];
return get_special_filter_suggestions(last, operators, suggestions);
@@ -444,35 +447,26 @@ function get_is_filter_suggestions(last, operators) {
{operator: "pm-with"},
{operator: "in"},
],
-
},
{
search_string: "is:starred",
description: "starred messages",
- invalid: [
- {operator: "is", operand: "starred"},
- ],
+ invalid: [{operator: "is", operand: "starred"}],
},
{
search_string: "is:mentioned",
description: "@-mentions",
- invalid: [
- {operator: "is", operand: "mentioned"},
- ],
+ invalid: [{operator: "is", operand: "mentioned"}],
},
{
search_string: "is:alerted",
description: "alerted messages",
- invalid: [
- {operator: "is", operand: "alerted"},
- ],
+ invalid: [{operator: "is", operand: "alerted"}],
},
{
search_string: "is:unread",
description: "unread messages",
- invalid: [
- {operator: "is", operand: "unread"},
- ],
+ invalid: [{operator: "is", operand: "unread"}],
},
];
return get_special_filter_suggestions(last, operators, suggestions);
@@ -483,32 +477,25 @@ function get_has_filter_suggestions(last, operators) {
{
search_string: "has:link",
description: "messages with one or more link",
- invalid: [
- {operator: "has", operand: "link"},
- ],
+ invalid: [{operator: "has", operand: "link"}],
},
{
search_string: "has:image",
description: "messages with one or more image",
- invalid: [
- {operator: "has", operand: "image"},
- ],
+ invalid: [{operator: "has", operand: "image"}],
},
{
search_string: "has:attachment",
description: "messages with one or more attachment",
- invalid: [
- {operator: "has", operand: "attachment"},
- ],
+ invalid: [{operator: "has", operand: "attachment"}],
},
];
return get_special_filter_suggestions(last, operators, suggestions);
}
-
function get_sent_by_me_suggestions(last, operators) {
const last_string = Filter.unparse([last]).toLowerCase();
- const negated = last.negated || last.operator === "search" && last.operand[0] === "-";
+ const negated = last.negated || (last.operator === "search" && last.operand[0] === "-");
const negated_symbol = negated ? "-" : "";
const verb = negated ? "exclude " : "";
@@ -519,16 +506,14 @@ function get_sent_by_me_suggestions(last, operators) {
const sent_string = negated_symbol + "sent";
const description = verb + "sent by me";
- const invalid = [
- {operator: "sender"},
- {operator: "from"},
- ];
+ const invalid = [{operator: "sender"}, {operator: "from"}];
if (match_criteria(operators, invalid)) {
return [];
}
- if (last.operator === "" ||
+ if (
+ last.operator === "" ||
sender_query.startsWith(last_string) ||
sender_me_query.startsWith(last_string) ||
last_string === sent_string
@@ -539,9 +524,7 @@ function get_sent_by_me_suggestions(last, operators) {
description: description,
},
];
- } else if (from_query.startsWith(last_string) ||
- from_me_query.startsWith(last_string)
- ) {
+ } else if (from_query.startsWith(last_string) || from_me_query.startsWith(last_string)) {
return [
{
search_string: from_query,
@@ -641,9 +624,11 @@ exports.get_search_result = function (base_query, query) {
// and second last is {operator: 'sender', operand: 'sm'....}. If the second last operand
// is an email of a user, both of these operators remain unchanged. Otherwise search operator
// will be deleted and new last will become {operator:'sender', operand: 'Ted sm`....}.
- if (search_operators_len > 1 &&
+ if (
+ search_operators_len > 1 &&
last.operator === "search" &&
- person_suggestion_ops.includes(search_operators[search_operators_len - 2].operator)) {
+ person_suggestion_ops.includes(search_operators[search_operators_len - 2].operator)
+ ) {
const person_op = search_operators[search_operators_len - 2];
if (!people.reply_to_to_user_ids_string(person_op.operand)) {
last = {
diff --git a/static/js/search_util.js b/static/js/search_util.js
index 69bdc35bd91..fc597ab97c1 100644
--- a/static/js/search_util.js
+++ b/static/js/search_util.js
@@ -1,5 +1,8 @@
exports.get_search_terms = function (input) {
- const search_terms = input.toLowerCase().split(",").map((s) => s.trim());
+ const search_terms = input
+ .toLowerCase()
+ .split(",")
+ .map((s) => s.trim());
return search_terms;
};
diff --git a/static/js/sent_messages.js b/static/js/sent_messages.js
index ad39ffe2f22..10f41e635fc 100644
--- a/static/js/sent_messages.js
+++ b/static/js/sent_messages.js
@@ -10,8 +10,7 @@ exports.get_new_local_id = function () {
return "loc-" + local_id.toString();
};
-function report_send_time(send_time, receive_time,
- locally_echoed, rendered_changed) {
+function report_send_time(send_time, receive_time, locally_echoed, rendered_changed) {
const data = {
time: send_time.toString(),
received: receive_time.toString(),
@@ -55,7 +54,6 @@ exports.message_state = function (opts) {
self.data.local_id = opts.local_id;
self.data.locally_echoed = opts.locally_echoed;
-
self.data.received = undefined;
self.data.send_finished = undefined;
self.data.rendered_content_disparity = false;
@@ -73,9 +71,11 @@ exports.message_state = function (opts) {
return;
}
- blueslip.log("Restarting get_events due to " +
- "delayed receipt of sent message " +
- self.data.local_id);
+ blueslip.log(
+ "Restarting get_events due to " +
+ "delayed receipt of sent message " +
+ self.data.local_id,
+ );
server_events.restart_get_events();
};
@@ -85,10 +85,12 @@ exports.message_state = function (opts) {
return;
}
const data = self.data;
- report_send_time(data.send_finished - data.start,
- data.received - data.start,
- data.locally_echoed,
- data.rendered_content_disparity);
+ report_send_time(
+ data.send_finished - data.start,
+ data.received - data.start,
+ data.locally_echoed,
+ data.rendered_content_disparity,
+ );
};
self.report_event_received = function () {
@@ -115,8 +117,7 @@ exports.message_state = function (opts) {
};
self.ready = function () {
- return self.data.send_finished !== undefined &&
- self.data.received !== undefined;
+ return self.data.send_finished !== undefined && self.data.received !== undefined;
};
return self;
@@ -132,7 +133,6 @@ exports.get_message_state = function (local_id) {
return state;
};
-
exports.mark_disparity = function (local_id) {
const state = exports.get_message_state(local_id);
if (!state) {
diff --git a/static/js/server_events.js b/static/js/server_events.js
index 331e56e9048..90f7e96a389 100644
--- a/static/js/server_events.js
+++ b/static/js/server_events.js
@@ -27,12 +27,9 @@ function get_events_success(events) {
for (const event of events) {
try {
- get_events_params.last_event_id = Math.max(get_events_params.last_event_id,
- event.id);
+ get_events_params.last_event_id = Math.max(get_events_params.last_event_id, event.id);
} catch (ex) {
- blueslip.error("Failed to update last_event_id",
- {event: clean_event(event)},
- ex.stack);
+ blueslip.error("Failed to update last_event_id", {event: clean_event(event)}, ex.stack);
}
}
@@ -82,10 +79,11 @@ function get_events_success(events) {
try {
dispatch_event(event);
} catch (ex1) {
- blueslip.error("Failed to process an event\n" +
- blueslip.exception_msg(ex1),
- {event: clean_event(event)},
- ex1.stack);
+ blueslip.error(
+ "Failed to process an event\n" + blueslip.exception_msg(ex1),
+ {event: clean_event(event)},
+ ex1.stack,
+ );
}
}
@@ -113,10 +111,11 @@ function get_events_success(events) {
message_events.insert_new_messages(messages, sent_by_this_client);
}
} catch (ex2) {
- blueslip.error("Failed to insert new messages\n" +
- blueslip.exception_msg(ex2),
- undefined,
- ex2.stack);
+ blueslip.error(
+ "Failed to insert new messages\n" + blueslip.exception_msg(ex2),
+ undefined,
+ ex2.stack,
+ );
}
}
@@ -128,10 +127,11 @@ function get_events_success(events) {
try {
message_events.update_messages(update_message_events);
} catch (ex3) {
- blueslip.error("Failed to update messages\n" +
- blueslip.exception_msg(ex3),
- undefined,
- ex3.stack);
+ blueslip.error(
+ "Failed to update messages\n" + blueslip.exception_msg(ex3),
+ undefined,
+ ex3.stack,
+ );
}
}
@@ -199,10 +199,11 @@ function get_events(options) {
get_events_success(data.events);
} catch (ex) {
- blueslip.error("Failed to handle get_events success\n" +
- blueslip.exception_msg(ex),
- undefined,
- ex.stack);
+ blueslip.error(
+ "Failed to handle get_events success\n" + blueslip.exception_msg(ex),
+ undefined,
+ ex.stack,
+ );
}
get_events_timeout = setTimeout(get_events, 0);
},
@@ -211,13 +212,17 @@ function get_events(options) {
get_events_xhr = undefined;
// If we're old enough that our message queue has been
// garbage collected, immediately reload.
- if (xhr.status === 400 &&
- JSON.parse(xhr.responseText).code === "BAD_EVENT_QUEUE_ID") {
+ if (
+ xhr.status === 400 &&
+ JSON.parse(xhr.responseText).code === "BAD_EVENT_QUEUE_ID"
+ ) {
page_params.event_queue_expired = true;
- reload.initiate({immediate: true,
- save_pointer: false,
- save_narrow: true,
- save_compose: true});
+ reload.initiate({
+ immediate: true,
+ save_pointer: false,
+ save_narrow: true,
+ save_compose: true,
+ });
}
if (error_type === "abort") {
@@ -237,10 +242,11 @@ function get_events(options) {
hide_ui_connection_error();
}
} catch (ex) {
- blueslip.error("Failed to handle get_events error\n" +
- blueslip.exception_msg(ex),
- undefined,
- ex.stack);
+ blueslip.error(
+ "Failed to handle get_events error\n" + blueslip.exception_msg(ex),
+ undefined,
+ ex.stack,
+ );
}
const retry_sec = Math.min(90, Math.exp(get_events_failures / 2));
get_events_timeout = setTimeout(get_events, retry_sec * 1000);
@@ -269,11 +275,11 @@ exports.home_view_loaded = function home_view_loaded() {
$(document).trigger("home_view_loaded.zulip");
};
-
let watchdog_time = $.now();
exports.check_for_unsuspend = function () {
const new_time = $.now();
- if (new_time - watchdog_time > 20000) { // 20 seconds.
+ if (new_time - watchdog_time > 20000) {
+ // 20 seconds.
// Defensively reset watchdog_time here in case there's an
// exception in one of the event handlers
watchdog_time = new_time;
diff --git a/static/js/server_events_dispatch.js b/static/js/server_events_dispatch.js
index 173e86c5306..bbb9b3f67a9 100644
--- a/static/js/server_events_dispatch.js
+++ b/static/js/server_events_dispatch.js
@@ -55,9 +55,9 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
case "hotspots":
hotspots.load_new(event.hotspots);
- page_params.hotspots = page_params.hotspots ?
- page_params.hotspots.concat(event.hotspots) :
- event.hotspots;
+ page_params.hotspots = page_params.hotspots
+ ? page_params.hotspots.concat(event.hotspots)
+ : event.hotspots;
break;
case "invites_changed":
@@ -136,18 +136,21 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
video_chat_provider: compose.update_video_chat_button_display,
waiting_period_threshold: noop,
};
- if (event.op === "update" && Object.prototype.hasOwnProperty.call(realm_settings, event.property)) {
+ if (
+ event.op === "update" &&
+ Object.prototype.hasOwnProperty.call(realm_settings, event.property)
+ ) {
page_params["realm_" + event.property] = event.value;
realm_settings[event.property]();
settings_org.sync_realm_settings(event.property);
if (event.property === "create_stream_policy") {
- // TODO: Add waiting_period_threshold logic here.
- page_params.can_create_streams = page_params.is_admin ||
- page_params.realm_create_stream_policy === 1;
+ // TODO: Add waiting_period_threshold logic here.
+ page_params.can_create_streams =
+ page_params.is_admin || page_params.realm_create_stream_policy === 1;
} else if (event.property === "invite_to_stream_policy") {
- // TODO: Add waiting_period_threshold logic here.
- page_params.can_invite_to_stream = page_params.is_admin ||
- page_params.realm_invite_to_stream_policy === 1;
+ // TODO: Add waiting_period_threshold logic here.
+ page_params.can_invite_to_stream =
+ page_params.is_admin || page_params.realm_invite_to_stream_policy === 1;
}
if (event.property === "name" && window.electron_bridge !== undefined) {
@@ -188,8 +191,8 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
}
if (page_params.is_admin) {
- // Update the UI notice about the user's profile being
- // incomplete, as we might have filled in the missing field(s).
+ // Update the UI notice about the user's profile being
+ // incomplete, as we might have filled in the missing field(s).
panels.check_profile_incomplete();
}
break;
@@ -211,8 +214,8 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
break;
case "realm_emoji":
- // Update `page_params.realm_emoji` so that settings page
- // can display it properly when reopened without refresh.
+ // Update `page_params.realm_emoji` so that settings page
+ // can display it properly when reopened without refresh.
page_params.realm_emoji = event.realm_emoji;
emoji.update_emojis(event.realm_emoji);
settings_emoji.populate_emoji(event.realm_emoji);
@@ -234,7 +237,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
for (i = 0; i < page_params.realm_domains.length; i += 1) {
if (page_params.realm_domains[i].domain === event.realm_domain.domain) {
page_params.realm_domains[i].allow_subdomains =
- event.realm_domain.allow_subdomains;
+ event.realm_domain.allow_subdomains;
break;
}
}
@@ -263,15 +266,11 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
case "stream":
if (event.op === "update") {
- // Legacy: Stream properties are still managed by subs.js on the client side.
- stream_events.update_property(
- event.stream_id,
- event.property,
- event.value,
- {
- rendered_description: event.rendered_description,
- history_public_to_subscribers: event.history_public_to_subscribers,
- });
+ // Legacy: Stream properties are still managed by subs.js on the client side.
+ stream_events.update_property(event.stream_id, event.property, event.value, {
+ rendered_description: event.rendered_description,
+ history_public_to_subscribers: event.history_public_to_subscribers,
+ });
settings_streams.update_default_streams_table();
} else if (event.op === "create") {
stream_data.create_streams(event.streams);
@@ -306,9 +305,9 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
break;
case "submessage": {
- // The fields in the event don't quite exactly
- // match the layout of a submessage, since there's
- // an event id. We also want to be explicit here.
+ // The fields in the event don't quite exactly
+ // match the layout of a submessage, since there's
+ // an event id. We also want to be explicit here.
const submsg = {
id: event.submessage_id,
sender_id: event.sender_id,
@@ -373,18 +372,14 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
stream_events.mark_unsubscribed(sub);
}
} else if (event.op === "update") {
- stream_events.update_property(
- event.stream_id,
- event.property,
- event.value,
- );
+ stream_events.update_property(event.stream_id, event.property, event.value);
}
break;
case "typing":
if (event.sender.user_id === page_params.user_id) {
- // typing notifications are sent to the user who is typing
- // as well as recipients; we ignore such self-generated events.
+ // typing notifications are sent to the user who is typing
+ // as well as recipients; we ignore such self-generated events.
return;
}
@@ -414,11 +409,11 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
page_params[event.setting_name] = event.setting;
}
if (event.setting_name === "default_language") {
- // We additionally need to set the language name.
+ // We additionally need to set the language name.
page_params.default_language_name = event.language_name;
}
if (event.setting_name === "twenty_four_hour_time") {
- // Rerender the whole message list UI
+ // Rerender the whole message list UI
home_msg_list.rerender();
if (current_msg_list === message_list.narrowed) {
message_list.narrowed.rerender();
@@ -458,15 +453,15 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
scroll_bar.set_layout_width();
}
if (event.setting_name === "left_side_userlist") {
- // TODO: Make this change the view immediately rather
- // than requiring a reload or page resize.
+ // TODO: Make this change the view immediately rather
+ // than requiring a reload or page resize.
}
if (event.setting_name === "default_language") {
- // TODO: Make this change the view immediately rather than
- // requiring a reload. This is likely fairly difficult,
- // because various i18n strings are rendered by the
- // server; we may want to instead just trigger a page
- // reload.
+ // TODO: Make this change the view immediately rather than
+ // requiring a reload. This is likely fairly difficult,
+ // because various i18n strings are rendered by the
+ // server; we may want to instead just trigger a page
+ // reload.
}
if (event.setting_name === "emojiset") {
settings_display.report_emojiset_change();
@@ -482,8 +477,10 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
}
case "update_global_notifications":
- notifications.handle_global_notification_updates(event.notification_name,
- event.setting);
+ notifications.handle_global_notification_updates(
+ event.notification_name,
+ event.setting,
+ );
settings_notifications.update_page();
// TODO: This should also do a refresh of the stream_edit UI
// if it's currently displayed, possibly reusing some code
@@ -546,7 +543,6 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
settings_exports.populate_exports_table(event.exports);
break;
}
-
};
window.server_events_dispatch = exports;
diff --git a/static/js/settings.js b/static/js/settings.js
index 7eddf13669a..8bdd9f6f64d 100644
--- a/static/js/settings.js
+++ b/static/js/settings.js
@@ -23,13 +23,23 @@ $("body").ready(() => {
function setup_settings_label() {
exports.settings_label = {
// settings_notification
- enable_online_push_notifications: i18n.t("Send mobile notifications even if I'm online (useful for testing)"),
- pm_content_in_desktop_notifications: i18n.t("Include content of private messages in desktop notifications"),
- desktop_icon_count_display: i18n.t("Unread count summary (appears in desktop sidebar and browser tab)"),
+ enable_online_push_notifications: i18n.t(
+ "Send mobile notifications even if I'm online (useful for testing)",
+ ),
+ pm_content_in_desktop_notifications: i18n.t(
+ "Include content of private messages in desktop notifications",
+ ),
+ desktop_icon_count_display: i18n.t(
+ "Unread count summary (appears in desktop sidebar and browser tab)",
+ ),
enable_digest_emails: i18n.t("Send digest emails when I'm away"),
enable_login_emails: i18n.t("Send email notifications for new logins to my account"),
- message_content_in_email_notifications: i18n.t("Include message content in missed message emails"),
- realm_name_in_notifications: i18n.t("Include organization name in subject of missed message emails"),
+ message_content_in_email_notifications: i18n.t(
+ "Include message content in missed message emails",
+ ),
+ realm_name_in_notifications: i18n.t(
+ "Include organization name in subject of missed message emails",
+ ),
presence_enabled: i18n.t("Display my availability to other users when online"),
// display settings
@@ -39,7 +49,9 @@ function setup_settings_label() {
left_side_userlist: i18n.t("Show user list on left sidebar in narrow windows"),
starred_message_counts: i18n.t("Show counts for starred messages"),
twenty_four_hour_time: i18n.t("Time format"),
- translate_emoticons: i18n.t("Convert emoticons before sending (<code>:)</code> becomes 😃)"),
+ translate_emoticons: i18n.t(
+ "Convert emoticons before sending (<code>:)</code> becomes 😃)",
+ ),
};
}
@@ -49,8 +61,8 @@ exports.build_page = function () {
const rendered_settings_tab = render_settings_tab({
full_name: people.my_full_name(),
page_params: page_params,
- enable_sound_select: page_params.enable_sounds ||
- page_params.enable_stream_audible_notifications,
+ enable_sound_select:
+ page_params.enable_sounds || page_params.enable_stream_audible_notifications,
zuliprc: "zuliprc",
botserverrc: "botserverrc",
timezones: moment.tz.names(),
@@ -62,8 +74,8 @@ exports.build_page = function () {
general_settings: settings_config.all_notifications().general_settings,
notification_settings: settings_config.all_notifications().settings,
desktop_icon_count_display_values: settings_notifications.desktop_icon_count_display_values,
- show_push_notifications_tooltip:
- settings_config.all_notifications().show_push_notifications_tooltip,
+ show_push_notifications_tooltip: settings_config.all_notifications()
+ .show_push_notifications_tooltip,
display_settings: settings_config.get_all_display_settings(),
user_can_change_name: settings_account.user_can_change_name(),
user_can_change_avatar: settings_account.user_can_change_avatar(),
@@ -87,8 +99,12 @@ exports.set_settings_header = function (key) {
if (header_text) {
$(".settings-header h1 .section").text(" / " + header_text);
} else {
- blueslip.warn("Error: the key '" + key + "' does not exist in the settings" +
- " sidebar list. Please add it.");
+ blueslip.warn(
+ "Error: the key '" +
+ key +
+ "' does not exist in the settings" +
+ " sidebar list. Please add it.",
+ );
}
};
diff --git a/static/js/settings_account.js b/static/js/settings_account.js
index c377d0434d7..f55fb7b87df 100644
--- a/static/js/settings_account.js
+++ b/static/js/settings_account.js
@@ -68,10 +68,16 @@ exports.update_email_change_display = function () {
exports.update_avatar_change_display = function () {
if (!exports.user_can_change_avatar()) {
$("#user-avatar-upload-widget .image_upload_button").attr("disabled", "disabled");
- $("#user-avatar-upload-widget .settings-page-delete-button .button").attr("disabled", "disabled");
+ $("#user-avatar-upload-widget .settings-page-delete-button .button").attr(
+ "disabled",
+ "disabled",
+ );
} else {
$("#user-avatar-upload-widget .image_upload_button").attr("disabled", false);
- $("#user-avatar-upload-widget .settings-page-delete-button .button").attr("disabled", false);
+ $("#user-avatar-upload-widget .settings-page-delete-button .button").attr(
+ "disabled",
+ false,
+ );
}
};
@@ -88,7 +94,6 @@ function display_avatar_upload_started() {
$("#user-avatar-upload-widget .settings-page-delete-button").hide();
}
-
function settings_change_error(message, xhr) {
ui_report.error(message, xhr, $("#account-settings-status").expectOne());
}
@@ -101,10 +106,15 @@ function update_custom_profile_field(field, method) {
field_id = field.id;
}
- const spinner_element = $('.custom_user_field[data-field-id="' + field_id +
- '"] .custom-field-status').expectOne();
- settings_ui.do_settings_change(method, "/json/users/me/profile_data",
- {data: JSON.stringify([field])}, spinner_element);
+ const spinner_element = $(
+ '.custom_user_field[data-field-id="' + field_id + '"] .custom-field-status',
+ ).expectOne();
+ settings_ui.do_settings_change(
+ method,
+ "/json/users/me/profile_data",
+ {data: JSON.stringify([field])},
+ spinner_element,
+ );
}
function update_user_custom_profile_fields(fields, method) {
@@ -177,21 +187,29 @@ exports.initialize_custom_date_type_fields = function (element_id) {
allowInput: true,
});
- $(element_id).find(".custom_user_field .datepicker").on("mouseenter", function () {
- if ($(this).val().length <= 0) {
- $(this).parent().find(".remove_date").hide();
- } else {
- $(this).parent().find(".remove_date").show();
- }
- });
+ $(element_id)
+ .find(".custom_user_field .datepicker")
+ .on("mouseenter", function () {
+ if ($(this).val().length <= 0) {
+ $(this).parent().find(".remove_date").hide();
+ } else {
+ $(this).parent().find(".remove_date").show();
+ }
+ });
- $(element_id).find(".custom_user_field .remove_date").on("click", function () {
- $(this).parent().find(".custom_user_field_value").val("");
- });
+ $(element_id)
+ .find(".custom_user_field .remove_date")
+ .on("click", function () {
+ $(this).parent().find(".custom_user_field_value").val("");
+ });
};
-exports.initialize_custom_user_type_fields = function (element_id, user_id, is_editable,
- set_handler_on_update) {
+exports.initialize_custom_user_type_fields = function (
+ element_id,
+ user_id,
+ is_editable,
+ set_handler_on_update,
+) {
const field_types = page_params.custom_profile_field_types;
const user_pills = new Map();
@@ -210,8 +228,9 @@ exports.initialize_custom_user_type_fields = function (element_id, user_id, is_e
// If field is not editable and field value is null, we don't expect
// pill container for that field and proceed further
if (field.type === field_types.USER.id && (field_value_raw || is_editable)) {
- const pill_container = $(element_id).find('.custom_user_field[data-field-id="' +
- field.id + '"] .pill-container').expectOne();
+ const pill_container = $(element_id)
+ .find('.custom_user_field[data-field-id="' + field.id + '"] .pill-container')
+ .expectOne();
const pills = user_pill.create_pills(pill_container);
function update_custom_user_field() {
@@ -383,20 +402,26 @@ exports.set_up = function () {
}
});
- $("#change_password_modal").find("[data-dismiss=modal]").on("click", () => {
- clear_password_change();
- });
+ $("#change_password_modal")
+ .find("[data-dismiss=modal]")
+ .on("click", () => {
+ clear_password_change();
+ });
// If the modal is closed using the 'close' button or the 'Cancel' button
- $(".modal").find("[data-dismiss=modal]").on("click", () => {
- // Enable mouse events for the background on closing modal
- $(".overlay.show").attr("style", null);
- });
+ $(".modal")
+ .find("[data-dismiss=modal]")
+ .on("click", () => {
+ // Enable mouse events for the background on closing modal
+ $(".overlay.show").attr("style", null);
+ });
$("#change_password_button").on("click", (e) => {
e.preventDefault();
e.stopPropagation();
- const change_password_error = $("#change_password_modal").find(".change_password_info").expectOne();
+ const change_password_error = $("#change_password_modal")
+ .find(".change_password_info")
+ .expectOne();
const data = {
old_password: $("#old_password").val(),
@@ -412,7 +437,8 @@ exports.set_up = function () {
// zxcvbn.js didn't load, for whatever reason.
settings_change_error(
"An internal error occurred; try reloading the page. " +
- "Sorry for the trouble!");
+ "Sorry for the trouble!",
+ );
return;
} else if (!password_ok) {
settings_change_error(i18n.t("New password is too weak"));
@@ -426,8 +452,13 @@ exports.set_up = function () {
},
error_msg_element: change_password_error,
};
- settings_ui.do_settings_change(channel.patch, "/json/settings", data,
- $("#account-settings-status").expectOne(), opts);
+ settings_ui.do_settings_change(
+ channel.patch,
+ "/json/settings",
+ data,
+ $("#account-settings-status").expectOne(),
+ opts,
+ );
clear_password_change();
});
@@ -439,7 +470,9 @@ exports.set_up = function () {
$("#change_full_name_button").on("click", (e) => {
e.preventDefault();
e.stopPropagation();
- const change_full_name_error = $("#change_full_name_modal").find(".change_full_name_info").expectOne();
+ const change_full_name_error = $("#change_full_name_modal")
+ .find(".change_full_name_info")
+ .expectOne();
const data = {};
data.full_name = $(".full_name_change_container").find("input[name='full_name']").val();
@@ -450,8 +483,13 @@ exports.set_up = function () {
},
error_msg_element: change_full_name_error,
};
- settings_ui.do_settings_change(channel.patch, "/json/settings", data,
- $("#account-settings-status").expectOne(), opts);
+ settings_ui.do_settings_change(
+ channel.patch,
+ "/json/settings",
+ data,
+ $("#account-settings-status").expectOne(),
+ opts,
+ );
});
$("#change_email_button").on("click", (e) => {
@@ -465,16 +503,26 @@ exports.set_up = function () {
success_continuation: function () {
if (page_params.development_environment) {
const email_msg = render_settings_dev_env_email_access();
- ui_report.success(email_msg, $("#dev-account-settings-status").expectOne(), 4000);
+ ui_report.success(
+ email_msg,
+ $("#dev-account-settings-status").expectOne(),
+ 4000,
+ );
}
overlays.close_modal("#change_email_modal");
},
error_msg_element: change_email_error,
- success_msg: i18n.t("Check your email (%s) to confirm the new address.").replace(
- "%s", data.email),
+ success_msg: i18n
+ .t("Check your email (%s) to confirm the new address.")
+ .replace("%s", data.email),
};
- settings_ui.do_settings_change(channel.patch, "/json/settings", data,
- $("#account-settings-status").expectOne(), opts);
+ settings_ui.do_settings_change(
+ channel.patch,
+ "/json/settings",
+ data,
+ $("#account-settings-status").expectOne(),
+ opts,
+ );
});
$("#change_email").on("click", (e) => {
@@ -506,7 +554,10 @@ exports.set_up = function () {
$("#account-settings").on("change", ".custom_user_field_value", function (e) {
const fields = [];
const value = $(this).val();
- const field_id = parseInt($(e.target).closest(".custom_user_field").attr("data-field-id"), 10);
+ const field_id = parseInt(
+ $(e.target).closest(".custom_user_field").attr("data-field-id"),
+ 10,
+ );
if (value) {
fields.push({id: field_id, value: value});
update_user_custom_profile_fields(fields, channel.patch);
@@ -533,8 +584,12 @@ exports.set_up = function () {
window.location.href = "/login/";
},
error: function (xhr) {
- const error_last_admin = i18n.t("Error: Cannot deactivate the only organization administrator.");
- const error_last_user = i18n.t("Error: Cannot deactivate the only user. You can deactivate the whole organization though in your <a target=\"_blank\" href=\"/#organization/organization-profile\">Organization profile settings</a>.");
+ const error_last_admin = i18n.t(
+ "Error: Cannot deactivate the only organization administrator.",
+ );
+ const error_last_user = i18n.t(
+ 'Error: Cannot deactivate the only user. You can deactivate the whole organization though in your <a target="_blank" href="/#organization/organization-profile">Organization profile settings</a>.',
+ );
let rendered_error_msg;
if (xhr.responseJSON.code === "CANNOT_DEACTIVATE_LAST_USER") {
if (xhr.responseJSON.is_last_admin) {
@@ -544,7 +599,10 @@ exports.set_up = function () {
}
}
$("#deactivate_self_modal").modal("hide");
- $("#account-settings-status").addClass("alert-error").html(rendered_error_msg).show();
+ $("#account-settings-status")
+ .addClass("alert-error")
+ .html(rendered_error_msg)
+ .show();
},
});
}, 5000);
@@ -573,7 +631,6 @@ exports.set_up = function () {
});
});
-
function upload_avatar(file_input) {
const form_data = new FormData();
@@ -604,7 +661,6 @@ exports.set_up = function () {
$error.show();
},
});
-
}
avatar.build_user_avatar_widget(upload_avatar);
@@ -612,8 +668,6 @@ exports.set_up = function () {
if (page_params.realm_name_changes_disabled) {
$(".name_change_container").hide();
}
-
};
-
window.settings_account = exports;
diff --git a/static/js/settings_bots.js b/static/js/settings_bots.js
index 1c7afc6ca9c..4377d924c2d 100644
--- a/static/js/settings_bots.js
+++ b/static/js/settings_bots.js
@@ -60,7 +60,10 @@ function add_bot_row(info) {
function is_local_part(value, element) {
// Adapted from Django's EmailValidator
- return this.optional(element) || /^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*$/i.test(value);
+ return (
+ this.optional(element) ||
+ /^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*$/i.test(value)
+ );
}
exports.type_id_to_string = function (type_id) {
@@ -127,22 +130,33 @@ exports.generate_zuliprc_content = function (bot) {
if (bot.bot_type === 3) {
token = bot_data.get_services(bot.user_id)[0].token;
}
- return "[api]" +
- "\nemail=" + bot.email +
- "\nkey=" + bot.api_key +
- "\nsite=" + page_params.realm_uri +
- (token === undefined ? "" : "\ntoken=" + token) +
- // Some tools would not work in files without a trailing new line.
- "\n";
+ return (
+ "[api]" +
+ "\nemail=" +
+ bot.email +
+ "\nkey=" +
+ bot.api_key +
+ "\nsite=" +
+ page_params.realm_uri +
+ (token === undefined ? "" : "\ntoken=" + token) +
+ // Some tools would not work in files without a trailing new line.
+ "\n"
+ );
};
exports.generate_botserverrc_content = function (email, api_key, token) {
- return "[]" +
- "\nemail=" + email +
- "\nkey=" + api_key +
- "\nsite=" + page_params.realm_uri +
- "\ntoken=" + token +
- "\n";
+ return (
+ "[]" +
+ "\nemail=" +
+ email +
+ "\nkey=" +
+ api_key +
+ "\nsite=" +
+ page_params.realm_uri +
+ "\ntoken=" +
+ token +
+ "\n"
+ );
};
exports.bot_creation_policy_values = {
@@ -169,8 +183,10 @@ exports.can_create_new_bots = function () {
return false;
}
- return page_params.realm_bot_creation_policy !==
- exports.bot_creation_policy_values.admins_only.code;
+ return (
+ page_params.realm_bot_creation_policy !==
+ exports.bot_creation_policy_values.admins_only.code
+ );
};
exports.update_bot_settings_tip = function () {
@@ -222,17 +238,21 @@ exports.set_up = function () {
}
}
- $(this).attr("href", "data:application/octet-stream;charset=utf-8," + encodeURIComponent(content));
+ $(this).attr(
+ "href",
+ "data:application/octet-stream;charset=utf-8," + encodeURIComponent(content),
+ );
});
exports.render_bots();
- $.validator.addMethod("bot_local_part",
- function (value, element) {
- return is_local_part.call(this, value + "-bot", element);
- },
- "Please only use characters that are valid in an email address");
-
+ $.validator.addMethod(
+ "bot_local_part",
+ function (value, element) {
+ return is_local_part.call(this, value + "-bot", element);
+ },
+ "Please only use characters that are valid in an email address",
+ );
const create_avatar_widget = avatar.build_bot_create_widget();
const OUTGOING_WEBHOOK_BOT_TYPE = "3";
@@ -249,7 +269,8 @@ exports.set_up = function () {
submitHandler: function () {
const bot_type = $("#create_bot_type :selected").val();
const full_name = $("#create_bot_name").val();
- const short_name = $("#create_bot_short_name").val() || $("#create_bot_short_name").text();
+ const short_name =
+ $("#create_bot_short_name").val() || $("#create_bot_short_name").text();
const payload_url = $("#create_payload_url").val();
const interface_type = $("#create_interface_type").val();
const service_name = $("#select_service_name :selected").val();
@@ -273,7 +294,9 @@ exports.set_up = function () {
});
formData.append("config_data", JSON.stringify(config_data));
}
- for (const [i, file] of Array.prototype.entries.call($("#bot_avatar_file_input")[0].files)) {
+ for (const [i, file] of Array.prototype.entries.call(
+ $("#bot_avatar_file_input")[0].files,
+ )) {
formData.append("file-" + i, file);
}
loading.make_indicator(spinner, {text: i18n.t("Creating bot")});
@@ -324,7 +347,6 @@ exports.set_up = function () {
if (bot_type === OUTGOING_WEBHOOK_BOT_TYPE) {
$("#payload_url_inputbox").show();
$("#create_payload_url").addClass("required");
-
} else if (bot_type === EMBEDDED_BOT_TYPE) {
$("#service_name_list").show();
$("#select_service_name").addClass("required");
@@ -346,7 +368,9 @@ exports.set_up = function () {
url: "/json/bots/" + encodeURIComponent(bot_id),
success: function () {
const row = $(e.currentTarget).closest("li");
- row.hide("slow", () => { row.remove(); });
+ row.hide("slow", () => {
+ row.remove();
+ });
},
error: function (xhr) {
exports.bot_error(bot_id, xhr);
@@ -398,10 +422,12 @@ exports.set_up = function () {
}));
$("#edit_bot_modal").empty();
- $("#edit_bot_modal").append(render_edit_bot({
- bot: bot,
- users_list: users_list,
- }));
+ $("#edit_bot_modal").append(
+ render_edit_bot({
+ bot: bot,
+ users_list: users_list,
+ }),
+ );
const avatar_widget = avatar.build_bot_edit_widget($("#settings_page"));
const form = $("#settings_page .edit_bot_form");
const image = li.find(".image");
@@ -417,15 +443,19 @@ exports.set_up = function () {
const service = bot_data.get_services(bot_id)[0];
if (bot.bot_type.toString() === OUTGOING_WEBHOOK_BOT_TYPE) {
- $("#service_data").append(render_settings_edit_outgoing_webhook_service({
- service: service,
- }));
+ $("#service_data").append(
+ render_settings_edit_outgoing_webhook_service({
+ service: service,
+ }),
+ );
$("#edit_service_interface").val(service.interface);
}
if (bot.bot_type.toString() === EMBEDDED_BOT_TYPE) {
- $("#service_data").append(render_settings_edit_embedded_bot_service({
- service: service,
- }));
+ $("#service_data").append(
+ render_settings_edit_embedded_bot_service({
+ service: service,
+ }),
+ );
}
avatar_widget.clear();
@@ -484,7 +514,9 @@ exports.set_up = function () {
// when the user had a previous uploaded avatar. Only the content
// changes, so we version it to get an uncached copy.
image_version += 1;
- image.find("img").attr("src", data.avatar_url + "&v=" + image_version.toString());
+ image
+ .find("img")
+ .attr("src", data.avatar_url + "&v=" + image_version.toString());
}
overlays.close_modal("#edit_bot_modal");
},
@@ -532,7 +564,6 @@ exports.set_up = function () {
e.stopPropagation();
focus_tab.inactive_bots_tab();
});
-
};
window.settings_bots = exports;
diff --git a/static/js/settings_config.js b/static/js/settings_config.js
index 0f7bc107612..41921a4947c 100644
--- a/static/js/settings_config.js
+++ b/static/js/settings_config.js
@@ -136,36 +136,60 @@ exports.private_message_policy_values = {
};
const time_limit_dropdown_values = new Map([
- ["any_time", {
- text: i18n.t("Any time"),
- seconds: 0,
- }],
- ["never", {
- text: i18n.t("Never"),
- }],
- ["upto_two_min", {
- text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("2 minutes")}),
- seconds: 2 * 60,
- }],
- ["upto_ten_min", {
- text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("10 minutes")}),
- seconds: 10 * 60,
- }],
- ["upto_one_hour", {
- text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 hour")}),
- seconds: 60 * 60,
- }],
- ["upto_one_day", {
- text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 day")}),
- seconds: 24 * 60 * 60,
- }],
- ["upto_one_week", {
- text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 week")}),
- seconds: 7 * 24 * 60 * 60,
- }],
- ["custom_limit", {
- text: i18n.t("Up to N minutes after posting"),
- }],
+ [
+ "any_time",
+ {
+ text: i18n.t("Any time"),
+ seconds: 0,
+ },
+ ],
+ [
+ "never",
+ {
+ text: i18n.t("Never"),
+ },
+ ],
+ [
+ "upto_two_min",
+ {
+ text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("2 minutes")}),
+ seconds: 2 * 60,
+ },
+ ],
+ [
+ "upto_ten_min",
+ {
+ text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("10 minutes")}),
+ seconds: 10 * 60,
+ },
+ ],
+ [
+ "upto_one_hour",
+ {
+ text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 hour")}),
+ seconds: 60 * 60,
+ },
+ ],
+ [
+ "upto_one_day",
+ {
+ text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 day")}),
+ seconds: 24 * 60 * 60,
+ },
+ ],
+ [
+ "upto_one_week",
+ {
+ text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 week")}),
+ seconds: 7 * 24 * 60 * 60,
+ },
+ ],
+ [
+ "custom_limit",
+ {
+ text: i18n.t("Up to N minutes after posting"),
+ },
+ ],
]);
exports.msg_edit_limit_dropdown_values = time_limit_dropdown_values;
exports.msg_delete_limit_dropdown_values = time_limit_dropdown_values;
@@ -199,10 +223,14 @@ exports.user_role_map = new Map(user_role_array.map((role) => [role.code, role.d
exports.general_notifications_table_labels = {
realm: [
/* An array of notification settings of any category like
- * `stream_notification_settings` which makes a single row of
- * "Notification triggers" table should follow this order
- */
- "visual", "audio", "mobile", "email", "all_mentions",
+ * `stream_notification_settings` which makes a single row of
+ * "Notification triggers" table should follow this order
+ */
+ "visual",
+ "audio",
+ "mobile",
+ "email",
+ "all_mentions",
],
stream: {
is_muted: i18n.t("Mute stream"),
@@ -238,13 +266,9 @@ const pm_mention_notification_settings = [
"enable_offline_email_notifications",
];
-const desktop_notification_settings = [
- "pm_content_in_desktop_notifications",
-];
+const desktop_notification_settings = ["pm_content_in_desktop_notifications"];
-const mobile_notification_settings = [
- "enable_online_push_notifications",
-];
+const mobile_notification_settings = ["enable_online_push_notifications"];
const email_notification_settings = [
"enable_digest_emails",
@@ -253,9 +277,7 @@ const email_notification_settings = [
"realm_name_in_notifications",
];
-const presence_notification_settings = [
- "presence_enabled",
-];
+const presence_notification_settings = ["presence_enabled"];
const other_notification_settings = desktop_notification_settings.concat(
["desktop_icon_count_display"],
@@ -275,12 +297,14 @@ exports.all_notifications = () => ({
{
label: i18n.t("Streams"),
notification_settings: settings_notifications.get_notifications_table_row_data(
- exports.stream_notification_settings),
+ exports.stream_notification_settings,
+ ),
},
{
label: i18n.t("PMs, mentions, and alerts"),
notification_settings: settings_notifications.get_notifications_table_row_data(
- pm_mention_notification_settings),
+ pm_mention_notification_settings,
+ ),
},
],
settings: {
diff --git a/static/js/settings_data.js b/static/js/settings_data.js
index e2f681e142d..b8637f71cd1 100644
--- a/static/js/settings_data.js
+++ b/static/js/settings_data.js
@@ -11,12 +11,16 @@ const settings_config = require("./settings_config");
*/
exports.show_email = function () {
- if (page_params.realm_email_address_visibility ===
- settings_config.email_address_visibility_values.everyone.code) {
+ if (
+ page_params.realm_email_address_visibility ===
+ settings_config.email_address_visibility_values.everyone.code
+ ) {
return true;
}
- if (page_params.realm_email_address_visibility ===
- settings_config.email_address_visibility_values.admins_only.code) {
+ if (
+ page_params.realm_email_address_visibility ===
+ settings_config.email_address_visibility_values.admins_only.code
+ ) {
return page_params.is_admin;
}
};
@@ -26,9 +30,12 @@ exports.email_for_user_settings = function (person) {
return;
}
- if (page_params.is_admin && person.delivery_email &&
- page_params.realm_email_address_visibility ===
- settings_config.email_address_visibility_values.admins_only.code) {
+ if (
+ page_params.is_admin &&
+ person.delivery_email &&
+ page_params.realm_email_address_visibility ===
+ settings_config.email_address_visibility_values.admins_only.code
+ ) {
return person.delivery_email;
}
diff --git a/static/js/settings_display.js b/static/js/settings_display.js
index c0cb704bc7b..6d9e15cdd10 100644
--- a/static/js/settings_display.js
+++ b/static/js/settings_display.js
@@ -18,7 +18,13 @@ function change_display_setting(data, status_element, success_msg, sticky) {
$status_el.data("is_sticky", true);
$status_el.data("sticky_msg", success_msg);
}
- settings_ui.do_settings_change(channel.patch, "/json/settings/display", data, status_element, opts);
+ settings_ui.do_settings_change(
+ channel.patch,
+ "/json/settings/display",
+ data,
+ status_element,
+ opts,
+ );
}
exports.set_up = function () {
@@ -49,7 +55,11 @@ exports.set_up = function () {
change_display_setting(
data,
"#display-settings-status",
- i18n.t("Saved. Please <a class='reload_link'>reload</a> for the change to take effect."), true);
+ i18n.t(
+ "Saved. Please <a class='reload_link'>reload</a> for the change to take effect.",
+ ),
+ true,
+ );
} else {
change_display_setting(data, "#display-settings-status");
}
@@ -68,9 +78,14 @@ exports.set_up = function () {
const new_language = $link.attr("data-name");
$("#default_language_name").text(new_language);
- change_display_setting(data, "#language-settings-status",
- i18n.t("Saved. Please <a class='reload_link'>reload</a> for the change to take effect."), true);
-
+ change_display_setting(
+ data,
+ "#language-settings-status",
+ i18n.t(
+ "Saved. Please <a class='reload_link'>reload</a> for the change to take effect.",
+ ),
+ true,
+ );
});
$("#default_language").on("click", (e) => {
@@ -93,7 +108,6 @@ exports.set_up = function () {
window.location.reload();
});
-
$("#twenty_four_hour_time").change(function () {
const data = {twenty_four_hour_time: this.value};
change_display_setting(data, "#time-settings-status");
@@ -115,10 +129,13 @@ exports.set_up = function () {
channel.patch({
url: "/json/settings/display",
data: data,
- success: function () {
- },
+ success: function () {},
error: function (xhr) {
- ui_report.error(settings_ui.strings.failure, xhr, $("#emoji-settings-status").expectOne());
+ ui_report.error(
+ settings_ui.strings.failure,
+ xhr,
+ $("#emoji-settings-status").expectOne(),
+ );
},
});
});
@@ -142,8 +159,10 @@ exports.report_emojiset_change = async function () {
if ($("#emoji-settings-status").length) {
loading.destroy_indicator($("#emojiset_spinner"));
$("#emojiset_select").val(page_params.emojiset);
- ui_report.success(i18n.t("Emojiset changed successfully!"),
- $("#emoji-settings-status").expectOne());
+ ui_report.success(
+ i18n.t("Emojiset changed successfully!"),
+ $("#emoji-settings-status").expectOne(),
+ );
const spinner = $("#emoji-settings-status").expectOne();
settings_ui.display_checkmark(spinner);
}
diff --git a/static/js/settings_emoji.js b/static/js/settings_emoji.js
index ad64d05644a..638d02e010d 100644
--- a/static/js/settings_emoji.js
+++ b/static/js/settings_emoji.js
@@ -162,43 +162,45 @@ exports.set_up = function () {
const emoji_widget = exports.build_emoji_upload_widget();
- $(".organization form.admin-emoji-form").off("submit").on("submit", function (e) {
- e.preventDefault();
- e.stopPropagation();
- const emoji_status = $("#admin-emoji-status");
- $("#admin_emoji_submit").attr("disabled", true);
- const emoji = {};
- const formData = new FormData();
-
- for (const obj of $(this).serializeArray()) {
- emoji[obj.name] = obj.value;
- }
+ $(".organization form.admin-emoji-form")
+ .off("submit")
+ .on("submit", function (e) {
+ e.preventDefault();
+ e.stopPropagation();
+ const emoji_status = $("#admin-emoji-status");
+ $("#admin_emoji_submit").attr("disabled", true);
+ const emoji = {};
+ const formData = new FormData();
+
+ for (const obj of $(this).serializeArray()) {
+ emoji[obj.name] = obj.value;
+ }
- for (const [i, file] of Array.prototype.entries.call($("#emoji_file_input")[0].files)) {
- formData.append("file-" + i, file);
- }
- channel.post({
- url: "/json/realm/emoji/" + encodeURIComponent(emoji.name),
- data: formData,
- cache: false,
- processData: false,
- contentType: false,
- success: function () {
- $("#admin-emoji-status").hide();
- ui_report.success(i18n.t("Custom emoji added!"), emoji_status);
- $("form.admin-emoji-form input[type='text']").val("");
- $("#admin_emoji_submit").removeAttr("disabled");
- emoji_widget.clear();
- },
- error: function (xhr) {
- $("#admin-emoji-status").hide();
- const errors = JSON.parse(xhr.responseText).msg;
- xhr.responseText = JSON.stringify({msg: errors});
- ui_report.error(i18n.t("Failed"), xhr, emoji_status);
- $("#admin_emoji_submit").removeAttr("disabled");
- },
+ for (const [i, file] of Array.prototype.entries.call($("#emoji_file_input")[0].files)) {
+ formData.append("file-" + i, file);
+ }
+ channel.post({
+ url: "/json/realm/emoji/" + encodeURIComponent(emoji.name),
+ data: formData,
+ cache: false,
+ processData: false,
+ contentType: false,
+ success: function () {
+ $("#admin-emoji-status").hide();
+ ui_report.success(i18n.t("Custom emoji added!"), emoji_status);
+ $("form.admin-emoji-form input[type='text']").val("");
+ $("#admin_emoji_submit").removeAttr("disabled");
+ emoji_widget.clear();
+ },
+ error: function (xhr) {
+ $("#admin-emoji-status").hide();
+ const errors = JSON.parse(xhr.responseText).msg;
+ xhr.responseText = JSON.stringify({msg: errors});
+ ui_report.error(i18n.t("Failed"), xhr, emoji_status);
+ $("#admin_emoji_submit").removeAttr("disabled");
+ },
+ });
});
- });
};
window.settings_emoji = exports;
diff --git a/static/js/settings_exports.js b/static/js/settings_exports.js
index 30fcf5c9aa3..1ba0a6faf01 100644
--- a/static/js/settings_exports.js
+++ b/static/js/settings_exports.js
@@ -94,7 +94,11 @@ exports.set_up = function () {
channel.post({
url: "/json/export/realm",
success: function () {
- ui_report.success(i18n.t("Export started. Check back in a few minutes."), export_status, 4000);
+ ui_report.success(
+ i18n.t("Export started. Check back in a few minutes."),
+ export_status,
+ 4000,
+ );
},
error: function (xhr) {
ui_report.error(i18n.t("Export failed"), xhr, export_status);
diff --git a/static/js/settings_invites.js b/static/js/settings_invites.js
index 3d42591f9ae..364c6190a21 100644
--- a/static/js/settings_invites.js
+++ b/static/js/settings_invites.js
@@ -46,8 +46,9 @@ function populate_invites(invites_data) {
modifier: function (item) {
item.invited_absolute_time = timerender.absolute_time(item.invited * 1000);
item.is_admin = page_params.is_admin;
- item.disable_buttons = item.invited_as === settings_config.user_role_values.owner.code
- && !page_params.is_owner;
+ item.disable_buttons =
+ item.invited_as === settings_config.user_role_values.owner.code &&
+ !page_params.is_owner;
item.referrer_email = people.get_by_user_id(item.invited_by_user_id).email;
return render_admin_invites_list({invite: item});
},
@@ -75,14 +76,21 @@ function populate_invites(invites_data) {
}
function do_revoke_invite() {
- const modal_invite_id = $("#revoke_invite_modal #do_revoke_invite_button").attr("data-invite-id");
- const modal_is_multiuse = $("#revoke_invite_modal #do_revoke_invite_button").attr("data-is-multiuse");
+ const modal_invite_id = $("#revoke_invite_modal #do_revoke_invite_button").attr(
+ "data-invite-id",
+ );
+ const modal_is_multiuse = $("#revoke_invite_modal #do_revoke_invite_button").attr(
+ "data-is-multiuse",
+ );
const revoke_button = meta.current_revoke_invite_user_modal_row.find("button.revoke");
if (modal_invite_id !== meta.invite_id || modal_is_multiuse !== meta.is_multiuse) {
blueslip.error("Invite revoking canceled due to non-matching fields.");
- ui_report.message(i18n.t("Resending encountered an error. Please reload and try again."),
- $("#home-error"), "alert-error");
+ ui_report.message(
+ i18n.t("Resending encountered an error. Please reload and try again."),
+ $("#home-error"),
+ "alert-error",
+ );
}
$("#revoke_invite_modal").modal("hide");
revoke_button.prop("disabled", true).text(i18n.t("Working…"));
@@ -140,11 +148,18 @@ exports.on_load_success = function (invites_data, initialize_event_handlers) {
meta.current_revoke_invite_user_modal_row = row;
meta.invite_id = $(e.currentTarget).attr("data-invite-id");
meta.is_multiuse = $(e.currentTarget).attr("data-is-multiuse");
- const ctx = {is_multiuse: meta.is_multiuse === "true", email: email, referred_by: referred_by};
+ const ctx = {
+ is_multiuse: meta.is_multiuse === "true",
+ email: email,
+ referred_by: referred_by,
+ };
const rendered_revoke_modal = render_settings_revoke_invite_modal(ctx);
$("#revoke_invite_modal_holder").html(rendered_revoke_modal);
$("#revoke_invite_modal #do_revoke_invite_button").attr("data-invite-id", meta.invite_id);
- $("#revoke_invite_modal #do_revoke_invite_button").attr("data-is-multiuse", meta.is_multiuse);
+ $("#revoke_invite_modal #do_revoke_invite_button").attr(
+ "data-is-multiuse",
+ meta.is_multiuse,
+ );
$("#revoke_invite_modal").modal("show");
$("#do_revoke_invite_button").unbind("click");
$("#do_revoke_invite_button").click(do_revoke_invite);
@@ -167,13 +182,18 @@ exports.on_load_success = function (invites_data, initialize_event_handlers) {
});
$("#do_resend_invite_button").click(() => {
- const modal_invite_id = $("#resend_invite_modal #do_resend_invite_button").attr("data-invite-id");
+ const modal_invite_id = $("#resend_invite_modal #do_resend_invite_button").attr(
+ "data-invite-id",
+ );
const resend_button = meta.current_resend_invite_user_modal_row.find("button.resend");
if (modal_invite_id !== meta.invite_id) {
blueslip.error("Invite resending canceled due to non-matching fields.");
- ui_report.message(i18n.t("Resending encountered an error. Please reload and try again."),
- $("#home-error"), "alert-error");
+ ui_report.message(
+ i18n.t("Resending encountered an error. Please reload and try again."),
+ $("#home-error"),
+ "alert-error",
+ );
}
$("#resend_invite_modal").modal("hide");
resend_button.prop("disabled", true).text(i18n.t("Working…"));
diff --git a/static/js/settings_linkifiers.js b/static/js/settings_linkifiers.js
index d1b0166a1c7..d9198c101ae 100644
--- a/static/js/settings_linkifiers.js
+++ b/static/js/settings_linkifiers.js
@@ -52,8 +52,9 @@ exports.populate_filters = function (filters_data) {
filter: {
element: filters_table.closest(".settings-section").find(".search"),
predicate: function (item, value) {
- return item[0].toLowerCase().includes(value) ||
- item[1].toLowerCase().includes(value);
+ return (
+ item[0].toLowerCase().includes(value) || item[1].toLowerCase().includes(value)
+ );
},
onupdate: function () {
ui.reset_scrollbar(filters_table);
@@ -102,53 +103,53 @@ exports.build_page = function () {
});
});
- $(".organization form.admin-filter-form").off("submit").on("submit", function (e) {
- e.preventDefault();
- e.stopPropagation();
- const filter_status = $("#admin-filter-status");
- const pattern_status = $("#admin-filter-pattern-status");
- const format_status = $("#admin-filter-format-status");
- const add_filter_button = $(".new-filter-form button");
- add_filter_button.attr("disabled", "disabled");
- filter_status.hide();
- pattern_status.hide();
- format_status.hide();
- const filter = {};
-
- for (const obj of $(this).serializeArray()) {
- filter[obj.name] = obj.value;
- }
-
- channel.post({
- url: "/json/realm/filters",
- data: $(this).serialize(),
- success: function (data) {
- $("#filter_pattern").val("");
- $("#filter_format_string").val("");
- add_filter_button.removeAttr("disabled");
- filter.id = data.id;
- ui_report.success(i18n.t("Custom filter added!"), filter_status);
- },
- error: function (xhr) {
- const errors = JSON.parse(xhr.responseText).errors;
- add_filter_button.removeAttr("disabled");
- if (errors.pattern !== undefined) {
- xhr.responseText = JSON.stringify({msg: errors.pattern});
- ui_report.error(i18n.t("Failed"), xhr, pattern_status);
- }
- if (errors.url_format_string !== undefined) {
- xhr.responseText = JSON.stringify({msg: errors.url_format_string});
- ui_report.error(i18n.t("Failed"), xhr, format_status);
- }
- if (errors.__all__ !== undefined) {
- xhr.responseText = JSON.stringify({msg: errors.__all__});
- ui_report.error(i18n.t("Failed"), xhr, filter_status);
- }
- },
+ $(".organization form.admin-filter-form")
+ .off("submit")
+ .on("submit", function (e) {
+ e.preventDefault();
+ e.stopPropagation();
+ const filter_status = $("#admin-filter-status");
+ const pattern_status = $("#admin-filter-pattern-status");
+ const format_status = $("#admin-filter-format-status");
+ const add_filter_button = $(".new-filter-form button");
+ add_filter_button.attr("disabled", "disabled");
+ filter_status.hide();
+ pattern_status.hide();
+ format_status.hide();
+ const filter = {};
+
+ for (const obj of $(this).serializeArray()) {
+ filter[obj.name] = obj.value;
+ }
+
+ channel.post({
+ url: "/json/realm/filters",
+ data: $(this).serialize(),
+ success: function (data) {
+ $("#filter_pattern").val("");
+ $("#filter_format_string").val("");
+ add_filter_button.removeAttr("disabled");
+ filter.id = data.id;
+ ui_report.success(i18n.t("Custom filter added!"), filter_status);
+ },
+ error: function (xhr) {
+ const errors = JSON.parse(xhr.responseText).errors;
+ add_filter_button.removeAttr("disabled");
+ if (errors.pattern !== undefined) {
+ xhr.responseText = JSON.stringify({msg: errors.pattern});
+ ui_report.error(i18n.t("Failed"), xhr, pattern_status);
+ }
+ if (errors.url_format_string !== undefined) {
+ xhr.responseText = JSON.stringify({msg: errors.url_format_string});
+ ui_report.error(i18n.t("Failed"), xhr, format_status);
+ }
+ if (errors.__all__ !== undefined) {
+ xhr.responseText = JSON.stringify({msg: errors.__all__});
+ ui_report.error(i18n.t("Failed"), xhr, filter_status);
+ }
+ },
+ });
});
- });
-
-
};
window.settings_linkifiers = exports;
diff --git a/static/js/settings_notifications.js b/static/js/settings_notifications.js
index 0a7e3b3a435..208f4e0974b 100644
--- a/static/js/settings_notifications.js
+++ b/static/js/settings_notifications.js
@@ -54,7 +54,7 @@ function rerender_ui() {
render_stream_specific_notification_row({
stream: stream,
stream_specific_notification_settings:
- settings_config.stream_specific_notification_settings,
+ settings_config.stream_specific_notification_settings,
is_disabled: settings_config.all_notifications().show_push_notifications_tooltip,
}),
);
@@ -70,7 +70,12 @@ function rerender_ui() {
function change_notification_setting(setting, setting_data, status_element) {
const data = {};
data[setting] = JSON.stringify(setting_data);
- settings_ui.do_settings_change(channel.patch, "/json/settings/notifications", data, status_element);
+ settings_ui.do_settings_change(
+ channel.patch,
+ "/json/settings/notifications",
+ data,
+ status_element,
+ );
}
function update_desktop_icon_count_display() {
@@ -97,9 +102,11 @@ exports.set_up = function () {
return;
}
const setting_name = input_elem.attr("name");
- change_notification_setting(setting_name,
- settings_org.get_input_element_value(this),
- input_elem.closest(".subsection-parent").find(".alert-notification"));
+ change_notification_setting(
+ setting_name,
+ settings_org.get_input_element_value(this),
+ input_elem.closest(".subsection-parent").find(".alert-notification"),
+ );
});
update_desktop_icon_count_display();
@@ -118,7 +125,10 @@ exports.set_up = function () {
notification_sound_dropdown.val(page_params.notification_sound);
$("#enable_sounds, #enable_stream_audible_notifications").change(() => {
- if ($("#enable_stream_audible_notifications").prop("checked") || $("#enable_sounds").prop("checked")) {
+ if (
+ $("#enable_stream_audible_notifications").prop("checked") ||
+ $("#enable_sounds").prop("checked")
+ ) {
notification_sound_dropdown.prop("disabled", false);
notification_sound_dropdown.parent().removeClass("control-label-disabled");
} else {
@@ -132,8 +142,10 @@ exports.set_up = function () {
exports.update_page = function () {
for (const setting of settings_config.all_notification_settings) {
- if (setting === "enable_offline_push_notifications"
- && !page_params.realm_push_notifications_enabled) {
+ if (
+ setting === "enable_offline_push_notifications" &&
+ !page_params.realm_push_notifications_enabled
+ ) {
// If push notifications are disabled at the realm level,
// we should just leave the checkbox always off.
continue;
diff --git a/static/js/settings_org.js b/static/js/settings_org.js
index 313cef83105..aba0d757b39 100644
--- a/static/js/settings_org.js
+++ b/static/js/settings_org.js
@@ -11,14 +11,14 @@ exports.reset = function () {
meta.loaded = false;
};
-
exports.maybe_disable_widgets = function () {
if (page_params.is_owner) {
return;
}
$(".organization-box [data-name='auth-methods']")
- .find("input, button, select, checked").attr("disabled", true);
+ .find("input, button, select, checked")
+ .attr("disabled", true);
if (page_params.is_admin) {
$("#deactivate_realm_button").attr("disabled", true);
@@ -27,19 +27,24 @@ exports.maybe_disable_widgets = function () {
}
$(".organization-box [data-name='organization-profile']")
- .find("input, textarea, button, select").attr("disabled", true);
+ .find("input, textarea, button, select")
+ .attr("disabled", true);
$(".organization-box [data-name='organization-settings']")
- .find("input, textarea, button, select").attr("disabled", true);
+ .find("input, textarea, button, select")
+ .attr("disabled", true);
$(".organization-box [data-name='organization-settings']")
- .find(".control-label-disabled").addClass("enabled");
+ .find(".control-label-disabled")
+ .addClass("enabled");
$(".organization-box [data-name='organization-permissions']")
- .find("input, textarea, button, select").attr("disabled", true);
+ .find("input, textarea, button, select")
+ .attr("disabled", true);
$(".organization-box [data-name='organization-permissions']")
- .find(".control-label-disabled").addClass("enabled");
+ .find(".control-label-disabled")
+ .addClass("enabled");
};
exports.get_sorted_options_list = function (option_values_object) {
@@ -68,13 +73,17 @@ exports.get_sorted_options_list = function (option_values_object) {
exports.get_organization_settings_options = () => {
const options = {};
options.create_stream_policy_values = exports.get_sorted_options_list(
- settings_config.create_stream_policy_values);
+ settings_config.create_stream_policy_values,
+ );
options.invite_to_stream_policy_values = exports.get_sorted_options_list(
- settings_config.invite_to_stream_policy_values);
+ settings_config.invite_to_stream_policy_values,
+ );
options.user_group_edit_policy_values = exports.get_sorted_options_list(
- settings_config.user_group_edit_policy_values);
+ settings_config.user_group_edit_policy_values,
+ );
options.private_message_policy_values = exports.get_sorted_options_list(
- settings_config.private_message_policy_values);
+ settings_config.private_message_policy_values,
+ );
return options;
};
@@ -92,7 +101,9 @@ function get_property_value(property_name) {
}
if (property_name === "realm_message_content_delete_limit_minutes") {
- return exports.get_realm_time_limits_in_minutes("realm_message_content_delete_limit_seconds");
+ return exports.get_realm_time_limits_in_minutes(
+ "realm_message_content_delete_limit_seconds",
+ );
}
if (property_name === "realm_waiting_period_setting") {
@@ -182,12 +193,14 @@ function get_subsection_property_elements(element) {
return Array.from(subsection.find(".prop-element"));
}
-const simple_dropdown_properties = ["realm_create_stream_policy",
- "realm_invite_to_stream_policy",
- "realm_user_group_edit_policy",
- "realm_private_message_policy",
- "realm_add_emoji_by_admins_only",
- "realm_user_invite_restriction"];
+const simple_dropdown_properties = [
+ "realm_create_stream_policy",
+ "realm_invite_to_stream_policy",
+ "realm_user_group_edit_policy",
+ "realm_private_message_policy",
+ "realm_add_emoji_by_admins_only",
+ "realm_user_invite_restriction",
+];
function set_property_dropdown_value(property_name) {
$("#id_" + property_name).val(get_property_value(property_name));
@@ -205,8 +218,10 @@ function change_element_block_display_property(elem_id, show_element) {
function set_realm_waiting_period_dropdown() {
const value = get_property_value("realm_waiting_period_setting");
$("#id_realm_waiting_period_setting").val(value);
- change_element_block_display_property("id_realm_waiting_period_threshold",
- value === "custom_days");
+ change_element_block_display_property(
+ "id_realm_waiting_period_threshold",
+ value === "custom_days",
+ );
}
function set_video_chat_provider_dropdown() {
@@ -217,25 +232,37 @@ function set_video_chat_provider_dropdown() {
function set_msg_edit_limit_dropdown() {
const value = get_property_value("realm_msg_edit_limit_setting");
$("#id_realm_msg_edit_limit_setting").val(value);
- change_element_block_display_property("id_realm_message_content_edit_limit_minutes",
- value === "custom_limit");
- settings_ui.disable_sub_setting_onchange(value !== "never",
- "id_realm_allow_community_topic_editing", true);
+ change_element_block_display_property(
+ "id_realm_message_content_edit_limit_minutes",
+ value === "custom_limit",
+ );
+ settings_ui.disable_sub_setting_onchange(
+ value !== "never",
+ "id_realm_allow_community_topic_editing",
+ true,
+ );
}
function set_msg_delete_limit_dropdown() {
const value = get_property_value("realm_msg_delete_limit_setting");
$("#id_realm_msg_delete_limit_setting").val(value);
- change_element_block_display_property("id_realm_message_content_delete_limit_minutes",
- value === "custom_limit");
+ change_element_block_display_property(
+ "id_realm_message_content_delete_limit_minutes",
+ value === "custom_limit",
+ );
}
function set_message_retention_setting_dropdown() {
const value = get_property_value("realm_message_retention_setting");
$("#id_realm_message_retention_setting").val(value);
- change_element_block_display_property("id_realm_message_retention_days",
- value === "retain_for_period");
- if (get_property_value("realm_message_retention_days") === settings_config.retain_message_forever) {
+ change_element_block_display_property(
+ "id_realm_message_retention_days",
+ value === "retain_for_period",
+ );
+ if (
+ get_property_value("realm_message_retention_days") ===
+ settings_config.retain_message_forever
+ ) {
$("#id_realm_message_retention_days").val("");
}
}
@@ -243,19 +270,24 @@ function set_message_retention_setting_dropdown() {
function set_org_join_restrictions_dropdown() {
const value = get_property_value("realm_org_join_restrictions");
$("#id_realm_org_join_restrictions").val(value);
- change_element_block_display_property("allowed_domains_label",
- value === "only_selected_domain");
+ change_element_block_display_property(
+ "allowed_domains_label",
+ value === "only_selected_domain",
+ );
}
function set_message_content_in_email_notifications_visiblity() {
change_element_block_display_property(
"message_content_in_email_notifications_label",
- page_params.realm_message_content_allowed_in_email_notifications);
+ page_params.realm_message_content_allowed_in_email_notifications,
+ );
}
function set_digest_emails_weekday_visibility() {
- change_element_block_display_property("id_realm_digest_weekday",
- page_params.realm_digest_emails_enabled);
+ change_element_block_display_property(
+ "id_realm_digest_weekday",
+ page_params.realm_digest_emails_enabled,
+ );
}
exports.populate_realm_domains = function (realm_domains) {
@@ -263,8 +295,8 @@ exports.populate_realm_domains = function (realm_domains) {
return;
}
- const domains_list = realm_domains.map(
- (realm_domain) => realm_domain.allow_subdomains ? "*." + realm_domain.domain : realm_domain.domain,
+ const domains_list = realm_domains.map((realm_domain) =>
+ realm_domain.allow_subdomains ? "*." + realm_domain.domain : realm_domain.domain,
);
let domains = domains_list.join(", ");
if (domains.length === 0) {
@@ -315,16 +347,22 @@ function update_dependent_subsettings(property_name) {
set_property_dropdown_value(property_name);
} else if (property_name === "realm_waiting_period_threshold") {
set_realm_waiting_period_dropdown();
- } else if (property_name === "realm_video_chat_provider" ||
- property_name.startsWith("realm_zoom")) {
+ } else if (
+ property_name === "realm_video_chat_provider" ||
+ property_name.startsWith("realm_zoom")
+ ) {
set_video_chat_provider_dropdown();
- } else if (property_name === "realm_msg_edit_limit_setting" ||
- property_name === "realm_message_content_edit_limit_minutes") {
+ } else if (
+ property_name === "realm_msg_edit_limit_setting" ||
+ property_name === "realm_message_content_edit_limit_minutes"
+ ) {
set_msg_edit_limit_dropdown();
} else if (property_name === "realm_message_retention_days") {
set_message_retention_setting_dropdown();
- } else if (property_name === "realm_msg_delete_limit_setting" ||
- property_name === "realm_message_content_delete_limit_minutes") {
+ } else if (
+ property_name === "realm_msg_delete_limit_setting" ||
+ property_name === "realm_message_content_delete_limit_minutes"
+ ) {
set_msg_delete_limit_dropdown();
} else if (property_name === "realm_org_join_restrictions") {
set_org_join_restrictions_dropdown();
@@ -376,7 +414,10 @@ exports.sync_realm_settings = function (property) {
property = "message_content_edit_limit_minutes";
} else if (property === "allow_message_editing") {
property = "msg_edit_limit_setting";
- } else if (property === "emails_restricted_to_domains" || property === "disallow_disposable_email_addresses") {
+ } else if (
+ property === "emails_restricted_to_domains" ||
+ property === "disallow_disposable_email_addresses"
+ ) {
property = "org_join_restrictions";
} else if (property === "message_content_delete_limit_seconds") {
property = "message_content_delete_limit_minutes";
@@ -391,7 +432,6 @@ exports.sync_realm_settings = function (property) {
}
};
-
exports.change_save_button_state = function ($element, state) {
function show_hide_element($element, show, fadeout_delay) {
if (show) {
@@ -492,13 +532,14 @@ exports.set_up = function () {
exports.maybe_disable_widgets();
};
-
function get_auth_method_table_data() {
const new_auth_methods = {};
const auth_method_rows = $("#id_realm_authentication_methods").find("tr.method_row");
for (const method_row of auth_method_rows) {
- new_auth_methods[$(method_row).data("method")] = $(method_row).find("input").prop("checked");
+ new_auth_methods[$(method_row).data("method")] = $(method_row)
+ .find("input")
+ .prop("checked");
}
return new_auth_methods;
@@ -562,17 +603,23 @@ exports.init_dropdown_widgets = () => {
null_value: -1,
};
exports.notifications_stream_widget = dropdown_list_widget(
- Object.assign({
- widget_name: "realm_notifications_stream_id",
- value: page_params.realm_notifications_stream_id,
- },
- notification_stream_options));
+ Object.assign(
+ {
+ widget_name: "realm_notifications_stream_id",
+ value: page_params.realm_notifications_stream_id,
+ },
+ notification_stream_options,
+ ),
+ );
exports.signup_notifications_stream_widget = dropdown_list_widget(
- Object.assign({
- widget_name: "realm_signup_notifications_stream_id",
- value: page_params.realm_signup_notifications_stream_id,
- },
- notification_stream_options));
+ Object.assign(
+ {
+ widget_name: "realm_signup_notifications_stream_id",
+ value: page_params.realm_signup_notifications_stream_id,
+ },
+ notification_stream_options,
+ ),
+ );
exports.default_code_language_widget = dropdown_list_widget({
widget_name: "realm_default_code_block_language",
data: Object.keys(pygments_data.langs).map((x) => ({
@@ -633,13 +680,17 @@ exports.build_page = function () {
exports.save_discard_widget_status_handler(subsection);
});
- $(".organization").on("click", ".subsection-header .subsection-changes-discard .button", (e) => {
- e.preventDefault();
- e.stopPropagation();
- get_subsection_property_elements(e.target).forEach(discard_property_element_changes);
- const save_btn_controls = $(e.target).closest(".save-button-controls");
- exports.change_save_button_state(save_btn_controls, "discarded");
- });
+ $(".organization").on(
+ "click",
+ ".subsection-header .subsection-changes-discard .button",
+ (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ get_subsection_property_elements(e.target).forEach(discard_property_element_changes);
+ const save_btn_controls = $(e.target).closest(".save-button-controls");
+ exports.change_save_button_state(save_btn_controls, "discarded");
+ },
+ );
exports.save_organization_settings = function (data, save_button) {
const subsection_parent = save_button.closest(".org-subsection-parent");
@@ -673,42 +724,47 @@ exports.build_page = function () {
if (edit_limit_setting_value === "never") {
data.allow_message_editing = false;
} else if (edit_limit_setting_value === "custom_limit") {
- data.message_content_edit_limit_seconds = exports.parse_time_limit($("#id_realm_message_content_edit_limit_minutes"));
+ data.message_content_edit_limit_seconds = exports.parse_time_limit(
+ $("#id_realm_message_content_edit_limit_minutes"),
+ );
// Disable editing if the parsed time limit is 0 seconds
data.allow_message_editing = !!data.message_content_edit_limit_seconds;
} else {
data.allow_message_editing = true;
- data.message_content_edit_limit_seconds =
- settings_config.msg_edit_limit_dropdown_values.get(
- edit_limit_setting_value,
- ).seconds;
+ data.message_content_edit_limit_seconds = settings_config.msg_edit_limit_dropdown_values.get(
+ edit_limit_setting_value,
+ ).seconds;
}
const delete_limit_setting_value = $("#id_realm_msg_delete_limit_setting").val();
if (delete_limit_setting_value === "never") {
data.allow_message_deleting = false;
} else if (delete_limit_setting_value === "custom_limit") {
- data.message_content_delete_limit_seconds = exports.parse_time_limit($("#id_realm_message_content_delete_limit_minutes"));
+ data.message_content_delete_limit_seconds = exports.parse_time_limit(
+ $("#id_realm_message_content_delete_limit_minutes"),
+ );
// Disable deleting if the parsed time limit is 0 seconds
data.allow_message_deleting = !!data.message_content_delete_limit_seconds;
} else {
data.allow_message_deleting = true;
- data.message_content_delete_limit_seconds =
- settings_config.msg_delete_limit_dropdown_values.get(
- delete_limit_setting_value,
- ).seconds;
+ data.message_content_delete_limit_seconds = settings_config.msg_delete_limit_dropdown_values.get(
+ delete_limit_setting_value,
+ ).seconds;
}
} else if (subsection === "notifications") {
data.notifications_stream_id = JSON.stringify(
- parseInt(exports.notifications_stream_widget.value(), 10));
+ parseInt(exports.notifications_stream_widget.value(), 10),
+ );
data.signup_notifications_stream_id = JSON.stringify(
- parseInt(exports.signup_notifications_stream_widget.value(), 10));
+ parseInt(exports.signup_notifications_stream_widget.value(), 10),
+ );
} else if (subsection === "message_retention") {
const message_retention_setting_value = $("#id_realm_message_retention_setting").val();
if (message_retention_setting_value === "retain_forever") {
data.message_retention_days = JSON.stringify("forever");
} else {
- data.message_retention_days = JSON.stringify(exports.get_input_element_value(
- $("#id_realm_message_retention_days")));
+ data.message_retention_days = JSON.stringify(
+ exports.get_input_element_value($("#id_realm_message_retention_days")),
+ );
}
} else if (subsection === "other_settings") {
const code_block_language_value = exports.default_code_language_widget.value();
@@ -761,7 +817,9 @@ exports.build_page = function () {
data = {};
data.authentication_methods = JSON.stringify(get_auth_method_table_data());
} else if (subsection === "user_defaults") {
- const realm_default_twenty_four_hour_time = $("#id_realm_default_twenty_four_hour_time").val();
+ const realm_default_twenty_four_hour_time = $(
+ "#id_realm_default_twenty_four_hour_time",
+ ).val();
data.default_twenty_four_hour_time = realm_default_twenty_four_hour_time;
}
return data;
@@ -804,32 +862,43 @@ exports.build_page = function () {
e.stopPropagation();
if (e.keyCode === 13) {
e.preventDefault();
- $(e.target).closest(".org-subsection-parent").find(".subsection-changes-save button").click();
+ $(e.target)
+ .closest(".org-subsection-parent")
+ .find(".subsection-changes-save button")
+ .click();
}
});
$("#id_realm_msg_edit_limit_setting").change((e) => {
const msg_edit_limit_dropdown_value = e.target.value;
- change_element_block_display_property("id_realm_message_content_edit_limit_minutes",
- msg_edit_limit_dropdown_value === "custom_limit");
+ change_element_block_display_property(
+ "id_realm_message_content_edit_limit_minutes",
+ msg_edit_limit_dropdown_value === "custom_limit",
+ );
});
$("#id_realm_msg_delete_limit_setting").change((e) => {
const msg_delete_limit_dropdown_value = e.target.value;
- change_element_block_display_property("id_realm_message_content_delete_limit_minutes",
- msg_delete_limit_dropdown_value === "custom_limit");
+ change_element_block_display_property(
+ "id_realm_message_content_delete_limit_minutes",
+ msg_delete_limit_dropdown_value === "custom_limit",
+ );
});
$("#id_realm_message_retention_setting").change((e) => {
const message_retention_setting_dropdown_value = e.target.value;
- change_element_block_display_property("id_realm_message_retention_days",
- message_retention_setting_dropdown_value === "retain_for_period");
+ change_element_block_display_property(
+ "id_realm_message_retention_days",
+ message_retention_setting_dropdown_value === "retain_for_period",
+ );
});
$("#id_realm_waiting_period_setting").change(function () {
const waiting_period_threshold = this.value;
- change_element_block_display_property("id_realm_waiting_period_threshold",
- waiting_period_threshold === "custom_days");
+ change_element_block_display_property(
+ "id_realm_waiting_period_threshold",
+ waiting_period_threshold === "custom_days",
+ );
});
$("#id_realm_org_join_restrictions").change((e) => {
@@ -891,7 +960,10 @@ exports.build_page = function () {
data: data,
success: function () {
$("#add-realm-domain-widget .new-realm-domain").val("");
- $("#add-realm-domain-widget .new-realm-domain-allow-subdomains").prop("checked", false);
+ $("#add-realm-domain-widget .new-realm-domain-allow-subdomains").prop(
+ "checked",
+ false,
+ );
ui_report.success(i18n.t("Added successfully!"), realm_domains_info);
fade_status_element(realm_domains_info);
},
@@ -917,11 +989,19 @@ exports.build_page = function () {
data: data,
success: function () {
if (allow_subdomains) {
- ui_report.success(i18n.t("Update successful: Subdomains allowed for __domain__",
- {domain: domain}), realm_domains_info);
+ ui_report.success(
+ i18n.t("Update successful: Subdomains allowed for __domain__", {
+ domain: domain,
+ }),
+ realm_domains_info,
+ );
} else {
- ui_report.success(i18n.t("Update successful: Subdomains no longer allowed for __domain__",
- {domain: domain}), realm_domains_info);
+ ui_report.success(
+ i18n.t("Update successful: Subdomains no longer allowed for __domain__", {
+ domain: domain,
+ }),
+ realm_domains_info,
+ );
}
fade_status_element(realm_domains_info);
},
@@ -936,7 +1016,6 @@ exports.build_page = function () {
spinner.css({visibility: "hidden"});
upload_text.show();
delete_button.show();
-
}
function realm_icon_logo_upload_start(spinner, upload_text, delete_button) {
@@ -994,7 +1073,6 @@ exports.build_page = function () {
realm_logo.build_realm_logo_widget(upload_realm_logo_or_icon, true);
}
-
$("#deactivate_realm_button").on("click", (e) => {
if (!overlays.is_modal_open()) {
e.preventDefault();
@@ -1011,7 +1089,9 @@ exports.build_page = function () {
url: "/json/realm/deactivate",
error: function (xhr) {
ui_report.error(
- i18n.t("Failed"), xhr, $("#admin-realm-deactivation-status").expectOne(),
+ i18n.t("Failed"),
+ xhr,
+ $("#admin-realm-deactivation-status").expectOne(),
);
},
});
diff --git a/static/js/settings_profile_fields.js b/static/js/settings_profile_fields.js
index 44d3e630279..e5affae652f 100644
--- a/static/js/settings_profile_fields.js
+++ b/static/js/settings_profile_fields.js
@@ -11,7 +11,8 @@ exports.maybe_disable_widgets = function () {
}
$(".organization-box [data-name='profile-field-settings']")
- .find("input, button, select").attr("disabled", true);
+ .find("input, button, select")
+ .attr("disabled", true);
};
let order = [];
@@ -50,20 +51,24 @@ function delete_profile_field(e) {
settings_ui.do_settings_change(
channel.del,
"/json/realm/profile_fields/" + encodeURIComponent($(this).attr("data-profile-field-id")),
- {}, $("#admin-profile-field-status").expectOne());
+ {},
+ $("#admin-profile-field-status").expectOne(),
+ );
update_profile_fields_table_element();
}
function read_choice_field_data_from_form(field_elem) {
const field_data = {};
let field_order = 1;
- $(field_elem).find("div.choice-row").each(function () {
- const text = $(this).find("input")[0].value;
- if (text) {
- field_data[field_order - 1] = {text: text, order: field_order.toString()};
- field_order += 1;
- }
- });
+ $(field_elem)
+ .find("div.choice-row")
+ .each(function () {
+ const text = $(this).find("input")[0].value;
+ if (text) {
+ field_data[field_order - 1] = {text: text, order: field_order.toString()};
+ field_order += 1;
+ }
+ });
return field_data;
}
@@ -112,7 +117,8 @@ function clear_form_data() {
$("#custom_external_account_url_pattern").hide();
$("#profile_field_external_accounts").hide();
$("#profile_field_external_accounts_type").val(
- $("#profile_field_external_accounts_type option:first").val());
+ $("#profile_field_external_accounts_type option:first").val(),
+ );
}
function set_up_create_field_form() {
@@ -166,8 +172,13 @@ function create_profile_field(e) {
field_data: JSON.stringify(field_data),
};
- settings_ui.do_settings_change(channel.post, "/json/realm/profile_fields", form_data,
- $("#admin-add-profile-field-status").expectOne(), opts);
+ settings_ui.do_settings_change(
+ channel.post,
+ "/json/realm/profile_fields",
+ form_data,
+ $("#admin-add-profile-field-status").expectOne(),
+ opts,
+ );
update_profile_fields_table_element();
}
@@ -297,17 +308,29 @@ 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));
+ data.field_data = JSON.stringify(
+ read_field_data_from_form(parseInt(field.type, 10), profile_field.form),
+ );
- settings_ui.do_settings_change(channel.patch, "/json/realm/profile_fields/" + field_id,
- data, profile_field_status);
+ settings_ui.do_settings_change(
+ channel.patch,
+ "/json/realm/profile_fields/" + field_id,
+ data,
+ profile_field_status,
+ );
});
- profile_field.form.find(".edit_profile_field_choices_container").on("input", ".choice-row input", add_choice_row);
- profile_field.form.find(".edit_profile_field_choices_container").on("click", "button.delete-choice", delete_choice_row);
+ profile_field.form
+ .find(".edit_profile_field_choices_container")
+ .on("input", ".choice-row input", add_choice_row);
+ profile_field.form
+ .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($(e.target).closest(".profile-field-form").attr("data-profile-field-id"), 10);
+ const field_id = parseInt(
+ $(e.target).closest(".profile-field-form").attr("data-profile-field-id"),
+ 10,
+ );
const field_form = get_profile_field_info(field_id);
set_up_external_account_field_edit_form(field_form, "");
});
@@ -322,9 +345,12 @@ function update_field_order() {
$(".profile-field-row").each(function () {
order.push(parseInt($(this).attr("data-profile-field-id"), 10));
});
- settings_ui.do_settings_change(channel.patch, "/json/realm/profile_fields",
- {order: JSON.stringify(order)},
- $("#admin-profile-field-status").expectOne());
+ settings_ui.do_settings_change(
+ channel.patch,
+ "/json/realm/profile_fields",
+ {order: JSON.stringify(order)},
+ $("#admin-profile-field-status").expectOne(),
+ );
}
exports.populate_profile_fields = function (profile_fields_data) {
@@ -364,8 +390,8 @@ exports.do_populate_profile_fields = function (profile_fields_data) {
type: exports.field_type_id_to_string(profile_field.type),
choices: choices,
is_choice_field: profile_field.type === field_types.CHOICE.id,
- is_external_account_field: profile_field.type ===
- field_types.EXTERNAL_ACCOUNT.id,
+ is_external_account_field:
+ profile_field.type === field_types.EXTERNAL_ACCOUNT.id,
},
can_modify: page_params.is_admin,
realm_default_external_accounts: page_params.realm_default_external_accounts,
@@ -432,8 +458,7 @@ exports.get_external_account_link = function (field) {
if (field_subtype === "custom") {
field_url_pattern = field.field_data.url_pattern;
} else {
- field_url_pattern =
- page_params.realm_default_external_accounts[field_subtype].url_pattern;
+ field_url_pattern = page_params.realm_default_external_accounts[field_subtype].url_pattern;
}
return field_url_pattern.replace("%(username)s", field.value);
};
diff --git a/static/js/settings_streams.js b/static/js/settings_streams.js
index 738126ee8b6..d011a58d2e7 100644
--- a/static/js/settings_streams.js
+++ b/static/js/settings_streams.js
@@ -14,7 +14,8 @@ exports.maybe_disable_widgets = function () {
}
$(".organization-box [data-name='default-streams-list']")
- .find("input:not(.search), button, select").attr("disabled", true);
+ .find("input:not(.search), button, select")
+ .attr("disabled", true);
};
exports.build_default_stream_table = function () {
@@ -49,8 +50,7 @@ exports.build_default_stream_table = function () {
};
exports.update_default_streams_table = function () {
- if (/#*organization/.test(window.location.hash) ||
- /#*settings/.test(window.location.hash)) {
+ if (/#*organization/.test(window.location.hash) || /#*settings/.test(window.location.hash)) {
$("#admin_default_streams_table").expectOne().find("tr.default_stream_row").remove();
exports.build_default_stream_table();
}
diff --git a/static/js/settings_ui.js b/static/js/settings_ui.js
index 2e0ecdec587..e96458c4cff 100644
--- a/static/js/settings_ui.js
+++ b/static/js/settings_ui.js
@@ -74,12 +74,16 @@ exports.do_settings_change = function (request_method, url, data, status_element
// * disable_on_uncheck is boolean, true if sub setting should be disabled
// when main setting unchecked.
exports.disable_sub_setting_onchange = function (is_checked, sub_setting_id, disable_on_uncheck) {
- if (is_checked && disable_on_uncheck || !is_checked && !disable_on_uncheck) {
+ if ((is_checked && disable_on_uncheck) || (!is_checked && !disable_on_uncheck)) {
$("#" + sub_setting_id).attr("disabled", false);
- $("#" + sub_setting_id + "_label").parent().removeClass("control-label-disabled");
- } else if (is_checked && !disable_on_uncheck || !is_checked && disable_on_uncheck) {
+ $("#" + sub_setting_id + "_label")
+ .parent()
+ .removeClass("control-label-disabled");
+ } else if ((is_checked && !disable_on_uncheck) || (!is_checked && disable_on_uncheck)) {
$("#" + sub_setting_id).attr("disabled", "disabled");
- $("#" + sub_setting_id + "_label").parent().addClass("control-label-disabled");
+ $("#" + sub_setting_id + "_label")
+ .parent()
+ .addClass("control-label-disabled");
}
};
diff --git a/static/js/settings_user_groups.js b/static/js/settings_user_groups.js
index d68df88a831..8c10d5b2d64 100644
--- a/static/js/settings_user_groups.js
+++ b/static/js/settings_user_groups.js
@@ -42,13 +42,15 @@ exports.populate_user_groups = function () {
const user_groups_array = user_groups.get_realm_user_groups();
for (const data of user_groups_array) {
- user_groups_section.append(render_admin_user_group_list({
- user_group: {
- name: data.name,
- id: data.id,
- description: data.description,
- },
- }));
+ user_groups_section.append(
+ render_admin_user_group_list({
+ user_group: {
+ name: data.name,
+ id: data.id,
+ description: data.description,
+ },
+ }),
+ );
const pill_container = $('.pill-container[data-group-pills="' + data.id + '"]');
const pills = user_pill.create_pills(pill_container);
@@ -78,9 +80,12 @@ exports.populate_user_groups = function () {
pill_container.on("click", (e) => {
e.stopPropagation();
});
- pill_container.find(".pill").hover(() => {
- pill_container.find(".pill").find(".exit").css("opacity", "0.5");
- }, () => {});
+ pill_container.find(".pill").hover(
+ () => {
+ pill_container.find(".pill").find(".exit").css("opacity", "0.5");
+ },
+ () => {},
+ );
}
update_membership(data.id);
@@ -89,16 +94,23 @@ exports.populate_user_groups = function () {
const group_data = user_groups.get_user_group_from_id(data.id);
const original_group = Array.from(group_data.members);
const same_groups = _.isEqual(_.sortBy(draft_group), _.sortBy(original_group));
- const description = $("#user-groups #" + data.id + " .description").text().trim();
- const name = $("#user-groups #" + data.id + " .name").text().trim();
+ const description = $("#user-groups #" + data.id + " .description")
+ .text()
+ .trim();
+ const name = $("#user-groups #" + data.id + " .name")
+ .text()
+ .trim();
const user_group_status = $("#user-groups #" + data.id + " .user-group-status");
if (user_group_status.is(":visible")) {
return false;
}
- if (group_data.description === description && group_data.name === name &&
- (!draft_group.length || same_groups)) {
+ if (
+ group_data.description === description &&
+ group_data.name === name &&
+ (!draft_group.length || same_groups)
+ ) {
return false;
}
return true;
@@ -112,13 +124,11 @@ exports.populate_user_groups = function () {
const saved_button = $("#user-groups #" + data.id + " .save-status.sea-green");
const save_instructions = $("#user-groups #" + data.id + " .save-instructions");
- if (is_user_group_changed() &&
- !cancel_button.is(":visible")) {
+ if (is_user_group_changed() && !cancel_button.is(":visible")) {
saved_button.fadeOut(0);
cancel_button.css({display: "inline-block", opacity: "0"}).fadeTo(400, 1);
save_instructions.css({display: "block", opacity: "0"}).fadeTo(400, 1);
- } else if (!is_user_group_changed() &&
- cancel_button.is(":visible")) {
+ } else if (!is_user_group_changed() && cancel_button.is(":visible")) {
cancel_button.fadeOut();
save_instructions.fadeOut();
}
@@ -131,7 +141,11 @@ exports.populate_user_groups = function () {
if (!saved_button.is(":visible")) {
cancel_button.fadeOut(0);
save_instructions.fadeOut(0);
- saved_button.css({display: "inline-block", opacity: "0"}).fadeTo(400, 1).delay(2000).fadeTo(400, 0);
+ saved_button
+ .css({display: "inline-block", opacity: "0"})
+ .fadeTo(400, 1)
+ .delay(2000)
+ .fadeTo(400, 0);
}
}
@@ -160,8 +174,12 @@ exports.populate_user_groups = function () {
function save_name_desc() {
const user_group_status = $("#user-groups #" + data.id + " .user-group-status");
const group_data = user_groups.get_user_group_from_id(data.id);
- const description = $("#user-groups #" + data.id + " .description").text().trim();
- const name = $("#user-groups #" + data.id + " .name").text().trim();
+ const description = $("#user-groups #" + data.id + " .description")
+ .text()
+ .trim();
+ const name = $("#user-groups #" + data.id + " .name")
+ .text()
+ .trim();
if (group_data.description === description && group_data.name === name) {
return;
@@ -194,8 +212,10 @@ exports.populate_user_groups = function () {
return true;
}
- const blur_exceptions = _.without([".pill-container", ".name", ".description", ".input", ".delete"],
- except_class);
+ const blur_exceptions = _.without(
+ [".pill-container", ".name", ".description", ".input", ".delete"],
+ except_class,
+ );
if ($(event.relatedTarget).closest("#user-groups #" + data.id).length) {
return blur_exceptions.some(
(class_name) => $(event.relatedTarget).closest(class_name).length,
@@ -212,8 +232,10 @@ exports.populate_user_groups = function () {
if (do_not_blur(class_name, event)) {
return;
}
- if ($(event.relatedTarget).closest("#user-groups #" + data.id) &&
- $(event.relatedTarget).closest(".save-status.btn-danger").length) {
+ if (
+ $(event.relatedTarget).closest("#user-groups #" + data.id) &&
+ $(event.relatedTarget).closest(".save-status.btn-danger").length
+ ) {
exports.reload();
return;
}
@@ -264,39 +286,41 @@ exports.set_up = function () {
meta.loaded = true;
exports.populate_user_groups();
- $(".organization form.admin-user-group-form").off("submit").on("submit", function (e) {
- e.preventDefault();
- e.stopPropagation();
+ $(".organization form.admin-user-group-form")
+ .off("submit")
+ .on("submit", function (e) {
+ e.preventDefault();
+ e.stopPropagation();
- const user_group_status = $("#admin-user-group-status");
+ const user_group_status = $("#admin-user-group-status");
- const group = {
- members: JSON.stringify([people.my_current_user_id()]),
- };
+ const group = {
+ members: JSON.stringify([people.my_current_user_id()]),
+ };
- for (const obj of $(this).serializeArray()) {
- if (obj.value.trim() === "") {
- continue;
+ for (const obj of $(this).serializeArray()) {
+ if (obj.value.trim() === "") {
+ continue;
+ }
+ group[obj.name] = obj.value;
}
- group[obj.name] = obj.value;
- }
- channel.post({
- url: "/json/user_groups/create",
- data: group,
- success: function () {
- user_group_status.hide();
- ui_report.success(i18n.t("User group added!"), user_group_status);
- $("form.admin-user-group-form input[type='text']").val("");
- },
- error: function (xhr) {
- user_group_status.hide();
- const errors = JSON.parse(xhr.responseText).msg;
- xhr.responseText = JSON.stringify({msg: errors});
- ui_report.error(i18n.t("Failed"), xhr, user_group_status);
- },
+ channel.post({
+ url: "/json/user_groups/create",
+ data: group,
+ success: function () {
+ user_group_status.hide();
+ ui_report.success(i18n.t("User group added!"), user_group_status);
+ $("form.admin-user-group-form input[type='text']").val("");
+ },
+ error: function (xhr) {
+ user_group_status.hide();
+ const errors = JSON.parse(xhr.responseText).msg;
+ xhr.responseText = JSON.stringify({msg: errors});
+ ui_report.error(i18n.t("Failed"), xhr, user_group_status);
+ },
+ });
});
- });
$("#user-groups").on("click", ".delete", function () {
const group_id = parseInt($(this).parents(".user-group").attr("id"), 10);
diff --git a/static/js/settings_users.js b/static/js/settings_users.js
index 32147f7472a..e50637c3b39 100644
--- a/static/js/settings_users.js
+++ b/static/js/settings_users.js
@@ -22,10 +22,7 @@ function compare_a_b(a, b) {
function sort_email(a, b) {
const email_a = settings_data.email_for_user_settings(a) || "";
const email_b = settings_data.email_for_user_settings(b) || "";
- return compare_a_b(
- email_a.toLowerCase(),
- email_b.toLowerCase(),
- );
+ return compare_a_b(email_a.toLowerCase(), email_b.toLowerCase());
}
function sort_bot_email(a, b) {
@@ -38,8 +35,12 @@ function sort_bot_email(a, b) {
function sort_role(a, b) {
function role(user) {
- if (user.is_admin) { return 0; }
- if (user.is_guest) { return 2; }
+ if (user.is_admin) {
+ return 0;
+ }
+ if (user.is_guest) {
+ return 2;
+ }
return 1; // member
}
return compare_a_b(role(a), role(b));
@@ -50,10 +51,7 @@ function sort_bot_owner(a, b) {
return (bot.bot_owner_full_name || "").toLowerCase();
}
- return compare_a_b(
- owner_name(a),
- owner_name(b),
- );
+ return compare_a_b(owner_name(a), owner_name(b));
}
function sort_last_active(a, b) {
@@ -93,8 +91,11 @@ function update_view_on_deactivate(row) {
if (user_role) {
const user_id = row.data("user-id");
- user_role.text("%state (%role)".replace("%state", i18n.t("Deactivated")).
- replace("%role", people.get_user_type(user_id)));
+ user_role.text(
+ "%state (%role)"
+ .replace("%state", i18n.t("Deactivated"))
+ .replace("%role", people.get_user_type(user_id)),
+ );
}
}
@@ -228,7 +229,7 @@ function human_info(person) {
info.can_modify = page_params.is_admin;
info.is_current_user = people.is_my_user_id(person.user_id);
- info.cannot_deactivate = info.is_current_user || person.is_owner && !page_params.is_owner;
+ info.cannot_deactivate = info.is_current_user || (person.is_owner && !page_params.is_owner);
info.display_email = settings_data.email_for_user_settings(person);
if (info.is_active) {
@@ -260,8 +261,10 @@ section.bots.create_table = () => {
if (!item) {
return false;
}
- return item.full_name.toLowerCase().includes(value) ||
- item.display_email.toLowerCase().includes(value);
+ return (
+ item.full_name.toLowerCase().includes(value) ||
+ item.display_email.toLowerCase().includes(value)
+ );
},
onupdate: reset_scrollbar($bots_table),
},
@@ -370,7 +373,9 @@ exports.update_user_data = function (user_id, new_data) {
function start_data_load() {
loading.make_indicator($("#admin_page_users_loading_indicator"), {text: "Loading..."});
- loading.make_indicator($("#admin_page_deactivated_users_loading_indicator"), {text: "Loading..."});
+ loading.make_indicator($("#admin_page_deactivated_users_loading_indicator"), {
+ text: "Loading...",
+ });
$("#admin_deactivated_users_table").hide();
$("#admin_users_table").hide();
@@ -393,7 +398,9 @@ function open_human_form(person) {
overlays.open_modal("#admin-human-form");
set_user_role_dropdown(person);
if (!page_params.is_owner) {
- $("#user-role-select").find("option[value=" + settings_config.user_role_values.owner.code + "]").hide();
+ $("#user-role-select")
+ .find("option[value=" + settings_config.user_role_values.owner.code + "]")
+ .hide();
}
const element = "#admin-human-form .custom-profile-field-form";
@@ -504,7 +511,6 @@ function confirm_deactivation(row, user_id, status_field) {
};
const url = "/json/users/" + encodeURIComponent(user_id);
settings_ui.do_settings_change(channel.del, url, {}, status_field, opts);
-
}
modal_elem.modal("hide");
@@ -546,7 +552,6 @@ function handle_bot_deactivation(tbody, status_field) {
},
};
settings_ui.do_settings_change(channel.del, url, {}, status_field, opts);
-
});
}
diff --git a/static/js/setup.js b/static/js/setup.js
index 2f33c2a252a..5daaf8814f5 100644
--- a/static/js/setup.js
+++ b/static/js/setup.js
@@ -12,7 +12,10 @@ $(() => {
// Display loading indicator. This disappears after the first
// get_events completes.
if (!page_params.needs_tutorial) {
- loading.make_indicator($("#page_loading_indicator"), {text: "Loading...", abs_positioned: true});
+ loading.make_indicator($("#page_loading_indicator"), {
+ text: "Loading...",
+ abs_positioned: true,
+ });
}
// This is an issue fix where in jQuery v3 the result of outerHeight on a node
diff --git a/static/js/stats/stats.js b/static/js/stats/stats.js
index 84349040ceb..3b1e549e8f1 100644
--- a/static/js/stats/stats.js
+++ b/static/js/stats/stats.js
@@ -52,7 +52,7 @@ function format_date(date, include_hour) {
const str = hour >= 12 ? "PM" : "AM";
- return month_str + " " + day + ", " + hour % 12 + ":00" + str;
+ return month_str + " " + day + ", " + (hour % 12) + ":00" + str;
}
return month_str + " " + day + ", " + year;
}
@@ -64,7 +64,11 @@ function update_last_full_update(end_times) {
last_full_update = Math.min(last_full_update, end_times[end_times.length - 1]);
const update_time = new Date(last_full_update * 1000);
- const locale_date = update_time.toLocaleDateString("en-US", {year: "numeric", month: "long", day: "numeric"});
+ const locale_date = update_time.toLocaleDateString("en-US", {
+ year: "numeric",
+ month: "long",
+ day: "numeric",
+ });
const locale_time = update_time.toLocaleTimeString().replace(":00 ", " ");
$("#id_last_full_update").text(locale_time + " on " + locale_date);
@@ -94,16 +98,24 @@ function populate_messages_sent_over_time(data) {
const text = dates.map((date) => date_formatter(date));
const common = {x: dates, type: type, hoverinfo: "none", text: text};
return {
- human: { // 5062a0
- name: i18n.t("Humans"), y: values.human, marker: {color: "#5f6ea0"},
+ human: {
+ // 5062a0
+ name: i18n.t("Humans"),
+ y: values.human,
+ marker: {color: "#5f6ea0"},
...common,
},
- bot: { // a09b5f bbb56e
- name: i18n.t("Bots"), y: values.bot, marker: {color: "#b7b867"},
+ bot: {
+ // a09b5f bbb56e
+ name: i18n.t("Bots"),
+ y: values.bot,
+ marker: {color: "#b7b867"},
...common,
},
me: {
- name: i18n.t("Me"), y: values.me, marker: {color: "#be6d68"},
+ name: i18n.t("Me"),
+ y: values.me,
+ marker: {color: "#be6d68"},
...common,
},
};
@@ -121,28 +133,39 @@ function populate_messages_sent_over_time(data) {
},
yaxis: {fixedrange: true, rangemode: "tozero"},
legend: {
- x: 0.62, y: 1.12, orientation: "h", font: font_14pt,
+ x: 0.62,
+ y: 1.12,
+ orientation: "h",
+ font: font_14pt,
},
font: font_14pt,
};
function make_rangeselector(x, y, button1, button2) {
- return {x: x, y: y,
- buttons: [
- {stepmode: "backward", ...button1},
- {stepmode: "backward", ...button2},
- {step: "all", label: "All time"}]};
+ return {
+ x: x,
+ y: y,
+ buttons: [
+ {stepmode: "backward", ...button1},
+ {stepmode: "backward", ...button2},
+ {step: "all", label: "All time"},
+ ],
+ };
}
// This is also the cumulative rangeselector
const daily_rangeselector = make_rangeselector(
- 0.68, -0.62,
+ 0.68,
+ -0.62,
{count: 10, label: i18n.t("Last 10 days"), step: "day"},
- {count: 30, label: i18n.t("Last 30 days"), step: "day"});
+ {count: 30, label: i18n.t("Last 30 days"), step: "day"},
+ );
const weekly_rangeselector = make_rangeselector(
- 0.656, -0.62,
+ 0.656,
+ -0.62,
{count: 2, label: i18n.t("Last 2 months"), step: "month"},
- {count: 6, label: i18n.t("Last 6 months"), step: "month"});
+ {count: 6, label: i18n.t("Last 6 months"), step: "month"},
+ );
function add_hover_handler() {
document.getElementById("id_messages_sent_over_time").on("plotly_hover", (data) => {
@@ -168,9 +191,10 @@ function populate_messages_sent_over_time(data) {
});
}
- const start_dates = data.end_times.map((timestamp) =>
- // data.end_times are the ends of hour long intervals.
- new Date(timestamp * 1000 - 60 * 60 * 1000),
+ const start_dates = data.end_times.map(
+ (timestamp) =>
+ // data.end_times are the ends of hour long intervals.
+ new Date(timestamp * 1000 - 60 * 60 * 1000),
);
function aggregate_data(aggregation) {
@@ -192,9 +216,11 @@ function populate_messages_sent_over_time(data) {
let current = {human: 0, bot: 0, me: 0};
let i_init = 0;
if (is_boundary(start_dates[0])) {
- current = {human: data.everyone.human[0],
- bot: data.everyone.bot[0],
- me: data.user.human[0]};
+ current = {
+ human: data.everyone.human[0],
+ bot: data.everyone.bot[0],
+ me: data.user.human[0],
+ };
i_init = 1;
}
for (let i = i_init; i < start_dates.length; i += 1) {
@@ -213,9 +239,12 @@ function populate_messages_sent_over_time(data) {
values.bot.push(current.bot);
values.me.push(current.me);
return {
- dates: dates, values: values,
- last_value_is_partial: !is_boundary(new Date(
- start_dates[start_dates.length - 1].getTime() + 60 * 60 * 1000))};
+ dates: dates,
+ values: values,
+ last_value_is_partial: !is_boundary(
+ new Date(start_dates[start_dates.length - 1].getTime() + 60 * 60 * 1000),
+ ),
+ };
}
// Generate traces
@@ -239,8 +268,11 @@ function populate_messages_sent_over_time(data) {
const weekly_traces = make_traces(info.dates, info.values, "bar", date_formatter);
const dates = data.end_times.map((timestamp) => new Date(timestamp * 1000));
- values = {human: partial_sums(data.everyone.human), bot: partial_sums(data.everyone.bot),
- me: partial_sums(data.user.human)};
+ values = {
+ human: partial_sums(data.everyone.human),
+ bot: partial_sums(data.everyone.bot),
+ me: partial_sums(data.user.human),
+ };
date_formatter = function (date) {
return format_date(date, true);
};
@@ -267,8 +299,12 @@ function populate_messages_sent_over_time(data) {
}
layout.xaxis.rangeselector = rangeselector;
if (clicked_cumulative || initial_draw) {
- Plotly.newPlot("id_messages_sent_over_time",
- [traces.me, traces.human, traces.bot], layout, {displayModeBar: false});
+ Plotly.newPlot(
+ "id_messages_sent_over_time",
+ [traces.me, traces.human, traces.bot],
+ layout,
+ {displayModeBar: false},
+ );
add_hover_handler();
} else {
Plotly.deleteTraces("id_messages_sent_over_time", [0, 1, 2]);
@@ -316,7 +352,7 @@ function round_to_percentages(values, total) {
if (x === 0) {
return "0%";
}
- const unrounded = x / total * 100;
+ const unrounded = (x / total) * 100;
const precision = Math.min(
6, // this is the max precision (two #, 4 decimal points; 99.9999%).
@@ -381,7 +417,10 @@ function populate_messages_sent_by_client(data) {
// sort labels so that values are descending in the default view
const everyone_month = compute_summary_chart_data(
- data.everyone, 30, data.display_order.slice(0, 12));
+ data.everyone,
+ 30,
+ data.display_order.slice(0, 12),
+ );
const label_values = [];
for (let i = 0; i < everyone_month.values.length; i += 1) {
label_values.push({
@@ -391,7 +430,9 @@ function populate_messages_sent_by_client(data) {
}
label_values.sort((a, b) => b.value - a.value);
const labels = [];
- label_values.forEach((item) => { labels.push(item.label); });
+ label_values.forEach((item) => {
+ labels.push(item.label);
+ });
function make_plot_data(time_series_data, num_steps) {
const plot_data = compute_summary_chart_data(time_series_data, num_steps, labels);
@@ -403,7 +444,9 @@ function populate_messages_sent_by_client(data) {
if (plot_data.values[i] > 0) {
annotations.values.push(plot_data.values[i]);
annotations.labels.push(plot_data.labels[i]);
- annotations.text.push(" " + plot_data.labels[i] + " (" + plot_data.percentages[i] + ")");
+ annotations.text.push(
+ " " + plot_data.labels[i] + " (" + plot_data.percentages[i] + ")",
+ );
}
}
return {
@@ -469,10 +512,12 @@ function populate_messages_sent_by_client(data) {
const data_ = plot_data[user_button][time_button];
layout.height = layout.margin.b + data_.trace.x.length * 30;
layout.xaxis.range = [0, Math.max(...data_.trace.x) * 1.3];
- Plotly.newPlot("id_messages_sent_by_client",
- [data_.trace, data_.trace_annotations],
- layout,
- {displayModeBar: false, staticPlot: true});
+ Plotly.newPlot(
+ "id_messages_sent_by_client",
+ [data_.trace, data_.trace_annotations],
+ layout,
+ {displayModeBar: false, staticPlot: true},
+ );
}
draw_plot();
@@ -550,8 +595,9 @@ function populate_messages_sent_by_message_type(data) {
colors: ["#68537c", "#be6d68", "#b3b348"],
},
},
- total_str: "<b>Total messages:</b> " + plot_data.total.toString().
- replace(/\B(?=(\d{3})+(?!\d))/g, ","),
+ total_str:
+ "<b>Total messages:</b> " +
+ plot_data.total.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","),
};
}
@@ -593,10 +639,12 @@ function populate_messages_sent_by_message_type(data) {
function draw_plot() {
$("#id_messages_sent_by_message_type > div").removeClass("spinner");
- Plotly.newPlot("id_messages_sent_by_message_type",
- [plot_data[user_button][time_button].trace],
- layout,
- {displayModeBar: false});
+ Plotly.newPlot(
+ "id_messages_sent_by_message_type",
+ [plot_data[user_button][time_button].trace],
+ layout,
+ {displayModeBar: false},
+ );
totaldiv.innerHTML = plot_data[user_button][time_button].total_str;
}
@@ -635,12 +683,15 @@ function populate_number_of_users(data) {
fixedrange: true,
rangeslider: {bordercolor: "#D8D8D8", borderwidth: 1},
rangeselector: {
- x: 0.64, y: -0.79,
+ x: 0.64,
+ y: -0.79,
buttons: [
{count: 2, label: i18n.t("Last 2 months"), step: "month", stepmode: "backward"},
{count: 6, label: i18n.t("Last 6 months"), step: "month", stepmode: "backward"},
{step: "all", label: i18n.t("All time")},
- ]}},
+ ],
+ },
+ },
yaxis: {fixedrange: true, rangemode: "tozero"},
font: font_14pt,
};
@@ -671,7 +722,10 @@ function populate_number_of_users(data) {
values[trace.curveNumber] = trace.y;
});
const hover_value_ids = [
- "users_hover_1day_value", "users_hover_15day_value", "users_hover_all_time_value"];
+ "users_hover_1day_value",
+ "users_hover_15day_value",
+ "users_hover_all_time_value",
+ ];
for (let i = 0; i < values.length; i += 1) {
if (values[i] !== null) {
document.getElementById(hover_value_ids[i]).style.display = "inline";
@@ -692,7 +746,9 @@ function populate_number_of_users(data) {
// Redraw the plot every time for simplicity. If we have perf problems with this in the
// future, we can copy the update behavior from populate_messages_sent_over_time
function draw_or_update_plot(trace) {
- $("#1day_actives_button, #15day_actives_button, #all_time_actives_button").removeClass("selected");
+ $("#1day_actives_button, #15day_actives_button, #all_time_actives_button").removeClass(
+ "selected",
+ );
Plotly.newPlot("id_number_of_users", [trace], layout, {displayModeBar: false});
add_hover_handler();
}
@@ -729,11 +785,15 @@ function populate_messages_read_over_time(data) {
const common = {x: dates, type: type, hoverinfo: "none", text: text};
return {
everyone: {
- name: i18n.t("Everyone"), y: values.everyone, marker: {color: "#5f6ea0"},
+ name: i18n.t("Everyone"),
+ y: values.everyone,
+ marker: {color: "#5f6ea0"},
...common,
},
me: {
- name: i18n.t("Me"), y: values.me, marker: {color: "#be6d68"},
+ name: i18n.t("Me"),
+ y: values.me,
+ marker: {color: "#be6d68"},
...common,
},
};
@@ -751,28 +811,39 @@ function populate_messages_read_over_time(data) {
},
yaxis: {fixedrange: true, rangemode: "tozero"},
legend: {
- x: 0.62, y: 1.12, orientation: "h", font: font_14pt,
+ x: 0.62,
+ y: 1.12,
+ orientation: "h",
+ font: font_14pt,
},
font: font_14pt,
};
function make_rangeselector(x, y, button1, button2) {
- return {x: x, y: y,
- buttons: [
- {stepmode: "backward", ...button1},
- {stepmode: "backward", ...button2},
- {step: "all", label: "All time"}]};
+ return {
+ x: x,
+ y: y,
+ buttons: [
+ {stepmode: "backward", ...button1},
+ {stepmode: "backward", ...button2},
+ {step: "all", label: "All time"},
+ ],
+ };
}
// This is also the cumulative rangeselector
const daily_rangeselector = make_rangeselector(
- 0.68, -0.62,
+ 0.68,
+ -0.62,
{count: 10, label: i18n.t("Last 10 days"), step: "day"},
- {count: 30, label: i18n.t("Last 30 days"), step: "day"});
+ {count: 30, label: i18n.t("Last 30 days"), step: "day"},
+ );
const weekly_rangeselector = make_rangeselector(
- 0.656, -0.62,
+ 0.656,
+ -0.62,
{count: 2, label: i18n.t("Last 2 months"), step: "month"},
- {count: 6, label: i18n.t("Last 6 months"), step: "month"});
+ {count: 6, label: i18n.t("Last 6 months"), step: "month"},
+ );
function add_hover_handler() {
document.getElementById("id_messages_read_over_time").on("plotly_hover", (data) => {
@@ -798,9 +869,10 @@ function populate_messages_read_over_time(data) {
});
}
- const start_dates = data.end_times.map((timestamp) =>
- // data.end_times are the ends of hour long intervals.
- new Date(timestamp * 1000 - 60 * 60 * 1000),
+ const start_dates = data.end_times.map(
+ (timestamp) =>
+ // data.end_times are the ends of hour long intervals.
+ new Date(timestamp * 1000 - 60 * 60 * 1000),
);
function aggregate_data(aggregation) {
@@ -822,8 +894,7 @@ function populate_messages_read_over_time(data) {
let current = {everyone: 0, me: 0};
let i_init = 0;
if (is_boundary(start_dates[0])) {
- current = {everyone: data.everyone.read[0],
- me: data.user.read[0]};
+ current = {everyone: data.everyone.read[0], me: data.user.read[0]};
i_init = 1;
}
for (let i = i_init; i < start_dates.length; i += 1) {
@@ -839,9 +910,12 @@ function populate_messages_read_over_time(data) {
values.everyone.push(current.everyone);
values.me.push(current.me);
return {
- dates: dates, values: values,
- last_value_is_partial: !is_boundary(new Date(
- start_dates[start_dates.length - 1].getTime() + 60 * 60 * 1000))};
+ dates: dates,
+ values: values,
+ last_value_is_partial: !is_boundary(
+ new Date(start_dates[start_dates.length - 1].getTime() + 60 * 60 * 1000),
+ ),
+ };
}
// Generate traces
@@ -865,8 +939,7 @@ function populate_messages_read_over_time(data) {
const weekly_traces = make_traces(info.dates, info.values, "bar", date_formatter);
const dates = data.end_times.map((timestamp) => new Date(timestamp * 1000));
- values = {everyone: partial_sums(data.everyone.read),
- me: partial_sums(data.user.read)};
+ values = {everyone: partial_sums(data.everyone.read), me: partial_sums(data.user.read)};
date_formatter = function (date) {
return format_date(date, true);
};
@@ -879,7 +952,9 @@ function populate_messages_read_over_time(data) {
let clicked_cumulative = false;
function draw_or_update_plot(rangeselector, traces, last_value_is_partial, initial_draw) {
- $("#read_daily_button, #read_weekly_button, #read_cumulative_button").removeClass("selected");
+ $("#read_daily_button, #read_weekly_button, #read_cumulative_button").removeClass(
+ "selected",
+ );
$("#id_messages_read_over_time > div").removeClass("spinner");
if (initial_draw) {
traces.everyone.visible = true;
@@ -891,8 +966,9 @@ function populate_messages_read_over_time(data) {
}
layout.xaxis.rangeselector = rangeselector;
if (clicked_cumulative || initial_draw) {
- Plotly.newPlot("id_messages_read_over_time",
- [traces.me, traces.everyone], layout, {displayModeBar: false});
+ Plotly.newPlot("id_messages_read_over_time", [traces.me, traces.everyone], layout, {
+ displayModeBar: false,
+ });
add_hover_handler();
} else {
Plotly.deleteTraces("id_messages_read_over_time", [0, 1]);
@@ -962,10 +1038,7 @@ get_chart_data(
populate_messages_sent_by_message_type,
);
-get_chart_data(
- {chart_name: "number_of_humans", min_length: "10"},
- populate_number_of_users,
-);
+get_chart_data({chart_name: "number_of_humans", min_length: "10"}, populate_number_of_users);
get_chart_data(
{chart_name: "messages_read_over_time", min_length: "10"},
diff --git a/static/js/stream_color.js b/static/js/stream_color.js
index b5dee5f45ae..f163772edcc 100644
--- a/static/js/stream_color.js
+++ b/static/js/stream_color.js
@@ -15,10 +15,19 @@ function update_table_stream_color(table, stream_name, color) {
const $label = $(label);
if ($.trim($label.text()) === stream_name) {
const messages = $label.closest(".recipient_row").children(".message_row");
- messages.children(".messagebox").css("box-shadow", "inset 2px 0px 0px 0px " + style + ", -1px 0px 0px 0px " + style);
- messages.children(".date_row").css("box-shadow", "inset 2px 0px 0px 0px " + style + ", -1px 0px 0px 0px " + style);
- $label.css({background: style,
- "border-left-color": style});
+ messages
+ .children(".messagebox")
+ .css(
+ "box-shadow",
+ "inset 2px 0px 0px 0px " + style + ", -1px 0px 0px 0px " + style,
+ );
+ messages
+ .children(".date_row")
+ .css(
+ "box-shadow",
+ "inset 2px 0px 0px 0px " + style + ", -1px 0px 0px 0px " + style,
+ );
+ $label.css({background: style, "border-left-color": style});
$label.removeClass(exports.color_classes);
$label.addClass(color_class);
}
@@ -66,8 +75,19 @@ exports.update_stream_color = function (sub, color, opts) {
// The swatch in the subscription row header.
$(".stream-row[data-stream-id='" + stream_id + "'] .icon").css("background-color", color);
// The swatch in the color picker.
- exports.set_colorpicker_color($("#subscription_overlay .subscription_settings[data-stream-id='" + stream_id + "'] .colorpicker"), color);
- $("#subscription_overlay .subscription_settings[data-stream-id='" + stream_id + "'] .large-icon").css("color", color);
+ exports.set_colorpicker_color(
+ $(
+ "#subscription_overlay .subscription_settings[data-stream-id='" +
+ stream_id +
+ "'] .colorpicker",
+ ),
+ color,
+ );
+ $(
+ "#subscription_overlay .subscription_settings[data-stream-id='" +
+ stream_id +
+ "'] .large-icon",
+ ).css("color", color);
if (opts.update_historical) {
update_historical_message_color(sub.name, color);
@@ -109,8 +129,7 @@ exports.initialize = function () {
// sRGB color component for dark label text.
// 0x33 to match the color #333333 set by Bootstrap.
const label_color = 0x33;
- const lightness = colorspace.luminance_to_lightness(
- colorspace.sRGB_to_linear(label_color));
+ const lightness = colorspace.luminance_to_lightness(colorspace.sRGB_to_linear(label_color));
// Compute midpoint lightness between that and white (100).
lightness_threshold = (lightness + 100) / 2;
@@ -151,8 +170,7 @@ exports.get_color_class = _.memoize((color) => {
}
// Compute perceived lightness as CIE L*.
- const lightness = colorspace.luminance_to_lightness(
- colorspace.rgb_luminance(channel));
+ const lightness = colorspace.luminance_to_lightness(colorspace.rgb_luminance(channel));
// Determine if we're past the midpoint between the
// dark and light label lightness.
diff --git a/static/js/stream_create.js b/static/js/stream_create.js
index 0c245cd4383..0949e0c8409 100644
--- a/static/js/stream_create.js
+++ b/static/js/stream_create.js
@@ -20,12 +20,18 @@ const stream_subscription_error = (function () {
const self = {};
self.report_no_subs_to_stream = function () {
- $("#stream_subscription_error").text(i18n.t("You cannot create a stream with no subscribers!"));
+ $("#stream_subscription_error").text(
+ i18n.t("You cannot create a stream with no subscribers!"),
+ );
$("#stream_subscription_error").show();
};
self.cant_create_stream_without_susbscribing = function () {
- $("#stream_subscription_error").text(i18n.t("You must be an organization administrator to create a stream without subscribing."));
+ $("#stream_subscription_error").text(
+ i18n.t(
+ "You must be an organization administrator to create a stream without subscribing.",
+ ),
+ );
$("#stream_subscription_error").show();
};
@@ -34,7 +40,6 @@ const stream_subscription_error = (function () {
};
return self;
-
})();
const stream_name_error = (function () {
@@ -99,7 +104,6 @@ const stream_name_error = (function () {
// Within the new stream modal...
function update_announce_stream_state() {
-
// If there is no notifications_stream, we simply hide the widget.
if (!stream_data.realm_has_notifications_stream()) {
$("#announce-new-stream").hide();
@@ -112,7 +116,8 @@ function update_announce_stream_state() {
const announce_stream_label = $("#announce-new-stream");
let disable_it = false;
const privacy_type = $("input:radio[name=privacy]:checked").val();
- const is_invite_only = privacy_type === "invite-only" || privacy_type === "invite-only-public-history";
+ const is_invite_only =
+ privacy_type === "invite-only" || privacy_type === "invite-only-public-history";
announce_stream_label.removeClass("control-label-disabled");
if (is_invite_only) {
@@ -142,8 +147,11 @@ function create_stream() {
// newline characters (by pressing the enter key) it would still be possible to copy
// and paste over a description with newline characters in it. Prevent that.
if (description.includes("\n")) {
- ui_report.message(i18n.t("The stream description cannot contain newline characters."),
- $(".stream_create_info"), "alert-error");
+ ui_report.message(
+ i18n.t("The stream description cannot contain newline characters."),
+ $(".stream_create_info"),
+ "alert-error",
+ );
return;
}
data.subscriptions = JSON.stringify([{name: stream_name, description: description}]);
@@ -165,18 +173,27 @@ 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($("#stream_creation_form input[name=stream-post-policy]:checked").val(), 10);
+ const stream_post_policy = parseInt(
+ $("#stream_creation_form input[name=stream-post-policy]:checked").val(),
+ 10,
+ );
data.stream_post_policy = JSON.stringify(stream_post_policy);
- let message_retention_selection = $("#stream_creation_form select[name=stream_message_retention_setting]").val();
+ let message_retention_selection = $(
+ "#stream_creation_form select[name=stream_message_retention_setting]",
+ ).val();
if (message_retention_selection === "retain_for_period") {
- message_retention_selection = parseInt($("#stream_creation_form input[name=stream-message-retention-days]").val(), 10);
+ message_retention_selection = parseInt(
+ $("#stream_creation_form input[name=stream-message-retention-days]").val(),
+ 10,
+ );
}
data.message_retention_days = JSON.stringify(message_retention_selection);
- const announce = stream_data.realm_has_notifications_stream() &&
+ const announce =
+ stream_data.realm_has_notifications_stream() &&
$("#announce-new-stream input").prop("checked");
data.announce = JSON.stringify(announce);
@@ -380,7 +397,6 @@ exports.create_handlers_for_users = function (container) {
});
};
-
exports.set_up_handlers = function () {
const container = $("#stream-creation").expectOne();
@@ -442,10 +458,15 @@ exports.set_up_handlers = function () {
notifications_stream: stream_data.get_notifications_stream(),
}),
html: true,
- trigger: "manual"});
+ trigger: "manual",
+ });
announce_stream_docs.popover("show");
announce_stream_docs.data("popover").tip().css("z-index", 2000);
- announce_stream_docs.data("popover").tip().find(".popover-content").css("margin", "9px 14px");
+ announce_stream_docs
+ .data("popover")
+ .tip()
+ .find(".popover-content")
+ .css("margin", "9px 14px");
e.stopPropagation();
});
container.on("mouseout", "#announce-stream-docs", (e) => {
@@ -460,7 +481,6 @@ exports.set_up_handlers = function () {
e.preventDefault();
}
});
-
};
window.stream_create = exports;
diff --git a/static/js/stream_data.js b/static/js/stream_data.js
index 144780c431a..cfde0978d31 100644
--- a/static/js/stream_data.js
+++ b/static/js/stream_data.js
@@ -77,7 +77,6 @@ const BinaryDict = function (pred) {
self.falses.delete(k);
};
-
return self;
};
@@ -113,11 +112,15 @@ exports.clear_subscriptions = function () {
exports.clear_subscriptions();
exports.set_filter_out_inactives = function () {
- if (page_params.demote_inactive_streams ===
- settings_config.demote_inactive_streams_values.automatic.code) {
+ if (
+ page_params.demote_inactive_streams ===
+ settings_config.demote_inactive_streams_values.automatic.code
+ ) {
filter_out_inactives = exports.num_subscribed_subs() >= 30;
- } else if (page_params.demote_inactive_streams ===
- settings_config.demote_inactive_streams_values.always.code) {
+ } else if (
+ page_params.demote_inactive_streams ===
+ settings_config.demote_inactive_streams_values.always.code
+ ) {
filter_out_inactives = true;
} else {
filter_out_inactives = false;
@@ -303,7 +306,6 @@ exports.slug_to_name = function (slug) {
return slug;
};
-
exports.delete_sub = function (stream_id) {
const sub = subs_by_stream_id.get(stream_id);
if (!sub) {
@@ -430,7 +432,6 @@ exports.potential_subscribers = function (sub) {
}
return people.filter_all_users(is_potential_subscriber);
-
};
exports.update_stream_email_address = function (sub, email) {
@@ -484,16 +485,16 @@ exports.update_calculated_fields = function (sub) {
// If stream is public then any user can subscribe. If stream is private then only
// subscribed users can unsubscribe.
// Guest users can't subscribe themselves to any stream.
- sub.should_display_subscription_button = sub.subscribed ||
- !page_params.is_guest && !sub.invite_only;
- sub.should_display_preview_button = sub.subscribed || !sub.invite_only ||
- sub.previously_subscribed;
- sub.can_change_stream_permissions = page_params.is_admin && (
- !sub.invite_only || sub.subscribed);
+ sub.should_display_subscription_button =
+ sub.subscribed || (!page_params.is_guest && !sub.invite_only);
+ sub.should_display_preview_button =
+ sub.subscribed || !sub.invite_only || sub.previously_subscribed;
+ sub.can_change_stream_permissions =
+ page_params.is_admin && (!sub.invite_only || sub.subscribed);
// User can add other users to stream if stream is public or user is subscribed to stream.
// Guest users can't access subscribers of any(public or private) non-subscribed streams.
- sub.can_access_subscribers = page_params.is_admin || sub.subscribed || !page_params.is_guest &&
- !sub.invite_only;
+ sub.can_access_subscribers =
+ page_params.is_admin || sub.subscribed || (!page_params.is_guest && !sub.invite_only);
sub.preview_url = hash_util.by_stream_uri(sub.stream_id);
sub.can_add_subscribers = !page_params.is_guest && (!sub.invite_only || sub.subscribed);
sub.is_old_stream = sub.stream_weekly_traffic !== null;
@@ -688,7 +689,9 @@ exports.is_user_subscribed = function (stream_id, user_id) {
if (typeof sub === "undefined" || !sub.can_access_subscribers) {
// If we don't know about the stream, or we ourselves cannot access subscriber list,
// so we return undefined (treated as falsy if not explicitly handled).
- blueslip.warn("We got a is_user_subscribed call for a non-existent or inaccessible stream.");
+ blueslip.warn(
+ "We got a is_user_subscribed call for a non-existent or inaccessible stream.",
+ );
return;
}
if (typeof user_id === "undefined") {
@@ -775,7 +778,8 @@ exports.get_unmatched_streams_for_notification_settings = function () {
const settings_values = {};
let make_table_row = false;
for (const notification_name of settings_config.stream_specific_notification_settings) {
- const prepend = notification_name === "wildcard_mentions_notify" ? "" : "enable_stream_";
+ const prepend =
+ notification_name === "wildcard_mentions_notify" ? "" : "enable_stream_";
const default_setting = page_params[prepend + notification_name];
const stream_setting = exports.receives_notifications(row.stream_id, notification_name);
@@ -852,8 +856,9 @@ exports.sort_for_stream_settings = function (stream_ids, order) {
}
function by_subscriber_count(id_a, id_b) {
- const out = exports.get_sub_by_id(id_b).subscribers.size
- - exports.get_sub_by_id(id_a).subscribers.size;
+ const out =
+ exports.get_sub_by_id(id_b).subscribers.size -
+ exports.get_sub_by_id(id_a).subscribers.size;
if (out === 0) {
return by_stream_name(id_a, id_b);
}
diff --git a/static/js/stream_edit.js b/static/js/stream_edit.js
index cfae40c1f45..11e6a7664de 100644
--- a/static/js/stream_edit.js
+++ b/static/js/stream_edit.js
@@ -33,7 +33,9 @@ exports.setup_subscriptions_tab_hash = function (tab_key_value) {
};
exports.settings_for_sub = function (sub) {
- return $("#subscription_overlay .subscription_settings[data-stream-id='" + sub.stream_id + "']");
+ return $(
+ "#subscription_overlay .subscription_settings[data-stream-id='" + sub.stream_id + "']",
+ );
};
exports.is_sub_settings_active = function (sub) {
@@ -56,9 +58,11 @@ exports.get_retention_policy_text_for_subscription_type = function (sub) {
let message_retention_days = sub.message_retention_days;
// If both this stream and the organization-level policy are to retain forever,
// there's no need to comment on retention policies when describing the stream.
- if (page_params.realm_message_retention_days === settings_config.retain_message_forever
- && (sub.message_retention_days === null ||
- sub.message_retention_days === settings_config.retain_message_forever)) {
+ if (
+ page_params.realm_message_retention_days === settings_config.retain_message_forever &&
+ (sub.message_retention_days === null ||
+ sub.message_retention_days === settings_config.retain_message_forever)
+ ) {
return;
}
@@ -73,7 +77,10 @@ exports.get_retention_policy_text_for_subscription_type = function (sub) {
message_retention_days = page_params.realm_message_retention_days;
}
- return i18n.t("Messages in this stream will be automatically deleted after __retention_days__ days.", {retention_days: message_retention_days});
+ return i18n.t(
+ "Messages in this stream will be automatically deleted after __retention_days__ days.",
+ {retention_days: message_retention_days},
+ );
};
exports.get_display_text_for_realm_message_retention_setting = function () {
@@ -81,7 +88,9 @@ exports.get_display_text_for_realm_message_retention_setting = function () {
if (realm_message_retention_days === settings_config.retain_message_forever) {
return i18n.t("(forever)");
}
- return i18n.t("(__message_retention_days__ days)", {message_retention_days: realm_message_retention_days});
+ return i18n.t("(__message_retention_days__ days)", {
+ message_retention_days: realm_message_retention_days,
+ });
};
function change_stream_message_retention_days_block_display_property(value) {
@@ -174,9 +183,9 @@ exports.update_stream_name = function (sub, new_name) {
exports.update_stream_description = function (sub) {
const stream_settings = exports.settings_for_sub(sub);
stream_settings.find("input.description").val(sub.description);
- stream_settings.find(".stream-description-editable").html(
- util.clean_user_content_links(sub.rendered_description),
- );
+ stream_settings
+ .find(".stream-description-editable")
+ .html(util.clean_user_content_links(sub.rendered_description));
};
exports.invite_user_to_stream = function (user_ids, sub, success, failure) {
@@ -184,8 +193,10 @@ exports.invite_user_to_stream = function (user_ids, sub, success, failure) {
const stream_name = sub.name;
return channel.post({
url: "/json/users/me/subscriptions",
- data: {subscriptions: JSON.stringify([{name: stream_name}]),
- principals: JSON.stringify(user_ids)},
+ data: {
+ subscriptions: JSON.stringify([{name: stream_name}]),
+ principals: JSON.stringify(user_ids),
+ },
success: success,
error: failure,
});
@@ -203,8 +214,10 @@ function submit_add_subscriber_form(e) {
const stream_subscription_info_elem = $(".stream_subscription_info").expectOne();
if (user_ids.length === 0) {
- stream_subscription_info_elem.text(i18n.t("No user to subscribe."))
- .addClass("text-error").removeClass("text-success");
+ stream_subscription_info_elem
+ .text(i18n.t("No user to subscribe."))
+ .addClass("text-error")
+ .removeClass("text-success");
return;
}
@@ -216,17 +229,21 @@ function submit_add_subscriber_form(e) {
} else {
stream_subscription_info_elem.text(i18n.t("User already subscribed."));
const already_subscribed_users = Object.keys(data.already_subscribed).join(", ");
- stream_subscription_info_elem.text(i18n.t(
- " __already_subscribed_users__ are already subscribed.", {already_subscribed_users: already_subscribed_users}));
+ stream_subscription_info_elem.text(
+ i18n.t(" __already_subscribed_users__ are already subscribed.", {
+ already_subscribed_users: already_subscribed_users,
+ }),
+ );
}
- stream_subscription_info_elem.addClass("text-success")
- .removeClass("text-error");
+ stream_subscription_info_elem.addClass("text-success").removeClass("text-error");
}
function invite_failure(xhr) {
const error = JSON.parse(xhr.responseText);
- stream_subscription_info_elem.text(error.msg)
- .addClass("text-error").removeClass("text-success");
+ stream_subscription_info_elem
+ .text(error.msg)
+ .addClass("text-error")
+ .removeClass("text-success");
}
exports.invite_user_to_stream(user_ids, sub, invite_success, invite_failure);
@@ -237,8 +254,7 @@ exports.remove_user_from_stream = function (user_id, sub, success, failure) {
const stream_name = sub.name;
return channel.del({
url: "/json/users/me/subscriptions",
- data: {subscriptions: JSON.stringify([stream_name]),
- principals: JSON.stringify([user_id])},
+ data: {subscriptions: JSON.stringify([stream_name]), principals: JSON.stringify([user_id])},
success: success,
error: failure,
});
@@ -276,7 +292,11 @@ function show_subscription_settings(sub_row) {
stream_color.set_colorpicker_color(colorpicker, color);
stream_ui_updates.update_add_subscriptions_elements(sub);
- const container = $("#subscription_overlay .subscription_settings[data-stream-id='" + stream_id + "'] .pill-container");
+ const container = $(
+ "#subscription_overlay .subscription_settings[data-stream-id='" +
+ stream_id +
+ "'] .pill-container",
+ );
exports.pill_widget = input_pill.create({
container: container,
create_item_from_text: user_pill.create_item_from_email,
@@ -312,8 +332,10 @@ function show_subscription_settings(sub_row) {
const person = item;
if (person) {
- if (person.email.toLocaleLowerCase().includes(value) &&
- settings_data.show_email()) {
+ if (
+ person.email.toLocaleLowerCase().includes(value) &&
+ settings_data.show_email()
+ ) {
return true;
}
return person.full_name.toLowerCase().includes(value);
@@ -323,10 +345,12 @@ function show_subscription_settings(sub_row) {
simplebar_container: $(".subscriber_list_container"),
});
- user_pill.set_up_typeahead_on_pills(sub_settings.find(".input"),
- exports.pill_widget,
- () => {},
- get_users_for_subscriber_typeahead);
+ user_pill.set_up_typeahead_on_pills(
+ sub_settings.find(".input"),
+ exports.pill_widget,
+ () => {},
+ get_users_for_subscriber_typeahead,
+ );
}
exports.is_notification_setting = function (setting_label) {
@@ -463,7 +487,10 @@ function change_stream_privacy(e) {
const sub = stream_data.get_sub_by_id(stream_id);
const privacy_setting = $("#stream_privacy_modal input[name=privacy]:checked").val();
- const stream_post_policy = parseInt($("#stream_privacy_modal input[name=stream-post-policy]:checked").val(), 10);
+ const stream_post_policy = parseInt(
+ $("#stream_privacy_modal input[name=stream-post-policy]:checked").val(),
+ 10,
+ );
let invite_only;
let history_public_to_subscribers;
@@ -489,9 +516,14 @@ function change_stream_privacy(e) {
};
if (page_params.is_owner) {
- let message_retention_days = $("#stream_privacy_modal select[name=stream_message_retention_setting]").val();
+ let message_retention_days = $(
+ "#stream_privacy_modal select[name=stream_message_retention_setting]",
+ ).val();
if (message_retention_days === "retain_for_period") {
- message_retention_days = parseInt($("#stream_privacy_modal input[name=stream-message-retention-days]").val(), 10);
+ message_retention_days = parseInt(
+ $("#stream_privacy_modal input[name=stream-message-retention-days]").val(),
+ 10,
+ );
}
data.message_retention_days = JSON.stringify(message_retention_days);
}
@@ -524,7 +556,10 @@ exports.change_stream_name = function (e) {
data: {new_name: JSON.stringify(new_name)},
success: function () {
new_name_box.val("");
- ui_report.success(i18n.t("The stream has been renamed!"), $(".stream_change_property_info"));
+ ui_report.success(
+ i18n.t("The stream has been renamed!"),
+ $(".stream_change_property_info"),
+ );
},
error: function (xhr) {
new_name_box.text(stream_data.maybe_get_stream_name(stream_id));
@@ -565,13 +600,15 @@ exports.change_stream_description = function (e) {
},
success: function () {
// The event from the server will update the rest of the UI
- ui_report.success(i18n.t("The stream description has been updated!"),
- $(".stream_change_property_info"));
+ ui_report.success(
+ i18n.t("The stream description has been updated!"),
+ $(".stream_change_property_info"),
+ );
},
error: function (xhr) {
- sub_settings.find(".stream-description-editable").html(
- util.clean_user_content_links(sub.rendered_description),
- );
+ sub_settings
+ .find(".stream-description-editable")
+ .html(util.clean_user_content_links(sub.rendered_description));
ui_report.error(i18n.t("Error"), xhr, $(".stream_change_property_info"));
},
});
@@ -612,15 +649,14 @@ exports.initialize = function () {
stream_post_policy: stream.stream_post_policy,
is_public: !stream.invite_only,
is_private: stream.invite_only && !stream.history_public_to_subscribers,
- is_private_with_public_history: stream.invite_only &&
- stream.history_public_to_subscribers,
+ is_private_with_public_history:
+ stream.invite_only && stream.history_public_to_subscribers,
is_owner: page_params.is_owner,
zulip_plan_is_not_limited: page_params.zulip_plan_is_not_limited,
- disable_message_retention_setting: !page_params.zulip_plan_is_not_limited ||
- !page_params.is_owner,
+ disable_message_retention_setting:
+ !page_params.zulip_plan_is_not_limited || !page_params.is_owner,
stream_message_retention_days: stream.message_retention_days,
- realm_message_retention_setting:
- exports.get_display_text_for_realm_message_retention_setting(),
+ realm_message_retention_setting: exports.get_display_text_for_realm_message_retention_setting(),
upgrade_text_for_wide_organization_logo:
page_params.upgrade_text_for_wide_organization_logo,
is_stream_edit: true,
@@ -634,8 +670,7 @@ exports.initialize = function () {
e.stopPropagation();
});
- $("#subscriptions_table").on("click", "#change-stream-privacy-button",
- change_stream_privacy);
+ $("#subscriptions_table").on("click", "#change-stream-privacy-button", change_stream_privacy);
$("#subscriptions_table").on("click", ".close-privacy-modal", (e) => {
// Re-enable background mouse events when we close the modal
@@ -654,11 +689,9 @@ exports.initialize = function () {
e.stopPropagation();
});
- $("#subscriptions_table").on("click", "#sub_is_muted_setting",
- stream_is_muted_clicked);
+ $("#subscriptions_table").on("click", "#sub_is_muted_setting", stream_is_muted_clicked);
- $("#subscriptions_table").on("click", ".sub_setting_checkbox",
- exports.stream_setting_clicked);
+ $("#subscriptions_table").on("click", ".sub_setting_checkbox", exports.stream_setting_clicked);
$("#subscriptions_table").on("keyup", ".subscriber_list_add form", (e) => {
if (e.which === 13) {
@@ -695,17 +728,17 @@ exports.initialize = function () {
} else {
stream_subscription_info_elem.text(i18n.t("User is already not subscribed."));
}
- stream_subscription_info_elem.addClass("text-success")
- .removeClass("text-error");
+ stream_subscription_info_elem.addClass("text-success").removeClass("text-error");
}
function removal_failure() {
- stream_subscription_info_elem.text(i18n.t("Error removing user from this stream."))
- .addClass("text-error").removeClass("text-success");
+ stream_subscription_info_elem
+ .text(i18n.t("Error removing user from this stream."))
+ .addClass("text-error")
+ .removeClass("text-success");
}
- exports.remove_user_from_stream(target_user_id, sub, removal_success,
- removal_failure);
+ exports.remove_user_from_stream(target_user_id, sub, removal_success, removal_failure);
});
// This handler isn't part of the normal edit interface; it's the convenient
@@ -713,7 +746,9 @@ exports.initialize = function () {
$("#subscriptions_table").on("click", ".sub_unsub_button", (e) => {
const sub = get_sub_for_target(e.target);
// Makes sure we take the correct stream_row.
- const stream_row = $("#subscriptions_table div.stream-row[data-stream-id='" + sub.stream_id + "']");
+ const stream_row = $(
+ "#subscriptions_table div.stream-row[data-stream-id='" + sub.stream_id + "']",
+ );
subs.sub_or_unsub(sub, stream_row);
if (!sub.subscribed) {
@@ -731,7 +766,11 @@ exports.initialize = function () {
const stream_id = get_stream_id(e.target);
if (!stream_id) {
- ui_report.message(i18n.t("Invalid stream id"), $(".stream_change_property_info"), "alert-error");
+ ui_report.message(
+ i18n.t("Invalid stream id"),
+ $(".stream_change_property_info"),
+ "alert-error",
+ );
return;
}
const stream_name = stream_data.maybe_get_stream_name(stream_id);
@@ -749,7 +788,11 @@ exports.initialize = function () {
overlays.close_modal("#deactivation_stream_modal");
$("#deactivation_stream_modal").remove();
if (!stream_id) {
- ui_report.message(i18n.t("Invalid stream id"), $(".stream_change_property_info"), "alert-error");
+ ui_report.message(
+ i18n.t("Invalid stream id"),
+ $(".stream_change_property_info"),
+ "alert-error",
+ );
return;
}
const row = $(".stream-row.active");
diff --git a/static/js/stream_events.js b/static/js/stream_events.js
index 730a44bc672..c76f166fd1d 100644
--- a/static/js/stream_events.js
+++ b/static/js/stream_events.js
@@ -12,9 +12,11 @@ exports.update_property = function (stream_id, property, value, other_values) {
const sub = stream_data.get_sub_by_id(stream_id);
if (sub === undefined) {
// This isn't a stream we know about, so ignore it.
- blueslip.warn("Update for an unknown subscription", {stream_id: stream_id,
- property: property,
- value: value});
+ blueslip.warn("Update for an unknown subscription", {
+ stream_id: stream_id,
+ property: property,
+ value: value,
+ });
return;
}
@@ -59,8 +61,10 @@ exports.update_property = function (stream_id, property, value, other_values) {
subs.update_message_retention_setting(sub, value);
break;
default:
- blueslip.warn("Unexpected subscription property type", {property: property,
- value: value});
+ blueslip.warn("Unexpected subscription property type", {
+ property: property,
+ value: value,
+ });
}
};
@@ -148,5 +152,4 @@ exports.remove_deactivated_user_from_all_streams = function (user_id) {
}
};
-
window.stream_events = exports;
diff --git a/static/js/stream_list.js b/static/js/stream_list.js
index 97d81d4e4ab..b2a88499307 100644
--- a/static/js/stream_list.js
+++ b/static/js/stream_list.js
@@ -24,7 +24,6 @@ exports.update_count_in_dom = function (unread_count_elem, count) {
value_span.text(count);
};
-
exports.stream_sidebar = (function () {
const self = {};
@@ -254,7 +253,6 @@ function build_stream_sidebar_row(sub) {
list_item.remove();
};
-
self.update_unread_count = function () {
const count = unread.num_unread_for_stream(sub.stream_id);
exports.update_count_in_dom(list_item, count);
@@ -496,9 +494,11 @@ exports.set_event_handlers = function () {
$("#clear_search_stream_button").on("click", exports.clear_search);
- $("#streams_header").expectOne().click((e) => {
- exports.toggle_filter_displayed(e);
- });
+ $("#streams_header")
+ .expectOne()
+ .click((e) => {
+ exports.toggle_filter_displayed(e);
+ });
// check for user scrolls on streams list for first time
ui.get_scroll_element($("#stream-filters-container")).on("scroll", function () {
diff --git a/static/js/stream_muting.js b/static/js/stream_muting.js
index 7d60fb929f4..9b1ca59d712 100644
--- a/static/js/stream_muting.js
+++ b/static/js/stream_muting.js
@@ -7,8 +7,10 @@ exports.update_is_muted = function (sub, value) {
// Save our current scroll position
if (overlays.is_active()) {
saved_ypos = message_viewport.scrollTop();
- } else if (home_msg_list === current_msg_list &&
- current_msg_list.selected_row().offset() !== null) {
+ } else if (
+ home_msg_list === current_msg_list &&
+ current_msg_list.selected_row().offset() !== null
+ ) {
msg_offset = current_msg_list.selected_row().offset().top;
}
@@ -24,8 +26,10 @@ exports.update_is_muted = function (sub, value) {
// We pass use_closest to handle the case where the
// currently selected message is being hidden from the
// home view
- home_msg_list.select_id(home_msg_list.selected_id(),
- {use_closest: true, empty_ok: true});
+ home_msg_list.select_id(home_msg_list.selected_id(), {
+ use_closest: true,
+ empty_ok: true,
+ });
if (current_msg_list.selected_id() !== -1) {
current_msg_list.view.set_message_offset(msg_offset);
}
@@ -46,7 +50,11 @@ exports.update_is_muted = function (sub, value) {
stream_list.set_in_home_view(sub.stream_id, !sub.is_muted);
- const is_muted_checkbox = $(".subscription_settings[data-stream-id='" + sub.stream_id + "'] #sub_is_muted_setting .sub_setting_control");
+ const is_muted_checkbox = $(
+ ".subscription_settings[data-stream-id='" +
+ sub.stream_id +
+ "'] #sub_is_muted_setting .sub_setting_control",
+ );
is_muted_checkbox.prop("checked", value);
};
diff --git a/static/js/stream_popover.js b/static/js/stream_popover.js
index 2e1b4ef0cd3..d35bca3ca32 100644
--- a/static/js/stream_popover.js
+++ b/static/js/stream_popover.js
@@ -83,7 +83,6 @@ exports.hide_streamlist_sidebar = function () {
$(".app-main .column-left").removeClass("expanded");
};
-
function stream_popover_sub(e) {
const elem = $(e.currentTarget).parents("ul");
const stream_id = elem_to_stream_id(elem);
@@ -129,8 +128,7 @@ function build_stream_popover(opts) {
const elt = opts.elt;
const stream_id = opts.stream_id;
- if (exports.stream_popped()
- && current_stream_sidebar_elem === elt) {
+ if (exports.stream_popped() && current_stream_sidebar_elem === elt) {
// If the popover is already shown, clicking again should toggle it.
exports.hide_stream_popover();
return;
@@ -166,8 +164,7 @@ function build_topic_popover(opts) {
const stream_id = opts.stream_id;
const topic_name = opts.topic_name;
- if (exports.topic_popped()
- && current_topic_sidebar_elem === elt) {
+ if (exports.topic_popped() && current_topic_sidebar_elem === elt) {
// If the popover is already shown, clicking again should toggle it.
exports.hide_topic_popover();
return;
@@ -211,8 +208,7 @@ function build_topic_popover(opts) {
function build_all_messages_popover(e) {
const elt = e.target;
- if (exports.all_messages_popped()
- && all_messages_sidebar_elem === elt) {
+ if (exports.all_messages_popped() && all_messages_sidebar_elem === elt) {
exports.hide_all_messages_popover();
e.stopPropagation();
return;
@@ -232,14 +228,12 @@ function build_all_messages_popover(e) {
$(elt).popover("show");
all_messages_sidebar_elem = elt;
e.stopPropagation();
-
}
function build_starred_messages_popover(e) {
const elt = e.target;
- if (exports.starred_messages_popped()
- && starred_messages_sidebar_elem === elt) {
+ if (exports.starred_messages_popped() && starred_messages_sidebar_elem === elt) {
exports.hide_starred_messages_popover();
e.stopPropagation();
return;
@@ -261,7 +255,6 @@ function build_starred_messages_popover(e) {
$(elt).popover("show");
starred_messages_sidebar_elem = elt;
e.stopPropagation();
-
}
function build_move_topic_to_stream_popover(e, current_stream_id, topic_name) {
@@ -272,11 +265,15 @@ function build_move_topic_to_stream_popover(e, current_stream_id, topic_name) {
// NOTE: Private streams are also included in this list. We
// likely will make it possible to move messages to/from private
// streams in the future.
- const available_streams = stream_data.subscribed_subs()
+ const available_streams = stream_data
+ .subscribed_subs()
.filter((s) => s.stream_id !== current_stream_id);
const current_stream_name = stream_data.maybe_get_stream_name(current_stream_id);
const args = {
- available_streams, topic_name, current_stream_id, current_stream_name,
+ available_streams,
+ topic_name,
+ current_stream_id,
+ current_stream_name,
notify_new_thread: message_edit.notify_new_thread_default,
notify_old_thread: message_edit.notify_old_thread_default,
};
@@ -285,7 +282,9 @@ function build_move_topic_to_stream_popover(e, current_stream_id, topic_name) {
$("#move-a-topic-modal-holder").html(render_move_topic_to_stream(args));
- const stream_header_colorblock = $(".topic_stream_edit_header").find(".stream_header_colorblock");
+ const stream_header_colorblock = $(".topic_stream_edit_header").find(
+ ".stream_header_colorblock",
+ );
ui_util.decorate_stream_bar(current_stream_name, stream_header_colorblock, false);
$("#select_stream_id").change(function () {
const stream_name = stream_data.maybe_get_stream_name(parseInt(this.value, 10));
@@ -327,7 +326,11 @@ exports.register_click_handlers = function () {
$("#global_filters").on("click", ".all-messages-sidebar-menu-icon", build_all_messages_popover);
- $("#global_filters").on("click", ".starred-messages-sidebar-menu-icon", build_starred_messages_popover);
+ $("#global_filters").on(
+ "click",
+ ".starred-messages-sidebar-menu-icon",
+ build_starred_messages_popover,
+ );
exports.register_stream_handlers();
exports.register_topic_handlers();
@@ -433,7 +436,6 @@ exports.register_stream_handlers = function () {
exports.hide_stream_popover();
});
});
-
};
function topic_popover_sub(e) {
@@ -555,21 +557,29 @@ exports.register_topic_handlers = function () {
$("#topic_stream_edit_form_error").show();
}
- const params = $("#move_topic_form").serializeArray().reduce((obj, item) => {
- obj[item.name] = item.value;
- return obj;
- }, {});
+ const params = $("#move_topic_form")
+ .serializeArray()
+ .reduce((obj, item) => {
+ obj[item.name] = item.value;
+ return obj;
+ }, {});
const {old_topic_name, select_stream_id} = params;
- let {current_stream_id, new_topic_name,
- send_notification_to_new_thread, send_notification_to_old_thread} = params;
+ let {
+ current_stream_id,
+ new_topic_name,
+ send_notification_to_new_thread,
+ send_notification_to_old_thread,
+ } = params;
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);
- if (current_stream_id === parseInt(select_stream_id, 10) &&
- new_topic_name.toLowerCase() === old_topic_name.toLowerCase()) {
+ if (
+ current_stream_id === 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.");
return false;
}
@@ -592,10 +602,10 @@ exports.register_topic_handlers = function () {
anchor: "newest",
num_before: 1,
num_after: 0,
- narrow: JSON.stringify(
- [{operator: "stream", operand: current_stream_id},
- {operator: "topic", operand: old_topic_name}],
- ),
+ narrow: JSON.stringify([
+ {operator: "stream", operand: current_stream_id},
+ {operator: "topic", operand: old_topic_name},
+ ]),
};
channel.get({
@@ -613,9 +623,12 @@ exports.register_topic_handlers = function () {
if (old_topic_name && select_stream_id) {
message_edit.move_topic_containing_message_to_stream(
- message_id, select_stream_id, new_topic_name,
+ message_id,
+ select_stream_id,
+ new_topic_name,
send_notification_to_new_thread,
- send_notification_to_old_thread);
+ send_notification_to_old_thread,
+ );
$("#move_topic_modal").modal("hide");
}
},
diff --git a/static/js/stream_sort.js b/static/js/stream_sort.js
index 9f254f2699e..093c37b7a39 100644
--- a/static/js/stream_sort.js
+++ b/static/js/stream_sort.js
@@ -18,12 +18,14 @@ function filter_streams_by_search(streams, search_term) {
let search_terms = search_term.toLowerCase().split(",");
search_terms = search_terms.map((s) => s.trim());
- const filtered_streams = streams.filter((stream) => search_terms.some((search_term) => {
- const lower_stream_name = stream.toLowerCase();
- const cands = lower_stream_name.split(" ");
- cands.push(lower_stream_name);
- return cands.some((name) => name.startsWith(search_term));
- }));
+ const filtered_streams = streams.filter((stream) =>
+ search_terms.some((search_term) => {
+ const lower_stream_name = stream.toLowerCase();
+ const cands = lower_stream_name.split(" ");
+ cands.push(lower_stream_name);
+ return cands.some((name) => name.startsWith(search_term));
+ }),
+ );
return filtered_streams;
}
diff --git a/static/js/stream_ui_updates.js b/static/js/stream_ui_updates.js
index fa8cf7ad423..a0f0f1e1e2d 100644
--- a/static/js/stream_ui_updates.js
+++ b/static/js/stream_ui_updates.js
@@ -16,16 +16,19 @@ exports.update_check_button_for_sub = function (sub) {
}
};
-exports.initialize_disable_btn_hint_popover = function (btn_wrapper, popover_btn,
- disabled_btn, hint_text) {
+exports.initialize_disable_btn_hint_popover = function (
+ btn_wrapper,
+ popover_btn,
+ disabled_btn,
+ hint_text,
+) {
// Disabled button blocks mouse events(hover) from reaching
// to it's parent div element, so popover don't get triggered.
// Add css to prevent this.
disabled_btn.css("pointer-events", "none");
popover_btn.popover({
placement: "bottom",
- content: $("<div>", {class: "sub_disable_btn_hint"}).text(hint_text)
- .prop("outerHTML"),
+ content: $("<div>", {class: "sub_disable_btn_hint"}).text(hint_text).prop("outerHTML"),
trigger: "manual",
html: true,
animation: false,
@@ -45,8 +48,12 @@ exports.initialize_disable_btn_hint_popover = function (btn_wrapper, popover_btn
exports.initialize_cant_subscribe_popover = function (sub) {
const button_wrapper = stream_edit.settings_for_sub(sub).find(".sub_unsub_button_wrapper");
const settings_button = subs.settings_button_for_sub(sub);
- exports.initialize_disable_btn_hint_popover(button_wrapper, settings_button, settings_button,
- i18n.t("Only stream members can add users to a private stream"));
+ exports.initialize_disable_btn_hint_popover(
+ button_wrapper,
+ settings_button,
+ settings_button,
+ i18n.t("Only stream members can add users to a private stream"),
+ );
};
exports.update_settings_button_for_sub = function (sub) {
@@ -102,8 +109,10 @@ exports.update_notification_setting_checkbox = function (notification_name) {
return;
}
const stream_id = stream_row.data("stream-id");
- $(`#${notification_name}_${stream_id}`).prop("checked", stream_data.receives_notifications(
- stream_id, notification_name));
+ $(`#${notification_name}_${stream_id}`).prop(
+ "checked",
+ stream_data.receives_notifications(stream_id, notification_name),
+ );
};
exports.update_stream_row_in_settings_tab = function (sub) {
@@ -133,7 +142,9 @@ exports.update_stream_privacy_type_icon = function (sub) {
if (stream_edit.is_sub_settings_active(sub)) {
const large_icon = stream_settings.find(".large-icon").expectOne();
if (sub.invite_only) {
- large_icon.removeClass("hash").addClass("lock")
+ large_icon
+ .removeClass("hash")
+ .addClass("lock")
.html("<i class='fa fa-lock' aria-hidden='true'></i>");
} else {
large_icon.addClass("hash").removeClass("lock").html("");
@@ -160,7 +171,11 @@ exports.update_subscribers_count = function (sub, just_subscribed) {
return;
}
const stream_row = subs.row_for_stream_id(sub.stream_id);
- if (!sub.can_access_subscribers || just_subscribed && sub.invite_only || page_params.is_guest) {
+ if (
+ !sub.can_access_subscribers ||
+ (just_subscribed && sub.invite_only) ||
+ page_params.is_guest
+ ) {
const rendered_sub_count = render_subscription_count(sub);
stream_row.find(".subscriber-count").expectOne().html(rendered_sub_count);
} else {
@@ -213,7 +228,9 @@ exports.update_add_subscriptions_elements = function (sub) {
// Otherwise, we adjust whether the widgets are disabled based on
// whether this user is authorized to add subscribers.
const input_element = $(".add_subscribers_container").find(".input").expectOne();
- const button_element = $(".add_subscribers_container").find('button[name="add_subscriber"]').expectOne();
+ const button_element = $(".add_subscribers_container")
+ .find('button[name="add_subscriber"]')
+ .expectOne();
const allow_user_to_add_subs = sub.can_add_subscribers;
if (allow_user_to_add_subs) {
@@ -225,8 +242,12 @@ exports.update_add_subscriptions_elements = function (sub) {
input_element.attr("disabled", "disabled");
button_element.attr("disabled", "disabled");
- exports.initialize_disable_btn_hint_popover($(".add_subscribers_container"), input_element, button_element,
- i18n.t("Only stream members can add users to a private stream"));
+ exports.initialize_disable_btn_hint_popover(
+ $(".add_subscribers_container"),
+ input_element,
+ button_element,
+ i18n.t("Only stream members can add users to a private stream"),
+ );
}
};
diff --git a/static/js/subs.js b/static/js/subs.js
index e774057c183..5dbb3735bba 100644
--- a/static/js/subs.js
+++ b/static/js/subs.js
@@ -269,7 +269,9 @@ exports.remove_stream = function (stream_id) {
exports.update_settings_for_subscribed = function (sub) {
stream_ui_updates.update_add_subscriptions_elements(sub);
- $(".subscription_settings[data-stream-id='" + sub.stream_id + "'] #preview-stream-button").show();
+ $(
+ ".subscription_settings[data-stream-id='" + sub.stream_id + "'] #preview-stream-button",
+ ).show();
if (exports.is_sub_already_present(sub)) {
stream_data.update_subscribers_count(sub);
@@ -300,7 +302,8 @@ exports.show_active_stream_in_left_panel = function () {
exports.add_tooltips_to_left_panel = function () {
for (const row of $("#subscriptions_table .stream-row")) {
$(row).find('.sub-info-box [class$="-bar"] [class$="-count"]').tooltip({
- placement: "left", animation: false,
+ placement: "left",
+ animation: false,
});
}
};
@@ -445,14 +448,12 @@ exports.filter_table = function (query) {
ui.reset_scrollbar($("#subscription_overlay .streams-list"));
- const all_stream_ids = [
- ...buckets.name,
- ...buckets.desc,
- ...buckets.other,
- ];
+ const all_stream_ids = [...buckets.name, ...buckets.desc, ...buckets.other];
for (const stream_id of all_stream_ids) {
- ui.get_content_element($("#subscriptions_table .streams-list")).append(widgets.get(stream_id));
+ ui.get_content_element($("#subscriptions_table .streams-list")).append(
+ widgets.get(stream_id),
+ );
}
exports.maybe_reset_right_panel();
@@ -511,9 +512,11 @@ exports.switch_stream_tab = function (tab_name) {
exports.sort_toggler = undefined;
exports.switch_stream_sort = function (tab_name) {
- if (tab_name === "by-stream-name"
- || tab_name === "by-subscriber-count"
- || tab_name === "by-weekly-traffic") {
+ if (
+ tab_name === "by-stream-name" ||
+ tab_name === "by-subscriber-count" ||
+ tab_name === "by-weekly-traffic"
+ ) {
sort_order = tab_name;
} else {
sort_order = "by-stream-name";
@@ -540,9 +543,22 @@ exports.setup_page = function (callback) {
sort_order = "by-stream-name";
exports.sort_toggler = components.toggle({
values: [
- {label: `<i class="fa fa-sort-alpha-asc" title="${i18n.t("Sort by name")}"></i>`, key: "by-stream-name"},
- {label: `<i class="fa fa-user-o" title="${i18n.t("Sort by number of subscribers")}"></i>`, key: "by-subscriber-count"},
- {label: `<i class="fa fa-bar-chart" title="${i18n.t("Sort by estimated weekly traffic")}"></i>`, key: "by-weekly-traffic"},
+ {
+ label: `<i class="fa fa-sort-alpha-asc" title="${i18n.t("Sort by name")}"></i>`,
+ key: "by-stream-name",
+ },
+ {
+ label: `<i class="fa fa-user-o" title="${i18n.t(
+ "Sort by number of subscribers",
+ )}"></i>`,
+ key: "by-subscriber-count",
+ },
+ {
+ label: `<i class="fa fa-bar-chart" title="${i18n.t(
+ "Sort by estimated weekly traffic",
+ )}"></i>`,
+ key: "by-weekly-traffic",
+ },
],
html_class: "stream_sorter_toggle",
callback: function (value, key) {
@@ -578,7 +594,6 @@ exports.setup_page = function (callback) {
}
function populate_and_fill() {
-
$("#subscriptions_table").empty();
const template_data = {
@@ -758,7 +773,8 @@ exports.view_stream = function () {
const active_data = exports.get_active_data();
const row_data = get_row_data(active_data.row);
if (row_data) {
- const stream_narrow_hash = "#narrow/stream/" + hash_util.encode_stream_name(row_data.object.name);
+ const stream_narrow_hash =
+ "#narrow/stream/" + hash_util.encode_stream_name(row_data.object.name);
hashchange.go_to_location(stream_narrow_hash);
}
};
@@ -811,8 +827,10 @@ function ajaxSubscribe(stream, color, stream_row) {
if (!$.isEmptyObject(res.already_subscribed)) {
// Display the canonical stream capitalization.
true_stream_name = res.already_subscribed[people.my_current_email()][0];
- ui_report.success(i18n.t("Already subscribed to __stream__", {stream: true_stream_name}),
- $(".stream_change_property_info"));
+ ui_report.success(
+ i18n.t("Already subscribed to __stream__", {stream: true_stream_name}),
+ $(".stream_change_property_info"),
+ );
}
// The rest of the work is done via the subscribe event we will get
@@ -824,8 +842,11 @@ function ajaxSubscribe(stream, color, stream_row) {
if (stream_row !== undefined) {
hide_subscribe_toggle_spinner(stream_row);
}
- ui_report.error(i18n.t("Error adding subscription"), xhr,
- $(".stream_change_property_info"));
+ ui_report.error(
+ i18n.t("Error adding subscription"),
+ xhr,
+ $(".stream_change_property_info"),
+ );
},
});
}
@@ -850,8 +871,11 @@ function ajaxUnsubscribe(sub, stream_row) {
if (stream_row !== undefined) {
hide_subscribe_toggle_spinner(stream_row);
}
- ui_report.error(i18n.t("Error removing subscription"), xhr,
- $(".stream_change_property_info"));
+ ui_report.error(
+ i18n.t("Error removing subscription"),
+ xhr,
+ $(".stream_change_property_info"),
+ );
},
});
}
@@ -877,7 +901,6 @@ exports.open_create_stream = function () {
hashchange.update_browser_history("#streams/new");
};
-
exports.sub_or_unsub = function (sub, stream_row) {
if (sub.subscribed) {
ajaxUnsubscribe(sub, stream_row);
@@ -886,7 +909,6 @@ exports.sub_or_unsub = function (sub, stream_row) {
}
};
-
exports.initialize = function () {
$("#subscriptions_table").on("click", ".create_stream_button", (e) => {
e.preventDefault();
@@ -926,7 +948,6 @@ exports.initialize = function () {
}
});
})();
-
};
window.subs = exports;
diff --git a/static/js/tab_bar.js b/static/js/tab_bar.js
index 0b566a9b5bd..0ae895c3993 100644
--- a/static/js/tab_bar.js
+++ b/static/js/tab_bar.js
@@ -40,16 +40,21 @@ function make_tab_data(filter) {
tab_data.sub_count = get_sub_count(current_stream);
tab_data.formatted_sub_count = get_formatted_sub_count(current_stream);
// the "title" is passed as a variable and doesn't get translated (nor should it)
- tab_data.sub_count_tooltip_text =
- i18n.t("__count__ users are subscribed to #__title__", {count: tab_data.sub_count, title: tab_data.title});
- tab_data.stream_settings_link = "#streams/" + current_stream.stream_id + "/" + current_stream.name;
+ tab_data.sub_count_tooltip_text = i18n.t("__count__ users are subscribed to #__title__", {
+ count: tab_data.sub_count,
+ title: tab_data.title,
+ });
+ tab_data.stream_settings_link =
+ "#streams/" + current_stream.stream_id + "/" + current_stream.name;
}
return tab_data;
}
exports.colorize_tab_bar = function () {
const filter = narrow_state.filter();
- if (filter === undefined || !filter._sub) {return;}
+ if (filter === undefined || !filter._sub) {
+ return;
+ }
$("#tab_bar .stream > .fa").css("color", filter._sub.color);
};
@@ -92,11 +97,14 @@ function bind_title_area_handlers() {
// handler that makes sure that hover plays nicely
// with whether search is being opened or not.
- $("#tab_bar .narrow_description > a").hover(() => {
- $("#tab_bar .search_closed").addClass("search_icon_hover_highlight");
- }, () => {
- $("#tab_bar .search_closed").removeClass("search_icon_hover_highlight");
- });
+ $("#tab_bar .narrow_description > a").hover(
+ () => {
+ $("#tab_bar .search_closed").addClass("search_icon_hover_highlight");
+ },
+ () => {
+ $("#tab_bar .search_closed").removeClass("search_icon_hover_highlight");
+ },
+ );
}
function build_tab_bar(filter) {
diff --git a/static/js/templates.js b/static/js/templates.js
index 02e6ec8d358..38e25e6456a 100644
--- a/static/js/templates.js
+++ b/static/js/templates.js
@@ -12,10 +12,12 @@ const util = require("./util");
// Furthermore, waiting for DOM ready would introduce race conditions with
// other DOM-ready callbacks that attempt to render templates.
-Handlebars.registerHelper("plural", (condition, one, other) => condition === 1 ? one : other);
+Handlebars.registerHelper("plural", (condition, one, other) => (condition === 1 ? one : other));
Handlebars.registerHelper({
- eq: function (a, b) { return a === b; },
+ eq: function (a, b) {
+ return a === b;
+ },
and: function (...args) {
args.pop(); // Handlebars options
if (args.length === 0) {
@@ -42,7 +44,9 @@ Handlebars.registerHelper({
}
return last;
},
- not: function (a) { return !a || Handlebars.Utils.isEmpty(a); },
+ not: function (a) {
+ return !a || Handlebars.Utils.isEmpty(a);
+ },
});
// Note that this i18n caching strategy does not allow us to support
@@ -83,7 +87,15 @@ Handlebars.registerHelper("tr", (context, options) => {
// 1. `context` is very important. It can be `this` or an
// object or key of the current context.
// 2. Use `__` instead of `{{` and `}}` to declare expressions
- const result = i18n.t(options.fn(context).trim().split("\n").map((s) => s.trim()).join(" "), context);
+ const result = i18n.t(
+ options
+ .fn(context)
+ .trim()
+ .split("\n")
+ .map((s) => s.trim())
+ .join(" "),
+ context,
+ );
return new Handlebars.SafeString(result);
});
diff --git a/static/js/tictactoe_widget.js b/static/js/tictactoe_widget.js
index eb0ec6f9eb3..021393e1cc4 100644
--- a/static/js/tictactoe_widget.js
+++ b/static/js/tictactoe_widget.js
@@ -28,9 +28,7 @@ const tictactoe_data_holder = function () {
return false;
}
- return (
- square_values.get(line[1]) === token &&
- square_values.get(line[2]) === token);
+ return square_values.get(line[1]) === token && square_values.get(line[2]) === token;
}
const board = [1, 2, 3, 4, 5, 6, 7, 8, 9];
@@ -106,7 +104,6 @@ const tictactoe_data_holder = function () {
},
};
-
self.handle_event = function (sender_id, data) {
const type = data.type;
if (self.handle[type]) {
diff --git a/static/js/timerender.js b/static/js/timerender.js
index 75df5a57eb7..1bf1ffcdb51 100644
--- a/static/js/timerender.js
+++ b/static/js/timerender.js
@@ -31,8 +31,7 @@ exports.render_now = function (time, today) {
// constants.
const days_old = Math.round(start_of_other_day.diffDays(start_of_today));
- const is_older_year =
- start_of_today.getFullYear() - start_of_other_day.getFullYear() > 0;
+ const is_older_year = start_of_today.getFullYear() - start_of_other_day.getFullYear() > 0;
if (days_old === 0) {
time_str = i18n.t("Today");
@@ -90,12 +89,14 @@ exports.last_seen_status_from_date = function (last_active_date, current_date) {
} else if (days > 90 && days < 365) {
if (current_date.getFullYear() === last_active_date.getFullYear()) {
// Online more than 90 days ago, in the same year
- return i18n.t("__last_active_date__",
- {last_active_date: last_active_date.toString("MMM\xa0dd")});
+ return i18n.t("__last_active_date__", {
+ last_active_date: last_active_date.toString("MMM\xa0dd"),
+ });
}
}
- return i18n.t("__last_active_date__",
- {last_active_date: last_active_date.toString("MMM\xa0dd,\xa0yyyy")});
+ return i18n.t("__last_active_date__", {
+ last_active_date: last_active_date.toString("MMM\xa0dd,\xa0yyyy"),
+ });
};
// List of the dates that need to be updated when the day changes.
@@ -250,8 +251,18 @@ exports.stringify_time = function (time) {
// hour time in the format of "%mmm %d, %h:%m %p".
exports.absolute_time = (function () {
const MONTHS = [
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
+ "Jan",
+ "Feb",
+ "Mar",
+ "Apr",
+ "May",
+ "Jun",
+ "Jul",
+ "Aug",
+ "Sep",
+ "Oct",
+ "Nov",
+ "Dec",
];
const fmt_time = function (date, H_24) {
@@ -298,8 +309,7 @@ exports.get_full_datetime = function (time) {
const tz_offset = -time.getTimezoneOffset() / 60;
return {
date: time.toLocaleDateString(),
- time: time.toLocaleTimeString() +
- " (UTC" + (tz_offset < 0 ? "" : "+") + tz_offset + ")",
+ time: time.toLocaleTimeString() + " (UTC" + (tz_offset < 0 ? "" : "+") + tz_offset + ")",
};
};
diff --git a/static/js/top_left_corner.js b/static/js/top_left_corner.js
index 86e52c88697..be3354ca502 100644
--- a/static/js/top_left_corner.js
+++ b/static/js/top_left_corner.js
@@ -27,8 +27,7 @@ exports.update_dom_with_unread_counts = function (counts) {
exports.update_count_in_dom(mentioned_li, counts.mentioned_message_count);
exports.update_count_in_dom(home_li, counts.home_unread_messages);
- unread_ui.animate_mention_changes(mentioned_li,
- counts.mentioned_message_count);
+ unread_ui.animate_mention_changes(mentioned_li, counts.mentioned_message_count);
};
function deselect_top_left_corner_items() {
diff --git a/static/js/topic_list.js b/static/js/topic_list.js
index 4f6b1572607..dfbc2f2710c 100644
--- a/static/js/topic_list.js
+++ b/static/js/topic_list.js
@@ -70,12 +70,12 @@ exports.keyed_topic_li = (convo) => {
};
exports.more_li = (more_topics_unreads) => {
- const render = () => render_more_topics({
- more_topics_unreads: more_topics_unreads,
- });
+ const render = () =>
+ render_more_topics({
+ more_topics_unreads: more_topics_unreads,
+ });
- const eq = (other) => other.more_items &&
- more_topics_unreads === other.more_topics_unreads;
+ const eq = (other) => other.more_items && more_topics_unreads === other.more_topics_unreads;
const key = "more";
@@ -109,8 +109,7 @@ exports.widget = function (parent_elem, my_stream_id) {
self.prior_dom = undefined;
self.build_list = function (spinner) {
- const list_info = topic_list_data.get_list_info(
- my_stream_id, zoomed);
+ const list_info = topic_list_data.get_list_info(my_stream_id, zoomed);
const num_possible_topics = list_info.num_possible_topics;
const more_topics_unreads = list_info.more_topics_unreads;
@@ -119,9 +118,7 @@ exports.widget = function (parent_elem, my_stream_id) {
list_info.items.length === num_possible_topics &&
stream_topic_history.is_complete_for_stream_id(my_stream_id);
- const attrs = [
- ["class", "topic-list"],
- ];
+ const attrs = [["class", "topic-list"]];
const nodes = list_info.items.map(exports.keyed_topic_li);
@@ -264,14 +261,16 @@ exports.initialize = function () {
const sub = stream_data.get_sub_by_id(stream_id);
const topic = $(e.target).parents("li").attr("data-topic-name");
- narrow.activate([
- {operator: "stream", operand: sub.name},
- {operator: "topic", operand: topic}],
- {trigger: "sidebar"});
+ narrow.activate(
+ [
+ {operator: "stream", operand: sub.name},
+ {operator: "topic", operand: topic},
+ ],
+ {trigger: "sidebar"},
+ );
e.preventDefault();
});
};
-
window.topic_list = exports;
diff --git a/static/js/transmit.js b/static/js/transmit.js
index 99e62da6177..bebecf3e6d6 100644
--- a/static/js/transmit.js
+++ b/static/js/transmit.js
@@ -13,11 +13,13 @@ exports.send_message = function (request, on_success, error) {
error: function (xhr, error_type) {
if (error_type !== "timeout" && reload_state.is_pending()) {
// The error might be due to the server changing
- reload.initiate({immediate: true,
- save_pointer: true,
- save_narrow: true,
- save_compose: true,
- send_after_reload: true});
+ reload.initiate({
+ immediate: true,
+ save_pointer: true,
+ save_narrow: true,
+ save_compose: true,
+ send_after_reload: true,
+ });
return;
}
diff --git a/static/js/typeahead_helper.js b/static/js/typeahead_helper.js
index e9fabac25ea..d039ffff3cb 100644
--- a/static/js/typeahead_helper.js
+++ b/static/js/typeahead_helper.js
@@ -191,8 +191,8 @@ exports.compare_people_for_relevance = function (
person_a,
person_b,
tertiary_compare,
- current_stream_id) {
-
+ current_stream_id,
+) {
// give preference to "all", "everyone" or "stream"
// We use is_broadcast for a quick check. It will
// true for all/everyone/stream and undefined (falsy)
@@ -240,25 +240,21 @@ exports.sort_people_for_relevance = function (objs, current_stream_name, current
current_stream = stream_data.get_sub(current_stream_name);
}
if (!current_stream) {
- objs.sort((person_a, person_b) => exports.compare_people_for_relevance(
- person_a,
- person_b,
- exports.compare_by_pms,
- ));
+ objs.sort((person_a, person_b) =>
+ exports.compare_people_for_relevance(person_a, person_b, exports.compare_by_pms),
+ );
} else {
const stream_id = current_stream.stream_id;
- objs.sort((person_a, person_b) => exports.compare_people_for_relevance(
- person_a,
- person_b,
- (user_a, user_b) => recent_senders.compare_by_recency(
- user_a,
- user_b,
- stream_id,
- current_topic,
+ objs.sort((person_a, person_b) =>
+ exports.compare_people_for_relevance(
+ person_a,
+ person_b,
+ (user_a, user_b) =>
+ recent_senders.compare_by_recency(user_a, user_b, stream_id, current_topic),
+ current_stream.stream_id,
),
- current_stream.stream_id,
- ));
+ );
}
return objs;
@@ -307,24 +303,14 @@ exports.sort_recipients = function (
}
function sort_relevance(items) {
- return exports.sort_people_for_relevance(
- items, current_stream, current_topic);
+ return exports.sort_people_for_relevance(items, current_stream, current_topic);
}
- const users_name_results = typeahead.triage(
- query,
- users,
- (p) => p.full_name);
+ const users_name_results = typeahead.triage(query, users, (p) => p.full_name);
- const email_results = typeahead.triage(
- query,
- users_name_results.rest,
- (p) => p.email);
+ const email_results = typeahead.triage(query, users_name_results.rest, (p) => p.email);
- const groups_results = typeahead.triage(
- query,
- groups,
- (g) => g.name);
+ const groups_results = typeahead.triage(query, groups, (g) => g.name);
const best_users = () => sort_relevance(users_name_results.matches);
const best_groups = () => groups_results.matches;
@@ -332,13 +318,7 @@ exports.sort_recipients = function (
const worst_users = () => sort_relevance(email_results.rest);
const worst_groups = () => groups_results.rest;
- const getters = [
- best_users,
- best_groups,
- ok_users,
- worst_users,
- worst_groups,
- ];
+ const getters = [best_users, best_groups, ok_users, worst_users, worst_groups];
/*
The following optimization is important for large realms.
@@ -369,8 +349,7 @@ function slash_command_comparator(slash_command_a, slash_command_b) {
exports.sort_slash_commands = function (matches, query) {
// We will likely want to in the future make this sort the
// just-`/` commands by something approximating usefulness.
- const results = typeahead.triage(
- query, matches, (x) => x.name);
+ const results = typeahead.triage(query, matches, (x) => x.name);
results.matches = results.matches.sort(slash_command_comparator);
results.rest = results.rest.sort(slash_command_comparator);
@@ -409,11 +388,9 @@ exports.compare_by_activity = function (stream_a, stream_b) {
};
exports.sort_streams = function (matches, query) {
- const name_results = typeahead.triage(
- query, matches, (x) => x.name);
+ const name_results = typeahead.triage(query, matches, (x) => x.name);
- const desc_results = typeahead.triage(
- query, name_results.rest, (x) => x.description);
+ const desc_results = typeahead.triage(query, name_results.rest, (x) => x.description);
// Streams that start with the query.
name_results.matches = name_results.matches.sort(exports.compare_by_activity);
diff --git a/static/js/types/stacktrace-gps/index.d.ts b/static/js/types/stacktrace-gps/index.d.ts
index a5fd87cfbbd..e1a43fd93c7 100644
--- a/static/js/types/stacktrace-gps/index.d.ts
+++ b/static/js/types/stacktrace-gps/index.d.ts
@@ -3,8 +3,8 @@ import StackFrame from "stackframe";
declare namespace StackTraceGPS {
type StackTraceGPSOptions = {
- sourceCache?: { [url: string]: string | Promise<string> };
- sourceMapConsumerCache?: { [sourceMappingUrl: string]: SourceMap.SourceMapConsumer };
+ sourceCache?: {[url: string]: string | Promise<string>};
+ sourceMapConsumerCache?: {[sourceMappingUrl: string]: SourceMap.SourceMapConsumer};
offline?: boolean;
ajax?(url: string): Promise<string>;
atob?(base64: string): string;
diff --git a/static/js/typing.js b/static/js/typing.js
index db3f18ca674..d4bf913d4c1 100644
--- a/static/js/typing.js
+++ b/static/js/typing.js
@@ -61,8 +61,7 @@ exports.initialize = function () {
$(document).on("input", "#compose-textarea", () => {
// If our previous state was no typing notification, send a
// start-typing notice immediately.
- const new_recipient =
- is_valid_conversation() ? exports.get_recipient() : null;
+ const new_recipient = is_valid_conversation() ? exports.get_recipient() : null;
typing_status.update(worker, new_recipient);
});
diff --git a/static/js/typing_data.js b/static/js/typing_data.js
index 0f739b3f2ef..51ce3bed745 100644
--- a/static/js/typing_data.js
+++ b/static/js/typing_data.js
@@ -68,5 +68,4 @@ exports.kickstart_inbound_timer = function (group, delay, callback) {
inbound_timer_dict.set(key, timer);
};
-
window.typing_data = exports;
diff --git a/static/js/typing_events.js b/static/js/typing_events.js
index a5ef1574d6f..3f67975dfd2 100644
--- a/static/js/typing_events.js
+++ b/static/js/typing_events.js
@@ -30,7 +30,9 @@ function get_users_typing_for_narrow() {
if (!narrow_user_ids_string) {
return [];
}
- const narrow_user_ids = narrow_user_ids_string.split(",").map((user_id_string) => parseInt(user_id_string, 10));
+ const narrow_user_ids = narrow_user_ids_string
+ .split(",")
+ .map((user_id_string) => parseInt(user_id_string, 10));
const group = narrow_user_ids.concat([page_params.user_id]);
return typing_data.get_group_typists(group);
}
@@ -73,12 +75,8 @@ exports.display_notification = function (event) {
exports.render_notifications_for_narrow();
- typing_data.kickstart_inbound_timer(
- recipients,
- TYPING_STARTED_EXPIRY_PERIOD,
- () => {
- exports.hide_notification(event);
- },
- );
+ typing_data.kickstart_inbound_timer(recipients, TYPING_STARTED_EXPIRY_PERIOD, () => {
+ exports.hide_notification(event);
+ });
};
window.typing_events = exports;
diff --git a/static/js/ui.js b/static/js/ui.js
index 3236ad623e5..590c8f5afe2 100644
--- a/static/js/ui.js
+++ b/static/js/ui.js
@@ -64,7 +64,8 @@ exports.show_error_for_unsupported_platform = function () {
// We don't internationalize this string because it is long,
// and few users will have both the old desktop app and an
// internationalized version of Zulip anyway.
- const error = "Hello! You're using the unsupported old Zulip desktop app," +
+ const error =
+ "Hello! You're using the unsupported old Zulip desktop app," +
" which is no longer developed. We recommend switching to the new, " +
"modern desktop app, which you can download at " +
"<a href='https://zulip.com/apps'>zulip.com/apps</a>.";
@@ -144,8 +145,8 @@ exports.show_failed_message_success = function (message_id) {
exports.get_hotkey_deprecation_notice = function (originalHotkey, replacementHotkey) {
return i18n.t(
- 'We\'ve replaced the "__originalHotkey__" hotkey with "__replacementHotkey__" '
- + "to make this common shortcut easier to trigger.",
+ 'We\'ve replaced the "__originalHotkey__" hotkey with "__replacementHotkey__" ' +
+ "to make this common shortcut easier to trigger.",
{originalHotkey: originalHotkey, replacementHotkey: replacementHotkey},
);
};
@@ -180,7 +181,10 @@ exports.maybe_show_deprecation_notice = function (key) {
$("#close-deprecation-notice").focus();
shown_deprecation_notices.push(key);
if (localstorage.supported()) {
- localStorage.setItem("shown_deprecation_notices", JSON.stringify(shown_deprecation_notices));
+ localStorage.setItem(
+ "shown_deprecation_notices",
+ JSON.stringify(shown_deprecation_notices),
+ );
}
}
};
@@ -202,9 +206,7 @@ exports.set_compose_textarea_handlers = function () {
};
exports.restore_compose_cursor = function () {
- $("#compose-textarea")
- .focus()
- .caret(saved_compose_cursor);
+ $("#compose-textarea").focus().caret(saved_compose_cursor);
};
exports.initialize = function () {
diff --git a/static/js/ui_init.js b/static/js/ui_init.js
index 7c97fe1a382..a049b054042 100644
--- a/static/js/ui_init.js
+++ b/static/js/ui_init.js
@@ -37,11 +37,23 @@ function message_hover(message_row) {
}
// But the message edit hover icon is determined by whether the message is still editable
- if (message_edit.get_editability(message) === message_edit.editability_types.FULL &&
- !message.status_message) {
- message_row.find(".edit_content").html('<i class="fa fa-pencil edit_content_button" aria-hidden="true" title="Edit (e)"></i>');
+ if (
+ message_edit.get_editability(message) === message_edit.editability_types.FULL &&
+ !message.status_message
+ ) {
+ message_row
+ .find(".edit_content")
+ .html(
+ '<i class="fa fa-pencil edit_content_button" aria-hidden="true" title="Edit (e)"></i>',
+ );
} else {
- message_row.find(".edit_content").html('<i class="fa fa-file-code-o edit_content_button" aria-hidden="true" title="View source (e)" data-message-id="' + id + '"></i>');
+ message_row
+ .find(".edit_content")
+ .html(
+ '<i class="fa fa-file-code-o edit_content_button" aria-hidden="true" title="View source (e)" data-message-id="' +
+ id +
+ '"></i>',
+ );
}
}
@@ -97,8 +109,7 @@ exports.initialize_kitchen_sink_stuff = function () {
const max_scroll = self.prop("scrollHeight") - self.innerHeight() - 1;
e.stopPropagation();
- if (delta < 0 && scroll <= 0 ||
- delta > 0 && scroll >= max_scroll) {
+ if ((delta < 0 && scroll <= 0) || (delta > 0 && scroll >= max_scroll)) {
e.preventDefault();
}
});
@@ -167,8 +178,7 @@ exports.initialize_kitchen_sink_stuff = function () {
// variables to set play button position
const marginLeft = (imgW - 30) / 2;
const marginTop = (imgH - 26) / 2;
- elem.css("--margin-left", `${marginLeft}px`)
- .css("--margin-top", `${marginTop}px`);
+ elem.css("--margin-left", `${marginLeft}px`).css("--margin-top", `${marginTop}px`);
elem.data("entered-before", true);
}
elem.addClass("fa fa-play");
@@ -235,9 +245,10 @@ exports.initialize_kitchen_sink_stuff = function () {
// Scroll to place the message within the current view;
// but if this is the initial placement of the pointer,
// just place it in the very center
- message_viewport.recenter_view(row,
- {from_scroll: event.from_scroll,
- force_center: event.previously_selected === -1});
+ message_viewport.recenter_view(row, {
+ from_scroll: event.from_scroll,
+ force_center: event.previously_selected === -1,
+ });
}
}
});
@@ -249,17 +260,13 @@ exports.initialize_kitchen_sink_stuff = function () {
timerender.set_full_datetime(message, time_elem);
});
- $("#streams_header h4").tooltip({placement: "right",
- animation: false});
+ $("#streams_header h4").tooltip({placement: "right", animation: false});
- $('#streams_header i[data-toggle="tooltip"]').tooltip({placement: "left",
- animation: false});
+ $('#streams_header i[data-toggle="tooltip"]').tooltip({placement: "left", animation: false});
- $("#userlist-header #userlist-title").tooltip({placement: "right",
- animation: false});
+ $("#userlist-header #userlist-title").tooltip({placement: "right", animation: false});
- $("#userlist-header #user_filter_icon").tooltip({placement: "left",
- animation: false});
+ $("#userlist-header #user_filter_icon").tooltip({placement: "left", animation: false});
$('.message_failed i[data-toggle="tooltip"]').tooltip();
@@ -385,28 +392,15 @@ exports.initialize_everything = function () {
return result;
}
- const alert_words_params = pop_fields(
- "alert_words",
- );
+ const alert_words_params = pop_fields("alert_words");
- const bot_params = pop_fields(
- "realm_bots",
- );
+ const bot_params = pop_fields("realm_bots");
- const people_params = pop_fields(
- "realm_users",
- "realm_non_active_users",
- "cross_realm_bots",
- );
+ const people_params = pop_fields("realm_users", "realm_non_active_users", "cross_realm_bots");
- const pm_conversations_params = pop_fields(
- "recent_private_conversations",
- );
+ const pm_conversations_params = pop_fields("recent_private_conversations");
- const presence_params = pop_fields(
- "presences",
- "initial_servertime",
- );
+ const presence_params = pop_fields("presences", "initial_servertime");
const stream_data_params = pop_fields(
"subscriptions",
@@ -415,13 +409,9 @@ exports.initialize_everything = function () {
"realm_default_streams",
);
- const user_groups_params = pop_fields(
- "realm_user_groups",
- );
+ const user_groups_params = pop_fields("realm_user_groups");
- const user_status_params = pop_fields(
- "user_status",
- );
+ const user_status_params = pop_fields("user_status");
alert_words.initialize(alert_words_params);
emojisets.initialize();
@@ -457,10 +447,7 @@ exports.initialize_everything = function () {
message_fetch.initialize();
message_scroll.initialize();
emoji.initialize();
- markdown.initialize(
- page_params.realm_filters,
- markdown_config.get_helpers(),
- );
+ markdown.initialize(page_params.realm_filters, markdown_config.get_helpers());
compose.initialize();
composebox_typeahead.initialize(); // Must happen after compose.initialize()
search.initialize();
diff --git a/static/js/ui_report.js b/static/js/ui_report.js
index 4ada62569d1..19ec1d5ae53 100644
--- a/static/js/ui_report.js
+++ b/static/js/ui_report.js
@@ -11,8 +11,12 @@ exports.message = function (response, status_box, cls, remove_after) {
// Note we use html() below, since we can rely on our callers escaping HTML
// via i18n.t when interpolating data.
- status_box.removeClass(common.status_classes).addClass(cls)
- .html(response).stop(true).fadeTo(0, 1);
+ status_box
+ .removeClass(common.status_classes)
+ .addClass(cls)
+ .html(response)
+ .stop(true)
+ .fadeTo(0, 1);
if (remove_after) {
setTimeout(() => {
status_box.fadeOut(400);
@@ -44,7 +48,9 @@ exports.generic_embed_error = function (error) {
const $alert = $("<div class='alert home-error-bar'></div>");
const $exit = "<div class='exit'></div>";
- $(".alert-box").append($alert.html($exit + "<div class='content'>" + error + "</div>").addClass("show"));
+ $(".alert-box").append(
+ $alert.html($exit + "<div class='content'>" + error + "</div>").addClass("show"),
+ );
};
exports.generic_row_button_error = function (xhr, btn) {
diff --git a/static/js/ui_util.js b/static/js/ui_util.js
index 34ae02f477f..e063b6ea50d 100644
--- a/static/js/ui_util.js
+++ b/static/js/ui_util.js
@@ -9,8 +9,7 @@ exports.change_tab_to = function (tabname) {
exports.place_caret_at_end = function (el) {
el.focus();
- if (typeof window.getSelection !== "undefined"
- && typeof document.createRange !== "undefined") {
+ if (typeof window.getSelection !== "undefined" && typeof document.createRange !== "undefined") {
const range = document.createRange();
range.selectNodeContents(el);
range.collapse(false);
@@ -54,7 +53,8 @@ exports.decorate_stream_bar = function (stream_name, element, is_compose) {
if (is_compose) {
update_lock_icon_for_stream(stream_name);
}
- element.css("background-color", color)
+ element
+ .css("background-color", color)
.removeClass(stream_color.color_classes)
.addClass(stream_color.get_color_class(color));
};
diff --git a/static/js/unread.js b/static/js/unread.js
index eee89d66fcd..223d2b016d8 100644
--- a/static/js/unread.js
+++ b/static/js/unread.js
@@ -200,7 +200,6 @@ exports.unread_topic_counter = (function () {
bucketer.clear();
};
-
self.set_streams = function (objs) {
for (const obj of objs) {
const stream_id = obj.stream_id;
@@ -235,7 +234,6 @@ exports.unread_topic_counter = (function () {
res.stream_unread_messages = 0;
res.stream_count = new Map(); // hash by stream_id -> count
for (const [stream_id, per_stream_bucketer] of bucketer) {
-
// We track unread counts for streams that may be currently
// unsubscribed. Since users may re-subscribe, we don't
// completely throw away the data. But we do ignore it here,
@@ -256,7 +254,6 @@ exports.unread_topic_counter = (function () {
if (!stream_data.is_muted(stream_id)) {
res.stream_unread_messages += stream_count;
}
-
}
return res;
@@ -355,7 +352,6 @@ exports.unread_topic_counter = (function () {
return util.sorted_ids(ids);
};
-
self.topic_has_any_unread = function (stream_id, topic) {
const per_stream_bucketer = bucketer.get_bucket(stream_id);
@@ -403,9 +399,7 @@ exports.update_unread_topics = function (msg, event) {
return;
}
- exports.unread_topic_counter.delete(
- msg.id,
- );
+ exports.unread_topic_counter.delete(msg.id);
exports.unread_topic_counter.add(
new_stream_id || msg.stream_id,
@@ -427,11 +421,7 @@ exports.process_loaded_messages = function (messages) {
}
if (message.type === "stream") {
- exports.unread_topic_counter.add(
- message.stream_id,
- message.topic,
- message.id,
- );
+ exports.unread_topic_counter.add(message.stream_id, message.topic, message.id);
}
exports.update_message_for_mention(message);
@@ -504,9 +494,11 @@ exports.get_counts = function () {
exports.calculate_notifiable_count = function (res) {
let new_message_count = 0;
- const only_show_notifiable = page_params.desktop_icon_count_display ===
+ const only_show_notifiable =
+ page_params.desktop_icon_count_display ===
settings_notifications.desktop_icon_count_display_values.notifiable.code;
- const no_notifications = page_params.desktop_icon_count_display ===
+ const no_notifications =
+ page_params.desktop_icon_count_display ===
settings_notifications.desktop_icon_count_display_values.none.code;
if (only_show_notifiable) {
// DESKTOP_ICON_COUNT_DISPLAY_NOTIFIABLE
@@ -594,18 +586,26 @@ exports.initialize = function () {
}
for (const obj of unread_msgs.huddles) {
- for (const message_id of obj.unread_message_ids) {unread_messages.add(message_id);}
+ for (const message_id of obj.unread_message_ids) {
+ unread_messages.add(message_id);
+ }
}
for (const obj of unread_msgs.pms) {
- for (const message_id of obj.unread_message_ids) {unread_messages.add(message_id);}
+ for (const message_id of obj.unread_message_ids) {
+ unread_messages.add(message_id);
+ }
}
for (const obj of unread_msgs.streams) {
- for (const message_id of obj.unread_message_ids) {unread_messages.add(message_id);}
+ for (const message_id of obj.unread_message_ids) {
+ unread_messages.add(message_id);
+ }
}
- for (const message_id of unread_msgs.mentions) {unread_messages.add(message_id);}
+ for (const message_id of unread_msgs.mentions) {
+ unread_messages.add(message_id);
+ }
};
window.unread = exports;
diff --git a/static/js/unread_ops.js b/static/js/unread_ops.js
index 1108bf3adfd..d1ddd90d56e 100644
--- a/static/js/unread_ops.js
+++ b/static/js/unread_ops.js
@@ -8,10 +8,12 @@ exports.mark_all_as_read = function () {
success: () => {
// After marking all messages as read, we reload the browser.
// This is useful to avoid leaving ourselves deep in the past.
- reload.initiate({immediate: true,
- save_pointer: false,
- save_narrow: true,
- save_compose: true});
+ reload.initiate({
+ immediate: true,
+ save_pointer: false,
+ save_narrow: true,
+ save_compose: true,
+ });
},
});
};
@@ -60,7 +62,6 @@ exports.process_read_messages_event = function (message_ids) {
unread_ui.update_unread_counts();
};
-
// Takes a list of messages and marks them as read.
// Skips any messages that are already marked as read.
exports.notify_server_messages_read = function (messages, options) {
@@ -95,8 +96,7 @@ exports.process_visible = function () {
return;
}
- if (message_viewport.bottom_message_visible() &&
- current_msg_list.can_mark_messages_read()) {
+ if (message_viewport.bottom_message_visible() && current_msg_list.can_mark_messages_read()) {
exports.mark_current_list_as_read();
}
};
@@ -123,5 +123,4 @@ exports.mark_topic_as_read = function (stream_id, topic, cont) {
});
};
-
window.unread_ops = exports;
diff --git a/static/js/unread_ui.js b/static/js/unread_ui.js
index 5d693251b31..bb4e518aecb 100644
--- a/static/js/unread_ui.js
+++ b/static/js/unread_ui.js
@@ -50,9 +50,7 @@ exports.update_unread_counts = function () {
const notifiable_unread_count = unread.calculate_notifiable_count(res);
notifications.update_title_count(notifiable_unread_count);
- exports.set_count_toggle_button($("#streamlist-toggle-unreadcount"),
- res.home_unread_messages);
-
+ exports.set_count_toggle_button($("#streamlist-toggle-unreadcount"), res.home_unread_messages);
};
exports.should_display_bankruptcy_banner = function () {
@@ -67,8 +65,11 @@ exports.should_display_bankruptcy_banner = function () {
}
const now = new XDate(true).getTime() / 1000;
- if (page_params.unread_msgs.count > 500 &&
- now - page_params.furthest_read_time > 60 * 60 * 24 * 2) { // 2 days.
+ if (
+ page_params.unread_msgs.count > 500 &&
+ now - page_params.furthest_read_time > 60 * 60 * 24 * 2
+ ) {
+ // 2 days.
return true;
}
diff --git a/static/js/upload.js b/static/js/upload.js
index 23cca8d393a..8fd897e1526 100644
--- a/static/js/upload.js
+++ b/static/js/upload.js
@@ -56,7 +56,9 @@ exports.get_item = function (key, config) {
case "textarea":
return $("#message_edit_content_" + config.row);
case "send_button":
- return $("#message_edit_content_" + config.row).closest("#message_edit_form").find(".message_edit_save");
+ return $("#message_edit_content_" + config.row)
+ .closest("#message_edit_form")
+ .find(".message_edit_save");
case "send_status_identifier":
return "#message-edit-send-status-" + config.row;
case "send_status":
@@ -89,7 +91,11 @@ exports.show_error_message = function (config, message) {
message = i18n.t("An unknown error occurred.");
}
exports.get_item("send_button", config).prop("disabled", false);
- exports.get_item("send_status", config).addClass("alert-error").removeClass("alert-info").show();
+ exports
+ .get_item("send_status", config)
+ .addClass("alert-error")
+ .removeClass("alert-info")
+ .show();
exports.get_item("send_status_message", config).text(message);
};
@@ -98,15 +104,26 @@ exports.upload_files = function (uppy, config, files) {
return;
}
if (page_params.max_file_upload_size_mib === 0) {
- exports.show_error_message(config, i18n.t("File and image uploads have been disabled for this organization."));
+ exports.show_error_message(
+ config,
+ i18n.t("File and image uploads have been disabled for this organization."),
+ );
return;
}
exports.get_item("send_button", config).attr("disabled", "");
- exports.get_item("send_status", config).addClass("alert-info").removeClass("alert-error").show();
+ exports
+ .get_item("send_status", config)
+ .addClass("alert-info")
+ .removeClass("alert-error")
+ .show();
exports.get_item("send_status_message", config).html($("<p>").text(i18n.t("Uploading…")));
exports.get_item("send_status_close_button", config).one("click", () => {
uppy.getFiles().forEach((file) => {
- compose_ui.replace_syntax(exports.get_translated_status(file), "", exports.get_item("textarea", config));
+ compose_ui.replace_syntax(
+ exports.get_translated_status(file),
+ "",
+ exports.get_item("textarea", config),
+ );
});
compose_ui.autosize_textarea();
uppy.cancelAll();
@@ -118,7 +135,10 @@ exports.upload_files = function (uppy, config, files) {
for (const file of files) {
try {
- compose_ui.insert_syntax_and_focus(exports.get_translated_status(file), exports.get_item("textarea", config));
+ compose_ui.insert_syntax_and_focus(
+ exports.get_translated_status(file),
+ exports.get_item("textarea", config),
+ );
compose_ui.autosize_textarea();
uppy.addFile({
source: exports.get_item("source", config),
@@ -150,20 +170,18 @@ exports.setup_upload = function (config) {
uppy.setMeta({
csrfmiddlewaretoken: csrf_token,
});
- uppy.use(
- XHRUpload, {
- endpoint: "/json/user_uploads",
- formData: true,
- fieldName: "file",
- // Number of concurrent uploads
- limit: 5,
- locale: {
- strings: {
- timedOut: i18n.t("Upload stalled for %{seconds} seconds, aborting."),
- },
+ uppy.use(XHRUpload, {
+ endpoint: "/json/user_uploads",
+ formData: true,
+ fieldName: "file",
+ // Number of concurrent uploads
+ limit: 5,
+ locale: {
+ strings: {
+ timedOut: i18n.t("Upload stalled for %{seconds} seconds, aborting."),
},
},
- );
+ });
uppy.use(ProgressBar, {
target: exports.get_item("send_status_identifier", config),
@@ -215,7 +233,11 @@ exports.setup_upload = function (config) {
}
const absolute_uri = exports.make_upload_absolute(uri);
const filename_uri = "[" + filename + "](" + absolute_uri + ")";
- compose_ui.replace_syntax(exports.get_translated_status(file), filename_uri, exports.get_item("textarea", config));
+ compose_ui.replace_syntax(
+ exports.get_translated_status(file),
+ filename_uri,
+ exports.get_item("textarea", config),
+ );
compose_ui.autosize_textarea();
});
@@ -268,12 +290,20 @@ exports.setup_upload = function (config) {
const message = response ? response.body.msg : null;
uppy.cancelAll();
exports.show_error_message(config, message);
- compose_ui.replace_syntax(exports.get_translated_status(file), "", exports.get_item("textarea", config));
+ compose_ui.replace_syntax(
+ exports.get_translated_status(file),
+ "",
+ exports.get_item("textarea", config),
+ );
compose_ui.autosize_textarea();
});
uppy.on("restriction-failed", (file) => {
- compose_ui.replace_syntax(exports.get_translated_status(file), "", exports.get_item("textarea", config));
+ compose_ui.replace_syntax(
+ exports.get_translated_status(file),
+ "",
+ exports.get_item("textarea", config),
+ );
compose_ui.autosize_textarea();
});
diff --git a/static/js/upload_widget.js b/static/js/upload_widget.js
index f7ece690f00..921e749cdfa 100644
--- a/static/js/upload_widget.js
+++ b/static/js/upload_widget.js
@@ -1,11 +1,6 @@
const default_max_file_size = 5;
-const supported_types = [
- "image/jpeg",
- "image/png",
- "image/gif",
- "image/tiff",
-];
+const supported_types = ["image/jpeg", "image/png", "image/gif", "image/tiff"];
function is_image_format(file) {
const type = file.type;
@@ -51,8 +46,6 @@ exports.build_widget = function (
}
}
-
-
clear_button.on("click", (e) => {
clear();
e.preventDefault();
@@ -75,9 +68,11 @@ exports.build_widget = function (
} else if (e.target.files.length === 1) {
const file = e.target.files[0];
if (file.size > max_file_upload_size * 1024 * 1024) {
- input_error.text(i18n.t("File size must be < __max_file_size__Mb.", {
- max_file_size: max_file_upload_size,
- }));
+ input_error.text(
+ i18n.t("File size must be < __max_file_size__Mb.", {
+ max_file_size: max_file_upload_size,
+ }),
+ );
input_error.show();
clear();
} else if (!is_image_format(file)) {
@@ -157,9 +152,11 @@ exports.build_direct_upload_widget = function (
} else if (e.target.files.length === 1) {
const file = e.target.files[0];
if (file.size > max_file_upload_size * 1024 * 1024) {
- input_error.text(i18n.t("File size must be < __max_file_size__Mb.", {
- max_file_size: max_file_upload_size,
- }));
+ input_error.text(
+ i18n.t("File size must be < __max_file_size__Mb.", {
+ max_file_size: max_file_upload_size,
+ }),
+ );
input_error.show();
clear();
} else if (!is_image_format(file)) {
diff --git a/static/js/user_events.js b/static/js/user_events.js
index bd5527c02ae..aeaf4d849ed 100644
--- a/static/js/user_events.js
+++ b/static/js/user_events.js
@@ -49,8 +49,8 @@ exports.update_person = function update(person) {
if (Object.prototype.hasOwnProperty.call(person, "role")) {
person_obj.is_owner = person.role === settings_config.user_role_values.owner.code;
- person_obj.is_admin = person.role === settings_config.user_role_values.admin.code
- || person_obj.is_owner;
+ person_obj.is_admin =
+ person.role === settings_config.user_role_values.admin.code || person_obj.is_owner;
person_obj.is_guest = person.role === settings_config.user_role_values.guest.code;
settings_users.update_user_data(person.user_id, person);
diff --git a/static/js/user_pill.js b/static/js/user_pill.js
index 8ba6289484b..1aca5f4f600 100644
--- a/static/js/user_pill.js
+++ b/static/js/user_pill.js
@@ -136,12 +136,12 @@ exports.set_up_typeahead_on_pills = function (input, pills, update_func, source)
return item.full_name.toLowerCase().includes(query);
}
const email = people.get_visible_email(item);
- return email.toLowerCase().includes(query)
- || item.full_name.toLowerCase().includes(query);
+ return (
+ email.toLowerCase().includes(query) || item.full_name.toLowerCase().includes(query)
+ );
},
sorter: function (matches) {
- return typeahead_helper.sort_recipientbox_typeahead(
- this.query, matches, "");
+ return typeahead_helper.sort_recipientbox_typeahead(this.query, matches, "");
},
updater: function (user) {
exports.append_user(user, pills);
diff --git a/static/js/util.js b/static/js/util.js
index 6c8d09a65e5..8710c33b8c5 100644
--- a/static/js/util.js
+++ b/static/js/util.js
@@ -32,7 +32,9 @@ exports.lower_bound = function (array, arg1, arg2, arg3, arg4) {
}
if (less === undefined) {
- less = function (a, b) { return a < b; };
+ less = function (a, b) {
+ return a < b;
+ };
}
let len = last - first;
@@ -58,8 +60,7 @@ function lower_same(a, b) {
exports.same_stream_and_topic = function util_same_stream_and_topic(a, b) {
// Streams and topics are case-insensitive.
- return a.stream_id === b.stream_id &&
- lower_same(a.topic, b.topic);
+ return a.stream_id === b.stream_id && lower_same(a.topic, b.topic);
};
exports.is_pm_recipient = function (user_id, message) {
@@ -94,8 +95,11 @@ exports.same_recipient = function util_same_recipient(a, b) {
};
exports.same_sender = function util_same_sender(a, b) {
- return a !== undefined && b !== undefined &&
- a.sender_email.toLowerCase() === b.sender_email.toLowerCase();
+ return (
+ a !== undefined &&
+ b !== undefined &&
+ a.sender_email.toLowerCase() === b.sender_email.toLowerCase()
+ );
};
exports.normalize_recipients = function (recipients) {
@@ -325,7 +329,10 @@ exports.clean_user_content_links = function (html) {
title = url;
legacy_title = href;
}
- elt.setAttribute("title", ["", legacy_title].includes(elt.title) ? title : `${title}\n${elt.title}`);
+ elt.setAttribute(
+ "title",
+ ["", legacy_title].includes(elt.title) ? title : `${title}\n${elt.title}`,
+ );
}
return content.innerHTML;
};
diff --git a/static/js/vdom.js b/static/js/vdom.js
index 7bf03bbf410..3e550b0e6b1 100644
--- a/static/js/vdom.js
+++ b/static/js/vdom.js
@@ -35,7 +35,9 @@ exports.render_tag = (tag) => {
*/
const opts = tag.opts;
const tag_name = tag.tag_name;
- const attr_str = opts.attrs.map((attr) => " " + attr[0] + '="' + _.escape(attr[1]) + '"').join("");
+ const attr_str = opts.attrs
+ .map((attr) => " " + attr[0] + '="' + _.escape(attr[1]) + '"')
+ .join("");
const start_tag = "<" + tag_name + attr_str + ">";
const end_tag = "</" + tag_name + ">";
@@ -158,11 +160,7 @@ exports.update = (replace_content, find, new_dom, old_dom) => {
child_elems.eq(i).replaceWith(rendered_dom);
}
- exports.update_attrs(
- find(),
- new_opts.attrs,
- old_opts.attrs,
- );
+ exports.update_attrs(find(), new_opts.attrs, old_opts.attrs);
};
exports.update_attrs = (elem, new_attrs, old_attrs) => {
diff --git a/static/js/zcommand.js b/static/js/zcommand.js
index 76e1bb7cae5..9a15c39b2dc 100644
--- a/static/js/zcommand.js
+++ b/static/js/zcommand.js
@@ -40,9 +40,11 @@ exports.send = function (opts) {
exports.tell_user = function (msg) {
// This is a bit hacky, but we don't have a super easy API now
// for just telling users stuff.
- $("#compose-send-status").removeClass(common.status_classes)
+ $("#compose-send-status")
+ .removeClass(common.status_classes)
.addClass("alert-error")
- .stop(true).fadeTo(0, 1);
+ .stop(true)
+ .fadeTo(0, 1);
$("#compose-error-msg").text(msg);
};
@@ -135,7 +137,6 @@ exports.enter_fixed_mode = function () {
};
exports.process = function (message_content) {
-
const content = message_content.trim();
if (content === "/ping") {
diff --git a/static/js/zform.js b/static/js/zform.js
index c29f71ce0c5..89d6cc8b82a 100644
--- a/static/js/zform.js
+++ b/static/js/zform.js
@@ -12,11 +12,7 @@ exports.validate_extra_data = function (data) {
}
function check_choices(field_name, val) {
- return schema.check_array(
- field_name,
- val,
- check_choice_item,
- );
+ return schema.check_array(field_name, val, check_choice_item);
}
return schema.check_record("zform data", data, {
@@ -32,7 +28,6 @@ exports.validate_extra_data = function (data) {
return "unknown zform type: " + data.type;
}
-
const msg = check(data);
if (msg) {
diff --git a/static/shared/js/typeahead.js b/static/shared/js/typeahead.js
index 025aeccd6f6..f9785de8062 100644
--- a/static/shared/js/typeahead.js
+++ b/static/shared/js/typeahead.js
@@ -157,22 +157,13 @@ export function sort_emojis(objs, query) {
const popular_set = new Set(popular_emojis);
function is_popular(obj) {
- return popular_set.has(obj.emoji_code) &&
- decent_match(obj.emoji_name);
+ return popular_set.has(obj.emoji_code) && decent_match(obj.emoji_name);
}
const popular_emoji_matches = objs.filter(is_popular);
const others = objs.filter((obj) => !is_popular(obj));
- const triage_results = triage(
- query,
- others,
- (x) => x.emoji_name,
- );
-
- return [
- ...popular_emoji_matches,
- ...triage_results.matches,
- ...triage_results.rest,
- ];
+ const triage_results = triage(query, others, (x) => x.emoji_name);
+
+ return [...popular_emoji_matches, ...triage_results.matches, ...triage_results.rest];
}
diff --git a/static/shared/js/typing_status.js b/static/shared/js/typing_status.js
index c308969ce98..de2db772bbb 100644
--- a/static/shared/js/typing_status.js
+++ b/static/shared/js/typing_status.js
@@ -46,10 +46,7 @@ export function start_or_extend_idle_timer(worker) {
if (state.idle_timer) {
clearTimeout(state.idle_timer);
}
- state.idle_timer = setTimeout(
- on_idle_timeout,
- TYPING_STOPPED_WAIT_PERIOD,
- );
+ state.idle_timer = setTimeout(on_idle_timeout, TYPING_STOPPED_WAIT_PERIOD);
}
function set_next_start_time(current_time) {
diff --git a/tools/debug-require-webpack-plugin.ts b/tools/debug-require-webpack-plugin.ts
index 4da747bbfa2..1cb1aadfdac 100644
--- a/tools/debug-require-webpack-plugin.ts
+++ b/tools/debug-require-webpack-plugin.ts
@@ -47,7 +47,7 @@ export default class DebugRequirePlugin {
__dirname,
"./debug-require.js",
{},
- (err?: Error, result?: string) => err ? reject(err) : resolve(result),
+ (err?: Error, result?: string) => (err ? reject(err) : resolve(result)),
),
);
},
diff --git a/tools/message-screenshot.js b/tools/message-screenshot.js
index 24ab9d6fde7..7734b8677d3 100644
--- a/tools/message-screenshot.js
+++ b/tools/message-screenshot.js
@@ -24,7 +24,8 @@ async function run() {
const browser = await puppeteer.launch({
args: [
"--window-size=1400,1024",
- "--no-sandbox", "--disable-setuid-sandbox",
+ "--no-sandbox",
+ "--disable-setuid-sandbox",
// Helps render fonts correctly on Ubuntu: https://github.com/puppeteer/puppeteer/issues/661
"--font-render-hinting=none",
],
diff --git a/tools/webpack-helpers.ts b/tools/webpack-helpers.ts
index 2932713b6c5..210d99aa1e5 100644
--- a/tools/webpack-helpers.ts
+++ b/tools/webpack-helpers.ts
@@ -41,7 +41,7 @@ function getExposeLoaders(optionsArr: ExportLoaderOptions[]): RuleSetRule[] {
for (const exposeName of loaderEntry.name) {
useArr.push({loader: "expose-loader", options: exposeName});
}
- // If name is a string
+ // If name is a string
} else {
useArr.push({loader: "expose-loader", options: loaderEntry.name});
}
@@ -53,6 +53,4 @@ function getExposeLoaders(optionsArr: ExportLoaderOptions[]): RuleSetRule[] {
}
return exposeLoaders;
}
-export {
- getExposeLoaders,
-};
+export {getExposeLoaders};
diff --git a/tools/webpack.config.ts b/tools/webpack.config.ts
index 724dc6419b3..9bb599fafca 100644
--- a/tools/webpack.config.ts
+++ b/tools/webpack.config.ts
@@ -36,7 +36,9 @@ export default (env?: string): webpack.Configuration[] => {
{
loader: "webfonts-loader",
options: {
- fileName: production ? "files/[fontname].[chunkhash].[ext]" : "files/[fontname].[ext]",
+ fileName: production
+ ? "files/[fontname].[chunkhash].[ext]"
+ : "files/[fontname].[ext]",
publicPath: "",
},
},
@@ -115,10 +117,19 @@ export default (env?: string): webpack.Configuration[] => {
options: {
// Tell webpack not to explicitly require these.
knownHelpers: [
- "if", "unless", "each", "with",
+ "if",
+ "unless",
+ "each",
+ "with",
// The ones below are defined in static/js/templates.js
- "plural", "eq", "and", "or", "not",
- "t", "tr", "rendered_markdown",
+ "plural",
+ "eq",
+ "and",
+ "or",
+ "not",
+ "t",
+ "tr",
+ "rendered_markdown",
],
preventIndent: true,
},
@@ -128,13 +139,15 @@ export default (env?: string): webpack.Configuration[] => {
// load fonts and files
{
test: /\.(woff(2)?|ttf|eot|svg|otf|png)$/,
- use: [{
- loader: "file-loader",
- options: {
- name: production ? "[name].[hash].[ext]" : "[path][name].[ext]",
- outputPath: "files/",
+ use: [
+ {
+ loader: "file-loader",
+ options: {
+ name: production ? "[name].[hash].[ext]" : "[path][name].[ext]",
+ outputPath: "files/",
+ },
},
- }],
+ ],
},
],
},
@@ -203,14 +216,14 @@ export default (env?: string): webpack.Configuration[] => {
? "webpack-stats-production.json"
: "var/webpack-stats-dev.json",
}),
- ...production
+ ...(production
? []
: [
- // Better logging from console for hot reload
- new webpack.NamedModulesPlugin(),
- // script-loader should load sourceURL in dev
- new webpack.LoaderOptionsPlugin({debug: true}),
- ],
+ // Better logging from console for hot reload
+ new webpack.NamedModulesPlugin(),
+ // script-loader should load sourceURL in dev
+ new webpack.LoaderOptionsPlugin({debug: true}),
+ ]),
// Extract CSS from files
new MiniCssExtractPlugin({
filename: production ? "[name].[contenthash].css" : "[name].css",
diff --git a/zerver/openapi/javascript_examples.js b/zerver/openapi/javascript_examples.js
index abadc168632..000a24e471f 100644
--- a/zerver/openapi/javascript_examples.js
+++ b/zerver/openapi/javascript_examples.js
@@ -165,8 +165,10 @@ add_example("get_messages", "/messages:get", 200, async (client) => {
anchor: "newest",
num_before: 100,
num_after: 0,
- narrow: [{operator: "sender", operand: "[email protected]"},
- {operator: "stream", operand: "Verona"}],
+ narrow: [
+ {operator: "sender", operand: "[email protected]"},
+ {operator: "stream", operand: "Verona"},
+ ],
};
// Get the 100 last messages sent by "[email protected]" to the stream "Verona"
@@ -257,10 +259,7 @@ add_example("add_subscriptions", "/users/me/subscriptions:post", 200, async (cli
// {code_example|start}
// Subscribe to the streams "Verona" and "Denmark"
const meParams = {
- subscriptions: JSON.stringify([
- {name: "Verona"},
- {name: "Denmark"},
- ]),
+ subscriptions: JSON.stringify([{name: "Verona"}, {name: "Denmark"}]),
};
const result_1 = await client.users.me.subscriptions.add(meParams);
// {code_example|end}
@@ -270,10 +269,7 @@ add_example("add_subscriptions", "/users/me/subscriptions:post", 200, async (cli
// the `principals` parameter, like so:
const user_id = 7;
const anotherUserParams = {
- subscriptions: JSON.stringify([
- {name: "Verona"},
- {name: "Denmark"},
- ]),
+ subscriptions: JSON.stringify([{name: "Verona"}, {name: "Denmark"}]),
principals: JSON.stringify([user_id]),
};
const result_2 = await client.users.me.subscriptions.add(anotherUserParams);