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: Normalize strings to double quotes.

Anders Kaseorgf3726db89afd
diff --git a/.eslintrc.json b/.eslintrc.json
index 9ef47515004..eec188d2710 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -112,6 +112,11 @@
}
],
"quote-props": [ "error", "as-needed" ],
+ "quotes": [
+ "error",
+ "double",
+ { "avoidEscape": true, "allowTemplateLiterals": false }
+ ],
"radix": "error",
"semi": "error",
"semi-spacing": "error",
diff --git a/frontend_tests/casper_lib/common.js b/frontend_tests/casper_lib/common.js
index 22dc2b3612d..dce08c4e1dd 100644
--- a/frontend_tests/casper_lib/common.js
+++ b/frontend_tests/casper_lib/common.js
@@ -1,6 +1,6 @@
var util = require("util");
-var test_credentials = require('../../var/casper/test_credentials.js').test_credentials;
+var test_credentials = require("../../var/casper/test_credentials.js").test_credentials;
casper.options.clientScripts.push("frontend_tests/casper_lib/polyfill.js");
@@ -14,7 +14,7 @@ var last_send_or_update = -1;
function log_in() {
var credentials = test_credentials.default_user;
- casper.test.info('Logging in');
+ casper.test.info("Logging in");
casper.fill('form[action^="/accounts/login/"]', {
username: credentials.username,
password: credentials.password,
@@ -55,16 +55,16 @@ exports.initialize_casper = function () {
// set this at the PhantomJS level.
casper.page.onError = function (msg, trace) {
casper.test.error(msg);
- casper.echo('Traceback:');
+ casper.echo("Traceback:");
trace.forEach(function (item) {
- casper.echo(' ' + item.file + ':' + item.line);
+ casper.echo(" " + item.file + ":" + item.line);
});
casper.exit(1);
};
// Capture screens from all failures
var casper_failure_count = 1;
- casper.test.on('fail', function failure() {
+ casper.test.on("fail", function failure() {
if (casper_failure_count <= 10) {
casper.capture("var/casper/casper-failure" + casper_failure_count + ".png");
casper_failure_count += 1;
@@ -72,14 +72,14 @@ exports.initialize_casper = function () {
});
// Update last_send_or_update whenever get_events returns.
- casper.on('resource.received', function (resource) {
+ casper.on("resource.received", function (resource) {
if (/\/json\/get_events/.test(resource.url)) {
last_send_or_update = timestamp();
}
});
- casper.on('load.finished', function () {
- casper.test.info('page load finished');
+ casper.on("load.finished", function () {
+ casper.test.info("page load finished");
});
casper.evaluate(function () {
@@ -87,7 +87,7 @@ exports.initialize_casper = function () {
});
// This captures console messages from the app.
- casper.on('remote.message', function (msg) {
+ casper.on("remote.message", function (msg) {
casper.echo("app console: " + msg);
});
};
@@ -116,14 +116,14 @@ exports.then_log_in = function () {
};
exports.then_log_out = function () {
- var menu_selector = '#settings-dropdown';
+ var menu_selector = "#settings-dropdown";
var logout_selector = 'a[href="#logout"]';
casper.waitUntilVisible(menu_selector, function () {
casper.click(menu_selector);
casper.waitUntilVisible(logout_selector, function () {
- casper.test.info('Logging out');
+ casper.test.info("Logging out");
casper.click(logout_selector);
});
@@ -139,7 +139,7 @@ exports.then_log_out = function () {
// select the menu item matching item by typing str.
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.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
@@ -147,7 +147,7 @@ exports.select_item_via_typeahead = function (field_selector, str, item) {
$(field_selector)
.focus()
.val(str)
- .trigger($.Event('keyup', { which: 0 }));
+ .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 (??),
@@ -227,13 +227,13 @@ exports.wait_for_message_fully_processed = function (content) {
don't add the star icon until the server
responds.
*/
- return row.find('.star').length === 1;
+ return row.find(".star").length === 1;
}, { content: content});
});
};
exports.turn_off_press_enter_to_send = function () {
- var enter_send_selector = '#enter_sends';
+ var enter_send_selector = "#enter_sends";
casper.waitForSelector(enter_send_selector);
var is_checked = casper.evaluate(function (enter_send_selector) {
@@ -269,15 +269,15 @@ exports.then_send_message = function (type, params) {
delete params.outside_view;
casper.then(function () {
- casper.waitForSelector('#compose-send-button:enabled');
- casper.waitForSelector('#compose-textarea');
+ casper.waitForSelector("#compose-send-button:enabled");
+ casper.waitForSelector("#compose-textarea");
});
casper.then(function () {
if (type === "stream") {
- casper.page.sendEvent('keypress', "c");
+ casper.page.sendEvent("keypress", "c");
} else if (type === "private") {
- casper.page.sendEvent('keypress', "x");
+ casper.page.sendEvent("keypress", "x");
} else {
casper.test.assertTrue(false, "send_message got valid message type");
}
@@ -300,13 +300,13 @@ exports.then_send_message = function (type, params) {
exports.turn_off_press_enter_to_send();
casper.then(function () {
- casper.click('#compose-send-button');
+ casper.click("#compose-send-button");
});
});
casper.then(function () {
casper.waitFor(function emptyComposeBox() {
- return casper.getFormValues('form[action^="/json/messages"]').content === '';
+ return casper.getFormValues('form[action^="/json/messages"]').content === "";
});
if (!outside_view) {
exports.wait_for_message_fully_processed(params.content);
@@ -328,16 +328,16 @@ exports.then_send_message = function (type, params) {
// 'table' here).
exports.get_rendered_messages = function (table) {
return casper.evaluate(function (table) {
- var tbl = $('#' + table);
+ var tbl = $("#" + table);
return {
- headings: $.map(tbl.find('.recipient_row .message-header-contents'), function (elem) {
+ 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, ' ');
+ return $clone.text().trim().replace(/\s+/g, " ");
}),
- bodies: $.map(tbl.find('.message_content'), function (elem) {
+ bodies: $.map(tbl.find(".message_content"), function (elem) {
return elem.innerHTML;
}),
};
@@ -373,7 +373,7 @@ exports.get_stream_id = function (stream_name) {
// presses by code, only strings of printable characters.
exports.keypress = function (code) {
casper.evaluate(function (code) {
- $('body').trigger($.Event('keydown', { which: code }));
+ $("body").trigger($.Event("keydown", { which: code }));
}, {
code: code,
});
@@ -382,7 +382,7 @@ exports.keypress = function (code) {
exports.then_send_many = function (msgs) {
msgs.forEach(function (msg) {
exports.then_send_message(
- msg.stream !== undefined ? 'stream' : 'private',
+ msg.stream !== undefined ? "stream" : "private",
msg);
});
};
@@ -397,21 +397,21 @@ exports.wait_for_receive = function (step) {
// Wait until the loading spinner goes away (helpful just after logging in).
exports.wait_for_load = function (step) {
- casper.waitWhileVisible('#page_loading_indicator', step);
+ casper.waitWhileVisible("#page_loading_indicator", step);
};
// innerText sometimes gives us non-breaking space characters, and occasionally
// a different number of spaces than we expect.
exports.normalize_spaces = function (str) {
- return str.replace(/\s+/g, ' ');
+ return str.replace(/\s+/g, " ");
};
exports.ltrim = function (str) {
- return str.replace(/^\s+/g, '');
+ return str.replace(/^\s+/g, "");
};
exports.rtrim = function (str) {
- return str.replace(/\s+$/g, '');
+ return str.replace(/\s+$/g, "");
};
exports.trim = function (str) {
@@ -421,24 +421,24 @@ exports.trim = function (str) {
// Call get_rendered_messages and then check that the last few headings and
// bodies match the specified arrays.
exports.expected_messages = function (table, headings, bodies) {
- casper.test.assertVisible('#' + table, table + ' is visible');
+ casper.test.assertVisible("#" + table, table + " is visible");
var msg = exports.get_rendered_messages(table);
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 () {
- casper.test.info('Un-narrowing');
- if (casper.visible('.message_comp')) {
+ casper.test.info("Un-narrowing");
+ if (casper.visible(".message_comp")) {
// close the compose box
common.keypress(27); // Esc
}
@@ -447,20 +447,20 @@ exports.un_narrow = function () {
exports.manage_organization = function () {
casper.then(function () {
- var menu_selector = '#settings-dropdown';
+ var menu_selector = "#settings-dropdown";
casper.waitUntilVisible(menu_selector, function () {
casper.click(menu_selector);
});
});
casper.then(function () {
- casper.test.info('Organization page');
+ casper.test.info("Organization page");
casper.click('a[href^="#organization"]');
});
- 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.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.then(function () {
diff --git a/frontend_tests/casper_tests/00-realm-creation.js b/frontend_tests/casper_tests/00-realm-creation.js
index 41e464e4344..2f62e97b632 100644
--- a/frontend_tests/casper_tests/00-realm-creation.js
+++ b/frontend_tests/casper_tests/00-realm-creation.js
@@ -1,12 +1,12 @@
-var common = require('../casper_lib/common.js');
+var common = require("../casper_lib/common.js");
-var email = '[email protected]';
-var subdomain = 'testsubdomain';
-var organization_name = 'Awesome Organization';
+var email = "[email protected]";
+var subdomain = "testsubdomain";
+var organization_name = "Awesome Organization";
var host = "zulipdev.com:9981";
-var realm_host = "testsubdomain" + '.' + host;
+var realm_host = "testsubdomain" + "." + host;
-casper.start('http://' + host + '/new/');
+casper.start("http://" + host + "/new/");
casper.then(function () {
// Submit the email for realm creation
@@ -17,58 +17,58 @@ casper.then(function () {
});
// Make sure confirmation email is send
this.waitWhileVisible('form[name="email_form"]', function () {
- var regex = new RegExp('^http://[^/]+/accounts/new/send_confirm/' + email);
- this.test.assertUrlMatch(regex, 'Confirmation mail send');
+ var regex = new RegExp("^http://[^/]+/accounts/new/send_confirm/" + email);
+ this.test.assertUrlMatch(regex, "Confirmation mail send");
});
});
// Special endpoint enabled only during tests for extracting confirmation key
-casper.thenOpen('http://' + host + '/confirmation_key/');
+casper.thenOpen("http://" + host + "/confirmation_key/");
// Open the confirmation URL
casper.then(function () {
var confirmation_key = JSON.parse(this.getPageContent()).confirmation_key;
- var confirmation_url = 'http://' + host + '/accounts/do_confirm/' + confirmation_key;
+ var confirmation_url = "http://" + host + "/accounts/do_confirm/" + confirmation_key;
this.thenOpen(confirmation_url);
});
// Make sure the realm creation page is loaded correctly
casper.then(function () {
- this.waitUntilVisible('.pitch', function () {
- this.test.assertSelectorContains('.pitch', "We just need you to do one last thing.");
+ this.waitUntilVisible(".pitch", function () {
+ this.test.assertSelectorContains(".pitch", "We just need you to do one last thing.");
});
- this.waitUntilVisible('#id_email', function () {
+ this.waitUntilVisible("#id_email", function () {
this.test.assertEvalEquals(function () {
- return $('#id_email').attr('placeholder');
+ return $("#id_email").attr("placeholder");
}, email);
});
- this.waitUntilVisible('label[for=id_team_name]', function () {
- this.test.assertSelectorHasText('label[for=id_team_name]', 'Organization name');
+ this.waitUntilVisible("label[for=id_team_name]", function () {
+ this.test.assertSelectorHasText("label[for=id_team_name]", "Organization name");
});
});
casper.then(function () {
this.waitUntilVisible('form[action^="/accounts/register/"]', function () {
this.fill('form[action^="/accounts/register/"]', {
- full_name: 'Alice',
+ full_name: "Alice",
realm_name: organization_name,
realm_subdomain: subdomain,
- password: 'passwordwhichisreallyreallyreallycomplexandnotguessable',
+ password: "passwordwhichisreallyreallyreallycomplexandnotguessable",
terms: true,
realm_in_root_domain: false,
}, true);
});
this.waitWhileVisible('form[action^="/accounts/register/"]', function () {
- casper.test.assertUrlMatch(realm_host + '/', 'Home page loaded');
+ casper.test.assertUrlMatch(realm_host + "/", "Home page loaded");
});
});
casper.then(function () {
// The user is logged in to the newly created realm and the app is loaded
- casper.waitUntilVisible('.message_row', function () {
+ casper.waitUntilVisible(".message_row", function () {
this.test.assertTitleMatch(/ - Zulip$/, "Successfully logged into Zulip webapp");
}, null, 20000);
});
diff --git a/frontend_tests/casper_tests/01-login.js b/frontend_tests/casper_tests/01-login.js
index e718104b367..c2fdfd43fdf 100644
--- a/frontend_tests/casper_tests/01-login.js
+++ b/frontend_tests/casper_tests/01-login.js
@@ -1,4 +1,4 @@
-var common = require('../casper_lib/common.js');
+var common = require("../casper_lib/common.js");
var realm_url = "http://zulip.zulipdev.com:9981/";
// Start of test script.
@@ -6,7 +6,7 @@ common.init_viewport();
casper.start(realm_url, common.initialize_casper);
casper.then(function () {
- casper.test.assertUrlMatch(/^http:\/\/[^/]+\/login\/$/, 'Redirected to /login/');
+ casper.test.assertUrlMatch(/^http:\/\/[^/]+\/login\/$/, "Redirected to /login/");
});
common.then_log_in();
diff --git a/frontend_tests/casper_tests/02-site.js b/frontend_tests/casper_tests/02-site.js
index f64563e5363..75857469776 100644
--- a/frontend_tests/casper_tests/02-site.js
+++ b/frontend_tests/casper_tests/02-site.js
@@ -8,69 +8,69 @@
// Provides a few utility functions.
// See https://web.archive.org/web/20200110122733if_/https://docs.casperjs.org/en/latest/modules/utils.html
// For example, utils.dump() prints an Object with nice formatting.
-var common = require('../casper_lib/common.js');
+var common = require("../casper_lib/common.js");
common.start_and_log_in();
casper.then(function () {
- casper.test.info('Sanity-checking existing messages');
+ casper.test.info("Sanity-checking existing messages");
- var msg = common.get_rendered_messages('zhome');
+ 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');
+ "Heading is well-formed");
});
- casper.test.info('Sending messages');
+ casper.test.info("Sending messages");
});
// 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' },
+ content: "personal A" },
- content: 'personal B' },
+ 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',
+ 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>',
+ "<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');
+ 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' },
+ 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 524f48286eb..53ddd9ed730 100644
--- a/frontend_tests/casper_tests/03-narrow.js
+++ b/frontend_tests/casper_tests/03-narrow.js
@@ -1,4 +1,4 @@
-var common = require('../casper_lib/common.js');
+var common = require("../casper_lib/common.js");
common.start_and_log_in();
@@ -12,39 +12,39 @@ function get_stream_li(stream_name) {
// 'run' script provides for).
casper.then(function () {
- casper.test.info('Sending messages');
+ casper.test.info("Sending messages");
});
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' },
+ content: "personal A" },
- content: 'personal B' },
+ 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' },
+ content: "personal D" },
- { recipient: '[email protected]',
- content: 'personal E' },
+ { recipient: "[email protected]",
+ content: "personal E" },
]);
@@ -52,15 +52,15 @@ common.then_send_many([
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',
+ 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>',
+ "<p>test message D</p>",
+ "<p>personal D</p>",
+ "<p>personal E</p>",
]);
});
});
@@ -68,16 +68,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',
+ 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>',
+ "<p>test message A</p>",
+ "<p>test message B</p>",
+ "<p>test message C</p>",
+ "<p>test message D</p>",
]);
});
});
@@ -85,32 +85,32 @@ function expect_stream() {
function expect_stream_subject() {
casper.then(function () {
- casper.waitUntilVisible('#zfilt', function () {
- common.expected_messages('zfilt', [
- 'Verona > frontend test',
+ 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>',
+ "<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');
+ casper.test.assertEquals(casper.fetchText("#left_bar_compose_stream_button_big"), "New topic");
});
});
}
function expect_subject() {
casper.then(function () {
- casper.waitUntilVisible('#zfilt', function () {
- common.expected_messages('zfilt', [
- 'Verona > frontend test',
- 'Denmark > frontend test',
- 'Verona > frontend test',
+ 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>',
+ "<p>test message A</p>",
+ "<p>test message B</p>",
+ "<p>other message</p>",
+ "<p>test message D</p>",
]);
});
});
@@ -118,13 +118,13 @@ function expect_subject() {
function expect_huddle() {
casper.then(function () {
- casper.waitUntilVisible('#zfilt', function () {
- common.expected_messages('zfilt', [
- 'You and Cordelia Lear, King Hamlet',
+ 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>',
+ "<p>personal A</p>",
+ "<p>personal B</p>",
+ "<p>personal D</p>",
]);
});
});
@@ -132,12 +132,12 @@ function expect_huddle() {
function expect_1on1() {
casper.then(function () {
- casper.waitUntilVisible('#zfilt', function () {
- common.expected_messages('zfilt', [
- 'You and Cordelia Lear',
+ casper.waitUntilVisible("#zfilt", function () {
+ common.expected_messages("zfilt", [
+ "You and Cordelia Lear",
], [
- '<p>personal C</p>',
- '<p>personal E</p>',
+ "<p>personal C</p>",
+ "<p>personal E</p>",
]);
});
});
@@ -145,41 +145,41 @@ 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',
+ 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>',
+ "<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');
+ casper.test.assertEquals(casper.fetchText("#left_bar_compose_stream_button_big"), "New stream message");
});
});
}
function expect_non_existing_user() {
casper.then(function () {
- casper.waitUntilVisible('#non_existing_user', 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 ";
- this.test.assertEquals(casper.fetchText('#non_existing_user'), expected_message);
+ this.test.assertEquals(casper.fetchText("#non_existing_user"), expected_message);
});
});
}
function expect_non_existing_users() {
casper.then(function () {
- casper.waitUntilVisible('#non_existing_users', 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 ";
- this.test.assertEquals(casper.fetchText('#non_existing_users'), expected_message);
+ this.test.assertEquals(casper.fetchText("#non_existing_users"), expected_message);
});
});
}
@@ -188,38 +188,38 @@ function check_narrow_title(title) {
return function () {
// need to get title tag from HTML
// test if it's equal to some string passed in to function
- casper.test.assertSelectorHasText('title', title, 'Got expected narrow title');
+ casper.test.assertSelectorHasText("title", title, "Got expected narrow title");
};
}
function un_narrow() {
casper.then(common.un_narrow);
expect_home();
- casper.then(check_narrow_title('home - Zulip Dev - Zulip'));
+ casper.then(check_narrow_title("home - Zulip Dev - Zulip"));
}
function search_and_check(str, item, check, narrow_title) {
- common.select_item_via_typeahead('#search_query', str, item);
+ common.select_item_via_typeahead("#search_query", str, item);
check();
casper.then(check_narrow_title(narrow_title));
un_narrow();
}
function search_silent_user(str, item) {
- common.select_item_via_typeahead('#search_query', str, item);
+ common.select_item_via_typeahead("#search_query", str, item);
casper.then(function () {
- casper.waitUntilVisible('#silent_user', 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 ";
- this.test.assertEquals(casper.fetchText('#silent_user'), expected_message);
+ this.test.assertEquals(casper.fetchText("#silent_user"), expected_message);
});
});
un_narrow();
}
function search_non_existing_user(str, item) {
- common.select_item_via_typeahead('#search_query', str, item);
+ common.select_item_via_typeahead("#search_query", str, item);
expect_non_existing_user();
un_narrow();
}
@@ -228,248 +228,248 @@ function search_non_existing_user(str, item) {
casper.then(function () {
common.wait_for_receive(function () {
- casper.test.info('Narrowing by clicking stream');
+ casper.test.info("Narrowing by clicking stream");
casper.click('*[title="Narrow to stream \\"Verona\\""]');
});
});
expect_stream();
-casper.then(check_narrow_title('Verona - Zulip Dev - Zulip'));
+casper.then(check_narrow_title("Verona - Zulip Dev - Zulip"));
un_narrow();
expect_home();
casper.then(function () {
- casper.test.info('Narrowing by clicking subject');
+ casper.test.info("Narrowing by clicking subject");
casper.click('*[title="Narrow to stream \\"Verona\\", topic \\"frontend test\\""]');
});
expect_stream_subject();
-casper.then(check_narrow_title('frontend test - Zulip Dev - Zulip'));
+casper.then(check_narrow_title("frontend test - Zulip Dev - Zulip"));
casper.then(function () {
// Un-narrow by clicking "Zulip"
- casper.test.info('Un-narrowing');
- casper.click('.brand');
+ casper.test.info("Un-narrowing");
+ casper.click(".brand");
});
expect_home();
casper.then(function () {
- casper.test.info('Narrowing by clicking personal');
+ casper.test.info("Narrowing by clicking personal");
casper.click('*[title="Narrow to your private messages with Cordelia Lear, King Hamlet"]');
});
expect_huddle();
-casper.then(check_narrow_title('Cordelia Lear, King Hamlet - Zulip Dev - Zulip'));
+casper.then(check_narrow_title("Cordelia Lear, King Hamlet - Zulip Dev - Zulip"));
casper.then(function () {
// Un-narrow by clicking "Zulip"
- casper.test.info('Un-narrowing');
- casper.click('.brand');
+ casper.test.info("Un-narrowing");
+ casper.click(".brand");
});
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]', '');
+search_silent_user("sender:[email protected]", "");
-search_non_existing_user('sender:[email protected]', '');
+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]", "", expect_non_existing_user, "Invalid user");
-search_and_check('pm-with:[email protected],[email protected]', '', expect_non_existing_users,
- 'Invalid users');
+search_and_check("pm-with:[email protected],[email protected]", "", expect_non_existing_users,
+ "Invalid users");
// Narrow by clicking the left sidebar.
casper.then(function () {
- casper.test.info('Narrowing with left sidebar');
- casper.click(get_stream_li("Verona") + ' a');
+ casper.test.info("Narrowing with left sidebar");
+ casper.click(get_stream_li("Verona") + " a");
});
expect_stream();
-casper.then(check_narrow_title('Verona - Zulip Dev - Zulip'));
+casper.then(check_narrow_title("Verona - Zulip Dev - Zulip"));
-casper.thenClick('.top_left_all_messages a');
+casper.thenClick(".top_left_all_messages a");
expect_home();
-casper.then(check_narrow_title('home - Zulip Dev - Zulip'));
+casper.then(check_narrow_title("home - Zulip Dev - Zulip"));
-casper.thenClick('.top_left_private_messages a');
+casper.thenClick(".top_left_private_messages a");
expect_all_pm();
-casper.then(check_narrow_title('Private messages - Zulip Dev - Zulip'));
+casper.then(check_narrow_title("Private messages - Zulip Dev - Zulip"));
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.click('#streams_header .sidebar-title');
+ casper.test.info("Search streams using left sidebar");
+ 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.waitWhileSelector("#streams_list .input-append.notdisplayed", function () {
casper.test.assertExists(get_stream_li("Denmark"),
- 'Original stream list contains Denmark');
+ "Original stream list contains Denmark");
casper.test.assertExists(get_stream_li("Scotland"),
- 'Original stream list contains Scotland');
+ "Original stream list contains Scotland");
casper.test.assertExists(get_stream_li("Verona"),
- 'Original stream list contains 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()
+ $(".stream-list-filter").expectOne()
.focus()
- .trigger($.Event('click'));
+ .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.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");
});
// Use arrow keys to navigate through suggestions
casper.then(function () {
function arrow(key) {
- casper.sendKeys('.stream-list-filter',
+ casper.sendKeys(".stream-list-filter",
casper.page.event.key[key],
{keepFocus: true});
}
- arrow('Down'); // Denmark -> Scotland
- arrow('Up'); // Scotland -> Denmark
- arrow('Up'); // Denmark -> Denmark
- arrow('Down'); // Denmark -> Scotland
+ arrow("Down"); // Denmark -> Scotland
+ arrow("Up"); // Scotland -> Denmark
+ arrow("Up"); // Denmark -> Denmark
+ arrow("Down"); // Denmark -> Scotland
});
casper.then(function () {
- casper.waitForSelector(get_stream_li("Scotland") + '.highlighted_stream', function () {
- casper.test.info('Suggestion highlighting - after arrow key navigation');
+ casper.waitForSelector(get_stream_li("Scotland") + ".highlighted_stream", function () {
+ casper.test.info("Suggestion highlighting - after arrow key navigation");
casper.test.assertDoesntExist(
- get_stream_li("Denmark") + '.highlighted_stream',
- 'Stream Denmark is not highlighted');
+ get_stream_li("Denmark") + ".highlighted_stream",
+ "Stream Denmark is not highlighted");
casper.test.assertExist(
- get_stream_li("Scotland") + '.highlighted_stream',
- 'Stream Scotland is highlighted');
+ get_stream_li("Scotland") + ".highlighted_stream",
+ "Stream Scotland is highlighted");
casper.test.assertDoesntExist(
- get_stream_li("Verona") + '.highlighted_stream',
- 'Stream Verona is not highlighted');
+ get_stream_li("Verona") + ".highlighted_stream",
+ "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'))
- .trigger($.Event('click'));
+ .val("sCoT")
+ .trigger($.Event("input"))
+ .trigger($.Event("click"));
});
});
// There will be no race condition between these two waits because we
// expect them to happen in parallel.
casper.waitWhileVisible(get_stream_li("Denmark"), function () {
- casper.test.info('Search term entered');
+ casper.test.info("Search term entered");
casper.test.assertDoesntExist(get_stream_li("Denmark"),
- 'Filtered stream list does not contain 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');
+ "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');
+ "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()
+ $(".stream-list-filter").expectOne()
.focus()
- .val('')
- .trigger($.Event('input'));
+ .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');
+ "Restored stream list contains Denmark");
});
casper.waitUntilVisible(get_stream_li("Scotland"), function () {
casper.test.assertExists(get_stream_li("Denmark"),
- 'Restored stream list contains Scotland');
+ "Restored stream list contains Scotland");
});
casper.waitUntilVisible(get_stream_li("Verona"), function () {
casper.test.assertExists(get_stream_li("Denmark"),
- 'Restored stream list contains Verona');
+ "Restored stream list contains Verona");
});
});
-casper.thenClick('#streams_header .sidebar-title');
+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.waitForSelector(".input-append.notdisplayed", function () {
+ 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()
+ $(".stream-list-filter").expectOne()
.focus()
- .val('ver')
- .trigger($.Event('input'));
+ .val("ver")
+ .trigger($.Event("input"));
});
});
casper.waitWhileVisible(get_stream_li("Denmark"), function () {
// Clicking the narrowed list should clear the search
- casper.click(get_stream_li("Verona") + ' a');
+ 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();
@@ -477,14 +477,14 @@ un_narrow();
function assert_in_list(name) {
casper.test.assertExists(
'#user_presences li [data-name="' + name + '"]',
- 'User ' + name + ' is IN buddy list'
+ "User " + name + " is IN buddy list"
);
}
function assert_selected(name) {
casper.test.assertExists(
'#user_presences li.highlighted_user [data-name="' + name + '"]',
- 'User ' + name + ' is SELECTED IN buddy list'
+ "User " + name + " is SELECTED IN buddy list"
);
}
@@ -492,42 +492,42 @@ function assert_not_selected(name) {
assert_in_list(name);
casper.test.assertDoesntExist(
'#user_presences li.highlighted_user [data-name="' + name + '"]',
- 'User ' + name + ' is NOT SELECTED buddy list'
+ "User " + name + " is NOT SELECTED buddy list"
);
}
// User search at the right sidebar
casper.then(function () {
- casper.test.info('Search users using right sidebar');
- assert_in_list('Iago');
- assert_in_list('Cordelia Lear');
- assert_in_list('King Hamlet');
- assert_in_list('aaron');
+ casper.test.info("Search users using right sidebar");
+ assert_in_list("Iago");
+ assert_in_list("Cordelia Lear");
+ assert_in_list("King Hamlet");
+ assert_in_list("aaron");
});
// Enter the search box and test selected suggestion navigation
// Click on search icon
casper.then(function () {
casper.evaluate(function () {
- $('#user_filter_icon').expectOne()
+ $("#user_filter_icon").expectOne()
.focus()
- .trigger($.Event('click'));
+ .trigger($.Event("click"));
});
});
-casper.waitForSelector('#user_presences .highlighted_user', function () {
- casper.test.info('Suggestion highlighting - initial situation');
- assert_selected('Iago');
- assert_not_selected('Cordelia Lear');
- assert_not_selected('King Hamlet');
- assert_not_selected('aaron');
+casper.waitForSelector("#user_presences .highlighted_user", function () {
+ casper.test.info("Suggestion highlighting - initial situation");
+ assert_selected("Iago");
+ assert_not_selected("Cordelia Lear");
+ assert_not_selected("King Hamlet");
+ assert_not_selected("aaron");
});
// Use arrow keys to navigate through suggestions
casper.then(function () {
function arrow(key) {
- casper.sendKeys('.user-list-filter',
+ casper.sendKeys(".user-list-filter",
casper.page.event.key[key],
{keepFocus: true});
}
@@ -537,21 +537,21 @@ casper.then(function () {
// Cordelia
// Desdemona
// Hamlet
- arrow('Down');
- arrow('Down');
- arrow('Up');
- arrow('Up');
- arrow('Up'); // does nothing
- arrow('Down');
- arrow('Down');
- arrow('Down');
+ arrow("Down");
+ arrow("Down");
+ arrow("Up");
+ arrow("Up");
+ arrow("Up"); // does nothing
+ arrow("Down");
+ arrow("Down");
+ 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.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 84471f3639b..691e5bad045 100644
--- a/frontend_tests/casper_tests/04-compose.js
+++ b/frontend_tests/casper_tests/04-compose.js
@@ -1,4 +1,4 @@
-var common = require('../casper_lib/common.js');
+var common = require("../casper_lib/common.js");
common.start_and_log_in();
@@ -10,14 +10,14 @@ casper.then(function () {
casper.then(function () {
msgs_qty = this.evaluate(function () {
- return $('#zhome .message_row').length;
+ return $("#zhome .message_row").length;
});
});
// Send a message to try replying to
common.then_send_many([
- { stream: 'Verona',
- subject: 'Reply test',
+ { stream: "Verona",
+ subject: "Reply test",
content: "We reply to this message",
},
{ recipient: "[email protected]",
@@ -28,65 +28,65 @@ common.then_send_many([
casper.then(function () {
casper.waitFor(function check_length() {
return casper.evaluate(function (expected_length) {
- return $('#zhome .message_row').length === expected_length;
+ return $("#zhome .message_row").length === expected_length;
}, msgs_qty + 2);
});
});
casper.then(function () {
// TODO: Test opening the compose box from the left side buttons
- casper.click('body');
- casper.page.sendEvent('keypress', "c");
+ casper.click("body");
+ casper.page.sendEvent("keypress", "c");
});
function check_compose_is_cleared() {
common.check_form(
- '#send_message_form',
+ "#send_message_form",
{
- stream_message_recipient_stream: '',
- stream_message_recipient_topic: '',
+ stream_message_recipient_stream: "",
+ stream_message_recipient_topic: "",
},
"Stream empty on new compose"
);
}
casper.then(function () {
- casper.waitUntilVisible('#compose', function () {
- casper.test.assertVisible('#stream-message', 'Stream input box visible');
+ casper.waitUntilVisible("#compose", function () {
+ casper.test.assertVisible("#stream-message", "Stream input box visible");
check_compose_is_cleared();
- casper.click('body');
- casper.page.sendEvent('keypress', "x");
+ casper.click("body");
+ casper.page.sendEvent("keypress", "x");
});
});
casper.then(function () {
- casper.waitUntilVisible('#private_message_recipient', function () {
+ casper.waitUntilVisible("#private_message_recipient", function () {
common.pm_recipient.expect("");
- casper.click('body');
- casper.page.sendEvent('keypress', 'c');
+ casper.click("body");
+ casper.page.sendEvent("keypress", "c");
});
});
casper.then(function () {
- casper.waitUntilVisible('#stream-message', function () {
+ casper.waitUntilVisible("#stream-message", function () {
check_compose_is_cleared();
// Check that when you reply to a message it pre-populates the stream and subject fields
- casper.click('body');
+ casper.click("body");
});
});
casper.then(function () {
- casper.waitWhileVisible('#stream-message', function () {
+ casper.waitWhileVisible("#stream-message", function () {
casper.clickLabel("We reply to this message");
});
});
casper.then(function () {
- casper.waitUntilVisible('#stream-message', function () {
+ casper.waitUntilVisible("#stream-message", function () {
common.check_form(
- '#send_message_form',
+ "#send_message_form",
{
stream_message_recipient_stream: "Verona",
stream_message_recipient_topic: "Reply test",
@@ -94,25 +94,25 @@ casper.then(function () {
"Stream populated after reply by click"
);
// Or recipient field
- casper.click('body');
+ casper.click("body");
casper.clickLabel("And reply to this message");
});
});
casper.then(function () {
- casper.waitUntilVisible('#private_message_recipient', function () {
+ casper.waitUntilVisible("#private_message_recipient", function () {
common.pm_recipient.expect("[email protected]");
common.keypress(27); //escape
- casper.page.sendEvent('keypress', 'k');
- casper.page.sendEvent('keypress', 'r');
+ casper.page.sendEvent("keypress", "k");
+ casper.page.sendEvent("keypress", "r");
});
});
casper.then(function () {
- casper.waitUntilVisible('#stream-message', function () {
+ casper.waitUntilVisible("#stream-message", function () {
common.check_form(
- '#send_message_form',
+ "#send_message_form",
{
stream_message_recipient_stream: "Verona",
stream_message_recipient_topic: "Reply test",
@@ -121,21 +121,21 @@ casper.then(function () {
);
// Test "closing" the compose box
- casper.click('body');
+ casper.click("body");
});
});
casper.then(function () {
- casper.waitWhileVisible('#stream-message', function () {
- casper.test.assertNotVisible('#stream-message', 'Close stream compose box');
- casper.page.sendEvent('keypress', "x");
- casper.click('body');
+ casper.waitWhileVisible("#stream-message", function () {
+ casper.test.assertNotVisible("#stream-message", "Close stream compose box");
+ casper.page.sendEvent("keypress", "x");
+ casper.click("body");
});
});
casper.then(function () {
- casper.waitWhileVisible('#private-message', function () {
- casper.test.assertNotVisible('#private-message', 'Close PM compose box');
+ casper.waitWhileVisible("#private-message", function () {
+ casper.test.assertNotVisible("#private-message", "Close PM compose box");
});
});
@@ -145,32 +145,32 @@ casper.then(function () {
});
casper.then(function () {
- var cordelia_user_id = common.get_user_id('[email protected]');
+ 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';
casper.waitUntilVisible(pm_li, function () {
- casper.page.sendEvent('keypress', 'c');
+ casper.page.sendEvent("keypress", "c");
});
});
casper.then(function () {
- casper.waitUntilVisible('#compose', function () {
+ casper.waitUntilVisible("#compose", function () {
casper.test.assertEval(function () {
- return document.activeElement === $('.compose_table #stream_message_recipient_stream')[0];
- }, 'Stream box focused after narrowing to PMs with a user and pressing `c`');
+ return document.activeElement === $(".compose_table #stream_message_recipient_stream")[0];
+ }, "Stream box focused after narrowing to PMs with a user and pressing `c`");
});
});
// Make sure multiple PM recipients display properly.
-var recipients = ['[email protected]', '[email protected]'];
+var recipients = ["[email protected]", "[email protected]"];
casper.then(function () {
common.keypress(27); // escape to dismiss compose box
});
-casper.waitWhileVisible('.message_comp');
-common.then_send_message('private', {
- recipient: recipients.join(','),
+casper.waitWhileVisible(".message_comp");
+common.then_send_message("private", {
+ recipient: recipients.join(","),
outside_view: true,
- content: 'A huddle to check spaces',
+ content: "A huddle to check spaces",
});
@@ -180,39 +180,39 @@ casper.then(function () {
casper.then(function () {
common.un_narrow();
});
-casper.waitUntilVisible('#zhome', function () {
- casper.clickLabel('A huddle to check spaces');
+casper.waitUntilVisible("#zhome", function () {
+ casper.clickLabel("A huddle to check spaces");
});
casper.then(function () {
- casper.waitUntilVisible('#compose', function () {
- common.pm_recipient.expect(recipients.join(','));
+ casper.waitUntilVisible("#compose", function () {
+ common.pm_recipient.expect(recipients.join(","));
});
});
casper.then(function () {
- casper.waitUntilVisible('#markdown_preview', function () {
- casper.test.assertNotVisible('#undo_markdown_preview', 'Write button is hidden');
+ casper.waitUntilVisible("#markdown_preview", function () {
+ casper.test.assertNotVisible("#undo_markdown_preview", "Write button is hidden");
casper.click("#markdown_preview");
});
});
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.assertVisible("#undo_markdown_preview", "Write button is visible");
+ casper.test.assertEquals(casper.getHTML("#preview_content"), "Nothing to preview", "Nothing to preview");
casper.click("#undo_markdown_preview");
});
});
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.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.fill('form[action^="/json/messages"]', {
- content: '**Markdown Preview** >> Test for markdown preview',
+ content: "**Markdown Preview** >> Test for markdown preview",
}, false);
casper.click("#markdown_preview");
@@ -221,7 +221,7 @@ 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 194f5a5136e..361479dd0e0 100644
--- a/frontend_tests/casper_tests/05-subscriptions.js
+++ b/frontend_tests/casper_tests/05-subscriptions.js
@@ -1,4 +1,4 @@
-var common = require('../casper_lib/common.js');
+var common = require("../casper_lib/common.js");
function stream_checkbox(stream_name) {
const stream_id = common.get_stream_id(stream_name);
@@ -6,7 +6,7 @@ function stream_checkbox(stream_name) {
}
function stream_span(stream_name) {
- return stream_checkbox(stream_name) + ' input ~ span';
+ return stream_checkbox(stream_name) + " input ~ span";
}
function user_checkbox(email) {
@@ -15,13 +15,13 @@ function user_checkbox(email) {
}
function user_span(email) {
- return user_checkbox(email) + ' input ~ span';
+ return user_checkbox(email) + " input ~ span";
}
function is_checked(email) {
var sel = user_checkbox(email);
return casper.evaluate(function (sel) {
- return $(sel).find('input')[0].checked;
+ return $(sel).find("input")[0].checked;
}, {
sel: sel,
});
@@ -30,9 +30,9 @@ function is_checked(email) {
common.start_and_log_in();
casper.then(function () {
- var menu_selector = '#settings-dropdown';
+ var menu_selector = "#settings-dropdown";
- casper.test.info('Streams page');
+ casper.test.info("Streams page");
casper.waitUntilVisible(menu_selector, function () {
casper.click(menu_selector);
@@ -40,156 +40,156 @@ casper.then(function () {
casper.click('a[href^="#streams"]');
casper.test.assertUrlMatch(
/^http:\/\/[^/]+\/#streams/,
- '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');
+ "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.waitUntilVisible('.sub_unsub_button.checked', function () {
- casper.test.assertExists('.sub_unsub_button.checked', 'Initial subscriptions loaded');
- casper.click('#add_new_subscription .create_stream_button');
+casper.waitUntilVisible(".sub_unsub_button.checked", function () {
+ casper.test.assertExists(".sub_unsub_button.checked", "Initial subscriptions loaded");
+ casper.click("#add_new_subscription .create_stream_button");
});
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 () {
- casper.click('#copy-from-stream-expand-collapse');
+ casper.click("#copy-from-stream-expand-collapse");
});
casper.waitUntilVisible("#stream-checkboxes", function () {
- casper.test.assertExists(stream_checkbox('Scotland'), 'Original stream list contains Scotland');
- casper.test.assertExists(stream_checkbox('Rome'), 'Original stream list contains Rome');
+ casper.test.assertExists(stream_checkbox("Scotland"), "Original stream list contains Scotland");
+ casper.test.assertExists(stream_checkbox("Rome"), "Original stream list contains Rome");
});
casper.waitUntilVisible("form#stream_creation_form", function () {
casper.test.info("Filtering with keyword 'ot'");
- casper.fill('form#stream_creation_form', {user_list_filter: 'ot'});
+ casper.fill("form#stream_creation_form", {user_list_filter: "ot"});
});
casper.waitUntilVisible("#user-checkboxes", function () {
- casper.test.assertEquals(casper.visible(user_checkbox('[email protected]')),
+ casper.test.assertEquals(casper.visible(user_checkbox("[email protected]")),
false,
"Cordelia is not visible");
- casper.test.assertEquals(casper.visible(user_checkbox('[email protected]')),
+ 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')),
+ casper.test.assertEquals(casper.visible(stream_checkbox("Scotland")),
true,
"Scotland is visible");
- casper.test.assertEquals(casper.visible(stream_checkbox('Rome')),
+ 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.click(".subs_set_all_users");
casper.wait(100, function () {
casper.test.assert(
- !is_checked('[email protected]'),
+ !is_checked("[email protected]"),
"Cordelia is unchecked");
casper.test.assert(
- is_checked('[email protected]'),
+ 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.click(".subs_unset_all_users");
casper.wait(100, function () {
casper.test.assert(
- !is_checked('[email protected]'),
+ !is_checked("[email protected]"),
"Othello is unchecked");
});
});
casper.then(function () {
casper.test.info("Clearing user filter search box");
- casper.fill('form#stream_creation_form', {user_list_filter: ''});
+ casper.fill("form#stream_creation_form", {user_list_filter: ""});
});
casper.then(function () {
- casper.test.assertEquals(casper.visible(user_checkbox('[email protected]')),
+ casper.test.assertEquals(casper.visible(user_checkbox("[email protected]")),
true,
"Cordelia is visible again");
- casper.test.assertEquals(casper.visible(user_checkbox('[email protected]')),
+ casper.test.assertEquals(casper.visible(user_checkbox("[email protected]")),
true,
"Othello is visible again");
- casper.test.assertEquals(casper.visible(stream_checkbox('Scotland')),
+ casper.test.assertEquals(casper.visible(stream_checkbox("Scotland")),
true,
"Scotland is visible again");
- casper.test.assertEquals(casper.visible(stream_checkbox('Rome')),
+ 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.click(stream_span('Scotland'));
- casper.click(user_span('[email protected]'));
- casper.click(user_span('[email protected]'));
- casper.click('form#stream_creation_form button.button.sea-green');
+ 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.click(stream_span("Scotland"));
+ casper.click(user_span("[email protected]"));
+ casper.click(user_span("[email protected]"));
+ casper.click("form#stream_creation_form button.button.sea-green");
});
});
casper.then(function () {
casper.waitFor(function () {
return casper.evaluate(function () {
- return $('.stream-name').is(':contains("Waseemio")');
+ return $(".stream-name").is(':contains("Waseemio")');
});
});
});
casper.then(function () {
casper.test.info("User should be subscribed to stream Waseemio");
- casper.test.assertSelectorHasText('.stream-name', 'Waseemio');
- casper.test.assertSelectorHasText('.description', 'Oimeesaw');
+ casper.test.assertSelectorHasText(".stream-name", "Waseemio");
+ casper.test.assertSelectorHasText(".description", "Oimeesaw");
// Based on the selected checkboxes while creating stream,
// 4 users from Scotland are added.
// 1 user, Cordelia, is added. Othello (subscribed to Scotland) is removed.
// FIXME: This assertion may pick up the count from a random other stream.
- casper.test.assertSelectorHasText('.subscriber-count-text', '4');
- casper.fill('form#stream_creation_form', {stream_name: ' '});
- casper.click('form#stream_creation_form button.button.sea-green');
+ casper.test.assertSelectorHasText(".subscriber-count-text", "4");
+ casper.fill("form#stream_creation_form", {stream_name: " "});
+ casper.click("form#stream_creation_form button.button.sea-green");
});
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.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');
+ 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.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');
+ 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.then(function () {
casper.evaluate(function () {
$('#stream_filter input[type="text"]')
.expectOne()
- .val('waseem')
- .trigger($.Event('input'));
+ .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.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");
});
common.then_log_out();
diff --git a/frontend_tests/casper_tests/06-settings.js b/frontend_tests/casper_tests/06-settings.js
index e217a647b8b..b9e71bd49d0 100644
--- a/frontend_tests/casper_tests/06-settings.js
+++ b/frontend_tests/casper_tests/06-settings.js
@@ -1,7 +1,7 @@
-var common = require('../casper_lib/common.js');
-var test_credentials = require('../../var/casper/test_credentials.js').test_credentials;
-var OUTGOING_WEBHOOK_BOT_TYPE = '3';
-var GENERIC_BOT_TYPE = '1';
+var common = require("../casper_lib/common.js");
+var test_credentials = require("../../var/casper/test_credentials.js").test_credentials;
+var OUTGOING_WEBHOOK_BOT_TYPE = "3";
+var GENERIC_BOT_TYPE = "1";
common.start_and_log_in();
@@ -13,7 +13,7 @@ var regex_outgoing_webhook_zuliprc = /^data:application\/octet-stream;charset=ut
var regex_botserverrc = /^data:application\/octet-stream;charset=utf-8,\[\]\nemail=.+\nkey=.+\nsite=.+\ntoken=.+\n$/;
casper.then(function () {
- var menu_selector = '#settings-dropdown';
+ var menu_selector = "#settings-dropdown";
casper.waitUntilVisible(menu_selector, function () {
casper.click(menu_selector);
});
@@ -21,20 +21,20 @@ casper.then(function () {
casper.then(function () {
casper.waitUntilVisible('a[href^="#settings"]', function () {
- casper.test.info('Settings page');
+ casper.test.info("Settings page");
casper.click('a[href^="#settings"]');
});
});
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.assertVisible('.account-settings-form', 'Settings page is active');
+ 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");
// casper.click(".change_password_button");
- casper.click('#api_key_button');
+ casper.click("#api_key_button");
});
});
@@ -67,15 +67,15 @@ casper.then(function () {
*/
casper.then(function () {
- casper.waitUntilVisible('#get_api_key_button', function () {
- casper.fill('#api_key_form', {password: test_credentials.default_user.password});
- casper.click('#get_api_key_button');
+ casper.waitUntilVisible("#get_api_key_button", function () {
+ casper.fill("#api_key_form", {password: test_credentials.default_user.password});
+ casper.click("#get_api_key_button");
});
});
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.waitUntilVisible("#show_api_key", function () {
+ 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
@@ -90,23 +90,23 @@ casper.then(function () {
});
casper.then(function () {
- casper.waitUntilVisible('#show_api_key', function () {
- casper.test.assertExists('#download_zuliprc', '~/.zuliprc button exists');
- casper.click('#download_zuliprc');
+ casper.waitUntilVisible("#show_api_key", function () {
+ casper.test.assertExists("#download_zuliprc", "~/.zuliprc button exists");
+ casper.click("#download_zuliprc");
});
});
casper.then(function () {
casper.waitUntilVisible('#download_zuliprc[href^="data:application"]', function () {
casper.test.assertMatch(
- decodeURIComponent(casper.getElementsAttribute('#download_zuliprc', 'href')),
+ decodeURIComponent(casper.getElementsAttribute("#download_zuliprc", "href")),
regex_zuliprc,
- 'Looks like a zuliprc file');
+ "Looks like a zuliprc file");
});
});
casper.then(function () {
- casper.click('#api_key_modal .close');
+ casper.click("#api_key_modal .close");
// casper.waitUntilVisible('#account-settings-status', function () {
casper.click('[data-section="your-bots"]');
@@ -114,20 +114,20 @@ casper.then(function () {
});
casper.then(function create_bot() {
- casper.test.info('Filling out the create bot form for an outgoing webhook bot');
+ casper.test.info("Filling out the create bot form for an outgoing webhook bot");
- casper.fill('#create_bot_form', {
- bot_name: 'Bot 1',
- bot_short_name: '1',
+ casper.fill("#create_bot_form", {
+ bot_name: "Bot 1",
+ bot_short_name: "1",
bot_type: OUTGOING_WEBHOOK_BOT_TYPE,
- payload_url: 'http://hostname.example.com/bots/followup',
+ payload_url: "http://hostname.example.com/bots/followup",
});
- casper.test.info('Submitting the create bot form');
- casper.click('#create_bot_button');
+ casper.test.info("Submitting the create bot form");
+ casper.click("#create_bot_button");
});
-var bot_email = '[email protected]';
+var bot_email = "[email protected]";
var button_sel = '.download_bot_zuliprc[data-email="' + bot_email + '"]';
casper.then(function () {
@@ -139,26 +139,26 @@ casper.then(function () {
casper.then(function () {
casper.waitUntilVisible(button_sel + '[href^="data:application"]', function () {
casper.test.assertMatch(
- decodeURIComponent(casper.getElementsAttribute(button_sel, 'href')),
+ 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");
});
});
casper.then(function create_bot() {
- casper.test.info('Filling out the create bot form for a normal bot');
+ casper.test.info("Filling out the create bot form for a normal bot");
- casper.fill('#create_bot_form', {
- bot_name: 'Bot 2',
- bot_short_name: '2',
+ casper.fill("#create_bot_form", {
+ bot_name: "Bot 2",
+ bot_short_name: "2",
bot_type: GENERIC_BOT_TYPE,
});
- casper.test.info('Submitting the create bot form');
- casper.click('#create_bot_button');
+ casper.test.info("Submitting the create bot form");
+ casper.click("#create_bot_button");
});
-var second_bot_email = '[email protected]';
+var second_bot_email = "[email protected]";
var second_button_sel = '.download_bot_zuliprc[data-email="' + second_bot_email + '"]';
casper.then(function () {
@@ -170,28 +170,28 @@ casper.then(function () {
casper.then(function () {
casper.waitUntilVisible(second_button_sel + '[href^="data:application"]', function () {
casper.test.assertMatch(
- decodeURIComponent(casper.getElementsAttribute(second_button_sel, 'href')),
+ decodeURIComponent(casper.getElementsAttribute(second_button_sel, "href")),
regex_zuliprc,
- 'Looks like a bot ~/.zuliprc file');
+ "Looks like a bot ~/.zuliprc file");
});
});
casper.then(function () {
- casper.waitUntilVisible('#download_botserverrc', function () {
+ casper.waitUntilVisible("#download_botserverrc", function () {
casper.click("#download_botserverrc");
casper.waitUntilVisible('#download_botserverrc[href^="data:application"]', function () {
casper.test.assertMatch(
- decodeURIComponent(casper.getElementsAttribute('#download_botserverrc', 'href')),
+ 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.test.info("Opening edit bot form");
casper.click('.open_edit_bot_form[data-email="' + bot_email + '"]');
});
});
@@ -199,7 +199,7 @@ casper.then(function () {
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.info("Testing edit bot form values");
// casper.test.assertEqual(
// common.get_form_field_value(form_sel + ' [name=bot_name]'),
@@ -211,95 +211,95 @@ casper.then(function () {
// 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');
+ common.get_form_field_value(form_sel + " [name=bot_name]"),
+ "Bot 1");
});
});
casper.then(function () {
casper.click('[data-section="alert-words"]');
- casper.waitUntilVisible('#create_alert_word_form', function () {
- casper.test.info('Attempting to submit an empty alert word');
- 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.info('Closing the error message');
- casper.click('.close-alert-word-status');
- casper.test.info('Checking the error is hidden');
- casper.test.assertNotVisible('#alert_word_status');
+ casper.waitUntilVisible("#create_alert_word_form", function () {
+ casper.test.info("Attempting to submit an empty alert word");
+ 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.info("Closing the error message");
+ casper.click(".close-alert-word-status");
+ casper.test.info("Checking the error is hidden");
+ casper.test.assertNotVisible("#alert_word_status");
});
});
});
casper.then(function () {
- casper.test.info('Filling out the alert word input');
- casper.sendKeys('#create_alert_word_name', 'some phrase');
- 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.info('Closing the status message');
- casper.click('.close-alert-word-status');
- casper.test.info('Checking the status message is hidden');
- casper.test.assertNotVisible('#alert_word_status');
+ casper.test.info("Filling out the alert word input");
+ casper.sendKeys("#create_alert_word_name", "some phrase");
+ 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.info("Closing the status message");
+ casper.click(".close-alert-word-status");
+ casper.test.info("Checking the status message is hidden");
+ casper.test.assertNotVisible("#alert_word_status");
});
});
casper.then(function () {
- casper.test.info('Checking that an element was created');
+ casper.test.info("Checking that an element was created");
casper.waitUntilVisible(".alert-word-item[data-word='some phrase']", function () {
- casper.test.assertExists('div.alert-word-information-box');
- casper.test.assertSelectorHasText('span.value', 'some phrase');
+ casper.test.assertExists("div.alert-word-information-box");
+ casper.test.assertSelectorHasText("span.value", "some phrase");
});
});
casper.then(function () {
- casper.test.info('Trying to create a duplicate alert word');
- casper.sendKeys('#create_alert_word_name', 'some phrase');
- casper.click('#create_alert_word_button');
- casper.test.info('Checking that an error message is displayed');
- casper.waitUntilVisible('#alert_word_status', function () {
- casper.test.assertSelectorHasText('.alert_word_status_text', 'Alert word already exists!');
- casper.test.info('Closing the status message');
- casper.click('.close-alert-word-status');
- casper.test.info('Checking the status message is hidden');
- casper.test.assertNotVisible('#alert_word_status');
+ casper.test.info("Trying to create a duplicate alert word");
+ casper.sendKeys("#create_alert_word_name", "some phrase");
+ casper.click("#create_alert_word_button");
+ casper.test.info("Checking that an error message is displayed");
+ casper.waitUntilVisible("#alert_word_status", function () {
+ casper.test.assertSelectorHasText(".alert_word_status_text", "Alert word already exists!");
+ casper.test.info("Closing the status message");
+ casper.click(".close-alert-word-status");
+ casper.test.info("Checking the status message is hidden");
+ casper.test.assertNotVisible("#alert_word_status");
});
});
casper.then(function () {
- casper.test.info('Deleting alert word');
- 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.info('Closing the status message');
- casper.click('.close-alert-word-status');
- casper.test.info('Checking the status message is hidden');
- casper.test.assertNotVisible('#alert_word_status');
+ casper.test.info("Deleting alert word");
+ 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.info("Closing the status message");
+ casper.click(".close-alert-word-status");
+ casper.test.info("Checking the status message is hidden");
+ casper.test.assertNotVisible("#alert_word_status");
});
- casper.test.info('Checking that the element was deleted');
+ casper.test.info("Checking that the element was deleted");
casper.waitWhileVisible(".alert-word-item[data-word='some phrase']", function () {
- casper.test.assertDoesntExist('div.alert-word-information-box');
- casper.test.info('Element deleted successfully');
+ casper.test.assertDoesntExist("div.alert-word-information-box");
+ casper.test.info("Element deleted successfully");
});
});
casper.then(function change_default_language() {
- casper.test.info('Changing the default language');
+ casper.test.info("Changing the default language");
casper.click('[data-section="display-settings"]');
- casper.waitUntilVisible('#default_language');
+ casper.waitUntilVisible("#default_language");
});
-casper.thenClick('#default_language');
+casper.thenClick("#default_language");
-casper.waitUntilVisible('#default_language_modal');
+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.waitUntilVisible("#language-settings-status a", function () {
+ casper.test.assertSelectorHasText("#language-settings-status", "Saved. Please reload for the change to take effect.");
casper.test.info("Reloading the page.");
casper.reload();
});
@@ -308,13 +308,13 @@ casper.then(function () {
casper.waitUntilVisible("#default_language", function () {
casper.test.info("Checking if we are on Chinese page.");
casper.test.assertEvalEquals(function () {
- return $('#default_language_name').text().trim();
- }, '简体中文');
+ return $("#default_language_name").text().trim();
+ }, "简体中文");
casper.test.info("Opening German page through i18n url.");
});
});
-var settings_url = 'http://zulip.zulipdev.com:9981/de/#settings';
+var settings_url = "http://zulip.zulipdev.com:9981/de/#settings";
casper.thenOpen(settings_url);
@@ -322,27 +322,27 @@ casper.waitUntilVisible("#settings-change-box", function check_url_preference()
casper.test.info("Checking the i18n url language precedence.");
casper.test.assertEvalEquals(function () {
return document.documentElement.lang;
- }, 'de');
+ }, "de");
casper.test.info("English is now the default language");
casper.click('[data-section="display-settings"]');
});
-casper.thenClick('#default_language');
+casper.thenClick("#default_language");
-casper.waitUntilVisible('#default_language_modal');
+casper.waitUntilVisible("#default_language_modal");
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.waitUntilVisible("#language-settings-status a", function () {
+ casper.test.assertSelectorHasText("#language-settings-status", "Gespeichert. Bitte lade die Seite neu um die Änderungen zu aktivieren.");
});
casper.then(function () {
casper.waitUntilVisible('[data-section="notifications"]', function () {
- casper.test.info('Testing disabled/enabled behavior for Notification sound');
+ casper.test.info("Testing disabled/enabled behavior for Notification sound");
casper.click('[data-section="notifications"]');
});
});
@@ -352,13 +352,13 @@ casper.then(function () {
// will be off by default.
casper.test.assertVisible("#notification_sound:enabled", "Notification sound selector is enabled");
- casper.click('#enable_stream_audible_notifications');
+ casper.click("#enable_stream_audible_notifications");
casper.test.assertVisible("#notification_sound:enabled", "Notification sound selector is enabled");
- casper.click('#enable_sounds');
+ casper.click("#enable_sounds");
casper.test.assertVisible("#notification_sound:enabled", "Notification sound selector is enabled");
- casper.click('#enable_stream_audible_notifications');
+ casper.click("#enable_stream_audible_notifications");
casper.test.assertVisible("#notification_sound:disabled", "Notification sound selector is disabled");
});
diff --git a/frontend_tests/casper_tests/07-stars.js b/frontend_tests/casper_tests/07-stars.js
index a6cf5bba78e..bf33c624a06 100644
--- a/frontend_tests/casper_tests/07-stars.js
+++ b/frontend_tests/casper_tests/07-stars.js
@@ -1,4 +1,4 @@
-var common = require('../casper_lib/common.js');
+var common = require("../casper_lib/common.js");
function star_count() {
return casper.evaluate(function () {
@@ -11,22 +11,22 @@ function toggle_test_star_message() {
var msg = $('.message_content:contains("test star"):visible').last();
if (msg.length !== 1) {
- return 'cannot find test star message';
+ return "cannot find test star message";
}
var star_icon = msg
- .closest('.messagebox')
- .find('.star');
+ .closest(".messagebox")
+ .find(".star");
if (star_icon.length !== 1) {
- return 'cannot find star icon';
+ return "cannot find star icon";
}
star_icon.click();
});
if (error) {
- casper.test.info('\n\nERROR: ' + error);
+ casper.test.info("\n\nERROR: " + error);
}
casper.test.assert(!error);
@@ -38,10 +38,10 @@ casper.then(function () {
casper.test.info("Sending test message");
});
-common.then_send_message('stream', {
- stream: 'Verona',
- subject: 'stars',
- content: 'test star',
+common.then_send_message("stream", {
+ stream: "Verona",
+ subject: "stars",
+ content: "test star",
});
casper.then(function () {
@@ -60,7 +60,7 @@ casper.then(function () {
});
casper.then(function () {
- casper.waitUntilVisible('#zhome .fa-star', function () {
+ casper.waitUntilVisible("#zhome .fa-star", function () {
casper.test.assertEquals(star_count(), 1,
"Got expected single star count.");
@@ -68,9 +68,9 @@ casper.then(function () {
});
});
-casper.waitUntilVisible('#zfilt', function () {
+casper.waitUntilVisible("#zfilt", function () {
// You can narrow to your starred messages.
- common.expected_messages('zfilt', ['Verona > stars'], ['<p>test star</p>']);
+ common.expected_messages("zfilt", ["Verona > stars"], ["<p>test star</p>"]);
common.un_narrow();
});
diff --git a/frontend_tests/casper_tests/08-edit.js b/frontend_tests/casper_tests/08-edit.js
index 87bb7515d92..4f11b07274e 100644
--- a/frontend_tests/casper_tests/08-edit.js
+++ b/frontend_tests/casper_tests/08-edit.js
@@ -1,4 +1,4 @@
-var common = require('../casper_lib/common.js');
+var common = require("../casper_lib/common.js");
casper.options.verbose = true;
casper.options.logLevel = "debug";
@@ -8,9 +8,9 @@ common.start_and_log_in();
function then_edit_last_message() {
casper.then(function () {
casper.evaluate(function () {
- var msg = $('#zhome .message_row').last();
- msg.find('.info').click();
- $('.popover_edit_message').click();
+ var msg = $("#zhome .message_row").last();
+ msg.find(".info").click();
+ $(".popover_edit_message").click();
});
});
casper.then(function () {
@@ -20,20 +20,20 @@ function then_edit_last_message() {
// Send and edit a stream message
-common.then_send_message('stream', {
- stream: 'Verona',
- subject: 'edits',
- content: 'test editing',
+common.then_send_message("stream", {
+ stream: "Verona",
+ subject: "edits",
+ content: "test editing",
});
then_edit_last_message();
casper.then(function () {
casper.evaluate(function () {
- var msg = $('#zhome .message_row').last();
- msg.find('.message_edit_topic').val("edited");
- msg.find('.message_edit_content').val("test edited");
- msg.find('.message_edit_save').click();
+ var msg = $("#zhome .message_row").last();
+ msg.find(".message_edit_topic").val("edited");
+ msg.find(".message_edit_content").val("test edited");
+ msg.find(".message_edit_save").click();
});
});
@@ -41,20 +41,20 @@ casper.waitWhileVisible("textarea.message_edit_content", function () {
casper.test.assertSelectorHasText(".last_message .message_content", "test edited");
});
-common.then_send_message('stream', {
- stream: 'Verona',
- subject: 'edits',
- content: '/me test editing one line with me',
+common.then_send_message("stream", {
+ stream: "Verona",
+ subject: "edits",
+ content: "/me test editing one line with me",
});
then_edit_last_message();
casper.then(function () {
casper.evaluate(function () {
- var msg = $('#zhome .message_row').last();
- msg.find('.message_edit_topic').val("edited");
- msg.find('.message_edit_content').val("/me test edited one line with me");
- msg.find('.message_edit_save').click();
+ var msg = $("#zhome .message_row").last();
+ msg.find(".message_edit_topic").val("edited");
+ msg.find(".message_edit_content").val("/me test edited one line with me");
+ msg.find(".message_edit_save").click();
});
});
@@ -62,7 +62,7 @@ casper.waitWhileVisible("textarea.message_edit_content", function () {
casper.test.assertSelectorHasText(".last_message .sender-status", "test edited one line with me");
});
-common.then_send_message('private', {
+common.then_send_message("private", {
recipient: "[email protected]",
content: "test editing pm",
});
@@ -71,9 +71,9 @@ then_edit_last_message();
casper.then(function () {
casper.evaluate(function () {
- var msg = $('#zhome .message_row').last();
- msg.find('.message_edit_content').val("test edited pm");
- msg.find('.message_edit_save').click();
+ var msg = $("#zhome .message_row").last();
+ msg.find(".message_edit_content").val("test edited pm");
+ msg.find(".message_edit_save").click();
});
});
diff --git a/frontend_tests/casper_tests/09-navigation.js b/frontend_tests/casper_tests/09-navigation.js
index 8117344f173..41b43912706 100644
--- a/frontend_tests/casper_tests/09-navigation.js
+++ b/frontend_tests/casper_tests/09-navigation.js
@@ -1,22 +1,22 @@
-var common = require('../casper_lib/common.js');
+var common = require("../casper_lib/common.js");
// Test basic tab navigation.
common.start_and_log_in();
casper.then(function () {
- casper.test.info('Testing navigation');
+ casper.test.info("Testing navigation");
});
function wait_for_tab(tab) {
- casper.waitForSelector('#' + tab + '.tab-pane.active', function () {
- casper.test.assertExists('#' + tab + '.tab-pane.active', tab + ' page is active');
+ casper.waitForSelector("#" + tab + ".tab-pane.active", function () {
+ casper.test.assertExists("#" + tab + ".tab-pane.active", tab + " page is active");
});
}
function then_navigate_to(click_target, tab) {
casper.then(function () {
- casper.test.info('Visiting #' + click_target);
+ casper.test.info("Visiting #" + click_target);
casper.click("a[href='#" + click_target + "']");
wait_for_tab(tab);
});
@@ -24,15 +24,15 @@ function then_navigate_to(click_target, tab) {
function then_navigate_to_settings() {
casper.then(function () {
- casper.test.info('Navigate to settings');
- var menu_selector = '#settings-dropdown';
+ casper.test.info("Navigate to settings");
+ var menu_selector = "#settings-dropdown";
casper.waitUntilVisible(menu_selector, function () {
casper.click(menu_selector);
casper.waitUntilVisible('a[href^="#settings"]', function () {
casper.click('a[href^="#settings"]');
- casper.waitUntilVisible('#settings_page', function () {
- casper.test.assertExists('#settings_page', "Settings page is active");
- casper.click('#settings_page .exit');
+ casper.waitUntilVisible("#settings_page", function () {
+ casper.test.assertExists("#settings_page", "Settings page is active");
+ casper.click("#settings_page .exit");
});
});
});
@@ -41,15 +41,15 @@ function then_navigate_to_settings() {
function then_navigate_to_subscriptions() {
casper.then(function () {
- casper.test.info('Navigate to subscriptions');
+ casper.test.info("Navigate to subscriptions");
- var menu_selector = '#settings-dropdown';
+ var menu_selector = "#settings-dropdown";
casper.waitUntilVisible(menu_selector, function () {
casper.click(menu_selector);
casper.click('a[href^="#streams"]');
casper.waitUntilVisible("#subscription_overlay", function () {
- casper.test.assertExists('#subscriptions_table', "#subscriptions page is active");
- casper.click('#subscription_overlay .exit');
+ casper.test.assertExists("#subscriptions_table", "#subscriptions page is active");
+ casper.click("#subscription_overlay .exit");
});
});
});
@@ -62,19 +62,19 @@ then_navigate_to_settings();
var verona_narrow;
casper.then(function () {
var verona_id = casper.evaluate(function () {
- return stream_data.get_stream_id('Verona');
+ return stream_data.get_stream_id("Verona");
});
- verona_narrow = 'narrow/stream/' + verona_id + '-Verona';
+ verona_narrow = "narrow/stream/" + verona_id + "-Verona";
casper.test.info(verona_narrow);
- then_navigate_to(verona_narrow, 'home');
- then_navigate_to('home', 'home');
+ then_navigate_to(verona_narrow, "home");
+ then_navigate_to("home", "home");
then_navigate_to_subscriptions();
- then_navigate_to('', 'home');
+ then_navigate_to("", "home");
then_navigate_to_settings();
- then_navigate_to('narrow/is/private', 'home');
+ then_navigate_to("narrow/is/private", "home");
then_navigate_to_subscriptions();
- then_navigate_to(verona_narrow, 'home');
+ then_navigate_to(verona_narrow, "home");
});
var initial_page_load_time;
@@ -111,7 +111,7 @@ casper.then(function () {
});
casper.then(function () {
- casper.waitUntilVisible('#zfilt', function () {
+ casper.waitUntilVisible("#zfilt", function () {
// Verify that we're narrowed to the target stream
casper.test.assertEquals(orig_hash, hash);
casper.test.assertVisible("#zfilt");
diff --git a/frontend_tests/casper_tests/10-admin.js b/frontend_tests/casper_tests/10-admin.js
index f713d6ccdc1..5a073b8537d 100644
--- a/frontend_tests/casper_tests/10-admin.js
+++ b/frontend_tests/casper_tests/10-admin.js
@@ -1,4 +1,4 @@
-var common = require('../casper_lib/common.js');
+var common = require("../casper_lib/common.js");
common.start_and_log_in();
@@ -7,11 +7,11 @@ common.manage_organization();
function submit_notifications_stream_settings() {
casper.then(function () {
casper.waitUntilVisible('#org-submit-notifications[data-status="unsaved"]', function () {
- casper.test.assertSelectorHasText('#org-submit-notifications', 'Save');
+ casper.test.assertSelectorHasText("#org-submit-notifications", "Save");
});
});
casper.then(function () {
- casper.click('#org-submit-notifications');
+ casper.click("#org-submit-notifications");
});
}
@@ -19,8 +19,8 @@ function submit_notifications_stream_settings() {
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.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)");
});
});
@@ -29,9 +29,9 @@ submit_notifications_stream_settings();
casper.then(function () {
casper.waitUntilVisible('#org-submit-notifications[data-status="saved"]', function () {
- casper.test.assertSelectorHasText('#org-submit-notifications', 'Saved');
+ casper.test.assertSelectorHasText("#org-submit-notifications", "Saved");
});
- casper.waitWhileVisible('#org-submit-notifications');
+ casper.waitWhileVisible("#org-submit-notifications");
});
casper.then(function () {
@@ -42,17 +42,17 @@ submit_notifications_stream_settings();
casper.then(function () {
casper.waitUntilVisible('#org-submit-notifications[data-status="saved"]', function () {
- casper.test.assertSelectorHasText('#org-submit-notifications', 'Saved');
+ casper.test.assertSelectorHasText("#org-submit-notifications", "Saved");
});
- casper.waitWhileVisible('#org-submit-notifications');
+ casper.waitWhileVisible("#org-submit-notifications");
});
// Test changing signup notifications stream
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.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");
});
});
@@ -61,9 +61,9 @@ submit_notifications_stream_settings();
casper.then(function () {
casper.waitUntilVisible('#org-submit-notifications[data-status="saved"]', function () {
- casper.test.assertSelectorHasText('#org-submit-notifications', 'Saved');
+ casper.test.assertSelectorHasText("#org-submit-notifications", "Saved");
});
- casper.waitWhileVisible('#org-submit-notifications');
+ casper.waitWhileVisible("#org-submit-notifications");
});
casper.then(function () {
@@ -74,9 +74,9 @@ submit_notifications_stream_settings();
casper.then(function () {
casper.waitUntilVisible('#org-submit-notifications[data-status="saved"]', function () {
- casper.test.assertSelectorHasText('#org-submit-notifications', 'Saved');
+ casper.test.assertSelectorHasText("#org-submit-notifications", "Saved");
});
- casper.waitWhileVisible('#org-submit-notifications');
+ casper.waitWhileVisible("#org-submit-notifications");
});
// Test permissions setting
@@ -85,8 +85,8 @@ casper.then(function () {
});
function submit_permissions_change() {
- casper.test.assertSelectorHasText('#org-submit-other-permissions', "Save");
- casper.click('#org-submit-other-permissions');
+ casper.test.assertSelectorHasText("#org-submit-other-permissions", "Save");
+ casper.click("#org-submit-other-permissions");
}
// Test setting create streams policy to 'admins only'.
@@ -104,9 +104,9 @@ casper.then(function () {
casper.then(function () {
// Test that save worked.
casper.waitUntilVisible('#org-submit-other-permissions[data-status="saved"]', function () {
- casper.test.assertSelectorHasText('#org-submit-other-permissions', 'Saved');
+ casper.test.assertSelectorHasText("#org-submit-other-permissions", "Saved");
});
- casper.waitWhileVisible('#org-submit-notifications');
+ casper.waitWhileVisible("#org-submit-notifications");
});
// Test setting create streams policy to 'members and admins'.
@@ -124,9 +124,9 @@ casper.then(function () {
casper.then(function () {
// Test that save worked.
casper.waitUntilVisible('#org-submit-other-permissions[data-status="saved"]', function () {
- casper.test.assertSelectorHasText('#org-submit-other-permissions', 'Saved');
+ casper.test.assertSelectorHasText("#org-submit-other-permissions", "Saved");
});
- casper.waitWhileVisible('#org-submit-notifications');
+ casper.waitWhileVisible("#org-submit-notifications");
});
// Test setting create streams policy to 'full members'.
@@ -144,9 +144,9 @@ casper.then(function () {
casper.then(function () {
// Test that save worked.
casper.waitUntilVisible('#org-submit-other-permissions[data-status="saved"]', function () {
- casper.test.assertSelectorHasText('#org-submit-other-permissions', 'Saved');
+ casper.test.assertSelectorHasText("#org-submit-other-permissions", "Saved");
});
- casper.waitWhileVisible('#org-submit-notifications');
+ casper.waitWhileVisible("#org-submit-notifications");
});
// Test setting invite to streams policy to 'admins only'.
@@ -164,9 +164,9 @@ casper.then(function () {
casper.then(function () {
// Test that save worked.
casper.waitUntilVisible('#org-submit-other-permissions[data-status="saved"]', function () {
- casper.test.assertSelectorHasText('#org-submit-other-permissions', 'Saved');
+ casper.test.assertSelectorHasText("#org-submit-other-permissions", "Saved");
});
- casper.waitWhileVisible('#org-submit-notifications');
+ casper.waitWhileVisible("#org-submit-notifications");
});
// Test setting invite to streams policy to 'members and admins'.
@@ -184,9 +184,9 @@ casper.then(function () {
casper.then(function () {
// Test that save worked.
casper.waitUntilVisible('#org-submit-other-permissions[data-status="saved"]', function () {
- casper.test.assertSelectorHasText('#org-submit-other-permissions', 'Saved');
+ casper.test.assertSelectorHasText("#org-submit-other-permissions", "Saved");
});
- casper.waitWhileVisible('#org-submit-notifications');
+ casper.waitWhileVisible("#org-submit-notifications");
});
// Test setting invite to streams policy to 'full members'.
@@ -204,9 +204,9 @@ casper.then(function () {
casper.then(function () {
// Test that save worked.
casper.waitUntilVisible('#org-submit-other-permissions[data-status="saved"]', function () {
- casper.test.assertSelectorHasText('#org-submit-other-permissions', 'Saved');
+ casper.test.assertSelectorHasText("#org-submit-other-permissions", "Saved");
});
- casper.waitWhileVisible('#org-submit-notifications');
+ casper.waitWhileVisible("#org-submit-notifications");
});
// Test setting new user threshold to three days.
@@ -223,10 +223,10 @@ casper.then(function () {
casper.then(function () {
// Test that save worked.
casper.waitUntilVisible('#org-submit-other-permissions[data-status="saved"]', function () {
- casper.test.assertSelectorHasText('#org-submit-other-permissions', 'Saved');
- casper.test.assertNotVisible('#id_realm_waiting_period_threshold');
+ casper.test.assertSelectorHasText("#org-submit-other-permissions", "Saved");
+ casper.test.assertNotVisible("#id_realm_waiting_period_threshold");
});
- casper.waitWhileVisible('#org-submit-notifications');
+ casper.waitWhileVisible("#org-submit-notifications");
});
// Test setting new user threshold to N days.
@@ -243,40 +243,40 @@ casper.then(function () {
casper.then(function () {
// Test that save worked.
casper.waitUntilVisible('#org-submit-other-permissions[data-status="saved"]', function () {
- casper.test.assertSelectorHasText('#org-submit-other-permissions', 'Saved');
- casper.test.assertVisible('#id_realm_waiting_period_threshold');
+ casper.test.assertSelectorHasText("#org-submit-other-permissions", "Saved");
+ casper.test.assertVisible("#id_realm_waiting_period_threshold");
});
- casper.waitWhileVisible('#org-submit-notifications');
+ casper.waitWhileVisible("#org-submit-notifications");
});
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',
+ 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.then(function () {
- casper.waitUntilVisible('div#admin-emoji-status', function () {
- casper.test.assertSelectorHasText('div#admin-emoji-status', 'Custom emoji added!');
+ casper.waitUntilVisible("div#admin-emoji-status", function () {
+ casper.test.assertSelectorHasText("div#admin-emoji-status", "Custom emoji added!");
});
});
casper.then(function () {
- casper.waitUntilVisible('tr#emoji_new_mouse_face', function () {
- casper.test.assertSelectorHasText('tr#emoji_new_mouse_face .emoji_name', 'new mouse face');
- casper.test.assertExists('tr#emoji_new_mouse_face img');
- casper.click('tr#emoji_new_mouse_face button.delete');
+ casper.waitUntilVisible("tr#emoji_new_mouse_face", function () {
+ casper.test.assertSelectorHasText("tr#emoji_new_mouse_face .emoji_name", "new mouse face");
+ casper.test.assertExists("tr#emoji_new_mouse_face img");
+ casper.click("tr#emoji_new_mouse_face button.delete");
});
});
casper.then(function () {
- casper.waitWhileVisible('tr#emoji_new_mouse_face', function () {
- casper.test.assertDoesntExist('tr#emoji_new_mouse_face');
+ casper.waitWhileVisible("tr#emoji_new_mouse_face", function () {
+ casper.test.assertDoesntExist("tr#emoji_new_mouse_face");
});
});
@@ -284,10 +284,10 @@ var stream_name = "Scotland";
function get_suggestions(str) {
casper.then(function () {
casper.evaluate(function (str) {
- $('.create_default_stream')
+ $(".create_default_stream")
.focus()
.val(str)
- .trigger($.Event('keyup', { which: 0 }));
+ .trigger($.Event("keyup", { which: 0 }));
}, str);
});
}
@@ -295,7 +295,7 @@ function get_suggestions(str) {
function select_from_suggestions(item) {
casper.then(function () {
casper.evaluate(function (item) {
- var tah = $('.create_default_stream').data().typeahead;
+ var tah = $(".create_default_stream").data().typeahead;
tah.mouseenter({
currentTarget: $('.typeahead:visible li:contains("' + item + '")')[0],
});
@@ -322,8 +322,8 @@ casper.then(function () {
var stream_id = common.get_stream_id(stream_name);
var row = ".default_stream_row[data-stream-id='" + stream_id + "']";
casper.waitUntilVisible(row, function () {
- casper.test.assertSelectorHasText(row + ' .default_stream_name', stream_name);
- casper.click(row + ' button.remove-default-stream');
+ casper.test.assertSelectorHasText(row + " .default_stream_name", stream_name);
+ casper.click(row + " button.remove-default-stream");
casper.waitWhileVisible(row, function () {
casper.test.assertDoesntExist(row);
});
@@ -337,16 +337,16 @@ casper.then(function () {
casper.click("li[data-section='organization-profile']");
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',
+ 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.test.assertEqual(casper.visible("#realm-icon-upload-widget .settings-page-delete-button"), true);
});
});
});
@@ -355,30 +355,30 @@ 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.waitWhileVisible('#realm-icon-upload-widget .settings-page-delete-button', function () {
+ 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.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 () {
+ casper.waitUntilVisible("#id_realm_default_language", function () {
casper.test.info("Changing realm default language");
casper.evaluate(function () {
- $('#id_realm_default_language').val('de').change();
+ $("#id_realm_default_language").val("de").change();
});
- casper.test.assertSelectorHasText('#org-submit-user-defaults', "Save");
- casper.click('#org-submit-user-defaults');
+ casper.test.assertSelectorHasText("#org-submit-user-defaults", "Save");
+ casper.click("#org-submit-user-defaults");
});
});
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");
});
});
@@ -387,16 +387,16 @@ 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.test.assertSelectorHasText("#org-submit-auth_settings", "Save");
+ casper.click("#org-submit-auth_settings");
});
});
casper.then(function () {
// Leave the page and return
- casper.click('#settings-dropdown');
+ casper.click("#settings-dropdown");
casper.click('a[href^="#streams"]');
- casper.click('#settings-dropdown');
+ casper.click("#settings-dropdown");
casper.click('a[href^="#organization"]');
casper.click("li[data-section='auth-methods']");
diff --git a/frontend_tests/casper_tests/11-mention.js b/frontend_tests/casper_tests/11-mention.js
index 10f425e4dba..094aa8b1417 100644
--- a/frontend_tests/casper_tests/11-mention.js
+++ b/frontend_tests/casper_tests/11-mention.js
@@ -1,25 +1,25 @@
-var common = require('../casper_lib/common.js');
+var common = require("../casper_lib/common.js");
common.start_and_log_in();
-casper.waitUntilVisible('#zhome', function () {
- casper.test.info('compose box visible');
- casper.page.sendEvent('keypress', "c"); // brings up the compose box
+casper.waitUntilVisible("#zhome", function () {
+ casper.test.info("compose box visible");
+ casper.page.sendEvent("keypress", "c"); // brings up the compose box
});
casper.then(function () {
casper.fill('form[action^="/json/messages"]', {
- stream_message_recipient_stream: 'Verona',
- stream_message_recipient_topic: 'Test mention all',
+ stream_message_recipient_stream: "Verona",
+ stream_message_recipient_topic: "Test mention all",
});
});
-common.select_item_via_typeahead('#compose-textarea', '@**all**', 'all');
+common.select_item_via_typeahead("#compose-textarea", "@**all**", "all");
casper.then(function () {
common.turn_off_press_enter_to_send();
casper.test.info("Checking for all everyone warning");
var stream_size = this.evaluate(function () {
- return stream_data.get_sub('Verona').subscribers.size;
+ return stream_data.get_sub("Verona").subscribers.size;
});
casper.test.info(stream_size);
var threshold = this.evaluate(function () {
@@ -27,26 +27,26 @@ casper.then(function () {
return compose.all_everyone_warn_threshold;
});
casper.test.assertTrue(stream_size > threshold);
- casper.test.info('Click Send Button');
- casper.click('#compose-send-button');
+ casper.test.info("Click Send Button");
+ casper.click("#compose-send-button");
});
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');
+ 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.');
- casper.test.assertNotVisible('.compose-all-everyone-msg');
- casper.test.assertNotVisible('#compose-send-status');
+ casper.waitWhileVisible(".compose-all-everyone-confirm", function () {
+ casper.test.info("Check that error messages are gone.");
+ casper.test.assertNotVisible(".compose-all-everyone-msg");
+ casper.test.assertNotVisible("#compose-send-status");
});
});
casper.then(function () {
- common.expected_messages('zhome', ['Verona > Test mention all'],
+ common.expected_messages("zhome", ["Verona > Test mention all"],
["<p><span class=\"user-mention user-mention-me\" " +
"data-user-id=\"*\">@all</span></p>"]);
});
diff --git a/frontend_tests/casper_tests/12-custom-profile.js b/frontend_tests/casper_tests/12-custom-profile.js
index e135bcedfec..75d120ab6fa 100644
--- a/frontend_tests/casper_tests/12-custom-profile.js
+++ b/frontend_tests/casper_tests/12-custom-profile.js
@@ -1,4 +1,4 @@
-var common = require('../casper_lib/common.js');
+var common = require("../casper_lib/common.js");
common.start_and_log_in();
@@ -8,49 +8,49 @@ common.manage_organization();
casper.test.info("Testing custom profile fields");
casper.thenClick("li[data-section='profile-field-settings']");
casper.then(function () {
- casper.waitUntilVisible('.admin-profile-field-form', function () {
- casper.fill('form.admin-profile-field-form', {
- name: 'Teams',
- field_type: '1',
+ casper.waitUntilVisible(".admin-profile-field-form", function () {
+ casper.fill("form.admin-profile-field-form", {
+ name: "Teams",
+ field_type: "1",
});
casper.click("form.admin-profile-field-form button[type='submit']");
});
});
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.click('.profile-field-row button.open-edit-form');
+ 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.click(".profile-field-row button.open-edit-form");
});
});
});
casper.then(function () {
- casper.waitUntilVisible('tr.profile-field-form form', function () {
- casper.fill('tr.profile-field-form form.name-setting', {
- name: 'team',
+ casper.waitUntilVisible("tr.profile-field-form form", function () {
+ casper.fill("tr.profile-field-form form.name-setting", {
+ name: "team",
});
- casper.click('tr.profile-field-form button.submit');
+ casper.click("tr.profile-field-form button.submit");
});
});
casper.then(function () {
- casper.waitUntilVisible('#admin-profile-field-status img', function () {
- casper.test.assertSelectorHasText('div#admin-profile-field-status', 'Saved');
+ casper.waitUntilVisible("#admin-profile-field-status img", function () {
+ casper.test.assertSelectorHasText("div#admin-profile-field-status", "Saved");
});
- 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.click('.profile-field-row button.delete');
+ 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.click(".profile-field-row button.delete");
});
});
casper.then(function () {
- casper.waitUntilVisible('#admin-profile-field-status img', function () {
- casper.test.assertSelectorHasText('div#admin-profile-field-status', 'Saved');
+ casper.waitUntilVisible("#admin-profile-field-status img", function () {
+ casper.test.assertSelectorHasText("div#admin-profile-field-status", "Saved");
});
});
diff --git a/frontend_tests/casper_tests/13-user-deactivation.js b/frontend_tests/casper_tests/13-user-deactivation.js
index 6327363b741..c66ec15985a 100644
--- a/frontend_tests/casper_tests/13-user-deactivation.js
+++ b/frontend_tests/casper_tests/13-user-deactivation.js
@@ -1,7 +1,7 @@
-var common = require('../casper_lib/common.js');
+var common = require("../casper_lib/common.js");
function user_row(name) {
- var email = name + '@zulip.com';
+ var email = name + "@zulip.com";
var user_id = common.get_user_id(email);
return '.user_row[data-user-id="' + user_id + '"]';
}
@@ -9,7 +9,7 @@ function user_row(name) {
common.start_and_log_in();
casper.then(function () {
- var menu_selector = '#settings-dropdown';
+ var menu_selector = "#settings-dropdown";
casper.waitUntilVisible(menu_selector, function () {
casper.click(menu_selector);
casper.click('a[href^="#organization"]');
@@ -17,43 +17,43 @@ casper.then(function () {
});
casper.then(function () {
- casper.waitUntilVisible('#settings_overlay_container.show', function () {
+ casper.waitUntilVisible("#settings_overlay_container.show", function () {
casper.click("li[data-section='user-list-admin']");
});
});
// Test user deactivation and reactivation
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 now', 'Deactivate now button available');
- casper.click('#deactivation_user_modal .do_deactivate_button');
+ 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 now", "Deactivate now button available");
+ casper.click("#deactivation_user_modal .do_deactivate_button");
});
});
casper.then(function () {
- casper.waitUntilVisible(user_row('cordelia') + '.deactivated_user', function () {
- casper.test.assertExists('.fa-user-plus', 'Reactivate icon available');
- casper.click(user_row('cordelia') + ' .reactivate');
+ casper.waitUntilVisible(user_row("cordelia") + ".deactivated_user", function () {
+ casper.test.assertExists(".fa-user-plus", "Reactivate icon available");
+ casper.click(user_row("cordelia") + " .reactivate");
});
});
casper.then(function () {
- casper.waitUntilVisible(user_row('cordelia') + ':not(.deactivated_user)', function () {
- casper.test.assertExists('.fa-user-times', 'Deactivate icon available');
+ casper.waitUntilVisible(user_row("cordelia") + ":not(.deactivated_user)", function () {
+ casper.test.assertExists(".fa-user-times", "Deactivate icon available");
});
});
casper.then(function () {
// Test Deactivated users section of admin page
- 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 now', 'Deactivate now button available');
- casper.click('#deactivation_user_modal .do_deactivate_button');
+ 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 now", "Deactivate now button available");
+ casper.click("#deactivation_user_modal .do_deactivate_button");
});
});
@@ -65,15 +65,15 @@ casper.then(function () {
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");
});
});
@@ -84,22 +84,22 @@ casper.then(function () {
});
casper.then(function () {
- casper.waitUntilVisible(user_row('default-bot'), function () {
- casper.test.assertExists('.fa-user-times', 'Deactivate icon available');
- casper.click(user_row('default-bot') + ' .deactivate');
+ casper.waitUntilVisible(user_row("default-bot"), function () {
+ casper.test.assertExists(".fa-user-times", "Deactivate icon available");
+ casper.click(user_row("default-bot") + " .deactivate");
});
});
casper.then(function () {
- casper.waitUntilVisible(user_row('default-bot') + '.deactivated_user', function () {
- casper.test.assertExists('.fa-user-plus', 'Reactivate icon available');
- casper.click(user_row('default-bot') + ' .reactivate');
+ casper.waitUntilVisible(user_row("default-bot") + ".deactivated_user", function () {
+ casper.test.assertExists(".fa-user-plus", "Reactivate icon available");
+ casper.click(user_row("default-bot") + " .reactivate");
});
});
casper.then(function () {
- casper.waitUntilVisible(user_row('default-bot') + ':not(.deactivated_user)', function () {
- casper.test.assertExists('.fa-user-times', 'Deactivate icon available');
+ casper.waitUntilVisible(user_row("default-bot") + ":not(.deactivated_user)", function () {
+ casper.test.assertExists(".fa-user-times", "Deactivate icon available");
});
});
diff --git a/frontend_tests/casper_tests/14-drafts.js b/frontend_tests/casper_tests/14-drafts.js
index 68d56906197..f524ee493ad 100644
--- a/frontend_tests/casper_tests/14-drafts.js
+++ b/frontend_tests/casper_tests/14-drafts.js
@@ -1,4 +1,4 @@
-var common = require('../casper_lib/common.js');
+var common = require("../casper_lib/common.js");
function waitWhileDraftsVisible(then) {
casper.waitFor(function () {
@@ -21,211 +21,211 @@ function waitUntilDraftsVisible(then) {
common.start_and_log_in();
casper.then(function () {
- casper.test.info('Drafts page');
+ casper.test.info("Drafts page");
- casper.waitUntilVisible('.drafts-link', function () {
- casper.click('.drafts-link');
+ casper.waitUntilVisible(".drafts-link", function () {
+ casper.click(".drafts-link");
});
});
casper.then(function () {
casper.test.assertUrlMatch(/^http:\/\/[^/]+\/#drafts/,
- 'URL suggests we are on drafts page');
+ "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.test.assertExists("#draft_overlay", "Drafts page is active");
+ casper.test.assertSelectorHasText(".no-drafts", "No drafts.");
});
});
casper.then(function () {
- casper.click('#draft_overlay .exit');
+ casper.click("#draft_overlay .exit");
waitWhileDraftsVisible();
});
casper.then(function () {
- casper.test.info('Creating Stream Message Draft');
- 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',
+ casper.test.info("Creating Stream Message Draft");
+ 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.click("#compose_close");
});
});
casper.then(function () {
- casper.test.info('Creating Private Message Draft');
- casper.click('body');
- casper.page.sendEvent('keypress', "x");
- casper.waitUntilVisible('#private-message', function () {
- casper.fill('form#send_message_form', {
- content: 'Test Private Message',
+ casper.test.info("Creating Private Message Draft");
+ casper.click("body");
+ casper.page.sendEvent("keypress", "x");
+ casper.waitUntilVisible("#private-message", function () {
+ casper.fill("form#send_message_form", {
+ content: "Test Private Message",
}, false);
- common.pm_recipient.set('[email protected], [email protected]');
+ common.pm_recipient.set("[email protected], [email protected]");
casper.click("#compose_close");
});
});
casper.then(function () {
- casper.test.info('Opening Markdown Preview');
- casper.waitUntilVisible('#left_bar_compose_stream_button_big', function () {
- casper.click('#left_bar_compose_stream_button_big');
+ casper.test.info("Opening Markdown Preview");
+ casper.waitUntilVisible("#left_bar_compose_stream_button_big", function () {
+ casper.click("#left_bar_compose_stream_button_big");
});
- casper.waitUntilVisible('#markdown_preview', function () {
- casper.click('#markdown_preview');
+ casper.waitUntilVisible("#markdown_preview", function () {
+ casper.click("#markdown_preview");
});
});
casper.then(function () {
- casper.waitUntilVisible('.drafts-link', function () {
- casper.click('.drafts-link');
+ casper.waitUntilVisible(".drafts-link", function () {
+ casper.click(".drafts-link");
});
});
casper.then(function () {
waitUntilDraftsVisible(function () {
- casper.test.assertElementCount('.draft-row', 2, 'Drafts loaded');
+ 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_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_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");
});
});
casper.then(function () {
- casper.test.info('Restoring Stream Message Draft');
+ casper.test.info("Restoring Stream Message Draft");
casper.click("#drafts_table .message_row:not(.private-message) .restore-draft");
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',
+ 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');
+ 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',
+ 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.click("#compose_close");
});
casper.then(function () {
- casper.waitUntilVisible('.drafts-link', function () {
- casper.click('.drafts-link');
+ casper.waitUntilVisible(".drafts-link", function () {
+ casper.click(".drafts-link");
});
});
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_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.then(function () {
- casper.test.info('Restoring Private Message Draft');
+ casper.test.info("Restoring Private Message Draft");
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',
+ 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.pm_recipient.expect('[email protected],[email protected]');
- casper.test.assertSelectorHasText('title', 'Cordelia Lear, King Hamlet - Zulip Dev - Zulip', 'Narrowed to huddle');
+ common.pm_recipient.expect("[email protected],[email protected]");
+ casper.test.assertSelectorHasText("title", "Cordelia Lear, King Hamlet - Zulip Dev - Zulip", "Narrowed to huddle");
});
});
casper.then(function () {
casper.click("#compose_close");
- casper.waitUntilVisible('.drafts-link', function () {
- casper.click('.drafts-link');
+ casper.waitUntilVisible(".drafts-link", function () {
+ casper.click(".drafts-link");
});
});
casper.then(function () {
- casper.test.info('Deleting Draft');
+ casper.test.info("Deleting Draft");
casper.click("#drafts_table .message_row.private-message .delete-draft");
- casper.test.assertElementCount('.draft-row', 1, 'Draft deleted');
+ casper.test.assertElementCount(".draft-row", 1, "Draft deleted");
casper.test.assertDoesntExist("#drafts_table .message_row.private-message");
});
casper.then(function () {
- casper.test.info('Saving Draft by Reloading');
- casper.click('#draft_overlay .exit');
+ casper.test.info("Saving Draft by Reloading");
+ casper.click("#draft_overlay .exit");
waitWhileDraftsVisible(function () {
- casper.click('body');
- casper.page.sendEvent('keypress', "x");
+ casper.click("body");
+ casper.page.sendEvent("keypress", "x");
});
});
casper.then(function () {
- casper.waitUntilVisible('#private-message', function () {
- casper.fill('form#send_message_form', {
- content: 'Test Private Message',
+ casper.waitUntilVisible("#private-message", function () {
+ casper.fill("form#send_message_form", {
+ content: "Test Private Message",
}, false);
- common.pm_recipient.set('[email protected]');
+ common.pm_recipient.set("[email protected]");
});
casper.reload();
});
casper.then(function () {
- casper.test.info('Finished reloading; now opening drafts again');
+ casper.test.info("Finished reloading; now opening drafts again");
// Reloading into a narrow opens compose box automatically
casper.waitUntilVisible("#compose_close", function () {
casper.click("#compose_close");
});
- casper.waitUntilVisible('.drafts-link', function () {
- casper.click('.drafts-link');
+ casper.waitUntilVisible(".drafts-link", function () {
+ casper.click(".drafts-link");
});
});
casper.then(function () {
- casper.test.info('Checking drafts survived the reload');
+ 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.assertTextExists('Test Private Message');
+ 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.assertTextExists("Test Private Message");
});
});
casper.then(function () {
- casper.test.info('Deleting Draft after Sending Message');
+ casper.test.info("Deleting Draft after Sending Message");
casper.click("#drafts_table .message_row.private-message .restore-draft");
waitWhileDraftsVisible(function () {
- casper.test.assertVisible('#private-message');
+ casper.test.assertVisible("#private-message");
casper.click("#enter_sends");
- casper.waitUntilVisible('#compose-send-button', function () {
- casper.click('#compose-send-button');
+ casper.waitUntilVisible("#compose-send-button", function () {
+ casper.click("#compose-send-button");
});
});
});
casper.then(function () {
// This tests the second drafts link in the compose area
- casper.waitUntilVisible('.compose_table .drafts-link', function () {
- casper.click('.compose_table .drafts-link');
+ casper.waitUntilVisible(".compose_table .drafts-link", function () {
+ casper.click(".compose_table .drafts-link");
});
waitUntilDraftsVisible(function () {
- casper.test.assertElementCount('.draft-row', 1, 'Drafts loaded');
+ casper.test.assertElementCount(".draft-row", 1, "Drafts loaded");
casper.test.assertDoesntExist("#drafts_table .message_row.private-message");
});
});
diff --git a/frontend_tests/casper_tests/15-delete-message.js b/frontend_tests/casper_tests/15-delete-message.js
index b508f3e33b0..e0f60200cb7 100644
--- a/frontend_tests/casper_tests/15-delete-message.js
+++ b/frontend_tests/casper_tests/15-delete-message.js
@@ -1,4 +1,4 @@
-var common = require('../casper_lib/common.js');
+var common = require("../casper_lib/common.js");
common.start_and_log_in();
@@ -12,19 +12,19 @@ casper.then(function () {
casper.then(function () {
msgs_qty = this.evaluate(function () {
- return $('#zhome .message_row').length;
+ return $("#zhome .message_row").length;
});
last_message_id = this.evaluate(function () {
- var msg = $('#zhome .message_row').last();
- msg.find('.info').click();
- $('.delete_message').click();
- return msg.attr('id');
+ var msg = $("#zhome .message_row").last();
+ msg.find(".info").click();
+ $(".delete_message").click();
+ return msg.attr("id");
});
});
casper.then(function () {
casper.waitUntilVisible("#delete_message_modal", function () {
- casper.click('#do_delete_message_button');
+ casper.click("#do_delete_message_button");
});
});
casper.then(function () {
@@ -35,7 +35,7 @@ casper.then(function () {
casper.then(function () {
casper.waitFor(function check_length() {
return casper.evaluate(function (expected_length) {
- return $('#zhome .message_row').length === expected_length;
+ return $("#zhome .message_row").length === expected_length;
}, msgs_qty - 1);
});
});
diff --git a/frontend_tests/casper_tests/16-copy-and-paste.js b/frontend_tests/casper_tests/16-copy-and-paste.js
index 8294865a79b..dcd1c26dc69 100644
--- a/frontend_tests/casper_tests/16-copy-and-paste.js
+++ b/frontend_tests/casper_tests/16-copy-and-paste.js
@@ -1,53 +1,53 @@
-var common = require('../casper_lib/common.js');
+var common = require("../casper_lib/common.js");
common.start_and_log_in();
casper.then(function () {
- casper.test.info('Sending messages');
+ casper.test.info("Sending messages");
});
// 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',
+ 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>',
+ "<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 () {
- casper.test.info('Messages were sent successfully');
+ casper.test.info("Messages were sent successfully");
});
function get_message_node(message) {
@@ -66,14 +66,14 @@ function copy_messages(start_message, end_message) {
// 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();
+ $("#copytempdiv").remove();
// emulate copy event
- $('body').trigger($.Event('keydown', { which: 67, ctrlKey: true }));
+ $("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; });
+ 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,
@@ -83,85 +83,85 @@ function copy_messages(start_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 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 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');
+ 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");
});
// 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 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");
});
// test copying last message from previous topic and first message from next topic
casper.then(function () {
- var actual_copied_lines = copy_messages('copy paste test B', 'copy paste test C');
+ var actual_copied_lines = copy_messages("copy paste test B", "copy paste test C");
var expected_copied_lines = [
- 'Verona > copy-paste-subject #1 Today',
- 'Iago: copy paste test B',
- 'Verona > copy-paste-subject #2 Today',
- 'Iago: copy paste test C',
+ "Verona > copy-paste-subject #1 Today",
+ "Iago: copy paste test B",
+ "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
casper.then(function () {
- var actual_copied_lines = copy_messages('copy paste test B', 'copy paste test E');
+ var actual_copied_lines = copy_messages("copy paste test B", "copy paste test E");
var expected_copied_lines = [
- 'Verona > copy-paste-subject #1 Today',
- 'Iago: copy paste test B',
- 'Verona > copy-paste-subject #2 Today',
- 'Iago: copy paste test C',
- 'Iago: copy paste test D',
- 'Iago: copy paste test E',
+ "Verona > copy-paste-subject #1 Today",
+ "Iago: copy paste test B",
+ "Verona > copy-paste-subject #2 Today",
+ "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');
+ 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
casper.then(function () {
- var actual_copied_lines = copy_messages('copy paste test A', 'copy paste test C');
+ var actual_copied_lines = copy_messages("copy paste test A", "copy paste test C");
var expected_copied_lines = [
- 'Verona > copy-paste-subject #1 Today',
- 'Iago: copy paste test A',
- 'Iago: copy paste test B',
- 'Verona > copy-paste-subject #2 Today',
- 'Iago: copy paste test C',
+ "Verona > copy-paste-subject #1 Today",
+ "Iago: copy paste test A",
+ "Iago: copy paste test B",
+ "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
casper.then(function () {
- var actual_copied_lines = copy_messages('copy paste test B', 'copy paste test F');
+ var actual_copied_lines = copy_messages("copy paste test B", "copy paste test F");
var expected_copied_lines = [
- 'Verona > copy-paste-subject #1 Today',
- 'Iago: copy paste test B',
- 'Verona > copy-paste-subject #2 Today',
- 'Iago: copy paste test C',
- 'Iago: copy paste test D',
- 'Iago: copy paste test E',
- 'Verona > copy-paste-subject #3 Today',
- 'Iago: copy paste test F',
+ "Verona > copy-paste-subject #1 Today",
+ "Iago: copy paste test B",
+ "Verona > copy-paste-subject #2 Today",
+ "Iago: copy paste test C",
+ "Iago: copy paste test D",
+ "Iago: copy paste test E",
+ "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 54859cec80f..1a4a8411df1 100644
--- a/frontend_tests/casper_tests/17-realm-linkifier.js
+++ b/frontend_tests/casper_tests/17-realm-linkifier.js
@@ -1,4 +1,4 @@
-var common = require('../casper_lib/common.js');
+var common = require("../casper_lib/common.js");
common.start_and_log_in();
@@ -7,48 +7,48 @@ common.manage_organization();
// Test custom realm filters
casper.then(function () {
casper.click("li[data-section='filter-settings']");
- casper.waitUntilVisible('.admin-filter-form', function () {
- casper.fill('form.admin-filter-form', {
- pattern: '#(?P<id>[0-9]+)',
- url_format_string: 'https://trac.example.com/ticket/%(id)s',
+ casper.waitUntilVisible(".admin-filter-form", function () {
+ casper.fill("form.admin-filter-form", {
+ pattern: "#(?P<id>[0-9]+)",
+ url_format_string: "https://trac.example.com/ticket/%(id)s",
});
- casper.click('form.admin-filter-form button.button');
+ casper.click("form.admin-filter-form button.button");
});
});
casper.then(function () {
- casper.waitUntilVisible('div#admin-filter-status', function () {
- casper.test.assertSelectorHasText('div#admin-filter-status', 'Custom filter added!');
+ casper.waitUntilVisible("div#admin-filter-status", function () {
+ casper.test.assertSelectorHasText("div#admin-filter-status", "Custom filter added!");
});
});
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.click('.filter_row button');
+ 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.click(".filter_row button");
});
});
casper.then(function () {
- casper.waitWhileVisible('.filter_row', function () {
- casper.test.assertDoesntExist('.filter_row');
+ casper.waitWhileVisible(".filter_row", function () {
+ casper.test.assertDoesntExist(".filter_row");
});
});
casper.then(function () {
- casper.waitUntilVisible('.admin-filter-form', function () {
- casper.fill('form.admin-filter-form', {
- pattern: 'a$',
- url_format_string: 'https://trac.example.com/ticket/%(id)s',
+ casper.waitUntilVisible(".admin-filter-form", function () {
+ casper.fill("form.admin-filter-form", {
+ pattern: "a$",
+ url_format_string: "https://trac.example.com/ticket/%(id)s",
});
- casper.click('form.admin-filter-form button.button');
+ casper.click("form.admin-filter-form button.button");
});
});
casper.then(function () {
- casper.waitUntilVisible('div#admin-filter-pattern-status', function () {
- casper.test.assertSelectorHasText('div#admin-filter-pattern-status', 'Failed: Invalid filter pattern');
+ casper.waitUntilVisible("div#admin-filter-pattern-status", function () {
+ 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 013edf1ac56..a6ff1b420b4 100644
--- a/frontend_tests/node_tests/activity.js
+++ b/frontend_tests/node_tests/activity.js
@@ -1,8 +1,8 @@
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
let filter_key_handlers;
-const huddle_data = zrequire('huddle_data');
+const huddle_data = zrequire("huddle_data");
const _page_params = {
realm_users: [],
@@ -41,13 +41,13 @@ const _popovers = {
hide_all_except_sidebars: function () {},
hide_all: function () {},
show_userlist_sidebar: function () {
- $('.column-right').addClass('expanded');
+ $(".column-right").addClass("expanded");
},
};
const _stream_popover = {
show_streamlist_sidebar: function () {
- $('.column-left').addClass('expanded');
+ $(".column-left").addClass("expanded");
},
};
@@ -56,71 +56,71 @@ const _resize = {
resize_page_components: () => {},
};
-set_global('padded_widget', {
+set_global("padded_widget", {
update_padding: () => {},
});
-set_global('channel', _channel);
-set_global('compose_state', _compose_state);
-set_global('document', _document);
-set_global('keydown_util', _keydown_util);
-set_global('page_params', _page_params);
-set_global('pm_list', _pm_list);
-set_global('popovers', _popovers);
-set_global('resize', _resize);
-set_global('scroll_util', _scroll_util);
-set_global('stream_popover', _stream_popover);
-set_global('ui', _ui);
-
-zrequire('compose_fade');
-set_global('Handlebars', global.make_handlebars());
-zrequire('unread');
-zrequire('hash_util');
-zrequire('narrow');
-zrequire('presence');
-zrequire('people');
-zrequire('buddy_data');
-zrequire('buddy_list');
-zrequire('user_search');
-zrequire('user_status');
-zrequire('list_cursor');
-zrequire('activity');
+set_global("channel", _channel);
+set_global("compose_state", _compose_state);
+set_global("document", _document);
+set_global("keydown_util", _keydown_util);
+set_global("page_params", _page_params);
+set_global("pm_list", _pm_list);
+set_global("popovers", _popovers);
+set_global("resize", _resize);
+set_global("scroll_util", _scroll_util);
+set_global("stream_popover", _stream_popover);
+set_global("ui", _ui);
+
+zrequire("compose_fade");
+set_global("Handlebars", global.make_handlebars());
+zrequire("unread");
+zrequire("hash_util");
+zrequire("narrow");
+zrequire("presence");
+zrequire("people");
+zrequire("buddy_data");
+zrequire("buddy_list");
+zrequire("user_search");
+zrequire("user_status");
+zrequire("list_cursor");
+zrequire("activity");
const me = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 999,
- full_name: 'Me Myself',
+ full_name: "Me Myself",
};
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 1,
- full_name: 'Alice Smith',
+ full_name: "Alice Smith",
};
const fred = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 2,
full_name: "Fred Flintstone",
};
const jill = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 3,
- full_name: 'Jill Hill',
+ full_name: "Jill Hill",
};
const mark = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 4,
- full_name: 'Marky Mark',
+ full_name: "Marky Mark",
};
const norbert = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 5,
- full_name: 'Norbert Oswald',
+ full_name: "Norbert Oswald",
};
const zoe = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 6,
- full_name: 'Zoe Yang',
+ full_name: "Zoe Yang",
};
people.add_active_user(alice);
@@ -133,9 +133,9 @@ people.add_active_user(me);
people.initialize_current_user(me.user_id);
const presence_info = new Map();
-presence_info.set(alice.user_id, { status: 'inactive' });
-presence_info.set(fred.user_id, { status: 'active' });
-presence_info.set(jill.user_id, { status: 'active' });
+presence_info.set(alice.user_id, { status: "inactive" });
+presence_info.set(fred.user_id, { status: "active" });
+presence_info.set(jill.user_id, { status: "active" });
presence.presence_info = presence_info;
@@ -149,19 +149,19 @@ buddy_list.fill_screen_with_content = () => {
});
};
-run_test('get_status', () => {
+run_test("get_status", () => {
assert.equal(presence.get_status(page_params.user_id), "active");
assert.equal(presence.get_status(alice.user_id), "inactive");
assert.equal(presence.get_status(fred.user_id), "active");
assert.equal(presence.get_status(zoe.user_id), "offline");
});
-run_test('reload_defaults', () => {
- blueslip.expect('warn', 'get_filter_text() is called before initialization');
- assert.equal(activity.get_filter_text(), '');
+run_test("reload_defaults", () => {
+ blueslip.expect("warn", "get_filter_text() is called before initialization");
+ assert.equal(activity.get_filter_text(), "");
});
-run_test('sort_users', () => {
+run_test("sort_users", () => {
const user_ids = [alice.user_id, fred.user_id, jill.user_id];
buddy_data.sort_users(user_ids);
@@ -173,37 +173,37 @@ run_test('sort_users', () => {
]);
});
-run_test('huddle_data.process_loaded_messages', () => {
+run_test("huddle_data.process_loaded_messages", () => {
// TODO: move this to a module for just testing `huddle_data`
const timestamp1 = 1382479029; // older
const timestamp2 = 1382479033; // newer
const old_timestamp = 1382479000;
const messages = [
{
- type: 'private',
+ type: "private",
display_recipient: [{id: jill.user_id}, {id: norbert.user_id}],
timestamp: timestamp1,
},
{
- type: 'stream',
+ type: "stream",
},
{
- type: 'private',
+ type: "private",
display_recipient: [{id: me.user_id}], // PM to myself
},
{
- type: 'private',
+ type: "private",
display_recipient: [{id: alice.user_id}, {id: fred.user_id}],
timestamp: timestamp2,
},
{
- type: 'private',
+ type: "private",
display_recipient: [{id: fred.user_id}, {id: alice.user_id}],
timestamp: old_timestamp,
},
@@ -235,7 +235,7 @@ function reset_setup() {
$.clear_all_elements();
activity.set_cursor_and_filter();
- buddy_list.container = $('#user_presences');
+ buddy_list.container = $("#user_presences");
buddy_list.container.append = () => {};
clear_buddy_list();
@@ -243,8 +243,8 @@ function reset_setup() {
reset_setup();
-run_test('presence_list_full_update', () => {
- $('.user-list-filter').focus();
+run_test("presence_list_full_update", () => {
+ $(".user-list-filter").focus();
compose_state.private_message_recipient = () => fred.email;
compose_fade.set_focused_recipient("private");
@@ -262,54 +262,54 @@ run_test('presence_list_full_update', () => {
});
function simulate_right_column_buddy_list() {
- $('.user-list-filter').closest = function (selector) {
+ $(".user-list-filter").closest = function (selector) {
assert.equal(selector, ".app-main [class^='column-']");
- return $.create('right-sidebar').addClass('column-right');
+ return $.create("right-sidebar").addClass("column-right");
};
}
function simulate_left_column_buddy_list() {
- $('.user-list-filter').closest = function (selector) {
+ $(".user-list-filter").closest = function (selector) {
assert.equal(selector, ".app-main [class^='column-']");
- return $.create('left-sidebar').addClass('column-left');
+ return $.create("left-sidebar").addClass("column-left");
};
}
function buddy_list_add(user_id, stub) {
if (stub.attr) {
- stub.attr('data-user-id', user_id);
+ stub.attr("data-user-id", user_id);
}
stub.length = 1;
const sel = `li.user_sidebar_entry[data-user-id='${user_id}']`;
- $('#user_presences').set_find_results(sel, stub);
+ $("#user_presences").set_find_results(sel, stub);
}
-run_test('PM_update_dom_counts', () => {
- const value = $.create('alice-value');
- const count = $.create('alice-count');
+run_test("PM_update_dom_counts", () => {
+ const value = $.create("alice-value");
+ const count = $.create("alice-count");
const pm_key = alice.user_id.toString();
- const li = $.create('alice stub');
+ const li = $.create("alice stub");
buddy_list_add(pm_key, li);
- count.set_find_results('.value', value);
- li.set_find_results('.count', count);
- count.set_parents_result('li', li);
+ count.set_find_results(".value", value);
+ li.set_find_results(".count", count);
+ count.set_parents_result("li", li);
const counts = new Map();
counts.set(pm_key, 5);
- li.addClass('user_sidebar_entry');
+ li.addClass("user_sidebar_entry");
activity.update_dom_with_unread_counts({pm_count: counts});
- assert(li.hasClass('user-with-count'));
+ assert(li.hasClass("user-with-count"));
assert.equal(value.text(), "5");
counts.set(pm_key, 0);
activity.update_dom_with_unread_counts({pm_count: counts});
- assert(!li.hasClass('user-with-count'));
- assert.equal(value.text(), '');
+ assert(!li.hasClass("user-with-count"));
+ assert.equal(value.text(), "");
});
-run_test('handlers', () => {
+run_test("handlers", () => {
// This is kind of weak coverage; we are mostly making sure that
// keys and clicks got mapped to functions that don't crash.
let me_li;
@@ -322,9 +322,9 @@ run_test('handlers', () => {
keys: [me.user_id, alice.user_id, fred.user_id],
});
- me_li = $.create('me stub');
- alice_li = $.create('alice stub');
- fred_li = $.create('fred stub');
+ me_li = $.create("me stub");
+ alice_li = $.create("alice stub");
+ fred_li = $.create("fred stub");
buddy_list_add(me.user_id, me_li);
buddy_list_add(alice.user_id, alice_li);
@@ -344,14 +344,14 @@ run_test('handlers', () => {
stopPropagation: () => {},
};
- const handler = $('.user-list-filter').get_on_handler('focus');
+ const handler = $(".user-list-filter").get_on_handler("focus");
handler(e);
}());
(function test_click_header_filter() {
init();
const e = {};
- const handler = $('#userlist-header').get_on_handler('click');
+ const handler = $("#userlist-header").get_on_handler("click");
simulate_right_column_buddy_list();
@@ -365,11 +365,11 @@ run_test('handlers', () => {
let narrowed;
narrow.by = (method, email) => {
- assert.equal(email, '[email protected]');
+ assert.equal(email, "[email protected]");
narrowed = true;
};
- $('.user-list-filter').val('al');
+ $(".user-list-filter").val("al");
activity.user_cursor.go_to(alice.user_id);
filter_key_handlers.enter_key();
@@ -387,7 +387,7 @@ run_test('handlers', () => {
let narrowed;
narrow.by = (method, email) => {
- assert.equal(email, '[email protected]');
+ assert.equal(email, "[email protected]");
narrowed = true;
};
@@ -398,7 +398,7 @@ run_test('handlers', () => {
(function test_blur_filter() {
init();
const e = {};
- const handler = $('.user-list-filter').get_on_handler('blur');
+ const handler = $(".user-list-filter").get_on_handler("blur");
handler(e);
}());
});
@@ -413,7 +413,7 @@ presence.presence_info.set(zoe.user_id, { status: activity.ACTIVE });
reset_setup();
-run_test('first/prev/next', () => {
+run_test("first/prev/next", () => {
clear_buddy_list();
assert.equal(buddy_list.first_key(), undefined);
@@ -435,9 +435,9 @@ run_test('first/prev/next', () => {
reset_setup();
-run_test('filter_user_ids', () => {
- const user_filter = $('.user-list-filter');
- user_filter.val(''); // no search filter
+run_test("filter_user_ids", () => {
+ const user_filter = $(".user-list-filter");
+ user_filter.val(""); // no search filter
function get_user_ids() {
const filter_text = activity.get_filter_text();
@@ -455,83 +455,83 @@ run_test('filter_user_ids', () => {
mark.user_id,
]);
- user_filter.val('abc'); // no match
+ user_filter.val("abc"); // no match
user_ids = get_user_ids();
assert.deepEqual(user_ids, []);
- user_filter.val('fred'); // match fred
+ user_filter.val("fred"); // match fred
user_ids = get_user_ids();
assert.deepEqual(user_ids, [fred.user_id]);
- user_filter.val('fred,alice'); // match fred and alice
+ user_filter.val("fred,alice"); // match fred and alice
user_ids = get_user_ids();
assert.deepEqual(user_ids, [alice.user_id, fred.user_id]);
- user_filter.val('fr,al'); // match fred and alice partials
+ user_filter.val("fr,al"); // match fred and alice partials
user_ids = get_user_ids();
assert.deepEqual(user_ids, [alice.user_id, fred.user_id]);
- user_filter.val('fr|al'); // test | as OR-operator
+ user_filter.val("fr|al"); // test | as OR-operator
user_ids = get_user_ids();
assert.deepEqual(user_ids, [alice.user_id, fred.user_id]);
presence.presence_info.set(alice.user_id, { status: activity.IDLE });
- user_filter.val('fr,al'); // match fred and alice partials and idle user
+ user_filter.val("fr,al"); // match fred and alice partials and idle user
user_ids = get_user_ids();
assert.deepEqual(user_ids, [fred.user_id, alice.user_id]);
- $.stub_selector('.user-list-filter', []);
+ $.stub_selector(".user-list-filter", []);
presence.presence_info.set(alice.user_id, { status: activity.ACTIVE });
user_ids = get_user_ids();
assert.deepEqual(user_ids, [alice.user_id, fred.user_id]);
});
-run_test('insert_one_user_into_empty_list', () => {
+run_test("insert_one_user_into_empty_list", () => {
let appended_html;
- $('#user_presences').append = function (html) {
+ $("#user_presences").append = function (html) {
appended_html = html;
};
clear_buddy_list();
activity.redraw_user(alice.user_id);
assert(appended_html.indexOf('data-user-id="1"') > 0);
- assert(appended_html.indexOf('user_circle_green') > 0);
+ assert(appended_html.indexOf("user_circle_green") > 0);
});
reset_setup();
-run_test('insert_alice_then_fred', () => {
+run_test("insert_alice_then_fred", () => {
clear_buddy_list();
let appended_html;
- $('#user_presences').append = function (html) {
+ $("#user_presences").append = function (html) {
appended_html = html;
};
activity.redraw_user(alice.user_id);
assert(appended_html.indexOf('data-user-id="1"') > 0);
- assert(appended_html.indexOf('user_circle_green') > 0);
+ assert(appended_html.indexOf("user_circle_green") > 0);
activity.redraw_user(fred.user_id);
assert(appended_html.indexOf('data-user-id="2"') > 0);
- assert(appended_html.indexOf('user_circle_green') > 0);
+ assert(appended_html.indexOf("user_circle_green") > 0);
});
reset_setup();
-run_test('insert_fred_then_alice_then_rename', () => {
+run_test("insert_fred_then_alice_then_rename", () => {
clear_buddy_list();
let appended_html;
- $('#user_presences').append = function (html) {
+ $("#user_presences").append = function (html) {
appended_html = html;
};
activity.redraw_user(fred.user_id);
assert(appended_html.indexOf('data-user-id="2"') > 0);
- assert(appended_html.indexOf('user_circle_green') > 0);
+ assert(appended_html.indexOf("user_circle_green") > 0);
- const fred_stub = $.create('fred-first');
+ const fred_stub = $.create("fred-first");
buddy_list_add(fred.user_id, fred_stub);
let inserted_html;
@@ -541,7 +541,7 @@ run_test('insert_fred_then_alice_then_rename', () => {
activity.redraw_user(alice.user_id);
assert(inserted_html.indexOf('data-user-id="1"') > 0);
- assert(inserted_html.indexOf('user_circle_green') > 0);
+ assert(inserted_html.indexOf("user_circle_green") > 0);
// Next rename fred to Aaron.
const fred_with_new_name = {
@@ -551,7 +551,7 @@ run_test('insert_fred_then_alice_then_rename', () => {
};
people.add_active_user(fred_with_new_name);
- const alice_stub = $.create('alice-first');
+ const alice_stub = $.create("alice-first");
buddy_list_add(alice.user_id, alice_stub);
alice_stub.before = (html) => {
@@ -568,75 +568,75 @@ run_test('insert_fred_then_alice_then_rename', () => {
// Reset jquery here.
reset_setup();
-run_test('insert_unfiltered_user_with_filter', () => {
+run_test("insert_unfiltered_user_with_filter", () => {
// This test only tests that we do not explode when
// try to insert Fred into a list where he does not
// match the search filter.
- const user_filter = $('.user-list-filter');
- user_filter.val('do-not-match-filter');
+ const user_filter = $(".user-list-filter");
+ user_filter.val("do-not-match-filter");
activity.redraw_user(fred.user_id);
});
-run_test('realm_presence_disabled', () => {
+run_test("realm_presence_disabled", () => {
page_params.realm_presence_disabled = true;
activity.redraw_user();
activity.build_user_sidebar();
});
-run_test('clear_search', () => {
- $('.user-list-filter').val('somevalue');
+run_test("clear_search", () => {
+ $(".user-list-filter").val("somevalue");
activity.user_filter.clear_search();
- assert.equal($('.user-list-filter').val(), '');
+ assert.equal($(".user-list-filter").val(), "");
activity.user_filter.clear_search();
- assert($('#user_search_section').hasClass('notdisplayed'));
+ assert($("#user_search_section").hasClass("notdisplayed"));
});
-run_test('escape_search', () => {
+run_test("escape_search", () => {
clear_buddy_list();
- $('.user-list-filter').val('somevalue');
+ $(".user-list-filter").val("somevalue");
activity.escape_search();
- assert.equal($('.user-list-filter').val(), '');
+ assert.equal($(".user-list-filter").val(), "");
activity.escape_search();
- assert($('#user_search_section').hasClass('notdisplayed'));
+ assert($("#user_search_section").hasClass("notdisplayed"));
});
reset_setup();
-run_test('initiate_search', () => {
- $('.user-list-filter').blur();
+run_test("initiate_search", () => {
+ $(".user-list-filter").blur();
simulate_right_column_buddy_list();
activity.initiate_search();
- assert.equal($('.column-right').hasClass('expanded'), true);
- assert.equal($('.user-list-filter').is_focused(), true);
+ assert.equal($(".column-right").hasClass("expanded"), true);
+ assert.equal($(".user-list-filter").is_focused(), true);
simulate_left_column_buddy_list();
activity.initiate_search();
- assert.equal($('.column-left').hasClass('expanded'), true);
- assert.equal($('.user-list-filter').is_focused(), true);
+ assert.equal($(".column-left").hasClass("expanded"), true);
+ assert.equal($(".user-list-filter").is_focused(), true);
});
-run_test('toggle_filter_display', () => {
+run_test("toggle_filter_display", () => {
activity.user_filter.toggle_filter_displayed();
- assert($('#user_search_section').hasClass('notdisplayed'));
- $('.user-list-filter').closest = function (selector) {
+ assert($("#user_search_section").hasClass("notdisplayed"));
+ $(".user-list-filter").closest = function (selector) {
assert.equal(selector, ".app-main [class^='column-']");
- return $.create('sidebar').addClass('column-right');
+ return $.create("sidebar").addClass("column-right");
};
activity.user_filter.toggle_filter_displayed();
- assert.equal($('#user_search_section').hasClass('notdisplayed'), false);
+ assert.equal($("#user_search_section").hasClass("notdisplayed"), false);
});
-run_test('searching', () => {
- $('.user-list-filter').focus();
+run_test("searching", () => {
+ $(".user-list-filter").focus();
assert.equal(activity.searching(), true);
- $('.user-list-filter').blur();
+ $(".user-list-filter").blur();
assert.equal(activity.searching(), false);
});
reset_setup();
-run_test('update_presence_info', () => {
+run_test("update_presence_info", () => {
page_params.realm_presence_disabled = false;
const server_time = 500;
@@ -649,7 +649,7 @@ run_test('update_presence_info', () => {
buddy_data.matches_filter = () => true;
- const alice_li = $.create('alice stub');
+ const alice_li = $.create("alice stub");
buddy_list_add(alice.user_id, alice_li);
let inserted;
@@ -660,20 +660,20 @@ run_test('update_presence_info', () => {
presence.presence_info.delete(me.user_id);
activity.update_presence_info(me.user_id, info, server_time);
assert(inserted);
- assert.deepEqual(presence.presence_info.get(me.user_id).status, 'active');
+ assert.deepEqual(presence.presence_info.get(me.user_id).status, "active");
presence.presence_info.delete(alice.user_id);
activity.update_presence_info(alice.user_id, info, server_time);
assert(inserted);
- const expected = { status: 'active', last_active: 500 };
+ const expected = { status: "active", last_active: 500 };
assert.deepEqual(presence.presence_info.get(alice.user_id), expected);
});
-run_test('initialize', () => {
+run_test("initialize", () => {
function clear() {
$.clear_all_elements();
- buddy_list.container = $('#user_presences');
+ buddy_list.container = $("#user_presences");
buddy_list.container.append = () => {};
clear_buddy_list();
page_params.presences = {};
@@ -681,7 +681,7 @@ run_test('initialize', () => {
clear();
- $.stub_selector('html', {
+ $.stub_selector("html", {
on: function (name, func) {
func();
},
@@ -708,7 +708,7 @@ run_test('initialize', () => {
assert(scroll_handler_started);
assert(!activity.new_user_input);
- assert(!$('#zephyr-mirror-error').hasClass('show'));
+ assert(!$("#zephyr-mirror-error").hasClass("show"));
assert(activity.client_is_active);
$(window).idle = function (params) {
params.onIdle();
@@ -723,14 +723,14 @@ run_test('initialize', () => {
activity.initialize();
- assert($('#zephyr-mirror-error').hasClass('show'));
+ assert($("#zephyr-mirror-error").hasClass("show"));
assert(!activity.new_user_input);
assert(!activity.client_is_active);
clear();
});
-run_test('away_status', () => {
+run_test("away_status", () => {
assert(!user_status.is_away(alice.user_id));
activity.on_set_away(alice.user_id);
assert(user_status.is_away(alice.user_id));
@@ -738,7 +738,7 @@ run_test('away_status', () => {
assert(!user_status.is_away(alice.user_id));
});
-run_test('electron_bridge', () => {
+run_test("electron_bridge", () => {
activity.client_is_active = false;
window.electron_bridge = undefined;
assert.equal(activity.compute_active_status(), activity.IDLE);
diff --git a/frontend_tests/node_tests/alert_words.js b/frontend_tests/node_tests/alert_words.js
index c52ed4a42ca..5fbdac320b0 100644
--- a/frontend_tests/node_tests/alert_words.js
+++ b/frontend_tests/node_tests/alert_words.js
@@ -1,78 +1,78 @@
const params = {
- alert_words: ['alertone', 'alerttwo', 'alertthree', 'al*rt.*s', '.+', 'emoji'],
+ alert_words: ["alertone", "alerttwo", "alertthree", "al*rt.*s", ".+", "emoji"],
};
-zrequire('people');
-zrequire('alert_words');
+zrequire("people");
+zrequire("alert_words");
alert_words.initialize(params);
people.add_active_user({
- email: '[email protected]',
- full_name: 'Tester von Tester',
+ email: "[email protected]",
+ full_name: "Tester von Tester",
user_id: 42,
});
people.initialize_current_user(42);
const regular_message = {
- sender_email: '[email protected]',
- content: '<p>a message</p>',
+ sender_email: "[email protected]",
+ content: "<p>a message</p>",
};
const own_message = {
- sender_email: '[email protected]',
- content: '<p>hey this message alertone</p>',
+ sender_email: "[email protected]",
+ content: "<p>hey this message alertone</p>",
alerted: true,
};
const other_message = {
- sender_email: '[email protected]',
- content: '<p>another alertone message</p>',
+ sender_email: "[email protected]",
+ content: "<p>another alertone message</p>",
alerted: true,
};
const caps_message = {
- sender_email: '[email protected]',
- content: '<p>another ALERTtwo message</p>',
+ sender_email: "[email protected]",
+ content: "<p>another ALERTtwo message</p>",
alerted: true,
};
const alertwordboundary_message = {
- sender_email: '[email protected]',
- content: '<p>another alertthreemessage</p>',
+ sender_email: "[email protected]",
+ content: "<p>another alertthreemessage</p>",
alerted: false,
};
const multialert_message = {
- sender_email: '[email protected]',
- content: '<p>another alertthreemessage alertone and then alerttwo</p>',
+ sender_email: "[email protected]",
+ content: "<p>another alertthreemessage alertone and then alerttwo</p>",
alerted: true,
};
const unsafe_word_message = {
- sender_email: '[email protected]',
- content: '<p>gotta al*rt.*s all</p>',
+ sender_email: "[email protected]",
+ content: "<p>gotta al*rt.*s all</p>",
alerted: true,
};
const alert_in_url_message = {
- sender_email: '[email protected]',
- content: '<p>http://www.google.com/alertone/me</p>',
+ sender_email: "[email protected]",
+ content: "<p>http://www.google.com/alertone/me</p>",
alerted: true,
};
const question_word_message = {
- sender_email: '[email protected]',
- content: '<p>still alertone? me</p>',
+ sender_email: "[email protected]",
+ content: "<p>still alertone? me</p>",
alerted: true,
};
const alert_domain_message = {
- sender_email: '[email protected]',
+ 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>',
alerted: true,
};
// This test ensure we are not mucking up rendered HTML content.
const message_with_emoji = {
- sender_email: '[email protected]',
+ 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>',
alerted: true,
};
-run_test('notifications', () => {
+run_test("notifications", () => {
assert(!alert_words.notifies(regular_message));
assert(!alert_words.notifies(own_message));
assert(alert_words.notifies(other_message));
@@ -84,7 +84,7 @@ run_test('notifications', () => {
assert(alert_words.notifies(message_with_emoji));
});
-run_test('munging', () => {
+run_test("munging", () => {
let saved_content = regular_message.content;
alert_words.process_message(regular_message);
assert.equal(saved_content, regular_message.content);
@@ -111,17 +111,17 @@ run_test('munging', () => {
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', () => {
- assert(!alert_words.has_alert_word('breakfast'));
- assert(!alert_words.has_alert_word('lunch'));
- alert_words.set_words(['breakfast', 'lunch']);
- assert(alert_words.has_alert_word('breakfast'));
- assert(alert_words.has_alert_word('lunch'));
- assert(!alert_words.has_alert_word('dinner'));
+run_test("basic get/set operations", () => {
+ assert(!alert_words.has_alert_word("breakfast"));
+ assert(!alert_words.has_alert_word("lunch"));
+ alert_words.set_words(["breakfast", "lunch"]);
+ assert(alert_words.has_alert_word("breakfast"));
+ assert(alert_words.has_alert_word("lunch"));
+ assert(!alert_words.has_alert_word("dinner"));
});
diff --git a/frontend_tests/node_tests/alert_words_ui.js b/frontend_tests/node_tests/alert_words_ui.js
index 60ce49a65ae..0d54c2c8ab5 100644
--- a/frontend_tests/node_tests/alert_words_ui.js
+++ b/frontend_tests/node_tests/alert_words_ui.js
@@ -1,76 +1,76 @@
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
-set_global('channel', {});
+set_global("channel", {});
-zrequire('alert_words');
-zrequire('alert_words_ui');
+zrequire("alert_words");
+zrequire("alert_words_ui");
alert_words.initialize({
- alert_words: ['foo', 'bar'],
+ alert_words: ["foo", "bar"],
});
-run_test('render_alert_words_ui', () => {
- const word_list = $('#alert_words_list');
+run_test("render_alert_words_ui", () => {
+ const word_list = $("#alert_words_list");
const appended = [];
word_list.append = (rendered) => {
appended.push(rendered);
};
- const alert_word_items = $.create('alert_word_items');
- word_list.set_find_results('.alert-word-item', alert_word_items);
+ const alert_word_items = $.create("alert_word_items");
+ word_list.set_find_results(".alert-word-item", alert_word_items);
global.stub_templates((name, args) => {
- assert.equal(name, 'settings/alert_word_settings_item');
- return 'stub-' + args.word;
+ assert.equal(name, "settings/alert_word_settings_item");
+ return "stub-" + args.word;
});
- const new_alert_word = $('#create_alert_word_name');
+ const new_alert_word = $("#create_alert_word_name");
assert(!new_alert_word.is_focused());
alert_words_ui.render_alert_words_ui();
assert.deepEqual(appended, [
- 'stub-bar',
- 'stub-foo',
+ "stub-bar",
+ "stub-foo",
]);
assert(new_alert_word.is_focused());
});
-run_test('add_alert_word', () => {
+run_test("add_alert_word", () => {
alert_words_ui.render_alert_words_ui = () => {}; // we've already tested this above
alert_words_ui.set_up_alert_words();
- const create_form = $('#create_alert_word_form');
- const add_func = create_form.get_on_handler('click', '#create_alert_word_button');
+ const create_form = $("#create_alert_word_form");
+ const add_func = create_form.get_on_handler("click", "#create_alert_word_button");
- const new_alert_word = $('#create_alert_word_name');
- const alert_word_status = $('#alert_word_status');
- const alert_word_status_text = $('.alert_word_status_text');
- alert_word_status.set_find_results('.alert_word_status_text', alert_word_status_text);
+ const new_alert_word = $("#create_alert_word_name");
+ const alert_word_status = $("#alert_word_status");
+ const alert_word_status_text = $(".alert_word_status_text");
+ alert_word_status.set_find_results(".alert_word_status_text", alert_word_status_text);
// add '' as alert word
add_func();
- assert.equal(new_alert_word.val(), '');
- assert(alert_word_status.hasClass('alert-danger'));
+ assert.equal(new_alert_word.val(), "");
+ assert(alert_word_status.hasClass("alert-danger"));
assert.equal(alert_word_status_text.text(), "translated: Alert word can't be empty!");
assert(alert_word_status.visible());
// add 'foo' as alert word (existing word)
- new_alert_word.val('foo');
+ new_alert_word.val("foo");
add_func();
- assert(alert_word_status.hasClass('alert-danger'));
+ assert(alert_word_status.hasClass("alert-danger"));
assert.equal(alert_word_status_text.text(), "translated: Alert word already exists!");
assert(alert_word_status.visible());
// add 'zot' as alert word (new word)
- new_alert_word.val('zot');
+ new_alert_word.val("zot");
let success_func;
let fail_func;
channel.post = (opts) => {
- assert.equal(opts.url, '/json/users/me/alert_words');
+ assert.equal(opts.url, "/json/users/me/alert_words");
assert.deepEqual(opts.data, {alert_words: '["zot"]'});
success_func = opts.success;
fail_func = opts.error;
@@ -80,28 +80,28 @@ run_test('add_alert_word', () => {
// test failure
fail_func();
- assert(alert_word_status.hasClass('alert-danger'));
+ assert(alert_word_status.hasClass("alert-danger"));
assert.equal(alert_word_status_text.text(), "translated: Error adding alert word!");
assert(alert_word_status.visible());
// test success
success_func();
- assert(alert_word_status.hasClass('alert-success'));
+ assert(alert_word_status.hasClass("alert-success"));
assert.equal(alert_word_status_text.text(), "translated: Alert word \"zot\" added successfully!");
assert(alert_word_status.visible());
});
-run_test('add_alert_word_keypress', () => {
- const create_form = $('#create_alert_word_form');
- const keypress_func = create_form.get_on_handler('keypress', '#create_alert_word_name');
+run_test("add_alert_word_keypress", () => {
+ const create_form = $("#create_alert_word_form");
+ const keypress_func = create_form.get_on_handler("keypress", "#create_alert_word_name");
- const new_alert_word = $('#create_alert_word_name');
- new_alert_word.val('zot');
+ const new_alert_word = $("#create_alert_word_name");
+ new_alert_word.val("zot");
const event = {
preventDefault: () => {},
which: 13,
- target: '#create_alert_word_name',
+ target: "#create_alert_word_name",
};
let called = false;
@@ -114,26 +114,26 @@ run_test('add_alert_word_keypress', () => {
assert(called);
});
-run_test('remove_alert_word', () => {
- const word_list = $('#alert_words_list');
- const remove_func = word_list.get_on_handler('click', '.remove-alert-word');
+run_test("remove_alert_word", () => {
+ const word_list = $("#alert_words_list");
+ const remove_func = word_list.get_on_handler("click", ".remove-alert-word");
- const remove_alert_word = $('.remove-alert-word');
- const list_item = $('li.alert-word-item');
- const val_item = $('span.value');
- val_item.text(i18n.t('zot'));
+ const remove_alert_word = $(".remove-alert-word");
+ const list_item = $("li.alert-word-item");
+ const val_item = $("span.value");
+ val_item.text(i18n.t("zot"));
- remove_alert_word.set_parents_result('li', list_item);
- list_item.set_find_results('.value', val_item);
+ remove_alert_word.set_parents_result("li", list_item);
+ list_item.set_find_results(".value", val_item);
const event = {
- currentTarget: '.remove-alert-word',
+ currentTarget: ".remove-alert-word",
};
let success_func;
let fail_func;
channel.del = (opts) => {
- assert.equal(opts.url, '/json/users/me/alert_words');
+ assert.equal(opts.url, "/json/users/me/alert_words");
assert.deepEqual(opts.data, {alert_words: '["translated: zot"]'});
success_func = opts.success;
fail_func = opts.error;
@@ -141,36 +141,36 @@ run_test('remove_alert_word', () => {
remove_func(event);
- const alert_word_status = $('#alert_word_status');
- const alert_word_status_text = $('.alert_word_status_text');
- alert_word_status.set_find_results('.alert_word_status_text', alert_word_status_text);
+ const alert_word_status = $("#alert_word_status");
+ const alert_word_status_text = $(".alert_word_status_text");
+ alert_word_status.set_find_results(".alert_word_status_text", alert_word_status_text);
// test failure
fail_func();
- assert(alert_word_status.hasClass('alert-danger'));
+ assert(alert_word_status.hasClass("alert-danger"));
assert.equal(alert_word_status_text.text(), "translated: Error removing alert word!");
assert(alert_word_status.visible());
// test success
success_func();
- assert(alert_word_status.hasClass('alert-success'));
+ assert(alert_word_status.hasClass("alert-success"));
assert.equal(alert_word_status_text.text(), "translated: Alert word removed successfully!");
assert(alert_word_status.visible());
});
-run_test('close_status_message', () => {
- const alert_word_settings = $('#alert-word-settings');
- const close = alert_word_settings.get_on_handler('click', '.close-alert-word-status');
+run_test("close_status_message", () => {
+ const alert_word_settings = $("#alert-word-settings");
+ const close = alert_word_settings.get_on_handler("click", ".close-alert-word-status");
- const alert = $('.alert');
- const close_btn = $('.close-alert-word-status');
- close_btn.set_parents_result('.alert', alert);
+ const alert = $(".alert");
+ const close_btn = $(".close-alert-word-status");
+ close_btn.set_parents_result(".alert", alert);
alert.show();
const event = {
preventDefault: () => {},
- currentTarget: '.close-alert-word-status',
+ currentTarget: ".close-alert-word-status",
};
assert(alert.visible());
diff --git a/frontend_tests/node_tests/billing.js b/frontend_tests/node_tests/billing.js
index a4f143ef182..a6b95e12768 100644
--- a/frontend_tests/node_tests/billing.js
+++ b/frontend_tests/node_tests/billing.js
@@ -8,15 +8,15 @@ const document = dom.window.document;
let jquery_init;
global.$ = (f) => {jquery_init = f;};
-set_global('helpers', {
+set_global("helpers", {
set_tab: noop,
});
-set_global('StripeCheckout', {
+set_global("StripeCheckout", {
configure: noop,
});
-zrequire('billing', "js/billing/billing");
-set_global('$', global.make_zjquery());
+zrequire("billing", "js/billing/billing");
+set_global("$", global.make_zjquery());
run_test("initialize", () => {
let token_func;
@@ -51,9 +51,9 @@ run_test("initialize", () => {
let stripe_checkout_configure_called = false;
StripeCheckout.configure = (config_opts) => {
- assert.equal(config_opts.image, '/static/images/logo/zulip-icon-128x128.png');
- assert.equal(config_opts.locale, 'auto');
- assert.equal(config_opts.key, '{{publishable_key}}');
+ assert.equal(config_opts.image, "/static/images/logo/zulip-icon-128x128.png");
+ assert.equal(config_opts.locale, "auto");
+ assert.equal(config_opts.key, "{{publishable_key}}");
token_func = config_opts.token;
stripe_checkout_configure_called = true;
@@ -71,7 +71,7 @@ run_test("initialize", () => {
const e = {
preventDefault: noop,
};
- const update_card_click_handler = $('#update-card-button').get_on_handler('click');
+ const update_card_click_handler = $("#update-card-button").get_on_handler("click");
update_card_click_handler(e);
assert(create_ajax_request_called);
assert(open_func_called);
@@ -85,7 +85,7 @@ run_test("initialize", () => {
create_ajax_request_called = true;
};
- const change_plan_status_click_handler = $('#change-plan-status').get_on_handler('click');
+ const change_plan_status_click_handler = $("#change-plan-status").get_on_handler("click");
change_plan_status_click_handler(e);
assert(create_ajax_request_called);
});
diff --git a/frontend_tests/node_tests/billing_helpers.js b/frontend_tests/node_tests/billing_helpers.js
index d19cdbf6c9d..0caa97988ed 100644
--- a/frontend_tests/node_tests/billing_helpers.js
+++ b/frontend_tests/node_tests/billing_helpers.js
@@ -2,24 +2,24 @@ const { JSDOM } = require("jsdom");
const fs = require("fs");
const template = fs.readFileSync("templates/corporate/upgrade.html", "utf-8");
const dom = new JSDOM(template, { pretendToBeVisual: true });
-const jquery = require('jquery')(dom.window);
+const jquery = require("jquery")(dom.window);
-set_global('$', global.make_zjquery());
-set_global('page_params', {});
-set_global('loading', {});
-set_global('history', {});
-set_global('document', {
+set_global("$", global.make_zjquery());
+set_global("page_params", {});
+set_global("loading", {});
+set_global("history", {});
+set_global("document", {
title: "Zulip",
});
-set_global('location', {
+set_global("location", {
pathname: "/upgrade/",
search: "",
hash: "#billing",
});
-zrequire('helpers', "js/billing/helpers");
+zrequire("helpers", "js/billing/helpers");
-run_test('create_ajax_request', () => {
+run_test("create_ajax_request", () => {
const form_loading_indicator = "#autopay_loading_indicator";
const form_input_section = "#autopay-input-section";
const form_success = "#autopay-success";
@@ -124,7 +124,7 @@ run_test('create_ajax_request', () => {
assert.equal(data.billing_modality, '"charge_automatically"');
assert.equal(data.schedule, '"monthly"');
assert.equal(data.license_management, '"automatic"');
- assert.equal(data.licenses, '');
+ assert.equal(data.licenses, "");
history.pushState = (state_object, title, path) => {
state.pushState += 1;
@@ -224,8 +224,8 @@ run_test("show_license_section", () => {
assert.equal(state.hide_license_manual_section, 1);
assert.equal(state.show_license_automatic_section, 1);
assert.equal(state.show_license_manual_section, 0);
- assert.equal($("#automatic_license_count").prop('disabled'), false);
- assert.equal($("#manual_license_count").prop('disabled'), true);
+ assert.equal($("#automatic_license_count").prop("disabled"), false);
+ assert.equal($("#manual_license_count").prop("disabled"), true);
helpers.show_license_section("manual");
@@ -233,8 +233,8 @@ run_test("show_license_section", () => {
assert.equal(state.hide_license_manual_section, 2);
assert.equal(state.show_license_automatic_section, 1);
assert.equal(state.show_license_manual_section, 1);
- assert.equal($("#automatic_license_count").prop('disabled'), true);
- assert.equal($("#manual_license_count").prop('disabled'), false);
+ assert.equal($("#automatic_license_count").prop("disabled"), true);
+ assert.equal($("#manual_license_count").prop("disabled"), false);
});
run_test("set_tab", () => {
diff --git a/frontend_tests/node_tests/bot_data.js b/frontend_tests/node_tests/bot_data.js
index df99d7b7cf4..2d7adfe9f77 100644
--- a/frontend_tests/node_tests/bot_data.js
+++ b/frontend_tests/node_tests/bot_data.js
@@ -2,20 +2,20 @@ const _settings_bots = {
render_bots: () => {},
};
-set_global('settings_bots', _settings_bots);
+set_global("settings_bots", _settings_bots);
-zrequire('bot_data');
-zrequire('people');
+zrequire("bot_data");
+zrequire("people");
const me = {
- email: '[email protected]',
- full_name: 'Me Myself',
+ email: "[email protected]",
+ full_name: "Me Myself",
user_id: 2,
};
const fred = {
- email: '[email protected]',
- full_name: 'Fred Frederickson',
+ email: "[email protected]",
+ full_name: "Fred Frederickson",
user_id: 3,
};
@@ -24,36 +24,36 @@ 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',
+ realm_bots: [{email: "[email protected]", user_id: 42, full_name: "Bot 0",
services: []},
- {email: '[email protected]', user_id: 314, full_name: "Outgoing webhook",
+ {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');
-assert.equal(bot_data.get(314).full_name, 'Outgoing webhook');
+assert.equal(bot_data.get(42).full_name, "Bot 0");
+assert.equal(bot_data.get(314).full_name, "Outgoing webhook");
-run_test('test_basics', () => {
+run_test("test_basics", () => {
const test_bot = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 43,
- avatar_url: '',
- full_name: 'Bot 1',
+ avatar_url: "",
+ full_name: "Bot 1",
services: [{base_url: "http://bar.com", interface: 1}],
- extra: 'Not in data',
+ extra: "Not in data",
};
const test_embedded_bot = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 143,
- avatar_url: '',
- full_name: 'Embedded bot 1',
- services: [{config_data: {key: '12345678'},
+ avatar_url: "",
+ full_name: "Embedded bot 1",
+ services: [{config_data: {key: "12345678"},
service_name: "giphy"}],
- owner: '[email protected]',
+ owner: "[email protected]",
};
(function test_add() {
@@ -61,8 +61,8 @@ run_test('test_basics', () => {
const bot = bot_data.get(43);
const services = bot_data.get_services(43);
- assert.equal('Bot 1', bot.full_name);
- assert.equal('http://bar.com', services[0].base_url);
+ assert.equal("Bot 1", bot.full_name);
+ assert.equal("http://bar.com", services[0].base_url);
assert.equal(1, services[0].interface);
assert.equal(undefined, bot.extra);
}());
@@ -71,15 +71,15 @@ run_test('test_basics', () => {
bot_data.add(test_bot);
let bot = bot_data.get(43);
- assert.equal('Bot 1', bot.full_name);
- bot_data.update(43, {full_name: 'New Bot 1',
+ assert.equal("Bot 1", bot.full_name);
+ bot_data.update(43, {full_name: "New Bot 1",
services: [{interface: 2,
- base_url: 'http://baz.com'}]});
+ 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);
+ assert.equal("New Bot 1", bot.full_name);
assert.equal(2, services[0].interface);
- assert.equal('http://baz.com', services[0].base_url);
+ assert.equal("http://baz.com", services[0].base_url);
const change_owner_event = {
owner_id: fred.user_id,
@@ -94,9 +94,9 @@ run_test('test_basics', () => {
bot_data.add(test_embedded_bot);
const bot_id = 143;
const services = bot_data.get_services(bot_id);
- assert.equal('12345678', services[0].config_data.key);
- bot_data.update(bot_id, {services: [{config_data: {key: '87654321'}}]});
- assert.equal('87654321', services[0].config_data.key);
+ assert.equal("12345678", services[0].config_data.key);
+ bot_data.update(bot_id, {services: [{config_data: {key: "87654321"}}]});
+ assert.equal("87654321", services[0].config_data.key);
}());
(function test_remove() {
@@ -105,7 +105,7 @@ run_test('test_basics', () => {
bot_data.add({ ...test_bot, is_active: true });
bot = bot_data.get(43);
- assert.equal('Bot 1', bot.full_name);
+ assert.equal("Bot 1", bot.full_name);
assert(bot.is_active);
bot_data.deactivate(43);
bot = bot_data.get(43);
@@ -124,7 +124,7 @@ run_test('test_basics', () => {
bot_data.add({ ...test_bot, is_active: true });
bot = bot_data.get(43);
- assert.equal('Bot 1', bot.full_name);
+ assert.equal("Bot 1", bot.full_name);
assert(bot.is_active);
bot_data.del(43);
bot = bot_data.get(43);
@@ -134,18 +134,18 @@ 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);
+ assert.deepEqual(["[email protected]", "[email protected]"], editable_bots);
}());
(function test_get_all_bots_for_current_user() {
const bots = bot_data.get_all_bots_for_current_user();
assert.equal(bots.length, 2);
- assert.equal(bots[0].email, '[email protected]');
- assert.equal(bots[1].email, '[email protected]');
+ assert.equal(bots[0].email, "[email protected]");
+ assert.equal(bots[1].email, "[email protected]");
}());
});
diff --git a/frontend_tests/node_tests/buddy_data.js b/frontend_tests/node_tests/buddy_data.js
index 57379702acb..e63b139881a 100644
--- a/frontend_tests/node_tests/buddy_data.js
+++ b/frontend_tests/node_tests/buddy_data.js
@@ -1,13 +1,13 @@
const _page_params = {};
-set_global('page_params', _page_params);
-set_global('$', global.make_zjquery());
-zrequire('people');
-zrequire('presence');
-zrequire('user_status');
+set_global("page_params", _page_params);
+set_global("$", global.make_zjquery());
+zrequire("people");
+zrequire("presence");
+zrequire("user_status");
-zrequire('buddy_data');
-set_global('timerender', {});
+zrequire("buddy_data");
+set_global("timerender", {});
// The buddy_data module is mostly tested indirectly through
// activity.js, but we should feel free to add direct tests
@@ -15,61 +15,61 @@ set_global('timerender', {});
const selma = {
user_id: 1000,
- full_name: 'Human Selma',
- email: '[email protected]',
+ full_name: "Human Selma",
+ email: "[email protected]",
};
const me = {
user_id: 1001,
- full_name: 'Human Myself',
- email: '[email protected]',
+ full_name: "Human Myself",
+ email: "[email protected]",
};
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 1002,
- full_name: 'Alice Smith',
+ full_name: "Alice Smith",
};
const fred = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 1003,
full_name: "Fred Flintstone",
};
const jill = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 1004,
- full_name: 'Jill Hill',
+ full_name: "Jill Hill",
};
const mark = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 1005,
- full_name: 'Marky Mark',
+ full_name: "Marky Mark",
};
const old_user = {
user_id: 9999,
- full_name: 'Old User',
- email: '[email protected]',
+ full_name: "Old User",
+ email: "[email protected]",
};
const bot = {
user_id: 55555,
- full_name: 'Red Herring Bot',
- email: '[email protected]',
+ full_name: "Red Herring Bot",
+ email: "[email protected]",
is_bot: true,
bot_owner_id: null,
};
const bot_with_owner = {
user_id: 55556,
- full_name: 'Blue Herring Bot',
- email: '[email protected]',
+ full_name: "Blue Herring Bot",
+ email: "[email protected]",
is_bot: true,
bot_owner_id: 1001,
- bot_owner_full_name: 'Human Myself',
+ bot_owner_full_name: "Human Myself",
};
function make_people() {
@@ -100,15 +100,15 @@ function make_people() {
make_people();
-run_test('huddle_fraction_present', () => {
+run_test("huddle_fraction_present", () => {
huddle = people.emails_strings_to_user_ids_string(huddle);
let presence_info = new Map();
- presence_info.set(alice.user_id, { status: 'active' }); // counts as present
- presence_info.set(fred.user_id, { status: 'idle' }); // does not count as present
+ presence_info.set(alice.user_id, { status: "active" }); // counts as present
+ presence_info.set(fred.user_id, { status: "idle" }); // does not count as present
// jill not in list
- presence_info.set(mark.user_id, { status: 'offline' }); // does not count
+ presence_info.set(mark.user_id, { status: "offline" }); // does not count
presence.presence_info = presence_info;
assert.equal(
@@ -117,7 +117,7 @@ run_test('huddle_fraction_present', () => {
presence_info = new Map();
for (const user of [alice, fred, jill, mark]) {
- presence_info.set(user.user_id, { status: 'active' }); // counts as present
+ presence_info.set(user.user_id, { status: "active" }); // counts as present
}
presence.presence_info = presence_info;
@@ -125,13 +125,13 @@ run_test('huddle_fraction_present', () => {
buddy_data.huddle_fraction_present(huddle),
1);
huddle = people.emails_strings_to_user_ids_string(huddle);
presence_info = new Map();
- presence_info.set(alice.user_id, { status: 'idle' });
- presence_info.set(fred.user_id, { status: 'idle' }); // does not count as present
+ presence_info.set(alice.user_id, { status: "idle" });
+ presence_info.set(fred.user_id, { status: "idle" }); // does not count as present
// jill not in list
- presence_info.set(mark.user_id, { status: 'offline' }); // does not count
+ presence_info.set(mark.user_id, { status: "offline" }); // does not count
presence.presence_info = presence_info;
assert.equal(
@@ -150,108 +150,108 @@ function activate_people() {
}
// Make 400 of the users active
- set_presence(selma.user_id, 'active');
- set_presence(me.user_id, 'active');
+ set_presence(selma.user_id, "active");
+ set_presence(me.user_id, "active");
for (const user_id of _.range(1000, 1400)) {
- set_presence(user_id, 'active');
+ set_presence(user_id, "active");
}
// And then 300 not active
for (const user_id of _.range(1400, 1700)) {
- set_presence(user_id, 'offline');
+ set_presence(user_id, "offline");
}
}
activate_people();
-run_test('user_circle', () => {
- assert.equal(buddy_data.get_user_circle_class(selma.user_id), 'user_circle_green');
+run_test("user_circle", () => {
+ assert.equal(buddy_data.get_user_circle_class(selma.user_id), "user_circle_green");
user_status.set_away(selma.user_id);
- assert.equal(buddy_data.get_user_circle_class(selma.user_id), 'user_circle_empty_line');
+ assert.equal(buddy_data.get_user_circle_class(selma.user_id), "user_circle_empty_line");
user_status.revoke_away(selma.user_id);
- assert.equal(buddy_data.get_user_circle_class(selma.user_id), 'user_circle_green');
+ assert.equal(buddy_data.get_user_circle_class(selma.user_id), "user_circle_green");
- assert.equal(buddy_data.get_user_circle_class(me.user_id), 'user_circle_green');
+ assert.equal(buddy_data.get_user_circle_class(me.user_id), "user_circle_green");
user_status.set_away(me.user_id);
- assert.equal(buddy_data.get_user_circle_class(me.user_id), 'user_circle_empty_line');
+ assert.equal(buddy_data.get_user_circle_class(me.user_id), "user_circle_empty_line");
user_status.revoke_away(me.user_id);
- assert.equal(buddy_data.get_user_circle_class(me.user_id), 'user_circle_green');
+ assert.equal(buddy_data.get_user_circle_class(me.user_id), "user_circle_green");
});
-run_test('buddy_status', () => {
- assert.equal(buddy_data.buddy_status(selma.user_id), 'active');
+run_test("buddy_status", () => {
+ assert.equal(buddy_data.buddy_status(selma.user_id), "active");
user_status.set_away(selma.user_id);
- assert.equal(buddy_data.buddy_status(selma.user_id), 'away_them');
+ assert.equal(buddy_data.buddy_status(selma.user_id), "away_them");
user_status.revoke_away(selma.user_id);
- assert.equal(buddy_data.buddy_status(selma.user_id), 'active');
+ assert.equal(buddy_data.buddy_status(selma.user_id), "active");
- assert.equal(buddy_data.buddy_status(me.user_id), 'active');
+ assert.equal(buddy_data.buddy_status(me.user_id), "active");
user_status.set_away(me.user_id);
- assert.equal(buddy_data.buddy_status(me.user_id), 'away_me');
+ assert.equal(buddy_data.buddy_status(me.user_id), "away_me");
user_status.revoke_away(me.user_id);
- assert.equal(buddy_data.buddy_status(me.user_id), 'active');
+ assert.equal(buddy_data.buddy_status(me.user_id), "active");
});
-run_test('title_data', () => {
+run_test("title_data", () => {
// Groups
let is_group = true;
const user_ids_string = "9999,1000";
let expected_group_data = {
- first_line: 'Human Selma, Old User',
- second_line: '',
- third_line: '',
+ first_line: "Human Selma, Old User",
+ second_line: "",
+ third_line: "",
};
assert.deepEqual(buddy_data.get_title_data(user_ids_string, is_group), expected_group_data);
- is_group = '';
+ is_group = "";
// Bots with owners.
expected_group_data = {
- first_line: 'Blue Herring Bot',
- second_line: 'translated: Owner: Human Myself',
- third_line: '',
+ first_line: "Blue Herring Bot",
+ 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);
// Bots without owners.
expected_group_data = {
- first_line: 'Red Herring Bot',
- second_line: '',
- third_line: '',
+ first_line: "Red Herring Bot",
+ second_line: "",
+ third_line: "",
};
assert.deepEqual(buddy_data.get_title_data(bot.user_id, is_group), expected_group_data);
// Individual Users.
user_status.set_status_text({
user_id: me.user_id,
- status_text: 'out to lunch',
+ status_text: "out to lunch",
});
let expected_data = {
- first_line: 'Human Myself',
- second_line: 'out to lunch',
- third_line: 'translated: Active now',
+ 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);
expected_data = {
- first_line: 'Old User',
- second_line: 'translated: Last active: translated: More than 2 weeks ago',
- third_line: '',
+ first_line: "Old User",
+ second_line: "translated: Last active: translated: More than 2 weeks ago",
+ third_line: "",
};
assert.deepEqual(buddy_data.get_title_data(old_user.user_id, is_group), expected_data);
});
-run_test('simple search', () => {
- const user_ids = buddy_data.get_filtered_and_sorted_user_ids('sel');
+run_test("simple search", () => {
+ const user_ids = buddy_data.get_filtered_and_sorted_user_ids("sel");
assert.deepEqual(user_ids, [selma.user_id]);
});
-run_test('bulk_data_hacks', () => {
+run_test("bulk_data_hacks", () => {
let user_ids;
// Even though we have 1000 users, we only get the 400 active
@@ -259,40 +259,40 @@ run_test('bulk_data_hacks', () => {
user_ids = buddy_data.get_filtered_and_sorted_user_ids();
assert.equal(user_ids.length, 400);
- user_ids = buddy_data.get_filtered_and_sorted_user_ids('');
+ user_ids = buddy_data.get_filtered_and_sorted_user_ids("");
assert.equal(user_ids.length, 400);
// We don't match on "so", because it's not at the start of a
// word in the name/email.
- user_ids = buddy_data.get_filtered_and_sorted_user_ids('so');
+ user_ids = buddy_data.get_filtered_and_sorted_user_ids("so");
assert.equal(user_ids.length, 0);
// We match on "h" for the first name, and the result limit
// is relaxed for searches. (We exclude "me", though.)
- user_ids = buddy_data.get_filtered_and_sorted_user_ids('h');
+ user_ids = buddy_data.get_filtered_and_sorted_user_ids("h");
assert.equal(user_ids.length, 996);
// We match on "p" for the email.
- user_ids = buddy_data.get_filtered_and_sorted_user_ids('p');
+ user_ids = buddy_data.get_filtered_and_sorted_user_ids("p");
assert.equal(user_ids.length, 994);
// Make our shrink limit higher, and go back to an empty search.
// We won't get all 1000 users, just the present ones.
buddy_data.max_size_before_shrinking = 50000;
- user_ids = buddy_data.get_filtered_and_sorted_user_ids('');
+ user_ids = buddy_data.get_filtered_and_sorted_user_ids("");
assert.equal(user_ids.length, 700);
});
-run_test('level', () => {
- assert.equal(buddy_data.my_user_status(me.user_id), 'translated: (you)');
+run_test("level", () => {
+ assert.equal(buddy_data.my_user_status(me.user_id), "translated: (you)");
user_status.set_away(me.user_id);
- assert.equal(buddy_data.my_user_status(me.user_id), 'translated: (unavailable)');
+ assert.equal(buddy_data.my_user_status(me.user_id), "translated: (unavailable)");
user_status.revoke_away(me.user_id);
- assert.equal(buddy_data.my_user_status(me.user_id), 'translated: (you)');
+ assert.equal(buddy_data.my_user_status(me.user_id), "translated: (you)");
});
-run_test('level', () => {
+run_test("level", () => {
presence.presence_info.clear();
assert.equal(buddy_data.level(me.user_id), 0);
assert.equal(buddy_data.level(selma.user_id), 3);
@@ -319,38 +319,38 @@ run_test('level', () => {
assert.equal(buddy_data.level(selma.user_id), 3);
});
-run_test('user_last_seen_time_status', () => {
+run_test("user_last_seen_time_status", () => {
assert.equal(buddy_data.user_last_seen_time_status(selma.user_id),
- 'translated: Active now');
+ "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');
+ "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');
+ "translated: More than 2 weeks ago");
presence.last_active_date = (user_id) => {
assert.equal(user_id, old_user.user_id);
return {
- clone: () => 'date-stub',
+ clone: () => "date-stub",
};
};
timerender.last_seen_status_from_date = (date) => {
- assert.equal(date, 'date-stub');
- return 'May 12';
+ assert.equal(date, "date-stub");
+ return "May 12";
};
assert.equal(buddy_data.user_last_seen_time_status(old_user.user_id),
- 'May 12');
+ "May 12");
});
-run_test('error handling', () => {
+run_test("error handling", () => {
presence.get_user_ids = () => [42];
- blueslip.expect('error', 'Unknown user_id in get_by_user_id: 42');
- blueslip.expect('warn', 'Got user_id in presence but not people: 42');
+ blueslip.expect("error", "Unknown user_id in get_by_user_id: 42");
+ blueslip.expect("warn", "Got user_id in presence but not people: 42");
buddy_data.get_filtered_and_sorted_user_ids();
});
diff --git a/frontend_tests/node_tests/buddy_list.js b/frontend_tests/node_tests/buddy_list.js
index 1fc3e92ad61..b34f26d2d32 100644
--- a/frontend_tests/node_tests/buddy_list.js
+++ b/frontend_tests/node_tests/buddy_list.js
@@ -1,15 +1,15 @@
-set_global('$', global.make_zjquery());
-zrequire('people');
-zrequire('buddy_data');
-zrequire('buddy_list');
-zrequire('ui');
+set_global("$", global.make_zjquery());
+zrequire("people");
+zrequire("buddy_data");
+zrequire("buddy_list");
+zrequire("ui");
-set_global('padded_widget', {
+set_global("padded_widget", {
update_padding: () => {},
});
function init_simulated_scrolling() {
- set_global('message_viewport', {
+ set_global("message_viewport", {
height: () => 550,
});
@@ -19,23 +19,23 @@ function init_simulated_scrolling() {
scrollHeight: 0,
};
- $('#buddy_list_wrapper')[0] = elem;
+ $("#buddy_list_wrapper")[0] = elem;
- $('#buddy_list_wrapper_padding').height = () => 0;
+ $("#buddy_list_wrapper_padding").height = () => 0;
return elem;
}
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 10,
- full_name: 'Alice Smith',
+ full_name: "Alice Smith",
};
people.add_active_user(alice);
-run_test('get_items', () => {
- const alice_li = $.create('alice stub');
- const sel = 'li.user_sidebar_entry';
+run_test("get_items", () => {
+ const alice_li = $.create("alice stub");
+ const sel = "li.user_sidebar_entry";
buddy_list.container.set_find_results(sel, {
map: (f) => [f(0, alice_li)],
@@ -45,26 +45,26 @@ run_test('get_items', () => {
assert.deepEqual(items, [alice_li]);
});
-run_test('basics', () => {
+run_test("basics", () => {
init_simulated_scrolling();
buddy_list.get_data_from_keys = (opts) => {
const keys = opts.keys;
assert.deepEqual(keys, [alice.user_id]);
- return 'data-stub';
+ return "data-stub";
};
buddy_list.items_to_html = (opts) => {
const items = opts.items;
- assert.equal(items, 'data-stub');
+ assert.equal(items, "data-stub");
- return 'html-stub';
+ return "html-stub";
};
let appended;
buddy_list.container.append = (html) => {
- assert.equal(html, 'html-stub');
+ assert.equal(html, "html-stub");
appended = true;
};
@@ -73,7 +73,7 @@ run_test('basics', () => {
});
assert(appended);
- const alice_li = $.create('alice-li-stub');
+ const alice_li = $.create("alice-li-stub");
alice_li.length = 1;
buddy_list.get_li_from_key = (opts) => {
@@ -89,7 +89,7 @@ run_test('basics', () => {
assert.equal(li, alice_li);
});
-run_test('big_list', () => {
+run_test("big_list", () => {
const elem = init_simulated_scrolling();
// Don't actually render, but do simulate filling up
@@ -108,9 +108,9 @@ run_test('big_list', () => {
_.times(num_users, (i) => {
const person = {
- email: 'foo' + i + '@zulip.com',
+ email: "foo" + i + "@zulip.com",
user_id: 100 + i,
- full_name: 'Somebody ' + i,
+ full_name: "Somebody " + i,
};
people.add_active_user(person);
user_ids.push(person.user_id);
@@ -123,7 +123,7 @@ run_test('big_list', () => {
assert.equal(chunks_inserted, 6);
});
-run_test('force_render', () => {
+run_test("force_render", () => {
buddy_list.render_count = 50;
let num_rendered = 0;
@@ -138,18 +138,18 @@ run_test('force_render', () => {
assert.equal(num_rendered, 60 - 50 + 3);
// Force a contrived error case for line coverage.
- blueslip.expect('error', 'cannot show key at this position: 10');
+ blueslip.expect("error", "cannot show key at this position: 10");
buddy_list.force_render({
pos: 10,
});
});
-run_test('find_li w/force_render', () => {
+run_test("find_li w/force_render", () => {
// If we call find_li w/force_render set, and the
// key is not already rendered in DOM, then the
// widget will call show_key to force-render it.
- const key = '999';
- const stub_li = $.create('nada');
+ const key = "999";
+ const stub_li = $.create("nada");
stub_li.length = 0;
@@ -159,7 +159,7 @@ run_test('find_li w/force_render', () => {
};
buddy_list.keys = [
- 'foo', 'bar', key, 'baz',
+ "foo", "bar", key, "baz",
];
let shown;
@@ -186,7 +186,7 @@ run_test('find_li w/force_render', () => {
buddy_list.get_li_from_key = () => ({length: 0});
const undefined_li = buddy_list.find_li({
- key: 'not-there',
+ key: "not-there",
force_render: true,
});
@@ -194,7 +194,7 @@ run_test('find_li w/force_render', () => {
assert.equal(undefined_li.length, 0);
});
-run_test('scrolling', () => {
+run_test("scrolling", () => {
let scroll_f;
$(buddy_list.scroll_container_sel).scroll = (f) => {
diff --git a/frontend_tests/node_tests/channel.js b/frontend_tests/node_tests/channel.js
index 0967fa1ff3b..b5db9d688cc 100644
--- a/frontend_tests/node_tests/channel.js
+++ b/frontend_tests/node_tests/channel.js
@@ -1,10 +1,10 @@
-set_global('$', {});
+set_global("$", {});
-set_global('reload', {});
-zrequire('reload_state');
-zrequire('channel');
+set_global("reload", {});
+zrequire("reload_state");
+zrequire("channel");
-const default_stub_xhr = 'default-stub-xhr';
+const default_stub_xhr = "default-stub-xhr";
function test_with_mock_ajax(test_params) {
const {
@@ -36,15 +36,15 @@ function test_with_mock_ajax(test_params) {
check_ajax_options(ajax_options);
}
-run_test('basics', () => {
+run_test("basics", () => {
test_with_mock_ajax({
run_code: function () {
channel.post({});
},
check_ajax_options: function (options) {
- assert.equal(options.type, 'POST');
- assert.equal(options.dataType, 'json');
+ assert.equal(options.type, "POST");
+ assert.equal(options.dataType, "json");
// Just make sure these don't explode.
options.simulate_success();
@@ -58,9 +58,9 @@ run_test('basics', () => {
},
check_ajax_options: function (options) {
- assert.equal(options.type, 'POST');
- assert.equal(options.data.method, 'PATCH');
- assert.equal(options.dataType, 'json');
+ assert.equal(options.type, "POST");
+ assert.equal(options.data.method, "PATCH");
+ assert.equal(options.dataType, "json");
// Just make sure these don't explode.
options.simulate_success();
@@ -74,8 +74,8 @@ run_test('basics', () => {
},
check_ajax_options: function (options) {
- assert.equal(options.type, 'PUT');
- assert.equal(options.dataType, 'json');
+ assert.equal(options.type, "PUT");
+ assert.equal(options.dataType, "json");
// Just make sure these don't explode.
options.simulate_success();
@@ -89,8 +89,8 @@ run_test('basics', () => {
},
check_ajax_options: function (options) {
- assert.equal(options.type, 'DELETE');
- assert.equal(options.dataType, 'json');
+ assert.equal(options.type, "DELETE");
+ assert.equal(options.dataType, "json");
// Just make sure these don't explode.
options.simulate_success();
@@ -104,8 +104,8 @@ run_test('basics', () => {
},
check_ajax_options: function (options) {
- assert.equal(options.type, 'GET');
- assert.equal(options.dataType, 'json');
+ assert.equal(options.type, "GET");
+ assert.equal(options.dataType, "json");
// Just make sure these don't explode.
options.simulate_success();
@@ -115,16 +115,16 @@ run_test('basics', () => {
});
-run_test('normal_post', () => {
+run_test("normal_post", () => {
const data = {
- s: 'some_string',
+ s: "some_string",
num: 7,
lst: [1, 2, 4, 8],
};
let orig_success_called;
let orig_error_called;
- const stub_xhr = 'stub-xhr-normal-post';
+ const stub_xhr = "stub-xhr-normal-post";
test_with_mock_ajax({
xhr: stub_xhr,
@@ -132,11 +132,11 @@ run_test('normal_post', () => {
run_code: function () {
channel.post({
data: data,
- url: '/json/endpoint',
+ url: "/json/endpoint",
success: function (data, text_status, xhr) {
orig_success_called = true;
- assert.equal(data, 'response data');
- assert.equal(text_status, 'success');
+ assert.equal(data, "response data");
+ assert.equal(text_status, "success");
assert.equal(xhr, stub_xhr);
},
error: function () {
@@ -146,12 +146,12 @@ run_test('normal_post', () => {
},
check_ajax_options: function (options) {
- assert.equal(options.type, 'POST');
- assert.equal(options.dataType, 'json');
+ assert.equal(options.type, "POST");
+ assert.equal(options.dataType, "json");
assert.deepEqual(options.data, data);
- assert.equal(options.url, '/json/endpoint');
+ assert.equal(options.url, "/json/endpoint");
- options.simulate_success('response data', 'success');
+ options.simulate_success("response data", "success");
assert(orig_success_called);
options.simulate_error();
@@ -160,13 +160,13 @@ run_test('normal_post', () => {
});
});
-run_test('patch_with_form_data', () => {
+run_test("patch_with_form_data", () => {
let appended;
const data = {
append: function (k, v) {
- assert.equal(k, 'method');
- assert.equal(v, 'PATCH');
+ assert.equal(k, "method");
+ assert.equal(v, "PATCH");
appended = true;
},
};
@@ -181,8 +181,8 @@ run_test('patch_with_form_data', () => {
},
check_ajax_options: function (options) {
- assert.equal(options.type, 'POST');
- assert.equal(options.dataType, 'json');
+ assert.equal(options.type, "POST");
+ assert.equal(options.dataType, "json");
// Just make sure these don't explode.
options.simulate_success();
@@ -191,7 +191,7 @@ run_test('patch_with_form_data', () => {
});
});
-run_test('reload_on_403_error', () => {
+run_test("reload_on_403_error", () => {
test_with_mock_ajax({
xhr: {
status: 403,
@@ -220,11 +220,11 @@ run_test('reload_on_403_error', () => {
});
});
-run_test('unexpected_403_response', () => {
+run_test("unexpected_403_response", () => {
test_with_mock_ajax({
xhr: {
status: 403,
- responseText: 'unexpected',
+ responseText: "unexpected",
},
run_code: function () {
@@ -232,13 +232,13 @@ run_test('unexpected_403_response', () => {
},
check_ajax_options: function (options) {
- blueslip.expect('error', 'Unexpected 403 response from server');
+ blueslip.expect("error", "Unexpected 403 response from server");
options.simulate_error();
},
});
});
-run_test('retry', () => {
+run_test("retry", () => {
test_with_mock_ajax({
run_code: function () {
channel.post({
@@ -248,12 +248,12 @@ run_test('retry', () => {
},
check_ajax_options: function (options) {
- global.patch_builtin('setTimeout', (f, delay) => {
+ global.patch_builtin("setTimeout", (f, delay) => {
assert.equal(delay, 0);
f();
});
- blueslip.expect('log', 'Retrying idempotent[object Object]');
+ blueslip.expect("log", "Retrying idempotent[object Object]");
test_with_mock_ajax({
run_code: function () {
options.simulate_success();
@@ -267,32 +267,32 @@ run_test('retry', () => {
});
});
-run_test('too_many_pending', () => {
+run_test("too_many_pending", () => {
$.ajax = function () {
- const xhr = 'stub';
+ const xhr = "stub";
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({});
});
});
-run_test('xhr_error_message', () => {
+run_test("xhr_error_message", () => {
let xhr = {
- status: '200',
- responseText: 'does not matter',
+ status: "200",
+ responseText: "does not matter",
};
- let msg = 'data added';
- assert.equal(channel.xhr_error_message(msg, xhr), 'data added');
+ let msg = "data added";
+ assert.equal(channel.xhr_error_message(msg, xhr), "data added");
xhr = {
- status: '404',
+ status: "404",
responseText: '{"msg": "file not found"}',
};
- msg = 'some message';
- assert.equal(channel.xhr_error_message(msg, xhr), 'some message: file not found');
+ msg = "some message";
+ assert.equal(channel.xhr_error_message(msg, xhr), "some message: file not found");
});
diff --git a/frontend_tests/node_tests/color_data.js b/frontend_tests/node_tests/color_data.js
index 39f67aa8583..2ec62944a99 100644
--- a/frontend_tests/node_tests/color_data.js
+++ b/frontend_tests/node_tests/color_data.js
@@ -1,44 +1,44 @@
-zrequire('color_data');
+zrequire("color_data");
-run_test('pick_color', () => {
+run_test("pick_color", () => {
color_data.colors = [
- 'blue',
- 'orange',
- 'red',
- 'yellow',
+ "blue",
+ "orange",
+ "red",
+ "yellow",
];
color_data.reset();
color_data.claim_colors([
- { color: 'orange' },
- { foo: 'whatever' },
- { color: 'yellow' },
- { color: 'bogus' },
+ { color: "orange" },
+ { foo: "whatever" },
+ { color: "yellow" },
+ { color: "bogus" },
]);
const expected_colors = [
- 'blue',
- 'red',
+ "blue",
+ "red",
// ok, now we'll cycle through all colors
- 'blue',
- 'orange',
- 'red',
- 'yellow',
- 'blue',
- 'orange',
- 'red',
- 'yellow',
- 'blue',
- 'orange',
- 'red',
- 'yellow',
+ "blue",
+ "orange",
+ "red",
+ "yellow",
+ "blue",
+ "orange",
+ "red",
+ "yellow",
+ "blue",
+ "orange",
+ "red",
+ "yellow",
];
for (const expected_color of expected_colors) {
assert.equal(color_data.pick_color(), expected_color);
}
- color_data.claim_color('blue');
- assert.equal(color_data.pick_color(), 'orange');
+ color_data.claim_color("blue");
+ assert.equal(color_data.pick_color(), "orange");
});
diff --git a/frontend_tests/node_tests/colorspace.js b/frontend_tests/node_tests/colorspace.js
index 988bc541de6..5bfcef963d1 100644
--- a/frontend_tests/node_tests/colorspace.js
+++ b/frontend_tests/node_tests/colorspace.js
@@ -1,6 +1,6 @@
-zrequire('colorspace');
+zrequire("colorspace");
-run_test('sRGB_to_linear', () => {
+run_test("sRGB_to_linear", () => {
let srgb_color = 0.0042;
let expected_value = 0.0042 / 255.0 / 12.92;
let actual_value = colorspace.sRGB_to_linear(srgb_color);
@@ -12,14 +12,14 @@ run_test('sRGB_to_linear', () => {
assert.equal(actual_value, expected_value);
});
-run_test('rgb_luminance', () => {
+run_test("rgb_luminance", () => {
const channel = [1, 1, 1];
const expected_value = 1;
const actual_value = colorspace.rgb_luminance(channel);
assert.equal(actual_value, expected_value);
});
-run_test('luminance_to_lightness', () => {
+run_test("luminance_to_lightness", () => {
let luminance = 0;
let expected_value = 116 * 4 / 29 - 16;
let actual_value = colorspace.luminance_to_lightness(luminance);
@@ -31,8 +31,8 @@ run_test('luminance_to_lightness', () => {
assert.equal(actual_value, expected_value);
});
-run_test('getDecimalColor', () => {
- const hex_color = '#1f293b';
+run_test("getDecimalColor", () => {
+ const hex_color = "#1f293b";
const expected_value = {
r: 31,
g: 41,
@@ -42,7 +42,7 @@ run_test('getDecimalColor', () => {
assert.deepEqual(actual_value, expected_value);
});
-run_test('getLighterColor', () => {
+run_test("getLighterColor", () => {
const rgb_color = {
r: 31,
g: 41,
@@ -54,13 +54,13 @@ run_test('getLighterColor', () => {
assert.deepEqual(actual_value, expected_value);
});
-run_test('getHexColor', () => {
+run_test("getHexColor", () => {
const rgb_color = {
r: 31,
g: 41,
b: 59,
};
- const expected_value = '#1f293b';
+ const expected_value = "#1f293b";
const actual_value = colorspace.getHexColor(rgb_color);
assert.equal(actual_value, expected_value);
});
diff --git a/frontend_tests/node_tests/common.js b/frontend_tests/node_tests/common.js
index ef46c6b79f6..7700ce98ec9 100644
--- a/frontend_tests/node_tests/common.js
+++ b/frontend_tests/node_tests/common.js
@@ -1,8 +1,8 @@
const noop = () => {};
-set_global('$', global.make_zjquery());
-const input = $.create('input');
-set_global('document', {
+set_global("$", global.make_zjquery());
+const input = $.create("input");
+set_global("document", {
createElement: () => input,
execCommand: noop,
});
@@ -15,7 +15,7 @@ $(input).val = (arg) => {
};
};
-zrequire('common');
+zrequire("common");
function get_key_stub_html(key_text, expected_key, obj_name) {
const key_stub = $.create(obj_name);
@@ -26,23 +26,23 @@ function get_key_stub_html(key_text, expected_key, obj_name) {
return key_stub;
}
-run_test('basics', () => {
- common.autofocus('#home');
- assert($('#home').is_focused());
+run_test("basics", () => {
+ common.autofocus("#home");
+ assert($("#home").is_focused());
});
-run_test('phrase_match', () => {
- assert(common.phrase_match('tes', 'test'));
- assert(common.phrase_match('Tes', 'test'));
- assert(common.phrase_match('Tes', 'Test'));
- assert(common.phrase_match('tes', 'Stream Test'));
+run_test("phrase_match", () => {
+ assert(common.phrase_match("tes", "test"));
+ assert(common.phrase_match("Tes", "test"));
+ assert(common.phrase_match("Tes", "Test"));
+ assert(common.phrase_match("tes", "Stream Test"));
- assert(!common.phrase_match('tests', 'test'));
- assert(!common.phrase_match('tes', 'hostess'));
+ assert(!common.phrase_match("tests", "test"));
+ assert(!common.phrase_match("tes", "hostess"));
});
-run_test('copy_data_attribute_value', () => {
- const elem = $.create('.envelope-link');
+run_test("copy_data_attribute_value", () => {
+ const elem = $.create(".envelope-link");
elem.data = (key) => {
if (key === "admin-emails") {
@@ -55,35 +55,35 @@ run_test('copy_data_attribute_value', () => {
elem.fadeIn = (val) => {
assert.equal(val, 1000);
};
- common.copy_data_attribute_value(elem, 'admin-emails');
+ common.copy_data_attribute_value(elem, "admin-emails");
});
-run_test('adjust_mac_shortcuts', () => {
+run_test("adjust_mac_shortcuts", () => {
const keys_to_test_mac = new Map([
- ['Backspace', 'Delete'],
- ['Enter', 'Return'],
- ['Home', 'Fn + ←'],
- ['End', 'Fn + →'],
- ['PgUp', 'Fn + ↑'],
- ['PgDn', 'Fn + ↓'],
- ['X + Shift', 'X + Shift'],
- ['⌘ + Return', '⌘ + Return'],
- ['Enter or Backspace', "Return or Delete"],
- ['Ctrl', '⌘'],
- ['Ctrl + Shift', '⌘ + Shift'],
- ['Ctrl + Backspace + End', '⌘ + Delete + Fn + →'],
+ ["Backspace", "Delete"],
+ ["Enter", "Return"],
+ ["Home", "Fn + ←"],
+ ["End", "Fn + →"],
+ ["PgUp", "Fn + ↑"],
+ ["PgDn", "Fn + ↓"],
+ ["X + Shift", "X + Shift"],
+ ["⌘ + Return", "⌘ + Return"],
+ ["Enter or Backspace", "Return or Delete"],
+ ["Ctrl", "⌘"],
+ ["Ctrl + Shift", "⌘ + Shift"],
+ ["Ctrl + Backspace + End", "⌘ + Delete + Fn + →"],
]);
const keys_to_test_non_mac = new Map([
- ['Backspace', 'Backspace'],
- ['Enter', 'Enter'],
- ['Home', 'Home'],
- ['End', 'End'],
- ['PgUp', 'PgUp'],
- ['PgDn', 'PgDn'],
- ['X + Shift', 'X + Shift'],
- ['⌘ + Return', '⌘ + Return'],
- ['Ctrl + Shift', 'Ctrl + Shift'],
- ['Ctrl + Backspace + End', 'Ctrl + Backspace + End'],
+ ["Backspace", "Backspace"],
+ ["Enter", "Enter"],
+ ["Home", "Home"],
+ ["End", "End"],
+ ["PgUp", "PgUp"],
+ ["PgDn", "PgDn"],
+ ["X + Shift", "X + Shift"],
+ ["⌘ + Return", "⌘ + Return"],
+ ["Ctrl + Shift", "Ctrl + Shift"],
+ ["Ctrl + Backspace + End", "Ctrl + Backspace + End"],
]);
let key_no;
diff --git a/frontend_tests/node_tests/components.js b/frontend_tests/node_tests/components.js
index c8e08a9a4c2..9c26af50d0d 100644
--- a/frontend_tests/node_tests/components.js
+++ b/frontend_tests/node_tests/components.js
@@ -1,13 +1,13 @@
-zrequire('keydown_util');
-zrequire('components');
+zrequire("keydown_util");
+zrequire("components");
const noop = function () {};
const LEFT_KEY = { which: 37, preventDefault: noop, stopPropagation: noop };
const RIGHT_KEY = { which: 39, preventDefault: noop, stopPropagation: noop };
-run_test('basics', () => {
+run_test("basics", () => {
let keydown_f;
let click_f;
const tabs = [];
@@ -23,14 +23,14 @@ run_test('basics', () => {
self.class = [];
self.addClass = function (c) {
- self.class += ' ' + c;
+ self.class += " " + c;
const tokens = self.class.trim().split(/ +/);
- self.class = _.uniq(tokens).join(' ');
+ self.class = _.uniq(tokens).join(" ");
};
self.removeClass = function (c) {
const tokens = self.class.trim().split(/ +/);
- self.class = _.without(tokens, c).join(' ');
+ self.class = _.without(tokens, c).join(" ");
};
self.hasClass = function (c) {
@@ -39,7 +39,7 @@ run_test('basics', () => {
};
self.data = function (name) {
- assert.equal(name, 'tab-id');
+ assert.equal(name, "tab-id");
return i;
};
@@ -101,14 +101,14 @@ run_test('basics', () => {
case ".ind-tab":
return ind_tab;
default:
- throw Error('unknown selector: ' + sel);
+ throw Error("unknown selector: " + sel);
}
};
return self;
}());
- set_global('$', (sel) => {
+ set_global("$", (sel) => {
if (sel.stub) {
// The component often redundantly re-wraps objects.
return sel;
@@ -126,7 +126,7 @@ run_test('basics', () => {
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);
+ throw Error("unknown selector: " + sel);
}
});
@@ -157,69 +157,69 @@ run_test('basics', () => {
assert.deepEqual(switcher.children, tabs);
- assert.equal(switcher.addedClass, 'stream_sorter_toggle');
+ assert.equal(switcher.addedClass, "stream_sorter_toggle");
assert.equal(focused_tab, 0);
- assert.equal(tabs[0].class, 'first selected');
- assert.equal(tabs[1].class, 'middle');
- assert.equal(tabs[2].class, 'last');
- assert.deepEqual(callback_args, ['translated: Keyboard shortcuts', 'keyboard-shortcuts']);
- assert.equal(widget.value(), 'translated: Keyboard shortcuts');
+ assert.equal(tabs[0].class, "first selected");
+ assert.equal(tabs[1].class, "middle");
+ assert.equal(tabs[2].class, "last");
+ assert.deepEqual(callback_args, ["translated: Keyboard shortcuts", "keyboard-shortcuts"]);
+ assert.equal(widget.value(), "translated: Keyboard shortcuts");
callback_args = undefined;
- widget.goto('message-formatting');
+ widget.goto("message-formatting");
assert.equal(focused_tab, 1);
- assert.equal(tabs[0].class, 'first');
- assert.equal(tabs[1].class, 'middle selected');
- assert.equal(tabs[2].class, 'last');
- assert.deepEqual(callback_args, ['translated: Message formatting', 'message-formatting']);
- assert.equal(widget.value(), 'translated: Message formatting');
+ assert.equal(tabs[0].class, "first");
+ assert.equal(tabs[1].class, "middle selected");
+ assert.equal(tabs[2].class, "last");
+ assert.deepEqual(callback_args, ["translated: Message formatting", "message-formatting"]);
+ assert.equal(widget.value(), "translated: Message formatting");
// Go to same tab twice and make sure we get callback.
callback_args = undefined;
- widget.goto('message-formatting');
- assert.deepEqual(callback_args, ['translated: Message formatting', 'message-formatting']);
+ widget.goto("message-formatting");
+ assert.deepEqual(callback_args, ["translated: Message formatting", "message-formatting"]);
callback_args = undefined;
keydown_f.call(tabs[focused_tab], RIGHT_KEY);
assert.equal(focused_tab, 2);
- assert.equal(tabs[0].class, 'first');
- assert.equal(tabs[1].class, 'middle');
- assert.equal(tabs[2].class, 'last selected');
- assert.deepEqual(callback_args, ['translated: Search operators', 'search-operators']);
- assert.equal(widget.value(), 'translated: Search operators');
+ assert.equal(tabs[0].class, "first");
+ assert.equal(tabs[1].class, "middle");
+ assert.equal(tabs[2].class, "last selected");
+ assert.deepEqual(callback_args, ["translated: Search operators", "search-operators"]);
+ assert.equal(widget.value(), "translated: Search operators");
assert.equal(widget.value(), callback_value);
// try to crash the key handler
keydown_f.call(tabs[focused_tab], RIGHT_KEY);
- assert.equal(widget.value(), 'translated: Search operators');
+ assert.equal(widget.value(), "translated: Search operators");
callback_args = undefined;
keydown_f.call(tabs[focused_tab], LEFT_KEY);
- assert.equal(widget.value(), 'translated: Message formatting');
+ assert.equal(widget.value(), "translated: Message formatting");
callback_args = undefined;
keydown_f.call(tabs[focused_tab], LEFT_KEY);
- assert.equal(widget.value(), 'translated: Keyboard shortcuts');
+ assert.equal(widget.value(), "translated: Keyboard shortcuts");
// try to crash the key handler
keydown_f.call(tabs[focused_tab], LEFT_KEY);
- assert.equal(widget.value(), 'translated: Keyboard shortcuts');
+ assert.equal(widget.value(), "translated: Keyboard shortcuts");
callback_args = undefined;
click_f.call(tabs[1]);
- assert.equal(widget.value(), 'translated: Message formatting');
+ assert.equal(widget.value(), "translated: Message formatting");
callback_args = undefined;
widget.disable_tab("search-operators");
- assert.equal(tabs[2].hasClass('disabled'), true);
+ assert.equal(tabs[2].hasClass("disabled"), true);
assert.equal(tabs[2].class, "last disabled");
- widget.goto('keyboard-shortcuts');
+ widget.goto("keyboard-shortcuts");
assert.equal(focused_tab, 0);
widget.goto("search-operators");
assert.equal(focused_tab, 0);
diff --git a/frontend_tests/node_tests/compose.js b/frontend_tests/node_tests/compose.js
index ecf76a1734b..4beebb3c56e 100644
--- a/frontend_tests/node_tests/compose.js
+++ b/frontend_tests/node_tests/compose.js
@@ -1,21 +1,21 @@
const rewiremock = require("rewiremock/node");
const { JSDOM } = require("jsdom");
-set_global('bridge', false);
+set_global("bridge", false);
const noop = function () {};
-set_global('$', global.make_zjquery());
-set_global('DOMParser', new JSDOM().window.DOMParser);
+set_global("$", global.make_zjquery());
+set_global("DOMParser", new JSDOM().window.DOMParser);
-const LazySet = zrequire('lazy_set.js').LazySet;
+const LazySet = zrequire("lazy_set.js").LazySet;
const _navigator = {
- platform: '',
+ platform: "",
};
const _document = {
- getElementById: function () { return $('#compose-textarea'); },
+ getElementById: function () { return $("#compose-textarea"); },
execCommand: function () { return false; },
location: {},
};
@@ -35,52 +35,52 @@ const _reminder = {
is_deferred_delivery: noop,
};
-set_global('document', _document);
-set_global('drafts', _drafts);
-set_global('navigator', _navigator);
-set_global('notifications', _notifications);
-set_global('reminder', _reminder);
-set_global('sent_messages', _sent_messages);
-
-set_global('local_message', {});
-set_global('transmit', {});
-set_global('channel', {});
-set_global('stream_edit', {});
-set_global('markdown', {});
-set_global('loading', {});
-set_global('page_params', {});
-set_global('resize', {});
-set_global('subs', {});
-set_global('ui_util', {});
+set_global("document", _document);
+set_global("drafts", _drafts);
+set_global("navigator", _navigator);
+set_global("notifications", _notifications);
+set_global("reminder", _reminder);
+set_global("sent_messages", _sent_messages);
+
+set_global("local_message", {});
+set_global("transmit", {});
+set_global("channel", {});
+set_global("stream_edit", {});
+set_global("markdown", {});
+set_global("loading", {});
+set_global("page_params", {});
+set_global("resize", {});
+set_global("subs", {});
+set_global("ui_util", {});
// Setting these up so that we can test that links to uploads within messages are
// automatically converted to server relative links.
-global.document.location.protocol = 'https:';
-global.document.location.host = 'foo.com';
-
-zrequire('zcommand');
-zrequire('compose_ui');
-const util = zrequire('util');
-zrequire('rtl');
-zrequire('common');
-set_global('Handlebars', global.make_handlebars());
-zrequire('stream_data');
-zrequire('compose_state');
-zrequire('people');
-zrequire('input_pill');
-zrequire('user_pill');
-zrequire('compose_pm_pill');
-zrequire('echo');
-rewiremock.proxy(() => zrequire('compose'), {
+global.document.location.protocol = "https:";
+global.document.location.host = "foo.com";
+
+zrequire("zcommand");
+zrequire("compose_ui");
+const util = zrequire("util");
+zrequire("rtl");
+zrequire("common");
+set_global("Handlebars", global.make_handlebars());
+zrequire("stream_data");
+zrequire("compose_state");
+zrequire("people");
+zrequire("input_pill");
+zrequire("user_pill");
+zrequire("compose_pm_pill");
+zrequire("echo");
+rewiremock.proxy(() => zrequire("compose"), {
"../../static/js/rendered_markdown": {
update_elements: () => {},
},
});
-zrequire('upload');
-zrequire('server_events_dispatch');
+zrequire("upload");
+zrequire("server_events_dispatch");
people.small_avatar_url_for_person = function () {
- return 'http://example.com/example.png';
+ return "http://example.com/example.png";
};
function stub_out_video_calls() {
@@ -96,33 +96,33 @@ function stub_out_video_calls() {
function reset_jquery() {
// Avoid leaks.
- set_global('$', global.make_zjquery());
+ set_global("$", global.make_zjquery());
}
const new_user = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 101,
- full_name: 'New User',
+ full_name: "New User",
date_joined: new Date(),
};
const me = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 30,
- full_name: 'Me Myself',
+ full_name: "Me Myself",
date_joined: new Date(),
};
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 31,
- full_name: 'Alice',
+ full_name: "Alice",
};
const bob = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 32,
- full_name: 'Bob',
+ full_name: "Bob",
};
people.add_active_user(new_user);
@@ -132,73 +132,73 @@ people.initialize_current_user(me.user_id);
people.add_active_user(alice);
people.add_active_user(bob);
-run_test('validate_stream_message_address_info', () => {
+run_test("validate_stream_message_address_info", () => {
const sub = {
stream_id: 101,
- name: 'social',
+ name: "social",
subscribed: true,
};
stream_data.add_sub(sub);
- assert(compose.validate_stream_message_address_info('social'));
+ assert(compose.validate_stream_message_address_info("social"));
- $('#stream_message_recipient_stream').select(noop);
+ $("#stream_message_recipient_stream").select(noop);
sub.subscribed = false;
stream_data.add_sub(sub);
global.stub_templates((template_name) => {
- assert.equal(template_name, 'compose_not_subscribed');
- return 'compose_not_subscribed_stub';
+ assert.equal(template_name, "compose_not_subscribed");
+ return "compose_not_subscribed_stub";
});
- assert(!compose.validate_stream_message_address_info('social'));
- assert.equal($('#compose-error-msg').html(), 'compose_not_subscribed_stub');
+ assert(!compose.validate_stream_message_address_info("social"));
+ assert.equal($("#compose-error-msg").html(), "compose_not_subscribed_stub");
page_params.narrow_stream = false;
channel.post = function (payload) {
- assert.equal(payload.data.stream, 'social');
+ assert.equal(payload.data.stream, "social");
payload.data.subscribed = true;
payload.success(payload.data);
};
- assert(compose.validate_stream_message_address_info('social'));
+ assert(compose.validate_stream_message_address_info("social"));
- sub.name = 'Frontend';
+ sub.name = "Frontend";
sub.stream_id = 102;
stream_data.add_sub(sub);
channel.post = function (payload) {
- assert.equal(payload.data.stream, 'Frontend');
+ assert.equal(payload.data.stream, "Frontend");
payload.data.subscribed = false;
payload.success(payload.data);
};
- assert(!compose.validate_stream_message_address_info('Frontend'));
- assert.equal($('#compose-error-msg').html(), 'compose_not_subscribed_stub');
+ assert(!compose.validate_stream_message_address_info("Frontend"));
+ assert.equal($("#compose-error-msg").html(), "compose_not_subscribed_stub");
channel.post = function (payload) {
- assert.equal(payload.data.stream, 'Frontend');
+ assert.equal(payload.data.stream, "Frontend");
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(!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>");
channel.post = function (payload) {
- assert.equal(payload.data.stream, 'social');
+ assert.equal(payload.data.stream, "social");
payload.error({status: 500});
};
- assert(!compose.validate_stream_message_address_info('social'));
- assert.equal($('#compose-error-msg').html(), i18n.t("Error checking subscription"));
+ assert(!compose.validate_stream_message_address_info("social"));
+ assert.equal($("#compose-error-msg").html(), i18n.t("Error checking subscription"));
});
-run_test('validate', () => {
+run_test("validate", () => {
function initialize_pm_pill() {
- set_global('$', global.make_zjquery());
+ set_global("$", global.make_zjquery());
- $("#compose-send-button").prop('disabled', false);
+ $("#compose-send-button").prop("disabled", false);
$("#compose-send-button").focus();
$("#sending-indicator").hide();
$("#compose-textarea").select(noop);
- const pm_pill_container = $.create('fake-pm-pill-container');
- $('#private_message_recipient').set_parent(pm_pill_container);
- pm_pill_container.set_find_results('.input', $('#private_message_recipient'));
- $('#private_message_recipient').before = noop;
+ const pm_pill_container = $.create("fake-pm-pill-container");
+ $("#private_message_recipient").set_parent(pm_pill_container);
+ pm_pill_container.set_find_results(".input", $("#private_message_recipient"));
+ $("#private_message_recipient").before = noop;
compose_pm_pill.initialize();
@@ -208,25 +208,25 @@ run_test('validate', () => {
$("#private_message_recipient").select(noop);
global.stub_templates((fn) => {
- assert.equal(fn, 'input_pill');
- return '<div>pill-html</div>';
+ assert.equal(fn, "input_pill");
+ return "<div>pill-html</div>";
});
}
function add_content_to_compose_box() {
- $("#compose-textarea").val('foobarfoobar');
+ $("#compose-textarea").val("foobarfoobar");
}
initialize_pm_pill();
assert(!compose.validate());
assert(!$("#sending-indicator").visible());
assert(!$("#compose-send-button").is_focused());
- assert.equal($("#compose-send-button").prop('disabled'), false);
- assert.equal($('#compose-error-msg').html(), i18n.t('You have nothing to send!'));
+ assert.equal($("#compose-send-button").prop("disabled"), false);
+ assert.equal($("#compose-error-msg").html(), i18n.t("You have nothing to send!"));
reminder.is_deferred_delivery = () => true;
compose.validate();
- assert.equal($('#sending-indicator').text(), 'translated: Scheduling...');
+ assert.equal($("#sending-indicator").text(), "translated: Scheduling...");
reminder.is_deferred_delivery = noop;
add_content_to_compose_box();
@@ -240,58 +240,58 @@ 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();
// test validating private messages
- compose_state.set_message_type('private');
+ compose_state.set_message_type("private");
- compose_state.private_message_recipient('');
+ 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();
- compose_state.private_message_recipient('[email protected]');
+ compose_state.private_message_recipient("[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", {}));
- compose_state.private_message_recipient('[email protected],[email protected]');
+ 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]');
+ compose_state.private_message_recipient("[email protected]");
assert(compose.validate());
page_params.realm_is_zephyr_mirror_realm = true;
assert(compose.validate());
page_params.realm_is_zephyr_mirror_realm = false;
- compose_state.set_message_type('stream');
- compose_state.stream_name('');
+ compose_state.set_message_type("stream");
+ compose_state.stream_name("");
$("#stream_message_recipient_stream").select(noop);
assert(!compose.validate());
- assert.equal($('#compose-error-msg').html(), i18n.t('Please specify a stream'));
+ assert.equal($("#compose-error-msg").html(), i18n.t("Please specify a stream"));
- compose_state.stream_name('Denmark');
+ compose_state.stream_name("Denmark");
page_params.realm_mandatory_topics = true;
- compose_state.topic('');
+ compose_state.topic("");
$("#stream_message_recipient_topic").select(noop);
assert(!compose.validate());
- assert.equal($('#compose-error-msg').html(), i18n.t('Please specify a topic'));
+ assert.equal($("#compose-error-msg").html(), i18n.t("Please specify a topic"));
});
-run_test('get_invalid_recipient_emails', () => {
+run_test("get_invalid_recipient_emails", () => {
const welcome_bot = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 124,
- full_name: 'Welcome Bot',
+ full_name: "Welcome Bot",
};
page_params.user_id = 30;
@@ -303,11 +303,11 @@ run_test('get_invalid_recipient_emails', () => {
people.initialize(page_params.user_id, params);
- compose_state.private_message_recipient('[email protected]');
+ compose_state.private_message_recipient("[email protected]");
assert.deepEqual(compose.get_invalid_recipient_emails(), []);
});
-run_test('validate_stream_message', () => {
+run_test("validate_stream_message", () => {
// This test is in kind of continuation to test_validate but since it is
// primarily used to get coverage over functions called from validate()
// we are separating it up in different test. Though their relative position
@@ -315,11 +315,11 @@ run_test('validate_stream_message', () => {
page_params.realm_mandatory_topics = false;
const sub = {
stream_id: 101,
- name: 'social',
+ name: "social",
subscribed: true,
};
stream_data.add_sub(sub);
- compose_state.stream_name('social');
+ compose_state.stream_name("social");
assert(compose.validate());
assert(!$("#compose-all-everyone").visible());
assert(!$("#compose-send-status").visible());
@@ -329,23 +329,23 @@ run_test('validate_stream_message', () => {
return 16;
};
global.stub_templates((template_name, data) => {
- assert.equal(template_name, 'compose_all_everyone');
+ assert.equal(template_name, "compose_all_everyone");
assert.equal(data.count, 16);
- return 'compose_all_everyone_stub';
+ return "compose_all_everyone_stub";
});
let compose_content;
- $('#compose-all-everyone').append = function (data) {
+ $("#compose-all-everyone").append = function (data) {
compose_content = data;
};
- compose_state.message_content('Hey @**all**');
+ compose_state.message_content("Hey @**all**");
assert(!compose.validate());
- assert.equal($("#compose-send-button").prop('disabled'), false);
+ assert.equal($("#compose-send-button").prop("disabled"), false);
assert(!$("#compose-send-status").visible());
- assert.equal(compose_content, 'compose_all_everyone_stub');
+ assert.equal(compose_content, "compose_all_everyone_stub");
assert($("#compose-all-everyone").visible());
});
-run_test('test_validate_stream_message_post_policy', () => {
+run_test("test_validate_stream_message_post_policy", () => {
// This test is in continuation with test_validate but it has been separated out
// for better readability. Their relative position of execution should not be changed.
// Although the position with respect to test_validate_stream_message does not matter
@@ -353,66 +353,66 @@ run_test('test_validate_stream_message_post_policy', () => {
page_params.is_admin = false;
const sub = {
stream_id: 102,
- name: 'stream102',
+ name: "stream102",
subscribed: true,
stream_post_policy: stream_data.stream_post_policy_values.admins.code,
};
- compose_state.topic('subject102');
- compose_state.stream_name('stream102');
+ compose_state.topic("subject102");
+ 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.
- compose_state.stream_name('social');
+ compose_state.stream_name("social");
});
-run_test('markdown_rtl', () => {
- const textarea = $('#compose-textarea');
+run_test("markdown_rtl", () => {
+ const textarea = $("#compose-textarea");
const event = {
keyCode: 65, // A
};
rtl.get_direction = (text) => {
- assert.equal(text, ' foo');
- return 'rtl';
+ assert.equal(text, " foo");
+ return "rtl";
};
- assert.equal(textarea.hasClass('rtl'), false);
+ assert.equal(textarea.hasClass("rtl"), false);
- textarea.val('```quote foo');
+ textarea.val("```quote foo");
compose.handle_keyup(event, $("#compose-textarea"));
- assert.equal(textarea.hasClass('rtl'), true);
+ assert.equal(textarea.hasClass("rtl"), true);
});
// This is important for subsequent tests--put
// us back to the "normal" ltr case.
-rtl.get_direction = () => 'ltr';
+rtl.get_direction = () => "ltr";
-run_test('markdown_ltr', () => {
- const textarea = $('#compose-textarea');
+run_test("markdown_ltr", () => {
+ const textarea = $("#compose-textarea");
const event = {
keyCode: 65, // A
};
- assert.equal(textarea.hasClass('rtl'), true);
- textarea.val('```quote foo');
+ assert.equal(textarea.hasClass("rtl"), true);
+ textarea.val("```quote foo");
compose.handle_keyup(event, textarea);
- assert.equal(textarea.hasClass('rtl'), false);
+ assert.equal(textarea.hasClass("rtl"), false);
});
-run_test('markdown_shortcuts', () => {
+run_test("markdown_shortcuts", () => {
let queryCommandEnabled = true;
const event = {
keyCode: 66,
target: {
- id: 'compose-textarea',
+ id: "compose-textarea",
},
stopPropagation: noop,
preventDefault: noop,
@@ -442,17 +442,17 @@ run_test('markdown_shortcuts', () => {
text: $("#compose-textarea").val().substring(range_start, range_length + range_start),
};
};
- $('#compose-textarea').caret = noop;
+ $("#compose-textarea").caret = noop;
function test_i_typed(isCtrl, isCmd) {
// Test 'i' is typed correctly.
- $("#compose-textarea").val('i');
+ $("#compose-textarea").val("i");
event.keyCode = undefined;
event.which = 73;
event.metaKey = isCmd;
event.ctrlKey = isCtrl;
compose.handle_keydown(event, $("#compose-textarea"));
- assert.equal("i", $('#compose-textarea').val());
+ assert.equal("i", $("#compose-textarea").val());
}
function all_markdown_test(isCtrl, isCmd) {
@@ -471,13 +471,13 @@ run_test('markdown_shortcuts', () => {
event.ctrlKey = isCtrl;
event.metaKey = isCmd;
compose.handle_keydown(event, $("#compose-textarea"));
- assert.equal("Any **text**.", $('#compose-textarea').val());
+ assert.equal("Any **text**.", $("#compose-textarea").val());
// Test if no text is selected.
range_start = 0;
// Change cursor to first position.
range_length = 0;
compose.handle_keydown(event, $("#compose-textarea"));
- assert.equal("****Any **text**.", $('#compose-textarea').val());
+ assert.equal("****Any **text**.", $("#compose-textarea").val());
// Test italic:
// Mac = cmd+i
@@ -488,13 +488,13 @@ run_test('markdown_shortcuts', () => {
event.keyCode = 73;
event.shiftKey = false;
compose.handle_keydown(event, $("#compose-textarea"));
- assert.equal("Any *text*.", $('#compose-textarea').val());
+ assert.equal("Any *text*.", $("#compose-textarea").val());
// Test if no text is selected.
range_length = 0;
// Change cursor to first position.
range_start = 0;
compose.handle_keydown(event, $("#compose-textarea"));
- assert.equal("**Any *text*.", $('#compose-textarea').val());
+ assert.equal("**Any *text*.", $("#compose-textarea").val());
// Test link insertion:
// Mac = cmd+shift+l
@@ -506,7 +506,7 @@ run_test('markdown_shortcuts', () => {
event.which = undefined;
event.shiftKey = true;
compose.handle_keydown(event, $("#compose-textarea"));
- assert.equal("Any [text](url).", $('#compose-textarea').val());
+ assert.equal("Any [text](url).", $("#compose-textarea").val());
// Test if exec command is not enabled in browser.
queryCommandEnabled = false;
compose.handle_keydown(event, $("#compose-textarea"));
@@ -528,17 +528,17 @@ run_test('markdown_shortcuts', () => {
event.keyCode = 66;
compose.handle_keydown(event, $("#compose-textarea"));
- assert.equal(input_text, $('#compose-textarea').val());
+ assert.equal(input_text, $("#compose-textarea").val());
event.keyCode = 73;
event.shiftKey = false;
compose.handle_keydown(event, $("#compose-textarea"));
- assert.equal(input_text, $('#compose-textarea').val());
+ assert.equal(input_text, $("#compose-textarea").val());
event.keyCode = 76;
event.shiftKey = true;
compose.handle_keydown(event, $("#compose-textarea"));
- assert.equal(input_text, $('#compose-textarea').val());
+ assert.equal(input_text, $("#compose-textarea").val());
}
// These keyboard shortcuts differ as to what key one should use
@@ -565,11 +565,11 @@ run_test('markdown_shortcuts', () => {
_navigator.userAgent = "";
});
-run_test('send_message_success', () => {
- $("#compose-textarea").val('foobarfoobar');
+run_test("send_message_success", () => {
+ $("#compose-textarea").val("foobarfoobar");
$("#compose-textarea").blur();
$("#compose-send-status").show();
- $("#compose-send-button").attr('disabled', 'disabled');
+ $("#compose-send-button").attr("disabled", "disabled");
$("#sending-indicator").show();
let reify_message_id_checked;
@@ -581,16 +581,16 @@ run_test('send_message_success', () => {
compose.send_message_success("1001", 12, false);
- assert.equal($("#compose-textarea").val(), '');
+ assert.equal($("#compose-textarea").val(), "");
assert($("#compose-textarea").is_focused());
assert(!$("#compose-send-status").visible());
- assert.equal($("#compose-send-button").prop('disabled'), false);
+ assert.equal($("#compose-send-button").prop("disabled"), false);
assert(!$("#sending-indicator").visible());
assert(reify_message_id_checked);
});
-run_test('send_message', () => {
+run_test("send_message", () => {
// This is the common setup stuff for all of the four tests.
let stub_state;
function initialize_state_stub_dict() {
@@ -601,7 +601,7 @@ run_test('send_message', () => {
return stub_state;
}
- global.patch_builtin('setTimeout', (func) => {
+ global.patch_builtin("setTimeout", (func) => {
func();
});
global.server_events = {
@@ -613,11 +613,11 @@ run_test('send_message', () => {
// Tests start here.
(function test_message_send_success_codepath() {
stub_state = initialize_state_stub_dict();
- compose_state.topic('');
- compose_state.set_message_type('private');
+ compose_state.topic("");
+ compose_state.set_message_type("private");
page_params.user_id = 101;
compose_state.private_message_recipient = function () {
- return '[email protected]';
+ return "[email protected]";
};
const server_message_id = 127;
@@ -636,17 +636,17 @@ run_test('send_message', () => {
};
transmit.send_message = function (payload, success) {
const single_msg = {
- type: 'private',
- content: '[foobar](/user_uploads/123456)',
+ type: "private",
+ content: "[foobar](/user_uploads/123456)",
sender_id: 101,
queue_id: undefined,
- stream: '',
- topic: '',
+ stream: "",
+ topic: "",
to: `[${alice.user_id}]`,
- reply_to: '[email protected]',
- private_message_recipient: '[email protected]',
- to_user_ids: '31',
- local_id: '123.04',
+ reply_to: "[email protected]",
+ private_message_recipient: "[email protected]",
+ to_user_ids: "31",
+ local_id: "123.04",
locally_echoed: true,
};
@@ -656,19 +656,19 @@ run_test('send_message', () => {
stub_state.send_msg_called += 1;
};
echo.reify_message_id = function (local_id, message_id) {
- assert.equal(typeof local_id, 'string');
- assert.equal(typeof message_id, 'number');
+ assert.equal(typeof local_id, "string");
+ assert.equal(typeof message_id, "number");
assert.equal(message_id, server_message_id);
stub_state.reify_message_id_checked += 1;
};
// 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');
+ $("#compose-send-button").attr("disabled", "disabled");
$("#sending-indicator").show();
compose.send_message();
@@ -679,24 +679,24 @@ run_test('send_message', () => {
send_msg_called: 1,
};
assert.deepEqual(stub_state, state);
- assert.equal($("#compose-textarea").val(), '');
+ assert.equal($("#compose-textarea").val(), "");
assert($("#compose-textarea").is_focused());
assert(!$("#compose-send-status").visible());
- assert.equal($("#compose-send-button").prop('disabled'), false);
+ assert.equal($("#compose-send-button").prop("disabled"), false);
assert(!$("#sending-indicator").visible());
}());
// This is the additional setup which is common to both the tests below.
transmit.send_message = function (payload, success, error) {
stub_state.send_msg_called += 1;
- error('Error sending message: Server says 408');
+ error("Error sending message: Server says 408");
};
let echo_error_msg_checked;
echo.message_send_error = function (local_id, error_response) {
assert.equal(local_id, 123.04);
- assert.equal(error_response, 'Error sending message: Server says 408');
+ assert.equal(error_response, "Error sending message: Server says 408");
echo_error_msg_checked = true;
};
@@ -717,10 +717,10 @@ run_test('send_message', () => {
(function test_error_codepath_local_id_undefined() {
stub_state = initialize_state_stub_dict();
- $("#compose-textarea").val('foobarfoobar');
+ $("#compose-textarea").val("foobarfoobar");
$("#compose-textarea").blur();
$("#compose-send-status").show();
- $("#compose-send-button").attr('disabled', 'disabled');
+ $("#compose-send-button").attr("disabled", "disabled");
$("#sending-indicator").show();
$("#compose-textarea").select(noop);
echo_error_msg_checked = false;
@@ -729,7 +729,7 @@ run_test('send_message', () => {
};
sent_messages.get_new_local_id = function () {
- return 'loc-55';
+ return "loc-55";
};
compose.send_message();
@@ -741,23 +741,23 @@ 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-textarea").val(), 'foobarfoobar');
+ assert.equal($("#compose-send-button").prop("disabled"), false);
+ 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());
- assert.equal($("#compose-send-button").prop('disabled'), false);
+ assert.equal($("#compose-send-button").prop("disabled"), false);
assert(!$("#sending-indicator").visible());
}());
});
-set_global('document', 'document-stub');
+set_global("document", "document-stub");
-run_test('enter_with_preview_open', () => {
+run_test("enter_with_preview_open", () => {
// Test sending a message with content.
- compose_state.set_message_type('stream');
- $("#compose-textarea").val('message me');
+ compose_state.set_message_type("stream");
+ $("#compose-textarea").val("message me");
$("#compose-textarea").hide();
$("#undo_markdown_preview").show();
$("#preview_message_area").show();
@@ -780,7 +780,7 @@ run_test('enter_with_preview_open', () => {
assert($("#compose-textarea").is_focused());
// Test sending a message without content.
- $("#compose-textarea").val('');
+ $("#compose-textarea").val("");
$("#preview_message_area").show();
$("#enter_sends").prop("checked", true);
page_params.enter_sends = true;
@@ -788,24 +788,24 @@ run_test('enter_with_preview_open', () => {
compose.enter_with_preview_open();
assert($("#enter_sends").prop("checked"));
- assert.equal($("#compose-error-msg").html(), i18n.t('You have nothing to send!'));
+ assert.equal($("#compose-error-msg").html(), i18n.t("You have nothing to send!"));
});
-run_test('finish', () => {
+run_test("finish", () => {
(function test_when_compose_validation_fails() {
$("#compose_invite_users").show();
- $("#compose-send-button").prop('disabled', false);
+ $("#compose-send-button").prop("disabled", false);
$("#compose-send-button").focus();
$("#sending-indicator").hide();
$("#compose-textarea").select(noop);
- $("#compose-textarea").val('');
+ $("#compose-textarea").val("");
const res = compose.finish();
assert.equal(res, false);
assert(!$("#compose_invite_users").visible());
assert(!$("#sending-indicator").visible());
assert(!$("#compose-send-button").is_focused());
- assert.equal($("#compose-send-button").prop('disabled'), false);
- assert.equal($('#compose-error-msg').html(), i18n.t('You have nothing to send!'));
+ assert.equal($("#compose-send-button").prop("disabled"), false);
+ assert.equal($("#compose-error-msg").html(), i18n.t("You have nothing to send!"));
}());
(function test_when_compose_validation_succeed() {
@@ -813,15 +813,15 @@ run_test('finish', () => {
$("#undo_markdown_preview").show();
$("#preview_message_area").show();
$("#markdown_preview").hide();
- $("#compose-textarea").val('foobarfoobar');
- compose_state.set_message_type('private');
+ $("#compose-textarea").val("foobarfoobar");
+ compose_state.set_message_type("private");
compose_state.private_message_recipient = function () {
- return '[email protected]';
+ return "[email protected]";
};
let compose_finished_event_checked = false;
$(document).trigger = function (e) {
- assert.equal(e.name, 'compose_finished.zulip');
+ assert.equal(e.name, "compose_finished.zulip");
compose_finished_event_checked = true;
};
let send_message_called = false;
@@ -838,7 +838,7 @@ run_test('finish', () => {
}());
});
-run_test('warn_if_private_stream_is_linked', () => {
+run_test("warn_if_private_stream_is_linked", () => {
stream_data.add_sub({
name: compose_state.stream_name(),
subscribers: new LazySet([1, 2]),
@@ -846,15 +846,15 @@ run_test('warn_if_private_stream_is_linked', () => {
});
let denmark = {
- name: 'Denmark',
+ name: "Denmark",
subscribers: new LazySet([1, 2, 3]),
};
function test_noop_case(invite_only) {
- compose_state.set_message_type('stream');
+ compose_state.set_message_type("stream");
denmark.invite_only = invite_only;
compose.warn_if_private_stream_is_linked(denmark);
- assert.equal($('#compose_private_stream_alert').visible(), false);
+ assert.equal($("#compose_private_stream_alert").visible(), false);
}
test_noop_case(false);
@@ -863,16 +863,16 @@ run_test('warn_if_private_stream_is_linked', () => {
test_noop_case(true);
$("#compose_private").hide();
- compose_state.set_message_type('stream');
+ compose_state.set_message_type("stream");
const checks = [
(function () {
let called;
global.stub_templates((template_name, context) => {
called = true;
- assert.equal(template_name, 'compose_private_stream_alert');
- assert.equal(context.stream_name, 'Denmark');
- return 'fake-compose_private_stream_alert-template';
+ assert.equal(template_name, "compose_private_stream_alert");
+ assert.equal(context.stream_name, "Denmark");
+ return "fake-compose_private_stream_alert-template";
});
return function () { assert(called); };
}()),
@@ -881,7 +881,7 @@ run_test('warn_if_private_stream_is_linked', () => {
let called;
$("#compose_private_stream_alert").append = function (html) {
called = true;
- assert.equal(html, 'fake-compose_private_stream_alert-template');
+ assert.equal(html, "fake-compose_private_stream_alert-template");
};
return function () { assert(called); };
}()),
@@ -889,36 +889,36 @@ run_test('warn_if_private_stream_is_linked', () => {
denmark = {
invite_only: true,
- name: 'Denmark',
+ name: "Denmark",
subscribers: new LazySet([1]),
};
compose.warn_if_private_stream_is_linked(denmark);
- assert.equal($('#compose_private_stream_alert').visible(), true);
+ assert.equal($("#compose_private_stream_alert").visible(), true);
for (const f of checks) { f(); }
});
-run_test('initialize', () => {
+run_test("initialize", () => {
// In this test we mostly do the setup stuff in addition to testing the
// normal workflow of the function. All the tests for the on functions are
// done in subsequent tests directly below this test.
let resize_watch_manual_resize_checked = false;
resize.watch_manual_resize = function (elem) {
- assert.equal('#compose-textarea', elem);
+ assert.equal("#compose-textarea", elem);
resize_watch_manual_resize_checked = true;
};
- set_global('bridge', true);
+ set_global("bridge", true);
let xmlhttprequest_checked = false;
- set_global('XMLHttpRequest', function () {
+ set_global("XMLHttpRequest", function () {
this.upload = true;
xmlhttprequest_checked = true;
});
$("#compose #attach_files").addClass("notdisplayed");
- global.document = 'document-stub';
- global.csrf_token = 'fake-csrf-token';
+ global.document = "document-stub";
+ global.csrf_token = "fake-csrf-token";
page_params.max_file_upload_size_mib = 512;
@@ -971,7 +971,7 @@ run_test('initialize', () => {
global.compose_actions = {
start: function (msg_type, opts) {
- assert.equal(msg_type, 'stream');
+ assert.equal(msg_type, "stream");
assert.deepEqual(opts, expected_opts);
compose_actions_start_checked = true;
},
@@ -991,11 +991,11 @@ run_test('initialize', () => {
}());
(function test_page_params_narrow_topic() {
- page_params.narrow_topic = 'testing';
+ page_params.narrow_topic = "testing";
reset_jquery();
stub_out_video_calls();
- set_up_compose_start_mock({topic: 'testing'});
+ set_up_compose_start_mock({topic: "testing"});
compose.initialize();
@@ -1003,7 +1003,7 @@ run_test('initialize', () => {
}());
(function test_abort_xhr() {
- $("#compose-send-button").attr('disabled', 'disabled');
+ $("#compose-send-button").attr("disabled", "disabled");
reset_jquery();
stub_out_video_calls();
@@ -1016,16 +1016,16 @@ run_test('initialize', () => {
}());
});
-run_test('update_fade', () => {
- const selector = '#stream_message_recipient_stream,#stream_message_recipient_topic,#private_message_recipient';
- const keyup_handler_func = $(selector).get_on_handler('keyup');
+run_test("update_fade", () => {
+ 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;
let update_all_called = false;
global.compose_fade = {
set_focused_recipient: function (msg_type) {
- assert.equal(msg_type, 'private');
+ assert.equal(msg_type, "private");
set_focused_recipient_checked = true;
},
update_all: function () {
@@ -1038,13 +1038,13 @@ run_test('update_fade', () => {
assert(!set_focused_recipient_checked);
assert(!update_all_called);
- compose_state.set_message_type('private');
+ compose_state.set_message_type("private");
keyup_handler_func();
assert(set_focused_recipient_checked);
assert(update_all_called);
});
-run_test('trigger_submit_compose_form', () => {
+run_test("trigger_submit_compose_form", () => {
let prevent_default_checked = false;
let compose_finish_checked = false;
const e = {
@@ -1056,7 +1056,7 @@ run_test('trigger_submit_compose_form', () => {
compose_finish_checked = true;
};
- const submit_handler = $('#compose form').get_on_handler('submit');
+ const submit_handler = $("#compose form").get_on_handler("submit");
submit_handler(e);
@@ -1064,12 +1064,12 @@ run_test('trigger_submit_compose_form', () => {
assert(compose_finish_checked);
});
-run_test('needs_subscribe_warning', () => {
+run_test("needs_subscribe_warning", () => {
const invalid_user_id = 999;
const test_bot = {
- full_name: 'Test Bot',
- email: '[email protected]',
+ full_name: "Test Bot",
+ email: "[email protected]",
user_id: 135,
is_bot: true,
};
@@ -1077,14 +1077,14 @@ run_test('needs_subscribe_warning', () => {
const sub = {
stream_id: 110,
- name: 'stream',
+ name: "stream",
can_access_subscribers: true,
};
stream_data.add_sub(sub);
stream_data.set_subscribers(sub, [bob.user_id, me.user_id]);
- blueslip.expect('error', 'Unknown user_id in get_by_user_id: 999');
+ blueslip.expect("error", "Unknown user_id in get_by_user_id: 999");
// Test with an invalid user id.
assert.equal(compose.needs_subscribe_warning(invalid_user_id, sub.stream_id), false);
@@ -1099,20 +1099,20 @@ run_test('needs_subscribe_warning', () => {
assert.equal(compose.needs_subscribe_warning(bob.user_id, sub.stream_id), true);
});
-run_test('warn_if_mentioning_unsubscribed_user', () => {
+run_test("warn_if_mentioning_unsubscribed_user", () => {
let mentioned = {
- email: '[email protected]',
+ email: "[email protected]",
};
- $('#compose_invite_users .compose_invite_user').length = 0;
+ $("#compose_invite_users .compose_invite_user").length = 0;
function test_noop_case(is_private, is_zephyr_mirror, is_broadcast) {
- const msg_type = is_private ? 'private' : 'stream';
+ const msg_type = is_private ? "private" : "stream";
compose_state.set_message_type(msg_type);
page_params.realm_is_zephyr_mirror_realm = is_zephyr_mirror;
mentioned.is_broadcast = is_broadcast;
compose.warn_if_mentioning_unsubscribed_user(mentioned);
- assert.equal($('#compose_invite_users').visible(), false);
+ assert.equal($("#compose_invite_users").visible(), false);
}
test_noop_case(true, false, false);
@@ -1120,23 +1120,23 @@ run_test('warn_if_mentioning_unsubscribed_user', () => {
test_noop_case(false, false, true);
$("#compose_invite_users").hide();
- compose_state.set_message_type('stream');
+ compose_state.set_message_type("stream");
page_params.realm_is_zephyr_mirror_realm = false;
// Test with empty stream name in compose box. It should return noop.
assert.equal(compose_state.stream_name(), "");
compose.warn_if_mentioning_unsubscribed_user(mentioned);
- assert.equal($('#compose_invite_users').visible(), false);
+ assert.equal($("#compose_invite_users").visible(), false);
- compose_state.stream_name('random');
+ compose_state.stream_name("random");
const sub = {
stream_id: 111,
- name: 'random',
+ name: "random",
};
// Test with invalid stream in compose box. It should return noop.
compose.warn_if_mentioning_unsubscribed_user(mentioned);
- assert.equal($('#compose_invite_users').visible(), false);
+ assert.equal($("#compose_invite_users").visible(), false);
// Test mentioning a user that should gets a warning.
@@ -1156,11 +1156,11 @@ run_test('warn_if_mentioning_unsubscribed_user', () => {
let called;
global.stub_templates((template_name, context) => {
called = true;
- assert.equal(template_name, 'compose_invite_users');
+ assert.equal(template_name, "compose_invite_users");
assert.equal(context.user_id, 34);
assert.equal(context.stream_id, 111);
- assert.equal(context.name, 'Foo Barson');
- return 'fake-compose-invite-user-template';
+ assert.equal(context.name, "Foo Barson");
+ return "fake-compose-invite-user-template";
});
return function () { assert(called); };
}()),
@@ -1169,61 +1169,61 @@ run_test('warn_if_mentioning_unsubscribed_user', () => {
let called;
$("#compose_invite_users").append = function (html) {
called = true;
- assert.equal(html, 'fake-compose-invite-user-template');
+ assert.equal(html, "fake-compose-invite-user-template");
};
return function () { assert(called); };
}()),
];
mentioned = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 34,
- full_name: 'Foo Barson',
+ full_name: "Foo Barson",
};
stream_data.add_sub(sub);
compose.warn_if_mentioning_unsubscribed_user(mentioned);
- assert.equal($('#compose_invite_users').visible(), true);
+ assert.equal($("#compose_invite_users").visible(), true);
for (const f of checks) { f(); }
// Simulate that the row was added to the DOM.
- const warning_row = $('<warning row>');
+ const warning_row = $("<warning row>");
let looked_for_existing;
warning_row.data = function (field) {
- if (field === 'user-id') {
+ if (field === "user-id") {
looked_for_existing = true;
- return '34';
+ return "34";
}
- if (field === 'stream-id') {
- return '111';
+ if (field === "stream-id") {
+ return "111";
}
};
- const previous_users = $('#compose_invite_users .compose_invite_user');
+ const previous_users = $("#compose_invite_users .compose_invite_user");
previous_users.length = 1;
previous_users[0] = warning_row;
- $('#compose_invite_users').hide();
+ $("#compose_invite_users").hide();
// Now try to mention the same person again. The template should
// not render.
global.stub_templates(noop);
compose.warn_if_mentioning_unsubscribed_user(mentioned);
- assert.equal($('#compose_invite_users').visible(), true);
+ assert.equal($("#compose_invite_users").visible(), true);
assert(looked_for_existing);
});
-run_test('on_events', () => {
+run_test("on_events", () => {
function setup_parents_and_mock_remove(container_sel, target_sel, parent) {
- const container = $.create('fake ' + container_sel);
+ const container = $.create("fake " + container_sel);
let container_removed = false;
container.remove = function () {
container_removed = true;
};
- const target = $.create('fake click target (' + target_sel + ')');
+ const target = $.create("fake click target (" + target_sel + ")");
target.set_parents_result(parent, container);
@@ -1244,12 +1244,12 @@ run_test('on_events', () => {
(function test_compose_all_everyone_confirm_clicked() {
const handler = $("#compose-all-everyone")
- .get_on_handler('click', '.compose-all-everyone-confirm');
+ .get_on_handler("click", ".compose-all-everyone-confirm");
const helper = setup_parents_and_mock_remove(
- 'compose-all-everyone',
- 'compose-all-everyone',
- '.compose-all-everyone',
+ "compose-all-everyone",
+ "compose-all-everyone",
+ ".compose-all-everyone",
);
$("#compose-all-everyone").show();
@@ -1270,15 +1270,15 @@ run_test('on_events', () => {
(function test_compose_invite_users_clicked() {
const handler = $("#compose_invite_users")
- .get_on_handler('click', '.compose_invite_link');
+ .get_on_handler("click", ".compose_invite_link");
const subscription = {
stream_id: 102,
- name: 'test',
+ name: "test",
subscribed: true,
};
const mentioned = {
- full_name: 'Foo Barson',
- email: '[email protected]',
+ full_name: "Foo Barson",
+ email: "[email protected]",
user_id: 34,
};
people.add_active_user(mentioned);
@@ -1291,25 +1291,25 @@ run_test('on_events', () => {
};
const helper = setup_parents_and_mock_remove(
- 'compose_invite_users',
- 'compose_invite_link',
- '.compose_invite_user',
+ "compose_invite_users",
+ "compose_invite_link",
+ ".compose_invite_user",
);
helper.container.data = function (field) {
- if (field === 'user-id') {
- return '34';
+ if (field === "user-id") {
+ return "34";
}
- if (field === 'stream-id') {
- return '102';
+ if (field === "stream-id") {
+ return "102";
}
};
$("#compose-textarea").select(noop);
- helper.target.prop('disabled', false);
+ helper.target.prop("disabled", false);
// !sub will result in true here and we check the success code path.
stream_data.add_sub(subscription);
- $('#stream_message_recipient_stream').val('test');
+ $("#stream_message_recipient_stream").val("test");
let all_invite_children_called = false;
$("#compose_invite_users").children = function () {
all_invite_children_called = true;
@@ -1327,12 +1327,12 @@ run_test('on_events', () => {
(function test_compose_invite_close_clicked() {
const handler = $("#compose_invite_users")
- .get_on_handler('click', '.compose_invite_close');
+ .get_on_handler("click", ".compose_invite_close");
const helper = setup_parents_and_mock_remove(
- 'compose_invite_users_close',
- 'compose_invite_close',
- '.compose_invite_user',
+ "compose_invite_users_close",
+ "compose_invite_close",
+ ".compose_invite_user",
);
let all_invite_children_called = false;
@@ -1351,10 +1351,10 @@ run_test('on_events', () => {
(function test_compose_not_subscribed_clicked() {
const handler = $("#compose-send-status")
- .get_on_handler('click', '.sub_unsub_button');
+ .get_on_handler("click", ".sub_unsub_button");
const subscription = {
stream_id: 102,
- name: 'test',
+ name: "test",
subscribed: false,
};
let compose_not_subscribed_called = false;
@@ -1363,9 +1363,9 @@ run_test('on_events', () => {
};
const helper = setup_parents_and_mock_remove(
- 'compose-send-status',
- 'sub_unsub_button',
- '.compose_not_subscribed',
+ "compose-send-status",
+ "sub_unsub_button",
+ ".compose_not_subscribed",
);
handler(helper.event);
@@ -1373,7 +1373,7 @@ run_test('on_events', () => {
assert(compose_not_subscribed_called);
stream_data.add_sub(subscription);
- $('#stream_message_recipient_stream').val('test');
+ $("#stream_message_recipient_stream").val("test");
$("#compose-send-status").show();
handler(helper.event);
@@ -1383,12 +1383,12 @@ run_test('on_events', () => {
(function test_compose_not_subscribed_close_clicked() {
const handler = $("#compose-send-status")
- .get_on_handler('click', '#compose_not_subscribed_close');
+ .get_on_handler("click", "#compose_not_subscribed_close");
const helper = setup_parents_and_mock_remove(
- 'compose_user_not_subscribed_close',
- 'compose_not_subscribed_close',
- '.compose_not_subscribed',
+ "compose_user_not_subscribed_close",
+ "compose_not_subscribed_close",
+ ".compose_not_subscribed",
);
$("#compose-send-status").show();
@@ -1401,12 +1401,12 @@ run_test('on_events', () => {
(function test_attach_files_compose_clicked() {
const handler = $("#compose")
.get_on_handler("click", "#attach_files");
- $('#file_input').clone = function (param) {
+ $("#file_input").clone = function (param) {
assert(param);
};
let compose_file_input_clicked = false;
- $('#compose #file_input').trigger = function (ev_name) {
- assert.equal(ev_name, 'click');
+ $("#compose #file_input").trigger = function (ev_name) {
+ assert.equal(ev_name, "click");
compose_file_input_clicked = true;
};
@@ -1419,12 +1419,12 @@ run_test('on_events', () => {
}());
(function test_video_link_compose_clicked() {
- page_params.jitsi_server_url = 'https://meet.jit.si';
+ page_params.jitsi_server_url = "https://meet.jit.si";
let syntax_to_insert;
let called = false;
- const textarea = $.create('target-stub');
+ const textarea = $.create("target-stub");
const ev = {
preventDefault: noop,
@@ -1439,7 +1439,7 @@ run_test('on_events', () => {
};
const handler = $("body").get_on_handler("click", ".video_link");
- $('#compose-textarea').val('');
+ $("#compose-textarea").val("");
handler(ev);
assert(!called);
@@ -1461,7 +1461,7 @@ run_test('on_events', () => {
page_params.realm_available_video_chat_providers.zoom.id;
window.open = function (url) {
- assert(url.endsWith('/calls/zoom/register'));
+ assert(url.endsWith("/calls/zoom/register"));
server_events_dispatch.dispatch_normal_event({
type: "has_zoom_token",
value: true,
@@ -1469,8 +1469,8 @@ run_test('on_events', () => {
};
channel.post = function (payload) {
- assert.equal(payload.url, '/json/calls/zoom/create');
- payload.success({ url: 'example.zoom.com' });
+ assert.equal(payload.url, "/json/calls/zoom/create");
+ payload.success({ url: "example.zoom.com" });
};
handler(ev);
@@ -1481,8 +1481,8 @@ run_test('on_events', () => {
page_params.realm_available_video_chat_providers.big_blue_button.id;
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' });
+ assert(options.url === "/json/calls/bigbluebutton/create");
+ options.success({ url: "/calls/bigbluebutton/join?meeting_id=%22zulip-1%22&password=%22AAAAAAAAAA%22&checksum=%2232702220bff2a22a44aee72e96cfdb4c4091752e%22" });
};
handler(ev);
@@ -1523,21 +1523,21 @@ run_test('on_events', () => {
function test_post_success(success_callback) {
const resp = {
- rendered: 'Server: foobarfoobar',
+ rendered: "Server: foobarfoobar",
};
success_callback(resp);
- assert.equal($("#preview_content").html(), 'Server: foobarfoobar');
+ assert.equal($("#preview_content").html(), "Server: foobarfoobar");
}
function test_post_error(error_callback) {
error_callback();
assert.equal($("#preview_content").html(),
- 'translated: Failed to generate preview');
+ "translated: Failed to generate preview");
}
function mock_channel_post(msg) {
channel.post = function (payload) {
- assert.equal(payload.url, '/json/messages/render');
+ assert.equal(payload.url, "/json/messages/render");
assert(payload.idempotent);
assert(payload.data);
assert.deepEqual(payload.data.content, msg);
@@ -1565,7 +1565,7 @@ run_test('on_events', () => {
.get_on_handler("click", "#markdown_preview");
// Tests start here
- $("#compose-textarea").val('');
+ $("#compose-textarea").val("");
setup_visibilities();
const event = {
@@ -1575,19 +1575,19 @@ run_test('on_events', () => {
handler(event);
assert.equal($("#preview_content").html(),
- 'translated: Nothing to preview');
+ "translated: Nothing to preview");
assert_visibilities();
let make_indicator_called = false;
- $("#compose-textarea").val('```foobarfoobar```');
+ $("#compose-textarea").val("```foobarfoobar```");
setup_visibilities();
- setup_mock_markdown_contains_backend_only_syntax('```foobarfoobar```', true);
- setup_mock_markdown_is_status_message('```foobarfoobar```', false);
+ setup_mock_markdown_contains_backend_only_syntax("```foobarfoobar```", true);
+ setup_mock_markdown_is_status_message("```foobarfoobar```", false);
loading.make_indicator = function (spinner) {
assert.equal(spinner.selector, "#markdown_preview_spinner");
make_indicator_called = true;
};
- mock_channel_post('```foobarfoobar```');
+ mock_channel_post("```foobarfoobar```");
handler(event);
@@ -1595,13 +1595,13 @@ run_test('on_events', () => {
assert_visibilities();
let apply_markdown_called = false;
- $("#compose-textarea").val('foobarfoobar');
+ $("#compose-textarea").val("foobarfoobar");
setup_visibilities();
- setup_mock_markdown_contains_backend_only_syntax('foobarfoobar', false);
- setup_mock_markdown_is_status_message('foobarfoobar', false);
- mock_channel_post('foobarfoobar');
+ setup_mock_markdown_contains_backend_only_syntax("foobarfoobar", false);
+ setup_mock_markdown_is_status_message("foobarfoobar", false);
+ mock_channel_post("foobarfoobar");
markdown.apply_markdown = function (msg) {
- assert.equal(msg.raw_content, 'foobarfoobar');
+ assert.equal(msg.raw_content, "foobarfoobar");
apply_markdown_called = true;
return msg;
};
@@ -1611,7 +1611,7 @@ run_test('on_events', () => {
assert(apply_markdown_called);
assert_visibilities();
assert.equal($("#preview_content").html(),
- 'Server: foobarfoobar');
+ "Server: foobarfoobar");
}());
(function test_undo_markdown_preview_clicked() {
@@ -1637,18 +1637,18 @@ run_test('on_events', () => {
});
-run_test('create_message_object', () => {
+run_test("create_message_object", () => {
const sub = {
stream_id: 101,
- name: 'social',
+ name: "social",
subscribed: true,
};
stream_data.add_sub(sub);
const page = {
- '#stream_message_recipient_stream': 'social',
- '#stream_message_recipient_topic': 'lunch',
- '#compose-textarea': 'burrito',
+ "#stream_message_recipient_stream": "social",
+ "#stream_message_recipient_topic": "lunch",
+ "#compose-textarea": "burrito",
};
global.$ = function (selector) {
@@ -1660,7 +1660,7 @@ run_test('create_message_object', () => {
};
global.compose_state.get_message_type = function () {
- return 'stream';
+ return "stream";
};
global.$.trim = function (s) {
@@ -1669,28 +1669,28 @@ run_test('create_message_object', () => {
let message = compose.create_message_object();
assert.equal(message.to, sub.stream_id);
- assert.equal(message.topic, 'lunch');
- assert.equal(message.content, 'burrito');
+ assert.equal(message.topic, "lunch");
+ assert.equal(message.content, "burrito");
- blueslip.expect('error', 'Trying to send message with bad stream name: BOGUS STREAM');
+ blueslip.expect("error", "Trying to send message with bad stream name: BOGUS STREAM");
- page['#stream_message_recipient_stream'] = 'BOGUS STREAM';
+ page["#stream_message_recipient_stream"] = "BOGUS STREAM";
message = compose.create_message_object();
- assert.equal(message.to, 'BOGUS STREAM');
- assert.equal(message.topic, 'lunch');
- assert.equal(message.content, 'burrito');
+ assert.equal(message.to, "BOGUS STREAM");
+ assert.equal(message.topic, "lunch");
+ assert.equal(message.content, "burrito");
global.compose_state.get_message_type = function () {
- return 'private';
+ return "private";
};
compose_state.private_message_recipient = function () {
};
message = compose.create_message_object();
assert.deepEqual(message.to, [alice.user_id, bob.user_id]);
- assert.equal(message.to_user_ids, '31,32');
- assert.equal(message.content, 'burrito');
+ assert.equal(message.to_user_ids, "31,32");
+ assert.equal(message.content, "burrito");
const { email_list_to_user_ids_string } = people;
people.email_list_to_user_ids_string = () => undefined;
@@ -1699,8 +1699,8 @@ run_test('create_message_object', () => {
people.email_list_to_user_ids_string = email_list_to_user_ids_string;
});
-run_test('nonexistent_stream_reply_error', () => {
- set_global('$', global.make_zjquery());
+run_test("nonexistent_stream_reply_error", () => {
+ set_global("$", global.make_zjquery());
const actions = [];
$("#nonexistent_stream_reply_error").show = () => {
@@ -1711,11 +1711,11 @@ run_test('nonexistent_stream_reply_error', () => {
};
compose.nonexistent_stream_reply_error();
- assert.equal($("#compose-reply-error-msg").html(), 'There are no messages to reply to yet.');
+ assert.equal($("#compose-reply-error-msg").html(), "There are no messages to reply to yet.");
assert.deepEqual(actions, ["show", "hide"]);
});
-run_test('narrow_button_titles', () => {
+run_test("narrow_button_titles", () => {
util.is_mobile = () => false;
compose.update_closed_compose_buttons_for_private();
@@ -1727,7 +1727,7 @@ run_test('narrow_button_titles', () => {
assert.equal($("#left_bar_compose_private_button_big").text(), i18n.t("New private message"));
});
-run_test('test_video_chat_button_toggle', () => {
+run_test("test_video_chat_button_toggle", () => {
reset_jquery();
stub_out_video_calls();
@@ -1745,7 +1745,7 @@ run_test('test_video_chat_button_toggle', () => {
reset_jquery();
stub_out_video_calls();
- page_params.jitsi_server_url = 'https://meet.jit.si';
+ page_params.jitsi_server_url = "https://meet.jit.si";
compose.initialize();
assert.equal($("#below-compose-content .video_link").visible(), true);
});
diff --git a/frontend_tests/node_tests/compose_actions.js b/frontend_tests/node_tests/compose_actions.js
index 78c77234224..8e496058761 100644
--- a/frontend_tests/node_tests/compose_actions.js
+++ b/frontend_tests/node_tests/compose_actions.js
@@ -2,29 +2,29 @@ const noop = function () {};
const return_false = function () { return false; };
const return_true = function () { return true; };
-set_global('document', {
+set_global("document", {
location: {}, // we need this to load compose.js
});
-set_global('page_params', {});
+set_global("page_params", {});
-set_global('$', global.make_zjquery());
+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');
-zrequire('compose');
-zrequire('compose_state');
-zrequire('compose_actions');
-zrequire('fenced_code');
-zrequire('stream_data');
+zrequire("people");
+zrequire("compose_ui");
+zrequire("compose");
+zrequire("compose_state");
+zrequire("compose_actions");
+zrequire("fenced_code");
+zrequire("stream_data");
-set_global('document', 'document-stub');
+set_global("document", "document-stub");
const start = compose_actions.start;
const cancel = compose_actions.cancel;
@@ -47,36 +47,36 @@ compose_state.private_message_recipient = (function () {
};
}());
-set_global('reload_state', {
+set_global("reload_state", {
is_in_progress: return_false,
});
-set_global('notifications', {
+set_global("notifications", {
clear_compose_notifications: noop,
});
-set_global('compose_fade', {
+set_global("compose_fade", {
clear_compose: noop,
});
-set_global('drafts', {
+set_global("drafts", {
update_draft: noop,
});
-set_global('narrow_state', {
+set_global("narrow_state", {
set_compose_defaults: noop,
});
-set_global('unread_ops', {
+set_global("unread_ops", {
notify_server_message_read: noop,
});
-set_global('common', {
- status_classes: 'status_classes',
+set_global("common", {
+ status_classes: "status_classes",
});
function stub_selected_message(msg) {
- set_global('current_msg_list', {
+ set_global("current_msg_list", {
selected_message: function () {
return msg;
},
@@ -87,7 +87,7 @@ function stub_selected_message(msg) {
}
function stub_channel_get(success_value) {
- set_global('channel', {
+ set_global("channel", {
get: function (opts) {
opts.success(success_value);
},
@@ -102,13 +102,13 @@ function assert_hidden(sel) {
assert(!$(sel).visible());
}
-run_test('initial_state', () => {
+run_test("initial_state", () => {
assert.equal(compose_state.composing(), false);
assert.equal(compose_state.get_message_type(), false);
assert.equal(compose_state.has_message_content(), false);
});
-run_test('start', () => {
+run_test("start", () => {
compose_actions.autosize_message_content = noop;
compose_actions.expand_compose_box = noop;
compose_actions.set_focus = noop;
@@ -119,27 +119,27 @@ run_test('start', () => {
// Start stream message
global.narrow_state.set_compose_defaults = function () {
const opts = {};
- opts.stream = 'stream1';
- opts.topic = 'topic1';
+ opts.stream = "stream1";
+ opts.topic = "topic1";
return opts;
};
let opts = {};
- start('stream', opts);
+ start("stream", opts);
- assert_visible('#stream-message');
- assert_hidden('#private-message');
+ assert_visible("#stream-message");
+ assert_hidden("#private-message");
- assert.equal($('#stream_message_recipient_stream').val(), 'stream1');
- assert.equal($('#stream_message_recipient_topic').val(), 'topic1');
- assert.equal(compose_state.get_message_type(), 'stream');
+ assert.equal($("#stream_message_recipient_stream").val(), "stream1");
+ assert.equal($("#stream_message_recipient_topic").val(), "topic1");
+ assert.equal(compose_state.get_message_type(), "stream");
assert(compose_state.composing());
// Autofill stream field for single subscription
const denmark = {
subscribed: true,
- color: 'blue',
- name: 'Denmark',
+ color: "blue",
+ name: "Denmark",
stream_id: 1,
};
stream_data.add_sub(denmark);
@@ -151,9 +151,9 @@ run_test('start', () => {
};
opts = {};
- start('stream', opts);
- assert.equal($('#stream_message_recipient_stream').val(), 'Denmark');
- assert.equal($('#stream_message_recipient_topic').val(), '');
+ start("stream", opts);
+ assert.equal($("#stream_message_recipient_stream").val(), "Denmark");
+ assert.equal($("#stream_message_recipient_topic").val(), "");
global.narrow_state.set_compose_defaults = function () {
const opts = {};
@@ -162,45 +162,45 @@ run_test('start', () => {
};
opts = {};
- start('stream', opts);
- assert.equal($('#stream_message_recipient_stream').val(), 'Denmark');
- assert.equal($('#stream_message_recipient_topic').val(), '');
+ start("stream", opts);
+ assert.equal($("#stream_message_recipient_stream").val(), "Denmark");
+ assert.equal($("#stream_message_recipient_topic").val(), "");
const social = {
subscribed: true,
- color: 'red',
- name: 'social',
+ color: "red",
+ name: "social",
stream_id: 2,
};
stream_data.add_sub(social);
// More than 1 subscription, do not autofill
opts = {};
- start('stream', opts);
- assert.equal($('#stream_message_recipient_stream').val(), '');
- assert.equal($('#stream_message_recipient_topic').val(), '');
+ start("stream", opts);
+ assert.equal($("#stream_message_recipient_stream").val(), "");
+ assert.equal($("#stream_message_recipient_topic").val(), "");
stream_data.clear_subscriptions();
// Start PM
global.narrow_state.set_compose_defaults = function () {
const opts = {};
- opts.private_message_recipient = '[email protected]';
+ opts.private_message_recipient = "[email protected]";
return opts;
};
opts = {
- content: 'hello',
+ content: "hello",
};
- $('#compose-textarea').trigger = noop;
- start('private', opts);
+ $("#compose-textarea").trigger = noop;
+ start("private", opts);
- assert_hidden('#stream-message');
- assert_visible('#private-message');
+ assert_hidden("#stream-message");
+ assert_visible("#private-message");
- assert.equal(compose_state.private_message_recipient(), '[email protected]');
- assert.equal($('#compose-textarea').val(), 'hello');
- assert.equal(compose_state.get_message_type(), 'private');
+ assert.equal(compose_state.private_message_recipient(), "[email protected]");
+ assert.equal($("#compose-textarea").val(), "hello");
+ assert.equal(compose_state.get_message_type(), "private");
assert(compose_state.composing());
// Cancel compose.
@@ -214,43 +214,43 @@ run_test('start', () => {
abort_xhr_called = true;
};
- assert_hidden('#compose_controls');
+ assert_hidden("#compose_controls");
cancel();
assert(abort_xhr_called);
assert(pill_cleared);
- assert_visible('#compose_controls');
- assert_hidden('#private-message');
+ assert_visible("#compose_controls");
+ assert_hidden("#private-message");
assert(!compose_state.composing());
});
-run_test('respond_to_message', () => {
+run_test("respond_to_message", () => {
// Test PM
const person = {
user_id: 22,
- email: '[email protected]',
- full_name: 'Alice',
+ email: "[email protected]",
+ full_name: "Alice",
};
people.add_active_user(person);
let msg = {
- type: 'private',
+ type: "private",
sender_id: person.user_id,
};
stub_selected_message(msg);
let opts = {
- reply_type: 'personal',
+ reply_type: "personal",
};
respond_to_message(opts);
- assert.equal(compose_state.private_message_recipient(), '[email protected]');
+ assert.equal(compose_state.private_message_recipient(), "[email protected]");
// Test stream
msg = {
- type: 'stream',
- stream: 'devel',
- topic: 'python',
- reply_to: 'bob', // compose.start needs this for dubious reasons
+ type: "stream",
+ stream: "devel",
+ topic: "python",
+ reply_to: "bob", // compose.start needs this for dubious reasons
};
stub_selected_message(msg);
@@ -258,16 +258,16 @@ run_test('respond_to_message', () => {
};
respond_to_message(opts);
- assert.equal($('#stream_message_recipient_stream').val(), 'devel');
+ assert.equal($("#stream_message_recipient_stream").val(), "devel");
});
-run_test('reply_with_mention', () => {
+run_test("reply_with_mention", () => {
const msg = {
- type: 'stream',
- stream: 'devel',
- topic: 'python',
- reply_to: 'bob', // compose.start needs this for dubious reasons
- sender_full_name: 'Bob Roberts',
+ type: "stream",
+ stream: "devel",
+ topic: "python",
+ reply_to: "bob", // compose.start needs this for dubious reasons
+ sender_full_name: "Bob Roberts",
sender_id: 40,
};
stub_selected_message(msg);
@@ -281,43 +281,43 @@ run_test('reply_with_mention', () => {
};
reply_with_mention(opts);
- assert.equal($('#stream_message_recipient_stream').val(), 'devel');
- assert.equal(syntax_to_insert, '@**Bob Roberts**');
+ assert.equal($("#stream_message_recipient_stream").val(), "devel");
+ assert.equal(syntax_to_insert, "@**Bob Roberts**");
assert(compose_state.has_message_content());
// Test for extended mention syntax
const bob_1 = {
user_id: 30,
- email: '[email protected]',
- full_name: 'Bob Roberts',
+ email: "[email protected]",
+ full_name: "Bob Roberts",
};
people.add_active_user(bob_1);
const bob_2 = {
user_id: 40,
- email: '[email protected]',
- full_name: 'Bob Roberts',
+ email: "[email protected]",
+ full_name: "Bob Roberts",
};
people.add_active_user(bob_2);
reply_with_mention(opts);
- assert.equal($('#stream_message_recipient_stream').val(), 'devel');
- assert.equal(syntax_to_insert, '@**Bob Roberts|40**');
+ assert.equal($("#stream_message_recipient_stream").val(), "devel");
+ assert.equal(syntax_to_insert, "@**Bob Roberts|40**");
assert(compose_state.has_message_content());
});
-run_test('quote_and_reply', () => {
+run_test("quote_and_reply", () => {
const msg = {
- type: 'stream',
- stream: 'devel',
- topic: 'python',
- reply_to: 'bob',
- sender_full_name: 'Bob Roberts',
+ type: "stream",
+ stream: "devel",
+ topic: "python",
+ reply_to: "bob",
+ sender_full_name: "Bob Roberts",
sender_id: 40,
};
- hash_util.by_conversation_and_time_uri = () => 'link_to_message';
+ hash_util.by_conversation_and_time_uri = () => "link_to_message";
stub_selected_message(msg);
stub_channel_get({
- raw_content: 'Testing.',
+ raw_content: "Testing.",
});
current_msg_list.selected_id = function () {
@@ -325,19 +325,19 @@ run_test('quote_and_reply', () => {
};
compose_ui.insert_syntax_and_focus = function (syntax) {
- assert.equal(syntax, '[Quoting…]\n');
+ assert.equal(syntax, "[Quoting…]\n");
};
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(syntax, "[Quoting…]");
+ assert.equal(replacement, "@_**Bob Roberts|40** [said](link_to_message):\n```quote\nTesting.\n```");
};
const opts = {
- reply_type: 'personal',
+ reply_type: "personal",
};
- $('#compose-textarea').caret = (pos) => {
+ $("#compose-textarea").caret = (pos) => {
assert.equal(pos, 0);
};
@@ -345,78 +345,78 @@ run_test('quote_and_reply', () => {
current_msg_list.selected_message = function () {
return {
- type: 'stream',
- stream: 'devel',
- topic: 'test',
- reply_to: 'bob',
- sender_full_name: 'Bob Roberts',
+ type: "stream",
+ stream: "devel",
+ topic: "test",
+ reply_to: "bob",
+ sender_full_name: "Bob Roberts",
sender_id: 40,
- raw_content: 'Testing.',
+ raw_content: "Testing.",
};
};
channel.get = function () {
- assert.fail('channel.get should not be used if raw_content is present');
+ assert.fail("channel.get should not be used if raw_content is present");
};
quote_and_reply(opts);
current_msg_list.selected_message = function () {
return {
- type: 'stream',
- stream: 'devel',
- topic: 'test',
- reply_to: 'bob',
- sender_full_name: 'Bob Roberts',
+ type: "stream",
+ stream: "devel",
+ topic: "test",
+ reply_to: "bob",
+ sender_full_name: "Bob Roberts",
sender_id: 40,
- raw_content: '```\nmultiline code block\nshoudln\'t mess with quotes\n```',
+ raw_content: "```\nmultiline code block\nshoudln't mess with quotes\n```",
};
};
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(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````");
};
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('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');
+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("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");
});
-run_test('focus_in_empty_compose', () => {
- $('#compose-textarea').is = function (attr) {
- assert.equal(attr, ':focus');
- return $('#compose-textarea').is_focused;
+run_test("focus_in_empty_compose", () => {
+ $("#compose-textarea").is = function (attr) {
+ assert.equal(attr, ":focus");
+ return $("#compose-textarea").is_focused;
};
compose_state.composing = return_true;
- $('#compose-textarea').val('');
- $('#compose-textarea').focus();
+ $("#compose-textarea").val("");
+ $("#compose-textarea").focus();
assert(compose_state.focus_in_empty_compose());
compose_state.composing = return_false;
assert(!compose_state.focus_in_empty_compose());
- $('#compose-textarea').val('foo');
+ $("#compose-textarea").val("foo");
assert(!compose_state.focus_in_empty_compose());
- $('#compose-textarea').blur();
+ $("#compose-textarea").blur();
assert(!compose_state.focus_in_empty_compose());
});
-run_test('on_narrow', () => {
+run_test("on_narrow", () => {
let cancel_called = false;
compose_actions.cancel = function () {
cancel_called = true;
@@ -465,16 +465,16 @@ run_test('on_narrow', () => {
};
compose_actions.on_narrow({
force_close: false,
- trigger: 'not-search',
- private_message_recipient: '[email protected]',
+ trigger: "not-search",
+ private_message_recipient: "[email protected]",
});
assert(start_called);
start_called = false;
compose_actions.on_narrow({
force_close: false,
- trigger: 'search',
- private_message_recipient: '',
+ trigger: "search",
+ private_message_recipient: "",
});
assert(!start_called);
diff --git a/frontend_tests/node_tests/compose_fade.js b/frontend_tests/node_tests/compose_fade.js
index 6095bab4902..f2be64d36fb 100644
--- a/frontend_tests/node_tests/compose_fade.js
+++ b/frontend_tests/node_tests/compose_fade.js
@@ -1,23 +1,23 @@
-zrequire('stream_data');
-zrequire('people');
-zrequire('compose_fade');
+zrequire("stream_data");
+zrequire("people");
+zrequire("compose_fade");
const me = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 30,
- full_name: 'Me Myself',
+ full_name: "Me Myself",
};
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 31,
- full_name: 'Alice',
+ full_name: "Alice",
};
const bob = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 32,
- full_name: 'Bob',
+ full_name: "Bob",
};
people.add_active_user(me);
@@ -26,10 +26,10 @@ people.initialize_current_user(me.user_id);
people.add_active_user(alice);
people.add_active_user(bob);
-run_test('set_focused_recipient', () => {
+run_test("set_focused_recipient", () => {
const sub = {
stream_id: 101,
- name: 'social',
+ name: "social",
subscribed: true,
can_access_subscribers: true,
};
@@ -38,36 +38,36 @@ run_test('set_focused_recipient', () => {
global.$ = function (selector) {
switch (selector) {
- case '#stream_message_recipient_stream':
+ case "#stream_message_recipient_stream":
return {
val: function () {
- return 'social';
+ return "social";
},
};
- case '#stream_message_recipient_topic':
+ case "#stream_message_recipient_topic":
return {
val: function () {
- return 'lunch';
+ return "lunch";
},
};
}
};
- compose_fade.set_focused_recipient('stream');
+ compose_fade.set_focused_recipient("stream");
assert.equal(compose_fade.would_receive_message(me.user_id), true);
assert.equal(compose_fade.would_receive_message(alice.user_id), true);
assert.equal(compose_fade.would_receive_message(bob.user_id), false);
const good_msg = {
- type: 'stream',
+ type: "stream",
stream_id: 101,
- topic: 'lunch',
+ topic: "lunch",
};
const bad_msg = {
- type: 'stream',
+ type: "stream",
stream_id: 999,
- topic: 'lunch',
+ topic: "lunch",
};
assert(!compose_fade.should_fade_message(good_msg));
assert(compose_fade.should_fade_message(bad_msg));
diff --git a/frontend_tests/node_tests/compose_pm_pill.js b/frontend_tests/node_tests/compose_pm_pill.js
index a5a3ad8d0ed..995775718b3 100644
--- a/frontend_tests/node_tests/compose_pm_pill.js
+++ b/frontend_tests/node_tests/compose_pm_pill.js
@@ -1,38 +1,38 @@
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
const _people = {
small_avatar_url_for_person: function () {
- return 'http://example.com/example.png';
+ return "http://example.com/example.png";
},
};
-set_global('people', _people);
+set_global("people", _people);
-zrequire('compose_pm_pill');
-zrequire('input_pill');
-zrequire('user_pill');
+zrequire("compose_pm_pill");
+zrequire("input_pill");
+zrequire("user_pill");
let pills = {
pill: {},
};
-run_test('pills', () => {
+run_test("pills", () => {
const othello = {
user_id: 1,
- email: '[email protected]',
- full_name: 'Othello',
+ email: "[email protected]",
+ full_name: "Othello",
};
const iago = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 2,
- full_name: 'Iago',
+ full_name: "Iago",
};
const hamlet = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 3,
- full_name: 'Hamlet',
+ full_name: "Hamlet",
};
people.get_realm_users = function () {
@@ -72,7 +72,7 @@ run_test('pills', () => {
let appendValue_called;
pills.appendValue = function (value) {
appendValue_called = true;
- assert.equal(value, '[email protected]');
+ assert.equal(value, "[email protected]");
this.appendValidatedData(othello);
};
@@ -108,7 +108,7 @@ run_test('pills', () => {
get_by_email_called = false;
const res = handler(iago.email, pills.items());
assert(get_by_email_called);
- assert.equal(typeof res, 'object');
+ assert.equal(typeof res, "object");
assert.equal(res.user_id, iago.user_id);
assert.equal(res.display_value, iago.full_name);
}());
@@ -133,18 +133,18 @@ run_test('pills', () => {
assert.deepEqual(user_ids, [othello.user_id, hamlet.user_id]);
const user_ids_string = compose_pm_pill.get_user_ids_string();
- assert.equal(user_ids_string, '1,3');
+ assert.equal(user_ids_string, "1,3");
const emails = compose_pm_pill.get_emails();
- assert.equal(emails, '[email protected],[email protected]');
+ assert.equal(emails, "[email protected],[email protected]");
const persons = [othello, iago, hamlet];
const items = compose_pm_pill.filter_taken_users(persons);
- assert.deepEqual(items, [{email: '[email protected]', user_id: 2, full_name: 'Iago'}]);
+ assert.deepEqual(items, [{email: "[email protected]", user_id: 2, full_name: "Iago"}]);
test_create_item(create_item_handler);
- compose_pm_pill.set_from_emails('[email protected]');
+ compose_pm_pill.set_from_emails("[email protected]");
assert(compose_pm_pill.widget);
assert(get_by_user_id_called);
@@ -153,7 +153,7 @@ run_test('pills', () => {
assert(text_cleared);
});
-run_test('has_unconverted_data', () => {
+run_test("has_unconverted_data", () => {
compose_pm_pill.widget = {
is_pending: () => true,
};
@@ -173,7 +173,7 @@ run_test('has_unconverted_data', () => {
compose_pm_pill.widget = {
is_pending: () => false,
- items: () => [{user_id: 99}, {email: '[email protected]'}],
+ items: () => [{user_id: 99}, {email: "[email protected]"}],
};
// One of our items only knows email (as in a bridge-with-zephyr
diff --git a/frontend_tests/node_tests/compose_ui.js b/frontend_tests/node_tests/compose_ui.js
index e29fdefd503..0fdb30b92a6 100644
--- a/frontend_tests/node_tests/compose_ui.js
+++ b/frontend_tests/node_tests/compose_ui.js
@@ -1,22 +1,22 @@
-zrequire('compose_ui');
-zrequire('people');
-zrequire('user_status');
+zrequire("compose_ui");
+zrequire("people");
+zrequire("user_status");
-set_global('document', {
+set_global("document", {
execCommand: function () { return false; },
});
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 101,
- full_name: 'Alice',
+ full_name: "Alice",
};
const bob = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 102,
- full_name: 'Bob',
+ full_name: "Bob",
};
people.add_active_user(alice);
@@ -30,7 +30,7 @@ function make_textbox(s) {
widget.focused = false;
widget.caret = function (arg) {
- if (typeof arg === 'number') {
+ if (typeof arg === "number") {
widget.pos = arg;
return;
}
@@ -71,75 +71,75 @@ function make_textbox(s) {
return widget;
}
-run_test('insert_syntax_and_focus', () => {
- $('#compose-textarea').val("xyz ");
- $('#compose-textarea').caret = function (syntax) {
+run_test("insert_syntax_and_focus", () => {
+ $("#compose-textarea").val("xyz ");
+ $("#compose-textarea").caret = function (syntax) {
if (syntax !== undefined) {
- $('#compose-textarea').val($('#compose-textarea').val() + syntax);
+ $("#compose-textarea").val($("#compose-textarea").val() + syntax);
} else {
return 4;
}
};
- compose_ui.insert_syntax_and_focus(':octopus:');
- assert.equal($('#compose-textarea').caret(), 4);
- assert.equal($('#compose-textarea').val(), 'xyz :octopus: ');
+ compose_ui.insert_syntax_and_focus(":octopus:");
+ assert.equal($("#compose-textarea").caret(), 4);
+ assert.equal($("#compose-textarea").val(), "xyz :octopus: ");
assert($("#compose-textarea").is_focused());
});
-run_test('smart_insert', () => {
- let textbox = make_textbox('abc');
+run_test("smart_insert", () => {
+ let textbox = make_textbox("abc");
textbox.caret(4);
- compose_ui.smart_insert(textbox, ':smile:');
+ compose_ui.smart_insert(textbox, ":smile:");
assert.equal(textbox.insert_pos, 4);
- assert.equal(textbox.insert_text, ' :smile: ');
- assert.equal(textbox.val(), 'abc :smile: ');
+ assert.equal(textbox.insert_text, " :smile: ");
+ assert.equal(textbox.val(), "abc :smile: ");
assert(textbox.focused);
textbox.blur();
- compose_ui.smart_insert(textbox, ':airplane:');
- assert.equal(textbox.insert_text, ':airplane: ');
- assert.equal(textbox.val(), 'abc :smile: :airplane: ');
+ compose_ui.smart_insert(textbox, ":airplane:");
+ assert.equal(textbox.insert_text, ":airplane: ");
+ assert.equal(textbox.val(), "abc :smile: :airplane: ");
assert(textbox.focused);
textbox.caret(0);
textbox.blur();
- compose_ui.smart_insert(textbox, ':octopus:');
- assert.equal(textbox.insert_text, ':octopus: ');
- assert.equal(textbox.val(), ':octopus: abc :smile: :airplane: ');
+ compose_ui.smart_insert(textbox, ":octopus:");
+ assert.equal(textbox.insert_text, ":octopus: ");
+ assert.equal(textbox.val(), ":octopus: abc :smile: :airplane: ");
assert(textbox.focused);
textbox.caret(textbox.val().length);
textbox.blur();
- compose_ui.smart_insert(textbox, ':heart:');
- assert.equal(textbox.insert_text, ':heart: ');
- assert.equal(textbox.val(), ':octopus: abc :smile: :airplane: :heart: ');
+ compose_ui.smart_insert(textbox, ":heart:");
+ assert.equal(textbox.insert_text, ":heart: ");
+ assert.equal(textbox.val(), ":octopus: abc :smile: :airplane: :heart: ");
assert(textbox.focused);
// Test handling of spaces for ```quote
- textbox = make_textbox('');
+ textbox = make_textbox("");
textbox.caret(0);
textbox.blur();
- compose_ui.smart_insert(textbox, '```quote\nquoted message\n```\n');
- assert.equal(textbox.insert_text, '```quote\nquoted message\n```\n');
- assert.equal(textbox.val(), '```quote\nquoted message\n```\n');
+ compose_ui.smart_insert(textbox, "```quote\nquoted message\n```\n");
+ assert.equal(textbox.insert_text, "```quote\nquoted message\n```\n");
+ assert.equal(textbox.val(), "```quote\nquoted message\n```\n");
assert(textbox.focused);
- textbox = make_textbox('');
+ textbox = make_textbox("");
textbox.caret(0);
textbox.blur();
compose_ui.smart_insert(textbox, "[Quoting…]\n");
- assert.equal(textbox.insert_text, '[Quoting…]\n');
- assert.equal(textbox.val(), '[Quoting…]\n');
+ assert.equal(textbox.insert_text, "[Quoting…]\n");
+ assert.equal(textbox.val(), "[Quoting…]\n");
assert(textbox.focused);
- textbox = make_textbox('abc');
+ textbox = make_textbox("abc");
textbox.caret(3);
textbox.blur();
compose_ui.smart_insert(textbox, " test with space");
- assert.equal(textbox.insert_text, ' test with space ');
- assert.equal(textbox.val(), 'abc test with space ');
+ assert.equal(textbox.insert_text, " test with space ");
+ assert.equal(textbox.val(), "abc test with space ");
assert(textbox.focused);
// Note that we don't have any special logic for strings that are
@@ -147,26 +147,26 @@ run_test('smart_insert', () => {
// like emojis and file links.
});
-run_test('replace_syntax', () => {
- $('#compose-textarea').val('abcabc');
+run_test("replace_syntax", () => {
+ $("#compose-textarea").val("abcabc");
- compose_ui.replace_syntax('a', 'A');
- assert.equal($('#compose-textarea').val(), 'Abcabc');
+ compose_ui.replace_syntax("a", "A");
+ assert.equal($("#compose-textarea").val(), "Abcabc");
- compose_ui.replace_syntax(/b/g, 'B');
- assert.equal($('#compose-textarea').val(), 'ABcaBc');
+ compose_ui.replace_syntax(/b/g, "B");
+ assert.equal($("#compose-textarea").val(), "ABcaBc");
// Verify we correctly handle `$`s in the replacement syntax
- compose_ui.replace_syntax('Bca', '$$\\pi$$');
- assert.equal($('#compose-textarea').val(), 'A$$\\pi$$Bc');
+ compose_ui.replace_syntax("Bca", "$$\\pi$$");
+ assert.equal($("#compose-textarea").val(), "A$$\\pi$$Bc");
});
-run_test('compute_placeholder_text', () => {
+run_test("compute_placeholder_text", () => {
let opts = {
- message_type: 'stream',
- stream: '',
- topic: '',
- private_message_recipient: '',
+ message_type: "stream",
+ stream: "",
+ topic: "",
+ private_message_recipient: "",
};
// Stream narrows
@@ -180,28 +180,28 @@ run_test('compute_placeholder_text', () => {
// PM Narrows
opts = {
- message_type: 'private',
- stream: '',
- topic: '',
- private_message_recipient: '',
+ message_type: "private",
+ stream: "",
+ topic: "",
+ private_message_recipient: "",
};
assert.equal(compose_ui.compute_placeholder_text(opts), i18n.t("Compose your message here"));
- opts.private_message_recipient = '[email protected]';
+ opts.private_message_recipient = "[email protected]";
user_status.set_status_text({
user_id: bob.user_id,
- status_text: 'out to lunch',
+ status_text: "out to lunch",
});
assert.equal(compose_ui.compute_placeholder_text(opts), i18n.t("Message Bob (out to lunch)"));
- opts.private_message_recipient = '[email protected]';
+ opts.private_message_recipient = "[email protected]";
user_status.set_status_text({
user_id: alice.user_id,
- status_text: '',
+ status_text: "",
});
assert.equal(compose_ui.compute_placeholder_text(opts), i18n.t("Message Alice"));
// Group PM
- opts.private_message_recipient = '[email protected],[email protected]';
+ opts.private_message_recipient = "[email protected],[email protected]";
assert.equal(compose_ui.compute_placeholder_text(opts), i18n.t("Message Alice, Bob"));
});
diff --git a/frontend_tests/node_tests/composebox_typeahead.js b/frontend_tests/node_tests/composebox_typeahead.js
index e5e6185f182..51444cfda47 100644
--- a/frontend_tests/node_tests/composebox_typeahead.js
+++ b/frontend_tests/node_tests/composebox_typeahead.js
@@ -1,29 +1,29 @@
-const typeahead = zrequire('typeahead', 'shared/js/typeahead');
-zrequire('compose_state');
-zrequire('pm_conversations');
-zrequire('emoji');
-set_global('Handlebars', global.make_handlebars());
-zrequire('templates');
-zrequire('typeahead_helper');
-zrequire('people');
-zrequire('user_groups');
-zrequire('stream_data');
-zrequire('user_pill');
-zrequire('compose_pm_pill');
-zrequire('composebox_typeahead');
-zrequire('recent_senders');
-zrequire('settings_org');
-const settings_config = zrequire('settings_config');
-set_global('md5', (s) => 'md5-' + s);
+const typeahead = zrequire("typeahead", "shared/js/typeahead");
+zrequire("compose_state");
+zrequire("pm_conversations");
+zrequire("emoji");
+set_global("Handlebars", global.make_handlebars());
+zrequire("templates");
+zrequire("typeahead_helper");
+zrequire("people");
+zrequire("user_groups");
+zrequire("stream_data");
+zrequire("user_pill");
+zrequire("compose_pm_pill");
+zrequire("composebox_typeahead");
+zrequire("recent_senders");
+zrequire("settings_org");
+const settings_config = zrequire("settings_config");
+set_global("md5", (s) => "md5-" + s);
// To be eliminated in next commit:
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', {
+set_global("message_store", {
user_ids: () => [],
});
@@ -36,68 +36,68 @@ const noop = function () {};
ct.max_num_items = 15;
const mention_all = ct.broadcast_mentions()[0];
-assert.equal(mention_all.email, 'all');
-assert.equal(mention_all.full_name, 'all');
+assert.equal(mention_all.email, "all");
+assert.equal(mention_all.full_name, "all");
const emoji_stadium = {
- name: 'stadium',
- aliases: ['stadium'],
- emoji_url: 'TBD',
- emoji_code: '1f3df',
+ name: "stadium",
+ aliases: ["stadium"],
+ emoji_url: "TBD",
+ emoji_code: "1f3df",
};
const emoji_tada = {
- name: 'tada',
- aliases: ['tada'],
- emoji_url: 'TBD',
- emoji_code: '1f389',
+ name: "tada",
+ aliases: ["tada"],
+ emoji_url: "TBD",
+ emoji_code: "1f389",
};
const emoji_moneybag = {
- name: 'moneybag',
- aliases: ['moneybag'],
- emoji_url: 'TBD',
- emoji_code: '1f4b0',
+ name: "moneybag",
+ aliases: ["moneybag"],
+ emoji_url: "TBD",
+ emoji_code: "1f4b0",
};
const emoji_japanese_post_office = {
- name: 'japanese_post_office',
- aliases: ['japanese_post_office'],
- emoji_url: 'TBD',
- emoji_code: '1f3e3',
+ name: "japanese_post_office",
+ aliases: ["japanese_post_office"],
+ emoji_url: "TBD",
+ emoji_code: "1f3e3",
};
const emoji_panda_face = {
- name: 'panda_face',
- aliases: ['panda_face'],
- emoji_url: 'TBD',
- emoji_code: '1f43c',
+ name: "panda_face",
+ aliases: ["panda_face"],
+ emoji_url: "TBD",
+ emoji_code: "1f43c",
};
const emoji_see_no_evil = {
- name: 'see_no_evil',
- aliases: ['see_no_evil'],
- emoji_url: 'TBD',
- emoji_code: '1f648',
+ name: "see_no_evil",
+ aliases: ["see_no_evil"],
+ emoji_url: "TBD",
+ emoji_code: "1f648",
};
const emoji_thumbs_up = {
- name: 'thumbs_up',
- aliases: ['thumbs_up'],
- emoji_url: 'TBD',
- emoji_code: '1f44d',
+ name: "thumbs_up",
+ aliases: ["thumbs_up"],
+ emoji_url: "TBD",
+ emoji_code: "1f44d",
};
const emoji_thermometer = {
- name: 'thermometer',
- aliases: ['thermometer'],
- emoji_url: 'TBD',
- emoji_code: '1f321',
+ name: "thermometer",
+ aliases: ["thermometer"],
+ emoji_url: "TBD",
+ emoji_code: "1f321",
};
const emoji_heart = {
- name: 'heart',
- aliases: ['heart'],
- emoji_url: 'TBD',
- emoji_code: '2764',
+ name: "heart",
+ aliases: ["heart"],
+ emoji_url: "TBD",
+ emoji_code: "2764",
};
const emoji_headphones = {
- name: 'headphones',
- aliases: ['headphones'],
- emoji_url: 'TBD',
- emoji_code: '1f3a7',
+ name: "headphones",
+ aliases: ["headphones"],
+ emoji_url: "TBD",
+ emoji_code: "1f3a7",
};
const emojis_by_name = new Map(Object.entries({
@@ -137,21 +137,21 @@ const my_slash = {
};
const sweden_stream = {
- name: 'Sweden',
- description: 'Cold, mountains and home decor.',
+ name: "Sweden",
+ description: "Cold, mountains and home decor.",
stream_id: 1,
subscribed: true,
can_access_subscribers: true,
};
const denmark_stream = {
- name: 'Denmark',
- description: 'Vikings and boats, in a serene and cold weather.',
+ name: "Denmark",
+ description: "Vikings and boats, in a serene and cold weather.",
stream_id: 2,
subscribed: true,
};
const netherland_stream = {
- name: 'The Netherlands',
- description: 'The Netherlands, city of dream.',
+ name: "The Netherlands",
+ description: "The Netherlands, city of dream.",
stream_id: 3,
subscribed: false,
};
@@ -160,11 +160,11 @@ stream_data.add_sub(sweden_stream);
stream_data.add_sub(denmark_stream);
stream_data.add_sub(netherland_stream);
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
-set_global('page_params', {});
-set_global('channel', {});
-set_global('compose', {
+set_global("page_params", {});
+set_global("channel", {});
+set_global("compose", {
finish: noop,
});
@@ -175,66 +175,66 @@ emoji.emojis = emoji_list;
const pygments_data = zrequire("pygments_data", "generated/pygments_data.json");
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 99,
full_name: "Alice",
};
const hamlet = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 100,
full_name: "King Hamlet",
};
const othello = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 101,
full_name: "Othello, the Moor of Venice",
};
const cordelia = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 102,
full_name: "Cordelia Lear",
};
const deactivated_user = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 103,
full_name: "Deactivated User",
};
const lear = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 104,
full_name: "King Lear",
};
const twin1 = {
- full_name: 'Mark Twin',
+ full_name: "Mark Twin",
user_id: 105,
- email: '[email protected]',
+ email: "[email protected]",
};
const twin2 = {
- full_name: 'Mark Twin',
+ full_name: "Mark Twin",
user_id: 106,
- email: '[email protected]',
+ email: "[email protected]",
};
const gael = {
- full_name: 'Gaël Twin',
+ full_name: "Gaël Twin",
user_id: 107,
- email: '[email protected]',
+ email: "[email protected]",
};
const hal = {
- full_name: 'Earl Hal',
+ full_name: "Earl Hal",
user_id: 108,
- email: '[email protected]',
+ email: "[email protected]",
};
const harry = {
- full_name: 'Harry',
+ full_name: "Harry",
user_id: 109,
- email: '[email protected]',
+ email: "[email protected]",
};
people.add_active_user(alice);
@@ -279,24 +279,24 @@ const make_emoji = function (emoji_dict) {
return { emoji_name: emoji_dict.name, emoji_code: emoji_dict.emoji_code };
};
-run_test('topics_seen_for', () => {
+run_test("topics_seen_for", () => {
stream_topic_history.get_recent_topic_names = (stream_id) => {
assert.equal(stream_id, denmark_stream.stream_id);
- return ['With Twisted Metal', 'acceptance', 'civil fears'];
+ return ["With Twisted Metal", "acceptance", "civil fears"];
};
assert.deepEqual(
- ct.topics_seen_for('Denmark'),
- ['With Twisted Metal', 'acceptance', 'civil fears'],
+ 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'), []);
+ assert.deepEqual(ct.topics_seen_for("non-existing-stream"), []);
});
-run_test('content_typeahead_selected', () => {
+run_test("content_typeahead_selected", () => {
const fake_this = {
- query: '',
+ query: "",
$element: {},
};
let caret_called1 = false;
@@ -312,52 +312,52 @@ run_test('content_typeahead_selected', () => {
caret_called2 = true;
};
let autosize_called = false;
- set_global('compose_ui', {
+ set_global("compose_ui", {
autosize_textarea: function () {
autosize_called = true;
},
});
let set_timeout_called = false;
- global.patch_builtin('setTimeout', (f, time) => {
+ global.patch_builtin("setTimeout", (f, time) => {
f();
assert.equal(time, 0);
set_timeout_called = true;
});
- set_global('document', 'document-stub');
+ set_global("document", "document-stub");
// emoji
- fake_this.completing = 'emoji';
- fake_this.query = ':octo';
- fake_this.token = 'octo';
+ fake_this.completing = "emoji";
+ fake_this.query = ":octo";
+ fake_this.token = "octo";
const item = {
- emoji_name: 'octopus',
+ emoji_name: "octopus",
};
let actual_value = ct.content_typeahead_selected.call(fake_this, item);
- let expected_value = ':octopus: ';
+ let expected_value = ":octopus: ";
assert.equal(actual_value, expected_value);
- fake_this.query = ' :octo';
- fake_this.token = 'octo';
+ fake_this.query = " :octo";
+ fake_this.token = "octo";
actual_value = ct.content_typeahead_selected.call(fake_this, item);
- expected_value = ' :octopus: ';
+ expected_value = " :octopus: ";
assert.equal(actual_value, expected_value);
- fake_this.query = '{:octo';
- fake_this.token = 'octo';
+ fake_this.query = "{:octo";
+ fake_this.token = "octo";
actual_value = ct.content_typeahead_selected.call(fake_this, item);
- expected_value = '{ :octopus: ';
+ expected_value = "{ :octopus: ";
assert.equal(actual_value, expected_value);
// mention
- fake_this.completing = 'mention';
+ fake_this.completing = "mention";
compose.warn_if_mentioning_unsubscribed_user = () => {};
- fake_this.query = '@**Mark Tw';
- fake_this.token = 'Mark Tw';
+ fake_this.query = "@**Mark Tw";
+ fake_this.token = "Mark Tw";
actual_value = ct.content_typeahead_selected.call(fake_this, twin1);
- expected_value = '@**Mark Twin|105** ';
+ expected_value = "@**Mark Twin|105** ";
assert.equal(actual_value, expected_value);
let warned_for_mention = false;
@@ -366,144 +366,144 @@ run_test('content_typeahead_selected', () => {
warned_for_mention = true;
};
- fake_this.query = '@oth';
- fake_this.token = 'oth';
+ fake_this.query = "@oth";
+ fake_this.token = "oth";
actual_value = ct.content_typeahead_selected.call(fake_this, othello);
- expected_value = '@**Othello, the Moor of Venice** ';
+ expected_value = "@**Othello, the Moor of Venice** ";
assert.equal(actual_value, expected_value);
assert(warned_for_mention);
- fake_this.query = 'Hello @oth';
- fake_this.token = 'oth';
+ fake_this.query = "Hello @oth";
+ fake_this.token = "oth";
actual_value = ct.content_typeahead_selected.call(fake_this, othello);
- expected_value = 'Hello @**Othello, the Moor of Venice** ';
+ expected_value = "Hello @**Othello, the Moor of Venice** ";
assert.equal(actual_value, expected_value);
- fake_this.query = '@**oth';
- fake_this.token = 'oth';
+ fake_this.query = "@**oth";
+ fake_this.token = "oth";
actual_value = ct.content_typeahead_selected.call(fake_this, othello);
- expected_value = '@**Othello, the Moor of Venice** ';
+ expected_value = "@**Othello, the Moor of Venice** ";
assert.equal(actual_value, expected_value);
- fake_this.query = '@*oth';
- fake_this.token = 'oth';
+ fake_this.query = "@*oth";
+ fake_this.token = "oth";
actual_value = ct.content_typeahead_selected.call(fake_this, othello);
- expected_value = '@**Othello, the Moor of Venice** ';
+ expected_value = "@**Othello, the Moor of Venice** ";
assert.equal(actual_value, expected_value);
// silent mention
- fake_this.completing = 'silent_mention';
+ fake_this.completing = "silent_mention";
compose.warn_if_mentioning_unsubscribed_user = () => {
- throw Error('unexpected call for silent mentions');
+ throw Error("unexpected call for silent mentions");
};
- fake_this.query = '@_kin';
- fake_this.token = 'kin';
+ fake_this.query = "@_kin";
+ fake_this.token = "kin";
actual_value = ct.content_typeahead_selected.call(fake_this, hamlet);
- expected_value = '@_**King Hamlet** ';
+ expected_value = "@_**King Hamlet** ";
assert.equal(actual_value, expected_value);
- fake_this.query = 'Hello @_kin';
- fake_this.token = 'kin';
+ fake_this.query = "Hello @_kin";
+ fake_this.token = "kin";
actual_value = ct.content_typeahead_selected.call(fake_this, hamlet);
- expected_value = 'Hello @_**King Hamlet** ';
+ expected_value = "Hello @_**King Hamlet** ";
assert.equal(actual_value, expected_value);
- fake_this.query = '@_*kin';
- fake_this.token = 'kin';
+ fake_this.query = "@_*kin";
+ fake_this.token = "kin";
actual_value = ct.content_typeahead_selected.call(fake_this, hamlet);
- expected_value = '@_**King Hamlet** ';
+ expected_value = "@_**King Hamlet** ";
assert.equal(actual_value, expected_value);
- fake_this.query = '@_**kin';
- fake_this.token = 'kin';
+ fake_this.query = "@_**kin";
+ fake_this.token = "kin";
actual_value = ct.content_typeahead_selected.call(fake_this, hamlet);
- expected_value = '@_**King Hamlet** ';
+ expected_value = "@_**King Hamlet** ";
assert.equal(actual_value, expected_value);
// user group mention
compose.warn_if_mentioning_unsubscribed_user = () => {
- throw Error('unexpected call for user groups');
+ throw Error("unexpected call for user groups");
};
- fake_this.query = '@back';
- fake_this.token = 'back';
+ fake_this.query = "@back";
+ fake_this.token = "back";
actual_value = ct.content_typeahead_selected.call(fake_this, backend);
- expected_value = '@*Backend* ';
+ expected_value = "@*Backend* ";
assert.equal(actual_value, expected_value);
- fake_this.query = '@*back';
- fake_this.token = 'back';
+ fake_this.query = "@*back";
+ fake_this.token = "back";
actual_value = ct.content_typeahead_selected.call(fake_this, backend);
- expected_value = '@*Backend* ';
+ expected_value = "@*Backend* ";
assert.equal(actual_value, expected_value);
- fake_this.query = '/m';
- fake_this.completing = 'slash';
+ fake_this.query = "/m";
+ fake_this.completing = "slash";
actual_value = ct.content_typeahead_selected.call(fake_this, me_slash);
- expected_value = '/me ';
+ expected_value = "/me ";
assert.equal(actual_value, expected_value);
// stream
- fake_this.completing = 'stream';
+ fake_this.completing = "stream";
let warned_for_stream_link = false;
compose.warn_if_private_stream_is_linked = (linked_stream) => {
assert.equal(linked_stream, sweden_stream);
warned_for_stream_link = true;
};
- fake_this.query = '#swed';
- fake_this.token = 'swed';
+ fake_this.query = "#swed";
+ fake_this.token = "swed";
actual_value = ct.content_typeahead_selected.call(fake_this, sweden_stream);
- expected_value = '#**Sweden** ';
+ expected_value = "#**Sweden** ";
assert.equal(actual_value, expected_value);
- fake_this.query = 'Hello #swed';
- fake_this.token = 'swed';
+ fake_this.query = "Hello #swed";
+ fake_this.token = "swed";
actual_value = ct.content_typeahead_selected.call(fake_this, sweden_stream);
- expected_value = 'Hello #**Sweden** ';
+ expected_value = "Hello #**Sweden** ";
assert.equal(actual_value, expected_value);
- fake_this.query = '#**swed';
- fake_this.token = 'swed';
+ fake_this.query = "#**swed";
+ fake_this.token = "swed";
actual_value = ct.content_typeahead_selected.call(fake_this, sweden_stream);
- expected_value = '#**Sweden** ';
+ expected_value = "#**Sweden** ";
assert.equal(actual_value, expected_value);
// syntax
- fake_this.completing = 'syntax';
+ fake_this.completing = "syntax";
- fake_this.query = '~~~p';
- fake_this.token = 'p';
- actual_value = ct.content_typeahead_selected.call(fake_this, 'python');
- expected_value = '~~~python\n\n~~~';
+ fake_this.query = "~~~p";
+ fake_this.token = "p";
+ actual_value = ct.content_typeahead_selected.call(fake_this, "python");
+ expected_value = "~~~python\n\n~~~";
assert.equal(actual_value, expected_value);
- fake_this.query = 'Hello ~~~p';
- fake_this.token = 'p';
- actual_value = ct.content_typeahead_selected.call(fake_this, 'python');
- expected_value = 'Hello ~~~python\n\n~~~';
+ fake_this.query = "Hello ~~~p";
+ fake_this.token = "p";
+ actual_value = ct.content_typeahead_selected.call(fake_this, "python");
+ expected_value = "Hello ~~~python\n\n~~~";
assert.equal(actual_value, expected_value);
- fake_this.query = '```p';
- fake_this.token = 'p';
- actual_value = ct.content_typeahead_selected.call(fake_this, 'python');
- expected_value = '```python\n\n```';
+ fake_this.query = "```p";
+ fake_this.token = "p";
+ actual_value = ct.content_typeahead_selected.call(fake_this, "python");
+ expected_value = "```python\n\n```";
assert.equal(actual_value, expected_value);
// Test special case to not close code blocks if there is text afterward
- fake_this.query = '```p\nsome existing code';
- fake_this.token = 'p';
+ fake_this.query = "```p\nsome existing code";
+ fake_this.token = "p";
fake_this.$element.caret = function () {
return 4; // Put cursor right after ```p
};
- actual_value = ct.content_typeahead_selected.call(fake_this, 'python');
- expected_value = '```python\nsome existing code';
+ actual_value = ct.content_typeahead_selected.call(fake_this, "python");
+ expected_value = "```python\nsome existing code";
assert.equal(actual_value, expected_value);
- fake_this.completing = 'something-else';
+ fake_this.completing = "something-else";
- fake_this.query = 'foo';
+ fake_this.query = "foo";
actual_value = ct.content_typeahead_selected.call(fake_this, {});
expected_value = fake_this.query;
assert.equal(actual_value, expected_value);
@@ -519,72 +519,72 @@ function sorted_names_from(subs) {
return subs.map((sub) => sub.name).sort();
}
-run_test('initialize', () => {
+run_test("initialize", () => {
let expected_value;
let stream_typeahead_called = false;
- $('#stream_message_recipient_stream').typeahead = function (options) {
+ $("#stream_message_recipient_stream").typeahead = function (options) {
// options.source()
//
let actual_value = options.source();
- assert.deepEqual(actual_value.sort(), ['Denmark', 'Sweden']);
+ assert.deepEqual(actual_value.sort(), ["Denmark", "Sweden"]);
// options.highlighter()
- options.query = 'De';
- actual_value = options.highlighter('Denmark');
- expected_value = '<strong>Denmark</strong>';
+ options.query = "De";
+ actual_value = options.highlighter("Denmark");
+ expected_value = "<strong>Denmark</strong>";
assert.equal(actual_value, expected_value);
- options.query = 'the n';
- actual_value = options.highlighter('The Netherlands');
- expected_value = '<strong>The Netherlands</strong>';
+ options.query = "the n";
+ actual_value = options.highlighter("The Netherlands");
+ expected_value = "<strong>The Netherlands</strong>";
assert.equal(actual_value, expected_value);
// options.matcher()
- options.query = 'de';
- assert.equal(options.matcher('Denmark'), true);
- assert.equal(options.matcher('Sweden'), false);
+ options.query = "de";
+ assert.equal(options.matcher("Denmark"), true);
+ assert.equal(options.matcher("Sweden"), false);
- options.query = 'De';
- assert.equal(options.matcher('Denmark'), true);
- assert.equal(options.matcher('Sweden'), false);
+ options.query = "De";
+ assert.equal(options.matcher("Denmark"), true);
+ assert.equal(options.matcher("Sweden"), false);
- options.query = 'the ';
- assert.equal(options.matcher('The Netherlands'), true);
- assert.equal(options.matcher('Sweden'), false);
+ options.query = "the ";
+ assert.equal(options.matcher("The Netherlands"), true);
+ assert.equal(options.matcher("Sweden"), false);
stream_typeahead_called = true;
};
let subject_typeahead_called = false;
- $('#stream_message_recipient_topic').typeahead = function (options) {
- const topics = ['<&>', 'even more ice', 'furniture', 'ice', 'kronor', 'more ice'];
+ $("#stream_message_recipient_topic").typeahead = function (options) {
+ const topics = ["<&>", "even more ice", "furniture", "ice", "kronor", "more ice"];
stream_topic_history.get_recent_topic_names = (stream_id) => {
assert.equal(stream_id, sweden_stream.stream_id);
return topics;
};
- $('#stream_message_recipient_stream').val('Sweden');
+ $("#stream_message_recipient_stream").val("Sweden");
let actual_value = options.source();
// Topics should be sorted alphabetically, not by addition order.
let expected_value = topics;
assert.deepEqual(actual_value, expected_value);
// options.highlighter()
- options.query = 'Kro';
- actual_value = options.highlighter('kronor');
- expected_value = '<strong>kronor</strong>';
+ options.query = "Kro";
+ actual_value = options.highlighter("kronor");
+ expected_value = "<strong>kronor</strong>";
assert.equal(actual_value, expected_value);
// Highlighted content should be escaped.
- options.query = '<';
- actual_value = options.highlighter('<&>');
- expected_value = '<strong>&lt;&amp;&gt;</strong>';
+ options.query = "<";
+ actual_value = options.highlighter("<&>");
+ expected_value = "<strong>&lt;&amp;&gt;</strong>";
assert.equal(actual_value, expected_value);
- options.query = 'even m';
- actual_value = options.highlighter('even more ice');
- expected_value = '<strong>even more ice</strong>';
+ options.query = "even m";
+ actual_value = options.highlighter("even more ice");
+ expected_value = "<strong>even more ice</strong>";
assert.equal(actual_value, expected_value);
// options.sorter()
@@ -592,28 +592,28 @@ run_test('initialize', () => {
// Notice that alphabetical sorting isn't managed by this sorter,
// it is a result of the topics already being sorted after adding
// them with add_topic().
- options.query = 'furniture';
- actual_value = options.sorter(['furniture']);
- expected_value = ['furniture'];
+ options.query = "furniture";
+ actual_value = options.sorter(["furniture"]);
+ expected_value = ["furniture"];
assert.deepEqual(actual_value, expected_value);
// A literal match at the beginning of an element puts it at the top.
- options.query = 'ice';
- actual_value = options.sorter(['even more ice', 'ice', 'more ice']);
- expected_value = ['ice', 'even more ice', 'more ice'];
+ options.query = "ice";
+ actual_value = options.sorter(["even more ice", "ice", "more ice"]);
+ expected_value = ["ice", "even more ice", "more ice"];
assert.deepEqual(actual_value, expected_value);
// The sorter should return the query as the first element if there
// isn't a topic with such name.
// This only happens if typeahead is providing other suggestions.
- options.query = 'e'; // Letter present in "furniture" and "ice"
- actual_value = options.sorter(['furniture', 'ice']);
- expected_value = ['e', 'furniture', 'ice'];
+ options.query = "e"; // Letter present in "furniture" and "ice"
+ actual_value = options.sorter(["furniture", "ice"]);
+ expected_value = ["e", "furniture", "ice"];
assert.deepEqual(actual_value, expected_value);
// Don't make any suggestions if this query doesn't match any
// existing topic.
- options.query = 'non-existing-topic';
+ options.query = "non-existing-topic";
actual_value = options.sorter([]);
expected_value = [];
assert.deepEqual(actual_value, expected_value);
@@ -621,18 +621,18 @@ run_test('initialize', () => {
subject_typeahead_called = true;
// Unset the stream name.
- $('#stream_message_recipient_stream').val('');
+ $("#stream_message_recipient_stream").val("");
};
let pm_recipient_typeahead_called = false;
- $('#private_message_recipient').typeahead = function (options) {
+ $("#private_message_recipient").typeahead = function (options) {
let inserted_users = [];
user_pill.get_user_ids = function () {
return inserted_users;
};
// This should match the users added at the beginning of this test file.
- let actual_value = options.source('');
+ let actual_value = options.source("");
let expected_value = [alice, cordelia, hal, gael, harry,
hamlet, lear, twin1, twin2, othello,
hamletcharacters, backend, call_center];
@@ -642,17 +642,17 @@ run_test('initialize', () => {
// objects of the users matching the query, it only returns the
// HTML string with the "User_name <email>" format, with the
// corresponding parts in bold.
- options.query = 'oth';
+ options.query = "oth";
actual_value = options.highlighter(othello);
expected_value = ` <img class="typeahead-image" src="/avatar/${othello.user_id}&amp;s&#x3D;50" />\n<strong>Othello, the Moor of Venice</strong>`;
assert.equal(actual_value, expected_value);
- options.query = 'Lear';
+ options.query = "Lear";
actual_value = options.highlighter(cordelia);
expected_value = ` <img class="typeahead-image" src="/avatar/${cordelia.user_id}&amp;s&#x3D;50" />\n<strong>Cordelia Lear</strong>`;
assert.equal(actual_value, expected_value);
- options.query = '[email protected], co';
+ options.query = "[email protected], co";
actual_value = options.highlighter(cordelia);
expected_value = ` <img class="typeahead-image" src="/avatar/${cordelia.user_id}&amp;s&#x3D;50" />\n<strong>Cordelia Lear</strong>`;
assert.equal(actual_value, expected_value);
@@ -663,41 +663,41 @@ run_test('initialize', () => {
}
let query;
- query = 'el'; // Matches both "othELlo" and "cordELia"
+ query = "el"; // Matches both "othELlo" and "cordELia"
assert.equal(matcher(query, othello), true);
assert.equal(matcher(query, cordelia), true);
- query = 'bender'; // Doesn't exist
+ query = "bender"; // Doesn't exist
assert.equal(matcher(query, othello), false);
assert.equal(matcher(query, cordelia), false);
- query = 'gael';
+ query = "gael";
assert.equal(matcher(query, gael), true);
- query = 'Gaël';
+ query = "Gaël";
assert.equal(matcher(query, gael), true);
- query = 'gaël';
+ query = "gaël";
assert.equal(matcher(query, gael), true);
// Don't make suggestions if the last name only has whitespaces
// (we're between typing names).
- query = '[email protected], ';
+ query = "[email protected], ";
assert.equal(matcher(query, othello), false);
assert.equal(matcher(query, cordelia), false);
// query = '[email protected],, , cord';
- query = 'cord';
+ query = "cord";
assert.equal(matcher(query, othello), false);
assert.equal(matcher(query, cordelia), true);
// If the user is already in the list, typeahead doesn't include it
// again.
- query = '[email protected], cord';
+ query = "[email protected], cord";
assert.equal(matcher(query, othello), false);
assert.equal(matcher(query, cordelia), false);
- query = 'oth';
+ query = "oth";
page_params.realm_email_address_visibility =
settings_config.email_address_visibility_values.admins_only.code;
page_params.is_admin = false;
@@ -718,18 +718,18 @@ run_test('initialize', () => {
// The sorter's output has the items that match the query from the
// beginning first, and then the rest of them in REVERSE order of
// the input.
- query = 'othello';
+ query = "othello";
actual_value = sorter(query, [othello]);
expected_value = [othello];
assert.deepEqual(actual_value, expected_value);
// A literal match at the beginning of an element puts it at the top.
- query = 'co'; // Matches everything ("[email protected]")
+ query = "co"; // Matches everything ("[email protected]")
actual_value = sorter(query, [othello, deactivated_user, cordelia]);
expected_value = [cordelia, deactivated_user, othello];
assert.deepEqual(actual_value, expected_value);
- query = 'non-existing-user';
+ query = "non-existing-user";
actual_value = sorter(query, []);
expected_value = [];
assert.deepEqual(actual_value, expected_value);
@@ -737,12 +737,12 @@ run_test('initialize', () => {
// Adds a `no break-space` at the end. This should fail
// if there wasn't any logic replacing `no break-space`
// with normal space.
- query = 'cordelia' + String.fromCharCode(160);
+ query = "cordelia" + String.fromCharCode(160);
assert.equal(matcher(query, cordelia), true);
assert.equal(matcher(query, othello), false);
const event = {
- target: '#doesnotmatter',
+ target: "#doesnotmatter",
};
let appended_name;
@@ -751,20 +751,20 @@ run_test('initialize', () => {
};
// options.updater()
- options.query = 'othello';
+ options.query = "othello";
options.updater(othello, event);
- assert.equal(appended_name, 'Othello, the Moor of Venice');
+ assert.equal(appended_name, "Othello, the Moor of Venice");
- options.query = '[email protected], cor';
+ options.query = "[email protected], cor";
actual_value = options.updater(cordelia, event);
- assert.equal(appended_name, 'Cordelia Lear');
+ assert.equal(appended_name, "Cordelia Lear");
- const click_event = { type: 'click', target: '#doesnotmatter' };
- options.query = 'othello';
+ const click_event = { type: "click", target: "#doesnotmatter" };
+ options.query = "othello";
// Focus lost (caused by the click event in the typeahead list)
- $('#private_message_recipient').blur();
+ $("#private_message_recipient").blur();
actual_value = options.updater(othello, click_event);
- assert.equal(appended_name, 'Othello, the Moor of Venice');
+ assert.equal(appended_name, "Othello, the Moor of Venice");
let appended_names = [];
people.get_by_user_id = function (user_id) {
@@ -772,7 +772,7 @@ run_test('initialize', () => {
return users[user_id];
};
people.my_current_email = function () {
- return '[email protected]';
+ return "[email protected]";
};
compose_pm_pill.set_from_typeahead = function (item) {
appended_names.push(item.full_name);
@@ -784,9 +784,9 @@ run_test('initialize', () => {
}
compose_pm_pill.widget = {clear_text: fake_clear};
- options.query = 'hamletchar';
+ options.query = "hamletchar";
options.updater(hamletcharacters, event);
- assert.deepEqual(appended_names, ['King Lear']);
+ assert.deepEqual(appended_names, ["King Lear"]);
assert(cleared);
inserted_users = [lear.user_id];
@@ -800,7 +800,7 @@ run_test('initialize', () => {
};
let compose_textarea_typeahead_called = false;
- $('#compose-textarea').typeahead = function (options) {
+ $("#compose-textarea").typeahead = function (options) {
// options.source()
//
// For now we only test that get_sorted_filtered_items has been
@@ -816,10 +816,10 @@ run_test('initialize', () => {
};
fake_this.$element.closest = () => [];
fake_this.options = options;
- let actual_value = options.source.call(fake_this, 'test #s');
+ let actual_value = options.source.call(fake_this, "test #s");
assert.deepEqual(
sorted_names_from(actual_value),
- ['Denmark', 'Sweden', 'The Netherlands'],
+ ["Denmark", "Sweden", "The Netherlands"],
);
assert(caret_called);
@@ -827,12 +827,12 @@ run_test('initialize', () => {
//
// Again, here we only verify that the highlighter has been set to
// content_highlighter.
- fake_this = { completing: 'mention', token: 'othello' };
+ fake_this = { completing: "mention", token: "othello" };
actual_value = options.highlighter.call(fake_this, othello);
expected_value = ` <img class="typeahead-image" src="/avatar/${othello.user_id}&amp;s&#x3D;50" />\n<strong>Othello, the Moor of Venice</strong>`;
assert.equal(actual_value, expected_value);
- fake_this = { completing: 'mention', token: 'hamletcharacters' };
+ 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';
assert.equal(actual_value, expected_value);
@@ -846,19 +846,19 @@ run_test('initialize', () => {
return ct.compose_content_matcher(completing, token)(item);
}
- fake_this = { completing: 'emoji', token: 'ta' };
+ fake_this = { completing: "emoji", token: "ta" };
assert.equal(match(fake_this, make_emoji(emoji_tada)), true);
assert.equal(match(fake_this, make_emoji(emoji_moneybag)), false);
- fake_this = { completing: 'stream', token: 'swed' };
+ fake_this = { completing: "stream", token: "swed" };
assert.equal(match(fake_this, sweden_stream), true);
assert.equal(match(fake_this, denmark_stream), false);
- fake_this = { completing: 'syntax', token: 'py' };
- assert.equal(match(fake_this, 'python'), true);
- assert.equal(match(fake_this, 'javascript'), false);
+ fake_this = { completing: "syntax", token: "py" };
+ assert.equal(match(fake_this, "python"), true);
+ assert.equal(match(fake_this, "javascript"), false);
- fake_this = { completing: 'non-existing-completion' };
+ fake_this = { completing: "non-existing-completion" };
assert.equal(match(fake_this), undefined);
function sort_items(fake_this, item) {
@@ -869,30 +869,30 @@ run_test('initialize', () => {
}
// options.sorter()
- fake_this = { completing: 'emoji', token: 'ta' };
+ fake_this = { completing: "emoji", token: "ta" };
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' };
+ fake_this = { completing: "emoji", token: "th" };
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' };
+ fake_this = { completing: "emoji", token: "he" };
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);
- fake_this = { completing: 'slash', token: 'm' };
+ fake_this = { completing: "slash", token: "m" };
actual_value = sort_items(fake_this, [my_slash, me_slash]);
expected_value = [me_slash, my_slash];
assert.deepEqual(actual_value, expected_value);
- fake_this = { completing: 'stream', token: 'de' };
+ fake_this = { completing: "stream", token: "de" };
actual_value = sort_items(fake_this, [sweden_stream, denmark_stream]);
expected_value = [denmark_stream, sweden_stream];
assert.deepEqual(actual_value, expected_value);
@@ -900,19 +900,19 @@ run_test('initialize', () => {
// Matches in the descriptions affect the order as well.
// Testing "co" for "cold", in both streams' description. It's at the
// beginning of Sweden's description, so that one should go first.
- fake_this = { completing: 'stream', token: 'co' };
+ fake_this = { completing: "stream", token: "co" };
actual_value = sort_items(fake_this, [denmark_stream, sweden_stream]);
expected_value = [sweden_stream, denmark_stream];
assert.deepEqual(actual_value, expected_value);
- fake_this = { completing: 'syntax', token: 'ap' };
- actual_value = sort_items(fake_this, ['abap', 'applescript']);
- expected_value = ['applescript', 'abap'];
+ fake_this = { completing: "syntax", token: "ap" };
+ actual_value = sort_items(fake_this, ["abap", "applescript"]);
+ expected_value = ["applescript", "abap"];
assert.deepEqual(actual_value, expected_value);
const serbia_stream = {
- name: 'Serbia',
- description: 'Snow and cold',
+ name: "Serbia",
+ description: "Snow and cold",
stream_id: 3,
subscribed: false,
};
@@ -920,7 +920,7 @@ run_test('initialize', () => {
stream_data.is_active = function () {
return false;
};
- fake_this = { completing: 'stream', token: 's' };
+ fake_this = { completing: "stream", token: "s" };
actual_value = sort_items(fake_this, [sweden_stream, serbia_stream]);
expected_value = [sweden_stream, serbia_stream];
assert.deepEqual(actual_value, expected_value);
@@ -932,25 +932,25 @@ run_test('initialize', () => {
expected_value = [sweden_stream, serbia_stream];
assert.deepEqual(actual_value, expected_value);
- fake_this = { completing: 'stream', token: 'ser' };
+ fake_this = { completing: "stream", token: "ser" };
actual_value = sort_items(fake_this, [denmark_stream, serbia_stream]);
expected_value = [serbia_stream, denmark_stream];
assert.deepEqual(actual_value, expected_value);
- fake_this = { completing: 'non-existing-completion' };
+ fake_this = { completing: "non-existing-completion" };
assert.equal(sort_items(fake_this), undefined);
compose_textarea_typeahead_called = true;
};
let pm_recipient_blur_called = false;
- const old_pm_recipient_blur = $('#private_message_recipient').blur;
- $('#private_message_recipient').blur = function (handler) {
+ const old_pm_recipient_blur = $("#private_message_recipient").blur;
+ $("#private_message_recipient").blur = function (handler) {
if (handler) { // The blur handler is being set.
- this.val('[email protected], ');
+ this.val("[email protected], ");
handler.call(this);
const actual_value = this.val();
- const expected_value = '[email protected]';
+ const expected_value = "[email protected]";
assert.equal(actual_value, expected_value);
} else { // The element is simply losing the focus.
old_pm_recipient_blur();
@@ -971,39 +971,39 @@ run_test('initialize', () => {
let event = {
keyCode: 13,
target: {
- id: 'stream_message_recipient_stream',
+ id: "stream_message_recipient_stream",
},
preventDefault: noop,
};
- $('#stream_message_recipient_topic').data = function () {
+ $("#stream_message_recipient_topic").data = function () {
return { typeahead: { shown: true }};
};
- $('form#send_message_form').keydown(event);
+ $("form#send_message_form").keydown(event);
const stub_typeahead_hidden = function () {
return { typeahead: { shown: false }};
};
- $('#stream_message_recipient_topic').data = stub_typeahead_hidden;
- $('#stream_message_recipient_stream').data = stub_typeahead_hidden;
- $('#private_message_recipient').data = stub_typeahead_hidden;
- $('#compose-textarea').data = stub_typeahead_hidden;
- $('form#send_message_form').keydown(event);
+ $("#stream_message_recipient_topic").data = stub_typeahead_hidden;
+ $("#stream_message_recipient_stream").data = stub_typeahead_hidden;
+ $("#private_message_recipient").data = stub_typeahead_hidden;
+ $("#compose-textarea").data = stub_typeahead_hidden;
+ $("form#send_message_form").keydown(event);
event.keyCode = undefined;
event.which = 9;
event.shiftKey = false;
- event.target.id = 'subject';
- $('form#send_message_form').keydown(event);
- event.target.id = 'compose-textarea';
- $('form#send_message_form').keydown(event);
- event.target.id = 'some_non_existing_id';
- $('form#send_message_form').keydown(event);
+ event.target.id = "subject";
+ $("form#send_message_form").keydown(event);
+ event.target.id = "compose-textarea";
+ $("form#send_message_form").keydown(event);
+ event.target.id = "some_non_existing_id";
+ $("form#send_message_form").keydown(event);
// Setup jquery functions used in compose_textarea enter
// handler.
let range_length = 0;
- $('#compose-textarea').range = function () {
+ $("#compose-textarea").range = function () {
return {
length: range_length,
range: noop,
@@ -1011,12 +1011,12 @@ run_test('initialize', () => {
end: 0 + range_length,
};
};
- $('#compose-textarea').caret = noop;
+ $("#compose-textarea").caret = noop;
event.keyCode = 13;
- event.target.id = 'stream_message_recipient_topic';
- $('form#send_message_form').keydown(event);
- event.target.id = 'compose-textarea';
+ event.target.id = "stream_message_recipient_topic";
+ $("form#send_message_form").keydown(event);
+ event.target.id = "compose-textarea";
page_params.enter_sends = false;
event.metaKey = true;
let compose_finish_called = false;
@@ -1024,57 +1024,57 @@ run_test('initialize', () => {
compose_finish_called = true;
};
- $('form#send_message_form').keydown(event);
+ $("form#send_message_form").keydown(event);
assert(compose_finish_called);
event.metaKey = false;
event.ctrlKey = true;
- $('form#send_message_form').keydown(event);
+ $("form#send_message_form").keydown(event);
page_params.enter_sends = true;
event.ctrlKey = false;
event.altKey = true;
- $('form#send_message_form').keydown(event);
+ $("form#send_message_form").keydown(event);
// Cover case where there's a least one character there.
range_length = 2;
- $('form#send_message_form').keydown(event);
+ $("form#send_message_form").keydown(event);
event.altKey = false;
event.metaKey = true;
- $('form#send_message_form').keydown(event);
- event.target.id = 'private_message_recipient';
- $('form#send_message_form').keydown(event);
+ $("form#send_message_form").keydown(event);
+ event.target.id = "private_message_recipient";
+ $("form#send_message_form").keydown(event);
event.keyCode = 42;
- $('form#send_message_form').keydown(event);
+ $("form#send_message_form").keydown(event);
// handle_keyup()
event = {
keyCode: 13,
target: {
- id: 'stream_message_recipient_stream',
+ id: "stream_message_recipient_stream",
},
preventDefault: noop,
};
// We execute .keydown() in order to make nextFocus !== false
- $('#stream_message_recipient_topic').data = function () {
+ $("#stream_message_recipient_topic").data = function () {
return { typeahead: { shown: true }};
};
- $('form#send_message_form').keydown(event);
- $('form#send_message_form').keyup(event);
+ $("form#send_message_form").keydown(event);
+ $("form#send_message_form").keyup(event);
event.keyCode = undefined;
event.which = 9;
event.shiftKey = false;
- $('form#send_message_form').keyup(event);
+ $("form#send_message_form").keyup(event);
event.keyCode = 42;
- $('form#send_message_form').keyup(event);
+ $("form#send_message_form").keyup(event);
// select_on_focus()
let focus_handler_called = false;
let stream_one_called = false;
- $('#stream_message_recipient_stream').focus = function (f) {
+ $("#stream_message_recipient_stream").focus = function (f) {
// This .one() function emulates the possible infinite recursion that
// in_handler tries to avoid.
- $('#stream_message_recipient_stream').one = function (event, handler) {
+ $("#stream_message_recipient_stream").one = function (event, handler) {
handler({ preventDefault: noop });
f(); // This time in_handler will already be true.
stream_one_called = true;
@@ -1087,19 +1087,19 @@ run_test('initialize', () => {
$("#compose-send-button").fadeIn = noop;
let channel_post_called = false;
global.channel.post = function (params) {
- assert.equal(params.url, '/json/users/me/enter-sends');
+ assert.equal(params.url, "/json/users/me/enter-sends");
assert.equal(params.idempotent, true);
assert.deepEqual(params.data, {enter_sends: page_params.enter_sends});
channel_post_called = true;
};
- $('#enter_sends').is = function () { return false; };
- $('#enter_sends').click();
+ $("#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').click();
+ $("#enter_sends").is = function () { return true; };
+ $("#enter_sends").click();
ct.initialize();
// Now let's make sure that all the stub functions have been called
@@ -1114,7 +1114,7 @@ run_test('initialize', () => {
assert(stream_one_called);
});
-run_test('begins_typeahead', () => {
+run_test("begins_typeahead", () => {
const begin_typehead_this = {options: {completions: {
emoji: true,
@@ -1145,7 +1145,7 @@ run_test('begins_typeahead', () => {
// In the above examples, '|' serves as the cursor.
if (reference === undefined) {
reference = rest;
- rest = '';
+ rest = "";
}
const values = get_values(input, rest);
assert.deepEqual(values, reference);
@@ -1153,12 +1153,12 @@ run_test('begins_typeahead', () => {
function assert_stream_list(input, rest) {
if (rest === undefined) {
- rest = '';
+ rest = "";
}
const values = get_values(input, rest);
assert.deepEqual(
sorted_names_from(values),
- ['Denmark', 'Sweden', 'The Netherlands'],
+ ["Denmark", "Sweden", "The Netherlands"],
);
}
@@ -1290,25 +1290,25 @@ run_test('begins_typeahead', () => {
// topic_jump
assert_typeahead_equals("@**a person**>", false);
assert_typeahead_equals("@**a person** >", false);
- assert_typeahead_equals("#**stream**>", ['']); // this is deliberately a blank choice.
- assert_typeahead_equals("#**stream** >", ['']);
+ assert_typeahead_equals("#**stream**>", [""]); // this is deliberately a blank choice.
+ assert_typeahead_equals("#**stream** >", [""]);
assert_typeahead_equals("#**Sweden>some topic** >", false); // Already completed a topic.
// topic_list
// includes "more ice"
const sweden_topics_to_show = stream_topic_history.get_recent_topic_names(1);
assert_typeahead_equals("#**Sweden>more ice", sweden_topics_to_show);
- sweden_topics_to_show.push('totally new topic');
+ sweden_topics_to_show.push("totally new topic");
assert_typeahead_equals("#**Sweden>totally new topic", sweden_topics_to_show);
// time_jump
assert_typeahead_equals("<tim", false);
assert_typeahead_equals("<timerandom", false);
- assert_typeahead_equals("<time", ['translated: Mention a timezone-aware time']);
- assert_typeahead_equals("<time:", ['translated: Mention a timezone-aware time']);
- assert_typeahead_equals("<time:something", ['translated: Mention a timezone-aware time']);
- assert_typeahead_equals("<time:something", "> ", ['translated: Mention a timezone-aware time']);
- assert_typeahead_equals("<time:something>", ['translated: Mention a timezone-aware time']);
+ assert_typeahead_equals("<time", ["translated: Mention a timezone-aware time"]);
+ assert_typeahead_equals("<time:", ["translated: Mention a timezone-aware time"]);
+ assert_typeahead_equals("<time:something", ["translated: Mention a timezone-aware time"]);
+ assert_typeahead_equals("<time:something", "> ", ["translated: Mention a timezone-aware time"]);
+ assert_typeahead_equals("<time:something>", ["translated: Mention a timezone-aware time"]);
assert_typeahead_equals("<time:something> ", false); // Already completed the mention
// Following tests place the cursor before the second string
@@ -1327,7 +1327,7 @@ run_test('begins_typeahead', () => {
});
});
-run_test('tokenizing', () => {
+run_test("tokenizing", () => {
assert.equal(ct.tokenize_compose_str("/m"), "/m");
assert.equal(ct.tokenize_compose_str("1/3"), "");
assert.equal(ct.tokenize_compose_str("foo bar"), "");
@@ -1350,9 +1350,9 @@ run_test('tokenizing', () => {
assert.equal(ct.tokenize_compose_str("foo #streams@foo"), "#streams@foo");
});
-run_test('content_highlighter', () => {
- let fake_this = { completing: 'emoji' };
- const emoji = { emoji_name: 'person shrugging', emoji_url: '¯\\_(ツ)_/¯' };
+run_test("content_highlighter", () => {
+ let fake_this = { completing: "emoji" };
+ const emoji = { emoji_name: "person shrugging", emoji_url: "¯\\_(ツ)_/¯" };
let th_render_typeahead_item_called = false;
typeahead_helper.render_emoji = function (item) {
assert.deepEqual(item, emoji);
@@ -1360,7 +1360,7 @@ run_test('content_highlighter', () => {
};
ct.content_highlighter.call(fake_this, emoji);
- fake_this = { completing: 'mention' };
+ fake_this = { completing: "mention" };
let th_render_person_called = false;
typeahead_helper.render_person = function (person) {
assert.deepEqual(person, othello);
@@ -1376,7 +1376,7 @@ run_test('content_highlighter', () => {
ct.content_highlighter.call(fake_this, backend);
// We don't have any fancy rendering for slash commands yet.
- fake_this = { completing: 'slash' };
+ fake_this = { completing: "slash" };
let th_render_slash_command_called = false;
const me_slash = {
text: "/me is excited (Display action text)",
@@ -1389,7 +1389,7 @@ run_test('content_highlighter', () => {
};
ct.content_highlighter.call(fake_this, me_slash);
- fake_this = { completing: 'stream' };
+ fake_this = { completing: "stream" };
let th_render_stream_called = false;
typeahead_helper.render_stream = function (stream) {
assert.deepEqual(stream, denmark_stream);
@@ -1397,15 +1397,15 @@ run_test('content_highlighter', () => {
};
ct.content_highlighter.call(fake_this, denmark_stream);
- fake_this = { completing: 'syntax' };
+ fake_this = { completing: "syntax" };
th_render_typeahead_item_called = false;
typeahead_helper.render_typeahead_item = function (item) {
- assert.deepEqual(item, { primary: 'py' });
+ assert.deepEqual(item, { primary: "py" });
th_render_typeahead_item_called = true;
};
- ct.content_highlighter.call(fake_this, 'py');
+ ct.content_highlighter.call(fake_this, "py");
- fake_this = { completing: 'something-else' };
+ fake_this = { completing: "something-else" };
assert(!ct.content_highlighter.call(fake_this));
// Verify that all stub functions have been called.
@@ -1417,11 +1417,11 @@ run_test('content_highlighter', () => {
assert(th_render_slash_command_called);
});
-run_test('filter_and_sort_mentions (normal)', () => {
+run_test("filter_and_sort_mentions (normal)", () => {
const is_silent = false;
const suggestions = ct.filter_and_sort_mentions(
- is_silent, 'al');
+ is_silent, "al");
assert.deepEqual(suggestions, [
mention_all,
@@ -1431,16 +1431,16 @@ run_test('filter_and_sort_mentions (normal)', () => {
]);
});
-run_test('filter_and_sort_mentions (silent)', () => {
+run_test("filter_and_sort_mentions (silent)", () => {
const is_silent = true;
const suggestions = ct.filter_and_sort_mentions(
- is_silent, 'al');
+ is_silent, "al");
assert.deepEqual(suggestions, [alice, hal]);
});
-run_test('typeahead_results', () => {
+run_test("typeahead_results", () => {
const stream_list = [denmark_stream, sweden_stream, netherland_stream];
function compose_typeahead_results(completing, items, token) {
@@ -1448,7 +1448,7 @@ run_test('typeahead_results', () => {
}
function assert_emoji_matches(input, expected) {
- const returned = compose_typeahead_results('emoji', emoji_list, input);
+ const returned = compose_typeahead_results("emoji", emoji_list, input);
assert.deepEqual(returned, expected);
}
function assert_mentions_matches(input, expected) {
@@ -1457,55 +1457,55 @@ run_test('typeahead_results', () => {
assert.deepEqual(returned, expected);
}
function assert_stream_matches(input, expected) {
- const returned = compose_typeahead_results('stream', stream_list, input);
+ const returned = compose_typeahead_results("stream", stream_list, input);
assert.deepEqual(returned, expected);
}
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"},
+ 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('notaemoji', []);
+ 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("notaemoji", []);
// Autocomplete user mentions by user name.
- assert_mentions_matches('cordelia', [cordelia]);
- assert_mentions_matches('cordelia le', [cordelia]);
- assert_mentions_matches('cordelia le ', []);
- assert_mentions_matches('King ', [hamlet, lear]);
- assert_mentions_matches('King H', [hamlet]);
- assert_mentions_matches('King L', [lear]);
- assert_mentions_matches('delia lear', []);
- assert_mentions_matches('Mark Tw', [twin1, twin2]);
+ assert_mentions_matches("cordelia", [cordelia]);
+ assert_mentions_matches("cordelia le", [cordelia]);
+ assert_mentions_matches("cordelia le ", []);
+ assert_mentions_matches("King ", [hamlet, lear]);
+ assert_mentions_matches("King H", [hamlet]);
+ assert_mentions_matches("King L", [lear]);
+ assert_mentions_matches("delia lear", []);
+ assert_mentions_matches("Mark Tw", [twin1, twin2]);
// Autocomplete user group mentions by group name.
- assert_mentions_matches('hamletchar', [hamletcharacters]);
+ assert_mentions_matches("hamletchar", [hamletcharacters]);
// Autocomplete user group mentions by group descriptions.
- assert_mentions_matches('characters ', [hamletcharacters]);
- assert_mentions_matches('characters of ', [hamletcharacters]);
- assert_mentions_matches('characters o ', []);
- assert_mentions_matches('haracters of hamlet', []);
- assert_mentions_matches('of hamlet', []);
+ assert_mentions_matches("characters ", [hamletcharacters]);
+ assert_mentions_matches("characters of ", [hamletcharacters]);
+ assert_mentions_matches("characters o ", []);
+ assert_mentions_matches("haracters of hamlet", []);
+ assert_mentions_matches("of hamlet", []);
// Autocomplete by slash commands.
- assert_slash_matches('me', [me_slash]);
+ assert_slash_matches("me", [me_slash]);
// Autocomplete stream by stream name or stream description.
- assert_stream_matches('den', [denmark_stream, sweden_stream]);
- assert_stream_matches('denmark', [denmark_stream]);
- assert_stream_matches('denmark ', []);
- assert_stream_matches('den ', []);
- assert_stream_matches('cold', [sweden_stream, denmark_stream]);
- assert_stream_matches('the ', [netherland_stream]);
- assert_stream_matches('city', [netherland_stream]);
+ assert_stream_matches("den", [denmark_stream, sweden_stream]);
+ assert_stream_matches("denmark", [denmark_stream]);
+ assert_stream_matches("denmark ", []);
+ assert_stream_matches("den ", []);
+ assert_stream_matches("cold", [sweden_stream, denmark_stream]);
+ assert_stream_matches("the ", [netherland_stream]);
+ assert_stream_matches("city", [netherland_stream]);
});
-run_test('message people', () => {
+run_test("message people", () => {
let results;
compose_state.stream_name = () => undefined;
@@ -1527,22 +1527,22 @@ run_test('message people', () => {
filter_pills: false,
};
- results = ct.get_person_suggestions('Ha', opts);
+ results = ct.get_person_suggestions("Ha", opts);
assert.deepEqual(results, [harry, hamletcharacters]);
// Now let's exclude Hal.
message_store.user_ids = () => [hamlet.user_id, harry.user_id];
- results = ct.get_person_suggestions('Ha', opts);
+ results = ct.get_person_suggestions("Ha", opts);
assert.deepEqual(results, [harry, hamletcharacters]);
message_store.user_ids = () => [hamlet.user_id, harry.user_id, hal.user_id];
- results = ct.get_person_suggestions('Ha', opts);
+ results = ct.get_person_suggestions("Ha", opts);
assert.deepEqual(results, [harry, hamletcharacters]);
people.deactivate(harry);
- results = ct.get_person_suggestions('Ha', opts);
+ results = ct.get_person_suggestions("Ha", opts);
// harry is excluded since it has been deactivated.
assert.deepEqual(results, [hamletcharacters, hal]);
});
diff --git a/frontend_tests/node_tests/copy_and_paste.js b/frontend_tests/node_tests/copy_and_paste.js
index 8b6925096bc..1b8a5037f56 100644
--- a/frontend_tests/node_tests/copy_and_paste.js
+++ b/frontend_tests/node_tests/copy_and_paste.js
@@ -1,18 +1,18 @@
global.stub_out_jquery();
-set_global('page_params', {
+set_global("page_params", {
development_environment: true,
});
-set_global('compose_ui', {});
+set_global("compose_ui", {});
const { JSDOM } = require("jsdom");
-const { window } = new JSDOM('<!DOCTYPE html><p>Hello world</p>');
+const { window } = new JSDOM("<!DOCTYPE html><p>Hello world</p>");
const { DOMParser, document } = window;
-set_global('$', require('jquery')(window));
-set_global('DOMParser', DOMParser);
-set_global('document', document);
+set_global("$", require("jquery")(window));
+set_global("DOMParser", DOMParser);
+set_global("document", document);
-const copy_and_paste = zrequire('copy_and_paste');
+const copy_and_paste = zrequire("copy_and_paste");
// Super stripped down version of the code in the drag-mock library
// https://github.com/andywer/drag-mock/blob/6d46c7c0ffd6a4d685e6612a90cd58cda80f30fc/src/DataTransfer.js
@@ -28,52 +28,52 @@ DataTransfer.prototype.setData = function (dataFormat, data) {
const createPasteEvent = function () {
const clipboardData = new DataTransfer();
- const pasteEvent = new window.Event('paste');
+ const pasteEvent = new window.Event("paste");
pasteEvent.clipboardData = clipboardData;
return $.Event(pasteEvent);
};
-run_test('paste_handler', () => {
+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**.');
+ " 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');
+ "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');
+ "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)');
+ "[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');
+ "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');
+ "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*');
+ "*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');
+ "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');
+ "Test List:\n* Item 1\n* Item 2");
- let data = '<p>text</p>';
+ let data = "<p>text</p>";
let event = createPasteEvent();
- event.originalEvent.clipboardData.setData('text/html', data);
+ event.originalEvent.clipboardData.setData("text/html", data);
let insert_syntax_and_focus_called = false;
compose_ui.insert_syntax_and_focus = function () {
insert_syntax_and_focus_called = true;
@@ -83,7 +83,7 @@ run_test('paste_handler', () => {
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);
+ 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 570083daaa2..fc80b05c913 100644
--- a/frontend_tests/node_tests/dispatch.js
+++ b/frontend_tests/node_tests/dispatch.js
@@ -1,65 +1,65 @@
const noop = function () {};
-const events = require('./lib/events.js');
+const events = require("./lib/events.js");
const event_fixtures = events.fixtures;
const test_message = events.test_message;
const test_user = events.test_user;
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
-global.patch_builtin('setTimeout', (func) => func());
+global.patch_builtin("setTimeout", (func) => func());
// These dependencies are closer to the dispatcher, and they
// apply to all tests.
-set_global('home_msg_list', {
+set_global("home_msg_list", {
rerender: noop,
select_id: noop,
selected_id: function () {return 1;},
});
-set_global('markdown', {
+set_global("markdown", {
update_realm_filter_rules: noop,
});
-set_global('notifications', {
+set_global("notifications", {
redraw_title: noop,
});
-set_global('settings_emoji', {
+set_global("settings_emoji", {
update_custom_emoji_ui: noop,
});
-set_global('settings_account', {
+set_global("settings_account", {
update_email_change_display: noop,
update_name_change_display: noop,
add_custom_profile_fields_to_settings: noop,
});
-set_global('settings_display', {
+set_global("settings_display", {
update_page: noop,
});
-set_global('settings_notifications', {
+set_global("settings_notifications", {
update_page: noop,
});
-set_global('settings_org', {
+set_global("settings_org", {
sync_realm_settings: noop,
});
-set_global('message_edit', {
+set_global("message_edit", {
update_message_topic_editing_pencil: noop,
});
-set_global('settings_bots', {
+set_global("settings_bots", {
update_bot_permissions_ui: noop,
});
-set_global('compose', {
+set_global("compose", {
update_video_chat_button_display: noop,
});
-set_global('settings_exports', {
+set_global("settings_exports", {
populate_exports_table: function (exports) {
return exports;
},
@@ -67,18 +67,18 @@ set_global('settings_exports', {
});
// page_params is highly coupled to dispatching now
-set_global('page_params', {
+set_global("page_params", {
test_suite: false,
is_admin: true,
- realm_description: 'already set description',
+ realm_description: "already set description",
});
const page_params = global.page_params;
// We access various msg_list object to rerender them
-set_global('current_msg_list', {rerender: noop});
+set_global("current_msg_list", {rerender: noop});
// We use blueslip to print the traceback
-set_global('blueslip', {
+set_global("blueslip", {
info: noop,
error: function (msg, more_info, stack) {
console.log("\nFailed to process an event:\n", more_info.event, "\n");
@@ -91,25 +91,25 @@ set_global('blueslip', {
},
});
-set_global('overlays', {
+set_global("overlays", {
streams_open: () => true,
});
// For data-oriented modules, just use them, don't stub them.
-zrequire('alert_words');
-zrequire('unread');
-zrequire('stream_topic_history');
-zrequire('stream_list');
-zrequire('message_flags');
-zrequire('message_store');
-zrequire('people');
-zrequire('starred_messages');
-zrequire('user_status');
-zrequire('subs');
-zrequire('stream_ui_updates');
-
-zrequire('server_events_dispatch');
-zrequire('panels');
+zrequire("alert_words");
+zrequire("unread");
+zrequire("stream_topic_history");
+zrequire("stream_list");
+zrequire("message_flags");
+zrequire("message_store");
+zrequire("people");
+zrequire("starred_messages");
+zrequire("user_status");
+zrequire("subs");
+zrequire("stream_ui_updates");
+
+zrequire("server_events_dispatch");
+zrequire("panels");
function dispatch(ev) {
server_events_dispatch.dispatch_normal_event(ev);
@@ -131,65 +131,65 @@ const with_overrides = global.with_overrides; // make lint happy
with_overrides((override) => {
// alert_words
- assert(!alert_words.has_alert_word('fire'));
- assert(!alert_words.has_alert_word('lunch'));
+ assert(!alert_words.has_alert_word("fire"));
+ assert(!alert_words.has_alert_word("lunch"));
- override('alert_words_ui.render_alert_words_ui', noop);
+ override("alert_words_ui.render_alert_words_ui", noop);
const event = event_fixtures.alert_words;
dispatch(event);
assert.deepEqual(
alert_words.get_word_list(),
- ['fire', 'lunch'],
+ ["fire", "lunch"],
);
- assert(alert_words.has_alert_word('fire'));
- assert(alert_words.has_alert_word('lunch'));
+ assert(alert_words.has_alert_word("fire"));
+ assert(alert_words.has_alert_word("lunch"));
});
with_overrides((override) => {
// attachments
const event = event_fixtures.attachment;
global.with_stub((stub) => {
- override('attachments_ui.update_attachments', stub.f);
+ override("attachments_ui.update_attachments", stub.f);
dispatch(event);
- assert_same(stub.get_args('event').event, event);
+ assert_same(stub.get_args("event").event, event);
});
});
with_overrides((override) => {
// User groups
let event = event_fixtures.user_group__add;
- override('settings_user_groups.reload', noop);
+ override("settings_user_groups.reload", noop);
global.with_stub((stub) => {
- override('user_groups.add', stub.f);
+ override("user_groups.add", stub.f);
dispatch(event);
- const args = stub.get_args('group');
+ const args = stub.get_args("group");
assert_same(args.group, event.group);
});
event = event_fixtures.user_group__add_members;
global.with_stub((stub) => {
- override('user_groups.add_members', stub.f);
+ override("user_groups.add_members", stub.f);
dispatch(event);
- const args = stub.get_args('group_id', 'user_ids');
+ const args = stub.get_args("group_id", "user_ids");
assert_same(args.group_id, event.group_id);
assert_same(args.user_ids, event.user_ids);
});
event = event_fixtures.user_group__remove_members;
global.with_stub((stub) => {
- override('user_groups.remove_members', stub.f);
+ override("user_groups.remove_members", stub.f);
dispatch(event);
- const args = stub.get_args('group_id', 'user_ids');
+ const args = stub.get_args("group_id", "user_ids");
assert_same(args.group_id, event.group_id);
assert_same(args.user_ids, event.user_ids);
});
event = event_fixtures.user_group__update;
global.with_stub((stub) => {
- override('user_groups.update', stub.f);
+ override("user_groups.update", stub.f);
dispatch(event);
- const args = stub.get_args('event');
+ const args = stub.get_args("event");
assert_same(args.event.group_id, event.group_id);
assert_same(args.event.data.name, event.data.name);
assert_same(args.event.data.description, event.data.description);
@@ -199,8 +199,8 @@ with_overrides((override) => {
with_overrides((override) => {
// custom profile fields
const event = event_fixtures.custom_profile_fields;
- override('settings_profile_fields.populate_profile_fields', noop);
- override('settings_profile_fields.report_success', noop);
+ override("settings_profile_fields.populate_profile_fields", noop);
+ override("settings_profile_fields.report_success", noop);
dispatch(event);
assert_same(global.page_params.custom_profile_fields, event.fields);
@@ -209,11 +209,11 @@ with_overrides((override) => {
with_overrides((override) => {
// default_streams
const event = event_fixtures.default_streams;
- override('settings_streams.update_default_streams_table', noop);
+ override("settings_streams.update_default_streams_table", noop);
global.with_stub((stub) => {
- override('stream_data.set_realm_default_streams', stub.f);
+ override("stream_data.set_realm_default_streams", stub.f);
dispatch(event);
- const args = stub.get_args('realm_default_streams');
+ const args = stub.get_args("realm_default_streams");
assert_same(args.realm_default_streams, event.default_streams);
});
@@ -222,7 +222,7 @@ with_overrides((override) => {
with_overrides((override) => {
// hotspots
const event = event_fixtures.hotspots;
- override('hotspots.load_new', noop);
+ override("hotspots.load_new", noop);
dispatch(event);
assert_same(page_params.hotspots, event.hotspots);
});
@@ -230,9 +230,9 @@ with_overrides((override) => {
with_overrides((override) => {
// invites_changed
const event = event_fixtures.invites_changed;
- $('#admin-invites-list').length = 1;
+ $("#admin-invites-list").length = 1;
global.with_stub((stub) => {
- override('settings_invites.set_up', stub.f);
+ override("settings_invites.set_up", stub.f);
dispatch(event); // stub automatically checks if stub.f is called once
});
});
@@ -242,9 +242,9 @@ with_overrides((override) => {
const event = event_fixtures.muted_topics;
global.with_stub((stub) => {
- override('muting_ui.handle_updates', stub.f);
+ override("muting_ui.handle_updates", stub.f);
dispatch(event);
- const args = stub.get_args('muted_topics');
+ const args = stub.get_args("muted_topics");
assert_same(args.muted_topics, event.muted_topics);
});
});
@@ -254,9 +254,9 @@ with_overrides((override) => {
const event = event_fixtures.presence;
global.with_stub((stub) => {
- override('activity.update_presence_info', stub.f);
+ override("activity.update_presence_info", stub.f);
dispatch(event);
- const args = stub.get_args('user_id', 'presence', 'server_time');
+ const args = stub.get_args("user_id", "presence", "server_time");
assert_same(args.user_id, event.user_id);
assert_same(args.presence, event.presence);
assert_same(args.server_time, event.server_timestamp);
@@ -267,18 +267,18 @@ with_overrides((override) => {
// reaction
let event = event_fixtures.reaction__add;
global.with_stub((stub) => {
- override('reactions.add_reaction', stub.f);
+ override("reactions.add_reaction", stub.f);
dispatch(event);
- const args = stub.get_args('event');
+ const args = stub.get_args("event");
assert_same(args.event.emoji_name, event.emoji_name);
assert_same(args.event.message_id, event.message_id);
});
event = event_fixtures.reaction__remove;
global.with_stub((stub) => {
- override('reactions.remove_reaction', stub.f);
+ override("reactions.remove_reaction", stub.f);
dispatch(event);
- const args = stub.get_args('event');
+ const args = stub.get_args("event");
assert_same(args.event.emoji_name, event.emoji_name);
assert_same(args.event.message_id, event.message_id);
});
@@ -317,26 +317,26 @@ with_overrides((override) => {
}
let event = event_fixtures.realm__update__create_stream_policy;
- test_realm_integer(event, 'realm_create_stream_policy');
+ test_realm_integer(event, "realm_create_stream_policy");
event = event_fixtures.realm__update__invite_to_stream_policy;
- test_realm_integer(event, 'realm_invite_to_stream_policy');
+ test_realm_integer(event, "realm_invite_to_stream_policy");
event = event_fixtures.realm__update__bot_creation_policy;
- test_realm_integer(event, 'realm_bot_creation_policy');
+ test_realm_integer(event, "realm_bot_creation_policy");
event = event_fixtures.realm__update__invite_required;
- test_realm_boolean(event, 'realm_invite_required');
+ test_realm_boolean(event, "realm_invite_required");
event = event_fixtures.realm__update__name;
dispatch(event);
- assert_same(page_params.realm_name, 'new_realm_name');
+ assert_same(page_params.realm_name, "new_realm_name");
let called = false;
- set_global('electron_bridge', {
+ set_global("electron_bridge", {
send_event: (key, val) => {
- assert_same(key, 'realm_name');
- assert_same(val, 'new_realm_name');
+ assert_same(key, "realm_name");
+ assert_same(val, "new_realm_name");
called = true;
},
});
@@ -345,16 +345,16 @@ with_overrides((override) => {
assert_same(called, true);
event = event_fixtures.realm__update__emails_restricted_to_domains;
- test_realm_boolean(event, 'realm_emails_restricted_to_domains');
+ test_realm_boolean(event, "realm_emails_restricted_to_domains");
event = event_fixtures.realm__update__disallow_disposable_email_addresses;
- test_realm_boolean(event, 'realm_disallow_disposable_email_addresses');
+ test_realm_boolean(event, "realm_disallow_disposable_email_addresses");
event = event_fixtures.realm__update_default_twenty_four_hour_time;
- test_realm_boolean(event, 'realm_default_twenty_four_hour_time');
+ test_realm_boolean(event, "realm_default_twenty_four_hour_time");
event = event_fixtures.realm__update__email_addresses_visibility;
- override('stream_ui_updates.update_subscribers_list', noop);
+ override("stream_ui_updates.update_subscribers_list", noop);
dispatch(event);
assert_same(page_params.realm_email_address_visibility, 3);
@@ -370,25 +370,25 @@ with_overrides((override) => {
event = event_fixtures.realm__update_default_code_block_language;
dispatch(event);
- assert_same(page_params.realm_default_code_block_language, 'javascript');
+ assert_same(page_params.realm_default_code_block_language, "javascript");
event = event_fixtures.realm__update_dict__default;
page_params.realm_allow_message_editing = false;
page_params.realm_message_content_edit_limit_seconds = 0;
- override('settings_org.populate_auth_methods', noop);
+ override("settings_org.populate_auth_methods", noop);
dispatch(event);
assert_same(page_params.realm_allow_message_editing, true);
assert_same(page_params.realm_message_content_edit_limit_seconds, 5);
assert_same(page_params.realm_authentication_methods, {Google: true});
event = event_fixtures.realm__update_dict__icon;
- override('realm_icon.rerender', noop);
+ override("realm_icon.rerender", noop);
called = false;
- set_global('electron_bridge', {
+ set_global("electron_bridge", {
send_event: (key, val) => {
- assert_same(key, 'realm_icon_url');
- assert_same(val, 'icon.png');
+ assert_same(key, "realm_icon_url");
+ assert_same(val, "icon.png");
called = true;
},
});
@@ -396,23 +396,23 @@ with_overrides((override) => {
dispatch(event);
assert_same(called, true);
- assert_same(page_params.realm_icon_url, 'icon.png');
- assert_same(page_params.realm_icon_source, 'U');
+ assert_same(page_params.realm_icon_url, "icon.png");
+ assert_same(page_params.realm_icon_source, "U");
event = event_fixtures.realm__update_dict__logo;
- override('realm_logo.rerender', noop);
+ override("realm_logo.rerender", noop);
dispatch(event);
- assert_same(page_params.realm_logo_url, 'logo.png');
- assert_same(page_params.realm_logo_source, 'U');
+ assert_same(page_params.realm_logo_url, "logo.png");
+ assert_same(page_params.realm_logo_source, "U");
event = event_fixtures.realm__update_dict__night_logo;
- override('realm_logo.rerender', noop);
+ override("realm_logo.rerender", noop);
dispatch(event);
- assert_same(page_params.realm_night_logo_url, 'night_logo.png');
- assert_same(page_params.realm_night_logo_source, 'U');
+ assert_same(page_params.realm_night_logo_url, "night_logo.png");
+ assert_same(page_params.realm_night_logo_source, "U");
event = event_fixtures.realm__deactivated;
- set_global('location', {});
+ set_global("location", {});
dispatch(event);
assert_same(window.location.href, "/accounts/deactivated/");
});
@@ -422,26 +422,26 @@ with_overrides((override) => {
let event = event_fixtures.realm_bot__add;
global.with_stub((bot_stub) => {
global.with_stub((admin_stub) => {
- override('bot_data.add', bot_stub.f);
- override('settings_users.update_bot_data', admin_stub.f);
+ override("bot_data.add", bot_stub.f);
+ override("settings_users.update_bot_data", admin_stub.f);
dispatch(event);
- const args = bot_stub.get_args('bot');
+ const args = bot_stub.get_args("bot");
assert_same(args.bot, event.bot);
- admin_stub.get_args('update_user_id', 'update_bot_data');
+ admin_stub.get_args("update_user_id", "update_bot_data");
});
});
event = event_fixtures.realm_bot__remove;
global.with_stub((bot_stub) => {
global.with_stub((admin_stub) => {
- override('bot_data.deactivate', bot_stub.f);
- override('settings_users.update_bot_data', admin_stub.f);
+ override("bot_data.deactivate", bot_stub.f);
+ override("settings_users.update_bot_data", admin_stub.f);
dispatch(event);
- const args = bot_stub.get_args('user_id');
+ const args = bot_stub.get_args("user_id");
assert_same(args.user_id, event.bot.user_id);
- admin_stub.get_args('update_user_id', 'update_bot_data');
+ admin_stub.get_args("update_user_id", "update_bot_data");
});
});
@@ -452,16 +452,16 @@ with_overrides((override) => {
event = event_fixtures.realm_bot__update;
global.with_stub((bot_stub) => {
global.with_stub((admin_stub) => {
- override('bot_data.update', bot_stub.f);
- override('settings_users.update_bot_data', admin_stub.f);
+ override("bot_data.update", bot_stub.f);
+ override("settings_users.update_bot_data", admin_stub.f);
dispatch(event);
- let args = bot_stub.get_args('user_id', 'bot');
+ let args = bot_stub.get_args("user_id", "bot");
assert_same(args.user_id, event.bot.user_id);
assert_same(args.bot, event.bot);
- args = admin_stub.get_args('update_user_id', 'update_bot_data');
+ args = admin_stub.get_args("update_user_id", "update_bot_data");
assert_same(args.update_user_id, event.bot.user_id);
});
});
@@ -472,12 +472,12 @@ with_overrides((override) => {
const event = event_fixtures.realm_emoji;
global.with_stub((stub) => {
- override('emoji.update_emojis', stub.f);
- override('settings_emoji.populate_emoji', noop);
- override('emoji_picker.generate_emoji_picker_data', noop);
- override('composebox_typeahead.update_emoji_data', noop);
+ override("emoji.update_emojis", stub.f);
+ override("settings_emoji.populate_emoji", noop);
+ override("emoji_picker.generate_emoji_picker_data", noop);
+ override("composebox_typeahead.update_emoji_data", noop);
dispatch(event);
- const args = stub.get_args('realm_emoji');
+ const args = stub.get_args("realm_emoji");
assert_same(args.realm_emoji, event.realm_emoji);
});
});
@@ -486,7 +486,7 @@ with_overrides((override) => {
// realm_filters
const event = event_fixtures.realm_filters;
page_params.realm_filters = [];
- override('settings_linkifiers.populate_filters', noop);
+ override("settings_linkifiers.populate_filters", noop);
dispatch(event);
assert_same(page_params.realm_filters, event.realm_filters);
@@ -496,7 +496,7 @@ with_overrides((override) => {
// realm_domains
let event = event_fixtures.realm_domains__add;
page_params.realm_domains = [];
- override('settings_org.populate_realm_domains', noop);
+ override("settings_org.populate_realm_domains", noop);
dispatch(event);
assert_same(page_params.realm_domains, [event.realm_domain]);
@@ -514,23 +514,23 @@ with_overrides((override) => {
let event = event_fixtures.realm_user__add;
dispatch(event);
const added_person = people.get_by_user_id(event.person.user_id);
- assert.equal(added_person.full_name, 'Added Person');
+ assert.equal(added_person.full_name, "Added Person");
assert(people.is_active_user_for_popover(event.person.user_id));
event = event_fixtures.realm_user__remove;
- override('stream_events.remove_deactivated_user_from_all_streams', noop);
+ override("stream_events.remove_deactivated_user_from_all_streams", noop);
dispatch(event);
// We don't actually remove the person, we just deactivate them.
const removed_person = people.get_by_user_id(event.person.user_id);
- assert.equal(removed_person.full_name, 'Added Person');
+ assert.equal(removed_person.full_name, "Added Person");
assert(!people.is_active_user_for_popover(event.person.user_id));
event = event_fixtures.realm_user__update;
global.with_stub((stub) => {
- override('user_events.update_person', stub.f);
+ override("user_events.update_person", stub.f);
dispatch(event);
- const args = stub.get_args('person');
+ const args = stub.get_args("person");
assert_same(args.person, event.person);
});
});
@@ -539,9 +539,9 @@ with_overrides((override) => {
// restart
const event = event_fixtures.restart;
global.with_stub((stub) => {
- override('reload.initiate', stub.f);
+ override("reload.initiate", stub.f);
dispatch(event);
- const args = stub.get_args('options');
+ const args = stub.get_args("options");
assert.equal(args.options.save_pointer, true);
assert.equal(args.options.immediate, true);
});
@@ -552,10 +552,10 @@ with_overrides((override) => {
let event = event_fixtures.stream__update;
global.with_stub((stub) => {
- override('stream_events.update_property', stub.f);
- override('settings_streams.update_default_streams_table', noop);
+ override("stream_events.update_property", stub.f);
+ override("settings_streams.update_default_streams_table", noop);
dispatch(event);
- const args = stub.get_args('stream_id', 'property', 'value');
+ const args = stub.get_args("stream_id", "property", "value");
assert_same(args.stream_id, event.stream_id);
assert_same(args.property, event.property);
assert_same(args.value, event.value);
@@ -564,30 +564,30 @@ with_overrides((override) => {
// stream create
event = event_fixtures.stream__create;
global.with_stub((stub) => {
- override('stream_data.create_streams', stub.f);
- override('stream_data.get_sub_by_id', noop);
- override('stream_data.update_calculated_fields', noop);
- override('subs.add_sub_to_table', noop);
+ override("stream_data.create_streams", stub.f);
+ override("stream_data.get_sub_by_id", noop);
+ override("stream_data.update_calculated_fields", noop);
+ override("subs.add_sub_to_table", noop);
dispatch(event);
- const args = stub.get_args('streams');
+ const args = stub.get_args("streams");
assert_same(args.streams.map((stream) => stream.stream_id), [42, 99]);
});
// stream delete
event = event_fixtures.stream__delete;
global.with_stub((stub) => {
- override('subs.remove_stream', noop);
- override('stream_data.delete_sub', noop);
- override('settings_streams.update_default_streams_table', noop);
- override('stream_data.remove_default_stream', noop);
+ override("subs.remove_stream", noop);
+ override("stream_data.delete_sub", noop);
+ 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_list.remove_sidebar_row', stub.f);
+ 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');
+ const args = stub.get_args("stream_id");
assert_same(args.stream_id, 42);
- override('stream_list.remove_sidebar_row', noop);
+ override("stream_list.remove_sidebar_row", noop);
page_params.realm_notifications_stream_id = 42;
dispatch(event);
assert_same(page_params.realm_notifications_stream_id, -1);
@@ -602,15 +602,15 @@ with_overrides((override) => {
// submessage
const event = event_fixtures.submessage;
global.with_stub((stub) => {
- override('submessage.handle_event', stub.f);
+ override("submessage.handle_event", stub.f);
dispatch(event);
- const submsg = stub.get_args('submsg').submsg;
+ const submsg = stub.get_args("submsg").submsg;
assert_same(submsg, {
id: 99,
sender_id: 42,
- msg_type: 'stream',
+ msg_type: "stream",
message_id: 56,
- content: 'test',
+ content: "test",
});
});
});
@@ -621,17 +621,17 @@ with_overrides((override) => {
// typing
let event = event_fixtures.typing__start;
global.with_stub((stub) => {
- override('typing_events.display_notification', stub.f);
+ override("typing_events.display_notification", stub.f);
dispatch(event);
- const args = stub.get_args('event');
+ const args = stub.get_args("event");
assert_same(args.event.sender.user_id, 4);
});
event = event_fixtures.typing__stop;
global.with_stub((stub) => {
- override('typing_events.hide_notification', stub.f);
+ override("typing_events.hide_notification", stub.f);
dispatch(event);
- const args = stub.get_args('event');
+ const args = stub.get_args("event");
assert_same(args.event.sender.user_id, 6);
});
@@ -643,9 +643,9 @@ with_overrides((override) => {
with_overrides((override) => {
// update_display_settings
let event = event_fixtures.update_display_settings__default_language;
- page_params.default_language = 'en';
+ page_params.default_language = "en";
dispatch(event);
- assert_same(page_params.default_language, 'fr');
+ assert_same(page_params.default_language, "fr");
event = event_fixtures.update_display_settings__left_side_userlist;
page_params.left_side_userlist = false;
@@ -657,7 +657,7 @@ with_overrides((override) => {
called = true;
};
- override('message_list.narrowed', current_msg_list);
+ override("message_list.narrowed", current_msg_list);
event = event_fixtures.update_display_settings__twenty_four_hour_time;
page_params.twenty_four_hour_time = false;
dispatch(event);
@@ -677,14 +677,14 @@ with_overrides((override) => {
};
dispatch(event);
assert_same(page_params.high_contrast_mode, true);
- assert_same(toggled, ['high-contrast']);
+ assert_same(toggled, ["high-contrast"]);
event = event_fixtures.update_display_settings__dense_mode;
page_params.dense_mode = false;
toggled = [];
dispatch(event);
assert_same(page_params.dense_mode, true);
- assert_same(toggled, ['less_dense_mode', 'more_dense_mode']);
+ assert_same(toggled, ["less_dense_mode", "more_dense_mode"]);
$("body").fadeOut = (secs) => { assert_same(secs, 300); };
$("body").fadeIn = (secs) => { assert_same(secs, 300); };
@@ -692,8 +692,8 @@ with_overrides((override) => {
global.with_stub((stub) => {
event = event_fixtures.update_display_settings__color_scheme_dark;
page_params.color_scheme = 1;
- override('night_mode.enable', stub.f); // automatically checks if called
- override('realm_logo.rerender', noop);
+ override("night_mode.enable", stub.f); // automatically checks if called
+ override("realm_logo.rerender", noop);
dispatch(event);
assert(page_params.color_scheme, 2);
});
@@ -701,8 +701,8 @@ with_overrides((override) => {
global.with_stub((stub) => {
event = event_fixtures.update_display_settings__color_scheme_light;
page_params.color_scheme = 1;
- override('night_mode.disable', stub.f); // automatically checks if called
- override('realm_logo.rerender', noop);
+ override("night_mode.disable", stub.f); // automatically checks if called
+ override("realm_logo.rerender", noop);
dispatch(event);
assert(page_params.color_scheme, 3);
});
@@ -710,8 +710,8 @@ with_overrides((override) => {
global.with_stub((stub) => {
event = event_fixtures.update_display_settings__color_scheme_automatic;
page_params.color_scheme = 2;
- override('night_mode.default_preference_checker', stub.f); // automatically checks if called
- override('realm_logo.rerender', noop);
+ override("night_mode.default_preference_checker", stub.f); // automatically checks if called
+ override("realm_logo.rerender", noop);
dispatch(event);
assert(page_params.color_scheme, 1);
});
@@ -719,20 +719,20 @@ with_overrides((override) => {
global.with_stub((stub) => {
event = event_fixtures.update_display_settings__emojiset;
called = false;
- override('settings_display.report_emojiset_change', stub.f);
- page_params.emojiset = 'text';
+ override("settings_display.report_emojiset_change", stub.f);
+ page_params.emojiset = "text";
dispatch(event);
assert_same(called, true);
- assert_same(page_params.emojiset, 'google');
+ assert_same(page_params.emojiset, "google");
});
- override('starred_messages.rerender_ui', noop);
+ override("starred_messages.rerender_ui", noop);
event = event_fixtures.update_display_settings__starred_message_counts;
page_params.starred_message_counts = false;
dispatch(event);
assert_same(page_params.starred_message_counts, true);
- override('scroll_bar.set_layout_width', noop);
+ override("scroll_bar.set_layout_width", noop);
event = event_fixtures.update_display_settings__fluid_layout_width;
page_params.fluid_layout_width = false;
dispatch(event);
@@ -740,8 +740,8 @@ with_overrides((override) => {
global.with_stub((stub) => {
event = event_fixtures.update_display_settings__demote_inactive_streams;
- override('stream_data.set_filter_out_inactives', noop);
- override('stream_list.update_streams_sidebar', stub.f);
+ override("stream_data.set_filter_out_inactives", noop);
+ override("stream_list.update_streams_sidebar", stub.f);
page_params.demote_inactive_streams = 1;
dispatch(event);
assert_same(page_params.demote_inactive_streams, 2);
@@ -752,9 +752,9 @@ with_overrides((override) => {
// update_global_notifications
const event = event_fixtures.update_global_notifications;
global.with_stub((stub) => {
- override('notifications.handle_global_notification_updates', stub.f);
+ override("notifications.handle_global_notification_updates", stub.f);
dispatch(event);
- const args = stub.get_args('name', 'setting');
+ const args = stub.get_args("name", "setting");
assert_same(args.name, event.notification_name);
assert_same(args.setting, event.setting);
});
@@ -765,9 +765,9 @@ with_overrides((override) => {
const event = event_fixtures.update_message_flags__read;
global.with_stub((stub) => {
- override('unread_ops.process_read_messages_event', stub.f);
+ override("unread_ops.process_read_messages_event", stub.f);
dispatch(event);
- const args = stub.get_args('message_ids');
+ const args = stub.get_args("message_ids");
assert_same(args.message_ids, [999]);
});
});
@@ -775,13 +775,13 @@ with_overrides((override) => {
with_overrides((override) => {
// update_message_flags__starred
- override('starred_messages.rerender_ui', noop);
+ override("starred_messages.rerender_ui", noop);
let event = event_fixtures.update_message_flags__starred_add;
global.with_stub((stub) => {
- override('ui.update_starred_view', stub.f);
+ override("ui.update_starred_view", stub.f);
dispatch(event);
- const args = stub.get_args('message_id', 'new_value');
+ const args = stub.get_args("message_id", "new_value");
assert_same(args.message_id, test_message.id);
assert_same(args.new_value, true); // for 'add'
const msg = message_store.get(test_message.id);
@@ -790,9 +790,9 @@ with_overrides((override) => {
event = event_fixtures.update_message_flags__starred_remove;
global.with_stub((stub) => {
- override('ui.update_starred_view', stub.f);
+ override("ui.update_starred_view", stub.f);
dispatch(event);
- const args = stub.get_args('message_id', 'new_value');
+ const args = stub.get_args("message_id", "new_value");
assert_same(args.message_id, test_message.id);
assert_same(args.new_value, false);
const msg = message_store.get(test_message.id);
@@ -804,26 +804,26 @@ with_overrides((override) => {
// delete_message
const event = event_fixtures.delete_message;
- override('stream_list.update_streams_sidebar', noop);
+ override("stream_list.update_streams_sidebar", noop);
global.with_stub((stub) => {
- override('unread_ops.process_read_messages_event', noop);
- override('ui.remove_messages', stub.f);
+ override("unread_ops.process_read_messages_event", noop);
+ override("ui.remove_messages", stub.f);
dispatch(event);
- const args = stub.get_args('message_ids');
+ const args = stub.get_args("message_ids");
assert_same(args.message_ids, [1337]);
});
global.with_stub((stub) => {
- override('unread_ops.process_read_messages_event', stub.f);
+ override("unread_ops.process_read_messages_event", stub.f);
dispatch(event);
- const args = stub.get_args('message_ids');
+ const args = stub.get_args("message_ids");
assert_same(args.message_ids, [1337]);
});
global.with_stub((stub) => {
- override('stream_topic_history.remove_messages', stub.f);
+ override("stream_topic_history.remove_messages", stub.f);
dispatch(event);
- const args = stub.get_args('opts');
+ const args = stub.get_args("opts");
assert_same(args.opts.stream_id, 99);
- assert_same(args.opts.topic_name, 'topic1');
+ assert_same(args.opts.topic_name, "topic1");
assert_same(args.opts.num_messages, 1);
});
});
@@ -832,42 +832,42 @@ with_overrides((override) => {
// attachments
let event = event_fixtures.user_status__set_away;
global.with_stub((stub) => {
- override('activity.on_set_away', stub.f);
+ override("activity.on_set_away", stub.f);
dispatch(event);
- const args = stub.get_args('user_id');
+ const args = stub.get_args("user_id");
assert_same(args.user_id, 55);
});
event = event_fixtures.user_status__revoke_away;
global.with_stub((stub) => {
- override('activity.on_revoke_away', stub.f);
+ override("activity.on_revoke_away", stub.f);
dispatch(event);
- const args = stub.get_args('user_id');
+ const args = stub.get_args("user_id");
assert_same(args.user_id, 63);
});
event = event_fixtures.user_status__set_status_text;
global.with_stub((stub) => {
- override('activity.redraw_user', stub.f);
+ override("activity.redraw_user", stub.f);
dispatch(event);
- const args = stub.get_args('user_id');
+ const args = stub.get_args("user_id");
assert_same(args.user_id, test_user.user_id);
const status_text = user_status.get_status_text(test_user.user_id);
- assert.equal(status_text, 'out to lunch');
+ assert.equal(status_text, "out to lunch");
});
});
with_overrides((override) => {
const event = event_fixtures.realm_export;
- override('settings_exports.populate_exports_table', noop);
+ override("settings_exports.populate_exports_table", noop);
dispatch(event);
global.with_stub((stub) => {
- override('settings_exports.populate_exports_table', stub.f);
+ override("settings_exports.populate_exports_table", stub.f);
dispatch(event);
- const args = stub.get_args('exports');
+ const args = stub.get_args("exports");
assert.equal(args.exports.acting_user_id, 55);
- assert.equal(args.exports.event_time, 'noon');
- assert.equal(args.exports.path, 'some_path');
+ assert.equal(args.exports.event_time, "noon");
+ assert.equal(args.exports.path, "some_path");
});
});
diff --git a/frontend_tests/node_tests/dispatch_subs.js b/frontend_tests/node_tests/dispatch_subs.js
index f3bd367ba4b..169676c7dc8 100644
--- a/frontend_tests/node_tests/dispatch_subs.js
+++ b/frontend_tests/node_tests/dispatch_subs.js
@@ -1,13 +1,13 @@
-const events = require('./lib/events.js');
+const events = require("./lib/events.js");
const event_fixtures = events.fixtures;
const test_user = events.test_user;
const noop = function () {};
-zrequire('people');
-zrequire('stream_data');
-zrequire('server_events_dispatch');
+zrequire("people");
+zrequire("stream_data");
+zrequire("server_events_dispatch");
people.add_active_user(test_user);
@@ -21,7 +21,7 @@ function test(label, f) {
});
}
-test('add', (override) => {
+test("add", (override) => {
const event = event_fixtures.subscription__add;
const sub = event.subscriptions[0];
@@ -33,27 +33,27 @@ test('add', (override) => {
});
global.with_stub((subscription_stub) => {
- override('stream_events.mark_subscribed', subscription_stub.f);
+ override("stream_events.mark_subscribed", subscription_stub.f);
dispatch(event);
- const args = subscription_stub.get_args('sub', 'subscribers');
+ const args = subscription_stub.get_args("sub", "subscribers");
assert.deepEqual(args.sub.stream_id, stream_id);
assert.deepEqual(args.subscribers, event.subscriptions[0].subscribers);
});
});
-test('peer add/remove', (override) => {
+test("peer add/remove", (override) => {
let event = event_fixtures.subscription__peer_add;
stream_data.add_sub({
- name: 'devel',
+ name: "devel",
stream_id: event.stream_id,
});
const subs_stub = global.make_stub();
- override('subs.update_subscribers_ui', subs_stub.f);
+ override("subs.update_subscribers_ui", subs_stub.f);
const compose_fade_stub = global.make_stub();
- override('compose_fade.update_faded_users', compose_fade_stub.f);
+ override("compose_fade.update_faded_users", compose_fade_stub.f);
dispatch(event);
assert.equal(compose_fade_stub.num_calls, 1);
@@ -65,7 +65,7 @@ test('peer add/remove', (override) => {
assert.equal(subs_stub.num_calls, 2);
});
-test('remove', (override) => {
+test("remove", (override) => {
const event = event_fixtures.subscription__remove;
const event_sub = event.subscriptions[0];
const stream_id = event_sub.stream_id;
@@ -78,88 +78,88 @@ test('remove', (override) => {
stream_data.add_sub(sub);
global.with_stub((stub) => {
- override('stream_events.mark_unsubscribed', stub.f);
+ override("stream_events.mark_unsubscribed", stub.f);
dispatch(event);
- const args = stub.get_args('sub');
+ const args = stub.get_args("sub");
assert.deepEqual(args.sub, sub);
});
});
-test('update', (override) => {
+test("update", (override) => {
const event = event_fixtures.subscription__update;
global.with_stub((stub) => {
- override('stream_events.update_property', stub.f);
+ override("stream_events.update_property", stub.f);
dispatch(event);
- const args = stub.get_args('stream_id', 'property', 'value');
+ const args = stub.get_args("stream_id", "property", "value");
assert.deepEqual(args.stream_id, event.stream_id);
assert.deepEqual(args.property, event.property);
assert.deepEqual(args.value, event.value);
});
});
-test('add error handling', (override) => {
+test("add error handling", (override) => {
// test blueslip errors/warns
const event = event_fixtures.subscription__add;
global.with_stub((stub) => {
- override('blueslip.error', stub.f);
+ override("blueslip.error", stub.f);
dispatch(event);
- assert.deepEqual(stub.get_args('param').param, 'Subscribing to unknown stream with ID 42');
+ assert.deepEqual(stub.get_args("param").param, "Subscribing to unknown stream with ID 42");
});
});
-test('peer event error handling (bad stream_ids)', (override) => {
- override('compose_fade.update_faded_users', noop);
+test("peer event error handling (bad stream_ids)", (override) => {
+ override("compose_fade.update_faded_users", noop);
const add_event = {
- type: 'subscription',
- op: 'peer_add',
+ type: "subscription",
+ op: "peer_add",
stream_id: 99999,
};
- blueslip.expect('warn', 'Cannot find stream for peer_add: 99999');
+ blueslip.expect("warn", "Cannot find stream for peer_add: 99999");
dispatch(add_event);
blueslip.reset();
const remove_event = {
- type: 'subscription',
- op: 'peer_remove',
+ type: "subscription",
+ op: "peer_remove",
stream_id: 99999,
};
- blueslip.expect('warn', 'Cannot find stream for peer_remove: 99999');
+ blueslip.expect("warn", "Cannot find stream for peer_remove: 99999");
dispatch(remove_event);
});
-test('peer event error handling (add_subscriber)', (override) => {
+test("peer event error handling (add_subscriber)", (override) => {
stream_data.add_sub({
- name: 'devel',
+ name: "devel",
stream_id: 1,
});
- override('stream_data.add_subscriber', () => false);
+ override("stream_data.add_subscriber", () => false);
const add_event = {
- type: 'subscription',
- op: 'peer_add',
+ type: "subscription",
+ op: "peer_add",
stream_id: 1,
user_id: 99999, // id is irrelevant
};
- blueslip.expect('warn', 'Cannot process peer_add event');
+ blueslip.expect("warn", "Cannot process peer_add event");
dispatch(add_event);
blueslip.reset();
- override('stream_data.remove_subscriber', () => false);
+ override("stream_data.remove_subscriber", () => false);
const remove_event = {
- type: 'subscription',
- op: 'peer_remove',
+ type: "subscription",
+ op: "peer_remove",
stream_id: 1,
user_id: 99999, // id is irrelevant
};
- blueslip.expect('warn', 'Cannot process peer_remove event.');
+ 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 f403d8d3ee7..3601bdb46c5 100644
--- a/frontend_tests/node_tests/drafts.js
+++ b/frontend_tests/node_tests/drafts.js
@@ -1,17 +1,17 @@
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
-zrequire('localstorage');
-zrequire('drafts');
-set_global('XDate', zrequire('XDate', 'xdate'));
-zrequire('timerender');
-set_global('Handlebars', global.make_handlebars());
-zrequire('stream_color');
-zrequire('colorspace');
+zrequire("localstorage");
+zrequire("drafts");
+set_global("XDate", zrequire("XDate", "xdate"));
+zrequire("timerender");
+set_global("Handlebars", global.make_handlebars());
+zrequire("stream_color");
+zrequire("colorspace");
const ls_container = new Map();
const noop = function () { return; };
-set_global('localStorage', {
+set_global("localStorage", {
getItem: function (key) {
return ls_container.get(key);
},
@@ -25,26 +25,26 @@ set_global('localStorage', {
ls_container.clear();
},
});
-set_global('compose', {});
-set_global('compose_state', {});
-set_global('stream_data', {
+set_global("compose", {});
+set_global("compose_state", {});
+set_global("stream_data", {
get_color: function () {
- return '#FFFFFF';
+ return "#FFFFFF";
},
});
-set_global('people', {
+set_global("people", {
// Mocking get_by_email function, here we are
// just returning string before `@` in email
get_by_email: function (email) {
return {
- full_name: email.split('@')[0],
+ full_name: email.split("@")[0],
};
},
});
-set_global('markdown', {
+set_global("markdown", {
apply_markdown: noop,
});
-set_global('page_params', {
+set_global("page_params", {
twenty_four_hour_time: false,
});
@@ -90,14 +90,14 @@ const short_msg = {
content: "a",
};
-run_test('legacy', () => {
+run_test("legacy", () => {
assert.deepEqual(
drafts.restore_message(legacy_draft),
compose_args_for_legacy_draft,
);
});
-run_test('draft_model', () => {
+run_test("draft_model", () => {
const draft_model = drafts.draft_model;
const ls = localstorage();
@@ -149,7 +149,7 @@ run_test('draft_model', () => {
}());
});
-run_test('snapshot_message', () => {
+run_test("snapshot_message", () => {
function stub_draft(draft) {
global.compose_state.get_message_type = function () {
return draft.type;
@@ -184,7 +184,7 @@ run_test('snapshot_message', () => {
assert.equal(drafts.snapshot_message(), undefined);
});
-run_test('initialize', () => {
+run_test("initialize", () => {
const message_content = $("#compose-textarea");
message_content.focusout = function (f) {
assert.equal(f, drafts.update_draft);
@@ -202,7 +202,7 @@ run_test('initialize', () => {
drafts.initialize();
});
-run_test('remove_old_drafts', () => {
+run_test("remove_old_drafts", () => {
const draft_3 = {
stream: "stream",
subject: "topic",
@@ -228,7 +228,7 @@ run_test('remove_old_drafts', () => {
assert.deepEqual(draft_model.get(), {id3: draft_3});
});
-run_test('format_drafts', () => {
+run_test("format_drafts", () => {
drafts.remove_old_drafts = noop;
draft_1.updatedAt = new Date(1549958107000).getTime(); // 2/12/2019 07:55:07 AM (UTC+0)
@@ -257,49 +257,49 @@ run_test('format_drafts', () => {
const expected = [
{
- draft_id: 'id1',
+ draft_id: "id1",
is_stream: true,
- stream: 'stream',
- stream_color: '#FFFFFF',
- dark_background: '',
- topic: 'topic',
- raw_content: 'Test Stream Message',
- time_stamp: '7:55 AM',
+ stream: "stream",
+ stream_color: "#FFFFFF",
+ dark_background: "",
+ topic: "topic",
+ raw_content: "Test Stream Message",
+ time_stamp: "7:55 AM",
},
{
- draft_id: 'id2',
+ draft_id: "id2",
is_stream: false,
- recipients: 'aaron',
- raw_content: 'Test Private Message',
- time_stamp: 'Jan 30',
+ recipients: "aaron",
+ raw_content: "Test Private Message",
+ time_stamp: "Jan 30",
},
{
- draft_id: 'id5',
+ draft_id: "id5",
is_stream: false,
- recipients: 'aaron',
- raw_content: 'Test Private Message 3',
- time_stamp: 'Jan 29',
+ recipients: "aaron",
+ raw_content: "Test Private Message 3",
+ time_stamp: "Jan 29",
},
{
- draft_id: 'id4',
+ draft_id: "id4",
is_stream: false,
- recipients: 'aaron',
- raw_content: 'Test Private Message 2',
- time_stamp: 'Jan 26',
+ recipients: "aaron",
+ raw_content: "Test Private Message 2",
+ time_stamp: "Jan 26",
},
{
- draft_id: 'id3',
+ draft_id: "id3",
is_stream: true,
- stream: 'stream 2',
- stream_color: '#FFFFFF',
- dark_background: '',
- topic: 'topic',
- raw_content: 'Test Stream Message 2',
- time_stamp: 'Jan 21',
+ stream: "stream 2",
+ stream_color: "#FFFFFF",
+ dark_background: "",
+ topic: "topic",
+ raw_content: "Test Stream Message 2",
+ time_stamp: "Jan 21",
},
];
- $('#drafts_table').append = noop;
+ $("#drafts_table").append = noop;
const draft_model = drafts.draft_model;
const ls = localstorage();
@@ -314,10 +314,10 @@ run_test('format_drafts', () => {
};
global.stub_templates((template_name, data) => {
- assert.equal(template_name, 'draft_table_body');
+ assert.equal(template_name, "draft_table_body");
// Tests formatting and sorting of drafts
assert.deepEqual(data.drafts, expected);
- return '<draft table stub>';
+ return "<draft table stub>";
});
drafts.open_overlay = noop;
diff --git a/frontend_tests/node_tests/dropdown_list_widget.js b/frontend_tests/node_tests/dropdown_list_widget.js
index b355a09ef51..e1301e82572 100644
--- a/frontend_tests/node_tests/dropdown_list_widget.js
+++ b/frontend_tests/node_tests/dropdown_list_widget.js
@@ -1,29 +1,29 @@
-zrequire('dropdown_list_widget');
-zrequire('scroll_util');
-set_global('$', global.make_zjquery());
+zrequire("dropdown_list_widget");
+zrequire("scroll_util");
+set_global("$", global.make_zjquery());
const noop = () => {};
const _list_render = {
create: () => ({ init: noop }),
};
-set_global('list_render', _list_render);
+set_global("list_render", _list_render);
const setup_zjquery_data = (name) => {
$.clear_all_elements();
const input_group = $(".input_group");
- const reset_button = $('.dropdown_list_reset_button');
- input_group.set_find_results('.dropdown_list_reset_button:not([disabled])', reset_button);
+ const reset_button = $(".dropdown_list_reset_button");
+ input_group.set_find_results(".dropdown_list_reset_button:not([disabled])", reset_button);
$(`#${name}_widget #${name}_name`).closest = () => input_group;
const $widget = $(`#${name}_widget #${name}_name`);
return {reset_button, $widget};
};
-run_test('basic_functions', () => {
+run_test("basic_functions", () => {
let updated_value;
const opts = {
- widget_name: 'my_setting',
- data: ['one', 'two', 'three'].map((x) => ({name: x, value: x})),
- value: 'one',
+ widget_name: "my_setting",
+ data: ["one", "two", "three"].map((x) => ({name: x, value: x})),
+ value: "one",
on_update: (val) => { updated_value = val; },
default_text: i18n.t("not set"),
render_text: (text) => `rendered: ${text}`,
@@ -33,34 +33,34 @@ run_test('basic_functions', () => {
const widget = dropdown_list_widget(opts);
- assert.equal(widget.value(), 'one');
+ assert.equal(widget.value(), "one");
assert.equal(updated_value, undefined); // We haven't 'updated' the widget yet.
assert(reset_button.visible());
- widget.update('two');
- assert.equal($widget.text(), 'rendered: two');
- assert.equal(widget.value(), 'two');
- assert.equal(updated_value, 'two');
+ widget.update("two");
+ assert.equal($widget.text(), "rendered: two");
+ assert.equal(widget.value(), "two");
+ assert.equal(updated_value, "two");
assert(reset_button.visible());
widget.update(null);
- assert.equal($widget.text(), 'translated: not set');
- assert.equal(widget.value(), '');
+ assert.equal($widget.text(), "translated: not set");
+ assert.equal(widget.value(), "");
assert.equal(updated_value, null);
assert(!reset_button.visible());
});
-run_test('no_default_value', () => {
+run_test("no_default_value", () => {
const opts = {
- widget_name: 'my_setting',
- data: ['one', 'two', 'three'].map((x) => ({name: x, value: x})),
+ widget_name: "my_setting",
+ data: ["one", "two", "three"].map((x) => ({name: x, value: x})),
default_text: i18n.t("not set"),
render_text: (text) => `rendered: ${text}`,
- null_value: 'null-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');
+ assert.equal(widget.value(), "null-value");
});
diff --git a/frontend_tests/node_tests/echo.js b/frontend_tests/node_tests/echo.js
index 47b61408e79..87930b4bc9f 100644
--- a/frontend_tests/node_tests/echo.js
+++ b/frontend_tests/node_tests/echo.js
@@ -1,36 +1,36 @@
-set_global('$', global.make_zjquery());
-set_global('markdown', {});
-set_global('local_message', {
+set_global("$", global.make_zjquery());
+set_global("markdown", {});
+set_global("local_message", {
now: () => "timestamp",
});
-set_global('page_params', {});
+set_global("page_params", {});
-zrequire('echo');
-zrequire('people');
+zrequire("echo");
+zrequire("people");
let disparities = [];
let messages_to_rerender = [];
-set_global('ui', {
+set_global("ui", {
show_failed_message_success: () => {},
});
-set_global('sent_messages', {
+set_global("sent_messages", {
mark_disparity: (local_id) => {
disparities.push(local_id);
},
});
-set_global('message_store', {
+set_global("message_store", {
get: () => ({ failed_request: true }),
update_booleans: () => {},
});
-set_global('alert_words', {
+set_global("alert_words", {
process_message: () => {},
});
-set_global('home_msg_list', {
+set_global("home_msg_list", {
view: {
rerender_messages: (msgs) => {
messages_to_rerender = msgs;
@@ -38,11 +38,11 @@ set_global('home_msg_list', {
},
});
-set_global('message_list', {});
+set_global("message_list", {});
-set_global('current_msg_list', '');
+set_global("current_msg_list", "");
-run_test('process_from_server for un-echoed messages', () => {
+run_test("process_from_server for un-echoed messages", () => {
const waiting_for_ack = new Map();
const server_messages = [
{
@@ -54,11 +54,11 @@ run_test('process_from_server for un-echoed messages', () => {
assert.deepEqual(non_echo_messages, server_messages);
});
-run_test('process_from_server for differently rendered messages', () => {
+run_test("process_from_server for differently rendered messages", () => {
// Test that we update all the booleans and the content of the message
// in local echo.
- const old_value = 'old_value';
- const new_value = 'new_value';
+ 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>",
@@ -93,7 +93,7 @@ run_test('process_from_server for differently rendered messages', () => {
}]);
});
-run_test('build_display_recipient', () => {
+run_test("build_display_recipient", () => {
page_params.user_id = 123;
const params = {};
@@ -162,7 +162,7 @@ run_test('build_display_recipient', () => {
});
-run_test('insert_local_message', () => {
+run_test("insert_local_message", () => {
const local_id_float = 1;
page_params.user_id = 123;
diff --git a/frontend_tests/node_tests/emoji.js b/frontend_tests/node_tests/emoji.js
index 525b2afcb30..908f36a772a 100644
--- a/frontend_tests/node_tests/emoji.js
+++ b/frontend_tests/node_tests/emoji.js
@@ -1,14 +1,14 @@
-set_global('$', global.make_zjquery());
-set_global('page_params', {
- emojiset: 'google',
+set_global("$", global.make_zjquery());
+set_global("page_params", {
+ emojiset: "google",
realm_emoji: {},
});
-set_global('upload_widget', {});
+set_global("upload_widget", {});
-zrequire('emoji');
-zrequire('settings_emoji');
+zrequire("emoji");
+zrequire("settings_emoji");
-run_test('build_emoji_upload_widget', () => {
+run_test("build_emoji_upload_widget", () => {
let build_widget_stub = false;
upload_widget.build_widget = function (
get_file_input,
@@ -17,59 +17,59 @@ run_test('build_emoji_upload_widget', () => {
clear_button,
upload_button,
) {
- assert.deepEqual(get_file_input(), $('#emoji_file_input'));
- assert.deepEqual(file_name_field, $('#emoji-file-name'));
- assert.deepEqual(input_error, $('#emoji_file_input_error'));
- assert.deepEqual(clear_button, $('#emoji_image_clear_button'));
- assert.deepEqual(upload_button, $('#emoji_upload_button'));
+ assert.deepEqual(get_file_input(), $("#emoji_file_input"));
+ assert.deepEqual(file_name_field, $("#emoji-file-name"));
+ assert.deepEqual(input_error, $("#emoji_file_input_error"));
+ assert.deepEqual(clear_button, $("#emoji_image_clear_button"));
+ assert.deepEqual(upload_button, $("#emoji_upload_button"));
build_widget_stub = true;
};
settings_emoji.build_emoji_upload_widget();
assert(build_widget_stub);
});
-run_test('get_canonical_name', () => {
+run_test("get_canonical_name", () => {
emoji.active_realm_emojis = new Map(Object.entries({
- realm_emoji: 'TBD',
+ realm_emoji: "TBD",
}));
- let canonical_name = emoji.get_canonical_name('realm_emoji');
- assert.equal(canonical_name, 'realm_emoji');
+ let canonical_name = emoji.get_canonical_name("realm_emoji");
+ assert.equal(canonical_name, "realm_emoji");
- canonical_name = emoji.get_canonical_name('thumbs_up');
- assert.equal(canonical_name, '+1');
+ canonical_name = emoji.get_canonical_name("thumbs_up");
+ assert.equal(canonical_name, "+1");
- canonical_name = emoji.get_canonical_name('+1');
- assert.equal(canonical_name, '+1');
+ canonical_name = emoji.get_canonical_name("+1");
+ assert.equal(canonical_name, "+1");
- canonical_name = emoji.get_canonical_name('airplane');
- assert.equal(canonical_name, 'airplane');
+ canonical_name = emoji.get_canonical_name("airplane");
+ assert.equal(canonical_name, "airplane");
- blueslip.expect('error', 'Invalid emoji name: non_existent');
- emoji.get_canonical_name('non_existent');
+ blueslip.expect("error", "Invalid emoji name: non_existent");
+ emoji.get_canonical_name("non_existent");
});
function set_up_spain_realm_emoji_for_test() {
const realm_emojis = {
101: {
id: 101,
- name: 'spain',
- source_url: '/some/path/to/spain.png',
+ name: "spain",
+ source_url: "/some/path/to/spain.png",
deactivated: false,
},
};
emoji.update_emojis(realm_emojis);
}
-run_test('get_emoji_* API', () => {
- assert.equal(emoji.get_emoji_name('1f384'), 'holiday_tree');
- assert.equal(emoji.get_emoji_name('1f951'), 'avocado');
- assert.equal(emoji.get_emoji_name('bogus'), undefined);
+run_test("get_emoji_* API", () => {
+ assert.equal(emoji.get_emoji_name("1f384"), "holiday_tree");
+ assert.equal(emoji.get_emoji_name("1f951"), "avocado");
+ assert.equal(emoji.get_emoji_name("bogus"), undefined);
- assert.equal(emoji.get_emoji_codepoint('avocado'), '1f951');
- assert.equal(emoji.get_emoji_codepoint('holiday_tree'), '1f384');
- assert.equal(emoji.get_emoji_codepoint('bogus'), undefined);
+ assert.equal(emoji.get_emoji_codepoint("avocado"), "1f951");
+ assert.equal(emoji.get_emoji_codepoint("holiday_tree"), "1f384");
+ assert.equal(emoji.get_emoji_codepoint("bogus"), undefined);
- assert.equal(emoji.get_realm_emoji_url('spain'), undefined);
+ assert.equal(emoji.get_realm_emoji_url("spain"), undefined);
set_up_spain_realm_emoji_for_test();
- assert.equal(emoji.get_realm_emoji_url('spain'), '/some/path/to/spain.png');
+ assert.equal(emoji.get_realm_emoji_url("spain"), "/some/path/to/spain.png");
});
diff --git a/frontend_tests/node_tests/emoji_picker.js b/frontend_tests/node_tests/emoji_picker.js
index e0b4fcdb2a8..497f028c31b 100644
--- a/frontend_tests/node_tests/emoji_picker.js
+++ b/frontend_tests/node_tests/emoji_picker.js
@@ -1,11 +1,11 @@
-zrequire('emoji');
-zrequire('emoji_picker');
+zrequire("emoji");
+zrequire("emoji_picker");
-run_test('initialize', () => {
+run_test("initialize", () => {
emoji.update_emojis({});
emoji_picker.initialize();
- const complete_emoji_catalog = _.sortBy(emoji_picker.complete_emoji_catalog, 'name');
+ const complete_emoji_catalog = _.sortBy(emoji_picker.complete_emoji_catalog, "name");
assert.equal(complete_emoji_catalog.length, 11);
assert.equal(emoji.emojis_by_name.size, 1037);
@@ -19,7 +19,7 @@ run_test('initialize', () => {
assert.equal(this_emoji.is_realm_emoji, val);
}
}
- if (ele.name === 'Custom') {
+ if (ele.name === "Custom") {
check_emojis(true);
} else {
check_emojis(false);
@@ -28,17 +28,17 @@ run_test('initialize', () => {
}
const popular_emoji_count = 6;
const zulip_emoji_count = 1;
- assert_emoji_category(complete_emoji_catalog.pop(), 'fa-car', 170);
- assert_emoji_category(complete_emoji_catalog.pop(), 'fa-hashtag', 180);
- assert_emoji_category(complete_emoji_catalog.pop(), 'fa-smile-o', 129);
- assert_emoji_category(complete_emoji_catalog.pop(), 'fa-star-o', popular_emoji_count);
- assert_emoji_category(complete_emoji_catalog.pop(), 'fa-thumbs-o-up', 102);
- assert_emoji_category(complete_emoji_catalog.pop(), 'fa-lightbulb-o', 191);
- assert_emoji_category(complete_emoji_catalog.pop(), 'fa-cutlery', 92);
- assert_emoji_category(complete_emoji_catalog.pop(), 'fa-flag', 5);
- assert_emoji_category(complete_emoji_catalog.pop(), 'fa-cog', 1);
- assert_emoji_category(complete_emoji_catalog.pop(), 'fa-leaf', 104);
- assert_emoji_category(complete_emoji_catalog.pop(), 'fa-soccer-ball-o', 63);
+ assert_emoji_category(complete_emoji_catalog.pop(), "fa-car", 170);
+ assert_emoji_category(complete_emoji_catalog.pop(), "fa-hashtag", 180);
+ assert_emoji_category(complete_emoji_catalog.pop(), "fa-smile-o", 129);
+ assert_emoji_category(complete_emoji_catalog.pop(), "fa-star-o", popular_emoji_count);
+ assert_emoji_category(complete_emoji_catalog.pop(), "fa-thumbs-o-up", 102);
+ assert_emoji_category(complete_emoji_catalog.pop(), "fa-lightbulb-o", 191);
+ assert_emoji_category(complete_emoji_catalog.pop(), "fa-cutlery", 92);
+ assert_emoji_category(complete_emoji_catalog.pop(), "fa-flag", 5);
+ assert_emoji_category(complete_emoji_catalog.pop(), "fa-cog", 1);
+ assert_emoji_category(complete_emoji_catalog.pop(), "fa-leaf", 104);
+ 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,
diff --git a/frontend_tests/node_tests/fenced_code.js b/frontend_tests/node_tests/fenced_code.js
index cf63bae510b..8ad856d496f 100644
--- a/frontend_tests/node_tests/fenced_code.js
+++ b/frontend_tests/node_tests/fenced_code.js
@@ -1,20 +1,20 @@
-zrequire('fenced_code');
+zrequire("fenced_code");
-run_test('get_unused_fence', () => {
- assert.equal(fenced_code.get_unused_fence('```js\nsomething\n```'), '`'.repeat(4));
- 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));
- let large_testcase = '';
+run_test("get_unused_fence", () => {
+ assert.equal(fenced_code.get_unused_fence("```js\nsomething\n```"), "`".repeat(4));
+ 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));
+ let large_testcase = "";
// ```
// ````
// `````
// ... up to N chars
// We insert a N + 1 character fence.
for (let i = 3; i <= 20; i += 1) {
- large_testcase += '`'.repeat(i) + '\n';
+ large_testcase += "`".repeat(i) + "\n";
}
- assert.equal(fenced_code.get_unused_fence(large_testcase), '`'.repeat(21));
+ assert.equal(fenced_code.get_unused_fence(large_testcase), "`".repeat(21));
});
diff --git a/frontend_tests/node_tests/fetch_status.js b/frontend_tests/node_tests/fetch_status.js
index 11a1ff01acd..51e1d0c3fad 100644
--- a/frontend_tests/node_tests/fetch_status.js
+++ b/frontend_tests/node_tests/fetch_status.js
@@ -1,5 +1,5 @@
-const FetchStatus = zrequire('fetch_status');
-set_global('message_scroll', {
+const FetchStatus = zrequire("fetch_status");
+set_global("message_scroll", {
hide_loading_older: () => {},
show_loading_older: () => {},
hide_loading_newer: () => {},
@@ -52,7 +52,7 @@ function blocked_history() {
assert.equal(fetch_status.history_limited(), true);
}
-run_test('basics', () => {
+run_test("basics", () => {
reset();
fetch_status.start_newer_batch({ update_loading_indicator: false });
diff --git a/frontend_tests/node_tests/filter.js b/frontend_tests/node_tests/filter.js
index 639cfa3f861..e1182cd78ef 100644
--- a/frontend_tests/node_tests/filter.js
+++ b/frontend_tests/node_tests/filter.js
@@ -1,32 +1,32 @@
-zrequire('unread');
-zrequire('stream_data');
-zrequire('people');
-set_global('Handlebars', global.make_handlebars());
+zrequire("unread");
+zrequire("stream_data");
+zrequire("people");
+set_global("Handlebars", global.make_handlebars());
global.stub_out_jquery();
-set_global('$', global.make_zjquery());
-zrequire('message_util', 'js/message_util');
-zrequire('Filter', 'js/filter');
+set_global("$", global.make_zjquery());
+zrequire("message_util", "js/message_util");
+zrequire("Filter", "js/filter");
-set_global('message_store', {});
-set_global('page_params', {});
+set_global("message_store", {});
+set_global("page_params", {});
const me = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 30,
- full_name: 'Me Myself',
+ full_name: "Me Myself",
};
const joe = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 31,
- full_name: 'joe',
+ full_name: "joe",
};
const steve = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 32,
- full_name: 'steve',
+ full_name: "steve",
};
people.add_active_user(me);
@@ -51,23 +51,23 @@ function assert_same_operators(result, terms) {
assert.deepEqual(result, terms);
}
-run_test('basics', () => {
+run_test("basics", () => {
let operators = [
- {operator: 'stream', operand: 'foo'},
- {operator: 'stream', operand: 'exclude_stream', negated: true},
- {operator: 'topic', operand: 'bar'},
+ {operator: "stream", operand: "foo"},
+ {operator: "stream", operand: "exclude_stream", negated: true},
+ {operator: "topic", operand: "bar"},
];
let filter = new Filter(operators);
assert_same_operators(filter.operators(), operators);
- assert.deepEqual(filter.operands('stream'), ['foo']);
+ assert.deepEqual(filter.operands("stream"), ["foo"]);
- assert(filter.has_operator('stream'));
- assert(!filter.has_operator('search'));
+ assert(filter.has_operator("stream"));
+ assert(!filter.has_operator("search"));
- assert(filter.has_operand('stream', 'foo'));
- assert(!filter.has_operand('stream', 'exclude_stream'));
- assert(!filter.has_operand('stream', 'nada'));
+ assert(filter.has_operand("stream", "foo"));
+ assert(!filter.has_operand("stream", "exclude_stream"));
+ assert(!filter.has_operand("stream", "nada"));
assert(!filter.is_search());
assert(!filter.can_mark_messages_read());
@@ -78,9 +78,9 @@ run_test('basics', () => {
assert(!filter.is_personal_filter());
operators = [
- {operator: 'stream', operand: 'foo'},
- {operator: 'topic', operand: 'bar'},
- {operator: 'search', operand: 'pizza'},
+ {operator: "stream", operand: "foo"},
+ {operator: "topic", operand: "bar"},
+ {operator: "search", operand: "pizza"},
];
filter = new Filter(operators);
@@ -90,18 +90,18 @@ run_test('basics', () => {
assert(!filter.allow_use_first_unread_when_narrowing());
assert(!filter.can_apply_locally());
assert(!filter.is_personal_filter());
- assert(filter.can_bucket_by('stream'));
- assert(filter.can_bucket_by('stream', 'topic'));
+ assert(filter.can_bucket_by("stream"));
+ assert(filter.can_bucket_by("stream", "topic"));
// 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},
+ {operator: "stream", operand: "exclude", negated: true},
];
filter = new Filter(operators);
assert(!filter.contains_only_private_messages());
- assert(!filter.has_operator('stream'));
+ assert(!filter.has_operator("stream"));
assert(!filter.can_mark_messages_read());
assert(!filter.is_personal_filter());
@@ -109,21 +109,21 @@ run_test('basics', () => {
// 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},
+ {operator: "search", operand: "stop_word", negated: true},
];
filter = new Filter(operators);
assert(!filter.contains_only_private_messages());
- assert(filter.has_operator('search'));
+ assert(filter.has_operator("search"));
assert(!filter.can_apply_locally());
assert(!filter.can_mark_messages_read());
assert(!filter.is_personal_filter());
// Similar logic applies to negated "has" searches.
operators = [
- {operator: 'has', operand: 'images', negated: true},
+ {operator: "has", operand: "images", negated: true},
];
filter = new Filter(operators);
- assert(filter.has_operator('has'));
+ assert(filter.has_operator("has"));
assert(filter.can_apply_locally());
assert(!filter.can_apply_locally(true));
assert(!filter.includes_full_stream_history());
@@ -131,113 +131,113 @@ run_test('basics', () => {
assert(!filter.is_personal_filter());
operators = [
- {operator: 'streams', operand: 'public', negated: true},
+ {operator: "streams", operand: "public", negated: true},
];
filter = new Filter(operators);
assert(!filter.contains_only_private_messages());
- assert(!filter.has_operator('streams'));
+ assert(!filter.has_operator("streams"));
assert(!filter.can_mark_messages_read());
- assert(filter.has_negated_operand('streams', 'public'));
+ assert(filter.has_negated_operand("streams", "public"));
assert(!filter.can_apply_locally());
assert(!filter.is_personal_filter());
operators = [
- {operator: 'streams', operand: 'public'},
+ {operator: "streams", operand: "public"},
];
filter = new Filter(operators);
assert(!filter.contains_only_private_messages());
- assert(filter.has_operator('streams'));
+ assert(filter.has_operator("streams"));
assert(!filter.can_mark_messages_read());
- assert(!filter.has_negated_operand('streams', 'public'));
+ assert(!filter.has_negated_operand("streams", "public"));
assert(!filter.can_apply_locally());
assert(filter.includes_full_stream_history());
assert(!filter.is_personal_filter());
operators = [
- {operator: 'is', operand: 'private'},
+ {operator: "is", operand: "private"},
];
filter = new Filter(operators);
assert(filter.contains_only_private_messages());
assert(filter.can_mark_messages_read());
- assert(!filter.has_operator('search'));
+ assert(!filter.has_operator("search"));
assert(filter.can_apply_locally());
assert(!filter.is_personal_filter());
operators = [
- {operator: 'is', operand: 'mentioned'},
+ {operator: "is", operand: "mentioned"},
];
filter = new Filter(operators);
assert(!filter.contains_only_private_messages());
assert(filter.can_mark_messages_read());
- assert(!filter.has_operator('search'));
+ assert(!filter.has_operator("search"));
assert(filter.can_apply_locally());
assert(filter.is_personal_filter());
operators = [
- {operator: 'is', operand: 'starred'},
+ {operator: "is", operand: "starred"},
];
filter = new Filter(operators);
assert(!filter.contains_only_private_messages());
assert(!filter.can_mark_messages_read());
- assert(!filter.has_operator('search'));
+ assert(!filter.has_operator("search"));
assert(filter.can_apply_locally());
assert(filter.is_personal_filter());
operators = [
- {operator: 'pm-with', operand: '[email protected]'},
+ {operator: "pm-with", operand: "[email protected]"},
];
filter = new Filter(operators);
assert(filter.contains_only_private_messages());
- assert(!filter.has_operator('search'));
+ assert(!filter.has_operator("search"));
assert(filter.can_apply_locally());
assert(!filter.is_personal_filter());
operators = [
- {operator: 'group-pm-with', operand: '[email protected]'},
+ {operator: "group-pm-with", operand: "[email protected]"},
];
filter = new Filter(operators);
assert(filter.contains_only_private_messages());
- assert(!filter.has_operator('search'));
+ assert(!filter.has_operator("search"));
assert(filter.can_apply_locally());
});
function assert_not_mark_read_with_has_operands(additional_operators_to_test) {
additional_operators_to_test = additional_operators_to_test || [];
- let has_operator = [{ operator: 'has', operand: 'link' }];
+ let has_operator = [{ operator: "has", operand: "link" }];
let filter = new Filter(additional_operators_to_test.concat(has_operator));
assert(!filter.can_mark_messages_read());
- has_operator = [{ operator: 'has', operand: 'link', negated: true }];
+ has_operator = [{ operator: "has", operand: "link", negated: true }];
filter = new Filter(additional_operators_to_test.concat(has_operator));
assert(!filter.can_mark_messages_read());
- has_operator = [{ operator: 'has', operand: 'image' }];
+ has_operator = [{ operator: "has", operand: "image" }];
filter = new Filter(additional_operators_to_test.concat(has_operator));
assert(!filter.can_mark_messages_read());
- has_operator = [{ operator: 'has', operand: 'image', negated: true }];
+ has_operator = [{ operator: "has", operand: "image", negated: true }];
filter = new Filter(additional_operators_to_test.concat(has_operator));
assert(!filter.can_mark_messages_read());
- has_operator = [{ operator: 'has', operand: 'attachment', negated: true }];
+ has_operator = [{ operator: "has", operand: "attachment", negated: true }];
filter = new Filter(additional_operators_to_test.concat(has_operator));
assert(!filter.can_mark_messages_read());
- has_operator = [{ operator: 'has', operand: 'attachment' }];
+ has_operator = [{ operator: "has", operand: "attachment" }];
filter = new Filter(additional_operators_to_test.concat(has_operator));
assert(!filter.can_mark_messages_read());
}
function assert_not_mark_read_with_is_operands(additional_operators_to_test) {
additional_operators_to_test = additional_operators_to_test || [];
- let is_operator = [{ operator: 'is', operand: 'starred' }];
+ let is_operator = [{ operator: "is", operand: "starred" }];
let filter = new Filter(additional_operators_to_test.concat(is_operator));
assert(!filter.can_mark_messages_read());
- is_operator = [{ operator: 'is', operand: 'starred', negated: true }];
+ is_operator = [{ operator: "is", operand: "starred", negated: true }];
filter = new Filter(additional_operators_to_test.concat(is_operator));
assert(!filter.can_mark_messages_read());
- is_operator = [{ operator: 'is', operand: 'mentioned' }];
+ is_operator = [{ operator: "is", operand: "mentioned" }];
filter = new Filter(additional_operators_to_test.concat(is_operator));
if (additional_operators_to_test.length === 0) {
assert(filter.can_mark_messages_read());
@@ -245,45 +245,45 @@ function assert_not_mark_read_with_is_operands(additional_operators_to_test) {
assert(!filter.can_mark_messages_read());
}
- is_operator = [{ operator: 'is', operand: 'mentioned', negated: true }];
+ is_operator = [{ operator: "is", operand: "mentioned", negated: true }];
filter = new Filter(additional_operators_to_test.concat(is_operator));
assert(!filter.can_mark_messages_read());
- is_operator = [{ operator: 'is', operand: 'alerted' }];
+ is_operator = [{ operator: "is", operand: "alerted" }];
filter = new Filter(additional_operators_to_test.concat(is_operator));
assert(!filter.can_mark_messages_read());
- is_operator = [{ operator: 'is', operand: 'alerted', negated: true }];
+ is_operator = [{ operator: "is", operand: "alerted", negated: true }];
filter = new Filter(additional_operators_to_test.concat(is_operator));
assert(!filter.can_mark_messages_read());
- is_operator = [{ operator: 'is', operand: 'unread' }];
+ is_operator = [{ operator: "is", operand: "unread" }];
filter = new Filter(additional_operators_to_test.concat(is_operator));
assert(!filter.can_mark_messages_read());
- is_operator = [{ operator: 'is', operand: 'unread', negated: true }];
+ is_operator = [{ operator: "is", operand: "unread", negated: true }];
filter = new Filter(additional_operators_to_test.concat(is_operator));
assert(!filter.can_mark_messages_read());
}
function assert_not_mark_read_when_searching(additional_operators_to_test) {
additional_operators_to_test = additional_operators_to_test || [];
- let search_op = [{ operator: 'search', operand: 'keyword' }];
+ let search_op = [{ operator: "search", operand: "keyword" }];
let filter = new Filter(additional_operators_to_test.concat(search_op));
assert(!filter.can_mark_messages_read());
- search_op = [{ operator: 'search', operand: 'keyword', negated: true }];
+ search_op = [{ operator: "search", operand: "keyword", negated: true }];
filter = new Filter(additional_operators_to_test.concat(search_op));
assert(!filter.can_mark_messages_read());
}
-run_test('can_mark_messages_read', () => {
+run_test("can_mark_messages_read", () => {
assert_not_mark_read_with_has_operands();
assert_not_mark_read_with_is_operands();
assert_not_mark_read_when_searching();
const stream_operator = [
- { operator: 'stream', operand: 'foo' },
+ { operator: "stream", operand: "foo" },
];
let filter = new Filter(stream_operator);
assert(filter.can_mark_messages_read());
@@ -292,14 +292,14 @@ run_test('can_mark_messages_read', () => {
assert_not_mark_read_when_searching(stream_operator);
const stream_negated_operator = [
- { operator: 'stream', operand: 'foo', negated: true },
+ { operator: "stream", operand: "foo", negated: true },
];
filter = new Filter(stream_negated_operator);
assert(!filter.can_mark_messages_read());
const stream_topic_operators = [
- { operator: 'stream', operand: 'foo' },
- { operator: 'topic', operand: 'bar' },
+ { operator: "stream", operand: "foo" },
+ { operator: "topic", operand: "bar" },
];
filter = new Filter(stream_topic_operators);
assert(filter.can_mark_messages_read());
@@ -308,22 +308,22 @@ run_test('can_mark_messages_read', () => {
assert_not_mark_read_when_searching(stream_topic_operators);
const stream_negated_topic_operators = [
- { operator: 'stream', operand: 'foo' },
- { operator: 'topic', operand: 'bar', negated: true},
+ { operator: "stream", operand: "foo" },
+ { operator: "topic", operand: "bar", negated: true},
];
filter = new Filter(stream_negated_topic_operators);
assert(!filter.can_mark_messages_read());
const pm_with = [
- { operator: 'pm-with', operand: '[email protected],' },
+ { operator: "pm-with", operand: "[email protected]," },
];
const pm_with_negated = [
- { operator: 'pm-with', operand: '[email protected],', negated: true},
+ { operator: "pm-with", operand: "[email protected],", negated: true},
];
const group_pm = [
- { operator: 'pm-with', operand: '[email protected],[email protected]' },
+ { operator: "pm-with", operand: "[email protected],[email protected]" },
];
filter = new Filter(pm_with);
assert(filter.can_mark_messages_read());
@@ -339,7 +339,7 @@ run_test('can_mark_messages_read', () => {
assert_not_mark_read_when_searching(pm_with);
const is_private = [
- { operator: 'is', operand: 'private' },
+ { operator: "is", operand: "private" },
];
filter = new Filter(is_private);
assert(filter.can_mark_messages_read());
@@ -348,7 +348,7 @@ run_test('can_mark_messages_read', () => {
assert_not_mark_read_when_searching(is_private);
const in_all = [
- { operator: 'in', operand: 'all' },
+ { operator: "in", operand: "all" },
];
filter = new Filter(in_all);
assert(filter.can_mark_messages_read());
@@ -357,10 +357,10 @@ run_test('can_mark_messages_read', () => {
assert_not_mark_read_when_searching(in_all);
const in_home = [
- { operator: 'in', operand: 'home' },
+ { operator: "in", operand: "home" },
];
const in_home_negated = [
- { operator: 'in', operand: 'home', negated: true },
+ { operator: "in", operand: "home", negated: true },
];
filter = new Filter(in_home);
assert(filter.can_mark_messages_read());
@@ -372,10 +372,10 @@ run_test('can_mark_messages_read', () => {
// Do not mark messages as read when in an unsupported 'in:*' filter.
const in_random = [
- { operator: 'in', operand: 'xxxxxxxxx' },
+ { operator: "in", operand: "xxxxxxxxx" },
];
const in_random_negated = [
- { operator: 'in', operand: 'xxxxxxxxx', negated: true },
+ { operator: "in", operand: "xxxxxxxxx", negated: true },
];
filter = new Filter(in_random);
assert(!filter.can_mark_messages_read());
@@ -402,15 +402,15 @@ run_test('can_mark_messages_read', () => {
assert(!filter.calc_can_mark_messages_read_called);
});
-run_test('show_first_unread', () => {
+run_test("show_first_unread", () => {
let operators = [
- {operator: 'is', operand: 'any'},
+ {operator: "is", operand: "any"},
];
let filter = new Filter(operators);
assert(filter.allow_use_first_unread_when_narrowing());
operators = [
- {operator: 'search', operand: 'query to search'},
+ {operator: "search", operand: "query to search"},
];
filter = new Filter(operators);
assert(!filter.allow_use_first_unread_when_narrowing());
@@ -421,152 +421,152 @@ run_test('show_first_unread', () => {
// Side case
operators = [
- {operator: 'is', operand: 'any'},
+ {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', () => {
+run_test("filter_with_new_params_topic", () => {
const operators = [
- {operator: 'stream', operand: 'foo'},
- {operator: 'topic', operand: 'old topic'},
+ {operator: "stream", operand: "foo"},
+ {operator: "topic", operand: "old topic"},
];
const filter = new Filter(operators);
- assert(filter.has_topic('foo', 'old topic'));
- assert(!filter.has_topic('wrong', 'old topic'));
- assert(!filter.has_topic('foo', 'wrong'));
+ assert(filter.has_topic("foo", "old topic"));
+ assert(!filter.has_topic("wrong", "old topic"));
+ assert(!filter.has_topic("foo", "wrong"));
const new_filter = filter.filter_with_new_params({
- operator: 'topic',
- operand: 'new topic',
+ operator: "topic",
+ operand: "new topic",
});
- assert.deepEqual(new_filter.operands('stream'), ['foo']);
- assert.deepEqual(new_filter.operands('topic'), ['new topic']);
+ assert.deepEqual(new_filter.operands("stream"), ["foo"]);
+ assert.deepEqual(new_filter.operands("topic"), ["new topic"]);
});
-run_test('filter_with_new_params_stream', () => {
+run_test("filter_with_new_params_stream", () => {
const operators = [
- {operator: 'stream', operand: 'foo'},
- {operator: 'topic', operand: 'old topic'},
+ {operator: "stream", operand: "foo"},
+ {operator: "topic", operand: "old topic"},
];
const filter = new Filter(operators);
- assert(filter.has_topic('foo', 'old topic'));
- assert(!filter.has_topic('wrong', 'old topic'));
- assert(!filter.has_topic('foo', 'wrong'));
+ assert(filter.has_topic("foo", "old topic"));
+ assert(!filter.has_topic("wrong", "old topic"));
+ assert(!filter.has_topic("foo", "wrong"));
const new_filter = filter.filter_with_new_params({
- operator: 'stream',
- operand: 'new stream',
+ operator: "stream",
+ operand: "new stream",
});
- assert.deepEqual(new_filter.operands('stream'), ['new stream']);
- assert.deepEqual(new_filter.operands('topic'), ['old topic']);
+ assert.deepEqual(new_filter.operands("stream"), ["new stream"]);
+ assert.deepEqual(new_filter.operands("topic"), ["old topic"]);
});
-run_test('new_style_operators', () => {
+run_test("new_style_operators", () => {
const term = {
- operator: 'stream',
- operand: 'foo',
+ operator: "stream",
+ operand: "foo",
};
const operators = [term];
const filter = new Filter(operators);
- assert.deepEqual(filter.operands('stream'), ['foo']);
- assert(filter.can_bucket_by('stream'));
+ assert.deepEqual(filter.operands("stream"), ["foo"]);
+ assert(filter.can_bucket_by("stream"));
});
-run_test('public_operators', () => {
+run_test("public_operators", () => {
let operators = [
- {operator: 'stream', operand: 'foo'},
- {operator: 'in', operand: 'all'},
- {operator: 'topic', operand: 'bar'},
+ {operator: "stream", operand: "foo"},
+ {operator: "in", operand: "all"},
+ {operator: "topic", operand: "bar"},
];
let filter = new Filter(operators);
assert_same_operators(filter.public_operators(), operators);
- assert(filter.can_bucket_by('stream'));
+ assert(filter.can_bucket_by("stream"));
- global.page_params.narrow_stream = 'default';
+ global.page_params.narrow_stream = "default";
operators = [
- {operator: 'stream', operand: 'default'},
+ {operator: "stream", operand: "default"},
];
filter = new Filter(operators);
assert_same_operators(filter.public_operators(), []);
});
-run_test('redundancies', () => {
+run_test("redundancies", () => {
let terms;
let filter;
terms = [
- { operator: 'pm-with', operand: '[email protected],' },
- { operator: 'is', operand: 'private' },
+ { operator: "pm-with", operand: "[email protected]," },
+ { operator: "is", operand: "private" },
];
filter = new Filter(terms);
- assert(filter.can_bucket_by('pm-with'));
+ assert(filter.can_bucket_by("pm-with"));
terms = [
- { operator: 'pm-with',
- operand: '[email protected],',
+ { operator: "pm-with",
+ operand: "[email protected],",
negated: true,
},
- { operator: 'is', operand: 'private' },
+ { operator: "is", operand: "private" },
];
filter = new Filter(terms);
- assert(filter.can_bucket_by('is-private', 'not-pm-with'));
+ assert(filter.can_bucket_by("is-private", "not-pm-with"));
});
-run_test('canonicalizations', () => {
- assert.equal(Filter.canonicalize_operator('Is'), 'is');
- assert.equal(Filter.canonicalize_operator('Stream'), 'stream');
- assert.equal(Filter.canonicalize_operator('Subject'), 'topic');
- assert.equal(Filter.canonicalize_operator('FROM'), 'sender');
+run_test("canonicalizations", () => {
+ assert.equal(Filter.canonicalize_operator("Is"), "is");
+ assert.equal(Filter.canonicalize_operator("Stream"), "stream");
+ assert.equal(Filter.canonicalize_operator("Subject"), "topic");
+ assert.equal(Filter.canonicalize_operator("FROM"), "sender");
let term;
- term = Filter.canonicalize_term({operator: 'Stream', operand: 'Denmark'});
- assert.equal(term.operator, 'stream');
- assert.equal(term.operand, 'Denmark');
+ term = Filter.canonicalize_term({operator: "Stream", operand: "Denmark"});
+ assert.equal(term.operator, "stream");
+ assert.equal(term.operand, "Denmark");
- term = Filter.canonicalize_term({operator: 'sender', operand: 'me'});
- assert.equal(term.operator, 'sender');
- assert.equal(term.operand, '[email protected]');
+ term = Filter.canonicalize_term({operator: "sender", operand: "me"});
+ assert.equal(term.operator, "sender");
+ assert.equal(term.operand, "[email protected]");
- term = Filter.canonicalize_term({operator: 'pm-with', operand: 'me'});
- assert.equal(term.operator, 'pm-with');
- assert.equal(term.operand, '[email protected]');
+ term = Filter.canonicalize_term({operator: "pm-with", operand: "me"});
+ assert.equal(term.operator, "pm-with");
+ assert.equal(term.operand, "[email protected]");
- term = Filter.canonicalize_term({operator: 'search', operand: 'foo'});
- assert.equal(term.operator, 'search');
- assert.equal(term.operand, 'foo');
+ term = Filter.canonicalize_term({operator: "search", operand: "foo"});
+ assert.equal(term.operator, "search");
+ assert.equal(term.operand, "foo");
- term = Filter.canonicalize_term({operator: 'search', operand: 'fOO'});
- assert.equal(term.operator, 'search');
- assert.equal(term.operand, 'foo');
+ term = Filter.canonicalize_term({operator: "search", operand: "fOO"});
+ assert.equal(term.operator, "search");
+ assert.equal(term.operand, "foo");
- term = Filter.canonicalize_term({operator: 'search', operand: 123});
- assert.equal(term.operator, 'search');
- assert.equal(term.operand, '123');
+ term = Filter.canonicalize_term({operator: "search", operand: 123});
+ assert.equal(term.operator, "search");
+ assert.equal(term.operand, "123");
- term = Filter.canonicalize_term({operator: 'search', operand: 'abc “xyz”'});
- assert.equal(term.operator, 'search');
+ term = Filter.canonicalize_term({operator: "search", operand: "abc “xyz”"});
+ assert.equal(term.operator, "search");
assert.equal(term.operand, 'abc "xyz"');
- term = Filter.canonicalize_term({operator: 'has', operand: 'attachments'});
- assert.equal(term.operator, 'has');
- assert.equal(term.operand, 'attachment');
+ term = Filter.canonicalize_term({operator: "has", operand: "attachments"});
+ assert.equal(term.operator, "has");
+ assert.equal(term.operand, "attachment");
- term = Filter.canonicalize_term({operator: 'has', operand: 'images'});
- assert.equal(term.operator, 'has');
- assert.equal(term.operand, 'image');
+ term = Filter.canonicalize_term({operator: "has", operand: "images"});
+ assert.equal(term.operator, "has");
+ assert.equal(term.operand, "image");
- term = Filter.canonicalize_term({operator: 'has', operand: 'links'});
- assert.equal(term.operator, 'has');
- assert.equal(term.operand, 'link');
+ term = Filter.canonicalize_term({operator: "has", operand: "links"});
+ assert.equal(term.operator, "has");
+ assert.equal(term.operand, "link");
});
@@ -586,7 +586,7 @@ function make_sub(name, stream_id) {
global.stream_data.add_sub(sub);
}
-run_test('predicate_basics', () => {
+run_test("predicate_basics", () => {
// Predicates are functions that accept a message object with the message
// attributes (not content), and return true if the message belongs in a
// given narrow. If the narrow parameters include a search, the predicate
@@ -596,147 +596,147 @@ run_test('predicate_basics', () => {
// rather than full-fledged message objects.
const stream_id = 42;
- make_sub('Foo', stream_id);
- let predicate = get_predicate([['stream', 'Foo'], ['topic', 'Bar']]);
+ make_sub("Foo", stream_id);
+ 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'}));
- assert(!predicate({type: 'stream', stream_id: 9999999}));
- assert(!predicate({type: 'private'}));
+ assert(predicate({type: "stream", stream_id: stream_id, topic: "bar"}));
+ assert(!predicate({type: "stream", stream_id: stream_id, topic: "whatever"}));
+ assert(!predicate({type: "stream", stream_id: 9999999}));
+ assert(!predicate({type: "private"}));
// 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']]);
- assert(predicate({type: 'stream', stream: 'Old-stream', topic: 'bar'}));
- assert(!predicate({type: 'stream', stream: 'no-match', topic: 'whatever'}));
+ 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"}));
- predicate = get_predicate([['search', 'emoji']]);
+ predicate = get_predicate([["search", "emoji"]]);
assert(predicate({}));
- predicate = get_predicate([['topic', 'Bar']]);
- assert(!predicate({type: 'private'}));
+ predicate = get_predicate([["topic", "Bar"]]);
+ assert(!predicate({type: "private"}));
- predicate = get_predicate([['is', 'private']]);
- assert(predicate({type: 'private'}));
- assert(!predicate({type: 'stream'}));
+ predicate = get_predicate([["is", "private"]]);
+ assert(predicate({type: "private"}));
+ assert(!predicate({type: "stream"}));
- predicate = get_predicate([['streams', 'public']]);
+ predicate = get_predicate([["streams", "public"]]);
assert(predicate({}));
- predicate = get_predicate([['is', 'starred']]);
+ predicate = get_predicate([["is", "starred"]]);
assert(predicate({starred: true}));
assert(!predicate({starred: false}));
- predicate = get_predicate([['is', 'unread']]);
+ predicate = get_predicate([["is", "unread"]]);
assert(predicate({unread: true}));
assert(!predicate({unread: false}));
- predicate = get_predicate([['is', 'alerted']]);
+ predicate = get_predicate([["is", "alerted"]]);
assert(predicate({alerted: true}));
assert(!predicate({alerted: false}));
assert(!predicate({}));
- predicate = get_predicate([['is', 'mentioned']]);
+ predicate = get_predicate([["is", "mentioned"]]);
assert(predicate({mentioned: true}));
assert(!predicate({mentioned: false}));
- predicate = get_predicate([['in', 'all']]);
+ predicate = get_predicate([["in", "all"]]);
assert(predicate({}));
const unknown_stream_id = 999;
- predicate = get_predicate([['in', 'home']]);
- assert(!predicate({stream_id: unknown_stream_id, stream: 'unknown'}));
- assert(predicate({type: 'private'}));
- global.page_params.narrow_stream = 'kiosk';
- assert(predicate({stream: 'kiosk'}));
+ predicate = get_predicate([["in", "home"]]);
+ assert(!predicate({stream_id: unknown_stream_id, stream: "unknown"}));
+ assert(predicate({type: "private"}));
+ global.page_params.narrow_stream = "kiosk";
+ assert(predicate({stream: "kiosk"}));
- predicate = get_predicate([['near', 5]]);
+ predicate = get_predicate([["near", 5]]);
assert(predicate({}));
- predicate = get_predicate([['id', 5]]);
+ predicate = get_predicate([["id", 5]]);
assert(predicate({id: 5}));
assert(!predicate({id: 6}));
- predicate = get_predicate([['id', 5], ['topic', 'lunch']]);
- assert(predicate({type: 'stream', id: 5, topic: 'lunch'}));
- assert(!predicate({type: 'stream', id: 5, topic: 'dinner'}));
+ predicate = get_predicate([["id", 5], ["topic", "lunch"]]);
+ assert(predicate({type: "stream", id: 5, topic: "lunch"}));
+ assert(!predicate({type: "stream", id: 5, topic: "dinner"}));
- predicate = get_predicate([['sender', '[email protected]']]);
+ predicate = get_predicate([["sender", "[email protected]"]]);
assert(predicate({sender_id: joe.user_id}));
assert(!predicate({sender_email: steve.user_id}));
- predicate = get_predicate([['pm-with', '[email protected]']]);
+ predicate = get_predicate([["pm-with", "[email protected]"]]);
assert(predicate({
- type: 'private',
+ type: "private",
display_recipient: [{id: joe.user_id}],
}));
assert(!predicate({
- type: 'private',
+ type: "private",
display_recipient: [{id: steve.user_id}],
}));
assert(!predicate({
- type: 'private',
+ type: "private",
display_recipient: [{id: 999999}],
}));
- assert(!predicate({type: 'stream'}));
+ assert(!predicate({type: "stream"}));
- predicate = get_predicate([['pm-with', '[email protected],[email protected]']]);
+ predicate = get_predicate([["pm-with", "[email protected],[email protected]"]]);
assert(predicate({
- type: 'private',
+ 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]']]);
+ predicate = get_predicate([["pm-with", "[email protected],[email protected],[email protected]"]]);
assert(predicate({
- type: 'private',
+ type: "private",
display_recipient: [{id: joe.user_id}, {id: steve.user_id}],
}));
- predicate = get_predicate([['pm-with', '[email protected]']]);
+ predicate = get_predicate([["pm-with", "[email protected]"]]);
assert(!predicate({
- type: 'private',
+ type: "private",
display_recipient: [{id: joe.user_id}],
}));
- predicate = get_predicate([['group-pm-with', '[email protected]']]);
+ predicate = get_predicate([["group-pm-with", "[email protected]"]]);
assert(!predicate({
- type: 'private',
+ type: "private",
display_recipient: [{id: joe.user_id}],
}));
- predicate = get_predicate([['group-pm-with', '[email protected]']]);
+ predicate = get_predicate([["group-pm-with", "[email protected]"]]);
assert(predicate({
- type: 'private',
+ 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',
+ type: "private",
display_recipient: [{id: joe.user_id}, {id: steve.user_id}],
}));
assert(!predicate({
- type: 'private',
+ type: "private",
display_recipient: [{id: steve.user_id}, {id: me.user_id}],
}));
- assert(!predicate({type: 'stream'}));
+ 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 = {
content: "<p>Testing</p>",
};
- predicate = get_predicate([['has', 'non_valid_operand']]);
+ predicate = get_predicate([["has", "non_valid_operand"]]);
assert(!predicate(img_msg));
assert(!predicate(non_img_attachment_msg));
assert(!predicate(link_msg));
@@ -745,7 +745,7 @@ run_test('predicate_basics', () => {
// HTML content of message is used to determine if image have link, image or attachment.
// We are using jquery to parse the html and find existence of relevant tags/elements.
// In tests we need to stub the calls to jquery so using zjquery's .set_find_results method.
- const has_link = get_predicate([['has', 'link']]);
+ const has_link = get_predicate([["has", "link"]]);
$(img_msg.content).set_find_results("a", [$("<a>")]);
assert(has_link(img_msg));
$(non_img_attachment_msg.content).set_find_results("a", [$("<a>")]);
@@ -755,7 +755,7 @@ run_test('predicate_basics', () => {
$(no_has_filter_matching_msg.content).set_find_results("a", false);
assert(!has_link(no_has_filter_matching_msg));
- const has_attachment = get_predicate([['has', 'attachment']]);
+ const has_attachment = get_predicate([["has", "attachment"]]);
$(img_msg.content).set_find_results("a[href^='/user_uploads']", [$("<a>")]);
assert(has_attachment(img_msg));
$(non_img_attachment_msg.content).set_find_results("a[href^='/user_uploads']", [$("<a>")]);
@@ -765,7 +765,7 @@ run_test('predicate_basics', () => {
$(no_has_filter_matching_msg.content).set_find_results("a[href^='/user_uploads']", false);
assert(!has_attachment(no_has_filter_matching_msg));
- const has_image = get_predicate([['has', 'image']]);
+ const has_image = get_predicate([["has", "image"]]);
$(img_msg.content).set_find_results(".message_inline_image", [$("<img>")]);
assert(has_image(img_msg));
$(non_img_attachment_msg.content).set_find_results(".message_inline_image", false);
@@ -777,60 +777,60 @@ run_test('predicate_basics', () => {
});
-run_test('negated_predicates', () => {
+run_test("negated_predicates", () => {
let predicate;
let narrow;
const social_stream_id = 555;
- make_sub('social', social_stream_id);
+ make_sub("social", social_stream_id);
narrow = [
- {operator: 'stream', operand: 'social', negated: true},
+ {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}));
+ assert(predicate({type: "stream", stream_id: 999999}));
+ assert(!predicate({type: "stream", stream_id: social_stream_id}));
narrow = [
- {operator: 'streams', operand: 'public', negated: true},
+ {operator: "streams", operand: "public", negated: true},
];
predicate = new Filter(narrow).predicate();
assert(predicate({}));
});
-run_test('mit_exceptions', () => {
+run_test("mit_exceptions", () => {
global.page_params.realm_is_zephyr_mirror_realm = true;
- 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: ''}));
- assert(!predicate({type: 'stream', stream: 'wrong'}));
- assert(!predicate({type: 'stream', stream: 'foo', topic: 'whatever'}));
- assert(!predicate({type: 'private'}));
+ 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: ""}));
+ assert(!predicate({type: "stream", stream: "wrong"}));
+ assert(!predicate({type: "stream", stream: "foo", topic: "whatever"}));
+ assert(!predicate({type: "private"}));
- predicate = get_predicate([['stream', 'Foo'], ['topic', 'bar']]);
- assert(predicate({type: 'stream', stream: 'foo', topic: 'bar.d'}));
+ 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.
let terms = [
- {operator: 'stream', operand: ''},
- {operator: 'topic', operand: 'bar'},
+ {operator: "stream", operand: ""},
+ {operator: "topic", operand: "bar"},
];
predicate = new Filter(terms).predicate();
- assert(!predicate({type: 'stream', stream: 'foo', topic: 'bar'}));
+ assert(!predicate({type: "stream", stream: "foo", topic: "bar"}));
// Try to get the MIT regex to explode for an empty topic.
terms = [
- {operator: 'stream', operand: 'foo'},
- {operator: 'topic', operand: ''},
+ {operator: "stream", operand: "foo"},
+ {operator: "topic", operand: ""},
];
predicate = new Filter(terms).predicate();
- assert(!predicate({type: 'stream', stream: 'foo', topic: 'bar'}));
+ assert(!predicate({type: "stream", stream: "foo", topic: "bar"}));
});
-run_test('predicate_edge_cases', () => {
+run_test("predicate_edge_cases", () => {
let predicate;
// The code supports undefined as an operator to Filter, which results
// in a predicate that accepts any message.
@@ -840,28 +840,28 @@ run_test('predicate_edge_cases', () => {
// Upstream code should prevent Filter.predicate from being called with
// invalid operator/operand combinations, but right now we just silently
// return a function that accepts all messages.
- predicate = get_predicate([['in', 'bogus']]);
+ predicate = get_predicate([["in", "bogus"]]);
assert(predicate({}));
- predicate = get_predicate([['bogus', 33]]);
+ predicate = get_predicate([["bogus", 33]]);
assert(predicate({}));
- predicate = get_predicate([['is', 'bogus']]);
+ predicate = get_predicate([["is", "bogus"]]);
assert(predicate({}));
// Exercise caching feature.
const terms = [
- {operator: 'stream', operand: 'Foo'},
- {operator: 'topic', operand: 'bar'},
+ {operator: "stream", operand: "Foo"},
+ {operator: "topic", operand: "bar"},
];
const filter = new Filter(terms);
filter.predicate();
predicate = filter.predicate(); // get cached version
- assert(predicate({type: 'stream', stream: 'foo', topic: 'bar'}));
+ assert(predicate({type: "stream", stream: "foo", topic: "bar"}));
});
-run_test('parse', () => {
+run_test("parse", () => {
let string;
let operators;
@@ -870,385 +870,385 @@ run_test('parse', () => {
assert_same_operators(result, operators);
}
- string = 'stream:Foo topic:Bar yo';
+ string = "stream:Foo topic:Bar yo";
operators = [
- {operator: 'stream', operand: 'Foo'},
- {operator: 'topic', operand: 'Bar'},
- {operator: 'search', operand: 'yo'},
+ {operator: "stream", operand: "Foo"},
+ {operator: "topic", operand: "Bar"},
+ {operator: "search", operand: "yo"},
];
_test();
- string = 'pm-with:[email protected]';
+ string = "pm-with:[email protected]";
operators = [
- {operator: 'pm-with', operand: '[email protected]'},
+ {operator: "pm-with", operand: "[email protected]"},
];
_test();
- string = 'sender:[email protected]';
+ string = "sender:[email protected]";
operators = [
- {operator: 'sender', operand: '[email protected]'},
+ {operator: "sender", operand: "[email protected]"},
];
_test();
- string = 'stream:With+Space';
+ string = "stream:With+Space";
operators = [
- {operator: 'stream', operand: 'With Space'},
+ {operator: "stream", operand: "With Space"},
];
_test();
string = 'stream:"with quoted space" topic:and separate';
operators = [
- {operator: 'stream', operand: 'with quoted space'},
- {operator: 'topic', operand: 'and'},
- {operator: 'search', operand: 'separate'},
+ {operator: "stream", operand: "with quoted space"},
+ {operator: "topic", operand: "and"},
+ {operator: "search", operand: "separate"},
];
_test();
string = 'stream:"unclosed quote';
operators = [
- {operator: 'stream', operand: 'unclosed quote'},
+ {operator: "stream", operand: "unclosed quote"},
];
_test();
string = 'stream:""';
operators = [
- {operator: 'stream', operand: ''},
+ {operator: "stream", operand: ""},
];
_test();
- string = 'https://www.google.com';
+ string = "https://www.google.com";
operators = [
- {operator: 'search', operand: 'https://www.google.com'},
+ {operator: "search", operand: "https://www.google.com"},
];
_test();
- string = 'stream:foo -stream:exclude';
+ string = "stream:foo -stream:exclude";
operators = [
- {operator: 'stream', operand: 'foo'},
- {operator: 'stream', operand: 'exclude', negated: true},
+ {operator: "stream", operand: "foo"},
+ {operator: "stream", operand: "exclude", negated: true},
];
_test();
- string = 'text stream:foo more text';
+ string = "text stream:foo more text";
operators = [
- {operator: 'stream', operand: 'foo'},
- {operator: 'search', operand: 'text more text'},
+ {operator: "stream", operand: "foo"},
+ {operator: "search", operand: "text more text"},
];
_test();
- string = 'text streams:public more text';
+ string = "text streams:public more text";
operators = [
- {operator: 'streams', operand: 'public'},
- {operator: 'search', operand: 'text more text'},
+ {operator: "streams", operand: "public"},
+ {operator: "search", operand: "text more text"},
];
_test();
- string = 'streams:public';
+ string = "streams:public";
operators = [
- {operator: 'streams', operand: 'public'},
+ {operator: "streams", operand: "public"},
];
_test();
- string = '-streams:public';
+ string = "-streams:public";
operators = [
- {operator: 'streams', operand: 'public', negated: true},
+ {operator: "streams", operand: "public", negated: true},
];
_test();
- string = 'stream:foo :emoji: are cool';
+ string = "stream:foo :emoji: are cool";
operators = [
- {operator: 'stream', operand: 'foo'},
- {operator: 'search', operand: ':emoji: are cool'},
+ {operator: "stream", operand: "foo"},
+ {operator: "search", operand: ":emoji: are cool"},
];
_test();
- string = ':stream: stream:foo :emoji: are cool';
+ string = ":stream: stream:foo :emoji: are cool";
operators = [
- {operator: 'stream', operand: 'foo'},
- {operator: 'search', operand: ':stream: :emoji: are cool'},
+ {operator: "stream", operand: "foo"},
+ {operator: "search", operand: ":stream: :emoji: are cool"},
];
_test();
- string = ':stream: stream:foo -:emoji: are cool';
+ string = ":stream: stream:foo -:emoji: are cool";
operators = [
- {operator: 'stream', operand: 'foo'},
- {operator: 'search', operand: ':stream: -:emoji: are cool'},
+ {operator: "stream", operand: "foo"},
+ {operator: "search", operand: ":stream: -:emoji: are cool"},
];
_test();
- string = '';
+ string = "";
operators = [];
_test();
string = 'stream: separated topic: "with space"';
operators = [
- {operator: 'stream', operand: 'separated'},
- {operator: 'topic', operand: 'with space'},
+ {operator: "stream", operand: "separated"},
+ {operator: "topic", operand: "with space"},
];
_test();
});
-run_test('unparse', () => {
+run_test("unparse", () => {
let string;
let operators;
operators = [
- {operator: 'stream', operand: 'Foo'},
- {operator: 'topic', operand: 'Bar', negated: true},
- {operator: 'search', operand: 'yo'},
+ {operator: "stream", operand: "Foo"},
+ {operator: "topic", operand: "Bar", negated: true},
+ {operator: "search", operand: "yo"},
];
- string = 'stream:Foo -topic:Bar yo';
+ string = "stream:Foo -topic:Bar yo";
assert.deepEqual(Filter.unparse(operators), string);
operators = [
- {operator: 'streams', operand: 'public'},
- {operator: 'search', operand: 'text'},
+ {operator: "streams", operand: "public"},
+ {operator: "search", operand: "text"},
];
- string = 'streams:public text';
+ string = "streams:public text";
assert.deepEqual(Filter.unparse(operators), string);
operators = [
- {operator: 'streams', operand: 'public'},
+ {operator: "streams", operand: "public"},
];
- string = 'streams:public';
+ string = "streams:public";
assert.deepEqual(Filter.unparse(operators), string);
operators = [
- {operator: 'streams', operand: 'public', negated: true},
+ {operator: "streams", operand: "public", negated: true},
];
- string = '-streams:public';
+ string = "-streams:public";
assert.deepEqual(Filter.unparse(operators), string);
operators = [
- {operator: 'id', operand: 50},
+ {operator: "id", operand: 50},
];
- string = 'id:50';
+ string = "id:50";
assert.deepEqual(Filter.unparse(operators), string);
operators = [
- {operator: 'near', operand: 150},
+ {operator: "near", operand: 150},
];
- string = 'near:150';
+ string = "near:150";
assert.deepEqual(Filter.unparse(operators), string);
operators = [
- {operator: '', operand: ''},
+ {operator: "", operand: ""},
];
- string = '';
+ string = "";
assert.deepEqual(Filter.unparse(operators), string);
});
-run_test('describe', () => {
+run_test("describe", () => {
let narrow;
let string;
narrow = [
- {operator: 'streams', operand: 'public'},
+ {operator: "streams", operand: "public"},
];
- string = 'streams public';
+ string = "streams public";
assert.equal(Filter.describe(narrow), string);
narrow = [
- {operator: 'streams', operand: 'public', negated: true},
+ {operator: "streams", operand: "public", negated: true},
];
- string = 'exclude streams public';
+ string = "exclude streams public";
assert.equal(Filter.describe(narrow), string);
narrow = [
- {operator: 'stream', operand: 'devel'},
- {operator: 'is', operand: 'starred'},
+ {operator: "stream", operand: "devel"},
+ {operator: "is", operand: "starred"},
];
- string = 'stream devel, starred messages';
+ string = "stream devel, starred messages";
assert.equal(Filter.describe(narrow), string);
narrow = [
- {operator: 'stream', operand: 'river'},
- {operator: 'is', operand: 'unread'},
+ {operator: "stream", operand: "river"},
+ {operator: "is", operand: "unread"},
];
- string = 'stream river, unread messages';
+ string = "stream river, unread messages";
assert.equal(Filter.describe(narrow), string);
narrow = [
- {operator: 'stream', operand: 'devel'},
- {operator: 'topic', operand: 'JS'},
+ {operator: "stream", operand: "devel"},
+ {operator: "topic", operand: "JS"},
];
- string = 'stream devel &gt; JS';
+ string = "stream devel &gt; JS";
assert.equal(Filter.describe(narrow), string);
narrow = [
- {operator: 'is', operand: 'private'},
- {operator: 'search', operand: 'lunch'},
+ {operator: "is", operand: "private"},
+ {operator: "search", operand: "lunch"},
];
- string = 'private messages, search for lunch';
+ string = "private messages, search for lunch";
assert.equal(Filter.describe(narrow), string);
narrow = [
- {operator: 'id', operand: 99},
+ {operator: "id", operand: 99},
];
- string = 'message ID 99';
+ string = "message ID 99";
assert.equal(Filter.describe(narrow), string);
narrow = [
- {operator: 'in', operand: 'home'},
+ {operator: "in", operand: "home"},
];
- string = 'messages in home';
+ string = "messages in home";
assert.equal(Filter.describe(narrow), string);
narrow = [
- {operator: 'is', operand: 'mentioned'},
+ {operator: "is", operand: "mentioned"},
];
- string = '@-mentions';
+ string = "@-mentions";
assert.equal(Filter.describe(narrow), string);
narrow = [
- {operator: 'is', operand: 'alerted'},
+ {operator: "is", operand: "alerted"},
];
- string = 'alerted messages';
+ string = "alerted messages";
assert.equal(Filter.describe(narrow), string);
narrow = [
- {operator: 'is', operand: 'something_we_do_not_support'},
+ {operator: "is", operand: "something_we_do_not_support"},
];
- string = 'invalid something_we_do_not_support operand for is operator';
+ 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'},
+ {operator: "bogus", operand: "foo"},
];
- string = 'unknown operator';
+ string = "unknown operator";
assert.equal(Filter.describe(narrow), string);
narrow = [
- {operator: 'stream', operand: 'devel'},
- {operator: 'topic', operand: 'JS', negated: true},
+ {operator: "stream", operand: "devel"},
+ {operator: "topic", operand: "JS", negated: true},
];
- string = 'stream devel, exclude topic JS';
+ string = "stream devel, exclude topic JS";
assert.equal(Filter.describe(narrow), string);
narrow = [
- {operator: 'is', operand: 'private'},
- {operator: 'search', operand: 'lunch', negated: true},
+ {operator: "is", operand: "private"},
+ {operator: "search", operand: "lunch", negated: true},
];
- string = 'private messages, exclude lunch';
+ string = "private messages, exclude lunch";
assert.equal(Filter.describe(narrow), string);
narrow = [
- {operator: 'stream', operand: 'devel'},
- {operator: 'is', operand: 'starred', negated: true},
+ {operator: "stream", operand: "devel"},
+ {operator: "is", operand: "starred", negated: true},
];
- string = 'stream devel, exclude starred messages';
+ string = "stream devel, exclude starred messages";
assert.equal(Filter.describe(narrow), string);
narrow = [
- {operator: 'stream', operand: 'devel'},
- {operator: 'has', operand: 'image', negated: true},
+ {operator: "stream", operand: "devel"},
+ {operator: "has", operand: "image", negated: true},
];
- string = 'stream devel, exclude messages with one or more image';
+ string = "stream devel, exclude messages with one or more image";
assert.equal(Filter.describe(narrow), string);
narrow = [
- {operator: 'has', operand: 'abc', negated: true},
- {operator: 'stream', operand: 'devel'},
+ {operator: "has", operand: "abc", negated: true},
+ {operator: "stream", operand: "devel"},
];
- string = 'invalid abc operand for has operator, stream devel';
+ string = "invalid abc operand for has operator, stream devel";
assert.equal(Filter.describe(narrow), string);
narrow = [
- {operator: 'has', operand: 'image', negated: true},
- {operator: 'stream', operand: 'devel'},
+ {operator: "has", operand: "image", negated: true},
+ {operator: "stream", operand: "devel"},
];
- string = 'exclude messages with one or more image, stream devel';
+ string = "exclude messages with one or more image, stream devel";
assert.equal(Filter.describe(narrow), string);
narrow = [];
- string = 'all messages';
+ string = "all messages";
assert.equal(Filter.describe(narrow), string);
});
-run_test('can_bucket_by', () => {
+run_test("can_bucket_by", () => {
let terms = [
- {operator: 'stream', operand: 'My Stream'},
+ {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);
- assert.equal(filter.can_bucket_by('pm-with'), false);
+ assert.equal(filter.can_bucket_by("stream"), true);
+ assert.equal(filter.can_bucket_by("stream", "topic"), false);
+ assert.equal(filter.can_bucket_by("pm-with"), false);
terms = [
// try a non-orthodox ordering
- {operator: 'topic', operand: 'My Topic'},
- {operator: 'stream', operand: 'My Stream'},
+ {operator: "topic", operand: "My Topic"},
+ {operator: "stream", operand: "My Stream"},
];
filter = new Filter(terms);
- assert.equal(filter.can_bucket_by('stream'), true);
- assert.equal(filter.can_bucket_by('stream', 'topic'), true);
- assert.equal(filter.can_bucket_by('pm-with'), false);
+ assert.equal(filter.can_bucket_by("stream"), true);
+ assert.equal(filter.can_bucket_by("stream", "topic"), true);
+ assert.equal(filter.can_bucket_by("pm-with"), false);
terms = [
- {operator: 'stream', operand: 'My Stream', negated: true},
- {operator: 'topic', operand: 'My Topic'},
+ {operator: "stream", operand: "My Stream", negated: true},
+ {operator: "topic", operand: "My Topic"},
];
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);
+ 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]', negated: true},
+ {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);
+ 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]'},
+ {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);
- assert.equal(filter.can_bucket_by('pm-with'), true);
- assert.equal(filter.can_bucket_by('is-mentioned'), false);
- assert.equal(filter.can_bucket_by('is-private'), false);
+ 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"), true);
+ assert.equal(filter.can_bucket_by("is-mentioned"), false);
+ assert.equal(filter.can_bucket_by("is-private"), false);
terms = [
- {operator: 'is', operand: 'private'},
+ {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);
+ assert.equal(filter.can_bucket_by("is-mentioned"), false);
+ assert.equal(filter.can_bucket_by("is-private"), true);
terms = [
- {operator: 'is', operand: 'mentioned'},
+ {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);
+ assert.equal(filter.can_bucket_by("is-mentioned"), true);
+ assert.equal(filter.can_bucket_by("is-private"), false);
terms = [
- {operator: 'is', operand: 'mentioned'},
- {operator: 'is', operand: 'starred'},
+ {operator: "is", operand: "mentioned"},
+ {operator: "is", operand: "starred"},
];
filter = new Filter(terms);
- assert.equal(filter.can_bucket_by('is-mentioned'), true);
- assert.equal(filter.can_bucket_by('is-private'), false);
+ assert.equal(filter.can_bucket_by("is-mentioned"), true);
+ assert.equal(filter.can_bucket_by("is-private"), false);
// The call below returns false for somewhat arbitrary
// reasons -- we say is-private has precedence over
// is-starred.
- assert.equal(filter.can_bucket_by('is-starred'), false);
+ assert.equal(filter.can_bucket_by("is-starred"), false);
terms = [
- {operator: 'is', operand: 'mentioned', negated: true},
+ {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);
+ assert.equal(filter.can_bucket_by("is-mentioned"), false);
+ assert.equal(filter.can_bucket_by("is-private"), false);
});
-run_test('term_type', () => {
+run_test("term_type", () => {
function assert_term_type(term, expected_term_type) {
assert.equal(Filter.term_type(term), expected_term_type);
}
@@ -1261,13 +1261,13 @@ run_test('term_type', () => {
};
}
- assert_term_type(term('streams', 'public'), 'streams-public');
- assert_term_type(term('stream', 'whatever'), 'stream');
- assert_term_type(term('pm-with', 'whomever'), 'pm-with');
- assert_term_type(term('pm-with', 'whomever', true), 'not-pm-with');
- assert_term_type(term('is', 'private'), 'is-private');
- assert_term_type(term('has', 'link'), 'has-link');
- assert_term_type(term('has', 'attachment', true), 'not-has-attachment');
+ assert_term_type(term("streams", "public"), "streams-public");
+ assert_term_type(term("stream", "whatever"), "stream");
+ assert_term_type(term("pm-with", "whomever"), "pm-with");
+ assert_term_type(term("pm-with", "whomever", true), "not-pm-with");
+ assert_term_type(term("is", "private"), "is-private");
+ assert_term_type(term("has", "link"), "has-link");
+ assert_term_type(term("has", "attachment", true), "not-has-attachment");
function assert_term_sort(in_terms, expected) {
const sorted_terms = Filter.sorted_term_types(in_terms);
@@ -1275,38 +1275,38 @@ run_test('term_type', () => {
}
assert_term_sort(
- ['topic', 'stream', 'sender'],
- ['stream', 'topic', 'sender'],
+ ["topic", "stream", "sender"],
+ ["stream", "topic", "sender"],
);
assert_term_sort(
- ['has-link', 'near', 'is-unread', 'pm-with'],
- ['pm-with', 'near', 'is-unread', 'has-link'],
+ ["has-link", "near", "is-unread", "pm-with"],
+ ["pm-with", "near", "is-unread", "has-link"],
);
assert_term_sort(
- ['bogus', 'stream', 'topic'],
- ['stream', 'topic', 'bogus'],
+ ["bogus", "stream", "topic"],
+ ["stream", "topic", "bogus"],
);
assert_term_sort(
- ['stream', 'topic', 'stream'],
- ['stream', 'stream', 'topic'],
+ ["stream", "topic", "stream"],
+ ["stream", "stream", "topic"],
);
assert_term_sort(
- ['search', 'streams-public'],
- ['streams-public', 'search'],
+ ["search", "streams-public"],
+ ["streams-public", "search"],
);
const terms = [
- {operator: 'topic', operand: 'lunch'},
- {operator: 'sender', operand: '[email protected]'},
- {operator: 'stream', operand: 'Verona'},
+ {operator: "topic", operand: "lunch"},
+ {operator: "sender", operand: "[email protected]"},
+ {operator: "stream", operand: "Verona"},
];
let filter = new Filter(terms);
const term_types = filter.sorted_term_types();
- assert.deepEqual(term_types, ['stream', 'topic', 'sender']);
+ assert.deepEqual(term_types, ["stream", "topic", "sender"]);
// test caching of term types
// init and stub
@@ -1320,19 +1320,19 @@ run_test('term_type', () => {
// uncached trial
filter._build_sorted_term_types_called = false;
const built_terms = filter.sorted_term_types();
- assert.deepEqual(built_terms, ['stream', 'topic', 'sender']);
+ assert.deepEqual(built_terms, ["stream", "topic", "sender"]);
assert(filter._build_sorted_term_types_called);
// cached trial
filter._build_sorted_term_types_called = false;
const cached_terms = filter.sorted_term_types();
- assert.deepEqual(cached_terms, ['stream', 'topic', 'sender']);
+ assert.deepEqual(cached_terms, ["stream", "topic", "sender"]);
assert(!filter._build_sorted_term_types_called);
});
-run_test('first_valid_id_from', () => {
+run_test("first_valid_id_from", () => {
const terms = [
- {operator: 'is', operand: 'alerted'},
+ {operator: "is", operand: "alerted"},
];
const filter = new Filter(terms);
@@ -1341,7 +1341,7 @@ run_test('first_valid_id_from', () => {
5: { id: 5, alerted: true },
10: { id: 10 },
20: { id: 20, alerted: true },
- 30: { id: 30, type: 'stream' },
+ 30: { id: 30, type: "stream" },
40: { id: 40, alerted: false },
};
@@ -1356,17 +1356,17 @@ run_test('first_valid_id_from', () => {
assert.equal(filter.first_valid_id_from(msg_ids), 20);
});
-run_test('update_email', () => {
+run_test("update_email", () => {
const terms = [
- {operator: 'pm-with', operand: '[email protected]'},
- {operator: 'sender', operand: '[email protected]'},
- {operator: 'stream', operand: '[email protected]'}, // try to be tricky
+ {operator: "pm-with", operand: "[email protected]"},
+ {operator: "sender", operand: "[email protected]"},
+ {operator: "stream", operand: "[email protected]"}, // try to be tricky
];
const filter = new Filter(terms);
- filter.update_email(steve.user_id, '[email protected]');
- assert.deepEqual(filter.operands('pm-with'), ['[email protected]']);
- assert.deepEqual(filter.operands('sender'), ['[email protected]']);
- assert.deepEqual(filter.operands('stream'), ['[email protected]']);
+ filter.update_email(steve.user_id, "[email protected]");
+ assert.deepEqual(filter.operands("pm-with"), ["[email protected]"]);
+ assert.deepEqual(filter.operands("sender"), ["[email protected]"]);
+ assert.deepEqual(filter.operands("stream"), ["[email protected]"]);
});
function make_private_sub(name, stream_id) {
@@ -1387,14 +1387,14 @@ function make_web_public_sub(name, stream_id) {
global.stream_data.add_sub(sub);
}
-run_test('navbar_helpers', () => {
+run_test("navbar_helpers", () => {
// make sure title has names separated with correct delimiters
function properly_separated_names(names) {
- return names.join(', ');
+ return names.join(", ");
}
function test_redirect_url_with_search(test_case) {
- test_case.operator.push({ operator: 'search', operand: 'fizzbuzz'});
+ test_case.operator.push({ operator: "search", operand: "fizzbuzz"});
const filter = new Filter(test_case.operator);
assert.equal(
filter.generate_redirect_url(),
@@ -1425,136 +1425,136 @@ run_test('navbar_helpers', () => {
test_redirect_url_with_search(test_case);
}
- const in_home = [{ operator: 'in', operand: 'home'}];
- const in_all = [{ operator: 'in', operand: 'all'}];
- const is_starred = [{ operator: 'is', operand: 'starred'}];
- const is_private = [{ operator: 'is', operand: 'private'}];
- const is_mentioned = [{ operator: 'is', operand: 'mentioned'}];
- const streams_public = [{ operator: 'streams', operand: 'public'}];
+ const in_home = [{ operator: "in", operand: "home"}];
+ const in_all = [{ operator: "in", operand: "all"}];
+ const is_starred = [{ operator: "is", operand: "starred"}];
+ const is_private = [{ operator: "is", operand: "private"}];
+ const is_mentioned = [{ operator: "is", operand: "mentioned"}];
+ const streams_public = [{ operator: "streams", operand: "public"}];
const stream_topic_operators = [
- { operator: 'stream', operand: 'foo' },
- { operator: 'topic', operand: 'bar' },
+ { operator: "stream", operand: "foo" },
+ { operator: "topic", operand: "bar" },
];
// foo stream exists
- const stream_operator = [{ operator: 'stream', operand: 'foo'}];
- make_private_sub('psub', '22');
- const private_stream_operator = [{ operator: 'stream', operand: 'psub'}];
- make_web_public_sub('webPublicSub', '12'); // capitalized just to try be tricky and robust.
- const web_public_stream_operator = [{ operator: 'stream', operand: 'webPublicSub'}];
- const non_existent_stream = [{ operator: 'stream', operand: 'Elephant' }];
+ const stream_operator = [{ operator: "stream", operand: "foo"}];
+ make_private_sub("psub", "22");
+ const private_stream_operator = [{ operator: "stream", operand: "psub"}];
+ make_web_public_sub("webPublicSub", "12"); // capitalized just to try be tricky and robust.
+ const web_public_stream_operator = [{ operator: "stream", operand: "webPublicSub"}];
+ const non_existent_stream = [{ operator: "stream", operand: "Elephant" }];
const non_existent_stream_topic = [
- { operator: 'stream', operand: 'Elephant' },
- { operator: 'topic', operand: 'pink' },
+ { operator: "stream", operand: "Elephant" },
+ { operator: "topic", operand: "pink" },
];
- 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 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 test_cases = [
{
operator: is_starred,
is_common_narrow: true,
- icon: 'star',
- title: 'translated: Starred messages',
- redirect_url_with_search: '/#narrow/is/starred',
+ icon: "star",
+ title: "translated: Starred messages",
+ redirect_url_with_search: "/#narrow/is/starred",
},
{
operator: in_home,
is_common_narrow: true,
- icon: 'home',
- title: 'translated: All messages',
- redirect_url_with_search: '#',
+ icon: "home",
+ title: "translated: All messages",
+ redirect_url_with_search: "#",
},
{
operator: in_all,
is_common_narrow: true,
- icon: 'home',
- title: 'translated: All messages including muted streams',
- redirect_url_with_search: '#',
+ icon: "home",
+ title: "translated: All messages including muted streams",
+ redirect_url_with_search: "#",
},
{
operator: is_private,
is_common_narrow: true,
- icon: 'envelope',
- title: 'translated: Private messages',
- redirect_url_with_search: '/#narrow/is/private',
+ icon: "envelope",
+ title: "translated: Private messages",
+ redirect_url_with_search: "/#narrow/is/private",
},
{
operator: is_mentioned,
is_common_narrow: true,
- icon: 'at',
- title: 'translated: Mentions',
- redirect_url_with_search: '/#narrow/is/mentioned',
+ icon: "at",
+ title: "translated: Mentions",
+ redirect_url_with_search: "/#narrow/is/mentioned",
},
{
operator: stream_topic_operators,
is_common_narrow: true,
- icon: 'hashtag',
- title: 'Foo',
- redirect_url_with_search: '/#narrow/stream/42-Foo/topic/bar',
+ icon: "hashtag",
+ title: "Foo",
+ redirect_url_with_search: "/#narrow/stream/42-Foo/topic/bar",
},
{
operator: streams_public,
is_common_narrow: true,
icon: undefined,
- title: 'translated: Public stream messages in organization',
- redirect_url_with_search: '/#narrow/streams/public',
+ title: "translated: Public stream messages in organization",
+ redirect_url_with_search: "/#narrow/streams/public",
},
{
operator: stream_operator,
is_common_narrow: true,
- icon: 'hashtag',
- title: 'Foo',
- redirect_url_with_search: '/#narrow/stream/42-Foo',
+ icon: "hashtag",
+ title: "Foo",
+ redirect_url_with_search: "/#narrow/stream/42-Foo",
},
{
operator: non_existent_stream,
is_common_narrow: true,
- icon: 'question-circle-o',
- title: 'translated: Unknown stream',
- redirect_url_with_search: '#',
+ icon: "question-circle-o",
+ title: "translated: Unknown stream",
+ redirect_url_with_search: "#",
},
{
operator: non_existent_stream_topic,
is_common_narrow: true,
- icon: 'question-circle-o',
- title: 'translated: Unknown stream',
- redirect_url_with_search: '#',
+ icon: "question-circle-o",
+ title: "translated: Unknown stream",
+ redirect_url_with_search: "#",
},
{
operator: private_stream_operator,
is_common_narrow: true,
- icon: 'lock',
- title: 'psub',
- redirect_url_with_search: '/#narrow/stream/22-psub',
+ icon: "lock",
+ title: "psub",
+ redirect_url_with_search: "/#narrow/stream/22-psub",
},
{
operator: web_public_stream_operator,
is_common_narrow: true,
- icon: 'globe',
- title: 'webPublicSub',
- redirect_url_with_search: '/#narrow/stream/12-webPublicSub',
+ icon: "globe",
+ title: "webPublicSub",
+ redirect_url_with_search: "/#narrow/stream/12-webPublicSub",
},
{
operator: pm_with,
is_common_narrow: true,
- icon: 'envelope',
+ 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',
+ 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]']),
- redirect_url_with_search: '/#narrow/pm-with/undefined',
+ icon: "envelope",
+ title: properly_separated_names([joe.full_name, steve.full_name, "[email protected]"]),
+ redirect_url_with_search: "/#narrow/pm-with/undefined",
},
];
@@ -1563,18 +1563,18 @@ run_test('navbar_helpers', () => {
});
// TODO: these may be removed, based on design decisions
- const sender_me = [{operator: 'sender', operand: 'me'}];
- const sender_joe = [{operator: 'sender', operand: joe.email}];
+ const sender_me = [{operator: "sender", operand: "me"}];
+ const sender_joe = [{operator: "sender", operand: joe.email}];
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,
},
];
@@ -1587,9 +1587,9 @@ run_test('navbar_helpers', () => {
// incomplete and weak test cases just to restore coverage of filter.js
const complex_operator = [
- {operator: 'stream', operand: 'foo'},
- {operator: 'topic', operand: 'bar'},
- {operator: 'sender', operand: 'me'},
+ {operator: "stream", operand: "foo"},
+ {operator: "topic", operand: "bar"},
+ {operator: "sender", operand: "me"},
];
const complex_operators_test_case = {
@@ -1605,14 +1605,14 @@ run_test('navbar_helpers', () => {
assert.equal(filter.is_common_narrow(), false);
const stream_topic_search_operator = [
- {operator: 'stream', operand: 'foo'},
- {operator: 'topic', operand: 'bar'},
- {operator: 'search', operand: 'potato'},
+ {operator: "stream", operand: "foo"},
+ {operator: "topic", operand: "bar"},
+ {operator: "search", operand: "potato"},
];
const stream_topic_search_operator_test_case = {
operator: stream_topic_search_operator,
- title: 'Foo',
+ title: "Foo",
};
test_get_title(stream_topic_search_operator_test_case);
@@ -1620,7 +1620,7 @@ run_test('navbar_helpers', () => {
// this is actually wrong, but the code is currently not robust enough to throw an error here
// also, used as an example of triggering last return statement.
const default_redirect = {
- operator: [{operator: 'stream', operand: 'foo'}],
+ operator: [{operator: "stream", operand: "foo"}],
redirect_url: "#",
};
@@ -1631,11 +1631,11 @@ run_test('navbar_helpers', () => {
);
});
-run_test('error_cases', () => {
+run_test("error_cases", () => {
// This test just gives us 100% line coverage on defensive code that
// should not be reached unless we break other code.
people.pm_with_user_ids = function () {};
- const predicate = get_predicate([['pm-with', '[email protected]']]);
- assert(!predicate({type: 'private'}));
+ const predicate = get_predicate([["pm-with", "[email protected]"]]);
+ assert(!predicate({type: "private"}));
});
diff --git a/frontend_tests/node_tests/fold_dict.js b/frontend_tests/node_tests/fold_dict.js
index 1d8a540f1b7..ed1c6c18974 100644
--- a/frontend_tests/node_tests/fold_dict.js
+++ b/frontend_tests/node_tests/fold_dict.js
@@ -1,79 +1,79 @@
-const FoldDict = zrequire('fold_dict').FoldDict;
+const FoldDict = zrequire("fold_dict").FoldDict;
-run_test('basic', () => {
+run_test("basic", () => {
const d = new FoldDict();
assert.equal(d.size, 0);
assert.deepEqual(Array.from(d.keys()), []);
- d.set('foo', 'bar');
- assert.equal(d.get('foo'), 'bar');
+ d.set("foo", "bar");
+ assert.equal(d.get("foo"), "bar");
assert.notEqual(d.size, 0);
- d.set('foo', 'baz');
- assert.equal(d.get('foo'), 'baz');
+ d.set("foo", "baz");
+ assert.equal(d.get("foo"), "baz");
assert.equal(d.size, 1);
- d.set('bar', 'qux');
- assert.equal(d.get('foo'), 'baz');
- assert.equal(d.get('bar'), 'qux');
+ d.set("bar", "qux");
+ assert.equal(d.get("foo"), "baz");
+ assert.equal(d.get("bar"), "qux");
assert.equal(d.size, 2);
- assert.equal(d.has('bar'), true);
- assert.equal(d.has('baz'), false);
+ assert.equal(d.has("bar"), true);
+ assert.equal(d.has("baz"), false);
- 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.keys()), ["foo", "bar"]);
+ assert.deepEqual(Array.from(d.values()), ["baz", "qux"]);
+ assert.deepEqual(Array.from(d), [["foo", "baz"], ["bar", "qux"]]);
- d.delete('bar');
- assert.equal(d.has('bar'), false);
- assert.strictEqual(d.get('bar'), undefined);
+ d.delete("bar");
+ assert.equal(d.has("bar"), false);
+ assert.strictEqual(d.get("bar"), undefined);
- assert.deepEqual(Array.from(d.keys()), ['foo']);
+ assert.deepEqual(Array.from(d.keys()), ["foo"]);
- const val = ['foo'];
- const res = d.set('abc', val);
+ const val = ["foo"];
+ const res = d.set("abc", val);
assert.strictEqual(res, d);
});
-run_test('case insensitivity', () => {
+run_test("case insensitivity", () => {
const d = new FoldDict();
assert.deepEqual(Array.from(d.keys()), []);
- assert(!d.has('foo'));
- d.set('fOO', 'Hello World');
- assert.equal(d.get('foo'), 'Hello World');
- assert(d.has('foo'));
- assert(d.has('FOO'));
- assert(!d.has('not_a_key'));
+ assert(!d.has("foo"));
+ d.set("fOO", "Hello World");
+ assert.equal(d.get("foo"), "Hello World");
+ assert(d.has("foo"));
+ assert(d.has("FOO"));
+ assert(!d.has("not_a_key"));
- assert.deepEqual(Array.from(d.keys()), ['fOO']);
+ assert.deepEqual(Array.from(d.keys()), ["fOO"]);
- d.delete('Foo');
- assert.equal(d.has('foo'), false);
+ d.delete("Foo");
+ assert.equal(d.has("foo"), false);
assert.deepEqual(Array.from(d.keys()), []);
});
-run_test('clear', () => {
+run_test("clear", () => {
const d = new FoldDict();
function populate() {
- d.set('fOO', 1);
- assert.equal(d.get('foo'), 1);
- d.set('bAR', 2);
- assert.equal(d.get('bar'), 2);
+ d.set("fOO", 1);
+ assert.equal(d.get("foo"), 1);
+ d.set("bAR", 2);
+ assert.equal(d.get("bar"), 2);
}
populate();
assert.equal(d.size, 2);
d.clear();
- assert.equal(d.get('fOO'), undefined);
- assert.equal(d.get('bAR'), undefined);
+ assert.equal(d.get("fOO"), undefined);
+ assert.equal(d.get("bAR"), undefined);
assert.equal(d.size, 0);
// make sure it still works after clearing
@@ -81,8 +81,8 @@ run_test('clear', () => {
assert.equal(d.size, 2);
});
-run_test('undefined_keys', () => {
- blueslip.expect('error', 'Tried to call a FoldDict method with an undefined key.', 2);
+run_test("undefined_keys", () => {
+ blueslip.expect("error", "Tried to call a FoldDict method with an undefined key.", 2);
const d = new FoldDict();
diff --git a/frontend_tests/node_tests/general.js b/frontend_tests/node_tests/general.js
index 58c1fcf7d82..750aa696c37 100644
--- a/frontend_tests/node_tests/general.js
+++ b/frontend_tests/node_tests/general.js
@@ -6,20 +6,20 @@
// The most basic unit tests load up code, call functions,
// and assert truths:
-const util = zrequire('util');
-assert(!util.find_wildcard_mentions('boring text'));
-assert(util.find_wildcard_mentions('mention @**everyone**'));
+const util = zrequire("util");
+assert(!util.find_wildcard_mentions("boring text"));
+assert(util.find_wildcard_mentions("mention @**everyone**"));
// Let's test with people.js next. We'll show this technique:
// * get a false value
// * change the data
// * get a true value
-zrequire('people');
+zrequire("people");
const isaac = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 30,
- full_name: 'Isaac Newton',
+ full_name: "Isaac Newton",
};
assert(!people.is_known_user_id(isaac.user_id));
@@ -33,9 +33,9 @@ assert(people.is_known_user_id(isaac.user_id));
// require.
const me = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 31,
- full_name: 'Me Myself',
+ full_name: "Me Myself",
};
people.add_active_user(me);
people.initialize_current_user(me.user_id);
@@ -45,8 +45,8 @@ people.initialize_current_user(me.user_id);
// tests):
const denmark_stream = {
- color: 'blue',
- name: 'Denmark',
+ color: "blue",
+ name: "Denmark",
stream_id: 101,
subscribed: false,
};
@@ -55,15 +55,15 @@ const denmark_stream = {
// structure that the server sends down to us when the app starts. We
// prefer to test with a clean slate.
-set_global('page_params', {});
+set_global("page_params", {});
-zrequire('stream_data');
+zrequire("stream_data");
-run_test('stream_data', () => {
- assert.equal(stream_data.get_sub_by_name('Denmark'), undefined);
+run_test("stream_data", () => {
+ assert.equal(stream_data.get_sub_by_name("Denmark"), undefined);
stream_data.add_sub(denmark_stream);
- const sub = stream_data.get_sub_by_name('Denmark');
- assert.equal(sub.color, 'blue');
+ const sub = stream_data.get_sub_by_name("Denmark");
+ assert.equal(sub.color, "blue");
});
// Hopefully the basic patterns for testing data-oriented modules
@@ -77,9 +77,9 @@ const messages = {
id: 400,
sender_id: isaac.user_id,
stream_id: denmark_stream.stream_id,
- type: 'stream',
- flags: ['has_alert_word'],
- topic: 'copenhagen',
+ type: "stream",
+ flags: ["has_alert_word"],
+ topic: "copenhagen",
// note we don't have every field that a "real" message
// would have, and that can be fine
},
@@ -91,21 +91,21 @@ const messages = {
const noop = () => undefined;
-set_global('alert_words', {});
+set_global("alert_words", {});
alert_words.process_message = noop;
// We can also bring in real code:
-zrequire('recent_senders');
-zrequire('unread');
-zrequire('stream_topic_history');
-zrequire('recent_topics');
-zrequire('overlays');
+zrequire("recent_senders");
+zrequire("unread");
+zrequire("stream_topic_history");
+zrequire("recent_topics");
+zrequire("overlays");
// And finally require the module that we will test directly:
-zrequire('message_store');
+zrequire("message_store");
-run_test('message_store', () => {
+run_test("message_store", () => {
const in_message = { ...messages.isaac_to_denmark_stream };
assert.equal(in_message.alerted, undefined);
@@ -121,15 +121,15 @@ run_test('message_store', () => {
// There are more side effects.
const topic_names = stream_topic_history.get_recent_topic_names(denmark_stream.stream_id);
- assert.deepEqual(topic_names, ['copenhagen']);
+ assert.deepEqual(topic_names, ["copenhagen"]);
});
// Tracking unread messages is a very fundamental part of the Zulip
// app, and we use the unread object to track unread messages.
-run_test('unread', () => {
+run_test("unread", () => {
const stream_id = denmark_stream.stream_id;
- const topic_name = 'copenhagen';
+ const topic_name = "copenhagen";
assert.equal(unread.num_unread_for_topic(stream_id, topic_name), 0);
@@ -147,12 +147,12 @@ run_test('unread', () => {
// We use the second argument of zrequire to find the location of the
// Filter class.
-zrequire('Filter', 'js/filter');
+zrequire("Filter", "js/filter");
-run_test('filter', () => {
+run_test("filter", () => {
const filter_terms = [
- {operator: 'stream', operand: 'Denmark'},
- {operator: 'topic', operand: 'copenhagen'},
+ {operator: "stream", operand: "Denmark"},
+ {operator: "topic", operand: "copenhagen"},
];
const filter = new Filter(filter_terms);
@@ -162,18 +162,18 @@ run_test('filter', () => {
// We don't need full-fledged messages to test the gist of
// our filter. If there are details that are distracting from
// your test, you should not feel guilty about removing them.
- assert.equal(predicate({type: 'personal'}), false);
+ assert.equal(predicate({type: "personal"}), false);
assert.equal(predicate({
- type: 'stream',
+ type: "stream",
stream_id: denmark_stream.stream_id,
- topic: 'does not match filter',
+ topic: "does not match filter",
}), false);
assert.equal(predicate({
- type: 'stream',
+ type: "stream",
stream_id: denmark_stream.stream_id,
- topic: 'copenhagen',
+ topic: "copenhagen",
}), true);
});
@@ -181,9 +181,9 @@ run_test('filter', () => {
// "filter" abstraction. If you are in a narrow, we track the
// state with the narrow_state module.
-zrequire('narrow_state');
+zrequire("narrow_state");
-run_test('narrow_state', () => {
+run_test("narrow_state", () => {
// As we often do, first make assertions about the starting
// state:
@@ -191,16 +191,16 @@ run_test('narrow_state', () => {
// Now set the state.
const filter_terms = [
- {operator: 'stream', operand: 'Denmark'},
- {operator: 'topic', operand: 'copenhagen'},
+ {operator: "stream", operand: "Denmark"},
+ {operator: "topic", operand: "copenhagen"},
];
const filter = new Filter(filter_terms);
narrow_state.set_current_filter(filter);
- assert.equal(narrow_state.stream(), 'Denmark');
- assert.equal(narrow_state.topic(), 'copenhagen');
+ assert.equal(narrow_state.stream(), "Denmark");
+ assert.equal(narrow_state.topic(), "copenhagen");
});
/*
@@ -279,19 +279,19 @@ run_test('narrow_state', () => {
*/
-zrequire('server_events_dispatch');
+zrequire("server_events_dispatch");
// We will use Bob in several tests.
const bob = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 33,
- full_name: 'Bob Roberts',
+ full_name: "Bob Roberts",
};
-run_test('add_user_event', () => {
+run_test("add_user_event", () => {
const event = {
- type: 'realm_user',
- op: 'add',
+ type: "realm_user",
+ op: "add",
person: bob,
};
@@ -314,23 +314,23 @@ run_test('add_user_event', () => {
*/
-set_global('activity', {});
-set_global('message_live_update', {});
-set_global('pm_list', {});
-set_global('settings_users', {});
+set_global("activity", {});
+set_global("message_live_update", {});
+set_global("pm_list", {});
+set_global("settings_users", {});
-zrequire('user_events');
+zrequire("user_events");
-run_test('update_user_event', () => {
+run_test("update_user_event", () => {
const new_bob = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: bob.user_id,
- full_name: 'The Artist Formerly Known as Bob',
+ full_name: "The Artist Formerly Known as Bob",
};
const event = {
- type: 'realm_user',
- op: 'update',
+ type: "realm_user",
+ op: "update",
person: new_bob,
};
@@ -348,7 +348,7 @@ run_test('update_user_event', () => {
const user = people.get_by_user_id(bob.user_id);
// Verify that the code actually did its main job:
- assert.equal(user.full_name, 'The Artist Formerly Known as Bob');
+ assert.equal(user.full_name, "The Artist Formerly Known as Bob");
});
/*
@@ -370,7 +370,7 @@ function test_helper() {
return {
redirect: (module_name, func_name) => {
- const full_name = module_name + '.' + func_name;
+ const full_name = module_name + "." + func_name;
global[module_name][func_name] = () => {
events.push(full_name);
};
@@ -395,35 +395,35 @@ function test_helper() {
*/
-set_global('home_msg_list', {});
-set_global('message_list', {});
-set_global('message_util', {});
-set_global('notifications', {});
-set_global('resize', {});
-set_global('stream_list', {});
-set_global('unread_ops', {});
-set_global('unread_ui', {});
+set_global("home_msg_list", {});
+set_global("message_list", {});
+set_global("message_util", {});
+set_global("notifications", {});
+set_global("resize", {});
+set_global("stream_list", {});
+set_global("unread_ops", {});
+set_global("unread_ui", {});
-zrequire('message_events');
+zrequire("message_events");
-run_test('insert_message', () => {
+run_test("insert_message", () => {
const helper = test_helper();
const new_message = {
sender_id: isaac.user_id,
id: 1001,
- content: 'example content',
+ content: "example content",
};
assert.equal(message_store.get(new_message.id), undefined);
- helper.redirect('huddle_data', 'process_loaded_messages');
- helper.redirect('message_util', 'add_new_messages');
- helper.redirect('notifications', 'received_messages');
- helper.redirect('resize', 'resize_page_components');
- helper.redirect('stream_list', 'update_streams_sidebar');
- helper.redirect('unread_ops', 'process_visible');
- helper.redirect('unread_ui', 'update_unread_counts');
+ helper.redirect("huddle_data", "process_loaded_messages");
+ helper.redirect("message_util", "add_new_messages");
+ helper.redirect("notifications", "received_messages");
+ helper.redirect("resize", "resize_page_components");
+ helper.redirect("stream_list", "update_streams_sidebar");
+ helper.redirect("unread_ops", "process_visible");
+ helper.redirect("unread_ui", "update_unread_counts");
narrow_state.reset_current_filter();
@@ -434,14 +434,14 @@ run_test('insert_message', () => {
// the code invokes various objects when a new message
// comes in:
assert.deepEqual(helper.events, [
- 'huddle_data.process_loaded_messages',
- 'message_util.add_new_messages',
- 'message_util.add_new_messages',
- 'unread_ui.update_unread_counts',
- 'resize.resize_page_components',
- 'unread_ops.process_visible',
- 'notifications.received_messages',
- 'stream_list.update_streams_sidebar',
+ "huddle_data.process_loaded_messages",
+ "message_util.add_new_messages",
+ "message_util.add_new_messages",
+ "unread_ui.update_unread_counts",
+ "resize.resize_page_components",
+ "unread_ops.process_visible",
+ "notifications.received_messages",
+ "stream_list.update_streams_sidebar",
]);
// Despite all of our stubbing/mocking, the call to
@@ -449,7 +449,7 @@ run_test('insert_message', () => {
// side effect that we can verify:
const inserted_message = message_store.get(new_message.id);
assert.equal(inserted_message.id, new_message.id);
- assert.equal(inserted_message.content, 'example content');
+ assert.equal(inserted_message.content, "example content");
});
/*
@@ -486,22 +486,22 @@ run_test('insert_message', () => {
*/
-set_global('channel', {});
-set_global('home_msg_list', {});
-set_global('message_list', {});
-set_global('message_viewport', {});
-zrequire('message_flags');
+set_global("channel", {});
+set_global("home_msg_list", {});
+set_global("message_list", {});
+set_global("message_viewport", {});
+zrequire("message_flags");
-zrequire('unread_ops');
+zrequire("unread_ops");
-run_test('unread_ops', () => {
+run_test("unread_ops", () => {
(function set_up() {
const test_messages = [
{
id: 50,
- type: 'stream',
+ type: "stream",
stream_id: denmark_stream.stream_id,
- topic: 'copenhagen',
+ topic: "copenhagen",
unread: true,
},
];
@@ -521,7 +521,7 @@ run_test('unread_ops', () => {
// Set current_message_list containing messages that
// can be marked read
- set_global('current_msg_list', {
+ set_global("current_msg_list", {
all_messages: () => test_messages,
can_mark_messages_read: () => true,
});
@@ -552,9 +552,9 @@ run_test('unread_ops', () => {
// we post info to the server. We can verify that the correct
// url and parameters are specified:
assert.deepEqual(channel_post_opts, {
- url: '/json/messages/flags',
+ url: "/json/messages/flags",
idempotent: true,
- data: { messages: '[50]', op: 'add', flag: 'read' },
+ data: { messages: "[50]", op: "add", flag: "read" },
success: channel_post_opts.success,
});
@@ -573,24 +573,24 @@ run_test('unread_ops', () => {
*/
-set_global('topic_list', {});
+set_global("topic_list", {});
-zrequire('stream_sort');
-zrequire('stream_list');
+zrequire("stream_sort");
+zrequire("stream_list");
const social_stream = {
- color: 'red',
- name: 'Social',
+ color: "red",
+ name: "Social",
stream_id: 102,
subscribed: true,
};
-run_test('set_up_filter', () => {
+run_test("set_up_filter", () => {
stream_data.add_sub(social_stream);
const filter_terms = [
- {operator: 'stream', operand: 'Social'},
- {operator: 'topic', operand: 'lunch'},
+ {operator: "stream", operand: "Social"},
+ {operator: "topic", operand: "lunch"},
];
const filter = new Filter(filter_terms);
@@ -614,7 +614,7 @@ function jquery_elem() {
function make_jquery_helper() {
const stream_list_filter = jquery_elem();
- stream_list_filter.val = () => '';
+ stream_list_filter.val = () => "";
const stream_filters = jquery_elem();
@@ -625,24 +625,24 @@ function make_jquery_helper() {
function fake_jquery(selector) {
switch (selector) {
- case '.stream-list-filter':
+ case ".stream-list-filter":
return stream_list_filter;
- case 'ul#stream_filters li':
+ case "ul#stream_filters li":
return jquery_elem();
- case '#stream_filters':
+ case "#stream_filters":
return stream_filters;
default:
- throw Error('unknown selector: ' + selector);
+ throw Error("unknown selector: " + selector);
}
}
- set_global('$', fake_jquery);
+ set_global("$", fake_jquery);
return {
verify_actions: () => {
const expected_data_to_append = [
[
- 'stream stub',
+ "stream stub",
],
];
@@ -692,7 +692,7 @@ function make_sidebar_helper() {
update_whether_active: () => {
updated_whether_active = true;
},
- get_li: () => ['stream stub'],
+ get_li: () => ["stream stub"],
};
}
@@ -709,9 +709,9 @@ function make_sidebar_helper() {
};
}
-zrequire('topic_zoom');
+zrequire("topic_zoom");
-run_test('stream_list', () => {
+run_test("stream_list", () => {
const jquery_helper = make_jquery_helper();
const sidebar_helper = make_sidebar_helper();
const topic_list_helper = make_topic_list_helper();
diff --git a/frontend_tests/node_tests/hash_util.js b/frontend_tests/node_tests/hash_util.js
index cbcd9c82d1f..4539b4e70f2 100644
--- a/frontend_tests/node_tests/hash_util.js
+++ b/frontend_tests/node_tests/hash_util.js
@@ -1,19 +1,19 @@
-zrequire('hash_util');
-zrequire('stream_data');
-zrequire('people');
-zrequire('Filter', 'js/filter');
-zrequire('narrow_state');
+zrequire("hash_util");
+zrequire("stream_data");
+zrequire("people");
+zrequire("Filter", "js/filter");
+zrequire("narrow_state");
-set_global('$', global.make_zjquery({
+set_global("$", global.make_zjquery({
silent: true,
}));
-set_global('ui_report', {
+set_global("ui_report", {
displayed_error: false,
error: () => {
ui_report.displayed_error = true;
},
});
-set_global('location', {
+set_global("location", {
protocol: "https:",
host: "example.com",
pathname: "/",
@@ -21,24 +21,24 @@ set_global('location', {
const hamlet = {
user_id: 15,
- email: '[email protected]',
- full_name: 'Hamlet',
+ email: "[email protected]",
+ full_name: "Hamlet",
};
people.add_active_user(hamlet);
const frontend = {
stream_id: 99,
- name: 'frontend',
+ name: "frontend",
};
stream_data.add_sub(frontend);
-run_test('hash_util', () => {
+run_test("hash_util", () => {
// Test encodeHashComponent
- const str = 'https://www.zulipexample.com';
+ const str = "https://www.zulipexample.com";
const result1 = hash_util.encodeHashComponent(str);
- assert.equal(result1, 'https.3A.2F.2Fwww.2Ezulipexample.2Ecom');
+ assert.equal(result1, "https.3A.2F.2Fwww.2Ezulipexample.2Ecom");
// Test decodeHashComponent
const result2 = hash_util.decodeHashComponent(result1);
@@ -54,20 +54,20 @@ run_test('hash_util', () => {
assert.equal(decode_result, operand);
}
- let operator = 'sender';
+ let operator = "sender";
let operand = hamlet.email;
- encode_decode_operand(operator, operand, '15-hamlet');
+ encode_decode_operand(operator, operand, "15-hamlet");
- operator = 'stream';
- operand = 'frontend';
+ operator = "stream";
+ operand = "frontend";
- encode_decode_operand(operator, operand, '99-frontend');
+ encode_decode_operand(operator, operand, "99-frontend");
- operator = 'topic';
- operand = 'testing 123';
+ operator = "topic";
+ operand = "testing 123";
- encode_decode_operand(operator, operand, 'testing.20123');
+ encode_decode_operand(operator, operand, "testing.20123");
// Test invalid url decode.
const result = hash_util.decodeHashComponent("foo.foo");
@@ -75,96 +75,96 @@ run_test('hash_util', () => {
assert.equal(ui_report.displayed_error, true);
});
-run_test('test_get_hash_category', () => {
+run_test("test_get_hash_category", () => {
assert.deepEqual(
- hash_util.get_hash_category('streams/subscribed'),
- 'streams',
+ hash_util.get_hash_category("streams/subscribed"),
+ "streams",
);
assert.deepEqual(
- hash_util.get_hash_category('#settings/display-settings'),
- 'settings',
+ hash_util.get_hash_category("#settings/display-settings"),
+ "settings",
);
assert.deepEqual(
- hash_util.get_hash_category('#drafts'),
- 'drafts',
+ hash_util.get_hash_category("#drafts"),
+ "drafts",
);
assert.deepEqual(
- hash_util.get_hash_category('invites'),
- 'invites',
+ hash_util.get_hash_category("invites"),
+ "invites",
);
});
-run_test('test_get_hash_section', () => {
+run_test("test_get_hash_section", () => {
assert.equal(
- hash_util.get_hash_section('streams/subscribed'),
- 'subscribed',
+ hash_util.get_hash_section("streams/subscribed"),
+ "subscribed",
);
assert.equal(
- hash_util.get_hash_section('#settings/your-account'),
- 'your-account',
+ hash_util.get_hash_section("#settings/your-account"),
+ "your-account",
);
assert.equal(
- hash_util.get_hash_section('settings/10/general/'),
- '10',
+ hash_util.get_hash_section("settings/10/general/"),
+ "10",
);
assert.equal(
- hash_util.get_hash_section('#drafts'),
- '',
+ hash_util.get_hash_section("#drafts"),
+ "",
);
assert.equal(
- hash_util.get_hash_section(''),
- '',
+ hash_util.get_hash_section(""),
+ "",
);
});
-run_test('test_parse_narrow', () => {
+run_test("test_parse_narrow", () => {
assert.deepEqual(
- hash_util.parse_narrow(['narrow', 'stream', '99-frontend']),
- [{negated: false, operator: 'stream', operand: 'frontend'}],
+ 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'}],
+ hash_util.parse_narrow(["narrow", "-stream", "99-frontend"]),
+ [{negated: true, operator: "stream", operand: "frontend"}],
);
assert.equal(
- hash_util.parse_narrow(['narrow', 'BOGUS']),
+ 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'}],
+ hash_util.parse_narrow(["narrow", "stream", "42-bogus"]),
+ [{negated: false, operator: "stream", operand: "42-bogus"}],
);
});
-run_test('test_stream_edit_uri', () => {
+run_test("test_stream_edit_uri", () => {
const sub = {
- name: 'research & development',
+ name: "research & development",
stream_id: 42,
};
assert.equal(hash_util.stream_edit_uri(sub),
- '#streams/42/research.20.26.20development');
+ "#streams/42/research.20.26.20development");
});
-run_test('test_by_conversation_and_time_uri', () => {
+run_test("test_by_conversation_and_time_uri", () => {
let message = {
- type: 'stream',
+ type: "stream",
stream_id: frontend.stream_id,
- topic: 'testing',
+ topic: "testing",
id: 42,
};
assert.equal(hash_util.by_conversation_and_time_uri(message),
- 'https://example.com/#narrow/stream/99-frontend/topic/testing/near/42');
+ "https://example.com/#narrow/stream/99-frontend/topic/testing/near/42");
message = {
- type: 'private',
+ type: "private",
display_recipient: [
{
id: hamlet.user_id,
@@ -174,12 +174,12 @@ run_test('test_by_conversation_and_time_uri', () => {
};
assert.equal(hash_util.by_conversation_and_time_uri(message),
- 'https://example.com/#narrow/pm-with/15-pm/near/43');
+ "https://example.com/#narrow/pm-with/15-pm/near/43");
});
-run_test('test_search_public_streams_notice_url', () => {
+run_test("test_search_public_streams_notice_url", () => {
function set_uri(uri) {
- const operators = hash_util.parse_narrow(uri.split('/'));
+ const operators = hash_util.parse_narrow(uri.split("/"));
narrow_state.set_current_filter(new Filter(operators));
}
diff --git a/frontend_tests/node_tests/hashchange.js b/frontend_tests/node_tests/hashchange.js
index 95e710ca637..90bf3585595 100644
--- a/frontend_tests/node_tests/hashchange.js
+++ b/frontend_tests/node_tests/hashchange.js
@@ -1,114 +1,114 @@
-set_global('$', global.make_zjquery());
-const window_stub = $.create('window-stub');
-set_global('location', {
- protocol: 'http:',
- host: 'example.com',
+set_global("$", global.make_zjquery());
+const window_stub = $.create("window-stub");
+set_global("location", {
+ protocol: "http:",
+ host: "example.com",
});
-set_global('to_$', () => window_stub);
-
-zrequire('people');
-zrequire('hash_util');
-zrequire('hashchange');
-zrequire('stream_data');
-
-set_global('document', 'document-stub');
-set_global('history', {});
-
-set_global('admin', {});
-set_global('drafts', {});
-set_global('favicon', {});
-set_global('floating_recipient_bar', {});
-set_global('info_overlay', {});
-set_global('message_viewport', {});
-set_global('narrow', {});
-set_global('overlays', {});
-set_global('settings', {});
-set_global('subs', {});
-set_global('ui_util', {});
-
-run_test('operators_round_trip', () => {
+set_global("to_$", () => window_stub);
+
+zrequire("people");
+zrequire("hash_util");
+zrequire("hashchange");
+zrequire("stream_data");
+
+set_global("document", "document-stub");
+set_global("history", {});
+
+set_global("admin", {});
+set_global("drafts", {});
+set_global("favicon", {});
+set_global("floating_recipient_bar", {});
+set_global("info_overlay", {});
+set_global("message_viewport", {});
+set_global("narrow", {});
+set_global("overlays", {});
+set_global("settings", {});
+set_global("subs", {});
+set_global("ui_util", {});
+
+run_test("operators_round_trip", () => {
let operators;
let hash;
let narrow;
operators = [
- {operator: 'stream', operand: 'devel'},
- {operator: 'topic', operand: 'algol'},
+ {operator: "stream", operand: "devel"},
+ {operator: "topic", operand: "algol"},
];
hash = hash_util.operators_to_hash(operators);
- assert.equal(hash, '#narrow/stream/devel/topic/algol');
+ assert.equal(hash, "#narrow/stream/devel/topic/algol");
- narrow = hash_util.parse_narrow(hash.split('/'));
+ narrow = hash_util.parse_narrow(hash.split("/"));
assert.deepEqual(narrow, [
- {operator: 'stream', operand: 'devel', negated: false},
- {operator: 'topic', operand: 'algol', negated: false},
+ {operator: "stream", operand: "devel", negated: false},
+ {operator: "topic", operand: "algol", negated: false},
]);
operators = [
- {operator: 'stream', operand: 'devel'},
- {operator: 'topic', operand: 'visual c++', negated: true},
+ {operator: "stream", operand: "devel"},
+ {operator: "topic", operand: "visual c++", negated: true},
];
hash = hash_util.operators_to_hash(operators);
- assert.equal(hash, '#narrow/stream/devel/-topic/visual.20c.2B.2B');
+ assert.equal(hash, "#narrow/stream/devel/-topic/visual.20c.2B.2B");
- narrow = hash_util.parse_narrow(hash.split('/'));
+ narrow = hash_util.parse_narrow(hash.split("/"));
assert.deepEqual(narrow, [
- {operator: 'stream', operand: 'devel', negated: false},
- {operator: 'topic', operand: 'visual c++', negated: true},
+ {operator: "stream", operand: "devel", negated: false},
+ {operator: "topic", operand: "visual c++", negated: true},
]);
// test new encodings, where we have a stream id
const florida_stream = {
- name: 'Florida, USA',
+ name: "Florida, USA",
stream_id: 987,
};
stream_data.add_sub(florida_stream);
operators = [
- {operator: 'stream', operand: 'Florida, USA'},
+ {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.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},
+ {operator: "stream", operand: "Florida, USA", negated: false},
]);
});
-run_test('operators_trailing_slash', () => {
- const hash = '#narrow/stream/devel/topic/algol/';
- const narrow = hash_util.parse_narrow(hash.split('/'));
+run_test("operators_trailing_slash", () => {
+ const hash = "#narrow/stream/devel/topic/algol/";
+ const narrow = hash_util.parse_narrow(hash.split("/"));
assert.deepEqual(narrow, [
- {operator: 'stream', operand: 'devel', negated: false},
- {operator: 'topic', operand: 'algol', negated: false},
+ {operator: "stream", operand: "devel", negated: false},
+ {operator: "topic", operand: "algol", negated: false},
]);
});
-run_test('people_slugs', () => {
+run_test("people_slugs", () => {
let operators;
let hash;
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 42,
- full_name: 'Alice Smith',
+ full_name: "Alice Smith",
};
people.add_active_user(alice);
operators = [
- {operator: 'sender', operand: '[email protected]'},
+ {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.equal(hash, "#narrow/sender/42-alice");
+ const narrow = hash_util.parse_narrow(hash.split("/"));
assert.deepEqual(narrow, [
- {operator: 'sender', operand: '[email protected]', negated: false},
+ {operator: "sender", operand: "[email protected]", negated: false},
]);
operators = [
- {operator: 'pm-with', operand: '[email protected]'},
+ {operator: "pm-with", operand: "[email protected]"},
];
hash = hash_util.operators_to_hash(operators);
- assert.equal(hash, '#narrow/pm-with/42-alice');
+ assert.equal(hash, "#narrow/pm-with/42-alice");
});
function test_helper() {
@@ -117,31 +117,31 @@ function test_helper() {
function stub(module_name, func_name) {
global[module_name][func_name] = () => {
- events.push(module_name + '.' + func_name);
+ events.push(module_name + "." + func_name);
};
}
- stub('admin', 'launch');
- stub('drafts', 'launch');
- stub('floating_recipient_bar', 'update');
- stub('message_viewport', 'stop_auto_scrolling');
- stub('narrow', 'deactivate');
- stub('overlays', 'close_for_hash_change');
- stub('settings', 'launch');
- stub('subs', 'launch');
- stub('ui_util', 'blur_active_element');
+ stub("admin", "launch");
+ stub("drafts", "launch");
+ stub("floating_recipient_bar", "update");
+ stub("message_viewport", "stop_auto_scrolling");
+ stub("narrow", "deactivate");
+ stub("overlays", "close_for_hash_change");
+ stub("settings", "launch");
+ stub("subs", "launch");
+ stub("ui_util", "blur_active_element");
ui_util.change_tab_to = (hash) => {
- events.push('change_tab_to ' + hash);
+ events.push("change_tab_to " + hash);
};
narrow.activate = (terms) => {
narrow_terms = terms;
- events.push('narrow.activate');
+ events.push("narrow.activate");
};
info_overlay.show = (name) => {
- events.push('info: ' + name);
+ events.push("info: " + name);
};
return {
@@ -155,123 +155,123 @@ function test_helper() {
};
}
-run_test('hash_interactions', () => {
+run_test("hash_interactions", () => {
const helper = test_helper();
- window.location.hash = '#';
+ window.location.hash = "#";
helper.clear_events();
hashchange.initialize();
helper.assert_events([
- 'overlays.close_for_hash_change',
- 'message_viewport.stop_auto_scrolling',
- 'change_tab_to #home',
- 'narrow.deactivate',
- 'floating_recipient_bar.update',
+ "overlays.close_for_hash_change",
+ "message_viewport.stop_auto_scrolling",
+ "change_tab_to #home",
+ "narrow.deactivate",
+ "floating_recipient_bar.update",
]);
helper.clear_events();
- $(window).trigger($.Event('hashchange', {}));
+ $(window).trigger($.Event("hashchange", {}));
helper.assert_events([
- 'overlays.close_for_hash_change',
- 'message_viewport.stop_auto_scrolling',
- 'change_tab_to #home',
- 'narrow.deactivate',
- 'floating_recipient_bar.update',
+ "overlays.close_for_hash_change",
+ "message_viewport.stop_auto_scrolling",
+ "change_tab_to #home",
+ "narrow.deactivate",
+ "floating_recipient_bar.update",
]);
- window.location.hash = '#narrow/stream/Denmark';
+ window.location.hash = "#narrow/stream/Denmark";
helper.clear_events();
- $(window).trigger($.Event('hashchange', {}));
+ $(window).trigger($.Event("hashchange", {}));
helper.assert_events([
- 'overlays.close_for_hash_change',
- 'message_viewport.stop_auto_scrolling',
- 'change_tab_to #home',
- 'narrow.activate',
- 'floating_recipient_bar.update',
+ "overlays.close_for_hash_change",
+ "message_viewport.stop_auto_scrolling",
+ "change_tab_to #home",
+ "narrow.activate",
+ "floating_recipient_bar.update",
]);
let terms = helper.get_narrow_terms();
- assert.equal(terms[0].operand, 'Denmark');
+ assert.equal(terms[0].operand, "Denmark");
- window.location.hash = '#narrow';
+ window.location.hash = "#narrow";
helper.clear_events();
- $(window).trigger($.Event('hashchange', {}));
+ $(window).trigger($.Event("hashchange", {}));
helper.assert_events([
- 'overlays.close_for_hash_change',
- 'message_viewport.stop_auto_scrolling',
- 'change_tab_to #home',
- 'narrow.activate',
- 'floating_recipient_bar.update',
+ "overlays.close_for_hash_change",
+ "message_viewport.stop_auto_scrolling",
+ "change_tab_to #home",
+ "narrow.activate",
+ "floating_recipient_bar.update",
]);
terms = helper.get_narrow_terms();
assert.equal(terms.length, 0);
- window.location.hash = '#streams/whatever';
+ window.location.hash = "#streams/whatever";
helper.clear_events();
- $(window).trigger($.Event('hashchange', {}));
+ $(window).trigger($.Event("hashchange", {}));
helper.assert_events([
- 'overlays.close_for_hash_change',
- 'subs.launch',
+ "overlays.close_for_hash_change",
+ "subs.launch",
]);
- window.location.hash = '#keyboard-shortcuts/whatever';
+ window.location.hash = "#keyboard-shortcuts/whatever";
helper.clear_events();
- $(window).trigger($.Event('hashchange', {}));
+ $(window).trigger($.Event("hashchange", {}));
helper.assert_events([
- 'overlays.close_for_hash_change',
- 'message_viewport.stop_auto_scrolling',
- 'info: keyboard-shortcuts',
+ "overlays.close_for_hash_change",
+ "message_viewport.stop_auto_scrolling",
+ "info: keyboard-shortcuts",
]);
- window.location.hash = '#message-formatting/whatever';
+ window.location.hash = "#message-formatting/whatever";
helper.clear_events();
- $(window).trigger($.Event('hashchange', {}));
+ $(window).trigger($.Event("hashchange", {}));
helper.assert_events([
- 'overlays.close_for_hash_change',
- 'message_viewport.stop_auto_scrolling',
- 'info: message-formatting',
+ "overlays.close_for_hash_change",
+ "message_viewport.stop_auto_scrolling",
+ "info: message-formatting",
]);
- window.location.hash = '#search-operators/whatever';
+ window.location.hash = "#search-operators/whatever";
helper.clear_events();
- $(window).trigger($.Event('hashchange', {}));
+ $(window).trigger($.Event("hashchange", {}));
helper.assert_events([
- 'overlays.close_for_hash_change',
- 'message_viewport.stop_auto_scrolling',
- 'info: search-operators',
+ "overlays.close_for_hash_change",
+ "message_viewport.stop_auto_scrolling",
+ "info: search-operators",
]);
- window.location.hash = '#drafts';
+ window.location.hash = "#drafts";
helper.clear_events();
- $(window).trigger($.Event('hashchange', {}));
+ $(window).trigger($.Event("hashchange", {}));
helper.assert_events([
- 'overlays.close_for_hash_change',
- 'drafts.launch',
+ "overlays.close_for_hash_change",
+ "drafts.launch",
]);
- window.location.hash = '#settings/alert-words';
+ window.location.hash = "#settings/alert-words";
helper.clear_events();
- $(window).trigger($.Event('hashchange', {}));
+ $(window).trigger($.Event("hashchange", {}));
helper.assert_events([
- 'overlays.close_for_hash_change',
- 'settings.launch',
+ "overlays.close_for_hash_change",
+ "settings.launch",
]);
- window.location.hash = '#organization/user-list-admin';
+ window.location.hash = "#organization/user-list-admin";
helper.clear_events();
- $(window).trigger($.Event('hashchange', {}));
+ $(window).trigger($.Event("hashchange", {}));
helper.assert_events([
- 'overlays.close_for_hash_change',
- 'admin.launch',
+ "overlays.close_for_hash_change",
+ "admin.launch",
]);
let called_back;
@@ -282,26 +282,26 @@ run_test('hash_interactions', () => {
});
helper.assert_events([
- 'ui_util.blur_active_element',
+ "ui_util.blur_active_element",
]);
assert(called_back);
});
-run_test('save_narrow', () => {
+run_test("save_narrow", () => {
const helper = test_helper();
let operators = [
- {operator: 'is', operand: 'private'},
+ {operator: "is", operand: "private"},
];
- blueslip.expect('warn', 'browser does not support pushState');
+ blueslip.expect("warn", "browser does not support pushState");
hashchange.save_narrow(operators);
helper.assert_events([
- 'message_viewport.stop_auto_scrolling',
+ "message_viewport.stop_auto_scrolling",
]);
- assert.equal(window.location.hash, '#narrow/is/private');
+ assert.equal(window.location.hash, "#narrow/is/private");
let url_pushed;
global.history.pushState = (state, title, url) => {
@@ -309,13 +309,13 @@ run_test('save_narrow', () => {
};
operators = [
- {operator: 'is', operand: 'starred'},
+ {operator: "is", operand: "starred"},
];
helper.clear_events();
hashchange.save_narrow(operators);
helper.assert_events([
- 'message_viewport.stop_auto_scrolling',
+ "message_viewport.stop_auto_scrolling",
]);
- assert.equal(url_pushed, 'http://example.com/#narrow/is/starred');
+ 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 d027b12a7c1..bffacff53cb 100644
--- a/frontend_tests/node_tests/hotkey.js
+++ b/frontend_tests/node_tests/hotkey.js
@@ -11,35 +11,35 @@
// 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("navigator", {
+ platform: "",
});
-set_global('page_params', {
+set_global("page_params", {
});
-set_global('overlays', {
+set_global("overlays", {
});
const noop = () => {};
// jQuery stuff should go away if we make an initialize() method.
-set_global('document', 'document-stub');
-set_global('$', global.make_zjquery());
+set_global("document", "document-stub");
+set_global("$", global.make_zjquery());
$.fn.keydown = noop;
$.fn.keypress = noop;
-zrequire('emoji');
-const hotkey = zrequire('hotkey');
-zrequire('common');
+zrequire("emoji");
+const hotkey = zrequire("hotkey");
+zrequire("common");
-set_global('list_util', {
+set_global("list_util", {
});
-set_global('current_msg_list', {
+set_global("current_msg_list", {
selected_id: function () {
return 42;
},
@@ -67,7 +67,7 @@ function stubbing(func_name_to_stub, test_function) {
});
}
-run_test('mappings', () => {
+run_test("mappings", () => {
function map_press(which, shiftKey) {
return hotkey.get_keypress_hotkey({
which: which,
@@ -89,25 +89,25 @@ run_test('mappings', () => {
assert.equal(map_press(33), undefined);
// Test page-up does work.
- assert.equal(map_down(33).name, 'page_up');
+ assert.equal(map_down(33).name, "page_up");
// Test other mappings.
- assert.equal(map_down(9).name, 'tab');
- assert.equal(map_down(9, true).name, 'shift_tab');
- assert.equal(map_down(27).name, 'escape');
- assert.equal(map_down(37).name, 'left_arrow');
- assert.equal(map_down(13).name, 'enter');
- assert.equal(map_down(46).name, 'delete');
- assert.equal(map_down(13, true).name, 'enter');
-
- assert.equal(map_press(47).name, 'search'); // slash
- assert.equal(map_press(106).name, 'vim_down'); // j
-
- assert.equal(map_down(219, false, true).name, 'escape'); // ctrl + [
- assert.equal(map_down(67, false, true).name, 'copy_with_c'); // ctrl + c
- assert.equal(map_down(75, false, true).name, 'search_with_k'); // ctrl + k
- assert.equal(map_down(83, false, true).name, 'star_message'); // ctrl + s
- assert.equal(map_down(190, false, true).name, 'narrow_to_compose_target'); // ctrl + .
+ assert.equal(map_down(9).name, "tab");
+ assert.equal(map_down(9, true).name, "shift_tab");
+ assert.equal(map_down(27).name, "escape");
+ assert.equal(map_down(37).name, "left_arrow");
+ assert.equal(map_down(13).name, "enter");
+ assert.equal(map_down(46).name, "delete");
+ assert.equal(map_down(13, true).name, "enter");
+
+ assert.equal(map_press(47).name, "search"); // slash
+ assert.equal(map_press(106).name, "vim_down"); // j
+
+ assert.equal(map_down(219, false, true).name, "escape"); // ctrl + [
+ assert.equal(map_down(67, false, true).name, "copy_with_c"); // ctrl + c
+ assert.equal(map_down(75, false, true).name, "search_with_k"); // ctrl + k
+ assert.equal(map_down(83, false, true).name, "star_message"); // ctrl + s
+ assert.equal(map_down(190, false, true).name, "narrow_to_compose_target"); // ctrl + .
// More negative tests.
assert.equal(map_down(47), undefined);
@@ -134,21 +134,21 @@ run_test('mappings', () => {
// CMD tests for MacOS
global.navigator.platform = "MacIntel";
- assert.equal(map_down(219, false, true, false).name, 'escape'); // ctrl + [
+ assert.equal(map_down(219, false, true, false).name, "escape"); // ctrl + [
assert.equal(map_down(219, false, false, true), undefined); // cmd + [
- assert.equal(map_down(67, false, true, true).name, 'copy_with_c'); // ctrl + c
+ assert.equal(map_down(67, false, true, true).name, "copy_with_c"); // ctrl + c
assert.equal(map_down(67, false, true, false), undefined); // cmd + c
- assert.equal(map_down(75, false, false, true).name, 'search_with_k'); // cmd + k
+ assert.equal(map_down(75, false, false, true).name, "search_with_k"); // cmd + k
assert.equal(map_down(75, false, true, false), undefined); // ctrl + k
- assert.equal(map_down(83, false, false, true).name, 'star_message'); // cmd + s
+ assert.equal(map_down(83, false, false, true).name, "star_message"); // cmd + s
assert.equal(map_down(83, false, true, false), undefined); // ctrl + s
- assert.equal(map_down(190, false, false, true).name, 'narrow_to_compose_target'); // cmd + .
+ assert.equal(map_down(190, false, false, true).name, "narrow_to_compose_target"); // cmd + .
assert.equal(map_down(190, false, true, false), undefined); // ctrl + .
// Reset platform
- global.navigator.platform = '';
+ global.navigator.platform = "";
});
-run_test('basic_chars', () => {
+run_test("basic_chars", () => {
function process(s) {
const e = {
which: s.charCodeAt(0),
@@ -178,25 +178,25 @@ run_test('basic_chars', () => {
// Unmapped keys should immediately return false, without
// calling any functions outside of hotkey.js.
- assert_unmapped('abfhlmoyz');
- assert_unmapped('BEFHILNOQTUWXYZ');
+ assert_unmapped("abfhlmoyz");
+ assert_unmapped("BEFHILNOQTUWXYZ");
// We have to skip some checks due to the way the code is
// currently organized for mapped keys.
hotkey.in_content_editable_widget = return_false;
overlays.settings_open = return_false;
- set_global('popovers', {
+ set_global("popovers", {
actions_popped: return_false,
message_info_popped: return_false,
});
- set_global('emoji_picker', {
+ set_global("emoji_picker", {
reactions_popped: return_false,
});
- set_global('hotspots', {
+ set_global("hotspots", {
is_open: return_false,
});
- set_global('gear_menu', {
+ set_global("gear_menu", {
is_open: return_false,
});
@@ -204,17 +204,17 @@ run_test('basic_chars', () => {
hotkey.processing_text = return_true;
function test_normal_typing() {
- assert_unmapped('abcdefghijklmnopqrsuvwxyz');
- assert_unmapped(' ');
- assert_unmapped('[]\\.,;');
- assert_unmapped('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
+ assert_unmapped("abcdefghijklmnopqrsuvwxyz");
+ assert_unmapped(" ");
+ assert_unmapped("[]\\.,;");
+ assert_unmapped("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
assert_unmapped('~!@#$%^*()_+{}:"<>');
}
for (const settings_open of [return_true, return_false]) {
for (const is_active of [return_true, return_false]) {
for (const info_overlay_open of [return_true, return_false]) {
- set_global('overlays', {
+ set_global("overlays", {
is_active: is_active,
settings_open: settings_open,
info_overlay_open: info_overlay_open,
@@ -235,48 +235,48 @@ run_test('basic_chars', () => {
page_params.can_create_streams = true;
overlays.streams_open = return_true;
overlays.is_active = return_true;
- assert_mapping('S', 'subs.keyboard_sub');
- assert_mapping('V', 'subs.view_stream');
- assert_mapping('n', 'subs.open_create_stream');
+ assert_mapping("S", "subs.keyboard_sub");
+ assert_mapping("V", "subs.view_stream");
+ assert_mapping("n", "subs.open_create_stream");
page_params.can_create_streams = false;
- assert_unmapped('n');
+ assert_unmapped("n");
overlays.streams_open = return_false;
test_normal_typing();
overlays.is_active = return_false;
- assert_mapping('?', 'info_overlay.maybe_show_keyboard_shortcuts');
- assert_mapping('/', 'search.initiate_search');
- assert_mapping('w', 'activity.initiate_search');
- assert_mapping('q', 'stream_list.initiate_search');
+ assert_mapping("?", "info_overlay.maybe_show_keyboard_shortcuts");
+ assert_mapping("/", "search.initiate_search");
+ assert_mapping("w", "activity.initiate_search");
+ assert_mapping("q", "stream_list.initiate_search");
- assert_mapping('A', 'narrow.stream_cycle_backward');
- assert_mapping('D', 'narrow.stream_cycle_forward');
+ assert_mapping("A", "narrow.stream_cycle_backward");
+ assert_mapping("D", "narrow.stream_cycle_forward");
- assert_mapping('c', 'compose_actions.start');
- assert_mapping('x', 'compose_actions.start');
- assert_mapping('P', 'narrow.by');
- assert_mapping('g', 'gear_menu.open');
+ assert_mapping("c", "compose_actions.start");
+ assert_mapping("x", "compose_actions.start");
+ assert_mapping("P", "narrow.by");
+ assert_mapping("g", "gear_menu.open");
overlays.is_active = return_true;
overlays.drafts_open = return_true;
- assert_mapping('d', 'overlays.close_overlay');
+ assert_mapping("d", "overlays.close_overlay");
overlays.drafts_open = return_false;
test_normal_typing();
overlays.is_active = return_false;
- assert_mapping('d', 'drafts.launch');
+ assert_mapping("d", "drafts.launch");
// Test opening and closing of Recent Topics
overlays.is_active = return_true;
overlays.recent_topics_open = return_true;
- assert_mapping('t', 'overlays.close_overlay');
+ assert_mapping("t", "overlays.close_overlay");
overlays.recent_topics_open = return_false;
test_normal_typing();
overlays.is_active = return_false;
- assert_mapping('t', 'hashchange.go_to_location');
+ assert_mapping("t", "hashchange.go_to_location");
// Next, test keys that only work on a selected message.
- const message_view_only_keys = '@+>RjJkKsSuvi:GM';
+ const message_view_only_keys = "@+>RjJkKsSuvi:GM";
// Check that they do nothing without a selected message
global.current_msg_list.empty = return_true;
@@ -286,54 +286,54 @@ run_test('basic_chars', () => {
// Check that they do nothing while in the settings overlay
overlays.settings_open = return_true;
- assert_unmapped('@*+->rRjJkKsSuvi:GM');
+ assert_unmapped("@*+->rRjJkKsSuvi:GM");
overlays.settings_open = return_false;
// TODO: Similar check for being in the subs page
- assert_mapping('@', 'compose_actions.reply_with_mention');
- assert_mapping('+', 'reactions.toggle_emoji_reaction');
- assert_mapping('-', 'condense.toggle_collapse');
- assert_mapping('r', 'compose_actions.respond_to_message');
- assert_mapping('R', 'compose_actions.respond_to_message', true);
- assert_mapping('j', 'navigate.down');
- assert_mapping('J', 'navigate.page_down');
- assert_mapping('k', 'navigate.up');
- assert_mapping('K', 'navigate.page_up');
- assert_mapping('s', 'narrow.by_recipient');
- assert_mapping('S', 'narrow.by_topic');
- assert_mapping('u', 'popovers.show_sender_info');
- assert_mapping('i', 'popovers.open_message_menu');
- assert_mapping(':', 'reactions.open_reactions_popover', true);
- assert_mapping('>', 'compose_actions.quote_and_reply');
- assert_mapping('e', 'message_edit.start');
+ assert_mapping("@", "compose_actions.reply_with_mention");
+ assert_mapping("+", "reactions.toggle_emoji_reaction");
+ assert_mapping("-", "condense.toggle_collapse");
+ assert_mapping("r", "compose_actions.respond_to_message");
+ assert_mapping("R", "compose_actions.respond_to_message", true);
+ assert_mapping("j", "navigate.down");
+ assert_mapping("J", "navigate.page_down");
+ assert_mapping("k", "navigate.up");
+ assert_mapping("K", "navigate.page_up");
+ assert_mapping("s", "narrow.by_recipient");
+ assert_mapping("S", "narrow.by_topic");
+ assert_mapping("u", "popovers.show_sender_info");
+ assert_mapping("i", "popovers.open_message_menu");
+ assert_mapping(":", "reactions.open_reactions_popover", true);
+ assert_mapping(">", "compose_actions.quote_and_reply");
+ assert_mapping("e", "message_edit.start");
overlays.is_active = return_true;
overlays.lightbox_open = return_true;
- assert_mapping('v', 'overlays.close_overlay');
+ assert_mapping("v", "overlays.close_overlay");
overlays.lightbox_open = return_false;
test_normal_typing();
overlays.is_active = return_false;
- assert_mapping('v', 'lightbox.show_from_selected_message');
+ assert_mapping("v", "lightbox.show_from_selected_message");
global.emoji_picker.reactions_popped = return_true;
- assert_mapping(':', 'emoji_picker.navigate', true);
+ assert_mapping(":", "emoji_picker.navigate", true);
global.emoji_picker.reactions_popped = return_false;
- assert_mapping('G', 'navigate.to_end');
- assert_mapping('M', 'muting_ui.toggle_mute');
+ assert_mapping("G", "navigate.to_end");
+ assert_mapping("M", "muting_ui.toggle_mute");
// Test keys that work when a message is selected and
// also when the message list is empty.
- assert_mapping('n', 'narrow.narrow_to_next_topic');
- assert_mapping('p', 'narrow.narrow_to_next_pm_string');
+ assert_mapping("n", "narrow.narrow_to_next_topic");
+ assert_mapping("p", "narrow.narrow_to_next_pm_string");
global.current_msg_list.empty = return_true;
- assert_mapping('n', 'narrow.narrow_to_next_topic');
+ assert_mapping("n", "narrow.narrow_to_next_topic");
global.current_msg_list.empty = return_false;
});
-run_test('motion_keys', () => {
+run_test("motion_keys", () => {
const codes = {
down_arrow: 40,
end: 35,
@@ -344,7 +344,7 @@ run_test('motion_keys', () => {
page_down: 34,
spacebar: 32,
up_arrow: 38,
- '+': 187,
+ "+": 187,
};
function process(name, shiftKey, ctrlKey) {
@@ -381,62 +381,62 @@ run_test('motion_keys', () => {
overlays.streams_open = return_false;
overlays.lightbox_open = return_false;
- assert_unmapped('down_arrow');
- assert_unmapped('end');
- assert_unmapped('home');
- assert_unmapped('page_up');
- assert_unmapped('page_down');
- assert_unmapped('spacebar');
- assert_unmapped('up_arrow');
+ assert_unmapped("down_arrow");
+ assert_unmapped("end");
+ assert_unmapped("home");
+ assert_unmapped("page_up");
+ assert_unmapped("page_down");
+ assert_unmapped("spacebar");
+ assert_unmapped("up_arrow");
global.list_util.inside_list = return_true;
- assert_mapping('up_arrow', 'list_util.go_up');
- assert_mapping('down_arrow', 'list_util.go_down');
+ assert_mapping("up_arrow", "list_util.go_up");
+ assert_mapping("down_arrow", "list_util.go_down");
list_util.inside_list = return_false;
global.current_msg_list.empty = return_false;
- assert_mapping('down_arrow', 'navigate.down');
- assert_mapping('end', 'navigate.to_end');
- assert_mapping('home', 'navigate.to_home');
- assert_mapping('left_arrow', 'message_edit.edit_last_sent_message');
- assert_mapping('page_up', 'navigate.page_up');
- assert_mapping('page_down', 'navigate.page_down');
- assert_mapping('spacebar', 'navigate.page_down');
- assert_mapping('up_arrow', 'navigate.up');
+ assert_mapping("down_arrow", "navigate.down");
+ assert_mapping("end", "navigate.to_end");
+ assert_mapping("home", "navigate.to_home");
+ assert_mapping("left_arrow", "message_edit.edit_last_sent_message");
+ assert_mapping("page_up", "navigate.page_up");
+ assert_mapping("page_down", "navigate.page_down");
+ assert_mapping("spacebar", "navigate.page_down");
+ assert_mapping("up_arrow", "navigate.up");
overlays.info_overlay_open = return_true;
- assert_unmapped('down_arrow');
- assert_unmapped('up_arrow');
+ assert_unmapped("down_arrow");
+ assert_unmapped("up_arrow");
overlays.info_overlay_open = return_false;
overlays.streams_open = return_true;
- assert_mapping('up_arrow', 'subs.switch_rows');
- assert_mapping('down_arrow', 'subs.switch_rows');
+ assert_mapping("up_arrow", "subs.switch_rows");
+ assert_mapping("down_arrow", "subs.switch_rows");
overlays.streams_open = return_false;
overlays.lightbox_open = return_true;
- assert_mapping('left_arrow', 'lightbox.prev');
- assert_mapping('right_arrow', 'lightbox.next');
+ assert_mapping("left_arrow", "lightbox.prev");
+ assert_mapping("right_arrow", "lightbox.next");
overlays.lightbox_open = return_false;
hotkey.in_content_editable_widget = return_true;
- assert_unmapped('down_arrow');
- assert_unmapped('up_arrow');
+ assert_unmapped("down_arrow");
+ assert_unmapped("up_arrow");
hotkey.in_content_editable_widget = return_false;
overlays.settings_open = return_true;
- assert_unmapped('end');
- assert_unmapped('home');
- assert_unmapped('left_arrow');
- assert_unmapped('page_up');
- assert_unmapped('page_down');
- assert_unmapped('spacebar');
+ assert_unmapped("end");
+ assert_unmapped("home");
+ assert_unmapped("left_arrow");
+ assert_unmapped("page_up");
+ assert_unmapped("page_down");
+ assert_unmapped("spacebar");
overlays.settings_open = return_false;
overlays.is_active = return_true;
overlays.drafts_open = return_true;
- assert_mapping('up_arrow', 'drafts.drafts_handle_events');
- assert_mapping('down_arrow', 'drafts.drafts_handle_events');
+ assert_mapping("up_arrow", "drafts.drafts_handle_events");
+ assert_mapping("down_arrow", "drafts.drafts_handle_events");
overlays.is_active = return_false;
overlays.drafts_open = return_false;
});
diff --git a/frontend_tests/node_tests/i18n.js b/frontend_tests/node_tests/i18n.js
index e9cba104c39..3cb745b0687 100644
--- a/frontend_tests/node_tests/i18n.js
+++ b/frontend_tests/node_tests/i18n.js
@@ -1,10 +1,10 @@
-set_global('Handlebars', global.make_handlebars());
-zrequire('templates');
+set_global("Handlebars", global.make_handlebars());
+zrequire("templates");
// We download our translations in `page_params` (which
// are for the user's chosen language), so we simulate
// that here for the tests.
-set_global('page_params', {
+set_global("page_params", {
translation_data: {
"Quote and reply": "French translation",
"Notification triggers": "Some French text",
@@ -16,9 +16,9 @@ set_global('page_params', {
// We use `i18n.js` to initialize `i18next` and
// to set `i18n` to `i18next` on the global namespace
// for `templates.js`.
-zrequire('i18n');
+zrequire("i18n");
-run_test('t_tag', () => {
+run_test("t_tag", () => {
const args = {
message: {
is_stream: true,
@@ -33,11 +33,11 @@ run_test('t_tag', () => {
narrowed: true,
};
- const html = require('../../static/templates/actions_popover_content.hbs')(args);
+ const html = require("../../static/templates/actions_popover_content.hbs")(args);
assert(html.indexOf("French translation") > 0);
});
-run_test('tr_tag', () => {
+run_test("tr_tag", () => {
const args = {
page_params: {
full_name: "John Doe",
@@ -57,6 +57,6 @@ run_test('tr_tag', () => {
},
};
- const html = require('../../static/templates/settings_tab.hbs')(args);
- assert(html.indexOf('Some French text') > 0);
+ const html = require("../../static/templates/settings_tab.hbs")(args);
+ assert(html.indexOf("Some French text") > 0);
});
diff --git a/frontend_tests/node_tests/input_pill.js b/frontend_tests/node_tests/input_pill.js
index 4fe21f7d920..af8233bee75 100644
--- a/frontend_tests/node_tests/input_pill.js
+++ b/frontend_tests/node_tests/input_pill.js
@@ -1,30 +1,30 @@
-set_global('$', global.make_zjquery());
-zrequire('input_pill');
+set_global("$", global.make_zjquery());
+zrequire("input_pill");
-set_global('Handlebars', global.make_handlebars());
-zrequire('templates');
+set_global("Handlebars", global.make_handlebars());
+zrequire("templates");
-set_global('document', {});
+set_global("document", {});
const noop = function () {};
-const example_img_link = 'http://example.com/example.png';
+const example_img_link = "http://example.com/example.png";
-set_global('ui_util', {
+set_global("ui_util", {
place_caret_at_end: noop,
});
-set_global('getSelection', () => ({
+set_global("getSelection", () => ({
anchorOffset: 0,
}));
let id_seq = 0;
-run_test('set_up_ids', () => {
+run_test("set_up_ids", () => {
// just get coverage on a simple one-liner:
input_pill.random_id();
input_pill.random_id = function () {
id_seq += 1;
- return 'some_id' + id_seq;
+ return "some_id" + id_seq;
};
});
@@ -41,24 +41,24 @@ function pill_html(value, data_id, img_src) {
opts.img_src = img_src;
}
- return require('../../static/templates/input_pill.hbs')(opts);
+ return require("../../static/templates/input_pill.hbs")(opts);
}
-run_test('basics', () => {
+run_test("basics", () => {
const config = {};
- blueslip.expect('error', 'Pill needs container.');
+ blueslip.expect("error", "Pill needs container.");
input_pill.create(config);
- const pill_input = $.create('pill_input');
- const container = $.create('container');
- container.set_find_results('.input', pill_input);
+ const pill_input = $.create("pill_input");
+ const container = $.create("container");
+ container.set_find_results(".input", pill_input);
- blueslip.expect('error', 'Pill needs create_item_from_text');
+ blueslip.expect("error", "Pill needs create_item_from_text");
config.container = container;
input_pill.create(config);
- blueslip.expect('error', 'Pill needs get_text_from_item');
+ blueslip.expect("error", "Pill needs get_text_from_item");
config.create_item_from_text = noop;
input_pill.create(config);
@@ -66,13 +66,13 @@ run_test('basics', () => {
const widget = input_pill.create(config);
const item = {
- display_value: 'JavaScript',
- language: 'js',
+ display_value: "JavaScript",
+ language: "js",
img_src: example_img_link,
};
let inserted_before;
- const expected_html = pill_html('JavaScript', 'some_id1', example_img_link);
+ const expected_html = pill_html("JavaScript", "some_id1", example_img_link);
pill_input.before = function (elem) {
inserted_before = true;
@@ -86,26 +86,26 @@ run_test('basics', () => {
});
function set_up() {
- set_global('$', global.make_zjquery());
+ set_global("$", global.make_zjquery());
const items = {
blue: {
- display_value: 'BLUE',
- description: 'color of the sky',
+ display_value: "BLUE",
+ description: "color of the sky",
img_src: example_img_link,
},
red: {
- display_value: 'RED',
- description: 'color of stop signs',
+ display_value: "RED",
+ description: "color of stop signs",
},
yellow: {
- display_value: 'YELLOW',
- description: 'color of bananas',
+ display_value: "YELLOW",
+ description: "color of bananas",
},
};
- const pill_input = $.create('pill_input');
+ const pill_input = $.create("pill_input");
pill_input.before = () => {};
@@ -113,8 +113,8 @@ function set_up() {
return items[text];
};
- const container = $.create('container');
- container.set_find_results('.input', pill_input);
+ const container = $.create("container");
+ container.set_find_results(".input", pill_input);
const config = {
container: container,
@@ -132,22 +132,22 @@ function set_up() {
};
}
-run_test('copy from pill', () => {
+run_test("copy from pill", () => {
const info = set_up();
const config = info.config;
const container = info.container;
const widget = input_pill.create(config);
- widget.appendValue('blue,red');
+ widget.appendValue("blue,red");
- const copy_handler = container.get_on_handler('copy', '.pill');
+ const copy_handler = container.get_on_handler("copy", ".pill");
let copied_text;
const pill_stub = {
data: (field) => {
- assert.equal(field, 'id');
- return 'some_id2';
+ assert.equal(field, "id");
+ return "some_id2";
},
};
@@ -155,7 +155,7 @@ run_test('copy from pill', () => {
originalEvent: {
clipboardData: {
setData: (format, text) => {
- assert.equal(format, 'text/plain');
+ assert.equal(format, "text/plain");
copied_text = text;
},
},
@@ -163,14 +163,14 @@ run_test('copy from pill', () => {
preventDefault: noop,
};
- container.set_find_results(':focus', pill_stub);
+ container.set_find_results(":focus", pill_stub);
copy_handler(e);
- assert.equal(copied_text, 'RED');
+ assert.equal(copied_text, "RED");
});
-run_test('paste to input', () => {
+run_test("paste to input", () => {
const info = set_up();
const config = info.config;
const container = info.container;
@@ -178,15 +178,15 @@ run_test('paste to input', () => {
const widget = input_pill.create(config);
- const paste_handler = container.get_on_handler('paste', '.input');
+ const paste_handler = container.get_on_handler("paste", ".input");
- const paste_text = 'blue,yellow';
+ const paste_text = "blue,yellow";
const e = {
originalEvent: {
clipboardData: {
getData: (format) => {
- assert.equal(format, 'text/plain');
+ assert.equal(format, "text/plain");
return paste_text;
},
},
@@ -195,8 +195,8 @@ run_test('paste to input', () => {
};
document.execCommand = (cmd, _, text) => {
- assert.equal(cmd, 'insertText');
- container.find('.input').text(text);
+ assert.equal(cmd, "insertText");
+ container.find(".input").text(text);
};
paste_handler(e);
@@ -215,15 +215,15 @@ run_test('paste to input', () => {
assert(entered);
});
-run_test('arrows on pills', () => {
+run_test("arrows on pills", () => {
const info = set_up();
const config = info.config;
const container = info.container;
const widget = input_pill.create(config);
- widget.appendValue('blue,red');
+ widget.appendValue("blue,red");
- const key_handler = container.get_on_handler('keydown', '.pill');
+ const key_handler = container.get_on_handler("keydown", ".pill");
function test_key(c) {
key_handler({
@@ -250,7 +250,7 @@ run_test('arrows on pills', () => {
}),
};
- container.set_find_results('.pill:focus', pill_stub);
+ container.set_find_results(".pill:focus", pill_stub);
// We use the same stub to test both arrows, since we don't
// actually cause any real state changes here. We stub out
@@ -262,20 +262,20 @@ run_test('arrows on pills', () => {
assert(next_focused);
});
-run_test('left arrow on input', () => {
+run_test("left arrow on input", () => {
const info = set_up();
const config = info.config;
const container = info.container;
const widget = input_pill.create(config);
- widget.appendValue('blue,red');
+ widget.appendValue("blue,red");
const LEFT_ARROW = 37;
- const key_handler = container.get_on_handler('keydown', '.input');
+ const key_handler = container.get_on_handler("keydown", ".input");
let last_pill_focused = false;
- container.set_find_results('.pill', {
+ container.set_find_results(".pill", {
last: () => ({
focus: () => {
last_pill_focused = true;
@@ -290,7 +290,7 @@ run_test('left arrow on input', () => {
assert(last_pill_focused);
});
-run_test('comma', () => {
+run_test("comma", () => {
const info = set_up();
const config = info.config;
const items = info.items;
@@ -298,7 +298,7 @@ run_test('comma', () => {
const container = info.container;
const widget = input_pill.create(config);
- widget.appendValue('blue,red');
+ widget.appendValue("blue,red");
assert.deepEqual(widget.items(), [
items.blue,
@@ -306,9 +306,9 @@ run_test('comma', () => {
]);
const COMMA = 188;
- const key_handler = container.get_on_handler('keydown', '.input');
+ const key_handler = container.get_on_handler("keydown", ".input");
- pill_input.text = () => ' yel';
+ pill_input.text = () => " yel";
key_handler({
keyCode: COMMA,
@@ -320,7 +320,7 @@ run_test('comma', () => {
items.red,
]);
- pill_input.text = () => ' yellow';
+ pill_input.text = () => " yellow";
key_handler({
keyCode: COMMA,
@@ -334,14 +334,14 @@ run_test('comma', () => {
]);
});
-run_test('enter key with text', () => {
+run_test("enter key with text", () => {
const info = set_up();
const config = info.config;
const items = info.items;
const container = info.container;
const widget = input_pill.create(config);
- widget.appendValue('blue,red');
+ widget.appendValue("blue,red");
assert.deepEqual(widget.items(), [
items.blue,
@@ -349,14 +349,14 @@ run_test('enter key with text', () => {
]);
const ENTER = 13;
- const key_handler = container.get_on_handler('keydown', '.input');
+ const key_handler = container.get_on_handler("keydown", ".input");
key_handler({
keyCode: ENTER,
preventDefault: noop,
stopPropagation: noop,
target: {
- innerText: ' yellow ',
+ innerText: " yellow ",
},
});
@@ -367,7 +367,7 @@ run_test('enter key with text', () => {
]);
});
-run_test('insert_remove', () => {
+run_test("insert_remove", () => {
const info = set_up();
const config = info.config;
@@ -393,15 +393,15 @@ run_test('insert_remove', () => {
removed = true;
});
- widget.appendValue('blue,chartreuse,red,yellow,mauve');
+ widget.appendValue("blue,chartreuse,red,yellow,mauve");
assert(created);
assert(!removed);
assert.deepEqual(inserted_html, [
- pill_html('BLUE', 'some_id1', example_img_link),
- pill_html('RED', 'some_id2'),
- pill_html('YELLOW', 'some_id3'),
+ pill_html("BLUE", "some_id1", example_img_link),
+ pill_html("RED", "some_id2"),
+ pill_html("YELLOW", "some_id3"),
]);
assert.deepEqual(widget.items(), [
@@ -410,20 +410,20 @@ run_test('insert_remove', () => {
items.yellow,
]);
- assert.equal(pill_input.text(), 'chartreuse, mauve');
+ assert.equal(pill_input.text(), "chartreuse, mauve");
assert.equal(widget.is_pending(), true);
widget.clear_text();
- assert.equal(pill_input.text(), '');
+ assert.equal(pill_input.text(), "");
assert.equal(widget.is_pending(), false);
const BACKSPACE = 8;
- let key_handler = container.get_on_handler('keydown', '.input');
+ let key_handler = container.get_on_handler("keydown", ".input");
key_handler({
keyCode: BACKSPACE,
target: {
- innerText: '',
+ innerText: "",
},
preventDefault: noop,
});
@@ -446,14 +446,14 @@ run_test('insert_remove', () => {
const focus_pill_stub = {
next: () => next_pill_stub,
data: (field) => {
- assert.equal(field, 'id');
- return 'some_id1';
+ assert.equal(field, "id");
+ return "some_id1";
},
};
- container.set_find_results('.pill:focus', focus_pill_stub);
+ container.set_find_results(".pill:focus", focus_pill_stub);
- key_handler = container.get_on_handler('keydown', '.pill');
+ key_handler = container.get_on_handler("keydown", ".pill");
key_handler({
keyCode: BACKSPACE,
preventDefault: noop,
@@ -462,7 +462,7 @@ run_test('insert_remove', () => {
assert(next_pill_focused);
});
-run_test('exit button on pill', () => {
+run_test("exit button on pill", () => {
const info = set_up();
const config = info.config;
@@ -471,7 +471,7 @@ run_test('exit button on pill', () => {
const widget = input_pill.create(config);
- widget.appendValue('blue,red');
+ widget.appendValue("blue,red");
let next_pill_focused = false;
@@ -484,15 +484,15 @@ run_test('exit button on pill', () => {
const curr_pill_stub = {
next: () => next_pill_stub,
data: (field) => {
- assert.equal(field, 'id');
- return 'some_id1';
+ assert.equal(field, "id");
+ return "some_id1";
},
};
const exit_button_stub = {
to_$: () => ({
closest: (sel) => {
- assert.equal(sel, '.pill');
+ assert.equal(sel, ".pill");
return curr_pill_stub;
},
}),
@@ -501,7 +501,7 @@ run_test('exit button on pill', () => {
const e = {
stopPropagation: noop,
};
- const exit_click_handler = container.get_on_handler('click', '.exit');
+ const exit_click_handler = container.get_on_handler("click", ".exit");
exit_click_handler.call(exit_button_stub, e);
@@ -513,7 +513,7 @@ run_test('exit button on pill', () => {
});
-run_test('misc things', () => {
+run_test("misc things", () => {
const info = set_up();
const config = info.config;
@@ -523,14 +523,14 @@ run_test('misc things', () => {
const widget = input_pill.create(config);
// animation
- const animation_end_handler = container.get_on_handler('animationend', '.input');
+ const animation_end_handler = container.get_on_handler("animationend", ".input");
let shake_class_removed = false;
const input_stub = {
to_$: () => ({
removeClass: (cls) => {
- assert.equal(cls, 'shake');
+ assert.equal(cls, "shake");
shake_class_removed = true;
},
}),
@@ -540,16 +540,16 @@ run_test('misc things', () => {
assert(shake_class_removed);
// bad data
- blueslip.expect('error', 'no display_value returned');
- widget.appendValidatedData('this-has-no-item-attribute');
+ blueslip.expect("error", "no display_value returned");
+ widget.appendValidatedData("this-has-no-item-attribute");
// click on container
- const container_click_handler = container.get_on_handler('click');
+ const container_click_handler = container.get_on_handler("click");
- const stub = $.create('the-pill-container');
- stub.set_find_results('.input', pill_input);
+ const stub = $.create("the-pill-container");
+ stub.set_find_results(".input", pill_input);
stub.is = (sel) => {
- assert.equal(sel, '.pill-container');
+ assert.equal(sel, ".pill-container");
return true;
};
diff --git a/frontend_tests/node_tests/keydown_util.js b/frontend_tests/node_tests/keydown_util.js
index 57ea24916a4..677dfd7b800 100644
--- a/frontend_tests/node_tests/keydown_util.js
+++ b/frontend_tests/node_tests/keydown_util.js
@@ -1,14 +1,14 @@
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
-zrequire('keydown_util');
+zrequire("keydown_util");
-run_test('test_early_returns', () => {
- const stub = $.create('stub');
+run_test("test_early_returns", () => {
+ const stub = $.create("stub");
const opts = {
elem: stub,
handlers: {
left_arrow: () => {
- throw Error('do not dispatch this with alt key');
+ throw Error("do not dispatch this with alt key");
},
},
};
diff --git a/frontend_tests/node_tests/lazy_set.js b/frontend_tests/node_tests/lazy_set.js
index 552a748864c..8e917715a93 100644
--- a/frontend_tests/node_tests/lazy_set.js
+++ b/frontend_tests/node_tests/lazy_set.js
@@ -1,4 +1,4 @@
-const LazySet = zrequire('lazy_set').LazySet;
+const LazySet = zrequire("lazy_set").LazySet;
/*
We mostly test LazySet indirectly. This code
@@ -6,7 +6,7 @@ const LazySet = zrequire('lazy_set').LazySet;
how we download subscribers in page_params.
*/
-run_test('map', () => {
+run_test("map", () => {
const ls = new LazySet([1, 2]);
const triple = (n) => n * 3;
@@ -14,9 +14,9 @@ run_test('map', () => {
assert.deepEqual(ls.map(triple), [3, 6]);
});
-run_test('conversions', () => {
- blueslip.expect('error', 'not a number', 2);
+run_test("conversions", () => {
+ blueslip.expect("error", "not a number", 2);
const ls = new LazySet([1, 2]);
- ls.add('3');
- assert(ls.has('3'));
+ ls.add("3");
+ assert(ls.has("3"));
});
diff --git a/frontend_tests/node_tests/lib/events.js b/frontend_tests/node_tests/lib/events.js
index 78c761ad1e9..9a762ec0285 100644
--- a/frontend_tests/node_tests/lib/events.js
+++ b/frontend_tests/node_tests/lib/events.js
@@ -7,9 +7,9 @@
// a shared fixture.
exports.test_user = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 101,
- full_name: 'Test User',
+ full_name: "Test User",
};
exports.test_message = {
@@ -19,26 +19,26 @@ exports.test_message = {
exports.fixtures = {
alert_words: {
- type: 'alert_words',
- alert_words: ['fire', 'lunch'],
+ type: "alert_words",
+ alert_words: ["fire", "lunch"],
},
attachment: {
- type: 'attachment',
+ type: "attachment",
},
default_streams: {
- type: 'default_streams',
+ type: "default_streams",
default_streams: [
{
- name: 'devel',
- description: 'devel',
+ name: "devel",
+ description: "devel",
invite_only: false,
stream_id: 1,
},
{
- name: 'test',
- description: 'test',
+ name: "test",
+ description: "test",
invite_only: true,
stream_id: 1,
},
@@ -46,25 +46,25 @@ exports.fixtures = {
},
hotspots: {
- type: 'hotspots',
- hotspots: ['nice', 'chicken'],
+ type: "hotspots",
+ hotspots: ["nice", "chicken"],
},
invites_changed: {
- type: 'invites_changed',
+ type: "invites_changed",
},
muted_topics: {
- type: 'muted_topics',
- muted_topics: [['devel', 'js'], ['lunch', 'burritos']],
+ type: "muted_topics",
+ muted_topics: [["devel", "js"], ["lunch", "burritos"]],
},
presence: {
- type: 'presence',
- email: '[email protected]',
+ type: "presence",
+ email: "[email protected]",
user_id: 42,
presence: {
- client_name: 'electron',
+ client_name: "electron",
is_mirror_dummy: false,
// etc.
},
@@ -72,10 +72,10 @@ exports.fixtures = {
},
reaction__add: {
- type: 'reaction',
- op: 'add',
+ type: "reaction",
+ op: "add",
message_id: 128,
- emoji_name: 'anguished_pig',
+ emoji_name: "anguished_pig",
user_id: "1",
user: {
id: "1",
@@ -83,10 +83,10 @@ exports.fixtures = {
},
reaction__remove: {
- type: 'reaction',
- op: 'remove',
+ type: "reaction",
+ op: "remove",
message_id: 256,
- emoji_name: 'angery',
+ emoji_name: "angery",
user_id: "1",
user: {
id: "1",
@@ -96,93 +96,93 @@ exports.fixtures = {
// Please keep this next section un-nested, as we want this to partly
// be simple documentation on the formats of individual events.
realm__update__create_stream_policy: {
- type: 'realm',
- op: 'update',
- property: 'create_stream_policy',
+ type: "realm",
+ op: "update",
+ property: "create_stream_policy",
value: 2,
},
realm__update__invite_to_stream_policy: {
- type: 'realm',
- op: 'update',
- property: 'invite_to_stream_policy',
+ type: "realm",
+ op: "update",
+ property: "invite_to_stream_policy",
value: 2,
},
realm__update__invite_required: {
- type: 'realm',
- op: 'update',
- property: 'invite_required',
+ type: "realm",
+ op: "update",
+ property: "invite_required",
value: false,
},
realm__update__name: {
- type: 'realm',
- op: 'update',
- property: 'name',
- value: 'new_realm_name',
+ type: "realm",
+ op: "update",
+ property: "name",
+ value: "new_realm_name",
},
realm__update__emails_restricted_to_domains: {
- type: 'realm',
- op: 'update',
- property: 'emails_restricted_to_domains',
+ type: "realm",
+ op: "update",
+ property: "emails_restricted_to_domains",
value: false,
},
realm__update__bot_creation_policy: {
- type: 'realm',
- op: 'update',
- property: 'bot_creation_policy',
+ type: "realm",
+ op: "update",
+ property: "bot_creation_policy",
value: 1,
},
realm__update__email_addresses_visibility: {
- type: 'realm',
- op: 'update',
- property: 'email_address_visibility',
+ type: "realm",
+ op: "update",
+ property: "email_address_visibility",
value: 3,
},
realm__update__disallow_disposable_email_addresses: {
- type: 'realm',
- op: 'update',
- property: 'disallow_disposable_email_addresses',
+ type: "realm",
+ op: "update",
+ property: "disallow_disposable_email_addresses",
value: false,
},
realm__update_default_twenty_four_hour_time: {
- type: 'realm',
- op: 'update',
- property: 'default_twenty_four_hour_time',
+ type: "realm",
+ op: "update",
+ property: "default_twenty_four_hour_time",
value: false,
},
realm__update_notifications_stream_id: {
- type: 'realm',
- op: 'update',
- property: 'notifications_stream_id',
+ type: "realm",
+ op: "update",
+ property: "notifications_stream_id",
value: 42,
},
realm__update_signup_notifications_stream_id: {
- type: 'realm',
- op: 'update',
- property: 'signup_notifications_stream_id',
+ type: "realm",
+ op: "update",
+ property: "signup_notifications_stream_id",
value: 41,
},
realm__update_default_code_block_language: {
- type: 'realm',
- op: 'update',
- property: 'default_code_block_language',
- value: 'javascript',
+ type: "realm",
+ op: "update",
+ property: "default_code_block_language",
+ value: "javascript",
},
realm__update_dict__default: {
- type: 'realm',
- op: 'update_dict',
- property: 'default',
+ type: "realm",
+ op: "update_dict",
+ property: "default",
data: {
allow_message_editing: true,
message_content_edit_limit_seconds: 5,
@@ -193,165 +193,165 @@ exports.fixtures = {
},
realm__update_dict__icon: {
- type: 'realm',
- op: 'update_dict',
- property: 'icon',
+ type: "realm",
+ op: "update_dict",
+ property: "icon",
data: {
- icon_url: 'icon.png',
- icon_source: 'U',
+ icon_url: "icon.png",
+ icon_source: "U",
},
},
realm__update_dict__logo: {
- type: 'realm',
- op: 'update_dict',
- property: 'logo',
+ type: "realm",
+ op: "update_dict",
+ property: "logo",
data: {
- logo_url: 'logo.png',
- logo_source: 'U',
+ logo_url: "logo.png",
+ logo_source: "U",
},
},
realm__update_dict__night_logo: {
- type: 'realm',
- op: 'update_dict',
- property: 'night_logo',
+ type: "realm",
+ op: "update_dict",
+ property: "night_logo",
data: {
- night_logo_url: 'night_logo.png',
- night_logo_source: 'U',
+ night_logo_url: "night_logo.png",
+ night_logo_source: "U",
},
},
realm__deactivated: {
- type: 'realm',
- op: 'deactivated',
+ type: "realm",
+ op: "deactivated",
},
realm_bot__add: {
- type: 'realm_bot',
- op: 'add',
+ type: "realm_bot",
+ op: "add",
bot: {
- email: '[email protected]',
- full_name: 'The Bot',
+ email: "[email protected]",
+ full_name: "The Bot",
// etc.
},
},
realm_bot__remove: {
- type: 'realm_bot',
- op: 'remove',
+ type: "realm_bot",
+ op: "remove",
bot: {
- email: '[email protected]',
- user_id: '42',
- full_name: 'The Bot',
+ email: "[email protected]",
+ user_id: "42",
+ full_name: "The Bot",
},
},
realm_bot__delete: {
- type: 'realm_bot',
- op: 'delete',
+ type: "realm_bot",
+ op: "delete",
bot: {
- email: '[email protected]',
- user_id: '42',
+ email: "[email protected]",
+ user_id: "42",
},
},
realm_bot__update: {
- type: 'realm_bot',
- op: 'update',
+ type: "realm_bot",
+ op: "update",
bot: {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 4321,
- full_name: 'The Bot Has A New Name',
+ full_name: "The Bot Has A New Name",
},
},
realm_emoji: {
- type: 'realm_emoji',
+ type: "realm_emoji",
realm_emoji: {
airplane: {
- source_url: 'some_url',
+ source_url: "some_url",
},
},
},
realm_filters: {
- type: 'realm_filters',
+ type: "realm_filters",
realm_filters: [
- ['#[123]', 'ticket %(id)s'],
+ ["#[123]", "ticket %(id)s"],
],
},
realm_domains__add: {
- type: 'realm_domains',
- op: 'add',
+ type: "realm_domains",
+ op: "add",
realm_domain: {
- domain: 'ramen',
+ domain: "ramen",
allow_subdomains: false,
},
},
realm_domains__change: {
- type: 'realm_domains',
- op: 'change',
+ type: "realm_domains",
+ op: "change",
realm_domain: {
- domain: 'ramen',
+ domain: "ramen",
allow_subdomains: true,
},
},
realm_domains__remove: {
- type: 'realm_domains',
- op: 'remove',
- domain: 'ramen',
+ type: "realm_domains",
+ op: "remove",
+ domain: "ramen",
},
realm_user__add: {
- type: 'realm_user',
- op: 'add',
+ type: "realm_user",
+ op: "add",
person: {
- email: '[email protected]',
- full_name: 'Added Person',
+ email: "[email protected]",
+ full_name: "Added Person",
user_id: 1001,
},
},
realm_user__remove: {
- type: 'realm_user',
- op: 'remove',
+ type: "realm_user",
+ op: "remove",
person: {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 1001,
},
},
realm_user__update: {
- type: 'realm_user',
- op: 'update',
+ type: "realm_user",
+ op: "update",
person: {
- email: '[email protected]',
- full_name: 'Alice NewName',
+ email: "[email protected]",
+ full_name: "Alice NewName",
// etc.
},
},
restart: {
- type: 'restart',
+ type: "restart",
immediate: true,
},
stream__update: {
- type: 'stream',
- op: 'update',
- name: 'devel',
+ type: "stream",
+ op: "update",
+ name: "devel",
stream_id: 99,
- property: 'color',
- value: 'blue',
+ property: "color",
+ value: "blue",
},
stream__create: {
- type: 'stream',
- op: 'create',
+ type: "stream",
+ op: "create",
streams: [
{stream_id: 42},
{stream_id: 99},
@@ -359,8 +359,8 @@ exports.fixtures = {
},
stream__delete: {
- type: 'stream',
- op: 'delete',
+ type: "stream",
+ op: "delete",
streams: [
{stream_id: 42},
{stream_id: 99},
@@ -368,257 +368,257 @@ exports.fixtures = {
},
submessage: {
- type: 'submessage',
+ type: "submessage",
submessage_id: 99,
sender_id: 42,
- msg_type: 'stream',
+ msg_type: "stream",
message_id: 56,
- content: 'test',
+ content: "test",
},
subscription__add: {
- type: 'subscription',
- op: 'add',
+ type: "subscription",
+ op: "add",
subscriptions: [
{
- name: 'devel',
+ name: "devel",
stream_id: 42,
- subscribers: ['[email protected]', '[email protected]'],
- email_address: '[email protected]:9991',
+ subscribers: ["[email protected]", "[email protected]"],
+ email_address: "[email protected]:9991",
// etc.
},
],
},
subscription__remove: {
- type: 'subscription',
- op: 'remove',
+ type: "subscription",
+ op: "remove",
subscriptions: [
{
- name: 'devel',
+ name: "devel",
stream_id: 42,
},
],
},
subscription__peer_add: {
- type: 'subscription',
- op: 'peer_add',
+ type: "subscription",
+ op: "peer_add",
user_id: exports.test_user.user_id,
stream_id: 42,
},
subscription__peer_remove: {
- type: 'subscription',
- op: 'peer_remove',
+ type: "subscription",
+ op: "peer_remove",
user_id: exports.test_user.user_id,
stream_id: 42,
},
subscription__update: {
- type: 'subscription',
- op: 'update',
- name: 'devel',
+ type: "subscription",
+ op: "update",
+ name: "devel",
stream_id: 43,
- property: 'color',
- value: 'black',
+ property: "color",
+ value: "black",
},
typing__start: {
- type: 'typing',
+ type: "typing",
sender: {
user_id: 4,
},
- op: 'start',
+ op: "start",
},
typing__stop: {
- type: 'typing',
+ type: "typing",
sender: {
user_id: 6,
},
- op: 'stop',
+ op: "stop",
},
typing__self: {
- type: 'typing',
+ type: "typing",
sender: {
user_id: 5,
},
},
update_display_settings__default_language: {
- type: 'update_display_settings',
- setting_name: 'default_language',
- setting: 'fr',
- language_name: 'French',
+ type: "update_display_settings",
+ setting_name: "default_language",
+ setting: "fr",
+ language_name: "French",
},
update_display_settings__left_side_userlist: {
- type: 'update_display_settings',
- setting_name: 'left_side_userlist',
+ type: "update_display_settings",
+ setting_name: "left_side_userlist",
setting: true,
},
update_display_settings__twenty_four_hour_time: {
- type: 'update_display_settings',
- setting_name: 'twenty_four_hour_time',
+ type: "update_display_settings",
+ setting_name: "twenty_four_hour_time",
setting: true,
},
update_display_settings__high_contrast_mode: {
- type: 'update_display_settings',
- setting_name: 'high_contrast_mode',
+ type: "update_display_settings",
+ setting_name: "high_contrast_mode",
setting: true,
},
update_display_settings__dense_mode: {
- type: 'update_display_settings',
- setting_name: 'dense_mode',
+ type: "update_display_settings",
+ setting_name: "dense_mode",
setting: true,
},
update_display_settings__color_scheme_automatic: {
- type: 'update_display_settings',
- setting_name: 'color_scheme',
+ type: "update_display_settings",
+ setting_name: "color_scheme",
setting: 1,
},
update_display_settings__color_scheme_dark: {
- type: 'update_display_settings',
- setting_name: 'color_scheme',
+ type: "update_display_settings",
+ setting_name: "color_scheme",
setting: 2,
},
update_display_settings__color_scheme_light: {
- type: 'update_display_settings',
- setting_name: 'color_scheme',
+ type: "update_display_settings",
+ setting_name: "color_scheme",
setting: 3,
},
update_display_settings__starred_message_counts: {
- type: 'update_display_settings',
- setting_name: 'starred_message_counts',
+ type: "update_display_settings",
+ setting_name: "starred_message_counts",
setting: true,
},
update_display_settings__fluid_layout_width: {
- type: 'update_display_settings',
- setting_name: 'fluid_layout_width',
+ type: "update_display_settings",
+ setting_name: "fluid_layout_width",
setting: true,
},
update_display_settings__demote_inactive_streams: {
- type: 'update_display_settings',
- setting_name: 'demote_inactive_streams',
+ type: "update_display_settings",
+ setting_name: "demote_inactive_streams",
setting: 2,
},
update_display_settings__translate_emoticons: {
- type: 'update_display_settings',
- setting_name: 'translate_emoticons',
+ type: "update_display_settings",
+ setting_name: "translate_emoticons",
setting: true,
},
update_display_settings__emojiset: {
- type: 'update_display_settings',
- setting_name: 'emojiset',
- setting: 'google',
+ type: "update_display_settings",
+ setting_name: "emojiset",
+ setting: "google",
},
update_global_notifications: {
- type: 'update_global_notifications',
- notification_name: 'enable_stream_audible_notifications',
+ type: "update_global_notifications",
+ notification_name: "enable_stream_audible_notifications",
setting: true,
},
update_message_flags__read: {
- type: 'update_message_flags',
- operation: 'add',
- flag: 'read',
+ type: "update_message_flags",
+ operation: "add",
+ flag: "read",
messages: [999],
},
update_message_flags__starred_add: {
- type: 'update_message_flags',
- operation: 'add',
- flag: 'starred',
+ type: "update_message_flags",
+ operation: "add",
+ flag: "starred",
messages: [exports.test_message.id],
},
update_message_flags__starred_remove: {
- type: 'update_message_flags',
- operation: 'remove',
- flag: 'starred',
+ type: "update_message_flags",
+ operation: "remove",
+ flag: "starred",
messages: [exports.test_message.id],
},
delete_message: {
- type: 'delete_message',
+ type: "delete_message",
message_ids: [1337],
message_type: "stream",
stream_id: 99,
- topic: 'topic1',
+ topic: "topic1",
},
custom_profile_fields: {
- type: 'custom_profile_fields',
+ type: "custom_profile_fields",
fields: [
- {id: 1, name: 'teams', type: 1},
- {id: 2, name: 'hobbies', type: 1},
+ {id: 1, name: "teams", type: 1},
+ {id: 2, name: "hobbies", type: 1},
],
},
user_group__add: {
- type: 'user_group',
- op: 'add',
+ type: "user_group",
+ op: "add",
group: {
- name: 'Mobile',
- id: '1',
+ name: "Mobile",
+ id: "1",
members: [1],
},
},
user_group__add_members: {
- type: 'user_group',
- op: 'add_members',
+ type: "user_group",
+ op: "add_members",
group_id: 1,
user_ids: [2],
},
user_group__remove_members: {
- type: 'user_group',
- op: 'remove_members',
+ type: "user_group",
+ op: "remove_members",
group_id: 3,
user_ids: [99, 100],
},
user_group__update: {
- type: 'user_group',
- op: 'update',
+ type: "user_group",
+ op: "update",
group_id: 3,
data: {
- name: 'Frontend',
- description: 'All Frontend people',
+ name: "Frontend",
+ description: "All Frontend people",
},
},
user_status__revoke_away: {
- type: 'user_status',
+ type: "user_status",
user_id: 63,
away: false,
},
user_status__set_away: {
- type: 'user_status',
+ type: "user_status",
user_id: 55,
away: true,
},
user_status__set_status_text: {
- type: 'user_status',
+ type: "user_status",
user_id: exports.test_user.user_id,
- status_text: 'out to lunch',
+ status_text: "out to lunch",
},
realm_export: {
- type: 'realm_export',
+ type: "realm_export",
exports: {
acting_user_id: 55,
- event_time: 'noon',
- path: 'some_path',
+ event_time: "noon",
+ path: "some_path",
},
},
};
diff --git a/frontend_tests/node_tests/lightbox.js b/frontend_tests/node_tests/lightbox.js
index 177e05a6e70..202615c9df6 100644
--- a/frontend_tests/node_tests/lightbox.js
+++ b/frontend_tests/node_tests/lightbox.js
@@ -1,27 +1,27 @@
-zrequire('rows');
-zrequire('lightbox');
+zrequire("rows");
+zrequire("lightbox");
-set_global('message_store', {});
-set_global('Image', class Image {});
-set_global('overlays', {
+set_global("message_store", {});
+set_global("Image", class Image {});
+set_global("overlays", {
close_overlay: () => {},
close_active: () => {},
open_overlay: () => {},
});
-set_global('popovers', {
+set_global("popovers", {
hide_all: () => {},
});
rows.is_draft_row = () => false;
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
-run_test('pan_and_zoom', () => {
+run_test("pan_and_zoom", () => {
$.clear_all_elements();
- const img = $.create('img-stub');
- const link = $.create('link-stub');
- const msg = $.create('msg-stub');
+ const img = $.create("img-stub");
+ const link = $.create("link-stub");
+ const msg = $.create("msg-stub");
$(img).closest = () => [];
@@ -34,45 +34,45 @@ run_test('pan_and_zoom', () => {
message_store.get = (zid) => {
fetched_zid = zid;
- return 'message-stub';
+ return "message-stub";
};
// Used by render_lightbox_list_images
- $.stub_selector('.focused_table .message_inline_image img', []);
+ $.stub_selector(".focused_table .message_inline_image img", []);
lightbox.open(img);
assert.equal(fetched_zid, 1234);
});
-run_test('youtube', () => {
+run_test("youtube", () => {
$.clear_all_elements();
- const href = 'https://youtube.com/some-random-clip';
- const img = $.create('img-stub');
- const link = $.create('link-stub');
- const msg = $.create('msg-stub');
+ const href = "https://youtube.com/some-random-clip";
+ const img = $.create("img-stub");
+ const link = $.create("link-stub");
+ const msg = $.create("msg-stub");
msg.attr("zid", "4321");
- $(img).attr('src', href);
+ $(img).attr("src", href);
$(img).closest = (sel) => {
- if (sel === '.youtube-video') {
+ if (sel === ".youtube-video") {
// We just need a nonempty array to
// set is_youtube_video to true.
- return ['whatever'];
+ return ["whatever"];
}
return [];
};
img.set_parent(link);
link.closest = () => msg;
- link.attr('href', href);
+ link.attr("href", href);
// Used by render_lightbox_list_images
- $.stub_selector('.focused_table .message_inline_image img', []);
+ $.stub_selector(".focused_table .message_inline_image img", []);
lightbox.open(img);
- assert.equal($('.image-actions .open').attr('href'), href);
+ assert.equal($(".image-actions .open").attr("href"), href);
});
diff --git a/frontend_tests/node_tests/list_cursor.js b/frontend_tests/node_tests/list_cursor.js
index b8cb4e2bc18..79f8e7c964d 100644
--- a/frontend_tests/node_tests/list_cursor.js
+++ b/frontend_tests/node_tests/list_cursor.js
@@ -1,13 +1,13 @@
-zrequire('list_cursor');
+zrequire("list_cursor");
-run_test('config errors', () => {
- blueslip.expect('error', 'Programming error');
+run_test("config errors", () => {
+ blueslip.expect("error", "Programming error");
list_cursor({});
});
function basic_conf() {
const list = {
- scroll_container_sel: 'whatever',
+ scroll_container_sel: "whatever",
find_li: () => {},
first_key: () => {},
prev_key: () => {},
@@ -16,13 +16,13 @@ function basic_conf() {
const conf = {
list: list,
- highlight_class: 'highlight',
+ highlight_class: "highlight",
};
return conf;
}
-run_test('misc errors', () => {
+run_test("misc errors", () => {
const conf = basic_conf();
const cursor = list_cursor(conf);
@@ -30,28 +30,28 @@ run_test('misc errors', () => {
// Test that we just ignore empty
// lists for unknown keys.
conf.list.find_li = (opts) => {
- assert.equal(opts.key, 'nada');
+ assert.equal(opts.key, "nada");
assert.equal(opts.force_render, true);
return [];
};
- cursor.get_row('nada');
+ cursor.get_row("nada");
- blueslip.expect('error', 'Caller is not checking keys for list_cursor.go_to');
+ blueslip.expect("error", "Caller is not checking keys for list_cursor.go_to");
cursor.go_to(undefined);
- blueslip.expect('error', 'Cannot highlight key for list_cursor: nada');
- cursor.go_to('nada');
+ blueslip.expect("error", "Cannot highlight key for list_cursor: nada");
+ cursor.go_to("nada");
cursor.prev();
cursor.next();
});
-run_test('single item list', () => {
+run_test("single item list", () => {
const conf = basic_conf();
const cursor = list_cursor(conf);
- const valid_key = '42';
+ const valid_key = "42";
const li_stub = {
length: 1,
addClass: () => {},
diff --git a/frontend_tests/node_tests/list_render.js b/frontend_tests/node_tests/list_render.js
index fbe30fc67fa..0a13cb2bc12 100644
--- a/frontend_tests/node_tests/list_render.js
+++ b/frontend_tests/node_tests/list_render.js
@@ -1,20 +1,20 @@
-zrequire('list_render');
+zrequire("list_render");
// We need these stubs to get by instanceof checks.
// The list_render library allows you to insert objects
// that are either jQuery, Element, or just raw HTML
// strings. We initially test with raw strings.
-set_global('jQuery', 'stub');
+set_global("jQuery", "stub");
function Element() {
return { };
}
-set_global('Element', Element);
-set_global('ui', {});
+set_global("Element", Element);
+set_global("ui", {});
// We only need very simple jQuery wrappers for when the
// "real" code wraps html or sets up click handlers.
// We'll simulate most other objects ourselves.
-set_global('$', (arg) => {
+set_global("$", (arg) => {
if (arg.to_jquery) {
return arg.to_jquery();
}
@@ -41,8 +41,8 @@ function make_container() {
container.length = () => 1;
container.is = () => false;
container.css = (prop) => {
- assert.equal(prop, 'max-height');
- return 'none';
+ assert.equal(prop, "max-height");
+ return "none";
};
// Make our append function just set a field we can
@@ -62,14 +62,14 @@ function make_scroll_container() {
// Capture the scroll callback so we can call it in
// our tests.
scroll_container.on = (ev, f) => {
- assert.equal(ev, 'scroll.list_widget_container');
+ assert.equal(ev, "scroll.list_widget_container");
scroll_container.call_scroll = () => {
f.call(scroll_container);
};
};
scroll_container.off = (ev) => {
- assert.equal(ev, 'scroll.list_widget_container');
+ assert.equal(ev, "scroll.list_widget_container");
scroll_container.cleared = true;
};
@@ -82,13 +82,13 @@ function make_sort_container() {
sort_container.cleared = false;
sort_container.on = (ev, sel, f) => {
- assert.equal(ev, 'click.list_widget_sort');
- assert.equal(sel, '[data-sort]');
+ assert.equal(ev, "click.list_widget_sort");
+ assert.equal(sel, "[data-sort]");
sort_container.f = f;
};
sort_container.off = (ev) => {
- assert.equal(ev, 'click.list_widget_sort');
+ assert.equal(ev, "click.list_widget_sort");
sort_container.cleared = true;
};
@@ -101,12 +101,12 @@ function make_filter_element() {
element.cleared = false;
element.on = (ev, f) => {
- assert.equal(ev, 'input.list_widget_filter');
+ assert.equal(ev, "input.list_widget_filter");
element.f = f;
};
element.off = (ev) => {
- assert.equal(ev, 'input.list_widget_filter');
+ assert.equal(ev, "input.list_widget_filter");
element.cleared = true;
};
@@ -121,7 +121,7 @@ function make_search_input() {
$element.to_jquery = () => $element;
$element.on = (event_name, f) => {
- assert.equal(event_name, 'input.list_widget_filter');
+ assert.equal(event_name, "input.list_widget_filter");
$element.simulate_input_event = () => {
const elem = {
value: $element.val(),
@@ -134,10 +134,10 @@ function make_search_input() {
}
function div(item) {
- return '<div>' + item + '</div>';
+ return "<div>" + item + "</div>";
}
-run_test('scrolling', () => {
+run_test("scrolling", () => {
const container = make_container();
const scroll_container = make_scroll_container();
@@ -150,7 +150,7 @@ run_test('scrolling', () => {
};
for (let i = 0; i < 200; i += 1) {
- items.push('item ' + i);
+ items.push("item " + i);
}
const opts = {
@@ -158,12 +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(''),
+ items.slice(0, 80).join(""),
);
assert.equal(get_scroll_element_called, true);
@@ -177,24 +177,24 @@ run_test('scrolling', () => {
scroll_container.call_scroll();
assert.deepEqual(
container.appended_data.html(),
- items.slice(80, 100).join(''),
+ items.slice(80, 100).join(""),
);
});
-run_test('filtering', () => {
+run_test("filtering", () => {
const container = make_container();
const scroll_container = make_scroll_container();
const search_input = make_search_input();
const list = [
- 'apple',
- 'banana',
- 'carrot',
- 'dog',
- 'egg',
- 'fence',
- 'grape',
+ "apple",
+ "banana",
+ "carrot",
+ "dog",
+ "egg",
+ "fence",
+ "grape",
];
const opts = {
filter: {
@@ -205,47 +205,47 @@ 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 =
- '<div>apple</div>' +
- '<div>banana</div>' +
- '<div>carrot</div>' +
- '<div>dog</div>' +
- '<div>egg</div>' +
- '<div>fence</div>' +
- '<div>grape</div>';
+ "<div>apple</div>" +
+ "<div>banana</div>" +
+ "<div>carrot</div>" +
+ "<div>dog</div>" +
+ "<div>egg</div>" +
+ "<div>fence</div>" +
+ "<div>grape</div>";
assert.deepEqual(container.appended_data.html(), expected_html);
// Filtering will pick out dog/egg/grape when we put "g"
// into our search input. (This uses the default filter, which
// is a glorified indexOf call.)
- search_input.val = () => 'g';
+ search_input.val = () => "g";
search_input.simulate_input_event();
- expected_html = '<div>dog</div><div>egg</div><div>grape</div>';
+ expected_html = "<div>dog</div><div>egg</div><div>grape</div>";
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',
+ "greta",
+ "faye",
+ "gary",
+ "frank",
+ "giraffe",
+ "fox",
];
widget.replace_list_data(new_data);
expected_html =
- '<div>greta</div>' +
- '<div>gary</div>' +
- '<div>giraffe</div>';
+ "<div>greta</div>" +
+ "<div>gary</div>" +
+ "<div>giraffe</div>";
assert.deepEqual(container.appended_data.html(), expected_html);
});
-run_test('no filtering', () => {
+run_test("no filtering", () => {
const container = make_container();
const scroll_container = make_scroll_container();
container.html = () => {};
@@ -255,12 +255,12 @@ run_test('no filtering', () => {
modifier: (item) => div(item),
simplebar_container: scroll_container,
};
- const widget = list_render.create(container, ['apple', 'banana'], opts);
+ const widget = list_render.create(container, ["apple", "banana"], opts);
widget.render();
const expected_html =
- '<div>apple</div>' +
- '<div>banana</div>';
+ "<div>apple</div>" +
+ "<div>banana</div>";
assert.deepEqual(container.appended_data.html(), expected_html);
});
@@ -274,7 +274,7 @@ function sort_button(opts) {
switch (sel) {
case "sort": return opts.sort_type;
case "sort-prop": return opts.prop_name;
- default: throw Error('unknown selector: ' + sel);
+ default: throw Error("unknown selector: " + sel);
}
}
@@ -289,8 +289,8 @@ function sort_button(opts) {
const button = {
data: data,
- closest: lookup('.progressive-table-wrapper', {
- data: lookup('list-render', opts.list_name),
+ closest: lookup(".progressive-table-wrapper", {
+ data: lookup("list-render", opts.list_name),
}),
addClass: (cls) => {
classList.add(cls);
@@ -299,9 +299,9 @@ function sort_button(opts) {
removeClass: (cls) => {
classList.delete(cls);
},
- siblings: lookup('.active', {
+ siblings: lookup(".active", {
removeClass: (cls) => {
- assert.equal(cls, 'active');
+ assert.equal(cls, "active");
button.siblings_deactivated = true;
},
}),
@@ -312,14 +312,14 @@ function sort_button(opts) {
return button;
}
-run_test('wire up filter element', () => {
+run_test("wire up filter element", () => {
const lst = [
- 'alice',
- 'JESSE',
- 'moses',
- 'scott',
- 'Sean',
- 'Xavier',
+ "alice",
+ "JESSE",
+ "moses",
+ "scott",
+ "Sean",
+ "Xavier",
];
const container = make_container();
@@ -334,39 +334,39 @@ run_test('wire up filter element', () => {
filterer: (list, value) => list.filter((item) => item.toLowerCase().includes(value)),
element: filter_element,
},
- modifier: (s) => '(' + s + ')',
+ modifier: (s) => "(" + s + ")",
simplebar_container: scroll_container,
};
list_render.create(container, lst, opts);
- filter_element.f.apply({value: 'se'});
+ filter_element.f.apply({value: "se"});
assert.equal(
container.appended_data.html(),
- '(JESSE)(moses)(Sean)',
+ "(JESSE)(moses)(Sean)",
);
});
-run_test('sorting', () => {
+run_test("sorting", () => {
const container = make_container();
const scroll_container = make_scroll_container();
const sort_container = make_sort_container();
let cleared;
container.html = (html) => {
- assert.equal(html, '');
+ assert.equal(html, "");
cleared = true;
};
- const alice = { name: 'alice', salary: 50 };
- const bob = { name: 'Bob', salary: 40 };
- const cal = { name: 'cal', salary: 30 };
- const dave = { name: 'dave', salary: 25 };
- const ellen = { name: 'ellen', salary: 95 };
+ const alice = { name: "alice", salary: 50 };
+ const bob = { name: "Bob", salary: 40 };
+ const cal = { name: "cal", salary: 30 };
+ const dave = { name: "dave", salary: 25 };
+ const ellen = { name: "ellen", salary: 95 };
const list = [bob, ellen, dave, alice, cal];
const opts = {
- name: 'sorting-list',
+ name: "sorting-list",
parent_container: sort_container,
modifier: (item) => div(item.name) + div(item.salary),
filter: {
@@ -376,7 +376,7 @@ run_test('sorting', () => {
};
function html_for(people) {
- return people.map(opts.modifier).join('');
+ return people.map(opts.modifier).join("");
}
list_render.create(container, list, opts);
@@ -386,9 +386,9 @@ run_test('sorting', () => {
let expected_html;
button_opts = {
- sort_type: 'alphabetic',
- prop_name: 'name',
- list_name: 'my-list',
+ sort_type: "alphabetic",
+ prop_name: "name",
+ list_name: "my-list",
active: false,
};
@@ -420,7 +420,7 @@ run_test('sorting', () => {
alice,
]);
assert.deepEqual(container.appended_data.html(), expected_html);
- assert(button.hasClass('descend'));
+ assert(button.hasClass("descend"));
// And then hit a third time to go back to the forward sort.
cleared = false;
@@ -434,13 +434,13 @@ run_test('sorting', () => {
ellen,
]);
assert.deepEqual(container.appended_data.html(), expected_html);
- assert(!button.hasClass('descend'));
+ assert(!button.hasClass("descend"));
// Now try a numeric sort.
button_opts = {
- sort_type: 'numeric',
- prop_name: 'salary',
- list_name: 'my-list',
+ sort_type: "numeric",
+ prop_name: "salary",
+ list_name: "my-list",
active: false,
};
@@ -475,10 +475,10 @@ run_test('sorting', () => {
dave,
]);
assert.deepEqual(container.appended_data.html(), expected_html);
- assert(button.hasClass('descend'));
+ assert(button.hasClass("descend"));
});
-run_test('custom sort', () => {
+run_test("custom sort", () => {
const container = make_container();
const scroll_container = make_scroll_container();
container.html = () => {};
@@ -498,8 +498,8 @@ run_test('custom sort', () => {
}
list_render.create(container, list, {
- name: 'custom-sort-list',
- modifier: (n) => '(' + n.x + ', ' + n.y + ')',
+ name: "custom-sort-list",
+ modifier: (n) => "(" + n.x + ", " + n.y + ")",
sort_fields: {
product: sort_by_product,
x_value: sort_by_x,
@@ -510,15 +510,15 @@ run_test('custom sort', () => {
assert.deepEqual(
container.appended_data.html(),
- '(6, 7)(1, 43)(4, 11)',
+ "(6, 7)(1, 43)(4, 11)",
);
- const widget = list_render.get('custom-sort-list');
+ const widget = list_render.get("custom-sort-list");
- widget.sort('x_value');
+ widget.sort("x_value");
assert.deepEqual(
container.appended_data.html(),
- '(1, 43)(4, 11)(6, 7)',
+ "(1, 43)(4, 11)(6, 7)",
);
// We can sort without registering the function, too.
@@ -529,11 +529,11 @@ run_test('custom sort', () => {
widget.sort(sort_by_y);
assert.deepEqual(
container.appended_data.html(),
- '(6, 7)(4, 11)(1, 43)',
+ "(6, 7)(4, 11)(1, 43)",
);
});
-run_test('clear_event_handlers', () => {
+run_test("clear_event_handlers", () => {
const container = make_container();
const scroll_container = make_scroll_container();
const sort_container = make_sort_container();
@@ -544,7 +544,7 @@ run_test('clear_event_handlers', () => {
container.html = () => {};
const opts = {
- name: 'list-we-create-twice',
+ name: "list-we-create-twice",
parent_container: sort_container,
modifier: () => {},
filter: {
@@ -567,39 +567,39 @@ run_test('clear_event_handlers', () => {
assert.equal(filter_element.cleared, true);
});
-run_test('errors', () => {
+run_test("errors", () => {
// We don't care about actual data for this test.
- const list = 'stub';
+ const list = "stub";
const container = make_container();
const scroll_container = make_scroll_container();
- blueslip.expect('error', 'Need opts to create widget.');
+ blueslip.expect("error", "Need opts to create widget.");
list_render.create(container, list);
blueslip.reset();
- blueslip.expect('error', 'simplebar_container is missing.');
+ blueslip.expect("error", "simplebar_container is missing.");
list_render.create(container, list, {
- modifier: 'hello world',
+ modifier: "hello world",
});
blueslip.reset();
- blueslip.expect('error', 'get_item should be a function');
+ blueslip.expect("error", "get_item should be a function");
list_render.create(container, list, {
- get_item: 'not a function',
+ get_item: "not a function",
simplebar_container: scroll_container,
});
blueslip.reset();
- blueslip.expect('error', 'Filter predicate is not a function.');
+ blueslip.expect("error", "Filter predicate is not a function.");
list_render.create(container, list, {
filter: {
- predicate: 'wrong type',
+ predicate: "wrong type",
},
simplebar_container: scroll_container,
});
blueslip.reset();
- blueslip.expect('error', 'Filterer and predicate are mutually exclusive.');
+ blueslip.expect("error", "Filterer and predicate are mutually exclusive.");
list_render.create(container, list, {
filter: {
filterer: () => true,
@@ -609,7 +609,7 @@ run_test('errors', () => {
});
blueslip.reset();
- blueslip.expect('error', 'Filter filterer is not a function (or missing).');
+ blueslip.expect("error", "Filter filterer is not a function (or missing).");
list_render.create(container, list, {
filter: {
},
@@ -618,7 +618,7 @@ run_test('errors', () => {
blueslip.reset();
container.html = () => {};
- blueslip.expect('error', 'List item is not a string: 999');
+ blueslip.expect("error", "List item is not a string: 999");
list_render.create(container, list, {
modifier: () => 999,
simplebar_container: scroll_container,
@@ -626,19 +626,19 @@ run_test('errors', () => {
blueslip.reset();
});
-run_test('sort helpers', () => {
+run_test("sort helpers", () => {
/*
We mostly test our sorting helpers using the
actual widget, but this test gets us a bit
more line coverage.
*/
- const alice2 = {name: 'alice', id: 2};
- const alice10 = {name: 'alice', id: 10};
- const bob2 = {name: 'bob', id: 2};
- const bob10 = {name: 'bob', id: 10};
+ const alice2 = {name: "alice", id: 2};
+ const alice10 = {name: "alice", id: 10};
+ const bob2 = {name: "bob", id: 2};
+ const bob10 = {name: "bob", id: 10};
- const alpha_cmp = list_render.alphabetic_sort('name');
- const num_cmp = list_render.numeric_sort('id');
+ const alpha_cmp = list_render.alphabetic_sort("name");
+ const num_cmp = list_render.numeric_sort("id");
assert.equal(alpha_cmp(alice2, alice10), 0);
assert.equal(alpha_cmp(alice2, bob2), -1);
@@ -648,7 +648,7 @@ run_test('sort helpers', () => {
assert.equal(num_cmp(alice10, bob2), 1);
});
-run_test('replace_list_data w/filter update', () => {
+run_test("replace_list_data w/filter update", () => {
const container = make_container();
const scroll_container = make_scroll_container();
container.html = () => {};
@@ -657,8 +657,8 @@ run_test('replace_list_data w/filter update', () => {
let num_updates = 0;
list_render.create(container, list, {
- name: 'replace-list',
- modifier: (n) => '(' + n.toString() + ')',
+ name: "replace-list",
+ modifier: (n) => "(" + n.toString() + ")",
filter: {
predicate: (n) => n % 2 === 0,
onupdate: () => {
@@ -672,27 +672,27 @@ run_test('replace_list_data w/filter update', () => {
assert.deepEqual(
container.appended_data.html(),
- '(2)(4)',
+ "(2)(4)",
);
- const widget = list_render.get('replace-list');
+ 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)',
+ "(6)(8)",
);
});
-run_test('opts.get_item', () => {
+run_test("opts.get_item", () => {
const items = {};
- items[1] = 'one';
- items[2] = 'two';
- items[3] = 'three';
- items[4] = 'four';
+ items[1] = "one";
+ items[2] = "two";
+ items[3] = "three";
+ items[4] = "four";
const list = [1, 2, 3, 4];
@@ -702,9 +702,9 @@ run_test('opts.get_item', () => {
assert.deepEqual(
list_render.get_filtered_items(
- 'whatever', list, boring_opts,
+ "whatever", list, boring_opts,
),
- ['one', 'two', 'three', 'four'],
+ ["one", "two", "three", "four"],
);
const predicate = (item, value) => item.startsWith(value);
@@ -718,9 +718,9 @@ run_test('opts.get_item', () => {
assert.deepEqual(
list_render.get_filtered_items(
- 't', list, predicate_opts,
+ "t", list, predicate_opts,
),
- ['two', 'three'],
+ ["two", "three"],
);
const filterer_opts = {
@@ -732,13 +732,13 @@ run_test('opts.get_item', () => {
assert.deepEqual(
list_render.get_filtered_items(
- 't', list, filterer_opts,
+ "t", list, filterer_opts,
),
- ['two', 'three'],
+ ["two", "three"],
);
});
-run_test('render item', () => {
+run_test("render item", () => {
const container = make_container();
const scroll_container = make_scroll_container();
const INITIAL_RENDER_COUNT = 80; // Keep this in sync with the actual code.
@@ -768,11 +768,11 @@ run_test('render item', () => {
const list = [...Array(100).keys()];
- let text = 'initial';
+ let text = "initial";
const get_item = (item) => ({text: `${text}: ${item}`, value: item});
const widget = list_render.create(container, list, {
- name: 'replace-list',
+ name: "replace-list",
modifier: (item) => `<tr data-item=${item.value}>${item.text}</tr>\n`,
get_item: get_item,
html_selector: (item) => `tr[data-item='${item}']`,
@@ -780,13 +780,13 @@ run_test('render item', () => {
});
const item = INITIAL_RENDER_COUNT - 1;
- assert(container.appended_data.html().includes('<tr data-item=2>initial: 2</tr>'));
- assert(container.appended_data.html().includes('<tr data-item=3>initial: 3</tr>'));
- text = 'updated';
+ assert(container.appended_data.html().includes("<tr data-item=2>initial: 2</tr>"));
+ assert(container.appended_data.html().includes("<tr data-item=3>initial: 3</tr>"));
+ text = "updated";
called = false;
widget.render_item(INITIAL_RENDER_COUNT - 1);
assert(called);
- assert(container.appended_data.html().includes('<tr data-item=2>initial: 2</tr>'));
+ assert(container.appended_data.html().includes("<tr data-item=2>initial: 2</tr>"));
assert(container.appended_data.html().includes(`<tr data-item=${item}>updated: ${item}</tr>`));
// Item 80 should not be in the rendered list. (0 indexed)
@@ -799,19 +799,19 @@ run_test('render item', () => {
// Tests below this are for the corner cases, where we abort the rerender.
- blueslip.expect('error', 'html_selector should be a function.');
+ blueslip.expect("error", "html_selector should be a function.");
list_render.create(container, list, {
- name: 'replace-list',
+ name: "replace-list",
modifier: (item) => `<tr data-item=${item.value}>${item.text}</tr>\n`,
get_item: get_item,
- html_selector: 'hello world',
+ html_selector: "hello world",
simplebar_container: scroll_container,
});
blueslip.reset();
let get_item_called;
const widget_2 = list_render.create(container, list, {
- name: 'replace-list',
+ name: "replace-list",
modifier: (item) => `<tr data-item=${item.value}>${item.text}</tr>\n`,
get_item: (item) => {
get_item_called = true;
@@ -826,7 +826,7 @@ run_test('render item', () => {
let rendering_item = false;
const widget_3 = list_render.create(container, list, {
- name: 'replace-list',
+ name: "replace-list",
modifier: (item) => rendering_item ? undefined : `${item}\n`,
get_item: get_item,
html_selector: (item) => `tr[data-item='${item}']`,
@@ -835,7 +835,7 @@ run_test('render item', () => {
// Once we have initially rendered the widget, change the
// behavior of the modifier function.
rendering_item = true;
- blueslip.expect('error', 'List item is not a string: undefined');
+ blueslip.expect("error", "List item is not a string: undefined");
widget_3.render_item(item);
blueslip.reset();
});
diff --git a/frontend_tests/node_tests/markdown.js b/frontend_tests/node_tests/markdown.js
index 171e3cdcdfb..0cd99e04f37 100644
--- a/frontend_tests/node_tests/markdown.js
+++ b/frontend_tests/node_tests/markdown.js
@@ -1,29 +1,29 @@
-zrequire('hash_util');
-set_global('katex', zrequire('katex', 'katex/dist/katex.min.js'));
-set_global('marked', zrequire('marked', 'third/marked/lib/marked'));
-
-zrequire('fenced_code');
-zrequire('stream_data');
-zrequire('people');
-zrequire('user_groups');
-const emoji_codes = zrequire('emoji_codes', 'generated/emoji/emoji_codes.json');
-zrequire('emoji');
-zrequire('message_store');
-const markdown_config = zrequire('markdown_config');
-zrequire('markdown');
-
-set_global('location', {
- origin: 'http://zulip.zulipdev.com',
+zrequire("hash_util");
+set_global("katex", zrequire("katex", "katex/dist/katex.min.js"));
+set_global("marked", zrequire("marked", "third/marked/lib/marked"));
+
+zrequire("fenced_code");
+zrequire("stream_data");
+zrequire("people");
+zrequire("user_groups");
+const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json");
+zrequire("emoji");
+zrequire("message_store");
+const markdown_config = zrequire("markdown_config");
+zrequire("markdown");
+
+set_global("location", {
+ origin: "http://zulip.zulipdev.com",
});
-set_global('moment', require('moment-timezone'));
+set_global("moment", require("moment-timezone"));
-set_global('page_params', {
+set_global("page_params", {
realm_users: [],
realm_emoji: {
1: {id: 1,
- name: 'burrito',
- source_url: '/static/generated/emoji/images/emoji/burrito.png',
+ name: "burrito",
+ source_url: "/static/generated/emoji/images/emoji/burrito.png",
deactivated: false,
},
},
@@ -47,49 +47,49 @@ set_global('page_params', {
function Image() {
return {};
}
-set_global('Image', Image);
+set_global("Image", Image);
emoji.initialize();
const doc = "";
-set_global('document', doc);
+set_global("document", doc);
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
const cordelia = {
- full_name: 'Cordelia Lear',
+ full_name: "Cordelia Lear",
user_id: 101,
- email: '[email protected]',
+ email: "[email protected]",
};
people.add_active_user(cordelia);
people.add_active_user({
- full_name: 'Leo',
+ full_name: "Leo",
user_id: 102,
- email: '[email protected]',
+ email: "[email protected]",
});
people.add_active_user({
- full_name: 'Bobby <h1>Tables</h1>',
+ full_name: "Bobby <h1>Tables</h1>",
user_id: 103,
- email: '[email protected]',
+ email: "[email protected]",
});
people.add_active_user({
- full_name: 'Mark Twin',
+ full_name: "Mark Twin",
user_id: 104,
- email: '[email protected]',
+ email: "[email protected]",
});
people.add_active_user({
- full_name: 'Mark Twin',
+ full_name: "Mark Twin",
user_id: 105,
- email: '[email protected]',
+ email: "[email protected]",
});
people.add_active_user({
- full_name: 'Brother of Bobby|123',
+ full_name: "Brother of Bobby|123",
user_id: 106,
- email: '[email protected]',
+ email: "[email protected]",
});
people.add_active_user({
@@ -136,37 +136,37 @@ global.user_groups.add(amp_group);
const stream_data = global.stream_data;
const denmark = {
subscribed: false,
- color: 'blue',
- name: 'Denmark',
+ color: "blue",
+ name: "Denmark",
stream_id: 1,
is_muted: true,
};
const social = {
subscribed: true,
- color: 'red',
- name: 'social',
+ color: "red",
+ name: "social",
stream_id: 2,
is_muted: false,
invite_only: true,
};
const edgecase_stream = {
subscribed: true,
- color: 'green',
- name: 'Bobby <h1>Tables</h1>',
+ color: "green",
+ name: "Bobby <h1>Tables</h1>",
stream_id: 3,
is_muted: false,
};
const edgecase_stream_2 = {
subscribed: true,
- color: 'yellow',
- name: 'Bobby <h1',
+ color: "yellow",
+ name: "Bobby <h1",
stream_id: 4,
is_muted: false,
};
const amp_stream = {
subscribed: true,
- color: 'orange',
- name: '& & &amp;',
+ color: "orange",
+ name: "& & &amp;",
stream_id: 5,
is_muted: false,
};
@@ -180,8 +180,8 @@ stream_data.add_sub(amp_stream);
// Check the default behavior of fenced code blocks
// works properly before markdown is initialized.
-run_test('fenced_block_defaults', () => {
- const input = '\n```\nfenced code\n```\n\nand then after\n';
+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 output = fenced_code.process_fenced_code(input);
assert.equal(output, expected);
@@ -192,9 +192,9 @@ markdown.initialize(
markdown_config.get_helpers(),
);
-const markdown_data = global.read_fixture_data('markdown_test_cases.json');
+const markdown_data = global.read_fixture_data("markdown_test_cases.json");
-run_test('markdown_detection', () => {
+run_test("markdown_detection", () => {
const no_markup = [
"This is a plaintext message",
"This is a plaintext: message",
@@ -240,7 +240,7 @@ run_test('markdown_detection', () => {
});
});
-run_test('marked_shared', () => {
+run_test("marked_shared", () => {
const tests = markdown_data.regular_tests;
tests.forEach((test) => {
@@ -266,154 +266,154 @@ run_test('marked_shared', () => {
});
});
-run_test('message_flags', () => {
- let message = {raw_content: '@**Leo**'};
+run_test("message_flags", () => {
+ let message = {raw_content: "@**Leo**"};
markdown.apply_markdown(message);
assert(!message.mentioned);
assert(!message.mentioned_me_directly);
- message = {raw_content: '@**Cordelia Lear**'};
+ message = {raw_content: "@**Cordelia Lear**"};
markdown.apply_markdown(message);
assert(message.mentioned);
assert(message.mentioned_me_directly);
- message = {raw_content: '@**all**'};
+ message = {raw_content: "@**all**"};
markdown.apply_markdown(message);
assert(message.mentioned);
assert(!message.mentioned_me_directly);
});
-run_test('marked', () => {
+run_test("marked", () => {
const test_cases = [
- {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__', expected: '<p>__hello__</p>'},
- {input: '\n```\nfenced code\n```\n\nand then after\n',
+ {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__", 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',
+ {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',
+ {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',
+ {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',
+ {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',
+ {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',
+ {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',
+ {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**.',
+ {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',
+ {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',
+ {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**',
+ {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**',
+ {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',
+ {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',
+ {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**',
+ {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**',
+ {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.',
+ {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.',
+ {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**',
+ {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*',
+ {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*',
+ {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: "@*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: ':)',
+ {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>*',
+ {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;*',
+ {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>**',
+ {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;**',
+ {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>**',
+ {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;**',
+ {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;**',
+ {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
// cases (U+1F6B2), to verify that we display the emoji as it was input if it
// isn't present in emoji_codes.codepoint_to_name.
- delete emoji_codes.codepoint_to_name['1f6b2'];
+ delete emoji_codes.codepoint_to_name["1f6b2"];
test_cases.forEach((test_case) => {
// Disable emoji conversion by default.
@@ -429,44 +429,44 @@ run_test('marked', () => {
});
});
-run_test('topic_links', () => {
- let message = {type: 'stream', topic: "No links here"};
+run_test("topic_links", () => {
+ let message = {type: "stream", topic: "No links here"};
markdown.add_topic_links(message);
assert.equal(message.topic_links.length, 0);
- message = {type: 'stream', topic: "One #123 link here"};
+ message = {type: "stream", topic: "One #123 link here"};
markdown.add_topic_links(message);
assert.equal(message.topic_links.length, 1);
assert.equal(message.topic_links[0], "https://trac.example.com/ticket/123");
- message = {type: 'stream', topic: "Two #123 #456 link here"};
+ message = {type: "stream", topic: "Two #123 #456 link here"};
markdown.add_topic_links(message);
assert.equal(message.topic_links.length, 2);
assert.equal(message.topic_links[0], "https://trac.example.com/ticket/123");
assert.equal(message.topic_links[1], "https://trac.example.com/ticket/456");
- message = {type: 'stream', topic: "New ZBUG_123 link here"};
+ message = {type: "stream", topic: "New ZBUG_123 link here"};
markdown.add_topic_links(message);
assert.equal(message.topic_links.length, 1);
assert.equal(message.topic_links[0], "https://trac2.zulip.net/ticket/123");
- message = {type: 'stream', topic: "New ZBUG_123 with #456 link here"};
+ message = {type: "stream", topic: "New ZBUG_123 with #456 link here"};
markdown.add_topic_links(message);
assert.equal(message.topic_links.length, 2);
assert(message.topic_links.includes("https://trac2.zulip.net/ticket/123"));
assert(message.topic_links.includes("https://trac.example.com/ticket/456"));
- message = {type: 'stream', topic: "One ZGROUP_123:45 link here"};
+ message = {type: "stream", topic: "One ZGROUP_123:45 link here"};
markdown.add_topic_links(message);
assert.equal(message.topic_links.length, 1);
assert.equal(message.topic_links[0], "https://zone_45.zulip.net/ticket/123");
- message = {type: 'stream', topic: "Hello https://google.com"};
+ message = {type: "stream", topic: "Hello https://google.com"};
markdown.add_topic_links(message);
assert.equal(message.topic_links.length, 1);
assert.equal(message.topic_links[0], "https://google.com");
- message = {type: 'stream', topic: "#456 https://google.com https://github.com"};
+ message = {type: "stream", topic: "#456 https://google.com https://github.com"};
markdown.add_topic_links(message);
assert.equal(message.topic_links.length, 3);
assert(message.topic_links.includes("https://google.com"));
@@ -478,7 +478,7 @@ run_test('topic_links', () => {
assert.equal(message.topic_links.length, 0);
});
-run_test('message_flags', () => {
+run_test("message_flags", () => {
let input = "/me is testing this";
let message = {topic: "No links here", raw_content: input};
markdown.apply_markdown(message);
@@ -550,47 +550,47 @@ run_test('message_flags', () => {
assert.equal(message.mentioned, false);
});
-run_test('backend_only_realm_filters', () => {
+run_test("backend_only_realm_filters", () => {
const backend_only_realm_filters = [
- 'Here is the PR-#123.',
- 'Function abc() was introduced in (PR)#123.',
+ "Here is the PR-#123.",
+ "Function abc() was introduced in (PR)#123.",
];
backend_only_realm_filters.forEach((content) => {
assert.equal(markdown.contains_backend_only_syntax(content), true);
});
});
-run_test('python_to_js_filter', () => {
+run_test("python_to_js_filter", () => {
// The only way to reach python_to_js_filter is indirectly, hence the call
// to update_realm_filter_rules.
- markdown.update_realm_filter_rules([['/a(?im)a/g'], ['/a(?L)a/g']]);
+ markdown.update_realm_filter_rules([["/a(?im)a/g"], ["/a(?L)a/g"]]);
let actual_value = marked.InlineLexer.rules.zulip.realm_filters;
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');
- markdown.update_realm_filter_rules([['!@#@(!#&((!&(@#(', 'http://google.com']]);
+ 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 = [];
assert.deepEqual(actual_value, expected_value);
});
-run_test('katex_throws_unexpected_exceptions', () => {
- katex.renderToString = function () { throw new Error('some-exception'); };
- blueslip.expect('error', 'Error: some-exception');
- const message = { raw_content: '$$a$$' };
+run_test("katex_throws_unexpected_exceptions", () => {
+ katex.renderToString = function () { throw new Error("some-exception"); };
+ blueslip.expect("error", "Error: some-exception");
+ const message = { raw_content: "$$a$$" };
markdown.apply_markdown(message);
});
-run_test('translate_emoticons_to_names', () => {
+run_test("translate_emoticons_to_names", () => {
// Simple test
- const test_text = 'Testing :)';
- const expected = 'Testing :slight_smile:';
+ const test_text = "Testing :)";
+ const expected = "Testing :slight_smile:";
const result = markdown.translate_emoticons_to_names(test_text);
assert.equal(expected, result);
@@ -598,16 +598,16 @@ run_test('translate_emoticons_to_names', () => {
// The following code loops over the test cases and each emoticon conversion
// to generate multiple test cases.
const testcases = [
- {name: 'only emoticon', original: '<original>', expected: '<converted>'},
- {name: 'space at start', original: ' <original>', expected: ' <converted>'},
- {name: 'space at end', original: '<original> ', expected: '<converted> '},
- {name: 'symbol at end', original: '<original>!', expected: '<converted>!'},
- {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: "only emoticon", original: "<original>", expected: "<converted>"},
+ {name: "space at start", original: " <original>", expected: " <converted>"},
+ {name: "space at end", original: "<original> ", expected: "<converted> "},
+ {name: "symbol at end", original: "<original>!", expected: "<converted>!"},
+ {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>!"},
];
for (const [shortcut, full_name] of Object.entries(emoji_codes.emoticon_conversions)) {
for (const t of testcases) {
diff --git a/frontend_tests/node_tests/message_edit.js b/frontend_tests/node_tests/message_edit.js
index 83d975b0715..c2ab1c6f0d9 100644
--- a/frontend_tests/node_tests/message_edit.js
+++ b/frontend_tests/node_tests/message_edit.js
@@ -1,17 +1,17 @@
-set_global('document', null);
-set_global('page_params', {
+set_global("document", null);
+set_global("page_params", {
realm_community_topic_editing_limit_seconds: 86400,
});
global.stub_out_jquery();
-set_global('XDate', zrequire('XDate', 'xdate/src/xdate'));
-zrequire('message_edit');
+set_global("XDate", zrequire("XDate", "xdate/src/xdate"));
+zrequire("message_edit");
const get_editability = message_edit.get_editability;
const editability_types = message_edit.editability_types;
-run_test('get_editability', () => {
+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
@@ -62,16 +62,16 @@ run_test('get_editability', () => {
assert.equal(get_editability(message, 55), editability_types.FULL);
// It's been 60 > 45+10 since message.timestamp. When realm_allow_message_editing
// is true, we can edit the topic if there is one.
- message.type = 'stream';
+ message.type = "stream";
assert.equal(get_editability(message, 45), editability_types.TOPIC_ONLY);
- message.type = 'private';
+ message.type = "private";
assert.equal(get_editability(message, 45), editability_types.NO_LONGER);
// If we don't pass a second argument, treat it as 0
assert.equal(get_editability(message), editability_types.NO_LONGER);
message = {
sent_by_me: false,
- type: 'stream',
+ type: "stream",
};
global.page_params = {
realm_allow_community_topic_editing: true,
@@ -103,7 +103,7 @@ run_test('get_editability', () => {
assert.equal(message_edit.is_topic_editable(message), false);
});
-run_test('get_deletability', () => {
+run_test("get_deletability", () => {
global.page_params = {
is_admin: true,
realm_allow_message_deleting: false,
diff --git a/frontend_tests/node_tests/message_events.js b/frontend_tests/node_tests/message_events.js
index b9661041373..727e4a15f19 100644
--- a/frontend_tests/node_tests/message_events.js
+++ b/frontend_tests/node_tests/message_events.js
@@ -1,37 +1,37 @@
-zrequire('message_events');
-zrequire('message_store');
-zrequire('muting');
-zrequire('people');
-zrequire('recent_senders');
-zrequire('stream_data');
-zrequire('stream_topic_history');
-zrequire('unread');
-
-set_global('$', global.make_zjquery());
-set_global('alert_words', {});
-set_global('condense', {});
-set_global('current_msg_list', {});
-set_global('message_edit', {});
-set_global('message_list', {});
-set_global('notifications', {});
-set_global('page_params', {});
-set_global('pm_list', {});
-set_global('stream_list', {});
-set_global('unread_ui', {});
+zrequire("message_events");
+zrequire("message_store");
+zrequire("muting");
+zrequire("people");
+zrequire("recent_senders");
+zrequire("stream_data");
+zrequire("stream_topic_history");
+zrequire("unread");
+
+set_global("$", global.make_zjquery());
+set_global("alert_words", {});
+set_global("condense", {});
+set_global("current_msg_list", {});
+set_global("message_edit", {});
+set_global("message_list", {});
+set_global("notifications", {});
+set_global("page_params", {});
+set_global("pm_list", {});
+set_global("stream_list", {});
+set_global("unread_ui", {});
alert_words.process_message = () => {};
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 32,
- full_name: 'Alice Patel',
+ full_name: "Alice Patel",
};
people.add_active_user(alice);
const denmark = {
subscribed: false,
- name: 'Denmark',
+ name: "Denmark",
stream_id: 101,
};
stream_data.add_sub(denmark);
@@ -40,7 +40,7 @@ function test_helper(side_effects) {
const events = [];
for (const side_effect of side_effects) {
- const parts = side_effect.split('.');
+ const parts = side_effect.split(".");
const module = parts[0];
const field = parts[1];
@@ -58,15 +58,15 @@ function test_helper(side_effects) {
return self;
}
-run_test('update_messages', () => {
+run_test("update_messages", () => {
const original_message = {
id: 111,
display_recipient: denmark.name,
- flags: ['mentioned'],
+ flags: ["mentioned"],
sender_id: alice.user_id,
stream_id: denmark.stream_id,
- topic: 'lunch',
- type: 'stream',
+ topic: "lunch",
+ type: "stream",
};
message_store.add_message_metadata(original_message);
@@ -77,7 +77,7 @@ run_test('update_messages', () => {
assert.deepEqual(
stream_topic_history.get_recent_topic_names(denmark.stream_id),
- ['lunch'],
+ ["lunch"],
);
unread.update_message_for_mention(original_message);
@@ -87,15 +87,15 @@ run_test('update_messages', () => {
{
message_id: original_message.id,
flags: [],
- orig_content: 'old stuff',
- content: '**new content**',
- rendered_content: '<b>new content</b>',
+ orig_content: "old stuff",
+ content: "**new content**",
+ rendered_content: "<b>new content</b>",
},
];
current_msg_list.get_row = (message_id) => {
assert.equal(message_id, 111);
- return ['row-stub'];
+ return ["row-stub"];
};
current_msg_list.view = {};
@@ -107,18 +107,18 @@ run_test('update_messages', () => {
};
const side_effects = [
- 'condense.un_cache_message_content_height',
- 'message_edit.end_message_row_edit',
- 'notifications.received_messages',
- 'unread_ui.update_unread_counts',
- 'stream_list.update_streams_sidebar',
- 'pm_list.update_private_messages',
+ "condense.un_cache_message_content_height",
+ "message_edit.end_message_row_edit",
+ "notifications.received_messages",
+ "unread_ui.update_unread_counts",
+ "stream_list.update_streams_sidebar",
+ "pm_list.update_private_messages",
];
const helper = test_helper(side_effects);
page_params.realm_allow_edit_history = false;
- message_list.narrowed = 'stub-to-ignore';
+ message_list.narrowed = "stub-to-ignore";
// TEST THIS:
message_events.update_messages(events);
@@ -131,7 +131,7 @@ run_test('update_messages', () => {
{
alerted: false,
collapsed: false,
- content: '<b>new content</b>',
+ content: "<b>new content</b>",
display_recipient: denmark.name,
historical: false,
id: 111,
@@ -139,7 +139,7 @@ run_test('update_messages', () => {
last_edit_timestamp: undefined,
mentioned: false,
mentioned_me_directly: false,
- raw_content: '**new content**',
+ raw_content: "**new content**",
reactions: [],
reply_to: alice.email,
sender_email: alice.email,
@@ -149,8 +149,8 @@ run_test('update_messages', () => {
starred: false,
stream: denmark.name,
stream_id: denmark.stream_id,
- topic: 'lunch',
- type: 'stream',
+ topic: "lunch",
+ type: "stream",
unread: true,
},
]);
diff --git a/frontend_tests/node_tests/message_fetch.js b/frontend_tests/node_tests/message_fetch.js
index f76cfb80948..5654871da77 100644
--- a/frontend_tests/node_tests/message_fetch.js
+++ b/frontend_tests/node_tests/message_fetch.js
@@ -1,52 +1,52 @@
-set_global('$', global.make_zjquery());
-set_global('document', 'document-stub');
+set_global("$", global.make_zjquery());
+set_global("document", "document-stub");
-zrequire('message_fetch');
+zrequire("message_fetch");
const noop = () => {};
function MessageListView() {
return {};
}
-set_global('MessageListView', MessageListView);
+set_global("MessageListView", MessageListView);
-zrequire('FetchStatus', 'js/fetch_status');
-zrequire('Filter', 'js/filter');
-zrequire('MessageListData', 'js/message_list_data');
-zrequire('message_list');
-zrequire('people');
+zrequire("FetchStatus", "js/fetch_status");
+zrequire("Filter", "js/filter");
+zrequire("MessageListData", "js/message_list_data");
+zrequire("message_list");
+zrequire("people");
-set_global('recent_topics', {
+set_global("recent_topics", {
process_messages: noop,
});
// Still required for page_params.initial_pointer
-set_global('page_params', {});
-set_global('ui_report', {
+set_global("page_params", {});
+set_global("ui_report", {
hide_error: noop,
});
-set_global('channel', {});
-set_global('document', 'document-stub');
-set_global('message_scroll', {
+set_global("channel", {});
+set_global("document", "document-stub");
+set_global("message_scroll", {
show_loading_older: noop,
hide_loading_older: noop,
show_loading_newer: noop,
hide_loading_newer: noop,
update_top_of_narrow_notices: () => {},
});
-set_global('message_util', {});
-set_global('message_store', {});
-set_global('narrow_state', {});
-set_global('pm_list', {});
-set_global('server_events', {});
-set_global('stream_list', {
+set_global("message_util", {});
+set_global("message_store", {});
+set_global("narrow_state", {});
+set_global("pm_list", {});
+set_global("server_events", {});
+set_global("stream_list", {
maybe_scroll_narrow_into_view: () => {},
});
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 7,
- full_name: 'Alice',
+ full_name: "Alice",
};
people.add_active_user(alice);
@@ -59,7 +59,7 @@ function stub_message_view(list) {
}
function make_home_msg_list() {
- const table_name = 'whatever';
+ const table_name = "whatever";
const filter = new Filter();
const list = new message_list.MessageList({
@@ -74,8 +74,8 @@ function make_all_list() {
}
function reset_lists() {
- set_global('home_msg_list', make_home_msg_list());
- set_global('current_msg_list', home_msg_list);
+ set_global("home_msg_list", make_home_msg_list());
+ set_global("current_msg_list", home_msg_list);
message_list.all = make_all_list();
stub_message_view(home_msg_list);
stub_message_view(message_list.all);
@@ -92,7 +92,7 @@ function config_fake_channel(conf) {
if (!conf.can_call_again) {
assert(self.success === undefined);
}
- assert.equal(opts.url, '/json/messages');
+ assert.equal(opts.url, "/json/messages");
assert.deepEqual(opts.data, conf.expected_opts_data);
self.success = opts.success;
called = true;
@@ -141,7 +141,7 @@ function message_range(start, end) {
const initialize_data = {
initial_fetch: {
req: {
- anchor: 'first_unread',
+ anchor: "first_unread",
num_before: 200,
num_after: 200,
client_gravatar: true,
@@ -155,7 +155,7 @@ const initialize_data = {
forward_fill: {
req: {
- anchor: '800',
+ anchor: "800",
num_before: 0,
num_after: 1000,
client_gravatar: true,
@@ -168,7 +168,7 @@ const initialize_data = {
back_fill: {
req: {
- anchor: '201',
+ anchor: "201",
num_before: 1000,
num_after: 0,
client_gravatar: true,
@@ -228,7 +228,7 @@ function forward_fill_step() {
const response = initialize_data.forward_fill.resp;
let idle_config;
- $('document-stub').idle = function (config) {
+ $("document-stub").idle = function (config) {
idle_config = config;
};
@@ -260,7 +260,7 @@ function test_backfill_idle(idle_config) {
});
}
-run_test('initialize', () => {
+run_test("initialize", () => {
reset_lists();
const step1 = initial_fetch_step();
@@ -284,19 +284,19 @@ function simulate_narrow() {
narrow_state.active = function () { return true; };
narrow_state.public_operators = function () {
- return [{ operator: 'pm-with', operand: alice.email }];
+ return [{ operator: "pm-with", operand: alice.email }];
};
const msg_list = new message_list.MessageList({
- table_name: 'zfilt',
+ table_name: "zfilt",
filter: filter,
});
- set_global('current_msg_list', msg_list);
+ set_global("current_msg_list", msg_list);
return msg_list;
}
-run_test('loading_newer', () => {
+run_test("loading_newer", () => {
function test_dup_new_fetch(msg_list) {
assert.equal(msg_list.data.fetch_status.can_load_newer_messages(), false);
message_fetch.maybe_load_newer_messages({
@@ -350,7 +350,7 @@ run_test('loading_newer', () => {
const data = {
req: {
- anchor: '444',
+ anchor: "444",
num_before: 0,
num_after: 100,
narrow: `[{"operator":"pm-with","operand":[${alice.user_id}]}]`,
@@ -407,7 +407,7 @@ run_test('loading_newer', () => {
const data = [
{
req: {
- anchor: '444',
+ anchor: "444",
num_before: 0,
num_after: 100,
client_gravatar: true,
@@ -419,7 +419,7 @@ run_test('loading_newer', () => {
},
{
req: {
- anchor: '599',
+ anchor: "599",
num_before: 0,
num_after: 100,
client_gravatar: true,
diff --git a/frontend_tests/node_tests/message_flags.js b/frontend_tests/node_tests/message_flags.js
index 57a85803118..09b5c4f9d0f 100644
--- a/frontend_tests/node_tests/message_flags.js
+++ b/frontend_tests/node_tests/message_flags.js
@@ -1,19 +1,19 @@
-zrequire('unread');
-zrequire('unread_ops');
-zrequire('message_flags');
+zrequire("unread");
+zrequire("unread_ops");
+zrequire("message_flags");
-set_global('ui', {});
-set_global('channel', {});
-set_global('starred_messages', {
+set_global("ui", {});
+set_global("channel", {});
+set_global("starred_messages", {
add: () => {},
remove: () => {},
});
-run_test('starred', () => {
+run_test("starred", () => {
const message = {
id: 50,
};
- set_global('current_msg_list', {
+ set_global("current_msg_list", {
all_messages: () => [message],
is_search: () => false,
});
@@ -26,7 +26,7 @@ run_test('starred', () => {
let posted_data;
channel.post = (opts) => {
- assert.equal(opts.url, '/json/messages/flags');
+ assert.equal(opts.url, "/json/messages/flags");
posted_data = opts.data;
};
@@ -35,9 +35,9 @@ run_test('starred', () => {
assert(ui_updated);
assert.deepEqual(posted_data, {
- messages: '[50]',
- flag: 'starred',
- op: 'add',
+ messages: "[50]",
+ flag: "starred",
+ op: "add",
});
assert.deepEqual(message, {
@@ -52,9 +52,9 @@ run_test('starred', () => {
assert(ui_updated);
assert.deepEqual(posted_data, {
- messages: '[50]',
- flag: 'starred',
- op: 'remove',
+ messages: "[50]",
+ flag: "starred",
+ op: "remove",
});
assert.deepEqual(message, {
@@ -62,7 +62,7 @@ run_test('starred', () => {
starred: false,
});
});
-run_test('read', () => {
+run_test("read", () => {
// Way to capture posted info in every request
let channel_post_opts;
channel.post = (opts) => {
@@ -82,12 +82,12 @@ run_test('read', () => {
];
message_flags.send_read(msgs_to_flag_read);
assert.deepEqual(channel_post_opts, {
- url: '/json/messages/flags',
+ url: "/json/messages/flags",
idempotent: true,
data: {
- messages: '[1,2,3,4,5]',
- op: 'add',
- flag: 'read',
+ messages: "[1,2,3,4,5]",
+ op: "add",
+ flag: "read",
},
success: channel_post_opts.success,
});
@@ -98,12 +98,12 @@ run_test('read', () => {
};
channel_post_opts.success(success_response_data);
assert.deepEqual(channel_post_opts, {
- url: '/json/messages/flags',
+ url: "/json/messages/flags",
idempotent: true,
data: {
- messages: '[6,7]',
- op: 'add',
- flag: 'read',
+ messages: "[6,7]",
+ op: "add",
+ flag: "read",
},
success: channel_post_opts.success,
});
@@ -126,12 +126,12 @@ run_test('read', () => {
];
message_flags.send_read(msgs_to_flag_read);
assert.deepEqual(channel_post_opts, {
- url: '/json/messages/flags',
+ url: "/json/messages/flags",
idempotent: true,
data: {
- messages: '[3,4,5,6,7]',
- op: 'add',
- flag: 'read',
+ messages: "[3,4,5,6,7]",
+ op: "add",
+ flag: "read",
},
success: channel_post_opts.success,
});
@@ -148,12 +148,12 @@ run_test('read', () => {
// Former locally echoed messages flagging retried
assert.deepEqual(channel_post_opts, {
- url: '/json/messages/flags',
+ url: "/json/messages/flags",
idempotent: true,
data: {
- messages: '[1,2]',
- op: 'add',
- flag: 'read',
+ messages: "[1,2]",
+ op: "add",
+ flag: "read",
},
success: channel_post_opts.success,
});
diff --git a/frontend_tests/node_tests/message_list.js b/frontend_tests/node_tests/message_list.js
index c628daca640..c136eea1650 100644
--- a/frontend_tests/node_tests/message_list.js
+++ b/frontend_tests/node_tests/message_list.js
@@ -4,16 +4,16 @@
const noop = function () {};
-set_global('Filter', noop);
+set_global("Filter", noop);
global.stub_out_jquery();
-set_global('document', null);
-set_global('current_msg_list', {});
+set_global("document", null);
+set_global("current_msg_list", {});
-zrequire('FetchStatus', 'js/fetch_status');
-zrequire('muting');
-zrequire('MessageListData', 'js/message_list_data');
-zrequire('MessageListView', 'js/message_list_view');
-const MessageList = zrequire('message_list').MessageList;
+zrequire("FetchStatus", "js/fetch_status");
+zrequire("muting");
+zrequire("MessageListData", "js/message_list_data");
+zrequire("MessageListView", "js/message_list_view");
+const MessageList = zrequire("message_list").MessageList;
const with_overrides = global.with_overrides; // make lint happy
@@ -25,7 +25,7 @@ function accept_all_filter() {
return filter;
}
-run_test('basics', () => {
+run_test("basics", () => {
const filter = accept_all_filter();
const list = new MessageList({
@@ -35,7 +35,7 @@ run_test('basics', () => {
const messages = [
{
id: 50,
- content: 'fifty',
+ content: "fifty",
},
{
id: 60,
@@ -57,7 +57,7 @@ run_test('basics', () => {
assert.equal(list.first().id, 50);
assert.equal(list.last().id, 80);
- assert.equal(list.get(50).content, 'fifty');
+ assert.equal(list.get(50).content, "fifty");
assert.equal(list.closest_id(49), 50);
assert.equal(list.closest_id(50), 50);
@@ -69,7 +69,7 @@ run_test('basics', () => {
assert.deepEqual(list.all_messages(), messages);
global.$.Event = function (ev) {
- assert.equal(ev, 'message_selected.zulip');
+ assert.equal(ev, "message_selected.zulip");
};
list.select_id(50);
@@ -119,7 +119,7 @@ run_test('basics', () => {
assert.deepEqual(list.all_messages(), []);
});
-run_test('prev_next', () => {
+run_test("prev_next", () => {
const list = new MessageList({});
assert.equal(list.prev(), undefined);
@@ -158,7 +158,7 @@ run_test('prev_next', () => {
assert.equal(list.is_at_end(), true);
});
-run_test('message_range', () => {
+run_test("message_range", () => {
const list = new MessageList({});
const messages = [{id: 30}, {id: 40}, {id: 50}, {id: 60}];
@@ -168,11 +168,11 @@ run_test('message_range', () => {
assert.deepEqual(list.message_range(30, 40), [{id: 30}, {id: 40}]);
assert.deepEqual(list.message_range(31, 39), [{id: 40}]);
assert.deepEqual(list.message_range(31, 1000), [{id: 40}, {id: 50}, {id: 60}]);
- blueslip.expect('error', 'message_range given a start of -1');
+ blueslip.expect("error", "message_range given a start of -1");
assert.deepEqual(list.message_range(-1, 40), [{id: 30}, {id: 40}]);
});
-run_test('updates', () => {
+run_test("updates", () => {
const list = new MessageList({});
list.view.rerender_preserving_scrolltop = noop;
@@ -209,7 +209,7 @@ run_test('updates', () => {
assert.equal(list.get(1).stream, "denmark");
});
-run_test('nth_most_recent_id', () => {
+run_test("nth_most_recent_id", () => {
const list = new MessageList({});
list.append([{id: 10}, {id: 20}, {id: 30}]);
assert.equal(list.nth_most_recent_id(1), 30);
@@ -218,7 +218,7 @@ run_test('nth_most_recent_id', () => {
assert.equal(list.nth_most_recent_id(4), -1);
});
-run_test('change_message_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!"}]);
@@ -236,7 +236,7 @@ run_test('change_message_id', () => {
assert.equal(list.change_message_id(13, 15), undefined);
});
-run_test('last_sent_by_me', () => {
+run_test("last_sent_by_me", () => {
const list = new MessageList({});
const items = [
{
@@ -259,7 +259,7 @@ run_test('last_sent_by_me', () => {
assert.equal(list.get_last_message_sent_by_me().id, 2);
});
-run_test('local_echo', () => {
+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}]);
@@ -308,7 +308,7 @@ run_test('local_echo', () => {
assert.equal(list.closest_id(50.01), 50.01);
});
-run_test('bookend', () => {
+run_test("bookend", () => {
const list = new MessageList({});
with_overrides((override) => {
@@ -323,7 +323,7 @@ run_test('bookend', () => {
global.with_stub((stub) => {
list.view.render_trailing_bookend = stub.f;
list.update_trailing_bookend();
- const bookend = stub.get_args('content', 'subscribed', 'show_button');
+ const bookend = stub.get_args("content", "subscribed", "show_button");
assert.equal(bookend.content, expected);
assert.equal(bookend.subscribed, true);
assert.equal(bookend.show_button, true);
@@ -338,7 +338,7 @@ run_test('bookend', () => {
global.with_stub((stub) => {
list.view.render_trailing_bookend = stub.f;
list.update_trailing_bookend();
- const bookend = stub.get_args('content', 'subscribed', 'show_button');
+ const bookend = stub.get_args("content", "subscribed", "show_button");
assert.equal(bookend.content, expected);
assert.equal(bookend.subscribed, false);
assert.equal(bookend.show_button, true);
@@ -353,7 +353,7 @@ run_test('bookend', () => {
global.with_stub((stub) => {
list.view.render_trailing_bookend = stub.f;
list.update_trailing_bookend();
- const bookend = stub.get_args('content', 'subscribed', 'show_button');
+ const bookend = stub.get_args("content", "subscribed", "show_button");
assert.equal(bookend.content, expected);
assert.equal(bookend.subscribed, false);
assert.equal(bookend.show_button, false);
@@ -365,7 +365,7 @@ run_test('bookend', () => {
global.with_stub((stub) => {
list.view.render_trailing_bookend = stub.f;
list.update_trailing_bookend();
- const bookend = stub.get_args('content', 'subscribed', 'show_button');
+ const bookend = stub.get_args("content", "subscribed", "show_button");
assert.equal(bookend.content, expected);
assert.equal(bookend.subscribed, false);
assert.equal(bookend.show_button, true);
@@ -373,7 +373,7 @@ run_test('bookend', () => {
});
});
-run_test('unmuted_messages', () => {
+run_test("unmuted_messages", () => {
const list = new MessageList({});
const muted_stream_id = 999;
@@ -383,13 +383,13 @@ run_test('unmuted_messages', () => {
id: 50,
stream_id: muted_stream_id,
mentioned: true, // overrides mute
- topic: 'whatever',
+ topic: "whatever",
},
{
id: 60,
stream_id: 42,
mentioned: false,
- topic: 'whatever',
+ topic: "whatever",
},
];
const muted = [
@@ -397,12 +397,12 @@ run_test('unmuted_messages', () => {
id: 70,
stream_id: muted_stream_id,
mentioned: false,
- topic: 'whatever',
+ topic: "whatever",
},
];
with_overrides((override) => {
- override('muting.is_topic_muted', (stream_id) => stream_id === muted_stream_id);
+ override("muting.is_topic_muted", (stream_id) => stream_id === muted_stream_id);
// Make sure unmuted_message filters out the "muted" entry,
// which we mark as having a muted topic, and not mentioned.
@@ -411,7 +411,7 @@ run_test('unmuted_messages', () => {
});
});
-run_test('add_remove_rerender', () => {
+run_test("add_remove_rerender", () => {
const filter = accept_all_filter();
const list = new MessageList({filter: filter});
diff --git a/frontend_tests/node_tests/message_list_data.js b/frontend_tests/node_tests/message_list_data.js
index 201f9525bf6..9936a19e08c 100644
--- a/frontend_tests/node_tests/message_list_data.js
+++ b/frontend_tests/node_tests/message_list_data.js
@@ -1,13 +1,13 @@
-zrequire('unread');
+zrequire("unread");
-zrequire('Filter', 'js/filter');
-zrequire('FetchStatus', 'js/fetch_status');
-zrequire('MessageListData', 'js/message_list_data');
+zrequire("Filter", "js/filter");
+zrequire("FetchStatus", "js/fetch_status");
+zrequire("MessageListData", "js/message_list_data");
-set_global('page_params', {});
-set_global('muting', {});
+set_global("page_params", {});
+set_global("muting", {});
-global.patch_builtin('setTimeout', (f, delay) => {
+global.patch_builtin("setTimeout", (f, delay) => {
assert.equal(delay, 0);
return f();
});
@@ -16,7 +16,7 @@ function make_msg(msg_id) {
return {
id: msg_id,
unread: true,
- topic: 'whatever',
+ topic: "whatever",
};
}
@@ -29,7 +29,7 @@ function assert_contents(mld, msg_ids) {
assert.deepEqual(msgs, make_msgs(msg_ids));
}
-run_test('basics', () => {
+run_test("basics", () => {
const mld = new MessageListData({
muting_enabled: false,
filter: undefined,
@@ -98,7 +98,7 @@ run_test('basics', () => {
assert.equal(mld.first_unread_message_id(), 145);
});
-run_test('muting enabled', () => {
+run_test("muting enabled", () => {
const mld = new MessageListData({
muting_enabled: true,
filter: undefined,
@@ -126,9 +126,9 @@ run_test('muting enabled', () => {
assert.deepEqual(mld._all_items, []);
});
-run_test('more muting', () => {
+run_test("more muting", () => {
muting.is_topic_muted = function (stream_id, topic) {
- return topic === 'muted';
+ return topic === "muted";
};
const mld = new MessageListData({
@@ -137,10 +137,10 @@ run_test('more muting', () => {
});
const orig_messages = [
- {id: 3, topic: 'muted'},
- {id: 4, topic: 'whatever'},
- {id: 7, topic: 'muted'},
- {id: 8, topic: 'whatever'},
+ {id: 3, topic: "muted"},
+ {id: 4, topic: "whatever"},
+ {id: 7, topic: "muted"},
+ {id: 8, topic: "whatever"},
];
const orig_info = mld.add_messages(orig_messages);
@@ -149,8 +149,8 @@ run_test('more muting', () => {
top_messages: [],
interior_messages: [],
bottom_messages: [
- {id: 4, topic: 'whatever'},
- {id: 8, topic: 'whatever'},
+ {id: 4, topic: "whatever"},
+ {id: 8, topic: "whatever"},
],
});
@@ -165,13 +165,13 @@ run_test('more muting', () => {
);
const more_messages = [
- {id: 1, topic: 'muted'},
- {id: 2, topic: 'whatever'},
- {id: 3, topic: 'muted'}, // dup
- {id: 5, topic: 'muted'},
- {id: 6, topic: 'whatever'},
- {id: 9, topic: 'muted'},
- {id: 10, topic: 'whatever'},
+ {id: 1, topic: "muted"},
+ {id: 2, topic: "whatever"},
+ {id: 3, topic: "muted"}, // dup
+ {id: 5, topic: "muted"},
+ {id: 6, topic: "whatever"},
+ {id: 9, topic: "muted"},
+ {id: 10, topic: "whatever"},
];
const more_info = mld.add_messages(more_messages);
@@ -188,30 +188,30 @@ run_test('more muting', () => {
assert.deepEqual(more_info, {
top_messages: [
- {id: 2, topic: 'whatever'},
+ {id: 2, topic: "whatever"},
],
interior_messages: [
- {id: 6, topic: 'whatever'},
+ {id: 6, topic: "whatever"},
],
bottom_messages: [
- {id: 10, topic: 'whatever'},
+ {id: 10, topic: "whatever"},
],
});
});
-run_test('errors', () => {
+run_test("errors", () => {
const mld = new MessageListData({
muting_enabled: false,
filter: undefined,
});
- assert.equal(mld.get('bogus-id'), undefined);
+ assert.equal(mld.get("bogus-id"), undefined);
assert.throws(() => {
- mld._add_to_hash(['asdf']);
- }, {message: 'Bad message id'});
+ mld._add_to_hash(["asdf"]);
+ }, {message: "Bad message id"});
- blueslip.expect('error', 'Duplicate message added to MessageListData');
- mld._hash.set(1, 'taken');
+ blueslip.expect("error", "Duplicate message added to MessageListData");
+ mld._hash.set(1, "taken");
mld._add_to_hash(make_msgs([1]));
});
diff --git a/frontend_tests/node_tests/message_list_view.js b/frontend_tests/node_tests/message_list_view.js
index 6c6eb34fbda..36f23e4310a 100644
--- a/frontend_tests/node_tests/message_list_view.js
+++ b/frontend_tests/node_tests/message_list_view.js
@@ -1,38 +1,38 @@
-set_global('$', global.make_zjquery());
-set_global('document', 'document-stub');
+set_global("$", global.make_zjquery());
+set_global("document", "document-stub");
-set_global('XDate', zrequire('XDate', 'xdate/src/xdate'));
-zrequire('Filter', 'js/filter');
-zrequire('FetchStatus', 'js/fetch_status');
-zrequire('MessageListData', 'js/message_list_data');
-zrequire('MessageListView', 'js/message_list_view');
-zrequire('message_list');
+set_global("XDate", zrequire("XDate", "xdate/src/xdate"));
+zrequire("Filter", "js/filter");
+zrequire("FetchStatus", "js/fetch_status");
+zrequire("MessageListData", "js/message_list_data");
+zrequire("MessageListView", "js/message_list_view");
+zrequire("message_list");
const noop = function () {};
-set_global('page_params', {
+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('unread', {message_unread: function () {}});
+set_global("home_msg_list", null);
+set_global("people", {small_avatar_url: function () { return ""; }});
+set_global("unread", {message_unread: function () {}});
// timerender calls setInterval when imported
-set_global('timerender', {
+set_global("timerender", {
render_date: function (time1, time2) {
if (time2 === undefined) {
return [{outerHTML: String(time1.getTime())}];
}
- return [{outerHTML: String(time1.getTime()) + ' - ' + String(time2.getTime())}];
+ return [{outerHTML: String(time1.getTime()) + " - " + String(time2.getTime())}];
},
stringify_time: function (time) {
if (page_params.twenty_four_hour_time) {
- return time.toString('HH:mm');
+ return time.toString("HH:mm");
}
- return time.toString('h:mm TT');
+ return time.toString("h:mm TT");
},
});
-set_global('rows', {
+set_global("rows", {
get_table: function () {
return {
children: function () {
@@ -46,7 +46,7 @@ set_global('rows', {
let next_timestamp = 1500000000;
-run_test('msg_edited_vars', () => {
+run_test("msg_edited_vars", () => {
// This is a test to verify that only one of the three bools,
// `edited_in_left_col`, `edited_alongside_sender`, `edited_status_msg`
// is not false; Tests for three different kinds of messages:
@@ -123,7 +123,7 @@ run_test('msg_edited_vars', () => {
}());
});
-run_test('merge_message_groups', () => {
+run_test("merge_message_groups", () => {
// MessageListView has lots of DOM code, so we are going to test the message
// group mearging logic on its own.
@@ -139,12 +139,12 @@ run_test('merge_message_groups', () => {
...message_context,
};
message_context.msg = {
- id: _.uniqueId('test_message_'),
+ id: _.uniqueId("test_message_"),
status_message: false,
- type: 'stream',
- stream: 'Test Stream 1',
- topic: 'Test Subject 1',
- sender_email: '[email protected]',
+ type: "stream",
+ stream: "Test Stream 1",
+ topic: "Test Subject 1",
+ sender_email: "[email protected]",
timestamp: next_timestamp += 1,
...message,
};
@@ -154,7 +154,7 @@ run_test('merge_message_groups', () => {
function build_message_group(messages) {
return {
message_containers: messages,
- message_group_id: _.uniqueId('test_message_group_'),
+ message_group_id: _.uniqueId("test_message_group_"),
};
}
@@ -196,7 +196,7 @@ run_test('merge_message_groups', () => {
build_message_context(),
]);
- const result = list.merge_message_groups([message_group], 'bottom');
+ const result = list.merge_message_groups([message_group], "bottom");
assert_message_groups_list_equal(list._message_groups, [message_group]);
assert_message_groups_list_equal(result.append_groups, [message_group]);
@@ -219,7 +219,7 @@ run_test('merge_message_groups', () => {
]);
const list = build_list([message_group1]);
- const result = list.merge_message_groups([message_group2], 'bottom');
+ const result = list.merge_message_groups([message_group2], "bottom");
assert_message_groups_list_equal(
list._message_groups,
@@ -238,13 +238,13 @@ run_test('merge_message_groups', () => {
message1,
]);
- const message2 = build_message_context({topic: 'Test subject 2'});
+ const message2 = build_message_context({topic: "Test subject 2"});
const message_group2 = build_message_group([
message2,
]);
const list = build_list([message_group1]);
- const result = list.merge_message_groups([message_group2], 'bottom');
+ const result = list.merge_message_groups([message_group2], "bottom");
assert(!message_group2.group_date_divider_html);
assert_message_groups_list_equal(
@@ -264,14 +264,14 @@ run_test('merge_message_groups', () => {
message1,
]);
- const message2 = build_message_context({topic: 'Test subject 2',
+ 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');
+ const result = list.merge_message_groups([message_group2], "bottom");
assert_message_groups_list_equal(
list._message_groups,
@@ -283,7 +283,7 @@ run_test('merge_message_groups', () => {
assert.deepEqual(result.rerender_messages_next_same_sender, []);
assert.equal(
message_group2.group_date_divider_html,
- '900000000 - 1000000');
+ "900000000 - 1000000");
}());
(function test_append_message_different_day() {
@@ -299,7 +299,7 @@ run_test('merge_message_groups', () => {
]);
const list = build_list([message_group1]);
- const result = list.merge_message_groups([message_group2], 'bottom');
+ const result = list.merge_message_groups([message_group2], "bottom");
assert_message_groups_list_equal(list._message_groups, [message_group1]);
assert.deepEqual(result.append_groups, []);
@@ -323,7 +323,7 @@ run_test('merge_message_groups', () => {
]);
const list = build_list([message_group1]);
- const result = list.merge_message_groups([message_group2], 'bottom');
+ const result = list.merge_message_groups([message_group2], "bottom");
assert(message_group2.bookend_top);
assert_message_groups_list_equal(
@@ -349,7 +349,7 @@ run_test('merge_message_groups', () => {
]);
const list = build_list([message_group1]);
- const result = list.merge_message_groups([message_group2], 'bottom');
+ const result = list.merge_message_groups([message_group2], "bottom");
assert(message2.include_sender);
assert_message_groups_list_equal(
@@ -375,7 +375,7 @@ run_test('merge_message_groups', () => {
]);
const list = build_list([message_group1]);
- const result = list.merge_message_groups([message_group2], 'top');
+ const result = list.merge_message_groups([message_group2], "top");
assert_message_groups_list_equal(
list._message_groups,
@@ -395,13 +395,13 @@ run_test('merge_message_groups', () => {
message1,
]);
- const message2 = build_message_context({topic: 'Test Subject 2'});
+ const message2 = build_message_context({topic: "Test Subject 2"});
const message_group2 = build_message_group([
message2,
]);
const list = build_list([message_group1]);
- const result = list.merge_message_groups([message_group2], 'top');
+ const result = list.merge_message_groups([message_group2], "top");
assert_message_groups_list_equal(
list._message_groups,
@@ -420,19 +420,19 @@ run_test('merge_message_groups', () => {
message1,
]);
- const message2 = build_message_context({topic: 'Test Subject 2',
+ 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');
+ 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');
+ "900000000 - 1000000");
assert_message_groups_list_equal(
list._message_groups,
[message_group2, message_group1]);
@@ -456,12 +456,12 @@ run_test('merge_message_groups', () => {
]);
const list = build_list([message_group1]);
- const result = list.merge_message_groups([message_group2], 'top');
+ 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');
+ "900000000 - 1000000");
assert_message_groups_list_equal(
list._message_groups,
[message_group2]);
@@ -485,7 +485,7 @@ run_test('merge_message_groups', () => {
]);
const list = build_list([message_group1]);
- const result = list.merge_message_groups([message_group2], 'top');
+ const result = list.merge_message_groups([message_group2], "top");
assert(message_group1.bookend_top);
assert_message_groups_list_equal(
@@ -504,14 +504,14 @@ run_test('merge_message_groups', () => {
// where new messages added via local echo have a different date from
// the older messages.
-run_test('render_windows', () => {
+run_test("render_windows", () => {
// We only render up to 400 messages at a time in our message list,
// and we only change the window (which is a range, really, with
// start/end) when the pointer moves outside of the window or close
// to the edges.
const view = (function make_view() {
- const table_name = 'zfilt';
+ const table_name = "zfilt";
const filter = new Filter();
const list = new message_list.MessageList({
diff --git a/frontend_tests/node_tests/message_store.js b/frontend_tests/node_tests/message_store.js
index a0763d2f347..586f5f3497c 100644
--- a/frontend_tests/node_tests/message_store.js
+++ b/frontend_tests/node_tests/message_store.js
@@ -1,58 +1,58 @@
-const util = zrequire('util');
-zrequire('pm_conversations');
-zrequire('people');
-zrequire('message_store');
+const util = zrequire("util");
+zrequire("pm_conversations");
+zrequire("people");
+zrequire("message_store");
const noop = function () {};
-set_global('$', global.make_zjquery());
-set_global('document', 'document-stub');
+set_global("$", global.make_zjquery());
+set_global("document", "document-stub");
-set_global('alert_words', {
+set_global("alert_words", {
process_message: noop,
});
-set_global('stream_topic_history', {
+set_global("stream_topic_history", {
add_message: noop,
});
-set_global('recent_senders', {
+set_global("recent_senders", {
process_message_for_senders: noop,
});
-set_global('page_params', {
+set_global("page_params", {
realm_allow_message_editing: true,
is_admin: true,
});
const me = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 101,
- full_name: 'Me Myself',
+ full_name: "Me Myself",
};
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 102,
- full_name: 'Alice',
+ full_name: "Alice",
};
const bob = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 103,
- full_name: 'Bob',
+ full_name: "Bob",
};
const cindy = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 104,
- full_name: 'Cindy',
+ full_name: "Cindy",
};
const denise = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 105,
- full_name: 'Denise ',
+ full_name: "Denise ",
};
people.add_active_user(me);
@@ -72,13 +72,13 @@ function convert_recipients(people) {
}));
}
-run_test('add_message_metadata', () => {
+run_test("add_message_metadata", () => {
let message = {
- sender_email: '[email protected]',
+ sender_email: "[email protected]",
sender_id: me.user_id,
- type: 'private',
+ type: "private",
display_recipient: convert_recipients([me, bob, cindy]),
- flags: ['has_alert_word'],
+ flags: ["has_alert_word"],
is_me_message: false,
id: 2067,
};
@@ -90,17 +90,17 @@ run_test('add_message_metadata', () => {
[me.user_id, bob.user_id, cindy.user_id]);
assert.equal(message.is_private, true);
- assert.equal(message.reply_to, '[email protected],[email protected]');
- assert.equal(message.to_user_ids, '103,104');
- assert.equal(message.display_reply_to, 'Bob, Cindy');
+ assert.equal(message.reply_to, "[email protected],[email protected]");
+ assert.equal(message.to_user_ids, "103,104");
+ assert.equal(message.display_reply_to, "Bob, Cindy");
assert.equal(message.alerted, true);
assert.equal(message.is_me_message, false);
let retrieved_message = message_store.get(2067);
assert.equal(retrieved_message, message);
- blueslip.expect('error', 'message_store got non-number: 2067');
- retrieved_message = message_store.get('2067');
+ blueslip.expect("error", "message_store got non-number: 2067");
+ retrieved_message = message_store.get("2067");
assert.equal(retrieved_message, message);
// access cached previous message, and test match subject/content
@@ -111,26 +111,26 @@ run_test('add_message_metadata', () => {
};
message = message_store.add_message_metadata(message);
- assert.equal(message.reply_to, '[email protected],[email protected]');
- assert.equal(message.to_user_ids, '103,104');
- assert.equal(message.display_reply_to, 'Bob, Cindy');
- assert.equal(util.get_match_topic(message), 'topic foo');
- assert.equal(message.match_content, 'bar content');
+ assert.equal(message.reply_to, "[email protected],[email protected]");
+ assert.equal(message.to_user_ids, "103,104");
+ assert.equal(message.display_reply_to, "Bob, Cindy");
+ assert.equal(util.get_match_topic(message), "topic foo");
+ assert.equal(message.match_content, "bar content");
message = {
sender_email: denise.email,
sender_id: denise.user_id,
- type: 'stream',
- display_recipient: 'Zoolippy',
- topic: 'cool thing',
- subject: 'the_subject',
+ type: "stream",
+ display_recipient: "Zoolippy",
+ topic: "cool thing",
+ subject: "the_subject",
id: 2068,
};
message_store.set_message_booleans(message);
message_store.add_message_metadata(message);
assert.deepEqual(message.stream, message.display_recipient);
- assert.equal(message.reply_to, '[email protected]');
+ assert.equal(message.reply_to, "[email protected]");
assert.deepEqual(message.flags, undefined);
assert.equal(message.alerted, false);
@@ -139,38 +139,38 @@ run_test('add_message_metadata', () => {
[me.user_id, bob.user_id, cindy.user_id, denise.user_id]);
});
-run_test('message_booleans_parity', () => {
+run_test("message_booleans_parity", () => {
// We have two code paths that update/set message booleans.
// This test asserts that both have identical behavior for the
// flags common between them.
const assert_bool_match = (flags, expected_message) => {
- const set_message = {topic: 'set_message_booleans', flags: flags};
- const update_message = {topic: 'update_booleans'};
+ const set_message = {topic: "set_message_booleans", flags: flags};
+ const update_message = {topic: "update_booleans"};
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(update_message[key], expected_message[key]);
});
- assert.equal(set_message.topic, 'set_message_booleans');
- assert.equal(update_message.topic, 'update_booleans');
+ assert.equal(set_message.topic, "set_message_booleans");
+ assert.equal(update_message.topic, "update_booleans");
};
- assert_bool_match(['wildcard_mentioned'],
+ assert_bool_match(["wildcard_mentioned"],
{
mentioned: true,
mentioned_me_directly: false,
alerted: false,
});
- assert_bool_match(['mentioned'],
+ assert_bool_match(["mentioned"],
{
mentioned: true,
mentioned_me_directly: true,
alerted: false,
});
- assert_bool_match(['has_alert_word'],
+ assert_bool_match(["has_alert_word"],
{
mentioned: false,
mentioned_me_directly: false,
@@ -178,32 +178,32 @@ run_test('message_booleans_parity', () => {
});
});
-run_test('errors', () => {
+run_test("errors", () => {
// Test a user that doesn't exist
let message = {
- type: 'private',
+ type: "private",
display_recipient: [{id: 92714}],
};
- blueslip.expect('error', 'Unknown user_id in get_by_user_id: 92714', 2);
- blueslip.expect('error', 'Unknown user id 92714', 2); // From person.js
+ blueslip.expect("error", "Unknown user_id in get_by_user_id: 92714", 2);
+ blueslip.expect("error", "Unknown user id 92714", 2); // From person.js
// Expect each to throw two blueslip errors
// One from message_store.js, one from person.js
const emails = message_store.get_pm_emails(message);
- assert.equal(emails, '?');
+ assert.equal(emails, "?");
const names = message_store.get_pm_full_names(message);
- assert.equal(names, '?');
+ assert.equal(names, "?");
message = {
- type: 'stream',
+ type: "stream",
display_recipient: [{}],
};
// This should early return and not run pm_conversation.set_partner
let num_partner = 0;
- set_global('pm_conversation', {
+ set_global("pm_conversation", {
set_partner: function () {
num_partner += 1;
},
@@ -212,7 +212,7 @@ run_test('errors', () => {
assert.equal(num_partner, 0);
});
-run_test('update_booleans', () => {
+run_test("update_booleans", () => {
const message = {};
// First, test fields that we do actually want to update.
@@ -220,18 +220,18 @@ run_test('update_booleans', () => {
message.mentioned_me_directly = false;
message.alerted = false;
- let flags = ['mentioned', 'has_alert_word', 'read'];
+ let flags = ["mentioned", "has_alert_word", "read"];
message_store.update_booleans(message, flags);
assert.equal(message.mentioned, true);
assert.equal(message.mentioned_me_directly, true);
assert.equal(message.alerted, true);
- flags = ['wildcard_mentioned', 'unread'];
+ flags = ["wildcard_mentioned", "unread"];
message_store.update_booleans(message, flags);
assert.equal(message.mentioned, true);
assert.equal(message.mentioned_me_directly, false);
- flags = ['read'];
+ flags = ["read"];
message_store.update_booleans(message, flags);
assert.equal(message.mentioned, false);
assert.equal(message.mentioned_me_directly, false);
@@ -239,40 +239,40 @@ run_test('update_booleans', () => {
// Make sure we don't muck with unread.
message.unread = false;
- flags = [''];
+ flags = [""];
message_store.update_booleans(message, flags);
assert.equal(message.unread, false);
message.unread = true;
- flags = ['read'];
+ flags = ["read"];
message_store.update_booleans(message, flags);
assert.equal(message.unread, true);
});
-run_test('each', () => {
+run_test("each", () => {
message_store.each((message) => {
assert(message.alerted !== undefined);
});
});
-run_test('message_id_change', () => {
+run_test("message_id_change", () => {
const message = {
- sender_email: '[email protected]',
+ sender_email: "[email protected]",
sender_id: me.user_id,
- type: 'private',
+ type: "private",
display_recipient: convert_recipients([me, bob, cindy]),
- flags: ['has_alert_word'],
+ flags: ["has_alert_word"],
id: 401,
};
message_store.add_message_metadata(message);
- set_global('pointer', {
+ set_global("pointer", {
furthest_read: 401,
set_furthest_read: function (value) { this.furthest_read = value; },
});
- set_global('message_list', {});
- set_global('home_msg_list', {});
+ set_global("message_list", {});
+ set_global("home_msg_list", {});
const opts = {
old_id: 401,
@@ -282,7 +282,7 @@ run_test('message_id_change', () => {
global.with_stub((stub) => {
home_msg_list.change_message_id = stub.f;
message_store.reify_message_id(opts);
- const msg_id = stub.get_args('old', 'new');
+ const msg_id = stub.get_args("old", "new");
assert.equal(msg_id.old, 401);
assert.equal(msg_id.new, 402);
});
@@ -291,14 +291,14 @@ run_test('message_id_change', () => {
global.with_stub((stub) => {
home_msg_list.view.change_message_id = stub.f;
message_store.reify_message_id(opts);
- const msg_id = stub.get_args('old', 'new');
+ const msg_id = stub.get_args("old", "new");
assert.equal(msg_id.old, 401);
assert.equal(msg_id.new, 402);
});
});
-run_test('errors', () => {
- blueslip.expect('error', 'message_store.get got bad value: undefined');
+run_test("errors", () => {
+ blueslip.expect("error", "message_store.get got bad value: undefined");
message_store.get(undefined);
});
diff --git a/frontend_tests/node_tests/muting.js b/frontend_tests/node_tests/muting.js
index e12898e1956..fb5ba3c0a6d 100644
--- a/frontend_tests/node_tests/muting.js
+++ b/frontend_tests/node_tests/muting.js
@@ -1,38 +1,38 @@
-zrequire('timerender');
-zrequire('muting');
-zrequire('stream_data');
-set_global('XDate', zrequire('XDate', 'xdate'));
-set_global('page_params', {});
+zrequire("timerender");
+zrequire("muting");
+zrequire("stream_data");
+set_global("XDate", zrequire("XDate", "xdate"));
+set_global("page_params", {});
-run_test('edge_cases', () => {
+run_test("edge_cases", () => {
// private messages
assert(!muting.is_topic_muted(undefined, undefined));
});
const design = {
stream_id: 100,
- name: 'design',
+ name: "design",
};
const devel = {
stream_id: 101,
- name: 'devel',
+ name: "devel",
};
const office = {
stream_id: 102,
- name: 'office',
+ name: "office",
};
const social = {
stream_id: 103,
- name: 'social',
+ name: "social",
};
const unknown = {
stream_id: 999,
- name: 'whatever',
+ name: "whatever",
};
stream_data.add_sub(design);
@@ -40,53 +40,53 @@ stream_data.add_sub(devel);
stream_data.add_sub(office);
stream_data.add_sub(social);
-run_test('basics', () => {
- assert(!muting.is_topic_muted(devel.stream_id, 'java'));
- muting.add_muted_topic(devel.stream_id, 'java');
- assert(muting.is_topic_muted(devel.stream_id, 'java'));
+run_test("basics", () => {
+ assert(!muting.is_topic_muted(devel.stream_id, "java"));
+ muting.add_muted_topic(devel.stream_id, "java");
+ assert(muting.is_topic_muted(devel.stream_id, "java"));
// test idempotentcy
- muting.add_muted_topic(devel.stream_id, 'java');
- assert(muting.is_topic_muted(devel.stream_id, 'java'));
+ muting.add_muted_topic(devel.stream_id, "java");
+ assert(muting.is_topic_muted(devel.stream_id, "java"));
- muting.remove_muted_topic(devel.stream_id, 'java');
- assert(!muting.is_topic_muted(devel.stream_id, 'java'));
+ muting.remove_muted_topic(devel.stream_id, "java");
+ assert(!muting.is_topic_muted(devel.stream_id, "java"));
// test idempotentcy
- muting.remove_muted_topic(devel.stream_id, 'java');
- assert(!muting.is_topic_muted(devel.stream_id, 'java'));
+ muting.remove_muted_topic(devel.stream_id, "java");
+ assert(!muting.is_topic_muted(devel.stream_id, "java"));
// test unknown stream is harmless too
- muting.remove_muted_topic(unknown.stream_id, 'java');
- assert(!muting.is_topic_muted(unknown.stream_id, 'java'));
+ muting.remove_muted_topic(unknown.stream_id, "java");
+ assert(!muting.is_topic_muted(unknown.stream_id, "java"));
});
-run_test('get_and_set_muted_topics', () => {
+run_test("get_and_set_muted_topics", () => {
assert.deepEqual(muting.get_muted_topics(), []);
- muting.add_muted_topic(office.stream_id, 'gossip', 1577836800);
- muting.add_muted_topic(devel.stream_id, 'java', 1577836800);
+ muting.add_muted_topic(office.stream_id, "gossip", 1577836800);
+ muting.add_muted_topic(devel.stream_id, "java", 1577836800);
assert.deepEqual(muting.get_muted_topics().sort(), [
{
date_muted: 1577836800000,
- date_muted_str: 'Jan 01',
+ date_muted_str: "Jan 01",
stream: devel.name,
stream_id: devel.stream_id,
- topic: 'java',
+ topic: "java",
},
{
date_muted: 1577836800000,
- date_muted_str: 'Jan 01',
+ date_muted_str: "Jan 01",
stream: office.name,
stream_id: office.stream_id,
- topic: 'gossip',
+ topic: "gossip",
}]);
- blueslip.expect('warn', 'Unknown stream in set_muted_topics: BOGUS STREAM');
+ blueslip.expect("warn", "Unknown stream in set_muted_topics: BOGUS STREAM");
page_params.muted_topics = [
- ['social', 'breakfast', 1577836800],
- ['design', 'typography', 1577836800],
- ['BOGUS STREAM', 'whatever', 1577836800],
+ ["social", "breakfast", 1577836800],
+ ["design", "typography", 1577836800],
+ ["BOGUS STREAM", "whatever", 1577836800],
];
muting.initialize();
@@ -94,26 +94,26 @@ run_test('get_and_set_muted_topics', () => {
assert.deepEqual(muting.get_muted_topics().sort(), [
{
date_muted: 1577836800000,
- date_muted_str: 'Jan 01',
+ date_muted_str: "Jan 01",
stream: social.name,
stream_id: social.stream_id,
- topic: 'breakfast',
+ topic: "breakfast",
},
{
date_muted: 1577836800000,
- date_muted_str: 'Jan 01',
+ date_muted_str: "Jan 01",
stream: design.name,
stream_id: design.stream_id,
- topic: 'typography',
+ topic: "typography",
}]);
});
-run_test('case_insensitivity', () => {
+run_test("case_insensitivity", () => {
muting.set_muted_topics([]);
- assert(!muting.is_topic_muted(social.stream_id, 'breakfast'));
+ assert(!muting.is_topic_muted(social.stream_id, "breakfast"));
muting.set_muted_topics([
- ['SOCial', 'breakfast'],
+ ["SOCial", "breakfast"],
]);
- assert(muting.is_topic_muted(social.stream_id, 'breakfast'));
- assert(muting.is_topic_muted(social.stream_id, '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 805c470810f..6d96a16eb80 100644
--- a/frontend_tests/node_tests/narrow.js
+++ b/frontend_tests/node_tests/narrow.js
@@ -1,20 +1,20 @@
-set_global('$', global.make_zjquery());
-zrequire('hash_util');
-zrequire('hashchange');
-zrequire('narrow_state');
-zrequire('people');
-zrequire('stream_data');
-zrequire('Filter', 'js/filter');
-set_global('page_params', {
- stop_words: ['what', 'about'],
+set_global("$", global.make_zjquery());
+zrequire("hash_util");
+zrequire("hashchange");
+zrequire("narrow_state");
+zrequire("people");
+zrequire("stream_data");
+zrequire("Filter", "js/filter");
+set_global("page_params", {
+ stop_words: ["what", "about"],
});
-set_global('resize', {
+set_global("resize", {
resize_page_components: () => {},
resize_stream_filters_container: () => {},
});
-zrequire('narrow');
+zrequire("narrow");
function set_filter(operators) {
operators = operators.map((op) => ({
@@ -25,110 +25,110 @@ function set_filter(operators) {
}
const me = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 5,
- full_name: 'Me Myself',
+ full_name: "Me Myself",
};
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 23,
- full_name: 'Alice Smith',
+ full_name: "Alice Smith",
};
const ray = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 22,
- full_name: 'Raymond',
+ full_name: "Raymond",
};
-run_test('uris', () => {
+run_test("uris", () => {
people.add_active_user(ray);
people.add_active_user(alice);
people.add_active_user(me);
people.initialize_current_user(me.user_id);
let uri = hash_util.pm_with_uri(ray.email);
- assert.equal(uri, '#narrow/pm-with/22-ray');
+ assert.equal(uri, "#narrow/pm-with/22-ray");
uri = hash_util.huddle_with_uri("22,23");
- assert.equal(uri, '#narrow/pm-with/22,23-group');
+ assert.equal(uri, "#narrow/pm-with/22,23-group");
uri = hash_util.by_sender_uri(ray.email);
- assert.equal(uri, '#narrow/sender/22-ray');
+ assert.equal(uri, "#narrow/sender/22-ray");
- let emails = global.hash_util.decode_operand('pm-with', '22,23-group');
- assert.equal(emails, '[email protected],[email protected]');
+ let emails = global.hash_util.decode_operand("pm-with", "22,23-group");
+ assert.equal(emails, "[email protected],[email protected]");
- emails = global.hash_util.decode_operand('pm-with', '5,22,23-group');
- assert.equal(emails, '[email protected],[email protected]');
+ emails = global.hash_util.decode_operand("pm-with", "5,22,23-group");
+ assert.equal(emails, "[email protected],[email protected]");
- emails = global.hash_util.decode_operand('pm-with', '5-group');
- assert.equal(emails, '[email protected]');
+ emails = global.hash_util.decode_operand("pm-with", "5-group");
+ assert.equal(emails, "[email protected]");
});
-run_test('show_empty_narrow_message', () => {
+run_test("show_empty_narrow_message", () => {
narrow_state.reset_current_filter();
narrow.show_empty_narrow_message();
- assert.equal($('.empty_feed_notice').visible(), false);
- assert($('#empty_narrow_message').visible());
+ assert.equal($(".empty_feed_notice").visible(), false);
+ assert($("#empty_narrow_message").visible());
assert.equal(
- $('#left_bar_compose_reply_button_big').attr('title'),
- 'translated: There are no messages to reply to.',
+ $("#left_bar_compose_reply_button_big").attr("title"),
+ "translated: There are no messages to reply to.",
);
// for non-existent or private stream
- set_filter([['stream', 'Foo']]);
+ set_filter([["stream", "Foo"]]);
narrow.show_empty_narrow_message();
- assert($('#nonsubbed_private_nonexistent_stream_narrow_message').visible());
+ assert($("#nonsubbed_private_nonexistent_stream_narrow_message").visible());
// for non sub public stream
- stream_data.add_sub({name: 'ROME', stream_id: 99});
+ stream_data.add_sub({name: "ROME", stream_id: 99});
stream_data.update_calculated_fields(stream_data.get_sub("ROME"));
- set_filter([['stream', 'Rome']]);
+ set_filter([["stream", "Rome"]]);
narrow.show_empty_narrow_message();
- assert($('#nonsubbed_stream_narrow_message').visible());
+ assert($("#nonsubbed_stream_narrow_message").visible());
- set_filter([['is', 'starred']]);
+ set_filter([["is", "starred"]]);
narrow.show_empty_narrow_message();
- assert($('#empty_star_narrow_message').visible());
+ assert($("#empty_star_narrow_message").visible());
- set_filter([['is', 'mentioned']]);
+ set_filter([["is", "mentioned"]]);
narrow.show_empty_narrow_message();
- assert($('#empty_narrow_all_mentioned').visible());
+ assert($("#empty_narrow_all_mentioned").visible());
- set_filter([['is', 'private']]);
+ set_filter([["is", "private"]]);
narrow.show_empty_narrow_message();
- assert($('#empty_narrow_all_private_message').visible());
+ assert($("#empty_narrow_all_private_message").visible());
- set_filter([['is', 'unread']]);
+ set_filter([["is", "unread"]]);
narrow.show_empty_narrow_message();
- assert($('#no_unread_narrow_message').visible());
+ assert($("#no_unread_narrow_message").visible());
- set_filter([['pm-with', ['Yo']]]);
+ set_filter([["pm-with", ["Yo"]]]);
narrow.show_empty_narrow_message();
- assert($('#non_existing_user').visible());
+ assert($("#non_existing_user").visible());
people.add_active_user(alice);
- set_filter([['pm-with', ['[email protected]', 'Yo']]]);
+ set_filter([["pm-with", ["[email protected]", "Yo"]]]);
narrow.show_empty_narrow_message();
- assert($('#non_existing_users').visible());
+ assert($("#non_existing_users").visible());
- set_filter([['pm-with', '[email protected]']]);
+ set_filter([["pm-with", "[email protected]"]]);
narrow.show_empty_narrow_message();
- assert($('#empty_narrow_private_message').visible());
+ assert($("#empty_narrow_private_message").visible());
- set_filter([['group-pm-with', '[email protected]']]);
+ set_filter([["group-pm-with", "[email protected]"]]);
narrow.show_empty_narrow_message();
- assert($('#empty_narrow_group_private_message').visible());
+ assert($("#empty_narrow_group_private_message").visible());
- set_filter([['sender', '[email protected]']]);
+ set_filter([["sender", "[email protected]"]]);
narrow.show_empty_narrow_message();
- assert($('#silent_user').visible());
+ assert($("#silent_user").visible());
- set_filter([['sender', '[email protected]']]);
+ set_filter([["sender", "[email protected]"]]);
narrow.show_empty_narrow_message();
- assert($('#non_existing_user').visible());
+ assert($("#non_existing_user").visible());
const display = $("#empty_search_stop_words_string");
@@ -137,16 +137,16 @@ run_test('show_empty_narrow_message', () => {
items.push(html);
};
- set_filter([['search', 'grail']]);
+ set_filter([["search", "grail"]]);
narrow.show_empty_narrow_message();
- assert($('#empty_search_narrow_message').visible());
+ assert($("#empty_search_narrow_message").visible());
assert.equal(items.length, 2);
- assert.equal(items[0], ' ');
- assert.equal(items[1].text(), 'grail');
+ assert.equal(items[0], " ");
+ assert.equal(items[1].text(), "grail");
});
-run_test('show_search_stopwords', () => {
+run_test("show_search_stopwords", () => {
narrow_state.reset_current_filter();
let items = [];
@@ -158,67 +158,67 @@ run_test('show_search_stopwords', () => {
}
};
- set_filter([['search', 'what about grail']]);
+ set_filter([["search", "what about grail"]]);
narrow.show_empty_narrow_message();
- assert($('#empty_search_narrow_message').visible());
+ assert($("#empty_search_narrow_message").visible());
assert.equal(items.length, 3);
- assert.equal(items[0], '<del>what');
- assert.equal(items[1], '<del>about');
- assert.equal(items[2], '<span>grail');
+ assert.equal(items[0], "<del>what");
+ assert.equal(items[1], "<del>about");
+ 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());
+ assert($("#empty_search_narrow_message").visible());
assert.equal(items.length, 4);
- assert.equal(items[0], '<span>stream: streamA');
- assert.equal(items[1], '<del>what');
- assert.equal(items[2], '<del>about');
- assert.equal(items[3], '<span>grail');
+ assert.equal(items[0], "<span>stream: streamA");
+ assert.equal(items[1], "<del>what");
+ assert.equal(items[2], "<del>about");
+ 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());
+ assert($("#empty_search_narrow_message").visible());
assert.equal(items.length, 4);
- assert.equal(items[0], '<span>stream: streamA topic: topicA');
- assert.equal(items[1], '<del>what');
- assert.equal(items[2], '<del>about');
- assert.equal(items[3], '<span>grail');
+ assert.equal(items[0], "<span>stream: streamA topic: topicA");
+ assert.equal(items[1], "<del>what");
+ assert.equal(items[2], "<del>about");
+ assert.equal(items[3], "<span>grail");
});
-run_test('show_invalid_narrow_message', () => {
+run_test("show_invalid_narrow_message", () => {
narrow_state.reset_current_filter();
const display = $("#empty_search_stop_words_string");
- stream_data.add_sub({name: 'streamA', stream_id: 88});
- stream_data.add_sub({name: 'streamB', stream_id: 77});
+ 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($("#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.");
- 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($("#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.");
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($("#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.");
});
-run_test('narrow_to_compose_target', () => {
- set_global('compose_state', {});
- set_global('stream_topic_history', {});
+run_test("narrow_to_compose_target", () => {
+ set_global("compose_state", {});
+ set_global("stream_topic_history", {});
const args = {called: false};
const activate_backup = narrow.activate;
narrow.activate = function (operators, opts) {
@@ -234,45 +234,45 @@ run_test('narrow_to_compose_target', () => {
global.compose_state.composing = () => true;
// No-op when empty stream.
- global.compose_state.get_message_type = () => 'stream';
- global.compose_state.stream_name = () => '';
+ global.compose_state.get_message_type = () => "stream";
+ global.compose_state.stream_name = () => "";
args.called = false;
narrow.to_compose_target();
assert.equal(args.called, false);
// --- Tests for stream messages ---
- global.compose_state.get_message_type = () => 'stream';
- stream_data.add_sub({name: 'ROME', stream_id: 99});
- global.compose_state.stream_name = () => 'ROME';
- global.stream_topic_history.get_recent_topic_names = () => ['one', 'two', 'three'];
+ global.compose_state.get_message_type = () => "stream";
+ stream_data.add_sub({name: "ROME", stream_id: 99});
+ global.compose_state.stream_name = () => "ROME";
+ global.stream_topic_history.get_recent_topic_names = () => ["one", "two", "three"];
// Test with existing topic
- global.compose_state.topic = () => 'one';
+ global.compose_state.topic = () => "one";
args.called = false;
narrow.to_compose_target();
assert.equal(args.called, true);
- assert.equal(args.opts.trigger, 'narrow_to_compose_target');
+ assert.equal(args.opts.trigger, "narrow_to_compose_target");
assert.deepEqual(args.operators, [
- {operator: 'stream', operand: 'ROME'},
- {operator: 'topic', operand: 'one'},
+ {operator: "stream", operand: "ROME"},
+ {operator: "topic", operand: "one"},
]);
// Test with new topic
- global.compose_state.topic = () => 'four';
+ global.compose_state.topic = () => "four";
args.called = false;
narrow.to_compose_target();
assert.equal(args.called, true);
assert.deepEqual(args.operators, [
- {operator: 'stream', operand: 'ROME'},
+ {operator: "stream", operand: "ROME"},
]);
// Test with blank topic
- global.compose_state.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'},
+ {operator: "stream", operand: "ROME"},
]);
// Test with no topic
@@ -281,58 +281,58 @@ run_test('narrow_to_compose_target', () => {
narrow.to_compose_target();
assert.equal(args.called, true);
assert.deepEqual(args.operators, [
- {operator: 'stream', operand: 'ROME'},
+ {operator: "stream", operand: "ROME"},
]);
// --- Tests for PMs ---
- global.compose_state.get_message_type = () => 'private';
+ global.compose_state.get_message_type = () => "private";
people.add_active_user(ray);
people.add_active_user(alice);
people.add_active_user(me);
// Test with valid person
- global.compose_state.private_message_recipient = () => '[email protected]';
+ global.compose_state.private_message_recipient = () => "[email protected]";
args.called = false;
narrow.to_compose_target();
assert.equal(args.called, true);
assert.deepEqual(args.operators, [
- {operator: 'pm-with', operand: '[email protected]'},
+ {operator: "pm-with", operand: "[email protected]"},
]);
// Test with valid persons
- global.compose_state.private_message_recipient = () => '[email protected],[email protected]';
+ global.compose_state.private_message_recipient = () => "[email protected],[email protected]";
args.called = false;
narrow.to_compose_target();
assert.equal(args.called, true);
assert.deepEqual(args.operators, [
- {operator: 'pm-with', operand: '[email protected],[email protected]'},
+ {operator: "pm-with", operand: "[email protected],[email protected]"},
]);
// Test with some invalid persons
- global.compose_state.private_message_recipient = () => '[email protected],random,[email protected]';
+ global.compose_state.private_message_recipient = () => "[email protected],random,[email protected]";
args.called = false;
narrow.to_compose_target();
assert.equal(args.called, true);
assert.deepEqual(args.operators, [
- {operator: 'is', operand: 'private'},
+ {operator: "is", operand: "private"},
]);
// Test with all invalid persons
- global.compose_state.private_message_recipient = () => 'alice,random,ray';
+ 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'},
+ {operator: "is", operand: "private"},
]);
// Test with no persons
- global.compose_state.private_message_recipient = () => '';
+ 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'},
+ {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 b24ba59f35c..bd7f86e01cc 100644
--- a/frontend_tests/node_tests/narrow_activate.js
+++ b/frontend_tests/node_tests/narrow_activate.js
@@ -1,40 +1,40 @@
-const util = zrequire('util');
-set_global('$', global.make_zjquery());
+const util = zrequire("util");
+set_global("$", global.make_zjquery());
-zrequire('narrow_state');
-set_global('resize', {
+zrequire("narrow_state");
+set_global("resize", {
resize_stream_filters_container: () => {},
});
-zrequire('stream_data');
-zrequire('Filter', 'js/filter');
-zrequire('FetchStatus', 'js/fetch_status');
-zrequire('MessageListData', 'js/message_list_data');
-zrequire('unread');
-zrequire('narrow');
-zrequire('search_pill');
-
-set_global('channel', {});
-set_global('compose', {});
-set_global('compose_actions', {});
-set_global('current_msg_list', {});
-set_global('hashchange', {});
-set_global('home_msg_list', {});
-set_global('message_fetch', {});
-set_global('message_list', {
+zrequire("stream_data");
+zrequire("Filter", "js/filter");
+zrequire("FetchStatus", "js/fetch_status");
+zrequire("MessageListData", "js/message_list_data");
+zrequire("unread");
+zrequire("narrow");
+zrequire("search_pill");
+
+set_global("channel", {});
+set_global("compose", {});
+set_global("compose_actions", {});
+set_global("current_msg_list", {});
+set_global("hashchange", {});
+set_global("home_msg_list", {});
+set_global("message_fetch", {});
+set_global("message_list", {
set_narrowed: function (value) { this.narrowed = value; },
});
-set_global('message_scroll', {});
-set_global('message_util', {});
-set_global('notifications', {});
-set_global('page_params', {});
-set_global('search', {});
-set_global('stream_list', {});
-set_global('tab_bar', {});
-set_global('top_left_corner', {});
-set_global('typing_events', {});
-set_global('ui_util', {});
-set_global('unread_ops', {});
-set_global('search_pill_widget', {
+set_global("message_scroll", {});
+set_global("message_util", {});
+set_global("notifications", {});
+set_global("page_params", {});
+set_global("search", {});
+set_global("stream_list", {});
+set_global("tab_bar", {});
+set_global("top_left_corner", {});
+set_global("typing_events", {});
+set_global("ui_util", {});
+set_global("unread_ops", {});
+set_global("search_pill_widget", {
widget: {
clear: function () {return true;},
appendValue: function () {return true;},
@@ -44,19 +44,19 @@ set_global('search_pill_widget', {
//
// We have strange hacks in narrow.activate to sleep 0
// seconds.
-global.patch_builtin('setTimeout', (f, t) => {
+global.patch_builtin("setTimeout", (f, t) => {
assert.equal(t, 0);
f();
});
-set_global('muting', {
+set_global("muting", {
is_topic_muted: () => false,
});
const denmark = {
subscribed: false,
- color: 'blue',
- name: 'Denmark',
+ color: "blue",
+ name: "Denmark",
stream_id: 1,
is_muted: true,
};
@@ -67,26 +67,26 @@ function test_helper() {
function stub(module_name, func_name) {
global[module_name][func_name] = () => {
- events.push(module_name + '.' + func_name);
+ events.push(module_name + "." + func_name);
};
}
- stub('compose_actions', 'on_narrow');
- stub('hashchange', 'save_narrow');
- stub('message_scroll', 'hide_indicators');
- stub('message_scroll', 'show_loading_older');
- stub('message_scroll', 'hide_top_of_narrow_notices');
- stub('notifications', 'clear_compose_notifications');
- stub('notifications', 'redraw_title');
- stub('search', 'update_button_visibility');
- stub('stream_list', 'handle_narrow_activated');
- stub('tab_bar', 'initialize');
- stub('top_left_corner', 'handle_narrow_activated');
- stub('typing_events', 'render_notifications_for_narrow');
- stub('ui_util', 'change_tab_to');
- stub('unread_ops', 'process_visible');
- stub('compose', 'update_closed_compose_buttons_for_stream');
- stub('compose', 'update_closed_compose_buttons_for_private');
+ stub("compose_actions", "on_narrow");
+ stub("hashchange", "save_narrow");
+ stub("message_scroll", "hide_indicators");
+ stub("message_scroll", "show_loading_older");
+ stub("message_scroll", "hide_top_of_narrow_notices");
+ stub("notifications", "clear_compose_notifications");
+ stub("notifications", "redraw_title");
+ stub("search", "update_button_visibility");
+ stub("stream_list", "handle_narrow_activated");
+ stub("tab_bar", "initialize");
+ stub("top_left_corner", "handle_narrow_activated");
+ stub("typing_events", "render_notifications_for_narrow");
+ stub("ui_util", "change_tab_to");
+ stub("unread_ops", "process_visible");
+ stub("compose", "update_closed_compose_buttons_for_stream");
+ stub("compose", "update_closed_compose_buttons_for_private");
return {
clear: () => {
@@ -129,21 +129,21 @@ function stub_message_list() {
};
}
-run_test('basics', () => {
+run_test("basics", () => {
stub_message_list();
const helper = test_helper();
const terms = [
- { operator: 'stream', operand: 'Denmark' },
+ { operator: "stream", operand: "Denmark" },
];
const selected_id = 1000;
const selected_message = {
id: selected_id,
- type: 'stream',
+ type: "stream",
stream_id: denmark.stream_id,
- topic: 'whatever',
+ topic: "whatever",
};
const messages = [selected_message];
@@ -192,41 +192,41 @@ run_test('basics', () => {
assert.equal(narrow_state.narrowed_to_pms(), false);
helper.assert_events([
- 'notifications.clear_compose_notifications',
- 'notifications.redraw_title',
- 'message_scroll.hide_top_of_narrow_notices',
- 'message_scroll.hide_indicators',
- 'ui_util.change_tab_to',
- 'unread_ops.process_visible',
- 'hashchange.save_narrow',
- 'compose.update_closed_compose_buttons_for_stream',
- 'search.update_button_visibility',
- 'compose_actions.on_narrow',
- 'top_left_corner.handle_narrow_activated',
- 'stream_list.handle_narrow_activated',
- 'typing_events.render_notifications_for_narrow',
- 'tab_bar.initialize',
+ "notifications.clear_compose_notifications",
+ "notifications.redraw_title",
+ "message_scroll.hide_top_of_narrow_notices",
+ "message_scroll.hide_indicators",
+ "ui_util.change_tab_to",
+ "unread_ops.process_visible",
+ "hashchange.save_narrow",
+ "compose.update_closed_compose_buttons_for_stream",
+ "search.update_button_visibility",
+ "compose_actions.on_narrow",
+ "top_left_corner.handle_narrow_activated",
+ "stream_list.handle_narrow_activated",
+ "typing_events.render_notifications_for_narrow",
+ "tab_bar.initialize",
]);
current_msg_list.selected_id = () => -1;
current_msg_list.get_row = () => row;
util.sorted_ids = () => [];
- narrow.activate([{ operator: 'is', operand: 'private' }], {
+ narrow.activate([{ operator: "is", operand: "private" }], {
then_select_id: selected_id,
});
assert.equal(narrow_state.narrowed_to_pms(), true);
channel.post = (opts) => {
- assert.equal(opts.url, '/json/report/narrow_times');
- helper.push_event('report narrow times');
+ assert.equal(opts.url, "/json/report/narrow_times");
+ helper.push_event("report narrow times");
};
helper.clear();
cont();
helper.assert_events([
- 'report narrow times',
+ "report narrow times",
]);
});
diff --git a/frontend_tests/node_tests/narrow_local.js b/frontend_tests/node_tests/narrow_local.js
index c984d5cc76d..54d9ec8e391 100644
--- a/frontend_tests/node_tests/narrow_local.js
+++ b/frontend_tests/node_tests/narrow_local.js
@@ -1,13 +1,13 @@
-zrequire('Filter', 'js/filter');
-zrequire('FetchStatus', 'js/fetch_status');
-zrequire('MessageListData', 'js/message_list_data');
-zrequire('narrow_state');
-zrequire('narrow');
-zrequire('stream_data');
-
-set_global('message_list', {});
-set_global('muting', {
+zrequire("Filter", "js/filter");
+zrequire("FetchStatus", "js/fetch_status");
+zrequire("MessageListData", "js/message_list_data");
+zrequire("narrow_state");
+zrequire("narrow");
+zrequire("stream_data");
+
+set_global("message_list", {});
+set_global("muting", {
is_topic_muted: () => false,
});
@@ -18,7 +18,7 @@ function test_with(fixture) {
// Make sure our simulated tests data satisfies the
// invarariant that the first unread message we find
// does indeed satisfy our filter.
- if (fixture.unread_info.flavor === 'found') {
+ if (fixture.unread_info.flavor === "found") {
for (const msg of fixture.all_messages) {
if (msg.id === fixture.unread_info.msg_id) {
assert(filter.predicate()(msg));
@@ -72,23 +72,23 @@ function test_with(fixture) {
assert.deepEqual(msg_ids, fixture.expected_msg_ids);
}
-run_test('near after unreads', () => {
+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},
+ {operator: "near", operand: 42},
],
target_id: 42,
unread_info: {
- flavor: 'found',
+ flavor: "found",
msg_id: 37,
},
has_found_newest: false,
all_messages: [
- {id: 37, topic: 'whatever'},
- {id: 42, topic: 'whatever'},
- {id: 44, topic: 'whatever'},
+ {id: 37, topic: "whatever"},
+ {id: 42, topic: "whatever"},
+ {id: 44, topic: "whatever"},
],
expected_id_info: {
target_id: 42,
@@ -101,23 +101,23 @@ run_test('near after unreads', () => {
test_with(fixture);
});
-run_test('near not in message list', () => {
+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},
+ {operator: "near", operand: 42},
],
target_id: 42,
unread_info: {
- flavor: 'found',
+ flavor: "found",
msg_id: 46,
},
has_found_newest: false,
all_messages: [
- {id: 41, topic: 'whatever'},
- {id: 45, topic: 'whatever'},
- {id: 46, topic: 'whatever'},
+ {id: 41, topic: "whatever"},
+ {id: 45, topic: "whatever"},
+ {id: 46, topic: "whatever"},
],
expected_id_info: {
target_id: 42,
@@ -130,21 +130,21 @@ run_test('near not in message list', () => {
test_with(fixture);
});
-run_test('near before unreads', () => {
+run_test("near before unreads", () => {
const fixture = {
filter_terms: [
- {operator: 'near', operand: 42},
+ {operator: "near", operand: 42},
],
target_id: 42,
unread_info: {
- flavor: 'found',
+ flavor: "found",
msg_id: 43,
},
has_found_newest: false,
all_messages: [
- {id: 42, topic: 'whatever'},
- {id: 43, topic: 'whatever'},
- {id: 44, topic: 'whatever'},
+ {id: 42, topic: "whatever"},
+ {id: 43, topic: "whatever"},
+ {id: 44, topic: "whatever"},
],
expected_id_info: {
target_id: 42,
@@ -157,14 +157,14 @@ run_test('near before unreads', () => {
test_with(fixture);
});
-run_test('near with no unreads', () => {
+run_test("near with no unreads", () => {
const fixture = {
filter_terms: [
- {operator: 'near', operand: 42},
+ {operator: "near", operand: 42},
],
target_id: 42,
unread_info: {
- flavor: 'not_found',
+ flavor: "not_found",
},
has_found_newest: false,
empty: true,
@@ -179,20 +179,20 @@ run_test('near with no unreads', () => {
test_with(fixture);
});
-run_test('is private with no target', () => {
+run_test("is private with no target", () => {
const fixture = {
filter_terms: [
- {operator: 'is', operand: 'private'},
+ {operator: "is", operand: "private"},
],
unread_info: {
- flavor: 'found',
+ flavor: "found",
msg_id: 550,
},
has_found_newest: true,
all_messages: [
- {id: 450, type: 'private'},
- {id: 500, type: 'private'},
- {id: 550, type: 'private'},
+ {id: 450, type: "private"},
+ {id: 500, type: "private"},
+ {id: 550, type: "private"},
],
expected_id_info: {
target_id: undefined,
@@ -205,14 +205,14 @@ run_test('is private with no target', () => {
test_with(fixture);
});
-run_test('pm-with with target outside of range', () => {
+run_test("pm-with with target outside of range", () => {
const fixture = {
filter_terms: [
- {operator: 'pm-with', operand: '[email protected]'},
+ {operator: "pm-with", operand: "[email protected]"},
],
target_id: 5,
unread_info: {
- flavor: 'not_found',
+ flavor: "not_found",
},
has_found_newest: false,
all_messages: [
@@ -229,13 +229,13 @@ run_test('pm-with with target outside of range', () => {
test_with(fixture);
});
-run_test('is:private with no unreads before fetch', () => {
+run_test("is:private with no unreads before fetch", () => {
const fixture = {
filter_terms: [
- {operator: 'is', operand: 'private'},
+ {operator: "is", operand: "private"},
],
unread_info: {
- flavor: 'not_found',
+ flavor: "not_found",
},
has_found_newest: false,
empty: true,
@@ -250,22 +250,22 @@ run_test('is:private with no unreads before fetch', () => {
test_with(fixture);
});
-run_test('is:private with target and no unreads', () => {
+run_test("is:private with target and no unreads", () => {
const fixture = {
filter_terms: [
- {operator: 'is', operand: 'private'},
+ {operator: "is", operand: "private"},
],
target_id: 450,
unread_info: {
- flavor: 'not_found',
+ flavor: "not_found",
},
has_found_newest: true,
empty: false,
all_messages: [
{id: 350},
- {id: 400, type: 'private'},
- {id: 450, type: 'private'},
- {id: 500, type: 'private'},
+ {id: 400, type: "private"},
+ {id: 450, type: "private"},
+ {id: 500, type: "private"},
],
expected_id_info: {
target_id: 450,
@@ -278,13 +278,13 @@ run_test('is:private with target and no unreads', () => {
test_with(fixture);
});
-run_test('is:mentioned with no unreads and no matches', () => {
+run_test("is:mentioned with no unreads and no matches", () => {
const fixture = {
filter_terms: [
- {operator: 'is', operand: 'mentioned'},
+ {operator: "is", operand: "mentioned"},
],
unread_info: {
- flavor: 'not_found',
+ flavor: "not_found",
},
has_found_newest: true,
all_messages: [],
@@ -299,18 +299,18 @@ run_test('is:mentioned with no unreads and no matches', () => {
test_with(fixture);
});
-run_test('is:alerted with no unreads and one match', () => {
+run_test("is:alerted with no unreads and one match", () => {
const fixture = {
filter_terms: [
- {operator: 'is', operand: 'alerted'},
+ {operator: "is", operand: "alerted"},
],
unread_info: {
- flavor: 'not_found',
+ flavor: "not_found",
},
has_found_newest: true,
all_messages: [
- {id: 55, topic: 'whatever', alerted: true},
- {id: 57, topic: 'whatever', alerted: false},
+ {id: 55, topic: "whatever", alerted: true},
+ {id: 57, topic: "whatever", alerted: false},
],
expected_id_info: {
target_id: undefined,
@@ -323,13 +323,13 @@ run_test('is:alerted with no unreads and one match', () => {
test_with(fixture);
});
-run_test('search', () => {
+run_test("search", () => {
const fixture = {
filter_terms: [
- {operator: 'search', operand: 'whatever'},
+ {operator: "search", operand: "whatever"},
],
unread_info: {
- flavor: 'cannot_compute',
+ flavor: "cannot_compute",
},
expected_id_info: {
target_id: undefined,
@@ -342,15 +342,15 @@ run_test('search', () => {
test_with(fixture);
});
-run_test('search near', () => {
+run_test("search near", () => {
const fixture = {
filter_terms: [
- {operator: 'search', operand: 'whatever'},
- {operator: 'near', operand: 22},
+ {operator: "search", operand: "whatever"},
+ {operator: "near", operand: 22},
],
target_id: 22,
unread_info: {
- flavor: 'cannot_compute',
+ flavor: "cannot_compute",
},
expected_id_info: {
target_id: 22,
@@ -363,7 +363,7 @@ run_test('search near', () => {
test_with(fixture);
});
-run_test('stream, no unread, not in all_messages', () => {
+run_test("stream, no unread, not in all_messages", () => {
// This might be something you'd see zooming out from
// a muted topic, maybe? It's possibly this scenario
// is somewhat contrived, but we exercise fairly simple
@@ -372,11 +372,11 @@ run_test('stream, no unread, not in all_messages', () => {
// the range of all_messages.
const fixture = {
filter_terms: [
- {operator: 'stream', operand: 'whatever'},
+ {operator: "stream", operand: "whatever"},
],
target_id: 450,
unread_info: {
- flavor: 'not_found',
+ flavor: "not_found",
},
has_found_newest: true,
empty: false,
@@ -395,14 +395,14 @@ run_test('stream, no unread, not in all_messages', () => {
test_with(fixture);
});
-run_test('search, stream, not in all_messages', () => {
+run_test("search, stream, not in all_messages", () => {
const fixture = {
filter_terms: [
- {operator: 'search', operand: 'foo'},
- {operator: 'stream', operand: 'whatever'},
+ {operator: "search", operand: "foo"},
+ {operator: "stream", operand: "whatever"},
],
unread_info: {
- flavor: 'cannot_compute',
+ flavor: "cannot_compute",
},
has_found_newest: true,
empty: false,
@@ -421,19 +421,19 @@ run_test('search, stream, not in all_messages', () => {
test_with(fixture);
});
-run_test('stream/topic not in all_messages', () => {
+run_test("stream/topic not in all_messages", () => {
// This is a bit of a corner case, but you could have a scenario
// where you've gone way back in a topic (perhaps something that
// has been muted a long time) and find an unread message that isn't
// actually in message_list.all.
const fixture = {
filter_terms: [
- {operator: 'stream', operand: 'one'},
- {operator: 'topic', operand: 'whatever'},
+ {operator: "stream", operand: "one"},
+ {operator: "topic", operand: "whatever"},
],
target_id: 1000,
unread_info: {
- flavor: 'found',
+ flavor: "found",
msg_id: 2,
},
has_found_newest: true,
@@ -452,24 +452,24 @@ run_test('stream/topic not in all_messages', () => {
test_with(fixture);
});
-run_test('final corner case', () => {
+run_test("final corner case", () => {
// This tries to get all the way to the end of
// the function (as written now). The data here
// may be completely contrived.
const fixture = {
filter_terms: [
- {operator: 'is', operand: 'starred'},
+ {operator: "is", operand: "starred"},
],
target_id: 450,
unread_info: {
- flavor: 'not_found',
+ flavor: "not_found",
},
has_found_newest: true,
empty: false,
all_messages: [
- {id: 400, topic: 'whatever'},
- {id: 425, topic: 'whatever', starred: true},
- {id: 500, topic: 'whatever'},
+ {id: 400, topic: "whatever"},
+ {id: 425, topic: "whatever", starred: true},
+ {id: 500, topic: "whatever"},
],
expected_id_info: {
target_id: 450,
diff --git a/frontend_tests/node_tests/narrow_state.js b/frontend_tests/node_tests/narrow_state.js
index b34b6c4d461..155156d7a6e 100644
--- a/frontend_tests/node_tests/narrow_state.js
+++ b/frontend_tests/node_tests/narrow_state.js
@@ -1,10 +1,10 @@
-zrequire('people');
-zrequire('Filter', 'js/filter');
-zrequire('stream_data');
-zrequire('narrow_state');
+zrequire("people");
+zrequire("Filter", "js/filter");
+zrequire("stream_data");
+zrequire("narrow_state");
-set_global('page_params', {});
+set_global("page_params", {});
function set_filter(operators) {
operators = operators.map((op) => ({
@@ -14,39 +14,39 @@ function set_filter(operators) {
narrow_state.set_current_filter(new Filter(operators));
}
-run_test('stream', () => {
+run_test("stream", () => {
assert.equal(narrow_state.public_operators(), undefined);
assert(!narrow_state.active());
- const test_stream = {name: 'Test', stream_id: 15};
+ const test_stream = {name: "Test", stream_id: 15};
stream_data.add_sub(test_stream);
assert(!narrow_state.is_for_stream_id(test_stream.stream_id));
set_filter([
- ['stream', 'Test'],
- ['topic', 'Bar'],
- ['search', 'yo'],
+ ["stream", "Test"],
+ ["topic", "Bar"],
+ ["search", "yo"],
]);
assert(narrow_state.active());
- assert.equal(narrow_state.stream(), 'Test');
+ assert.equal(narrow_state.stream(), "Test");
assert.equal(narrow_state.stream_id(), test_stream.stream_id);
- assert.equal(narrow_state.topic(), 'Bar');
+ assert.equal(narrow_state.topic(), "Bar");
assert(narrow_state.is_for_stream_id(test_stream.stream_id));
const expected_operators = [
- { negated: false, operator: 'stream', operand: 'Test' },
- { negated: false, operator: 'topic', operand: 'Bar' },
- { negated: false, operator: 'search', operand: 'yo' },
+ { negated: false, operator: "stream", operand: "Test" },
+ { negated: false, operator: "topic", operand: "Bar" },
+ { negated: false, operator: "search", operand: "yo" },
];
const public_operators = narrow_state.public_operators();
assert.deepEqual(public_operators, expected_operators);
- assert.equal(narrow_state.search_string(), 'stream:Test topic:Bar yo');
+ assert.equal(narrow_state.search_string(), "stream:Test topic:Bar yo");
});
-run_test('narrowed', () => {
+run_test("narrowed", () => {
narrow_state.reset_current_filter(); // not narrowed, basically
assert(!narrow_state.narrowed_to_pms());
assert(!narrow_state.narrowed_by_reply());
@@ -58,7 +58,7 @@ run_test('narrowed', () => {
assert.equal(narrow_state.stream_id(), undefined);
assert(!narrow_state.narrowed_to_starred());
- set_filter([['stream', 'Foo']]);
+ set_filter([["stream", "Foo"]]);
assert(!narrow_state.narrowed_to_pms());
assert(!narrow_state.narrowed_by_reply());
assert(!narrow_state.narrowed_by_pm_reply());
@@ -68,7 +68,7 @@ run_test('narrowed', () => {
assert(narrow_state.narrowed_by_stream_reply());
assert(!narrow_state.narrowed_to_starred());
- set_filter([['pm-with', '[email protected]']]);
+ set_filter([["pm-with", "[email protected]"]]);
assert(narrow_state.narrowed_to_pms());
assert(narrow_state.narrowed_by_reply());
assert(narrow_state.narrowed_by_pm_reply());
@@ -78,7 +78,7 @@ 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());
@@ -88,7 +88,7 @@ run_test('narrowed', () => {
assert(!narrow_state.narrowed_by_stream_reply());
assert(!narrow_state.narrowed_to_starred());
- set_filter([['search', 'grail']]);
+ set_filter([["search", "grail"]]);
assert(!narrow_state.narrowed_to_pms());
assert(!narrow_state.narrowed_by_reply());
assert(!narrow_state.narrowed_by_pm_reply());
@@ -98,7 +98,7 @@ run_test('narrowed', () => {
assert(!narrow_state.narrowed_by_stream_reply());
assert(!narrow_state.narrowed_to_starred());
- set_filter([['is', 'starred']]);
+ set_filter([["is", "starred"]]);
assert(!narrow_state.narrowed_to_pms());
assert(!narrow_state.narrowed_by_reply());
assert(!narrow_state.narrowed_by_pm_reply());
@@ -109,110 +109,110 @@ run_test('narrowed', () => {
assert(narrow_state.narrowed_to_starred());
});
-run_test('operators', () => {
- set_filter([['stream', 'Foo'], ['topic', 'Bar'], ['search', 'Yo']]);
+run_test("operators", () => {
+ set_filter([["stream", "Foo"], ["topic", "Bar"], ["search", "Yo"]]);
let result = narrow_state.operators();
assert.equal(result.length, 3);
- assert.equal(result[0].operator, 'stream');
- assert.equal(result[0].operand, 'Foo');
+ assert.equal(result[0].operator, "stream");
+ assert.equal(result[0].operand, "Foo");
- assert.equal(result[1].operator, 'topic');
- assert.equal(result[1].operand, 'Bar');
+ assert.equal(result[1].operator, "topic");
+ assert.equal(result[1].operand, "Bar");
- assert.equal(result[2].operator, 'search');
- assert.equal(result[2].operand, 'yo');
+ assert.equal(result[2].operator, "search");
+ assert.equal(result[2].operand, "yo");
narrow_state.reset_current_filter();
result = narrow_state.operators();
assert.equal(result.length, 0);
});
-run_test('muting_enabled', () => {
- set_filter([['stream', 'devel']]);
+run_test("muting_enabled", () => {
+ set_filter([["stream", "devel"]]);
assert(narrow_state.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']]);
+ set_filter([["search", "whatever"]]);
assert(!narrow_state.muting_enabled());
- set_filter([['is', 'private']]);
+ set_filter([["is", "private"]]);
assert(!narrow_state.muting_enabled());
- set_filter([['is', 'starred']]);
+ set_filter([["is", "starred"]]);
assert(!narrow_state.muting_enabled());
});
-run_test('set_compose_defaults', () => {
- set_filter([['stream', 'Foo'], ['topic', 'Bar']]);
+run_test("set_compose_defaults", () => {
+ set_filter([["stream", "Foo"], ["topic", "Bar"]]);
const stream_and_subject = narrow_state.set_compose_defaults();
- assert.equal(stream_and_subject.stream, 'Foo');
- assert.equal(stream_and_subject.topic, 'Bar');
+ assert.equal(stream_and_subject.stream, "Foo");
+ assert.equal(stream_and_subject.topic, "Bar");
- set_filter([['pm-with', '[email protected]']]);
+ set_filter([["pm-with", "[email protected]"]]);
let pm_test = narrow_state.set_compose_defaults();
assert.equal(pm_test.private_message_recipient, undefined);
const john = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 57,
- full_name: 'John Doe',
+ full_name: "John Doe",
};
people.add_active_user(john);
people.add_active_user(john);
- set_filter([['pm-with', '[email protected]']]);
+ set_filter([["pm-with", "[email protected]"]]);
pm_test = narrow_state.set_compose_defaults();
- assert.equal(pm_test.private_message_recipient, '[email protected]');
+ 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});
- set_filter([['stream', 'rome']]);
+ stream_data.add_sub({name: "ROME", stream_id: 99});
+ set_filter([["stream", "rome"]]);
const stream_test = narrow_state.set_compose_defaults();
- assert.equal(stream_test.stream, 'ROME');
+ assert.equal(stream_test.stream, "ROME");
});
-run_test('update_email', () => {
+run_test("update_email", () => {
const steve = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 43,
- full_name: 'Steve',
+ full_name: "Steve",
};
people.add_active_user(steve);
set_filter([
- ['pm-with', '[email protected]'],
- ['sender', '[email protected]'],
- ['stream', '[email protected]'], // try to be tricky
+ ["pm-with", "[email protected]"],
+ ["sender", "[email protected]"],
+ ["stream", "[email protected]"], // try to be tricky
]);
- narrow_state.update_email(steve.user_id, '[email protected]');
+ narrow_state.update_email(steve.user_id, "[email protected]");
const filter = narrow_state.filter();
- assert.deepEqual(filter.operands('pm-with'), ['[email protected]']);
- assert.deepEqual(filter.operands('sender'), ['[email protected]']);
- assert.deepEqual(filter.operands('stream'), ['[email protected]']);
+ assert.deepEqual(filter.operands("pm-with"), ["[email protected]"]);
+ assert.deepEqual(filter.operands("sender"), ["[email protected]"]);
+ assert.deepEqual(filter.operands("stream"), ["[email protected]"]);
});
-run_test('topic', () => {
- set_filter([['stream', 'Foo'], ['topic', 'Bar']]);
- assert.equal(narrow_state.topic(), 'Bar');
+run_test("topic", () => {
+ set_filter([["stream", "Foo"], ["topic", "Bar"]]);
+ assert.equal(narrow_state.topic(), "Bar");
- set_filter([['stream', 'release'], ['topic', '@#$$^test']]);
- assert.equal(narrow_state.topic(), '@#$$^test');
+ set_filter([["stream", "release"], ["topic", "@#$$^test"]]);
+ assert.equal(narrow_state.topic(), "@#$$^test");
set_filter([]);
assert.equal(narrow_state.topic(), undefined);
set_filter([
- ['sender', '[email protected]'],
- ['pm-with', '[email protected]'],
+ ["sender", "[email protected]"],
+ ["pm-with", "[email protected]"],
]);
assert.equal(narrow_state.topic(), undefined);
@@ -220,56 +220,56 @@ run_test('topic', () => {
assert.equal(narrow_state.topic(), undefined);
});
-run_test('stream', () => {
+run_test("stream", () => {
set_filter([]);
assert.equal(narrow_state.stream(), undefined);
assert.equal(narrow_state.stream_id(), undefined);
- set_filter([['stream', 'Foo'], ['topic', 'Bar']]);
- assert.equal(narrow_state.stream(), 'Foo');
+ 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);
- const sub = {name: 'Foo', stream_id: 55};
+ const sub = {name: "Foo", stream_id: 55};
stream_data.add_sub(sub);
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);
});
-run_test('pm_string', () => {
+run_test("pm_string", () => {
// This function will return undefined unless we're clearly
// narrowed to a specific PM (including huddles) with real
// users.
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', '']]);
+ set_filter([["pm-with", ""]]);
assert.equal(narrow_state.pm_string(), undefined);
- set_filter([['pm-with', '[email protected]']]);
+ set_filter([["pm-with", "[email protected]"]]);
assert.equal(narrow_state.pm_string(), undefined);
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 444,
- full_name: 'Alice',
+ full_name: "Alice",
};
const bob = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 555,
- full_name: 'Bob',
+ full_name: "Bob",
};
people.add_active_user(alice);
people.add_active_user(bob);
- set_filter([['pm-with', '[email protected],[email protected]']]);
- assert.equal(narrow_state.pm_string(), '444,555');
+ set_filter([["pm-with", "[email protected],[email protected]"]]);
+ assert.equal(narrow_state.pm_string(), "444,555");
});
diff --git a/frontend_tests/node_tests/narrow_unread.js b/frontend_tests/node_tests/narrow_unread.js
index de886be7eae..e9e7939b478 100644
--- a/frontend_tests/node_tests/narrow_unread.js
+++ b/frontend_tests/node_tests/narrow_unread.js
@@ -1,23 +1,23 @@
-zrequire('Filter', 'js/filter');
-zrequire('people');
-zrequire('stream_data');
-zrequire('unread');
+zrequire("Filter", "js/filter");
+zrequire("people");
+zrequire("stream_data");
+zrequire("unread");
-set_global('message_store', {});
-set_global('page_params', {});
+set_global("message_store", {});
+set_global("page_params", {});
-set_global('muting', {
+set_global("muting", {
is_topic_muted: () => false,
});
// The main code we are testing lives here.
-zrequire('narrow_state');
+zrequire("narrow_state");
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 11,
- full_name: 'Alice',
+ full_name: "Alice",
};
people.init();
@@ -37,20 +37,20 @@ function candidate_ids() {
return narrow_state._possible_unread_message_ids();
}
-run_test('get_unread_ids', () => {
+run_test("get_unread_ids", () => {
let unread_ids;
let terms;
const sub = {
- name: 'My Stream',
+ name: "My Stream",
stream_id: 55,
};
const stream_msg = {
id: 101,
- type: 'stream',
+ type: "stream",
stream_id: sub.stream_id,
- topic: 'my topic',
+ topic: "my topic",
unread: true,
mentioned: true,
mentioned_me_directly: true,
@@ -58,7 +58,7 @@ run_test('get_unread_ids', () => {
const private_msg = {
id: 102,
- type: 'private',
+ type: "private",
unread: true,
display_recipient: [
{id: alice.user_id},
@@ -71,35 +71,35 @@ run_test('get_unread_ids', () => {
assert.equal(unread_ids, undefined);
terms = [
- {operator: 'search', operand: 'whatever'},
+ {operator: "search", operand: "whatever"},
];
set_filter(terms);
unread_ids = candidate_ids();
assert.equal(unread_ids, undefined);
- assert_unread_info({flavor: 'cannot_compute'});
+ assert_unread_info({flavor: "cannot_compute"});
terms = [
- {operator: 'bogus_operator', operand: '[email protected]'},
+ {operator: "bogus_operator", operand: "[email protected]"},
];
set_filter(terms);
unread_ids = candidate_ids();
assert.deepEqual(unread_ids, []);
- assert_unread_info({flavor: 'not_found'});
+ assert_unread_info({flavor: "not_found"});
terms = [
- {operator: 'stream', operand: 'bogus'},
+ {operator: "stream", operand: "bogus"},
];
set_filter(terms);
unread_ids = candidate_ids();
assert.deepEqual(unread_ids, []);
terms = [
- {operator: 'stream', operand: sub.name},
+ {operator: "stream", operand: sub.name},
];
set_filter(terms);
unread_ids = candidate_ids();
assert.deepEqual(unread_ids, []);
- assert_unread_info({flavor: 'not_found'});
+ assert_unread_info({flavor: "not_found"});
unread.process_loaded_messages([stream_msg]);
message_store.get = (msg_id) => {
@@ -110,35 +110,35 @@ run_test('get_unread_ids', () => {
unread_ids = candidate_ids();
assert.deepEqual(unread_ids, [stream_msg.id]);
assert_unread_info({
- flavor: 'found',
+ flavor: "found",
msg_id: stream_msg.id,
});
terms = [
- {operator: 'stream', operand: 'bogus'},
- {operator: 'topic', operand: 'my topic'},
+ {operator: "stream", operand: "bogus"},
+ {operator: "topic", operand: "my topic"},
];
set_filter(terms);
unread_ids = candidate_ids();
assert.deepEqual(unread_ids, []);
terms = [
- {operator: 'stream', operand: sub.name},
- {operator: 'topic', operand: 'my topic'},
+ {operator: "stream", operand: sub.name},
+ {operator: "topic", operand: "my topic"},
];
set_filter(terms);
unread_ids = candidate_ids();
assert.deepEqual(unread_ids, [stream_msg.id]);
terms = [
- {operator: 'is', operand: 'mentioned'},
+ {operator: "is", operand: "mentioned"},
];
set_filter(terms);
unread_ids = candidate_ids();
assert.deepEqual(unread_ids, [stream_msg.id]);
terms = [
- {operator: 'sender', operand: '[email protected]'},
+ {operator: "sender", operand: "[email protected]"},
];
set_filter(terms);
// note that our candidate ids are just "all" ids now
@@ -146,10 +146,10 @@ run_test('get_unread_ids', () => {
assert.deepEqual(unread_ids, [stream_msg.id]);
// this actually does filtering
- assert_unread_info({flavor: 'not_found'});
+ assert_unread_info({flavor: "not_found"});
terms = [
- {operator: 'pm-with', operand: '[email protected]'},
+ {operator: "pm-with", operand: "[email protected]"},
];
set_filter(terms);
unread_ids = candidate_ids();
@@ -166,12 +166,12 @@ run_test('get_unread_ids', () => {
assert.deepEqual(unread_ids, [private_msg.id]);
assert_unread_info({
- flavor: 'found',
+ flavor: "found",
msg_id: private_msg.id,
});
terms = [
- {operator: 'is', operand: 'private'},
+ {operator: "is", operand: "private"},
];
set_filter(terms);
unread_ids = candidate_ids();
@@ -180,14 +180,14 @@ run_test('get_unread_ids', () => {
// 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},
+ {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]'},
+ {operator: "pm-with", operand: "[email protected]"},
];
set_filter(terms);
@@ -195,39 +195,39 @@ run_test('get_unread_ids', () => {
assert.deepEqual(unread_ids, []);
terms = [
- {operator: 'is', operand: 'starred'},
+ {operator: "is", operand: "starred"},
];
set_filter(terms);
unread_ids = candidate_ids();
assert.deepEqual(unread_ids, []);
terms = [
- {operator: 'search', operand: 'needle'},
+ {operator: "search", operand: "needle"},
];
set_filter(terms);
assert_unread_info({
- flavor: 'cannot_compute',
+ flavor: "cannot_compute",
});
narrow_state.reset_current_filter();
- blueslip.expect('error', 'unexpected call to get_first_unread_info');
+ blueslip.expect("error", "unexpected call to get_first_unread_info");
assert_unread_info({
- flavor: 'cannot_compute',
+ flavor: "cannot_compute",
});
});
-run_test('defensive code', () => {
+run_test("defensive code", () => {
// Test defensive code. We actually avoid calling
// _possible_unread_message_ids for any case where we
// 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'},
+ {operator: "some-unhandled-case", operand: "whatever"},
];
set_filter(terms);
assert_unread_info({
- flavor: 'cannot_compute',
+ flavor: "cannot_compute",
});
});
diff --git a/frontend_tests/node_tests/notifications.js b/frontend_tests/node_tests/notifications.js
index 2801ec2ca64..d07799b8db8 100644
--- a/frontend_tests/node_tests/notifications.js
+++ b/frontend_tests/node_tests/notifications.js
@@ -1,13 +1,13 @@
// Dependencies
-set_global('$', global.make_zjquery({
+set_global("$", global.make_zjquery({
silent: true,
}));
-set_global('document', {
+set_global("document", {
hasFocus: function () {
return true;
},
});
-set_global('page_params', {
+set_global("page_params", {
is_admin: false,
realm_users: [],
enable_desktop_notifications: true,
@@ -15,24 +15,24 @@ set_global('page_params', {
wildcard_mentions_notify: true,
});
const _navigator = {
- userAgent: 'Mozilla/5.0 AppleWebKit/537.36 Chrome/64.0.3282.167 Safari/537.36',
+ userAgent: "Mozilla/5.0 AppleWebKit/537.36 Chrome/64.0.3282.167 Safari/537.36",
};
-set_global('navigator', _navigator);
-
-zrequire('alert_words');
-zrequire('muting');
-zrequire('stream_data');
-zrequire('people');
-zrequire('ui');
-zrequire('spoilers');
+set_global("navigator", _navigator);
+
+zrequire("alert_words");
+zrequire("muting");
+zrequire("stream_data");
+zrequire("people");
+zrequire("ui");
+zrequire("spoilers");
spoilers.hide_spoilers_in_notification = () => {};
-zrequire('notifications');
+zrequire("notifications");
// Not muted streams
const general = {
subscribed: true,
- name: 'general',
+ name: "general",
stream_id: 10,
is_muted: false,
wildcard_mentions_notify: null,
@@ -41,7 +41,7 @@ const general = {
// Muted streams
const muted = {
subscribed: true,
- name: 'muted',
+ name: "muted",
stream_id: 20,
is_muted: true,
wildcard_mentions_notify: null,
@@ -50,9 +50,9 @@ const muted = {
stream_data.add_sub(general);
stream_data.add_sub(muted);
-muting.add_muted_topic(general.stream_id, 'muted topic');
+muting.add_muted_topic(general.stream_id, "muted topic");
-run_test('message_is_notifiable', () => {
+run_test("message_is_notifiable", () => {
// A notification is sent if both message_is_notifiable(message)
// and the appropriate should_send_*_notification function return
// true.
@@ -63,15 +63,15 @@ run_test('message_is_notifiable', () => {
// EXCEPT sent_by_me, which should trump them
let message = {
id: muted.stream_id,
- content: 'message number 1',
+ content: "message number 1",
sent_by_me: true,
notification_sent: false,
mentioned: true,
mentioned_me_directly: true,
- type: 'stream',
- stream: 'general',
+ type: "stream",
+ stream: "general",
stream_id: general.stream_id,
- topic: 'whatever',
+ topic: "whatever",
};
assert.equal(notifications.should_send_desktop_notification(message), true);
assert.equal(notifications.should_send_audible_notification(message), true);
@@ -85,15 +85,15 @@ run_test('message_is_notifiable', () => {
// (ie: it mentions user, it's not muted, etc)
message = {
id: general.stream_id,
- content: 'message number 2',
+ content: "message number 2",
sent_by_me: false,
notification_sent: true,
mentioned: true,
mentioned_me_directly: true,
- type: 'stream',
- stream: 'general',
+ type: "stream",
+ stream: "general",
stream_id: general.stream_id,
- topic: 'whatever',
+ topic: "whatever",
};
assert.equal(notifications.should_send_desktop_notification(message), true);
assert.equal(notifications.should_send_audible_notification(message), true);
@@ -104,15 +104,15 @@ run_test('message_is_notifiable', () => {
// Mentioning trumps muting
message = {
id: 30,
- content: 'message number 3',
+ content: "message number 3",
sent_by_me: false,
notification_sent: false,
mentioned: true,
mentioned_me_directly: true,
- type: 'stream',
- stream: 'muted',
+ type: "stream",
+ stream: "muted",
stream_id: muted.stream_id,
- topic: 'topic_three',
+ topic: "topic_three",
};
assert.equal(notifications.should_send_desktop_notification(message), true);
assert.equal(notifications.should_send_audible_notification(message), true);
@@ -122,15 +122,15 @@ run_test('message_is_notifiable', () => {
// Mentioning should trigger notification in unmuted topic
message = {
id: 40,
- content: 'message number 4',
+ content: "message number 4",
sent_by_me: false,
notification_sent: false,
mentioned: true,
mentioned_me_directly: true,
- type: 'stream',
- stream: 'general',
+ type: "stream",
+ stream: "general",
stream_id: general.stream_id,
- topic: 'vanilla',
+ topic: "vanilla",
};
assert.equal(notifications.should_send_desktop_notification(message), true);
assert.equal(notifications.should_send_audible_notification(message), true);
@@ -141,15 +141,15 @@ run_test('message_is_notifiable', () => {
// if wildcard_mentions_notify
message = {
id: 40,
- content: 'message number 4',
+ content: "message number 4",
sent_by_me: false,
notification_sent: false,
mentioned: true,
mentioned_me_directly: false,
- type: 'stream',
- stream: 'general',
+ type: "stream",
+ stream: "general",
stream_id: general.stream_id,
- topic: 'vanilla',
+ topic: "vanilla",
};
assert.equal(notifications.should_send_desktop_notification(message), true);
assert.equal(notifications.should_send_audible_notification(message), true);
@@ -176,15 +176,15 @@ run_test('message_is_notifiable', () => {
// DO NOT notify the user
message = {
id: 50,
- content: 'message number 5',
+ content: "message number 5",
sent_by_me: false,
notification_sent: false,
mentioned: true,
mentioned_me_directly: false,
- type: 'stream',
- stream: 'muted',
+ type: "stream",
+ stream: "muted",
stream_id: muted.stream_id,
- topic: 'whatever',
+ topic: "whatever",
};
assert.equal(notifications.should_send_desktop_notification(message), true);
assert.equal(notifications.should_send_audible_notification(message), true);
@@ -195,15 +195,15 @@ run_test('message_is_notifiable', () => {
// DO notify the user
message = {
id: 50,
- content: 'message number 5',
+ content: "message number 5",
sent_by_me: false,
notification_sent: false,
mentioned: true,
mentioned_me_directly: true,
- type: 'stream',
- stream: 'muted',
+ type: "stream",
+ stream: "muted",
stream_id: muted.stream_id,
- topic: 'whatever',
+ topic: "whatever",
};
assert.equal(notifications.should_send_desktop_notification(message), true);
assert.equal(notifications.should_send_audible_notification(message), true);
@@ -214,15 +214,15 @@ run_test('message_is_notifiable', () => {
// DO NOT notify the user
message = {
id: 50,
- content: 'message number 6',
+ content: "message number 6",
sent_by_me: false,
notification_sent: false,
mentioned: true,
mentioned_me_directly: false,
- type: 'stream',
- stream: 'general',
+ type: "stream",
+ stream: "general",
stream_id: general.stream_id,
- topic: 'muted topic',
+ topic: "muted topic",
};
assert.equal(notifications.should_send_desktop_notification(message), true);
assert.equal(notifications.should_send_audible_notification(message), true);
@@ -234,22 +234,22 @@ run_test('message_is_notifiable', () => {
// return true to pass it to notifications settings, which will return false.
message = {
id: 60,
- content: 'message number 7',
+ content: "message number 7",
sent_by_me: false,
notification_sent: false,
mentioned: false,
mentioned_me_directly: false,
- type: 'stream',
- stream: 'general',
+ type: "stream",
+ stream: "general",
stream_id: general.stream_id,
- topic: 'whatever',
+ topic: "whatever",
};
assert.equal(notifications.should_send_desktop_notification(message), false);
assert.equal(notifications.should_send_audible_notification(message), false);
assert.equal(notifications.message_is_notifiable(message), true);
});
-run_test('basic_notifications', () => {
+run_test("basic_notifications", () => {
let n; // Object for storing all notification data for assertions.
let last_closed_message_id = null;
@@ -279,43 +279,43 @@ run_test('basic_notifications', () => {
const message_1 = {
id: 1000,
- content: '@-mentions the user',
- avatar_url: 'url',
+ content: "@-mentions the user",
+ avatar_url: "url",
sent_by_me: false,
- sender_full_name: 'Jesse Pinkman',
+ sender_full_name: "Jesse Pinkman",
notification_sent: false,
mentioned_me_directly: true,
- type: 'stream',
- stream: 'general',
+ type: "stream",
+ stream: "general",
stream_id: muted.stream_id,
- topic: 'whatever',
+ topic: "whatever",
};
const message_2 = {
id: 1500,
- avatar_url: 'url',
- content: '@-mentions the user',
+ avatar_url: "url",
+ content: "@-mentions the user",
sent_by_me: false,
- sender_full_name: 'Gus Fring',
+ sender_full_name: "Gus Fring",
notification_sent: false,
mentioned_me_directly: true,
- type: 'stream',
- stream: 'general',
+ type: "stream",
+ stream: "general",
stream_id: muted.stream_id,
- topic: 'lunch',
+ topic: "lunch",
};
// Send notification.
notifications.process_notification({message: message_1, desktop_notify: true});
n = notifications.get_notifications();
- assert.equal(n.has('Jesse Pinkman to general > whatever'), true);
+ assert.equal(n.has("Jesse Pinkman to general > whatever"), true);
assert.equal(n.size, 1);
assert.equal(last_shown_message_id, message_1.id);
// Remove notification.
notifications.close_notification(message_1);
n = notifications.get_notifications();
- assert.equal(n.has('Jesse Pinkman to general > whatever'), false);
+ assert.equal(n.has("Jesse Pinkman to general > whatever"), false);
assert.equal(n.size, 0);
assert.equal(last_closed_message_id, message_1.id);
@@ -323,7 +323,7 @@ run_test('basic_notifications', () => {
message_1.id = 1001;
notifications.process_notification({message: message_1, desktop_notify: true});
n = notifications.get_notifications();
- assert.equal(n.has('Jesse Pinkman to general > whatever'), true);
+ assert.equal(n.has("Jesse Pinkman to general > whatever"), true);
assert.equal(n.size, 1);
assert.equal(last_shown_message_id, message_1.id);
@@ -331,15 +331,15 @@ run_test('basic_notifications', () => {
message_1.id = 1002;
notifications.process_notification({message: message_1, desktop_notify: true});
n = notifications.get_notifications();
- assert.equal(n.has('Jesse Pinkman to general > whatever'), true);
+ assert.equal(n.has("Jesse Pinkman to general > whatever"), true);
assert.equal(n.size, 1);
assert.equal(last_shown_message_id, message_1.id);
// Send another message. Notification count should increase.
notifications.process_notification({message: message_2, desktop_notify: true});
n = notifications.get_notifications();
- assert.equal(n.has('Gus Fring to general > lunch'), true);
- assert.equal(n.has('Jesse Pinkman to general > whatever'), true);
+ assert.equal(n.has("Gus Fring to general > lunch"), true);
+ assert.equal(n.has("Jesse Pinkman to general > whatever"), true);
assert.equal(n.size, 2);
assert.equal(last_shown_message_id, message_2.id);
@@ -347,7 +347,7 @@ run_test('basic_notifications', () => {
notifications.close_notification(message_1);
notifications.close_notification(message_2);
n = notifications.get_notifications();
- assert.equal(n.has('Jesse Pinkman to general > whatever'), false);
+ assert.equal(n.has("Jesse Pinkman to general > whatever"), false);
assert.equal(n.size, 0);
assert.equal(last_closed_message_id, message_2.id);
});
diff --git a/frontend_tests/node_tests/password.js b/frontend_tests/node_tests/password.js
index a5e3b67bca7..19c3a86c0dc 100644
--- a/frontend_tests/node_tests/password.js
+++ b/frontend_tests/node_tests/password.js
@@ -1,7 +1,7 @@
-set_global('zxcvbn', zrequire('zxcvbn', 'zxcvbn'));
-zrequire('common');
+set_global("zxcvbn", zrequire("zxcvbn", "zxcvbn"));
+zrequire("common");
-run_test('basics', () => {
+run_test("basics", () => {
let accepted;
let password;
let warning;
@@ -15,7 +15,7 @@ run_test('basics', () => {
};
self.removeClass = function (arg) {
- assert.equal(arg, 'bar-success bar-danger');
+ assert.equal(arg, "bar-success bar-danger");
return self;
};
@@ -31,9 +31,9 @@ run_test('basics', () => {
const self = {};
self.data = function (field) {
- if (field === 'minLength') {
+ if (field === "minLength") {
return min_length;
- } else if (field === 'minGuesses') {
+ } else if (field === "minGuesses") {
return min_guesses;
}
};
@@ -41,31 +41,31 @@ run_test('basics', () => {
return self;
}
- password = 'z!X4@S_&';
+ password = "z!X4@S_&";
accepted = common.password_quality(password, bar, password_field(10, 80000));
assert(!accepted);
- assert.equal(bar.w, '39.7%');
- assert.equal(bar.added_class, 'bar-danger');
+ assert.equal(bar.w, "39.7%");
+ assert.equal(bar.added_class, "bar-danger");
warning = common.password_warning(password, password_field(10));
- assert.equal(warning, 'translated: Password should be at least 10 characters long');
+ assert.equal(warning, "translated: Password should be at least 10 characters long");
- password = 'foo';
+ password = "foo";
accepted = common.password_quality(password, bar, password_field(2, 200));
assert(accepted);
- assert.equal(bar.w, '10.390277164940581%');
- assert.equal(bar.added_class, 'bar-success');
+ assert.equal(bar.w, "10.390277164940581%");
+ assert.equal(bar.added_class, "bar-success");
warning = common.password_warning(password, password_field(2));
- assert.equal(warning, 'translated: Password is too weak');
+ assert.equal(warning, "translated: Password is too weak");
- password = 'aaaaaaaa';
+ password = "aaaaaaaa";
accepted = common.password_quality(password, bar, password_field(6, 1e100));
assert(!accepted);
- assert.equal(bar.added_class, 'bar-danger');
+ assert.equal(bar.added_class, "bar-danger");
warning = common.password_warning(password, password_field(6));
assert.equal(warning, 'Repeats like "aaa" are easy to guess');
delete global.zxcvbn;
- password = 'aaaaaaaa';
+ password = "aaaaaaaa";
accepted = common.password_quality(password, bar, password_field(6, 1e100));
assert(accepted === undefined);
warning = common.password_warning(password, password_field(6));
diff --git a/frontend_tests/node_tests/people.js b/frontend_tests/node_tests/people.js
index dd9f0ab3a0f..840436ba9a4 100644
--- a/frontend_tests/node_tests/people.js
+++ b/frontend_tests/node_tests/people.js
@@ -1,10 +1,10 @@
-zrequire('people');
-set_global('message_store', {});
-set_global('page_params', {});
-set_global('settings_data', {});
-set_global('md5', (s) => 'md5-' + s);
+zrequire("people");
+set_global("message_store", {});
+set_global("page_params", {});
+set_global("settings_data", {});
+set_global("md5", (s) => "md5-" + s);
-const settings_config = zrequire('settings_config');
+const settings_config = zrequire("settings_config");
const visibility = settings_config.email_address_visibility_values;
const admins_only = visibility.admins_only.code;
const everyone = visibility.everyone.code;
@@ -16,18 +16,18 @@ function set_email_visibility(code) {
set_email_visibility(admins_only);
const welcome_bot = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 4,
- full_name: 'Welcome Bot',
+ full_name: "Welcome Bot",
is_bot: true,
// cross realm bots have no owner
};
const me = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 30,
- full_name: 'Me Myself',
- timezone: 'US/Pacific',
+ full_name: "Me Myself",
+ timezone: "US/Pacific",
is_admin: false,
is_guest: false,
is_bot: false,
@@ -35,10 +35,10 @@ const me = {
};
const isaac = {
- email: '[email protected]',
- delivery_email: '[email protected]',
+ email: "[email protected]",
+ delivery_email: "[email protected]",
user_id: 32,
- full_name: 'Isaac Newton',
+ full_name: "Isaac Newton",
};
function initialize() {
@@ -64,8 +64,8 @@ initialize();
*/
const realm_admin = {
- email: '[email protected]',
- full_name: 'Realm Admin',
+ email: "[email protected]",
+ full_name: "Realm Admin",
user_id: 32,
is_owner: false,
is_admin: true,
@@ -74,8 +74,8 @@ const realm_admin = {
};
const guest = {
- email: '[email protected]',
- full_name: 'Guest User',
+ email: "[email protected]",
+ full_name: "Guest User",
user_id: 33,
is_owner: false,
is_admin: false,
@@ -84,8 +84,8 @@ const guest = {
};
const realm_owner = {
- email: '[email protected]',
- full_name: 'Realm Owner',
+ email: "[email protected]",
+ full_name: "Realm Owner",
user_id: 34,
is_owner: true,
is_admin: true,
@@ -94,112 +94,112 @@ const realm_owner = {
};
const bot_botson = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 35,
- full_name: 'Bot Botson',
+ full_name: "Bot Botson",
is_bot: true,
bot_owner_id: isaac.user_id,
};
const steven = {
- email: '[email protected]',
- delivery_email: '[email protected]',
+ email: "[email protected]",
+ delivery_email: "[email protected]",
user_id: 77,
- full_name: 'Steven',
+ full_name: "Steven",
};
const alice1 = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 202,
- full_name: 'Alice',
+ full_name: "Alice",
};
const bob = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 203,
- full_name: 'Bob van Roberts',
+ full_name: "Bob van Roberts",
};
const alice2 = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 204,
- full_name: 'Alice',
+ full_name: "Alice",
};
const charles = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 301,
- full_name: 'Charles Dickens',
- avatar_url: 'charles.com/foo.png',
+ full_name: "Charles Dickens",
+ avatar_url: "charles.com/foo.png",
is_guest: false,
};
const maria = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 302,
- full_name: 'Maria Athens',
+ full_name: "Maria Athens",
// With client_gravatar enabled, requests that client compute gravatar
avatar_url: null,
};
const ashton = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 303,
- full_name: 'Ashton Smith',
+ full_name: "Ashton Smith",
};
const linus = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 304,
- full_name: 'Linus Torvalds',
+ full_name: "Linus Torvalds",
};
const emp401 = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 401,
- full_name: 'whatever 401',
+ full_name: "whatever 401",
};
const emp402 = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 402,
- full_name: 'whatever 402',
+ full_name: "whatever 402",
};
const debbie = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 501,
- full_name: 'Debra Henton',
+ full_name: "Debra Henton",
};
const stephen1 = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 601,
- full_name: 'Stephen King',
+ full_name: "Stephen King",
};
const stephen2 = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 602,
- full_name: 'Stephen King',
+ full_name: "Stephen King",
};
const noah = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 1200,
- full_name: 'Nöôáàh Ëmerson',
+ full_name: "Nöôáàh Ëmerson",
};
const plain_noah = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 1201,
- full_name: 'Nooaah Emerson',
+ full_name: "Nooaah Emerson",
};
// This is for error checking--never actually
// tell people.js about this user.
const unknown_user = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 999,
unknown_local_echo_user: true,
};
@@ -208,23 +208,23 @@ function get_all_persons() {
return people.filter_all_persons(() => true);
}
-run_test('basics', () => {
+run_test("basics", () => {
const persons = get_all_persons();
assert.deepEqual(people.get_realm_users(), [me]);
assert.equal(persons.length, 1);
- assert.equal(persons[0].full_name, 'Me Myself');
+ assert.equal(persons[0].full_name, "Me Myself");
let realm_persons = people.get_realm_users();
- assert.equal(realm_persons[0].full_name, 'Me Myself');
+ assert.equal(realm_persons[0].full_name, "Me Myself");
realm_persons = people.get_realm_users();
assert.equal(realm_persons.length, 1);
assert.equal(people.get_active_human_ids().length, 1);
- const full_name = 'Isaac Newton';
- const email = '[email protected]';
+ const full_name = "Isaac Newton";
+ const email = "[email protected]";
assert(!people.is_known_user_id(32));
assert(!people.is_valid_full_name_and_user_id(full_name, 32));
@@ -266,7 +266,7 @@ run_test('basics', () => {
assert.equal(
people.get_bot_owner_user(bot_botson).full_name,
- 'Isaac Newton',
+ "Isaac Newton",
);
// Add our cross-realm bot. It won't add to our human
@@ -276,7 +276,7 @@ run_test('basics', () => {
assert.equal(people.get_active_human_count(), 1);
assert.equal(
people.get_by_email(welcome_bot.email).full_name,
- 'Welcome Bot',
+ "Welcome Bot",
);
// get_realm_users() will include our active bot,
@@ -293,7 +293,7 @@ run_test('basics', () => {
assert.equal(people.get_active_human_count(), 1);
// Invalid user ID returns false and warns.
- blueslip.expect('warn', 'Unexpectedly invalid user_id in user popover query: 123412');
+ blueslip.expect("warn", "Unexpectedly invalid user_id in user popover query: 123412");
assert.equal(people.is_active_user_for_popover(123412), false);
// We can still get their info for non-realm needs.
@@ -301,11 +301,11 @@ run_test('basics', () => {
assert.equal(person.email, email);
// The current user should still be there
- person = people.get_by_email('[email protected]');
- assert.equal(person.full_name, 'Me Myself');
+ person = people.get_by_email("[email protected]");
+ assert.equal(person.full_name, "Me Myself");
// Test undefined people
- assert.equal(people.is_cross_realm_email('[email protected]'), undefined);
+ assert.equal(people.is_cross_realm_email("[email protected]"), undefined);
// Test is_my_user_id function
assert.equal(people.is_my_user_id(me.user_id), true);
@@ -321,7 +321,7 @@ run_test('basics', () => {
[me.user_id, isaac.user_id]);
});
-run_test('check_active_non_active_users', () => {
+run_test("check_active_non_active_users", () => {
let active_users = people.get_realm_users();
let non_active_users = people.get_non_active_realm_users();
assert.equal(active_users.length, 3);
@@ -332,7 +332,7 @@ run_test('check_active_non_active_users', () => {
active_users = people.get_realm_users();
assert.equal(active_users.length, 5);
// Invalid ID
- blueslip.expect('error', 'No user found.');
+ blueslip.expect("error", "No user found.");
people.is_person_active(1000001);
assert.equal(people.is_person_active(maria.user_id), true);
assert.equal(people.is_person_active(linus.user_id), true);
@@ -354,30 +354,30 @@ run_test('check_active_non_active_users', () => {
assert.equal(people.is_person_active(linus.user_id), false);
});
-run_test('pm_lookup_key', () => {
- assert.equal(people.pm_lookup_key('30'), '30');
- assert.equal(people.pm_lookup_key('32,30'), '32');
- assert.equal(people.pm_lookup_key('101,32,30'), '32,101');
+run_test("pm_lookup_key", () => {
+ assert.equal(people.pm_lookup_key("30"), "30");
+ assert.equal(people.pm_lookup_key("32,30"), "32");
+ assert.equal(people.pm_lookup_key("101,32,30"), "32,101");
});
-run_test('get_recipients', () => {
- assert.equal(people.get_recipients('30'), 'Me Myself');
- assert.equal(people.get_recipients('30,32'), 'Isaac Newton');
+run_test("get_recipients", () => {
+ assert.equal(people.get_recipients("30"), "Me Myself");
+ assert.equal(people.get_recipients("30,32"), "Isaac Newton");
});
-run_test('safe_full_names', () => {
+run_test("safe_full_names", () => {
const names = people.safe_full_names([me.user_id, isaac.user_id]);
- assert.equal(names, 'Me Myself, Isaac Newton');
+ assert.equal(names, "Me Myself, Isaac Newton");
});
-run_test('my_custom_profile_data', () => {
+run_test("my_custom_profile_data", () => {
const person = people.get_by_email(me.email);
- person.profile_data = {3: 'My address', 4: 'My phone number'};
- assert.equal(people.my_custom_profile_data(3), 'My address');
- assert.equal(people.my_custom_profile_data(4), 'My phone number');
+ person.profile_data = {3: "My address", 4: "My phone number"};
+ assert.equal(people.my_custom_profile_data(3), "My address");
+ assert.equal(people.my_custom_profile_data(4), "My phone number");
});
-run_test('bot_custom_profile_data', () => {
+run_test("bot_custom_profile_data", () => {
// If this test fails, then try opening organization settings > bots
// http://localhost:9991/#organization/bot-list-admin
// and then try to edit any of the bots.
@@ -385,31 +385,31 @@ run_test('bot_custom_profile_data', () => {
assert.equal(people.get_custom_profile_data(bot_botson.user_id, 3), null);
});
-run_test('user_timezone', () => {
+run_test("user_timezone", () => {
const expected_pref = {
- timezone: 'US/Pacific',
- format: 'H:mm',
+ timezone: "US/Pacific",
+ format: "H:mm",
};
global.page_params.twenty_four_hour_time = true;
assert.deepEqual(people.get_user_time_preferences(me.user_id), expected_pref);
- expected_pref.format = 'h:mm A';
+ expected_pref.format = "h:mm A";
global.page_params.twenty_four_hour_time = false;
assert.deepEqual(people.get_user_time_preferences(me.user_id), expected_pref);
- const actual_moment = zrequire('actual_moment', 'moment-timezone');
- set_global('moment', () => actual_moment('20130208T080910'));
+ const actual_moment = zrequire("actual_moment", "moment-timezone");
+ set_global("moment", () => actual_moment("20130208T080910"));
global.page_params.twenty_four_hour_time = true;
- assert.equal(people.get_user_time(me.user_id), '0:09');
+ assert.equal(people.get_user_time(me.user_id), "0:09");
- expected_pref.format = 'h:mm A';
+ expected_pref.format = "h:mm A";
global.page_params.twenty_four_hour_time = false;
- assert.equal(people.get_user_time(me.user_id), '12:09 AM');
+ assert.equal(people.get_user_time(me.user_id), "12:09 AM");
});
-run_test('user_type', () => {
+run_test("user_type", () => {
people.init();
people.add_active_user(me);
@@ -417,36 +417,36 @@ run_test('user_type', () => {
people.add_active_user(guest);
people.add_active_user(realm_owner);
people.add_active_user(bot_botson);
- assert.equal(people.get_user_type(me.user_id), i18n.t('Member'));
- assert.equal(people.get_user_type(realm_admin.user_id), i18n.t('Administrator'));
- assert.equal(people.get_user_type(guest.user_id), i18n.t('Guest'));
- assert.equal(people.get_user_type(realm_owner.user_id), i18n.t('Owner'));
- assert.equal(people.get_user_type(bot_botson.user_id), i18n.t('Bot'));
+ assert.equal(people.get_user_type(me.user_id), i18n.t("Member"));
+ assert.equal(people.get_user_type(realm_admin.user_id), i18n.t("Administrator"));
+ assert.equal(people.get_user_type(guest.user_id), i18n.t("Guest"));
+ assert.equal(people.get_user_type(realm_owner.user_id), i18n.t("Owner"));
+ assert.equal(people.get_user_type(bot_botson.user_id), i18n.t("Bot"));
});
-run_test('updates', () => {
- const person = people.get_by_email('[email protected]');
- people.set_full_name(person, 'Me the Third');
- assert.equal(people.my_full_name(), 'Me the Third');
- assert.equal(person.full_name, 'Me the Third');
- assert.equal(people.get_user_id_from_name('Me the Third'), me.user_id);
+run_test("updates", () => {
+ const person = people.get_by_email("[email protected]");
+ people.set_full_name(person, "Me the Third");
+ assert.equal(people.my_full_name(), "Me the Third");
+ assert.equal(person.full_name, "Me the Third");
+ assert.equal(people.get_user_id_from_name("Me the Third"), me.user_id);
});
-run_test('get_by_user_id', () => {
+run_test("get_by_user_id", () => {
let person = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 42,
- full_name: 'Mary',
+ full_name: "Mary",
};
people.add_active_user(person);
- person = people.get_by_email('[email protected]');
- assert.equal(person.full_name, 'Mary');
+ person = people.get_by_email("[email protected]");
+ assert.equal(person.full_name, "Mary");
person = people.get_by_user_id(42);
- assert.equal(person.email, '[email protected]');
+ assert.equal(person.email, "[email protected]");
- people.set_full_name(person, 'Mary New');
+ people.set_full_name(person, "Mary New");
person = people.get_by_user_id(42);
- assert.equal(person.full_name, 'Mary New');
+ assert.equal(person.full_name, "Mary New");
// deactivate() should eventually just take a user_id, but
// now it takes a full person object. Note that deactivate()
@@ -458,18 +458,18 @@ run_test('get_by_user_id', () => {
initialize();
-run_test('set_custom_profile_field_data', () => {
+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>');
+ assert.equal(person.profile_data[field.id].value, "Field value");
+ assert.equal(person.profile_data[field.id].rendered_value, "<p>Field value</p>");
});
initialize();
-run_test('get_people_for_stream_create', () => {
+run_test("get_people_for_stream_create", () => {
people.add_active_user(alice1);
people.add_active_user(bob);
people.add_active_user(alice2);
@@ -477,9 +477,9 @@ run_test('get_people_for_stream_create', () => {
const others = people.get_people_for_stream_create();
const expected = [
- { email: '[email protected]', user_id: alice1.user_id, full_name: 'Alice' },
- { email: '[email protected]', user_id: alice2.user_id, full_name: 'Alice' },
- { email: '[email protected]', user_id: bob.user_id, full_name: 'Bob van Roberts' },
+ { email: "[email protected]", user_id: alice1.user_id, full_name: "Alice" },
+ { email: "[email protected]", user_id: alice2.user_id, full_name: "Alice" },
+ { email: "[email protected]", user_id: bob.user_id, full_name: "Bob van Roberts" },
];
assert.deepEqual(others, expected);
@@ -487,7 +487,7 @@ run_test('get_people_for_stream_create', () => {
initialize();
-run_test('recipient_counts', () => {
+run_test("recipient_counts", () => {
const user_id = 99;
assert.equal(people.get_recipient_count({user_id: user_id}), 0);
people.incr_recipient_count(user_id);
@@ -497,7 +497,7 @@ run_test('recipient_counts', () => {
assert.equal(people.get_recipient_count({pm_recipient_count: 5}), 5);
});
-run_test('filtered_users', () => {
+run_test("filtered_users", () => {
people.add_active_user(charles);
people.add_active_user(maria);
people.add_active_user(ashton);
@@ -505,7 +505,7 @@ run_test('filtered_users', () => {
people.add_active_user(noah);
people.add_active_user(plain_noah);
- const search_term = 'a';
+ const search_term = "a";
const users = people.get_people_for_stream_create();
let filtered_people = people.filter_people_by_search_terms(users, [search_term]);
assert.equal(filtered_people.size, 2);
@@ -516,38 +516,38 @@ run_test('filtered_users', () => {
filtered_people = people.filter_people_by_search_terms(users, []);
assert.equal(filtered_people.size, 0);
- filtered_people = people.filter_people_by_search_terms(users, ['ltorv']);
+ filtered_people = people.filter_people_by_search_terms(users, ["ltorv"]);
assert.equal(filtered_people.size, 1);
assert(filtered_people.has(linus.user_id));
- filtered_people = people.filter_people_by_search_terms(users, ['ch di', 'maria']);
+ filtered_people = people.filter_people_by_search_terms(users, ["ch di", "maria"]);
assert.equal(filtered_people.size, 2);
assert(filtered_people.has(charles.user_id));
assert(filtered_people.has(maria.user_id));
// Test filtering of names with diacritics
// This should match Nöôáàh by ignoring diacritics, and also match Nooaah
- filtered_people = people.filter_people_by_search_terms(users, ['noOa']);
+ filtered_people = people.filter_people_by_search_terms(users, ["noOa"]);
assert.equal(filtered_people.size, 2);
assert(filtered_people.has(noah.user_id));
assert(filtered_people.has(plain_noah.user_id));
// This should match ëmerson, but not emerson
- filtered_people = people.filter_people_by_search_terms(users, ['ëm']);
+ filtered_people = people.filter_people_by_search_terms(users, ["ëm"]);
assert.equal(filtered_people.size, 1);
assert(filtered_people.has(noah.user_id));
// Test filtering with undefined user
users.push(unknown_user);
- filtered_people = people.filter_people_by_search_terms(users, ['ltorv']);
+ filtered_people = people.filter_people_by_search_terms(users, ["ltorv"]);
assert.equal(filtered_people.size, 1);
assert(filtered_people.has(linus.user_id));
});
people.init();
-run_test('multi_user_methods', () => {
+run_test("multi_user_methods", () => {
people.add_active_user(emp401);
people.add_active_user(emp402);
@@ -555,31 +555,31 @@ run_test('multi_user_methods', () => {
assert.equal(emp401.user_id, 401);
assert.equal(emp402.user_id, 402);
- let emails_string = people.user_ids_string_to_emails_string('402,401');
- assert.equal(emails_string, '[email protected],[email protected]');
+ let emails_string = people.user_ids_string_to_emails_string("402,401");
+ assert.equal(emails_string, "[email protected],[email protected]");
- emails_string = people.slug_to_emails('402,401');
- assert.equal(emails_string, '[email protected],[email protected]');
+ emails_string = people.slug_to_emails("402,401");
+ assert.equal(emails_string, "[email protected],[email protected]");
- emails_string = people.slug_to_emails('402,401-group');
- assert.equal(emails_string, '[email protected],[email protected]');
+ emails_string = people.slug_to_emails("402,401-group");
+ assert.equal(emails_string, "[email protected],[email protected]");
let user_ids_string = people.emails_strings_to_user_ids_string(emails_string);
- assert.equal(user_ids_string, '401,402');
+ assert.equal(user_ids_string, "401,402");
user_ids_string = people.reply_to_to_user_ids_string(emails_string);
- assert.equal(user_ids_string, '401,402');
+ assert.equal(user_ids_string, "401,402");
const slug = people.emails_to_slug(emails_string);
- assert.equal(slug, '401,402-group');
+ assert.equal(slug, "401,402-group");
- assert.equal(people.reply_to_to_user_ids_string('[email protected]'), undefined);
+ assert.equal(people.reply_to_to_user_ids_string("[email protected]"), undefined);
});
initialize();
-run_test('concat_huddle', () => {
+run_test("concat_huddle", () => {
/*
We assume that user_ids passed in
to concat_huddle have already been
@@ -593,20 +593,20 @@ run_test('concat_huddle', () => {
assert.equal(
people.concat_huddle(user_ids, 304),
- '301,302,303,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',
+ "99,301,302,303",
);
});
initialize();
-run_test('message_methods', () => {
+run_test("message_methods", () => {
people.add_active_user(charles);
people.add_active_user(maria);
people.add_active_user(ashton);
@@ -616,29 +616,29 @@ run_test('message_methods', () => {
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');
+ "https://secure.gravatar.com/avatar/[email protected]?d=identicon&s=50");
assert.deepEqual(people.sender_info_with_small_avatar_urls_for_sender_ids([30]), [
{
- avatar_url_small: '/avatar/30&s=50',
- email: '[email protected]',
- full_name: 'Me the Third',
+ avatar_url_small: "/avatar/30&s=50",
+ email: "[email protected]",
+ full_name: "Me the Third",
is_admin: false,
is_bot: false,
is_guest: false,
profile_data: {
3: {
- rendered_value: '<p>Field value</p>',
- value: 'Field value',
+ rendered_value: "<p>Field value</p>",
+ value: "Field value",
},
},
- timezone: 'US/Pacific',
+ timezone: "US/Pacific",
user_id: 30,
},
]);
let message = {
- type: 'private',
+ type: "private",
display_recipient: [
{id: maria.user_id},
{id: me.user_id},
@@ -646,44 +646,44 @@ run_test('message_methods', () => {
],
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_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');
+ "charles.com/foo.png&s=50");
message = {
- type: 'private',
+ type: "private",
display_recipient: [
{id: maria.user_id},
{id: me.user_id},
],
- avatar_url: 'legacy.png',
+ 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_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');
+ "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',
+ "https://secure.gravatar.com/avatar/[email protected]?d=identicon&s=50",
);
- blueslip.expect('error', 'Unknown user_id in get_by_user_id: 9999999');
+ blueslip.expect("error", "Unknown user_id in get_by_user_id: 9999999");
message = {
avatar_url: undefined,
- sender_email: '[email protected]',
+ 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',
+ "https://secure.gravatar.com/avatar/[email protected]?d=identicon&s=50",
);
message = {
@@ -694,15 +694,15 @@ run_test('message_methods', () => {
);
message = {
- type: 'private',
+ type: "private",
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');
+ assert.equal(people.pm_with_url(message), "#narrow/pm-with/30-me");
+ assert.equal(people.pm_perma_link(message), "#narrow/pm-with/30-pm");
- message = { type: 'stream' };
+ message = { type: "stream" };
assert.equal(people.pm_with_user_ids(message), undefined);
assert.equal(people.all_user_ids_in_pm(message), undefined);
@@ -742,9 +742,9 @@ run_test('message_methods', () => {
initialize();
-run_test('extract_people_from_message', () => {
+run_test("extract_people_from_message", () => {
let message = {
- type: 'stream',
+ type: "stream",
sender_full_name: maria.full_name,
sender_id: maria.user_id,
sender_email: maria.email,
@@ -764,11 +764,11 @@ run_test('extract_people_from_message', () => {
// Get line coverage
people.report_late_add = function () {
- throw Error('unexpected late add');
+ throw Error("unexpected late add");
};
message = {
- type: 'private',
+ type: "private",
display_recipient: [unknown_user],
};
people.extract_people_from_message(message);
@@ -776,14 +776,14 @@ run_test('extract_people_from_message', () => {
initialize();
-run_test('maybe_incr_recipient_count', () => {
+run_test("maybe_incr_recipient_count", () => {
const maria_recip = {
id: maria.user_id,
};
people.add_active_user(maria);
let message = {
- type: 'private',
+ type: "private",
display_recipient: [maria_recip],
sent_by_me: true,
};
@@ -794,7 +794,7 @@ run_test('maybe_incr_recipient_count', () => {
// Test all the no-op conditions to get test
// coverage.
message = {
- type: 'private',
+ type: "private",
sent_by_me: false,
display_recipient: [maria_recip],
};
@@ -802,13 +802,13 @@ run_test('maybe_incr_recipient_count', () => {
assert.equal(people.get_recipient_count(maria), 1);
const unknown_recip = {
- email: '[email protected]',
+ email: "[email protected]",
id: 500,
unknown_local_echo_user: true,
};
message = {
- type: 'private',
+ type: "private",
sent_by_me: true,
display_recipient: [unknown_recip],
};
@@ -816,46 +816,46 @@ run_test('maybe_incr_recipient_count', () => {
assert.equal(people.get_recipient_count(maria), 1);
message = {
- type: 'stream',
+ type: "stream",
};
people.maybe_incr_recipient_count(message);
assert.equal(people.get_recipient_count(maria), 1);
});
-run_test('slugs', () => {
+run_test("slugs", () => {
people.add_active_user(debbie);
const slug = people.emails_to_slug(debbie.email);
- assert.equal(slug, '501-debbie71');
+ assert.equal(slug, "501-debbie71");
const email = people.slug_to_emails(slug);
- assert.equal(email, '[email protected]');
+ assert.equal(email, "[email protected]");
// Test undefined slug
- assert.equal(people.emails_to_slug('[email protected]'), undefined);
+ assert.equal(people.emails_to_slug("[email protected]"), undefined);
});
initialize();
-run_test('get_people_for_search_bar', () => {
+run_test("get_people_for_search_bar", () => {
message_store.user_ids = () => [];
for (const i of _.range(20)) {
const person = {
- email: '[email protected]',
- full_name: 'James Jones',
+ email: "[email protected]",
+ full_name: "James Jones",
user_id: 1000 + i,
};
people.add_active_user(person);
}
- const big_results = people.get_people_for_search_bar('James');
+ const big_results = people.get_people_for_search_bar("James");
assert.equal(big_results.length, 20);
message_store.user_ids = () => [1001, 1002, 1003, 1004, 1005, 1006];
- const small_results = people.get_people_for_search_bar('Jones');
+ const small_results = people.get_people_for_search_bar("Jones");
// As long as there are 5+ results among the user_ids
// in message_store, we will get a small result and not
@@ -865,15 +865,15 @@ run_test('get_people_for_search_bar', () => {
initialize();
-run_test('updates', () => {
- const old_email = '[email protected]';
- const new_email = '[email protected]';
+run_test("updates", () => {
+ const old_email = "[email protected]";
+ const new_email = "[email protected]";
const user_id = 502;
let person = {
email: old_email,
user_id: user_id,
- full_name: 'Foo Barson',
+ full_name: "Foo Barson",
};
people.add_active_user(person);
@@ -894,49 +894,49 @@ run_test('updates', () => {
assert.equal(all_people.length, 2);
person = all_people.filter((p) => p.email === new_email)[0];
- assert.equal(person.full_name, 'Foo Barson');
+ assert.equal(person.full_name, "Foo Barson");
// 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: " +
person = people.get_by_email(old_email);
assert.equal(person.user_id, user_id);
});
initialize();
-run_test('update_email_in_reply_to', () => {
+run_test("update_email_in_reply_to", () => {
people.add_active_user(charles);
people.add_active_user(maria);
assert.equal(
- people.update_email_in_reply_to(reply_to, 9999, 'whatever'),
+ 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]'),
+ 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'),
+ people.update_email_in_reply_to(reply_to, 9999, "whatever"),
reply_to,
);
});
initialize();
-run_test('track_duplicate_full_names', () => {
+run_test("track_duplicate_full_names", () => {
people.add_active_user(maria);
people.add_active_user(stephen1);
- assert(!people.is_duplicate_full_name('Stephen King'));
+ assert(!people.is_duplicate_full_name("Stephen King"));
assert.equal(
- people.get_user_id_from_name('Stephen King'),
+ people.get_user_id_from_name("Stephen King"),
stephen1.user_id,
);
@@ -947,65 +947,65 @@ run_test('track_duplicate_full_names', () => {
// user_id the person means; the UI should use
// other codepaths for disambiguation.
assert.equal(
- people.get_user_id_from_name('Stephen King'),
+ 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'));
- assert(!people.is_duplicate_full_name('Some Random Name'));
+ assert(people.is_duplicate_full_name("Stephen King"));
+ assert(!people.is_duplicate_full_name("Maria Athens"));
+ assert(!people.is_duplicate_full_name("Some Random Name"));
// It is somewhat janky that we have to clone
// stephen2 here. It would be nice if people.set_full_name
// just took a user_id as the first parameter.
- people.set_full_name({...stephen2}, 'Stephen King JP');
- assert(!people.is_duplicate_full_name('Stephen King'));
- assert(!people.is_duplicate_full_name('Stephen King JP'));
+ people.set_full_name({...stephen2}, "Stephen King JP");
+ assert(!people.is_duplicate_full_name("Stephen King"));
+ assert(!people.is_duplicate_full_name("Stephen King JP"));
});
initialize();
-run_test('get_mention_syntax', () => {
+run_test("get_mention_syntax", () => {
people.add_active_user(stephen1);
people.add_active_user(stephen2);
people.add_active_user(maria);
- assert(people.is_duplicate_full_name('Stephen King'));
+ assert(people.is_duplicate_full_name("Stephen King"));
- blueslip.expect('warn', 'get_mention_syntax called without user_id.');
- assert.equal(people.get_mention_syntax('Stephen King'), '@**Stephen King**');
+ blueslip.expect("warn", "get_mention_syntax called without user_id.");
+ assert.equal(people.get_mention_syntax("Stephen King"), "@**Stephen King**");
blueslip.reset();
- assert.equal(people.get_mention_syntax('Stephen King', 601), '@**Stephen King|601**');
- assert.equal(people.get_mention_syntax('Stephen King', 602), '@**Stephen King|602**');
- assert.equal(people.get_mention_syntax('Maria Athens', 603), '@**Maria Athens**');
+ assert.equal(people.get_mention_syntax("Stephen King", 601), "@**Stephen King|601**");
+ assert.equal(people.get_mention_syntax("Stephen King", 602), "@**Stephen King|602**");
+ assert.equal(people.get_mention_syntax("Maria Athens", 603), "@**Maria Athens**");
});
-run_test('initialize', () => {
+run_test("initialize", () => {
people.init();
const params = {};
params.realm_non_active_users = [
{
- email: '[email protected]',
+ email: "[email protected]",
user_id: 15,
- full_name: 'Retiree',
+ full_name: "Retiree",
},
];
params.realm_users = [
{
- email: '[email protected]',
+ email: "[email protected]",
user_id: 16,
- full_name: 'Alice',
+ full_name: "Alice",
},
];
params.cross_realm_bots = [
{
- email: '[email protected]',
+ email: "[email protected]",
user_id: 17,
- full_name: 'Test Bot',
+ full_name: "Test Bot",
},
];
@@ -1013,24 +1013,24 @@ run_test('initialize', () => {
people.initialize(my_user_id, params);
assert.equal(people.is_active_user_for_popover(17), true);
- assert(people.is_cross_realm_email('[email protected]'));
- assert(people.is_valid_email_for_compose('[email protected]'));
- assert(people.is_valid_email_for_compose('[email protected]'));
- assert(!people.is_valid_email_for_compose('[email protected]'));
- assert(!people.is_valid_email_for_compose('[email protected]'));
- assert(people.is_valid_bulk_emails_for_compose(['[email protected]', '[email protected]']));
- assert(!people.is_valid_bulk_emails_for_compose(['[email protected]', '[email protected]']));
+ assert(people.is_cross_realm_email("[email protected]"));
+ assert(people.is_valid_email_for_compose("[email protected]"));
+ assert(people.is_valid_email_for_compose("[email protected]"));
+ assert(!people.is_valid_email_for_compose("[email protected]"));
+ assert(!people.is_valid_email_for_compose("[email protected]"));
+ assert(people.is_valid_bulk_emails_for_compose(["[email protected]", "[email protected]"]));
+ assert(!people.is_valid_bulk_emails_for_compose(["[email protected]", "[email protected]"]));
assert(people.is_my_user_id(42));
const fetched_retiree = people.get_by_user_id(15);
- assert.equal(fetched_retiree.full_name, 'Retiree');
+ assert.equal(fetched_retiree.full_name, "Retiree");
assert.equal(global.page_params.realm_users, undefined);
assert.equal(global.page_params.cross_realm_bots, undefined);
assert.equal(global.page_params.realm_non_active_users, undefined);
});
-run_test('filter_for_user_settings_search', () => {
+run_test("filter_for_user_settings_search", () => {
/*
This function calls matches_user_settings_search,
so that is where we do more thorough testing.
@@ -1038,79 +1038,79 @@ run_test('filter_for_user_settings_search', () => {
*/
page_params.is_admin = false;
- const fred_smith = {full_name: 'Fred Smith'};
- const alice_lee = {full_name: 'Alice Lee'};
- const jenny_franklin = {full_name: 'Jenny Franklin'};
+ const fred_smith = {full_name: "Fred Smith"};
+ const alice_lee = {full_name: "Alice Lee"};
+ const jenny_franklin = {full_name: "Jenny Franklin"};
const persons = [fred_smith, alice_lee, jenny_franklin];
assert.deepEqual(
- people.filter_for_user_settings_search(persons, 'fr'),
+ people.filter_for_user_settings_search(persons, "fr"),
[fred_smith, jenny_franklin]);
assert.deepEqual(
- people.filter_for_user_settings_search(persons, 'le'),
+ people.filter_for_user_settings_search(persons, "le"),
[alice_lee]);
});
-run_test('matches_user_settings_search', () => {
+run_test("matches_user_settings_search", () => {
const match = people.matches_user_settings_search;
page_params.is_admin = false;
- assert.equal(match({email: '[email protected]'}, 'fred'), false);
- assert.equal(match({full_name: 'Fred Smith'}, 'fr'), true);
+ assert.equal(match({email: "[email protected]"}, "fred"), false);
+ assert.equal(match({full_name: "Fred Smith"}, "fr"), true);
page_params.is_admin = true;
- assert.equal(match({delivery_email: '[email protected]'}, 'fr'), true);
+ assert.equal(match({delivery_email: "[email protected]"}, "fr"), true);
assert.equal(
- match({delivery_email: 'bogus', email: '[email protected]'}, 'fr'),
+ match({delivery_email: "bogus", email: "[email protected]"}, "fr"),
false);
set_email_visibility(everyone);
page_params.is_admin = false;
- assert.equal(match({delivery_email: '[email protected]'}, 'fr'), false);
- assert.equal(match({email: '[email protected]'}, 'fr'), true);
+ assert.equal(match({delivery_email: "[email protected]"}, "fr"), false);
+ assert.equal(match({email: "[email protected]"}, "fr"), true);
// test normal stuff
- assert.equal(match({email: '[email protected]'}, 'st'), false);
- assert.equal(match({full_name: 'Fred Smith'}, 'st'), false);
- assert.equal(match({full_name: 'Joe Frederick'}, 'st'), false);
+ assert.equal(match({email: "[email protected]"}, "st"), false);
+ assert.equal(match({full_name: "Fred Smith"}, "st"), false);
+ assert.equal(match({full_name: "Joe Frederick"}, "st"), false);
- assert.equal(match({email: '[email protected]'}, 'fr'), true);
- assert.equal(match({full_name: 'Fred Smith'}, 'fr'), true);
- assert.equal(match({full_name: 'Joe Frederick'}, 'fr'), true);
+ assert.equal(match({email: "[email protected]"}, "fr"), true);
+ assert.equal(match({full_name: "Fred Smith"}, "fr"), true);
+ assert.equal(match({full_name: "Joe Frederick"}, "fr"), true);
// test in-string matches...we may want not to be so liberal
// here about matching, as it's noisy for large realms (who
// need search the most)
- assert.equal(match({email: '[email protected]'}, 're'), true);
- assert.equal(match({full_name: 'Fred Smith'}, 're'), true);
- assert.equal(match({full_name: 'Joe Frederick'}, 're'), true);
+ assert.equal(match({email: "[email protected]"}, "re"), true);
+ assert.equal(match({full_name: "Fred Smith"}, "re"), true);
+ assert.equal(match({full_name: "Joe Frederick"}, "re"), true);
});
initialize();
-run_test('is_valid_full_name_and_user_id', () => {
- assert(!people.is_valid_full_name_and_user_id('bogus', 99));
+run_test("is_valid_full_name_and_user_id", () => {
+ assert(!people.is_valid_full_name_and_user_id("bogus", 99));
assert(!people.is_valid_full_name_and_user_id(me.full_name, 99));
assert(people.is_valid_full_name_and_user_id(me.full_name, me.user_id));
});
-run_test('emails_strings_to_user_ids_array', () => {
+run_test("emails_strings_to_user_ids_array", () => {
people.add_active_user(steven);
people.add_active_user(maria);
let user_ids = people.emails_strings_to_user_ids_array(`${steven.email},${maria.email}`);
assert.deepEqual(user_ids, [steven.user_id, maria.user_id]);
- blueslip.expect('warn', 'Unknown emails: [email protected]');
- user_ids = people.emails_strings_to_user_ids_array('[email protected]');
+ blueslip.expect("warn", "Unknown emails: [email protected]");
+ user_ids = people.emails_strings_to_user_ids_array("[email protected]");
assert.equal(user_ids, undefined);
});
-run_test('get_visible_email', () => {
+run_test("get_visible_email", () => {
people.add_active_user(steven);
people.add_active_user(maria);
@@ -1121,7 +1121,7 @@ run_test('get_visible_email', () => {
assert.equal(email, maria.email);
});
-run_test('get_active_message_people', () => {
+run_test("get_active_message_people", () => {
message_store.user_ids = () => [
steven.user_id,
maria.user_id,
diff --git a/frontend_tests/node_tests/people_errors.js b/frontend_tests/node_tests/people_errors.js
index a8750a20b57..446eff00dd3 100644
--- a/frontend_tests/node_tests/people_errors.js
+++ b/frontend_tests/node_tests/people_errors.js
@@ -1,96 +1,96 @@
-zrequire('people');
+zrequire("people");
const return_false = function () { return false; };
const return_true = function () { return true; };
-set_global('reload_state', {
+set_global("reload_state", {
is_in_progress: return_false,
});
const me = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 30,
- full_name: 'Me Myself',
- timezone: 'US/Pacific',
+ full_name: "Me Myself",
+ timezone: "US/Pacific",
};
people.init();
people.add_active_user(me);
people.initialize_current_user(me.user_id);
-run_test('report_late_add', () => {
- blueslip.expect('error', 'Added user late: user_id=55 [email protected]');
- people.report_late_add(55, '[email protected]');
+run_test("report_late_add", () => {
+ blueslip.expect("error", "Added user late: user_id=55 [email protected]");
+ people.report_late_add(55, "[email protected]");
- blueslip.expect('log', 'Added user late: user_id=55 [email protected]');
+ blueslip.expect("log", "Added user late: user_id=55 [email protected]");
reload_state.is_in_progress = return_true;
- people.report_late_add(55, '[email protected]');
+ people.report_late_add(55, "[email protected]");
});
-run_test('is_my_user_id', () => {
- blueslip.expect('error', 'user_id is a string in my_user_id: 999');
- assert.equal(people.is_my_user_id('999'), false);
+run_test("is_my_user_id", () => {
+ blueslip.expect("error", "user_id is a string in my_user_id: 999");
+ assert.equal(people.is_my_user_id("999"), false);
- blueslip.expect('error', 'user_id is a string in my_user_id: 30');
+ blueslip.expect("error", "user_id is a string in my_user_id: 30");
assert.equal(people.is_my_user_id(me.user_id.toString()), true);
});
-run_test('blueslip', () => {
+run_test("blueslip", () => {
const unknown_email = "[email protected]";
- blueslip.expect('debug', 'User email operand unknown: ' + unknown_email);
+ blueslip.expect("debug", "User email operand unknown: " + unknown_email);
people.id_matches_email_operand(42, unknown_email);
- blueslip.expect('error', 'Unknown user_id: 9999');
+ blueslip.expect("error", "Unknown user_id: 9999");
people.get_actual_name_from_user_id(9999);
- blueslip.expect('error', 'Unknown email for get_user_id: ' + unknown_email);
+ blueslip.expect("error", "Unknown email for get_user_id: " + unknown_email);
people.get_user_id(unknown_email);
- blueslip.expect('warn', 'No user_id provided for [email protected]');
+ blueslip.expect("warn", "No user_id provided for [email protected]");
const person = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: undefined,
- full_name: 'Person Person',
+ full_name: "Person Person",
};
people.add_active_user(person);
- blueslip.expect('error', 'No user_id found for [email protected]');
- const user_id = people.get_user_id('[email protected]');
+ blueslip.expect("error", "No user_id found for [email protected]");
+ const user_id = people.get_user_id("[email protected]");
assert.equal(user_id, undefined);
- blueslip.expect('warn', 'Unknown user ids: 1,2');
- people.user_ids_string_to_emails_string('1,2');
+ blueslip.expect("warn", "Unknown user ids: 1,2");
+ people.user_ids_string_to_emails_string("1,2");
- blueslip.expect('warn', 'Unknown emails: ' + unknown_email);
+ blueslip.expect("warn", "Unknown emails: " + unknown_email);
people.email_list_to_user_ids_string([unknown_email]);
let message = {
- type: 'private',
+ type: "private",
display_recipient: [],
sender_id: me.user_id,
};
- blueslip.expect('error', 'Empty recipient list in message', 4);
+ blueslip.expect("error", "Empty recipient list in message", 4);
people.pm_with_user_ids(message);
people.group_pm_with_user_ids(message);
people.all_user_ids_in_pm(message);
assert.equal(people.pm_perma_link(message), undefined);
const charles = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 451,
- full_name: 'Charles Dickens',
- avatar_url: 'charles.com/foo.png',
+ full_name: "Charles Dickens",
+ avatar_url: "charles.com/foo.png",
};
const maria = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 452,
- full_name: 'Maria Athens',
+ full_name: "Maria Athens",
};
people.add_active_user(charles);
people.add_active_user(maria);
message = {
- type: 'private',
+ type: "private",
display_recipient: [
{id: maria.user_id},
{id: 42},
@@ -98,19 +98,19 @@ run_test('blueslip', () => {
],
sender_id: charles.user_id,
};
- blueslip.expect('error', 'Unknown user id in message: 42');
+ blueslip.expect("error", "Unknown user id in message: 42");
const reply_to = people.pm_reply_to(message);
- assert(reply_to.includes('?'));
+ assert(reply_to.includes("?"));
people.pm_with_user_ids = function () { return [42]; };
people.get_by_user_id = function () { return; };
- blueslip.expect('error', 'Unknown people in message');
+ blueslip.expect("error", "Unknown people in message");
const uri = people.pm_with_url({});
- assert.equal(uri.indexOf('unk'), uri.length - 3);
+ assert.equal(uri.indexOf("unk"), uri.length - 3);
- blueslip.expect('error', 'Undefined field id');
+ blueslip.expect("error", "Undefined field id");
assert.equal(people.my_custom_profile_data(undefined), undefined);
- blueslip.expect('error', 'Trying to set undefined field id');
+ blueslip.expect("error", "Trying to set undefined field id");
people.set_custom_profile_field_data(maria.user_id, {});
});
diff --git a/frontend_tests/node_tests/pm_conversations.js b/frontend_tests/node_tests/pm_conversations.js
index 6db73c3edaa..2821e3ef5a5 100644
--- a/frontend_tests/node_tests/pm_conversations.js
+++ b/frontend_tests/node_tests/pm_conversations.js
@@ -1,6 +1,6 @@
-const pmc = zrequire('pm_conversations');
+const pmc = zrequire("pm_conversations");
-run_test('partners', () => {
+run_test("partners", () => {
const user1_id = 1;
const user2_id = 2;
const user3_id = 3;
@@ -15,7 +15,7 @@ run_test('partners', () => {
zrequire("people");
-run_test('insert_recent_private_message', () => {
+run_test("insert_recent_private_message", () => {
const params = {
recent_private_conversations: [
{user_ids: [11, 2],
@@ -33,9 +33,9 @@ run_test('insert_recent_private_message', () => {
pmc.recent.initialize(params);
assert.deepEqual(pmc.recent.get(), [
- {user_ids_string: '2,11', max_message_id: 150},
- {user_ids_string: '1', max_message_id: 111},
- {user_ids_string: '15', max_message_id: 7},
+ {user_ids_string: "2,11", max_message_id: 150},
+ {user_ids_string: "1", max_message_id: 111},
+ {user_ids_string: "15", max_message_id: 7},
]);
pmc.recent.insert([1], 1001);
@@ -46,11 +46,11 @@ run_test('insert_recent_private_message', () => {
pmc.recent.insert([1], 555);
assert.deepEqual(pmc.recent.get(), [
- {user_ids_string: '1', max_message_id: 3001},
- {user_ids_string: '2', max_message_id: 2001},
- {user_ids_string: '2,11', max_message_id: 150},
- {user_ids_string: '15', max_message_id: 7},
+ {user_ids_string: "1", max_message_id: 3001},
+ {user_ids_string: "2", max_message_id: 2001},
+ {user_ids_string: "2,11", max_message_id: 150},
+ {user_ids_string: "15", max_message_id: 7},
]);
- assert.deepEqual(pmc.recent.get_strings(), ['1', '2', '2,11', '15']);
+ assert.deepEqual(pmc.recent.get_strings(), ["1", "2", "2,11", "15"]);
});
diff --git a/frontend_tests/node_tests/pm_list.js b/frontend_tests/node_tests/pm_list.js
index fbddb128ade..76be9f8150e 100644
--- a/frontend_tests/node_tests/pm_list.js
+++ b/frontend_tests/node_tests/pm_list.js
@@ -1,44 +1,44 @@
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
-set_global('narrow_state', {});
-set_global('ui', {
+set_global("narrow_state", {});
+set_global("ui", {
get_content_element: (element) => element,
});
-set_global('stream_popover', {
+set_global("stream_popover", {
hide_topic_popover: function () {},
});
-set_global('unread', {});
-set_global('unread_ui', {});
-set_global('vdom', {
- render: () => 'fake-dom-for-pm-list',
+set_global("unread", {});
+set_global("unread_ui", {});
+set_global("vdom", {
+ render: () => "fake-dom-for-pm-list",
});
-set_global('pm_list_dom', {});
+set_global("pm_list_dom", {});
-zrequire('user_status');
-zrequire('presence');
-zrequire('buddy_data');
-zrequire('hash_util');
-zrequire('people');
-zrequire('pm_conversations');
-zrequire('pm_list');
+zrequire("user_status");
+zrequire("presence");
+zrequire("buddy_data");
+zrequire("hash_util");
+zrequire("people");
+zrequire("pm_conversations");
+zrequire("pm_list");
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 101,
- full_name: 'Alice',
+ full_name: "Alice",
};
const bob = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 102,
- full_name: 'Bob',
+ full_name: "Bob",
};
const me = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 103,
- full_name: 'Me Myself',
+ full_name: "Me Myself",
};
const bot_test = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 314,
full_name: "Outgoing webhook",
is_admin: false,
@@ -50,16 +50,16 @@ people.add_active_user(me);
people.add_active_user(bot_test);
people.initialize_current_user(me.user_id);
-run_test('close', () => {
+run_test("close", () => {
let collapsed;
- $('#private-container').empty = function () {
+ $("#private-container").empty = function () {
collapsed = true;
};
pm_list.close();
assert(collapsed);
});
-run_test('build_private_messages_list', () => {
+run_test("build_private_messages_list", () => {
const timestamp = 0;
pm_conversations.recent.insert([101, 102], timestamp);
@@ -78,13 +78,13 @@ run_test('build_private_messages_list', () => {
const expected_data = [
{
- recipients: 'Alice, Bob',
- user_ids_string: '101,102',
+ recipients: "Alice, Bob",
+ user_ids_string: "101,102",
unread: 1,
is_zero: false,
is_active: false,
- url: '#narrow/pm-with/101,102-group',
- user_circle_class: 'user_circle_fraction',
+ url: "#narrow/pm-with/101,102-group",
+ user_circle_class: "user_circle_fraction",
fraction_present: undefined,
is_group: true,
},
@@ -105,7 +105,7 @@ run_test('build_private_messages_list', () => {
assert.deepEqual(pm_data, expected_data);
});
-run_test('build_private_messages_list_bot', () => {
+run_test("build_private_messages_list_bot", () => {
const timestamp = 0;
pm_conversations.recent.insert([314], timestamp);
@@ -123,24 +123,24 @@ run_test('build_private_messages_list_bot', () => {
pm_list._build_private_messages_list();
const expected_data = [
{
- recipients: 'Outgoing webhook',
- user_ids_string: '314',
+ recipients: "Outgoing webhook",
+ user_ids_string: "314",
unread: 1,
is_zero: false,
is_active: false,
- url: '#narrow/pm-with/314-outgoingwebhook',
- user_circle_class: 'user_circle_green',
+ url: "#narrow/pm-with/314-outgoingwebhook",
+ user_circle_class: "user_circle_green",
fraction_present: undefined,
is_group: false,
},
{
- recipients: 'Alice, Bob',
- user_ids_string: '101,102',
+ recipients: "Alice, Bob",
+ user_ids_string: "101,102",
unread: 1,
is_zero: false,
is_active: false,
- url: '#narrow/pm-with/101,102-group',
- user_circle_class: 'user_circle_fraction',
+ url: "#narrow/pm-with/101,102-group",
+ user_circle_class: "user_circle_fraction",
fraction_present: undefined,
is_group: true,
},
@@ -149,15 +149,15 @@ run_test('build_private_messages_list_bot', () => {
assert.deepEqual(pm_data, expected_data);
});
-run_test('update_dom_with_unread_counts', () => {
+run_test("update_dom_with_unread_counts", () => {
let counts;
let toggle_button_set;
- const total_value = $.create('total-value-stub');
- const total_count = $.create('total-count-stub');
+ const total_value = $.create("total-value-stub");
+ const total_count = $.create("total-count-stub");
const private_li = $(".top_left_private_messages");
- private_li.set_find_results('.count', total_count);
- total_count.set_find_results('.value', total_value);
+ private_li.set_find_results(".count", total_count);
+ total_count.set_find_results(".value", total_value);
counts = {
private_message_count: 10,
@@ -186,7 +186,7 @@ run_test('update_dom_with_unread_counts', () => {
assert(toggle_button_set);
});
-run_test('get_active_user_ids_string', () => {
+run_test("get_active_user_ids_string", () => {
narrow_state.filter = () => {};
assert.equal(
@@ -196,7 +196,7 @@ run_test('get_active_user_ids_string', () => {
function set_filter_result(emails) {
narrow_state.filter = () => ({
operands: (operand) => {
- assert.equal(operand, 'pm-with');
+ assert.equal(operand, "pm-with");
return emails;
},
});
@@ -207,13 +207,13 @@ run_test('get_active_user_ids_string', () => {
pm_list.get_active_user_ids_string(),
undefined);
- set_filter_result(['[email protected],[email protected]']);
+ set_filter_result(["[email protected],[email protected]"]);
assert.equal(
pm_list.get_active_user_ids_string(),
- '101,102');
+ "101,102");
});
-run_test('is_all_privates', () => {
+run_test("is_all_privates", () => {
narrow_state.filter = () => {};
assert.equal(
@@ -222,8 +222,8 @@ run_test('is_all_privates', () => {
narrow_state.filter = () => ({
operands: (operand) => {
- assert.equal(operand, 'is');
- return ['private', 'starred'];
+ assert.equal(operand, "is");
+ return ["private", "starred"];
},
});
@@ -234,12 +234,12 @@ run_test('is_all_privates', () => {
function with_fake_list(f) {
const orig = pm_list._build_private_messages_list;
- pm_list._build_private_messages_list = () => 'PM_LIST_CONTENTS';
+ pm_list._build_private_messages_list = () => "PM_LIST_CONTENTS";
f();
pm_list._build_private_messages_list = orig;
}
-run_test('expand', () => {
+run_test("expand", () => {
with_fake_list(() => {
let html_updated;
@@ -253,11 +253,11 @@ run_test('expand', () => {
});
});
-run_test('update_private_messages', () => {
+run_test("update_private_messages", () => {
narrow_state.active = () => true;
- $('#private-container').find = (sel) => {
- assert.equal(sel, 'ul');
+ $("#private-container").find = (sel) => {
+ assert.equal(sel, "ul");
};
with_fake_list(() => {
@@ -277,18 +277,18 @@ run_test('update_private_messages', () => {
pm_list.update_private_messages();
assert(html_updated);
- assert($(".top_left_private_messages").hasClass('active-filter'));
+ assert($(".top_left_private_messages").hasClass("active-filter"));
pm_list.is_all_privates = orig_is_all_privates;
});
});
-run_test('ensure coverage', () => {
+run_test("ensure coverage", () => {
// These aren't rigorous; they just cover cases
// where functions early exit.
narrow_state.active = () => false;
pm_list.rebuild_recent = () => {
- throw Error('we should not call rebuild_recent');
+ throw Error("we should not call rebuild_recent");
};
pm_list.update_private_messages();
});
diff --git a/frontend_tests/node_tests/poll_widget.js b/frontend_tests/node_tests/poll_widget.js
index bbbff296003..25f11fe9ee5 100644
--- a/frontend_tests/node_tests/poll_widget.js
+++ b/frontend_tests/node_tests/poll_widget.js
@@ -1,16 +1,16 @@
-zrequire('poll_widget');
+zrequire("poll_widget");
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
-set_global('people', {});
+set_global("people", {});
const noop = () => {};
const return_false = () => false;
const return_true = () => true;
-run_test('poll_data_holder my question', () => {
+run_test("poll_data_holder my question", () => {
const is_my_poll = true;
- const question = 'Favorite color?';
+ const question = "Favorite color?";
const sender_id = 99;
people.my_current_user_id = () => sender_id;
@@ -21,12 +21,12 @@ run_test('poll_data_holder my question', () => {
assert.deepEqual(data, {
options: [],
- question: 'Favorite color?',
+ question: "Favorite color?",
});
const question_event = {
- type: 'question',
- question: 'best plan?',
+ type: "question",
+ question: "best plan?",
};
data_holder.handle_event(sender_id, question_event);
@@ -34,16 +34,16 @@ run_test('poll_data_holder my question', () => {
assert.deepEqual(data, {
options: [],
- question: 'best plan?',
+ question: "best plan?",
});
const option_event = {
- type: 'new_option',
+ type: "new_option",
idx: 1,
- option: 'release now',
+ option: "release now",
};
- people.safe_full_names = () => '';
+ people.safe_full_names = () => "";
data_holder.handle_event(sender_id, option_event);
data = data_holder.get_widget_data();
@@ -51,19 +51,19 @@ run_test('poll_data_holder my question', () => {
assert.deepEqual(data, {
options: [
{
- option: 'release now',
- names: '',
+ option: "release now",
+ names: "",
count: 0,
- key: '99,1',
+ key: "99,1",
current_user_vote: false,
},
],
- question: 'best plan?',
+ question: "best plan?",
});
let vote_event = {
- type: 'vote',
- key: '99,1',
+ type: "vote",
+ key: "99,1",
vote: 1,
};
@@ -73,46 +73,46 @@ run_test('poll_data_holder my question', () => {
assert.deepEqual(data, {
options: [
{
- option: 'release now',
- names: '',
+ option: "release now",
+ names: "",
count: 1,
- key: '99,1',
+ key: "99,1",
current_user_vote: true,
},
],
- question: 'best plan?',
+ question: "best plan?",
});
const invalid_vote_event = {
- type: 'vote',
- key: '98,1',
+ type: "vote",
+ key: "98,1",
vote: 1,
};
- blueslip.expect('warn', `unknown key for poll: ${invalid_vote_event.key}`);
+ blueslip.expect("warn", `unknown key for poll: ${invalid_vote_event.key}`);
data_holder.handle_event(sender_id, invalid_vote_event);
data = data_holder.get_widget_data();
- const option_outbound_event = data_holder.handle.new_option.outbound('new option');
+ const option_outbound_event = data_holder.handle.new_option.outbound("new option");
assert.deepEqual(option_outbound_event, {
- type: 'new_option',
+ type: "new_option",
idx: 2,
- option: 'new option',
+ option: "new option",
});
- const new_question = 'Any new plan?';
+ const new_question = "Any new plan?";
const question_outbound_event = data_holder.handle.question.outbound(new_question);
assert.deepEqual(question_outbound_event, {
- type: 'question',
+ type: "question",
question: new_question,
});
- const vote_outbound_event = data_holder.handle.vote.outbound('99,1');
- assert.deepEqual(vote_outbound_event, { type: 'vote', key: '99,1', vote: -1 });
+ const vote_outbound_event = data_holder.handle.vote.outbound("99,1");
+ assert.deepEqual(vote_outbound_event, { type: "vote", key: "99,1", vote: -1 });
vote_event = {
- type: 'vote',
- key: '99,1',
+ type: "vote",
+ key: "99,1",
vote: -1,
};
@@ -122,29 +122,29 @@ run_test('poll_data_holder my question', () => {
assert.deepEqual(data, {
options: [
{
- option: 'release now',
- names: '',
+ option: "release now",
+ names: "",
count: 0,
- key: '99,1',
+ key: "99,1",
current_user_vote: false,
},
],
- question: 'best plan?',
+ question: "best plan?",
});
});
-run_test('activate another person poll', () => {
+run_test("activate another person poll", () => {
people.is_my_user_id = return_false;
global.stub_templates((template_name) => {
- if (template_name === 'widgets/poll_widget') {
- return 'widgets/poll_widget';
+ if (template_name === "widgets/poll_widget") {
+ return "widgets/poll_widget";
}
- if (template_name === 'widgets/poll_widget_results') {
- return 'widgets/poll_widget_results';
+ if (template_name === "widgets/poll_widget_results") {
+ return "widgets/poll_widget_results";
}
});
- const widget_elem = $('<div>').addClass('widget-content');
+ const widget_elem = $("<div>").addClass("widget-content");
let out_data; // Used to check the event data sent to the server
const callback = (data) => {
@@ -158,7 +158,7 @@ run_test('activate another person poll', () => {
sender_id: 100,
},
extra_data: {
- question: 'What do you want?',
+ question: "What do you want?",
},
};
@@ -168,33 +168,33 @@ run_test('activate another person poll', () => {
return elem;
};
- const poll_option = set_widget_find_result('button.poll-option');
- const poll_option_input = set_widget_find_result('input.poll-option');
- const widget_option_container = set_widget_find_result('ul.poll-widget');
+ const poll_option = set_widget_find_result("button.poll-option");
+ const poll_option_input = set_widget_find_result("input.poll-option");
+ const widget_option_container = set_widget_find_result("ul.poll-widget");
- const poll_question_submit = set_widget_find_result('button.poll-question-check');
- const poll_edit_question = set_widget_find_result('.poll-edit-question');
- const poll_question_header = set_widget_find_result('.poll-question-header');
- const poll_question_container = set_widget_find_result('.poll-question-bar');
- const poll_option_container = set_widget_find_result('.poll-option-bar');
+ const poll_question_submit = set_widget_find_result("button.poll-question-check");
+ const poll_edit_question = set_widget_find_result(".poll-edit-question");
+ const poll_question_header = set_widget_find_result(".poll-question-header");
+ const poll_question_container = set_widget_find_result(".poll-question-bar");
+ const poll_option_container = set_widget_find_result(".poll-option-bar");
- const poll_vote_button = set_widget_find_result('button.poll-vote');
- const poll_please_wait = set_widget_find_result('.poll-please-wait');
- const poll_author_help = set_widget_find_result('.poll-author-help');
+ const poll_vote_button = set_widget_find_result("button.poll-vote");
+ const poll_please_wait = set_widget_find_result(".poll-please-wait");
+ const poll_author_help = set_widget_find_result(".poll-author-help");
- set_widget_find_result('button.poll-question-remove');
- set_widget_find_result('input.poll-question');
+ set_widget_find_result("button.poll-question-remove");
+ set_widget_find_result("input.poll-question");
let option_button_callback;
let vote_button_callback;
poll_option.on = (event, func) => {
- assert.equal(event, 'click');
+ assert.equal(event, "click");
option_button_callback = func;
};
poll_vote_button.on = (event, func) => {
- assert.equal(event, 'click');
+ assert.equal(event, "click");
vote_button_callback = func;
};
@@ -229,9 +229,9 @@ run_test('activate another person poll', () => {
poll_widget.activate(opts);
- assert.equal(widget_elem.html(), 'widgets/poll_widget');
- assert.equal(widget_option_container.html(), 'widgets/poll_widget_results');
- assert.equal(poll_question_header.text(), 'What do you want?');
+ assert.equal(widget_elem.html(), "widgets/poll_widget");
+ assert.equal(widget_option_container.html(), "widgets/poll_widget_results");
+ assert.equal(poll_question_header.text(), "What do you want?");
const e = {
stopPropagation: noop,
@@ -239,12 +239,12 @@ run_test('activate another person poll', () => {
{
/* Testing data sent to server on adding option */
- poll_option_input.val('cool choice');
+ poll_option_input.val("cool choice");
out_data = undefined;
option_button_callback(e);
- assert.deepEqual(out_data, { type: 'new_option', idx: 1, option: 'cool choice' });
+ assert.deepEqual(out_data, { type: "new_option", idx: 1, option: "cool choice" });
- poll_option_input.val('');
+ poll_option_input.val("");
out_data = undefined;
option_button_callback(e);
assert.deepEqual(out_data, undefined);
@@ -254,16 +254,16 @@ run_test('activate another person poll', () => {
{
sender_id: 100,
data: {
- type: 'new_option',
+ type: "new_option",
idx: 1,
- option: 'release now',
+ option: "release now",
},
},
{
sender_id: 100,
data: {
- type: 'vote',
- key: '100,1',
+ type: "vote",
+ key: "100,1",
vote: 1,
},
},
@@ -273,22 +273,22 @@ run_test('activate another person poll', () => {
{
/* Testing data sent to server on voting */
- poll_vote_button.attr('data-key', '100,1');
+ poll_vote_button.attr("data-key", "100,1");
const e = {
stopPropagation: noop,
target: poll_vote_button,
};
out_data = undefined;
vote_button_callback(e);
- assert.deepEqual(out_data, { type: 'vote', key: '100,1', vote: 1 });
+ assert.deepEqual(out_data, { type: "vote", key: "100,1", vote: 1 });
}
const add_question_event = [
{
sender_id: 100,
data: {
- type: 'question',
- question: 'best plan?',
+ type: "question",
+ question: "best plan?",
},
},
];
@@ -296,20 +296,20 @@ run_test('activate another person poll', () => {
widget_elem.handle_events(add_question_event);
});
-run_test('activate own poll', () => {
+run_test("activate own poll", () => {
$.clear_all_elements();
people.is_my_user_id = return_true;
global.stub_templates((template_name) => {
- if (template_name === 'widgets/poll_widget') {
- return 'widgets/poll_widget';
+ if (template_name === "widgets/poll_widget") {
+ return "widgets/poll_widget";
}
- if (template_name === 'widgets/poll_widget_results') {
- return 'widgets/poll_widget_results';
+ if (template_name === "widgets/poll_widget_results") {
+ return "widgets/poll_widget_results";
}
});
- const widget_elem = $('<div>').addClass('widget-content');
+ const widget_elem = $("<div>").addClass("widget-content");
let out_data;
const callback = (data) => {
out_data = data;
@@ -321,7 +321,7 @@ run_test('activate own poll', () => {
sender_id: 100,
},
extra_data: {
- question: 'Where to go?',
+ question: "Where to go?",
},
};
@@ -331,27 +331,27 @@ run_test('activate own poll', () => {
return elem;
};
- const poll_option = set_widget_find_result('button.poll-option');
- const poll_option_input = set_widget_find_result('input.poll-option');
- const widget_option_container = set_widget_find_result('ul.poll-widget');
+ const poll_option = set_widget_find_result("button.poll-option");
+ const poll_option_input = set_widget_find_result("input.poll-option");
+ const widget_option_container = set_widget_find_result("ul.poll-widget");
- const poll_question_submit = set_widget_find_result('button.poll-question-check');
- const poll_edit_question = set_widget_find_result('.poll-edit-question');
- const poll_question_input = set_widget_find_result('input.poll-question');
- const poll_question_header = set_widget_find_result('.poll-question-header');
- const poll_question_container = set_widget_find_result('.poll-question-bar');
- const poll_option_container = set_widget_find_result('.poll-option-bar');
+ const poll_question_submit = set_widget_find_result("button.poll-question-check");
+ const poll_edit_question = set_widget_find_result(".poll-edit-question");
+ const poll_question_input = set_widget_find_result("input.poll-question");
+ const poll_question_header = set_widget_find_result(".poll-question-header");
+ const poll_question_container = set_widget_find_result(".poll-question-bar");
+ const poll_option_container = set_widget_find_result(".poll-option-bar");
- const poll_vote_button = set_widget_find_result('button.poll-vote');
- const poll_please_wait = set_widget_find_result('.poll-please-wait');
- const poll_author_help = set_widget_find_result('.poll-author-help');
+ const poll_vote_button = set_widget_find_result("button.poll-vote");
+ const poll_please_wait = set_widget_find_result(".poll-please-wait");
+ const poll_author_help = set_widget_find_result(".poll-author-help");
- set_widget_find_result('button.poll-question-remove');
+ set_widget_find_result("button.poll-question-remove");
let question_button_callback;
poll_question_submit.on = (event, func) => {
- assert.equal(event, 'click');
+ assert.equal(event, "click");
question_button_callback = func;
};
@@ -391,9 +391,9 @@ run_test('activate own poll', () => {
poll_widget.activate(opts);
- assert.equal(widget_elem.html(), 'widgets/poll_widget');
- assert.equal(widget_option_container.html(), 'widgets/poll_widget_results');
- assert.equal(poll_question_header.text(), 'Where to go?');
+ assert.equal(widget_elem.html(), "widgets/poll_widget");
+ assert.equal(widget_option_container.html(), "widgets/poll_widget_results");
+ assert.equal(poll_question_header.text(), "Where to go?");
{
/* Testing data sent to server on editing question */
@@ -401,13 +401,13 @@ run_test('activate own poll', () => {
stopPropagation: noop,
};
- poll_question_input.val('Is it new?');
+ poll_question_input.val("Is it new?");
out_data = undefined;
show_submit = true;
question_button_callback(e);
- assert.deepEqual(out_data, { type: 'question', question: 'Is it new?' });
+ assert.deepEqual(out_data, { type: "question", question: "Is it new?" });
- poll_option_input.val('');
+ poll_option_input.val("");
out_data = undefined;
question_button_callback(e);
assert.deepEqual(out_data, undefined);
diff --git a/frontend_tests/node_tests/popovers.js b/frontend_tests/node_tests/popovers.js
index ef079a768bc..ccce5455b83 100644
--- a/frontend_tests/node_tests/popovers.js
+++ b/frontend_tests/node_tests/popovers.js
@@ -1,38 +1,38 @@
-set_global('$', global.make_zjquery());
-
-zrequire('hash_util');
-zrequire('narrow');
-zrequire('narrow_state');
-zrequire('people');
-zrequire('presence');
-zrequire('buddy_data');
-zrequire('user_status');
-zrequire('feature_flags');
-zrequire('message_edit');
+set_global("$", global.make_zjquery());
+
+zrequire("hash_util");
+zrequire("narrow");
+zrequire("narrow_state");
+zrequire("people");
+zrequire("presence");
+zrequire("buddy_data");
+zrequire("user_status");
+zrequire("feature_flags");
+zrequire("message_edit");
const noop = function () {};
$.fn.popover = noop; // this will get wrapped by our code
-zrequire('popovers');
+zrequire("popovers");
popovers.hide_user_profile = noop;
-set_global('current_msg_list', {});
-set_global('page_params', {
+set_global("current_msg_list", {});
+set_global("page_params", {
is_admin: false,
realm_email_address_visibility: 3,
custom_profile_fields: [],
});
-set_global('rows', {});
+set_global("rows", {});
-set_global('message_viewport', {
+set_global("message_viewport", {
height: () => 500,
});
-set_global('emoji_picker', {
+set_global("emoji_picker", {
hide_emoji_popover: noop,
});
-set_global('stream_popover', {
+set_global("stream_popover", {
hide_stream_popover: noop,
hide_topic_popover: noop,
hide_all_messages_popover: noop,
@@ -40,16 +40,16 @@ set_global('stream_popover', {
hide_streamlist_sidebar: noop,
});
-set_global('stream_data', {});
+set_global("stream_data", {});
function ClipboardJS(sel) {
- assert.equal(sel, '.copy_link');
+ assert.equal(sel, ".copy_link");
}
-set_global('ClipboardJS', ClipboardJS);
+set_global("ClipboardJS", ClipboardJS);
const alice = {
- email: '[email protected]',
- full_name: 'Alice Smith',
+ email: "[email protected]",
+ full_name: "Alice Smith",
user_id: 42,
avatar_version: 5,
is_guest: false,
@@ -57,13 +57,13 @@ const alice = {
};
const me = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 30,
- full_name: 'Me Myself',
- timezone: 'US/Pacific',
+ full_name: "Me Myself",
+ timezone: "US/Pacific",
};
-const target = $.create('click target');
+const target = $.create("click target");
target.offset = () => ({
top: 10,
});
@@ -96,7 +96,7 @@ function make_image_stubber() {
return image;
}
- set_global('Image', stub_image);
+ set_global("Image", stub_image);
return {
get: (i) => images[i],
@@ -105,9 +105,9 @@ function make_image_stubber() {
popovers.register_click_handlers();
-run_test('sender_hover', () => {
+run_test("sender_hover", () => {
const selection = ".sender_name, .sender_name-in-status, .inline_profile_picture";
- const handler = $('#main_div').get_on_handler('click', selection);
+ const handler = $("#main_div").get_on_handler("click", selection);
const message = {
id: 999,
@@ -116,7 +116,7 @@ run_test('sender_hover', () => {
user_status.set_status_text({
user_id: alice.user_id,
- status_text: 'on the beach',
+ status_text: "on the beach",
});
rows.id = () => message.id;
@@ -131,82 +131,82 @@ run_test('sender_hover', () => {
};
target.closest = (sel) => {
- assert.equal(sel, '.message_row');
+ assert.equal(sel, ".message_row");
return {};
};
global.stub_templates((fn, opts) => {
switch (fn) {
- case 'no_arrow_popover':
+ case "no_arrow_popover":
assert.deepEqual(opts, {
- class: 'message-info-popover',
+ class: "message-info-popover",
});
- return 'popover-html';
+ return "popover-html";
- case 'user_info_popover_title':
+ case "user_info_popover_title":
assert.deepEqual(opts, {
- user_avatar: 'avatar/[email protected]',
+ user_avatar: "avatar/[email protected]",
user_is_guest: false,
});
- return 'title-html';
+ return "title-html";
- case 'user_info_popover_content':
+ 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_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',
+ 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',
+ status_text: "on the beach",
});
- return 'content-html';
+ return "content-html";
default:
- throw Error('unrecognized template: ' + fn);
+ throw Error("unrecognized template: " + fn);
}
});
- $('.user_popover_email').each = noop;
+ $(".user_popover_email").each = noop;
const image_stubber = make_image_stubber();
window.location = {
- href: 'http://chat.zulip.org/',
+ href: "http://chat.zulip.org/",
};
const base_url = window.location.href;
handler.call(target, e);
const avatar_img = image_stubber.get(0);
- const expected_url = new URL('avatar/42/medium?v=' + alice.avatar_version, base_url);
+ const expected_url = new URL("avatar/42/medium?v=" + alice.avatar_version, base_url);
assert.equal(avatar_img.src.toString(), expected_url.toString());
// todo: load image
});
-run_test('actions_popover', () => {
- const handler = $('#main_div').get_on_handler('click', '.actions_hover');
+run_test("actions_popover", () => {
+ const handler = $("#main_div").get_on_handler("click", ".actions_hover");
window.location = {
- protocol: 'http:',
- host: 'chat.zulip.org',
- pathname: '/',
+ protocol: "http:",
+ host: "chat.zulip.org",
+ pathname: "/",
};
const message = {
id: 999,
- topic: 'Actions (1)',
- type: 'stream',
+ topic: "Actions (1)",
+ type: "stream",
stream_id: 123,
};
@@ -219,11 +219,11 @@ run_test('actions_popover', () => {
stream_data.id_to_slug = (stream_id) => {
assert.equal(stream_id, 123);
- return 'Bracket ( stream';
+ return "Bracket ( stream";
};
target.closest = (sel) => {
- assert.equal(sel, '.message_row');
+ assert.equal(sel, ".message_row");
return {
toggleClass: noop,
};
@@ -232,13 +232,13 @@ run_test('actions_popover', () => {
global.stub_templates((fn, opts) => {
// TODO: Test all the properties of the popover
switch (fn) {
- case 'actions_popover_content':
+ 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';
+ "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);
+ throw Error("unrecognized template: " + fn);
}
});
diff --git a/frontend_tests/node_tests/presence.js b/frontend_tests/node_tests/presence.js
index 256e738e594..39f5d5f6798 100644
--- a/frontend_tests/node_tests/presence.js
+++ b/frontend_tests/node_tests/presence.js
@@ -1,64 +1,64 @@
-zrequire('people');
-zrequire('presence');
+zrequire("people");
+zrequire("presence");
const return_false = function () { return false; };
-set_global('server_events', {});
-set_global('reload_state', {
+set_global("server_events", {});
+set_global("reload_state", {
is_in_progress: return_false,
});
function XDate(ms) {
return {seconds: ms};
}
-set_global('XDate', XDate);
+set_global("XDate", XDate);
const OFFLINE_THRESHOLD_SECS = 140;
const me = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 101,
- full_name: 'Me Myself',
+ full_name: "Me Myself",
};
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 1,
- full_name: 'Alice Smith',
+ full_name: "Alice Smith",
};
const fred = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 2,
full_name: "Fred Flintstone",
};
const sally = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 3,
- full_name: 'Sally Jones',
+ full_name: "Sally Jones",
};
const zoe = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 6,
- full_name: 'Zoe Yang',
+ full_name: "Zoe Yang",
};
const bot = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 7,
- full_name: 'The Bot',
+ full_name: "The Bot",
is_bot: true,
};
const john = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 8,
full_name: "John Doe",
};
const jane = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 9,
full_name: "Jane Doe",
};
@@ -73,17 +73,17 @@ people.add_active_user(john);
people.add_active_user(jane);
people.initialize_current_user(me.user_id);
-run_test('my user', () => {
- assert.equal(presence.get_status(me.user_id), 'active');
+run_test("my user", () => {
+ assert.equal(presence.get_status(me.user_id), "active");
});
-run_test('unknown user', () => {
+run_test("unknown user", () => {
const unknown_user_id = 999;
const now = 888888;
const presences = {};
- presences[unknown_user_id.toString()] = 'does-not-matter';
+ presences[unknown_user_id.toString()] = "does-not-matter";
- blueslip.expect('error', 'Unknown user ID in presence data: 999');
+ blueslip.expect("error", "Unknown user ID in presence data: 999");
presence.set_info(presences, now);
// If the server is suspected to be offline or reloading,
@@ -98,7 +98,7 @@ run_test('unknown user', () => {
reload_state.is_in_progress = () => false;
});
-run_test('status_from_raw', () => {
+run_test("status_from_raw", () => {
const status_from_raw = presence.status_from_raw;
const now = 5000;
@@ -112,7 +112,7 @@ run_test('status_from_raw', () => {
assert.deepEqual(
status_from_raw(raw),
{
- status: 'active',
+ status: "active",
last_active: raw.active_timestamp,
},
);
@@ -125,7 +125,7 @@ run_test('status_from_raw', () => {
assert.deepEqual(
status_from_raw(raw),
{
- status: 'offline',
+ status: "offline",
last_active: raw.active_timestamp,
},
);
@@ -138,13 +138,13 @@ run_test('status_from_raw', () => {
assert.deepEqual(
status_from_raw(raw),
{
- status: 'idle',
+ status: "idle",
last_active: raw.idle_timestamp,
},
);
});
-run_test('set_presence_info', () => {
+run_test("set_presence_info", () => {
const presences = {};
const now = 5000;
const recent = now + 1 - OFFLINE_THRESHOLD_SECS;
@@ -181,51 +181,51 @@ run_test('set_presence_info', () => {
presence.initialize(params);
assert.deepEqual(presence.presence_info.get(alice.user_id),
- { status: 'active', last_active: recent},
+ { status: "active", last_active: recent},
);
- assert.equal(presence.get_status(alice.user_id), 'active');
+ 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},
+ { status: "idle", last_active: now},
);
- assert.equal(presence.get_status(fred.user_id), 'idle');
+ assert.equal(presence.get_status(fred.user_id), "idle");
assert.deepEqual(presence.presence_info.get(me.user_id),
- { status: 'active', last_active: now},
+ { status: "active", last_active: now},
);
- assert.equal(presence.get_status(me.user_id), 'active');
+ 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},
+ { status: "offline", last_active: a_while_ago},
);
- assert.equal(presence.get_status(sally.user_id), 'offline');
+ assert.equal(presence.get_status(sally.user_id), "offline");
assert.deepEqual(presence.presence_info.get(zoe.user_id),
- { status: 'offline', last_active: undefined},
+ { status: "offline", last_active: undefined},
);
- assert.equal(presence.get_status(zoe.user_id), 'offline');
+ 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.equal(presence.get_status(bot.user_id), "offline");
assert.deepEqual(presence.presence_info.get(john.user_id),
- { status: 'offline', last_active: a_while_ago},
+ { status: "offline", last_active: a_while_ago},
);
- assert.equal(presence.get_status(john.user_id), 'offline');
+ assert.equal(presence.get_status(john.user_id), "offline");
assert.deepEqual(presence.presence_info.get(jane.user_id),
- { status: 'idle', last_active: now},
+ { status: "idle", last_active: now},
);
- assert.equal(presence.get_status(jane.user_id), 'idle');
+ assert.equal(presence.get_status(jane.user_id), "idle");
});
-run_test('falsy values', () => {
+run_test("falsy values", () => {
/*
When a user does not have a relevant active timestamp,
the server just leaves off the `active_timestamp` field
@@ -250,7 +250,7 @@ run_test('falsy values', () => {
assert.deepEqual(
presence.presence_info.get(zoe.user_id),
- { status: 'idle', last_active: a_bit_ago },
+ { status: "idle", last_active: a_bit_ago },
);
presences[zoe.user_id.toString()] = {
@@ -262,12 +262,12 @@ run_test('falsy values', () => {
assert.deepEqual(
presence.presence_info.get(zoe.user_id),
- { status: 'offline', last_active: undefined },
+ { status: "offline", last_active: undefined },
);
}
});
-run_test('big realms', () => {
+run_test("big realms", () => {
const presences = {};
const now = 5000;
@@ -286,7 +286,7 @@ run_test('big realms', () => {
people.get_active_human_count = get_active_human_count;
});
-run_test('last_active_date', () => {
+run_test("last_active_date", () => {
const unknown_id = 42;
presence.presence_info.clear();
presence.presence_info.set(alice.user_id, { last_active: 500 });
@@ -297,7 +297,7 @@ run_test('last_active_date', () => {
assert.deepEqual(presence.last_active_date(alice.user_id), {seconds: 500000});
});
-run_test('update_info_from_event', () => {
+run_test("update_info_from_event", () => {
let info;
info = {
@@ -312,7 +312,7 @@ run_test('update_info_from_event', () => {
assert.deepEqual(
presence.presence_info.get(alice.user_id),
- { status: 'active', last_active: 500 },
+ { status: "active", last_active: 500 },
);
info = {
@@ -325,7 +325,7 @@ run_test('update_info_from_event', () => {
assert.deepEqual(
presence.presence_info.get(alice.user_id),
- { status: 'active', last_active: 510 },
+ { status: "active", last_active: 510 },
);
info = {
@@ -338,6 +338,6 @@ run_test('update_info_from_event', () => {
assert.deepEqual(
presence.presence_info.get(alice.user_id),
- { status: 'idle', last_active: 1000 },
+ { status: "idle", last_active: 1000 },
);
});
diff --git a/frontend_tests/node_tests/reactions.js b/frontend_tests/node_tests/reactions.js
index fc9148b9cfb..c4dd4121094 100644
--- a/frontend_tests/node_tests/reactions.js
+++ b/frontend_tests/node_tests/reactions.js
@@ -1,29 +1,29 @@
-set_global('document', 'document-stub');
-set_global('$', global.make_zjquery());
+set_global("document", "document-stub");
+set_global("$", global.make_zjquery());
-zrequire('emoji');
-zrequire('people');
-zrequire('reactions');
+zrequire("emoji");
+zrequire("people");
+zrequire("reactions");
-set_global('page_params', {
+set_global("page_params", {
user_id: 5,
realm_emoji: {
991: {
- id: '991',
- name: 'realm_emoji',
- source_url: 'TBD',
+ id: "991",
+ name: "realm_emoji",
+ source_url: "TBD",
deactivated: false,
},
992: {
- id: '992',
- name: 'inactive_realm_emoji',
- source_url: 'TBD',
+ id: "992",
+ name: "inactive_realm_emoji",
+ source_url: "TBD",
deactivated: true,
},
zulip: {
- id: 'zulip',
- name: 'zulip',
- source_url: 'TBD',
+ id: "zulip",
+ name: "zulip",
+ source_url: "TBD",
deactivated: false,
},
},
@@ -31,25 +31,25 @@ set_global('page_params', {
emoji.initialize();
-set_global('channel', {});
-set_global('emoji_picker', {
+set_global("channel", {});
+set_global("emoji_picker", {
hide_emoji_popover: function () {},
});
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 5,
- full_name: 'Alice',
+ full_name: "Alice",
};
const bob = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 6,
- full_name: 'Bob van Roberts',
+ full_name: "Bob van Roberts",
};
const cali = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 7,
- full_name: 'Cali',
+ full_name: "Cali",
};
people.add_active_user(alice);
people.add_active_user(bob);
@@ -58,46 +58,46 @@ people.add_active_user(cali);
const message = {
id: 1001,
reactions: [
- {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: "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"},
// add some bogus user_ids
- {emoji_name: 'octopus', user_id: 8888, reaction_type: 'unicode_emoji', emoji_code: '1f419'},
- {emoji_name: 'frown', user_id: 9999, reaction_type: 'unicode_emoji', emoji_code: '1f641'},
+ {emoji_name: "octopus", user_id: 8888, reaction_type: "unicode_emoji", emoji_code: "1f419"},
+ {emoji_name: "frown", user_id: 9999, reaction_type: "unicode_emoji", emoji_code: "1f641"},
],
};
-set_global('message_store', {
+set_global("message_store", {
get: function (message_id) {
assert.equal(message_id, 1001);
return message;
},
});
-set_global('current_msg_list', {
+set_global("current_msg_list", {
selected_message: function () {
return { sent_by_me: true };
},
selected_row: function () {
- return $('.selected-row');
+ return $(".selected-row");
},
selected_id: function () {
return 42;
},
});
-run_test('open_reactions_popover', () => {
- $('.selected-row').set_find_results('.actions_hover', $('.target-action'));
- $('.selected-row').set_find_results('.reaction_button', $('.target-reaction'));
+run_test("open_reactions_popover", () => {
+ $(".selected-row").set_find_results(".actions_hover", $(".target-action"));
+ $(".selected-row").set_find_results(".reaction_button", $(".target-reaction"));
let called = false;
emoji_picker.toggle_emoji_popover = function (target, id) {
called = true;
assert.equal(id, 42);
- assert.equal(target, $('.target-reaction')[0]);
+ assert.equal(target, $(".target-reaction")[0]);
};
assert(reactions.open_reactions_popover());
@@ -109,65 +109,65 @@ run_test('open_reactions_popover', () => {
emoji_picker.toggle_emoji_popover = function (target, id) {
called = true;
assert.equal(id, 42);
- assert.equal(target, $('.target-action')[0]);
+ assert.equal(target, $(".target-action")[0]);
};
assert(reactions.open_reactions_popover());
assert(called);
});
-run_test('basics', () => {
- blueslip.expect('warn', 'Unknown user_id 8888 in reaction for message 1001');
- blueslip.expect('warn', 'Unknown user_id 9999 in reaction for message 1001');
+run_test("basics", () => {
+ blueslip.expect("warn", "Unknown user_id 8888 in reaction for message 1001");
+ blueslip.expect("warn", "Unknown user_id 9999 in reaction for message 1001");
const result = reactions.get_message_reactions(message);
- assert(reactions.current_user_has_reacted_to_emoji(message, 'unicode_emoji,263a'));
- assert(!reactions.current_user_has_reacted_to_emoji(message, 'bogus'));
+ assert(reactions.current_user_has_reacted_to_emoji(message, "unicode_emoji,263a"));
+ assert(!reactions.current_user_has_reacted_to_emoji(message, "bogus"));
result.sort((a, b) => a.count - b.count);
const expected_result = [
{
- emoji_name: 'frown',
- reaction_type: 'unicode_emoji',
- emoji_code: '1f641',
- local_id: 'unicode_emoji,1f641',
+ emoji_name: "frown",
+ reaction_type: "unicode_emoji",
+ emoji_code: "1f641",
+ local_id: "unicode_emoji,1f641",
count: 1,
user_ids: [7],
- label: 'Cali reacted with :frown:',
+ label: "Cali reacted with :frown:",
emoji_alt_code: false,
- class: 'message_reaction',
+ class: "message_reaction",
},
{
- emoji_name: 'inactive_realm_emoji',
- reaction_type: 'realm_emoji',
- emoji_code: '992',
- local_id: 'realm_emoji,992',
+ emoji_name: "inactive_realm_emoji",
+ reaction_type: "realm_emoji",
+ emoji_code: "992",
+ local_id: "realm_emoji,992",
count: 1,
user_ids: [5],
- label: 'You (click to remove) reacted with :inactive_realm_emoji:',
+ label: "You (click to remove) reacted with :inactive_realm_emoji:",
emoji_alt_code: false,
is_realm_emoji: true,
- url: 'TBD',
- class: 'message_reaction reacted',
+ url: "TBD",
+ class: "message_reaction reacted",
},
{
- emoji_name: 'smile',
- reaction_type: 'unicode_emoji',
- emoji_code: '263a',
- local_id: 'unicode_emoji,263a',
+ emoji_name: "smile",
+ reaction_type: "unicode_emoji",
+ emoji_code: "263a",
+ local_id: "unicode_emoji,263a",
count: 2,
user_ids: [5, 6],
- label: 'You (click to remove) and Bob van Roberts reacted with :smile:',
+ label: "You (click to remove) and Bob van Roberts reacted with :smile:",
emoji_alt_code: false,
- class: 'message_reaction reacted',
+ class: "message_reaction reacted",
},
];
assert.deepEqual(result, expected_result);
});
-run_test('sending', () => {
+run_test("sending", () => {
const message_id = 1001; // see above for setup
- let emoji_name = 'smile'; // should be a current reaction
+ let emoji_name = "smile"; // should be a current reaction
const orig_remove_reaction = reactions.remove_reaction;
const orig_add_reaction = reactions.add_reaction;
@@ -177,115 +177,115 @@ run_test('sending', () => {
global.with_stub((stub) => {
global.channel.del = stub.f;
reactions.toggle_emoji_reaction(message_id, emoji_name);
- const args = stub.get_args('args').args;
- assert.equal(args.url, '/json/messages/1001/reactions');
+ const args = stub.get_args("args").args;
+ assert.equal(args.url, "/json/messages/1001/reactions");
assert.deepEqual(args.data, {
- reaction_type: 'unicode_emoji',
- emoji_name: 'smile',
- emoji_code: '263a',
+ reaction_type: "unicode_emoji",
+ emoji_name: "smile",
+ emoji_code: "263a",
});
// args.success() does nothing; just make sure it doesn't crash
args.success();
// 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.';};
+ blueslip.expect("warn", "XHR Error Message.");
+ global.channel.xhr_error_message = function () {return "XHR Error Message.";};
args.error();
});
- emoji_name = 'alien'; // not set yet
+ emoji_name = "alien"; // not set yet
global.with_stub((stub) => {
global.channel.post = stub.f;
reactions.toggle_emoji_reaction(message_id, emoji_name);
- const args = stub.get_args('args').args;
- assert.equal(args.url, '/json/messages/1001/reactions');
+ const args = stub.get_args("args").args;
+ assert.equal(args.url, "/json/messages/1001/reactions");
assert.deepEqual(args.data, {
- reaction_type: 'unicode_emoji',
- emoji_name: 'alien',
- emoji_code: '1f47d',
+ reaction_type: "unicode_emoji",
+ emoji_name: "alien",
+ emoji_code: "1f47d",
});
});
- emoji_name = 'inactive_realm_emoji';
+ emoji_name = "inactive_realm_emoji";
global.with_stub((stub) => {
// Test removing a deactivated realm emoji. An user can interact with a
// deactivated realm emoji only by clicking on a reaction, hence, only
// `process_reaction_click()` codepath supports deleting/adding a deactivated
// realm emoji.
global.channel.del = stub.f;
- reactions.process_reaction_click(message_id, 'realm_emoji,992');
- const args = stub.get_args('args').args;
- assert.equal(args.url, '/json/messages/1001/reactions');
+ reactions.process_reaction_click(message_id, "realm_emoji,992");
+ const args = stub.get_args("args").args;
+ assert.equal(args.url, "/json/messages/1001/reactions");
assert.deepEqual(args.data, {
- reaction_type: 'realm_emoji',
- emoji_name: 'inactive_realm_emoji',
- emoji_code: '992',
+ reaction_type: "realm_emoji",
+ emoji_name: "inactive_realm_emoji",
+ emoji_code: "992",
});
});
- emoji_name = 'zulip'; // Test adding zulip emoji.
+ emoji_name = "zulip"; // Test adding zulip emoji.
global.with_stub((stub) => {
global.channel.post = stub.f;
reactions.toggle_emoji_reaction(message_id, emoji_name);
- const args = stub.get_args('args').args;
- assert.equal(args.url, '/json/messages/1001/reactions');
+ const args = stub.get_args("args").args;
+ assert.equal(args.url, "/json/messages/1001/reactions");
assert.deepEqual(args.data, {
- reaction_type: 'zulip_extra_emoji',
- emoji_name: 'zulip',
- emoji_code: 'zulip',
+ reaction_type: "zulip_extra_emoji",
+ emoji_name: "zulip",
+ emoji_code: "zulip",
});
});
- emoji_name = 'unknown-emoji'; // Test sending an emoji unknown to frontend.
- blueslip.expect('warn', 'Bad emoji name: ' + emoji_name);
+ emoji_name = "unknown-emoji"; // Test sending an emoji unknown to frontend.
+ blueslip.expect("warn", "Bad emoji name: " + emoji_name);
reactions.toggle_emoji_reaction(message_id, emoji_name);
reactions.add_reaction = orig_add_reaction;
reactions.remove_reaction = orig_remove_reaction;
});
-run_test('set_reaction_count', () => {
- const count_element = $.create('count-stub');
- const reaction_element = $.create('reaction-stub');
+run_test("set_reaction_count", () => {
+ const count_element = $.create("count-stub");
+ const reaction_element = $.create("reaction-stub");
- reaction_element.set_find_results('.message_reaction_count', count_element);
+ reaction_element.set_find_results(".message_reaction_count", count_element);
reactions.set_reaction_count(reaction_element, 5);
- assert.equal(count_element.text(), '5');
+ assert.equal(count_element.text(), "5");
});
-run_test('get_reaction_section', () => {
- const message_table = $.create('.message_table');
- const message_row = $.create('some-message-row');
- const message_reactions = $.create('our-reactions-section');
+run_test("get_reaction_section", () => {
+ const message_table = $.create(".message_table");
+ const message_row = $.create("some-message-row");
+ const message_reactions = $.create("our-reactions-section");
message_table.set_find_results("[zid='555']", message_row);
- message_row.set_find_results('.message_reactions', message_reactions);
+ message_row.set_find_results(".message_reactions", message_reactions);
const section = reactions.get_reaction_section(555);
assert.equal(section, message_reactions);
});
-run_test('emoji_reaction_title', () => {
+run_test("emoji_reaction_title", () => {
const message_id = 1001;
- const local_id = 'unicode_emoji,263a';
+ 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:");
});
-run_test('add_and_remove_reaction', () => {
+run_test("add_and_remove_reaction", () => {
// Insert 8ball for Alice.
let alice_event = {
message_id: 1001,
- reaction_type: 'unicode_emoji',
- emoji_name: '8ball',
- emoji_code: '1f3b1',
+ reaction_type: "unicode_emoji",
+ emoji_name: "8ball",
+ emoji_code: "1f3b1",
user_id: alice.user_id,
};
- const message_reactions = $.create('our-reactions');
+ const message_reactions = $.create("our-reactions");
reactions.get_reaction_section = function (message_id) {
assert.equal(message_id, 1001);
@@ -293,24 +293,24 @@ run_test('add_and_remove_reaction', () => {
};
message_reactions.find = function (selector) {
- assert.equal(selector, '.reaction_button');
- return 'reaction-button-stub';
+ assert.equal(selector, ".reaction_button");
+ return "reaction-button-stub";
};
let template_called;
global.stub_templates((template_name, data) => {
template_called = true;
- assert.equal(template_name, 'message_reaction');
- assert.equal(data.class, 'message_reaction reacted');
+ assert.equal(template_name, "message_reaction");
+ assert.equal(data.class, "message_reaction reacted");
assert(!data.is_realm_emoji);
assert.equal(data.message_id, 1001);
- assert.equal(data.label, 'You (click to remove) reacted with :8ball:');
- return '<new reaction html>';
+ assert.equal(data.label, "You (click to remove) reacted with :8ball:");
+ return "<new reaction html>";
});
let insert_called;
- $('<new reaction html>').insertBefore = function (element) {
- assert.equal(element, 'reaction-button-stub');
+ $("<new reaction html>").insertBefore = function (element) {
+ assert.equal(element, "reaction-button-stub");
insert_called = true;
};
@@ -319,7 +319,7 @@ run_test('add_and_remove_reaction', () => {
assert(insert_called);
// Testing tooltip title data for added reaction.
- const local_id = 'unicode_emoji,1f3b1';
+ 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:");
@@ -334,15 +334,15 @@ run_test('add_and_remove_reaction', () => {
const bob_event = {
message_id: 1001,
- reaction_type: 'unicode_emoji',
- emoji_name: '8ball',
- emoji_code: '1f3b1',
+ reaction_type: "unicode_emoji",
+ emoji_name: "8ball",
+ emoji_code: "1f3b1",
user_id: bob.user_id,
};
- const count_element = $.create('count-element');
- const reaction_element = $.create('reaction-element');
- reaction_element.set_find_results('.message_reaction_count', count_element);
+ const count_element = $.create("count-element");
+ const reaction_element = $.create("reaction-element");
+ reaction_element.set_find_results(".message_reaction_count", count_element);
message_reactions.find = function (selector) {
assert.equal(selector, "[data-reaction-id='unicode_emoji,1f3b1']");
@@ -350,13 +350,13 @@ run_test('add_and_remove_reaction', () => {
};
reactions.add_reaction(bob_event);
- assert.equal(count_element.text(), '2');
+ assert.equal(count_element.text(), "2");
reactions.remove_reaction(bob_event);
- assert.equal(count_element.text(), '1');
+ assert.equal(count_element.text(), "1");
let current_emojis = reactions.get_emojis_used_by_user_for_message_id(1001);
- assert.deepEqual(current_emojis, ['smile', 'inactive_realm_emoji', '8ball']);
+ assert.deepEqual(current_emojis, ["smile", "inactive_realm_emoji", "8ball"]);
// Next, remove Alice's reaction, which exercises removing the
// emoji icon.
@@ -374,40 +374,40 @@ run_test('add_and_remove_reaction', () => {
assert(!removed);
current_emojis = reactions.get_emojis_used_by_user_for_message_id(1001);
- assert.deepEqual(current_emojis, ['smile', 'inactive_realm_emoji']);
+ assert.deepEqual(current_emojis, ["smile", "inactive_realm_emoji"]);
// Now add Cali's realm_emoji reaction.
const cali_event = {
message_id: 1001,
- reaction_type: 'realm_emoji',
- emoji_name: 'realm_emoji',
- emoji_code: '991',
+ reaction_type: "realm_emoji",
+ emoji_name: "realm_emoji",
+ emoji_code: "991",
user_id: cali.user_id,
};
template_called = false;
global.stub_templates((template_name, data) => {
- assert.equal(data.class, 'message_reaction');
+ assert.equal(data.class, "message_reaction");
assert(data.is_realm_emoji);
template_called = true;
- return '<new reaction html>';
+ return "<new reaction html>";
});
message_reactions.find = function (selector) {
- assert.equal(selector, '.reaction_button');
- return 'reaction-button-stub';
+ assert.equal(selector, ".reaction_button");
+ return "reaction-button-stub";
};
reactions.add_reaction(cali_event);
assert(template_called);
- assert(!reaction_element.hasClass('reacted'));
+ assert(!reaction_element.hasClass("reacted"));
// And then have Alice update it.
alice_event = {
message_id: 1001,
- reaction_type: 'realm_emoji',
- emoji_name: 'realm_emoji',
- emoji_code: '991',
+ reaction_type: "realm_emoji",
+ emoji_name: "realm_emoji",
+ emoji_code: "991",
user_id: alice.user_id,
};
@@ -419,18 +419,18 @@ run_test('add_and_remove_reaction', () => {
reactions.add_reaction(alice_event);
const result = reactions.get_message_reactions(message);
- assert(reaction_element.hasClass('reacted'));
- const realm_emoji_data = result.filter((v) => v.emoji_name === 'realm_emoji')[0];
+ assert(reaction_element.hasClass("reacted"));
+ const realm_emoji_data = result.filter((v) => v.emoji_name === "realm_emoji")[0];
assert.equal(realm_emoji_data.count, 2);
assert.equal(realm_emoji_data.is_realm_emoji, true);
// And then remove Alice's reaction.
reactions.remove_reaction(alice_event);
- assert(!reaction_element.hasClass('reacted'));
+ assert(!reaction_element.hasClass("reacted"));
});
-run_test('with_view_stubs', () => {
+run_test("with_view_stubs", () => {
// This function tests reaction events by mocking out calls to
// the view.
@@ -456,9 +456,9 @@ run_test('with_view_stubs', () => {
}
reactions.view = {
- insert_new_reaction: add_call_func('insert_new_reaction'),
- update_existing_reaction: add_call_func('update_existing_reaction'),
- remove_reaction: add_call_func('remove_reaction'),
+ insert_new_reaction: add_call_func("insert_new_reaction"),
+ update_existing_reaction: add_call_func("update_existing_reaction"),
+ remove_reaction: add_call_func("remove_reaction"),
};
test_params.run_code();
@@ -468,25 +468,25 @@ run_test('with_view_stubs', () => {
const alice_8ball_event = {
message_id: 2001,
- reaction_type: 'unicode_emoji',
- emoji_name: '8ball',
- emoji_code: '1f3b1',
+ reaction_type: "unicode_emoji",
+ emoji_name: "8ball",
+ emoji_code: "1f3b1",
user_id: alice.user_id,
};
const bob_8ball_event = {
message_id: 2001,
- reaction_type: 'unicode_emoji',
- emoji_name: '8ball',
- emoji_code: '1f3b1',
+ reaction_type: "unicode_emoji",
+ emoji_name: "8ball",
+ emoji_code: "1f3b1",
user_id: bob.user_id,
};
const cali_airplane_event = {
message_id: 2001,
- reaction_type: 'unicode_emoji',
- emoji_name: 'airplane',
- emoji_code: '2708',
+ reaction_type: "unicode_emoji",
+ emoji_name: "airplane",
+ emoji_code: "2708",
user_id: cali.user_id,
};
@@ -496,12 +496,12 @@ run_test('with_view_stubs', () => {
},
expected_view_calls: [
{
- name: 'insert_new_reaction',
+ name: "insert_new_reaction",
opts: {
message_id: 2001,
- reaction_type: 'unicode_emoji',
- emoji_name: '8ball',
- emoji_code: '1f3b1',
+ reaction_type: "unicode_emoji",
+ emoji_name: "8ball",
+ emoji_code: "1f3b1",
user_id: alice.user_id,
},
},
@@ -514,12 +514,12 @@ run_test('with_view_stubs', () => {
},
expected_view_calls: [
{
- name: 'update_existing_reaction',
+ name: "update_existing_reaction",
opts: {
message_id: 2001,
- reaction_type: 'unicode_emoji',
- emoji_name: '8ball',
- emoji_code: '1f3b1',
+ reaction_type: "unicode_emoji",
+ emoji_name: "8ball",
+ emoji_code: "1f3b1",
user_id: bob.user_id,
user_list: [alice.user_id, bob.user_id],
},
@@ -533,12 +533,12 @@ run_test('with_view_stubs', () => {
},
expected_view_calls: [
{
- name: 'insert_new_reaction',
+ name: "insert_new_reaction",
opts: {
message_id: 2001,
- reaction_type: 'unicode_emoji',
- emoji_name: 'airplane',
- emoji_code: '2708',
+ reaction_type: "unicode_emoji",
+ emoji_name: "airplane",
+ emoji_code: "2708",
user_id: cali.user_id,
},
},
@@ -551,12 +551,12 @@ run_test('with_view_stubs', () => {
},
expected_view_calls: [
{
- name: 'remove_reaction',
+ name: "remove_reaction",
opts: {
message_id: 2001,
- reaction_type: 'unicode_emoji',
- emoji_name: '8ball',
- emoji_code: '1f3b1',
+ reaction_type: "unicode_emoji",
+ emoji_name: "8ball",
+ emoji_code: "1f3b1",
user_id: bob.user_id,
user_list: [alice.user_id],
},
@@ -570,12 +570,12 @@ run_test('with_view_stubs', () => {
},
expected_view_calls: [
{
- name: 'remove_reaction',
+ name: "remove_reaction",
opts: {
message_id: 2001,
- reaction_type: 'unicode_emoji',
- emoji_name: '8ball',
- emoji_code: '1f3b1',
+ reaction_type: "unicode_emoji",
+ emoji_name: "8ball",
+ emoji_code: "1f3b1",
user_id: alice.user_id,
user_list: [],
},
@@ -585,18 +585,18 @@ run_test('with_view_stubs', () => {
});
-run_test('error_handling', () => {
+run_test("error_handling", () => {
global.message_store.get = function () {
return;
};
- blueslip.expect('error', 'reactions: Bad message id: 55');
+ blueslip.expect("error", "reactions: Bad message id: 55");
const bogus_event = {
message_id: 55,
- reaction_type: 'realm_emoji',
- emoji_name: 'realm_emoji',
- emoji_code: '991',
+ reaction_type: "realm_emoji",
+ emoji_name: "realm_emoji",
+ emoji_code: "991",
user_id: 99,
};
@@ -612,14 +612,14 @@ run_test('error_handling', () => {
message_store.get = () => message;
-run_test('remove spurious user', () => {
+run_test("remove spurious user", () => {
// get coverage for removing non-user (it should just
// silently fail)
const event = {
- reaction_type: 'unicode_emoji',
- emoji_name: 'frown',
- emoji_code: '1f641',
+ reaction_type: "unicode_emoji",
+ emoji_name: "frown",
+ emoji_code: "1f641",
message_id: message.id,
user_id: alice.user_id,
};
@@ -627,7 +627,7 @@ run_test('remove spurious user', () => {
reactions.remove_reaction(event);
});
-run_test('remove last user', () => {
+run_test("remove last user", () => {
function assert_names(names) {
assert.deepEqual(
reactions.get_message_reactions(message).map((r) => r.emoji_name),
@@ -635,34 +635,34 @@ run_test('remove last user', () => {
);
}
- assert_names(['smile', 'frown', 'inactive_realm_emoji', 'realm_emoji']);
+ assert_names(["smile", "frown", "inactive_realm_emoji", "realm_emoji"]);
const event = {
- reaction_type: 'unicode_emoji',
- emoji_name: 'frown',
- emoji_code: '1f641',
+ reaction_type: "unicode_emoji",
+ emoji_name: "frown",
+ emoji_code: "1f641",
message_id: message.id,
user_id: cali.user_id,
};
reactions.remove_reaction(event);
- assert_names(['smile', 'inactive_realm_emoji', 'realm_emoji']);
+ assert_names(["smile", "inactive_realm_emoji", "realm_emoji"]);
});
-run_test('local_reaction_id', () => {
+run_test("local_reaction_id", () => {
const reaction_info = {
- reaction_type: 'unicode_emoji',
- emoji_code: '1f44d',
+ reaction_type: "unicode_emoji",
+ emoji_code: "1f44d",
};
const local_id = reactions.get_local_reaction_id(reaction_info);
- assert.equal(local_id, 'unicode_emoji,1f44d');
+ assert.equal(local_id, "unicode_emoji,1f44d");
});
-run_test('process_reaction_click', () => {
+run_test("process_reaction_click", () => {
const message_id = 1001;
let expected_reaction_info = {
- reaction_type: 'unicode_emoji',
- emoji_code: '1f3b1',
+ reaction_type: "unicode_emoji",
+ emoji_code: "1f3b1",
};
global.message_store.get = function (message_id) {
assert.equal(message_id, 1001);
@@ -670,28 +670,28 @@ run_test('process_reaction_click', () => {
};
expected_reaction_info = {
- reaction_type: 'unicode_emoji',
- emoji_name: 'smile',
- emoji_code: '263a',
+ reaction_type: "unicode_emoji",
+ emoji_name: "smile",
+ emoji_code: "263a",
};
global.with_stub((stub) => {
global.channel.del = stub.f;
- reactions.process_reaction_click(message_id, 'unicode_emoji,263a');
- const args = stub.get_args('args').args;
- assert.equal(args.url, '/json/messages/1001/reactions');
+ reactions.process_reaction_click(message_id, "unicode_emoji,263a");
+ const args = stub.get_args("args").args;
+ assert.equal(args.url, "/json/messages/1001/reactions");
assert.deepEqual(args.data, expected_reaction_info);
});
});
-run_test('warnings', () => {
+run_test("warnings", () => {
// Clean the slate
delete message.clean_reactions;
- blueslip.expect('warn', 'Unknown user_id 8888 in reaction for message 1001');
- blueslip.expect('warn', 'Unknown user_id 9999 in reaction for message 1001');
+ blueslip.expect("warn", "Unknown user_id 8888 in reaction for message 1001");
+ blueslip.expect("warn", "Unknown user_id 9999 in reaction for message 1001");
reactions.get_message_reactions(message);
});
-run_test('code coverage', () => {
+run_test("code coverage", () => {
/*
We just silently fail in a few places in the reaction
code, since events may come for messages that we don't
@@ -713,28 +713,28 @@ run_test('code coverage', () => {
});
});
-run_test('duplicates', () => {
+run_test("duplicates", () => {
const dup_reaction_message = {
id: 1001,
reactions: [
- {emoji_name: 'smile', user_id: 5, reaction_type: 'unicode_emoji', emoji_code: '263a'},
- {emoji_name: 'smile', user_id: 5, reaction_type: 'unicode_emoji', emoji_code: '263a'},
+ {emoji_name: "smile", user_id: 5, reaction_type: "unicode_emoji", emoji_code: "263a"},
+ {emoji_name: "smile", user_id: 5, reaction_type: "unicode_emoji", emoji_code: "263a"},
],
};
blueslip.expect(
- 'error',
- 'server sent duplicate reactions for user 5 (key=unicode_emoji,263a)');
+ "error",
+ "server sent duplicate reactions for user 5 (key=unicode_emoji,263a)");
reactions.set_clean_reactions(dup_reaction_message);
});
-run_test('process_reaction_click errors', () => {
+run_test("process_reaction_click errors", () => {
global.message_store.get = () => undefined;
- blueslip.expect('error', 'reactions: Bad message id: 55');
- blueslip.expect('error', 'message_id for reaction click is unknown: 55');
- reactions.process_reaction_click(55, 'whatever');
+ blueslip.expect("error", "reactions: Bad message id: 55");
+ blueslip.expect("error", "message_id for reaction click is unknown: 55");
+ 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)');
- reactions.process_reaction_click('some-msg-id', 'bad-local-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 369f8608e01..b4f2c4d04ec 100644
--- a/frontend_tests/node_tests/recent_senders.js
+++ b/frontend_tests/node_tests/recent_senders.js
@@ -1,14 +1,14 @@
-const rs = zrequire('recent_senders');
+const rs = zrequire("recent_senders");
let next_id = 0;
const messages = [];
-set_global('message_util', {
+set_global("message_util", {
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', () => {
+run_test("process_message_for_senders", () => {
const stream1 = 1;
const stream2 = 2;
const stream3 = 3;
@@ -130,7 +130,7 @@ run_test('process_message_for_senders', () => {
rs.compare_by_recency({user_id: sender2}, {user_id: sender1}, stream3, topic3) < 0,
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 = {
@@ -145,10 +145,10 @@ run_test('process_message_for_senders', () => {
// Test topic change
assert.equal(
- rs.get_topic_recent_senders(stream3, topic3).toString(), '3',
+ rs.get_topic_recent_senders(stream3, topic3).toString(), "3",
);
assert.equal(
- rs.get_topic_recent_senders(stream3, topic2).toString(), '2,3',
+ rs.get_topic_recent_senders(stream3, topic2).toString(), "2,3",
);
// message7's topic was changed by user
@@ -156,36 +156,36 @@ run_test('process_message_for_senders', () => {
rs.process_topic_edit(stream3, topic2, topic3);
assert.equal(
- rs.get_topic_recent_senders(stream3, topic3).toString(), '2,3',
+ rs.get_topic_recent_senders(stream3, topic3).toString(), "2,3",
);
assert.equal(
- rs.get_topic_recent_senders(stream3, topic2).toString(), '3',
+ rs.get_topic_recent_senders(stream3, topic2).toString(), "3",
);
// Test stream change
assert.equal(
- rs.get_topic_recent_senders(stream3, topic3).toString(), '2,3',
+ rs.get_topic_recent_senders(stream3, topic3).toString(), "2,3",
);
assert.equal(
- rs.get_topic_recent_senders(stream4, topic3).toString(), '',
+ 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(), '',
+ rs.get_topic_recent_senders(stream3, topic3).toString(), "",
);
assert.equal(
- rs.get_topic_recent_senders(stream4, topic3).toString(), '2,3',
+ 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',
+ rs.get_topic_recent_senders(stream4, topic3).toString(), "2,3",
);
assert.equal(
- rs.get_topic_recent_senders(stream5, topic4).toString(), '',
+ 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;
@@ -194,24 +194,24 @@ run_test('process_message_for_senders', () => {
messages[7].topic = topic4;
rs.process_topic_edit(stream4, topic3, topic4, stream5);
assert.equal(
- rs.get_topic_recent_senders(stream4, topic3).toString(), '',
+ rs.get_topic_recent_senders(stream4, topic3).toString(), "",
);
assert.equal(
- rs.get_topic_recent_senders(stream5, topic4).toString(), '2,3',
+ rs.get_topic_recent_senders(stream5, topic4).toString(), "2,3",
);
- set_global('message_store', {
+ set_global("message_store", {
get: () => message1,
});
assert.equal(
- rs.get_topic_recent_senders(stream1, topic1).toString(), '2,1',
+ 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',
+ 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 0c533862a5d..76f3cda99a7 100644
--- a/frontend_tests/node_tests/recent_topics.js
+++ b/frontend_tests/node_tests/recent_topics.js
@@ -1,33 +1,33 @@
-zrequire('message_util');
+zrequire("message_util");
const noop = () => {};
-set_global('$', global.make_zjquery({
+set_global("$", global.make_zjquery({
silent: true,
}));
-set_global('hashchange', {
+set_global("hashchange", {
exit_overlay: noop,
});
-set_global('overlays', {
+set_global("overlays", {
open_overlay: (opts) => {
overlays.close_callback = opts.on_close;
},
recent_topics_open: () => true,
});
-set_global('people', {
+set_global("people", {
is_my_user_id: function (id) {
return id === 1;
},
sender_info_with_small_avatar_urls_for_sender_ids: (ids) => ids,
});
-set_global('XDate', zrequire('XDate', 'xdate'));
-set_global('timerender', {
+set_global("XDate", zrequire("XDate", "xdate"));
+set_global("timerender", {
last_seen_status_from_date: () => "Just now",
get_full_datetime: () => ({
date: "date",
time: "time",
}),
});
-set_global('unread', {
+set_global("unread", {
unread_topic_counter: {
get: (stream_id, topic) => {
if (stream_id === 1 && topic === "topic-1") {
@@ -38,14 +38,14 @@ set_global('unread', {
},
},
});
-set_global('hash_util', {
+set_global("hash_util", {
by_stream_uri: () => "https://www.example.com",
by_stream_topic_uri: () => "https://www.example.com",
});
-set_global('recent_senders', {
+set_global("recent_senders", {
get_topic_recent_senders: () => [1, 2],
});
-set_global('list_render', {
+set_global("list_render", {
modifier: noop,
create: (container, mapped_topic_values, opts) => {
const formatted_topics = [];
@@ -91,7 +91,7 @@ const topic8 = "topic-8";
const topic9 = "topic-9";
const topic10 = "topic-10";
-set_global('muting', {
+set_global("muting", {
is_topic_muted: (stream_id, topic) => {
if (stream_id === stream1 && topic === topic7) {
return true;
@@ -107,17 +107,17 @@ const sender2 = 2;
const messages = [];
-set_global('message_list', {
+set_global("message_list", {
all: {
all_messages: function () {
return messages;
},
},
});
-set_global('message_store', {
+set_global("message_store", {
get: (msg_id) => messages[msg_id - 1],
});
-set_global('stream_data', {
+set_global("stream_data", {
get_sub_by_id: (stream) => {
if (stream === stream5) {
// No data is available for deactivated streams
@@ -141,102 +141,102 @@ let id = 0;
messages[0] = {
stream_id: stream1,
- stream: 'stream1',
+ stream: "stream1",
id: id += 1,
topic: topic1,
sender_id: sender1,
- type: 'stream',
+ type: "stream",
};
messages[1] = {
stream_id: stream1,
- stream: 'stream1',
+ stream: "stream1",
id: id += 1,
topic: topic2,
sender_id: sender1,
- type: 'stream',
+ type: "stream",
};
messages[2] = {
stream_id: stream1,
- stream: 'stream1',
+ stream: "stream1",
id: id += 1,
topic: topic2,
sender_id: sender2,
- type: 'stream',
+ type: "stream",
};
messages[3] = {
stream_id: stream1,
- stream: 'stream1',
+ stream: "stream1",
id: id += 1,
topic: topic3,
sender_id: sender2,
- type: 'stream',
+ type: "stream",
};
messages[4] = {
stream_id: stream1,
- stream: 'stream1',
+ stream: "stream1",
id: id += 1,
topic: topic4,
sender_id: sender2,
- type: 'stream',
+ type: "stream",
};
messages[5] = {
stream_id: stream1,
- stream: 'stream1',
+ stream: "stream1",
id: id += 1,
topic: topic5,
sender_id: sender1,
- type: 'stream',
+ type: "stream",
};
messages[6] = {
stream_id: stream1,
- stream: 'stream1',
+ stream: "stream1",
id: id += 1,
topic: topic5,
sender_id: sender2,
- type: 'stream',
+ type: "stream",
};
messages[7] = {
stream_id: stream1,
- stream: 'stream1',
+ stream: "stream1",
id: id += 1,
topic: topic6,
sender_id: sender1,
- type: 'stream',
+ type: "stream",
};
messages[8] = {
stream_id: stream1,
- stream: 'stream1',
+ stream: "stream1",
id: id += 1,
topic: topic6,
sender_id: sender2,
- type: 'stream',
+ type: "stream",
};
messages[9] = {
stream_id: stream1,
- stream: 'stream1',
+ stream: "stream1",
id: id += 1,
topic: topic7,
sender_id: sender1,
- type: 'stream',
+ type: "stream",
};
// a message of stream4
messages[10] = {
stream_id: stream4,
- stream: 'stream4',
+ stream: "stream4",
id: id += 1,
topic: topic10,
sender_id: sender1,
- type: 'stream',
+ type: "stream",
};
function get_topic_key(stream_id, topic) {
@@ -251,7 +251,7 @@ function generate_topic_data(topic_info_array) {
const selectors = [];
for (const [stream_id, topic, unread_count, muted, participated] of topic_info_array) {
- const topic_selector = $.create('#recent_topic:' + get_topic_key(stream_id, topic));
+ const topic_selector = $.create("#recent_topic:" + get_topic_key(stream_id, topic));
topic_selector.data = function () {
return {
participated: participated,
@@ -265,19 +265,19 @@ function generate_topic_data(topic_info_array) {
other_senders_count: 0,
invite_only: false,
is_web_public: true,
- last_msg_time: 'Just now',
+ last_msg_time: "Just now",
full_last_msg_date_time: "date time",
senders: [
1,
2,
],
- stream: 'stream' + stream_id,
- stream_color: '',
+ stream: "stream" + stream_id,
+ stream_color: "",
stream_id: stream_id,
- stream_url: 'https://www.example.com',
+ stream_url: "https://www.example.com",
topic: topic,
topic_key: get_topic_key(stream_id, topic),
- topic_url: 'https://www.example.com',
+ topic_url: "https://www.example.com",
unread_count: unread_count,
muted: muted,
topic_muted: muted,
@@ -289,7 +289,7 @@ function generate_topic_data(topic_info_array) {
function verify_topic_data(all_topics, stream, topic, last_msg_id,
participated) {
- const topic_data = all_topics.get(stream + ':' + topic);
+ const topic_data = all_topics.get(stream + ":" + topic);
assert.equal(topic_data.last_msg_id, last_msg_id);
assert.equal(topic_data.participated, participated);
}
@@ -302,20 +302,20 @@ run_test("test_recent_topics_launch", () => {
filter_participated: false,
filter_unread: false,
filter_muted: false,
- search_val: '',
+ search_val: "",
};
global.stub_templates((template_name, data) => {
- if (template_name === 'recent_topics_table') {
+ if (template_name === "recent_topics_table") {
assert.deepEqual(data, expected);
- } else if (template_name === 'recent_topics_filters') {
+ } else if (template_name === "recent_topics_filters") {
assert.equal(data.filter_unread, expected.filter_unread);
assert.equal(data.filter_participated, expected.filter_participated);
}
- return '<recent_topics table stub>';
+ return "<recent_topics table stub>";
});
- const rt = zrequire('recent_topics');
+ const rt = zrequire("recent_topics");
rt.process_messages(messages);
rt.launch();
@@ -324,10 +324,10 @@ run_test("test_recent_topics_launch", () => {
overlays.close_callback();
// incorrect topic_key
- assert.equal(rt.inplace_rerender('stream_unknown:topic_unknown'), false);
+ assert.equal(rt.inplace_rerender("stream_unknown:topic_unknown"), false);
});
-run_test('test_filter_all', () => {
+run_test("test_filter_all", () => {
// Just tests inplace rerender of a message
// in All topics filter.
const expected = {
@@ -339,200 +339,200 @@ run_test('test_filter_all', () => {
let row_data;
let i;
global.stub_templates((template_name, data) => {
- if (template_name === 'recent_topic_row') {
+ if (template_name === "recent_topic_row") {
// All the row will be processed.
i -= 1;
assert.deepEqual(data, row_data[i]);
- } else if (template_name === 'recent_topics_table') {
+ } else if (template_name === "recent_topics_table") {
assert.deepEqual(data, expected);
}
- return '<recent_topics row stub>';
+ return "<recent_topics row stub>";
});
// topic is not muted
- row_data = generate_topic_data([[1, 'topic-1', 0, false, true]]);
+ row_data = generate_topic_data([[1, "topic-1", 0, false, true]]);
i = row_data.length;
- const rt = zrequire('recent_topics');
- rt.set_filter('all');
+ const rt = zrequire("recent_topics");
+ rt.set_filter("all");
rt.process_messages([messages[0]]);
- row_data = row_data.concat(generate_topic_data([[1, 'topic-7', 1, true, true]]));
+ row_data = row_data.concat(generate_topic_data([[1, "topic-7", 1, true, true]]));
i = row_data.length;
// topic is muted (=== hidden)
rt.process_messages([messages[9]]);
// Test search
expected.search_val = "topic-1";
- row_data = generate_topic_data([[1, 'topic-1', 0, false, true]]);
+ row_data = generate_topic_data([[1, "topic-1", 0, false, true]]);
const search_element = $.create("#recent_topics_search");
- search_element.val('topic-3');
+ search_element.val("topic-3");
i = row_data.length;
- assert.equal(rt.inplace_rerender('1:topic-1'), true);
+ assert.equal(rt.inplace_rerender("1:topic-1"), true);
});
-run_test('test_filter_unread', () => {
+run_test("test_filter_unread", () => {
// Tests rerender of all topics when filter changes to "unread".
const expected = {
filter_participated: false,
filter_unread: true,
filter_muted: false,
- search_val: '',
+ search_val: "",
};
const row_data = generate_topic_data([
// stream_id, topic, unread_count, muted, participated
- [4, 'topic-10', 1, false, true],
- [1, 'topic-7', 1, true, true],
- [1, 'topic-6', 1, false, true],
- [1, 'topic-5', 1, false, true],
- [1, 'topic-4', 1, false, false],
- [1, 'topic-3', 1, false, false],
- [1, 'topic-2', 1, false, true],
- [1, 'topic-1', 0, false, true],
+ [4, "topic-10", 1, false, true],
+ [1, "topic-7", 1, true, true],
+ [1, "topic-6", 1, false, true],
+ [1, "topic-5", 1, false, true],
+ [1, "topic-4", 1, false, false],
+ [1, "topic-3", 1, false, false],
+ [1, "topic-2", 1, false, true],
+ [1, "topic-1", 0, false, true],
]);
let i = 0;
- const rt = zrequire('recent_topics');
+ const rt = zrequire("recent_topics");
- global.stub_templates(() => '<recent_topics table stub>');
+ global.stub_templates(() => "<recent_topics table stub>");
rt.process_messages(messages);
- assert.equal(rt.inplace_rerender('1:topic-1'), true);
+ assert.equal(rt.inplace_rerender("1:topic-1"), true);
- $('#recent_topics_filter_buttons').removeClass('btn-recent-selected');
+ $("#recent_topics_filter_buttons").removeClass("btn-recent-selected");
global.stub_templates((template_name, data) => {
- assert.equal(template_name, 'recent_topics_filters');
+ assert.equal(template_name, "recent_topics_filters");
assert.equal(data.filter_unread, expected.filter_unread);
assert.equal(data.filter_participated, expected.filter_participated);
- return '<recent_topics table stub>';
+ return "<recent_topics table stub>";
});
- rt.set_filter('unread');
+ rt.set_filter("unread");
rt.update_filters_view();
global.stub_templates((template_name, data) => {
- if (template_name === 'recent_topic_row') {
+ if (template_name === "recent_topic_row") {
// All the row will be processed.
assert.deepEqual(data, row_data[i]);
i += 1;
- } else if (template_name === 'recent_topics_table') {
+ } else if (template_name === "recent_topics_table") {
assert.deepEqual(data, expected);
}
- return '<recent_topics row stub>';
+ return "<recent_topics row stub>";
});
rt.process_messages([messages[0]]);
// Unselect "unread" filter by clicking twice.
expected.filter_unread = false;
- $('#recent_topics_filter_buttons').addClass('btn-recent-selected');
- rt.set_filter('unread');
+ $("#recent_topics_filter_buttons").addClass("btn-recent-selected");
+ rt.set_filter("unread");
- $('#recent_topics_filter_buttons').removeClass('btn-recent-selected');
+ $("#recent_topics_filter_buttons").removeClass("btn-recent-selected");
// reselect "unread" filter
- rt.set_filter('unread');
+ rt.set_filter("unread");
// Now clicking "all" filter should have no change to expected data.
- rt.set_filter('all');
+ rt.set_filter("all");
});
-run_test('test_filter_participated', () => {
+run_test("test_filter_participated", () => {
// Tests rerender of all topics when filter changes to "unread".
const expected = {
filter_participated: true,
filter_unread: false,
filter_muted: false,
- search_val: '',
+ search_val: "",
};
const row_data = generate_topic_data([
// stream_id, topic, unread_count, muted, participated
- [4, 'topic-10', 1, false, true],
- [1, 'topic-7', 1, true, true],
- [1, 'topic-6', 1, false, true],
- [1, 'topic-5', 1, false, true],
- [1, 'topic-4', 1, false, false],
- [1, 'topic-3', 1, false, false],
- [1, 'topic-2', 1, false, true],
- [1, 'topic-1', 0, false, true],
+ [4, "topic-10", 1, false, true],
+ [1, "topic-7", 1, true, true],
+ [1, "topic-6", 1, false, true],
+ [1, "topic-5", 1, false, true],
+ [1, "topic-4", 1, false, false],
+ [1, "topic-3", 1, false, false],
+ [1, "topic-2", 1, false, true],
+ [1, "topic-1", 0, false, true],
]);
let i = 0;
- const rt = zrequire('recent_topics');
+ const rt = zrequire("recent_topics");
- global.stub_templates(() => '<recent_topics table stub>');
+ global.stub_templates(() => "<recent_topics table stub>");
rt.process_messages(messages);
- assert.equal(rt.inplace_rerender('1:topic-4'), true);
+ assert.equal(rt.inplace_rerender("1:topic-4"), true);
// Set muted filter
- rt.set_filter('muted');
- assert.equal(rt.inplace_rerender('1:topic-7'), true);
+ rt.set_filter("muted");
+ assert.equal(rt.inplace_rerender("1:topic-7"), true);
// remove muted filter
- rt.set_filter('muted');
+ rt.set_filter("muted");
- $('#recent_topics_filter_buttons').removeClass('btn-recent-selected');
+ $("#recent_topics_filter_buttons").removeClass("btn-recent-selected");
global.stub_templates((template_name, data) => {
- assert.equal(template_name, 'recent_topics_filters');
+ assert.equal(template_name, "recent_topics_filters");
assert.equal(data.filter_unread, expected.filter_unread);
assert.equal(data.filter_participated, expected.filter_participated);
- return '<recent_topics table stub>';
+ return "<recent_topics table stub>";
});
- rt.set_filter('participated');
+ rt.set_filter("participated");
rt.update_filters_view();
global.stub_templates((template_name, data) => {
- if (template_name === 'recent_topic_row') {
+ if (template_name === "recent_topic_row") {
// All the row will be processed.
assert.deepEqual(data, row_data[i]);
i += 1;
- } else if (template_name === 'recent_topics_table') {
+ } else if (template_name === "recent_topics_table") {
assert.deepEqual(data, expected);
}
- return '<recent_topics row stub>';
+ return "<recent_topics row stub>";
});
rt.process_messages([messages[4]]);
expected.filter_participated = false;
- rt.set_filter('all');
+ rt.set_filter("all");
});
-run_test('test_update_unread_count', () => {
- const rt = zrequire('recent_topics');
- rt.set_filter('all');
- global.stub_templates(() => '<recent_topics table stub>');
+run_test("test_update_unread_count", () => {
+ const rt = zrequire("recent_topics");
+ rt.set_filter("all");
+ global.stub_templates(() => "<recent_topics table stub>");
rt.process_messages(messages);
// update a message
- generate_topic_data([[1, 'topic-7', 1, false, true]]);
+ generate_topic_data([[1, "topic-7", 1, false, true]]);
rt.update_topic_unread_count(messages[9]);
});
// template rendering is tested in test_recent_topics_launch.
-global.stub_templates(() => '<recent_topics table stub>');
+global.stub_templates(() => "<recent_topics table stub>");
-run_test('basic assertions', () => {
- const rt = zrequire('recent_topics');
- rt.set_filter('all');
+run_test("basic assertions", () => {
+ const rt = zrequire("recent_topics");
+ rt.set_filter("all");
rt.process_messages(messages);
let all_topics = rt.get();
// update a message
- generate_topic_data([[1, 'topic-7', 1, false, true]]);
+ generate_topic_data([[1, "topic-7", 1, false, true]]);
rt.process_messages([messages[9]]);
// 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');
+ "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',
+ type: "private",
});
// 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');
+ "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);
@@ -549,12 +549,12 @@ run_test('basic assertions', () => {
id: id += 1,
topic: topic3,
sender_id: sender1,
- type: 'stream',
+ 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');
+ "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)
@@ -564,12 +564,12 @@ run_test('basic assertions', () => {
id: id += 1,
topic: topic7,
sender_id: sender1,
- type: 'stream',
+ 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');
+ "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.
@@ -579,9 +579,9 @@ run_test('basic assertions', () => {
assert.equal(rt.update_topic_is_muted(stream1, "topic-10"), false);
});
-run_test('test_reify_local_echo_message', () => {
- const rt = zrequire('recent_topics');
- rt.set_filter('all');
+run_test("test_reify_local_echo_message", () => {
+ const rt = zrequire("recent_topics");
+ rt.set_filter("all");
rt.process_messages(messages);
rt.process_message({
@@ -589,7 +589,7 @@ run_test('test_reify_local_echo_message', () => {
id: 1000.01,
topic: topic7,
sender_id: sender1,
- type: 'stream',
+ type: "stream",
});
assert.equal(rt.reify_message_id_if_available({
@@ -602,7 +602,7 @@ run_test('test_reify_local_echo_message', () => {
id: 1001.01,
topic: topic7,
sender_id: sender1,
- type: 'stream',
+ type: "stream",
});
// A new message arrived in the same topic before we could reify the message_id
@@ -611,7 +611,7 @@ run_test('test_reify_local_echo_message', () => {
id: 1003,
topic: topic7,
sender_id: sender1,
- type: 'stream',
+ type: "stream",
});
assert.equal(rt.reify_message_id_if_available({
@@ -621,12 +621,12 @@ run_test('test_reify_local_echo_message', () => {
});
-run_test('test_delete_messages', () => {
- const rt = zrequire('recent_topics');
- rt.set_filter('all');
+run_test("test_delete_messages", () => {
+ const rt = zrequire("recent_topics");
+ rt.set_filter("all");
rt.process_messages(messages);
- set_global('message_list', {
+ set_global("message_list", {
all: {
all_messages: function () {
// messages[0] was removed.
@@ -639,14 +639,14 @@ 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');
+ "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');
+ "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', {
+ set_global("message_list", {
all: {
all_messages: function () {
// messages[0], messages[1] and message[2] were removed.
@@ -661,11 +661,11 @@ run_test('test_delete_messages', () => {
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');
+ "4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3");
});
-run_test('test_topic_edit', () => {
- set_global('message_list', {
+run_test("test_topic_edit", () => {
+ set_global("message_list", {
all: {
all_messages: function () {
return messages;
@@ -673,19 +673,19 @@ run_test('test_topic_edit', () => {
},
});
// NOTE: This test should always run in the end as it modified the messages data.
- const rt = zrequire('recent_topics');
- rt.set_filter('all');
+ const rt = zrequire("recent_topics");
+ rt.set_filter("all");
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');
+ "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);
assert.equal(all_topics.get(get_topic_key(stream1, topic8)), undefined);
- let topic_selector = $.create('#recent_topic:' + get_topic_key(stream1, topic8));
+ let topic_selector = $.create("#recent_topic:" + get_topic_key(stream1, topic8));
topic_selector.data = function () {
return {
participated: true,
@@ -706,7 +706,7 @@ run_test('test_topic_edit', () => {
verify_topic_data(all_topics, stream1, topic1, messages[0].id, true);
assert.equal(all_topics.get(get_topic_key(stream2, topic1)), undefined);
- topic_selector = $.create('#recent_topic:' + get_topic_key(stream2, topic1));
+ topic_selector = $.create("#recent_topic:" + get_topic_key(stream2, topic1));
topic_selector.data = function () {
return {
participated: true,
@@ -725,7 +725,7 @@ run_test('test_topic_edit', () => {
verify_topic_data(all_topics, stream2, topic1, messages[0].id, true);
assert.equal(all_topics.get(get_topic_key(stream3, topic9)), undefined);
- topic_selector = $.create('#recent_topic:' + get_topic_key(stream3, topic9));
+ topic_selector = $.create("#recent_topic:" + get_topic_key(stream3, topic9));
topic_selector.data = function () {
return {
participated: false,
@@ -746,41 +746,41 @@ run_test('test_topic_edit', () => {
messages[0].topic = topic8;
rt.process_topic_edit(stream3, topic9, topic8, stream5);
all_topics = rt.get();
- assert.equal(rt.filters_should_hide_topic(all_topics.get('5:topic-8')), true);
+ assert.equal(rt.filters_should_hide_topic(all_topics.get("5:topic-8")), true);
});
-run_test('test_search', () => {
- const rt = zrequire('recent_topics');
- assert.equal(rt.topic_in_search_results('t', 'general', 'Recent Topic'), true);
- assert.equal(rt.topic_in_search_results('T', 'general', 'Recent Topic'), true);
- assert.equal(rt.topic_in_search_results('to', 'general', 'Recent Topic'), true);
- assert.equal(rt.topic_in_search_results('top', 'general', 'Recent Topic'), true);
- assert.equal(rt.topic_in_search_results('ToP', 'general', 'Recent Topic'), true);
- assert.equal(rt.topic_in_search_results('Topi', 'general', 'Recent Topic'), true);
- assert.equal(rt.topic_in_search_results('tOpi', 'general', 'Recent Topic'), true);
- assert.equal(rt.topic_in_search_results('toPic', 'general', 'Recent Topic'), true);
- assert.equal(rt.topic_in_search_results('Topic', 'general', 'Recent Topic'), true);
- assert.equal(rt.topic_in_search_results('topic', 'general', 'Recent Topic'), true);
- assert.equal(rt.topic_in_search_results('recent', 'general', 'Recent Topic'), true);
- assert.equal(rt.topic_in_search_results('RECENT', 'general', 'Recent Topic'), true);
+run_test("test_search", () => {
+ const rt = zrequire("recent_topics");
+ assert.equal(rt.topic_in_search_results("t", "general", "Recent Topic"), true);
+ assert.equal(rt.topic_in_search_results("T", "general", "Recent Topic"), true);
+ assert.equal(rt.topic_in_search_results("to", "general", "Recent Topic"), true);
+ assert.equal(rt.topic_in_search_results("top", "general", "Recent Topic"), true);
+ assert.equal(rt.topic_in_search_results("ToP", "general", "Recent Topic"), true);
+ assert.equal(rt.topic_in_search_results("Topi", "general", "Recent Topic"), true);
+ assert.equal(rt.topic_in_search_results("tOpi", "general", "Recent Topic"), true);
+ assert.equal(rt.topic_in_search_results("toPic", "general", "Recent Topic"), true);
+ assert.equal(rt.topic_in_search_results("Topic", "general", "Recent Topic"), true);
+ assert.equal(rt.topic_in_search_results("topic", "general", "Recent Topic"), true);
+ assert.equal(rt.topic_in_search_results("recent", "general", "Recent Topic"), true);
+ assert.equal(rt.topic_in_search_results("RECENT", "general", "Recent Topic"), true);
// match in any order of words
- assert.equal(rt.topic_in_search_results('topic recent', 'general', 'Recent Topic'), true);
+ assert.equal(rt.topic_in_search_results("topic recent", "general", "Recent Topic"), true);
// Matches any sequence of words.
- assert.equal(rt.topic_in_search_results('o', 'general', 'Recent Topic'), true);
- assert.equal(rt.topic_in_search_results('nt to', 'general', 'Recent Topic'), true);
- assert.equal(rt.topic_in_search_results('z', 'general', 'Recent Topic'), false);
+ assert.equal(rt.topic_in_search_results("o", "general", "Recent Topic"), true);
+ assert.equal(rt.topic_in_search_results("nt to", "general", "Recent Topic"), true);
+ assert.equal(rt.topic_in_search_results("z", "general", "Recent Topic"), false);
- assert.equal(rt.topic_in_search_results('?', 'general', 'Recent Topic'), false);
+ assert.equal(rt.topic_in_search_results("?", "general", "Recent Topic"), false);
// Test special character match
- assert.equal(rt.topic_in_search_results('.*+?^${}()[]\\', 'general', 'Recent Topic'), false);
- assert.equal(rt.topic_in_search_results('?', 'general', 'not-at-start?'), true);
+ assert.equal(rt.topic_in_search_results(".*+?^${}()[]\\", "general", "Recent Topic"), false);
+ assert.equal(rt.topic_in_search_results("?", "general", "not-at-start?"), true);
- assert.equal(rt.topic_in_search_results('?', 'general', '?'), true);
- assert.equal(rt.topic_in_search_results('?', 'general', '\\?'), true);
+ assert.equal(rt.topic_in_search_results("?", "general", "?"), true);
+ assert.equal(rt.topic_in_search_results("?", "general", "\\?"), true);
- assert.equal(rt.topic_in_search_results('\\', 'general', '\\'), true);
- assert.equal(rt.topic_in_search_results('\\', 'general', '\\\\'), true);
+ assert.equal(rt.topic_in_search_results("\\", "general", "\\"), true);
+ assert.equal(rt.topic_in_search_results("\\", "general", "\\\\"), true);
});
diff --git a/frontend_tests/node_tests/rendered_markdown.js b/frontend_tests/node_tests/rendered_markdown.js
index 999099cf32a..677921cf861 100644
--- a/frontend_tests/node_tests/rendered_markdown.js
+++ b/frontend_tests/node_tests/rendered_markdown.js
@@ -1,25 +1,25 @@
-const rm = zrequire('rendered_markdown');
-set_global('moment', zrequire('moment', 'moment-timezone'));
-zrequire('people');
-zrequire('user_groups');
-zrequire('stream_data');
-zrequire('timerender');
-set_global('$', global.make_zjquery());
-
-set_global('rtl', {
- get_direction: () => 'ltr',
+const rm = zrequire("rendered_markdown");
+set_global("moment", zrequire("moment", "moment-timezone"));
+zrequire("people");
+zrequire("user_groups");
+zrequire("stream_data");
+zrequire("timerender");
+set_global("$", global.make_zjquery());
+
+set_global("rtl", {
+ get_direction: () => "ltr",
});
const iago = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 30,
- full_name: 'Iago',
+ full_name: "Iago",
};
const cordelia = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 31,
- full_name: 'Cordelia',
+ full_name: "Cordelia",
};
people.init();
people.add_active_user(iago);
@@ -27,12 +27,12 @@ people.add_active_user(cordelia);
people.initialize_current_user(iago.user_id);
const group_me = {
- name: 'my user group',
+ name: "my user group",
id: 1,
members: [iago.user_id, cordelia.user_id],
};
const group_other = {
- name: 'other user group',
+ name: "other user group",
id: 2,
members: [cordelia.user_id],
};
@@ -42,8 +42,8 @@ user_groups.initialize({
const stream = {
subscribed: true,
- color: 'yellow',
- name: 'test',
+ color: "yellow",
+ name: "test",
stream_id: 3,
is_muted: true,
invite_only: false,
@@ -59,96 +59,96 @@ const $array = (array) => {
return {each};
};
-set_global('page_params', { emojiset: 'apple' });
+set_global("page_params", { emojiset: "apple" });
const get_content_element = () => {
$.clear_all_elements();
- const $content = $.create('.rendered_markdown');
- $content.set_find_results('.user-mention', $array([]));
- $content.set_find_results('.user-group-mention', $array([]));
- $content.set_find_results('a.stream', $array([]));
- $content.set_find_results('a.stream-topic', $array([]));
- $content.set_find_results('time', $array([]));
- $content.set_find_results('span.timestamp-error', $array([]));
- $content.set_find_results('.emoji', $array([]));
- $content.set_find_results('div.spoiler-header', $array([]));
+ const $content = $.create(".rendered_markdown");
+ $content.set_find_results(".user-mention", $array([]));
+ $content.set_find_results(".user-group-mention", $array([]));
+ $content.set_find_results("a.stream", $array([]));
+ $content.set_find_results("a.stream-topic", $array([]));
+ $content.set_find_results("time", $array([]));
+ $content.set_find_results("span.timestamp-error", $array([]));
+ $content.set_find_results(".emoji", $array([]));
+ $content.set_find_results("div.spoiler-header", $array([]));
return $content;
};
-run_test('misc_helpers', () => {
- const elem = $.create('.user-mention');
- rm.set_name_in_mention_element(elem, 'Aaron');
- assert.equal(elem.text(), '@Aaron');
- elem.addClass('silent');
- rm.set_name_in_mention_element(elem, 'Aaron, but silent');
- assert.equal(elem.text(), 'Aaron, but silent');
+run_test("misc_helpers", () => {
+ const elem = $.create(".user-mention");
+ rm.set_name_in_mention_element(elem, "Aaron");
+ assert.equal(elem.text(), "@Aaron");
+ elem.addClass("silent");
+ rm.set_name_in_mention_element(elem, "Aaron, but silent");
+ assert.equal(elem.text(), "Aaron, but silent");
});
-run_test('user-mention', () => {
+run_test("user-mention", () => {
// Setup
const $content = get_content_element();
- const $iago = $.create('.user-mention(iago)');
- $iago.set_find_results('.highlight', false);
- $iago.attr('data-user-id', iago.user_id);
- const $cordelia = $.create('.user-mention(cordelia)');
- $cordelia.set_find_results('.highlight', false);
- $cordelia.attr('data-user-id', cordelia.user_id);
- $content.set_find_results('.user-mention', $array([$iago, $cordelia]));
+ const $iago = $.create(".user-mention(iago)");
+ $iago.set_find_results(".highlight", false);
+ $iago.attr("data-user-id", iago.user_id);
+ const $cordelia = $.create(".user-mention(cordelia)");
+ $cordelia.set_find_results(".highlight", false);
+ $cordelia.attr("data-user-id", cordelia.user_id);
+ $content.set_find_results(".user-mention", $array([$iago, $cordelia]));
// Initial asserts
- assert(!$iago.hasClass('user-mention-me'));
- assert.equal($iago.text(), 'never-been-set');
- assert.equal($cordelia.text(), 'never-been-set');
+ assert(!$iago.hasClass("user-mention-me"));
+ assert.equal($iago.text(), "never-been-set");
+ assert.equal($cordelia.text(), "never-been-set");
rm.update_elements($content);
// Final asserts
- assert($iago.hasClass('user-mention-me'));
+ assert($iago.hasClass("user-mention-me"));
assert.equal($iago.text(), `@${iago.full_name}`);
assert.equal($cordelia.text(), `@${cordelia.full_name}`);
});
-run_test('user-group-mention', () => {
+run_test("user-group-mention", () => {
// Setup
const $content = get_content_element();
- const $group_me = $.create('.user-group-mention(me)');
- $group_me.set_find_results('.highlight', false);
- $group_me.attr('data-user-group-id', group_me.id);
- const $group_other = $.create('.user-group-mention(other)');
- $group_other.set_find_results('.highlight', false);
- $group_other.attr('data-user-group-id', group_other.id);
- $content.set_find_results('.user-group-mention', $array([$group_me, $group_other]));
+ const $group_me = $.create(".user-group-mention(me)");
+ $group_me.set_find_results(".highlight", false);
+ $group_me.attr("data-user-group-id", group_me.id);
+ const $group_other = $.create(".user-group-mention(other)");
+ $group_other.set_find_results(".highlight", false);
+ $group_other.attr("data-user-group-id", group_other.id);
+ $content.set_find_results(".user-group-mention", $array([$group_me, $group_other]));
// Initial asserts
- assert(!$group_me.hasClass('user-mention-me'));
- assert.equal($group_me.text(), 'never-been-set');
- assert.equal($group_other.text(), 'never-been-set');
+ assert(!$group_me.hasClass("user-mention-me"));
+ assert.equal($group_me.text(), "never-been-set");
+ assert.equal($group_other.text(), "never-been-set");
rm.update_elements($content);
// Final asserts
- assert($group_me.hasClass('user-mention-me'));
+ assert($group_me.hasClass("user-mention-me"));
assert.equal($group_me.text(), `@${group_me.name}`);
assert.equal($group_other.text(), `@${group_other.name}`);
});
-run_test('stream-links', () => {
+run_test("stream-links", () => {
// Setup
const $content = get_content_element();
- const $stream = $.create('a.stream');
- $stream.set_find_results('.highlight', false);
- $stream.attr('data-stream-id', stream.stream_id);
- const $stream_topic = $.create('a.stream-topic');
- $stream_topic.set_find_results('.highlight', false);
- $stream_topic.attr('data-stream-id', stream.stream_id);
- $stream_topic.text('#random>topic name');
- $content.set_find_results('a.stream', $array([$stream]));
- $content.set_find_results('a.stream-topic', $array([$stream_topic]));
+ const $stream = $.create("a.stream");
+ $stream.set_find_results(".highlight", false);
+ $stream.attr("data-stream-id", stream.stream_id);
+ const $stream_topic = $.create("a.stream-topic");
+ $stream_topic.set_find_results(".highlight", false);
+ $stream_topic.attr("data-stream-id", stream.stream_id);
+ $stream_topic.text("#random>topic name");
+ $content.set_find_results("a.stream", $array([$stream]));
+ $content.set_find_results("a.stream-topic", $array([$stream_topic]));
// Initial asserts
- assert.equal($stream.text(), 'never-been-set');
- assert.equal($stream_topic.text(), '#random>topic name');
+ assert.equal($stream.text(), "never-been-set");
+ assert.equal($stream_topic.text(), "#random>topic name");
rm.update_elements($content);
@@ -157,110 +157,110 @@ run_test('stream-links', () => {
assert.equal($stream_topic.text(), `#${stream.name} > topic name`);
});
-run_test('timestamp', () => {
+run_test("timestamp", () => {
// Setup
const $content = get_content_element();
- const $timestamp = $.create('timestamp(valid)');
- $timestamp.attr('datetime', '1970-01-01T00:00:01Z');
- const $timestamp_invalid = $.create('timestamp(invalid)');
- $timestamp_invalid.attr('datetime', 'invalid');
- $content.set_find_results('time', $array([$timestamp, $timestamp_invalid]));
- blueslip.expect('error', 'Moment could not parse datetime supplied by backend: invalid');
+ const $timestamp = $.create("timestamp(valid)");
+ $timestamp.attr("datetime", "1970-01-01T00:00:01Z");
+ const $timestamp_invalid = $.create("timestamp(invalid)");
+ $timestamp_invalid.attr("datetime", "invalid");
+ $content.set_find_results("time", $array([$timestamp, $timestamp_invalid]));
+ blueslip.expect("error", "Moment could not parse datetime supplied by backend: invalid");
// Initial asserts
- assert.equal($timestamp.text(), 'never-been-set');
- assert.equal($timestamp_invalid.text(), 'never-been-set');
+ assert.equal($timestamp.text(), "never-been-set");
+ assert.equal($timestamp_invalid.text(), "never-been-set");
rm.update_elements($content);
// 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_invalid.text(), 'never-been-set');
+ 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_invalid.text(), "never-been-set");
});
-run_test('timestamp-twenty-four-hour-time', () => {
+run_test("timestamp-twenty-four-hour-time", () => {
const $content = get_content_element();
- const $timestamp = $.create('timestamp');
- $timestamp.attr('datetime', '2020-07-15T20:40:00Z');
- $content.set_find_results('time', $array([$timestamp]));
+ const $timestamp = $.create("timestamp");
+ $timestamp.attr("datetime", "2020-07-15T20:40:00Z");
+ $content.set_find_results("time", $array([$timestamp]));
// We will temporarily change the 24h setting for this test.
const old_page_params = global.page_params;
- set_global('page_params', { ...old_page_params, twenty_four_hour_time: true });
+ set_global("page_params", { ...old_page_params, twenty_four_hour_time: true });
rm.update_elements($content);
- assert.equal($timestamp.text(), 'Wed, Jul 15 2020, 20:40');
+ assert.equal($timestamp.text(), "Wed, Jul 15 2020, 20:40");
- set_global('page_params', { ...old_page_params, twenty_four_hour_time: false });
+ set_global("page_params", { ...old_page_params, twenty_four_hour_time: false });
rm.update_elements($content);
- assert.equal($timestamp.text(), 'Wed, Jul 15 2020, 8:40 PM');
+ assert.equal($timestamp.text(), "Wed, Jul 15 2020, 8:40 PM");
// Set page_params back to its original value.
- set_global('page_params', old_page_params);
+ set_global("page_params", old_page_params);
});
-run_test('timestamp-error', () => {
+run_test("timestamp-error", () => {
// Setup
const $content = get_content_element();
- const $timestamp_error = $.create('timestamp-error');
- $timestamp_error.text('Invalid time format: the-time-format');
- $content.set_find_results('span.timestamp-error', $array([$timestamp_error]));
+ const $timestamp_error = $.create("timestamp-error");
+ $timestamp_error.text("Invalid time format: the-time-format");
+ $content.set_find_results("span.timestamp-error", $array([$timestamp_error]));
// Initial assert
- assert.equal($timestamp_error.text(), 'Invalid time format: the-time-format');
+ assert.equal($timestamp_error.text(), "Invalid time format: the-time-format");
rm.update_elements($content);
// Final assert
- assert.equal($timestamp_error.text(), 'translated: Invalid time format: the-time-format');
+ assert.equal($timestamp_error.text(), "translated: Invalid time format: the-time-format");
});
-run_test('emoji', () => {
+run_test("emoji", () => {
// Setup
const $content = get_content_element();
- const $emoji = $.create('.emoji');
- $emoji.attr('title', 'tada');
+ const $emoji = $.create(".emoji");
+ $emoji.attr("title", "tada");
let called = false;
$emoji.replaceWith = (f) => {
const text = f.call($emoji);
- assert.equal(':tada:', text);
+ assert.equal(":tada:", text);
called = true;
};
- $content.set_find_results('.emoji', $emoji);
- page_params.emojiset = 'text';
+ $content.set_find_results(".emoji", $emoji);
+ page_params.emojiset = "text";
rm.update_elements($content);
assert(called);
// Set page paramaters back so that test run order is independent
- page_params.emojiset = 'apple';
+ page_params.emojiset = "apple";
});
-run_test('spoiler-header', () => {
+run_test("spoiler-header", () => {
// Setup
const $content = get_content_element();
- const $header = $.create('div.spoiler-header');
- $content.set_find_results('div.spoiler-header', $array([$header]));
+ const $header = $.create("div.spoiler-header");
+ $content.set_find_results("div.spoiler-header", $array([$header]));
// Test that the show/hide button gets added to a spoiler header.
- const label = 'My Spoiler Header';
+ const label = "My Spoiler Header";
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());
});
-run_test('spoiler-header-empty-fill', () => {
+run_test("spoiler-header-empty-fill", () => {
// Setup
const $content = get_content_element();
- const $header = $.create('div.spoiler-header');
- $content.set_find_results('div.spoiler-header', $array([$header]));
+ const $header = $.create("div.spoiler-header");
+ $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>';
- $header.html('');
+ $header.html("");
rm.update_elements($content);
- assert.equal(toggle_button_html + '<p>translated: Spoiler</p>', $header.html());
+ 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 e682835176c..dedfb024445 100644
--- a/frontend_tests/node_tests/rtl.js
+++ b/frontend_tests/node_tests/rtl.js
@@ -1,83 +1,83 @@
-const rtl = zrequire('rtl');
+const rtl = zrequire("rtl");
-run_test('get_direction', () => {
+run_test("get_direction", () => {
// These characters are strong R or AL: ا ب پ ج ض و د ؛
// These characters are not strong: ۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹ ۰
- assert.equal(rtl.get_direction('abcابپ'), 'ltr');
- assert.equal(rtl.get_direction('ابپabc'), 'rtl');
- assert.equal(rtl.get_direction('123abc'), 'ltr');
- assert.equal(rtl.get_direction('۱۲۳abc'), 'ltr');
- assert.equal(rtl.get_direction('123؛بپ'), 'rtl');
- assert.equal(rtl.get_direction('۱۲۳ابپ'), 'rtl');
- assert.equal(rtl.get_direction('۱۲جg'), 'rtl');
- assert.equal(rtl.get_direction('12gج'), 'ltr');
- assert.equal(rtl.get_direction('۱۲۳'), 'ltr');
- assert.equal(rtl.get_direction('1234'), 'ltr');
+ assert.equal(rtl.get_direction("abcابپ"), "ltr");
+ assert.equal(rtl.get_direction("ابپabc"), "rtl");
+ assert.equal(rtl.get_direction("123abc"), "ltr");
+ assert.equal(rtl.get_direction("۱۲۳abc"), "ltr");
+ assert.equal(rtl.get_direction("123؛بپ"), "rtl");
+ assert.equal(rtl.get_direction("۱۲۳ابپ"), "rtl");
+ assert.equal(rtl.get_direction("۱۲جg"), "rtl");
+ assert.equal(rtl.get_direction("12gج"), "ltr");
+ assert.equal(rtl.get_direction("۱۲۳"), "ltr");
+ assert.equal(rtl.get_direction("1234"), "ltr");
- const supp_plane_ltr_char = '\ud800\udfa0';
- const supp_plane_rtl_char = '\ud802\udc40';
+ const supp_plane_ltr_char = "\ud800\udfa0";
+ const supp_plane_rtl_char = "\ud802\udc40";
- assert.equal(rtl.get_direction(supp_plane_ltr_char), 'ltr');
- assert.equal(rtl.get_direction(supp_plane_rtl_char), 'rtl');
- assert.equal(rtl.get_direction('123' + supp_plane_ltr_char), 'ltr');
- assert.equal(rtl.get_direction('123' + supp_plane_rtl_char), 'rtl');
- assert.equal(rtl.get_direction(supp_plane_ltr_char + supp_plane_rtl_char), 'ltr');
- assert.equal(rtl.get_direction(supp_plane_rtl_char + supp_plane_ltr_char), 'rtl');
- assert.equal(rtl.get_direction(supp_plane_ltr_char + ' ' + supp_plane_rtl_char), 'ltr');
- assert.equal(rtl.get_direction(supp_plane_rtl_char + ' ' + supp_plane_ltr_char), 'rtl');
- assert.equal(rtl.get_direction(supp_plane_ltr_char + 'ج' + supp_plane_rtl_char), 'ltr');
- assert.equal(rtl.get_direction(supp_plane_rtl_char + 'ج' + supp_plane_ltr_char), 'rtl');
- assert.equal(rtl.get_direction('پ' + supp_plane_ltr_char + '.' + supp_plane_rtl_char), 'rtl');
- assert.equal(rtl.get_direction('پ' + supp_plane_rtl_char + '.' + supp_plane_ltr_char), 'rtl');
- assert.equal(rtl.get_direction('b' + supp_plane_ltr_char + '.' + supp_plane_rtl_char), 'ltr');
- assert.equal(rtl.get_direction('b' + supp_plane_rtl_char + '.' + supp_plane_ltr_char), 'ltr');
+ assert.equal(rtl.get_direction(supp_plane_ltr_char), "ltr");
+ assert.equal(rtl.get_direction(supp_plane_rtl_char), "rtl");
+ assert.equal(rtl.get_direction("123" + supp_plane_ltr_char), "ltr");
+ assert.equal(rtl.get_direction("123" + supp_plane_rtl_char), "rtl");
+ assert.equal(rtl.get_direction(supp_plane_ltr_char + supp_plane_rtl_char), "ltr");
+ assert.equal(rtl.get_direction(supp_plane_rtl_char + supp_plane_ltr_char), "rtl");
+ assert.equal(rtl.get_direction(supp_plane_ltr_char + " " + supp_plane_rtl_char), "ltr");
+ assert.equal(rtl.get_direction(supp_plane_rtl_char + " " + supp_plane_ltr_char), "rtl");
+ assert.equal(rtl.get_direction(supp_plane_ltr_char + "ج" + supp_plane_rtl_char), "ltr");
+ assert.equal(rtl.get_direction(supp_plane_rtl_char + "ج" + supp_plane_ltr_char), "rtl");
+ assert.equal(rtl.get_direction("پ" + supp_plane_ltr_char + "." + supp_plane_rtl_char), "rtl");
+ assert.equal(rtl.get_direction("پ" + supp_plane_rtl_char + "." + supp_plane_ltr_char), "rtl");
+ assert.equal(rtl.get_direction("b" + supp_plane_ltr_char + "." + supp_plane_rtl_char), "ltr");
+ assert.equal(rtl.get_direction("b" + supp_plane_rtl_char + "." + supp_plane_ltr_char), "ltr");
- const unmatched_surrogate_1 = '\ud800';
- const unmatched_surrogate_2 = '\udf00';
+ const unmatched_surrogate_1 = "\ud800";
+ const unmatched_surrogate_2 = "\udf00";
- assert.equal(rtl.get_direction(unmatched_surrogate_1 + ' '), 'ltr');
- assert.equal(rtl.get_direction(unmatched_surrogate_2 + ' '), 'ltr');
- assert.equal(rtl.get_direction(' ' + unmatched_surrogate_1), 'ltr');
- assert.equal(rtl.get_direction(' ' + unmatched_surrogate_2), 'ltr');
- assert.equal(rtl.get_direction(' ' + unmatched_surrogate_1 + ' '), 'ltr');
- assert.equal(rtl.get_direction(' ' + unmatched_surrogate_2 + ' '), 'ltr');
- assert.equal(rtl.get_direction(unmatched_surrogate_1 + supp_plane_ltr_char), 'ltr');
- assert.equal(rtl.get_direction(unmatched_surrogate_1 + supp_plane_rtl_char), 'ltr');
- assert.equal(rtl.get_direction(unmatched_surrogate_2 + supp_plane_ltr_char), 'ltr');
- assert.equal(rtl.get_direction(unmatched_surrogate_2 + supp_plane_rtl_char), 'ltr');
- assert.equal(rtl.get_direction(supp_plane_ltr_char + unmatched_surrogate_1), 'ltr');
- assert.equal(rtl.get_direction(supp_plane_ltr_char + unmatched_surrogate_2), 'ltr');
- assert.equal(rtl.get_direction(supp_plane_rtl_char + unmatched_surrogate_1), 'rtl');
- assert.equal(rtl.get_direction(supp_plane_rtl_char + unmatched_surrogate_2), 'rtl');
+ assert.equal(rtl.get_direction(unmatched_surrogate_1 + " "), "ltr");
+ assert.equal(rtl.get_direction(unmatched_surrogate_2 + " "), "ltr");
+ assert.equal(rtl.get_direction(" " + unmatched_surrogate_1), "ltr");
+ assert.equal(rtl.get_direction(" " + unmatched_surrogate_2), "ltr");
+ assert.equal(rtl.get_direction(" " + unmatched_surrogate_1 + " "), "ltr");
+ assert.equal(rtl.get_direction(" " + unmatched_surrogate_2 + " "), "ltr");
+ assert.equal(rtl.get_direction(unmatched_surrogate_1 + supp_plane_ltr_char), "ltr");
+ assert.equal(rtl.get_direction(unmatched_surrogate_1 + supp_plane_rtl_char), "ltr");
+ assert.equal(rtl.get_direction(unmatched_surrogate_2 + supp_plane_ltr_char), "ltr");
+ assert.equal(rtl.get_direction(unmatched_surrogate_2 + supp_plane_rtl_char), "ltr");
+ assert.equal(rtl.get_direction(supp_plane_ltr_char + unmatched_surrogate_1), "ltr");
+ assert.equal(rtl.get_direction(supp_plane_ltr_char + unmatched_surrogate_2), "ltr");
+ assert.equal(rtl.get_direction(supp_plane_rtl_char + unmatched_surrogate_1), "rtl");
+ assert.equal(rtl.get_direction(supp_plane_rtl_char + unmatched_surrogate_2), "rtl");
// Testing with some isolate initiators and PDIs.
- const i_chars = '\u2066\u2067\u2068';
- const pdi = '\u2069';
+ const i_chars = "\u2066\u2067\u2068";
+ const pdi = "\u2069";
- assert.equal(rtl.get_direction('aa' + i_chars.charAt(0) + 'bb' + pdi + 'cc'), 'ltr');
- assert.equal(rtl.get_direction('دد' + i_chars.charAt(0) + 'bb' + pdi + 'cc'), 'rtl');
- assert.equal(rtl.get_direction('12' + i_chars.charAt(0) + 'bb' + pdi + 'جج'), 'rtl');
- assert.equal(rtl.get_direction('۱۲' + i_chars.charAt(0) + 'جج' + pdi + 'cc'), 'ltr');
- 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("aa" + i_chars.charAt(0) + "bb" + pdi + "cc"), "ltr");
+ assert.equal(rtl.get_direction("دد" + i_chars.charAt(0) + "bb" + pdi + "cc"), "rtl");
+ assert.equal(rtl.get_direction("12" + i_chars.charAt(0) + "bb" + pdi + "جج"), "rtl");
+ assert.equal(rtl.get_direction("۱۲" + i_chars.charAt(0) + "جج" + pdi + "cc"), "ltr");
+ 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('aa' + i_chars.charAt(1) + 'bb' + pdi + 'cc'), 'ltr');
- assert.equal(rtl.get_direction('دد' + i_chars.charAt(2) + 'bb' + pdi + 'cc'), 'rtl');
- assert.equal(rtl.get_direction('12' + i_chars.charAt(1) + 'bb' + pdi + 'جج'), 'rtl');
- assert.equal(rtl.get_direction('۱۲' + i_chars.charAt(2) + 'جج' + pdi + 'cc'), 'ltr');
- 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("aa" + i_chars.charAt(1) + "bb" + pdi + "cc"), "ltr");
+ assert.equal(rtl.get_direction("دد" + i_chars.charAt(2) + "bb" + pdi + "cc"), "rtl");
+ assert.equal(rtl.get_direction("12" + i_chars.charAt(1) + "bb" + pdi + "جج"), "rtl");
+ assert.equal(rtl.get_direction("۱۲" + i_chars.charAt(2) + "جج" + pdi + "cc"), "ltr");
+ 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");
});
diff --git a/frontend_tests/node_tests/schema.js b/frontend_tests/node_tests/schema.js
index f8f48028ee4..46cf06dc05c 100644
--- a/frontend_tests/node_tests/schema.js
+++ b/frontend_tests/node_tests/schema.js
@@ -1,55 +1,55 @@
-zrequire('schema');
+zrequire("schema");
-run_test('basics', () => {
- assert.equal(schema.check_string('x', 'fred'), undefined);
- assert.equal(schema.check_string('x', [1, 2]), 'x is not a string');
+run_test("basics", () => {
+ assert.equal(schema.check_string("x", "fred"), undefined);
+ assert.equal(schema.check_string("x", [1, 2]), "x is not a string");
const fields = {
foo: schema.check_string,
bar: schema.check_string,
};
- const check_rec = (val) => schema.check_record('my_rec', val, fields);
+ const check_rec = (val) => schema.check_record("my_rec", val, fields);
assert.equal(
- check_rec({foo: 'apple', bar: 'banana'}),
+ check_rec({foo: "apple", bar: "banana"}),
undefined,
);
assert.equal(
- check_rec('bogus'),
- 'my_rec is not a record',
+ check_rec("bogus"),
+ "my_rec is not a record",
);
assert.equal(
- check_rec({foo: 'apple'}),
- 'in my_rec bar is missing',
+ check_rec({foo: "apple"}),
+ "in my_rec bar is missing",
);
assert.equal(
check_rec({}),
- 'in my_rec bar is missing, foo is missing',
+ "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',
+ 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);
+ const check_array = (val) => schema.check_array("lst", val, schema.check_string);
assert.equal(
- check_array(['foo', 'bar']),
+ check_array(["foo", "bar"]),
undefined,
);
assert.equal(
- check_array('foo'),
- 'lst is not an array',
+ 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',
+ 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 591ef8af2d5..6b66536c0f8 100644
--- a/frontend_tests/node_tests/scroll_util.js
+++ b/frontend_tests/node_tests/scroll_util.js
@@ -1,9 +1,9 @@
-zrequire('scroll_util');
-set_global('ui', {
+zrequire("scroll_util");
+set_global("ui", {
get_scroll_element: (element) => element,
});
-run_test('scroll_delta', () => {
+run_test("scroll_delta", () => {
// If we are entirely on-screen, don't scroll
assert.equal(0, scroll_util.scroll_delta({
elem_top: 1,
@@ -57,7 +57,7 @@ run_test('scroll_delta', () => {
});
-run_test('scroll_element_into_container', () => {
+run_test("scroll_element_into_container", () => {
const container = (function () {
let top = 3;
return {
diff --git a/frontend_tests/node_tests/search.js b/frontend_tests/node_tests/search.js
index 0c7fa766418..c3b91112047 100644
--- a/frontend_tests/node_tests/search.js
+++ b/frontend_tests/node_tests/search.js
@@ -1,24 +1,24 @@
-set_global('page_params', {
+set_global("page_params", {
search_pills_enabled: true,
});
-zrequire('search');
-zrequire('search_pill');
-zrequire('Filter', 'js/filter');
-zrequire('tab_bar');
+zrequire("search");
+zrequire("search_pill");
+zrequire("Filter", "js/filter");
+zrequire("tab_bar");
const noop = () => {};
const return_true = () => true;
const return_false = () => false;
-set_global('$', global.make_zjquery());
-set_global('narrow_state', {filter: return_false});
-set_global('search_suggestion', {});
-set_global('ui_util', {
+set_global("$", global.make_zjquery());
+set_global("narrow_state", {filter: return_false});
+set_global("search_suggestion", {});
+set_global("ui_util", {
change_tab_to: noop,
place_caret_at_end: noop,
});
-set_global('narrow', {});
-set_global('search_pill_widget', {
+set_global("narrow", {});
+set_global("search_pill_widget", {
widget: {
getByID: return_true,
},
@@ -27,68 +27,68 @@ set_global('search_pill_widget', {
search_pill.append_search_string = noop;
search_pill.get_search_string_for_current_filter = noop;
-global.patch_builtin('setTimeout', (func) => func());
+global.patch_builtin("setTimeout", (func) => func());
-run_test('clear_search_form', () => {
- $('#search_query').val('noise');
- $('#search_query').focus();
- $('.search_button').prop('disabled', false);
+run_test("clear_search_form", () => {
+ $("#search_query").val("noise");
+ $("#search_query").focus();
+ $(".search_button").prop("disabled", false);
search.clear_search_form();
- assert.equal($('#search_query').is_focused(), false);
- assert.equal($('#search_query').val(), '');
- assert.equal($('.search_button').prop('disabled'), true);
+ assert.equal($("#search_query").is_focused(), false);
+ assert.equal($("#search_query").val(), "");
+ assert.equal($(".search_button").prop("disabled"), true);
});
-run_test('update_button_visibility', () => {
- const search_query = $('#search_query');
- const search_button = $('.search_button');
+run_test("update_button_visibility", () => {
+ const search_query = $("#search_query");
+ const search_button = $(".search_button");
search_query.is = return_false;
- search_query.val('');
+ search_query.val("");
narrow_state.active = return_false;
- search_button.prop('disabled', true);
+ search_button.prop("disabled", true);
search.update_button_visibility();
- assert(search_button.prop('disabled'));
+ assert(search_button.prop("disabled"));
search_query.is = return_true;
- search_query.val('');
+ search_query.val("");
narrow_state.active = return_false;
- search_button.prop('disabled', true);
+ search_button.prop("disabled", true);
search.update_button_visibility();
- assert(!search_button.prop('disabled'));
+ assert(!search_button.prop("disabled"));
search_query.is = return_false;
- search_query.val('Test search term');
+ search_query.val("Test search term");
narrow_state.active = return_false;
- search_button.prop('disabled', true);
+ search_button.prop("disabled", true);
search.update_button_visibility();
- assert(!search_button.prop('disabled'));
+ assert(!search_button.prop("disabled"));
search_query.is = return_false;
- search_query.val('');
+ search_query.val("");
narrow_state.active = return_true;
- search_button.prop('disabled', true);
+ search_button.prop("disabled", true);
search.update_button_visibility();
- assert(!search_button.prop('disabled'));
+ assert(!search_button.prop("disabled"));
});
-run_test('initialize', () => {
- const search_query_box = $('#search_query');
- const searchbox_form = $('#searchbox_form');
- const search_button = $('.search_button');
- const searchbox = $('#searchbox');
+run_test("initialize", () => {
+ const search_query_box = $("#search_query");
+ const searchbox_form = $("#searchbox_form");
+ const search_button = $(".search_button");
+ const searchbox = $("#searchbox");
searchbox_form.on = (event, func) => {
- assert.equal(event, 'compositionend');
+ assert.equal(event, "compositionend");
search.is_using_input_method = false;
func();
assert(search.is_using_input_method);
};
search_pill.get_search_string_for_current_filter = function () {
- return 'is:starred';
+ return "is:starred";
};
search_suggestion.max_num_of_search_results = 99;
@@ -104,29 +104,29 @@ run_test('initialize', () => {
{
const search_suggestions = {
lookup_table: new Map([
- ['stream:Verona', {
- description: 'Stream <strong>Ver</strong>ona',
- search_string: 'stream:Verona',
+ ["stream:Verona", {
+ description: "Stream <strong>Ver</strong>ona",
+ search_string: "stream:Verona",
}],
- ['ver', {
- description: 'Search for ver',
- search_string: 'ver',
+ ["ver", {
+ description: "Search for ver",
+ search_string: "ver",
}],
]),
- strings: ['ver', 'stream:Verona'],
+ strings: ["ver", "stream:Verona"],
};
/* Test source */
search_suggestion.get_suggestions = () => search_suggestions;
const expected_source_value = search_suggestions.strings;
- const source = opts.source('ver');
+ const source = opts.source("ver");
assert.equal(source, expected_source_value);
/* Test highlighter */
- let expected_value = 'Search for ver';
+ let expected_value = "Search for ver";
assert.equal(opts.highlighter(source[0]), expected_value);
- expected_value = 'Stream <strong>Ver</strong>ona';
+ expected_value = "Stream <strong>Ver</strong>ona";
assert.equal(opts.highlighter(source[1]), expected_value);
/* Test sorter */
@@ -154,37 +154,37 @@ run_test('initialize', () => {
};
narrow.activate = (raw_operators, options) => {
assert.deepEqual(raw_operators, operators);
- assert.deepEqual(options, {trigger: 'search'});
+ assert.deepEqual(options, {trigger: "search"});
};
search_pill.get_search_string_for_current_filter = () => search_box_val;
};
operators = [{
negated: false,
- operator: 'search',
- operand: 'ver',
+ operator: "search",
+ operand: "ver",
}];
- _setup('ver');
+ _setup("ver");
- assert.equal(opts.updater('ver'), 'ver');
+ assert.equal(opts.updater("ver"), "ver");
assert(!is_blurred);
assert(is_append_search_string_called);
operators = [{
negated: false,
- operator: 'stream',
- operand: 'Verona',
+ operator: "stream",
+ operand: "Verona",
}];
- _setup('stream:Verona');
+ _setup("stream:Verona");
- assert.equal(opts.updater('stream:Verona'), 'stream:Verona');
+ assert.equal(opts.updater("stream:Verona"), "stream:Verona");
assert(!is_blurred);
assert(is_append_search_string_called);
search.is_using_input_method = true;
- _setup('stream:Verona');
+ _setup("stream:Verona");
- assert.equal(opts.updater('stream:Verona'), 'stream:Verona');
+ assert.equal(opts.updater("stream:Verona"), "stream:Verona");
assert(!is_blurred);
assert(is_append_search_string_called);
}
@@ -218,7 +218,7 @@ run_test('initialize', () => {
const _setup = (search_box_val) => {
is_blurred = false;
- search_button.prop('disabled', false);
+ search_button.prop("disabled", false);
search_query_box.val(search_box_val);
Filter.parse = (search_string) => {
assert.equal(search_string, search_box_val);
@@ -226,76 +226,76 @@ run_test('initialize', () => {
};
narrow.activate = (raw_operators, options) => {
assert.deepEqual(raw_operators, operators);
- assert.deepEqual(options, {trigger: 'search'});
+ assert.deepEqual(options, {trigger: "search"});
};
search_pill.get_search_string_for_current_filter = () => search_box_val;
};
operators = [{
negated: false,
- operator: 'search',
- operand: '',
+ operator: "search",
+ operand: "",
}];
- _setup('');
+ _setup("");
ev.which = 15;
search_query_box.is = return_false;
func(ev);
assert(!is_blurred);
- assert(!search_button.prop('disabled'));
+ assert(!search_button.prop("disabled"));
ev.which = 13;
search_query_box.is = return_false;
func(ev);
assert(!is_blurred);
- assert(!search_button.prop('disabled'));
+ assert(!search_button.prop("disabled"));
ev.which = 13;
search_query_box.is = return_true;
func(ev);
assert(is_blurred);
- _setup('ver');
+ _setup("ver");
search.is_using_input_method = true;
func(ev);
// No change on enter keyup event when using input tool
assert(!is_blurred);
- assert(!search_button.prop('disabled'));
+ assert(!search_button.prop("disabled"));
- _setup('ver');
+ _setup("ver");
ev.which = 13;
search_query_box.is = return_true;
func(ev);
assert(is_blurred);
- assert(!search_button.prop('disabled'));
+ assert(!search_button.prop("disabled"));
};
- const search_pill_stub = $.create('.pill');
+ const search_pill_stub = $.create(".pill");
search_pill_stub.closest = () => ({ data: noop });
const stub_event = {
relatedTarget: search_pill_stub,
};
search_query_box.on = (event, callback) => {
- if (event === 'focus') {
- search_button.prop('disabled', true);
+ if (event === "focus") {
+ search_button.prop("disabled", true);
callback();
- assert(!search_button.prop('disabled'));
- } else if (event === 'blur') {
+ assert(!search_button.prop("disabled"));
+ } else if (event === "blur") {
search_query_box.val("test string");
- narrow_state.search_string = () => 'ver';
+ narrow_state.search_string = () => "ver";
callback(stub_event);
- assert.equal(search_query_box.val(), 'test string');
+ assert.equal(search_query_box.val(), "test string");
}
};
searchbox.on = (event, callback) => {
- if (event === 'focusin') {
+ if (event === "focusin") {
searchbox.css({"box-shadow": "unset"});
callback();
assert.deepEqual(searchbox.css(), {"box-shadow": "inset 0px 0px 0px 2px hsl(204, 20%, 74%)"});
- } else if (event === 'focusout') {
+ } else if (event === "focusout") {
searchbox.css({"box-shadow": "inset 0px 0px 0px 2px hsl(204, 20%, 74%)"});
callback();
assert.deepEqual(searchbox.css(), {"box-shadow": "unset"});
@@ -305,7 +305,7 @@ run_test('initialize', () => {
search.initialize();
});
-run_test('initiate_search', () => {
+run_test("initiate_search", () => {
// open typeahead and select text when navbar is open
// this implicitly expects the code to used the chained
// function calls, which is something to keep in mind if
@@ -313,11 +313,11 @@ run_test('initiate_search', () => {
let typeahead_forced_open = false;
let is_searchbox_text_selected = false;
let is_searchbox_focused = false;
- $('#search_query').focus = () => {
+ $("#search_query").focus = () => {
is_searchbox_focused = true;
};
- $('#search_query').select = noop;
- $('#search_query').typeahead = (lookup) => {
+ $("#search_query").select = noop;
+ $("#search_query").typeahead = (lookup) => {
if (lookup === "lookup") {
typeahead_forced_open = true;
return {
diff --git a/frontend_tests/node_tests/search_legacy.js b/frontend_tests/node_tests/search_legacy.js
index 72c1c54ae74..766cd672993 100644
--- a/frontend_tests/node_tests/search_legacy.js
+++ b/frontend_tests/node_tests/search_legacy.js
@@ -1,64 +1,64 @@
-set_global('page_params', {
+set_global("page_params", {
search_pills_enabled: false,
});
-zrequire('search');
-zrequire('tab_bar');
+zrequire("search");
+zrequire("tab_bar");
const noop = () => {};
const return_true = () => true;
const return_false = () => false;
-set_global('$', global.make_zjquery());
-set_global('narrow_state', {});
-set_global('search_suggestion', {});
-set_global('ui_util', {
+set_global("$", global.make_zjquery());
+set_global("narrow_state", {});
+set_global("search_suggestion", {});
+set_global("ui_util", {
change_tab_to: noop,
});
-set_global('narrow', {});
-set_global('Filter', {});
+set_global("narrow", {});
+set_global("Filter", {});
-global.patch_builtin('setTimeout', (func) => func());
+global.patch_builtin("setTimeout", (func) => func());
-run_test('update_button_visibility', () => {
- const search_query = $('#search_query');
- const search_button = $('.search_button');
+run_test("update_button_visibility", () => {
+ const search_query = $("#search_query");
+ const search_button = $(".search_button");
search_query.is = return_false;
- search_query.val('');
+ search_query.val("");
narrow_state.active = return_false;
- search_button.prop('disabled', true);
+ search_button.prop("disabled", true);
search.update_button_visibility();
- assert(search_button.prop('disabled'));
+ assert(search_button.prop("disabled"));
search_query.is = return_true;
- search_query.val('');
+ search_query.val("");
narrow_state.active = return_false;
- search_button.prop('disabled', true);
+ search_button.prop("disabled", true);
search.update_button_visibility();
- assert(!search_button.prop('disabled'));
+ assert(!search_button.prop("disabled"));
search_query.is = return_false;
- search_query.val('Test search term');
+ search_query.val("Test search term");
narrow_state.active = return_false;
- search_button.prop('disabled', true);
+ search_button.prop("disabled", true);
search.update_button_visibility();
- assert(!search_button.prop('disabled'));
+ assert(!search_button.prop("disabled"));
search_query.is = return_false;
- search_query.val('');
+ search_query.val("");
narrow_state.active = return_true;
- search_button.prop('disabled', true);
+ search_button.prop("disabled", true);
search.update_button_visibility();
- assert(!search_button.prop('disabled'));
+ assert(!search_button.prop("disabled"));
});
-run_test('initialize', () => {
- const search_query_box = $('#search_query');
- const searchbox_form = $('#searchbox_form');
- const search_button = $('.search_button');
+run_test("initialize", () => {
+ const search_query_box = $("#search_query");
+ const searchbox_form = $("#searchbox_form");
+ const search_button = $(".search_button");
searchbox_form.on = (event, func) => {
- assert.equal(event, 'compositionend');
+ assert.equal(event, "compositionend");
search.is_using_input_method = false;
func();
assert(search.is_using_input_method);
@@ -75,29 +75,29 @@ run_test('initialize', () => {
{
const search_suggestions = {
lookup_table: new Map([
- ['stream:Verona', {
- description: 'Stream <strong>Ver</strong>ona',
- search_string: 'stream:Verona',
+ ["stream:Verona", {
+ description: "Stream <strong>Ver</strong>ona",
+ search_string: "stream:Verona",
}],
- ['ver', {
- description: 'Search for ver',
- search_string: 'ver',
+ ["ver", {
+ description: "Search for ver",
+ search_string: "ver",
}],
]),
- strings: ['ver', 'stream:Verona'],
+ strings: ["ver", "stream:Verona"],
};
/* Test source */
search_suggestion.get_suggestions = () => search_suggestions;
const expected_source_value = search_suggestions.strings;
- const source = opts.source('ver');
+ const source = opts.source("ver");
assert.equal(source, expected_source_value);
/* Test highlighter */
- let expected_value = 'Search for ver';
+ let expected_value = "Search for ver";
assert.equal(opts.highlighter(source[0]), expected_value);
- expected_value = 'Stream <strong>Ver</strong>ona';
+ expected_value = "Stream <strong>Ver</strong>ona";
assert.equal(opts.highlighter(source[1]), expected_value);
/* Test sorter */
@@ -120,31 +120,31 @@ run_test('initialize', () => {
};
narrow.activate = (raw_operators, options) => {
assert.deepEqual(raw_operators, operators);
- assert.deepEqual(options, {trigger: 'search'});
+ assert.deepEqual(options, {trigger: "search"});
};
};
operators = [{
negated: false,
- operator: 'search',
- operand: 'ver',
+ operator: "search",
+ operand: "ver",
}];
- _setup('ver');
- assert.equal(opts.updater('ver'), 'ver');
+ _setup("ver");
+ assert.equal(opts.updater("ver"), "ver");
assert(is_blurred);
operators = [{
negated: false,
- operator: 'stream',
- operand: 'Verona',
+ operator: "stream",
+ operand: "Verona",
}];
- _setup('stream:Verona');
- assert.equal(opts.updater('stream:Verona'), 'stream:Verona');
+ _setup("stream:Verona");
+ assert.equal(opts.updater("stream:Verona"), "stream:Verona");
assert(is_blurred);
search.is_using_input_method = true;
- _setup('stream:Verona');
- assert.equal(opts.updater('stream:Verona'), 'stream:Verona');
+ _setup("stream:Verona");
+ assert.equal(opts.updater("stream:Verona"), "stream:Verona");
assert(!is_blurred);
}
};
@@ -177,7 +177,7 @@ run_test('initialize', () => {
const _setup = (search_box_val) => {
is_blurred = false;
- search_button.prop('disabled', false);
+ search_button.prop("disabled", false);
search_query_box.val(search_box_val);
Filter.parse = (search_string) => {
assert.equal(search_string, search_box_val);
@@ -185,68 +185,68 @@ run_test('initialize', () => {
};
narrow.activate = (raw_operators, options) => {
assert.deepEqual(raw_operators, operators);
- assert.deepEqual(options, {trigger: 'search'});
+ assert.deepEqual(options, {trigger: "search"});
};
};
operators = [{
negated: false,
- operator: 'search',
- operand: '',
+ operator: "search",
+ operand: "",
}];
- _setup('');
+ _setup("");
ev.which = 15;
search_query_box.is = return_false;
func(ev);
assert(!is_blurred);
- assert(!search_button.prop('disabled'));
+ assert(!search_button.prop("disabled"));
ev.which = 13;
search_query_box.is = return_false;
func(ev);
assert(!is_blurred);
- assert(!search_button.prop('disabled'));
+ assert(!search_button.prop("disabled"));
ev.which = 13;
search_query_box.is = return_true;
func(ev);
assert(is_blurred);
- _setup('ver');
+ _setup("ver");
search.is_using_input_method = true;
func(ev);
// No change on enter keyup event when using input tool
assert(!is_blurred);
- assert(!search_button.prop('disabled'));
+ assert(!search_button.prop("disabled"));
- _setup('ver');
+ _setup("ver");
ev.which = 13;
search_query_box.is = return_true;
func(ev);
assert(is_blurred);
- assert(!search_button.prop('disabled'));
+ assert(!search_button.prop("disabled"));
};
search_query_box.on = (event, callback) => {
- if (event === 'focus') {
- search_button.prop('disabled', true);
+ if (event === "focus") {
+ search_button.prop("disabled", true);
callback();
- assert(!search_button.prop('disabled'));
- } else if (event === 'blur') {
+ assert(!search_button.prop("disabled"));
+ } else if (event === "blur") {
search_query_box.val("test string");
- narrow_state.search_string = () => 'ver';
+ narrow_state.search_string = () => "ver";
callback();
- assert.equal(search_query_box.val(), 'test string');
+ assert.equal(search_query_box.val(), "test string");
}
};
search.initialize();
});
-run_test('initiate_search', () => {
+run_test("initiate_search", () => {
// open typeahead and select text when navbar is open
// this implicitly expects the code to used the chained
// function calls, which is something to keep in mind if
@@ -254,8 +254,8 @@ run_test('initiate_search', () => {
narrow_state.filter = () => ({is_search: return_true});
let typeahead_forced_open = false;
let is_searchbox_text_selected = false;
- $('#search_query').select = noop;
- $('#search_query').typeahead = (lookup) => {
+ $("#search_query").select = noop;
+ $("#search_query").typeahead = (lookup) => {
if (lookup === "lookup") {
typeahead_forced_open = true;
return {
@@ -268,10 +268,10 @@ run_test('initiate_search', () => {
search.initiate_search();
assert(typeahead_forced_open);
assert(is_searchbox_text_selected);
- assert.equal($('#search_query').val(), "ver");
+ assert.equal($("#search_query").val(), "ver");
// test that we append space for user convenience
narrow_state.filter = () => ({is_search: return_false});
search.initiate_search();
- assert.equal($('#search_query').val(), "ver ");
+ assert.equal($("#search_query").val(), "ver ");
});
diff --git a/frontend_tests/node_tests/search_pill.js b/frontend_tests/node_tests/search_pill.js
index 2785ea54e60..d1c1e0b17e0 100644
--- a/frontend_tests/node_tests/search_pill.js
+++ b/frontend_tests/node_tests/search_pill.js
@@ -1,33 +1,33 @@
-zrequire('search_pill');
-zrequire('input_pill');
-zrequire('Filter', 'js/filter');
-set_global('Handlebars', global.make_handlebars());
+zrequire("search_pill");
+zrequire("input_pill");
+zrequire("Filter", "js/filter");
+set_global("Handlebars", global.make_handlebars());
const is_starred_item = {
- display_value: 'is:starred',
- description: 'starred messages',
+ display_value: "is:starred",
+ description: "starred messages",
};
const is_private_item = {
- display_value: 'is:private',
- description: 'private messages',
+ display_value: "is:private",
+ description: "private messages",
};
-run_test('create_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);
}
- test_create_item('is:starred', [], is_starred_item);
+ test_create_item("is:starred", [], is_starred_item);
});
-run_test('get_search_string', () => {
- assert.equal(search_pill.get_search_string_from_item(is_starred_item), 'is:starred');
+run_test("get_search_string", () => {
+ assert.equal(search_pill.get_search_string_from_item(is_starred_item), "is:starred");
});
-run_test('append', () => {
+run_test("append", () => {
let appended;
let cleared;
@@ -51,7 +51,7 @@ run_test('append', () => {
assert(cleared);
});
-run_test('get_items', () => {
+run_test("get_items", () => {
const items = [is_starred_item, is_private_item];
const pill_widget = {
@@ -59,18 +59,18 @@ run_test('get_items', () => {
};
assert.deepEqual(search_pill.get_search_string_for_current_filter(pill_widget),
- is_starred_item.display_value + ' ' + is_private_item.display_value);
+ is_starred_item.display_value + " " + is_private_item.display_value);
});
-run_test('create_pills', () => {
+run_test("create_pills", () => {
let input_pill_create_called = false;
input_pill.create = function () {
input_pill_create_called = true;
- return {dummy: 'dummy'};
+ return {dummy: "dummy"};
};
const pills = search_pill.create_pills({});
assert(input_pill_create_called);
- assert.deepEqual(pills, {dummy: 'dummy'});
+ assert.deepEqual(pills, {dummy: "dummy"});
});
diff --git a/frontend_tests/node_tests/search_suggestion.js b/frontend_tests/node_tests/search_suggestion.js
index 63b748970b9..61b4cc48694 100644
--- a/frontend_tests/node_tests/search_suggestion.js
+++ b/frontend_tests/node_tests/search_suggestion.js
@@ -1,61 +1,61 @@
-set_global('page_params', {
+set_global("page_params", {
search_pills_enabled: true,
});
-set_global('message_store', {
+set_global("message_store", {
user_ids: () => [],
});
-const settings_config = zrequire('settings_config');
+const settings_config = zrequire("settings_config");
page_params.realm_email_address_visibility =
settings_config.email_address_visibility_values.admins_only.code;
-const huddle_data = zrequire('huddle_data');
+const huddle_data = zrequire("huddle_data");
-zrequire('typeahead_helper');
-set_global('Handlebars', global.make_handlebars());
-zrequire('Filter', 'js/filter');
-zrequire('narrow_state');
-zrequire('stream_data');
-zrequire('stream_topic_history');
-zrequire('people');
-zrequire('unread');
-zrequire('common');
-const search = zrequire('search_suggestion');
+zrequire("typeahead_helper");
+set_global("Handlebars", global.make_handlebars());
+zrequire("Filter", "js/filter");
+zrequire("narrow_state");
+zrequire("stream_data");
+zrequire("stream_topic_history");
+zrequire("people");
+zrequire("unread");
+zrequire("common");
+const search = zrequire("search_suggestion");
search.max_num_of_search_results = 15;
const me = {
- email: '[email protected]',
- full_name: 'Me Myself',
+ email: "[email protected]",
+ full_name: "Me Myself",
user_id: 41,
};
const bob = {
- email: '[email protected]',
- full_name: 'Bob Roberts',
+ email: "[email protected]",
+ full_name: "Bob Roberts",
user_id: 42,
};
const ted =
{
- email: '[email protected]',
+ email: "[email protected]",
user_id: 101,
- full_name: 'Ted Smith',
+ full_name: "Ted Smith",
};
const alice =
{
- email: '[email protected]',
+ email: "[email protected]",
user_id: 102,
- full_name: 'Alice Ignore',
+ full_name: "Alice Ignore",
};
const jeff =
{
- email: '[email protected]',
+ email: "[email protected]",
user_id: 103,
- full_name: 'Jeff Zoolipson',
+ full_name: "Jeff Zoolipson",
};
const noop = () => {};
@@ -73,7 +73,7 @@ function init() {
init();
page_params.is_admin = true;
-set_global('narrow', {});
+set_global("narrow", {});
stream_topic_history.reset();
@@ -81,28 +81,28 @@ function get_suggestions(base_query, query) {
return search.get_suggestions(base_query, query);
}
-run_test('basic_get_suggestions', () => {
- const query = 'fred';
+run_test("basic_get_suggestions", () => {
+ const query = "fred";
global.stream_data.subscribed_streams = function () {
return [];
};
global.narrow_state.stream = function () {
- return 'office';
+ return "office";
};
- const suggestions = get_suggestions('', query);
+ const suggestions = get_suggestions("", query);
const expected = [
- 'fred',
+ "fred",
];
assert.deepEqual(suggestions.strings, expected);
});
-run_test('subset_suggestions', () => {
- const query = 'shakespeare';
- const base_query = 'stream:Denmark topic:Hamlet';
+run_test("subset_suggestions", () => {
+ const query = "shakespeare";
+ const base_query = "stream:Denmark topic:Hamlet";
global.stream_data.subscribed_streams = function () {
return [];
@@ -121,7 +121,7 @@ run_test('subset_suggestions', () => {
assert.deepEqual(suggestions.strings, expected);
});
-run_test('private_suggestions', () => {
+run_test("private_suggestions", () => {
global.stream_data.subscribed_streams = function () {
return [];
};
@@ -130,8 +130,8 @@ run_test('private_suggestions', () => {
return;
};
- let query = 'is:private';
- let suggestions = get_suggestions('', query);
+ let query = "is:private";
+ let suggestions = get_suggestions("", query);
let expected = [
"is:private",
"pm-with:[email protected]",
@@ -142,8 +142,8 @@ run_test('private_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = 'al';
- let base_query = 'is:private';
+ query = "al";
+ let base_query = "is:private";
suggestions = get_suggestions(base_query, query);
expected = [
"al",
@@ -154,62 +154,62 @@ run_test('private_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = 'pm-with:t';
- suggestions = get_suggestions('', query);
+ query = "pm-with:t";
+ suggestions = get_suggestions("", query);
expected = [
"pm-with:t",
"pm-with:[email protected]",
];
assert.deepEqual(suggestions.strings, expected);
- query = '-pm-with:t';
- suggestions = get_suggestions('', query);
+ query = "-pm-with:t";
+ suggestions = get_suggestions("", query);
expected = [
"-pm-with:t",
"is:private -pm-with:[email protected]",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'pm-with:[email protected]';
- suggestions = get_suggestions('', query);
+ query = "pm-with:[email protected]";
+ suggestions = get_suggestions("", query);
expected = [
"pm-with:[email protected]",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'sender:ted';
- suggestions = get_suggestions('', query);
+ query = "sender:ted";
+ suggestions = get_suggestions("", query);
expected = [
"sender:ted",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'sender:te';
- suggestions = get_suggestions('', query);
+ query = "sender:te";
+ suggestions = get_suggestions("", query);
expected = [
"sender:te",
];
assert.deepEqual(suggestions.strings, expected);
- query = '-sender:te';
- suggestions = get_suggestions('', query);
+ query = "-sender:te";
+ suggestions = get_suggestions("", query);
expected = [
"-sender:te",
"-sender:[email protected]",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'sender:[email protected]';
- suggestions = get_suggestions('', query);
+ query = "sender:[email protected]";
+ suggestions = get_suggestions("", query);
expected = [
];
assert.deepEqual(suggestions.strings, expected);
- query = 'from:ted';
- base_query = 'is:unread';
+ query = "from:ted";
+ base_query = "is:unread";
suggestions = get_suggestions(base_query, query);
expected = [
"from:ted",
@@ -219,16 +219,16 @@ run_test('private_suggestions', () => {
// Users can enter bizarre queries, and if they do, we want to
// be conservative with suggestions.
- query = 'near:3';
- base_query = 'is:private';
+ query = "near:3";
+ base_query = "is:private";
suggestions = get_suggestions(base_query, query);
expected = [
"near:3",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'near:3';
- base_query = 'pm-with:[email protected]';
+ query = "near:3";
+ base_query = "pm-with:[email protected]";
suggestions = get_suggestions(base_query, query);
expected = [
"near:3",
@@ -236,16 +236,16 @@ run_test('private_suggestions', () => {
assert.deepEqual(suggestions.strings, expected);
// Make sure suggestions still work if preceding tokens
- query = 'sender:[email protected]';
- base_query = 'is:alerted';
+ query = "sender:[email protected]";
+ base_query = "is:alerted";
suggestions = get_suggestions(base_query, query);
expected = [
];
assert.deepEqual(suggestions.strings, expected);
- query = 'al';
- base_query = 'is:starred has:link is:private';
+ query = "al";
+ base_query = "is:starred has:link is:private";
suggestions = get_suggestions(base_query, query);
expected = [
"al",
@@ -257,24 +257,24 @@ run_test('private_suggestions', () => {
assert.deepEqual(suggestions.strings, expected);
// Make sure it handles past context correctly
- query = 'pm-with:';
- base_query = 'stream:Denmark';
+ query = "pm-with:";
+ base_query = "stream:Denmark";
suggestions = get_suggestions(base_query, query);
expected = [
- 'pm-with:',
+ "pm-with:",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'sender:';
- base_query = 'sender:[email protected]';
+ query = "sender:";
+ base_query = "sender:[email protected]";
suggestions = get_suggestions(base_query, query);
expected = [
- 'sender:',
+ "sender:",
];
assert.deepEqual(suggestions.strings, expected);
});
-run_test('group_suggestions', () => {
+run_test("group_suggestions", () => {
global.stream_data.subscribed_streams = function () {
return [];
};
@@ -285,8 +285,8 @@ run_test('group_suggestions', () => {
// Entering a comma in a pm-with query should immediately generate
// suggestions for the next person.
- let query = 'pm-with:[email protected],';
- let suggestions = get_suggestions('', query);
+ let query = "pm-with:[email protected],";
+ let suggestions = get_suggestions("", query);
let expected = [
"pm-with:[email protected],",
@@ -297,8 +297,8 @@ run_test('group_suggestions', () => {
// Only the last part of a comma-separated pm-with query should be used to
// generate suggestions.
- query = 'pm-with:[email protected],t';
- suggestions = get_suggestions('', query);
+ query = "pm-with:[email protected],t";
+ suggestions = get_suggestions("", query);
expected = [
"pm-with:[email protected],t",
@@ -306,8 +306,8 @@ run_test('group_suggestions', () => {
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);
+ query = "pm-with:[email protected],Smit";
+ suggestions = get_suggestions("", query);
expected = [
"pm-with:[email protected],Smit",
@@ -315,16 +315,16 @@ run_test('group_suggestions', () => {
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);
+ query = "pm-with:[email protected],mys";
+ suggestions = get_suggestions("", query);
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);
+ query = "pm-with:[email protected],red";
+ suggestions = get_suggestions("", query);
expected = [
"pm-with:[email protected],red",
];
@@ -333,8 +333,8 @@ run_test('group_suggestions', () => {
// is:private should be properly prepended to each suggestion if the pm-with
// operator is negated.
- query = '-pm-with:[email protected],';
- suggestions = get_suggestions('', query);
+ query = "-pm-with:[email protected],";
+ suggestions = get_suggestions("", query);
expected = [
"-pm-with:[email protected],",
"is:private -pm-with:[email protected],[email protected]",
@@ -343,32 +343,32 @@ run_test('group_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = '-pm-with:[email protected],t';
- suggestions = get_suggestions('', query);
+ query = "-pm-with:[email protected],t";
+ suggestions = get_suggestions("", query);
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);
+ query = "-pm-with:[email protected],Smit";
+ suggestions = get_suggestions("", query);
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);
+ query = "-pm-with:[email protected],red";
+ suggestions = get_suggestions("", query);
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';
+ 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",
@@ -376,8 +376,8 @@ run_test('group_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = 'pm-with:[email protected],Smit';
- base_query = 'stream:Denmark has:link';
+ query = "pm-with:[email protected],Smit";
+ base_query = "stream:Denmark has:link";
suggestions = get_suggestions(base_query, query);
expected = [
"pm-with:[email protected],Smit",
@@ -386,7 +386,7 @@ run_test('group_suggestions', () => {
function message(user_ids, timestamp) {
return {
- type: 'private',
+ type: "private",
display_recipient: user_ids.map((id) => ({
id: id,
})),
@@ -400,8 +400,8 @@ run_test('group_suggestions', () => {
]);
// Simulate a past huddle which should now prioritize ted over alice
- query = 'pm-with:[email protected],';
- suggestions = get_suggestions('', query);
+ query = "pm-with:[email protected],";
+ suggestions = get_suggestions("", query);
expected = [
"pm-with:[email protected],",
@@ -411,8 +411,8 @@ run_test('group_suggestions', () => {
assert.deepEqual(suggestions.strings, expected);
// bob,ted,jeff is already an existing huddle, so prioritize this one
- suggestions = get_suggestions('', query);
+ suggestions = get_suggestions("", query);
expected = [
@@ -422,8 +422,8 @@ run_test('group_suggestions', () => {
// bob,ted,jeff is already an existing huddle, but if we start with just jeff,
// then don't prioritize ted over alice because it doesn't complete the full huddle.
- query = 'pm-with:[email protected],';
- suggestions = get_suggestions('', query);
+ query = "pm-with:[email protected],";
+ suggestions = get_suggestions("", query);
expected = [
"pm-with:[email protected],",
@@ -442,18 +442,18 @@ run_test('group_suggestions', () => {
init();
-run_test('empty_query_suggestions', () => {
- const query = '';
+run_test("empty_query_suggestions", () => {
+ const query = "";
global.stream_data.subscribed_streams = function () {
- return ['devel', 'office'];
+ return ["devel", "office"];
};
global.narrow_state.stream = function () {
return;
};
- const suggestions = get_suggestions('', query);
+ const suggestions = get_suggestions("", query);
const expected = [
"",
@@ -466,9 +466,9 @@ run_test('empty_query_suggestions', () => {
"stream:devel",
"stream:office",
- 'has:link',
- 'has:image',
- 'has:attachment',
+ "has:link",
+ "has:image",
+ "has:attachment",
];
assert.deepEqual(suggestions.strings, expected);
@@ -476,34 +476,34 @@ run_test('empty_query_suggestions', () => {
function describe(q) {
return suggestions.lookup_table.get(q).description;
}
- assert.equal(describe('is:private'), 'Private messages');
- assert.equal(describe('is:starred'), 'Starred messages');
- assert.equal(describe('is:mentioned'), '@-mentions');
- assert.equal(describe('is:alerted'), 'Alerted messages');
- assert.equal(describe('is:unread'), 'Unread messages');
- assert.equal(describe('sender:[email protected]'), 'Sent by me');
- assert.equal(describe('has:link'), 'Messages with one or more link');
- assert.equal(describe('has:image'), 'Messages with one or more image');
- assert.equal(describe('has:attachment'), 'Messages with one or more attachment');
+ assert.equal(describe("is:private"), "Private messages");
+ assert.equal(describe("is:starred"), "Starred messages");
+ assert.equal(describe("is:mentioned"), "@-mentions");
+ assert.equal(describe("is:alerted"), "Alerted messages");
+ assert.equal(describe("is:unread"), "Unread messages");
+ assert.equal(describe("sender:[email protected]"), "Sent by me");
+ assert.equal(describe("has:link"), "Messages with one or more link");
+ assert.equal(describe("has:image"), "Messages with one or more image");
+ assert.equal(describe("has:attachment"), "Messages with one or more attachment");
});
-run_test('has_suggestions', () => {
+run_test("has_suggestions", () => {
// Checks that category wise suggestions are displayed instead of a single
// default suggestion when suggesting `has` operator.
- let query = 'h';
+ let query = "h";
global.stream_data.subscribed_streams = function () {
- return ['devel', 'office'];
+ return ["devel", "office"];
};
global.narrow_state.stream = function () {
return;
};
- let suggestions = get_suggestions('', query);
+ let suggestions = get_suggestions("", query);
let expected = [
"h",
- 'has:link',
- 'has:image',
- 'has:attachment',
+ "has:link",
+ "has:image",
+ "has:attachment",
];
assert.deepEqual(suggestions.strings, expected);
@@ -511,86 +511,86 @@ run_test('has_suggestions', () => {
return suggestions.lookup_table.get(q).description;
}
- assert.equal(describe('has:link'), 'Messages with one or more link');
- assert.equal(describe('has:image'), 'Messages with one or more image');
- assert.equal(describe('has:attachment'), 'Messages with one or more attachment');
+ assert.equal(describe("has:link"), "Messages with one or more link");
+ assert.equal(describe("has:image"), "Messages with one or more image");
+ assert.equal(describe("has:attachment"), "Messages with one or more attachment");
- query = '-h';
- suggestions = get_suggestions('', query);
+ query = "-h";
+ suggestions = get_suggestions("", query);
expected = [
"-h",
- '-has:link',
- '-has:image',
- '-has:attachment',
+ "-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');
- assert.equal(describe('-has:attachment'), 'Exclude messages with one or more attachment');
+ assert.equal(describe("-has:link"), "Exclude messages with one or more link");
+ assert.equal(describe("-has:image"), "Exclude messages with one or more image");
+ assert.equal(describe("-has:attachment"), "Exclude messages with one or more attachment");
// operand suggestions follow.
- query = 'has:';
- suggestions = get_suggestions('', query);
+ query = "has:";
+ suggestions = get_suggestions("", query);
expected = [
- 'has:link',
- 'has:image',
- 'has:attachment',
+ "has:link",
+ "has:image",
+ "has:attachment",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'has:im';
- suggestions = get_suggestions('', query);
+ query = "has:im";
+ suggestions = get_suggestions("", query);
expected = [
- 'has:image',
+ "has:image",
];
assert.deepEqual(suggestions.strings, expected);
- query = '-has:im';
- suggestions = get_suggestions('', query);
+ query = "-has:im";
+ suggestions = get_suggestions("", query);
expected = [
- '-has:image',
+ "-has:image",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'att';
- suggestions = get_suggestions('', query);
+ query = "att";
+ suggestions = get_suggestions("", query);
expected = [
- 'att',
- 'has:attachment',
+ "att",
+ "has:attachment",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'has:lin';
- const base_query = 'stream:Denmark is:alerted';
+ query = "has:lin";
+ const base_query = "stream:Denmark is:alerted";
suggestions = get_suggestions(base_query, query);
expected = [
- 'has:link',
+ "has:link",
];
assert.deepEqual(suggestions.strings, expected);
});
-run_test('check_is_suggestions', () => {
- let query = 'i';
+run_test("check_is_suggestions", () => {
+ let query = "i";
global.stream_data.subscribed_streams = function () {
- return ['devel', 'office'];
+ return ["devel", "office"];
};
global.narrow_state.stream = function () {
return;
};
- let suggestions = get_suggestions('', query);
+ let suggestions = get_suggestions("", query);
let expected = [
- 'i',
- 'is:private',
- 'is:starred',
- 'is:mentioned',
- 'is:alerted',
- 'is:unread',
- 'sender:[email protected]',
- 'pm-with:[email protected]',
- 'group-pm-with:[email protected]',
- 'has:image',
+ "i",
+ "is:private",
+ "is:starred",
+ "is:mentioned",
+ "is:alerted",
+ "is:unread",
+ "sender:[email protected]",
+ "pm-with:[email protected]",
+ "group-pm-with:[email protected]",
+ "has:image",
];
assert.deepEqual(suggestions.strings, expected);
@@ -598,111 +598,111 @@ run_test('check_is_suggestions', () => {
return suggestions.lookup_table.get(q).description;
}
- assert.equal(describe('is:private'), 'Private messages');
- assert.equal(describe('is:starred'), 'Starred messages');
- assert.equal(describe('is:mentioned'), '@-mentions');
- assert.equal(describe('is:alerted'), 'Alerted messages');
- assert.equal(describe('is:unread'), 'Unread messages');
+ assert.equal(describe("is:private"), "Private messages");
+ assert.equal(describe("is:starred"), "Starred messages");
+ assert.equal(describe("is:mentioned"), "@-mentions");
+ assert.equal(describe("is:alerted"), "Alerted messages");
+ assert.equal(describe("is:unread"), "Unread messages");
- query = '-i';
- suggestions = get_suggestions('', query);
+ query = "-i";
+ suggestions = get_suggestions("", query);
expected = [
- '-i',
- '-is:private',
- '-is:starred',
- '-is:mentioned',
- '-is:alerted',
- '-is:unread',
+ "-i",
+ "-is:private",
+ "-is:starred",
+ "-is:mentioned",
+ "-is:alerted",
+ "-is:unread",
];
assert.deepEqual(suggestions.strings, expected);
- assert.equal(describe('-is:private'), 'Exclude private messages');
- assert.equal(describe('-is:starred'), 'Exclude starred messages');
- assert.equal(describe('-is:mentioned'), 'Exclude @-mentions');
- assert.equal(describe('-is:alerted'), 'Exclude alerted messages');
- assert.equal(describe('-is:unread'), 'Exclude unread messages');
+ assert.equal(describe("-is:private"), "Exclude private messages");
+ assert.equal(describe("-is:starred"), "Exclude starred messages");
+ assert.equal(describe("-is:mentioned"), "Exclude @-mentions");
+ assert.equal(describe("-is:alerted"), "Exclude alerted messages");
+ assert.equal(describe("-is:unread"), "Exclude unread messages");
- query = '';
- suggestions = get_suggestions('', query);
+ query = "";
+ suggestions = get_suggestions("", query);
expected = [
- '',
- 'streams:public',
- 'is:private',
- 'is:starred',
- 'is:mentioned',
- 'is:alerted',
- 'is:unread',
- 'sender:[email protected]',
- 'stream:devel',
- 'stream:office',
- 'has:link',
- 'has:image',
- 'has:attachment',
+ "",
+ "streams:public",
+ "is:private",
+ "is:starred",
+ "is:mentioned",
+ "is:alerted",
+ "is:unread",
+ "sender:[email protected]",
+ "stream:devel",
+ "stream:office",
+ "has:link",
+ "has:image",
+ "has:attachment",
];
assert.deepEqual(suggestions.strings, expected);
- query = '';
- let base_query = 'is:private';
+ query = "";
+ let base_query = "is:private";
suggestions = get_suggestions(base_query, query);
expected = [
- 'is:starred',
- 'is:mentioned',
- 'is:alerted',
- 'is:unread',
- 'sender:[email protected]',
- 'has:link',
- 'has:image',
- 'has:attachment',
+ "is:starred",
+ "is:mentioned",
+ "is:alerted",
+ "is:unread",
+ "sender:[email protected]",
+ "has:link",
+ "has:image",
+ "has:attachment",
];
assert.deepEqual(suggestions.strings, expected);
// operand suggestions follow.
- query = 'is:';
- suggestions = get_suggestions('', query);
+ query = "is:";
+ suggestions = get_suggestions("", query);
expected = [
- 'is:private',
- 'is:starred',
- 'is:mentioned',
- 'is:alerted',
- 'is:unread',
+ "is:private",
+ "is:starred",
+ "is:mentioned",
+ "is:alerted",
+ "is:unread",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'is:st';
- suggestions = get_suggestions('', query);
+ query = "is:st";
+ suggestions = get_suggestions("", query);
expected = [
- 'is:starred',
+ "is:starred",
];
assert.deepEqual(suggestions.strings, expected);
- query = '-is:st';
- suggestions = get_suggestions('', query);
+ query = "-is:st";
+ suggestions = get_suggestions("", query);
expected = [
- '-is:starred',
+ "-is:starred",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'st';
- suggestions = get_suggestions('', query);
+ query = "st";
+ suggestions = get_suggestions("", query);
expected = [
- 'st',
- 'streams:public',
- 'is:starred',
- 'stream:',
+ "st",
+ "streams:public",
+ "is:starred",
+ "stream:",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'is:sta';
- base_query = 'stream:Denmark has:link';
+ query = "is:sta";
+ base_query = "stream:Denmark has:link";
suggestions = get_suggestions(base_query, query);
expected = [
- 'is:starred',
+ "is:starred",
];
assert.deepEqual(suggestions.strings, expected);
});
-run_test('sent_by_me_suggestions', () => {
+run_test("sent_by_me_suggestions", () => {
global.stream_data.subscribed_streams = function () {
return [];
};
@@ -711,14 +711,14 @@ run_test('sent_by_me_suggestions', () => {
return;
};
- 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');
+ 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");
- query = 'sender';
- suggestions = get_suggestions('', query);
+ query = "sender";
+ suggestions = get_suggestions("", query);
let expected = [
"sender",
@@ -726,8 +726,8 @@ run_test('sent_by_me_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = '-sender';
- suggestions = get_suggestions('', query);
+ query = "-sender";
+ suggestions = get_suggestions("", query);
expected = [
"-sender",
"-sender:[email protected]",
@@ -735,8 +735,8 @@ run_test('sent_by_me_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = 'from';
- suggestions = get_suggestions('', query);
+ query = "from";
+ suggestions = get_suggestions("", query);
expected = [
"from",
@@ -744,8 +744,8 @@ run_test('sent_by_me_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = '-from';
- suggestions = get_suggestions('', query);
+ query = "-from";
+ suggestions = get_suggestions("", query);
expected = [
"-from",
@@ -753,38 +753,38 @@ run_test('sent_by_me_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = 'sender:[email protected]';
- suggestions = get_suggestions('', query);
+ query = "sender:[email protected]";
+ suggestions = get_suggestions("", query);
expected = [
];
assert.deepEqual(suggestions.strings, expected);
- query = 'from:[email protected]';
- suggestions = get_suggestions('', query);
+ query = "from:[email protected]";
+ suggestions = get_suggestions("", query);
expected = [
];
assert.deepEqual(suggestions.strings, expected);
- query = 'sent';
- suggestions = get_suggestions('', query);
+ query = "sent";
+ suggestions = get_suggestions("", query);
expected = [
"sent",
];
assert.deepEqual(suggestions.strings, expected);
- query = '-sent';
- suggestions = get_suggestions('', query);
+ query = "-sent";
+ suggestions = get_suggestions("", query);
expected = [
"-sent",
"-sender:[email protected]",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'sent';
- let base_query = 'stream:Denmark topic:Denmark1';
+ query = "sent";
+ let base_query = "stream:Denmark topic:Denmark1";
suggestions = get_suggestions(base_query, query);
expected = [
"sent",
@@ -792,8 +792,8 @@ run_test('sent_by_me_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = 'sender:m';
- base_query = 'is:starred';
+ query = "sender:m";
+ base_query = "is:starred";
suggestions = get_suggestions(base_query, query);
expected = [
"sender:m",
@@ -801,30 +801,30 @@ run_test('sent_by_me_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = 'sender:';
- base_query = 'is:starred';
+ query = "sender:";
+ base_query = "is:starred";
suggestions = get_suggestions(base_query, query);
expected = [
- 'sender:',
- 'sender:[email protected]',
- 'sender:[email protected]',
- 'sender:[email protected]',
- 'sender:[email protected]',
- 'sender:[email protected]',
+ "sender:",
+ "sender:[email protected]",
+ "sender:[email protected]",
+ "sender:[email protected]",
+ "sender:[email protected]",
+ "sender:[email protected]",
];
assert.deepEqual(suggestions.strings, expected);
});
-run_test('topic_suggestions', () => {
+run_test("topic_suggestions", () => {
let suggestions;
let expected;
global.stream_data.subscribed_streams = function () {
- return ['office'];
+ return ["office"];
};
global.narrow_state.stream = function () {
- return 'office';
+ return "office";
};
const devel_id = 44;
@@ -832,103 +832,103 @@ 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;
}
};
stream_topic_history.reset();
- suggestions = get_suggestions('', 'te');
+ suggestions = get_suggestions("", "te");
expected = [
- 'te',
- 'sender:[email protected]',
- 'pm-with:[email protected]',
- 'group-pm-with:[email protected]',
+ "te",
+ "sender:[email protected]",
+ "pm-with:[email protected]",
+ "group-pm-with:[email protected]",
];
assert.deepEqual(suggestions.strings, expected);
stream_topic_history.add_message({
stream_id: devel_id,
- topic_name: 'REXX',
+ topic_name: "REXX",
});
- for (const topic_name of ['team', 'ignore', 'test']) {
+ for (const topic_name of ["team", "ignore", "test"]) {
stream_topic_history.add_message({
stream_id: office_id,
topic_name: topic_name,
});
}
- suggestions = get_suggestions('', 'te');
+ suggestions = get_suggestions("", "te");
expected = [
- 'te',
- 'sender:[email protected]',
- 'pm-with:[email protected]',
- 'group-pm-with:[email protected]',
- 'stream:office topic:team',
- 'stream:office topic:test',
+ "te",
+ "sender:[email protected]",
+ "pm-with:[email protected]",
+ "group-pm-with:[email protected]",
+ "stream:office topic:team",
+ "stream:office topic:test",
];
assert.deepEqual(suggestions.strings, expected);
function describe(q) {
return suggestions.lookup_table.get(q).description;
}
- assert.equal(describe('te'), "Search for te");
- assert.equal(describe('stream:office topic:team'), "Stream office &gt; team");
+ assert.equal(describe("te"), "Search for te");
+ assert.equal(describe("stream:office topic:team"), "Stream office &gt; team");
- suggestions = get_suggestions('topic:staplers', 'stream:office');
+ suggestions = get_suggestions("topic:staplers", "stream:office");
expected = [
- 'stream:office',
+ "stream:office",
];
assert.deepEqual(suggestions.strings, expected);
- suggestions = get_suggestions('stream:devel', 'topic:');
+ suggestions = get_suggestions("stream:devel", "topic:");
expected = [
- 'topic:',
- 'topic:REXX',
+ "topic:",
+ "topic:REXX",
];
assert.deepEqual(suggestions.strings, expected);
- suggestions = get_suggestions('stream:devel', '-topic:');
+ suggestions = get_suggestions("stream:devel", "-topic:");
expected = [
- '-topic:',
- '-topic:REXX',
+ "-topic:",
+ "-topic:REXX",
];
assert.deepEqual(suggestions.strings, expected);
- suggestions = get_suggestions('', '-topic:te');
+ suggestions = get_suggestions("", "-topic:te");
expected = [
- '-topic:te',
- 'stream:office -topic:team',
- 'stream:office -topic:test',
+ "-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:');
+ suggestions = get_suggestions("is:alerted stream:devel is:starred", "topic:");
expected = [
- 'topic:',
- 'topic:REXX',
+ "topic:",
+ "topic:REXX",
];
assert.deepEqual(suggestions.strings, expected);
- suggestions = get_suggestions('is:private stream:devel', 'topic:');
+ suggestions = get_suggestions("is:private stream:devel", "topic:");
expected = [
- 'topic:',
+ "topic:",
];
assert.deepEqual(suggestions.strings, expected);
- suggestions = get_suggestions('topic:REXX stream:devel', 'topic:');
+ suggestions = get_suggestions("topic:REXX stream:devel", "topic:");
expected = [
- 'topic:',
+ "topic:",
];
assert.deepEqual(suggestions.strings, expected);
});
-run_test('whitespace_glitch', () => {
- const query = 'stream:office '; // note trailing space
+run_test("whitespace_glitch", () => {
+ const query = "stream:office "; // note trailing space
global.stream_data.subscribed_streams = function () {
- return ['office'];
+ return ["office"];
};
global.narrow_state.stream = function () {
@@ -937,7 +937,7 @@ run_test('whitespace_glitch', () => {
stream_topic_history.reset();
- const suggestions = get_suggestions('', query);
+ const suggestions = get_suggestions("", query);
const expected = [
"stream:office",
@@ -946,9 +946,9 @@ run_test('whitespace_glitch', () => {
assert.deepEqual(suggestions.strings, expected);
});
-run_test('stream_completion', () => {
+run_test("stream_completion", () => {
global.stream_data.subscribed_streams = function () {
- return ['office', 'dev help'];
+ return ["office", "dev help"];
};
global.narrow_state.stream = function () {
@@ -957,24 +957,24 @@ run_test('stream_completion', () => {
stream_topic_history.reset();
- let query = 'stream:of';
- let suggestions = get_suggestions('', query);
+ let query = "stream:of";
+ let suggestions = get_suggestions("", query);
let expected = [
"stream:of",
"stream:office",
];
assert.deepEqual(suggestions.strings, expected);
- query = '-stream:of';
- suggestions = get_suggestions('', query);
+ query = "-stream:of";
+ suggestions = get_suggestions("", query);
expected = [
"-stream:of",
"-stream:office",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'hel';
- suggestions = get_suggestions('', query);
+ query = "hel";
+ suggestions = get_suggestions("", query);
expected = [
"hel",
"stream:dev+help",
@@ -987,33 +987,33 @@ function people_suggestion_setup() {
global.narrow_state.stream = noop;
const ted = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 201,
- full_name: 'Ted Smith',
+ full_name: "Ted Smith",
};
people.add_active_user(ted);
const bob = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 202,
- full_name: 'Bob Térry',
+ full_name: "Bob Térry",
};
people.add_active_user(bob);
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 203,
- full_name: 'Alice Ignore',
+ full_name: "Alice Ignore",
};
people.add_active_user(alice);
stream_topic_history.reset();
}
-run_test('people_suggestions', () => {
+run_test("people_suggestions", () => {
people_suggestion_setup();
- let query = 'te';
- let suggestions = get_suggestions('', query);
+ let query = "te";
+ let suggestions = get_suggestions("", query);
let expected = [
"te",
@@ -1028,12 +1028,12 @@ run_test('people_suggestions', () => {
const describe = (q) => suggestions.lookup_table.get(q).description;
- assert.equal(describe('pm-with:[email protected]'),
+ 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]'),
+ 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
+ suggestions = get_suggestions("", "Ted "); // note space
expected = [
"Ted",
@@ -1043,47 +1043,47 @@ run_test('people_suggestions', () => {
assert.deepEqual(suggestions.strings, expected);
- query = 'sender:ted sm';
- let base_query = '';
+ query = "sender:ted sm";
+ let base_query = "";
expected = [
- 'sender:ted+sm',
- 'sender:[email protected]',
+ "sender:ted+sm",
+ "sender:[email protected]",
];
suggestions = get_suggestions(base_query, query);
assert.deepEqual(suggestions.strings, expected);
- query = 'new';
- base_query = 'sender:[email protected]';
+ query = "new";
+ base_query = "sender:[email protected]";
expected = [
- 'new',
+ "new",
];
suggestions = get_suggestions(base_query, query);
assert.deepEqual(suggestions.strings, expected);
- query = 'sender:[email protected] new';
- base_query = '';
+ query = "sender:[email protected] new";
+ base_query = "";
expected = [
- 'sender:[email protected]+new',
+ "sender:[email protected]+new",
];
suggestions = get_suggestions(base_query, query);
assert.deepEqual(suggestions.strings, expected);
- query = 'new';
- base_query = 'sender:[email protected]';
+ query = "new";
+ base_query = "sender:[email protected]";
expected = [
- 'new',
+ "new",
];
suggestions = get_suggestions(base_query, query);
assert.deepEqual(suggestions.strings, expected);
});
-run_test('people_suggestion (Admin only email visibility)', () => {
+run_test("people_suggestion (Admin only email visibility)", () => {
/* Suggestions when realm_email_address_visibility is set to admin
only */
people_suggestion_setup();
- const query = 'te';
+ const query = "te";
page_params.is_admin = false;
- const suggestions = get_suggestions('', query);
+ const suggestions = get_suggestions("", query);
const expected = [
"te",
@@ -1098,64 +1098,64 @@ 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', () => {
+run_test("operator_suggestions", () => {
// Completed operator should return nothing
- let query = 'stream:';
- let suggestions = get_suggestions('', query);
+ let query = "stream:";
+ let suggestions = get_suggestions("", query);
let expected = [
- 'stream:',
+ "stream:",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'st';
- suggestions = get_suggestions('', query);
+ query = "st";
+ suggestions = get_suggestions("", query);
expected = [
- 'st',
- 'streams:public',
- 'is:starred',
- 'stream:',
+ "st",
+ "streams:public",
+ "is:starred",
+ "stream:",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'group-';
- suggestions = get_suggestions('', query);
+ query = "group-";
+ suggestions = get_suggestions("", query);
expected = [
- 'group-',
- 'group-pm-with:',
+ "group-",
+ "group-pm-with:",
];
assert.deepEqual(suggestions.strings, expected);
- query = '-s';
- suggestions = get_suggestions('', query);
+ query = "-s";
+ suggestions = get_suggestions("", query);
expected = [
- '-s',
- '-streams:public',
- '-sender:[email protected]',
- '-stream:',
- '-sender:',
+ "-s",
+ "-streams:public",
+ "-sender:[email protected]",
+ "-stream:",
+ "-sender:",
];
assert.deepEqual(suggestions.strings, expected);
- query = '-f';
- const base_query = 'stream:Denmark is:alerted';
+ query = "-f";
+ const base_query = "stream:Denmark is:alerted";
suggestions = get_suggestions(base_query, query);
expected = [
- '-f',
- '-from:',
+ "-f",
+ "-from:",
];
assert.deepEqual(suggestions.strings, expected);
});
-run_test('queries_with_spaces', () => {
+run_test("queries_with_spaces", () => {
global.stream_data.subscribed_streams = function () {
- return ['office', 'dev help'];
+ return ["office", "dev help"];
};
global.narrow_state.stream = function () {
@@ -1166,7 +1166,7 @@ run_test('queries_with_spaces', () => {
// test allowing spaces with quotes surrounding operand
let query = 'stream:"dev he"';
- let suggestions = get_suggestions('', query);
+ let suggestions = get_suggestions("", query);
let expected = [
"stream:dev+he",
"stream:dev+help",
@@ -1175,7 +1175,7 @@ run_test('queries_with_spaces', () => {
// test mismatched quote
query = 'stream:"dev h';
- suggestions = get_suggestions('', query);
+ suggestions = get_suggestions("", query);
expected = [
"stream:dev+h",
"stream:dev+help",
@@ -1183,8 +1183,8 @@ run_test('queries_with_spaces', () => {
assert.deepEqual(suggestions.strings, expected);
// test extra space after operator still works
- query = 'stream: offi';
- suggestions = get_suggestions('', query);
+ query = "stream: offi";
+ suggestions = get_suggestions("", query);
expected = [
"stream:offi",
"stream:office",
@@ -1194,9 +1194,9 @@ run_test('queries_with_spaces', () => {
// When input search query contains multiple operators
// and a pill hasn't been formed from those operators.
-run_test('multiple_operators_without_pills', () => {
- let query = 'is:private al';
- let base_query = '';
+run_test("multiple_operators_without_pills", () => {
+ let query = "is:private al";
+ let base_query = "";
let suggestions = get_suggestions(base_query, query);
let expected = [
"is:private al",
@@ -1207,8 +1207,8 @@ run_test('multiple_operators_without_pills', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = 'abc is:alerted sender:[email protected]';
- base_query = '';
+ query = "abc is:alerted sender:[email protected]";
+ base_query = "";
suggestions = get_suggestions(base_query, query);
expected = [
"is:alerted sender:[email protected] abc",
diff --git a/frontend_tests/node_tests/search_suggestion_legacy.js b/frontend_tests/node_tests/search_suggestion_legacy.js
index 7c275817b32..d94a57568d7 100644
--- a/frontend_tests/node_tests/search_suggestion_legacy.js
+++ b/frontend_tests/node_tests/search_suggestion_legacy.js
@@ -1,60 +1,60 @@
-set_global('page_params', {
+set_global("page_params", {
search_pills_enabled: false,
});
-set_global('message_store', {
+set_global("message_store", {
user_ids: () => [],
});
-const settings_config = zrequire('settings_config');
+const settings_config = zrequire("settings_config");
page_params.realm_email_address_visibility =
settings_config.email_address_visibility_values.admins_only.code;
-const huddle_data = zrequire('huddle_data');
+const huddle_data = zrequire("huddle_data");
-zrequire('typeahead_helper');
-set_global('Handlebars', global.make_handlebars());
-zrequire('Filter', 'js/filter');
-zrequire('narrow_state');
-zrequire('stream_data');
-zrequire('stream_topic_history');
-zrequire('people');
-zrequire('unread');
-zrequire('common');
-const search = zrequire('search_suggestion');
+zrequire("typeahead_helper");
+set_global("Handlebars", global.make_handlebars());
+zrequire("Filter", "js/filter");
+zrequire("narrow_state");
+zrequire("stream_data");
+zrequire("stream_topic_history");
+zrequire("people");
+zrequire("unread");
+zrequire("common");
+const search = zrequire("search_suggestion");
search.max_num_of_search_results = 15;
const me = {
- email: '[email protected]',
- full_name: 'Me Myself',
+ email: "[email protected]",
+ full_name: "Me Myself",
user_id: 41,
};
const bob = {
- email: '[email protected]',
- full_name: 'Bob Roberts',
+ email: "[email protected]",
+ full_name: "Bob Roberts",
user_id: 42,
};
const ted =
{
- email: '[email protected]',
+ email: "[email protected]",
user_id: 101,
- full_name: 'Ted Smith',
+ full_name: "Ted Smith",
};
const alice =
{
- email: '[email protected]',
+ email: "[email protected]",
user_id: 102,
- full_name: 'Alice Ignore',
+ full_name: "Alice Ignore",
};
const jeff =
{
- email: '[email protected]',
+ email: "[email protected]",
user_id: 103,
- full_name: 'Jeff Zoolipson',
+ full_name: "Jeff Zoolipson",
};
function init() {
@@ -69,7 +69,7 @@ function init() {
}
init();
-set_global('narrow', {});
+set_global("narrow", {});
page_params.is_admin = true;
@@ -79,27 +79,27 @@ function get_suggestions(base_query, query) {
return search.get_suggestions(base_query, query);
}
-run_test('basic_get_suggestions', () => {
- const query = 'fred';
+run_test("basic_get_suggestions", () => {
+ const query = "fred";
global.stream_data.subscribed_streams = function () {
return [];
};
global.narrow_state.stream = function () {
- return 'office';
+ return "office";
};
- const suggestions = get_suggestions('', query);
+ const suggestions = get_suggestions("", query);
const expected = [
- 'fred',
+ "fred",
];
assert.deepEqual(suggestions.strings, expected);
});
-run_test('subset_suggestions', () => {
- const query = 'stream:Denmark topic:Hamlet shakespeare';
+run_test("subset_suggestions", () => {
+ const query = "stream:Denmark topic:Hamlet shakespeare";
global.stream_data.subscribed_streams = function () {
return [];
@@ -109,7 +109,7 @@ run_test('subset_suggestions', () => {
return;
};
- const suggestions = get_suggestions('', query);
+ const suggestions = get_suggestions("", query);
const expected = [
"stream:Denmark topic:Hamlet shakespeare",
@@ -120,7 +120,7 @@ run_test('subset_suggestions', () => {
assert.deepEqual(suggestions.strings, expected);
});
-run_test('private_suggestions', () => {
+run_test("private_suggestions", () => {
global.stream_data.subscribed_streams = function () {
return [];
};
@@ -129,8 +129,8 @@ run_test('private_suggestions', () => {
return;
};
- let query = 'is:private';
- let suggestions = get_suggestions('', query);
+ let query = "is:private";
+ let suggestions = get_suggestions("", query);
let expected = [
"is:private",
"pm-with:[email protected]",
@@ -141,8 +141,8 @@ run_test('private_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = 'is:private al';
- suggestions = get_suggestions('', query);
+ query = "is:private al";
+ suggestions = get_suggestions("", query);
expected = [
"is:private al",
"is:private is:alerted",
@@ -153,62 +153,62 @@ run_test('private_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = 'pm-with:t';
- suggestions = get_suggestions('', query);
+ query = "pm-with:t";
+ suggestions = get_suggestions("", query);
expected = [
"pm-with:t",
"pm-with:[email protected]",
];
assert.deepEqual(suggestions.strings, expected);
- query = '-pm-with:t';
- suggestions = get_suggestions('', query);
+ query = "-pm-with:t";
+ suggestions = get_suggestions("", query);
expected = [
"-pm-with:t",
"is:private -pm-with:[email protected]",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'pm-with:[email protected]';
- suggestions = get_suggestions('', query);
+ query = "pm-with:[email protected]";
+ suggestions = get_suggestions("", query);
expected = [
"pm-with:[email protected]",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'sender:ted';
- suggestions = get_suggestions('', query);
+ query = "sender:ted";
+ suggestions = get_suggestions("", query);
expected = [
"sender:ted",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'sender:te';
- suggestions = get_suggestions('', query);
+ query = "sender:te";
+ suggestions = get_suggestions("", query);
expected = [
"sender:te",
];
assert.deepEqual(suggestions.strings, expected);
- query = '-sender:te';
- suggestions = get_suggestions('', query);
+ query = "-sender:te";
+ suggestions = get_suggestions("", query);
expected = [
"-sender:te",
"-sender:[email protected]",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'sender:[email protected]';
- suggestions = get_suggestions('', query);
+ query = "sender:[email protected]";
+ suggestions = get_suggestions("", query);
expected = [
];
assert.deepEqual(suggestions.strings, expected);
- query = 'is:unread from:ted';
- suggestions = get_suggestions('', query);
+ query = "is:unread from:ted";
+ suggestions = get_suggestions("", query);
expected = [
"is:unread from:ted",
"is:unread from:[email protected]",
@@ -218,16 +218,16 @@ run_test('private_suggestions', () => {
// 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);
+ query = "is:private near:3";
+ suggestions = get_suggestions("", query);
expected = [
"is:private near:3",
"is:private",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'pm-with:[email protected] near:3';
- suggestions = get_suggestions('', query);
+ query = "pm-with:[email protected] near:3";
+ suggestions = get_suggestions("", query);
expected = [
"pm-with:[email protected] near:3",
"pm-with:[email protected]",
@@ -235,16 +235,16 @@ run_test('private_suggestions', () => {
assert.deepEqual(suggestions.strings, expected);
// Make sure suggestions still work if preceding tokens
- query = 'is:alerted sender:[email protected]';
- suggestions = get_suggestions('', query);
+ query = "is:alerted sender:[email protected]";
+ suggestions = get_suggestions("", query);
expected = [
"is:alerted sender:[email protected]",
"is:alerted",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'is:starred has:link is:private al';
- suggestions = get_suggestions('', query);
+ query = "is:starred has:link is:private al";
+ suggestions = get_suggestions("", query);
expected = [
"is:starred has:link is:private al",
"is:starred has:link is:private is:alerted",
@@ -258,24 +258,24 @@ run_test('private_suggestions', () => {
assert.deepEqual(suggestions.strings, expected);
// Make sure it handles past context correctly
- query = 'stream:Denmark pm-with:';
- suggestions = get_suggestions('', query);
+ query = "stream:Denmark pm-with:";
+ suggestions = get_suggestions("", query);
expected = [
- 'stream:Denmark pm-with:',
- 'stream:Denmark',
+ "stream:Denmark pm-with:",
+ "stream:Denmark",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'sender:[email protected] sender:';
- suggestions = get_suggestions('', query);
+ query = "sender:[email protected] sender:";
+ suggestions = get_suggestions("", query);
expected = [
- 'sender:[email protected] sender:',
- 'sender:[email protected]',
+ "sender:[email protected] sender:",
+ "sender:[email protected]",
];
assert.deepEqual(suggestions.strings, expected);
});
-run_test('group_suggestions', () => {
+run_test("group_suggestions", () => {
global.stream_data.subscribed_streams = function () {
return [];
};
@@ -286,8 +286,8 @@ run_test('group_suggestions', () => {
// Entering a comma in a pm-with query should immediately generate
// suggestions for the next person.
- let query = 'pm-with:[email protected],';
- let suggestions = get_suggestions('', query);
+ let query = "pm-with:[email protected],";
+ let suggestions = get_suggestions("", query);
let expected = [
"pm-with:[email protected],",
@@ -298,8 +298,8 @@ run_test('group_suggestions', () => {
// Only the last part of a comma-separated pm-with query should be used to
// generate suggestions.
- query = 'pm-with:[email protected],t';
- suggestions = get_suggestions('', query);
+ query = "pm-with:[email protected],t";
+ suggestions = get_suggestions("", query);
expected = [
"pm-with:[email protected],t",
@@ -307,8 +307,8 @@ run_test('group_suggestions', () => {
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);
+ query = "pm-with:[email protected],Smit";
+ suggestions = get_suggestions("", query);
expected = [
"pm-with:[email protected],Smit",
@@ -316,16 +316,16 @@ run_test('group_suggestions', () => {
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);
+ query = "pm-with:[email protected],my";
+ suggestions = get_suggestions("", query);
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);
+ query = "pm-with:[email protected],red";
+ suggestions = get_suggestions("", query);
expected = [
"pm-with:[email protected],red",
];
@@ -334,8 +334,8 @@ run_test('group_suggestions', () => {
// is:private should be properly prepended to each suggestion if the pm-with
// operator is negated.
- query = '-pm-with:[email protected],';
- suggestions = get_suggestions('', query);
+ query = "-pm-with:[email protected],";
+ suggestions = get_suggestions("", query);
expected = [
"-pm-with:[email protected],",
"is:private -pm-with:[email protected],[email protected]",
@@ -344,32 +344,32 @@ run_test('group_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = '-pm-with:[email protected],t';
- suggestions = get_suggestions('', query);
+ query = "-pm-with:[email protected],t";
+ suggestions = get_suggestions("", query);
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);
+ query = "-pm-with:[email protected],Smit";
+ suggestions = get_suggestions("", query);
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);
+ query = "-pm-with:[email protected],red";
+ suggestions = get_suggestions("", query);
expected = [
"-pm-with:[email protected],red",
];
assert.deepEqual(suggestions.strings, expected);
// Test multiple operators
- query = 'is:starred has:link pm-with:[email protected],Smit';
- suggestions = get_suggestions('', query);
+ query = "is:starred has:link pm-with:[email protected],Smit";
+ suggestions = get_suggestions("", query);
expected = [
"is:starred has:link pm-with:[email protected],Smit",
"is:starred has:link pm-with:[email protected],[email protected]",
@@ -378,8 +378,8 @@ run_test('group_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = 'stream:Denmark has:link pm-with:[email protected],Smit';
- suggestions = get_suggestions('', query);
+ query = "stream:Denmark has:link pm-with:[email protected],Smit";
+ suggestions = get_suggestions("", query);
expected = [
"stream:Denmark has:link pm-with:[email protected],Smit",
"stream:Denmark has:link",
@@ -389,7 +389,7 @@ run_test('group_suggestions', () => {
function message(user_ids, timestamp) {
return {
- type: 'private',
+ type: "private",
display_recipient: user_ids.map((id) => ({
id: id,
})),
@@ -403,8 +403,8 @@ run_test('group_suggestions', () => {
]);
// Simulate a past huddle which should now prioritize ted over alice
- query = 'pm-with:[email protected],';
- suggestions = get_suggestions('', query);
+ query = "pm-with:[email protected],";
+ suggestions = get_suggestions("", query);
expected = [
"pm-with:[email protected],",
@@ -414,8 +414,8 @@ run_test('group_suggestions', () => {
assert.deepEqual(suggestions.strings, expected);
// bob,ted,jeff is already an existing huddle, so prioritize this one
- suggestions = get_suggestions('', query);
+ suggestions = get_suggestions("", query);
expected = [
@@ -425,8 +425,8 @@ run_test('group_suggestions', () => {
// bob,ted,jeff is already an existing huddle, but if we start with just jeff,
// then don't prioritize ted over alice because it doesn't complete the full huddle.
- query = 'pm-with:[email protected],';
- suggestions = get_suggestions('', query);
+ query = "pm-with:[email protected],";
+ suggestions = get_suggestions("", query);
expected = [
"pm-with:[email protected],",
@@ -436,7 +436,7 @@ run_test('group_suggestions', () => {
assert.deepEqual(suggestions.strings, expected);
query = "pm-with:[email protected],[email protected] hi";
- suggestions = get_suggestions('', query);
+ suggestions = get_suggestions("", query);
expected = [
@@ -447,18 +447,18 @@ run_test('group_suggestions', () => {
init();
-run_test('empty_query_suggestions', () => {
- const query = '';
+run_test("empty_query_suggestions", () => {
+ const query = "";
global.stream_data.subscribed_streams = function () {
- return ['devel', 'office'];
+ return ["devel", "office"];
};
global.narrow_state.stream = function () {
return;
};
- const suggestions = get_suggestions('', query);
+ const suggestions = get_suggestions("", query);
const expected = [
"",
@@ -471,9 +471,9 @@ run_test('empty_query_suggestions', () => {
"stream:devel",
"stream:office",
- 'has:link',
- 'has:image',
- 'has:attachment',
+ "has:link",
+ "has:image",
+ "has:attachment",
];
assert.deepEqual(suggestions.strings, expected);
@@ -481,34 +481,34 @@ run_test('empty_query_suggestions', () => {
function describe(q) {
return suggestions.lookup_table.get(q).description;
}
- assert.equal(describe('is:private'), 'Private messages');
- assert.equal(describe('is:starred'), 'Starred messages');
- assert.equal(describe('is:mentioned'), '@-mentions');
- assert.equal(describe('is:alerted'), 'Alerted messages');
- assert.equal(describe('is:unread'), 'Unread messages');
- assert.equal(describe('sender:[email protected]'), 'Sent by me');
- assert.equal(describe('has:link'), 'Messages with one or more link');
- assert.equal(describe('has:image'), 'Messages with one or more image');
- assert.equal(describe('has:attachment'), 'Messages with one or more attachment');
+ assert.equal(describe("is:private"), "Private messages");
+ assert.equal(describe("is:starred"), "Starred messages");
+ assert.equal(describe("is:mentioned"), "@-mentions");
+ assert.equal(describe("is:alerted"), "Alerted messages");
+ assert.equal(describe("is:unread"), "Unread messages");
+ assert.equal(describe("sender:[email protected]"), "Sent by me");
+ assert.equal(describe("has:link"), "Messages with one or more link");
+ assert.equal(describe("has:image"), "Messages with one or more image");
+ assert.equal(describe("has:attachment"), "Messages with one or more attachment");
});
-run_test('has_suggestions', () => {
+run_test("has_suggestions", () => {
// Checks that category wise suggestions are displayed instead of a single
// default suggestion when suggesting `has` operator.
- let query = 'h';
+ let query = "h";
global.stream_data.subscribed_streams = function () {
- return ['devel', 'office'];
+ return ["devel", "office"];
};
global.narrow_state.stream = function () {
return;
};
- let suggestions = get_suggestions('', query);
+ let suggestions = get_suggestions("", query);
let expected = [
"h",
- 'has:link',
- 'has:image',
- 'has:attachment',
+ "has:link",
+ "has:image",
+ "has:attachment",
];
assert.deepEqual(suggestions.strings, expected);
@@ -516,87 +516,87 @@ run_test('has_suggestions', () => {
return suggestions.lookup_table.get(q).description;
}
- assert.equal(describe('has:link'), 'Messages with one or more link');
- assert.equal(describe('has:image'), 'Messages with one or more image');
- assert.equal(describe('has:attachment'), 'Messages with one or more attachment');
+ assert.equal(describe("has:link"), "Messages with one or more link");
+ assert.equal(describe("has:image"), "Messages with one or more image");
+ assert.equal(describe("has:attachment"), "Messages with one or more attachment");
- query = '-h';
- suggestions = get_suggestions('', query);
+ query = "-h";
+ suggestions = get_suggestions("", query);
expected = [
"-h",
- '-has:link',
- '-has:image',
- '-has:attachment',
+ "-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');
- assert.equal(describe('-has:attachment'), 'Exclude messages with one or more attachment');
+ assert.equal(describe("-has:link"), "Exclude messages with one or more link");
+ assert.equal(describe("-has:image"), "Exclude messages with one or more image");
+ assert.equal(describe("-has:attachment"), "Exclude messages with one or more attachment");
// operand suggestions follow.
- query = 'has:';
- suggestions = get_suggestions('', query);
+ query = "has:";
+ suggestions = get_suggestions("", query);
expected = [
- 'has:link',
- 'has:image',
- 'has:attachment',
+ "has:link",
+ "has:image",
+ "has:attachment",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'has:im';
- suggestions = get_suggestions('', query);
+ query = "has:im";
+ suggestions = get_suggestions("", query);
expected = [
- 'has:image',
+ "has:image",
];
assert.deepEqual(suggestions.strings, expected);
- query = '-has:im';
- suggestions = get_suggestions('', query);
+ query = "-has:im";
+ suggestions = get_suggestions("", query);
expected = [
- '-has:image',
+ "-has:image",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'att';
- suggestions = get_suggestions('', query);
+ query = "att";
+ suggestions = get_suggestions("", query);
expected = [
- 'att',
- 'has:attachment',
+ "att",
+ "has:attachment",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'stream:Denmark is:alerted has:lin';
- suggestions = get_suggestions('', query);
+ query = "stream:Denmark is:alerted has:lin";
+ suggestions = get_suggestions("", query);
expected = [
- 'stream:Denmark is:alerted has:link',
- 'stream:Denmark is:alerted',
- 'stream:Denmark',
+ "stream:Denmark is:alerted has:link",
+ "stream:Denmark is:alerted",
+ "stream:Denmark",
];
assert.deepEqual(suggestions.strings, expected);
});
-run_test('check_is_suggestions', () => {
+run_test("check_is_suggestions", () => {
global.stream_data.subscribed_streams = function () {
- return ['devel', 'office'];
+ return ["devel", "office"];
};
global.narrow_state.stream = function () {
return;
};
- let query = 'i';
- let suggestions = get_suggestions('', query);
+ let query = "i";
+ let suggestions = get_suggestions("", query);
let expected = [
- 'i',
- 'is:private',
- 'is:starred',
- 'is:mentioned',
- 'is:alerted',
- 'is:unread',
- 'sender:[email protected]',
- 'pm-with:[email protected]',
- 'group-pm-with:[email protected]',
- 'has:image',
+ "i",
+ "is:private",
+ "is:starred",
+ "is:mentioned",
+ "is:alerted",
+ "is:unread",
+ "sender:[email protected]",
+ "pm-with:[email protected]",
+ "group-pm-with:[email protected]",
+ "has:image",
];
assert.deepEqual(suggestions.strings, expected);
@@ -604,78 +604,78 @@ run_test('check_is_suggestions', () => {
return suggestions.lookup_table.get(q).description;
}
- assert.equal(describe('is:private'), 'Private messages');
- assert.equal(describe('is:starred'), 'Starred messages');
- assert.equal(describe('is:mentioned'), '@-mentions');
- assert.equal(describe('is:alerted'), 'Alerted messages');
- assert.equal(describe('is:unread'), 'Unread messages');
+ assert.equal(describe("is:private"), "Private messages");
+ assert.equal(describe("is:starred"), "Starred messages");
+ assert.equal(describe("is:mentioned"), "@-mentions");
+ assert.equal(describe("is:alerted"), "Alerted messages");
+ assert.equal(describe("is:unread"), "Unread messages");
- query = '-i';
- suggestions = get_suggestions('', query);
+ query = "-i";
+ suggestions = get_suggestions("", query);
expected = [
- '-i',
- '-is:private',
- '-is:starred',
- '-is:mentioned',
- '-is:alerted',
- '-is:unread',
+ "-i",
+ "-is:private",
+ "-is:starred",
+ "-is:mentioned",
+ "-is:alerted",
+ "-is:unread",
];
assert.deepEqual(suggestions.strings, expected);
- assert.equal(describe('-is:private'), 'Exclude private messages');
- assert.equal(describe('-is:starred'), 'Exclude starred messages');
- assert.equal(describe('-is:mentioned'), 'Exclude @-mentions');
- assert.equal(describe('-is:alerted'), 'Exclude alerted messages');
- assert.equal(describe('-is:unread'), 'Exclude unread messages');
+ assert.equal(describe("-is:private"), "Exclude private messages");
+ assert.equal(describe("-is:starred"), "Exclude starred messages");
+ assert.equal(describe("-is:mentioned"), "Exclude @-mentions");
+ assert.equal(describe("-is:alerted"), "Exclude alerted messages");
+ assert.equal(describe("-is:unread"), "Exclude unread messages");
// operand suggestions follow.
- query = 'is:';
- suggestions = get_suggestions('', query);
+ query = "is:";
+ suggestions = get_suggestions("", query);
expected = [
- 'is:private',
- 'is:starred',
- 'is:mentioned',
- 'is:alerted',
- 'is:unread',
+ "is:private",
+ "is:starred",
+ "is:mentioned",
+ "is:alerted",
+ "is:unread",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'is:st';
- suggestions = get_suggestions('', query);
+ query = "is:st";
+ suggestions = get_suggestions("", query);
expected = [
- 'is:starred',
+ "is:starred",
];
assert.deepEqual(suggestions.strings, expected);
- query = '-is:st';
- suggestions = get_suggestions('', query);
+ query = "-is:st";
+ suggestions = get_suggestions("", query);
expected = [
- '-is:starred',
+ "-is:starred",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'st';
- suggestions = get_suggestions('', query);
+ query = "st";
+ suggestions = get_suggestions("", query);
expected = [
- 'st',
- 'streams:public',
- 'is:starred',
- 'stream:',
+ "st",
+ "streams:public",
+ "is:starred",
+ "stream:",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'stream:Denmark has:link is:sta';
- suggestions = get_suggestions('', query);
+ query = "stream:Denmark has:link is:sta";
+ suggestions = get_suggestions("", query);
expected = [
- 'stream:Denmark has:link is:starred',
- 'stream:Denmark has:link',
- 'stream:Denmark',
+ "stream:Denmark has:link is:starred",
+ "stream:Denmark has:link",
+ "stream:Denmark",
];
assert.deepEqual(suggestions.strings, expected);
});
-run_test('sent_by_me_suggestions', () => {
+run_test("sent_by_me_suggestions", () => {
global.stream_data.subscribed_streams = function () {
return [];
};
@@ -684,14 +684,14 @@ run_test('sent_by_me_suggestions', () => {
return;
};
- 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');
+ 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");
- query = 'sender';
- suggestions = get_suggestions('', query);
+ query = "sender";
+ suggestions = get_suggestions("", query);
let expected = [
"sender",
@@ -699,8 +699,8 @@ run_test('sent_by_me_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = '-sender';
- suggestions = get_suggestions('', query);
+ query = "-sender";
+ suggestions = get_suggestions("", query);
expected = [
"-sender",
"-sender:[email protected]",
@@ -708,8 +708,8 @@ run_test('sent_by_me_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = 'from';
- suggestions = get_suggestions('', query);
+ query = "from";
+ suggestions = get_suggestions("", query);
expected = [
"from",
@@ -717,8 +717,8 @@ run_test('sent_by_me_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = '-from';
- suggestions = get_suggestions('', query);
+ query = "-from";
+ suggestions = get_suggestions("", query);
expected = [
"-from",
@@ -726,38 +726,38 @@ run_test('sent_by_me_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = 'sender:[email protected]';
- suggestions = get_suggestions('', query);
+ query = "sender:[email protected]";
+ suggestions = get_suggestions("", query);
expected = [
];
assert.deepEqual(suggestions.strings, expected);
- query = 'from:[email protected]';
- suggestions = get_suggestions('', query);
+ query = "from:[email protected]";
+ suggestions = get_suggestions("", query);
expected = [
];
assert.deepEqual(suggestions.strings, expected);
- query = 'sent';
- suggestions = get_suggestions('', query);
+ query = "sent";
+ suggestions = get_suggestions("", query);
expected = [
"sent",
];
assert.deepEqual(suggestions.strings, expected);
- query = '-sent';
- suggestions = get_suggestions('', query);
+ query = "-sent";
+ suggestions = get_suggestions("", query);
expected = [
"-sent",
"-sender:[email protected]",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'stream:Denmark topic:Denmark1 sent';
- suggestions = get_suggestions('', query);
+ query = "stream:Denmark topic:Denmark1 sent";
+ suggestions = get_suggestions("", query);
expected = [
"stream:Denmark topic:Denmark1 sent",
"stream:Denmark topic:Denmark1 sender:[email protected]",
@@ -766,8 +766,8 @@ run_test('sent_by_me_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = 'is:starred sender:m';
- suggestions = get_suggestions('', query);
+ query = "is:starred sender:m";
+ suggestions = get_suggestions("", query);
expected = [
"is:starred sender:m",
"is:starred sender:[email protected]",
@@ -775,8 +775,8 @@ run_test('sent_by_me_suggestions', () => {
];
assert.deepEqual(suggestions.strings, expected);
- query = 'sender:[email protected] sender:';
- suggestions = get_suggestions('', query);
+ query = "sender:[email protected] sender:";
+ suggestions = get_suggestions("", query);
expected = [
"sender:[email protected] sender:",
@@ -784,16 +784,16 @@ run_test('sent_by_me_suggestions', () => {
assert.deepEqual(suggestions.strings, expected);
});
-run_test('topic_suggestions', () => {
+run_test("topic_suggestions", () => {
let suggestions;
let expected;
global.stream_data.subscribed_streams = function () {
- return ['office'];
+ return ["office"];
};
global.narrow_state.stream = function () {
- return 'office';
+ return "office";
};
const devel_id = 44;
@@ -801,13 +801,13 @@ 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;
}
};
stream_topic_history.reset();
- suggestions = get_suggestions('', 'te');
+ suggestions = get_suggestions("", "te");
expected = [
"te",
@@ -818,17 +818,17 @@ run_test('topic_suggestions', () => {
stream_topic_history.add_message({
stream_id: devel_id,
- topic_name: 'REXX',
+ topic_name: "REXX",
});
- for (const topic_name of ['team', 'ignore', 'test']) {
+ for (const topic_name of ["team", "ignore", "test"]) {
stream_topic_history.add_message({
stream_id: office_id,
topic_name: topic_name,
});
}
- suggestions = get_suggestions('', 'te');
+ suggestions = get_suggestions("", "te");
expected = [
"te",
@@ -842,72 +842,72 @@ run_test('topic_suggestions', () => {
function describe(q) {
return suggestions.lookup_table.get(q).description;
}
- assert.equal(describe('te'), "Search for te");
- assert.equal(describe('stream:office topic:team'), "Stream office &gt; team");
+ assert.equal(describe("te"), "Search for te");
+ assert.equal(describe("stream:office topic:team"), "Stream office &gt; team");
- suggestions = get_suggestions('', 'topic:staplers stream:office');
+ suggestions = get_suggestions("", "topic:staplers stream:office");
expected = [
- 'topic:staplers stream:office',
- 'topic:staplers',
+ "topic:staplers stream:office",
+ "topic:staplers",
];
assert.deepEqual(suggestions.strings, expected);
- suggestions = get_suggestions('', 'stream:devel topic:');
+ suggestions = get_suggestions("", "stream:devel topic:");
expected = [
- 'stream:devel topic:',
- 'stream:devel topic:REXX',
- 'stream:devel',
+ "stream:devel topic:",
+ "stream:devel topic:REXX",
+ "stream:devel",
];
assert.deepEqual(suggestions.strings, expected);
- suggestions = get_suggestions('', 'stream:devel -topic:');
+ suggestions = get_suggestions("", "stream:devel -topic:");
expected = [
- 'stream:devel -topic:',
- 'stream:devel -topic:REXX',
- 'stream:devel',
+ "stream:devel -topic:",
+ "stream:devel -topic:REXX",
+ "stream:devel",
];
assert.deepEqual(suggestions.strings, expected);
- suggestions = get_suggestions('', '-topic:te');
+ suggestions = get_suggestions("", "-topic:te");
expected = [
- '-topic:te',
- 'stream:office -topic:team',
- 'stream:office -topic:test',
+ "-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:');
+ suggestions = get_suggestions("", "is:alerted stream:devel is:starred topic:");
expected = [
- 'is:alerted stream:devel is:starred topic:',
- 'is:alerted stream:devel is:starred topic:REXX',
- 'is:alerted stream:devel is:starred',
- 'is:alerted stream:devel',
- 'is:alerted',
+ "is:alerted stream:devel is:starred topic:",
+ "is:alerted stream:devel is:starred topic:REXX",
+ "is:alerted stream:devel is:starred",
+ "is:alerted stream:devel",
+ "is:alerted",
];
assert.deepEqual(suggestions.strings, expected);
- suggestions = get_suggestions('', 'is:private stream:devel topic:');
+ suggestions = get_suggestions("", "is:private stream:devel topic:");
expected = [
- 'is:private stream:devel topic:',
- 'is:private stream:devel',
- 'is:private',
+ "is:private stream:devel topic:",
+ "is:private stream:devel",
+ "is:private",
];
assert.deepEqual(suggestions.strings, expected);
- suggestions = get_suggestions('', 'topic:REXX stream:devel topic:');
+ suggestions = get_suggestions("", "topic:REXX stream:devel topic:");
expected = [
- 'topic:REXX stream:devel topic:',
- 'topic:REXX stream:devel',
- 'topic:REXX',
+ "topic:REXX stream:devel topic:",
+ "topic:REXX stream:devel",
+ "topic:REXX",
];
assert.deepEqual(suggestions.strings, expected);
});
-run_test('whitespace_glitch', () => {
- const query = 'stream:office '; // note trailing space
+run_test("whitespace_glitch", () => {
+ const query = "stream:office "; // note trailing space
global.stream_data.subscribed_streams = function () {
- return ['office'];
+ return ["office"];
};
global.narrow_state.stream = function () {
@@ -916,7 +916,7 @@ run_test('whitespace_glitch', () => {
stream_topic_history.reset();
- const suggestions = get_suggestions('', query);
+ const suggestions = get_suggestions("", query);
const expected = [
"stream:office",
@@ -925,9 +925,9 @@ run_test('whitespace_glitch', () => {
assert.deepEqual(suggestions.strings, expected);
});
-run_test('stream_completion', () => {
+run_test("stream_completion", () => {
global.stream_data.subscribed_streams = function () {
- return ['office', 'dev help'];
+ return ["office", "dev help"];
};
global.narrow_state.stream = function () {
@@ -936,24 +936,24 @@ run_test('stream_completion', () => {
stream_topic_history.reset();
- let query = 'stream:of';
- let suggestions = get_suggestions('', query);
+ let query = "stream:of";
+ let suggestions = get_suggestions("", query);
let expected = [
"stream:of",
"stream:office",
];
assert.deepEqual(suggestions.strings, expected);
- query = '-stream:of';
- suggestions = get_suggestions('', query);
+ query = "-stream:of";
+ suggestions = get_suggestions("", query);
expected = [
"-stream:of",
"-stream:office",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'hel';
- suggestions = get_suggestions('', query);
+ query = "hel";
+ suggestions = get_suggestions("", query);
expected = [
"hel",
"stream:dev+help",
@@ -961,8 +961,8 @@ run_test('stream_completion', () => {
assert.deepEqual(suggestions.strings, expected);
});
-run_test('people_suggestions', () => {
- let query = 'te';
+run_test("people_suggestions", () => {
+ let query = "te";
global.stream_data.subscribed_streams = function () {
return [];
@@ -973,21 +973,21 @@ run_test('people_suggestions', () => {
};
const ted = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 201,
- full_name: 'Ted Smith',
+ full_name: "Ted Smith",
};
const bob = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 202,
- full_name: 'Bob Térry',
+ full_name: "Bob Térry",
};
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 203,
- full_name: 'Alice Ignore',
+ full_name: "Alice Ignore",
};
people.add_active_user(ted);
people.add_active_user(bob);
@@ -996,7 +996,7 @@ run_test('people_suggestions', () => {
stream_topic_history.reset();
- let suggestions = get_suggestions('', query);
+ let suggestions = get_suggestions("", query);
let expected = [
"te",
@@ -1012,12 +1012,12 @@ run_test('people_suggestions', () => {
function describe(q) {
return suggestions.lookup_table.get(q).description;
}
- assert.equal(describe('pm-with:[email protected]'),
+ 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]'),
+ 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
+ suggestions = get_suggestions("", "Ted "); // note space
expected = [
"Ted",
@@ -1028,83 +1028,83 @@ run_test('people_suggestions', () => {
assert.deepEqual(suggestions.strings, expected);
- query = 'sender:ted sm';
+ query = "sender:ted sm";
expected = [
- 'sender:ted+sm',
- 'sender:[email protected]',
+ "sender:ted+sm",
+ "sender:[email protected]",
];
- suggestions = get_suggestions('', query);
+ suggestions = get_suggestions("", query);
assert.deepEqual(suggestions.strings, expected);
- query = 'sender:[email protected] new';
+ query = "sender:[email protected] new";
expected = [
- 'sender:[email protected] new',
- 'sender:[email protected]',
+ "sender:[email protected] new",
+ "sender:[email protected]",
];
- suggestions = get_suggestions('', query);
+ suggestions = get_suggestions("", query);
assert.deepEqual(suggestions.strings, expected);
- query = 'sender:[email protected] new';
+ query = "sender:[email protected] new";
expected = [
- 'sender:[email protected]+new',
+ "sender:[email protected]+new",
];
- suggestions = get_suggestions('', query);
+ suggestions = get_suggestions("", query);
assert.deepEqual(suggestions.strings, expected);
});
-run_test('operator_suggestions', () => {
+run_test("operator_suggestions", () => {
// Completed operator should return nothing
- let query = 'stream:';
- let suggestions = get_suggestions('', query);
+ let query = "stream:";
+ let suggestions = get_suggestions("", query);
let expected = [
- 'stream:',
+ "stream:",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'st';
- suggestions = get_suggestions('', query);
+ query = "st";
+ suggestions = get_suggestions("", query);
expected = [
- 'st',
- 'streams:public',
- 'is:starred',
- 'stream:',
+ "st",
+ "streams:public",
+ "is:starred",
+ "stream:",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'group-';
- suggestions = get_suggestions('', query);
+ query = "group-";
+ suggestions = get_suggestions("", query);
expected = [
- 'group-',
- 'group-pm-with:',
+ "group-",
+ "group-pm-with:",
];
assert.deepEqual(suggestions.strings, expected);
- query = '-s';
- suggestions = get_suggestions('', query);
+ query = "-s";
+ suggestions = get_suggestions("", query);
expected = [
- '-s',
- '-streams:public',
- '-sender:[email protected]',
- '-stream:',
- '-sender:',
+ "-s",
+ "-streams:public",
+ "-sender:[email protected]",
+ "-stream:",
+ "-sender:",
];
assert.deepEqual(suggestions.strings, expected);
- query = 'stream:Denmark is:alerted -f';
- suggestions = get_suggestions('', query);
+ query = "stream:Denmark is:alerted -f";
+ suggestions = get_suggestions("", query);
expected = [
- 'stream:Denmark is:alerted -f',
- 'stream:Denmark is:alerted -from:[email protected]',
- 'stream:Denmark is:alerted -from:',
- 'stream:Denmark is:alerted',
- 'stream:Denmark',
+ "stream:Denmark is:alerted -f",
+ "stream:Denmark is:alerted -from:[email protected]",
+ "stream:Denmark is:alerted -from:",
+ "stream:Denmark is:alerted",
+ "stream:Denmark",
];
assert.deepEqual(suggestions.strings, expected);
});
-run_test('queries_with_spaces', () => {
+run_test("queries_with_spaces", () => {
global.stream_data.subscribed_streams = function () {
- return ['office', 'dev help'];
+ return ["office", "dev help"];
};
global.narrow_state.stream = function () {
@@ -1115,7 +1115,7 @@ run_test('queries_with_spaces', () => {
// test allowing spaces with quotes surrounding operand
let query = 'stream:"dev he"';
- let suggestions = get_suggestions('', query);
+ let suggestions = get_suggestions("", query);
let expected = [
"stream:dev+he",
"stream:dev+help",
@@ -1124,7 +1124,7 @@ run_test('queries_with_spaces', () => {
// test mismatched quote
query = 'stream:"dev h';
- suggestions = get_suggestions('', query);
+ suggestions = get_suggestions("", query);
expected = [
"stream:dev+h",
"stream:dev+help",
@@ -1132,8 +1132,8 @@ run_test('queries_with_spaces', () => {
assert.deepEqual(suggestions.strings, expected);
// test extra space after operator still works
- query = 'stream: offi';
- suggestions = get_suggestions('', query);
+ query = "stream: offi";
+ suggestions = get_suggestions("", query);
expected = [
"stream:offi",
"stream:office",
diff --git a/frontend_tests/node_tests/server_events.js b/frontend_tests/node_tests/server_events.js
index e14634912c5..3c81b64a31d 100644
--- a/frontend_tests/node_tests/server_events.js
+++ b/frontend_tests/node_tests/server_events.js
@@ -1,51 +1,51 @@
const noop = function () {};
-set_global('document', {});
-set_global('addEventListener', noop);
+set_global("document", {});
+set_global("addEventListener", noop);
global.stub_out_jquery();
-zrequire('message_store');
-zrequire('server_events_dispatch');
-zrequire('server_events');
-zrequire('sent_messages');
+zrequire("message_store");
+zrequire("server_events_dispatch");
+zrequire("server_events");
+zrequire("sent_messages");
-set_global('channel', {});
-set_global('home_msg_list', {
+set_global("channel", {});
+set_global("home_msg_list", {
select_id: noop,
selected_id: function () {return 1;},
});
-set_global('page_params', {test_suite: false});
-set_global('reload_state', {
+set_global("page_params", {test_suite: false});
+set_global("reload_state", {
is_in_progress: function () {return false;},
});
// we also directly write to pointer
-set_global('pointer', {});
+set_global("pointer", {});
-set_global('echo', {
+set_global("echo", {
process_from_server: function (messages) {
return messages;
},
update_realm_filter_rules: noop,
});
-set_global('ui_report', {
+set_global("ui_report", {
hide_error: function () { return false; },
show_error: function () { return false; },
});
server_events.home_view_loaded();
-run_test('message_event', () => {
+run_test("message_event", () => {
const event = {
- type: 'message',
+ type: "message",
message: {
- content: 'hello',
+ content: "hello",
},
flags: [],
};
let inserted;
- set_global('message_events', {
+ set_global("message_events", {
insert_new_messages: function (messages) {
assert.equal(messages[0].content, event.message.content);
inserted = true;
@@ -60,69 +60,69 @@ run_test('message_event', () => {
const setup = function () {
server_events.home_view_loaded();
- set_global('message_events', {
+ set_global("message_events", {
insert_new_messages: function () {
- throw Error('insert error');
+ throw Error("insert error");
},
update_messages: function () {
- throw Error('update error');
+ throw Error("update error");
},
});
- set_global('stream_events', {
+ set_global("stream_events", {
update_property: function () {
- throw Error('subs update error');
+ throw Error("subs update error");
},
});
};
-run_test('event_dispatch_error', () => {
+run_test("event_dispatch_error", () => {
setup();
- const data = {events: [{type: 'stream', op: 'update', id: 1, other: 'thing'}]};
+ const data = {events: [{type: "stream", op: "update", id: 1, other: "thing"}]};
global.channel.get = function (options) {
options.success(data);
};
- blueslip.expect('error', 'Failed to process an event\nsubs update error');
+ blueslip.expect("error", "Failed to process an event\nsubs update error");
server_events.restart_get_events();
- const logs = blueslip.get_test_logs('error');
+ const logs = blueslip.get_test_logs("error");
assert.equal(logs.length, 1);
- assert.equal(logs[0].more_info.event.type, 'stream');
- assert.equal(logs[0].more_info.event.op, 'update');
+ assert.equal(logs[0].more_info.event.type, "stream");
+ assert.equal(logs[0].more_info.event.op, "update");
assert.equal(logs[0].more_info.event.id, 1);
assert.equal(logs[0].more_info.other, undefined);
});
-run_test('event_new_message_error', () => {
+run_test("event_new_message_error", () => {
setup();
- const data = {events: [{type: 'message', id: 1, other: 'thing', message: {}}]};
+ const data = {events: [{type: "message", id: 1, other: "thing", message: {}}]};
global.channel.get = function (options) {
options.success(data);
};
- blueslip.expect('error', 'Failed to insert new messages\ninsert error');
+ blueslip.expect("error", "Failed to insert new messages\ninsert error");
server_events.restart_get_events();
- const logs = blueslip.get_test_logs('error');
+ const logs = blueslip.get_test_logs("error");
assert.equal(logs.length, 1);
assert.equal(logs[0].more_info, undefined);
});
-run_test('event_edit_message_error', () => {
+run_test("event_edit_message_error", () => {
setup();
- const data = {events: [{type: 'update_message', id: 1, other: 'thing'}]};
+ const data = {events: [{type: "update_message", id: 1, other: "thing"}]};
global.channel.get = function (options) {
options.success(data);
};
- blueslip.expect('error', 'Failed to update messages\nupdate error');
+ blueslip.expect("error", "Failed to update messages\nupdate error");
server_events.restart_get_events();
- const logs = blueslip.get_test_logs('error');
+ const logs = blueslip.get_test_logs("error");
assert.equal(logs.length, 1);
assert.equal(logs[0].more_info, undefined);
});
diff --git a/frontend_tests/node_tests/settings_bots.js b/frontend_tests/node_tests/settings_bots.js
index 9b914897b06..59bee7b7d33 100644
--- a/frontend_tests/node_tests/settings_bots.js
+++ b/frontend_tests/node_tests/settings_bots.js
@@ -8,9 +8,9 @@ set_global("page_params", {
});
const bot_data_params = {
- realm_bots: [{api_key: 'QadL788EkiottHmukyhHgePUFHREiu8b',
- email: '[email protected]',
- full_name: 'Error bot',
+ realm_bots: [{api_key: "QadL788EkiottHmukyhHgePUFHREiu8b",
+ email: "[email protected]",
+ full_name: "Error bot",
user_id: 1,
services: []},
],
@@ -18,20 +18,20 @@ const bot_data_params = {
set_global("avatar", {});
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
-zrequire('bot_data');
-zrequire('settings_bots');
-zrequire('people');
+zrequire("bot_data");
+zrequire("settings_bots");
+zrequire("people");
function ClipboardJS(sel) {
- assert.equal(sel, '#copy_zuliprc');
+ assert.equal(sel, "#copy_zuliprc");
}
-set_global('ClipboardJS', ClipboardJS);
+set_global("ClipboardJS", ClipboardJS);
bot_data.initialize(bot_data_params);
-run_test('generate_zuliprc_uri', () => {
+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" +
@@ -42,7 +42,7 @@ run_test('generate_zuliprc_uri', () => {
assert.equal(uri, expected);
});
-run_test('generate_zuliprc_content', () => {
+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" +
@@ -52,7 +52,7 @@ run_test('generate_zuliprc_content', () => {
assert.equal(content, expected);
});
-run_test('generate_botserverrc_content', () => {
+run_test("generate_botserverrc_content", () => {
const user = {
api_key: "nSlA0mUm7G42LP85lMv7syqFTzDE2q34",
@@ -72,36 +72,36 @@ run_test('generate_botserverrc_content', () => {
});
function test_create_bot_type_input_box_toggle(f) {
- const create_payload_url = $('#create_payload_url');
- const payload_url_inputbox = $('#payload_url_inputbox');
- const config_inputbox = $('#config_inputbox');
- const EMBEDDED_BOT_TYPE = '4';
- const OUTGOING_WEBHOOK_BOT_TYPE = '3';
- const GENERIC_BOT_TYPE = '1';
-
- $('#create_bot_type :selected').val(EMBEDDED_BOT_TYPE);
+ const create_payload_url = $("#create_payload_url");
+ const payload_url_inputbox = $("#payload_url_inputbox");
+ const config_inputbox = $("#config_inputbox");
+ const EMBEDDED_BOT_TYPE = "4";
+ const OUTGOING_WEBHOOK_BOT_TYPE = "3";
+ const GENERIC_BOT_TYPE = "1";
+
+ $("#create_bot_type :selected").val(EMBEDDED_BOT_TYPE);
f();
- assert(!create_payload_url.hasClass('required'));
+ assert(!create_payload_url.hasClass("required"));
assert(!payload_url_inputbox.visible());
- assert($('#select_service_name').hasClass('required'));
- assert($('#service_name_list').visible());
+ assert($("#select_service_name").hasClass("required"));
+ assert($("#service_name_list").visible());
assert(config_inputbox.visible());
- $('#create_bot_type :selected').val(OUTGOING_WEBHOOK_BOT_TYPE);
+ $("#create_bot_type :selected").val(OUTGOING_WEBHOOK_BOT_TYPE);
f();
- assert(create_payload_url.hasClass('required'));
+ assert(create_payload_url.hasClass("required"));
assert(payload_url_inputbox.visible());
assert(!config_inputbox.visible());
- $('#create_bot_type :selected').val(GENERIC_BOT_TYPE);
+ $("#create_bot_type :selected").val(GENERIC_BOT_TYPE);
f();
- assert(!create_payload_url.hasClass('required'));
+ assert(!create_payload_url.hasClass("required"));
assert(!payload_url_inputbox.visible());
assert(!config_inputbox.visible());
}
function set_up() {
- set_global('$', global.make_zjquery());
+ set_global("$", global.make_zjquery());
// bunch of stubs
@@ -109,13 +109,13 @@ function set_up() {
$("#create_bot_form").validate = () => {};
- $('#create_bot_type').on = (action, f) => {
- if (action === 'change') {
+ $("#create_bot_type").on = (action, f) => {
+ if (action === "change") {
test_create_bot_type_input_box_toggle(f);
}
};
- $('#config_inputbox').children = () => {
+ $("#config_inputbox").children = () => {
const mock_children = {
hide: () => {},
};
@@ -127,11 +127,11 @@ function set_up() {
settings_bots.set_up();
}
-run_test('set_up', () => {
+run_test("set_up", () => {
set_up();
});
-run_test('test tab clicks', () => {
+run_test("test tab clicks", () => {
set_up();
function click_on_tab(tab_elem) {
@@ -143,29 +143,29 @@ run_test('test tab clicks', () => {
}
const tabs = {
- add: $('#bots_lists_navbar .add-a-new-bot-tab'),
- active: $('#bots_lists_navbar .active-bots-tab'),
- inactive: $('#bots_lists_navbar .inactive-bots-tab'),
+ add: $("#bots_lists_navbar .add-a-new-bot-tab"),
+ active: $("#bots_lists_navbar .active-bots-tab"),
+ inactive: $("#bots_lists_navbar .inactive-bots-tab"),
};
- $('#bots_lists_navbar .active').removeClass = (cls) => {
- assert.equal(cls, 'active');
+ $("#bots_lists_navbar .active").removeClass = (cls) => {
+ assert.equal(cls, "active");
for (const tab of Object.values(tabs)) {
- tab.removeClass('active');
+ tab.removeClass("active");
}
};
const forms = {
- add: $('#add-a-new-bot-form'),
- active: $('#active_bots_list'),
- inactive: $('#inactive_bots_list'),
+ add: $("#add-a-new-bot-form"),
+ active: $("#active_bots_list"),
+ inactive: $("#inactive_bots_list"),
};
(function () {
click_on_tab(tabs.add);
- assert(tabs.add.hasClass('active'));
- assert(!tabs.active.hasClass('active'));
- assert(!tabs.inactive.hasClass('active'));
+ assert(tabs.add.hasClass("active"));
+ assert(!tabs.active.hasClass("active"));
+ assert(!tabs.inactive.hasClass("active"));
assert(forms.add.visible());
assert(!forms.active.visible());
@@ -174,9 +174,9 @@ run_test('test tab clicks', () => {
(function () {
click_on_tab(tabs.active);
- assert(!tabs.add.hasClass('active'));
- assert(tabs.active.hasClass('active'));
- assert(!tabs.inactive.hasClass('active'));
+ assert(!tabs.add.hasClass("active"));
+ assert(tabs.active.hasClass("active"));
+ assert(!tabs.inactive.hasClass("active"));
assert(!forms.add.visible());
assert(forms.active.visible());
@@ -185,9 +185,9 @@ run_test('test tab clicks', () => {
(function () {
click_on_tab(tabs.inactive);
- assert(!tabs.add.hasClass('active'));
- assert(!tabs.active.hasClass('active'));
- assert(tabs.inactive.hasClass('active'));
+ assert(!tabs.add.hasClass("active"));
+ assert(!tabs.active.hasClass("active"));
+ assert(tabs.inactive.hasClass("active"));
assert(!forms.add.visible());
assert(!forms.active.visible());
@@ -195,7 +195,7 @@ run_test('test tab clicks', () => {
}());
});
-run_test('can_create_new_bots', () => {
+run_test("can_create_new_bots", () => {
page_params.is_admin = true;
assert(settings_bots.can_create_new_bots());
diff --git a/frontend_tests/node_tests/settings_data.js b/frontend_tests/node_tests/settings_data.js
index f1f5b60bde6..cd513655531 100644
--- a/frontend_tests/node_tests/settings_data.js
+++ b/frontend_tests/node_tests/settings_data.js
@@ -1,7 +1,7 @@
-const settings_data = zrequire('settings_data');
-const settings_config = zrequire('settings_config');
+const settings_data = zrequire("settings_data");
+const settings_config = zrequire("settings_config");
-set_global('page_params', {});
+set_global("page_params", {});
/*
Some methods in settings_data are fairly
@@ -11,11 +11,11 @@ set_global('page_params', {});
*/
const isaac = {
- email: '[email protected]',
- delivery_email: '[email protected]',
+ email: "[email protected]",
+ delivery_email: "[email protected]",
};
-run_test('email_for_user_settings', () => {
+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
@@ -37,7 +37,7 @@ run_test('email_for_user_settings', () => {
assert.equal(email(isaac), isaac.email);
});
-run_test('user_can_change_logo', () => {
+run_test("user_can_change_logo", () => {
const can_change_logo = settings_data.user_can_change_logo;
page_params.is_admin = true;
diff --git a/frontend_tests/node_tests/settings_muting.js b/frontend_tests/node_tests/settings_muting.js
index 1eb172c042a..5aff013e194 100644
--- a/frontend_tests/node_tests/settings_muting.js
+++ b/frontend_tests/node_tests/settings_muting.js
@@ -1,33 +1,33 @@
-set_global('$', global.make_zjquery());
-set_global('XDate', zrequire('XDate', 'xdate'));
+set_global("$", global.make_zjquery());
+set_global("XDate", zrequire("XDate", "xdate"));
-zrequire('timerender');
-zrequire('settings_muting');
-zrequire('stream_data');
-zrequire('muting');
-set_global('muting_ui', {});
+zrequire("timerender");
+zrequire("settings_muting");
+zrequire("stream_data");
+zrequire("muting");
+set_global("muting_ui", {});
const noop = function () {};
const frontend = {
stream_id: 101,
- name: 'frontend',
+ name: "frontend",
};
stream_data.add_sub(frontend);
-run_test('settings', () => {
+run_test("settings", () => {
- muting.add_muted_topic(frontend.stream_id, 'js', 1577836800);
+ muting.add_muted_topic(frontend.stream_id, "js", 1577836800);
let set_up_ui_called = false;
muting_ui.set_up_muted_topics_ui = function () {
const opts = muting.get_muted_topics();
assert.deepEqual(opts, [
{
date_muted: 1577836800000,
- date_muted_str: 'Jan 01',
+ date_muted_str: "Jan 01",
stream: frontend.name,
stream_id: frontend.stream_id,
- topic: 'js',
+ topic: "js",
}]);
set_up_ui_called = true;
};
@@ -37,36 +37,36 @@ run_test('settings', () => {
settings_muting.set_up();
assert.equal(settings_muting.loaded, true);
- const click_handler = $('body').get_on_handler('click', '.settings-unmute-topic');
- assert.equal(typeof click_handler, 'function');
+ const click_handler = $("body").get_on_handler("click", ".settings-unmute-topic");
+ assert.equal(typeof click_handler, "function");
const event = {
stopImmediatePropagation: noop,
};
- const fake_this = $.create('fake.settings-unmute-topic');
+ const fake_this = $.create("fake.settings-unmute-topic");
const tr_html = $('tr[data-topic="js"]');
fake_this.closest = function (opts) {
- assert.equal(opts, 'tr');
+ assert.equal(opts, "tr");
return tr_html;
};
let data_called = 0;
tr_html.attr = function (opts) {
- if (opts === 'data-stream-id') {
+ if (opts === "data-stream-id") {
data_called += 1;
return frontend.stream_id;
}
- if (opts === 'data-topic') {
+ if (opts === "data-topic") {
data_called += 1;
- return 'js';
+ return "js";
}
};
let unmute_called = false;
muting_ui.unmute = function (stream_id, topic) {
assert.equal(stream_id, frontend.stream_id);
- assert.equal(topic, 'js');
+ assert.equal(topic, "js");
unmute_called = true;
};
click_handler.call(fake_this, event);
@@ -75,7 +75,7 @@ run_test('settings', () => {
assert.equal(data_called, 2);
});
-run_test('reset', () => {
+run_test("reset", () => {
settings_muting.reset();
assert.equal(settings_muting.loaded, false);
});
diff --git a/frontend_tests/node_tests/settings_org.js b/frontend_tests/node_tests/settings_org.js
index c6b5f93f1fd..126ed1db9cf 100644
--- a/frontend_tests/node_tests/settings_org.js
+++ b/frontend_tests/node_tests/settings_org.js
@@ -1,4 +1,4 @@
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
const noop = () => {};
@@ -24,8 +24,8 @@ const _loading = {
const _page_params = {
is_admin: false,
realm_domains: [
- { domain: 'example.com', allow_subdomains: true },
- { domain: 'example.org', allow_subdomains: false },
+ { domain: "example.com", allow_subdomains: true },
+ { domain: "example.org", allow_subdomains: false },
],
realm_authentication_methods: {},
};
@@ -34,9 +34,9 @@ const _realm_icon = {};
const _channel = {};
global.stub_templates((name, data) => {
- if (name === 'settings/admin_realm_domains_list') {
+ if (name === "settings/admin_realm_domains_list") {
assert(data.realm_domain.domain);
- return 'stub-domains-list';
+ return "stub-domains-list";
}
});
@@ -60,27 +60,27 @@ const _list_render = {
create: () => ({ init: noop }),
};
-set_global('channel', _channel);
-set_global('csrf_token', 'token-stub');
-set_global('FormData', _FormData);
-set_global('jQuery', _jQuery);
-set_global('loading', _loading);
-set_global('overlays', _overlays);
-set_global('page_params', _page_params);
-set_global('realm_icon', _realm_icon);
-set_global('realm_logo', _realm_logo);
-set_global('ui_report', _ui_report);
-set_global('list_render', _list_render);
-
-const settings_config = zrequire('settings_config');
-const settings_bots = zrequire('settings_bots');
-zrequire('stream_data');
-zrequire('settings_account');
-zrequire('settings_org');
-zrequire('settings_ui');
-zrequire('dropdown_list_widget');
-
-run_test('unloaded', () => {
+set_global("channel", _channel);
+set_global("csrf_token", "token-stub");
+set_global("FormData", _FormData);
+set_global("jQuery", _jQuery);
+set_global("loading", _loading);
+set_global("overlays", _overlays);
+set_global("page_params", _page_params);
+set_global("realm_icon", _realm_icon);
+set_global("realm_logo", _realm_logo);
+set_global("ui_report", _ui_report);
+set_global("list_render", _list_render);
+
+const settings_config = zrequire("settings_config");
+const settings_bots = zrequire("settings_bots");
+zrequire("stream_data");
+zrequire("settings_account");
+zrequire("settings_org");
+zrequire("settings_ui");
+zrequire("dropdown_list_widget");
+
+run_test("unloaded", () => {
// This test mostly gets us line coverage, and makes
// sure things don't explode before set_up is called.
@@ -90,15 +90,15 @@ 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) {
appended = true;
- assert.equal(html, 'stub-domains-list');
+ assert.equal(html, "stub-domains-list");
};
return function verify() {
@@ -107,16 +107,16 @@ function simulate_realm_domains_table() {
}
function test_realms_domain_modal(add_realm_domain) {
- const info = $('.realm_domains_info');
+ const info = $(".realm_domains_info");
- $('#add-realm-domain-widget').set_find_results(
- '.new-realm-domain',
- $.create('new-realm-domain-stub'),
+ $("#add-realm-domain-widget").set_find_results(
+ ".new-realm-domain",
+ $.create("new-realm-domain-stub"),
);
- $('#add-realm-domain-widget').set_find_results(
- '.new-realm-domain-allow-subdomains',
- $.create('new-realm-domain-allow-subdomains-stub'),
+ $("#add-realm-domain-widget").set_find_results(
+ ".new-realm-domain-allow-subdomains",
+ $.create("new-realm-domain-allow-subdomains-stub"),
);
let posted;
@@ -124,7 +124,7 @@ function test_realms_domain_modal(add_realm_domain) {
let error_callback;
channel.post = function (req) {
posted = true;
- assert.equal(req.url, '/json/realm/domains');
+ assert.equal(req.url, "/json/realm/domains");
success_callback = req.success;
error_callback = req.error;
};
@@ -134,36 +134,36 @@ function test_realms_domain_modal(add_realm_domain) {
assert(posted);
success_callback();
- assert.equal(info.val(), 'translated: Added successfully!');
+ assert.equal(info.val(), "translated: Added successfully!");
error_callback({});
- assert.equal(info.val(), 'translated: Failed');
+ assert.equal(info.val(), "translated: Failed");
}
function createSaveButtons(subsection) {
const stub_save_button_header = $(`#org-${subsection}`);
- const save_button_controls = $('.save-button-controls');
+ const save_button_controls = $(".save-button-controls");
const stub_save_button = $(`#org-submit-${subsection}`);
const stub_discard_button = $(`#org-discard-${subsection}`);
- const stub_save_button_text = $('.icon-button-text');
+ 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,
+ ".save-button", stub_save_button,
);
stub_save_button.set_find_results(
- '.icon-button-text', stub_save_button_text,
+ ".icon-button-text", stub_save_button_text,
);
stub_save_button_header.set_find_results(
- '.save-button-controls', save_button_controls,
+ ".save-button-controls", save_button_controls,
);
stub_save_button_header.set_find_results(
- '.subsection-changes-discard .button', $(`#org-discard-${subsection}`),
+ ".subsection-changes-discard .button", $(`#org-discard-${subsection}`),
);
save_button_controls.set_find_results(
- '.discard-button', stub_discard_button,
+ ".discard-button", stub_discard_button,
);
const props = {};
props.hidden = false;
@@ -198,7 +198,7 @@ function test_submit_settings_form(submit_form) {
realm_create_stream_policy: settings_config.create_stream_policy_values.by_members.code,
});
- global.patch_builtin('setTimeout', (func) => func());
+ global.patch_builtin("setTimeout", (func) => func());
const ev = {
preventDefault: noop,
stopPropagation: noop,
@@ -209,46 +209,46 @@ function test_submit_settings_form(submit_form) {
let success_callback;
channel.patch = (req) => {
patched = true;
- assert.equal(req.url, '/json/realm');
+ assert.equal(req.url, "/json/realm");
data = req.data;
success_callback = req.success;
};
- let subsection = 'other-permissions';
+ let subsection = "other-permissions";
ev.currentTarget = `#org-submit-${subsection}`;
let stubs = createSaveButtons(subsection);
let save_button = stubs.save_button;
- save_button.attr('id', `org-submit-${subsection}`);
+ save_button.attr("id", `org-submit-${subsection}`);
save_button.replace = () => `${subsection}`;
$("#id_realm_waiting_period_threshold").val(10);
const invite_to_stream_policy_elem = $("#id_realm_invite_to_stream_policy");
- invite_to_stream_policy_elem.val('1');
- invite_to_stream_policy_elem.attr("id", 'id_realm_invite_to_stream_policy');
+ invite_to_stream_policy_elem.val("1");
+ invite_to_stream_policy_elem.attr("id", "id_realm_invite_to_stream_policy");
invite_to_stream_policy_elem.data = () => "number";
const create_stream_policy_elem = $("#id_realm_create_stream_policy");
- create_stream_policy_elem.val('2');
- create_stream_policy_elem.attr("id", 'id_realm_create_stream_policy');
+ create_stream_policy_elem.val("2");
+ create_stream_policy_elem.attr("id", "id_realm_create_stream_policy");
create_stream_policy_elem.data = () => "number";
const add_emoji_by_admins_only_elem = $("#id_realm_add_emoji_by_admins_only");
add_emoji_by_admins_only_elem.val("by_anyone");
- add_emoji_by_admins_only_elem.attr("id", 'id_realm_add_emoji_by_admins_only');
+ add_emoji_by_admins_only_elem.attr("id", "id_realm_add_emoji_by_admins_only");
const bot_creation_policy_elem = $("#id_realm_bot_creation_policy");
bot_creation_policy_elem.val("1");
- bot_creation_policy_elem.attr('id', 'id_realm_bot_creation_policy');
+ bot_creation_policy_elem.attr("id", "id_realm_bot_creation_policy");
bot_creation_policy_elem.data = () => "number";
const email_address_visibility_elem = $("#id_realm_email_address_visibility");
email_address_visibility_elem.val("1");
- email_address_visibility_elem.attr('id', 'id_realm_email_address_visibility');
+ email_address_visibility_elem.attr("id", "id_realm_email_address_visibility");
email_address_visibility_elem.data = () => "number";
let subsection_elem = $(`#org-${subsection}`);
subsection_elem.closest = () => subsection_elem;
- subsection_elem.set_find_results('.prop-element', [
+ subsection_elem.set_find_results(".prop-element", [
bot_creation_policy_elem,
email_address_visibility_elem,
add_emoji_by_admins_only_elem,
@@ -261,32 +261,32 @@ function test_submit_settings_form(submit_form) {
assert(patched);
let expected_value = {
- bot_creation_policy: '1',
- invite_to_stream_policy: '1',
- email_address_visibility: '1',
+ bot_creation_policy: "1",
+ invite_to_stream_policy: "1",
+ email_address_visibility: "1",
add_emoji_by_admins_only: false,
- create_stream_policy: '2',
+ create_stream_policy: "2",
};
assert.deepEqual(data, expected_value);
- subsection = 'user-defaults';
+ subsection = "user-defaults";
ev.currentTarget = `#org-submit-${subsection}`;
stubs = createSaveButtons(subsection);
save_button = stubs.save_button;
- save_button.attr('id', `org-submit-${subsection}`);
+ save_button.attr("id", `org-submit-${subsection}`);
const realm_default_language_elem = $("#id_realm_default_language");
realm_default_language_elem.val("en");
- realm_default_language_elem.attr('id', 'id_realm_default_language');
+ realm_default_language_elem.attr("id", "id_realm_default_language");
realm_default_language_elem.data = () => "string";
const realm_default_twenty_four_hour_time_elem = $("#id_realm_default_twenty_four_hour_time");
- realm_default_twenty_four_hour_time_elem.val('true');
- realm_default_twenty_four_hour_time_elem.attr('id', 'id_realm_default_twenty_four_hour_time');
+ realm_default_twenty_four_hour_time_elem.val("true");
+ realm_default_twenty_four_hour_time_elem.attr("id", "id_realm_default_twenty_four_hour_time");
realm_default_twenty_four_hour_time_elem.data = () => "boolean";
subsection_elem = $(`#org-${subsection}`);
subsection_elem.closest = () => subsection_elem;
- subsection_elem.set_find_results('.prop-element', [
+ subsection_elem.set_find_results(".prop-element", [
realm_default_language_elem,
realm_default_twenty_four_hour_time_elem,
]);
@@ -296,7 +296,7 @@ function test_submit_settings_form(submit_form) {
expected_value = {
default_language: '"en"',
- default_twenty_four_hour_time: 'true',
+ default_twenty_four_hour_time: "true",
};
assert.deepEqual(data, expected_value);
@@ -304,7 +304,7 @@ function test_submit_settings_form(submit_form) {
success_callback();
assert.equal(stubs.props.hidden, true);
assert.equal(save_button.attr("data-status"), "saved");
- assert.equal(stubs.save_button_text.text(), 'translated: Saved');
+ assert.equal(stubs.save_button_text.text(), "translated: Saved");
}
function test_change_save_button_state() {
@@ -314,27 +314,27 @@ function test_change_save_button_state() {
save_button,
discard_button,
props,
- } = createSaveButtons('msg-editing');
+ } = createSaveButtons("msg-editing");
save_button.attr("id", "org-submit-msg-editing");
{
settings_org.change_save_button_state(save_button_controls, "unsaved");
- assert.equal(save_button_text.text(), 'translated: Save changes');
+ assert.equal(save_button_text.text(), "translated: Save changes");
assert.equal(props.hidden, false);
assert.equal(save_button.attr("data-status"), "unsaved");
assert.equal(discard_button.visible(), true);
}
{
settings_org.change_save_button_state(save_button_controls, "saved");
- assert.equal(save_button_text.text(), 'translated: Save changes');
+ assert.equal(save_button_text.text(), "translated: Save changes");
assert.equal(props.hidden, true);
assert.equal(save_button.attr("data-status"), "");
}
{
settings_org.change_save_button_state(save_button_controls, "saving");
- assert.equal(save_button_text.text(), 'translated: Saving');
+ assert.equal(save_button_text.text(), "translated: Saving");
assert.equal(save_button.attr("data-status"), "saving");
- assert.equal(save_button.hasClass('saving'), true);
+ assert.equal(save_button.hasClass("saving"), true);
assert.equal(discard_button.visible(), false);
}
{
@@ -345,13 +345,13 @@ function test_change_save_button_state() {
settings_org.change_save_button_state(save_button_controls, "succeeded");
assert.equal(props.hidden, true);
assert.equal(save_button.attr("data-status"), "saved");
- assert.equal(save_button_text.text(), 'translated: Saved');
+ assert.equal(save_button_text.text(), "translated: Saved");
}
{
settings_org.change_save_button_state(save_button_controls, "failed");
assert.equal(props.hidden, false);
assert.equal(save_button.attr("data-status"), "failed");
- assert.equal(save_button_text.text(), 'translated: Save changes');
+ assert.equal(save_button_text.text(), "translated: Save changes");
}
}
@@ -363,16 +363,16 @@ function test_upload_realm_icon(upload_realm_logo_or_icon) {
};
const file_input = [
- {files: ['image1.png', 'image2.png']},
+ {files: ["image1.png", "image2.png"]},
];
let posted;
channel.post = function (req) {
posted = true;
- assert.equal(req.url, '/json/realm/icon');
- assert.equal(req.data.csrfmiddlewaretoken, 'token-stub');
- assert.equal(req.data['file-0'], 'image1.png');
- assert.equal(req.data['file-1'], 'image2.png');
+ assert.equal(req.url, "/json/realm/icon");
+ assert.equal(req.data.csrfmiddlewaretoken, "token-stub");
+ assert.equal(req.data["file-0"], "image1.png");
+ assert.equal(req.data["file-1"], "image2.png");
};
upload_realm_logo_or_icon(file_input, null, true);
@@ -384,66 +384,66 @@ function test_change_allow_subdomains(change_allow_subdomains) {
stopPropagation: noop,
};
- const info = $('.realm_domains_info');
+ const info = $(".realm_domains_info");
info.fadeOut = noop;
- const domain = 'example.com';
+ const domain = "example.com";
let allow = true;
let success_callback;
let error_callback;
channel.patch = function (req) {
- assert.equal(req.url, '/json/realm/domains/example.com');
+ assert.equal(req.url, "/json/realm/domains/example.com");
assert.equal(req.data.allow_subdomains, JSON.stringify(allow));
success_callback = req.success;
error_callback = req.error;
};
- const domain_obj = $.create('domain object');
+ const domain_obj = $.create("domain object");
domain_obj.text(domain);
- const elem_obj = $.create('<elem html>');
- const parents_obj = $.create('parents object');
+ const elem_obj = $.create("<elem html>");
+ const parents_obj = $.create("parents object");
- elem_obj.set_parents_result('tr', parents_obj);
- parents_obj.set_find_results('.domain', domain_obj);
- elem_obj.prop('checked', allow);
+ elem_obj.set_parents_result("tr", parents_obj);
+ parents_obj.set_find_results(".domain", domain_obj);
+ elem_obj.prop("checked", allow);
change_allow_subdomains.call(elem_obj, ev);
success_callback();
assert.equal(info.val(),
- 'translated: Update successful: Subdomains allowed for example.com');
+ "translated: Update successful: Subdomains allowed for example.com");
error_callback({});
- assert.equal(info.val(), 'translated: Failed');
+ assert.equal(info.val(), "translated: Failed");
allow = false;
- elem_obj.prop('checked', allow);
+ 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');
+ "translated: Update successful: Subdomains no longer allowed for example.com");
}
function test_extract_property_name() {
- $('#id_realm_allow_message_editing').attr('id', 'id_realm_allow_message_editing');
+ $("#id_realm_allow_message_editing").attr("id", "id_realm_allow_message_editing");
assert.equal(
- settings_org.extract_property_name($('#id_realm_allow_message_editing')),
- 'realm_allow_message_editing',
+ settings_org.extract_property_name($("#id_realm_allow_message_editing")),
+ "realm_allow_message_editing",
);
- $('#id_realm_message_content_edit_limit_minutes_label').attr(
- 'id', 'id_realm_message_content_edit_limit_minutes_label');
+ $("#id_realm_message_content_edit_limit_minutes_label").attr(
+ "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',
+ 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',
+ settings_org.extract_property_name($("#id-realm-allow-message-deleting")),
+ "realm_allow_message_deleting",
);
}
@@ -452,12 +452,12 @@ function test_sync_realm_settings() {
{
/* Test invalid settings property sync */
- const property_elem = $('#id_realm_invalid_settings_property');
- property_elem.attr('id', 'id_realm_invalid_settings_property');
+ const property_elem = $("#id_realm_invalid_settings_property");
+ 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');
- settings_org.sync_realm_settings('invalid_settings_property');
+ blueslip.expect("error", "Element refers to unknown property realm_invalid_settings_property");
+ settings_org.sync_realm_settings("invalid_settings_property");
}
{
@@ -465,13 +465,13 @@ function test_sync_realm_settings() {
Test that when create stream policy is set to "full members" that the dropdown
is set to the correct value.
*/
- const property_elem = $('#id_realm_create_stream_policy');
+ const property_elem = $("#id_realm_create_stream_policy");
property_elem.length = 1;
- property_elem.attr('id', 'id_realm_create_stream_policy');
+ property_elem.attr("id", "id_realm_create_stream_policy");
page_params.realm_create_stream_policy = 3;
- settings_org.sync_realm_settings('create_stream_policy');
+ 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);
}
@@ -481,13 +481,13 @@ function test_sync_realm_settings() {
Test that when create stream policy is set to "by members" that the dropdown
is set to the correct value.
*/
- const property_elem = $('#id_realm_create_stream_policy');
+ const property_elem = $("#id_realm_create_stream_policy");
property_elem.length = 1;
- property_elem.attr('id', 'id_realm_create_stream_policy');
+ property_elem.attr("id", "id_realm_create_stream_policy");
page_params.realm_create_stream_policy = 1;
- settings_org.sync_realm_settings('create_stream_policy');
+ 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);
}
@@ -497,13 +497,13 @@ function test_sync_realm_settings() {
Test that when create stream policy is set to "by admins only" that the dropdown
is set to the correct value.
*/
- const property_elem = $('#id_realm_create_stream_policy');
+ const property_elem = $("#id_realm_create_stream_policy");
property_elem.length = 1;
- property_elem.attr('id', 'id_realm_create_stream_policy');
+ property_elem.attr("id", "id_realm_create_stream_policy");
page_params.realm_create_stream_policy = 2;
- settings_org.sync_realm_settings('create_stream_policy');
+ 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);
}
@@ -513,13 +513,13 @@ function test_sync_realm_settings() {
Test that when invite to stream policy is set to "full members" that the dropdown
is set to the correct value.
*/
- const property_elem = $('#id_realm_invite_to_stream_policy');
+ const property_elem = $("#id_realm_invite_to_stream_policy");
property_elem.length = 1;
- property_elem.attr('id', 'id_realm_invite_to_stream_policy');
+ property_elem.attr("id", "id_realm_invite_to_stream_policy");
page_params.realm_invite_to_stream_policy = 3;
- settings_org.sync_realm_settings('invite_to_stream_policy');
+ 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);
}
@@ -529,13 +529,13 @@ function test_sync_realm_settings() {
Test that when create stream policy is set to "by members" that the dropdown
is set to the correct value.
*/
- const property_elem = $('#id_realm_invite_to_stream_policy');
+ const property_elem = $("#id_realm_invite_to_stream_policy");
property_elem.length = 1;
- property_elem.attr('id', 'id_realm_invite_to_stream_policy');
+ property_elem.attr("id", "id_realm_invite_to_stream_policy");
page_params.realm_invite_to_stream_policy = 1;
- settings_org.sync_realm_settings('invite_to_stream_policy');
+ 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);
}
@@ -545,122 +545,122 @@ function test_sync_realm_settings() {
Test that when create stream policy is set to "by admins only" that the dropdown
is set to the correct value.
*/
- const property_elem = $('#id_realm_invite_to_stream_policy');
+ const property_elem = $("#id_realm_invite_to_stream_policy");
property_elem.length = 1;
- property_elem.attr('id', 'id_realm_invite_to_stream_policy');
+ property_elem.attr("id", "id_realm_invite_to_stream_policy");
page_params.realm_invite_to_stream_policy = 2;
- settings_org.sync_realm_settings('invite_to_stream_policy');
+ 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);
}
{
/* Test message content edit limit minutes sync */
- const property_elem = $('#id_realm_message_content_edit_limit_minutes');
+ const property_elem = $("#id_realm_message_content_edit_limit_minutes");
property_elem.length = 1;
- property_elem.attr('id', 'id_realm_message_content_edit_limit_minutes');
+ property_elem.attr("id", "id_realm_message_content_edit_limit_minutes");
page_params.realm_create_stream_policy = 1;
page_params.realm_message_content_edit_limit_seconds = 120;
- settings_org.sync_realm_settings('message_content_edit_limit_seconds');
+ settings_org.sync_realm_settings("message_content_edit_limit_seconds");
assert.equal($("#id_realm_message_content_edit_limit_minutes").val(), "2");
}
{
/* Test message content edit limit dropdown value sync */
- const property_elem = $('#id_realm_msg_edit_limit_setting');
+ const property_elem = $("#id_realm_msg_edit_limit_setting");
property_elem.length = 1;
- property_elem.attr('id', 'id_realm_msg_edit_limit_setting');
+ property_elem.attr("id", "id_realm_msg_edit_limit_setting");
page_params.realm_allow_message_editing = false;
page_params.realm_message_content_edit_limit_seconds = 120;
- settings_org.sync_realm_settings('allow_message_editing');
+ settings_org.sync_realm_settings("allow_message_editing");
assert.equal($("#id_realm_msg_edit_limit_setting").val(), "never");
page_params.realm_allow_message_editing = true;
page_params.realm_message_content_edit_limit_seconds = 120;
- settings_org.sync_realm_settings('allow_message_editing');
+ settings_org.sync_realm_settings("allow_message_editing");
assert.equal($("#id_realm_msg_edit_limit_setting").val(), "upto_two_min");
page_params.realm_message_content_edit_limit_seconds = 130;
- settings_org.sync_realm_settings('allow_message_editing');
+ settings_org.sync_realm_settings("allow_message_editing");
assert.equal($("#id_realm_msg_edit_limit_setting").val(), "custom_limit");
}
{
/* Test message content edit limit minutes sync */
- const property_elem = $('#id_realm_message_content_edit_limit_minutes');
+ const property_elem = $("#id_realm_message_content_edit_limit_minutes");
property_elem.length = 1;
- property_elem.attr('id', 'id_realm_message_content_edit_limit_minutes');
+ property_elem.attr("id", "id_realm_message_content_edit_limit_minutes");
page_params.realm_create_stream_policy = 1;
page_params.realm_message_content_edit_limit_seconds = 120;
- settings_org.sync_realm_settings('message_content_edit_limit_seconds');
+ settings_org.sync_realm_settings("message_content_edit_limit_seconds");
assert.equal($("#id_realm_message_content_edit_limit_minutes").val(), "2");
}
{
/* Test organization joining restrictions settings sync */
- const property_elem = $('#id_realm_org_join_restrictions');
+ const property_elem = $("#id_realm_org_join_restrictions");
property_elem.length = 1;
- property_elem.attr('id', 'id_realm_org_join_restrictions');
+ property_elem.attr("id", "id_realm_org_join_restrictions");
page_params.realm_emails_restricted_to_domains = true;
page_params.realm_disallow_disposable_email_addresses = false;
- settings_org.sync_realm_settings('emails_restricted_to_domains');
+ settings_org.sync_realm_settings("emails_restricted_to_domains");
assert.equal($("#id_realm_org_join_restrictions").val(), "only_selected_domain");
page_params.realm_emails_restricted_to_domains = false;
page_params.realm_disallow_disposable_email_addresses = true;
- settings_org.sync_realm_settings('emails_restricted_to_domains');
+ settings_org.sync_realm_settings("emails_restricted_to_domains");
assert.equal($("#id_realm_org_join_restrictions").val(), "no_disposable_email");
page_params.realm_disallow_disposable_email_addresses = false;
- settings_org.sync_realm_settings('emails_restricted_to_domains');
+ settings_org.sync_realm_settings("emails_restricted_to_domains");
assert.equal($("#id_realm_org_join_restrictions").val(), "no_restriction");
}
}
function test_parse_time_limit() {
- const elem = $('#id_realm_message_content_edit_limit_minutes');
+ 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'));
+ "realm_message_content_edit_limit_seconds"));
};
- test_function('0.01', '0');
- test_function('0.1');
- test_function('0.122', '0.1');
- test_function('0.155', '0.2');
- test_function('0.150', '0.1');
- test_function('0.5');
- test_function('1');
- test_function('1.1');
- test_function('10.5');
- test_function('50.3');
- test_function('100');
- test_function('100.1');
- test_function('127.79', '127.8');
- test_function('201.1');
- test_function('501.15', '501.1');
- test_function('501.34', '501.3');
+ test_function("0.01", "0");
+ test_function("0.1");
+ test_function("0.122", "0.1");
+ test_function("0.155", "0.2");
+ test_function("0.150", "0.1");
+ test_function("0.5");
+ test_function("1");
+ test_function("1.1");
+ test_function("10.5");
+ test_function("50.3");
+ test_function("100");
+ test_function("100.1");
+ test_function("127.79", "127.8");
+ test_function("201.1");
+ test_function("501.15", "501.1");
+ test_function("501.34", "501.3");
}
function test_discard_changes_button(discard_changes) {
const ev = {
preventDefault: noop,
stopPropagation: noop,
- target: '#org-discard-msg-editing',
+ target: "#org-discard-msg-editing",
};
page_params.realm_allow_edit_history = true;
@@ -670,21 +670,21 @@ function test_discard_changes_button(discard_changes) {
page_params.realm_allow_message_deleting = true;
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 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 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);
-
- 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');
-
- const discard_button_parent = $('.org-subsection-parent');
+ 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 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 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);
+
+ 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");
+
+ const discard_button_parent = $(".org-subsection-parent");
discard_button_parent.find = () => [
allow_edit_history,
msg_edit_limit_setting,
@@ -694,7 +694,7 @@ function test_discard_changes_button(discard_changes) {
message_content_delete_limit_minutes,
];
- $('#org-discard-msg-editing').closest = () => discard_button_parent;
+ $("#org-discard-msg-editing").closest = () => discard_button_parent;
const stubbed_function = settings_org.change_save_button_state;
settings_org.change_save_button_state = (save_button_controls, state) => {
@@ -703,8 +703,8 @@ function test_discard_changes_button(discard_changes) {
discard_changes(ev);
- assert.equal(allow_edit_history.prop('checked'), true);
- assert.equal(allow_community_topic_editing.prop('checked'), true);
+ assert.equal(allow_edit_history.prop("checked"), true);
+ assert.equal(allow_community_topic_editing.prop("checked"), true);
assert.equal(msg_edit_limit_setting.val(), "upto_one_hour");
assert.equal(message_content_edit_limit_minutes.val(), "60");
assert.equal(msg_delete_limit_setting.val(), "upto_two_min");
@@ -713,7 +713,7 @@ function test_discard_changes_button(discard_changes) {
settings_org.change_save_button_state = stubbed_function;
}
-run_test('set_up', () => {
+run_test("set_up", () => {
const callbacks = {};
const set_callback = (name) => (f) => {
@@ -736,26 +736,26 @@ run_test('set_up', () => {
},
};
- $('#id_realm_video_chat_provider').change = set_callback('realm_video_chat_provider');
- $("#id_realm_org_join_restrictions").change = set_callback('change_org_join_restrictions');
- $('#submit-add-realm-domain').click = set_callback('add_realm_domain');
+ $("#id_realm_video_chat_provider").change = set_callback("realm_video_chat_provider");
+ $("#id_realm_org_join_restrictions").change = set_callback("change_org_join_restrictions");
+ $("#submit-add-realm-domain").click = set_callback("add_realm_domain");
let submit_settings_form;
let discard_changes;
- $('.organization').on = function (action, selector, f) {
- if (selector === '.subsection-header .subsection-changes-save .button') {
- assert.equal(action, 'click');
+ $(".organization").on = function (action, selector, f) {
+ if (selector === ".subsection-header .subsection-changes-save .button") {
+ assert.equal(action, "click");
submit_settings_form = f;
- } else if (selector === '.subsection-header .subsection-changes-discard .button') {
- assert.equal(action, 'click');
+ } else if (selector === ".subsection-header .subsection-changes-discard .button") {
+ assert.equal(action, "click");
discard_changes = f;
}
};
let change_allow_subdomains;
- $('#realm_domains_table').on = function (action, selector, f) {
- if (action === 'change') {
- assert.equal(selector, '.allow-subdomains');
+ $("#realm_domains_table").on = function (action, selector, f) {
+ if (action === "change") {
+ assert.equal(selector, ".allow-subdomains");
change_allow_subdomains = f;
}
};
@@ -770,25 +770,25 @@ 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_retention_days").set_parent($.create('<stub retention period 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>'));
- $("#enable_digest_emails_label").set_parent($.create('<stub digest setting checkbox>'));
- $("#id_realm_digest_weekday").set_parent($.create('<stub digest weekday setting dropdown>'));
+ $("#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;
- $('#id_realm_msg_delete_limit_setting').change = noop;
- $("#allowed_domains_label").set_parent($.create('<stub-allowed-domain-label-parent>'));
- const waiting_period_parent_elem = $.create('waiting-period-parent-stub');
- $('#id_realm_waiting_period_threshold').set_parent(waiting_period_parent_elem);
+ $("#id_realm_msg_delete_limit_setting").change = noop;
+ $("#allowed_domains_label").set_parent($.create("<stub-allowed-domain-label-parent>"));
+ const waiting_period_parent_elem = $.create("waiting-period-parent-stub");
+ $("#id_realm_waiting_period_threshold").set_parent(waiting_period_parent_elem);
$("#id_realm_waiting_period_setting").change = noop;
- const allow_topic_edit_label_parent = $.create('allow-topic-edit-label-parent');
- $('#id_realm_allow_community_topic_editing_label').set_parent(allow_topic_edit_label_parent);
+ const allow_topic_edit_label_parent = $.create("allow-topic-edit-label-parent");
+ $("#id_realm_allow_community_topic_editing_label").set_parent(allow_topic_edit_label_parent);
channel.get = function (opts) {
- assert.equal(opts.url, '/json/export/realm');
+ assert.equal(opts.url, "/json/export/realm");
};
// TEST set_up() here, but this mostly just allows us to
@@ -811,24 +811,24 @@ run_test('set_up', () => {
window.dropdown_list_widget = dropdown_list_widget_backup;
});
-run_test('test get_organization_settings_options', () => {
+run_test("test get_organization_settings_options", () => {
const sorted_option_values = settings_org.get_organization_settings_options();
const sorted_create_stream_policy_values = sorted_option_values.create_stream_policy_values;
const expected_create_stream_policy_values = [
{
- key: 'by_admins_only',
+ key: "by_admins_only",
order: 1,
code: 2,
description: i18n.t("Admins"),
},
{
- key: 'by_full_members',
+ key: "by_full_members",
order: 2,
code: 3,
description: i18n.t("Admins and full members"),
},
{
- key: 'by_members',
+ key: "by_members",
order: 3,
code: 1,
description: i18n.t("Admins and members"),
@@ -837,7 +837,7 @@ run_test('test get_organization_settings_options', () => {
assert.deepEqual(sorted_create_stream_policy_values, expected_create_stream_policy_values);
});
-run_test('test get_sorted_options_list', () => {
+run_test("test get_sorted_options_list", () => {
const option_values_1 = {
by_admins_only: {
order: 3,
@@ -857,19 +857,19 @@ run_test('test get_sorted_options_list', () => {
};
let expected_option_values = [
{
- key: 'by_full_members',
+ key: "by_full_members",
order: 1,
code: 3,
description: i18n.t("Admins and full members"),
},
{
- key: 'by_members',
+ key: "by_members",
order: 2,
code: 1,
description: i18n.t("Admins and members"),
},
{
- key: 'by_admins_only',
+ key: "by_admins_only",
order: 3,
code: 2,
description: i18n.t("Admins"),
@@ -893,17 +893,17 @@ run_test('test get_sorted_options_list', () => {
};
expected_option_values = [
{
- key: 'by_admins_only',
+ key: "by_admins_only",
code: 1,
description: i18n.t("Admins"),
},
{
- key: 'by_full_members',
+ key: "by_full_members",
code: 3,
description: i18n.t("Admins and full members"),
},
{
- key: 'by_members',
+ key: "by_members",
code: 2,
description: i18n.t("Admins and members"),
},
@@ -911,77 +911,77 @@ run_test('test get_sorted_options_list', () => {
assert.deepEqual(settings_org.get_sorted_options_list(option_values_2), expected_option_values);
});
-run_test('misc', () => {
+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>'));
+ 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>"));
page_params.realm_name_changes_disabled = false;
page_params.server_name_changes_disabled = false;
settings_account.update_name_change_display();
- assert.equal($('#full_name').attr('disabled'), false);
- assert.equal($('.change_name_tooltip').is(':visible'), false);
+ assert.equal($("#full_name").attr("disabled"), false);
+ assert.equal($(".change_name_tooltip").is(":visible"), false);
page_params.realm_name_changes_disabled = true;
page_params.server_name_changes_disabled = false;
settings_account.update_name_change_display();
- assert.equal($('#full_name').attr('disabled'), 'disabled');
- assert($('.change_name_tooltip').is(':visible'));
+ assert.equal($("#full_name").attr("disabled"), "disabled");
+ assert($(".change_name_tooltip").is(":visible"));
page_params.realm_name_changes_disabled = true;
page_params.server_name_changes_disabled = true;
settings_account.update_name_change_display();
- assert.equal($('#full_name').attr('disabled'), 'disabled');
- assert($('.change_name_tooltip').is(':visible'));
+ assert.equal($("#full_name").attr("disabled"), "disabled");
+ assert($(".change_name_tooltip").is(":visible"));
page_params.realm_name_changes_disabled = false;
page_params.server_name_changes_disabled = true;
settings_account.update_name_change_display();
- assert.equal($('#full_name').attr('disabled'), 'disabled');
- assert($('.change_name_tooltip').is(':visible'));
+ assert.equal($("#full_name").attr("disabled"), "disabled");
+ assert($(".change_name_tooltip").is(":visible"));
page_params.realm_email_changes_disabled = false;
settings_account.update_email_change_display();
- assert.equal($("#change_email .button").attr('disabled'), false);
+ assert.equal($("#change_email .button").attr("disabled"), false);
page_params.realm_email_changes_disabled = true;
settings_account.update_email_change_display();
- assert.equal($("#change_email .button").attr('disabled'), 'disabled');
+ assert.equal($("#change_email .button").attr("disabled"), "disabled");
page_params.realm_avatar_changes_disabled = false;
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 .image_upload_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 .image_upload_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 .image_upload_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 .image_upload_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;
settings_account.update_name_change_display();
- assert.equal($('#full_name').attr('disabled'), false);
- assert.equal($('.change_name_tooltip').is(':visible'), false);
+ assert.equal($("#full_name").attr("disabled"), false);
+ assert.equal($(".change_name_tooltip").is(":visible"), false);
settings_account.update_email_change_display();
- assert.equal($("#change_email .button").attr('disabled'), false);
+ assert.equal($("#change_email .button").attr("disabled"), false);
stream_data.get_streams_for_settings_page = () => {
const arr = [];
@@ -991,54 +991,54 @@ 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 dropdown_list_parent = $.create(`<list parent>`);
- dropdown_list_parent.set_find_results('.dropdown_list_reset_button:not([disabled])', $.create('<disable button>'));
+ 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>"));
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';
+ let setting_name = "realm_notifications_stream_id";
let elem = $(`#${setting_name}_widget #${setting_name}_name`);
elem.closest = function () {
return stub_notification_disable_parent;
};
stream_data.get_sub_by_id = function (stream_id) {
assert.equal(stream_id, 42);
- return { name: 'some_stream' };
+ return { name: "some_stream" };
};
settings_org.notifications_stream_widget.render(42);
- assert.equal(elem.text(), '#some_stream');
- assert(!elem.hasClass('text-warning'));
+ assert.equal(elem.text(), "#some_stream");
+ assert(!elem.hasClass("text-warning"));
stream_data.get_sub_by_id = noop;
settings_org.notifications_stream_widget.render(undefined);
- assert.equal(elem.text(), 'translated: Disabled');
- assert(elem.hasClass('text-warning'));
+ assert.equal(elem.text(), "translated: Disabled");
+ assert(elem.hasClass("text-warning"));
- setting_name = 'realm_signup_notifications_stream_id';
+ setting_name = "realm_signup_notifications_stream_id";
elem = $(`#${setting_name}_widget #${setting_name}_name`);
elem.closest = function () {
return stub_notification_disable_parent;
};
stream_data.get_sub_by_id = function (stream_id) {
assert.equal(stream_id, 75);
- return { name: 'some_stream' };
+ return { name: "some_stream" };
};
settings_org.signup_notifications_stream_widget.render(75);
- assert.equal(elem.text(), '#some_stream');
- assert(!elem.hasClass('text-warning'));
+ assert.equal(elem.text(), "#some_stream");
+ assert(!elem.hasClass("text-warning"));
stream_data.get_sub_by_id = noop;
settings_org.signup_notifications_stream_widget.render(undefined);
- assert.equal(elem.text(), 'translated: Disabled');
- assert(elem.hasClass('text-warning'));
+ 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 4d795096036..152467d1694 100644
--- a/frontend_tests/node_tests/settings_profile_fields.js
+++ b/frontend_tests/node_tests/settings_profile_fields.js
@@ -1,7 +1,7 @@
-set_global('page_params', {});
-set_global('$', global.make_zjquery());
-set_global('loading', {});
-set_global('Sortable', {create: () => {}});
+set_global("page_params", {});
+set_global("$", global.make_zjquery());
+set_global("loading", {});
+set_global("Sortable", {create: () => {}});
const SHORT_TEXT_ID = 1;
const CHOICE_ID = 3;
@@ -29,17 +29,17 @@ page_params.custom_profile_field_types = {
},
};
-zrequire('settings_profile_fields');
+zrequire("settings_profile_fields");
function test_populate(opts) {
const fields_data = opts.fields_data;
page_params.is_admin = opts.is_admin;
- const table = $('#admin_profile_fields_table');
- const rows = $.create('rows');
- const form = $.create('forms');
- table.set_find_results('tr.profile-field-row', rows);
- table.set_find_results('tr.profile-field-form', form);
+ const table = $("#admin_profile_fields_table");
+ const rows = $.create("rows");
+ const form = $.create("forms");
+ table.set_find_results("tr.profile-field-row", rows);
+ table.set_find_results("tr.profile-field-form", form);
let num_appends = 0;
table.append = () => {
@@ -50,9 +50,9 @@ function test_populate(opts) {
const template_data = [];
global.stub_templates((fn, data) => {
- assert.equal(fn, 'admin_profile_field_list');
+ assert.equal(fn, "admin_profile_field_list");
template_data.push(data);
- return 'whatever';
+ return "whatever";
});
settings_profile_fields.do_populate_profile_fields(fields_data);
@@ -61,27 +61,27 @@ function test_populate(opts) {
assert.equal(num_appends, fields_data.length);
}
-run_test('populate_profile_fields', () => {
+run_test("populate_profile_fields", () => {
const fields_data = [
{
type: SHORT_TEXT_ID,
id: 10,
- name: 'favorite color',
- hint: 'blue?',
- field_data: '',
+ name: "favorite color",
+ hint: "blue?",
+ field_data: "",
},
{
type: CHOICE_ID,
id: 30,
- name: 'meal',
- hint: 'lunch',
+ name: "meal",
+ hint: "lunch",
field_data: JSON.stringify([
{
- text: 'lunch',
+ text: "lunch",
order: 0,
},
{
- text: 'dinner',
+ text: "dinner",
order: 1,
},
]),
@@ -89,20 +89,20 @@ run_test('populate_profile_fields', () => {
{
type: EXTERNAL_ACCOUNT_ID,
id: 20,
- name: 'github profile',
- hint: 'username only',
+ name: "github profile",
+ hint: "username only",
field_data: JSON.stringify({
- subtype: 'github',
+ subtype: "github",
}),
},
{
type: EXTERNAL_ACCOUNT_ID,
id: 21,
- name: 'zulip profile',
- hint: 'username only',
+ name: "zulip profile",
+ hint: "username only",
field_data: JSON.stringify({
- subtype: 'custom',
- url_pattern: 'https://chat.zulip.com/%(username)s',
+ subtype: "custom",
+ url_pattern: "https://chat.zulip.com/%(username)s",
}),
},
];
@@ -110,8 +110,8 @@ run_test('populate_profile_fields', () => {
{
profile_field: {
id: 10,
- name: 'favorite color',
- hint: 'blue?',
+ name: "favorite color",
+ hint: "blue?",
type: SHORT_TEXT_NAME,
choices: [],
is_choice_field: false,
@@ -124,12 +124,12 @@ run_test('populate_profile_fields', () => {
{
profile_field: {
id: 30,
- name: 'meal',
- hint: 'lunch',
+ name: "meal",
+ hint: "lunch",
type: CHOICE_NAME,
choices: [
- {order: 0, value: '0', text: 'lunch'},
- {order: 1, value: '1', text: 'dinner'},
+ {order: 0, value: "0", text: "lunch"},
+ {order: 1, value: "1", text: "dinner"},
],
is_choice_field: true,
is_external_account_field: false,
@@ -141,8 +141,8 @@ run_test('populate_profile_fields', () => {
{
profile_field: {
id: 20,
- name: 'github profile',
- hint: 'username only',
+ name: "github profile",
+ hint: "username only",
type: EXTERNAL_ACCOUNT_NAME,
choices: [],
is_choice_field: false,
@@ -155,8 +155,8 @@ run_test('populate_profile_fields', () => {
{
profile_field: {
id: 21,
- name: 'zulip profile',
- hint: 'username only',
+ name: "zulip profile",
+ hint: "username only",
type: EXTERNAL_ACCOUNT_NAME,
choices: [],
is_choice_field: false,
diff --git a/frontend_tests/node_tests/settings_user_groups.js b/frontend_tests/node_tests/settings_user_groups.js
index ca6d0ba0ede..415bae5ee67 100644
--- a/frontend_tests/node_tests/settings_user_groups.js
+++ b/frontend_tests/node_tests/settings_user_groups.js
@@ -1,33 +1,33 @@
-zrequire('user_pill');
-zrequire('settings_user_groups');
+zrequire("user_pill");
+zrequire("settings_user_groups");
-set_global('$', global.make_zjquery());
-set_global('confirm_dialog', {});
+set_global("$", global.make_zjquery());
+set_global("confirm_dialog", {});
const noop = function () {};
const pills = {
pill: {},
};
-const settings_config = zrequire('settings_config');
+const settings_config = zrequire("settings_config");
let create_item_handler;
-set_global('channel', {});
-set_global('typeahead_helper', {});
-set_global('user_groups', {
+set_global("channel", {});
+set_global("typeahead_helper", {});
+set_global("user_groups", {
get_user_group_from_id: noop,
remove: noop,
add: noop,
});
-set_global('ui_report', {});
-set_global('people', {
+set_global("ui_report", {});
+set_global("people", {
my_current_user_id: noop,
small_avatar_url_for_person: function () {
- return 'http://example.com/example.png';
+ return "http://example.com/example.png";
},
});
-set_global('page_params', {});
+set_global("page_params", {});
function reset_test_setup(pill_container_stub) {
function input_pill_stub(opts) {
@@ -36,12 +36,12 @@ function reset_test_setup(pill_container_stub) {
assert(create_item_handler);
return pills;
}
- set_global('input_pill', {
+ set_global("input_pill", {
create: input_pill_stub,
});
}
-run_test('can_edit', () => {
+run_test("can_edit", () => {
page_params.is_guest = false;
page_params.is_admin = true;
assert(settings_user_groups.can_edit(1));
@@ -89,27 +89,27 @@ const name_selector = "#user-groups #1 .name";
const description_selector = "#user-groups #1 .description";
const instructions_selector = "#user-groups #1 .save-instructions";
-run_test('populate_user_groups', () => {
+run_test("populate_user_groups", () => {
const realm_user_group = {
id: 1,
- name: 'Mobile',
- description: 'All mobile people',
+ name: "Mobile",
+ description: "All mobile people",
members: new Set([2, 4]),
};
const iago = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 2,
- full_name: 'Iago',
+ full_name: "Iago",
};
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 31,
- full_name: 'Alice',
+ full_name: "Alice",
};
const bob = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 32,
- full_name: 'Bob',
+ full_name: "Bob",
};
people.get_realm_users = function () {
@@ -125,18 +125,18 @@ run_test('populate_user_groups', () => {
};
let templates_render_called = false;
- const fake_rendered_temp = $.create('fake_admin_user_group_list_template_rendered');
+ const fake_rendered_temp = $.create("fake_admin_user_group_list_template_rendered");
global.stub_templates((template, args) => {
- assert.equal(template, 'admin_user_group_list');
+ assert.equal(template, "admin_user_group_list");
assert.equal(args.user_group.id, 1);
- assert.equal(args.user_group.name, 'Mobile');
- assert.equal(args.user_group.description, 'All mobile people');
+ assert.equal(args.user_group.name, "Mobile");
+ assert.equal(args.user_group.description, "All mobile people");
templates_render_called = true;
return fake_rendered_temp;
});
let user_groups_list_append_called = false;
- $('#user-groups').append = function (rendered_temp) {
+ $("#user-groups").append = function (rendered_temp) {
assert.equal(rendered_temp, fake_rendered_temp);
user_groups_list_append_called = true;
};
@@ -150,7 +150,7 @@ run_test('populate_user_groups', () => {
return noop;
}
assert.equal(user_id, 4);
- blueslip.expect('warn', 'Undefined user in function append_user');
+ blueslip.expect("warn", "Undefined user in function append_user");
get_by_user_id_called = true;
};
@@ -175,7 +175,7 @@ run_test('populate_user_groups', () => {
text_cleared = true;
};
- const input_field_stub = $.create('fake-input-field');
+ const input_field_stub = $.create("fake-input-field");
pill_container_stub.children = function () {
return input_field_stub;
};
@@ -186,14 +186,14 @@ run_test('populate_user_groups', () => {
assert(config.fixed);
assert(config.dropup);
assert(config.stopAdvance);
- assert.equal(typeof config.source, 'function');
- assert.equal(typeof config.highlighter, 'function');
- assert.equal(typeof config.matcher, 'function');
- assert.equal(typeof config.sorter, 'function');
- assert.equal(typeof config.updater, 'function');
+ assert.equal(typeof config.source, "function");
+ assert.equal(typeof config.highlighter, "function");
+ assert.equal(typeof config.matcher, "function");
+ assert.equal(typeof config.sorter, "function");
+ assert.equal(typeof config.updater, "function");
(function test_highlighter() {
- const fake_person = $.create('fake-person');
+ const fake_person = $.create("fake-person");
typeahead_helper.render_person = function () {
return fake_person;
};
@@ -201,11 +201,11 @@ run_test('populate_user_groups', () => {
}());
const fake_context = {
- query: 'ali',
+ query: "ali",
};
const fake_context_for_email = {
- query: 'am',
+ query: "am",
};
(function test_source() {
@@ -244,7 +244,7 @@ run_test('populate_user_groups', () => {
}());
(function test_updater() {
- input_field_stub.text('@ali');
+ input_field_stub.text("@ali");
user_groups.get_user_group_from_id = function () {
return realm_user_group;
};
@@ -256,24 +256,24 @@ run_test('populate_user_groups', () => {
saved_fade_out_called = true;
};
$(cancel_selector).css = function (data) {
- if (typeof data === 'string') {
- assert.equal(data, 'display');
+ if (typeof data === "string") {
+ assert.equal(data, "display");
}
- assert.equal(typeof data, 'object');
- assert.equal(data.display, 'inline-block');
- assert.equal(data.opacity, '0');
+ assert.equal(typeof data, "object");
+ assert.equal(data.display, "inline-block");
+ assert.equal(data.opacity, "0");
return $(cancel_selector);
};
$(cancel_selector).fadeTo = function () {
cancel_fade_to_called = true;
};
$(instructions_selector).css = function (data) {
- if (typeof data === 'string') {
- assert.equal(data, 'display');
+ if (typeof data === "string") {
+ assert.equal(data, "display");
}
- assert.equal(typeof data, 'object');
- assert.equal(data.display, 'block');
- assert.equal(data.opacity, '0');
+ assert.equal(typeof data, "object");
+ assert.equal(data.display, "block");
+ assert.equal(data.opacity, "0");
return $(instructions_selector);
};
$(instructions_selector).fadeTo = function () {
@@ -301,10 +301,10 @@ run_test('populate_user_groups', () => {
return bob;
}
assert.equal(user_email,
- 'Expected user email to be of Alice or Iago here.');
+ "Expected user email to be of Alice or Iago here.");
};
pills.onPillCreate = function (handler) {
- assert.equal(typeof handler, 'function');
+ assert.equal(typeof handler, "function");
handler();
};
@@ -319,14 +319,14 @@ run_test('populate_user_groups', () => {
get_by_email_called = false;
const res = handler(bob.email, pills.items());
assert(get_by_email_called);
- assert.equal(typeof res, 'object');
+ assert.equal(typeof res, "object");
assert.equal(res.user_id, bob.user_id);
assert.equal(res.display_value, bob.full_name);
}());
}
pills.onPillRemove = function (handler) {
- global.patch_builtin('setTimeout', (func) => {
+ global.patch_builtin("setTimeout", (func) => {
func();
});
realm_user_group.members = new Set([2, 31]);
@@ -342,16 +342,16 @@ 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 $('#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 $(".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");
});
-run_test('with_external_user', () => {
+run_test("with_external_user", () => {
const realm_user_group = {
id: 1,
- name: 'Mobile',
- description: 'All mobile people',
+ name: "Mobile",
+ description: "All mobile people",
members: new Set([2, 4]),
};
@@ -381,50 +381,50 @@ run_test('with_external_user', () => {
};
// Reset zjquery to test stuff with user who cannot edit
- set_global('$', global.make_zjquery());
+ set_global("$", global.make_zjquery());
let user_group_find_called = 0;
const user_group_stub = $('div.user-group[id="1"]');
- const name_field_stub = $.create('fake-name-field');
- const description_field_stub = $.create('fake-description-field');
- const input_stub = $.create('fake-input');
+ const name_field_stub = $.create("fake-name-field");
+ const description_field_stub = $.create("fake-description-field");
+ const input_stub = $.create("fake-input");
user_group_stub.find = function (elem) {
- if (elem === '.name') {
+ if (elem === ".name") {
user_group_find_called += 1;
return name_field_stub;
}
- if (elem === '.description') {
+ if (elem === ".description") {
user_group_find_called += 1;
return description_field_stub;
}
};
const pill_container_stub = $('.pill-container[data-group-pills="1"]');
- const pill_stub = $.create('fake-pill');
+ const pill_stub = $.create("fake-pill");
let pill_container_find_called = 0;
pill_container_stub.find = function (elem) {
- if (elem === '.input') {
+ if (elem === ".input") {
pill_container_find_called += 1;
return input_stub;
}
- if (elem === '.pill') {
+ if (elem === ".pill") {
pill_container_find_called += 1;
return pill_stub;
}
};
input_stub.css = function (property, val) {
- assert.equal(property, 'display');
- assert.equal(val, 'none');
+ assert.equal(property, "display");
+ assert.equal(val, "none");
};
// Test the 'off' handlers on the pill-container
const turned_off = {};
pill_container_stub.off = function (event_name, sel) {
if (sel === undefined) {
- sel = 'whole';
+ sel = "whole";
}
- turned_off[event_name + '/' + sel] = true;
+ turned_off[event_name + "/" + sel] = true;
};
let pill_hover_called = false;
@@ -434,17 +434,17 @@ run_test('with_external_user', () => {
callback = one;
empty_fn = two;
pill_hover_called = true;
- assert.equal(typeof one, 'function');
- assert.equal(typeof two, 'function');
+ assert.equal(typeof one, "function");
+ assert.equal(typeof two, "function");
};
- const exit_button = $.create('fake-pill-exit');
- pill_stub.set_find_results('.exit', exit_button);
+ const exit_button = $.create("fake-pill-exit");
+ pill_stub.set_find_results(".exit", exit_button);
let exit_button_called = false;
exit_button.css = function (property, value) {
exit_button_called = true;
- assert.equal(property, 'opacity');
- assert.equal(value, '0.5');
+ assert.equal(property, "opacity");
+ assert.equal(value, "0.5");
};
// We return noop because these are already tested, so we skip them
@@ -452,7 +452,7 @@ run_test('with_external_user', () => {
return noop;
};
- $('#user-groups').append = function () {
+ $("#user-groups").append = function () {
return noop;
};
@@ -464,11 +464,11 @@ run_test('with_external_user', () => {
let set_attributes_called = 0;
// Test different handlers with an external user
- const delete_handler = $('#user-groups').get_on_handler('click', '.delete');
- const fake_delete = $.create('fk-#user-groups.delete_btn');
- fake_delete.set_parents_result('.user-group', $('.user-group'));
+ const delete_handler = $("#user-groups").get_on_handler("click", ".delete");
+ const fake_delete = $.create("fk-#user-groups.delete_btn");
+ fake_delete.set_parents_result(".user-group", $(".user-group"));
set_parents_result_called += 1;
- $('.user-group').attr('id', '1');
+ $(".user-group").attr("id", "1");
set_attributes_called += 1;
const name_update_handler = $(user_group_selector).get_on_handler("input", ".name");
@@ -485,7 +485,7 @@ run_test('with_external_user', () => {
stopPropagation: noop,
};
let pill_click_called = false;
- const pill_click_handler = pill_container_stub.get_on_handler('click');
+ const pill_click_handler = pill_container_stub.get_on_handler("click");
pill_click_called = true;
assert(callback);
@@ -507,89 +507,89 @@ run_test('with_external_user', () => {
assert(pill_hover_called);
assert.equal(user_group_find_called, 2);
assert.equal(pill_container_find_called, 4);
- assert.equal(turned_off['keydown/.pill'], true);
- assert.equal(turned_off['keydown/.input'], true);
- assert.equal(turned_off['click/whole'], true);
+ assert.equal(turned_off["keydown/.pill"], true);
+ assert.equal(turned_off["keydown/.input"], true);
+ assert.equal(turned_off["click/whole"], true);
});
-run_test('reload', () => {
- $('#user-groups').html('Some text');
+run_test("reload", () => {
+ $("#user-groups").html("Some text");
let populate_user_groups_called = false;
settings_user_groups.populate_user_groups = function () {
populate_user_groups_called = true;
};
settings_user_groups.reload();
assert(populate_user_groups_called);
- assert.equal($('#user-groups').html(), '');
+ assert.equal($("#user-groups").html(), "");
});
-run_test('reset', () => {
+run_test("reset", () => {
settings_user_groups.reset();
const result = settings_user_groups.reload();
assert.equal(result, undefined);
});
-run_test('on_events', () => {
+run_test("on_events", () => {
settings_user_groups.can_edit = function () {
return true;
};
(function test_admin_user_group_form_submit_triggered() {
- const handler = $('.organization form.admin-user-group-form').get_on_handler("submit");
+ const handler = $(".organization form.admin-user-group-form").get_on_handler("submit");
const event = {
stopPropagation: noop,
preventDefault: noop,
};
- const fake_this = $.create('fake-form.admin-user-group-form');
+ const fake_this = $.create("fake-form.admin-user-group-form");
const fake_object_array = [{
- name: 'fake-name',
- value: '',
+ name: "fake-name",
+ value: "",
}, {
- name: 'fake-name',
- value: 'fake-value',
+ name: "fake-name",
+ value: "fake-value",
}];
fake_this.serializeArray = function () {
return fake_object_array;
};
channel.post = function (opts) {
const data = {
- members: '[null]',
+ members: "[null]",
};
data[fake_object_array[1].name] = fake_object_array[1].value;
assert.equal(opts.url, "/json/user_groups/create");
assert.deepEqual(opts.data, data);
(function test_post_success() {
- $('#admin-user-group-status').show();
- $("form.admin-user-group-form input[type='text']").val('fake-content');
+ $("#admin-user-group-status").show();
+ $("form.admin-user-group-form input[type='text']").val("fake-content");
ui_report.success = function (text, ele) {
- assert.equal(text, 'translated: User group added!');
- assert.equal(ele, $('#admin-user-group-status'));
+ assert.equal(text, "translated: User group added!");
+ assert.equal(ele, $("#admin-user-group-status"));
};
opts.success();
- assert(!$('#admin-user-group-status').visible());
- assert.equal($("form.admin-user-group-form input[type='text']").val(), '');
+ assert(!$("#admin-user-group-status").visible());
+ assert.equal($("form.admin-user-group-form input[type='text']").val(), "");
}());
(function test_post_error() {
- $('#admin-user-group-status').show();
+ $("#admin-user-group-status").show();
ui_report.error = function (error_msg, error_obj, ele) {
const xhr = {
responseText: '{"msg":"fake-msg"}',
};
- assert.equal(error_msg, 'translated: Failed');
+ assert.equal(error_msg, "translated: Failed");
assert.deepEqual(error_obj, xhr);
- assert.equal(ele, $('#admin-user-group-status'));
+ assert.equal(ele, $("#admin-user-group-status"));
};
const xhr = {
responseText: '{"msg":"fake-msg", "attrib":"val"}',
};
opts.error(xhr);
- assert(!$('#admin-user-group-status').visible());
+ assert(!$("#admin-user-group-status").visible());
}());
};
@@ -597,10 +597,10 @@ run_test('on_events', () => {
}());
(function test_user_groups_delete_click_triggered() {
- const handler = $('#user-groups').get_on_handler("click", ".delete");
- const fake_this = $.create('fake-#user-groups.delete_btn');
- fake_this.set_parents_result('.user-group', $('.user-group'));
- $('.user-group').attr('id', '1');
+ const handler = $("#user-groups").get_on_handler("click", ".delete");
+ const fake_this = $.create("fake-#user-groups.delete_btn");
+ fake_this.set_parents_result(".user-group", $(".user-group"));
+ $(".user-group").attr("id", "1");
channel.del = function (opts) {
const data = {
@@ -616,9 +616,9 @@ run_test('on_events', () => {
opts.success();
assert(settings_user_groups_reload_called);
- fake_this.text(i18n.t('fake-text'));
+ fake_this.text(i18n.t("fake-text"));
opts.error();
- assert.equal(fake_this.text(), 'translated: Failed!');
+ assert.equal(fake_this.text(), "translated: Failed!");
};
confirm_dialog.launch = (conf) => {
@@ -629,7 +629,7 @@ run_test('on_events', () => {
}());
(function test_user_groups_keypress_enter_triggered() {
- const handler = $('#user-groups').get_on_handler("keypress", ".user-group h4 > span");
+ const handler = $("#user-groups").get_on_handler("keypress", ".user-group h4 > span");
let default_action_for_enter_stopped = false;
const event = {
which: 13,
@@ -648,7 +648,7 @@ run_test('on_events', () => {
api_endpoint_called = true;
};
channel.patch = noop;
- const fake_this = $.create('fake-#user-groups_do_not_blur');
+ const fake_this = $.create("fake-#user-groups_do_not_blur");
const event = {
relatedTarget: fake_this,
};
@@ -704,12 +704,12 @@ run_test('on_events', () => {
const handler_desc = $(user_group_selector).get_on_handler("input", ".description");
const sib_des = $(description_selector);
const sib_name = $(name_selector);
- sib_name.text(i18n.t('mobile'));
- sib_des.text(i18n.t('All mobile members'));
+ sib_name.text(i18n.t("mobile"));
+ sib_des.text(i18n.t("All mobile members"));
const group_data = {
- name: 'translated: mobile',
- description: 'translated: All mobile members',
+ name: "translated: mobile",
+ description: "translated: All mobile members",
members: new Set([2, 31])};
user_groups.get_user_group_from_id = function () {
return group_data;
@@ -726,13 +726,13 @@ run_test('on_events', () => {
};
// Cancel button removed if user group if user group has no changes.
- const fake_this = $.create('fake-#update_cancel_button');
+ const fake_this = $.create("fake-#update_cancel_button");
handler_name.call(fake_this);
assert(cancel_fade_out_called);
assert(instructions_fade_out_called);
// Check if cancel button removed if user group error is showing.
- $(user_group_selector + ' .user-group-status').show();
+ $(user_group_selector + " .user-group-status").show();
cancel_fade_out_called = false;
instructions_fade_out_called = false;
handler_name.call(fake_this);
@@ -752,8 +752,8 @@ run_test('on_events', () => {
const handler_desc = $(user_group_selector).get_on_handler("blur", ".description");
const sib_des = $(description_selector);
const sib_name = $(name_selector);
- sib_name.text(i18n.t('mobile'));
- sib_des.text(i18n.t('All mobile members'));
+ sib_name.text(i18n.t("mobile"));
+ sib_des.text(i18n.t("All mobile members"));
const group_data = {members: new Set([2, 31])};
user_groups.get_user_group_from_id = function () {
@@ -770,12 +770,12 @@ run_test('on_events', () => {
cancel_fade_out_called = true;
};
$(saved_selector).css = function (data) {
- if (typeof data === 'string') {
- assert.equal(data, 'display');
+ if (typeof data === "string") {
+ assert.equal(data, "display");
}
- assert.equal(typeof data, 'object');
- assert.equal(data.display, 'inline-block');
- assert.equal(data.opacity, '0');
+ assert.equal(typeof data, "object");
+ assert.equal(data.display, "inline-block");
+ assert.equal(data.opacity, "0");
return $(saved_selector);
};
$(saved_selector).fadeTo = function () {
@@ -785,11 +785,11 @@ run_test('on_events', () => {
channel.patch = function (opts) {
assert.equal(opts.url, "/json/user_groups/1");
- assert.equal(opts.data.name, 'translated: mobile');
- assert.equal(opts.data.description, 'translated: All mobile members');
+ assert.equal(opts.data.name, "translated: mobile");
+ assert.equal(opts.data.description, "translated: All mobile members");
api_endpoint_called = true;
(function test_post_success() {
- global.patch_builtin('setTimeout', (func) => {
+ global.patch_builtin("setTimeout", (func) => {
func();
});
opts.success();
@@ -798,13 +798,13 @@ run_test('on_events', () => {
assert(saved_fade_to_called);
}());
(function test_post_error() {
- const user_group_error = $(user_group_selector + ' .user-group-status');
+ const user_group_error = $(user_group_selector + " .user-group-status");
user_group_error.show();
ui_report.error = function (error_msg, error_obj, ele) {
const xhr = {
responseText: '{"msg":"fake-msg"}',
};
- assert.equal(error_msg, 'translated: Failed');
+ assert.equal(error_msg, "translated: Failed");
assert.deepEqual(error_obj, xhr);
assert.equal(ele, user_group_error);
};
@@ -817,7 +817,7 @@ run_test('on_events', () => {
}());
};
- const fake_this = $.create('fake-#user-groups_blur_name');
+ const fake_this = $.create("fake-#user-groups_blur_name");
fake_this.closest = function () {
return [];
};
@@ -847,8 +847,8 @@ run_test('on_events', () => {
const handler = $(user_group_selector).get_on_handler("blur", ".input");
const realm_user_group = {
id: 1,
- name: 'Mobile',
- description: 'All mobile people',
+ name: "Mobile",
+ description: "All mobile people",
members: new Set([2, 4]),
};
@@ -877,8 +877,8 @@ run_test('on_events', () => {
let api_endpoint_called = false;
channel.post = function (opts) {
assert.equal(opts.url, "/json/user_groups/1/members");
- assert.equal(opts.data.add, '[31]');
- assert.equal(opts.data.delete, '[4]');
+ assert.equal(opts.data.add, "[31]");
+ assert.equal(opts.data.delete, "[4]");
api_endpoint_called = true;
(function test_post_success() {
@@ -889,7 +889,7 @@ run_test('on_events', () => {
}());
};
- const fake_this = $.create('fake-#user-groups_blur_input');
+ const fake_this = $.create("fake-#user-groups_blur_input");
fake_this.set_parents_result(user_group_selector, $(user_group_selector));
fake_this.closest = function () {
return [];
diff --git a/frontend_tests/node_tests/spoilers.js b/frontend_tests/node_tests/spoilers.js
index aa86a472c0c..d3a8d76bb4e 100644
--- a/frontend_tests/node_tests/spoilers.js
+++ b/frontend_tests/node_tests/spoilers.js
@@ -1,5 +1,5 @@
-set_global('$', global.make_zjquery());
-zrequire('spoilers');
+set_global("$", global.make_zjquery());
+zrequire("spoilers");
// This function is taken from rendered_markdown.js and slightly modified.
const $array = (array) => {
@@ -16,17 +16,17 @@ const get_spoiler_elem = (title) => {
const header = $.create(`header-${title}`);
const content = $.create(`content-${title}`);
header.text(title);
- block.set_find_results('.spoiler-header', header);
- block.set_find_results('.spoiler-content', content);
+ block.set_find_results(".spoiler-header", header);
+ block.set_find_results(".spoiler-content", content);
return block;
};
-run_test('hide spoilers in notifications', () => {
- const root = $.create('root element');
- const spoiler_1 = get_spoiler_elem('this is the title');
- const spoiler_2 = get_spoiler_elem('');
- root.set_find_results('.spoiler-block', $array([spoiler_1, spoiler_2]));
+run_test("hide spoilers in notifications", () => {
+ const root = $.create("root element");
+ const spoiler_1 = get_spoiler_elem("this is the title");
+ const spoiler_2 = get_spoiler_elem("");
+ root.set_find_results(".spoiler-block", $array([spoiler_1, spoiler_2]));
spoilers.hide_spoilers_in_notification(root);
- assert.equal(spoiler_1.find('.spoiler-header').text(), 'this is the title (…)');
- assert.equal(spoiler_2.find('.spoiler-header').text(), '(…)');
+ assert.equal(spoiler_1.find(".spoiler-header").text(), "this is the title (…)");
+ assert.equal(spoiler_2.find(".spoiler-header").text(), "(…)");
});
diff --git a/frontend_tests/node_tests/stream_data.js b/frontend_tests/node_tests/stream_data.js
index 868631584c4..12ecec876d0 100644
--- a/frontend_tests/node_tests/stream_data.js
+++ b/frontend_tests/node_tests/stream_data.js
@@ -1,32 +1,32 @@
-set_global('page_params', {
+set_global("page_params", {
is_admin: false,
realm_users: [],
is_guest: false,
});
-set_global('$', () => {
+set_global("$", () => {
});
-set_global('document', null);
+set_global("document", null);
global.stub_out_jquery();
-zrequire('color_data');
-zrequire('hash_util');
-zrequire('stream_topic_history');
-zrequire('people');
-zrequire('stream_color');
-zrequire('stream_data');
-zrequire('marked', 'third/marked/lib/marked');
-zrequire('FetchStatus', 'js/fetch_status');
-zrequire('Filter', 'js/filter');
-zrequire('MessageListData', 'js/message_list_data');
-zrequire('MessageListView', 'js/message_list_view');
-zrequire('message_list');
+zrequire("color_data");
+zrequire("hash_util");
+zrequire("stream_topic_history");
+zrequire("people");
+zrequire("stream_color");
+zrequire("stream_data");
+zrequire("marked", "third/marked/lib/marked");
+zrequire("FetchStatus", "js/fetch_status");
+zrequire("Filter", "js/filter");
+zrequire("MessageListData", "js/message_list_data");
+zrequire("MessageListView", "js/message_list_view");
+zrequire("message_list");
const settings_config = zrequire("settings_config");
const me = {
- email: '[email protected]',
- full_name: 'Current User',
+ email: "[email protected]",
+ full_name: "Current User",
user_id: 100,
};
@@ -38,18 +38,18 @@ function contains_sub(subs, sub) {
return subs.some((s) => s.name === sub.name);
}
-run_test('basics', () => {
+run_test("basics", () => {
const denmark = {
subscribed: false,
- color: 'blue',
- name: 'Denmark',
+ color: "blue",
+ name: "Denmark",
stream_id: 1,
is_muted: true,
};
const social = {
subscribed: true,
- color: 'red',
- name: 'social',
+ color: "red",
+ name: "social",
stream_id: 2,
is_muted: false,
invite_only: true,
@@ -57,8 +57,8 @@ run_test('basics', () => {
};
const test = {
subscribed: true,
- color: 'yellow',
- name: 'test',
+ color: "yellow",
+ name: "test",
stream_id: 3,
is_muted: true,
invite_only: false,
@@ -69,32 +69,32 @@ run_test('basics', () => {
stream_data.add_sub(test);
assert(!stream_data.all_subscribed_streams_are_in_home_view());
- assert.equal(stream_data.get_sub('denmark'), denmark);
- assert.equal(stream_data.get_sub('Social'), social);
+ assert.equal(stream_data.get_sub("denmark"), denmark);
+ assert.equal(stream_data.get_sub("Social"), social);
- assert.deepEqual(stream_data.home_view_stream_names(), ['social']);
- assert.deepEqual(stream_data.subscribed_streams(), ['social', 'test']);
- assert.deepEqual(stream_data.get_colors(), ['red', 'yellow']);
+ assert.deepEqual(stream_data.home_view_stream_names(), ["social"]);
+ assert.deepEqual(stream_data.subscribed_streams(), ["social", "test"]);
+ assert.deepEqual(stream_data.get_colors(), ["red", "yellow"]);
- assert(stream_data.is_subscribed('social'));
- assert(stream_data.is_subscribed('Social'));
- assert(!stream_data.is_subscribed('Denmark'));
- assert(!stream_data.is_subscribed('Rome'));
+ assert(stream_data.is_subscribed("social"));
+ assert(stream_data.is_subscribed("Social"));
+ assert(!stream_data.is_subscribed("Denmark"));
+ assert(!stream_data.is_subscribed("Rome"));
- assert(stream_data.get_invite_only('social'));
- assert(!stream_data.get_invite_only('unknown'));
+ assert(stream_data.get_invite_only("social"));
+ assert(!stream_data.get_invite_only("unknown"));
- assert.equal(stream_data.get_color('social'), 'red');
- assert.equal(stream_data.get_color('unknown'), global.stream_color.default_color);
+ assert.equal(stream_data.get_color("social"), "red");
+ assert.equal(stream_data.get_color("unknown"), global.stream_color.default_color);
- assert.equal(stream_data.get_name('denMARK'), 'Denmark');
- assert.equal(stream_data.get_name('unknown Stream'), 'unknown Stream');
+ assert.equal(stream_data.get_name("denMARK"), "Denmark");
+ assert.equal(stream_data.get_name("unknown Stream"), "unknown Stream");
assert(!stream_data.is_muted(social.stream_id));
assert(stream_data.is_muted(denmark.stream_id));
assert.equal(stream_data.maybe_get_stream_name(), undefined);
- assert.equal(stream_data.maybe_get_stream_name(social.stream_id), 'social');
+ assert.equal(stream_data.maybe_get_stream_name(social.stream_id), "social");
assert.equal(stream_data.maybe_get_stream_name(42), undefined);
stream_data.set_realm_default_streams([denmark]);
@@ -102,47 +102,47 @@ run_test('basics', () => {
assert(!stream_data.is_default_stream_id(social.stream_id));
assert(!stream_data.is_default_stream_id(999999));
- assert.equal(stream_data.slug_to_name('2-social'), 'social');
- assert.equal(stream_data.slug_to_name('2-whatever'), 'social');
- assert.equal(stream_data.slug_to_name('2'), 'social');
+ assert.equal(stream_data.slug_to_name("2-social"), "social");
+ assert.equal(stream_data.slug_to_name("2-whatever"), "social");
+ assert.equal(stream_data.slug_to_name("2"), "social");
- assert.equal(stream_data.slug_to_name('25-or-6-to-4'), '25-or-6-to-4');
+ assert.equal(stream_data.slug_to_name("25-or-6-to-4"), "25-or-6-to-4");
});
-run_test('renames', () => {
+run_test("renames", () => {
stream_data.clear_subscriptions();
const id = 42;
let sub = {
- name: 'Denmark',
+ name: "Denmark",
subscribed: true,
- color: 'red',
+ color: "red",
stream_id: id,
};
stream_data.add_sub(sub);
- sub = stream_data.get_sub('Denmark');
- assert.equal(sub.color, 'red');
+ sub = stream_data.get_sub("Denmark");
+ assert.equal(sub.color, "red");
sub = stream_data.get_sub_by_id(id);
- assert.equal(sub.color, 'red');
+ assert.equal(sub.color, "red");
- stream_data.rename_sub(sub, 'Sweden');
+ stream_data.rename_sub(sub, "Sweden");
sub = stream_data.get_sub_by_id(id);
- assert.equal(sub.color, 'red');
- assert.equal(sub.name, 'Sweden');
+ assert.equal(sub.color, "red");
+ assert.equal(sub.name, "Sweden");
- sub = stream_data.get_sub('Denmark');
+ sub = stream_data.get_sub("Denmark");
assert.equal(sub, undefined);
- sub = stream_data.get_sub_by_name('Denmark');
- assert.equal(sub.name, 'Sweden');
+ sub = stream_data.get_sub_by_name("Denmark");
+ assert.equal(sub.name, "Sweden");
- const actual_id = stream_data.get_stream_id('Denmark');
+ const actual_id = stream_data.get_stream_id("Denmark");
assert.equal(actual_id, 42);
});
-run_test('unsubscribe', () => {
+run_test("unsubscribe", () => {
stream_data.clear_subscriptions();
- let sub = {name: 'devel', subscribed: false, stream_id: 1};
+ let sub = {name: "devel", subscribed: false, stream_id: 1};
// set up our subscription
stream_data.add_sub(sub);
@@ -150,39 +150,39 @@ run_test('unsubscribe', () => {
stream_data.set_subscribers(sub, [me.user_id]);
// ensure our setup is accurate
- assert(stream_data.is_subscribed('devel'));
+ assert(stream_data.is_subscribed("devel"));
// DO THE UNSUBSCRIBE HERE
stream_data.unsubscribe_myself(sub);
assert(!sub.subscribed);
- assert(!stream_data.is_subscribed('devel'));
+ assert(!stream_data.is_subscribed("devel"));
assert(!contains_sub(stream_data.subscribed_subs(), sub));
assert(contains_sub(stream_data.unsubscribed_subs(), sub));
// make sure subsequent calls work
- sub = stream_data.get_sub('devel');
+ sub = stream_data.get_sub("devel");
assert(!sub.subscribed);
});
-run_test('subscribers', () => {
+run_test("subscribers", () => {
stream_data.clear_subscriptions();
- let sub = {name: 'Rome', subscribed: true, stream_id: 1};
+ let sub = {name: "Rome", subscribed: true, stream_id: 1};
stream_data.add_sub(sub);
const fred = {
- email: '[email protected]',
- full_name: 'Fred',
+ email: "[email protected]",
+ full_name: "Fred",
user_id: 101,
};
const not_fred = {
- email: '[email protected]',
- full_name: 'Not Fred',
+ email: "[email protected]",
+ full_name: "Not Fred",
user_id: 102,
};
const george = {
- email: '[email protected]',
- full_name: 'George',
+ email: "[email protected]",
+ full_name: "George",
user_id: 103,
};
people.add_active_user(fred);
@@ -221,8 +221,8 @@ run_test('subscribers', () => {
stream_data.set_subscribers(sub, []);
const brutus = {
- email: '[email protected]',
- full_name: 'Brutus',
+ email: "[email protected]",
+ full_name: "Brutus",
user_id: 104,
};
people.add_active_user(brutus);
@@ -232,7 +232,7 @@ run_test('subscribers', () => {
let ok = stream_data.add_subscriber(sub.stream_id, brutus.user_id);
assert(ok);
assert(stream_data.is_user_subscribed(sub.stream_id, brutus.user_id));
- sub = stream_data.get_sub('Rome');
+ sub = stream_data.get_sub("Rome");
stream_data.update_subscribers_count(sub);
assert.equal(sub.subscriber_count, 1);
const sub_email = "Rome:[email protected]:9991";
@@ -242,7 +242,7 @@ run_test('subscribers', () => {
// verify that adding an already-added subscriber is a noop
stream_data.add_subscriber(sub.stream_id, brutus.user_id);
assert(stream_data.is_user_subscribed(sub.stream_id, brutus.user_id));
- sub = stream_data.get_sub('Rome');
+ sub = stream_data.get_sub("Rome");
stream_data.update_subscribers_count(sub);
assert.equal(sub.subscriber_count, 1);
@@ -250,27 +250,27 @@ run_test('subscribers', () => {
ok = stream_data.remove_subscriber(sub.stream_id, brutus.user_id);
assert(ok);
assert(!stream_data.is_user_subscribed(sub.stream_id, brutus.user_id));
- sub = stream_data.get_sub('Rome');
+ sub = stream_data.get_sub("Rome");
stream_data.update_subscribers_count(sub);
assert.equal(sub.subscriber_count, 0);
// verify that checking subscription with undefined user id
- blueslip.expect('warn', 'Undefined user_id passed to function is_user_subscribed');
+ blueslip.expect("warn", "Undefined user_id passed to function is_user_subscribed");
assert.equal(stream_data.is_user_subscribed(sub.stream_id, undefined), undefined);
// 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);
// verify that removing an already-removed subscriber is a noop
- blueslip.expect('warn', 'We tried to remove invalid subscriber: 104');
+ blueslip.expect("warn", "We tried to remove invalid subscriber: 104");
ok = stream_data.remove_subscriber(sub.stream_id, brutus.user_id);
assert(!ok);
assert(!stream_data.is_user_subscribed(sub.stream_id, brutus.user_id));
- sub = stream_data.get_sub('Rome');
+ sub = stream_data.get_sub("Rome");
stream_data.update_subscribers_count(sub);
assert.equal(sub.subscriber_count, 0);
@@ -294,8 +294,8 @@ run_test('subscribers', () => {
assert.equal(stream_data.is_user_subscribed(sub.stream_id, brutus.user_id), true);
blueslip.expect(
- 'warn',
- 'We got a is_user_subscribed call for a non-existent or inaccessible stream.', 2);
+ "warn",
+ "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);
@@ -304,19 +304,19 @@ run_test('subscribers', () => {
// 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.');
+ "warn",
+ "We got an add_subscriber call for a non-existent stream.");
ok = stream_data.add_subscriber(9999999, brutus.user_id);
assert(!ok);
// Verify that we don't crash and return false for a bad user id.
- blueslip.expect('error', 'Unknown user_id in get_by_user_id: 9999999');
- blueslip.expect('error', 'We tried to add invalid subscriber: 9999999');
+ blueslip.expect("error", "Unknown user_id in get_by_user_id: 9999999");
+ blueslip.expect("error", "We tried to add invalid subscriber: 9999999");
ok = stream_data.add_subscriber(sub.stream_id, 9999999);
assert(!ok);
});
-run_test('is_active', () => {
+run_test("is_active", () => {
stream_data.clear_subscriptions();
let sub;
@@ -325,7 +325,7 @@ run_test('is_active', () => {
settings_config.demote_inactive_streams_values.automatic.code;
stream_data.set_filter_out_inactives();
- sub = {name: 'pets', subscribed: false, stream_id: 111};
+ sub = {name: "pets", subscribed: false, stream_id: 111};
stream_data.add_sub(sub);
assert(stream_data.is_active(sub));
@@ -346,7 +346,7 @@ run_test('is_active', () => {
const opts = {
stream_id: 222,
message_id: 108,
- topic_name: 'topic2',
+ topic_name: "topic2",
};
stream_topic_history.add_message(opts);
@@ -356,7 +356,7 @@ run_test('is_active', () => {
settings_config.demote_inactive_streams_values.always.code;
stream_data.set_filter_out_inactives();
- sub = {name: 'pets', subscribed: false, stream_id: 111};
+ sub = {name: "pets", subscribed: false, stream_id: 111};
stream_data.add_sub(sub);
assert(!stream_data.is_active(sub));
@@ -371,7 +371,7 @@ run_test('is_active', () => {
stream_data.unsubscribe_myself(sub);
assert(!stream_data.is_active(sub));
- sub = {name: 'lunch', subscribed: false, stream_id: 222};
+ sub = {name: "lunch", subscribed: false, stream_id: 222};
stream_data.add_sub(sub);
assert(stream_data.is_active(sub));
@@ -384,7 +384,7 @@ run_test('is_active', () => {
settings_config.demote_inactive_streams_values.never.code;
stream_data.set_filter_out_inactives();
- sub = {name: 'pets', subscribed: false, stream_id: 111};
+ sub = {name: "pets", subscribed: false, stream_id: 111};
stream_data.add_sub(sub);
assert(stream_data.is_active(sub));
@@ -403,12 +403,12 @@ run_test('is_active', () => {
assert(stream_data.is_active(sub));
});
-run_test('admin_options', () => {
+run_test("admin_options", () => {
function make_sub() {
const sub = {
subscribed: false,
- color: 'blue',
- name: 'stream_to_admin',
+ color: "blue",
+ name: "stream_to_admin",
stream_id: 1,
is_muted: true,
invite_only: false,
@@ -425,7 +425,7 @@ run_test('admin_options', () => {
assert(!sub.can_change_stream_permissions);
// just a sanity check that we leave "normal" fields alone
- assert.equal(sub.color, 'blue');
+ assert.equal(sub.color, "blue");
// the remaining cases are for admin users
global.page_params.is_admin = true;
@@ -453,27 +453,27 @@ run_test('admin_options', () => {
assert(sub.can_change_stream_permissions);
});
-run_test('stream_settings', () => {
+run_test("stream_settings", () => {
const cinnamon = {
stream_id: 1,
- name: 'c',
- color: 'cinnamon',
+ name: "c",
+ color: "cinnamon",
subscribed: true,
invite_only: false,
};
const blue = {
stream_id: 2,
- name: 'b',
- color: 'blue',
+ name: "b",
+ color: "blue",
subscribed: false,
invite_only: false,
};
const amber = {
stream_id: 3,
- name: 'a',
- color: 'amber',
+ name: "a",
+ color: "amber",
subscribed: true,
invite_only: true,
history_public_to_subscribers: true,
@@ -486,14 +486,14 @@ run_test('stream_settings', () => {
stream_data.add_sub(blue);
let sub_rows = stream_data.get_streams_for_settings_page();
- assert.equal(sub_rows[0].color, 'blue');
- assert.equal(sub_rows[1].color, 'amber');
- assert.equal(sub_rows[2].color, 'cinnamon');
+ assert.equal(sub_rows[0].color, "blue");
+ assert.equal(sub_rows[1].color, "amber");
+ assert.equal(sub_rows[2].color, "cinnamon");
sub_rows = stream_data.get_streams_for_admin();
- assert.equal(sub_rows[0].name, 'a');
- assert.equal(sub_rows[1].name, 'b');
- assert.equal(sub_rows[2].name, 'c');
+ assert.equal(sub_rows[0].name, "a");
+ assert.equal(sub_rows[1].name, "b");
+ assert.equal(sub_rows[2].name, "c");
assert.equal(sub_rows[0].invite_only, true);
assert.equal(sub_rows[1].invite_only, false);
assert.equal(sub_rows[2].invite_only, false);
@@ -503,7 +503,7 @@ run_test('stream_settings', () => {
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');
+ const sub = stream_data.get_sub("a");
stream_data.update_stream_privacy(sub, {
invite_only: false,
history_public_to_subscribers: false,
@@ -522,34 +522,34 @@ run_test('stream_settings', () => {
assert.equal(sub_rows.length, 3);
global.page_params.is_guest = true;
sub_rows = stream_data.get_updated_unsorted_subs();
- assert.equal(sub_rows[0].name, 'c');
- assert.equal(sub_rows[1].name, 'a');
+ assert.equal(sub_rows[0].name, "c");
+ assert.equal(sub_rows[1].name, "a");
assert.equal(sub_rows.length, 2);
});
-run_test('default_stream_names', () => {
+run_test("default_stream_names", () => {
const announce = {
stream_id: 101,
- name: 'announce',
+ name: "announce",
subscribed: true,
};
const public_stream = {
stream_id: 102,
- name: 'public',
+ name: "public",
subscribed: true,
};
const private_stream = {
stream_id: 103,
- name: 'private',
+ name: "private",
subscribed: true,
invite_only: true,
};
const general = {
stream_id: 104,
- name: 'general',
+ name: "general",
subscribed: true,
invite_only: false,
};
@@ -562,7 +562,7 @@ run_test('default_stream_names', () => {
stream_data.add_sub(general);
const names = stream_data.get_non_default_stream_names();
- assert.deepEqual(names.sort(), ['private', 'public']);
+ assert.deepEqual(names.sort(), ["private", "public"]);
const default_stream_ids = stream_data.get_default_stream_ids();
assert.deepEqual(
@@ -574,69 +574,69 @@ run_test('default_stream_names', () => {
);
});
-run_test('delete_sub', () => {
+run_test("delete_sub", () => {
const canada = {
stream_id: 101,
- name: 'Canada',
+ name: "Canada",
subscribed: true,
};
stream_data.clear_subscriptions();
stream_data.add_sub(canada);
- assert(stream_data.is_subscribed('Canada'));
- assert(stream_data.get_sub('Canada').stream_id, canada.stream_id);
- assert(stream_data.get_sub_by_id(canada.stream_id).name, 'Canada');
+ assert(stream_data.is_subscribed("Canada"));
+ assert(stream_data.get_sub("Canada").stream_id, canada.stream_id);
+ assert(stream_data.get_sub_by_id(canada.stream_id).name, "Canada");
stream_data.delete_sub(canada.stream_id);
- assert(!stream_data.is_subscribed('Canada'));
- assert(!stream_data.get_sub('Canada'));
+ assert(!stream_data.is_subscribed("Canada"));
+ assert(!stream_data.get_sub("Canada"));
assert(!stream_data.get_sub_by_id(canada.stream_id));
- blueslip.expect('warn', 'Failed to delete stream 99999');
+ blueslip.expect("warn", "Failed to delete stream 99999");
stream_data.delete_sub(99999);
});
-run_test('get_subscriber_count', () => {
+run_test("get_subscriber_count", () => {
const india = {
stream_id: 102,
- name: 'India',
+ name: "India",
subscribed: true,
};
stream_data.clear_subscriptions();
- blueslip.expect('warn', 'We got a get_subscriber_count count call for a non-existent stream.');
+ blueslip.expect("warn", "We got a get_subscriber_count count call for a non-existent stream.");
assert.equal(stream_data.get_subscriber_count(india.stream_id), undefined);
stream_data.add_sub(india);
assert.equal(stream_data.get_subscriber_count(india.stream_id), 0);
const fred = {
- email: '[email protected]',
- full_name: 'Fred',
+ email: "[email protected]",
+ full_name: "Fred",
user_id: 101,
};
people.add_active_user(fred);
stream_data.add_subscriber(india.stream_id, 102);
assert.equal(stream_data.get_subscriber_count(india.stream_id), 1);
const george = {
- email: '[email protected]',
- full_name: 'George',
+ email: "[email protected]",
+ full_name: "George",
user_id: 103,
};
people.add_active_user(george);
stream_data.add_subscriber(india.stream_id, 103);
assert.equal(stream_data.get_subscriber_count(india.stream_id), 2);
- const sub = stream_data.get_sub_by_name('India');
+ const sub = stream_data.get_sub_by_name("India");
delete sub.subscribers;
assert.deepStrictEqual(stream_data.get_subscriber_count(india.stream_id), 0);
});
-run_test('notifications', () => {
+run_test("notifications", () => {
const india = {
stream_id: 102,
- name: 'India',
+ name: "India",
subscribed: true,
invite_only: false,
is_web_public: false,
@@ -706,7 +706,7 @@ run_test('notifications', () => {
const canada = {
stream_id: 103,
- name: 'Canada',
+ name: "Canada",
subscribed: true,
invite_only: true,
is_web_public: false,
@@ -720,7 +720,7 @@ run_test('notifications', () => {
const antarctica = {
stream_id: 104,
- name: 'Antarctica',
+ name: "Antarctica",
subscribed: true,
desktop_notifications: null,
audible_notifications: null,
@@ -764,7 +764,7 @@ run_test('notifications', () => {
wildcard_mentions_notify: false,
invite_only: true,
is_web_public: false,
- stream_name: 'Canada',
+ stream_name: "Canada",
stream_id: 103,
},
{
@@ -775,7 +775,7 @@ run_test('notifications', () => {
wildcard_mentions_notify: false,
invite_only: false,
is_web_public: false,
- stream_name: 'India',
+ stream_name: "India",
stream_id: 102,
},
];
@@ -785,27 +785,27 @@ run_test('notifications', () => {
const tony = {
stream_id: 999,
- name: 'tony',
+ name: "tony",
subscribed: true,
is_muted: false,
};
const jazy = {
stream_id: 500,
- name: 'jazy',
+ name: "jazy",
subscribed: false,
is_muted: true,
};
-run_test('is_muted', () => {
+run_test("is_muted", () => {
stream_data.add_sub(tony);
stream_data.add_sub(jazy);
- assert(!stream_data.is_stream_muted_by_name('tony'));
- assert(stream_data.is_stream_muted_by_name('jazy'));
- assert(stream_data.is_stream_muted_by_name('EEXISTS'));
+ assert(!stream_data.is_stream_muted_by_name("tony"));
+ assert(stream_data.is_stream_muted_by_name("jazy"));
+ assert(stream_data.is_stream_muted_by_name("EEXISTS"));
});
-run_test('is_notifications_stream_muted', () => {
+run_test("is_notifications_stream_muted", () => {
stream_data.add_sub(tony);
stream_data.add_sub(jazy);
@@ -816,17 +816,17 @@ run_test('is_notifications_stream_muted', () => {
assert(stream_data.is_notifications_stream_muted());
});
-run_test('realm_has_notifications_stream', () => {
+run_test("realm_has_notifications_stream", () => {
page_params.realm_notifications_stream_id = 10;
assert(stream_data.realm_has_notifications_stream());
page_params.realm_notifications_stream_id = -1;
assert(!stream_data.realm_has_notifications_stream());
});
-run_test('remove_default_stream', () => {
+run_test("remove_default_stream", () => {
const remove_me = {
stream_id: 674,
- name: 'remove_me',
+ name: "remove_me",
subscribed: false,
is_muted: true,
};
@@ -837,69 +837,69 @@ run_test('remove_default_stream', () => {
assert(!stream_data.is_default_stream_id(remove_me.stream_id));
});
-run_test('canonicalized_name', () => {
+run_test("canonicalized_name", () => {
assert.deepStrictEqual(
- stream_data.canonicalized_name('Stream_Bar'),
+ stream_data.canonicalized_name("Stream_Bar"),
"stream_bar",
);
});
-run_test('create_sub', () => {
+run_test("create_sub", () => {
stream_data.clear_subscriptions();
const india = {
stream_id: 102,
- name: 'India',
+ name: "India",
subscribed: true,
};
const canada = {
- name: 'Canada',
+ name: "Canada",
subscribed: true,
};
const antarctica = {
stream_id: 103,
- name: 'Antarctica',
+ name: "Antarctica",
subscribed: true,
- color: '#76ce90',
+ color: "#76ce90",
};
color_data.pick_color = function () {
- return '#bd86e5';
+ return "#bd86e5";
};
const india_sub = stream_data.create_sub_from_server_data(india);
assert(india_sub);
- assert.equal(india_sub.color, '#bd86e5');
+ assert.equal(india_sub.color, "#bd86e5");
const new_sub = stream_data.create_sub_from_server_data(india);
// 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'});
+ 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);
- assert.equal(antarctica_sub.color, '#76ce90');
+ assert.equal(antarctica_sub.color, "#76ce90");
});
-run_test('initialize', () => {
+run_test("initialize", () => {
function get_params() {
const params = {};
params.subscriptions = [{
- name: 'subscriptions',
+ name: "subscriptions",
stream_id: 2001,
}];
params.unsubscribed = [{
- name: 'unsubscribed',
+ name: "unsubscribed",
stream_id: 2002,
}];
params.never_subscribed = [{
- name: 'never_subscribed',
+ name: "never_subscribed",
stream_id: 2003,
}];
@@ -920,9 +920,9 @@ run_test('initialize', () => {
assert(!stream_data.is_filtering_inactives());
const stream_names = stream_data.get_streams_for_admin().map((elem) => elem.name);
- assert(stream_names.includes('subscriptions'));
- assert(stream_names.includes('unsubscribed'));
- assert(stream_names.includes('never_subscribed'));
+ assert(stream_names.includes("subscriptions"));
+ assert(stream_names.includes("unsubscribed"));
+ assert(stream_names.includes("never_subscribed"));
assert.equal(stream_data.get_notifications_stream(), "");
// Simulate a private stream the user isn't subscribed to
@@ -933,7 +933,7 @@ run_test('initialize', () => {
// Now actually subscribe the user to the stream
initialize();
const foo = {
- name: 'foo',
+ name: "foo",
stream_id: 89,
};
@@ -942,7 +942,7 @@ run_test('initialize', () => {
assert.equal(stream_data.get_notifications_stream(), "foo");
});
-run_test('filter inactives', () => {
+run_test("filter inactives", () => {
const params = {};
params.unsubscribed = [];
params.never_subscribed = [];
@@ -953,7 +953,7 @@ run_test('filter inactives', () => {
assert(!stream_data.is_filtering_inactives());
_.times(30, (i) => {
- const name = 'random' + i.toString();
+ const name = "random" + i.toString();
const stream_id = 100 + i;
const sub = {
@@ -968,7 +968,7 @@ run_test('filter inactives', () => {
assert(stream_data.is_filtering_inactives());
});
-run_test('is_subscriber_subset', () => {
+run_test("is_subscriber_subset", () => {
function make_sub(user_ids) {
const sub = {};
stream_data.set_subscribers(sub, user_ids);
@@ -1007,17 +1007,17 @@ run_test('is_subscriber_subset', () => {
}
});
-run_test('edge_cases', () => {
+run_test("edge_cases", () => {
const bad_stream_ids = [555555, 99999];
// just make sure we don't explode
stream_data.sort_for_stream_settings(bad_stream_ids);
});
-run_test('get_invite_stream_data', () => {
+run_test("get_invite_stream_data", () => {
// add default stream
const orie = {
- name: 'Orie',
+ name: "Orie",
stream_id: 320,
invite_only: false,
subscribed: true,
@@ -1031,7 +1031,7 @@ run_test('get_invite_stream_data', () => {
stream_data.set_realm_default_streams([orie]);
const expected_list = [{
- name: 'Orie',
+ name: "Orie",
stream_id: 320,
invite_only: false,
default_stream: true,
@@ -1039,7 +1039,7 @@ run_test('get_invite_stream_data', () => {
assert.deepEqual(stream_data.get_invite_stream_data(), expected_list);
const inviter = {
- name: 'Inviter',
+ name: "Inviter",
stream_id: 25,
invite_only: true,
subscribed: true,
@@ -1047,7 +1047,7 @@ run_test('get_invite_stream_data', () => {
stream_data.add_sub(inviter);
expected_list.push({
- name: 'Inviter',
+ name: "Inviter",
stream_id: 25,
invite_only: true,
default_stream: false,
@@ -1055,10 +1055,10 @@ run_test('get_invite_stream_data', () => {
assert.deepEqual(stream_data.get_invite_stream_data(), expected_list);
});
-run_test('all_topics_in_cache', () => {
+run_test("all_topics_in_cache", () => {
// Add a new stream with first_message_id set.
const general = {
- name: 'general',
+ name: "general",
stream_id: 21,
first_message_id: null,
};
diff --git a/frontend_tests/node_tests/stream_events.js b/frontend_tests/node_tests/stream_events.js
index 892dab19a86..6183759a666 100644
--- a/frontend_tests/node_tests/stream_events.js
+++ b/frontend_tests/node_tests/stream_events.js
@@ -1,31 +1,31 @@
const noop = function () {};
const return_true = function () { return true; };
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
const _settings_notifications = {
update_page: () => {},
};
-set_global('settings_notifications', _settings_notifications);
+set_global("settings_notifications", _settings_notifications);
-zrequire('people');
-zrequire('stream_data');
-zrequire('stream_events');
-zrequire('Filter', 'js/filter');
-zrequire('narrow_state');
-zrequire('tab_bar');
+zrequire("people");
+zrequire("stream_data");
+zrequire("stream_events");
+zrequire("Filter", "js/filter");
+zrequire("narrow_state");
+zrequire("tab_bar");
const with_overrides = global.with_overrides;
const george = {
- email: '[email protected]',
- full_name: 'George',
+ email: "[email protected]",
+ full_name: "George",
user_id: 103,
};
people.add_active_user(george);
const frontend = {
subscribed: false,
- color: 'yellow',
- name: 'frontend',
+ color: "yellow",
+ name: "frontend",
stream_id: 1,
is_muted: true,
invite_only: false,
@@ -35,120 +35,120 @@ stream_data.add_sub(frontend);
const frontend_filter_terms = [
- { operator: 'stream', operand: 'frontend' },
+ { operator: "stream", operand: "frontend" },
];
const frontend_filter = new Filter(frontend_filter_terms);
-run_test('update_property', () => {
+run_test("update_property", () => {
// Invoke error for non-existent stream/property
with_overrides((override) => {
let errors = 0;
- override('blueslip.warn', () => {
+ override("blueslip.warn", () => {
errors += 1;
});
- stream_events.update_property(99, 'color', 'blue');
+ stream_events.update_property(99, "color", "blue");
assert.equal(errors, 1);
- stream_events.update_property(1, 'not_real', 42);
+ stream_events.update_property(1, "not_real", 42);
assert.equal(errors, 2);
});
// Test update color
with_overrides((override) => {
global.with_stub((stub) => {
- override('stream_color.update_stream_color', stub.f);
- stream_events.update_property(1, 'color', 'blue');
- const args = stub.get_args('sub', 'val');
+ override("stream_color.update_stream_color", stub.f);
+ stream_events.update_property(1, "color", "blue");
+ const args = stub.get_args("sub", "val");
assert.equal(args.sub.stream_id, 1);
- assert.equal(args.val, 'blue');
+ assert.equal(args.val, "blue");
});
});
// Test in home view
with_overrides((override) => {
global.with_stub((stub) => {
- override('stream_muting.update_is_muted', stub.f);
- stream_events.update_property(1, 'in_home_view', false);
- const args = stub.get_args('sub', 'val');
+ override("stream_muting.update_is_muted", stub.f);
+ stream_events.update_property(1, "in_home_view", false);
+ const args = stub.get_args("sub", "val");
assert.equal(args.sub.stream_id, 1);
assert.equal(args.val, true);
});
});
// Test desktop notifications
- stream_events.update_property(1, 'desktop_notifications', true);
+ stream_events.update_property(1, "desktop_notifications", true);
assert.equal(frontend.desktop_notifications, true);
let checkbox = $("#desktop_notifications_1");
- assert.equal(checkbox.prop('checked'), true);
+ assert.equal(checkbox.prop("checked"), true);
// Tests audible notifications
- stream_events.update_property(1, 'audible_notifications', true);
+ stream_events.update_property(1, "audible_notifications", true);
assert.equal(frontend.audible_notifications, true);
checkbox = $("#audible_notifications_1");
- assert.equal(checkbox.prop('checked'), true);
+ assert.equal(checkbox.prop("checked"), true);
// Tests push notifications
- stream_events.update_property(1, 'push_notifications', true);
+ stream_events.update_property(1, "push_notifications", true);
assert.equal(frontend.push_notifications, true);
checkbox = $("#push_notifications_1");
- assert.equal(checkbox.prop('checked'), true);
+ assert.equal(checkbox.prop("checked"), true);
// Tests email notifications
- stream_events.update_property(1, 'email_notifications', true);
+ stream_events.update_property(1, "email_notifications", true);
assert.equal(frontend.email_notifications, true);
checkbox = $("#email_notifications_1");
- assert.equal(checkbox.prop('checked'), true);
+ assert.equal(checkbox.prop("checked"), true);
// Tests wildcard_mentions_notify notifications
- stream_events.update_property(1, 'wildcard_mentions_notify', true);
+ stream_events.update_property(1, "wildcard_mentions_notify", true);
assert.equal(frontend.wildcard_mentions_notify, true);
checkbox = $("#wildcard_mentions_notify_1");
- assert.equal(checkbox.prop('checked'), true);
+ assert.equal(checkbox.prop("checked"), true);
// Test name change
with_overrides((override) => {
global.with_stub((stub) => {
- override('subs.update_stream_name', stub.f);
- stream_events.update_property(1, 'name', 'the frontend');
- const args = stub.get_args('sub', 'val');
+ override("subs.update_stream_name", stub.f);
+ stream_events.update_property(1, "name", "the frontend");
+ const args = stub.get_args("sub", "val");
assert.equal(args.sub.stream_id, 1);
- assert.equal(args.val, 'the frontend');
+ assert.equal(args.val, "the frontend");
});
});
// Test description change
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'});
- const args = stub.get_args('sub', 'val');
+ override("subs.update_stream_description", stub.f);
+ 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');
+ assert.equal(args.val, "we write code");
});
});
// Test email address change
- stream_events.update_property(1, 'email_address', '[email protected]');
- assert.equal(frontend.email_address, '[email protected]');
+ stream_events.update_property(1, "email_address", "[email protected]");
+ assert.equal(frontend.email_address, "[email protected]");
// Test pin to top
with_overrides((override) => {
- override('stream_list.refresh_pinned_or_unpinned_stream', noop);
- stream_events.update_property(1, 'pin_to_top', true);
+ override("stream_list.refresh_pinned_or_unpinned_stream", noop);
+ stream_events.update_property(1, "pin_to_top", true);
checkbox = $("#pin_to_top_1");
- assert.equal(checkbox.prop('checked'), true);
+ assert.equal(checkbox.prop("checked"), true);
});
// Test stream privacy change event
with_overrides((override) => {
global.with_stub((stub) => {
- override('subs.update_stream_privacy', stub.f);
- stream_events.update_property(1, 'invite_only', true, {
+ override("subs.update_stream_privacy", stub.f);
+ stream_events.update_property(1, "invite_only", true, {
history_public_to_subscribers: true,
});
- const args = stub.get_args('sub', 'val');
+ const args = stub.get_args("sub", "val");
assert.equal(args.sub.stream_id, 1);
assert.deepEqual(args.val, {
invite_only: true,
@@ -160,9 +160,9 @@ run_test('update_property', () => {
// Test stream stream_post_policy change event
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);
- const args = stub.get_args('sub', 'val');
+ override("subs.update_stream_post_policy", stub.f);
+ 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);
});
@@ -171,41 +171,41 @@ run_test('update_property', () => {
// Test stream message_retention_days change event
with_overrides((override) => {
global.with_stub((stub) => {
- override('subs.update_message_retention_setting', stub.f);
- stream_events.update_property(1, 'message_retention_days', 20);
- const args = stub.get_args('sub', 'val');
+ override("subs.update_message_retention_setting", stub.f);
+ stream_events.update_property(1, "message_retention_days", 20);
+ const args = stub.get_args("sub", "val");
assert.equal(args.sub.stream_id, 1);
assert.equal(args.val, 20);
});
});
});
-run_test('marked_subscribed', () => {
+run_test("marked_subscribed", () => {
// Test undefined error
with_overrides((override) => {
let errors = 0;
- override('stream_color.update_stream_color', noop);
- override('blueslip.error', () => {
+ override("stream_color.update_stream_color", noop);
+ override("blueslip.error", () => {
errors += 1;
});
- stream_events.mark_subscribed(undefined, [], 'yellow');
+ stream_events.mark_subscribed(undefined, [], "yellow");
assert.equal(errors, 1);
});
// Test early return if subscribed
with_overrides((override) => {
let completed = false;
- override('message_util.do_unread_count_updates', () => {
+ override("message_util.do_unread_count_updates", () => {
completed = true; // This gets run if we continue and don't early return
});
const subscribed = {subscribed: true};
- stream_events.mark_subscribed(subscribed, [], 'yellow');
+ stream_events.mark_subscribed(subscribed, [], "yellow");
assert.equal(completed, false);
});
- set_global('message_list', {
+ set_global("message_list", {
all: {
- all_messages: function () { return ['msg']; },
+ all_messages: function () { return ["msg"]; },
},
});
@@ -214,8 +214,8 @@ run_test('marked_subscribed', () => {
stream_data.get_colors = noop;
stream_data.update_calculated_fields = noop;
- set_global('subs', { update_settings_for_subscribed: noop });
- set_global('overlays', { streams_open: return_true });
+ set_global("subs", { update_settings_for_subscribed: noop });
+ set_global("overlays", { streams_open: return_true });
// Test basic dispatching and updating stream color
narrow_state.set_current_filter(frontend_filter);
@@ -227,48 +227,48 @@ run_test('marked_subscribed', () => {
const tab_bar_stub = global.make_stub();
const message_util_stub = global.make_stub();
- override('stream_color.update_stream_color', noop);
- override('stream_list.add_sidebar_row', stream_list_stub.f);
- override('message_util.do_unread_count_updates', message_util_stub.f);
- override('tab_bar.render_title_area', tab_bar_stub.f);
- override('current_msg_list.update_trailing_bookend', () => {
+ override("stream_color.update_stream_color", noop);
+ override("stream_list.add_sidebar_row", stream_list_stub.f);
+ override("message_util.do_unread_count_updates", message_util_stub.f);
+ override("tab_bar.render_title_area", tab_bar_stub.f);
+ override("current_msg_list.update_trailing_bookend", () => {
list_updated = true;
});
- stream_events.mark_subscribed(frontend, [], 'blue');
+ stream_events.mark_subscribed(frontend, [], "blue");
- args = message_util_stub.get_args('messages');
- assert.deepEqual(args.messages, ['msg']);
+ args = message_util_stub.get_args("messages");
+ assert.deepEqual(args.messages, ["msg"]);
- args = stream_list_stub.get_args('sub');
+ args = stream_list_stub.get_args("sub");
assert.equal(args.sub.stream_id, 1);
assert.equal(tab_bar_stub.num_calls, 1);
assert.equal(list_updated, true);
- assert.equal(frontend.color, 'blue');
+ assert.equal(frontend.color, "blue");
});
narrow_state.reset_current_filter();
// Test assigning generated color
with_overrides((override) => {
frontend.color = undefined;
- override('color_data.pick_color', () => 'green');
+ override("color_data.pick_color", () => "green");
let warnings = 0;
- override('blueslip.warn', () => {
+ override("blueslip.warn", () => {
warnings += 1;
});
// narrow state is undefined
global.with_stub((stub) => {
- override('message_util.do_unread_count_updates', noop);
- override('stream_list.add_sidebar_row', noop);
- override('stream_color.update_stream_color', noop);
- override('subs.set_color', stub.f);
+ override("message_util.do_unread_count_updates", noop);
+ override("stream_list.add_sidebar_row", noop);
+ override("stream_color.update_stream_color", noop);
+ override("subs.set_color", stub.f);
stream_events.mark_subscribed(frontend, [], undefined);
- const args = stub.get_args('id', 'color');
+ const args = stub.get_args("id", "color");
assert.equal(args.id, 1);
- assert.equal(args.color, 'green');
+ assert.equal(args.color, "green");
assert.equal(warnings, 1);
});
});
@@ -276,41 +276,41 @@ run_test('marked_subscribed', () => {
// Test assigning subscriber emails
// narrow state is undefined
with_overrides((override) => {
- override('stream_color.update_stream_color', noop);
- override('message_util.do_unread_count_updates', noop);
- override('stream_list.add_sidebar_row', noop);
+ override("stream_color.update_stream_color", noop);
+ override("message_util.do_unread_count_updates", noop);
+ override("stream_list.add_sidebar_row", noop);
global.with_stub((stub) => {
- override('stream_data.set_subscribers', stub.f);
+ override("stream_data.set_subscribers", stub.f);
const user_ids = [15, 20, 25];
- stream_events.mark_subscribed(frontend, user_ids, '');
- const args = stub.get_args('sub', 'subscribers');
+ stream_events.mark_subscribed(frontend, user_ids, "");
+ const args = stub.get_args("sub", "subscribers");
assert.deepEqual(frontend, args.sub);
assert.deepEqual(user_ids, args.subscribers);
});
// assign self as well
global.with_stub((stub) => {
- override('stream_data.subscribe_myself', stub.f);
- stream_events.mark_subscribed(frontend, [], '');
- const args = stub.get_args('sub');
+ override("stream_data.subscribe_myself", stub.f);
+ stream_events.mark_subscribed(frontend, [], "");
+ const args = stub.get_args("sub");
assert.deepEqual(frontend, args.sub);
});
// and finally update subscriber settings
global.with_stub((stub) => {
- override('subs.update_settings_for_subscribed', stub.f);
- stream_events.mark_subscribed(frontend, [], '');
- const args = stub.get_args('sub');
+ override("subs.update_settings_for_subscribed", stub.f);
+ stream_events.mark_subscribed(frontend, [], "");
+ const args = stub.get_args("sub");
assert.deepEqual(frontend, args.sub);
});
});
});
-run_test('mark_unsubscribed', () => {
+run_test("mark_unsubscribed", () => {
with_overrides((override) => {
let removed_sub = false;
- override('stream_list.remove_sidebar_row', () => {
+ override("stream_list.remove_sidebar_row", () => {
removed_sub = true;
});
@@ -328,11 +328,11 @@ run_test('mark_unsubscribed', () => {
frontend.subscribed = true;
with_overrides((override) => {
global.with_stub((stub) => {
- override('stream_data.unsubscribe_myself', stub.f);
- override('subs.update_settings_for_unsubscribed', noop);
- override('stream_list.remove_sidebar_row', noop);
+ override("stream_data.unsubscribe_myself", stub.f);
+ override("subs.update_settings_for_unsubscribed", noop);
+ override("stream_list.remove_sidebar_row", noop);
stream_events.mark_unsubscribed(frontend);
- const args = stub.get_args('sub');
+ const args = stub.get_args("sub");
assert.deepEqual(args.sub, frontend);
});
});
@@ -340,11 +340,11 @@ run_test('mark_unsubscribed', () => {
// Test update settings after unsubscribe
with_overrides((override) => {
global.with_stub((stub) => {
- override('subs.update_settings_for_unsubscribed', stub.f);
- override('stream_data.unsubscribe_myself', noop);
- override('stream_list.remove_sidebar_row', noop);
+ override("subs.update_settings_for_unsubscribed", stub.f);
+ override("stream_data.unsubscribe_myself", noop);
+ override("stream_list.remove_sidebar_row", noop);
stream_events.mark_unsubscribed(frontend);
- const args = stub.get_args('sub');
+ const args = stub.get_args("sub");
assert.deepEqual(args.sub, frontend);
});
});
@@ -353,17 +353,17 @@ run_test('mark_unsubscribed', () => {
narrow_state.set_current_filter(frontend_filter);
with_overrides((override) => {
const tab_bar_stub = global.make_stub();
- override('tab_bar.render_title_area', tab_bar_stub.f);
- override('stream_data.unsubscribe_myself', noop);
- override('subs.update_settings_for_unsubscribed', noop);
+ override("tab_bar.render_title_area", tab_bar_stub.f);
+ override("stream_data.unsubscribe_myself", noop);
+ override("subs.update_settings_for_unsubscribed", noop);
let updated = false;
- override('current_msg_list.update_trailing_bookend', () => {
+ override("current_msg_list.update_trailing_bookend", () => {
updated = true;
});
let event_triggered = false;
- override('stream_list.remove_sidebar_row', (stream_id) => {
+ override("stream_list.remove_sidebar_row", (stream_id) => {
assert.equal(stream_id, frontend.stream_id);
event_triggered = true;
});
@@ -380,15 +380,15 @@ run_test('mark_unsubscribed', () => {
stream_data.clear_subscriptions();
const dev_help = {
subscribed: true,
- color: 'blue',
- name: 'dev help',
+ color: "blue",
+ name: "dev help",
stream_id: 2,
is_muted: true,
invite_only: false,
};
stream_data.add_sub(dev_help);
-run_test('remove_deactivated_user_from_all_streams', () => {
+run_test("remove_deactivated_user_from_all_streams", () => {
const subs_stub = global.make_stub();
subs.update_subscribers_ui = subs_stub.f;
diff --git a/frontend_tests/node_tests/stream_list.js b/frontend_tests/node_tests/stream_list.js
index d6648506e17..b60658a4a92 100644
--- a/frontend_tests/node_tests/stream_list.js
+++ b/frontend_tests/node_tests/stream_list.js
@@ -1,20 +1,20 @@
-set_global('document', 'document-stub');
-set_global('$', global.make_zjquery());
-
-zrequire('unread_ui');
-zrequire('Filter', 'js/filter');
-zrequire('stream_sort');
-zrequire('colorspace');
-zrequire('stream_color');
-zrequire('hash_util');
-zrequire('unread');
-zrequire('stream_data');
-zrequire('scroll_util');
-zrequire('list_cursor');
-zrequire('stream_list');
-zrequire('topic_zoom');
-zrequire('ui');
-set_global('page_params', {
+set_global("document", "document-stub");
+set_global("$", global.make_zjquery());
+
+zrequire("unread_ui");
+zrequire("Filter", "js/filter");
+zrequire("stream_sort");
+zrequire("colorspace");
+zrequire("stream_color");
+zrequire("hash_util");
+zrequire("unread");
+zrequire("stream_data");
+zrequire("scroll_util");
+zrequire("list_cursor");
+zrequire("stream_list");
+zrequire("topic_zoom");
+zrequire("ui");
+set_global("page_params", {
is_admin: false,
realm_users: [],
});
@@ -25,31 +25,31 @@ const noop = function () {};
const return_false = function () { return false; };
const return_true = function () { return true; };
-set_global('topic_list', {});
-set_global('overlays', {});
-set_global('popovers', {});
+set_global("topic_list", {});
+set_global("overlays", {});
+set_global("popovers", {});
-set_global('keydown_util', {
+set_global("keydown_util", {
handle: noop,
});
-run_test('create_sidebar_row', () => {
+run_test("create_sidebar_row", () => {
// Make a couple calls to create_sidebar_row() and make sure they
// generate the right markup as well as play nice with get_stream_li().
page_params.demote_inactive_streams = 1;
const devel = {
- name: 'devel',
+ name: "devel",
stream_id: 100,
- color: 'blue',
+ color: "blue",
subscribed: true,
pin_to_top: true,
};
global.stream_data.add_sub(devel);
const social = {
- name: 'social',
+ name: "social",
stream_id: 200,
- color: 'green',
+ color: "green",
subscribed: true,
};
global.stream_data.add_sub(social);
@@ -59,50 +59,50 @@ run_test('create_sidebar_row', () => {
};
(function create_devel_sidebar_row() {
- const devel_value = $.create('devel-value');
- const devel_count = $.create('devel-count');
+ const devel_value = $.create("devel-value");
+ const devel_count = $.create("devel-count");
- const sidebar_row = $('<devel sidebar row>');
+ const sidebar_row = $("<devel sidebar row>");
- sidebar_row.set_find_results('.count', devel_count);
- devel_count.set_find_results('.value', devel_value);
+ sidebar_row.set_find_results(".count", devel_count);
+ devel_count.set_find_results(".value", devel_value);
devel_count.set_parent(sidebar_row);
global.stub_templates((template_name, data) => {
- assert.equal(template_name, 'stream_sidebar_row');
- assert.equal(data.uri, '#narrow/stream/100-devel');
- return '<devel sidebar row>';
+ assert.equal(template_name, "stream_sidebar_row");
+ assert.equal(data.uri, "#narrow/stream/100-devel");
+ return "<devel sidebar row>";
});
stream_list.create_sidebar_row(devel);
- assert.equal(devel_value.text(), '42');
+ assert.equal(devel_value.text(), "42");
}());
(function create_social_sidebar_row() {
- const social_value = $.create('social-value');
- const social_count = $.create('social-count');
- const sidebar_row = $('<social sidebar row>');
+ const social_value = $.create("social-value");
+ const social_count = $.create("social-count");
+ const sidebar_row = $("<social sidebar row>");
- sidebar_row.set_find_results('.count', social_count);
- social_count.set_find_results('.value', social_value);
+ sidebar_row.set_find_results(".count", social_count);
+ social_count.set_find_results(".value", social_value);
social_count.set_parent(sidebar_row);
global.stub_templates((template_name, data) => {
- assert.equal(template_name, 'stream_sidebar_row');
- assert.equal(data.uri, '#narrow/stream/200-social');
- return '<social sidebar row>';
+ assert.equal(template_name, "stream_sidebar_row");
+ assert.equal(data.uri, "#narrow/stream/200-social");
+ return "<social sidebar row>";
});
stream_list.create_sidebar_row(social);
- assert.equal(social_value.text(), '42');
+ assert.equal(social_value.text(), "42");
}());
const split = '<hr class="stream-split">';
- const devel_sidebar = $('<devel sidebar row>');
- const social_sidebar = $('<social sidebar row>');
+ const devel_sidebar = $("<devel sidebar row>");
+ const social_sidebar = $("<social sidebar row>");
let appended_elems;
- $('#stream_filters').append = function (elems) {
+ $("#stream_filters").append = function (elems) {
appended_elems = elems;
};
@@ -123,39 +123,39 @@ run_test('create_sidebar_row', () => {
assert.deepEqual(appended_elems, expected_elems);
- const social_li = $('<social sidebar row>');
+ const social_li = $("<social sidebar row>");
const stream_id = social.stream_id;
social_li.length = 0;
- const privacy_elem = $.create('privacy-stub');
- social_li.set_find_results('.stream-privacy', privacy_elem);
+ const privacy_elem = $.create("privacy-stub");
+ social_li.set_find_results(".stream-privacy", privacy_elem);
social.invite_only = true;
- social.color = '#222222';
+ social.color = "#222222";
global.stub_templates((template_name, data) => {
- assert.equal(template_name, 'stream_privacy');
+ assert.equal(template_name, "stream_privacy");
assert.equal(data.invite_only, true);
- assert.equal(data.dark_background, 'dark_background');
- return '<div>privacy-html';
+ assert.equal(data.dark_background, "dark_background");
+ return "<div>privacy-html";
});
stream_list.redraw_stream_privacy(social);
- assert.equal(privacy_elem.html(), '<div>privacy-html');
+ assert.equal(privacy_elem.html(), "<div>privacy-html");
stream_list.set_in_home_view(stream_id, false);
- assert(social_li.hasClass('out_of_home_view'));
+ assert(social_li.hasClass("out_of_home_view"));
stream_list.set_in_home_view(stream_id, true);
- assert(!social_li.hasClass('out_of_home_view'));
+ assert(!social_li.hasClass("out_of_home_view"));
const row = stream_list.stream_sidebar.get_row(stream_id);
stream_data.is_active = return_true;
row.update_whether_active();
- assert(!social_li.hasClass('inactive_stream'));
+ assert(!social_li.hasClass("inactive_stream"));
stream_data.is_active = return_false;
row.update_whether_active();
- assert(social_li.hasClass('inactive_stream'));
+ assert(social_li.hasClass("inactive_stream"));
let removed;
social_li.remove = function () {
@@ -166,23 +166,23 @@ run_test('create_sidebar_row', () => {
assert(removed);
});
-run_test('pinned_streams_never_inactive', () => {
+run_test("pinned_streams_never_inactive", () => {
// Ensure that pinned streams are never treated as dormant ie never given "inactive" class
stream_data.clear_subscriptions();
const devel = {
- name: 'devel',
+ name: "devel",
stream_id: 100,
- color: 'blue',
+ color: "blue",
subscribed: true,
pin_to_top: true,
};
global.stream_data.add_sub(devel);
const social = {
- name: 'social',
+ name: "social",
stream_id: 200,
- color: 'green',
+ color: "green",
subscribed: true,
};
global.stream_data.add_sub(social);
@@ -190,43 +190,43 @@ run_test('pinned_streams_never_inactive', () => {
// we use social and devel created in create_social_sidebar_row() and create_devel_sidebar_row()
// non-pinned streams can be made inactive
- const social_sidebar = $('<social sidebar row>');
+ const social_sidebar = $("<social sidebar row>");
let stream_id = social.stream_id;
let row = stream_list.stream_sidebar.get_row(stream_id);
stream_data.is_active = return_false;
stream_list.build_stream_list();
- assert(social_sidebar.hasClass('inactive_stream'));
+ assert(social_sidebar.hasClass("inactive_stream"));
stream_data.is_active = return_true;
row.update_whether_active();
- assert(!social_sidebar.hasClass('inactive_stream'));
+ assert(!social_sidebar.hasClass("inactive_stream"));
stream_data.is_active = return_false;
row.update_whether_active();
- assert(social_sidebar.hasClass('inactive_stream'));
+ assert(social_sidebar.hasClass("inactive_stream"));
// pinned streams can never be made inactive
- const devel_sidebar = $('<devel sidebar row>');
+ const devel_sidebar = $("<devel sidebar row>");
stream_id = devel.stream_id;
row = stream_list.stream_sidebar.get_row(stream_id);
stream_data.is_active = return_false;
stream_list.build_stream_list();
- assert(!devel_sidebar.hasClass('inactive_stream'));
+ assert(!devel_sidebar.hasClass("inactive_stream"));
row.update_whether_active();
- assert(!devel_sidebar.hasClass('inactive_stream'));
+ assert(!devel_sidebar.hasClass("inactive_stream"));
});
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
function add_row(sub) {
global.stream_data.add_sub(sub);
const row = {
update_whether_active: function () {},
get_li: function () {
- const html = '<' + sub.name + ' sidebar row html>';
+ const html = "<" + sub.name + " sidebar row html>";
const obj = $(html);
obj.length = 1; // bypass blueslip error
@@ -242,27 +242,27 @@ function initialize_stream_data() {
// pinned streams
const develSub = {
- name: 'devel',
+ name: "devel",
stream_id: 1000,
- color: 'blue',
+ color: "blue",
pin_to_top: true,
subscribed: true,
};
add_row(develSub);
const RomeSub = {
- name: 'Rome',
+ name: "Rome",
stream_id: 2000,
- color: 'blue',
+ color: "blue",
pin_to_top: true,
subscribed: true,
};
add_row(RomeSub);
const testSub = {
- name: 'test',
+ name: "test",
stream_id: 3000,
- color: 'blue',
+ color: "blue",
pin_to_top: true,
subscribed: true,
};
@@ -270,27 +270,27 @@ function initialize_stream_data() {
// unpinned streams
const announceSub = {
- name: 'announce',
+ name: "announce",
stream_id: 4000,
- color: 'green',
+ color: "green",
pin_to_top: false,
subscribed: true,
};
add_row(announceSub);
const DenmarkSub = {
- name: 'Denmark',
+ name: "Denmark",
stream_id: 5000,
- color: 'green',
+ color: "green",
pin_to_top: false,
subscribed: true,
};
add_row(DenmarkSub);
const carSub = {
- name: 'cars',
+ name: "cars",
stream_id: 6000,
- color: 'green',
+ color: "green",
pin_to_top: false,
subscribed: true,
};
@@ -301,9 +301,9 @@ function elem($obj) {
return {to_$: () => $obj};
}
-run_test('zoom_in_and_zoom_out', () => {
- const label1 = $.create('label1 stub');
- const label2 = $.create('label2 stub');
+run_test("zoom_in_and_zoom_out", () => {
+ const label1 = $.create("label1 stub");
+ const label2 = $.create("label2 stub");
label1.show();
label2.show();
@@ -311,39 +311,39 @@ run_test('zoom_in_and_zoom_out', () => {
assert(label1.visible());
assert(label2.visible());
- $('.stream-filters-label').each = (f) => {
+ $(".stream-filters-label").each = (f) => {
f.call(elem(label1));
f.call(elem(label2));
};
- const splitter = $.create('hr stub');
+ const splitter = $.create("hr stub");
splitter.show();
assert(splitter.visible());
- $('.stream-split').each = (f) => {
+ $(".stream-split").each = (f) => {
f.call(elem(splitter));
};
- const stream_li1 = $.create('stream1 stub');
- const stream_li2 = $.create('stream2 stub');
+ const stream_li1 = $.create("stream1 stub");
+ const stream_li2 = $.create("stream2 stub");
function make_attr(arg) {
return (sel) => {
- assert.equal(sel, 'data-stream-id');
+ assert.equal(sel, "data-stream-id");
return arg;
};
}
- stream_li1.attr = make_attr('42');
+ stream_li1.attr = make_attr("42");
stream_li1.hide();
- stream_li2.attr = make_attr('99');
+ stream_li2.attr = make_attr("99");
- $('#stream_filters li.narrow-filter').each = (f) => {
+ $("#stream_filters li.narrow-filter").each = (f) => {
f.call(elem(stream_li1));
f.call(elem(stream_li2));
};
- $('#stream-filters-container')[0] = {
+ $("#stream-filters-container")[0] = {
dataset: {},
};
stream_list.set_event_handlers();
@@ -355,9 +355,9 @@ run_test('zoom_in_and_zoom_out', () => {
assert(!splitter.visible());
assert(stream_li1.visible());
assert(!stream_li2.visible());
- assert($('#streams_list').hasClass('zoom-in'));
+ assert($("#streams_list").hasClass("zoom-in"));
- $('#stream_filters li.narrow-filter').show = () => {
+ $("#stream_filters li.narrow-filter").show = () => {
stream_li1.show();
stream_li2.show();
};
@@ -370,16 +370,16 @@ run_test('zoom_in_and_zoom_out', () => {
assert(splitter.visible());
assert(stream_li1.visible());
assert(stream_li2.visible());
- assert($('#streams_list').hasClass('zoom-out'));
+ assert($("#streams_list").hasClass("zoom-out"));
});
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
-run_test('narrowing', () => {
+run_test("narrowing", () => {
initialize_stream_data();
- set_global('narrow_state', {
- stream: function () { return 'devel'; },
+ set_global("narrow_state", {
+ stream: function () { return "devel"; },
topic: noop,
});
@@ -389,36 +389,36 @@ run_test('narrowing', () => {
topic_list.get_stream_li = noop;
scroll_util.scroll_element_into_container = noop;
- set_global('ui', {
+ set_global("ui", {
get_scroll_element: (element) => element,
});
- assert(!$('<devel sidebar row html>').hasClass('active-filter'));
+ assert(!$("<devel sidebar row html>").hasClass("active-filter"));
stream_list.set_event_handlers();
let filter;
filter = new Filter([
- {operator: 'stream', operand: 'devel'},
+ {operator: "stream", operand: "devel"},
]);
stream_list.handle_narrow_activated(filter);
- assert($('<devel sidebar row html>').hasClass('active-filter'));
+ assert($("<devel sidebar row html>").hasClass("active-filter"));
filter = new Filter([
- {operator: 'stream', operand: 'cars'},
- {operator: 'topic', operand: 'sedans'},
+ {operator: "stream", operand: "cars"},
+ {operator: "topic", operand: "sedans"},
]);
stream_list.handle_narrow_activated(filter);
- assert(!$("ul.filters li").hasClass('active-filter'));
- assert(!$('<cars sidebar row html>').hasClass('active-filter')); // false because of topic
+ 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'},
+ {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'));
+ assert(!$("ul.filters li").hasClass("active-filter"));
+ assert($("<cars sidebar row html>").hasClass("active-filter"));
let removed_classes;
$("ul#stream_filters li").removeClass = (classes) => {
@@ -431,25 +431,25 @@ run_test('narrowing', () => {
};
stream_list.handle_narrow_deactivated();
- assert.equal(removed_classes, 'active-filter');
+ assert.equal(removed_classes, "active-filter");
assert(topics_closed);
});
-run_test('focusout_user_filter', () => {
+run_test("focusout_user_filter", () => {
const e = { };
- const click_handler = $('.stream-list-filter').get_on_handler('focusout');
+ const click_handler = $(".stream-list-filter").get_on_handler("focusout");
click_handler(e);
});
-run_test('focus_user_filter', () => {
+run_test("focus_user_filter", () => {
const e = {
stopPropagation: function () {},
};
- const click_handler = $('.stream-list-filter').get_on_handler('click');
+ const click_handler = $(".stream-list-filter").get_on_handler("click");
click_handler(e);
});
-run_test('sort_streams', () => {
+run_test("sort_streams", () => {
stream_data.clear_subscriptions();
// Get coverage on early-exit.
@@ -458,11 +458,11 @@ run_test('sort_streams', () => {
initialize_stream_data();
global.stream_data.is_active = function (sub) {
- return sub.name !== 'cars';
+ return sub.name !== "cars";
};
let appended_elems;
- $('#stream_filters').append = function (elems) {
+ $("#stream_filters").append = function (elems) {
appended_elems = elems;
};
@@ -470,14 +470,14 @@ run_test('sort_streams', () => {
const split = '<hr class="stream-split">';
const expected_elems = [
- $('<devel sidebar row html>'),
- $('<Rome sidebar row html>'),
- $('<test sidebar row html>'),
+ $("<devel sidebar row html>"),
+ $("<Rome sidebar row html>"),
+ $("<test sidebar row html>"),
split,
- $('<announce sidebar row html>'),
- $('<Denmark sidebar row html>'),
+ $("<announce sidebar row html>"),
+ $("<Denmark sidebar row html>"),
split,
- $('<cars sidebar row html>'),
+ $("<cars sidebar row html>"),
];
assert.deepEqual(appended_elems, expected_elems);
@@ -486,24 +486,24 @@ run_test('sort_streams', () => {
assert.deepEqual(streams, [
// three groups: pinned, normal, dormant
- 'devel',
- 'Rome',
- 'test',
+ "devel",
+ "Rome",
+ "test",
//
- 'announce',
- 'Denmark',
+ "announce",
+ "Denmark",
//
- 'cars',
+ "cars",
]);
- const denmark_sub = stream_data.get_sub('Denmark');
+ const denmark_sub = stream_data.get_sub("Denmark");
const stream_id = denmark_sub.stream_id;
assert(stream_list.stream_sidebar.has_row_for(stream_id));
stream_list.remove_sidebar_row(stream_id);
assert(!stream_list.stream_sidebar.has_row_for(stream_id));
});
-run_test('separators_only_pinned_and_dormant', () => {
+run_test("separators_only_pinned_and_dormant", () => {
// Test only pinned and dormant streams
@@ -514,38 +514,38 @@ run_test('separators_only_pinned_and_dormant', () => {
// pinned streams
const develSub = {
- name: 'devel',
+ name: "devel",
stream_id: 1000,
- color: 'blue',
+ color: "blue",
pin_to_top: true,
subscribed: true,
};
add_row(develSub);
const RomeSub = {
- name: 'Rome',
+ name: "Rome",
stream_id: 2000,
- color: 'blue',
+ color: "blue",
pin_to_top: true,
subscribed: true,
};
add_row(RomeSub);
// dormant stream
const DenmarkSub = {
- name: 'Denmark',
+ name: "Denmark",
stream_id: 3000,
- color: 'blue',
+ color: "blue",
pin_to_top: false,
subscribed: true,
};
add_row(DenmarkSub);
global.stream_data.is_active = function (sub) {
- return sub.name !== 'Denmark';
+ return sub.name !== "Denmark";
};
let appended_elems;
- $('#stream_filters').append = function (elems) {
+ $("#stream_filters").append = function (elems) {
appended_elems = elems;
};
@@ -554,18 +554,18 @@ run_test('separators_only_pinned_and_dormant', () => {
const split = '<hr class="stream-split">';
const expected_elems = [
// pinned
- $('<devel sidebar row html>'),
- $('<Rome sidebar row html>'),
+ $("<devel sidebar row html>"),
+ $("<Rome sidebar row html>"),
split,
// dormant
- $('<Denmark sidebar row html>'),
+ $("<Denmark sidebar row html>"),
];
assert.deepEqual(appended_elems, expected_elems);
});
-run_test('separators_only_pinned', () => {
+run_test("separators_only_pinned", () => {
// Test only pinned streams
@@ -576,25 +576,25 @@ run_test('separators_only_pinned', () => {
// pinned streams
const develSub = {
- name: 'devel',
+ name: "devel",
stream_id: 1000,
- color: 'blue',
+ color: "blue",
pin_to_top: true,
subscribed: true,
};
add_row(develSub);
const RomeSub = {
- name: 'Rome',
+ name: "Rome",
stream_id: 2000,
- color: 'blue',
+ color: "blue",
pin_to_top: true,
subscribed: true,
};
add_row(RomeSub);
let appended_elems;
- $('#stream_filters').append = function (elems) {
+ $("#stream_filters").append = function (elems) {
appended_elems = elems;
};
@@ -602,8 +602,8 @@ run_test('separators_only_pinned', () => {
const expected_elems = [
// pinned
- $('<devel sidebar row html>'),
- $('<Rome sidebar row html>'),
+ $("<devel sidebar row html>"),
+ $("<Rome sidebar row html>"),
// no separator at the end as no stream follows
];
@@ -611,27 +611,27 @@ run_test('separators_only_pinned', () => {
});
-run_test('update_count_in_dom', () => {
+run_test("update_count_in_dom", () => {
function make_elem(elem, count_selector, value_selector) {
const count = $(count_selector);
const value = $(value_selector);
- elem.set_find_results('.count', count);
- count.set_find_results('.value', value);
+ elem.set_find_results(".count", count);
+ count.set_find_results(".value", value);
count.set_parent(elem);
return elem;
}
const stream_li = make_elem(
- $('<stream li>'),
- '<stream-count>',
- '<stream-value>',
+ $("<stream li>"),
+ "<stream-count>",
+ "<stream-value>",
);
- $('<stream li>').length = 0;
- stream_li.addClass('subscription_block');
- stream_li.addClass('stream-with-count');
- assert(stream_li.hasClass('stream-with-count'));
+ $("<stream li>").length = 0;
+ stream_li.addClass("subscription_block");
+ stream_li.addClass("stream-with-count");
+ assert(stream_li.hasClass("stream-with-count"));
const stream_count = new Map();
const stream_id = 11;
@@ -649,33 +649,33 @@ run_test('update_count_in_dom', () => {
};
stream_list.update_dom_with_unread_counts(counts);
- assert.equal($('<stream li>').text(), 'never-been-set');
- assert(!stream_li.hasClass('stream-with-count'));
+ assert.equal($("<stream li>").text(), "never-been-set");
+ assert(!stream_li.hasClass("stream-with-count"));
stream_count.set(stream_id, 99);
stream_list.update_dom_with_unread_counts(counts);
- assert.equal($('<stream-value>').text(), '99');
- assert(stream_li.hasClass('stream-with-count'));
+ assert.equal($("<stream-value>").text(), "99");
+ assert(stream_li.hasClass("stream-with-count"));
});
narrow_state.active = () => false;
-run_test('rename_stream', () => {
- const sub = stream_data.get_sub_by_name('devel');
- const new_name = 'Development';
+run_test("rename_stream", () => {
+ const sub = stream_data.get_sub_by_name("devel");
+ const new_name = "Development";
stream_data.rename_sub(sub, new_name);
- const li_stub = $.create('li stub');
+ const li_stub = $.create("li stub");
li_stub.length = 0;
global.stub_templates((name, payload) => {
- assert.equal(name, 'stream_sidebar_row');
+ assert.equal(name, "stream_sidebar_row");
assert.deepEqual(payload, {
- name: 'Development',
+ name: "Development",
id: 1000,
- uri: '#narrow/stream/1000-Development',
+ uri: "#narrow/stream/1000-Development",
is_muted: false,
invite_only: undefined,
is_web_public: undefined,
@@ -696,15 +696,15 @@ run_test('rename_stream', () => {
assert(count_updated);
});
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
-run_test('refresh_pin', () => {
+run_test("refresh_pin", () => {
initialize_stream_data();
const sub = {
- name: 'maybe_pin',
+ name: "maybe_pin",
stream_id: 100,
- color: 'blue',
+ color: "blue",
pin_to_top: false,
};
@@ -715,13 +715,13 @@ run_test('refresh_pin', () => {
pin_to_top: true,
};
- const li_stub = $.create('li stub');
+ const li_stub = $.create("li stub");
li_stub.length = 0;
global.stub_templates(() => ({to_$: () => li_stub}));
stream_list.update_count_in_dom = noop;
- $('#stream_filters').append = noop;
+ $("#stream_filters").append = noop;
let scrolled;
stream_list.scroll_stream_into_view = (li) => {
@@ -733,7 +733,7 @@ run_test('refresh_pin', () => {
assert(scrolled);
});
-run_test('create_initial_sidebar_rows', () => {
+run_test("create_initial_sidebar_rows", () => {
initialize_stream_data();
const html_dict = new Map();
@@ -748,13 +748,13 @@ run_test('create_initial_sidebar_rows', () => {
stream_list.update_count_in_dom = noop;
global.stub_templates((template_name, data) => {
- assert.equal(template_name, 'stream_sidebar_row');
- return '<div>stub-html-' + data.name;
+ assert.equal(template_name, "stream_sidebar_row");
+ return "<div>stub-html-" + data.name;
});
// Test this code with stubs above...
stream_list.create_initial_sidebar_rows();
- assert.equal(html_dict.get(1000), '<div>stub-html-devel');
- assert.equal(html_dict.get(5000), '<div>stub-html-Denmark');
+ assert.equal(html_dict.get(1000), "<div>stub-html-devel");
+ assert.equal(html_dict.get(5000), "<div>stub-html-Denmark");
});
diff --git a/frontend_tests/node_tests/stream_search.js b/frontend_tests/node_tests/stream_search.js
index 71962fb6188..edee4552f4c 100644
--- a/frontend_tests/node_tests/stream_search.js
+++ b/frontend_tests/node_tests/stream_search.js
@@ -1,21 +1,21 @@
// This tests the stream searching functionality which currently
// lives in stream_list.js.
-set_global('$', global.make_zjquery());
-zrequire('stream_list');
+set_global("$", global.make_zjquery());
+zrequire("stream_list");
const noop = () => {};
-set_global('resize', {
+set_global("resize", {
resize_page_components: noop,
resize_stream_filters_container: noop,
});
-set_global('popovers', {});
-set_global('stream_popover', {});
+set_global("popovers", {});
+set_global("stream_popover", {});
function expand_sidebar() {
- $('.app-main .column-left').addClass('expanded');
+ $(".app-main .column-left").addClass("expanded");
}
function make_cursor_helper() {
@@ -23,10 +23,10 @@ function make_cursor_helper() {
stream_list.stream_cursor = {
reset: () => {
- events.push('reset');
+ events.push("reset");
},
clear: () => {
- events.push('clear');
+ events.push("clear");
},
};
@@ -39,11 +39,11 @@ function simulate_search_expanded() {
// The way we check if the search widget is expanded
// is kind of awkward.
- $('.stream_search_section.notdisplayed').length = 0;
+ $(".stream_search_section.notdisplayed").length = 0;
}
function simulate_search_collapsed() {
- $('.stream_search_section.notdisplayed').length = 1;
+ $(".stream_search_section.notdisplayed").length = 1;
}
function toggle_filter() {
@@ -54,18 +54,18 @@ function clear_search_input() {
stream_list.clear_search({stopPropagation: noop});
}
-run_test('basics', () => {
+run_test("basics", () => {
let cursor_helper;
- const input = $('.stream-list-filter');
- const section = $('.stream_search_section');
+ const input = $(".stream-list-filter");
+ const section = $(".stream_search_section");
expand_sidebar();
- section.addClass('notdisplayed');
+ section.addClass("notdisplayed");
cursor_helper = make_cursor_helper();
function verify_expanded() {
- assert(!section.hasClass('notdisplayed'));
+ assert(!section.hasClass("notdisplayed"));
simulate_search_expanded();
}
@@ -80,7 +80,7 @@ run_test('basics', () => {
}
function verify_collapsed() {
- assert(section.hasClass('notdisplayed'));
+ assert(section.hasClass("notdisplayed"));
assert(!input.is_focused());
assert(!stream_list.searching());
simulate_search_collapsed();
@@ -101,7 +101,7 @@ run_test('basics', () => {
verify_expanded();
verify_focused();
- assert.deepEqual(cursor_helper.events, ['reset']);
+ assert.deepEqual(cursor_helper.events, ["reset"]);
// Collapse the widget.
cursor_helper = make_cursor_helper();
@@ -109,7 +109,7 @@ run_test('basics', () => {
toggle_filter();
verify_collapsed();
- assert.deepEqual(cursor_helper.events, ['clear']);
+ assert.deepEqual(cursor_helper.events, ["clear"]);
// Expand the widget.
toggle_filter();
@@ -118,13 +118,13 @@ run_test('basics', () => {
(function add_some_text_and_collapse() {
cursor_helper = make_cursor_helper();
- input.val('foo');
+ input.val("foo");
verify_list_updated(() => {
toggle_filter();
});
verify_collapsed();
- assert.deepEqual(cursor_helper.events, ['reset', 'clear']);
+ assert.deepEqual(cursor_helper.events, ["reset", "clear"]);
}());
// Expand the widget.
@@ -141,7 +141,7 @@ run_test('basics', () => {
stream_list.initiate_search();
// Clear a non-empty search.
- input.val('foo');
+ input.val("foo");
verify_list_updated(() => {
clear_search_input();
});
@@ -152,7 +152,7 @@ run_test('basics', () => {
stream_list.initiate_search();
// Escape a non-empty search.
- input.val('foo');
+ input.val("foo");
stream_list.escape_search();
verify_blurred();
@@ -161,27 +161,27 @@ run_test('basics', () => {
stream_list.initiate_search();
// Escape an empty search.
- input.val('');
+ input.val("");
stream_list.escape_search();
verify_collapsed();
});
-run_test('expanding_sidebar', () => {
- $('.app-main .column-left').removeClass('expanded');
+run_test("expanding_sidebar", () => {
+ $(".app-main .column-left").removeClass("expanded");
const events = [];
popovers.hide_all = () => {
- events.push('popovers.hide_all');
+ events.push("popovers.hide_all");
};
stream_popover.show_streamlist_sidebar = () => {
- events.push('stream_popover.show_streamlist_sidebar');
+ events.push("stream_popover.show_streamlist_sidebar");
};
stream_list.initiate_search();
assert.deepEqual(events, [
- 'popovers.hide_all',
- 'stream_popover.show_streamlist_sidebar',
+ "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 696db98d2a3..4a8463f5820 100644
--- a/frontend_tests/node_tests/stream_sort.js
+++ b/frontend_tests/node_tests/stream_sort.js
@@ -1,40 +1,40 @@
-zrequire('stream_data');
-zrequire('stream_sort');
+zrequire("stream_data");
+zrequire("stream_sort");
const with_overrides = global.with_overrides;
-run_test('no_subscribed_streams', () => {
- assert.equal(stream_sort.sort_groups(''), undefined);
+run_test("no_subscribed_streams", () => {
+ assert.equal(stream_sort.sort_groups(""), undefined);
assert.equal(stream_sort.first_stream_id(), undefined);
});
const scalene = {
subscribed: true,
- name: 'scalene',
+ name: "scalene",
stream_id: 1,
pin_to_top: true,
};
const fast_tortoise = {
subscribed: true,
- name: 'fast tortoise',
+ name: "fast tortoise",
stream_id: 2,
pin_to_top: false,
};
const pneumonia = {
subscribed: true,
- name: 'pneumonia',
+ name: "pneumonia",
stream_id: 3,
pin_to_top: false,
};
const clarinet = {
subscribed: true,
- name: 'clarinet',
+ name: "clarinet",
stream_id: 4,
pin_to_top: false,
};
const weaving = {
subscribed: false,
- name: 'weaving',
+ name: "weaving",
stream_id: 5,
pin_to_top: false,
};
@@ -51,13 +51,13 @@ function sort_groups(query) {
}
with_overrides((override) => {
- override('stream_data.is_active', (sub) => sub.name !== "pneumonia");
+ override("stream_data.is_active", (sub) => sub.name !== "pneumonia");
// Test sorting into categories/alphabetized
let sorted = sort_groups("");
- assert.deepEqual(sorted.pinned_streams, ['scalene']);
- assert.deepEqual(sorted.normal_streams, ['clarinet', 'fast tortoise']);
- assert.deepEqual(sorted.dormant_streams, ['pneumonia']);
+ assert.deepEqual(sorted.pinned_streams, ["scalene"]);
+ assert.deepEqual(sorted.normal_streams, ["clarinet", "fast tortoise"]);
+ assert.deepEqual(sorted.dormant_streams, ["pneumonia"]);
// Test cursor helpers.
assert.equal(stream_sort.first_stream_id(), scalene.stream_id);
@@ -70,7 +70,7 @@ with_overrides((override) => {
// Test filtering
sorted = sort_groups("s");
- assert.deepEqual(sorted.pinned_streams, ['scalene']);
+ assert.deepEqual(sorted.pinned_streams, ["scalene"]);
assert.deepEqual(sorted.normal_streams, []);
assert.deepEqual(sorted.dormant_streams, []);
@@ -82,17 +82,17 @@ with_overrides((override) => {
sorted = sort_groups("PnEuMoNiA");
assert.deepEqual(sorted.pinned_streams, []);
assert.deepEqual(sorted.normal_streams, []);
- assert.deepEqual(sorted.dormant_streams, ['pneumonia']);
+ assert.deepEqual(sorted.dormant_streams, ["pneumonia"]);
// Test searching part of word
sorted = sort_groups("tortoise");
assert.deepEqual(sorted.pinned_streams, []);
- assert.deepEqual(sorted.normal_streams, ['fast tortoise']);
+ assert.deepEqual(sorted.normal_streams, ["fast tortoise"]);
assert.deepEqual(sorted.dormant_streams, []);
// Test searching stream with spaces
sorted = sort_groups("fast t");
assert.deepEqual(sorted.pinned_streams, []);
- assert.deepEqual(sorted.normal_streams, ['fast tortoise']);
+ assert.deepEqual(sorted.normal_streams, ["fast tortoise"]);
assert.deepEqual(sorted.dormant_streams, []);
});
diff --git a/frontend_tests/node_tests/stream_topic_history.js b/frontend_tests/node_tests/stream_topic_history.js
index c2dba5d8f03..b9c7c8e5c22 100644
--- a/frontend_tests/node_tests/stream_topic_history.js
+++ b/frontend_tests/node_tests/stream_topic_history.js
@@ -1,53 +1,53 @@
-zrequire('unread');
-zrequire('stream_data');
-zrequire('stream_topic_history');
+zrequire("unread");
+zrequire("stream_data");
+zrequire("stream_topic_history");
-set_global('channel', {});
-set_global('message_list', {});
+set_global("channel", {});
+set_global("message_list", {});
-run_test('basics', () => {
+run_test("basics", () => {
const stream_id = 55;
stream_topic_history.add_message({
stream_id: stream_id,
message_id: 101,
- topic_name: 'toPic1',
+ topic_name: "toPic1",
});
let history = stream_topic_history.get_recent_topic_names(stream_id);
let max_message_id = stream_topic_history.get_max_message_id(stream_id);
- assert.deepEqual(history, ['toPic1']);
+ assert.deepEqual(history, ["toPic1"]);
assert.deepEqual(max_message_id, 101);
stream_topic_history.add_message({
stream_id: stream_id,
message_id: 102,
- topic_name: 'Topic1',
+ topic_name: "Topic1",
});
history = stream_topic_history.get_recent_topic_names(stream_id);
max_message_id = stream_topic_history.get_max_message_id(stream_id);
- assert.deepEqual(history, ['Topic1']);
+ assert.deepEqual(history, ["Topic1"]);
assert.deepEqual(max_message_id, 102);
stream_topic_history.add_message({
stream_id: stream_id,
message_id: 103,
- topic_name: 'topic2',
+ topic_name: "topic2",
});
history = stream_topic_history.get_recent_topic_names(stream_id);
max_message_id = stream_topic_history.get_max_message_id(stream_id);
- assert.deepEqual(history, ['topic2', 'Topic1']);
+ assert.deepEqual(history, ["topic2", "Topic1"]);
assert.deepEqual(max_message_id, 103);
// Removing first topic1 message has no effect.
stream_topic_history.remove_messages({
stream_id: stream_id,
- topic_name: 'toPic1',
+ topic_name: "toPic1",
num_messages: 1,
});
history = stream_topic_history.get_recent_topic_names(stream_id);
- assert.deepEqual(history, ['topic2', 'Topic1']);
+ assert.deepEqual(history, ["topic2", "Topic1"]);
// Removing a topic message shouldn't effect the max_message_id.
max_message_id = stream_topic_history.get_max_message_id(stream_id);
assert.deepEqual(max_message_id, 103);
@@ -55,20 +55,20 @@ run_test('basics', () => {
// Removing second topic1 message removes the topic.
stream_topic_history.remove_messages({
stream_id: stream_id,
- topic_name: 'Topic1',
+ topic_name: "Topic1",
num_messages: 1,
});
history = stream_topic_history.get_recent_topic_names(stream_id);
- assert.deepEqual(history, ['topic2']);
+ assert.deepEqual(history, ["topic2"]);
// Test that duplicate remove does not crash us.
stream_topic_history.remove_messages({
stream_id: stream_id,
- topic_name: 'Topic1',
+ topic_name: "Topic1",
num_messages: 1,
});
history = stream_topic_history.get_recent_topic_names(stream_id);
- assert.deepEqual(history, ['topic2']);
+ assert.deepEqual(history, ["topic2"]);
// get to 100% coverage for defensive code
stream_topic_history.remove_messages({
@@ -77,9 +77,9 @@ run_test('basics', () => {
});
});
-run_test('is_complete_for_stream_id', () => {
+run_test("is_complete_for_stream_id", () => {
const sub = {
- name: 'devel',
+ name: "devel",
stream_id: 444,
first_message_id: 1000,
};
@@ -117,9 +117,9 @@ run_test('is_complete_for_stream_id', () => {
false);
});
-run_test('server_history', () => {
+run_test("server_history", () => {
const sub = {
- name: 'devel',
+ name: "devel",
stream_id: 66,
};
const stream_id = sub.stream_id;
@@ -134,14 +134,14 @@ run_test('server_history', () => {
stream_topic_history.add_message({
stream_id: stream_id,
message_id: 501,
- topic_name: 'local',
+ topic_name: "local",
});
function add_server_history() {
stream_topic_history.add_history(stream_id, [
- { name: 'local', max_id: 501 },
- { name: 'hist2', max_id: 31 },
- { name: 'hist1', max_id: 30 },
+ { name: "local", max_id: 501 },
+ { name: "hist2", max_id: 31 },
+ { name: "hist1", max_id: 30 },
]);
}
@@ -154,82 +154,82 @@ run_test('server_history', () => {
true);
let history = stream_topic_history.get_recent_topic_names(stream_id);
- assert.deepEqual(history, ['local', 'hist2', 'hist1']);
+ assert.deepEqual(history, ["local", "hist2", "hist1"]);
// If new activity comes in for historical messages,
// they can bump to the front of the list.
stream_topic_history.add_message({
stream_id: stream_id,
message_id: 502,
- topic_name: 'hist1',
+ topic_name: "hist1",
});
history = stream_topic_history.get_recent_topic_names(stream_id);
- assert.deepEqual(history, ['hist1', 'local', 'hist2']);
+ assert.deepEqual(history, ["hist1", "local", "hist2"]);
// server history is allowed to backdate hist1
add_server_history();
history = stream_topic_history.get_recent_topic_names(stream_id);
- assert.deepEqual(history, ['local', 'hist2', 'hist1']);
+ assert.deepEqual(history, ["local", "hist2", "hist1"]);
// Removing a local message removes the topic if we have
// our counts right.
stream_topic_history.remove_messages({
stream_id: stream_id,
- topic_name: 'local',
+ topic_name: "local",
num_messages: 1,
});
history = stream_topic_history.get_recent_topic_names(stream_id);
- assert.deepEqual(history, ['hist2', 'hist1']);
+ assert.deepEqual(history, ["hist2", "hist1"]);
// We can try to remove a historical message, but it should
// have no effect.
stream_topic_history.remove_messages({
stream_id: stream_id,
- topic_name: 'hist2',
+ topic_name: "hist2",
num_messages: 1,
});
history = stream_topic_history.get_recent_topic_names(stream_id);
- assert.deepEqual(history, ['hist2', 'hist1']);
+ assert.deepEqual(history, ["hist2", "hist1"]);
// If we call back to the server for history, the
// effect is always additive. We may decide to prune old
// topics in the future, if they dropped off due to renames,
// but that is probably an edge case we can ignore for now.
stream_topic_history.add_history(stream_id, [
- { name: 'hist2', max_id: 931 },
- { name: 'hist3', max_id: 5 },
+ { name: "hist2", max_id: 931 },
+ { name: "hist3", max_id: 5 },
]);
history = stream_topic_history.get_recent_topic_names(stream_id);
- assert.deepEqual(history, ['hist2', 'hist1', 'hist3']);
+ assert.deepEqual(history, ["hist2", "hist1", "hist3"]);
});
-run_test('test_unread_logic', () => {
+run_test("test_unread_logic", () => {
const stream_id = 77;
stream_topic_history.add_message({
stream_id: stream_id,
message_id: 201,
- topic_name: 'toPic1',
+ topic_name: "toPic1",
});
stream_topic_history.add_message({
stream_id: stream_id,
message_id: 45,
- topic_name: 'topic2',
+ topic_name: "topic2",
});
let history = stream_topic_history.get_recent_topic_names(stream_id);
- assert.deepEqual(history, ['toPic1', 'topic2']);
+ assert.deepEqual(history, ["toPic1", "topic2"]);
const msgs = [
- { id: 150, topic: 'TOPIC2' }, // will be ignored
- { id: 61, topic: 'unread1' },
- { id: 60, topic: 'unread1' },
- { id: 20, topic: 'UNREAD2' },
+ { id: 150, topic: "TOPIC2" }, // will be ignored
+ { id: 61, topic: "unread1" },
+ { id: 60, topic: "unread1" },
+ { id: 20, topic: "UNREAD2" },
];
for (const msg of msgs) {
- msg.type = 'stream';
+ msg.type = "stream";
msg.stream_id = stream_id;
msg.unread = true;
}
@@ -237,10 +237,10 @@ run_test('test_unread_logic', () => {
unread.process_loaded_messages(msgs);
history = stream_topic_history.get_recent_topic_names(stream_id);
- assert.deepEqual(history, ['toPic1', 'unread1', 'topic2', 'UNREAD2']);
+ assert.deepEqual(history, ["toPic1", "unread1", "topic2", "UNREAD2"]);
});
-run_test('test_stream_has_topics', () => {
+run_test("test_stream_has_topics", () => {
const stream_id = 88;
assert.equal(stream_topic_history.stream_has_topics(stream_id), false);
@@ -254,28 +254,28 @@ run_test('test_stream_has_topics', () => {
stream_topic_history.add_message({
stream_id: stream_id,
message_id: 888,
- topic_name: 'whatever',
+ topic_name: "whatever",
});
assert.equal(stream_topic_history.stream_has_topics(stream_id), true);
});
-run_test('server_history_end_to_end', () => {
+run_test("server_history_end_to_end", () => {
stream_topic_history.reset();
const stream_id = 99;
const topics = [
- { name: 'topic3', max_id: 501 },
- { name: 'topic2', max_id: 31 },
- { name: 'topic1', max_id: 30 },
+ { name: "topic3", max_id: 501 },
+ { name: "topic2", max_id: 31 },
+ { name: "topic1", max_id: 30 },
];
let get_success_callback;
let on_success_called;
channel.get = function (opts) {
- assert.equal(opts.url, '/json/users/me/99/topics');
+ assert.equal(opts.url, "/json/users/me/99/topics");
assert.deepEqual(opts.data, {});
get_success_callback = opts.success;
};
@@ -289,12 +289,12 @@ run_test('server_history_end_to_end', () => {
assert(on_success_called);
const history = stream_topic_history.get_recent_topic_names(stream_id);
- assert.deepEqual(history, ['topic3', 'topic2', 'topic1']);
+ assert.deepEqual(history, ["topic3", "topic2", "topic1"]);
// Try getting server history for a second time.
channel.get = () => {
- throw Error('We should not get more data.');
+ throw Error("We should not get more data.");
};
on_success_called = false;
diff --git a/frontend_tests/node_tests/submessage.js b/frontend_tests/node_tests/submessage.js
index a576e52da77..c13741eab8c 100644
--- a/frontend_tests/node_tests/submessage.js
+++ b/frontend_tests/node_tests/submessage.js
@@ -1,10 +1,10 @@
-zrequire('submessage');
+zrequire("submessage");
-set_global('channel', {});
-set_global('widgetize', {});
-set_global('message_store', {});
+set_global("channel", {});
+set_global("widgetize", {});
+set_global("message_store", {});
-run_test('get_message_events', () => {
+run_test("get_message_events", () => {
let msg = {};
assert.equal(submessage.get_message_events(msg), undefined);
@@ -15,8 +15,8 @@ run_test('get_message_events', () => {
assert.equal(submessage.get_message_events(msg), undefined);
const submessages = [
- {id: 222, sender_id: 99, content: '84'},
- {id: 9, sender_id: 33, content: '42'},
+ {id: 222, sender_id: 99, content: "84"},
+ {id: 9, sender_id: 33, content: "42"},
];
msg = {
@@ -34,7 +34,7 @@ run_test('get_message_events', () => {
]);
});
-run_test('make_server_callback', () => {
+run_test("make_server_callback", () => {
const message_id = 444;
const callback = submessage.make_server_callback(message_id);
let was_posted;
@@ -42,31 +42,31 @@ run_test('make_server_callback', () => {
channel.post = function (opts) {
was_posted = true;
assert.deepEqual(opts, {
- url: '/json/submessage',
+ url: "/json/submessage",
data: {
message_id: message_id,
- msg_type: 'whatever',
+ msg_type: "whatever",
content: '{"foo":32}',
},
});
};
callback({
- msg_type: 'whatever',
+ msg_type: "whatever",
data: {foo: 32},
});
assert(was_posted);
});
-run_test('handle_event', () => {
+run_test("handle_event", () => {
const message = {
id: 42,
};
const event = {
id: 11,
- msg_type: 'widget',
+ msg_type: "widget",
sender_id: 99,
message_id: message.id,
content: '"some_data"',
@@ -87,7 +87,7 @@ run_test('handle_event', () => {
assert.deepEqual(args, {
sender_id: 99,
message_id: 42,
- data: 'some_data',
+ data: "some_data",
});
assert.deepEqual(message.submessages[0], event);
diff --git a/frontend_tests/node_tests/subs.js b/frontend_tests/node_tests/subs.js
index defcb98d73f..460a05b9380 100644
--- a/frontend_tests/node_tests/subs.js
+++ b/frontend_tests/node_tests/subs.js
@@ -1,25 +1,25 @@
global.stub_out_jquery();
-set_global('ui', {
+set_global("ui", {
get_content_element: (element) => element,
get_scroll_element: (element) => element,
});
-zrequire('stream_data');
-zrequire('search_util');
-set_global('page_params', {});
+zrequire("stream_data");
+zrequire("search_util");
+set_global("page_params", {});
-set_global('location', {
+set_global("location", {
hash: "#streams/1/announce",
});
-zrequire('subs');
+zrequire("subs");
-set_global('$', global.make_zjquery());
-set_global('hash_util', {
+set_global("$", global.make_zjquery());
+set_global("hash_util", {
by_stream_uri: () => {},
});
-run_test('filter_table', () => {
+run_test("filter_table", () => {
const stream_list = $(".streams-list");
let scrolltop_called = false;
@@ -34,47 +34,47 @@ run_test('filter_table', () => {
// set-up sub rows stubs
const sub_row_data = [
{
- elem: 'denmark',
+ elem: "denmark",
subscribed: false,
- name: 'Denmark',
+ name: "Denmark",
stream_id: 1,
- description: 'Copenhagen',
+ description: "Copenhagen",
subscribers: {size: 1},
stream_weekly_traffic: null,
},
{
- elem: 'poland',
+ elem: "poland",
subscribed: true,
- name: 'Poland',
+ name: "Poland",
stream_id: 2,
- description: 'monday',
+ description: "monday",
subscribers: {size: 3},
stream_weekly_traffic: 13,
},
{
- elem: 'pomona',
+ elem: "pomona",
subscribed: true,
- name: 'Pomona',
+ name: "Pomona",
stream_id: 3,
- description: 'college',
+ description: "college",
subscribers: {size: 0},
stream_weekly_traffic: 0,
},
{
- elem: 'cpp',
+ elem: "cpp",
subscribed: true,
- name: 'C++',
+ name: "C++",
stream_id: 4,
- description: 'programming lang',
+ description: "programming lang",
subscribers: {size: 2},
stream_weekly_traffic: 6,
},
{
- elem: 'zzyzx',
+ elem: "zzyzx",
subscribed: true,
- name: 'Zzyzx',
+ name: "Zzyzx",
stream_id: 5,
- description: 'california town',
+ description: "california town",
subscribers: {size: 2},
stream_weekly_traffic: 6,
},
@@ -87,7 +87,7 @@ run_test('filter_table', () => {
let populated_subs;
global.stub_templates((fn, data) => {
- assert.equal(fn, 'subscriptions');
+ assert.equal(fn, "subscriptions");
populated_subs = data.subscriptions;
});
@@ -110,14 +110,14 @@ run_test('filter_table', () => {
$(".tooltip").tooltip = function (obj) {
tooltip_called = true;
assert.deepEqual(obj, {
- placement: 'left',
+ placement: "left",
animation: false,
});
};
$.stub_selector("#subscriptions_table .stream-row", sub_stubs);
- const sub_table = $('#subscriptions_table .streams-list');
+ const sub_table = $("#subscriptions_table .streams-list");
let sub_table_append = [];
sub_table.append = function (rows) {
sub_table_append.push(rows);
@@ -142,11 +142,11 @@ run_test('filter_table', () => {
assert(scrolltop_called);
assert(tooltip_called);
assert.deepEqual(sub_table_append, [
- '.stream-row-poland',
- '.stream-row-pomona',
- '.stream-row-cpp',
- '.stream-row-zzyzx',
- '.stream-row-denmark',
+ ".stream-row-poland",
+ ".stream-row-pomona",
+ ".stream-row-cpp",
+ ".stream-row-zzyzx",
+ ".stream-row-denmark",
]);
// Search with multiple keywords
@@ -206,55 +206,55 @@ run_test('filter_table', () => {
assert($(".stream-row-cpp").hasClass("notdisplayed"));
assert($(".stream-row-zzyzx").hasClass("notdisplayed"));
assert.deepEqual(sub_table_append, [
- '.stream-row-pomona',
- '.stream-row-poland',
- '.stream-row-cpp',
- '.stream-row-zzyzx',
- '.stream-row-denmark',
+ ".stream-row-pomona",
+ ".stream-row-poland",
+ ".stream-row-cpp",
+ ".stream-row-zzyzx",
+ ".stream-row-denmark",
]);
// Explicitly order streams by name
sub_table_append = [];
subs.filter_table({input: "", subscribed_only: false, sort_order: "by-stream-name"});
assert.deepEqual(sub_table_append, [
- '.stream-row-cpp',
- '.stream-row-denmark',
- '.stream-row-poland',
- '.stream-row-pomona',
- '.stream-row-zzyzx',
+ ".stream-row-cpp",
+ ".stream-row-denmark",
+ ".stream-row-poland",
+ ".stream-row-pomona",
+ ".stream-row-zzyzx",
]);
// Order streams by subscriber count
sub_table_append = [];
subs.filter_table({input: "", subscribed_only: false, sort_order: "by-subscriber-count"});
assert.deepEqual(sub_table_append, [
- '.stream-row-poland',
- '.stream-row-cpp',
- '.stream-row-zzyzx',
- '.stream-row-denmark',
- '.stream-row-pomona',
+ ".stream-row-poland",
+ ".stream-row-cpp",
+ ".stream-row-zzyzx",
+ ".stream-row-denmark",
+ ".stream-row-pomona",
]);
// Order streams by weekly traffic
sub_table_append = [];
subs.filter_table({input: "", subscribed_only: false, sort_order: "by-weekly-traffic"});
assert.deepEqual(sub_table_append, [
- '.stream-row-poland',
- '.stream-row-cpp',
- '.stream-row-zzyzx',
- '.stream-row-pomona',
- '.stream-row-denmark',
+ ".stream-row-poland",
+ ".stream-row-cpp",
+ ".stream-row-zzyzx",
+ ".stream-row-pomona",
+ ".stream-row-denmark",
]);
// Showing subscribed streams only puts un-subscribed DOM elements last
sub_table_append = [];
subs.filter_table({input: "", subscribed_only: true, sort_order: "by-subscriber-count"});
assert.deepEqual(sub_table_append, [
- '.stream-row-poland',
- '.stream-row-cpp',
- '.stream-row-zzyzx',
- '.stream-row-pomona',
- '.stream-row-denmark',
+ ".stream-row-poland",
+ ".stream-row-cpp",
+ ".stream-row-zzyzx",
+ ".stream-row-pomona",
+ ".stream-row-denmark",
]);
// active stream-row is not included in results
diff --git a/frontend_tests/node_tests/support.js b/frontend_tests/node_tests/support.js
index 89eaf476755..32c219be851 100644
--- a/frontend_tests/node_tests/support.js
+++ b/frontend_tests/node_tests/support.js
@@ -6,13 +6,13 @@ const document = dom.window.document;
let jquery_init;
global.$ = (f) => {jquery_init = f;};
-zrequire('support', "js/analytics/support");
-set_global('$', global.make_zjquery());
+zrequire("support", "js/analytics/support");
+set_global("$", global.make_zjquery());
-run_test('scrub_realm', () => {
+run_test("scrub_realm", () => {
jquery_init();
- const click_handler = $('body').get_on_handler('click', '.scrub-realm-button');
- assert.equal(typeof click_handler, 'function');
+ const click_handler = $("body").get_on_handler("click", ".scrub-realm-button");
+ assert.equal(typeof click_handler, "function");
assert.equal(document.querySelectorAll(".scrub-realm-button").length, 1);
});
diff --git a/frontend_tests/node_tests/timerender.js b/frontend_tests/node_tests/timerender.js
index 44968c034c8..b36af25f9a1 100644
--- a/frontend_tests/node_tests/timerender.js
+++ b/frontend_tests/node_tests/timerender.js
@@ -1,16 +1,16 @@
-set_global('$', global.make_zjquery());
-set_global('page_params', {
+set_global("$", global.make_zjquery());
+set_global("page_params", {
twenty_four_hour_time: true,
});
-set_global('moment', require('moment-timezone'));
-set_global('XDate', zrequire('XDate', 'xdate'));
-zrequire('timerender');
+set_global("moment", require("moment-timezone"));
+set_global("XDate", zrequire("XDate", "xdate"));
+zrequire("timerender");
-run_test('render_now_returns_today', () => {
+run_test("render_now_returns_today", () => {
const today = new XDate(1555091573000); // Friday 4/12/2019 5:52:53 PM (UTC+0)
const expected = {
- time_str: i18n.t('Today'),
- formal_time_str: 'Friday, April 12, 2019',
+ time_str: i18n.t("Today"),
+ formal_time_str: "Friday, April 12, 2019",
needs_update: true,
};
const actual = timerender.render_now(today, today);
@@ -19,12 +19,12 @@ run_test('render_now_returns_today', () => {
assert.equal(expected.needs_update, actual.needs_update);
});
-run_test('render_now_returns_yesterday', () => {
+run_test("render_now_returns_yesterday", () => {
const today = new XDate(1555091573000); // Friday 4/12/2019 5:52:53 PM (UTC+0)
const yesterday = today.clone().addDays(-1);
const expected = {
- time_str: i18n.t('Yesterday'),
- formal_time_str: 'Thursday, April 11, 2019',
+ time_str: i18n.t("Yesterday"),
+ formal_time_str: "Thursday, April 11, 2019",
needs_update: true,
};
const actual = timerender.render_now(yesterday, today);
@@ -33,12 +33,12 @@ run_test('render_now_returns_yesterday', () => {
assert.equal(expected.needs_update, actual.needs_update);
});
-run_test('render_now_returns_year', () => {
+run_test("render_now_returns_year", () => {
const today = new XDate(1555091573000); // Friday 4/12/2019 5:52:53 PM (UTC+0)
const year_ago = today.clone().addYears(-1);
const expected = {
- time_str: 'Apr 12, 2018',
- formal_time_str: 'Thursday, April 12, 2018',
+ time_str: "Apr 12, 2018",
+ formal_time_str: "Thursday, April 12, 2018",
needs_update: false,
};
const actual = timerender.render_now(year_ago, today);
@@ -47,12 +47,12 @@ run_test('render_now_returns_year', () => {
assert.equal(expected.needs_update, actual.needs_update);
});
-run_test('render_now_returns_month_and_day', () => {
+run_test("render_now_returns_month_and_day", () => {
const today = new XDate(1555091573000); // Friday 4/12/2019 5:52:53 PM (UTC+0)
const three_months_ago = today.clone().addMonths(-3, true);
const expected = {
- time_str: 'Jan 12',
- formal_time_str: 'Saturday, January 12, 2019',
+ time_str: "Jan 12",
+ formal_time_str: "Saturday, January 12, 2019",
needs_update: false,
};
const actual = timerender.render_now(three_months_ago, today);
@@ -61,12 +61,12 @@ run_test('render_now_returns_month_and_day', () => {
assert.equal(expected.needs_update, actual.needs_update);
});
-run_test('render_now_returns_year_with_year_boundary', () => {
+run_test("render_now_returns_year_with_year_boundary", () => {
const today = new XDate(1555091573000); // Friday 4/12/2019 5:52:53 PM (UTC+0)
const three_months_ago = today.clone().addMonths(-6, true);
const expected = {
- time_str: 'Oct 12, 2018',
- formal_time_str: 'Friday, October 12, 2018',
+ time_str: "Oct 12, 2018",
+ formal_time_str: "Friday, October 12, 2018",
needs_update: false,
};
const actual = timerender.render_now(three_months_ago, today);
@@ -75,13 +75,13 @@ run_test('render_now_returns_year_with_year_boundary', () => {
assert.equal(expected.needs_update, actual.needs_update);
});
-run_test('render_date_renders_time_html', () => {
+run_test("render_date_renders_time_html", () => {
const today = new XDate(1555091573000); // Friday 4/12/2019 5:52:53 PM (UTC+0)
const message_time = today.clone();
- const expected_html = i18n.t('Today');
+ const expected_html = i18n.t("Today");
const attrs = {};
- const span_stub = $('<span />');
+ const span_stub = $("<span />");
span_stub.attr = function (name, val) {
attrs[name] = val;
@@ -95,16 +95,16 @@ run_test('render_date_renders_time_html', () => {
const actual = timerender.render_date(message_time, undefined, today);
assert.equal(expected_html, actual.html());
- assert.equal(attrs.title, 'Friday, April 12, 2019');
- assert.equal(attrs.class, 'timerender0');
+ assert.equal(attrs.title, "Friday, April 12, 2019");
+ assert.equal(attrs.class, "timerender0");
});
-run_test('render_date_renders_time_above_html', () => {
+run_test("render_date_renders_time_above_html", () => {
const today = new XDate(1555091573000); // Friday 4/12/2019 5:52:53 PM (UTC+0)
const message_time = today.clone();
const message_time_above = today.clone().addDays(-1);
- const span_stub = $('<span />');
+ const span_stub = $("<span />");
let appended_val;
span_stub.append = function (val) {
@@ -114,30 +114,30 @@ run_test('render_date_renders_time_above_html', () => {
const expected = [
'<i class="date-direction fa fa-caret-up"></i>',
- i18n.t('Yesterday'),
+ i18n.t("Yesterday"),
'<hr class="date-line">',
'<i class="date-direction fa fa-caret-down"></i>',
- i18n.t('Today'),
+ i18n.t("Today"),
];
timerender.render_date(message_time, message_time_above, today);
assert.deepEqual(appended_val, expected);
});
-run_test('get_full_time', () => {
+run_test("get_full_time", () => {
const timestamp = 1495091573; // 5/18/2017 7:12:53 AM (UTC+0)
- const expected = '2017-05-18T07:12:53Z'; // ISO 8601 date format
+ const expected = "2017-05-18T07:12:53Z"; // ISO 8601 date format
const actual = timerender.get_full_time(timestamp);
assert.equal(expected, actual);
});
-run_test('get_timestamp_for_flatpickr', () => {
+run_test("get_timestamp_for_flatpickr", () => {
const unix_timestamp = 1495091573000; // 5/18/2017 7:12:53 AM (UTC+0)
- const iso_timestamp = '2017-05-18T07:12:53Z'; // ISO 8601 date format
+ const iso_timestamp = "2017-05-18T07:12:53Z"; // ISO 8601 date format
const func = timerender.get_timestamp_for_flatpickr;
// Freeze time for testing.
const date_now = Date.now;
- Date.now = () => new Date('2020-07-07T10:00:00Z').getTime();
+ Date.now = () => new Date("2020-07-07T10:00:00Z").getTime();
// Invalid timestamps should show current time.
assert.equal(func("random str").valueOf(), moment().valueOf());
@@ -149,75 +149,75 @@ run_test('get_timestamp_for_flatpickr', () => {
Date.now = date_now;
});
-run_test('absolute_time_12_hour', () => {
- set_global('page_params', {
+run_test("absolute_time_12_hour", () => {
+ set_global("page_params", {
twenty_four_hour_time: false,
});
// timestamp with hour > 12, same year
let timestamp = 1555091573000; // 4/12/2019 5:52:53 PM (UTC+0)
let today = new Date(timestamp);
- let expected = 'Apr 12 05:52 PM';
+ let expected = "Apr 12 05:52 PM";
let actual = timerender.absolute_time(timestamp, today);
assert.equal(expected, actual);
// timestamp with hour > 12, different year
today.setFullYear(today.getFullYear() + 1);
- expected = 'Apr 12, 2019 05:52 PM';
+ expected = "Apr 12, 2019 05:52 PM";
actual = timerender.absolute_time(timestamp, today);
assert.equal(expected, actual);
// timestamp with hour < 12, same year
timestamp = 1495091573000; // 5/18/2017 7:12:53 AM (UTC+0)
today = new Date(timestamp);
- expected = 'May 18 07:12 AM';
+ expected = "May 18 07:12 AM";
actual = timerender.absolute_time(timestamp, today);
assert.equal(expected, actual);
// timestamp with hour < 12, different year
today.setFullYear(today.getFullYear() + 1);
- expected = 'May 18, 2017 07:12 AM';
+ expected = "May 18, 2017 07:12 AM";
actual = timerender.absolute_time(timestamp, today);
assert.equal(expected, actual);
});
-run_test('absolute_time_24_hour', () => {
- set_global('page_params', {
+run_test("absolute_time_24_hour", () => {
+ set_global("page_params", {
twenty_four_hour_time: true,
});
// timestamp with hour > 12, same year
let timestamp = 1555091573000; // 4/12/2019 5:52:53 PM (UTC+0)
let today = new Date(timestamp);
- let expected = 'Apr 12 17:52';
+ let expected = "Apr 12 17:52";
let actual = timerender.absolute_time(timestamp, today);
assert.equal(expected, actual);
// timestamp with hour > 12, different year
today.setFullYear(today.getFullYear() + 1);
- expected = 'Apr 12, 2019 17:52';
+ expected = "Apr 12, 2019 17:52";
actual = timerender.absolute_time(timestamp, today);
assert.equal(expected, actual);
// timestamp with hour < 12, same year
timestamp = 1495091573000; // 5/18/2017 7:12:53 AM (UTC+0)
today = new Date(timestamp);
- expected = 'May 18 07:12';
+ expected = "May 18 07:12";
actual = timerender.absolute_time(timestamp, today);
assert.equal(expected, actual);
// timestamp with hour < 12, different year
today.setFullYear(today.getFullYear() + 1);
- expected = 'May 18, 2017 07:12';
+ expected = "May 18, 2017 07:12";
actual = timerender.absolute_time(timestamp, today);
assert.equal(expected, actual);
});
-run_test('set_full_datetime', () => {
+run_test("set_full_datetime", () => {
const message = {
timestamp: 1495091573, // 2017/5/18 7:12:53 AM (UTC+0)
};
- const time_element = $('<span/>');
+ const time_element = $("<span/>");
const attrs = {};
time_element.attr = function (name, val) {
@@ -233,7 +233,7 @@ run_test('set_full_datetime', () => {
assert.equal(expected, attrs.title);
});
-run_test('last_seen_status_from_date', () => {
+run_test("last_seen_status_from_date", () => {
// Set base_dateto to March 1 2016 12.30 AM (months are zero based)
let base_date = new XDate(2016, 2, 1, 0, 30);
@@ -291,20 +291,20 @@ run_test('last_seen_status_from_date', () => {
});
-run_test('set_full_datetime', () => {
+run_test("set_full_datetime", () => {
let time = new XDate(1549958107000); // Tuesday 2/12/2019 07:55:07 AM (UTC+0)
let time_str = timerender.stringify_time(time);
- let expected = '07:55';
+ let expected = "07:55";
assert.equal(expected, time_str);
page_params.twenty_four_hour_time = false;
time_str = timerender.stringify_time(time);
- expected = '7:55 AM';
+ expected = "7:55 AM";
assert.equal(expected, time_str);
time = new XDate(1549979707000); // Tuesday 2/12/2019 13:55:07 PM (UTC+0)
page_params.twenty_four_hour_time = false;
time_str = timerender.stringify_time(time);
- expected = '1:55 PM';
+ expected = "1:55 PM";
assert.equal(expected, time_str);
});
diff --git a/frontend_tests/node_tests/top_left_corner.js b/frontend_tests/node_tests/top_left_corner.js
index 6c5b6db5513..bddc5b9c9d4 100644
--- a/frontend_tests/node_tests/top_left_corner.js
+++ b/frontend_tests/node_tests/top_left_corner.js
@@ -1,38 +1,38 @@
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
-zrequire('Filter', 'js/filter');
-zrequire('unread_ui');
-zrequire('people');
+zrequire("Filter", "js/filter");
+zrequire("unread_ui");
+zrequire("people");
-zrequire('top_left_corner');
+zrequire("top_left_corner");
-run_test('narrowing', () => {
+run_test("narrowing", () => {
// activating narrow
let pm_expanded;
let pm_closed;
- set_global('pm_list', {
+ set_global("pm_list", {
close: function () { pm_closed = true; },
expand: function () { pm_expanded = true; },
});
assert(!pm_expanded);
let filter = new Filter([
- {operator: 'is', operand: 'private'},
+ {operator: "is", operand: "private"},
]);
top_left_corner.handle_narrow_activated(filter);
assert(pm_expanded);
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 1,
- full_name: 'Alice Smith',
+ full_name: "Alice Smith",
};
const bob = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 2,
- full_name: 'Bob Patel',
+ full_name: "Bob Patel",
};
people.add_active_user(alice);
@@ -40,61 +40,61 @@ run_test('narrowing', () => {
pm_expanded = false;
filter = new Filter([
- {operator: 'pm-with', operand: '[email protected]'},
+ {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]'},
+ {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]'},
+ {operator: "pm-with", operand: "[email protected]"},
]);
top_left_corner.handle_narrow_activated(filter);
assert(!pm_expanded);
filter = new Filter([
- {operator: 'is', operand: 'mentioned'},
+ {operator: "is", operand: "mentioned"},
]);
top_left_corner.handle_narrow_activated(filter);
- assert($('.top_left_mentions').hasClass('active-filter'));
+ assert($(".top_left_mentions").hasClass("active-filter"));
filter = new Filter([
- {operator: 'is', operand: 'starred'},
+ {operator: "is", operand: "starred"},
]);
top_left_corner.handle_narrow_activated(filter);
- assert($('.top_left_starred_messages').hasClass('active-filter'));
+ assert($(".top_left_starred_messages").hasClass("active-filter"));
filter = new Filter([
- {operator: 'in', operand: 'home'},
+ {operator: "in", operand: "home"},
]);
top_left_corner.handle_narrow_activated(filter);
- assert($('.top_left_all_messages').hasClass('active-filter'));
+ assert($(".top_left_all_messages").hasClass("active-filter"));
// deactivating narrow
pm_closed = false;
top_left_corner.handle_narrow_deactivated();
- assert($('.top_left_all_messages').hasClass('active-filter'));
- assert(!$('.top_left_mentions').hasClass('active-filter'));
- assert(!$('.top_left_private_messages').hasClass('active-filter'));
- assert(!$('.top_left_starred_messages').hasClass('active-filter'));
+ assert($(".top_left_all_messages").hasClass("active-filter"));
+ assert(!$(".top_left_mentions").hasClass("active-filter"));
+ assert(!$(".top_left_private_messages").hasClass("active-filter"));
+ assert(!$(".top_left_starred_messages").hasClass("active-filter"));
assert(pm_closed);
});
-run_test('update_count_in_dom', () => {
+run_test("update_count_in_dom", () => {
function make_elem(elem, count_selector, value_selector) {
const count = $(count_selector);
const value = $(value_selector);
- elem.set_find_results('.count', count);
- count.set_find_results('.value', value);
+ elem.set_find_results(".count", count);
+ count.set_find_results(".value", value);
count.set_parent(elem);
return elem;
@@ -107,34 +107,34 @@ run_test('update_count_in_dom', () => {
make_elem(
$(".top_left_mentions"),
- '<mentioned-count>',
- '<mentioned-value>',
+ "<mentioned-count>",
+ "<mentioned-value>",
);
make_elem(
$(".top_left_all_messages"),
- '<home-count>',
- '<home-value>',
+ "<home-count>",
+ "<home-value>",
);
make_elem(
$(".top_left_starred_messages"),
- '<starred-count>',
- '<starred-value>',
+ "<starred-count>",
+ "<starred-value>",
);
top_left_corner.update_dom_with_unread_counts(counts);
top_left_corner.update_starred_count(444);
- assert.equal($('<mentioned-value>').text(), '222');
- assert.equal($('<home-value>').text(), '333');
- assert.equal($('<starred-value>').text(), '444');
+ assert.equal($("<mentioned-value>").text(), "222");
+ assert.equal($("<home-value>").text(), "333");
+ assert.equal($("<starred-value>").text(), "444");
counts.mentioned_message_count = 0;
top_left_corner.update_dom_with_unread_counts(counts);
top_left_corner.update_starred_count(0);
- assert(!$('<mentioned-count>').visible());
- assert.equal($('<mentioned-value>').text(), '');
- assert.equal($('<starred-value>').text(), '');
+ assert(!$("<mentioned-count>").visible());
+ assert.equal($("<mentioned-value>").text(), "");
+ assert.equal($("<starred-value>").text(), "");
});
diff --git a/frontend_tests/node_tests/topic_generator.js b/frontend_tests/node_tests/topic_generator.js
index 70e4b02198d..3eb79145909 100644
--- a/frontend_tests/node_tests/topic_generator.js
+++ b/frontend_tests/node_tests/topic_generator.js
@@ -1,18 +1,18 @@
-set_global('pm_conversations', {
+set_global("pm_conversations", {
recent: {},
});
-zrequire('muting');
-zrequire('unread');
-zrequire('stream_data');
-zrequire('stream_topic_history');
-zrequire('stream_sort');
-const tg = zrequire('topic_generator');
+zrequire("muting");
+zrequire("unread");
+zrequire("stream_data");
+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; }
-run_test('basics', () => {
+run_test("basics", () => {
let gen = tg.list_generator([10, 20, 30]);
assert.equal(gen.next(), 10);
assert.equal(gen.next(), 20);
@@ -79,7 +79,7 @@ run_test('basics', () => {
assert.equal(gen.next(), 200);
});
-run_test('reverse', () => {
+run_test("reverse", () => {
let gen = tg.reverse_list_generator([10, 20, 30]);
assert.equal(gen.next(), 30);
assert.equal(gen.next(), 20);
@@ -96,7 +96,7 @@ run_test('reverse', () => {
assert.equal(gen.next(), undefined);
assert.equal(gen.next(), undefined);
- gen = tg.reverse_wrap_exclude([10, 20, 30], 'whatever');
+ gen = tg.reverse_wrap_exclude([10, 20, 30], "whatever");
assert.equal(gen.next(), 30);
assert.equal(gen.next(), 20);
assert.equal(gen.next(), 10);
@@ -140,7 +140,7 @@ run_test('reverse', () => {
assert.equal(gen.next(), undefined);
});
-run_test('fchain', () => {
+run_test("fchain", () => {
const mults = function (n) {
let ret = 0;
return {
@@ -176,50 +176,50 @@ run_test('fchain', () => {
return;
};
- blueslip.expect('error', 'Invalid generator returned.');
+ blueslip.expect("error", "Invalid generator returned.");
ints = tg.list_generator([29, 43]);
gen = tg.fchain(ints, undef);
gen.next();
});
-run_test('streams', () => {
+run_test("streams", () => {
function assert_next_stream(curr_stream, expected) {
const actual = tg.get_next_stream(curr_stream);
assert.equal(actual, expected);
}
global.stream_sort.get_streams = function () {
- return ['announce', 'muted', 'devel', 'test here'];
+ return ["announce", "muted", "devel", "test here"];
};
- assert_next_stream(undefined, 'announce');
- assert_next_stream('NOT THERE', 'announce');
+ assert_next_stream(undefined, "announce");
+ assert_next_stream("NOT THERE", "announce");
- assert_next_stream('announce', 'muted');
- assert_next_stream('test here', 'announce');
+ assert_next_stream("announce", "muted");
+ assert_next_stream("test here", "announce");
function assert_prev_stream(curr_stream, expected) {
const actual = tg.get_prev_stream(curr_stream);
assert.equal(actual, expected);
}
- assert_prev_stream(undefined, 'test here');
- assert_prev_stream('test here', 'devel');
- assert_prev_stream('announce', 'test here');
+ assert_prev_stream(undefined, "test here");
+ assert_prev_stream("test here", "devel");
+ assert_prev_stream("announce", "test here");
});
-run_test('topics', () => {
+run_test("topics", () => {
const streams = [1, 2, 3, 4];
const topics = new Map([
- [1, ['read', 'read', '1a', '1b', 'read', '1c']],
+ [1, ["read", "read", "1a", "1b", "read", "1c"]],
[2, []],
- [3, ['3a', 'read', 'read', '3b', 'read']],
- [4, ['4a']],
+ [3, ["3a", "read", "read", "3b", "read"]],
+ [4, ["4a"]],
]);
function has_unread_messages(stream, topic) {
- return topic !== 'read';
+ return topic !== "read";
}
function get_topics(stream) {
@@ -235,24 +235,24 @@ run_test('topics', () => {
curr_topic);
}
- assert.deepEqual(next_topic(1, '1a'),
- {stream: 1, topic: '1b'});
+ 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'});
+ {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'});
+ {stream: 1, topic: "1a"});
// Now test the deeper function that is wired up to
// real functions stream_data/stream_sort/unread.
global.stream_sort.get_streams = function () {
- return ['announce', 'muted', 'devel', 'test here'];
+ return ["announce", "muted", "devel", "test here"];
};
const muted_stream_id = 400;
@@ -266,9 +266,9 @@ 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'];
+ return ["ms-topic1", "ms-topic2"];
case devel_stream_id:
- return ['muted', 'python'];
+ return ["muted", "python"];
}
return [];
@@ -279,7 +279,7 @@ run_test('topics', () => {
};
global.stream_data.is_stream_muted_by_name = function (stream_name) {
- return stream_name === 'muted';
+ return stream_name === "muted";
};
global.unread.topic_has_any_unread = function (stream_id) {
@@ -287,44 +287,44 @@ run_test('topics', () => {
};
global.muting.is_topic_muted = function (stream_name, topic) {
- return topic === 'muted';
+ return topic === "muted";
};
- let next_item = tg.get_next_topic('announce', 'whatever');
+ let next_item = tg.get_next_topic("announce", "whatever");
assert.deepEqual(next_item, {
- stream: 'devel',
- topic: 'python',
+ stream: "devel",
+ topic: "python",
});
- next_item = tg.get_next_topic('muted', undefined);
+ next_item = tg.get_next_topic("muted", undefined);
assert.deepEqual(next_item, {
- stream: 'muted',
- topic: 'ms-topic1',
+ stream: "muted",
+ topic: "ms-topic1",
});
});
-run_test('get_next_unread_pm_string', () => {
+run_test("get_next_unread_pm_string", () => {
pm_conversations.recent.get_strings = function () {
- return ['1', 'read', '2,3', '4', 'unk'];
+ return ["1", "read", "2,3", "4", "unk"];
};
unread.num_unread_for_person = function (user_ids_string) {
- if (user_ids_string === 'unk') {
+ if (user_ids_string === "unk") {
return;
}
- if (user_ids_string === 'read') {
+ if (user_ids_string === "read") {
return 0;
}
return 5; // random non-zero value
};
- assert.equal(tg.get_next_unread_pm_string(), '1');
- assert.equal(tg.get_next_unread_pm_string('4'), '1');
- assert.equal(tg.get_next_unread_pm_string('unk'), '1');
- assert.equal(tg.get_next_unread_pm_string('4'), '1');
- assert.equal(tg.get_next_unread_pm_string('1'), '2,3');
- assert.equal(tg.get_next_unread_pm_string('read'), '2,3');
- assert.equal(tg.get_next_unread_pm_string('2,3'), '4');
+ assert.equal(tg.get_next_unread_pm_string(), "1");
+ assert.equal(tg.get_next_unread_pm_string("4"), "1");
+ assert.equal(tg.get_next_unread_pm_string("unk"), "1");
+ assert.equal(tg.get_next_unread_pm_string("4"), "1");
+ assert.equal(tg.get_next_unread_pm_string("1"), "2,3");
+ assert.equal(tg.get_next_unread_pm_string("read"), "2,3");
+ assert.equal(tg.get_next_unread_pm_string("2,3"), "4");
});
diff --git a/frontend_tests/node_tests/topic_list_data.js b/frontend_tests/node_tests/topic_list_data.js
index 14626425b85..8cc0f5819e3 100644
--- a/frontend_tests/node_tests/topic_list_data.js
+++ b/frontend_tests/node_tests/topic_list_data.js
@@ -1,17 +1,17 @@
-set_global('narrow_state', {});
-set_global('unread', {});
-set_global('muting', {});
-set_global('message_list', {});
+set_global("narrow_state", {});
+set_global("unread", {});
+set_global("muting", {});
+set_global("message_list", {});
-zrequire('hash_util');
-zrequire('stream_data');
-zrequire('unread');
-zrequire('stream_topic_history');
-const topic_list_data = zrequire('topic_list_data');
+zrequire("hash_util");
+zrequire("stream_data");
+zrequire("unread");
+zrequire("stream_topic_history");
+const topic_list_data = zrequire("topic_list_data");
const general = {
stream_id: 556,
- name: 'general',
+ name: "general",
};
stream_data.add_sub(general);
@@ -28,7 +28,7 @@ function get_list_info(zoomed) {
stream_id, zoomed);
}
-run_test('get_list_info w/real stream_topic_history', () => {
+run_test("get_list_info w/real stream_topic_history", () => {
clear();
let list_info;
@@ -41,7 +41,7 @@ run_test('get_list_info w/real stream_topic_history', () => {
});
for (const i of _.range(7)) {
- const topic_name = 'topic ' + i;
+ const topic_name = "topic " + i;
stream_topic_history.add_message({
stream_id: general.stream_id,
topic_name: topic_name,
@@ -49,7 +49,7 @@ run_test('get_list_info w/real stream_topic_history', () => {
});
}
- narrow_state.topic = () => 'topic 6';
+ narrow_state.topic = () => "topic 6";
list_info = get_list_info();
assert.equal(list_info.items.length, 5);
@@ -60,9 +60,9 @@ run_test('get_list_info w/real stream_topic_history', () => {
is_active_topic: true,
is_muted: false,
is_zero: true,
- topic_name: 'topic 6',
+ topic_name: "topic 6",
unread: 0,
- url: '#narrow/stream/556-general/topic/topic.206',
+ url: "#narrow/stream/556-general/topic/topic.206",
});
// If we zoom in, we'll show all 7 topics.
@@ -73,14 +73,14 @@ run_test('get_list_info w/real stream_topic_history', () => {
assert.equal(list_info.num_possible_topics, 7);
});
-run_test('get_list_info unreads', () => {
+run_test("get_list_info unreads", () => {
clear();
let list_info;
// Going forward, we just stub get_recent_topic_names
// for simpler test setup.
- stream_topic_history.get_recent_topic_names = () => _.range(15).map((i) => 'topic ' + i);
+ stream_topic_history.get_recent_topic_names = () => _.range(15).map((i) => "topic " + i);
const unread_cnt = new Map();
unread.num_unread_for_topic = (stream_id, topic_name) => {
@@ -97,8 +97,8 @@ run_test('get_list_info unreads', () => {
So first we'll get 7 topics, where 2 are
unread.
*/
- unread_cnt.set('topic 8', 8);
- unread_cnt.set('topic 9', 9);
+ unread_cnt.set("topic 8", 8);
+ unread_cnt.set("topic 9", 9);
list_info = get_list_info();
assert.equal(list_info.items.length, 7);
@@ -108,17 +108,17 @@ 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);
+ unread_cnt.set("topic 6", 6);
+ unread_cnt.set("topic 7", 7);
list_info = get_list_info();
assert.equal(list_info.items.length, 8);
@@ -128,23 +128,23 @@ 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);
- unread_cnt.set('topic 13', 13);
+ unread_cnt.set("topic 4", 4);
+ unread_cnt.set("topic 5", 5);
+ unread_cnt.set("topic 13", 13);
muting.is_topic_muted = (stream_id, topic_name) => {
assert.equal(stream_id, general.stream_id);
- return topic_name === 'topic 4';
+ return topic_name === "topic 4";
};
list_info = get_list_info();
@@ -155,13 +155,13 @@ 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 5fc3118f020..36b0180d98c 100644
--- a/frontend_tests/node_tests/transmit.js
+++ b/frontend_tests/node_tests/transmit.js
@@ -1,30 +1,30 @@
const noop = function () {};
-set_global('$', global.make_zjquery());
-set_global('page_params', {});
-set_global('channel', {});
-set_global('reload', {});
-set_global('reload_state', {});
-set_global('sent_messages', {
+set_global("$", global.make_zjquery());
+set_global("page_params", {});
+set_global("channel", {});
+set_global("reload", {});
+set_global("reload_state", {});
+set_global("sent_messages", {
start_tracking_message: noop,
report_server_ack: noop,
});
-zrequire('people');
-zrequire('transmit');
+zrequire("people");
+zrequire("transmit");
-run_test('transmit_message_ajax', () => {
+run_test("transmit_message_ajax", () => {
let success_func_called;
const success = function () {
success_func_called = true;
};
- const request = {foo: 'bar'};
+ const request = {foo: "bar"};
channel.post = function (opts) {
- assert.equal(opts.url, '/json/messages');
- assert.equal(opts.data.foo, 'bar');
+ assert.equal(opts.url, "/json/messages");
+ assert.equal(opts.data.foo, "bar");
opts.success();
};
@@ -33,28 +33,28 @@ run_test('transmit_message_ajax', () => {
assert(success_func_called);
channel.xhr_error_message = function (msg) {
- assert.equal(msg, 'Error sending message');
+ assert.equal(msg, "Error sending message");
return msg;
};
channel.post = function (opts) {
- assert.equal(opts.url, '/json/messages');
- assert.equal(opts.data.foo, 'bar');
- const xhr = 'whatever';
- opts.error(xhr, 'timeout');
+ assert.equal(opts.url, "/json/messages");
+ assert.equal(opts.data.foo, "bar");
+ const xhr = "whatever";
+ opts.error(xhr, "timeout");
};
let error_func_called;
const error = function (response) {
- assert.equal(response, 'Error sending message');
+ assert.equal(response, "Error sending message");
error_func_called = true;
};
transmit.send_message(request, success, error);
assert(error_func_called);
});
-run_test('transmit_message_ajax_reload_pending', () => {
- const success = function () { throw 'unexpected success'; };
+run_test("transmit_message_ajax_reload_pending", () => {
+ const success = function () { throw "unexpected success"; };
reload_state.is_pending = function () {
return true;
@@ -72,36 +72,36 @@ run_test('transmit_message_ajax_reload_pending', () => {
});
};
- const request = {foo: 'bar'};
+ const request = {foo: "bar"};
let error_func_called;
const error = function (response) {
- assert.equal(response, 'Error sending message');
+ assert.equal(response, "Error sending message");
error_func_called = true;
};
error_func_called = false;
channel.post = function (opts) {
- assert.equal(opts.url, '/json/messages');
- assert.equal(opts.data.foo, 'bar');
- const xhr = 'whatever';
- opts.error(xhr, 'bad request');
+ assert.equal(opts.url, "/json/messages");
+ assert.equal(opts.data.foo, "bar");
+ const xhr = "whatever";
+ opts.error(xhr, "bad request");
};
transmit.send_message(request, success, error);
assert(!error_func_called);
assert(reload_initiated);
});
-run_test('reply_message_stream', () => {
+run_test("reply_message_stream", () => {
const stream_message = {
- type: 'stream',
- stream: 'social',
- topic: 'lunch',
- sender_full_name: 'Alice',
+ type: "stream",
+ stream: "social",
+ topic: "lunch",
+ sender_full_name: "Alice",
sender_id: 123,
};
- const content = 'hello';
+ const content = "hello";
let send_message_args;
@@ -121,32 +121,32 @@ run_test('reply_message_stream', () => {
assert.deepEqual(send_message_args, {
sender_id: 44,
queue_id: 66,
- local_id: '99',
- type: 'stream',
- to: 'social',
- content: '@**Alice** hello',
- topic: 'lunch',
+ local_id: "99",
+ type: "stream",
+ to: "social",
+ content: "@**Alice** hello",
+ topic: "lunch",
});
});
-run_test('reply_message_private', () => {
+run_test("reply_message_private", () => {
const fred = {
user_id: 3,
- email: '[email protected]',
- full_name: 'Fred Frost',
+ email: "[email protected]",
+ full_name: "Fred Frost",
};
people.add_active_user(fred);
people.is_my_user_id = () => false;
const pm_message = {
- type: 'private',
+ type: "private",
display_recipient: [
{id: fred.user_id},
],
};
- const content = 'hello';
+ const content = "hello";
let send_message_args;
@@ -166,19 +166,19 @@ run_test('reply_message_private', () => {
assert.deepEqual(send_message_args, {
sender_id: 155,
queue_id: 177,
- local_id: '199',
- type: 'private',
+ local_id: "199",
+ type: "private",
to: '["[email protected]"]',
- content: 'hello',
+ content: "hello",
});
});
-run_test('reply_message_errors', () => {
+run_test("reply_message_errors", () => {
const bogus_message = {
- type: 'bogus',
+ type: "bogus",
};
- blueslip.expect('error', 'unknown message type: bogus');
+ blueslip.expect("error", "unknown message type: bogus");
transmit.reply_message({
message: bogus_message,
diff --git a/frontend_tests/node_tests/typeahead.js b/frontend_tests/node_tests/typeahead.js
index 60a16f4a29d..b903c94346e 100644
--- a/frontend_tests/node_tests/typeahead.js
+++ b/frontend_tests/node_tests/typeahead.js
@@ -1,26 +1,26 @@
-const typeahead = zrequire('typeahead', 'shared/js/typeahead');
+const typeahead = zrequire("typeahead", "shared/js/typeahead");
// The data structures here may be different for
// different apps; the only key thing is we look
// at emoji_name and we'll return the entire structures.
const emoji_japanese_post_office = {
- emoji_name: 'japanese_post_office',
- url: 'TBD',
+ emoji_name: "japanese_post_office",
+ url: "TBD",
};
const emoji_panda_face = {
- emoji_name: 'panda_face',
- emoji_code: '1f43c',
+ emoji_name: "panda_face",
+ emoji_code: "1f43c",
};
const emoji_smile = {
- emoji_name: 'smile',
+ emoji_name: "smile",
};
const emoji_tada = {
- emoji_name: 'tada',
- random_field: 'whatever',
+ emoji_name: "tada",
+ random_field: "whatever",
};
const emojis = [
@@ -30,7 +30,7 @@ const emojis = [
emoji_tada,
];
-run_test('get_emoji_matcher', () => {
+run_test("get_emoji_matcher", () => {
function assert_matches(query, expected) {
const matcher = typeahead.get_emoji_matcher(query);
assert.deepEqual(
@@ -39,31 +39,31 @@ run_test('get_emoji_matcher', () => {
);
}
- assert_matches('notaemoji', []);
- assert_matches('da_', []);
- assert_matches('da ', []);
+ assert_matches("notaemoji", []);
+ assert_matches("da_", []);
+ assert_matches("da ", []);
- assert_matches('da', [emoji_panda_face, emoji_tada]);
- assert_matches('panda ', [emoji_panda_face]);
- assert_matches('smil', [emoji_smile]);
- assert_matches('mile', [emoji_smile]);
+ assert_matches("da", [emoji_panda_face, emoji_tada]);
+ assert_matches("panda ", [emoji_panda_face]);
+ assert_matches("smil", [emoji_smile]);
+ assert_matches("mile", [emoji_smile]);
assert_matches(
- 'japanese_post_', [emoji_japanese_post_office]);
+ "japanese_post_", [emoji_japanese_post_office]);
assert_matches(
- 'japanese post ', [emoji_japanese_post_office]);
+ "japanese post ", [emoji_japanese_post_office]);
});
-run_test('triage', () => {
- const alice = {name: 'alice'};
- const Alicia = {name: 'Alicia'};
- const steve = {name: 'steve'};
- const Stephanie = {name: 'Stephanie'};
+run_test("triage", () => {
+ const alice = {name: "alice"};
+ const Alicia = {name: "Alicia"};
+ const steve = {name: "steve"};
+ const Stephanie = {name: "Stephanie"};
const names = [alice, Alicia, steve, Stephanie];
assert.deepEqual(
- typeahead.triage('a', names, (r) => r.name),
+ typeahead.triage("a", names, (r) => r.name),
{
matches: [alice, Alicia],
rest: [steve, Stephanie],
@@ -71,7 +71,7 @@ run_test('triage', () => {
);
assert.deepEqual(
- typeahead.triage('A', names, (r) => r.name),
+ typeahead.triage("A", names, (r) => r.name),
{
matches: [Alicia, alice],
rest: [steve, Stephanie],
@@ -79,7 +79,7 @@ run_test('triage', () => {
);
assert.deepEqual(
- typeahead.triage('S', names, (r) => r.name),
+ typeahead.triage("S", names, (r) => r.name),
{
matches: [Stephanie, steve],
rest: [alice, Alicia],
@@ -87,7 +87,7 @@ run_test('triage', () => {
);
assert.deepEqual(
- typeahead.triage('fred', names, (r) => r.name),
+ typeahead.triage("fred", names, (r) => r.name),
{
matches: [],
rest: [alice, Alicia, steve, Stephanie],
@@ -95,15 +95,15 @@ run_test('triage', () => {
);
});
-run_test('sort_emojis th', () => {
+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,
@@ -113,7 +113,7 @@ run_test('sort_emojis th', () => {
];
assert.deepEqual(
- typeahead.sort_emojis(emoji_list, 'th'),
+ typeahead.sort_emojis(emoji_list, "th"),
[
thumbs_up,
thermometer,
@@ -123,13 +123,13 @@ run_test('sort_emojis th', () => {
);
});
-run_test('sort_emojis sm', () => {
+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,
@@ -138,7 +138,7 @@ run_test('sort_emojis sm', () => {
];
assert.deepEqual(
- typeahead.sort_emojis(emoji_list, 'sm'),
+ typeahead.sort_emojis(emoji_list, "sm"),
[
slight_smile,
small_airplane,
diff --git a/frontend_tests/node_tests/typeahead_helper.js b/frontend_tests/node_tests/typeahead_helper.js
index 6fd08af90f3..6179edb2815 100644
--- a/frontend_tests/node_tests/typeahead_helper.js
+++ b/frontend_tests/node_tests/typeahead_helper.js
@@ -1,24 +1,24 @@
-set_global('page_params', {realm_is_zephyr_mirror_realm: false});
-set_global('md5', (s) => 'md5-' + s);
+set_global("page_params", {realm_is_zephyr_mirror_realm: false});
+set_global("md5", (s) => "md5-" + s);
-const settings_config = zrequire('settings_config');
+const settings_config = zrequire("settings_config");
page_params.realm_email_address_visibility =
settings_config.email_address_visibility_values.admins_only.code;
-set_global('Handlebars', global.make_handlebars());
-zrequire('recent_senders');
-zrequire('pm_conversations');
-zrequire('people');
-zrequire('emoji');
-zrequire('stream_data');
-zrequire('narrow');
-zrequire('hash_util');
-zrequire('marked', 'third/marked/lib/marked');
-const pygments_data = zrequire('pygments_data', 'generated/pygments_data.json');
+set_global("Handlebars", global.make_handlebars());
+zrequire("recent_senders");
+zrequire("pm_conversations");
+zrequire("people");
+zrequire("emoji");
+zrequire("stream_data");
+zrequire("narrow");
+zrequire("hash_util");
+zrequire("marked", "third/marked/lib/marked");
+const pygments_data = zrequire("pygments_data", "generated/pygments_data.json");
const actual_pygments_data = Object.assign({}, pygments_data);
-const ct = zrequire('composebox_typeahead');
-const th = zrequire('typeahead_helper');
-const LazySet = zrequire('lazy_set.js').LazySet;
+const ct = zrequire("composebox_typeahead");
+const th = zrequire("typeahead_helper");
+const LazySet = zrequire("lazy_set.js").LazySet;
let next_id = 0;
@@ -30,29 +30,29 @@ function assertSameEmails(lst1, lst2) {
}
stream_data.create_streams([
- {name: 'Dev', subscribed: true, color: 'blue', stream_id: 1},
- {name: 'Linux', subscribed: true, color: 'red', stream_id: 2},
+ {name: "Dev", subscribed: true, color: "blue", stream_id: 1},
+ {name: "Linux", subscribed: true, color: "red", stream_id: 2},
]);
-run_test('sort_streams', () => {
+run_test("sort_streams", () => {
const popular = new LazySet([1, 2, 3, 4, 5, 6]);
const unpopular = new LazySet([1]);
let test_streams = [
- {name: 'Dev', pin_to_top: false, subscribers: unpopular, subscribed: true},
- {name: 'Docs', pin_to_top: false, subscribers: popular, subscribed: true},
- {name: 'Derp', pin_to_top: false, subscribers: unpopular, subscribed: true},
- {name: 'Denmark', pin_to_top: true, subscribers: popular, subscribed: true},
- {name: 'dead', pin_to_top: false, subscribers: unpopular, subscribed: true},
+ {name: "Dev", pin_to_top: false, subscribers: unpopular, subscribed: true},
+ {name: "Docs", pin_to_top: false, subscribers: popular, subscribed: true},
+ {name: "Derp", pin_to_top: false, subscribers: unpopular, subscribed: true},
+ {name: "Denmark", pin_to_top: true, subscribers: popular, subscribed: true},
+ {name: "dead", pin_to_top: false, subscribers: unpopular, subscribed: true},
];
test_streams.forEach(stream_data.update_calculated_fields);
global.stream_data.is_active = function (sub) {
- return sub.name !== 'dead';
+ return sub.name !== "dead";
};
- test_streams = th.sort_streams(test_streams, 'd');
+ test_streams = th.sort_streams(test_streams, "d");
assert.deepEqual(test_streams[0].name, "Denmark"); // Pinned streams first
assert.deepEqual(test_streams[1].name, "Docs"); // Active streams next
assert.deepEqual(test_streams[2].name, "Derp"); // Less subscribers
@@ -61,14 +61,14 @@ run_test('sort_streams', () => {
// Test sort streams with description
test_streams = [
- {name: 'Dev', description: 'development help', subscribers: unpopular, subscribed: true},
- {name: 'Docs', description: 'writing docs', subscribers: popular, subscribed: true},
- {name: 'Derp', description: 'derping around', subscribers: unpopular, subscribed: true},
- {name: 'Denmark', description: 'visiting Denmark', subscribers: popular, subscribed: true},
- {name: 'dead', description: 'dead stream', subscribers: unpopular, subscribed: true},
+ {name: "Dev", description: "development help", subscribers: unpopular, subscribed: true},
+ {name: "Docs", description: "writing docs", subscribers: popular, subscribed: true},
+ {name: "Derp", description: "derping around", subscribers: unpopular, subscribed: true},
+ {name: "Denmark", description: "visiting Denmark", subscribers: popular, subscribed: true},
+ {name: "dead", description: "dead stream", subscribers: unpopular, subscribed: true},
];
test_streams.forEach(stream_data.update_calculated_fields);
- test_streams = th.sort_streams(test_streams, 'wr');
+ test_streams = th.sort_streams(test_streams, "wr");
assert.deepEqual(test_streams[0].name, "Docs"); // Description match
assert.deepEqual(test_streams[1].name, "Denmark"); // Popular stream
assert.deepEqual(test_streams[2].name, "Derp"); // Less subscribers
@@ -77,16 +77,16 @@ run_test('sort_streams', () => {
// Test sort both subscribed and unsubscribed streams.
test_streams = [
- {name: 'Dev', description: 'Some devs', subscribed: true, subscribers: popular},
- {name: 'East', description: 'Developing east', subscribed: true, subscribers: popular},
- {name: 'New', description: 'No match', subscribed: true, subscribers: popular},
- {name: 'Derp', description: 'Always Derping', subscribed: false, subscribers: popular},
- {name: 'Ether', description: 'Destroying ether', subscribed: false, subscribers: popular},
- {name: 'Mew', description: 'Cat mews', subscribed: false, subscribers: popular},
+ {name: "Dev", description: "Some devs", subscribed: true, subscribers: popular},
+ {name: "East", description: "Developing east", subscribed: true, subscribers: popular},
+ {name: "New", description: "No match", subscribed: true, subscribers: popular},
+ {name: "Derp", description: "Always Derping", subscribed: false, subscribers: popular},
+ {name: "Ether", description: "Destroying ether", subscribed: false, subscribers: popular},
+ {name: "Mew", description: "Cat mews", subscribed: false, subscribers: popular},
];
test_streams.forEach(stream_data.update_calculated_fields);
- test_streams = th.sort_streams(test_streams, 'd');
+ test_streams = th.sort_streams(test_streams, "d");
assert.deepEqual(test_streams[0].name, "Dev"); // Subscribed and stream name starts with query
assert.deepEqual(test_streams[1].name, "Derp"); // Unsubscribed and stream name starts with query
assert.deepEqual(test_streams[2].name, "East"); // Subscribed and description starts with query
@@ -95,7 +95,7 @@ run_test('sort_streams', () => {
assert.deepEqual(test_streams[5].name, "Mew"); // Unsubscribed and no match
});
-run_test('sort_languages', () => {
+run_test("sort_languages", () => {
Object.assign(pygments_data, {langs:
{python: 40, javscript: 50, php: 38, pascal: 29, perl: 22, css: 0},
});
@@ -212,27 +212,27 @@ function get_typeahead_result(query, current_stream, current_topic) {
return result.map((person) => person.email);
}
-run_test('sort_recipients', () => {
+run_test("sort_recipients", () => {
// Typeahead for recipientbox [query, "", undefined]
assert.deepEqual(get_typeahead_result("b", ""), [
]);
// Typeahead for private message [query, "", ""]
assert.deepEqual(get_typeahead_result("a", "", ""), [
]);
const subscriber_email_1 = "[email protected]";
@@ -278,10 +278,10 @@ run_test('sort_recipients', () => {
subscriber_email_3,
subscriber_email_2,
subscriber_email_1,
]);
global.recent_senders.process_message_for_senders({
@@ -299,30 +299,30 @@ run_test('sort_recipients', () => {
// No match
assert.deepEqual(get_typeahead_result("h", "Linux", "Linux Topic"), [
]);
});
const all_obj = ct.broadcast_mentions()[0];
-assert.equal(all_obj.email, 'all');
+assert.equal(all_obj.email, "all");
assert.equal(all_obj.is_broadcast, true);
assert.equal(all_obj.idx, 0);
-run_test('sort_recipients all mention', () => {
+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',
+ "a",
+ "Linux",
+ "Linux Topic",
);
assertSameEmails(results, [
@@ -337,7 +337,7 @@ run_test('sort_recipients all mention', () => {
]);
});
-run_test('sort_recipients pm counts', () => {
+run_test("sort_recipients pm counts", () => {
// Test sort_recipients with pm counts
a_bot.pm_recipient_count = 50;
a_user.pm_recipient_count = 2;
@@ -347,35 +347,35 @@ run_test('sort_recipients pm counts', () => {
b_bot.pm_recipient_count = 1;
assert.deepEqual(get_typeahead_result("b", "Linux", "Linux Topic"), [
]);
});
-run_test('sort_recipients dup bots', () => {
+run_test("sort_recipients dup bots", () => {
const dup_objects = matches.concat([a_bot]);
const recipients = th.sort_recipients(dup_objects, "b", "", "");
const recipients_email = recipients.map((person) => person.email);
const expected = [
];
assert.deepEqual(recipients_email, expected);
});
-run_test('sort_recipients dup alls', () => {
+run_test("sort_recipients dup alls", () => {
// full_name starts with same character but emails are 'all'
const test_objs = [
all_obj,
@@ -394,44 +394,44 @@ run_test('sort_recipients dup alls', () => {
assertSameEmails(recipients, expected);
});
-run_test('sort_recipients subscribers', () => {
+run_test("sort_recipients subscribers", () => {
// b_user_2 is a subscriber and b_user_1 is not.
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 = [
];
assert.deepEqual(recipients_email, expected);
});
-run_test('sort_recipients pm partners', () => {
+run_test("sort_recipients pm partners", () => {
// b_user_3 is a pm partner and b_user_2 is not and
// both are not subscribered to the stream Linux.
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 = [
];
assert.deepEqual(recipients_email, expected);
});
-run_test('sort broadcast mentions', () => {
+run_test("sort broadcast mentions", () => {
// test the normal case, which is that the
// 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(),
- '',
- '');
+ "",
+ "");
assert.deepEqual(
results.map((r) => r.email),
- ['all', 'everyone', 'stream'],
+ ["all", "everyone", "stream"],
);
// Reverse the list to test actual sorting
@@ -443,20 +443,20 @@ run_test('sort broadcast mentions', () => {
const results2 = th.sort_people_for_relevance(
test_objs,
- '',
- '');
+ "",
+ "");
assert.deepEqual(
results2.map((r) => r.email),
- ['all',
- 'everyone',
- 'stream',
+ ["all",
+ "everyone",
+ "stream",
a_user.email,
zman.email],
);
});
-run_test('test compare directly', () => {
+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.
@@ -473,7 +473,7 @@ run_test('test compare directly', () => {
1);
});
-run_test('highlight_with_escaping', () => {
+run_test("highlight_with_escaping", () => {
function highlight(query, item) {
const regex = th.build_highlight_regex(query);
return th.highlight_with_escaping_and_regex(regex, item);
@@ -498,33 +498,33 @@ run_test('highlight_with_escaping', () => {
assert.equal(result, expected);
});
-run_test('render_person when emails hidden', () => {
+run_test("render_person when emails hidden", () => {
// Test render_person with regular person, under hidden email visibility case
page_params.is_admin = false;
let rendered = false;
global.stub_templates((template_name, args) => {
- assert.equal(template_name, 'typeahead_list_item');
+ assert.equal(template_name, "typeahead_list_item");
assert.equal(args.primary, b_user_1.full_name);
assert.equal(args.secondary, undefined);
rendered = true;
- return 'typeahead-item-stub';
+ return "typeahead-item-stub";
});
- assert.equal(th.render_person(b_user_1), 'typeahead-item-stub');
+ assert.equal(th.render_person(b_user_1), "typeahead-item-stub");
assert(rendered);
});
-run_test('render_person', () => {
+run_test("render_person", () => {
page_params.is_admin = true;
// Test render_person with regular person
let rendered = false;
global.stub_templates((template_name, args) => {
- assert.equal(template_name, 'typeahead_list_item');
+ assert.equal(template_name, "typeahead_list_item");
assert.equal(args.primary, a_user.full_name);
assert.equal(args.secondary, a_user.email);
rendered = true;
- return 'typeahead-item-stub';
+ return "typeahead-item-stub";
});
- assert.equal(th.render_person(a_user), 'typeahead-item-stub');
+ assert.equal(th.render_person(a_user), "typeahead-item-stub");
assert(rendered);
// Test render_person with special_item_text person
@@ -538,195 +538,195 @@ run_test('render_person', () => {
};
rendered = false;
global.stub_templates((template_name, args) => {
- assert.equal(template_name, 'typeahead_list_item');
+ assert.equal(template_name, "typeahead_list_item");
assert.equal(args.primary, special_person.special_item_text);
rendered = true;
- return 'typeahead-item-stub';
+ return "typeahead-item-stub";
});
- assert.equal(th.render_person(special_person), 'typeahead-item-stub');
+ assert.equal(th.render_person(special_person), "typeahead-item-stub");
assert(rendered);
});
-run_test('clear_rendered_person', () => {
+run_test("clear_rendered_person", () => {
let rendered = false;
global.stub_templates((template_name, args) => {
- assert.equal(template_name, 'typeahead_list_item');
+ assert.equal(template_name, "typeahead_list_item");
assert.equal(args.primary, b_bot.full_name);
assert.equal(args.secondary, b_bot.email);
rendered = true;
- return 'typeahead-item-stub';
+ return "typeahead-item-stub";
});
- assert.equal(th.render_person(b_bot), 'typeahead-item-stub');
+ assert.equal(th.render_person(b_bot), "typeahead-item-stub");
assert(rendered);
// Bot once rendered won't be rendered again until clear_rendered_person
// function is called. clear_rendered_person is used to clear rendered
// data once bot name is modified.
rendered = false;
- assert.equal(th.render_person(b_bot), 'typeahead-item-stub');
+ assert.equal(th.render_person(b_bot), "typeahead-item-stub");
assert.equal(rendered, false);
// Here rendered will be true as it is being rendered again.
th.clear_rendered_person(b_bot.user_id);
- assert.equal(th.render_person(b_bot), 'typeahead-item-stub');
+ assert.equal(th.render_person(b_bot), "typeahead-item-stub");
assert(rendered);
});
-run_test('render_stream', () => {
+run_test("render_stream", () => {
// Test render_stream with short description
let rendered = false;
let stream = {
- description: 'This is a short description.',
+ description: "This is a short description.",
stream_id: 42,
- name: 'Short Description',
+ name: "Short Description",
};
global.stub_templates((template_name, args) => {
- assert.equal(template_name, 'typeahead_list_item');
+ assert.equal(template_name, "typeahead_list_item");
assert.equal(args.primary, stream.name);
assert.equal(args.secondary, stream.description);
rendered = true;
- return 'typeahead-item-stub';
+ return "typeahead-item-stub";
});
- assert.equal(th.render_stream(stream), 'typeahead-item-stub');
+ assert.equal(th.render_stream(stream), "typeahead-item-stub");
assert(rendered);
// Test render_stream with long description
rendered = false;
stream = {
- description: 'This is a very very very very very long description.',
+ description: "This is a very very very very very long description.",
stream_id: 43,
- name: 'Long Description',
+ name: "Long Description",
};
global.stub_templates((template_name, args) => {
- assert.equal(template_name, 'typeahead_list_item');
+ assert.equal(template_name, "typeahead_list_item");
assert.equal(args.primary, stream.name);
const short_desc = stream.description.substring(0, 35);
assert.equal(args.secondary, short_desc + "...");
rendered = true;
- return 'typeahead-item-stub';
+ return "typeahead-item-stub";
});
- assert.equal(th.render_stream(stream), 'typeahead-item-stub');
+ assert.equal(th.render_stream(stream), "typeahead-item-stub");
assert(rendered);
});
-run_test('clear_rendered_stream', () => {
+run_test("clear_rendered_stream", () => {
let rendered = false;
const stream = {
- description: 'This is a description.',
+ description: "This is a description.",
stream_id: 44,
- name: 'Stream To Be Cleared',
+ name: "Stream To Be Cleared",
};
global.stub_templates((template_name, args) => {
- assert.equal(template_name, 'typeahead_list_item');
+ assert.equal(template_name, "typeahead_list_item");
assert.equal(args.primary, stream.name);
assert.equal(args.secondary, stream.description);
rendered = true;
- return 'typeahead-item-stub';
+ return "typeahead-item-stub";
});
- assert.equal(th.render_stream(stream), 'typeahead-item-stub');
+ assert.equal(th.render_stream(stream), "typeahead-item-stub");
assert(rendered);
rendered = false;
- assert.equal(th.render_stream(stream), 'typeahead-item-stub');
+ assert.equal(th.render_stream(stream), "typeahead-item-stub");
assert.equal(rendered, false);
// Here rendered will be true as it is being rendered again.
th.clear_rendered_stream(stream.stream_id);
- assert.equal(th.render_stream(stream), 'typeahead-item-stub');
+ assert.equal(th.render_stream(stream), "typeahead-item-stub");
assert(rendered);
});
-run_test('render_emoji', () => {
+run_test("render_emoji", () => {
// Test render_emoji with normal emoji.
let rendered = false;
let test_emoji = {
- emoji_name: 'thumbs_up',
- emoji_code: '1f44d',
+ emoji_name: "thumbs_up",
+ emoji_code: "1f44d",
};
emoji.active_realm_emojis = new Map(Object.entries({
- realm_emoji: 'TBD',
+ realm_emoji: "TBD",
}));
global.stub_templates((template_name, args) => {
- assert.equal(template_name, 'typeahead_list_item');
+ assert.equal(template_name, "typeahead_list_item");
assert.deepEqual(args, {
- primary: 'thumbs up',
- emoji_code: '1f44d',
+ primary: "thumbs up",
+ emoji_code: "1f44d",
is_emoji: true,
has_image: false,
has_secondary: false,
});
rendered = true;
- return 'typeahead-item-stub';
+ return "typeahead-item-stub";
});
- assert.equal(th.render_emoji(test_emoji), 'typeahead-item-stub');
+ assert.equal(th.render_emoji(test_emoji), "typeahead-item-stub");
assert(rendered);
// Test render_emoji with normal emoji.
rendered = false;
test_emoji = {
- emoji_name: 'realm_emoji',
- emoji_url: 'TBD',
+ emoji_name: "realm_emoji",
+ emoji_url: "TBD",
};
global.stub_templates((template_name, args) => {
- assert.equal(template_name, 'typeahead_list_item');
+ assert.equal(template_name, "typeahead_list_item");
assert.deepEqual(args, {
- primary: 'realm emoji',
- img_src: 'TBD',
+ primary: "realm emoji",
+ img_src: "TBD",
is_emoji: true,
has_image: true,
has_secondary: false,
});
rendered = true;
- return 'typeahead-item-stub';
+ return "typeahead-item-stub";
});
- assert.equal(th.render_emoji(test_emoji), 'typeahead-item-stub');
+ assert.equal(th.render_emoji(test_emoji), "typeahead-item-stub");
assert(rendered);
});
-run_test('sort_slash_commands', () => {
+run_test("sort_slash_commands", () => {
const slash_commands = [
- { name: 'my' },
- { name: 'poll' },
- { name: 'me' },
- { name: 'mine' },
- { name: 'test' },
- { name: 'ping' },
+ { name: "my" },
+ { name: "poll" },
+ { name: "me" },
+ { name: "mine" },
+ { name: "test" },
+ { name: "ping" },
];
- assert.deepEqual(th.sort_slash_commands(slash_commands, 'm'), [
- { name: 'me' },
- { name: 'mine' },
- { name: 'my' },
- { name: 'ping' },
- { name: 'poll' },
- { name: 'test' },
+ assert.deepEqual(th.sort_slash_commands(slash_commands, "m"), [
+ { name: "me" },
+ { name: "mine" },
+ { name: "my" },
+ { name: "ping" },
+ { name: "poll" },
+ { name: "test" },
]);
});
-run_test('sort_recipientbox_typeahead', () => {
+run_test("sort_recipientbox_typeahead", () => {
let recipients = th.sort_recipientbox_typeahead("b, a", matches, ""); // search "a"
let recipients_email = recipients.map((person) => person.email);
assert.deepEqual(recipients_email, [
- '[email protected]', // matches "a"
- '[email protected]', // matches "a"
+ "[email protected]", // matches "a"
+ "[email protected]", // matches "a"
]);
recipients = th.sort_recipientbox_typeahead("b, a, b", matches, ""); // search "b"
recipients_email = recipients.map((person) => person.email);
assert.deepEqual(recipients_email, [
]);
});
diff --git a/frontend_tests/node_tests/typing_data.js b/frontend_tests/node_tests/typing_data.js
index b062d7688ee..ff05b448e8e 100644
--- a/frontend_tests/node_tests/typing_data.js
+++ b/frontend_tests/node_tests/typing_data.js
@@ -1,6 +1,6 @@
zrequire("typing_data");
-run_test('basics', () => {
+run_test("basics", () => {
// The typing_data needs to be robust with lists of
// user ids being in arbitrary sorting order and
// possibly in string form instead of integer. So all
@@ -45,13 +45,13 @@ run_test('basics', () => {
assert.deepEqual(typing_data.get_group_typists([20, 40]), [20]);
});
-run_test('timers', () => {
+run_test("timers", () => {
const events = {};
- const stub_timer_id = 'timer_id_stub';
+ const stub_timer_id = "timer_id_stub";
const stub_group = [5, 10, 15];
const stub_delay = 99;
- const stub_f = 'function';
+ const stub_f = "function";
function set_timeout(f, delay) {
assert.equal(delay, stub_delay);
@@ -81,8 +81,8 @@ run_test('timers', () => {
typing_data.clear_inbound_timer(stub_group);
}
- global.patch_builtin('setTimeout', set_timeout);
- global.patch_builtin('clearTimeout', clear_timeout);
+ global.patch_builtin("setTimeout", set_timeout);
+ global.patch_builtin("clearTimeout", clear_timeout);
// first time, we set
kickstart();
diff --git a/frontend_tests/node_tests/typing_status.js b/frontend_tests/node_tests/typing_status.js
index 7d852b40bfc..8e5cd7879f0 100644
--- a/frontend_tests/node_tests/typing_status.js
+++ b/frontend_tests/node_tests/typing_status.js
@@ -1,7 +1,7 @@
-zrequire('typing');
-zrequire('people');
-zrequire('compose_pm_pill');
-const typing_status = zrequire('typing_status', 'shared/js/typing_status');
+zrequire("typing");
+zrequire("people");
+zrequire("compose_pm_pill");
+const typing_status = zrequire("typing_status", "shared/js/typing_status");
function make_time(secs) {
// make times semi-realistic
@@ -12,7 +12,7 @@ function returns_time(secs) {
return function () { return make_time(secs); };
}
-run_test('basics', () => {
+run_test("basics", () => {
// invalid conversation basically does nothing
let worker = {};
@@ -26,15 +26,15 @@ run_test('basics', () => {
function set_timeout(f, delay) {
assert.equal(delay, 5000);
events.idle_callback = f;
- return 'idle_timer_stub';
+ return "idle_timer_stub";
}
function clear_timeout() {
events.timer_cleared = true;
}
- global.patch_builtin('setTimeout', set_timeout);
- global.patch_builtin('clearTimeout', clear_timeout);
+ global.patch_builtin("setTimeout", set_timeout);
+ global.patch_builtin("clearTimeout", clear_timeout);
function notify_server_start(recipient) {
assert.equal(recipient, "alice");
@@ -68,8 +68,8 @@ run_test('basics', () => {
call_handler("alice");
assert.deepEqual(typing_status.state, {
next_send_start_time: make_time(5 + 10),
- idle_timer: 'idle_timer_stub',
- current_recipient: 'alice',
+ idle_timer: "idle_timer_stub",
+ current_recipient: "alice",
});
assert.deepEqual(events, {
idle_callback: events.idle_callback,
@@ -84,8 +84,8 @@ run_test('basics', () => {
call_handler("alice");
assert.deepEqual(typing_status.state, {
next_send_start_time: make_time(5 + 10),
- idle_timer: 'idle_timer_stub',
- current_recipient: 'alice',
+ idle_timer: "idle_timer_stub",
+ current_recipient: "alice",
});
assert.deepEqual(events, {
idle_callback: events.idle_callback,
@@ -101,8 +101,8 @@ run_test('basics', () => {
call_handler("alice");
assert.deepEqual(typing_status.state, {
next_send_start_time: make_time(18 + 10),
- idle_timer: 'idle_timer_stub',
- current_recipient: 'alice',
+ idle_timer: "idle_timer_stub",
+ current_recipient: "alice",
});
assert.deepEqual(events, {
idle_callback: events.idle_callback,
@@ -146,8 +146,8 @@ run_test('basics', () => {
call_handler("alice");
assert.deepEqual(typing_status.state, {
next_send_start_time: make_time(50 + 10),
- idle_timer: 'idle_timer_stub',
- current_recipient: 'alice',
+ idle_timer: "idle_timer_stub",
+ current_recipient: "alice",
});
assert.deepEqual(events, {
idle_callback: events.idle_callback,
@@ -176,8 +176,8 @@ run_test('basics', () => {
call_handler("alice");
assert.deepEqual(typing_status.state, {
next_send_start_time: make_time(80 + 10),
- idle_timer: 'idle_timer_stub',
- current_recipient: 'alice',
+ idle_timer: "idle_timer_stub",
+ current_recipient: "alice",
});
assert.deepEqual(events, {
idle_callback: events.idle_callback,
@@ -220,8 +220,8 @@ run_test('basics', () => {
call_handler("alice");
assert.deepEqual(typing_status.state, {
next_send_start_time: make_time(170 + 10),
- idle_timer: 'idle_timer_stub',
- current_recipient: 'alice',
+ idle_timer: "idle_timer_stub",
+ current_recipient: "alice",
});
assert.deepEqual(events, {
idle_callback: events.idle_callback,
@@ -242,8 +242,8 @@ run_test('basics', () => {
call_handler("bob");
assert.deepEqual(typing_status.state, {
next_send_start_time: make_time(171 + 10),
- idle_timer: 'idle_timer_stub',
- current_recipient: 'bob',
+ idle_timer: "idle_timer_stub",
+ current_recipient: "bob",
});
assert.deepEqual(events, {
idle_callback: events.idle_callback,
@@ -256,7 +256,7 @@ run_test('basics', () => {
// test that we correctly detect if worker.get_recipient
// and typing_status.state.current_recipient are the same
- compose_pm_pill.get_user_ids_string = () => '1,2,3';
+ compose_pm_pill.get_user_ids_string = () => "1,2,3";
typing_status.state.current_recipient = typing.get_recipient();
const call_count = {
@@ -287,14 +287,14 @@ run_test('basics', () => {
// change in recipient and new_recipient should make us
// call typing_status.stop_last_notification
- compose_pm_pill.get_user_ids_string = () => '2,3,4';
+ compose_pm_pill.get_user_ids_string = () => "2,3,4";
typing_status.update(worker, typing.get_recipient());
assert.deepEqual(call_count.maybe_ping_server, 2);
assert.deepEqual(call_count.start_or_extend_idle_timer, 3);
assert.deepEqual(call_count.stop_last_notification, 1);
// Stream messages are represented as get_user_ids_string being empty
- compose_pm_pill.get_user_ids_string = () => '';
+ compose_pm_pill.get_user_ids_string = () => "";
typing_status.update(worker, typing.get_recipient());
assert.deepEqual(call_count.maybe_ping_server, 2);
assert.deepEqual(call_count.start_or_extend_idle_timer, 3);
diff --git a/frontend_tests/node_tests/ui.js b/frontend_tests/node_tests/ui.js
index 4207478824e..70ade4cb5c2 100644
--- a/frontend_tests/node_tests/ui.js
+++ b/frontend_tests/node_tests/ui.js
@@ -1,20 +1,20 @@
-const ui = zrequire('ui');
+const ui = zrequire("ui");
-set_global('navigator', {
- userAgent: '',
+set_global("navigator", {
+ userAgent: "",
});
-run_test('get_hotkey_deprecation_notice', () => {
+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 actual = ui.get_hotkey_deprecation_notice('*', 'Ctrl + s');
+ const actual = ui.get_hotkey_deprecation_notice("*", "Ctrl + s");
assert.equal(expected, actual);
});
-run_test('get_hotkey_deprecation_notice_mac', () => {
+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.';
- const actual = ui.get_hotkey_deprecation_notice('*', 'Cmd + s');
+ const actual = ui.get_hotkey_deprecation_notice("*", "Cmd + s");
assert.equal(expected, actual);
// Reset userAgent
- global.navigator.userAgent = '';
+ global.navigator.userAgent = "";
});
diff --git a/frontend_tests/node_tests/ui_init.js b/frontend_tests/node_tests/ui_init.js
index 0c3826062a8..fe0a163d277 100644
--- a/frontend_tests/node_tests/ui_init.js
+++ b/frontend_tests/node_tests/ui_init.js
@@ -20,46 +20,46 @@ const rewiremock = require("rewiremock/node");
some things can happen later in a `launch` method.
*/
-const util = zrequire('util');
-set_global('document', {
+const util = zrequire("util");
+set_global("document", {
location: {
- protocol: 'http',
+ protocol: "http",
},
});
-set_global('csrf_token', 'whatever');
+set_global("csrf_token", "whatever");
-set_global('$', () => {});
-set_global('resize', {});
-set_global('page_params', {});
+set_global("$", () => {});
+set_global("resize", {});
+set_global("page_params", {});
const ignore_modules = [
- 'activity',
- 'click_handlers',
- 'compose_pm_pill',
- 'copy_and_paste',
- 'drafts',
- 'emoji',
- 'emoji_picker',
- 'gear_menu',
- 'hashchange',
- 'hotspots',
+ "activity",
+ "click_handlers",
+ "compose_pm_pill",
+ "copy_and_paste",
+ "drafts",
+ "emoji",
+ "emoji_picker",
+ "gear_menu",
+ "hashchange",
+ "hotspots",
// Accesses home_msg_list, which is a lot of complexity to setup
- 'message_fetch',
- 'message_scroll',
- 'message_viewport',
- 'panels',
- 'popovers',
- 'reload',
- 'scroll_bar',
- 'server_events',
- 'settings_sections',
- 'settings_panel_menu',
- 'settings_toggle',
- 'subs',
- 'timerender',
- 'ui',
- 'unread_ui',
+ "message_fetch",
+ "message_scroll",
+ "message_viewport",
+ "panels",
+ "popovers",
+ "reload",
+ "scroll_bar",
+ "server_events",
+ "settings_sections",
+ "settings_panel_menu",
+ "settings_toggle",
+ "subs",
+ "timerender",
+ "ui",
+ "unread_ui",
];
for (const mod of ignore_modules) {
@@ -71,56 +71,56 @@ for (const mod of ignore_modules) {
emoji.emojis_by_name = new Map();
util.is_mobile = () => false;
-global.stub_templates(() => 'some-html');
+global.stub_templates(() => "some-html");
ui.get_scroll_element = (element) => element;
-zrequire('alert_words');
-zrequire('hash_util');
-zrequire('echo');
-zrequire('colorspace');
-zrequire('stream_color');
-zrequire('stream_edit');
-zrequire('color_data');
-zrequire('stream_data');
-zrequire('muting');
-zrequire('condense');
-zrequire('spoilers');
-zrequire('lightbox');
-zrequire('overlays');
-zrequire('invite');
-zrequire('tab_bar');
-zrequire('narrow_state');
-zrequire('people');
-zrequire('presence');
-zrequire('search_pill_widget');
-zrequire('user_groups');
-zrequire('unread');
-zrequire('bot_data');
-set_global('marked', zrequire('marked', 'third/marked/lib/marked'));
-zrequire('fenced_code');
-zrequire('markdown');
-zrequire('upload');
-zrequire('compose');
-zrequire('composebox_typeahead');
-zrequire('narrow');
-zrequire('search_suggestion');
-zrequire('search');
-zrequire('tutorial');
-zrequire('notifications');
-zrequire('pm_conversations');
-zrequire('pm_list');
-zrequire('list_cursor');
-zrequire('keydown_util');
-zrequire('stream_sort');
-zrequire('stream_list');
-zrequire('topic_list');
-zrequire('topic_zoom');
-zrequire('sent_messages');
-zrequire('typing');
-zrequire('top_left_corner');
-zrequire('starred_messages');
-zrequire('user_status');
-zrequire('user_status_ui');
+zrequire("alert_words");
+zrequire("hash_util");
+zrequire("echo");
+zrequire("colorspace");
+zrequire("stream_color");
+zrequire("stream_edit");
+zrequire("color_data");
+zrequire("stream_data");
+zrequire("muting");
+zrequire("condense");
+zrequire("spoilers");
+zrequire("lightbox");
+zrequire("overlays");
+zrequire("invite");
+zrequire("tab_bar");
+zrequire("narrow_state");
+zrequire("people");
+zrequire("presence");
+zrequire("search_pill_widget");
+zrequire("user_groups");
+zrequire("unread");
+zrequire("bot_data");
+set_global("marked", zrequire("marked", "third/marked/lib/marked"));
+zrequire("fenced_code");
+zrequire("markdown");
+zrequire("upload");
+zrequire("compose");
+zrequire("composebox_typeahead");
+zrequire("narrow");
+zrequire("search_suggestion");
+zrequire("search");
+zrequire("tutorial");
+zrequire("notifications");
+zrequire("pm_conversations");
+zrequire("pm_list");
+zrequire("list_cursor");
+zrequire("keydown_util");
+zrequire("stream_sort");
+zrequire("stream_list");
+zrequire("topic_list");
+zrequire("topic_zoom");
+zrequire("sent_messages");
+zrequire("typing");
+zrequire("top_left_corner");
+zrequire("starred_messages");
+zrequire("user_status");
+zrequire("user_status_ui");
const ui_init = rewiremock.proxy(
() => zrequire("ui_init"),
@@ -131,15 +131,15 @@ const ui_init = rewiremock.proxy(
},
);
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
-const document_stub = $.create('document-stub');
+const document_stub = $.create("document-stub");
document.to_$ = () => document_stub;
document_stub.on = () => {};
document_stub.idle = () => {};
-const window_stub = $.create('window-stub');
-set_global('to_$', () => window_stub);
+const window_stub = $.create("window-stub");
+set_global("to_$", () => window_stub);
window_stub.idle = () => {};
ui_init.initialize_kitchen_sink_stuff = () => {};
@@ -167,7 +167,7 @@ page_params.realm_filters = [];
page_params.starred_messages = [];
page_params.presences = [];
-const $tab_bar = $.create('#tab_bar');
+const $tab_bar = $.create("#tab_bar");
$tab_bar.append = () => {};
upload.setup_upload = () => {};
@@ -181,10 +181,10 @@ $("#private_message_recipient").typeahead = () => {};
$("#compose-textarea").typeahead = () => {};
$("#search_query").typeahead = () => {};
-const value_stub = $.create('value');
-const count_stub = $.create('count');
-count_stub.set_find_results('.value', value_stub);
-$(".top_left_starred_messages").set_find_results('.count', count_stub);
+const value_stub = $.create("value");
+const count_stub = $.create("count");
+count_stub.set_find_results(".value", value_stub);
+$(".top_left_starred_messages").set_find_results(".count", count_stub);
$("#tab_bar .stream").length = 0;
@@ -196,6 +196,6 @@ $("#below-compose-content .video_link").toggle = () => {};
$("#tab_bar .narrow_description > a").hover = () => {};
-run_test('initialize_everything', () => {
+run_test("initialize_everything", () => {
ui_init.initialize_everything();
});
diff --git a/frontend_tests/node_tests/unread.js b/frontend_tests/node_tests/unread.js
index 894a0e09e8d..50b7fd14096 100644
--- a/frontend_tests/node_tests/unread.js
+++ b/frontend_tests/node_tests/unread.js
@@ -1,31 +1,31 @@
-zrequire('muting');
-zrequire('people');
-zrequire('stream_data');
-zrequire('unread');
+zrequire("muting");
+zrequire("people");
+zrequire("stream_data");
+zrequire("unread");
-set_global('page_params', {
+set_global("page_params", {
realm_push_notifications_enabled: false,
});
-zrequire('settings_notifications');
+zrequire("settings_notifications");
-const FoldDict = zrequire('fold_dict').FoldDict;
+const FoldDict = zrequire("fold_dict").FoldDict;
-set_global('narrow_state', {});
-set_global('current_msg_list', {});
-set_global('home_msg_list', {});
-set_global('message_store', {});
+set_global("narrow_state", {});
+set_global("current_msg_list", {});
+set_global("home_msg_list", {});
+set_global("message_store", {});
const me = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 30,
- full_name: 'Me Myself',
+ full_name: "Me Myself",
};
people.add_active_user(me);
people.initialize_current_user(me.user_id);
const social = {
stream_id: 200,
- name: 'social',
+ name: "social",
subscribed: true,
is_muted: false,
};
@@ -40,39 +40,39 @@ function assert_zero_counts(counts) {
}
function test_notifiable_count(home_unread_messages, expected_notifiable_count) {
- set_global('page_params', {
+ set_global("page_params", {
desktop_icon_count_display: 1,
});
let notifiable_counts = unread.get_notifiable_count();
assert.deepEqual(notifiable_counts, home_unread_messages);
- set_global('page_params', {
+ set_global("page_params", {
desktop_icon_count_display: 2,
});
notifiable_counts = unread.get_notifiable_count();
assert.deepEqual(notifiable_counts, expected_notifiable_count);
- set_global('page_params', {
+ set_global("page_params", {
desktop_icon_count_display: 3,
});
notifiable_counts = unread.get_notifiable_count();
assert.deepEqual(notifiable_counts, 0);
}
-run_test('empty_counts_while_narrowed', () => {
+run_test("empty_counts_while_narrowed", () => {
const counts = unread.get_counts();
assert_zero_counts(counts);
test_notifiable_count(counts.home_unread_messages, 0);
});
-run_test('empty_counts_while_home', () => {
+run_test("empty_counts_while_home", () => {
const counts = unread.get_counts();
assert_zero_counts(counts);
test_notifiable_count(counts.home_unread_messages, 0);
});
-run_test('changing_topics', () => {
+run_test("changing_topics", () => {
// Summary: change the topic of a message from 'lunch'
// to 'dinner' using update_unread_topics().
- let count = unread.num_unread_for_topic(social.stream_id, 'lunch');
+ let count = unread.num_unread_for_topic(social.stream_id, "lunch");
assert.equal(count, 0);
const stream_id = 100;
@@ -80,24 +80,24 @@ run_test('changing_topics', () => {
const message = {
id: 15,
- type: 'stream',
+ type: "stream",
stream_id: stream_id,
- topic: 'luNch',
+ topic: "luNch",
unread: true,
};
const other_message = {
id: 16,
- type: 'stream',
+ type: "stream",
stream_id: stream_id,
- topic: 'lunCH',
+ topic: "lunCH",
unread: true,
};
assert.deepEqual(unread.get_unread_message_ids([15, 16]), []);
assert.deepEqual(unread.get_unread_messages([message, other_message]), []);
- let msg_ids = unread.get_msg_ids_for_topic(stream_id, 'LuNcH');
+ let msg_ids = unread.get_msg_ids_for_topic(stream_id, "LuNcH");
assert.deepEqual(msg_ids, []);
msg_ids = unread.get_msg_ids_for_stream(stream_id);
@@ -112,59 +112,59 @@ run_test('changing_topics', () => {
[message, other_message],
);
- count = unread.num_unread_for_topic(stream_id, 'Lunch');
+ count = unread.num_unread_for_topic(stream_id, "Lunch");
assert.equal(count, 2);
- assert(unread.topic_has_any_unread(stream_id, 'lunch'));
- assert(!unread.topic_has_any_unread(wrong_stream_id, 'lunch'));
- assert(!unread.topic_has_any_unread(stream_id, 'NOT lunch'));
+ assert(unread.topic_has_any_unread(stream_id, "lunch"));
+ assert(!unread.topic_has_any_unread(wrong_stream_id, "lunch"));
+ assert(!unread.topic_has_any_unread(stream_id, "NOT lunch"));
- count = unread.num_unread_for_topic(stream_id, 'NOT lunch');
+ count = unread.num_unread_for_topic(stream_id, "NOT lunch");
assert.equal(count, 0);
- msg_ids = unread.get_msg_ids_for_topic(stream_id, 'NOT lunch');
+ msg_ids = unread.get_msg_ids_for_topic(stream_id, "NOT lunch");
assert.deepEqual(msg_ids, []);
let event = {
- topic: 'dinner',
+ topic: "dinner",
};
unread.update_unread_topics(message, event);
- count = unread.num_unread_for_topic(stream_id, 'lUnch');
+ count = unread.num_unread_for_topic(stream_id, "lUnch");
assert.equal(count, 1);
- count = unread.num_unread_for_topic(stream_id, 'dinner');
+ count = unread.num_unread_for_topic(stream_id, "dinner");
assert.equal(count, 1);
event = {
- topic: 'snack',
+ topic: "snack",
};
unread.update_unread_topics(other_message, event);
- count = unread.num_unread_for_topic(stream_id, 'lunch');
+ count = unread.num_unread_for_topic(stream_id, "lunch");
assert.equal(count, 0);
- assert(!unread.topic_has_any_unread(stream_id, 'lunch'));
- assert(!unread.topic_has_any_unread(wrong_stream_id, 'lunch'));
+ assert(!unread.topic_has_any_unread(stream_id, "lunch"));
+ assert(!unread.topic_has_any_unread(wrong_stream_id, "lunch"));
- count = unread.num_unread_for_topic(stream_id, 'snack');
+ count = unread.num_unread_for_topic(stream_id, "snack");
assert.equal(count, 1);
- assert(unread.topic_has_any_unread(stream_id, 'snack'));
- assert(!unread.topic_has_any_unread(wrong_stream_id, 'snack'));
+ assert(unread.topic_has_any_unread(stream_id, "snack"));
+ assert(!unread.topic_has_any_unread(wrong_stream_id, "snack"));
// Test defensive code. Trying to update a message we don't know
// about should be a no-op.
event = {
- topic: 'brunch',
+ topic: "brunch",
};
unread.update_unread_topics(other_message, event);
// Update a message that was never marked as unread.
const sticky_message = {
id: 17,
- type: 'stream',
+ type: "stream",
stream_id: stream_id,
- topic: 'sticky',
+ topic: "sticky",
unread: true,
};
@@ -178,37 +178,37 @@ run_test('changing_topics', () => {
};
unread.process_loaded_messages([sticky_message]);
- count = unread.num_unread_for_topic(stream_id, 'sticky');
+ count = unread.num_unread_for_topic(stream_id, "sticky");
assert.equal(count, 1);
assert(sticky_message.unread);
unread.mark_as_read(sticky_message.id);
- count = unread.num_unread_for_topic(stream_id, 'sticky');
+ count = unread.num_unread_for_topic(stream_id, "sticky");
assert.equal(count, 0);
assert(!sticky_message.unread);
event = {
- topic: 'sticky',
+ topic: "sticky",
};
unread.update_unread_topics(sticky_message, event);
- count = unread.num_unread_for_topic(stream_id, 'sticky');
+ count = unread.num_unread_for_topic(stream_id, "sticky");
assert.equal(count, 0);
// cleanup
unread.mark_as_read(message.id);
- count = unread.num_unread_for_topic(stream_id, 'dinner');
+ count = unread.num_unread_for_topic(stream_id, "dinner");
assert.equal(count, 0);
unread.mark_as_read(other_message.id);
- count = unread.num_unread_for_topic(stream_id, 'snack');
+ count = unread.num_unread_for_topic(stream_id, "snack");
assert.equal(count, 0);
// test coverage
unread.update_unread_topics(sticky_message, {});
});
-run_test('muting', () => {
+run_test("muting", () => {
unread.declare_bankruptcy();
const stream_id = social.stream_id;
@@ -216,9 +216,9 @@ run_test('muting', () => {
const message = {
id: 15,
- type: 'stream',
+ type: "stream",
stream_id: stream_id,
- topic: 'test_muting',
+ topic: "test_muting",
unread: true,
};
@@ -230,7 +230,7 @@ run_test('muting', () => {
assert.deepEqual(unread.get_msg_ids_for_stream(stream_id), [message.id]);
test_notifiable_count(counts.home_unread_messages, 0);
- muting.add_muted_topic(social.stream_id, 'test_muting');
+ muting.add_muted_topic(social.stream_id, "test_muting");
counts = unread.get_counts();
assert.equal(counts.stream_count.get(stream_id), 0);
assert.equal(counts.home_unread_messages, 0);
@@ -244,7 +244,7 @@ run_test('muting', () => {
assert.equal(unread.num_unread_for_stream(unknown_stream_id), 0);
});
-run_test('num_unread_for_topic', () => {
+run_test("num_unread_for_topic", () => {
// Test the num_unread_for_topic() function using many
// messages.
unread.declare_bankruptcy();
@@ -253,17 +253,17 @@ run_test('num_unread_for_topic', () => {
stream_data.get_sub_by_id = function (arg) {
if (arg === stream_id) {
- return {name: 'Some Stream'};
+ return {name: "Some Stream"};
}
};
- let count = unread.num_unread_for_topic(stream_id, 'lunch');
+ let count = unread.num_unread_for_topic(stream_id, "lunch");
assert.equal(count, 0);
const message = {
- type: 'stream',
+ type: "stream",
stream_id: stream_id,
- topic: 'LuncH',
+ topic: "LuncH",
unread: true,
};
@@ -276,10 +276,10 @@ run_test('num_unread_for_topic', () => {
unread.process_loaded_messages([message]);
}
- count = unread.num_unread_for_topic(stream_id, 'lunch');
+ count = unread.num_unread_for_topic(stream_id, "lunch");
assert.equal(count, num_msgs);
- let msg_ids = unread.get_msg_ids_for_topic(stream_id, 'LuNcH');
+ let msg_ids = unread.get_msg_ids_for_topic(stream_id, "LuNcH");
assert.deepEqual(msg_ids, _.range(1, 501));
msg_ids = unread.get_msg_ids_for_stream(stream_id);
@@ -293,10 +293,10 @@ run_test('num_unread_for_topic', () => {
});
assert.deepEqual(missing_topics, [
- { pretty_name: 'LuncH', message_id: 500 },
+ { pretty_name: "LuncH", message_id: 500 },
]);
- topic_dict.set('lUNCh', 'whatever');
+ topic_dict.set("lUNCh", "whatever");
missing_topics = unread.get_missing_topics({
stream_id: stream_id,
@@ -310,17 +310,17 @@ run_test('num_unread_for_topic', () => {
unread.mark_as_read(message.id);
}
- count = unread.num_unread_for_topic(stream_id, 'lunch');
+ count = unread.num_unread_for_topic(stream_id, "lunch");
assert.equal(count, 0);
- msg_ids = unread.get_msg_ids_for_topic(stream_id, 'LuNcH');
+ msg_ids = unread.get_msg_ids_for_topic(stream_id, "LuNcH");
assert.deepEqual(msg_ids, []);
msg_ids = unread.get_msg_ids_for_stream(stream_id);
assert.deepEqual(msg_ids, []);
});
-run_test('home_messages', () => {
+run_test("home_messages", () => {
stream_data.is_subscribed = function () {
return true;
};
@@ -332,15 +332,15 @@ run_test('home_messages', () => {
stream_data.get_sub_by_id = function () {
return {
- name: 'whatever',
+ name: "whatever",
};
};
const message = {
id: 15,
- type: 'stream',
+ type: "stream",
stream_id: stream_id,
- topic: 'lunch',
+ topic: "lunch",
unread: true,
};
@@ -374,12 +374,12 @@ run_test('home_messages', () => {
});
-run_test('phantom_messages', () => {
+run_test("phantom_messages", () => {
const message = {
id: 999,
- type: 'stream',
+ type: "stream",
stream_id: 555,
- topic: 'phantom',
+ topic: "phantom",
};
stream_data.get_sub_by_id = function () { return; };
@@ -390,20 +390,20 @@ run_test('phantom_messages', () => {
test_notifiable_count(counts.home_unread_messages, 0);
});
-run_test('private_messages', () => {
+run_test("private_messages", () => {
let counts = unread.get_counts();
assert.equal(counts.private_message_count, 0);
const anybody = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 999,
- full_name: 'Any Body',
+ full_name: "Any Body",
};
people.add_active_user(anybody);
const message = {
id: 15,
- type: 'private',
+ type: "private",
display_recipient: [
{id: anybody.user_id},
{id: me.user_id},
@@ -415,27 +415,27 @@ run_test('private_messages', () => {
counts = unread.get_counts();
assert.equal(counts.private_message_count, 1);
- assert.equal(counts.pm_count.get('999'), 1);
+ assert.equal(counts.pm_count.get("999"), 1);
test_notifiable_count(counts.home_unread_messages, 1);
unread.mark_as_read(message.id);
counts = unread.get_counts();
assert.equal(counts.private_message_count, 0);
- assert.equal(counts.pm_count.get('999'), 0);
+ assert.equal(counts.pm_count.get("999"), 0);
test_notifiable_count(counts.home_unread_messages, 0);
});
-run_test('private_messages', () => {
+run_test("private_messages", () => {
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 101,
- full_name: 'Alice',
+ full_name: "Alice",
};
people.add_active_user(alice);
const bob = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 102,
- full_name: 'Bob',
+ full_name: "Bob",
};
people.add_active_user(bob);
@@ -449,17 +449,17 @@ run_test('private_messages', () => {
const message = {
id: 15,
display_recipient: [{id: alice.user_id}],
- type: 'private',
+ type: "private",
unread: true,
};
const read_message = {
- flags: ['read'],
+ flags: ["read"],
};
unread.process_loaded_messages([message, read_message]);
assert.equal(unread.num_unread_for_person(alice.user_id.toString()), 1);
- assert.equal(unread.num_unread_for_person(''), 0);
+ assert.equal(unread.num_unread_for_person(""), 0);
assert.deepEqual(unread.get_msg_ids_for_person(alice.user_id.toString()), [message.id]);
assert.deepEqual(unread.get_msg_ids_for_person(bob.user_id.toString()), []);
@@ -468,7 +468,7 @@ run_test('private_messages', () => {
unread.mark_as_read(message.id);
assert.equal(unread.num_unread_for_person(alice.user_id.toString()), 0);
- assert.equal(unread.num_unread_for_person(''), 0);
+ assert.equal(unread.num_unread_for_person(""), 0);
assert.deepEqual(unread.get_msg_ids_for_person(alice.user_id.toString()), []);
assert.deepEqual(unread.get_msg_ids_for_person(bob.user_id.toString()), []);
assert.deepEqual(unread.get_msg_ids_for_private(), []);
@@ -478,7 +478,7 @@ run_test('private_messages', () => {
test_notifiable_count(counts.home_unread_messages, 0);
});
-run_test('mentions', () => {
+run_test("mentions", () => {
let counts = unread.get_counts();
assert.equal(counts.mentioned_message_count, 0);
assert.deepEqual(unread.get_msg_ids_for_mentions(), []);
@@ -486,13 +486,13 @@ run_test('mentions', () => {
const muted_stream_id = 401;
- muting.add_muted_topic(401, 'lunch');
+ muting.add_muted_topic(401, "lunch");
const already_read_message = {
id: 14,
- type: 'stream',
+ type: "stream",
stream_id: 400,
- topic: 'lunch',
+ topic: "lunch",
mentioned: true,
mentioned_me_directly: true,
unread: false,
@@ -500,9 +500,9 @@ run_test('mentions', () => {
const mention_me_message = {
id: 15,
- type: 'stream',
+ type: "stream",
stream_id: 400,
- topic: 'lunch',
+ topic: "lunch",
mentioned: true,
mentioned_me_directly: true,
unread: true,
@@ -510,9 +510,9 @@ run_test('mentions', () => {
const mention_all_message = {
id: 16,
- type: 'stream',
+ type: "stream",
stream_id: 400,
- topic: 'lunch',
+ topic: "lunch",
mentioned: true,
mentioned_me_directly: false,
unread: true,
@@ -521,9 +521,9 @@ run_test('mentions', () => {
// This message shouldn't affect the unread mention counts.
const muted_mention_all_message = {
id: 17,
- type: 'stream',
+ type: "stream",
stream_id: muted_stream_id,
- topic: 'lunch',
+ topic: "lunch",
mentioned: true,
mentioned_me_directly: false,
unread: true,
@@ -552,11 +552,11 @@ run_test('mentions', () => {
test_notifiable_count(counts.home_unread_messages, 0);
});
-run_test('mention updates', () => {
+run_test("mention updates", () => {
const message = {
id: 17,
unread: false,
- type: 'stream',
+ type: "stream",
};
function test_counted(counted) {
@@ -586,18 +586,18 @@ run_test('mention updates', () => {
test_counted(true);
});
-run_test('starring', () => {
+run_test("starring", () => {
// We don't need any setup here, because we just hard code
// this to [] in the code.
assert.deepEqual(unread.get_msg_ids_for_starred(), []);
});
-run_test('declare_bankruptcy', () => {
+run_test("declare_bankruptcy", () => {
const message = {
id: 16,
- type: 'whatever',
+ type: "whatever",
stream_id: 1999,
- topic: 'whatever',
+ topic: "whatever",
mentioned: true,
};
@@ -610,14 +610,14 @@ run_test('declare_bankruptcy', () => {
test_notifiable_count(counts.home_unread_messages, 0);
});
-run_test('message_unread', () => {
+run_test("message_unread", () => {
// Test some code that might be overly defensive, for line coverage sake.
assert(!unread.message_unread(undefined));
assert(unread.message_unread({unread: true}));
assert(!unread.message_unread({unread: false}));
});
-run_test('server_counts', () => {
+run_test("server_counts", () => {
// note that user_id 30 is "me"
page_params.unread_msgs = {
@@ -652,13 +652,13 @@ run_test('server_counts', () => {
unread.declare_bankruptcy();
unread.initialize();
- assert.equal(unread.num_unread_for_person('101'), 6);
- assert.equal(unread.num_unread_for_person('4,6,101'), 2);
- assert.equal(unread.num_unread_for_person('30'), 0);
+ assert.equal(unread.num_unread_for_person("101"), 6);
+ assert.equal(unread.num_unread_for_person("4,6,101"), 2);
+ assert.equal(unread.num_unread_for_person("30"), 0);
- assert.equal(unread.num_unread_for_topic(0, 'bogus'), 0);
- assert.equal(unread.num_unread_for_topic(1, 'bogus'), 0);
- assert.equal(unread.num_unread_for_topic(1, 'test'), 3);
+ assert.equal(unread.num_unread_for_topic(0, "bogus"), 0);
+ assert.equal(unread.num_unread_for_topic(1, "bogus"), 0);
+ assert.equal(unread.num_unread_for_topic(1, "test"), 3);
assert.equal(unread.unread_mentions_counter.size, 4);
@@ -666,17 +666,17 @@ run_test('server_counts', () => {
assert.equal(unread.unread_mentions_counter.size, 3);
unread.mark_as_read(35);
- assert.equal(unread.num_unread_for_topic(1, 'test'), 2);
+ assert.equal(unread.num_unread_for_topic(1, "test"), 2);
unread.mark_as_read(34);
- assert.equal(unread.num_unread_for_person('4,6,101'), 1);
+ assert.equal(unread.num_unread_for_person("4,6,101"), 1);
});
-run_test('empty_cases', () => {
+run_test("empty_cases", () => {
unread.declare_bankruptcy();
const stream_id = 999;
- let msg_ids = unread.get_msg_ids_for_topic(stream_id, 'LuNcH');
+ let msg_ids = unread.get_msg_ids_for_topic(stream_id, "LuNcH");
assert.deepEqual(msg_ids, []);
msg_ids = unread.get_msg_ids_for_stream(stream_id);
@@ -685,19 +685,19 @@ run_test('empty_cases', () => {
const missing_topics = unread.get_missing_topics({
stream_id: stream_id,
- topic_dict: 'should-never-be-referenced',
+ topic_dict: "should-never-be-referenced",
});
assert.deepEqual(missing_topics, []);
});
-run_test('errors', () => {
+run_test("errors", () => {
unread.declare_bankruptcy();
// Test unknown message leads to zero count
const message = {
id: 9,
- type: 'private',
+ type: "private",
display_recipient: [{id: 9999}],
};
diff --git a/frontend_tests/node_tests/upgrade.js b/frontend_tests/node_tests/upgrade.js
index 44aab358566..63266783984 100644
--- a/frontend_tests/node_tests/upgrade.js
+++ b/frontend_tests/node_tests/upgrade.js
@@ -9,24 +9,24 @@ let jquery_init;
global.$ = (f) => {jquery_init = f;};
-set_global('helpers', {
+set_global("helpers", {
set_tab: noop,
});
-set_global('StripeCheckout', {
+set_global("StripeCheckout", {
configure: noop,
});
-set_global('page_params', {
+set_global("page_params", {
annual_price: 8000,
monthly_price: 800,
seat_count: 8,
percent_off: 20,
});
-zrequire('helpers', "js/billing/helpers");
-zrequire('upgrade', "js/billing/upgrade");
-set_global('$', global.make_zjquery());
+zrequire("helpers", "js/billing/helpers");
+zrequire("upgrade", "js/billing/upgrade");
+set_global("$", global.make_zjquery());
run_test("initialize", () => {
let token_func;
@@ -68,9 +68,9 @@ run_test("initialize", () => {
};
StripeCheckout.configure = (config_opts) => {
- assert.equal(config_opts.image, '/static/images/logo/zulip-icon-128x128.png');
- assert.equal(config_opts.locale, 'auto');
- assert.equal(config_opts.key, '{{ publishable_key }}');
+ assert.equal(config_opts.image, "/static/images/logo/zulip-icon-128x128.png");
+ assert.equal(config_opts.locale, "auto");
+ assert.equal(config_opts.key, "{{ publishable_key }}");
token_func = config_opts.token;
return {
@@ -88,9 +88,9 @@ 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);
@@ -100,9 +100,9 @@ run_test("initialize", () => {
preventDefault: noop,
};
- const add_card_click_handler = $('#add-card-button').get_on_handler('click');
- const invoice_click_handler = $('#invoice-button').get_on_handler('click');
- const request_sponsorship_click_handler = $('#sponsorship-button').get_on_handler('click');
+ const add_card_click_handler = $("#add-card-button").get_on_handler("click");
+ const invoice_click_handler = $("#invoice-button").get_on_handler("click");
+ const request_sponsorship_click_handler = $("#sponsorship-button").get_on_handler("click");
helpers.is_valid_input = () => true;
@@ -118,7 +118,7 @@ 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) => {
@@ -126,7 +126,7 @@ run_test("initialize", () => {
assert.equal(prices.monthly, 640);
assert.equal(schedule, "monthly");
};
- const schedule_change_handler = $('input[type=radio][name=schedule]').get_on_handler('change');
+ const schedule_change_handler = $("input[type=radio][name=schedule]").get_on_handler("change");
schedule_change_handler.call({value: "monthly"});
assert.equal($("#autopay_annual_price").text(), "64");
@@ -135,7 +135,7 @@ 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.");
diff --git a/frontend_tests/node_tests/upload.js b/frontend_tests/node_tests/upload.js
index 259d4e86c49..226d39ba206 100644
--- a/frontend_tests/node_tests/upload.js
+++ b/frontend_tests/node_tests/upload.js
@@ -1,27 +1,27 @@
const rewiremock = require("rewiremock/node");
-set_global('$', global.make_zjquery());
-set_global('document', {
+set_global("$", global.make_zjquery());
+set_global("document", {
location: { },
});
-set_global('navigator', {
- userAgent: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)',
+set_global("navigator", {
+ userAgent: "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
});
-set_global('page_params', {
+set_global("page_params", {
max_file_upload_size: 25,
});
-set_global('csrf_token', "csrf_token");
-set_global('bridge', false);
+set_global("csrf_token", "csrf_token");
+set_global("bridge", false);
// Setting these up so that we can test that links to uploads within messages are
// automatically converted to server relative links.
-global.document.location.protocol = 'https:';
-global.document.location.host = 'foo.com';
+global.document.location.protocol = "https:";
+global.document.location.host = "foo.com";
-zrequire('compose_ui');
-zrequire('compose_state');
-zrequire('compose');
-zrequire('compose_actions');
+zrequire("compose_ui");
+zrequire("compose_state");
+zrequire("compose");
+zrequire("compose_actions");
const plugin_stub = {
prototype: {
@@ -29,9 +29,9 @@ const plugin_stub = {
},
};
-zrequire('upload');
+zrequire("upload");
-run_test('make_upload_absolute', () => {
+run_test("make_upload_absolute", () => {
let uri = "/user_uploads/5/d4/6lSlfIPIg9nDI2Upj0Mq_EbE/kerala.png";
const expected_uri = "https://foo.com/user_uploads/5/d4/6lSlfIPIg9nDI2Upj0Mq_EbE/kerala.png";
assert.equal(upload.make_upload_absolute(uri), expected_uri);
@@ -40,29 +40,29 @@ run_test('make_upload_absolute', () => {
assert.equal(upload.make_upload_absolute(uri), uri);
});
-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'));
+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("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'));
+ assert.equal(upload.get_item("drag_drop_container", {mode: "compose"}), $("#compose"));
- assert.equal(upload.get_item("textarea", {mode: "edit", row: 1}), $('#message_edit_content_1'));
+ assert.equal(upload.get_item("textarea", {mode: "edit", row: 1}), $("#message_edit_content_1"));
- $('#message_edit_content_2').closest = () => {
- $('#message_edit_form').set_find_results('.message_edit_save', $('.message_edit_save'));
- return $('#message_edit_form');
+ $("#message_edit_content_2").closest = () => {
+ $("#message_edit_form").set_find_results(".message_edit_save", $(".message_edit_save"));
+ return $("#message_edit_form");
};
- assert.equal(upload.get_item("send_button", {mode: "edit", row: 2}), $('.message_edit_save'));
+ 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"));
- $('#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'));
+ $("#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("source", {mode: "edit", row: 123}), "message-edit-file-input");
@@ -115,36 +115,36 @@ run_test('get_item', () => {
);
});
-run_test('hide_upload_status', () => {
- $('#compose-send-button').prop("disabled", "");
- $('#compose-send-status').addClass("alert-info").show();
+run_test("hide_upload_status", () => {
+ $("#compose-send-button").prop("disabled", "");
+ $("#compose-send-status").addClass("alert-info").show();
upload.hide_upload_status({mode: "compose"});
- assert.equal($('#compose-send-button').prop("disabled"), false);
- assert.equal($('#compose-send-button').hasClass("alert-info"), false);
- assert.equal($('#compose-send-button').visible(), false);
+ assert.equal($("#compose-send-button").prop("disabled"), false);
+ assert.equal($("#compose-send-button").hasClass("alert-info"), false);
+ assert.equal($("#compose-send-button").visible(), false);
});
-run_test('show_error_message', () => {
- $('#compose-send-button').prop("disabled", "");
- $('#compose-send-status').addClass("alert-info").removeClass("alert-error").hide();
- $('#compose-error-msg').text("");
- $('#compose-error-msg').hide();
+run_test("show_error_message", () => {
+ $("#compose-send-button").prop("disabled", "");
+ $("#compose-send-status").addClass("alert-info").removeClass("alert-error").hide();
+ $("#compose-error-msg").text("");
+ $("#compose-error-msg").hide();
upload.show_error_message({mode: "compose"}, "Error message");
- assert.equal($('#compose-send-button').prop("disabled"), false);
- assert($('#compose-send-status').hasClass("alert-error"));
- assert.equal($('#compose-send-status').hasClass("alert-info"), false);
- assert($('#compose-send-status').visible());
- assert.equal($('#compose-error-msg').text(), "Error message");
+ assert.equal($("#compose-send-button").prop("disabled"), false);
+ assert($("#compose-send-status").hasClass("alert-error"));
+ assert.equal($("#compose-send-status").hasClass("alert-info"), false);
+ assert($("#compose-send-status").visible());
+ assert.equal($("#compose-error-msg").text(), "Error message");
upload.show_error_message({mode: "compose"});
- assert.equal($('#compose-error-msg').text(), "translated: An unknown error occurred.");
+ assert.equal($("#compose-error-msg").text(), "translated: An unknown error occurred.");
});
-run_test('upload_files', () => {
+run_test("upload_files", () => {
let uppy_cancel_all_called = false;
let files = [
{
@@ -205,10 +205,10 @@ run_test('upload_files', () => {
$("#compose-send-button").attr("disabled", false);
$("#compose-send-status").removeClass("alert-info").hide();
upload.upload_files(uppy, config, files);
- assert.equal($("#compose-send-button").attr("disabled"), '');
+ assert.equal($("#compose-send-button").attr("disabled"), "");
assert($("#compose-send-status").hasClass("alert-info"));
assert($("#compose-send-status").visible());
- assert.equal($("<p>").text(), 'translated: Uploading…');
+ assert.equal($("<p>").text(), "translated: Uploading…");
assert(compose_ui_insert_syntax_and_focus_called);
assert(compose_ui_autosize_textarea_called);
assert(uppy_add_file_called);
@@ -248,7 +248,7 @@ run_test('upload_files', () => {
compose_ui_replace_syntax_called = true;
assert.equal(old_syntax, "[translated: Uploading budapest.png…]()");
assert.equal(new_syntax, "");
- assert.equal(textarea, $('#compose-textarea'));
+ assert.equal(textarea, $("#compose-textarea"));
};
on_click_close_button_callback();
assert(uppy_cancel_all_called);
@@ -257,15 +257,15 @@ run_test('upload_files', () => {
assert(compose_ui_replace_syntax_called);
hide_upload_status_called = false;
compose_ui_replace_syntax_called = false;
- $('#compose-textarea').val("user modified text");
+ $("#compose-textarea").val("user modified text");
on_click_close_button_callback();
assert(hide_upload_status_called);
assert(compose_ui_autosize_textarea_called);
assert(compose_ui_replace_syntax_called);
- assert($('#compose-textarea').val(), "user modified text");
+ assert($("#compose-textarea").val(), "user modified text");
});
-run_test('uppy_config', () => {
+run_test("uppy_config", () => {
let uppy_stub_called = false;
let uppy_set_meta_called = false;
let uppy_used_xhrupload = false;
@@ -282,21 +282,21 @@ run_test('uppy_config', () => {
return {
setMeta: (params) => {
uppy_set_meta_called = true;
- assert.equal(params.csrfmiddlewaretoken, 'csrf_token');
+ assert.equal(params.csrfmiddlewaretoken, "csrf_token");
},
use: (func, params) => {
const func_name = func.name;
if (func_name === "XHRUpload") {
uppy_used_xhrupload = true;
- assert.equal(params.endpoint, '/json/user_uploads');
+ assert.equal(params.endpoint, "/json/user_uploads");
assert.equal(params.formData, true);
- assert.equal(params.fieldName, 'file');
+ assert.equal(params.fieldName, "file");
assert.equal(params.limit, 5);
assert.equal(Object.keys(params.locale.strings).length, 1);
assert("timedOut" in params.locale.strings);
} else if (func_name === "ProgressBar") {
uppy_used_progressbar = true;
- assert.equal(params.target, '#compose-send-status');
+ assert.equal(params.target, "#compose-send-status");
assert.equal(params.hideAfterFinish, false);
} else {
/* istanbul ignore next */
@@ -307,7 +307,7 @@ run_test('uppy_config', () => {
};
}
uppy_stub.Plugin = plugin_stub;
- rewiremock.proxy(() => require("../../static/js/upload"), {'@uppy/core': uppy_stub});
+ rewiremock.proxy(() => require("../../static/js/upload"), {"@uppy/core": uppy_stub});
upload.setup_upload({mode: "compose"});
assert.equal(uppy_stub_called, true);
@@ -317,8 +317,8 @@ run_test('uppy_config', () => {
});
-run_test('file_input', () => {
- set_global('$', global.make_zjquery());
+run_test("file_input", () => {
+ set_global("$", global.make_zjquery());
upload.setup_upload({mode: "compose"});
@@ -340,8 +340,8 @@ run_test('file_input', () => {
assert(upload_files_called);
});
-run_test('file_drop', () => {
- set_global('$', global.make_zjquery());
+run_test("file_drop", () => {
+ set_global("$", global.make_zjquery());
upload.setup_upload({mode: "compose"});
@@ -378,8 +378,8 @@ run_test('file_drop', () => {
assert.equal(upload_files_called, true);
});
-run_test('copy_paste', () => {
- set_global('$', global.make_zjquery());
+run_test("copy_paste", () => {
+ set_global("$", global.make_zjquery());
upload.setup_upload({mode: "compose"});
@@ -419,8 +419,8 @@ run_test('copy_paste', () => {
assert.equal(upload_files_called, false);
});
-run_test('uppy_events', () => {
- set_global('$', global.make_zjquery());
+run_test("uppy_events", () => {
+ set_global("$", global.make_zjquery());
const callbacks = {};
let uppy_cancel_all_called = false;
let state = {};
@@ -450,7 +450,7 @@ run_test('uppy_events', () => {
};
}
uppy_stub.Plugin = plugin_stub;
- rewiremock.proxy(() => require("../../static/js/upload"), {'@uppy/core': uppy_stub});
+ rewiremock.proxy(() => require("../../static/js/upload"), {"@uppy/core": uppy_stub});
upload.setup_upload({mode: "compose"});
assert.equal(Object.keys(callbacks).length, 5);
@@ -472,7 +472,7 @@ run_test('uppy_events', () => {
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(textarea, $('#compose-textarea'));
+ assert.equal(textarea, $("#compose-textarea"));
};
let compose_ui_autosize_textarea_called = false;
compose_ui.autosize_textarea = () => {
@@ -497,7 +497,7 @@ run_test('uppy_events', () => {
assert.equal(compose_ui_autosize_textarea_called, false);
const on_complete_callback = callbacks.complete;
- global.patch_builtin('setTimeout', (func) => {
+ global.patch_builtin("setTimeout", (func) => {
func();
});
let hide_upload_status_called = false;
@@ -570,15 +570,15 @@ run_test('uppy_events', () => {
compose_ui_replace_syntax_called = true;
assert.equal(old_syntax, "[translated: Uploading copenhagen.png…]()");
assert.equal(new_syntax, "");
- assert.equal(textarea, $('#compose-textarea'));
+ assert.equal(textarea, $("#compose-textarea"));
};
on_restriction_failed_callback(file, null, null);
assert(compose_ui_replace_syntax_called);
compose_ui_replace_syntax_called = false;
- $('#comepose-textarea').val('user modified text');
+ $("#comepose-textarea").val("user modified text");
on_restriction_failed_callback(file, null, null);
assert(compose_ui_replace_syntax_called);
- assert.equal($('#comepose-textarea').val(), 'user modified text');
+ assert.equal($("#comepose-textarea").val(), "user modified text");
state = {
type: "error",
@@ -625,13 +625,13 @@ run_test('uppy_events', () => {
assert(show_error_message_called);
assert(compose_ui_replace_syntax_called);
show_error_message_called = false;
- $('#comepose-textarea').val('user modified text');
+ $("#comepose-textarea").val("user modified text");
uppy_cancel_all_called = false;
on_upload_error_callback(file, null);
assert(uppy_cancel_all_called);
assert(show_error_message_called);
assert(compose_ui_replace_syntax_called);
- assert.equal($('#comepose-textarea').val(), 'user modified text');
+ 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 cb5f483b401..d7c04cd0004 100644
--- a/frontend_tests/node_tests/user_events.js
+++ b/frontend_tests/node_tests/user_events.js
@@ -1,60 +1,60 @@
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
-zrequire('people');
-const settings_config = zrequire('settings_config');
-zrequire('user_events');
+zrequire("people");
+const settings_config = zrequire("settings_config");
+zrequire("user_events");
-set_global('activity', {
+set_global("activity", {
redraw: function () {},
});
-set_global('settings_linkifiers', {
+set_global("settings_linkifiers", {
maybe_disable_widgets: function () {},
});
-set_global('settings_org', {
+set_global("settings_org", {
maybe_disable_widgets: function () {},
});
-set_global('settings_profile_fields', {
+set_global("settings_profile_fields", {
maybe_disable_widgets: function () {},
});
-set_global('settings_streams', {
+set_global("settings_streams", {
maybe_disable_widgets: function () {},
});
-set_global('settings_users', {
+set_global("settings_users", {
update_user_data: function () {},
});
-set_global('gear_menu', {
+set_global("gear_menu", {
update_org_settings_menu_item: function () {},
});
-set_global('page_params', {
+set_global("page_params", {
is_admin: true,
});
-set_global('pm_list', {
+set_global("pm_list", {
update_private_messages: function () {},
});
-set_global('narrow_state', {
+set_global("narrow_state", {
update_email: function () {},
});
-set_global('compose', {
+set_global("compose", {
update_email: function () {},
});
-set_global('settings_account', {
+set_global("settings_account", {
update_email: function () {},
update_full_name: function () {},
});
-set_global('message_live_update', {
+set_global("message_live_update", {
});
const me = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 30,
- full_name: 'Me Myself',
+ full_name: "Me Myself",
is_admin: true,
};
@@ -66,13 +66,13 @@ function initialize() {
initialize();
-run_test('updates', () => {
+run_test("updates", () => {
let person;
const isaac = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 32,
- full_name: 'Isaac Newton',
+ full_name: "Isaac Newton",
};
people.add_active_user(isaac);
@@ -88,7 +88,7 @@ run_test('updates', () => {
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.full_name, "Isaac Newton");
assert.equal(person.is_admin, true);
user_events.update_person({user_id: isaac.user_id,
@@ -103,31 +103,31 @@ run_test('updates', () => {
full_name = full_name_arg;
};
- user_events.update_person({user_id: isaac.user_id, full_name: 'Sir Isaac'});
+ user_events.update_person({user_id: isaac.user_id, full_name: "Sir Isaac"});
person = people.get_by_email(isaac.email);
- assert.equal(person.full_name, 'Sir Isaac');
+ assert.equal(person.full_name, "Sir Isaac");
assert.equal(person.is_admin, true);
assert.equal(user_id, isaac.user_id);
- assert.equal(full_name, 'Sir Isaac');
+ assert.equal(full_name, "Sir Isaac");
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'});
- assert.equal(people.my_full_name(), 'Me V2');
+ user_events.update_person({user_id: me.user_id, full_name: "Me V2"});
+ assert.equal(people.my_full_name(), "Me V2");
assert.equal(user_id, me.user_id);
- assert.equal(full_name, 'Me V2');
+ assert.equal(full_name, "Me V2");
- user_events.update_person({user_id: isaac.user_id, new_email: '[email protected]'});
+ user_events.update_person({user_id: isaac.user_id, new_email: "[email protected]"});
person = people.get_by_user_id(isaac.user_id);
- assert.equal(person.email, '[email protected]');
- assert.equal(person.full_name, 'Sir Isaac');
+ assert.equal(person.email, "[email protected]");
+ assert.equal(person.full_name, "Sir Isaac");
- user_events.update_person({user_id: me.user_id, new_email: '[email protected]'});
+ user_events.update_person({user_id: me.user_id, new_email: "[email protected]"});
person = people.get_by_user_id(me.user_id);
- assert.equal(person.email, '[email protected]');
- assert.equal(person.full_name, 'Me V2');
+ assert.equal(person.email, "[email protected]");
+ assert.equal(person.full_name, "Me V2");
let avatar_url;
global.message_live_update.update_avatar = function (user_id_arg, avatar_url_arg) {
@@ -135,52 +135,52 @@ run_test('updates', () => {
avatar_url = avatar_url_arg;
};
- user_events.update_person({user_id: isaac.user_id, full_name: 'Sir Isaac'});
+ user_events.update_person({user_id: isaac.user_id, full_name: "Sir Isaac"});
person = people.get_by_email(isaac.email);
- assert.equal(person.full_name, 'Sir Isaac');
+ assert.equal(person.full_name, "Sir Isaac");
assert.equal(person.is_admin, true);
assert.equal(user_id, isaac.user_id);
- assert.equal(full_name, 'Sir Isaac');
+ assert.equal(full_name, "Sir Isaac");
- user_events.update_person({user_id: isaac.user_id, avatar_url: 'http://gravatar.com/123456'});
+ user_events.update_person({user_id: isaac.user_id, avatar_url: "http://gravatar.com/123456"});
person = people.get_by_email(isaac.email);
- assert.equal(person.full_name, 'Sir Isaac');
+ assert.equal(person.full_name, "Sir Isaac");
assert.equal(user_id, isaac.user_id);
assert.equal(person.avatar_url, avatar_url);
- user_events.update_person({user_id: me.user_id, avatar_url: 'http://gravatar.com/789456'});
+ user_events.update_person({user_id: me.user_id, avatar_url: "http://gravatar.com/789456"});
person = people.get_by_email(me.email);
- assert.equal(person.full_name, 'Me V2');
+ assert.equal(person.full_name, "Me V2");
assert.equal(user_id, me.user_id);
assert.equal(person.avatar_url, avatar_url);
- user_events.update_person({user_id: me.user_id, timezone: 'UTC'});
+ user_events.update_person({user_id: me.user_id, timezone: "UTC"});
person = people.get_by_email(me.email);
assert(person.timezone);
- blueslip.expect('error', 'Got update_person event for unexpected user 29');
- blueslip.expect('error', 'Unknown user_id in get_by_user_id: 29');
- assert(!user_events.update_person({user_id: 29, full_name: 'Sir Isaac Newton'}));
+ blueslip.expect("error", "Got update_person event for unexpected user 29");
+ blueslip.expect("error", "Unknown user_id in get_by_user_id: 29");
+ 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>');
+ assert.equal(person.profile_data[3].value, "Value");
+ assert.equal(person.profile_data[3].rendered_value, "<p>Value</p>");
let updated = false;
settings_account.update_email = (email) => {
- assert.equal(email, '[email protected]');
+ assert.equal(email, "[email protected]");
updated = true;
};
- user_events.update_person({user_id: me.user_id, delivery_email: '[email protected]'});
+ user_events.update_person({user_id: me.user_id, delivery_email: "[email protected]"});
assert(updated);
const test_bot = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 35,
- full_name: 'Test Bot',
+ full_name: "Test Bot",
is_bot: true,
bot_owner_id: isaac.id,
};
diff --git a/frontend_tests/node_tests/user_groups.js b/frontend_tests/node_tests/user_groups.js
index 452b37e9326..eb264240a86 100644
--- a/frontend_tests/node_tests/user_groups.js
+++ b/frontend_tests/node_tests/user_groups.js
@@ -1,9 +1,9 @@
-zrequire('user_groups');
+zrequire("user_groups");
-run_test('user_groups', () => {
+run_test("user_groups", () => {
const students = {
- name: 'Students',
+ name: "Students",
id: 0,
members: [1, 2],
};
@@ -15,13 +15,13 @@ run_test('user_groups', () => {
assert.equal(user_groups.get_user_group_from_id(students.id), students);
const admins = {
- name: 'Admins',
- description: 'foo',
+ name: "Admins",
+ description: "foo",
id: 1,
members: [3],
};
const all = {
- name: 'Everyone',
+ name: "Everyone",
id: 2,
members: [1, 2, 3],
};
@@ -47,12 +47,12 @@ run_test('user_groups', () => {
user_groups.update(update_des_event);
assert.equal(user_groups.get_user_group_from_id(admins.id).description, "administer");
- blueslip.expect('error', 'Unknown group_id in get_user_group_from_id: ' + all.id);
+ blueslip.expect("error", "Unknown group_id in get_user_group_from_id: " + all.id);
assert.equal(user_groups.get_user_group_from_id(all.id), undefined);
user_groups.remove(students);
- blueslip.expect('error', 'Unknown group_id in get_user_group_from_id: ' + students.id);
+ blueslip.expect("error", "Unknown group_id in get_user_group_from_id: " + students.id);
assert.equal(user_groups.get_user_group_from_id(students.id), undefined);
assert.equal(user_groups.get_user_group_from_name(all.name), undefined);
@@ -61,8 +61,8 @@ run_test('user_groups', () => {
user_groups.add(all);
const user_groups_array = user_groups.get_realm_user_groups();
assert.equal(user_groups_array.length, 2);
- assert.equal(user_groups_array[1].name, 'Everyone');
- assert.equal(user_groups_array[0].name, 'new admins');
+ assert.equal(user_groups_array[1].name, "Everyone");
+ assert.equal(user_groups_array[0].name, "new admins");
assert(!user_groups.is_member_of(admins.id, 4));
assert(user_groups.is_member_of(admins.id, 3));
@@ -77,7 +77,7 @@ run_test('user_groups', () => {
assert(user_groups.is_user_group(admins));
const object = {
- name: 'core',
+ name: "core",
id: 3,
};
assert(!user_groups.is_user_group(object));
@@ -85,6 +85,6 @@ run_test('user_groups', () => {
user_groups.init();
assert.equal(user_groups.get_realm_user_groups().length, 0);
- blueslip.expect('error', 'Could not find user group with ID -1');
+ blueslip.expect("error", "Could not find user group with ID -1");
assert.equal(user_groups.is_member_of(-1, 15), false);
});
diff --git a/frontend_tests/node_tests/user_pill.js b/frontend_tests/node_tests/user_pill.js
index 0b3888033c1..5383e1c8652 100644
--- a/frontend_tests/node_tests/user_pill.js
+++ b/frontend_tests/node_tests/user_pill.js
@@ -1,40 +1,40 @@
-zrequire('people');
-set_global('md5', (s) => 'md5-' + s);
-zrequire('user_pill');
+zrequire("people");
+set_global("md5", (s) => "md5-" + s);
+zrequire("user_pill");
-set_global('page_params', {
+set_global("page_params", {
});
const alice = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 99,
- full_name: 'Alice Barson',
+ full_name: "Alice Barson",
};
const isaac = {
- email: '[email protected]',
+ email: "[email protected]",
user_id: 102,
- full_name: 'Isaac Newton',
+ full_name: "Isaac Newton",
};
const bogus_item = {
- email: '[email protected]',
- display_value: '[email protected]',
+ email: "[email protected]",
+ display_value: "[email protected]",
};
const isaac_item = {
- email: '[email protected]',
- display_value: 'Isaac Newton',
+ email: "[email protected]",
+ display_value: "Isaac Newton",
user_id: isaac.user_id,
img_src: `/avatar/${isaac.user_id}&s=50`,
};
-run_test('setup', () => {
+run_test("setup", () => {
people.add_active_user(alice);
people.add_active_user(isaac);
});
-run_test('create_item', () => {
+run_test("create_item", () => {
function test_create_item(email, current_items, expected_item) {
const item = user_pill.create_item_from_email(email, current_items);
@@ -43,24 +43,24 @@ run_test('create_item', () => {
page_params.realm_is_zephyr_mirror_realm = true;
- test_create_item('[email protected]', [], bogus_item);
- test_create_item('[email protected]', [bogus_item], undefined);
+ test_create_item("[email protected]", [], bogus_item);
+ test_create_item("[email protected]", [bogus_item], undefined);
- test_create_item('[email protected]', [], isaac_item);
- test_create_item('[email protected]', [isaac_item], undefined);
+ test_create_item("[email protected]", [], isaac_item);
+ test_create_item("[email protected]", [isaac_item], undefined);
page_params.realm_is_zephyr_mirror_realm = false;
- test_create_item('[email protected]', [], undefined);
- test_create_item('[email protected]', [], isaac_item);
- test_create_item('[email protected]', [isaac_item], undefined);
+ test_create_item("[email protected]", [], undefined);
+ test_create_item("[email protected]", [], isaac_item);
+ test_create_item("[email protected]", [isaac_item], undefined);
});
-run_test('get_email', () => {
- assert.equal(user_pill.get_email_from_item({email: '[email protected]'}), '[email protected]');
+run_test("get_email", () => {
+ assert.equal(user_pill.get_email_from_item({email: "[email protected]"}), "[email protected]");
});
-run_test('append', () => {
+run_test("append", () => {
let appended;
let cleared;
@@ -90,7 +90,7 @@ run_test('append', () => {
assert(cleared);
});
-run_test('get_items', () => {
+run_test("get_items", () => {
const items = [isaac_item, bogus_item];
const pill_widget = {
@@ -100,7 +100,7 @@ run_test('get_items', () => {
assert.deepEqual(user_pill.get_user_ids(pill_widget), [isaac.user_id]);
});
-run_test('typeahead', () => {
+run_test("typeahead", () => {
const items = [isaac_item, bogus_item];
const pill_widget = {
diff --git a/frontend_tests/node_tests/user_status.js b/frontend_tests/node_tests/user_status.js
index b3cde3631a0..4295223b48f 100644
--- a/frontend_tests/node_tests/user_status.js
+++ b/frontend_tests/node_tests/user_status.js
@@ -1,10 +1,10 @@
-set_global('channel', {});
-zrequire('user_status');
+set_global("channel", {});
+zrequire("user_status");
function initialize() {
const params = {
user_status: {
- 1: {away: true, status_text: 'in a meeting'},
+ 1: {away: true, status_text: "in a meeting"},
2: {away: true},
3: {away: true},
},
@@ -12,7 +12,7 @@ function initialize() {
user_status.initialize(params);
}
-run_test('basics', () => {
+run_test("basics", () => {
initialize();
assert(user_status.is_away(2));
assert(!user_status.is_away(99));
@@ -23,22 +23,22 @@ run_test('basics', () => {
user_status.revoke_away(4);
assert(!user_status.is_away(4));
- assert.equal(user_status.get_status_text(1), 'in a meeting');
+ assert.equal(user_status.get_status_text(1), "in a meeting");
user_status.set_status_text({
user_id: 2,
- status_text: 'out to lunch',
+ status_text: "out to lunch",
});
- assert.equal(user_status.get_status_text(2), 'out to lunch');
+ assert.equal(user_status.get_status_text(2), "out to lunch");
user_status.set_status_text({
user_id: 2,
- status_text: '',
+ status_text: "",
});
assert.equal(user_status.get_status_text(2), undefined);
});
-run_test('server', () => {
+run_test("server", () => {
initialize();
let sent_data;
@@ -46,7 +46,7 @@ run_test('server', () => {
channel.post = (opts) => {
sent_data = opts.data;
- assert.equal(opts.url, '/json/users/me/status');
+ assert.equal(opts.url, "/json/users/me/status");
success = opts.success;
};
@@ -61,7 +61,7 @@ run_test('server', () => {
let called;
user_status.server_update({
- status_text: 'out to lunch',
+ status_text: "out to lunch",
success: () => {
called = true;
},
@@ -71,8 +71,8 @@ run_test('server', () => {
assert(called);
});
-run_test('defensive checks', () => {
- blueslip.expect('error', 'need ints for user_id', 2);
- user_status.set_away('string');
- user_status.revoke_away('string');
+run_test("defensive checks", () => {
+ blueslip.expect("error", "need ints for user_id", 2);
+ user_status.set_away("string");
+ user_status.revoke_away("string");
});
diff --git a/frontend_tests/node_tests/util.js b/frontend_tests/node_tests/util.js
index 3a144d763a7..76219dcc6ca 100644
--- a/frontend_tests/node_tests/util.js
+++ b/frontend_tests/node_tests/util.js
@@ -1,11 +1,11 @@
const { JSDOM } = require("jsdom");
-set_global('$', global.make_zjquery());
-set_global('DOMParser', new JSDOM().window.DOMParser);
-set_global('document', {});
-const util = zrequire('util');
+set_global("$", global.make_zjquery());
+set_global("DOMParser", new JSDOM().window.DOMParser);
+set_global("document", {});
+const util = zrequire("util");
-run_test('CachedValue', () => {
+run_test("CachedValue", () => {
let x = 5;
const cv = new util.CachedValue({
@@ -23,24 +23,24 @@ run_test('CachedValue', () => {
});
-run_test('get_reload_topic', () => {
- assert.equal(util.get_reload_topic({subject: 'foo'}), 'foo');
- assert.equal(util.get_reload_topic({topic: 'bar'}), 'bar');
+run_test("get_reload_topic", () => {
+ assert.equal(util.get_reload_topic({subject: "foo"}), "foo");
+ assert.equal(util.get_reload_topic({topic: "bar"}), "bar");
});
-run_test('extract_pm_recipients', () => {
- assert.equal(util.extract_pm_recipients('[email protected], [email protected]').length, 2);
- assert.equal(util.extract_pm_recipients('[email protected], ').length, 1);
+run_test("extract_pm_recipients", () => {
+ assert.equal(util.extract_pm_recipients("[email protected], [email protected]").length, 2);
+ assert.equal(util.extract_pm_recipients("[email protected], ").length, 1);
});
-run_test('is_pm_recipient', () => {
- const message = { to_user_ids: '31,32,33' };
+run_test("is_pm_recipient", () => {
+ const message = { to_user_ids: "31,32,33" };
assert(util.is_pm_recipient(31, message));
assert(util.is_pm_recipient(32, message));
assert(!util.is_pm_recipient(34, message));
});
-run_test('lower_bound', () => {
+run_test("lower_bound", () => {
let arr = [10, 20, 30, 40, 50];
assert.equal(util.lower_bound(arr, 5), 0);
assert.equal(util.lower_bound(arr, 10), 0);
@@ -61,71 +61,71 @@ run_test('lower_bound', () => {
});
-run_test('same_recipient', () => {
+run_test("same_recipient", () => {
assert(util.same_recipient(
- {type: 'stream', stream_id: 101, topic: 'Bar'},
- {type: 'stream', stream_id: 101, topic: 'bar'}));
+ {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'}));
+ {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'}));
+ {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'}));
+ {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'}));
+ {type: "stream", stream_id: 101, topic: "Bar"},
+ {type: "private"}));
assert(!util.same_recipient(
- {type: 'private', to_user_ids: undefined},
- {type: 'private'}));
+ {type: "private", to_user_ids: undefined},
+ {type: "private"}));
assert(!util.same_recipient(
- {type: 'unknown type'},
- {type: 'unknown type'}));
+ {type: "unknown type"},
+ {type: "unknown type"}));
assert(!util.same_recipient(
undefined,
- {type: 'private'}));
+ {type: "private"}));
assert(!util.same_recipient(undefined, undefined));
});
-run_test('robust_uri_decode', () => {
- assert.equal(util.robust_uri_decode('xxx%3Ayyy'), 'xxx:yyy');
- assert.equal(util.robust_uri_decode('xxx%3'), 'xxx');
+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');
+ util.robust_uri_decode("%E0%A4%A");
} catch (e) {
- assert.equal(e, 'foo');
+ assert.equal(e, "foo");
}
});
-run_test('dumb_strcmp', () => {
+run_test("dumb_strcmp", () => {
Intl.Collator = undefined;
const strcmp = util.make_strcmp();
- assert.equal(strcmp('a', 'b'), -1);
- assert.equal(strcmp('c', 'c'), 0);
- assert.equal(strcmp('z', 'y'), 1);
+ assert.equal(strcmp("a", "b"), -1);
+ assert.equal(strcmp("c", "c"), 0);
+ assert.equal(strcmp("z", "y"), 1);
});
-run_test('get_edit_event_orig_topic', () => {
- assert.equal(util.get_edit_event_orig_topic({orig_subject: 'lunch'}), 'lunch');
+run_test("get_edit_event_orig_topic", () => {
+ assert.equal(util.get_edit_event_orig_topic({orig_subject: "lunch"}), "lunch");
});
-run_test('get_edit_event_prev_topic', () => {
- assert.equal(util.get_edit_event_prev_topic({prev_subject: 'dinner'}), 'dinner');
+run_test("get_edit_event_prev_topic", () => {
+ assert.equal(util.get_edit_event_prev_topic({prev_subject: "dinner"}), "dinner");
});
-run_test('is_mobile', () => {
+run_test("is_mobile", () => {
global.window.navigator = { userAgent: "Android" };
assert(util.is_mobile());
@@ -133,7 +133,7 @@ run_test('is_mobile', () => {
assert(!util.is_mobile());
});
-run_test('array_compare', () => {
+run_test("array_compare", () => {
assert(util.array_compare([], []));
assert(util.array_compare([1, 2, 3], [1, 2, 3]));
assert(!util.array_compare([1, 2], [1, 2, 3]));
@@ -141,13 +141,13 @@ run_test('array_compare', () => {
assert(!util.array_compare([1, 2, 3, 4], [1, 2, 3, 5]));
});
-run_test('normalize_recipients', () => {
+run_test("normalize_recipients", () => {
assert.equal(
});
-run_test('random_int', () => {
+run_test("random_int", () => {
const min = 0;
const max = 100;
@@ -159,53 +159,53 @@ run_test('random_int', () => {
});
});
-run_test('all_and_everyone_mentions_regexp', () => {
+run_test("all_and_everyone_mentions_regexp", () => {
const messages_with_all_mentions = [
- '@**all**',
- 'some text before @**all** some text after',
- '@**all** some text after only',
- 'some text before only @**all**',
+ "@**all**",
+ "some text before @**all** some text after",
+ "@**all** some text after only",
+ "some text before only @**all**",
];
const messages_with_everyone_mentions = [
- '@**everyone**',
- 'some text before @**everyone** some text after',
- '@**everyone** some text after only',
- 'some text before only @**everyone**',
+ "@**everyone**",
+ "some text before @**everyone** some text after",
+ "@**everyone** some text after only",
+ "some text before only @**everyone**",
];
const messages_with_stream_mentions = [
- '@**stream**',
- 'some text before @**stream** some text after',
- '@**stream** some text after only',
- 'some text before only @**stream**',
+ "@**stream**",
+ "some text before @**stream** some text after",
+ "@**stream** some text after only",
+ "some text before only @**stream**",
];
const messages_without_all_mentions = [
- '@all',
- 'some text before @all some text after',
- '`@everyone`',
- '`@**everyone**`',
- 'some_email@**everyone**.com',
+ "@all",
+ "some text before @all some text after",
+ "`@everyone`",
+ "`@**everyone**`",
+ "some_email@**everyone**.com",
];
const messages_without_everyone_mentions = [
- 'some text before @everyone some text after',
- '@everyone',
- '`@everyone`',
- '`@**everyone**`',
- 'some_email@**everyone**.com',
+ "some text before @everyone some text after",
+ "@everyone",
+ "`@everyone`",
+ "`@**everyone**`",
+ "some_email@**everyone**.com",
];
const messages_without_stream_mentions = [
- 'some text before @stream some text after',
- '@stream',
- '`@stream`',
- '`@**stream**`',
- 'some_email@**stream**.com',
+ "some text before @stream some text after",
+ "@stream",
+ "`@stream`",
+ "`@**stream**`",
+ "some_email@**stream**.com",
];
let i;
@@ -234,44 +234,44 @@ run_test('all_and_everyone_mentions_regexp', () => {
}
});
-run_test('move_array_elements_to_front', () => {
+run_test("move_array_elements_to_front", () => {
const strings = [
- 'string1',
- 'string3',
- 'string2',
- 'string4',
+ "string1",
+ "string3",
+ "string2",
+ "string4",
];
const strings_selection = [
- 'string4',
- 'string1',
+ "string4",
+ "string1",
];
const strings_expected = [
- 'string1',
- 'string4',
- 'string3',
- 'string2',
+ "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);
const emails = [
- 'test@localhost',
- 'test@invalid@email',
+ "test@localhost",
+ "test@invalid@email",
];
const emails_selection = [
- 'test@localhost',
- 'test@invalid@email',
+ "test@localhost",
+ "test@invalid@email",
];
const emails_expected = [
- 'test@localhost',
- 'test@invalid@email',
+ "test@localhost",
+ "test@invalid@email",
];
const emails_actual = util.move_array_elements_to_front(emails, emails_selection);
let i;
@@ -303,8 +303,8 @@ run_test("clean_user_content_links", () => {
),
'<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>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 d28be64db41..24f74d435a7 100644
--- a/frontend_tests/node_tests/vdom.js
+++ b/frontend_tests/node_tests/vdom.js
@@ -1,11 +1,11 @@
-zrequire('vdom');
+zrequire("vdom");
-run_test('basics', () => {
+run_test("basics", () => {
const opts = {
keyed_nodes: [],
attrs: [
- ['class', 'foo'],
- ['title', 'cats & <"dogs">'],
+ ["class", "foo"],
+ ["title", 'cats & <"dogs">'],
],
};
@@ -16,11 +16,11 @@ run_test('basics', () => {
assert.equal(
html,
'<ul class="foo" title="cats &amp; &lt;&quot;dogs&quot;&gt;">\n\n' +
- '</ul>',
+ "</ul>",
);
});
-run_test('attribute escaping', () => {
+run_test("attribute escaping", () => {
// So far most of the time our attributes are
// hard-coded classes like "expanded_private_messages",
// but we need to be defensive about future code
@@ -28,8 +28,8 @@ run_test('attribute escaping', () => {
const opts = {
keyed_nodes: [],
attrs: [
- ['class', '">something evil<div class="'],
- ['title', 'apples & oranges'],
+ ["class", '">something evil<div class="'],
+ ["title", "apples & oranges"],
],
};
@@ -44,13 +44,13 @@ run_test('attribute escaping', () => {
);
});
-run_test('attribute updates', () => {
+run_test("attribute updates", () => {
const opts = {
keyed_nodes: [],
attrs: [
- ['class', 'same'],
- ['color', 'blue'],
- ['id', '101'],
+ ["class", "same"],
+ ["color", "blue"],
+ ["id", "101"],
],
};
@@ -61,7 +61,7 @@ run_test('attribute updates', () => {
assert.equal(
html,
'<ul class="same" color="blue" id="101">\n\n' +
- '</ul>',
+ "</ul>",
);
let updated;
@@ -72,13 +72,13 @@ run_test('attribute updates', () => {
children: () => [],
attr: (k, v) => {
- assert.equal(k, 'color');
- assert.equal(v, 'red');
+ assert.equal(k, "color");
+ assert.equal(v, "red");
updated = true;
},
removeAttr: (k) => {
- assert.equal(k, 'id');
+ assert.equal(k, "id");
removed = true;
},
};
@@ -87,8 +87,8 @@ run_test('attribute updates', () => {
const new_opts = {
keyed_nodes: [],
attrs: [
- ['class', 'same'], // unchanged
- ['color', 'red'],
+ ["class", "same"], // unchanged
+ ["color", "red"],
],
};
@@ -102,7 +102,7 @@ run_test('attribute updates', () => {
});
function make_child(i, name) {
- const render = () => '<li>' + name + '</li>';
+ const render = () => "<li>" + name + "</li>";
const eq = (other) => name === other.name;
@@ -115,10 +115,10 @@ function make_child(i, name) {
}
function make_children(lst) {
- return lst.map((i) => make_child(i, 'foo' + i));
+ return lst.map((i) => make_child(i, "foo" + i));
}
-run_test('children', () => {
+run_test("children", () => {
let rendered_html;
function replace_content(html) {
@@ -140,11 +140,11 @@ 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.
@@ -152,7 +152,7 @@ run_test('children', () => {
const new_opts = {
keyed_nodes: new_nodes,
attrs: [
- ['class', 'main'],
+ ["class", "main"],
],
};
@@ -162,13 +162,13 @@ run_test('children', () => {
assert.equal(
rendered_html,
'<ul class="main">\n' +
- '<li>foo4</li>\n' +
- '<li>foo5</li>\n' +
- '</ul>',
+ "<li>foo4</li>\n" +
+ "<li>foo5</li>\n" +
+ "</ul>",
);
});
-run_test('partial updates', () => {
+run_test("partial updates", () => {
let rendered_html;
let replace_content = (html) => {
@@ -190,15 +190,15 @@ 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 = () => {
- throw Error('should not replace entire html');
+ throw Error("should not replace entire html");
};
let patched_html;
@@ -217,7 +217,7 @@ run_test('partial updates', () => {
});
const new_nodes = make_children([1, 2, 3]);
- new_nodes[0] = make_child(1, 'modified1');
+ new_nodes[0] = make_child(1, "modified1");
const new_opts = {
keyed_nodes: new_nodes,
@@ -227,12 +227,12 @@ run_test('partial updates', () => {
const new_ul = vdom.ul(new_opts);
vdom.update(replace_content, find, new_ul, ul);
- assert.equal(patched_html, '<li>modified1</li>');
+ assert.equal(patched_html, "<li>modified1</li>");
});
-run_test('eq_array easy cases', () => {
+run_test("eq_array easy cases", () => {
const bogus_eq = () => {
- throw Error('we should not be comparing elements');
+ throw Error("we should not be comparing elements");
};
assert.equal(
@@ -260,27 +260,27 @@ run_test('eq_array easy cases', () => {
assert.equal(vdom.eq_array(x, z, eq), false);
});
-run_test('eq_array elementwise', () => {
+run_test("eq_array elementwise", () => {
const a = [51, 32, 93];
const b = [31, 52, 43];
const eq = (a, b) => a % 10 === b % 10;
assert.equal(vdom.eq_array(a, b, eq), true);
});
-run_test('error checking', () => {
+run_test("error checking", () => {
blueslip.expect(
- 'error',
- 'We need keyed_nodes for updates.');
+ "error",
+ "We need keyed_nodes for updates.");
- const replace_content = 'whatever';
- const find = 'whatever';
+ const replace_content = "whatever";
+ const find = "whatever";
const ul = {opts: { attrs: [] }};
vdom.update(replace_content, find, ul, ul);
blueslip.expect(
- 'error',
- 'We need keyed_nodes to render innards.');
+ "error",
+ "We need keyed_nodes to render innards.");
vdom.render_tag(ul);
});
diff --git a/frontend_tests/node_tests/widgetize.js b/frontend_tests/node_tests/widgetize.js
index 8200e278b69..1e616209a58 100644
--- a/frontend_tests/node_tests/widgetize.js
+++ b/frontend_tests/node_tests/widgetize.js
@@ -1,9 +1,9 @@
-set_global('$', global.make_zjquery());
-set_global('poll_widget', {});
-set_global('tictactoe_widget', {});
-set_global('todo_widget', {});
-set_global('zform', {});
-set_global('document', 'document-stub');
+set_global("$", global.make_zjquery());
+set_global("poll_widget", {});
+set_global("tictactoe_widget", {});
+set_global("todo_widget", {});
+set_global("zform", {});
+set_global("document", "document-stub");
const noop = () => {};
const return_true = () => true;
@@ -11,18 +11,18 @@ const return_false = () => false;
$(document).on = noop;
-zrequire('widgetize');
+zrequire("widgetize");
-set_global('narrow_state', {});
-set_global('current_msg_list', {});
+set_global("narrow_state", {});
+set_global("current_msg_list", {});
-run_test('activate', () => {
+run_test("activate", () => {
// Both widgetize.activate and widgetize.handle_event are tested
// here to use the "caching" of widgets
- const row = $.create('<stub message row>');
- row.attr('id', 'zhome2909');
- const message_content = $.create('#zhome2909');
- row.set_find_results('.message_content', message_content);
+ const row = $.create("<stub message row>");
+ row.attr("id", "zhome2909");
+ const message_content = $.create("#zhome2909");
+ row.set_find_results(".message_content", message_content);
const events = [
{
@@ -53,16 +53,16 @@ run_test('activate', () => {
const opts = {
events: events.slice(),
- extra_data: '',
+ extra_data: "",
message: {
id: 2001,
},
post_to_server: (data) => {
- assert.equal(data.msg_type, 'widget');
- assert.equal(data.data, 'test_data');
+ assert.equal(data.msg_type, "widget");
+ assert.equal(data.data, "test_data");
},
row: row,
- widget_type: 'poll',
+ widget_type: "poll",
};
narrow_state.active = return_false;
@@ -75,20 +75,20 @@ run_test('activate', () => {
poll_widget.activate = (data) => {
is_widget_activated = true;
widget_elem = data.elem;
- assert(widget_elem.hasClass('widget-content'));
+ assert(widget_elem.hasClass("widget-content"));
widget_elem.handle_events = (e) => {
is_event_handled = true;
assert.notDeepStrictEqual(e, events);
events.shift();
assert.deepStrictEqual(e, events);
};
- data.callback('test_data');
+ data.callback("test_data");
};
message_content.append = (elem) => {
is_widget_elem_inserted = true;
assert.equal(elem, widget_elem);
- assert(elem.hasClass('widget-content'));
+ assert(elem.hasClass("widget-content"));
};
is_widget_elem_inserted = false;
@@ -124,18 +124,18 @@ run_test('activate', () => {
assert(!is_widget_activated);
assert(!is_event_handled);
- blueslip.expect('warn', 'unknown widget_type');
+ blueslip.expect("warn", "unknown widget_type");
narrow_state.active = return_false;
is_widget_elem_inserted = false;
is_widget_activated = false;
is_event_handled = false;
- opts.widget_type = 'invalid_widget';
+ opts.widget_type = "invalid_widget";
widgetize.activate(opts);
assert(!is_widget_elem_inserted);
assert(!is_widget_activated);
assert(!is_event_handled);
- assert.equal(blueslip.get_test_logs('warn')[0].more_info, 'invalid_widget');
+ assert.equal(blueslip.get_test_logs("warn")[0].more_info, "invalid_widget");
/* Testing widgetize.handle_events */
const post_activate_event = {
diff --git a/frontend_tests/node_tests/zblueslip.js b/frontend_tests/node_tests/zblueslip.js
index 51005f3b018..52214d1fd19 100644
--- a/frontend_tests/node_tests/zblueslip.js
+++ b/frontend_tests/node_tests/zblueslip.js
@@ -22,10 +22,10 @@ Read the following contents for an overview of how zblueslip works. Also take a
look at `node_tests/people_errors.js` for actual usage of this module.
*/
-run_test('basics', () => {
+run_test("basics", () => {
// Let's create a sample piece of code to test:
function throw_an_error() {
- blueslip.error('world');
+ blueslip.error("world");
}
// Since the error 'world' is not being expected, blueslip will
@@ -34,7 +34,7 @@ run_test('basics', () => {
// zblueslip logs all the calls made to it, and they can be used in asserts like:
// Now, let's add our error to the list of expected errors.
- blueslip.expect('error', 'world', 2);
+ blueslip.expect("error", "world", 2);
// This time, blueslip will just log the error, which is
// being verified by the assert call on the length of the log.
// We can also check for which specific error was logged, but since
@@ -44,7 +44,7 @@ run_test('basics', () => {
throw_an_error();
// The following check is redundant; blueslip.reset() already asserts that
// we got the expected number of errors.
- assert.equal(blueslip.get_test_logs('error').length, 2);
+ assert.equal(blueslip.get_test_logs("error").length, 2);
// Let's clear the array of valid errors as well as the log. Now, all errors
// should be thrown directly by blueslip.
@@ -60,7 +60,7 @@ run_test('basics', () => {
// behaviour is slightly different.
function throw_a_warning() {
- blueslip.warn('world');
+ blueslip.warn("world");
}
assert.throws(throw_a_warning);
@@ -76,12 +76,12 @@ run_test('basics', () => {
// Now, let's add our warning to the list of expected warnings.
// This time, we shouldn't throw an error. However, to confirm that we
// indeed had logged a warning, we can check the length of the warning logs
- blueslip.expect('warn', 'world');
+ blueslip.expect("warn", "world");
throw_a_warning();
blueslip.reset();
// However, we detect when we have more or less of the expected errors/warnings.
- blueslip.expect('warn', 'world');
+ blueslip.expect("warn", "world");
assert.throws(() => {
blueslip.reset();
});
diff --git a/frontend_tests/node_tests/zjquery.js b/frontend_tests/node_tests/zjquery.js
index 44a7528e209..8dad11de3e9 100644
--- a/frontend_tests/node_tests/zjquery.js
+++ b/frontend_tests/node_tests/zjquery.js
@@ -26,52 +26,52 @@ The code we are testing lives here:
// with zjquery as follows. This call gives us our own instance of a
// zjquery stub variable. Like with real jQuery, the '$' function will
// be the gateway to a bigger API.
-set_global('$', global.make_zjquery());
+set_global("$", global.make_zjquery());
-run_test('basics', () => {
+run_test("basics", () => {
// Let's create a sample piece of code to test:
function show_my_form() {
- $('#my-form').show();
+ $("#my-form").show();
}
// Before we call show_my_form, we can assert that my-form is hidden:
- assert(!$('#my-form').visible());
+ assert(!$("#my-form").visible());
// Then calling show_my_form() should make it visible.
show_my_form();
- assert($('#my-form').visible());
+ assert($("#my-form").visible());
// Next, look at how several functions correctly simulate setting
// and getting for you.
- const widget = $('#my-widget');
+ const widget = $("#my-widget");
- widget.attr('data-employee-id', 42);
- assert.equal(widget.attr('data-employee-id'), 42);
- assert.equal(widget.data('employee-id'), 42);
+ widget.attr("data-employee-id", 42);
+ assert.equal(widget.attr("data-employee-id"), 42);
+ assert.equal(widget.data("employee-id"), 42);
- widget.data('department-id', 77);
- assert.equal(widget.attr('data-department-id'), 77);
- assert.equal(widget.data('department-id'), 77);
+ widget.data("department-id", 77);
+ assert.equal(widget.attr("data-department-id"), 77);
+ assert.equal(widget.data("department-id"), 77);
- widget.data('department-name', 'hr');
- assert.equal(widget.attr('data-department-name'), 'hr');
- assert.equal(widget.data('department-name'), 'hr');
+ widget.data("department-name", "hr");
+ assert.equal(widget.attr("data-department-name"), "hr");
+ assert.equal(widget.data("department-name"), "hr");
- widget.html('<b>hello</b>');
- assert.equal(widget.html(), '<b>hello</b>');
+ widget.html("<b>hello</b>");
+ assert.equal(widget.html(), "<b>hello</b>");
- widget.prop('title', 'My Widget');
- assert.equal(widget.prop('title'), 'My Widget');
+ widget.prop("title", "My Widget");
+ assert.equal(widget.prop("title"), "My Widget");
- widget.val('42');
- assert.equal(widget.val(), '42');
+ widget.val("42");
+ assert.equal(widget.val(), "42");
});
-run_test('finding_related_objects', () => {
+run_test("finding_related_objects", () => {
// Let's say you have a function like the following:
function update_message_emoji(emoji_src) {
- $('#my-message').find('.emoji').attr('src', emoji_src);
+ $("#my-message").find(".emoji").attr("src", emoji_src);
}
// This would explode:
@@ -84,16 +84,16 @@ run_test('finding_related_objects', () => {
//
// We will use set_find_results(), which is a special zjquery helper.
const emoji = $('<div class="emoji">');
- $('#my-message').set_find_results('.emoji', emoji);
+ $("#my-message").set_find_results(".emoji", emoji);
// And then calling the function produces the desired effect:
- update_message_emoji('foo.png');
- assert.equal(emoji.attr('src'), 'foo.png');
+ update_message_emoji("foo.png");
+ assert.equal(emoji.attr("src"), "foo.png");
// Sometimes you want to deliberatly test paths that do not find an
// element. You can pass 'false' as the result for those cases.
- emoji.set_find_results('.random', false);
- assert.equal(emoji.find('.random').length, 0);
+ emoji.set_find_results(".random", false);
+ assert.equal(emoji.find(".random").length, 0);
/*
An important thing to understand is that zjquery doesn't truly
simulate DOM. The way you make relationships work in zjquery
@@ -102,26 +102,26 @@ run_test('finding_related_objects', () => {
Here is another example.
*/
- const my_parents = $('#folder1,#folder4');
- const elem = $('#folder555');
+ const my_parents = $("#folder1,#folder4");
+ const elem = $("#folder555");
- elem.set_parents_result('.folder', my_parents);
- elem.parents('.folder').addClass('active');
- assert(my_parents.hasClass('active'));
+ elem.set_parents_result(".folder", my_parents);
+ elem.parents(".folder").addClass("active");
+ assert(my_parents.hasClass("active"));
});
-run_test('clicks', () => {
+run_test("clicks", () => {
// We can support basic handlers like click and keydown.
const state = {};
function set_up_click_handlers() {
- $('#widget1').click(() => {
+ $("#widget1").click(() => {
state.clicked = true;
});
- $('.some-class').keydown(() => {
+ $(".some-class").keydown(() => {
state.keydown = true;
});
}
@@ -132,16 +132,16 @@ run_test('clicks', () => {
assert(!state.keydown);
// But we can simulate clicks.
- $('#widget1').click();
+ $("#widget1").click();
assert.equal(state.clicked, true);
// and keydown
- $('.some-class').keydown();
+ $(".some-class").keydown();
assert.equal(state.keydown, true);
});
-run_test('events', () => {
+run_test("events", () => {
// Zulip's codebase uses jQuery's event API heavily with anonymous
// functions that are hard for naive test code to cover. zjquery
// will come to our rescue.
@@ -149,13 +149,13 @@ run_test('events', () => {
let value;
function initialize_handler() {
- $('#my-parent').on('click', '.button-red', (e) => {
- value = 'red'; // just a dummy side effect
+ $("#my-parent").on("click", ".button-red", (e) => {
+ value = "red"; // just a dummy side effect
e.stopPropagation();
});
- $('#my-parent').on('click', '.button-blue', (e) => {
- value = 'blue';
+ $("#my-parent").on("click", ".button-blue", (e) => {
+ value = "blue";
e.stopPropagation();
});
}
@@ -166,7 +166,7 @@ run_test('events', () => {
// We want to call the inner function, so first let's get it using the
// get_on_handler() helper from zjquery.
- const red_handler_func = $('#my-parent').get_on_handler('click', '.button-red');
+ const red_handler_func = $("#my-parent").get_on_handler("click", ".button-red");
// Set up a stub event so that stopPropagation doesn't explode on us.
const stub_event = {
@@ -177,29 +177,29 @@ run_test('events', () => {
red_handler_func(stub_event);
// And verify it did what it was supposed to do.
- assert.equal(value, 'red');
+ assert.equal(value, "red");
// Test we can have multiple click handlers in the parent.
- const blue_handler_func = $('#my-parent').get_on_handler('click', '.button-blue');
+ const blue_handler_func = $("#my-parent").get_on_handler("click", ".button-blue");
blue_handler_func(stub_event);
- assert.equal(value, 'blue');
+ assert.equal(value, "blue");
});
-run_test('create', () => {
+run_test("create", () => {
// You can create jQuery objects that aren't tied to any particular
// selector, and which just have a name.
- const obj1 = $.create('the table holding employees');
- const obj2 = $.create('the collection of rows in the table');
+ const obj1 = $.create("the table holding employees");
+ const obj2 = $.create("the collection of rows in the table");
obj1.show();
assert(obj1.visible());
- obj2.addClass('.striped');
- assert(obj2.hasClass('.striped'));
+ obj2.addClass(".striped");
+ assert(obj2.hasClass(".striped"));
});
-run_test('extensions', () => {
+run_test("extensions", () => {
// You can extend $.fn so that all subsequent objects
// we create get a new function.
@@ -211,7 +211,7 @@ run_test('extensions', () => {
// the predominant Zulip testing style is to stub objects
// using direct syntax:
- const rect = $.create('rectangle');
+ const rect = $.create("rectangle");
rect.width = () => 5;
rect.height = () => 7;
diff --git a/frontend_tests/puppeteer_lib/common.js b/frontend_tests/puppeteer_lib/common.js
index bdeab143689..56e13886a5d 100644
--- a/frontend_tests/puppeteer_lib/common.js
+++ b/frontend_tests/puppeteer_lib/common.js
@@ -1,7 +1,7 @@
-const path = require('path');
-const puppeteer = require('puppeteer');
+const path = require("path");
+const puppeteer = require("puppeteer");
const assert = require("assert").strict;
-const test_credentials = require('../../var/casper/test_credentials.js').test_credentials;
+const test_credentials = require("../../var/casper/test_credentials.js").test_credentials;
class CommonUtils {
constructor() {
@@ -14,8 +14,8 @@ class CommonUtils {
if (this.browser === null) {
this.browser = await puppeteer.launch({
args: [
- '--window-size=1400,1024',
- '--no-sandbox', '--disable-setuid-sandbox',
+ "--window-size=1400,1024",
+ "--no-sandbox", "--disable-setuid-sandbox",
],
defaultViewport: { width: 1280, height: 1024 },
headless: true,
@@ -40,8 +40,8 @@ class CommonUtils {
this.screenshot_id += 1;
}
- const root_dir = path.resolve(__dirname, '../../');
- const screenshot_path = path.join(root_dir, 'var/puppeteer', `${name}.png`);
+ const root_dir = path.resolve(__dirname, "../../");
+ const screenshot_path = path.join(root_dir, "var/puppeteer", `${name}.png`);
await page.screenshot({
path: screenshot_path,
});
@@ -87,8 +87,8 @@ class CommonUtils {
async log_in(page, credentials = null) {
console.log("Logging in");
- await page.goto(this.realm_url + 'login/');
- assert.equal(this.realm_url + 'login/', page.url());
+ await page.goto(this.realm_url + "login/");
+ assert.equal(this.realm_url + "login/", page.url());
if (credentials === null) {
credentials = test_credentials.default_user;
}
@@ -97,21 +97,21 @@ class CommonUtils {
username: credentials.username,
password: credentials.password,
};
- await this.fill_form(page, '#login_form', params);
+ await this.fill_form(page, "#login_form", params);
// We wait until DOMContentLoaded event is fired to ensure that zulip JavaScript
// is executed since some of our tests access those through page.evaluate. We use defer
// tag for script tags that load JavaScript which means that whey will be executed after DOM
// is parsed but before DOMContentLoaded event is fired.
await Promise.all([
- page.waitForNavigation({ waitUntil: 'domcontentloaded' }),
- page.$eval('#login_form', (form) => form.submit()),
+ page.waitForNavigation({ waitUntil: "domcontentloaded" }),
+ page.$eval("#login_form", (form) => form.submit()),
]);
}
async log_out(page) {
await page.goto(this.realm_url);
- const menu_selector = '#settings-dropdown';
+ const menu_selector = "#settings-dropdown";
const logout_selector = 'a[href="#logout"]';
console.log("Loggin out");
await page.waitForSelector(menu_selector, {visible: true});
@@ -122,7 +122,7 @@ class CommonUtils {
// Wait for a email input in login page so we know login
// page is loaded. Then check that we are at the login url.
await page.waitForSelector('input[name="username"]');
- assert(page.url().includes('/login/'));
+ assert(page.url().includes("/login/"));
}
async ensure_enter_does_not_send(page) {
@@ -181,7 +181,7 @@ class CommonUtils {
don't add the star icon until the server
responds.
*/
- return row.find('.star').length === 1;
+ return row.find(".star").length === 1;
}, {}, content);
}
@@ -192,13 +192,13 @@ class CommonUtils {
const { outside_view } = params;
delete params.outside_view;
- await page.waitForSelector('#compose-textarea');
+ await page.waitForSelector("#compose-textarea");
if (type === "stream") {
- await page.keyboard.press('KeyC');
+ await page.keyboard.press("KeyC");
} else if (type === "private") {
await page.keyboard.press("KeyX");
- const recipients = params.recipient.split(', ');
+ const recipients = params.recipient.split(", ");
for (let i = 0; i < recipients.length; i += 1) {
await this.set_pm_recipient(page, recipients[i]);
}
@@ -220,13 +220,13 @@ class CommonUtils {
await this.fill_form(page, 'form[action^="/json/messages"]', params);
await this.ensure_enter_does_not_send(page);
await page.waitForSelector("#compose-send-button", {visible: true});
- await page.click('#compose-send-button');
+ await page.click("#compose-send-button");
// 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);
- assert.equal(compose_box_content, '', 'Compose box not empty after message sent');
+ assert.equal(compose_box_content, "", "Compose box not empty after message sent");
if (!outside_view) {
await this.wait_for_fully_processed_message(page, params.content);
@@ -243,7 +243,7 @@ class CommonUtils {
const msg = msgs[msg_index];
await this.send_message(
page,
- msg.stream !== undefined ? 'stream' : 'private',
+ msg.stream !== undefined ? "stream" : "private",
msg,
);
}
@@ -258,24 +258,24 @@ class CommonUtils {
*
* The messages are sorted chronologically.
*/
- async get_rendered_messages(page, table = 'zhome') {
+ async get_rendered_messages(page, table = "zhome") {
return await page.evaluate((table) => {
const data = [];
- const $recipient_rows = $(`#${table}`).find('.recipient_row');
+ const $recipient_rows = $(`#${table}`).find(".recipient_row");
$.map($recipient_rows, (element) => {
const $el = $(element);
- const stream_name = $el.find('.stream_label').text().trim();
- const topic_name = $el.find('.stream_topic a').text().trim();
+ const stream_name = $el.find(".stream_label").text().trim();
+ const topic_name = $el.find(".stream_topic a").text().trim();
let key = stream_name;
- if (topic_name !== '') {
+ if (topic_name !== "") {
// If topic_name is '' then this is PMs, so only
// append > topic_name if we are not in PMs or Group PMs.
key = `${stream_name} > ${topic_name}`;
}
const messages = [];
- $.map($el.find('.message_row .message_content'), (message_row) => {
+ $.map($el.find(".message_row .message_content"), (message_row) => {
messages.push(message_row.innerText.trim());
});
@@ -292,7 +292,7 @@ class CommonUtils {
// The method will only check that all the messages in the
// messages array passed exist in the order they are passed.
async check_messages_sent(page, table, messages) {
- await page.waitForSelector('#' + table);
+ await page.waitForSelector("#" + table);
const rendered_messages = await this.get_rendered_messages(page, table);
// We only check the last n messages because if we run
diff --git a/frontend_tests/puppeteer_tests/00-realm-creation.js b/frontend_tests/puppeteer_tests/00-realm-creation.js
index 040dfade581..473e313c24e 100644
--- a/frontend_tests/puppeteer_tests/00-realm-creation.js
+++ b/frontend_tests/puppeteer_tests/00-realm-creation.js
@@ -1,32 +1,32 @@
-const common = require('../puppeteer_lib/common');
+const common = require("../puppeteer_lib/common");
const assert = require("assert").strict;
-const email = '[email protected]';
-const subdomain = 'testsubdomain';
-const organization_name = 'Awesome Organization';
+const email = "[email protected]";
+const subdomain = "testsubdomain";
+const organization_name = "Awesome Organization";
const host = "zulipdev.com:9981";
async function realm_creation_tests(page) {
- await page.goto('http://' + host + '/new/');
+ await page.goto("http://" + host + "/new/");
// submit the email for realm creation.
- await page.waitForSelector('#email');
- await page.type('#email', email);
+ await page.waitForSelector("#email");
+ await page.type("#email", email);
await Promise.all([
page.waitForNavigation(),
- page.$eval('#send_confirm', (form) => form.submit()),
+ page.$eval("#send_confirm", (form) => form.submit()),
]);
// Make sure onfirmation email is sent.
- assert(page.url().includes('/accounts/new/send_confirm/' + email));
+ assert(page.url().includes("/accounts/new/send_confirm/" + email));
// Special endpoint enabled only during tests for extracting confirmation key
- await page.goto('http://' + host + '/confirmation_key/');
+ await page.goto("http://" + host + "/confirmation_key/");
// Open the confirmation URL
- const page_content = await page.evaluate(() => document.querySelector('body').innerText);
+ const page_content = await page.evaluate(() => document.querySelector("body").innerText);
const confirmation_key = await JSON.parse(page_content).confirmation_key;
- const confirmation_url = 'http://' + host + '/accounts/do_confirm/' + confirmation_key;
+ const confirmation_url = "http://" + host + "/accounts/do_confirm/" + confirmation_key;
await page.goto(confirmation_url);
// We wait until the DOMContentLoaded event because we want the code
@@ -35,31 +35,31 @@ async function realm_creation_tests(page) {
// first input is focused when we are typing something for other fields causing
// validation errors. The code for focusing the input is wrapped in jQuery
// $() calls which runs when DOMContentLoaded is fired.
- await page.waitForNavigation({ waitUntil: 'domcontentloaded' });
+ await page.waitForNavigation({ waitUntil: "domcontentloaded" });
// Make sure the realm creation page is loaded correctly by
// checking the text in <p> tag under pitch class is as expected.
- await page.waitForSelector('.pitch');
- const text_in_pitch = await page.evaluate(() => document.querySelector('.pitch p').innerText);
+ await page.waitForSelector(".pitch");
+ const text_in_pitch = await page.evaluate(() => document.querySelector(".pitch p").innerText);
assert(text_in_pitch === "We just need you to do one last thing.");
// fill the form.
const params = {
realm_name: organization_name,
realm_subdomain: subdomain,
- full_name: 'Alice',
- password: 'passwordwhichisnotreallycomplex',
+ full_name: "Alice",
+ password: "passwordwhichisnotreallycomplex",
terms: true,
};
// For some reason, page.click() does not work this for particular checkbox
// so use page.$eval here to call the .click method in the browser.
- await page.$eval('#realm_in_root_domain', (el) => el.click());
- await common.fill_form(page, '#registration', params);
- await page.$eval('#registration', (form) => form.submit());
+ await page.$eval("#realm_in_root_domain", (el) => el.click());
+ await common.fill_form(page, "#registration", params);
+ await page.$eval("#registration", (form) => form.submit());
// Check if realm is created and user is logged in by checking if
// element of id `lightbox_overlay` exists.
- await page.waitForSelector('#lightbox_overlay'); // if element doesn't exist,timeout error raises
+ await page.waitForSelector("#lightbox_overlay"); // if element doesn't exist,timeout error raises
}
common.run_test(realm_creation_tests);
diff --git a/frontend_tests/puppeteer_tests/01-login.js b/frontend_tests/puppeteer_tests/01-login.js
index f68ceb66c71..34765756178 100644
--- a/frontend_tests/puppeteer_tests/01-login.js
+++ b/frontend_tests/puppeteer_tests/01-login.js
@@ -1,5 +1,5 @@
-const common = require('../puppeteer_lib/common');
-const test_credentials = require('../../var/casper/test_credentials.js').test_credentials;
+const common = require("../puppeteer_lib/common");
+const test_credentials = require("../../var/casper/test_credentials.js").test_credentials;
async function login_tests(page) {
await common.log_in(page, test_credentials.default_user);
diff --git a/frontend_tests/puppeteer_tests/02-message-basics.js b/frontend_tests/puppeteer_tests/02-message-basics.js
index 761c3c6dd15..cc7d9b6b60e 100644
--- a/frontend_tests/puppeteer_tests/02-message-basics.js
+++ b/frontend_tests/puppeteer_tests/02-message-basics.js
@@ -1,23 +1,23 @@
-const common = require('../puppeteer_lib/common');
+const common = require("../puppeteer_lib/common");
async function message_basic_tests(page) {
await common.log_in(page);
- console.log('Sending messages');
+ console.log("Sending messages");
await common.send_multiple_messages(page, [
- { stream: 'Verona', topic: 'test', content: 'verona test a' },
- { stream: 'Verona', topic: 'test', content: 'verona test b' },
- { stream: 'Verona', topic: 'other topic', content: 'verona other topic c' },
- { recipient: '[email protected], [email protected]', content: 'group pm a' },
- { recipient: '[email protected], [email protected]', content: 'group pm b' },
- { recipient: '[email protected]', content: 'pm c' },
+ { stream: "Verona", topic: "test", content: "verona test a" },
+ { stream: "Verona", topic: "test", content: "verona test b" },
+ { stream: "Verona", topic: "other topic", content: "verona other topic c" },
+ { recipient: "[email protected], [email protected]", content: "group pm a" },
+ { recipient: "[email protected], [email protected]", content: "group pm b" },
+ { recipient: "[email protected]", content: "pm c" },
]);
- await common.check_messages_sent(page, 'zhome', [
- ['Verona > test', ['verona test a', 'verona test b']],
- ['Verona > other topic', ['verona other topic c']],
- ['You and Cordelia Lear, King Hamlet', ['group pm a', 'group pm b']],
- ['You and Cordelia Lear', ['pm c']],
+ await common.check_messages_sent(page, "zhome", [
+ ["Verona > test", ["verona test a", "verona test b"]],
+ ["Verona > other topic", ["verona other topic c"]],
+ ["You and Cordelia Lear, King Hamlet", ["group pm a", "group pm b"]],
+ ["You and Cordelia Lear", ["pm c"]],
]);
await common.log_out(page);
diff --git a/frontend_tests/zjsunit/finder.js b/frontend_tests/zjsunit/finder.js
index bc6b716a241..e7f83840d12 100644
--- a/frontend_tests/zjsunit/finder.js
+++ b/frontend_tests/zjsunit/finder.js
@@ -1,6 +1,6 @@
-const _ = require('underscore/underscore.js');
-const fs = require('fs');
-const path = require('path');
+const _ = require("underscore/underscore.js");
+const fs = require("fs");
+const path = require("path");
exports.find_files_to_run = function () {
let oneFileFilter = [];
@@ -9,17 +9,17 @@ exports.find_files_to_run = function () {
oneFileFilter = process.argv
.slice(2)
.filter((filename) => (/[.]js$/).test(filename))
- .map((filename) => filename.replace(/\.js$/i, ''));
+ .map((filename) => filename.replace(/\.js$/i, ""));
}
// tests_dir is where we find our specific unit tests (as opposed
// to framework code)
- const tests_dir = __dirname.replace(/zjsunit/, 'node_tests');
+ 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))
- .map((filename) => filename.replace(/\.js$/i, ''));
+ .map((filename) => filename.replace(/\.js$/i, ""));
if (oneFileFilter.length > 0) {
tests = tests.filter((filename) => oneFileFilter.includes(filename));
diff --git a/frontend_tests/zjsunit/i18n.js b/frontend_tests/zjsunit/i18n.js
index 888ef467185..37137dd2fc7 100644
--- a/frontend_tests/zjsunit/i18n.js
+++ b/frontend_tests/zjsunit/i18n.js
@@ -1,7 +1,7 @@
exports.t = function (str, context) {
// HAPPY PATH: most translations are a simple string:
if (context === undefined) {
- return 'translated: ' + str;
+ return "translated: " + str;
}
/*
@@ -36,5 +36,5 @@ exports.t = function (str, context) {
context[item.keyword]);
}
- return 'translated: ' + str;
+ return "translated: " + str;
};
diff --git a/frontend_tests/zjsunit/index.js b/frontend_tests/zjsunit/index.js
index e4eeb22d7f7..ba2670dc35e 100644
--- a/frontend_tests/zjsunit/index.js
+++ b/frontend_tests/zjsunit/index.js
@@ -1,5 +1,5 @@
-const path = require('path');
-const fs = require('fs');
+const path = require("path");
+const fs = require("fs");
const escapeRegExp = require("lodash/escapeRegExp");
require("@babel/register")({
@@ -11,8 +11,8 @@ require("@babel/register")({
plugins: ["rewire-ts"],
});
-global.assert = require('assert').strict;
-global._ = require('underscore/underscore.js');
+global.assert = require("assert").strict;
+global._ = require("underscore/underscore.js");
const _ = global._;
// Create a helper function to avoid sneaky delays in tests.
@@ -21,14 +21,14 @@ function immediate(f) {
}
// Find the files we need to run.
-const finder = require('./finder.js');
+const finder = require("./finder.js");
const files = finder.find_files_to_run(); // may write to console
if (files.length === 0) {
throw "No tests found";
}
// Set up our namespace helpers.
-const namespace = require('./namespace.js');
+const namespace = require("./namespace.js");
global.set_global = namespace.set_global;
global.patch_builtin = namespace.set_global;
global.zrequire = namespace.zrequire;
@@ -41,70 +41,70 @@ global.window = new Proxy(global, {
global.to_$ = () => window;
// Set up stub helpers.
-const stub = require('./stub.js');
+const stub = require("./stub.js");
global.make_stub = stub.make_stub;
global.with_stub = stub.with_stub;
// Set up fake jQuery
-global.make_zjquery = require('./zjquery.js').make_zjquery;
+global.make_zjquery = require("./zjquery.js").make_zjquery;
// Set up fake blueslip
-const make_blueslip = require('./zblueslip.js').make_zblueslip;
+const make_blueslip = require("./zblueslip.js").make_zblueslip;
// Set up fake translation
-const stub_i18n = require('./i18n.js');
+const stub_i18n = require("./i18n.js");
// Set up Handlebars
-const handlebars = require('./handlebars.js');
+const handlebars = require("./handlebars.js");
global.make_handlebars = handlebars.make_handlebars;
global.stub_templates = handlebars.stub_templates;
const noop = function () {};
// Set up fake module.hot
-const Module = require('module');
+const Module = require("module");
Module.prototype.hot = {
accept: noop,
};
// Set up fixtures.
global.read_fixture_data = (fn) => {
- const full_fn = path.join(__dirname, '../../zerver/tests/fixtures/', fn);
- const data = JSON.parse(fs.readFileSync(full_fn, 'utf8', 'r'));
+ const full_fn = path.join(__dirname, "../../zerver/tests/fixtures/", fn);
+ const data = JSON.parse(fs.readFileSync(full_fn, "utf8", "r"));
return data;
};
function short_tb(tb) {
- const lines = tb.split('\n');
+ 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;
}
- return lines.splice(0, i + 1).join('\n') + '\n(...)\n';
+ return lines.splice(0, i + 1).join("\n") + "\n(...)\n";
}
// Set up markdown comparison helper
-global.markdown_assert = require('./markdown_assert.js');
+global.markdown_assert = require("./markdown_assert.js");
let current_file_name;
function run_one_module(file) {
- console.info('running tests for ' + file.name);
+ console.info("running tests for " + file.name);
current_file_name = file.name;
require(file.full_name);
}
global.run_test = (label, f) => {
if (files.length === 1) {
- console.info(' test: ' + label);
+ console.info(" test: " + label);
}
try {
f();
} catch (error) {
- console.info('-'.repeat(50));
+ console.info("-".repeat(50));
console.info(`test failed: ${current_file_name} > ${label}`);
console.info();
throw error;
@@ -115,16 +115,16 @@ global.run_test = (label, f) => {
try {
files.forEach((file) => {
- set_global('location', {
- hash: '#',
+ set_global("location", {
+ hash: "#",
});
- global.patch_builtin('setTimeout', noop);
- global.patch_builtin('setInterval', noop);
+ global.patch_builtin("setTimeout", noop);
+ global.patch_builtin("setInterval", noop);
_.throttle = immediate;
_.debounce = immediate;
- set_global('blueslip', make_blueslip());
- set_global('i18n', stub_i18n);
+ set_global("blueslip", make_blueslip());
+ set_global("i18n", stub_i18n);
namespace.clear_zulip_refs();
run_one_module(file);
diff --git a/frontend_tests/zjsunit/markdown_assert.js b/frontend_tests/zjsunit/markdown_assert.js
index e61ef9efe05..170c51cbb86 100644
--- a/frontend_tests/zjsunit/markdown_assert.js
+++ b/frontend_tests/zjsunit/markdown_assert.js
@@ -20,10 +20,10 @@
* HTML. This makes it easier to spot relevant differences.
*/
-const { JSDOM } = require('jsdom');
-const _ = require('underscore');
+const { JSDOM } = require("jsdom");
+const _ = require("underscore");
-const mdiff = require('./mdiff.js');
+const mdiff = require("./mdiff.js");
// Module-level global instance of MarkdownComparer, initialized when needed
let _markdownComparerInstance = null;
@@ -36,7 +36,7 @@ class MarkdownComparer {
actual,
"!=",
expected,
- ].join('\n');
+ ].join("\n");
};
this._document = new JSDOM().window.document;
}
@@ -46,8 +46,8 @@ class MarkdownComparer {
}
_htmlToElement(html, id) {
- const template = this._document.createElement('template');
- const id_node = this._document.createAttribute('id');
+ const template = this._document.createElement("template");
+ const id_node = this._document.createAttribute("id");
id_node.value = id;
template.setAttributeNode(id_node);
template.innerHTML = html;
@@ -131,8 +131,8 @@ class MarkdownComparer {
assertEqual(actual, expected, message) {
const comparison_results = this._compare(actual, expected);
- message = message || '';
- message += '\n';
+ message = message || "";
+ message += "\n";
if (comparison_results.are_equivalent === false) {
throw new assert.AssertionError({
@@ -147,8 +147,8 @@ class MarkdownComparer {
assertNotEqual(actual, expected, message) {
const comparison_results = this._compare(actual, expected);
- message = message || '';
- message += '\n';
+ message = message || "";
+ message += "\n";
if (comparison_results.are_equivalent) {
throw new assert.AssertionError({
@@ -157,7 +157,7 @@ class MarkdownComparer {
actual,
"==",
expected,
- ].join('\n'),
+ ].join("\n"),
});
}
}
@@ -168,7 +168,7 @@ function returnComparer() {
_markdownComparerInstance = new MarkdownComparer((actual, expected) => [
"Actual and expected output do not match. Showing diff",
mdiff.diff_strings(actual, expected),
- ].join('\n'));
+ ].join("\n"));
}
return _markdownComparerInstance;
}
diff --git a/frontend_tests/zjsunit/mdiff.js b/frontend_tests/zjsunit/mdiff.js
index e2cdf1217b0..ff5dbffd1e6 100644
--- a/frontend_tests/zjsunit/mdiff.js
+++ b/frontend_tests/zjsunit/mdiff.js
@@ -11,7 +11,7 @@
* unicode string containing their diff.
*/
-const difflib = require('difflib');
+const difflib = require("difflib");
function apply_color(input_string, changes) {
let previous_index = 0;
@@ -126,7 +126,7 @@ module.exports = { diff_strings };
// Only run this code if called as a command-line utility
if (require.main === module) {
// First two args are just "node" and "mdiff.js"
- const argv = require('minimist')(process.argv.slice(2));
+ const argv = require("minimist")(process.argv.slice(2));
if (Object.prototype.hasOwnProperty.call(argv, "help")) {
console.log(process.argv[0] + " " + process.argv[1] +
diff --git a/frontend_tests/zjsunit/namespace.js b/frontend_tests/zjsunit/namespace.js
index 1b5fa0012d2..85724fc0f71 100644
--- a/frontend_tests/zjsunit/namespace.js
+++ b/frontend_tests/zjsunit/namespace.js
@@ -15,10 +15,10 @@ exports.set_global = function (name, val) {
exports.zrequire = function (name, fn) {
if (fn === undefined) {
- fn = '../../static/js/' + name;
+ fn = "../../static/js/" + name;
} else if (/^generated\/|^js\/|^shared\/|^third\//.test(fn)) {
// FIXME: Stealing part of the NPM namespace is confusing.
- fn = '../../static/' + fn;
+ fn = "../../static/" + fn;
}
delete require.cache[require.resolve(fn)];
requires.push(fn);
@@ -36,8 +36,8 @@ exports.clear_zulip_refs = function () {
run it standalone.
*/
_.each(require.cache, (_, fn) => {
- if (fn.indexOf('static/') >= 0) {
- if (fn.indexOf('static/templates') < 0) {
+ if (fn.indexOf("static/") >= 0) {
+ if (fn.indexOf("static/templates") < 0) {
delete require.cache[fn];
}
}
@@ -57,7 +57,7 @@ exports.restore = function () {
};
exports.stub_out_jquery = function () {
- set_global('$', () => ({
+ set_global("$", () => ({
on: function () {},
trigger: function () {},
hide: function () {},
@@ -74,7 +74,7 @@ exports.with_overrides = function (test_function) {
const clobber_callbacks = [];
const override = function (name, f) {
- const parts = name.split('.');
+ const parts = name.split(".");
const module = parts[0];
const func_name = parts[1];
@@ -89,7 +89,7 @@ exports.with_overrides = function (test_function) {
// 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';
+ "ATTEMPTED TO REUSE OVERRIDDEN VALUE FROM PRIOR TEST";
});
};
diff --git a/frontend_tests/zjsunit/stub.js b/frontend_tests/zjsunit/stub.js
index 03ac5dd97e6..dc9cc30d3e0 100644
--- a/frontend_tests/zjsunit/stub.js
+++ b/frontend_tests/zjsunit/stub.js
@@ -34,9 +34,9 @@ exports.with_stub = function (f) {
(function test_ourselves() {
exports.with_stub((stub) => {
- stub.f('blue', 42);
- const args = stub.get_args('color', 'n');
- assert.equal(args.color, 'blue');
+ stub.f("blue", 42);
+ const args = stub.get_args("color", "n");
+ assert.equal(args.color, "blue");
assert.equal(args.n, 42);
});
}());
diff --git a/frontend_tests/zjsunit/zblueslip.js b/frontend_tests/zjsunit/zblueslip.js
index f7e877e725c..8309afa6ca4 100644
--- a/frontend_tests/zjsunit/zblueslip.js
+++ b/frontend_tests/zjsunit/zblueslip.js
@@ -28,10 +28,10 @@ exports.make_zblueslip = function () {
lib.expect = (name, message, count = 1) => {
if (opts[name] === undefined) {
- throw Error('unexpected arg for expect: ' + name);
+ throw Error("unexpected arg for expect: " + name);
}
if (count <= 0 && Number.isInteger(count)) {
- throw Error('expected count should be a positive integer');
+ throw Error("expected count should be a positive integer");
}
const obj = {message, count, expected_count: count};
lib.test_data[name].push(obj);
@@ -87,13 +87,13 @@ exports.make_zblueslip = function () {
continue;
}
lib[name] = function (message, more_info, stack) {
- if (typeof message !== 'string') {
+ if (typeof message !== "string") {
// We may catch exceptions in blueslip, and if
// so our stub should include that.
- if (message.toString().includes('exception')) {
+ if (message.toString().includes("exception")) {
message = message.toString();
} else {
- throw Error('message should be string: ' + message);
+ throw Error("message should be string: " + message);
}
}
lib.test_logs[name].push({message, more_info, stack});
@@ -113,7 +113,7 @@ exports.make_zblueslip = function () {
lib.start_timing = () => () => {};
- lib.preview_node = (node) => 'node:' + node;
+ lib.preview_node = (node) => "node:" + node;
return lib;
};
diff --git a/frontend_tests/zjsunit/zjquery.js b/frontend_tests/zjsunit/zjquery.js
index 4fa725e86ca..b374ec03a93 100644
--- a/frontend_tests/zjsunit/zjquery.js
+++ b/frontend_tests/zjsunit/zjquery.js
@@ -16,12 +16,12 @@ exports.make_event_store = (selector) => {
const child_on_functions = new Map();
function generic_event(event_name, arg) {
- if (typeof arg === 'function') {
+ if (typeof arg === "function") {
on_functions.set(event_name, arg);
} else {
const handler = on_functions.get(event_name);
if (!handler) {
- const error = 'Cannot find ' + event_name + ' handler for ' + selector;
+ const error = "Cannot find " + event_name + " handler for " + selector;
throw Error(error);
}
handler(arg);
@@ -37,7 +37,7 @@ exports.make_event_store = (selector) => {
if (child_selector === undefined) {
handler = on_functions.get(name);
if (!handler) {
- throw Error('no ' + name + ' handler for ' + selector);
+ throw Error("no " + name + " handler for " + selector);
}
return handler;
}
@@ -48,7 +48,7 @@ exports.make_event_store = (selector) => {
}
if (!handler) {
- throw Error('no ' + name + ' handler for ' + selector + ' ' + child_selector);
+ throw Error("no " + name + " handler for " + selector + " " + child_selector);
}
return handler;
@@ -64,7 +64,7 @@ exports.make_event_store = (selector) => {
// .off in code that we test: $(...).off('click', child_sel);
//
// So we don't support this for now.
- throw Error('zjquery does not support this call sequence');
+ throw Error("zjquery does not support this call sequence");
},
on: function (event_name, ...args) {
@@ -74,9 +74,9 @@ exports.make_event_store = (selector) => {
if (args.length === 1) {
const [handler] = args;
if (on_functions.has(event_name)) {
- console.info('\nEither the app or the test can be at fault here..');
- console.info('(sometimes you just want to call $.clear_all_elements();)\n');
- throw Error('dup ' + event_name + ' handler for ' + selector);
+ console.info("\nEither the app or the test can be at fault here..");
+ console.info("(sometimes you just want to call $.clear_all_elements();)\n");
+ throw Error("dup " + event_name + " handler for " + selector);
}
on_functions.set(event_name, handler);
@@ -84,12 +84,12 @@ exports.make_event_store = (selector) => {
}
if (args.length !== 2) {
- throw Error('wrong number of arguments passed in');
+ throw Error("wrong number of arguments passed in");
}
const [sel, handler] = args;
- assert.equal(typeof sel, 'string', 'String selectors expected here.');
- assert.equal(typeof handler, 'function', 'An handler function expected here.');
+ assert.equal(typeof sel, "string", "String selectors expected here.");
+ assert.equal(typeof handler, "function", "An handler function expected here.");
if (!child_on_functions.has(sel)) {
child_on_functions.set(sel, new Map());
@@ -98,14 +98,14 @@ exports.make_event_store = (selector) => {
const child_on = child_on_functions.get(sel);
if (child_on.has(event_name)) {
- throw Error('dup ' + event_name + ' handler for ' + selector + ' ' + sel);
+ throw Error("dup " + event_name + " handler for " + selector + " " + sel);
}
child_on.set(event_name, handler);
},
trigger: function (ev) {
- const ev_name = typeof ev === 'string' ? ev : ev.name;
+ const ev_name = typeof ev === "string" ? ev : ev.name;
const func = on_functions.get(ev_name);
if (!func) {
@@ -125,8 +125,8 @@ exports.make_event_store = (selector) => {
};
exports.make_new_elem = function (selector, opts) {
- let html = 'never-been-set';
- let text = 'never-been-set';
+ let html = "never-been-set";
+ let text = "never-been-set";
let value;
let css;
let shown = false;
@@ -160,18 +160,18 @@ exports.make_new_elem = function (selector, opts) {
return self;
},
click: function (arg) {
- event_store.generic_event('click', arg);
+ event_store.generic_event("click", arg);
return self;
},
data: function (name, val) {
if (val === undefined) {
- const data_val = attrs.get('data-' + name);
+ const data_val = attrs.get("data-" + name);
if (data_val === undefined) {
return;
}
return data_val;
}
- attrs.set('data-' + name, val);
+ attrs.set("data-" + name, val);
return self;
},
delay: function () {
@@ -250,10 +250,10 @@ exports.make_new_elem = function (selector, opts) {
return html;
},
is: function (arg) {
- if (arg === ':visible') {
+ if (arg === ":visible") {
return shown;
}
- if (arg === ':focus') {
+ if (arg === ":focus") {
return focused;
}
return self;
@@ -264,11 +264,11 @@ exports.make_new_elem = function (selector, opts) {
return focused;
},
keydown: function (arg) {
- event_store.generic_event('keydown', arg);
+ event_store.generic_event("keydown", arg);
return self;
},
keyup: function (arg) {
- event_store.generic_event('keyup', arg);
+ event_store.generic_event("keyup", arg);
return self;
},
off: function (...args) {
@@ -284,8 +284,8 @@ 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) {
@@ -304,7 +304,7 @@ exports.make_new_elem = function (selector, opts) {
return self;
},
removeClass: function (class_names) {
- class_names = class_names.split(' ');
+ class_names = class_names.split(" ");
class_names.forEach((class_name) => {
classes.delete(class_name);
});
@@ -321,7 +321,7 @@ exports.make_new_elem = function (selector, opts) {
return self;
},
select: function (arg) {
- event_store.generic_event('select', arg);
+ event_store.generic_event("select", arg);
return self;
},
set_find_results: function (find_selector, jquery_object) {
@@ -358,7 +358,7 @@ exports.make_new_elem = function (selector, opts) {
},
val: function (...args) {
if (args.length === 0) {
- return value || '';
+ return value || "";
}
[value] = args;
return self;
@@ -378,11 +378,11 @@ exports.make_new_elem = function (selector, opts) {
},
};
- if (selector[0] === '<') {
+ if (selector[0] === "<") {
self.html(selector);
}
- self[0] = 'you-must-set-the-child-yourself';
+ self[0] = "you-must-set-the-child-yourself";
self.selector = selector;
@@ -415,8 +415,8 @@ exports.make_zjquery = function (opts) {
// Handle the special case of equality checks, which
// 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, ' +
+ if (key === "stack") {
+ const error = "\nInstead of doing equality checks on a full object, " +
'do `assert_equal(foo.selector, ".some_class")\n';
throw Error(error);
}
@@ -427,10 +427,10 @@ exports.make_zjquery = function (opts) {
// For undefined values, we'll throw errors to devs saying
// they need to create stubs. We ignore certain keys that
// are used for simply printing out the object.
- if (typeof key === 'symbol') {
+ if (typeof key === "symbol") {
return;
}
- if (key === 'inspect') {
+ if (key === "inspect") {
return;
}
@@ -485,19 +485,19 @@ exports.make_zjquery = function (opts) {
}
const valid_selector =
- '<#.'.includes(selector[0]) ||
- selector === 'window-stub' ||
- selector === 'document-stub' ||
- selector === 'body' ||
- selector === 'html' ||
+ "<#.".includes(selector[0]) ||
+ selector === "window-stub" ||
+ selector === "document-stub" ||
+ selector === "body" ||
+ selector === "html" ||
selector.location ||
- selector.includes('#') ||
- selector.includes('.') ||
- selector.includes('[') && selector.indexOf(']') >= selector.indexOf('[');
+ selector.includes("#") ||
+ selector.includes(".") ||
+ selector.includes("[") && selector.indexOf("]") >= selector.indexOf("[");
assert(valid_selector,
- 'Invalid selector: ' + selector +
- ' Use $.create() maybe?');
+ "Invalid selector: " + selector +
+ " Use $.create() maybe?");
if (!elems.has(selector)) {
@@ -509,7 +509,7 @@ exports.make_zjquery = function (opts) {
zjquery.create = function (name) {
assert(!elems.has(name),
- 'You already created an object with this name!!');
+ "You already created an object with this name!!");
const elem = new_elem(name);
elems.set(name, elem);
return elem;
diff --git a/static/assets/icons/zulip-icons.font.js b/static/assets/icons/zulip-icons.font.js
index 771f1ebad11..3136e6c8efb 100644
--- a/static/assets/icons/zulip-icons.font.js
+++ b/static/assets/icons/zulip-icons.font.js
@@ -1,7 +1,7 @@
module.exports = {
- files: ['./*.svg'],
- fontName: 'zulip-icons',
- classPrefix: '',
- baseSelector: '.zulip-icon',
- cssTemplate: './template.hbs',
+ files: ["./*.svg"],
+ fontName: "zulip-icons",
+ classPrefix: "",
+ baseSelector: ".zulip-icon",
+ cssTemplate: "./template.hbs",
};
diff --git a/static/js/activity.js b/static/js/activity.js
index d12b4ce7947..ba6e4f8b9fc 100644
--- a/static/js/activity.js
+++ b/static/js/activity.js
@@ -25,12 +25,12 @@ exports.client_is_active = document.hasFocus && document.hasFocus();
exports.new_user_input = true;
function update_pm_count_in_dom(count_span, value_span, count) {
- const li = count_span.parents('li');
+ const li = count_span.parents("li");
if (count === 0) {
count_span.hide();
li.removeClass("user-with-count");
- value_span.text('');
+ value_span.text("");
return;
}
@@ -46,8 +46,8 @@ function get_pm_list_item(user_id) {
}
function set_pm_count(user_ids_string, count) {
- const count_span = get_pm_list_item(user_ids_string).find('.count');
- const value_span = count_span.find('.value');
+ const count_span = get_pm_list_item(user_ids_string).find(".count");
+ const value_span = count_span.find(".value");
update_pm_count_in_dom(count_span, value_span, count);
}
@@ -57,7 +57,7 @@ exports.update_dom_with_unread_counts = function (counts) {
for (const [user_ids_string, count] of counts.pm_count) {
// TODO: just use user_ids_string in our markup
- const is_pm = !user_ids_string.includes(',');
+ const is_pm = !user_ids_string.includes(",");
if (is_pm) {
set_pm_count(user_ids_string, count);
}
@@ -103,7 +103,7 @@ exports.build_user_sidebar = function () {
const user_ids = buddy_data.get_filtered_and_sorted_user_ids(filter_text);
- const finish = blueslip.start_timing('buddy_list.populate');
+ const finish = blueslip.start_timing("buddy_list.populate");
buddy_list.populate({
keys: user_ids,
});
@@ -168,7 +168,7 @@ function send_presence_to_server(want_redraw) {
server_events.check_for_unsuspend();
channel.post({
- url: '/json/users/me/presence',
+ url: "/json/users/me/presence",
data: {
status: exports.compute_active_status(),
ping_only: !want_redraw,
@@ -179,9 +179,9 @@ function send_presence_to_server(want_redraw) {
success: function (data) {
// Update Zephyr mirror activity warning
if (data.zephyr_mirror_active === false) {
- $('#zephyr-mirror-error').addClass("show");
+ $("#zephyr-mirror-error").addClass("show");
} else {
- $('#zephyr-mirror-error').removeClass("show");
+ $("#zephyr-mirror-error").removeClass("show");
}
exports.new_user_input = false;
@@ -268,7 +268,7 @@ exports.narrow_for_user_id = function (opts) {
const person = people.get_by_user_id(opts.user_id);
const email = person.email;
- narrow.by('pm-with', email, {trigger: 'sidebar'});
+ narrow.by("pm-with", email, {trigger: "sidebar"});
exports.user_filter.clear_and_hide_search();
};
@@ -285,7 +285,7 @@ function keydown_enter_key() {
exports.set_cursor_and_filter = function () {
exports.user_cursor = list_cursor({
list: buddy_list,
- highlight_class: 'highlighted_user',
+ highlight_class: "highlighted_user",
});
exports.user_filter = user_search({
@@ -296,7 +296,7 @@ exports.set_cursor_and_filter = function () {
const $input = exports.user_filter.input_field();
- $input.on('blur', exports.user_cursor.clear);
+ $input.on("blur", exports.user_cursor.clear);
keydown_util.handle({
elem: $input,
@@ -335,8 +335,8 @@ exports.get_filter_text = function () {
// situations where get called before everything is
// fully initialized. The empty string is a fine
// default here.
- blueslip.warn('get_filter_text() is called before initialization');
- return '';
+ blueslip.warn("get_filter_text() is called before initialization");
+ return "";
}
return exports.user_filter.text();
diff --git a/static/js/admin.js b/static/js/admin.js
index bdd4fb71c30..822c899799b 100644
--- a/static/js/admin.js
+++ b/static/js/admin.js
@@ -1,6 +1,6 @@
const settings_config = require("./settings_config");
const settings_data = require("./settings_data");
-const render_admin_tab = require('../templates/admin_tab.hbs');
+const render_admin_tab = require("../templates/admin_tab.hbs");
const render_settings_organization_settings_tip = require("../templates/settings/organization_settings_tip.hbs");
const admin_settings_label = {
@@ -61,9 +61,9 @@ exports.build_page = function () {
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'),
+ 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'),
+ 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,
@@ -103,7 +103,7 @@ exports.build_page = function () {
options.email_address_visibility_values = settings_config.email_address_visibility_values;
Object.assign(options, settings_org.get_organization_settings_options());
- if (options.realm_logo_source !== 'D' && options.realm_night_logo_source === 'D') {
+ if (options.realm_logo_source !== "D" && options.realm_night_logo_source === "D") {
// If no night mode logo is specified but a day mode one is,
// use the day mode one. See also similar code in realm_logo.js.
options.realm_night_logo_url = options.realm_logo_url;
@@ -137,7 +137,7 @@ exports.launch = function (section) {
overlays.open_settings();
settings_panel_menu.org_settings.activate_section_or_default(section);
- settings_toggle.highlight_toggle('organization');
+ settings_toggle.highlight_toggle("organization");
};
window.admin = exports;
diff --git a/static/js/alert_words.js b/static/js/alert_words.js
index 209b5696981..2d8ccfaf7b3 100644
--- a/static/js/alert_words.js
+++ b/static/js/alert_words.js
@@ -38,9 +38,9 @@ exports.process_message = function (message) {
const after_punctuation = '\\s|$|<|[\\)\\"\\?!:.,\';\\]!]';
- const regex = new RegExp('(' + before_punctuation + ')' +
- '(' + clean + ')' +
- '(' + after_punctuation + ')', 'ig');
+ 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.
@@ -50,7 +50,7 @@ exports.process_message = function (message) {
// 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('>');
+ 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;
diff --git a/static/js/alert_words_ui.js b/static/js/alert_words_ui.js
index 3df24661726..c32f1869766 100644
--- a/static/js/alert_words_ui.js
+++ b/static/js/alert_words_ui.js
@@ -1,11 +1,11 @@
-const render_alert_word_settings_item = require('../templates/settings/alert_word_settings_item.hbs');
+const render_alert_word_settings_item = require("../templates/settings/alert_word_settings_item.hbs");
exports.render_alert_words_ui = function () {
const words = alert_words.get_word_list();
words.sort();
- const word_list = $('#alert_words_list');
+ const word_list = $("#alert_words_list");
- word_list.find('.alert-word-item').remove();
+ word_list.find(".alert-word-item").remove();
for (const alert_word of words) {
const rendered_alert_word = render_alert_word_settings_item({
@@ -15,23 +15,23 @@ exports.render_alert_words_ui = function () {
}
// Focus new alert word name text box.
- $('#create_alert_word_name').focus();
+ $("#create_alert_word_name").focus();
};
function update_alert_word_status(status_text, is_error) {
- const alert_word_status = $('#alert_word_status');
+ const alert_word_status = $("#alert_word_status");
if (is_error) {
- alert_word_status.removeClass('alert-success').addClass('alert-danger');
+ alert_word_status.removeClass("alert-success").addClass("alert-danger");
} else {
- alert_word_status.removeClass('alert-danger').addClass('alert-success');
+ alert_word_status.removeClass("alert-danger").addClass("alert-success");
}
- alert_word_status.find('.alert_word_status_text').text(status_text);
+ alert_word_status.find(".alert_word_status_text").text(status_text);
alert_word_status.show();
}
function add_alert_word(alert_word) {
alert_word = $.trim(alert_word);
- if (alert_word === '') {
+ if (alert_word === "") {
update_alert_word_status(i18n.t("Alert word can't be empty!"), true);
return;
} else if (alert_words.has_alert_word(alert_word)) {
@@ -42,13 +42,13 @@ function add_alert_word(alert_word) {
const words_to_be_added = [alert_word];
channel.post({
- url: '/json/users/me/alert_words',
+ 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]});
update_alert_word_status(message, false);
- $('#create_alert_word_name').val('');
+ $("#create_alert_word_name").val("");
},
error: function () {
update_alert_word_status(i18n.t("Error adding alert word!"), true);
@@ -60,7 +60,7 @@ function remove_alert_word(alert_word) {
const words_to_be_removed = [alert_word];
channel.del({
- url: '/json/users/me/alert_words',
+ url: "/json/users/me/alert_words",
data: {alert_words: JSON.stringify(words_to_be_removed)},
success: function () {
update_alert_word_status(i18n.t("Alert word removed successfully!"), false);
@@ -76,17 +76,17 @@ exports.set_up_alert_words = function () {
exports.render_alert_words_ui();
- $('#create_alert_word_form').on('click', '#create_alert_word_button', () => {
- const word = $('#create_alert_word_name').val();
+ $("#create_alert_word_form").on("click", "#create_alert_word_button", () => {
+ const word = $("#create_alert_word_name").val();
add_alert_word(word);
});
- $('#alert_words_list').on('click', '.remove-alert-word', (event) => {
- const word = $(event.currentTarget).parents('li').find('.value').text();
+ $("#alert_words_list").on("click", ".remove-alert-word", (event) => {
+ const word = $(event.currentTarget).parents("li").find(".value").text();
remove_alert_word(word);
});
- $('#create_alert_word_form').on('keypress', '#create_alert_word_name', (event) => {
+ $("#create_alert_word_form").on("keypress", "#create_alert_word_name", (event) => {
const key = event.which;
// Handle enter (13) as "add".
if (key === 13) {
@@ -97,9 +97,9 @@ exports.set_up_alert_words = function () {
}
});
- $('#alert-word-settings').on('click', '.close-alert-word-status', (event) => {
+ $("#alert-word-settings").on("click", ".close-alert-word-status", (event) => {
event.preventDefault();
- const alert = $(event.currentTarget).parents('.alert');
+ const alert = $(event.currentTarget).parents(".alert");
alert.hide();
});
};
diff --git a/static/js/analytics/activity.js b/static/js/analytics/activity.js
index f89e0043d5c..d5012c2fd80 100644
--- a/static/js/analytics/activity.js
+++ b/static/js/analytics/activity.js
@@ -1,5 +1,5 @@
$(() => {
- $('a.envelope-link').click(function () {
+ $("a.envelope-link").click(function () {
common.copy_data_attribute_value($(this), "admin-emails");
});
});
diff --git a/static/js/analytics/support.js b/static/js/analytics/support.js
index a1a1fd02c78..840e303a18d 100644
--- a/static/js/analytics/support.js
+++ b/static/js/analytics/support.js
@@ -9,7 +9,7 @@ $(() => {
}
});
- $('a.copy-button').click(function () {
+ $("a.copy-button").click(function () {
common.copy_data_attribute_value($(this), "copytext");
});
});
diff --git a/static/js/archive.js b/static/js/archive.js
index fac744ec797..69c134d9f4d 100644
--- a/static/js/archive.js
+++ b/static/js/archive.js
@@ -1,4 +1,4 @@
-const render_archive_message_group = require('../templates/archive_message_group.hbs');
+const render_archive_message_group = require("../templates/archive_message_group.hbs");
function should_separate_into_groups(current_msg_time, next_msg_time) {
const current_time = new XDate(current_msg_time * 1000);
@@ -7,9 +7,9 @@ function should_separate_into_groups(current_msg_time, next_msg_time) {
}
function all_message_timestamps_to_human_readable() {
- $('.message_time').each(function () {
+ $(".message_time").each(function () {
const time = new XDate(parseInt($(this).text(), 10) * 1000);
- $(this).text(time.toString('h:mm TT'));
+ $(this).text(time.toString("h:mm TT"));
});
}
@@ -18,9 +18,9 @@ exports.initialize = function () {
const all_message_groups = [];
let current_message_group = {};
const today = new XDate();
- const recipient_and_topic = $('#display_recipient').html();
- const stream_name = recipient_and_topic.split('-')[0];
- const topic = recipient_and_topic.split('-')[1];
+ const recipient_and_topic = $("#display_recipient").html();
+ const stream_name = recipient_and_topic.split("-")[0];
+ const topic = recipient_and_topic.split("-")[1];
const recipient_color = color_data.pick_color();
current_message_group.message_containers = [];
current_message_group.show_group_date_divider = false;
@@ -45,10 +45,10 @@ exports.initialize = function () {
current_message_group.background_color = recipient_color;
}
- $('.message_row').each(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 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);
if (current_message_row.next().length === 0) {
separate_into_groups(current_message_row, cur_msg_time);
@@ -69,45 +69,45 @@ exports.initialize = function () {
message_groups: all_message_groups,
};
const message_groups_html = render_archive_message_group(context);
- $('.message_row').each(function () {
+ $(".message_row").each(function () {
$(this).detach();
});
- $('.message_table').prepend(message_groups_html);
- $('.messagebox').css('box-shadow', 'inset 2px 0px 0px 0px ' + recipient_color);
- $('#display_recipient').remove();
+ $(".message_table").prepend(message_groups_html);
+ $(".messagebox").css("box-shadow", "inset 2px 0px 0px 0px " + recipient_color);
+ $("#display_recipient").remove();
// Fixing include_sender after rendering groups.
let prev_sender;
- $('.recipient_row').each(function () {
+ $(".recipient_row").each(function () {
if (prev_sender !== undefined) {
- const first_group_msg = $(this).find('.message_row').first();
- const message_sender = first_group_msg.find('.message_sender');
- if (!message_sender.find('.inline_profile_picture').length) {
+ const first_group_msg = $(this).find(".message_row").first();
+ const message_sender = first_group_msg.find(".message_sender");
+ if (!message_sender.find(".inline_profile_picture").length) {
message_sender.replaceWith(prev_sender.clone());
}
}
- const all_senders = $(this).find('.message_sender').has('.inline_profile_picture');
+ const all_senders = $(this).find(".message_sender").has(".inline_profile_picture");
prev_sender = all_senders.last();
});
- $('.app').scrollTop($('.app').height());
+ $(".app").scrollTop($(".app").height());
all_message_timestamps_to_human_readable();
};
exports.current_msg_list = {
selected_row: function () {
- return $('.message_row').last();
+ return $(".message_row").last();
},
};
exports.rows = {
get_message_recipient_row: function (message_row) {
- return $(message_row).parent('.recipient_row');
+ return $(message_row).parent(".recipient_row");
},
first_message_in_group: function (message_group) {
- return $('div.message_row', message_group).first();
+ return $("div.message_row", message_group).first();
},
id: function (message_row) {
- return parseFloat(message_row.attr('zid'));
+ return parseFloat(message_row.attr("zid"));
},
};
@@ -124,7 +124,7 @@ $(() => {
$.fn.safeOuterWidth = function (...args) {
return this.outerWidth(...args) || 0;
};
- $('.app').scroll(_.throttle(() => {
+ $(".app").scroll(_.throttle(() => {
scroll_finish();
}, 50));
exports.initialize();
diff --git a/static/js/attachments_ui.js b/static/js/attachments_ui.js
index 75483e22b8a..2973ad05936 100644
--- a/static/js/attachments_ui.js
+++ b/static/js/attachments_ui.js
@@ -9,16 +9,16 @@ exports.bytes_to_size = function (bytes, kb_with_1024_bytes) {
kb_with_1024_bytes = false;
}
const kb_size = kb_with_1024_bytes ? 1024 : 1000;
- const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
+ const sizes = ["B", "KB", "MB", "GB", "TB"];
if (bytes === 0) {
- return '0 B';
+ return "0 B";
}
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;
}
- return size + ' ' + sizes[i];
+ return size + " " + sizes[i];
};
exports.percentage_used_space = function (uploads_size) {
@@ -42,9 +42,9 @@ function set_upload_space_stats() {
}
function delete_attachments(attachment) {
- const status = $('#delete-upload-status');
+ const status = $("#delete-upload-status");
channel.del({
- url: '/json/attachments/' + attachment,
+ url: "/json/attachments/" + attachment,
idempotent: true,
error: function (xhr) {
ui_report.error(i18n.t("Failed"), xhr, status);
@@ -91,12 +91,12 @@ function render_attachments_ui() {
ui.reset_scrollbar(uploaded_files_table.closest(".progressive-table-wrapper"));
},
},
- parent_container: $('#attachments-settings').expectOne(),
- init_sort: ['numeric', 'create_time'],
+ parent_container: $("#attachments-settings").expectOne(),
+ init_sort: ["numeric", "create_time"],
sort_fields: {
mentioned_in: sort_mentioned_in,
},
- simplebar_container: $('#attachments-settings .progressive-table-wrapper'),
+ simplebar_container: $("#attachments-settings .progressive-table-wrapper"),
});
ui.reset_scrollbar(uploaded_files_table.closest(".progressive-table-wrapper"));
@@ -115,10 +115,10 @@ exports.update_attachments = function (event) {
// If we haven't fetched attachment data yet, there's nothing to do.
return;
}
- if (event.op === 'remove' || event.op === 'update') {
+ if (event.op === "remove" || event.op === "update") {
attachments = attachments.filter((a) => a.id !== event.attachment.id);
}
- if (event.op === 'add' || event.op === 'update') {
+ if (event.op === "add" || event.op === "update") {
format_attachment_data([event.attachment]);
attachments.push(event.attachment);
}
@@ -131,25 +131,25 @@ exports.update_attachments = function (event) {
exports.set_up_attachments = function () {
// The settings page must be rendered before this function gets called.
- const status = $('#delete-upload-status');
- loading.make_indicator($('#attachments_loading_indicator'), {text: 'Loading...'});
+ const status = $("#delete-upload-status");
+ loading.make_indicator($("#attachments_loading_indicator"), {text: "Loading..."});
- $('#uploaded_files_table').on('click', '.remove-attachment', (e) => {
- delete_attachments($(e.target).closest(".uploaded_file_row").attr('data-attachment-id'));
+ $("#uploaded_files_table").on("click", ".remove-attachment", (e) => {
+ delete_attachments($(e.target).closest(".uploaded_file_row").attr("data-attachment-id"));
});
channel.get({
url: "/json/attachments",
idempotent: true,
success: function (data) {
- loading.destroy_indicator($('#attachments_loading_indicator'));
+ loading.destroy_indicator($("#attachments_loading_indicator"));
format_attachment_data(data.attachments);
attachments = data.attachments;
upload_space_used = data.upload_space_used;
render_attachments_ui();
},
error: function (xhr) {
- loading.destroy_indicator($('#attachments_loading_indicator'));
+ loading.destroy_indicator($("#attachments_loading_indicator"));
ui_report.error(i18n.t("Failed"), xhr, status);
},
});
diff --git a/static/js/avatar.js b/static/js/avatar.js
index bfe17ec5183..4f4bc195d0c 100644
--- a/static/js/avatar.js
+++ b/static/js/avatar.js
@@ -4,13 +4,13 @@ exports.build_bot_create_widget = function () {
// where we replace it wholesale, so we generalize the file input with
// a callback function.
const get_file_input = function () {
- return $('#bot_avatar_file_input');
+ return $("#bot_avatar_file_input");
};
- const file_name_field = $('#bot_avatar_file');
- const input_error = $('#bot_avatar_file_input_error');
- const clear_button = $('#bot_avatar_clear_button');
- const upload_button = $('#bot_avatar_upload_button');
+ const file_name_field = $("#bot_avatar_file");
+ const input_error = $("#bot_avatar_file_input_error");
+ const clear_button = $("#bot_avatar_clear_button");
+ const upload_button = $("#bot_avatar_upload_button");
return upload_widget.build_widget(
get_file_input,
@@ -23,13 +23,13 @@ exports.build_bot_create_widget = function () {
exports.build_bot_edit_widget = function (target) {
const get_file_input = function () {
- return target.find('.edit_bot_avatar_file_input');
+ return target.find(".edit_bot_avatar_file_input");
};
- const file_name_field = target.find('.edit_bot_avatar_file');
- const input_error = target.find('.edit_bot_avatar_error');
- const clear_button = target.find('.edit_bot_avatar_clear_button');
- const upload_button = target.find('.edit_bot_avatar_upload_button');
+ const file_name_field = target.find(".edit_bot_avatar_file");
+ const input_error = target.find(".edit_bot_avatar_error");
+ const clear_button = target.find(".edit_bot_avatar_clear_button");
+ const upload_button = target.find(".edit_bot_avatar_upload_button");
return upload_widget.build_widget(
get_file_input,
@@ -42,27 +42,27 @@ exports.build_bot_edit_widget = function (target) {
exports.build_user_avatar_widget = function (upload_function) {
const get_file_input = function () {
- return $('#user-avatar-upload-widget .image_file_input').expectOne();
+ return $("#user-avatar-upload-widget .image_file_input").expectOne();
};
- if (page_params.avatar_source === 'G') {
+ if (page_params.avatar_source === "G") {
$("#user-avatar-upload-widget .settings-page-delete-button").hide();
$("#user-avatar-source").show();
} else {
$("#user-avatar-source").hide();
}
- $("#user-avatar-upload-widget .settings-page-delete-button").on('click keydown', (e) => {
+ $("#user-avatar-upload-widget .settings-page-delete-button").on("click keydown", (e) => {
e.preventDefault();
e.stopPropagation();
channel.del({
- url: '/json/users/me/avatar',
+ url: "/json/users/me/avatar",
success: function () {
$("#user-avatar-upload-widget .settings-page-delete-button").hide();
$("#user-avatar-source").show();
// Need to clear input because of a small edge case
// where you try to upload the same image you just deleted.
- get_file_input().val('');
+ get_file_input().val("");
// Rest of the work is done via the user_events -> avatar_url event we will get
},
});
diff --git a/static/js/billing/billing.js b/static/js/billing/billing.js
index 6fa780d1cd2..7d188962e68 100644
--- a/static/js/billing/billing.js
+++ b/static/js/billing/billing.js
@@ -4,17 +4,17 @@ exports.initialize = function () {
const stripe_key = $("#payment-method").data("key");
const card_change_handler = StripeCheckout.configure({ // eslint-disable-line no-undef
key: stripe_key,
- image: '/static/images/logo/zulip-icon-128x128.png',
- locale: 'auto',
+ image: "/static/images/logo/zulip-icon-128x128.png",
+ locale: "auto",
token: function (stripe_token) {
helpers.create_ajax_request("/json/billing/sources/change", "cardchange", stripe_token);
},
});
- $('#update-card-button').on('click', (e) => {
+ $("#update-card-button").on("click", (e) => {
const email = $("#payment-method").data("email");
card_change_handler.open({
- name: 'Zulip',
+ name: "Zulip",
zipCode: true,
billingAddress: true,
panelLabel: "Update card",
@@ -25,7 +25,7 @@ exports.initialize = function () {
e.preventDefault();
});
- $("#change-plan-status").on('click', (e) => {
+ $("#change-plan-status").on("click", (e) => {
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 e45ecff063c..1ab3a2fac58 100644
--- a/static/js/billing/helpers.js
+++ b/static/js/billing/helpers.js
@@ -10,7 +10,7 @@ exports.create_ajax_request = function (url, form_name, stripe_token = null, num
const free_trial_alert_message = "#free-trial-alert-message";
loading.make_indicator($(form_loading_indicator),
- {text: 'Processing ...', abs_positioned: true});
+ {text: "Processing ...", abs_positioned: true});
$(form_input_section).hide();
$(form_error).hide();
$(form_loading).show();
@@ -91,8 +91,8 @@ exports.show_license_section = function (license) {
$("#license-automatic-section").hide();
$("#license-manual-section").hide();
- $("#automatic_license_count").prop('disabled', true);
- $("#manual_license_count").prop('disabled', true);
+ $("#automatic_license_count").prop("disabled", true);
+ $("#manual_license_count").prop("disabled", true);
const section_id = "#license-" + license + "-section";
$(section_id).show();
@@ -103,17 +103,17 @@ exports.show_license_section = function (license) {
exports.set_tab = function (page) {
const hash = location.hash;
if (hash) {
- $('#' + page + '-tabs.nav a[href="' + hash + '"]').tab('show');
- $('html').scrollTop(0);
+ $("#" + page + '-tabs.nav a[href="' + hash + '"]').tab("show");
+ $("html").scrollTop(0);
}
- $('#' + page + '-tabs.nav-tabs a').on("click", function () {
+ $("#" + page + "-tabs.nav-tabs a").on("click", function () {
location.hash = this.hash;
});
window.onhashchange = function () {
- $('#' + page + '-tabs.nav a[href="' + location.hash + '"]').tab('show');
- $('html').scrollTop(0);
+ $("#" + page + '-tabs.nav a[href="' + location.hash + '"]').tab("show");
+ $("html").scrollTop(0);
};
};
diff --git a/static/js/billing/upgrade.js b/static/js/billing/upgrade.js
index f0dc85e3639..6eea0122797 100644
--- a/static/js/billing/upgrade.js
+++ b/static/js/billing/upgrade.js
@@ -3,20 +3,20 @@ exports.initialize = () => {
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',
+ 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"]);
},
});
- $('#add-card-button').on('click', (e) => {
- const license_management = $('input[type=radio][name=license_management]:checked').val();
+ $("#add-card-button").on("click", (e) => {
+ const license_management = $("input[type=radio][name=license_management]:checked").val();
if (helpers.is_valid_input($("#" + license_management + "_license_count")) === false) {
return;
}
add_card_handler.open({
- name: 'Zulip',
+ name: "Zulip",
zipCode: true,
billingAddress: true,
panelLabel: "Make payment",
@@ -45,15 +45,15 @@ exports.initialize = () => {
prices.annual = page_params.annual_price * (1 - page_params.percent_off / 100);
prices.monthly = page_params.monthly_price * (1 - page_params.percent_off / 100);
- $('input[type=radio][name=license_management]').on("change", function () {
+ $("input[type=radio][name=license_management]").on("change", function () {
helpers.show_license_section(this.value);
});
- $('input[type=radio][name=schedule]').on("change", function () {
+ $("input[type=radio][name=schedule]").on("change", function () {
helpers.update_charged_amount(prices, this.value);
});
- $('select[name=organization-type]').on("change", function () {
+ $("select[name=organization-type]").on("change", function () {
helpers.update_discount_details(this.value);
});
@@ -63,8 +63,8 @@ exports.initialize = () => {
$("#invoice_annual_price").text(helpers.format_money(prices.annual));
$("#invoice_annual_price_per_month").text(helpers.format_money(prices.annual / 12));
- helpers.show_license_section($('input[type=radio][name=license_management]:checked').val());
- helpers.update_charged_amount(prices, $('input[type=radio][name=schedule]:checked').val());
+ helpers.show_license_section($("input[type=radio][name=license_management]:checked").val());
+ helpers.update_charged_amount(prices, $("input[type=radio][name=schedule]:checked").val());
};
window.upgrade = exports;
diff --git a/static/js/blueslip.js b/static/js/blueslip.js
index 8f5ae50c8d6..bf6cf4cf0f4 100644
--- a/static/js/blueslip.js
+++ b/static/js/blueslip.js
@@ -29,18 +29,18 @@ 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';
+ 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("");
+ ": " + str_args.join("");
this._memory_log.push(log_entry);
// Don't let the log grow without bound
@@ -61,7 +61,7 @@ Logger.prototype = (function () {
},
};
- const methods = ['debug', 'log', 'info', 'warn', 'error'];
+ const methods = ["debug", "log", "info", "warn", "error"];
let i;
for (i = 0; i < methods.length; i += 1) {
proto[methods[i]] = make_logger_func(methods[i]);
@@ -83,7 +83,7 @@ function report_error(msg, stack, opts) {
opts = { show_ui_msg: false, ...opts };
if (stack === undefined) {
- stack = 'No stacktrace available';
+ stack = "No stacktrace available";
}
if (page_params.debug_mode) {
@@ -92,7 +92,7 @@ function report_error(msg, stack, opts) {
blueslip_stacktrace.display_stacktrace(msg, stack);
}
- const key = ':' + msg + stack;
+ const key = ":" + msg + stack;
if (reported_errors.has(key)
|| last_report_attempt.has(key)
// Only try to report a given error once every 5 minutes
@@ -110,9 +110,9 @@ function report_error(msg, stack, opts) {
// Important: We don't use channel.js here so that exceptions
// always make it to the server even if reload_state.is_in_progress.
$.ajax({
- type: 'POST',
- url: '/json/report/error',
- dataType: 'json',
+ type: "POST",
+ url: "/json/report/error",
+ dataType: "json",
data: {
message: msg,
stacktrace: stack,
@@ -178,7 +178,7 @@ function BlueslipError(msg, more_info) {
self.name = "BlueslipError";
// Indirect access to __proto__ keeps jslint quiet
- const proto = '__proto__';
+ const proto = "__proto__";
self[proto] = BlueslipError.prototype;
if (more_info !== undefined) {
@@ -200,7 +200,7 @@ exports.exception_msg = function blueslip_exception_msg(ex) {
return message;
};
-$(window).on('error', (event) => {
+$(window).on("error", (event) => {
const ex = event.originalEvent.error;
if (!ex || ex instanceof BlueslipError) {
return;
diff --git a/static/js/bot_data.js b/static/js/bot_data.js
index f877b045b26..b3f6e5094c3 100644
--- a/static/js/bot_data.js
+++ b/static/js/bot_data.js
@@ -1,23 +1,23 @@
const bots = new Map();
const bot_fields = [
- 'api_key',
- 'avatar_url',
- 'bot_type',
- 'default_all_public_streams',
- 'default_events_register_stream',
- 'default_sending_stream',
- 'email',
- 'full_name',
- 'is_active',
- 'owner', // TODO: eliminate
- 'owner_id',
- 'user_id',
+ "api_key",
+ "avatar_url",
+ "bot_type",
+ "default_all_public_streams",
+ "default_events_register_stream",
+ "default_sending_stream",
+ "email",
+ "full_name",
+ "is_active",
+ "owner", // TODO: eliminate
+ "owner_id",
+ "user_id",
];
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();
@@ -53,7 +53,7 @@ exports.update = function (bot_id, bot_update) {
// We currently only support one service per bot.
const service = services.get(bot_id)[0];
- if (typeof bot_update.services !== 'undefined' && bot_update.services.length > 0) {
+ if (typeof bot_update.services !== "undefined" && bot_update.services.length > 0) {
Object.assign(service, _.pick(bot_update.services[0], services_fields));
}
diff --git a/static/js/buddy_data.js b/static/js/buddy_data.js
index 8d1a6d1d3fe..95ce48ef874 100644
--- a/static/js/buddy_data.js
+++ b/static/js/buddy_data.js
@@ -26,15 +26,15 @@ exports.get_user_circle_class = function (user_id) {
const status = exports.buddy_status(user_id);
switch (status) {
- case 'active':
- return 'user_circle_green';
- case 'idle':
- return 'user_circle_orange';
- case 'away_them':
- case 'away_me':
- return 'user_circle_empty_line';
+ case "active":
+ return "user_circle_green";
+ case "idle":
+ return "user_circle_orange";
+ case "away_them":
+ case "away_me":
+ return "user_circle_empty_line";
default:
- return 'user_circle_empty';
+ return "user_circle_empty";
}
};
@@ -42,15 +42,15 @@ exports.status_description = function (user_id) {
const status = exports.buddy_status(user_id);
switch (status) {
- case 'active':
- return i18n.t('Active');
- case 'idle':
- return i18n.t('Idle');
- case 'away_them':
- case 'away_me':
- return i18n.t('Unavailable');
+ case "active":
+ return i18n.t("Active");
+ case "idle":
+ return i18n.t("Idle");
+ case "away_them":
+ case "away_me":
+ return i18n.t("Unavailable");
default:
- return i18n.t('Offline');
+ return i18n.t("Offline");
}
};
@@ -63,11 +63,11 @@ exports.level = function (user_id) {
const status = exports.buddy_status(user_id);
switch (status) {
- case 'active':
+ case "active":
return 1;
- case 'idle':
+ case "idle":
return 2;
- case 'away_them':
+ case "away_them":
return 3;
default:
return 3;
@@ -77,10 +77,10 @@ exports.level = function (user_id) {
exports.buddy_status = function (user_id) {
if (user_status.is_away(user_id)) {
if (people.is_my_user_id(user_id)) {
- return 'away_me';
+ return "away_me";
}
- return 'away_them';
+ return "away_them";
}
// get active/idle/etc.
@@ -99,8 +99,8 @@ exports.compare_function = function (a, b) {
const person_a = people.get_by_user_id(a);
const person_b = people.get_by_user_id(b);
- const full_name_a = person_a ? person_a.full_name : '';
- const full_name_b = person_b ? person_b.full_name : '';
+ const full_name_a = person_a ? person_a.full_name : "";
+ const full_name_b = person_b ? person_b.full_name : "";
return util.strcmp(full_name_a, full_name_b);
};
@@ -112,7 +112,7 @@ exports.sort_users = function (user_ids) {
};
function filter_user_ids(user_filter_text, user_ids) {
- if (user_filter_text === '') {
+ if (user_filter_text === "") {
return user_ids;
}
@@ -143,10 +143,10 @@ exports.my_user_status = function (user_id) {
}
if (user_status.is_away(user_id)) {
- return i18n.t('(unavailable)');
+ return i18n.t("(unavailable)");
}
- return i18n.t('(you)');
+ return i18n.t("(you)");
};
exports.user_last_seen_time_status = function (user_id) {
@@ -192,11 +192,11 @@ exports.info_for = function (user_id) {
};
function get_last_seen(active_status, last_seen) {
- if (active_status === 'active') {
+ if (active_status === "active") {
return last_seen;
}
- const last_seen_text = i18n.t('Last active: __last_seen__', {last_seen: last_seen});
+ const last_seen_text = i18n.t("Last active: __last_seen__", {last_seen: last_seen});
return last_seen_text;
}
@@ -205,8 +205,8 @@ exports.get_title_data = function (user_ids_string, is_group) {
// For groups, just return a string with recipient names.
return {
first_line: people.get_recipients(user_ids_string),
- second_line: '',
- third_line: '',
+ second_line: "",
+ third_line: "",
};
}
@@ -219,22 +219,22 @@ exports.get_title_data = function (user_ids_string, is_group) {
if (bot_owner) {
const bot_owner_name = i18n.t(
- 'Owner: __name__',
+ "Owner: __name__",
{name: bot_owner.full_name},
);
return {
first_line: person.full_name,
second_line: bot_owner_name,
- third_line: '',
+ third_line: "",
};
}
// Bot does not have an owner.
return {
first_line: person.full_name,
- second_line: '',
- third_line: '',
+ second_line: "",
+ third_line: "",
};
}
@@ -257,7 +257,7 @@ exports.get_title_data = function (user_ids_string, is_group) {
return {
first_line: person.full_name,
second_line: get_last_seen(active_status, last_seen),
- third_line: '',
+ third_line: "",
};
};
@@ -310,7 +310,7 @@ function get_user_id_list(user_filter_text) {
const person = people.get_by_user_id(user_id);
if (!person) {
- blueslip.warn('Got user_id in presence but not people: ' + user_id);
+ blueslip.warn("Got user_id in presence but not people: " + user_id);
return false;
}
@@ -334,7 +334,7 @@ exports.get_items_for_users = function (user_ids) {
};
exports.huddle_fraction_present = function (huddle) {
- const user_ids = huddle.split(',').map((s) => parseInt(s, 10));
+ const user_ids = huddle.split(",").map((s) => parseInt(s, 10));
let num_present = 0;
diff --git a/static/js/buddy_list.js b/static/js/buddy_list.js
index e3a3c39baac..7dd51ee39d8 100644
--- a/static/js/buddy_list.js
+++ b/static/js/buddy_list.js
@@ -1,13 +1,13 @@
-const render_user_presence_row = require('../templates/user_presence_row.hbs');
-const render_user_presence_rows = require('../templates/user_presence_rows.hbs');
+const render_user_presence_row = require("../templates/user_presence_row.hbs");
+const render_user_presence_rows = require("../templates/user_presence_rows.hbs");
function buddy_list_conf() {
const conf = {};
- conf.container_sel = '#user_presences';
- conf.scroll_container_sel = '#buddy_list_wrapper';
- conf.item_sel = 'li.user_sidebar_entry';
- conf.padding_sel = '#buddy_list_wrapper_padding';
+ conf.container_sel = "#user_presences";
+ conf.scroll_container_sel = "#buddy_list_wrapper";
+ conf.item_sel = "li.user_sidebar_entry";
+ conf.padding_sel = "#buddy_list_wrapper_padding";
conf.items_to_html = function (opts) {
const user_info = opts.items;
@@ -28,7 +28,7 @@ function buddy_list_conf() {
};
conf.get_key_from_li = function (opts) {
- return parseInt(opts.li.expectOne().attr('data-user-id'), 10);
+ return parseInt(opts.li.expectOne().attr("data-user-id"), 10);
};
conf.get_data_from_keys = function (opts) {
@@ -63,13 +63,13 @@ function buddy_list_create() {
self.padding_sel = conf.padding_sel;
const func_names = [
- 'items_to_html',
- 'item_to_html',
- 'get_li_from_key',
- 'get_key_from_li',
- 'get_data_from_keys',
- 'compare_function',
- 'height_to_fill',
+ "items_to_html",
+ "item_to_html",
+ "get_li_from_key",
+ "get_key_from_li",
+ "get_data_from_keys",
+ "compare_function",
+ "height_to_fill",
];
for (const func_name of func_names) {
@@ -80,7 +80,7 @@ function buddy_list_create() {
self.populate = function (opts) {
self.render_count = 0;
- self.container.html('');
+ self.container.html("");
// We rely on our caller to give us items
// in already-sorted order.
@@ -190,7 +190,7 @@ function buddy_list_create() {
const chunk_size = pos + cushion_size - self.render_count;
if (chunk_size <= 0) {
- blueslip.error('cannot show key at this position: ' + pos);
+ blueslip.error("cannot show key at this position: " + pos);
}
self.render_more({
diff --git a/static/js/channel.js b/static/js/channel.js
index d7ef99a87b5..9a0d158db3e 100644
--- a/static/js/channel.js
+++ b/static/js/channel.js
@@ -3,8 +3,8 @@ 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.");
}
}
@@ -43,14 +43,14 @@ function call(args, idempotent) {
if (xhr.status === 403) {
try {
- if (JSON.parse(xhr.responseText).code === 'CSRF_FAILED') {
+ if (JSON.parse(xhr.responseText).code === "CSRF_FAILED") {
reload.initiate({immediate: true,
save_pointer: true,
save_narrow: true,
save_compose: true});
}
} catch (ex) {
- blueslip.error('Unexpected 403 response from server',
+ blueslip.error("Unexpected 403 response from server",
{xhr: xhr.responseText,
args: args},
ex.stack);
@@ -120,7 +120,7 @@ exports.patch = function (options) {
// method this way
options.data.append("method", "PATCH");
} else {
- options.data = { ...options.data, method: 'PATCH' };
+ options.data = { ...options.data, method: "PATCH" };
}
return exports.post(options, options.idempotent);
};
diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js
index 2995c8c58c2..016a1925fd2 100644
--- a/static/js/click_handlers.js
+++ b/static/js/click_handlers.js
@@ -1,9 +1,9 @@
const util = require("./util");
-const settings_panel_menu = require('./settings_panel_menu');
+const settings_panel_menu = require("./settings_panel_menu");
// You won't find every click handler here, but it's a good place to start!
-const render_buddy_list_tooltip = require('../templates/buddy_list_tooltip.hbs');
-const render_buddy_list_tooltip_content = require('../templates/buddy_list_tooltip_content.hbs');
+const render_buddy_list_tooltip = require("../templates/buddy_list_tooltip.hbs");
+const render_buddy_list_tooltip_content = require("../templates/buddy_list_tooltip_content.hbs");
function convert_enter_to_click(e) {
const key = e.which;
@@ -73,7 +73,7 @@ exports.initialize = function () {
// body that have UI behavior other than starting a reply.
// Links should be handled by the browser.
- if (target.closest('a').length > 0) {
+ if (target.closest("a").length > 0) {
return true;
}
@@ -133,7 +133,7 @@ exports.initialize = function () {
}
current_msg_list.select_id(id);
- compose_actions.respond_to_message({trigger: 'message click'});
+ compose_actions.respond_to_message({trigger: "message click"});
e.stopPropagation();
popovers.hide_all();
};
@@ -173,30 +173,30 @@ exports.initialize = function () {
$("#main_div").on("click", ".message_reaction", function (e) {
e.stopPropagation();
emoji_picker.hide_emoji_popover();
- const local_id = $(this).attr('data-reaction-id');
+ const local_id = $(this).attr("data-reaction-id");
const message_id = rows.get_message_id(this);
reactions.process_reaction_click(message_id, local_id);
$(".tooltip").remove();
});
- $('body').on('mouseenter', '.message_edit_notice', (e) => {
+ $("body").on("mouseenter", ".message_edit_notice", (e) => {
if (page_params.realm_allow_edit_history) {
$(e.currentTarget).addClass("message_edit_notice_hover");
}
});
- $('body').on('mouseleave', '.message_edit_notice', (e) => {
+ $("body").on("mouseleave", ".message_edit_notice", (e) => {
if (page_params.realm_allow_edit_history) {
$(e.currentTarget).removeClass("message_edit_notice_hover");
}
});
- $('body').on('click', '.message_edit_notice', (e) => {
+ $("body").on("click", ".message_edit_notice", (e) => {
popovers.hide_all();
const message_id = rows.id($(e.currentTarget).closest(".message_row"));
const row = current_msg_list.get_row(message_id);
const message = current_msg_list.get(rows.id(row));
- const message_history_cancel_btn = $('#message-history-cancel');
+ const message_history_cancel_btn = $("#message-history-cancel");
if (page_params.realm_allow_edit_history) {
message_edit_history.show_history(message);
@@ -208,33 +208,33 @@ exports.initialize = function () {
// TOOLTIP FOR MESSAGE REACTIONS
- $('#main_div').on('mouseenter', '.message_reaction', (e) => {
+ $("#main_div").on("mouseenter", ".message_reaction", (e) => {
e.stopPropagation();
const elem = $(e.currentTarget);
- const local_id = elem.attr('data-reaction-id');
+ const local_id = elem.attr("data-reaction-id");
const message_id = rows.get_message_id(e.currentTarget);
const title = reactions.get_reaction_title_data(message_id, local_id);
elem.tooltip({
title: title,
- trigger: 'hover',
- placement: 'bottom',
+ trigger: "hover",
+ placement: "bottom",
animation: false,
});
- elem.tooltip('show');
- $(".tooltip, .tooltip-inner").css('max-width', "600px");
+ elem.tooltip("show");
+ $(".tooltip, .tooltip-inner").css("max-width", "600px");
// Remove the arrow from the tooltip.
$(".tooltip-arrow").remove();
});
- $('#main_div').on('mouseleave', '.message_reaction', (e) => {
+ $("#main_div").on("mouseleave", ".message_reaction", (e) => {
e.stopPropagation();
- $(e.currentTarget).tooltip('destroy');
+ $(e.currentTarget).tooltip("destroy");
});
// DESTROY PERSISTING TOOLTIPS ON HOVER
- $("body").on('mouseenter', '.tooltip', (e) => {
+ $("body").on("mouseenter", ".tooltip", (e) => {
e.stopPropagation();
$(e.currentTarget).remove();
});
@@ -243,12 +243,12 @@ exports.initialize = function () {
e.preventDefault();
// Note that we may have an href here, but we trust the stream id more,
// so we re-encode the hash.
- const stream_id = parseInt($(this).attr('data-stream-id'), 10);
+ const stream_id = parseInt($(this).attr("data-stream-id"), 10);
if (stream_id) {
hashchange.go_to_location(hash_util.by_stream_uri(stream_id));
return;
}
- window.location.href = $(this).attr('href');
+ window.location.href = $(this).attr("href");
});
// USER STATUS MODAL
@@ -263,22 +263,22 @@ exports.initialize = function () {
// NOTIFICATION CLICK
- $('body').on('click', '.notification', function () {
+ $("body").on("click", ".notification", function () {
const payload = $(this).data("narrow");
- ui_util.change_tab_to('#home');
+ ui_util.change_tab_to("#home");
narrow.activate(payload.raw_operators, payload.opts_notif);
});
// MESSAGE EDITING
- $('body').on('click', '.edit_content_button', function (e) {
+ $("body").on("click", ".edit_content_button", function (e) {
const row = current_msg_list.get_row(rows.id($(this).closest(".message_row")));
current_msg_list.select_id(rows.id(row));
message_edit.start(row);
e.stopPropagation();
popovers.hide_all();
});
- $('body').on('click', '.always_visible_topic_edit,.on_hover_topic_edit', function (e) {
+ $("body").on("click", ".always_visible_topic_edit,.on_hover_topic_edit", function (e) {
const recipient_row = $(this).closest(".recipient_row");
message_edit.start_topic_edit(recipient_row);
e.stopPropagation();
@@ -328,9 +328,9 @@ exports.initialize = function () {
ui_util.blur_active_element();
}
});
- $('#message_edit_form .send-status-close').click(function () {
+ $("#message_edit_form .send-status-close").click(function () {
const row_id = rows.id($(this).closest(".message_row"));
- const send_status = $('#message-edit-send-status-' + row_id);
+ const send_status = $("#message-edit-send-status-" + row_id);
$(send_status).stop(true).fadeOut(200);
});
$("body").on("click", "#message_edit_form [id^='attach_files_']", function (e) {
@@ -374,55 +374,55 @@ exports.initialize = function () {
// MUTING
- $('body').on('click', '.on_hover_topic_mute', (e) => {
+ $("body").on("click", ".on_hover_topic_mute", (e) => {
e.stopPropagation();
- const stream_id = parseInt($(e.currentTarget).attr('data-stream-id'), 10);
- const topic = $(e.currentTarget).attr('data-topic-name');
+ const stream_id = parseInt($(e.currentTarget).attr("data-stream-id"), 10);
+ const topic = $(e.currentTarget).attr("data-topic-name");
muting_ui.mute(stream_id, topic);
});
- $('body').on('keydown', '.on_hover_topic_mute', convert_enter_to_click);
+ $("body").on("keydown", ".on_hover_topic_mute", convert_enter_to_click);
- $('body').on('click', '.on_hover_topic_unmute', (e) => {
+ $("body").on("click", ".on_hover_topic_unmute", (e) => {
e.stopPropagation();
- const stream_id = parseInt($(e.currentTarget).attr('data-stream-id'), 10);
- const topic = $(e.currentTarget).attr('data-topic-name');
+ const stream_id = parseInt($(e.currentTarget).attr("data-stream-id"), 10);
+ const topic = $(e.currentTarget).attr("data-topic-name");
muting_ui.unmute(stream_id, topic);
});
- $('body').on('keydown', '.on_hover_topic_unmute', convert_enter_to_click);
+ $("body").on("keydown", ".on_hover_topic_unmute", convert_enter_to_click);
// RECENT TOPICS
- $('body').on('click', '#recent_topics_search', (e) => {
+ $("body").on("click", "#recent_topics_search", (e) => {
e.stopPropagation();
- recent_topics.change_focused_element(e, 'click');
+ recent_topics.change_focused_element(e, "click");
});
- $('body').on('click', '.on_hover_topic_read', (e) => {
+ $("body").on("click", ".on_hover_topic_read", (e) => {
e.stopPropagation();
- const stream_id = parseInt($(e.currentTarget).attr('data-stream-id'), 10);
- const topic = $(e.currentTarget).attr('data-topic-name');
+ const stream_id = parseInt($(e.currentTarget).attr("data-stream-id"), 10);
+ const topic = $(e.currentTarget).attr("data-topic-name");
unread_ops.mark_topic_as_read(stream_id, topic);
});
- $('body').on('keydown', '.on_hover_topic_read', convert_enter_to_click);
+ $("body").on("keydown", ".on_hover_topic_read", convert_enter_to_click);
- $('body').on('click', '.btn-recent-filters', (e) => {
+ $("body").on("click", ".btn-recent-filters", (e) => {
e.stopPropagation();
recent_topics.set_filter(e.currentTarget.dataset.filter);
recent_topics.update_filters_view();
});
// Search for all table rows (this combines stream & topic names)
- $('body').on('keyup', '#recent_topics_search', _.debounce(() => {
+ $("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) => {
+ $("body").on("click", "#recent_topics_search_clear", (e) => {
e.stopPropagation();
- $('#recent_topics_search').val("");
+ $("#recent_topics_search").val("");
recent_topics.update_filters_view();
});
@@ -446,7 +446,7 @@ exports.initialize = function () {
}
e.preventDefault();
const row_id = get_row_id_for_narrowing(this);
- narrow.by_recipient(row_id, {trigger: 'message header'});
+ narrow.by_recipient(row_id, {trigger: "message header"});
});
$("#home").on("click", ".narrows_by_topic", function (e) {
@@ -455,7 +455,7 @@ exports.initialize = function () {
}
e.preventDefault();
const row_id = get_row_id_for_narrowing(this);
- narrow.by_topic(row_id, {trigger: 'message header'});
+ narrow.by_topic(row_id, {trigger: "message header"});
});
// SIDEBARS
@@ -482,8 +482,8 @@ 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});
@@ -498,53 +498,53 @@ exports.initialize = function () {
template: render_buddy_list_tooltip(),
title: render_buddy_list_tooltip_content(title_data),
html: true,
- trigger: 'hover',
- placement: 'bottom',
+ trigger: "hover",
+ placement: "bottom",
animation: false,
});
- elem.tooltip('show');
+ elem.tooltip("show");
- $(".tooltip").css('left', elem.pageX + 'px');
- $(".tooltip").css('top', elem.pageY + 'px');
+ $(".tooltip").css("left", elem.pageX + "px");
+ $(".tooltip").css("top", elem.pageY + "px");
}
// BUDDY LIST TOOLTIPS
- $('#user_presences').on('mouseenter', '.user-presence-link, .user_sidebar_entry .user_circle, .user_sidebar_entry .selectable_sidebar_block', (e) => {
+ $("#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 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) => {
+ $("#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');
+ $(elem).tooltip("destroy");
});
// PM LIST TOOLTIPS
- $("body").on('mouseenter', '#pm_user_status', (e) => {
+ $("body").on("mouseenter", "#pm_user_status", (e) => {
$(".tooltip").remove();
e.stopPropagation();
const elem = $(e.currentTarget);
- const user_ids_string = elem.attr('data-user-ids-string');
+ const user_ids_string = elem.attr("data-user-ids-string");
// This converts from 'true' in the DOM to true.
- const is_group = JSON.parse(elem.attr('data-is-group'));
+ const is_group = JSON.parse(elem.attr("data-is-group"));
const title_data = buddy_data.get_title_data(user_ids_string, is_group);
do_render_buddy_list_tooltip(elem, title_data);
});
- $("body").on('mouseleave', '#pm_user_status', (e) => {
+ $("body").on("mouseleave", "#pm_user_status", (e) => {
e.stopPropagation();
- $(e.currentTarget).tooltip('destroy');
+ $(e.currentTarget).tooltip("destroy");
});
// HOME
- $(document).on('click', ".top_left_all_messages", (e) => {
- ui_util.change_tab_to('#home');
+ $(document).on("click", ".top_left_all_messages", (e) => {
+ ui_util.change_tab_to("#home");
narrow.deactivate();
search.update_button_visibility();
// We need to maybe scroll to the selected message
@@ -553,7 +553,7 @@ exports.initialize = function () {
e.preventDefault();
});
- $(".brand").on('click', (e) => {
+ $(".brand").on("click", (e) => {
if (overlays.is_active()) {
overlays.close_active();
} else {
@@ -578,11 +578,11 @@ exports.initialize = function () {
stream_popover.register_click_handlers();
notifications.register_click_handlers();
- $('body').on('click', '.logout_button', () => {
- $('#logout_form').submit();
+ $("body").on("click", ".logout_button", () => {
+ $("#logout_form").submit();
});
- $('.restart_get_events_button').click(() => {
+ $(".restart_get_events_button").click(() => {
server_events.restart_get_events({dont_block: true});
});
@@ -607,42 +607,42 @@ 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); },
+ $("#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); },
+ $("#nonexistent_stream_reply_error .compose-send-status-close").click(
+ () => { $("#nonexistent_stream_reply_error").stop(true).fadeOut(500); },
);
- $('.compose_stream_button').click(() => {
+ $(".compose_stream_button").click(() => {
popovers.hide_mobile_message_buttons_popover();
- compose_actions.start('stream', {trigger: 'new topic button'});
+ compose_actions.start("stream", {trigger: "new topic button"});
});
- $('.compose_private_button').click(() => {
+ $(".compose_private_button").click(() => {
popovers.hide_mobile_message_buttons_popover();
- compose_actions.start('private');
+ compose_actions.start("private");
});
- $('body').on('click', '.compose_mobile_stream_button', () => {
+ $("body").on("click", ".compose_mobile_stream_button", () => {
popovers.hide_mobile_message_buttons_popover();
- compose_actions.start('stream', {trigger: 'new topic button'});
+ compose_actions.start("stream", {trigger: "new topic button"});
});
- $('body').on('click', '.compose_mobile_private_button', () => {
+ $("body").on("click", ".compose_mobile_private_button", () => {
popovers.hide_mobile_message_buttons_popover();
- compose_actions.start('private');
+ compose_actions.start("private");
});
- $('.compose_reply_button').click(() => {
- compose_actions.respond_to_message({trigger: 'reply button'});
+ $(".compose_reply_button").click(() => {
+ compose_actions.respond_to_message({trigger: "reply button"});
});
- $('.empty_feed_compose_stream').click((e) => {
- compose_actions.start('stream', {trigger: 'empty feed message'});
+ $(".empty_feed_compose_stream").click((e) => {
+ compose_actions.start("stream", {trigger: "empty feed message"});
e.preventDefault();
});
- $('.empty_feed_compose_private').click((e) => {
- compose_actions.start('private', {trigger: 'empty feed message'});
+ $(".empty_feed_compose_private").click((e) => {
+ compose_actions.start("private", {trigger: "empty feed message"});
e.preventDefault();
});
@@ -684,7 +684,7 @@ exports.initialize = function () {
$("#streams_inline_cog").click((e) => {
e.stopPropagation();
- hashchange.go_to_location('streams/subscribed');
+ hashchange.go_to_location("streams/subscribed");
});
$("#streams_filter_icon").click((e) => {
@@ -694,7 +694,7 @@ exports.initialize = function () {
// WEBATHENA
- $('body').on('click', '.webathena_login', (e) => {
+ $("body").on("click", ".webathena_login", (e) => {
$("#zephyr-mirror-error").removeClass("show");
const principal = ["zephyr", "zephyr"];
WinChan.open({
@@ -725,31 +725,31 @@ exports.initialize = function () {
},
});
});
- $('#settings-dropdown').dropdown("toggle");
+ $("#settings-dropdown").dropdown("toggle");
e.preventDefault();
e.stopPropagation();
});
// End Webathena code
// disable the draggability for left-sidebar components
- $('#stream_filters, #global_filters').on('dragstart', (e) => {
+ $("#stream_filters, #global_filters").on("dragstart", (e) => {
e.target.blur();
return false;
});
// Chrome focuses an element when dragging it which can be confusing when
// users involuntarily drag something and we show them the focus outline.
- $('body').on('dragstart', 'a', (e) => e.target.blur());
+ $("body").on("dragstart", "a", (e) => e.target.blur());
// Don't focus links on middle click.
- $('body').on('mouseup', 'a', (e) => {
+ $("body").on("mouseup", "a", (e) => {
if (e.which === 2) { // middle click
e.target.blur();
}
});
// Don't focus links on context menu.
- $('body').on('contextmenu', 'a', (e) => e.target.blur());
+ $("body").on("contextmenu", "a", (e) => e.target.blur());
(function () {
const map = {
@@ -832,23 +832,23 @@ exports.initialize = function () {
// HOTSPOTS
// open
- $('body').on('click', '.hotspot-icon', function (e) {
+ $("body").on("click", ".hotspot-icon", function (e) {
// hide icon
hotspots.close_hotspot_icon(this);
// show popover
- const hotspot_name = $(e.target).closest('.hotspot-icon')
- .attr('id')
- .replace('hotspot_', '')
- .replace('_icon', '');
- const overlay_name = 'hotspot_' + hotspot_name + '_overlay';
+ const hotspot_name = $(e.target).closest(".hotspot-icon")
+ .attr("id")
+ .replace("hotspot_", "")
+ .replace("_icon", "");
+ const overlay_name = "hotspot_" + hotspot_name + "_overlay";
overlays.open_overlay({
name: overlay_name,
- overlay: $('#' + overlay_name),
+ overlay: $("#" + overlay_name),
on_close: function () {
// close popover
- $(this).css({ display: 'block' });
+ $(this).css({ display: "block" });
$(this).animate({ opacity: 1 }, {
duration: 300,
});
@@ -860,40 +860,40 @@ exports.initialize = function () {
});
// confirm
- $('body').on('click', '.hotspot.overlay .hotspot-confirm', function (e) {
+ $("body").on("click", ".hotspot.overlay .hotspot-confirm", function (e) {
e.preventDefault();
e.stopPropagation();
- const overlay_name = $(this).closest('.hotspot.overlay').attr('id');
+ const overlay_name = $(this).closest(".hotspot.overlay").attr("id");
const hotspot_name = overlay_name
- .replace('hotspot_', '')
- .replace('_overlay', '');
+ .replace("hotspot_", "")
+ .replace("_overlay", "");
// Comment below to disable marking hotspots as read in production
hotspots.post_hotspot_as_read(hotspot_name);
overlays.close_overlay(overlay_name);
- $('#hotspot_' + hotspot_name + '_icon').remove();
+ $("#hotspot_" + hotspot_name + "_icon").remove();
});
- $('body').on('click', '.hotspot-button', (e) => {
+ $("body").on("click", ".hotspot-button", (e) => {
e.preventDefault();
e.stopPropagation();
- hotspots.post_hotspot_as_read('intro_reply');
- hotspots.close_hotspot_icon($('#hotspot_intro_reply_icon'));
+ hotspots.post_hotspot_as_read("intro_reply");
+ hotspots.close_hotspot_icon($("#hotspot_intro_reply_icon"));
});
// stop propagation
- $('body').on('click', '.hotspot.overlay .hotspot-popover', (e) => {
+ $("body").on("click", ".hotspot.overlay .hotspot-popover", (e) => {
e.stopPropagation();
});
// MAIN CLICK HANDLER
- $(document).on('click', (e) => {
+ $(document).on("click", (e) => {
if (e.button !== 0 || $(e.target).is(".drag")) {
// Firefox emits right click events on the document, but not on
// the child nodes, so the #compose stopPropagation doesn't get a
@@ -907,9 +907,9 @@ exports.initialize = function () {
}
// If user clicks outside an active modal
- if ($('.modal.in').has(e.target).length === 0) {
+ if ($(".modal.in").has(e.target).length === 0) {
// Enable mouse events for the background as the modal closes
- $('.overlay.show').attr("style", null);
+ $(".overlay.show").attr("style", null);
}
if (compose_state.composing()) {
@@ -923,10 +923,10 @@ exports.initialize = function () {
// should not have any effect on the compose
// state.
!$(e.target).closest(".overlay").length &&
- !$(e.target).closest('.popover').length &&
+ !$(e.target).closest(".popover").length &&
!$(e.target).closest(".modal").length &&
!$(e.target).closest(".modal-backdrop").length &&
- $(e.target).closest('body').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
@@ -939,7 +939,7 @@ exports.initialize = function () {
// Workaround for Bootstrap issue #5900, which basically makes dropdowns
// unclickable on mobile devices.
// https://github.com/twitter/bootstrap/issues/5900
- $('a.dropdown-toggle, .dropdown-menu a').on('touchstart', (e) => {
+ $("a.dropdown-toggle, .dropdown-menu a").on("touchstart", (e) => {
e.stopPropagation();
});
diff --git a/static/js/common.js b/static/js/common.js
index beda3c8ad3c..dcc94b758ef 100644
--- a/static/js/common.js
+++ b/static/js/common.js
@@ -3,7 +3,7 @@ if (module.hot) {
module.hot.accept();
}
-exports.status_classes = 'alert-error alert-success alert-info alert-warning';
+exports.status_classes = "alert-error alert-success alert-info alert-warning";
exports.autofocus = function (selector) {
$(() => {
@@ -21,12 +21,12 @@ exports.autofocus = function (selector) {
// and also from the in-app password change interface.
exports.password_quality = function (password, bar, password_field) {
// We load zxcvbn.js asynchronously, so the variable might not be set.
- if (typeof zxcvbn === 'undefined') {
+ if (typeof zxcvbn === "undefined") {
return;
}
- const min_length = password_field.data('minLength');
- const min_guesses = password_field.data('minGuesses');
+ const min_length = password_field.data("minLength");
+ const min_guesses = password_field.data("minGuesses");
const result = zxcvbn(password);
const acceptable = password.length >= min_length
@@ -44,23 +44,23 @@ exports.password_quality = function (password, bar, password_field) {
// The bar bottoms out at 10% so there's always something
// for the user to see.
- bar.width(90 * bar_progress + 10 + '%')
- .removeClass('bar-success bar-danger')
- .addClass(acceptable ? 'bar-success' : 'bar-danger');
+ bar.width(90 * bar_progress + 10 + "%")
+ .removeClass("bar-success bar-danger")
+ .addClass(acceptable ? "bar-success" : "bar-danger");
}
return acceptable;
};
exports.password_warning = function (password, password_field) {
- if (typeof zxcvbn === 'undefined') {
+ if (typeof zxcvbn === "undefined") {
return;
}
- const min_length = password_field.data('minLength');
+ 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");
};
@@ -75,7 +75,7 @@ exports.phrase_match = function (query, phrase) {
return true;
}
- const parts = phrase.split(' ');
+ const parts = phrase.split(" ");
for (i = 0; i < parts.length; i += 1) {
if (parts[i].startsWith(query)) {
return true;
@@ -87,7 +87,7 @@ exports.phrase_match = function (query, phrase) {
exports.copy_data_attribute_value = function (elem, key) {
// function to copy the value of data-key
// attribute of the element to clipboard
- const temp = $(document.createElement('input'));
+ const temp = $(document.createElement("input"));
$("body").append(temp);
temp.val(elem.data(key)).select();
document.execCommand("copy");
@@ -106,20 +106,20 @@ exports.adjust_mac_shortcuts = function (key_elem_class, require_cmd_style) {
}
const keys_map = new Map([
- ['Backspace', 'Delete'],
- ['Enter', 'Return'],
- ['Home', 'Fn + ←'],
- ['End', 'Fn + →'],
- ['PgUp', 'Fn + ↑'],
- ['PgDn', 'Fn + ↓'],
- ['Ctrl', '⌘'],
+ ["Backspace", "Delete"],
+ ["Enter", "Return"],
+ ["Home", "Fn + ←"],
+ ["End", "Fn + →"],
+ ["PgUp", "Fn + ↑"],
+ ["PgDn", "Fn + ↓"],
+ ["Ctrl", "⌘"],
]);
$(key_elem_class).each(function () {
let key_text = $(this).text();
const keys = key_text.match(/[^\s+]+/g) || [];
- if (key_text.includes('Ctrl') && require_cmd_style) {
+ if (key_text.includes("Ctrl") && require_cmd_style) {
$(this).addClass("mac-cmd-key");
}
diff --git a/static/js/components.js b/static/js/components.js
index 55da7285d8d..5a1ce9304db 100644
--- a/static/js/components.js
+++ b/static/js/components.js
@@ -44,7 +44,7 @@ exports.toggle = function (opts) {
function select_tab(idx) {
const elem = meta.$ind_tab.eq(idx);
- if (elem.hasClass('disabled')) {
+ if (elem.hasClass("disabled")) {
return;
}
meta.$ind_tab.removeClass("selected");
@@ -106,7 +106,7 @@ exports.toggle = function (opts) {
const value = opts.values.find((o) => o.key === name);
const idx = opts.values.indexOf(value);
- meta.$ind_tab.eq(idx).addClass('disabled');
+ meta.$ind_tab.eq(idx).addClass("disabled");
},
value: function () {
diff --git a/static/js/compose.js b/static/js/compose.js
index ded95388bf6..e645b01fd95 100644
--- a/static/js/compose.js
+++ b/static/js/compose.js
@@ -24,9 +24,9 @@ let uppy;
exports.all_everyone_warn_threshold = 15;
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_domain = document.location.protocol + "//" + document.location.host;
+exports.uploads_path = "/user_uploads";
+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
@@ -41,7 +41,7 @@ function show_all_everyone_warnings(stream_id) {
const error_area_all_everyone = $("#compose-all-everyone");
// only show one error for any number of @all or @everyone mentions
- if (!error_area_all_everyone.is(':visible')) {
+ if (!error_area_all_everyone.is(":visible")) {
error_area_all_everyone.append(all_everyone_template);
}
@@ -86,7 +86,7 @@ function show_announce_warnings(stream_id) {
const announce_template = render_compose_announce({count: stream_count});
const error_area_announce = $("#compose-announce");
- if (!error_area_announce.is(':visible')) {
+ if (!error_area_announce.is(":visible")) {
error_area_announce.append(announce_template);
}
@@ -199,9 +199,9 @@ function create_message_object() {
content: content,
sender_id: page_params.user_id,
queue_id: page_params.queue_id,
- stream: '',
+ stream: "",
};
- message.topic = '';
+ message.topic = "";
if (message.type === "private") {
// TODO: this should be collapsed with the code in composebox_typeahead.js
@@ -233,7 +233,7 @@ function create_message_object() {
// user started composing to the old stream name and
// manually entered the stream name, and it got past
// validation. We should try to kill this code off eventually.
- blueslip.error('Trying to send message with bad stream name: ' + stream_name);
+ blueslip.error("Trying to send message with bad stream name: " + stream_name);
message.to = stream_name;
}
message.topic = topic;
@@ -244,11 +244,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)
- .addClass('alert-error')
+ $("#compose-send-status").removeClass(common.status_classes)
+ .addClass("alert-error")
.stop(true).fadeTo(0, 1);
- $('#compose-error-msg').html(error_text);
- $("#compose-send-button").prop('disabled', false);
+ $("#compose-error-msg").html(error_text);
+ $("#compose-send-button").prop("disabled", false);
$("#sending-indicator").hide();
if (bad_input !== undefined) {
bad_input.focus().select();
@@ -266,11 +266,11 @@ function nonexistent_stream_reply_error() {
}
function compose_not_subscribed_error(error_text, bad_input) {
- $('#compose-send-status').removeClass(common.status_classes)
- .addClass('home-error-bar')
+ $("#compose-send-status").removeClass(common.status_classes)
+ .addClass("home-error-bar")
.stop(true).fadeTo(0, 1);
- $('#compose-error-msg').html(error_text);
- $("#compose-send-button").prop('disabled', false);
+ $("#compose-error-msg").html(error_text);
+ $("#compose-send-button").prop("disabled", false);
$("#sending-indicator").hide();
$(".compose-send-status-close").hide();
if (bad_input !== undefined) {
@@ -281,11 +281,11 @@ function compose_not_subscribed_error(error_text, bad_input) {
exports.nonexistent_stream_reply_error = nonexistent_stream_reply_error;
function clear_compose_box() {
- $("#compose-textarea").val('').focus();
+ $("#compose-textarea").val("").focus();
drafts.delete_draft_after_send();
compose_ui.autosize_textarea();
$("#compose-send-status").hide(0);
- $("#compose-send-button").prop('disabled', false);
+ $("#compose-send-button").prop("disabled", false);
$("#sending-indicator").hide();
}
@@ -346,7 +346,7 @@ exports.send_message = function send_message(request) {
// If we're not local echo'ing messages, or if this message was not
// locally echoed, show error in compose box
if (!locally_echoed) {
- compose_error(response, $('#compose-textarea'));
+ compose_error(response, $("#compose-textarea"));
return;
}
@@ -405,7 +405,7 @@ exports.do_post_send_tasks = function () {
exports.clear_preview_area();
// TODO: Do we want to fire the event even if the send failed due
// to a server-side error?
- $(document).trigger($.Event('compose_finished.zulip'));
+ $(document).trigger($.Event("compose_finished.zulip"));
};
exports.update_email = function (user_id, new_email) {
@@ -472,7 +472,7 @@ function validate_stream_message_mentions(stream_id) {
// user has not seen a warning message yet if undefined
show_all_everyone_warnings(stream_id);
- $("#compose-send-button").prop('disabled', false);
+ $("#compose-send-button").prop("disabled", false);
$("#sending-indicator").hide();
return false;
}
@@ -496,7 +496,7 @@ function validate_stream_message_announce(sub) {
// user has not seen a warning message yet if undefined
show_announce_warnings(sub.stream_id);
- $("#compose-send-button").prop('disabled', false);
+ $("#compose-send-button").prop("disabled", false);
$("#sending-indicator").hide();
return false;
}
@@ -545,7 +545,7 @@ 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);
- compose_error(response, $('#stream_message_recipient_stream'));
+ compose_error(response, $("#stream_message_recipient_stream"));
return false;
case "error":
compose_error(i18n.t("Error checking subscription"),
@@ -555,7 +555,7 @@ exports.validation_error = function (error_type, stream_name) {
const sub = stream_data.get_sub(stream_name);
const new_row = render_compose_not_subscribed({
should_display_sub_button: sub.should_display_subscription_button});
- compose_not_subscribed_error(new_row, $('#stream_message_recipient_stream'));
+ compose_not_subscribed_error(new_row, $("#stream_message_recipient_stream"));
return false;
}
}
@@ -657,12 +657,12 @@ function validate_private_message() {
}
exports.validate = function () {
- $("#compose-send-button").attr('disabled', 'disabled').blur();
+ $("#compose-send-button").attr("disabled", "disabled").blur();
const message_content = compose_state.message_content();
if (reminder.is_deferred_delivery(message_content)) {
- show_sending_indicator(i18n.t('Scheduling...'));
+ show_sending_indicator(i18n.t("Scheduling..."));
} else {
- show_sending_indicator(i18n.t('Sending...'));
+ show_sending_indicator(i18n.t("Sending..."));
}
if (/^\s*$/.test(message_content)) {
@@ -675,7 +675,7 @@ exports.validate = function () {
return false;
}
- if (compose_state.get_message_type() === 'private') {
+ if (compose_state.get_message_type() === "private") {
return validate_private_message();
}
return validate_stream_message();
@@ -693,7 +693,7 @@ exports.handle_keydown = function (event, textarea) {
if ((isBold || isItalic || isLink) && isCmdOrCtrl) {
const range = textarea.range();
function wrap_text_with_markdown(prefix, suffix) {
- if (!document.execCommand('insertText', false, prefix + range.text + suffix)) {
+ if (!document.execCommand("insertText", false, prefix + range.text + suffix)) {
textarea.range(range.start, range.end).range(prefix + range.text + suffix);
}
event.preventDefault();
@@ -724,7 +724,7 @@ exports.handle_keydown = function (event, textarea) {
// Position of cursor depends on whether browser supports exec
// command or not. So set cursor position accordingly.
if (range.length > 0) {
- if (document.queryCommandEnabled('insertText')) {
+ if (document.queryCommandEnabled("insertText")) {
txt.selectionStart = position - 4;
txt.selectionEnd = position - 1;
} else {
@@ -781,7 +781,7 @@ exports.needs_subscribe_warning = function (user_id, stream_id) {
};
function insert_video_call_url(url, target_textarea) {
- const video_call_link_text = '[' + _('Click to join video call') + '](' + url + ')';
+ const video_call_link_text = "[" + _("Click to join video call") + "](" + url + ")";
compose_ui.insert_syntax_and_focus(video_call_link_text, target_textarea);
}
@@ -824,7 +824,7 @@ exports.render_and_show_preview = function (preview_spinner, preview_content_box
markdown.apply_markdown(message_obj);
}
channel.post({
- url: '/json/messages/render',
+ url: "/json/messages/render",
idempotent: true,
data: {content: content},
success: function (response_data) {
@@ -848,7 +848,7 @@ exports.warn_if_private_stream_is_linked = function (linked_stream) {
// streams, since you are specifically sharing the existence of
// the private stream with someone. One could imagine changing
// this policy if user feedback suggested it was useful.
- if (compose_state.get_message_type() !== 'stream') {
+ if (compose_state.get_message_type() !== "stream") {
return;
}
@@ -890,7 +890,7 @@ exports.warn_if_private_stream_is_linked = function (linked_stream) {
};
exports.warn_if_mentioning_unsubscribed_user = function (mentioned) {
- if (compose_state.get_message_type() !== 'stream') {
+ if (compose_state.get_message_type() !== "stream") {
return;
}
@@ -919,9 +919,9 @@ exports.warn_if_mentioning_unsubscribed_user = function (mentioned) {
if (exports.needs_subscribe_warning(user_id, sub.stream_id)) {
const error_area = $("#compose_invite_users");
- const existing_invites_area = $('#compose_invite_users .compose_invite_user');
+ 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,12 +941,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);
- $('#compose-textarea').on('keydown', (event) => {
+ $("#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());
});
- $('#compose-textarea').on('keyup', (event) => {
+ $("#compose-textarea").on("keyup", (event) => {
exports.handle_keyup(event, $("#compose-textarea").expectOne());
});
@@ -959,28 +959,28 @@ exports.initialize = function () {
upload.feature_check($("#compose #attach_files"));
- $("#compose-all-everyone").on('click', '.compose-all-everyone-confirm', (event) => {
+ $("#compose-all-everyone").on("click", ".compose-all-everyone-confirm", (event) => {
event.preventDefault();
- $(event.target).parents('.compose-all-everyone').remove();
+ $(event.target).parents(".compose-all-everyone").remove();
user_acknowledged_all_everyone = true;
exports.clear_all_everyone_warnings();
exports.finish();
});
- $("#compose-announce").on('click', '.compose-announce-confirm', (event) => {
+ $("#compose-announce").on("click", ".compose-announce-confirm", (event) => {
event.preventDefault();
- $(event.target).parents('.compose-announce').remove();
+ $(event.target).parents(".compose-announce").remove();
user_acknowledged_announce = true;
exports.clear_announce_warnings();
exports.finish();
});
- $("#compose-send-status").on('click', '.sub_unsub_button', (event) => {
+ $("#compose-send-status").on("click", ".sub_unsub_button", (event) => {
event.preventDefault();
- const stream_name = $('#stream_message_recipient_stream').val();
+ const stream_name = $("#stream_message_recipient_stream").val();
if (stream_name === undefined) {
return;
}
@@ -989,19 +989,19 @@ exports.initialize = function () {
$("#compose-send-status").hide();
});
- $("#compose-send-status").on('click', '#compose_not_subscribed_close', (event) => {
+ $("#compose-send-status").on("click", "#compose_not_subscribed_close", (event) => {
event.preventDefault();
$("#compose-send-status").hide();
});
- $("#compose_invite_users").on('click', '.compose_invite_link', (event) => {
+ $("#compose_invite_users").on("click", ".compose_invite_link", (event) => {
event.preventDefault();
- const invite_row = $(event.target).parents('.compose_invite_user');
+ const invite_row = $(event.target).parents(".compose_invite_user");
- const user_id = parseInt($(invite_row).data('user-id'), 10);
- const stream_id = parseInt($(invite_row).data('stream-id'), 10);
+ const user_id = parseInt($(invite_row).data("user-id"), 10);
+ const stream_id = parseInt($(invite_row).data("stream-id"), 10);
function success() {
const all_invites = $("#compose_invite_users");
@@ -1015,7 +1015,7 @@ exports.initialize = function () {
function failure(error_msg) {
exports.clear_invites();
compose_error(error_msg, $("#compose-textarea"));
- $(event.target).attr('disabled', true);
+ $(event.target).attr("disabled", true);
}
function xhr_failure(xhr) {
@@ -1028,8 +1028,8 @@ exports.initialize = function () {
stream_edit.invite_user_to_stream([user_id], sub, success, xhr_failure);
});
- $("#compose_invite_users").on('click', '.compose_invite_close', (event) => {
- const invite_row = $(event.target).parents('.compose_invite_user');
+ $("#compose_invite_users").on("click", ".compose_invite_close", (event) => {
+ const invite_row = $(event.target).parents(".compose_invite_user");
const all_invites = $("#compose_invite_users");
invite_row.remove();
@@ -1039,8 +1039,8 @@ 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');
+ $("#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();
@@ -1058,7 +1058,7 @@ exports.initialize = function () {
$("#compose #file_input").trigger("click");
});
- $('body').on('click', '.video_link', (e) => {
+ $("body").on("click", ".video_link", (e) => {
e.preventDefault();
let target_textarea;
@@ -1066,7 +1066,7 @@ exports.initialize = function () {
// call icon present in the message edit form. If present,
// the request is for the edit UI; otherwise, it's for the
// compose box.
- const edit_message_id = $(e.target).attr('data-message-id');
+ const edit_message_id = $(e.target).attr("data-message-id");
if (edit_message_id !== undefined) {
target_textarea = $("#message_edit_content_" + edit_message_id);
}
@@ -1125,7 +1125,7 @@ exports.initialize = function () {
) {
channel.get({
- url: '/json/calls/bigbluebutton/create',
+ url: "/json/calls/bigbluebutton/create",
success: function (response) {
insert_video_call_url(response.url, target_textarea);
},
@@ -1159,8 +1159,8 @@ exports.initialize = function () {
$("#compose-textarea").focus(() => {
const opts = {
message_type: compose_state.get_message_type(),
- stream: $('#stream_message_recipient_stream').val(),
- topic: $('#stream_message_recipient_topic').val(),
+ stream: $("#stream_message_recipient_stream").val(),
+ topic: $("#stream_message_recipient_topic").val(),
private_message_recipient: compose_pm_pill.get_emails(),
};
compose_actions.update_placeholder_text(opts);
diff --git a/static/js/compose_actions.js b/static/js/compose_actions.js
index cdb636e62cd..c3a5c6d7044 100644
--- a/static/js/compose_actions.js
+++ b/static/js/compose_actions.js
@@ -1,36 +1,36 @@
-const autosize = require('autosize');
+const autosize = require("autosize");
exports.blur_textarea = function () {
- $('.message_comp').find('input, textarea, button').blur();
+ $(".message_comp").find("input, textarea, button").blur();
};
function hide_box() {
exports.blur_textarea();
- $('#stream-message').hide();
- $('#private-message').hide();
+ $("#stream-message").hide();
+ $("#private-message").hide();
$(".new_message_textarea").css("min-height", "");
compose_fade.clear_compose();
- $('.message_comp').hide();
+ $(".message_comp").hide();
$("#compose_controls").show();
compose.clear_preview_area();
}
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) {
+ 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) {
if (opts.trigger === "new topic button") {
- return '#stream_message_recipient_topic';
+ return "#stream_message_recipient_topic";
}
- return '#compose-textarea';
+ return "#compose-textarea";
}
- if (msg_type === 'stream') {
- return '#stream_message_recipient_stream';
+ if (msg_type === "stream") {
+ return "#stream_message_recipient_stream";
}
- return '#private_message_recipient';
+ return "#private_message_recipient";
}
// Export for testing
exports._get_focus_area = get_focus_area;
@@ -52,18 +52,18 @@ exports.set_focus = function (msg_type, opts) {
// Show the compose box.
function show_box(msg_type, opts) {
if (msg_type === "stream") {
- $('#private-message').hide();
- $('#stream-message').show();
+ $("#private-message").hide();
+ $("#stream-message").show();
$("#stream_toggle").addClass("active");
$("#private_message_toggle").removeClass("active");
} else {
- $('#private-message').show();
- $('#stream-message').hide();
+ $("#private-message").show();
+ $("#stream-message").hide();
$("#stream_toggle").removeClass("active");
$("#private_message_toggle").addClass("active");
}
$("#compose-send-status").removeClass(common.status_classes).hide();
- $('#compose').css({visibility: "visible"});
+ $("#compose").css({visibility: "visible"});
// When changing this, edit the 42px in _maybe_autoscroll
$(".new_message_textarea").css("min-height", "3em");
@@ -71,7 +71,7 @@ function show_box(msg_type, opts) {
}
exports.clear_textarea = function () {
- $("#compose").find('input[type=text], textarea').val('');
+ $("#compose").find("input[type=text], textarea").val("");
};
function clear_box() {
@@ -101,7 +101,7 @@ exports.autosize_message_content = function () {
exports.expand_compose_box = function () {
$("#compose_close").show();
$("#compose_controls").hide();
- $('.message_comp').show();
+ $(".message_comp").show();
};
exports.complete_starting_tasks = function (msg_type, opts) {
@@ -113,7 +113,7 @@ exports.complete_starting_tasks = function (msg_type, opts) {
ui_util.change_tab_to("#home");
compose_fade.start_compose(msg_type);
ui_util.decorate_stream_bar(opts.stream, $("#stream-message .message_header_stream"), true);
- $(document).trigger($.Event('compose_started.zulip', opts));
+ $(document).trigger($.Event("compose_started.zulip", opts));
exports.update_placeholder_text(opts);
};
@@ -145,10 +145,10 @@ exports.maybe_scroll_up_selected_message = function () {
function fill_in_opts_from_current_narrowed_view(msg_type, opts) {
return {
message_type: msg_type,
- stream: '',
- topic: '',
- private_message_recipient: '',
- trigger: 'unknown',
+ stream: "",
+ topic: "",
+ private_message_recipient: "",
+ trigger: "unknown",
// Set default parameters based on the current narrowed view.
...narrow_state.set_compose_defaults(),
@@ -168,7 +168,7 @@ function same_recipient_as_before(msg_type, opts) {
exports.update_placeholder_text = function (opts) {
const placeholder_text = compose_ui.compute_placeholder_text(opts);
- $('#compose-textarea').attr('placeholder', placeholder_text);
+ $("#compose-textarea").attr("placeholder", placeholder_text);
};
exports.start = function (msg_type, opts) {
@@ -186,8 +186,8 @@ exports.start = function (msg_type, opts) {
// PM recipient should be.
if (opts.trigger === "compose_hotkey" ||
opts.trigger === "new topic button") {
- opts.topic = '';
- opts.private_message_recipient = '';
+ opts.topic = "";
+ opts.private_message_recipient = "";
}
const subbed_streams = stream_data.subscribed_subs();
@@ -249,7 +249,7 @@ exports.cancel = function () {
compose.abort_zoom(undefined);
compose_state.set_message_type(false);
compose_pm_pill.clear();
- $(document).trigger($.Event('compose_canceled.zulip'));
+ $(document).trigger($.Event("compose_canceled.zulip"));
};
exports.respond_to_message = function (opts) {
@@ -279,9 +279,9 @@ exports.respond_to_message = function (opts) {
// Set msg_type to stream by default in the case of an empty
// home view.
- msg_type = 'stream';
+ msg_type = "stream";
if (narrow_state.narrowed_by_pm_reply()) {
- msg_type = 'private';
+ msg_type = "private";
}
const new_opts = fill_in_opts_from_current_narrowed_view(msg_type, opts);
@@ -296,15 +296,15 @@ exports.respond_to_message = function (opts) {
// Important note: A reply_type of 'personal' is for the R hotkey
// (replying to a message's sender with a private message). All
// other replies can just copy message.type.
- if (opts.reply_type === 'personal' || message.type === 'private') {
- msg_type = 'private';
+ if (opts.reply_type === "personal" || message.type === "private") {
+ msg_type = "private";
} else {
msg_type = message.type;
}
- let stream = '';
- let topic = '';
- let pm_recipient = '';
+ let stream = "";
+ let topic = "";
+ let pm_recipient = "";
if (msg_type === "stream") {
stream = message.stream;
topic = message.topic;
@@ -375,7 +375,7 @@ exports.on_topic_narrow = function () {
compose_state.topic(narrow_state.topic());
compose_fade.set_focused_recipient("stream");
compose_fade.update_message_list();
- $('#compose-textarea').focus().select();
+ $("#compose-textarea").focus().select();
};
exports.quote_and_reply = function (opts) {
@@ -417,8 +417,8 @@ exports.quote_and_reply = function (opts) {
content += `[said](${hash_util.by_conversation_and_time_uri(message)}):\n`;
const fence = fenced_code.get_unused_fence(message.raw_content);
content += `${fence}quote\n${message.raw_content}\n${fence}`;
- compose_ui.replace_syntax('[Quoting…]', content, textarea);
- autosize.update($('#compose-textarea'));
+ compose_ui.replace_syntax("[Quoting…]", content, textarea);
+ autosize.update($("#compose-textarea"));
}
if (message && message.raw_content) {
@@ -427,7 +427,7 @@ exports.quote_and_reply = function (opts) {
}
channel.get({
- url: '/json/messages/' + message_id,
+ url: "/json/messages/" + message_id,
idempotent: true,
success: function (data) {
message.raw_content = data.raw_content;
@@ -463,13 +463,13 @@ exports.on_narrow = function (opts) {
}
if (narrow_state.narrowed_by_pm_reply()) {
- opts = fill_in_opts_from_current_narrowed_view('private', opts);
+ opts = fill_in_opts_from_current_narrowed_view("private", opts);
// Do not open compose box if triggered by search and invalid recipient
// is present.
if (opts.trigger === "search" && !opts.private_message_recipient) {
return;
}
- exports.start('private');
+ exports.start("private");
return;
}
diff --git a/static/js/compose_fade.js b/static/js/compose_fade.js
index 9d833b08d3e..c85bea3214f 100644
--- a/static/js/compose_fade.js
+++ b/static/js/compose_fade.js
@@ -18,8 +18,8 @@ exports.set_focused_recipient = function (msg_type) {
};
if (focused_recipient.type === "stream") {
- const stream_name = $('#stream_message_recipient_stream').val();
- focused_recipient.topic = $('#stream_message_recipient_topic').val();
+ const stream_name = $("#stream_message_recipient_stream").val();
+ focused_recipient.topic = $("#stream_message_recipient_topic").val();
focused_recipient.stream = stream_name;
const sub = stream_data.get_sub(stream_name);
if (sub) {
@@ -36,7 +36,7 @@ exports.set_focused_recipient = function (msg_type) {
function display_messages_normally() {
const table = rows.get_table(current_msg_list.table_name);
- table.find('.recipient_row').removeClass("message-fade");
+ table.find(".recipient_row").removeClass("message-fade");
normal_display = true;
floating_recipient_bar.update();
@@ -93,7 +93,7 @@ function fade_messages() {
}
exports.would_receive_message = function (user_id) {
- if (focused_recipient.type === 'stream') {
+ if (focused_recipient.type === "stream") {
const sub = stream_data.get_sub_by_id(focused_recipient.stream_id);
if (!sub) {
// If the stream isn't valid, there is no risk of a mix
@@ -114,10 +114,10 @@ const user_fade_config = {
return buddy_list.get_key_from_li({li: li});
},
fade: function (li) {
- return li.addClass('user-fade');
+ return li.addClass("user-fade");
},
unfade: function (li) {
- return li.removeClass('user-fade');
+ return li.removeClass("user-fade");
},
};
diff --git a/static/js/compose_pm_pill.js b/static/js/compose_pm_pill.js
index 620eb09906a..13ac9efed1b 100644
--- a/static/js/compose_pm_pill.js
+++ b/static/js/compose_pm_pill.js
@@ -44,7 +44,7 @@ exports.has_unconverted_data = function () {
exports.get_user_ids_string = function () {
const user_ids = exports.get_user_ids();
const sorted_user_ids = util.sorted_ids(user_ids);
- const user_ids_string = sorted_user_ids.join(',');
+ const user_ids_string = sorted_user_ids.join(",");
return user_ids_string;
};
diff --git a/static/js/compose_state.js b/static/js/compose_state.js
index 5a3f9e13498..639ef0e5cf0 100644
--- a/static/js/compose_state.js
+++ b/static/js/compose_state.js
@@ -18,7 +18,7 @@ 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) {
@@ -26,7 +26,7 @@ function get_or_set(fieldname, keep_leading_whitespace) {
// because the DOM element might not exist yet when get_or_set
// is called.
return function (newval) {
- const elem = $('#' + fieldname);
+ const elem = $("#" + fieldname);
const oldval = elem.val();
if (newval !== undefined) {
elem.val(newval);
@@ -36,11 +36,11 @@ function get_or_set(fieldname, keep_leading_whitespace) {
}
// TODO: Break out setters and getter into their own functions.
-exports.stream_name = get_or_set('stream_message_recipient_stream');
-exports.topic = get_or_set('stream_message_recipient_topic');
+exports.stream_name = get_or_set("stream_message_recipient_stream");
+exports.topic = get_or_set("stream_message_recipient_topic");
// We can't trim leading whitespace in `compose_textarea` because
// of the indented syntax for multi-line code blocks.
-exports.message_content = get_or_set('compose-textarea', true);
+exports.message_content = get_or_set("compose-textarea", true);
exports.private_message_recipient = function (value) {
if (typeof value === "string") {
compose_pm_pill.set_from_emails(value);
diff --git a/static/js/compose_ui.js b/static/js/compose_ui.js
index ac6338f208a..d56fd112727 100644
--- a/static/js/compose_ui.js
+++ b/static/js/compose_ui.js
@@ -1,4 +1,4 @@
-const autosize = require('autosize');
+const autosize = require("autosize");
exports.autosize_textarea = function () {
autosize.update($("#compose-textarea"));
@@ -6,7 +6,7 @@ exports.autosize_textarea = function () {
exports.smart_insert = function (textarea, syntax) {
function is_space(c) {
- return c === ' ' || c === '\t' || c === '\n';
+ return c === " " || c === "\t" || c === "\n";
}
const pos = textarea.caret();
@@ -18,7 +18,7 @@ exports.smart_insert = function (textarea, syntax) {
// before the insert or (unlikely) at the start of the syntax,
// add one.
if (!is_space(before_str.slice(-1)) && !is_space(syntax[0])) {
- syntax = ' ' + syntax;
+ syntax = " " + syntax;
}
}
@@ -26,7 +26,7 @@ exports.smart_insert = function (textarea, syntax) {
// 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)))) {
- syntax += ' ';
+ syntax += " ";
}
textarea.focus();
@@ -48,7 +48,7 @@ exports.insert_syntax_and_focus = function (syntax, textarea) {
// where the cursor was and focusing the area. Mostly a thin
// wrapper around smart_insert.
if (textarea === undefined) {
- textarea = $('#compose-textarea');
+ textarea = $("#compose-textarea");
}
exports.smart_insert(textarea, syntax);
};
@@ -60,7 +60,7 @@ exports.replace_syntax = function (old_syntax, new_syntax, textarea) {
// a RegExp with a global flag, it will replace all instances.
if (textarea === undefined) {
- textarea = $('#compose-textarea');
+ textarea = $("#compose-textarea");
}
textarea.val(textarea.val().replace(old_syntax, () =>
@@ -79,7 +79,7 @@ exports.compute_placeholder_text = function (opts) {
// We return text with the stream and topic name unescaped,
// because the caller is expected to insert this into the
// placeholder field in a way that does HTML escaping.
- if (opts.message_type === 'stream') {
+ if (opts.message_type === "stream") {
if (opts.topic) {
return i18n.t("Message #__- stream_name__ > __- topic_name__",
{stream_name: opts.stream,
diff --git a/static/js/composebox_typeahead.js b/static/js/composebox_typeahead.js
index 9462e645b0e..c53ae882ae9 100644
--- a/static/js/composebox_typeahead.js
+++ b/static/js/composebox_typeahead.js
@@ -1,6 +1,6 @@
const pygments_data = require("../generated/pygments_data.json");
const typeahead = require("../shared/js/typeahead");
-const autosize = require('autosize');
+const autosize = require("autosize");
const settings_data = require("./settings_data");
const confirmDatePlugin = require("flatpickr/dist/plugins/confirmDate/confirmDate.js");
@@ -97,7 +97,7 @@ function get_topic_matcher(query) {
topic: topic,
};
- return typeahead.query_matches_source_attrs(query, obj, ['topic'], ' ');
+ return typeahead.query_matches_source_attrs(query, obj, ["topic"], " ");
};
}
@@ -150,7 +150,7 @@ exports.handle_enter = function (textarea, e) {
// we need those characters to be cleared.
const range = textarea.range();
if (range.length > 0) {
- textarea.range(range.start, range.end).range('');
+ textarea.range(range.start, range.end).range("");
}
// Now add the newline, remembering to resize the
@@ -170,13 +170,13 @@ function handle_keydown(e) {
let target_sel;
if (e.target.id) {
- target_sel = '#' + e.target.id;
+ target_sel = "#" + e.target.id;
}
const on_stream = target_sel === "#stream_message_recipient_stream";
const on_topic = target_sel === "#stream_message_recipient_topic";
const on_pm = target_sel === "#private_message_recipient";
- const on_compose = target_sel === '#compose-textarea';
+ const on_compose = target_sel === "#compose-textarea";
if (on_stream || on_topic || on_pm) {
// For enter, prevent the form from submitting
@@ -195,9 +195,9 @@ function handle_keydown(e) {
if (code === 13) {
e.preventDefault();
}
- nextFocus = '#compose-textarea';
+ nextFocus = "#compose-textarea";
} else if (on_pm) {
- nextFocus = '#compose-textarea';
+ nextFocus = "#compose-textarea";
} else if (on_compose) {
if (code === 13) {
nextFocus = false;
@@ -229,8 +229,8 @@ function handle_keydown(e) {
if (on_compose && code === 13) {
if (exports.should_enter_send(e)) {
e.preventDefault();
- if ($("#compose-send-button").attr('disabled') !== "disabled") {
- $("#compose-send-button").attr('disabled', 'disabled');
+ if ($("#compose-send-button").attr("disabled") !== "disabled") {
+ $("#compose-send-button").attr("disabled", "disabled");
compose.finish();
}
return;
@@ -262,7 +262,7 @@ function select_on_focus(field_id) {
return;
}
in_handler = true;
- $("#" + field_id).select().one('mouseup', (e) => {
+ $("#" + field_id).select().one("mouseup", (e) => {
e.preventDefault();
});
in_handler = false;
@@ -291,8 +291,8 @@ exports.tokenize_compose_str = function (s) {
while (i > min_i) {
i -= 1;
switch (s[i]) {
- case '`':
- case '~':
+ case "`":
+ case "~":
// Code block must start on a new line
if (i === 2) {
return s;
@@ -300,47 +300,47 @@ exports.tokenize_compose_str = function (s) {
return s.slice(i - 2);
}
break;
- case '/':
+ case "/":
if (i === 0) {
return s;
}
break;
- case '#':
- case '@':
- case ':':
- case '_':
+ case "#":
+ case "@":
+ case ":":
+ case "_":
if (i === 0) {
return s;
} else if (/[\s(){}[\]]/.test(s[i - 1])) {
return s.slice(i);
}
break;
- case '>':
+ 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>|`.
- if (s.substring(i - 2, i) === '**' || s.substring(i - 3, i) === '** ') {
+ if (s.substring(i - 2, i) === "**" || s.substring(i - 3, i) === "** ") {
// return any string as long as its not ''.
- return '>topic_jump';
+ return ">topic_jump";
}
// maybe topic_list; let's let the stream_topic_regex decide later.
- return '>topic_list';
+ return ">topic_list";
}
}
- const timestamp_index = s.indexOf('<time');
+ const timestamp_index = s.indexOf("<time");
if (timestamp_index >= 0) {
return s.slice(timestamp_index);
}
- return '';
+ return "";
};
exports.broadcast_mentions = function () {
- return ['all', 'everyone', 'stream'].map((mention, idx) => ({
+ return ["all", "everyone", "stream"].map((mention, idx) => ({
special_item_text: i18n.t("__wildcard_mention_token__ (Notify stream)",
{wildcard_mention_token: mention}),
@@ -359,12 +359,12 @@ exports.broadcast_mentions = function () {
};
function filter_mention_name(current_token) {
- if (current_token.startsWith('**')) {
+ if (current_token.startsWith("**")) {
current_token = current_token.substring(2);
- } else if (current_token.startsWith('*')) {
+ } else if (current_token.startsWith("*")) {
current_token = current_token.substring(1);
}
- if (current_token.length < 1 || current_token.lastIndexOf('*') !== -1) {
+ if (current_token.length < 1 || current_token.lastIndexOf("*") !== -1) {
return false;
}
@@ -525,7 +525,7 @@ exports.get_stream_topic_data = (hacky_this) => {
if (message_row.length === 1) {
// we are editting a message so we try to use it's keys.
const msg = message_store.get(rows.id(message_row));
- if (msg.type === 'stream') {
+ if (msg.type === "stream") {
opts.stream = msg.stream;
opts.topic = msg.topic;
}
@@ -575,7 +575,7 @@ exports.get_sorted_filtered_items = function (query) {
const opts = exports.get_stream_topic_data(hacky_this);
- if (completing === 'mention' || completing === 'silent_mention') {
+ if (completing === "mention" || completing === "silent_mention") {
return exports.filter_and_sort_mentions(
big_results.is_silent, token, opts);
}
@@ -596,7 +596,7 @@ exports.filter_and_sort_candidates = function (completing, candidates, token) {
exports.get_candidates = function (query) {
const split = exports.split_at_cursor(query, this.$element);
let current_token = exports.tokenize_compose_str(split[0]);
- if (current_token === '') {
+ if (current_token === "") {
return false;
}
const rest = split[1];
@@ -608,13 +608,13 @@ exports.get_candidates = function (query) {
// We will likely want to extend this list to be more i18n-friendly.
const terminal_symbols = ',.;?!()[]> "\'\n\t';
- if (rest !== '' && !terminal_symbols.includes(rest[0])) {
+ if (rest !== "" && !terminal_symbols.includes(rest[0])) {
return false;
}
// Start syntax highlighting autocompleter if the first three characters are ```
const syntax_token = current_token.substring(0, 3);
- if (this.options.completions.syntax && (syntax_token === '```' || syntax_token === "~~~")) {
+ if (this.options.completions.syntax && (syntax_token === "```" || syntax_token === "~~~")) {
// Only autocomplete if user starts typing a language after ```
if (current_token.length === 3) {
return false;
@@ -630,14 +630,14 @@ exports.get_candidates = function (query) {
if (current_token[0] === " ") {
current_token = current_token.substring(1);
}
- this.completing = 'syntax';
+ this.completing = "syntax";
this.token = current_token;
return Object.keys(pygments_data.langs);
}
// Only start the emoji autocompleter if : is directly after one
// of the whitespace or punctuation chars we split on.
- if (this.options.completions.emoji && current_token[0] === ':') {
+ if (this.options.completions.emoji && current_token[0] === ":") {
// We don't want to match non-emoji emoticons such
// as :P or :-p
// Also, if the user has only typed a colon and nothing after,
@@ -649,18 +649,18 @@ exports.get_candidates = function (query) {
if (current_token[1] === " ") {
return false;
}
- this.completing = 'emoji';
+ this.completing = "emoji";
this.token = current_token.substring(1);
return exports.emoji_collection;
}
- if (this.options.completions.mention && current_token[0] === '@') {
+ if (this.options.completions.mention && current_token[0] === "@") {
current_token = current_token.substring(1);
- this.completing = 'mention';
+ this.completing = "mention";
// Silent mentions
let is_silent = false;
- if (current_token.startsWith('_')) {
- this.completing = 'silent_mention';
+ if (current_token.startsWith("_")) {
+ this.completing = "silent_mention";
is_silent = true;
current_token = current_token.substring(1);
}
@@ -678,21 +678,21 @@ exports.get_candidates = function (query) {
return commands;
}
- if (this.options.completions.slash && current_token[0] === '/') {
+ if (this.options.completions.slash && current_token[0] === "/") {
current_token = current_token.substring(1);
- this.completing = 'slash';
+ this.completing = "slash";
this.token = current_token;
return get_slash_commands_data();
}
- if (this.options.completions.stream && current_token[0] === '#') {
+ if (this.options.completions.stream && current_token[0] === "#") {
if (current_token.length === 1) {
return false;
}
current_token = current_token.substring(1);
- if (current_token.startsWith('**')) {
+ if (current_token.startsWith("**")) {
current_token = current_token.substring(2);
}
@@ -701,7 +701,7 @@ exports.get_candidates = function (query) {
return false;
}
- this.completing = 'stream';
+ this.completing = "stream";
this.token = current_token;
return stream_data.get_unsorted_subs();
}
@@ -712,21 +712,21 @@ exports.get_candidates = function (query) {
const stream_regex = /#\*\*([^*>]+)\*\*\s?>$/;
const should_jump_inside_typeahead = stream_regex.test(split[0]);
if (should_jump_inside_typeahead) {
- this.completing = 'topic_jump';
- this.token = '>';
+ this.completing = "topic_jump";
+ this.token = ">";
// We return something so that the typeahead is shown, but ultimately
- return [''];
+ return [""];
}
// Matches '#**stream name>some text' at the end of a split.
const stream_topic_regex = /#\*\*([^*>]+)>([^*]*)$/;
const should_begin_typeahead = stream_topic_regex.test(split[0]);
if (should_begin_typeahead) {
- this.completing = 'topic_list';
+ this.completing = "topic_list";
const tokens = stream_topic_regex.exec(split[0]);
if (tokens[1]) {
const stream_name = tokens[1];
- this.token = tokens[2] || '';
+ this.token = tokens[2] || "";
const topic_list = exports.topics_seen_for(stream_name);
if (should_show_custom_query(this.token, topic_list)) {
topic_list.push(this.token);
@@ -738,31 +738,31 @@ exports.get_candidates = function (query) {
if (this.options.completions.timestamp) {
const time_jump_regex = /<time(:([^>]*?)>?)?$/;
if (time_jump_regex.test(split[0])) {
- this.completing = 'time_jump';
- return [i18n.t('Mention a timezone-aware time')];
+ this.completing = "time_jump";
+ return [i18n.t("Mention a timezone-aware time")];
}
}
return false;
};
exports.content_highlighter = function (item) {
- if (this.completing === 'emoji') {
+ if (this.completing === "emoji") {
return typeahead_helper.render_emoji(item);
- } else if (this.completing === 'mention' || this.completing === 'silent_mention') {
+ } else if (this.completing === "mention" || this.completing === "silent_mention") {
return typeahead_helper.render_person_or_user_group(item);
- } else if (this.completing === 'slash') {
+ } else if (this.completing === "slash") {
return typeahead_helper.render_typeahead_item({
primary: item.text,
});
- } else if (this.completing === 'stream') {
+ } else if (this.completing === "stream") {
return typeahead_helper.render_stream(item);
- } else if (this.completing === 'syntax') {
+ } else if (this.completing === "syntax") {
return typeahead_helper.render_typeahead_item({ primary: item });
- } else if (this.completing === 'topic_jump') {
+ } else if (this.completing === "topic_jump") {
return typeahead_helper.render_typeahead_item({ primary: item });
- } else if (this.completing === 'topic_list') {
+ } else if (this.completing === "topic_list") {
return typeahead_helper.render_typeahead_item({ primary: item });
- } else if (this.completing === 'time_jump') {
+ } else if (this.completing === "time_jump") {
return typeahead_helper.render_typeahead_item({ primary: item });
}
};
@@ -771,31 +771,31 @@ const show_flatpickr = (element, callback, default_timestamp) => {
const flatpickr_input = $("<input id='#timestamp_flatpickr'>");
const instance = flatpickr_input.flatpickr({
- mode: 'single',
+ mode: "single",
enableTime: true,
clickOpens: false,
defaultDate: default_timestamp,
plugins: [new confirmDatePlugin({})], // eslint-disable-line new-cap, no-undef
positionElement: element,
- dateFormat: 'Z',
+ dateFormat: "Z",
formatDate: (date) => {
const dt = moment(date);
return dt.local().format();
},
});
const container = $($(instance.innerContainer).parent());
- container.on('click', '.flatpickr-calendar', (e) => {
+ container.on("click", ".flatpickr-calendar", (e) => {
e.stopPropagation();
e.preventDefault();
});
- container.on('click', '.flatpickr-confirm', () => {
+ container.on("click", ".flatpickr-confirm", () => {
callback(flatpickr_input.val());
instance.close();
instance.destroy();
});
instance.open();
- container.find('.flatpickr-monthDropdown-months').focus();
+ container.find(".flatpickr-monthDropdown-months").focus();
};
exports.content_typeahead_selected = function (item, event) {
@@ -804,7 +804,7 @@ exports.content_typeahead_selected = function (item, event) {
let rest = pieces[1];
const textbox = this.$element;
- if (this.completing === 'emoji') {
+ 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 ||
@@ -814,18 +814,18 @@ exports.content_typeahead_selected = function (item, event) {
} else {
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';
+ } else if (this.completing === "mention" || this.completing === "silent_mention") {
+ const is_silent = this.completing === "silent_mention";
beginning = beginning.substring(0, beginning.length - this.token.length - 1);
- if (beginning.endsWith('@_*')) {
+ if (beginning.endsWith("@_*")) {
beginning = beginning.substring(0, beginning.length - 3);
- } else if (beginning.endsWith('@*') || beginning.endsWith('@_')) {
+ } else if (beginning.endsWith("@*") || beginning.endsWith("@_")) {
beginning = beginning.substring(0, beginning.length - 2);
- } else if (beginning.endsWith('@')) {
+ } else if (beginning.endsWith("@")) {
beginning = beginning.substring(0, beginning.length - 1);
}
if (user_groups.is_user_group(item)) {
- beginning += '@*' + item.name + '* ';
+ beginning += "@*" + item.name + "* ";
// We could theoretically warn folks if they are
// mentioning a user group that literally has zero
// members where we are posting to, but we don't have
@@ -833,67 +833,67 @@ exports.content_typeahead_selected = function (item, event) {
// feedback on this being an actual pitfall.
} else {
const mention_text = people.get_mention_syntax(item.full_name, item.user_id, is_silent);
- beginning += mention_text + ' ';
+ beginning += mention_text + " ";
if (!is_silent) {
compose.warn_if_mentioning_unsubscribed_user(item);
}
}
- } else if (this.completing === 'slash') {
+ } else if (this.completing === "slash") {
beginning = beginning.substring(0, beginning.length - this.token.length - 1) + "/" + item.name + " ";
- } else if (this.completing === 'stream') {
+ } else if (this.completing === "stream") {
beginning = beginning.substring(0, beginning.length - this.token.length - 1);
- if (beginning.endsWith('#*')) {
+ if (beginning.endsWith("#*")) {
beginning = beginning.substring(0, beginning.length - 2);
}
- beginning += '#**' + item.name;
- if (event && event.key === '>') {
+ beginning += "#**" + item.name;
+ if (event && event.key === ">") {
// Normally, one accepts typeahead with `tab` or `enter`, but when completing
// stream typeahead, we allow `>`, the delimiter for stream+topic mentions,
// as a completion that automatically sets up stream+topic typeahead for you.
- beginning += '>';
+ beginning += ">";
} else {
- beginning += '** ';
+ beginning += "** ";
}
compose.warn_if_private_stream_is_linked(item);
- } else if (this.completing === 'syntax') {
+ } else if (this.completing === "syntax") {
// Isolate the end index of the triple backticks/tildes, including
// possibly a space afterward
const backticks = beginning.length - this.token.length;
- if (rest === '') {
+ if (rest === "") {
// If cursor is at end of input ("rest" is empty), then
// complete the token before the cursor, and add a closing fence
// after the cursor
- beginning = beginning.substring(0, backticks) + item + '\n';
+ beginning = beginning.substring(0, backticks) + item + "\n";
rest = "\n" + beginning.substring(backticks - 4, backticks).trim() + rest;
} else {
// If more text after the input, then complete the token, but don't touch
// "rest" (i.e. do not add a closing fence)
beginning = beginning.substring(0, backticks) + item;
}
- } else if (this.completing === 'topic_jump') {
+ } else if (this.completing === "topic_jump") {
// Put the cursor at the end of immediately preceding stream mention syntax,
// just before where the `**` at the end of the syntax. This will delete that
// final ** and set things up for the topic_list typeahead.
- const index = beginning.lastIndexOf('**');
+ const index = beginning.lastIndexOf("**");
if (index !== -1) {
- beginning = beginning.substring(0, index) + '>';
+ beginning = beginning.substring(0, index) + ">";
}
- } else if (this.completing === 'topic_list') {
+ } else if (this.completing === "topic_list") {
// Stream + topic mention typeahead; close the stream+topic mention syntax
// with the topic and the final **.
const start = beginning.length - this.token.length;
- beginning = beginning.substring(0, start) + item + '** ';
- } else if (this.completing === 'time_jump') {
- let timestring = beginning.substring(beginning.lastIndexOf('<time:'));
- if (timestring.startsWith('<time:') && timestring.endsWith('>')) {
+ beginning = beginning.substring(0, start) + item + "** ";
+ } else if (this.completing === "time_jump") {
+ let timestring = beginning.substring(beginning.lastIndexOf("<time:"));
+ if (timestring.startsWith("<time:") && timestring.endsWith(">")) {
timestring = timestring.substring(6, timestring.length - 1);
}
const timestamp = timerender.get_timestamp_for_flatpickr(timestring);
const on_timestamp_selection = (val) => {
const datestr = val;
- beginning = beginning.substring(0, beginning.lastIndexOf('<time')) + `<time:${datestr}> `;
- if (rest.startsWith('>')) {
+ beginning = beginning.substring(0, beginning.lastIndexOf("<time")) + `<time:${datestr}> `;
+ if (rest.startsWith(">")) {
rest = rest.slice(1);
}
textbox.val(beginning + rest);
@@ -916,22 +916,22 @@ exports.content_typeahead_selected = function (item, event) {
exports.compose_content_matcher = function (completing, token) {
switch (completing) {
- case 'emoji':
+ case "emoji":
return typeahead.get_emoji_matcher(token);
- case 'slash':
+ case "slash":
return get_slash_matcher(token);
- case 'stream':
+ case "stream":
return get_stream_or_user_group_matcher(token);
- case 'syntax':
+ case "syntax":
return get_language_matcher(token);
- case 'topic_list':
+ case "topic_list":
return get_topic_matcher(token);
}
return function () {
switch (completing) {
- case 'topic_jump':
- case 'time_jump':
+ case "topic_jump":
+ case "time_jump":
// these don't actually have a typeahead popover, so we return quickly here.
return true;
}
@@ -940,25 +940,25 @@ exports.compose_content_matcher = function (completing, token) {
exports.sort_results = function (completing, matches, token) {
switch (completing) {
- case 'emoji':
+ case "emoji":
return typeahead.sort_emojis(matches, token);
- case 'slash':
+ case "slash":
return typeahead_helper.sort_slash_commands(matches, token);
- case 'stream':
+ case "stream":
return typeahead_helper.sort_streams(matches, token);
- case 'syntax':
+ case "syntax":
return typeahead_helper.sort_languages(matches, token);
- case 'topic_jump':
- case 'time_jump':
+ case "topic_jump":
+ case "time_jump":
// topic_jump doesn't actually have a typeahead popover, so we return quickly here.
return matches;
- case 'topic_list':
+ case "topic_list":
return typeahead_helper.sorter(token, matches, (x) => x);
}
};
exports.compose_automated_selection = function () {
- if (this.completing === 'topic_jump') {
+ if (this.completing === "topic_jump") {
// automatically jump inside stream mention on typing > just after
// a stream mention, to begin stream+topic mention typeahead (topic_list).
return true;
@@ -967,7 +967,7 @@ exports.compose_automated_selection = function () {
};
exports.compose_trigger_selection = function (event) {
- if (this.completing === 'stream' && event.key === '>') {
+ if (this.completing === "stream" && event.key === ">") {
// complete stream typeahead partially to immediately start the topic_list typeahead.
return true;
}
@@ -975,15 +975,15 @@ exports.compose_trigger_selection = function (event) {
};
function get_header_text() {
- let tip_text = '';
+ let tip_text = "";
switch (this.completing) {
- case 'stream':
- tip_text = i18n.t('Press > for list of topics');
+ case "stream":
+ tip_text = i18n.t("Press > for list of topics");
break;
- case 'silent_mention':
- tip_text = i18n.t('User will not be notified');
+ case "silent_mention":
+ tip_text = i18n.t("User will not be notified");
break;
- case 'syntax':
+ 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});
@@ -993,7 +993,7 @@ function get_header_text() {
default:
return false;
}
- return '<em>' + tip_text + '</em>';
+ return "<em>" + tip_text + "</em>";
}
exports.initialize_compose_typeahead = function (selector) {
@@ -1057,12 +1057,12 @@ exports.initialize = function () {
$("#compose-textarea").focus();
return channel.post({
- url: '/json/users/me/enter-sends',
+ url: "/json/users/me/enter-sends",
idempotent: true,
data: {enter_sends: page_params.enter_sends},
});
});
- $("#enter_sends").prop('checked', page_params.enter_sends);
+ $("#enter_sends").prop("checked", page_params.enter_sends);
if (page_params.enter_sends) {
$("#compose-send-button").hide();
}
diff --git a/static/js/condense.js b/static/js/condense.js
index 8ce64335229..4771d57d606 100644
--- a/static/js/condense.js
+++ b/static/js/condense.js
@@ -221,7 +221,7 @@ exports.condense_and_collapse = function (elems) {
// By default, condense a long message.
condense_row($(elem));
} else {
- content.removeClass('condensed');
+ content.removeClass("condensed");
$(elem).find(".message_expander").hide();
}
diff --git a/static/js/confirm_dialog.js b/static/js/confirm_dialog.js
index 62374ec41df..b13d54b0233 100644
--- a/static/js/confirm_dialog.js
+++ b/static/js/confirm_dialog.js
@@ -33,16 +33,16 @@ exports.launch = function (conf) {
// The next three fields should be safe HTML. If callers
// interpolate user data into strings, they should use
// templates.
- 'html_heading',
- 'html_body',
- 'html_yes_button',
- 'on_click',
- 'parent',
+ "html_heading",
+ "html_body",
+ "html_yes_button",
+ "on_click",
+ "parent",
];
for (const f of conf_fields) {
if (!conf[f]) {
- blueslip.error('programmer omitted ' + f);
+ blueslip.error("programmer omitted " + f);
}
}
@@ -51,28 +51,28 @@ exports.launch = function (conf) {
// Close any existing modals--on settings screens you can
// have multiple buttons that need confirmation.
if (overlays.is_modal_open()) {
- overlays.close_modal('#confirm_dialog_modal');
+ overlays.close_modal("#confirm_dialog_modal");
}
- confirm_dialog.find('.confirm_dialog_heading').html(conf.html_heading);
- confirm_dialog.find('.confirm_dialog_body').html(conf.html_body);
+ confirm_dialog.find(".confirm_dialog_heading").html(conf.html_heading);
+ confirm_dialog.find(".confirm_dialog_body").html(conf.html_body);
- const yes_button = confirm_dialog.find('.confirm_dialog_yes_button');
+ const yes_button = confirm_dialog.find(".confirm_dialog_yes_button");
yes_button.html(conf.html_yes_button);
// Set up handlers.
- yes_button.on('click', () => {
- overlays.close_modal('#confirm_dialog_modal');
+ yes_button.on("click", () => {
+ overlays.close_modal("#confirm_dialog_modal");
conf.on_click();
});
- confirm_dialog.on('hide', () => {
+ confirm_dialog.on("hide", () => {
confirm_dialog.remove();
});
// Open the modal
- overlays.open_modal('#confirm_dialog_modal');
+ overlays.open_modal("#confirm_dialog_modal");
};
window.confirm_dialog = exports;
diff --git a/static/js/copy_and_paste.js b/static/js/copy_and_paste.js
index b888d61e0be..876a7019678 100644
--- a/static/js/copy_and_paste.js
+++ b/static/js/copy_and_paste.js
@@ -18,7 +18,7 @@ function find_boundary_tr(initial_tr, iterate_row) {
// To ensure we can't enter an infinite loop, bail out (and let the
// browser handle the copy-paste on its own) if we don't hit what we
// are looking for within 10 rows.
- for (j = 0; !tr.is('.message_row') && j < 10; j += 1) {
+ for (j = 0; !tr.is(".message_row") && j < 10; j += 1) {
tr = iterate_row(tr);
}
if (j === 10) {
@@ -38,7 +38,7 @@ function construct_recipient_header(message_row) {
.text()
.replace(/\s+/g, " ")
.replace(/^\s/, "").replace(/\s$/, "");
- return $('<p>').append($('<strong>').text(message_header_content));
+ return $("<p>").append($("<strong>").text(message_header_content));
}
/*
@@ -90,8 +90,8 @@ function construct_copy_div(div, start_id, end_id) {
function select_div(div, selection) {
div.css({
- position: 'absolute',
- left: '-99999px',
+ position: "absolute",
+ left: "-99999px",
// Color and background is made according to "day mode"
// exclusively here because when copying the content
// into, say, Gmail compose box, the styles come along.
@@ -99,11 +99,11 @@ function select_div(div, selection) {
// background when using the app in night mode.
// We can avoid other custom styles since they are wrapped
// inside another parent such as `.message_content`.
- color: '#333',
- background: '#FFF',
+ color: "#333",
+ background: "#FFF",
})
- .attr('id', 'copytempdiv');
- $('body').append(div);
+ .attr("id", "copytempdiv");
+ $("body").append(div);
selection.selectAllChildren(div[0]);
}
@@ -116,7 +116,7 @@ function remove_div(div, ranges, selection) {
selection.addRange(range);
}
- $('#copytempdiv').remove();
+ $("#copytempdiv").remove();
}, 0);
}
@@ -142,21 +142,21 @@ exports.copy_handler = function () {
const start_id = analysis.start_id;
const end_id = analysis.end_id;
const skip_same_td_check = analysis.skip_same_td_check;
- const div = $('<div>');
+ const div = $("<div>");
if (start_id === undefined || end_id === undefined) {
// In this case either the starting message or the ending
// message is not defined, so this is definitely not a
// multi-message selection and we can let the browser handle
// the copy.
- document.execCommand('copy');
+ document.execCommand("copy");
return;
}
if (!skip_same_td_check && start_id === end_id) {
// Check whether the selection both starts and ends in the
// same message. If so, Let the browser handle this.
- document.execCommand('copy');
+ document.execCommand("copy");
return;
}
@@ -174,7 +174,7 @@ exports.copy_handler = function () {
// Select div so that the browser will copy it
// instead of copying the original selection
select_div(div, selection);
- document.execCommand('copy');
+ document.execCommand("copy");
remove_div(div, ranges, selection);
};
@@ -210,7 +210,7 @@ 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;
@@ -227,13 +227,13 @@ exports.analyze_selection = function (selection) {
// This handles the issue that Chrome seems to like selecting
// the compose_close button when you go off the end of the
// last message
- if (endc.attr('id') === "bottom_whitespace" || endc.attr('id') === "compose_close") {
+ if (endc.attr("id") === "bottom_whitespace" || endc.attr("id") === "compose_close") {
initial_end_tr = $(".message_row").last();
// The selection goes off the end of the message feed, so
// this is a multi-message selection.
skip_same_td_check = true;
} else {
- initial_end_tr = $(endc.parents('.selectable_row')[0]);
+ initial_end_tr = $(endc.parents(".selectable_row")[0]);
}
end_data = find_boundary_tr(initial_end_tr, (row) => row.prev());
@@ -262,20 +262,20 @@ exports.analyze_selection = function (selection) {
exports.paste_handler_converter = function (paste_html) {
const turndownService = new TurndownService();
- turndownService.addRule('headings', {
- filter: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
+ turndownService.addRule("headings", {
+ filter: ["h1", "h2", "h3", "h4", "h5", "h6"],
replacement: function (content) {
return content;
},
});
- turndownService.addRule('emphasis', {
- filter: ['em', 'i'],
+ turndownService.addRule("emphasis", {
+ filter: ["em", "i"],
replacement: function (content) {
- return '*' + content + '*';
+ return "*" + content + "*";
},
});
// Checks for raw links without custom text or title.
- turndownService.addRule('links', {
+ turndownService.addRule("links", {
filter: function (node) {
return node.nodeName === "A" &&
node.href === node.innerHTML &&
@@ -289,10 +289,10 @@ exports.paste_handler_converter = function (paste_html) {
let markdown_text = turndownService.turndown(paste_html);
// Checks for escaped ordered list syntax.
- markdown_text = markdown_text.replace(/^(\W* {0,3})(\d+)\\\. /gm, '$1$2. ');
+ markdown_text = markdown_text.replace(/^(\W* {0,3})(\d+)\\\. /gm, "$1$2. ");
// Removes newlines before the start of a list and between list elements.
- markdown_text = markdown_text.replace(/\n+([*+-])/g, '\n$1');
+ markdown_text = markdown_text.replace(/\n+([*+-])/g, "\n$1");
return markdown_text;
};
@@ -308,7 +308,7 @@ exports.paste_handler = function (event) {
}
if (clipboardData.getData) {
- const paste_html = clipboardData.getData('text/html');
+ const paste_html = clipboardData.getData("text/html");
if (paste_html && page_params.development_environment) {
const text = exports.paste_handler_converter(paste_html);
const mdImageRegex = /^!\[.*\]\(.*\)$/;
@@ -325,8 +325,8 @@ exports.paste_handler = function (event) {
};
exports.initialize = function () {
- $("#compose-textarea").bind('paste', exports.paste_handler);
- $('body').on('paste', '#message_edit_form', exports.paste_handler);
+ $("#compose-textarea").bind("paste", exports.paste_handler);
+ $("body").on("paste", "#message_edit_form", exports.paste_handler);
};
window.copy_and_paste = exports;
diff --git a/static/js/csrf.js b/static/js/csrf.js
index 7a69d9133d3..e51831e984c 100644
--- a/static/js/csrf.js
+++ b/static/js/csrf.js
@@ -3,7 +3,7 @@ $(() => {
// This requires that we used Jinja2's {% csrf_input %} somewhere on the page.
const csrf_input = $('input[name="csrfmiddlewaretoken"]');
if (csrf_input.length > 0) {
- csrf_token = csrf_input.attr('value');
+ csrf_token = csrf_input.attr("value");
} else {
csrf_token = undefined;
}
diff --git a/static/js/debug.js b/static/js/debug.js
index 161bd52a8cc..0215547109f 100644
--- a/static/js/debug.js
+++ b/static/js/debug.js
@@ -21,7 +21,7 @@ export function print_elapsed_time(name, fun) {
const t0 = new Date().getTime();
const out = fun();
const t1 = new Date().getTime();
- console.log(name + ': ' + (t1 - t0) + ' ms');
+ console.log(name + ": " + (t1 - t0) + " ms");
return out;
}
@@ -96,7 +96,7 @@ export function IterationProfiler() {
IterationProfiler.prototype = {
iteration_start: function () {
- this.section('_iteration_overhead');
+ this.section("_iteration_overhead");
},
iteration_stop: function () {
@@ -118,7 +118,7 @@ IterationProfiler.prototype = {
},
done: function () {
- this.section('_iteration_overhead');
+ this.section("_iteration_overhead");
for (const [prop, cost] of this.sections) {
console.log(prop, cost);
diff --git a/static/js/drafts.js b/static/js/drafts.js
index d7944c0b812..c322a2d8ef1 100644
--- a/static/js/drafts.js
+++ b/static/js/drafts.js
@@ -1,9 +1,9 @@
const util = require("./util");
-const render_draft_table_body = require('../templates/draft_table_body.hbs');
+const render_draft_table_body = require("../templates/draft_table_body.hbs");
function set_count(count) {
const draft_count = count.toString();
- const text = i18n.t('Drafts (__draft_count__)', {draft_count: draft_count});
+ const text = i18n.t("Drafts (__draft_count__)", {draft_count: draft_count});
$(".compose_drafts_button").text(text);
}
@@ -101,7 +101,7 @@ exports.restore_message = function (draft) {
if (draft.type === "stream") {
compose_args = {
- type: 'stream',
+ type: "stream",
stream: draft.stream,
topic: util.get_draft_topic(draft),
content: draft.content,
@@ -229,7 +229,7 @@ exports.format_draft = function (draft) {
let draft_topic = util.get_draft_topic(draft);
const draft_stream_color = stream_data.get_color(draft.stream);
- if (draft_topic === '') {
+ if (draft_topic === "") {
draft_topic = compose.empty_topic_placeholder();
}
@@ -252,7 +252,7 @@ exports.format_draft = function (draft) {
return person.full_name;
}
return email;
- }).join(', ');
+ }).join(", ");
formatted = {
draft_id: draft.id,
@@ -306,7 +306,7 @@ function remove_draft(draft_row) {
draft_row.remove();
if ($("#drafts_table .draft-row").length === 0) {
- $('#drafts_table .no-drafts').show();
+ $("#drafts_table .no-drafts").show();
}
}
@@ -328,14 +328,14 @@ exports.launch = function () {
}
function render_widgets(drafts) {
- $('#drafts_table').empty();
+ $("#drafts_table").empty();
const rendered = render_draft_table_body({
drafts: drafts,
draft_lifetime: DRAFT_LIFETIME,
});
- $('#drafts_table').append(rendered);
+ $("#drafts_table").append(rendered);
if ($("#drafts_table .draft-row").length > 0) {
- $('#drafts_table .no-drafts').hide();
+ $("#drafts_table .no-drafts").hide();
}
}
@@ -365,7 +365,7 @@ exports.launch = function () {
// We need to force a style calculation on the newly created
// element in order for the CSS transition to take effect.
- $('#draft_overlay').css('opacity');
+ $("#draft_overlay").css("opacity");
exports.open_overlay();
exports.set_initial_element(drafts);
@@ -373,8 +373,8 @@ exports.launch = function () {
};
function activate_element(elem) {
- $('.draft-info-box').removeClass('active');
- $(elem).expectOne().addClass('active');
+ $(".draft-info-box").removeClass("active");
+ $(elem).expectOne().addClass("active");
elem.focus();
}
@@ -418,7 +418,7 @@ 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.
@@ -494,8 +494,8 @@ exports.drafts_handle_events = function (e, event_key) {
exports.open_overlay = function () {
overlays.open_overlay({
- name: 'drafts',
- overlay: $('#draft_overlay'),
+ name: "drafts",
+ overlay: $("#draft_overlay"),
on_close: function () {
hashchange.exit_overlay();
},
@@ -522,7 +522,7 @@ exports.initialize = function () {
$("#compose-textarea").focusout(exports.update_draft);
- $('body').on('focus', '.draft-info-box', (e) => {
+ $("body").on("focus", ".draft-info-box", (e) => {
activate_element(e.target);
});
};
diff --git a/static/js/dropdown_list_widget.js b/static/js/dropdown_list_widget.js
index aa7e2d0159c..4e1d0e4292d 100644
--- a/static/js/dropdown_list_widget.js
+++ b/static/js/dropdown_list_widget.js
@@ -10,7 +10,7 @@ const DropdownListWidget = function (opts) {
opts.value_id = `id_${opts.widget_name}`;
if (opts.value === undefined) {
opts.value = opts.null_value;
- blueslip.warn('dropdown-list-widget: Called without a default value; using null value');
+ blueslip.warn("dropdown-list-widget: Called without a default value; using null value");
}
};
init();
@@ -25,7 +25,7 @@ const DropdownListWidget = function (opts) {
if (!value || value === opts.null_value) {
elem.text(opts.default_text);
elem.addClass("text-warning");
- elem.closest('.input-group').find('.dropdown_list_reset_button:not([disabled])').hide();
+ elem.closest(".input-group").find(".dropdown_list_reset_button:not([disabled])").hide();
return;
}
@@ -33,8 +33,8 @@ const DropdownListWidget = function (opts) {
const item = opts.data.find((x) => x.value === value.toString());
const text = opts.render_text(item.name);
elem.text(text);
- elem.removeClass('text-warning');
- elem.closest('.input-group').find('.dropdown_list_reset_button:not([disabled])').show();
+ elem.removeClass("text-warning");
+ elem.closest(".input-group").find(".dropdown_list_reset_button:not([disabled])").show();
};
const update = (value) => {
@@ -52,7 +52,7 @@ const DropdownListWidget = function (opts) {
return;
}
}
- const value = $(this).attr('data-value');
+ const value = $(this).attr("data-value");
update(value);
});
$(`#${opts.container_id} .dropdown_list_reset_button`).click((e) => {
@@ -112,9 +112,9 @@ const DropdownListWidget = function (opts) {
};
const value = () => {
- let val = $(`#${opts.container_id} #${opts.value_id}`).data('value');
+ let val = $(`#${opts.container_id} #${opts.value_id}`).data("value");
if (val === null) {
- val = '';
+ val = "";
}
return val;
};
diff --git a/static/js/echo.js b/static/js/echo.js
index 81e8e598a6f..88fe2fd71d6 100644
--- a/static/js/echo.js
+++ b/static/js/echo.js
@@ -11,8 +11,8 @@ function failed_message_success(message_id) {
function resend_message(message, row) {
message.content = message.raw_content;
- const retry_spinner = row.find('.refresh-failed-message');
- retry_spinner.toggleClass('rotating', true);
+ const retry_spinner = row.find(".refresh-failed-message");
+ retry_spinner.toggleClass("rotating", true);
// Always re-set queue_id if we've gotten a new one
// since the time when the message object was initially created
@@ -24,7 +24,7 @@ function resend_message(message, row) {
const message_id = data.id;
const locally_echoed = true;
- retry_spinner.toggleClass('rotating', false);
+ retry_spinner.toggleClass("rotating", false);
compose.send_message_success(local_id, message_id, locally_echoed);
@@ -35,7 +35,7 @@ function resend_message(message, row) {
function on_error(response) {
exports.message_send_error(message.id, response);
setTimeout(() => {
- retry_spinner.toggleClass('rotating', false);
+ retry_spinner.toggleClass("rotating", false);
}, 300);
blueslip.log("Manual resend of message failed");
}
@@ -45,7 +45,7 @@ function resend_message(message, row) {
}
exports.build_display_recipient = function (message) {
- if (message.type === 'stream') {
+ if (message.type === "stream") {
return message.stream;
}
@@ -122,7 +122,7 @@ exports.insert_local_message = function (message_request, local_id_float) {
// NOTE: This will parse synchronously. We're not using the async pipeline
markdown.apply_markdown(message);
- message.content_type = 'text/html';
+ message.content_type = "text/html";
message.sender_email = people.my_current_email();
message.sender_full_name = people.my_full_name();
message.avatar_url = page_params.avatar_url;
@@ -141,7 +141,7 @@ exports.insert_local_message = function (message_request, local_id_float) {
};
exports.is_slash_command = function (content) {
- return !content.startsWith('/me') && content.startsWith('/');
+ return !content.startsWith("/me") && content.startsWith("/");
};
@@ -381,8 +381,8 @@ exports.initialize = function () {
});
}
- on_failed_action('remove', abort_message);
- on_failed_action('refresh', resend_message);
+ on_failed_action("remove", abort_message);
+ on_failed_action("refresh", resend_message);
};
window.echo = exports;
diff --git a/static/js/emoji.js b/static/js/emoji.js
index 0cb45ec722d..41345a42720 100644
--- a/static/js/emoji.js
+++ b/static/js/emoji.js
@@ -36,7 +36,7 @@ const emoticon_translations = (() => {
const translations = [];
for (const [emoticon, replacement_text] of Object.entries(emoji_codes.emoticon_conversions)) {
- const regex = new RegExp('(' + util.escape_regexp(emoticon) + ')', 'g');
+ const regex = new RegExp("(" + util.escape_regexp(emoticon) + ")", "g");
translations.push({
regex: regex,
@@ -48,9 +48,9 @@ const emoticon_translations = (() => {
})();
const zulip_emoji = {
- id: 'zulip',
- emoji_name: 'zulip',
- emoji_url: '/static/generated/emoji/images/emoji/unicode/zulip.png',
+ id: "zulip",
+ emoji_name: "zulip",
+ emoji_url: "/static/generated/emoji/images/emoji/unicode/zulip.png",
is_realm_emoji: true,
deactivated: false,
};
diff --git a/static/js/emoji_picker.js b/static/js/emoji_picker.js
index f68490f6f79..951e7682542 100644
--- a/static/js/emoji_picker.js
+++ b/static/js/emoji_picker.js
@@ -1,9 +1,9 @@
const emoji_codes = require("../generated/emoji/emoji_codes.json");
const typeahead = require("../shared/js/typeahead");
-const render_emoji_popover = require('../templates/emoji_popover.hbs');
-const render_emoji_popover_content = require('../templates/emoji_popover_content.hbs');
-const render_emoji_popover_search_results = require('../templates/emoji_popover_search_results.hbs');
+const render_emoji_popover = require("../templates/emoji_popover.hbs");
+const render_emoji_popover_content = require("../templates/emoji_popover_content.hbs");
+const render_emoji_popover_search_results = require("../templates/emoji_popover_search_results.hbs");
const render_emoji_showcase = require("../templates/emoji_showcase.hbs");
// Emoji picker is of fixed width and height. Update these
@@ -157,9 +157,9 @@ const generate_emoji_picker_content = function (id) {
function refill_section_head_offsets(popover) {
section_head_offsets = [];
- popover.find('.emoji-popover-subheading').each(function () {
+ popover.find(".emoji-popover-subheading").each(function () {
section_head_offsets.push({
- section: $(this).attr('data-section'),
+ section: $(this).attr("data-section"),
position_y: $(this).position().top,
});
});
@@ -170,7 +170,7 @@ exports.reactions_popped = function () {
};
exports.hide_emoji_popover = function () {
- $('.has_popover').removeClass('has_popover has_emoji_popover');
+ $(".has_popover").removeClass("has_popover has_emoji_popover");
if (exports.reactions_popped()) {
const orig_title = current_message_emoji_popover_elem.data("original-title");
current_message_emoji_popover_elem.popover("destroy");
@@ -224,7 +224,7 @@ function filter_emojis() {
search_results: sorted_search_results,
message_id: message_id,
});
- $('.emoji-search-results').html(rendered_search_results);
+ $(".emoji-search-results").html(rendered_search_results);
ui.reset_scrollbar($(".emoji-search-results-container"));
if (!search_results_visible) {
show_search_results();
@@ -238,7 +238,7 @@ function toggle_reaction(emoji_name, event) {
const message_id = current_msg_list.selected_id();
const message = message_store.get(message_id);
if (!message) {
- blueslip.error('reactions: Bad message id: ' + message_id);
+ blueslip.error("reactions: Bad message id: " + message_id);
return;
}
@@ -248,11 +248,11 @@ function toggle_reaction(emoji_name, event) {
exports.hide_emoji_popover();
}
- $(event.target).closest('.reaction').toggleClass('reacted');
+ $(event.target).closest(".reaction").toggleClass("reacted");
}
function is_composition(emoji) {
- return $(emoji).hasClass('composition');
+ return $(emoji).hasClass("composition");
}
function process_enter_while_filtering(e) {
@@ -299,7 +299,7 @@ function update_emoji_showcase($focused_emoji) {
const emoji_dict = {
...focused_emoji_dict,
- name: focused_emoji_name.replace(/_/g, ' '),
+ name: focused_emoji_name.replace(/_/g, " "),
};
const rendered_showcase = render_emoji_showcase({
emoji_dict: emoji_dict,
@@ -378,7 +378,7 @@ function get_next_emoji_coordinates(move_by) {
}
function change_focus_to_filter() {
- $('.emoji-popover-filter').focus();
+ $(".emoji-popover-filter").focus();
// If search is active reset current selected emoji to first emoji.
if (search_is_active) {
current_section = 0;
@@ -388,7 +388,7 @@ function change_focus_to_filter() {
}
exports.navigate = function (event_name, e) {
- if (event_name === 'toggle_reactions_popover' && exports.reactions_popped() &&
+ if (event_name === "toggle_reactions_popover" && exports.reactions_popped() &&
(search_is_active === false || search_results.length === 0)) {
exports.hide_emoji_popover();
return true;
@@ -400,7 +400,7 @@ exports.navigate = function (event_name, e) {
return false;
}
- if (event_name === 'enter') {
+ if (event_name === "enter") {
if (is_composition(e.target)) {
e.target.click();
} else {
@@ -413,7 +413,7 @@ exports.navigate = function (event_name, e) {
const $emoji_map = $popover.find(".emoji-popover-emoji-map").expectOne();
const selected_emoji = get_rendered_emoji(current_section, current_index);
- const is_filter_focused = $('.emoji-popover-filter').is(':focus');
+ const is_filter_focused = $(".emoji-popover-filter").is(":focus");
let next_section = 0;
// special cases
if (is_filter_focused) {
@@ -435,8 +435,8 @@ 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
@@ -445,7 +445,7 @@ exports.navigate = function (event_name, e) {
// goes to beginning) with something reasonable and
// consistent (cursor goes to the end of the filter
// string).
- $('.emoji-popover-filter').focus().caret(Infinity);
+ $(".emoji-popover-filter").focus().caret(Infinity);
ui.get_scroll_element($emoji_map).scrollTop(0);
ui.get_scroll_element($(".emoji-search-results-container")).scrollTop(0);
current_section = 0;
@@ -453,35 +453,35 @@ exports.navigate = function (event_name, e) {
reset_emoji_showcase();
return true;
}
- } else if (event_name === 'tab') {
+ } else if (event_name === "tab") {
change_focus_to_filter();
return true;
- } else if (event_name === 'shift_tab') {
+ } else if (event_name === "shift_tab") {
if (!is_filter_focused) {
change_focus_to_filter();
}
return true;
- } else if (event_name === 'page_up') {
+ } else if (event_name === "page_up") {
next_section = current_section - 1;
maybe_change_active_section(next_section);
return true;
- } else if (event_name === 'page_down') {
+ } else if (event_name === "page_down") {
next_section = current_section + 1;
maybe_change_active_section(next_section);
return true;
} else if (!is_filter_focused) {
let next_coord = {};
switch (event_name) {
- case 'down_arrow':
+ case "down_arrow":
next_coord = get_next_emoji_coordinates(6);
break;
- case 'up_arrow':
+ case "up_arrow":
next_coord = get_next_emoji_coordinates(-6);
break;
- case 'left_arrow':
+ case "left_arrow":
next_coord = get_next_emoji_coordinates(-1);
break;
- case 'right_arrow':
+ case "right_arrow":
next_coord = get_next_emoji_coordinates(1);
break;
}
@@ -492,7 +492,7 @@ exports.navigate = function (event_name, e) {
};
function process_keypress(e) {
- const is_filter_focused = $('.emoji-popover-filter').is(':focus');
+ const is_filter_focused = $(".emoji-popover-filter").is(":focus");
const pressed_key = e.which;
if (!is_filter_focused && pressed_key !== 58) {
// ':' => 58, is a hotkey for toggling reactions popover.
@@ -501,7 +501,7 @@ function process_keypress(e) {
e.preventDefault();
e.stopPropagation();
- const emoji_filter = $('.emoji-popover-filter');
+ const emoji_filter = $(".emoji-popover-filter");
const old_query = emoji_filter.val();
let new_query = "";
@@ -521,7 +521,7 @@ function process_keypress(e) {
exports.emoji_select_tab = function (elt) {
const scrolltop = elt.scrollTop();
- const scrollheight = elt.prop('scrollHeight');
+ const scrollheight = elt.prop("scrollHeight");
const elt_height = elt.height();
let currently_selected = "";
section_head_offsets.forEach((o) => {
@@ -539,22 +539,22 @@ exports.emoji_select_tab = function (elt) {
currently_selected = section_head_offsets[0].section;
}
if (currently_selected) {
- $('.emoji-popover-tab-item.active').removeClass('active');
- $('.emoji-popover-tab-item[data-tab-name="' + currently_selected + '"]').addClass('active');
+ $(".emoji-popover-tab-item.active").removeClass("active");
+ $('.emoji-popover-tab-item[data-tab-name="' + currently_selected + '"]').addClass("active");
}
};
function register_popover_events(popover) {
- const $emoji_map = popover.find('.emoji-popover-emoji-map');
+ const $emoji_map = popover.find(".emoji-popover-emoji-map");
ui.get_scroll_element($emoji_map).on("scroll", () => {
exports.emoji_select_tab(ui.get_scroll_element($emoji_map));
});
- $('.emoji-popover-filter').on('input', filter_emojis);
- $('.emoji-popover-filter').keydown(process_enter_while_filtering);
- $('.emoji-popover').keypress(process_keypress);
- $('.emoji-popover').keydown((e) => {
+ $(".emoji-popover-filter").on("input", filter_emojis);
+ $(".emoji-popover-filter").keydown(process_enter_while_filtering);
+ $(".emoji-popover").keypress(process_keypress);
+ $(".emoji-popover").keydown((e) => {
// Because of cross-browser issues we need to handle backspace
// key separately. Firefox fires `keypress` event for backspace
// key but chrome doesn't so we need to trigger the logic for
@@ -571,11 +571,11 @@ exports.render_emoji_popover = function (elt, id) {
};
let placement = popovers.compute_placement(elt, APPROX_HEIGHT, APPROX_WIDTH, true);
- if (placement === 'viewport_center') {
+ if (placement === "viewport_center") {
// For legacy reasons `compute_placement` actually can
// return `viewport_center`, but bootstrap doesn't actually
// support that.
- placement = 'left';
+ placement = "left";
}
let template = render_emoji_popover(template_args);
@@ -599,8 +599,8 @@ exports.render_emoji_popover = function (elt, id) {
elt.popover("show");
elt.prop("title", i18n.t("Add emoji reaction (:)"));
- const popover = elt.data('popover').$tip;
- popover.find('.emoji-popover-filter').focus();
+ const popover = elt.data("popover").$tip;
+ popover.find(".emoji-popover-filter").focus();
current_message_emoji_popover_elem = elt;
emoji_catalog_last_coordinates = {
@@ -623,13 +623,13 @@ exports.toggle_emoji_popover = function (element, id) {
return;
}
- $(element).closest('.message_row').toggleClass('has_popover has_emoji_popover');
+ $(element).closest(".message_row").toggleClass("has_popover has_emoji_popover");
const elt = $(element);
if (id !== undefined) {
current_msg_list.select_id(id);
}
- if (elt.data('popover') === undefined) {
+ if (elt.data("popover") === undefined) {
// Keep the element over which the popover is based off visible.
elt.addClass("reaction_button_visible");
exports.render_emoji_popover(elt, id);
@@ -639,7 +639,7 @@ exports.toggle_emoji_popover = function (element, id) {
exports.register_click_handlers = function () {
- $(document).on('click', '.emoji-popover-emoji.reaction', function (e) {
+ $(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
// the reaction is removed
@@ -648,9 +648,9 @@ exports.register_click_handlers = function () {
toggle_reaction(emoji_name, e);
});
- $(document).on('click', '.emoji-popover-emoji.composition', function (e) {
+ $(document).on("click", ".emoji-popover-emoji.composition", function (e) {
const emoji_name = $(this).attr("data-emoji-name");
- const emoji_text = ':' + emoji_name + ':';
+ const emoji_text = ":" + emoji_name + ":";
// The following check will return false if emoji was not selected in
// message edit form.
if (edit_message_id !== null) {
@@ -696,21 +696,21 @@ exports.register_click_handlers = function () {
const title = i18n.t("Add emoji reaction");
elem.tooltip({
title: title + " (:)",
- trigger: 'hover',
- placement: 'bottom',
+ trigger: "hover",
+ placement: "bottom",
animation: false,
});
- elem.tooltip('show');
+ elem.tooltip("show");
$(".tooltip-arrow").remove();
});
- $('#main_div').on('mouseleave', '.reaction_button', (e) => {
+ $("#main_div").on("mouseleave", ".reaction_button", (e) => {
e.stopPropagation();
- $(e.currentTarget).tooltip('hide');
+ $(e.currentTarget).tooltip("hide");
});
$("body").on("click", ".actions_popover .reaction_button", (e) => {
- const message_id = $(e.currentTarget).data('message-id');
+ const message_id = $(e.currentTarget).data("message-id");
e.preventDefault();
e.stopPropagation();
// HACK: Because we need the popover to be based off an
@@ -726,7 +726,7 @@ exports.register_click_handlers = function () {
e.stopPropagation();
e.preventDefault();
- const $popover = $(e.currentTarget).closest('.emoji-info-popover').expectOne();
+ 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"));
diff --git a/static/js/emojisets.js b/static/js/emojisets.js
index af65d306b9c..a468a9f91e2 100644
--- a/static/js/emojisets.js
+++ b/static/js/emojisets.js
@@ -44,5 +44,5 @@ export function initialize() {
//
// TODO: We should probably just make this work just like the Zulip emoji.
const octopus_image = new Image();
- octopus_image.src = '/static/generated/emoji/images-google-64/1f419.png';
+ octopus_image.src = "/static/generated/emoji/images-google-64/1f419.png";
}
diff --git a/static/js/favicon.js b/static/js/favicon.js
index 527c090d3f2..de9dc3056a2 100644
--- a/static/js/favicon.js
+++ b/static/js/favicon.js
@@ -1,5 +1,5 @@
exports.set = function (url) {
- $('#favicon').attr('href', url);
+ $("#favicon").attr("href", url);
};
diff --git a/static/js/feedback_widget.js b/static/js/feedback_widget.js
index 2ac5e0ffb7d..df045be17bb 100644
--- a/static/js/feedback_widget.js
+++ b/static/js/feedback_widget.js
@@ -1,4 +1,4 @@
-const render_feedback_container = require('../templates/feedback_container.hbs');
+const render_feedback_container = require("../templates/feedback_container.hbs");
/*
@@ -91,11 +91,11 @@ function set_up_handlers() {
meta.hide_me_time = Math.max(meta.hide_me_time, new Date().getTime() + 2000);
});
- meta.$container.on('click', '.exit-me', () => {
+ meta.$container.on("click", ".exit-me", () => {
animate.fadeOut();
});
- meta.$container.on('click', '.feedback_undo', () => {
+ meta.$container.on("click", ".feedback_undo", () => {
if (meta.undo) {
meta.undo();
}
@@ -113,11 +113,11 @@ exports.dismiss = function () {
exports.show = function (opts) {
if (!opts.populate) {
- blueslip.error('programmer needs to supply populate callback.');
+ blueslip.error("programmer needs to supply populate callback.");
return;
}
- meta.$container = $('#feedback_container');
+ meta.$container = $("#feedback_container");
const html = render_feedback_container();
meta.$container.html(html);
@@ -129,9 +129,9 @@ exports.show = function (opts) {
// add a four second delay before closing up.
meta.hide_me_time = new Date().getTime() + 4000;
- meta.$container.find('.feedback_title').text(opts.title_text);
- meta.$container.find('.feedback_undo').text(opts.undo_button_text);
- opts.populate(meta.$container.find('.feedback_content'));
+ meta.$container.find(".feedback_title").text(opts.title_text);
+ meta.$container.find(".feedback_undo").text(opts.undo_button_text);
+ opts.populate(meta.$container.find(".feedback_content"));
animate.fadeIn();
};
diff --git a/static/js/fenced_code.js b/static/js/fenced_code.js
index 5ccec589427..1d45e4d1bd7 100644
--- a/static/js/fenced_code.js
+++ b/static/js/fenced_code.js
@@ -30,22 +30,22 @@ 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>' +
- _.escape(code.replace(/^\n+|\n+$/g, '')) +
- '\n</code></pre></div>\n';
+ _.escape(code.replace(/^\n+|\n+$/g, "")) +
+ "\n</code></pre></div>\n";
};
function wrap_quote(text) {
- const paragraphs = text.split('\n\n');
+ const paragraphs = text.split("\n\n");
const quoted_paragraphs = [];
// Prefix each quoted paragraph with > at the
// 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'));
+ const lines = paragraph.split("\n");
+ quoted_paragraphs.push(lines.filter((line) => line !== "").map((line) => "> " + line).join("\n"));
}
- return quoted_paragraphs.join('\n\n');
+ return quoted_paragraphs.join("\n\n");
}
function wrap_tex(tex) {
@@ -54,7 +54,7 @@ function wrap_tex(tex) {
displayMode: true,
});
} catch (ex) {
- return '<span class="tex-error">' + _.escape(tex) + '</span>';
+ return '<span class="tex-error">' + _.escape(tex) + "</span>";
}
}
@@ -62,7 +62,7 @@ function wrap_spoiler(header, text, stash_func) {
const output = [];
const header_div_open_html = '<div class="spoiler-block"><div class="spoiler-header">';
const end_header_start_content_html = '</div><div class="spoiler-content" aria-hidden="true">';
- const footer_html = '</div></div>';
+ const footer_html = "</div></div>";
output.push(stash_func(header_div_open_html));
output.push(header);
@@ -77,7 +77,7 @@ exports.set_stash_func = function (stash_handler) {
};
exports.process_fenced_code = function (content) {
- const input = content.split('\n');
+ const input = content.split("\n");
const output = [];
const handler_stack = [];
let consume_line;
@@ -87,7 +87,7 @@ exports.process_fenced_code = function (content) {
// don't do syntax highlighting yet
return (function () {
const lines = [];
- if (lang === 'quote') {
+ if (lang === "quote") {
return {
handle_line: function (line) {
if (line === fence) {
@@ -98,16 +98,16 @@ exports.process_fenced_code = function (content) {
},
done: function () {
- const text = wrap_quote(lines.join('\n'));
- output_lines.push('');
+ const text = wrap_quote(lines.join("\n"));
+ output_lines.push("");
output_lines.push(text);
- output_lines.push('');
+ output_lines.push("");
handler_stack.pop();
},
};
}
- if (lang === 'math') {
+ if (lang === "math") {
return {
handle_line: function (line) {
if (line === fence) {
@@ -118,17 +118,17 @@ exports.process_fenced_code = function (content) {
},
done: function () {
- const text = wrap_tex(lines.join('\n'));
+ const text = wrap_tex(lines.join("\n"));
const placeholder = stash_func(text, true);
- output_lines.push('');
+ output_lines.push("");
output_lines.push(placeholder);
- output_lines.push('');
+ output_lines.push("");
handler_stack.pop();
},
};
}
- if (lang === 'spoiler') {
+ if (lang === "spoiler") {
return {
handle_line: function (line) {
if (line === fence) {
@@ -139,10 +139,10 @@ exports.process_fenced_code = function (content) {
},
done: function () {
- const text = wrap_spoiler(header, lines.join('\n'), stash_func);
- output_lines.push('');
+ const text = wrap_spoiler(header, lines.join("\n"), stash_func);
+ output_lines.push("");
output_lines.push(text);
- output_lines.push('');
+ output_lines.push("");
handler_stack.pop();
},
};
@@ -158,12 +158,12 @@ exports.process_fenced_code = function (content) {
},
done: function () {
- const text = exports.wrap_code(lines.join('\n'));
+ const text = exports.wrap_code(lines.join("\n"));
// insert safe HTML that is passed through the parsing
const placeholder = stash_func(text, true);
- output_lines.push('');
+ output_lines.push("");
output_lines.push(placeholder);
- output_lines.push('');
+ output_lines.push("");
handler_stack.pop();
},
};
@@ -209,11 +209,11 @@ exports.process_fenced_code = function (content) {
handler.done();
}
- if (output.length > 2 && output[output.length - 2] !== '') {
- output.push('');
+ if (output.length > 2 && output[output.length - 2] !== "") {
+ output.push("");
}
- return output.join('\n');
+ return output.join("\n");
};
const fence_length_re = /^ {0,3}(`{3,})/gm;
@@ -225,7 +225,7 @@ exports.get_unused_fence = (content) => {
while ((match = fence_length_re.exec(content)) !== null) {
length = Math.max(length, match[1].length + 1);
}
- return '`'.repeat(length);
+ return "`".repeat(length);
};
window.fenced_code = exports;
diff --git a/static/js/filter.js b/static/js/filter.js
index e2f4df9395d..cd4f893654b 100644
--- a/static/js/filter.js
+++ b/static/js/filter.js
@@ -8,7 +8,7 @@ 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,12 +22,12 @@ 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'
+ 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);
@@ -46,46 +46,46 @@ function message_in_home(message) {
function message_matches_search_term(message, operator, operand) {
switch (operator) {
- case 'has':
- if (operand === 'image') {
+ case "has":
+ if (operand === "image") {
return message_util.message_has_image(message);
- } else if (operand === 'link') {
+ } else if (operand === "link") {
return message_util.message_has_link(message);
- } else if (operand === 'attachment') {
+ } else if (operand === "attachment") {
return message_util.message_has_attachment(message);
}
return false; // has:something_else returns false
- case 'is':
- if (operand === 'private') {
- return message.type === 'private';
- } else if (operand === 'starred') {
+ case "is":
+ if (operand === "private") {
+ return message.type === "private";
+ } else if (operand === "starred") {
return message.starred;
- } else if (operand === 'mentioned') {
+ } else if (operand === "mentioned") {
return message.mentioned;
- } else if (operand === 'alerted') {
+ } else if (operand === "alerted") {
return message.alerted;
- } else if (operand === 'unread') {
+ } else if (operand === "unread") {
return unread.message_unread(message);
}
return true; // is:whatever returns true
- case 'in':
- if (operand === 'home') {
+ case "in":
+ if (operand === "home") {
return message_in_home(message);
- } else if (operand === 'all') {
+ } else if (operand === "all") {
return true;
}
return true; // in:whatever returns true
- case 'near':
+ case "near":
// this is all handled server side
return true;
- case 'id':
+ case "id":
return message.id.toString() === operand;
- case 'stream': {
- if (message.type !== 'stream') {
+ case "stream": {
+ if (message.type !== "stream") {
return false;
}
@@ -107,8 +107,8 @@ function message_matches_search_term(message, operator, operand) {
return message.stream.toLowerCase() === operand;
}
- case 'topic':
- if (message.type !== 'stream') {
+ case "topic":
+ if (message.type !== "stream") {
return false;
}
@@ -119,10 +119,10 @@ function message_matches_search_term(message, operator, operand) {
return message.topic.toLowerCase() === operand;
- case 'sender':
+ case "sender":
return people.id_matches_email_operand(message.sender_id, operand);
- case 'group-pm-with': {
+ case "group-pm-with": {
const operand_ids = people.pm_with_operand_ids(operand);
if (!operand_ids) {
return false;
@@ -136,9 +136,9 @@ function message_matches_search_term(message, operator, operand) {
// message, but it is implicit by the fact that the current user has access to the message.
}
- case 'pm-with': {
+ case "pm-with": {
// TODO: use user_ids, not emails here
- if (message.type !== 'private') {
+ if (message.type !== "private") {
return false;
}
const operand_ids = people.pm_with_operand_ids(operand);
@@ -163,8 +163,8 @@ function Filter(operators) {
this._sub = undefined;
} else {
this._operators = this.fix_operators(operators);
- if (this.has_operator('stream')) {
- this._sub = stream_data.get_sub_by_name(this.operands('stream')[0]);
+ if (this.has_operator("stream")) {
+ this._sub = stream_data.get_sub_by_name(this.operands("stream")[0]);
}
}
}
@@ -172,12 +172,12 @@ function Filter(operators) {
Filter.canonicalize_operator = function (operator) {
operator = operator.toLowerCase();
- if (operator === 'from') {
- return 'sender';
+ if (operator === "from") {
+ return "sender";
}
if (util.is_topic_synonym(operator)) {
- return 'topic';
+ return "topic";
}
return operator;
};
@@ -196,27 +196,27 @@ Filter.canonicalize_term = function (opts) {
operator = Filter.canonicalize_operator(operator);
switch (operator) {
- case 'has':
+ case "has":
// images -> image, etc.
- operand = operand.replace(/s$/, '');
+ operand = operand.replace(/s$/, "");
break;
- case 'stream':
+ case "stream":
operand = stream_data.get_name(operand);
break;
- case 'topic':
+ case "topic":
break;
- case 'sender':
- case 'pm-with':
+ case "sender":
+ case "pm-with":
operand = operand.toString().toLowerCase();
- if (operand === 'me') {
+ if (operand === "me") {
operand = people.my_current_email();
}
break;
- case 'group-pm-with':
+ case "group-pm-with":
operand = operand.toString().toLowerCase();
break;
- case 'search':
+ 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
@@ -244,16 +244,16 @@ 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')
- .replace(/\+/g, '%2B')
- .replace(/ /g, '+')
- .replace(/"/g, '%22');
+ return operand.replace(/%/g, "%25")
+ .replace(/\+/g, "%2B")
+ .replace(/ /g, "+")
+ .replace(/"/g, "%22");
}
function decodeOperand(encoded, operator) {
- encoded = encoded.replace(/"/g, '');
- if (['group-pm-with', 'pm-with', 'sender', 'from'].includes(operator) === false) {
- encoded = encoded.replace(/\+/g, ' ');
+ encoded = encoded.replace(/"/g, "");
+ if (["group-pm-with", "pm-with", "sender", "from"].includes(operator) === false) {
+ encoded = encoded.replace(/\+/g, " ");
}
return util.robust_uri_decode(encoded).trim();
}
@@ -276,7 +276,7 @@ Filter.parse = function (str) {
for (const token of matches) {
let operator;
- const parts = token.split(':');
+ const parts = token.split(":");
if (token[0] === '"' || parts.length === 1) {
// Looks like a normal search term.
search_term.push(token);
@@ -284,17 +284,17 @@ Filter.parse = function (str) {
// Looks like an operator.
negated = false;
operator = parts.shift();
- if (operator[0] === '-') {
+ if (operator[0] === "-") {
negated = true;
operator = operator.slice(1);
}
- operand = decodeOperand(parts.join(':'), operator);
+ operand = decodeOperand(parts.join(":"), operator);
// We use Filter.operator_to_prefix() checks if the
// operator is known. If it is not known, then we treat
// it as a search for the given string (which may contain
// a `:`), not as a search operator.
- if (Filter.operator_to_prefix(operator, negated) === '') {
+ if (Filter.operator_to_prefix(operator, negated) === "") {
// Put it as a search term, to not have duplicate operators
search_term.push(token);
continue;
@@ -306,8 +306,8 @@ Filter.parse = function (str) {
// NB: Callers of 'parse' can assume that the 'search' operator is last.
if (search_term.length > 0) {
- operator = 'search';
- operand = search_term.join(' ');
+ operator = "search";
+ operand = search_term.join(" ");
term = {operator: operator, operand: operand, negated: false};
operators.push(term);
}
@@ -325,19 +325,19 @@ Filter.parse = function (str) {
Filter.unparse = function (operators) {
const parts = operators.map((elem) => {
- if (elem.operator === 'search') {
+ if (elem.operator === "search") {
// Search terms are the catch-all case.
// All tokens that don't start with a known operator and
// a colon are glued together to form a search term.
return elem.operand;
}
- const sign = elem.negated ? '-' : '';
- if (elem.operator === '') {
+ const sign = elem.negated ? "-" : "";
+ if (elem.operator === "") {
return elem.operand;
}
- return sign + elem.operator + ':' + encodeOperand(elem.operand.toString());
+ return sign + elem.operator + ":" + encodeOperand(elem.operand.toString());
});
- return parts.join(' ');
+ return parts.join(" ");
};
@@ -388,7 +388,7 @@ Filter.prototype = {
has_operator: function (operator) {
return this._operators.some((elem) => {
- if (elem.negated && !['search', 'has'].includes(elem.operator)) {
+ if (elem.negated && !["search", "has"].includes(elem.operator)) {
return false;
}
return elem.operator === operator;
@@ -396,17 +396,17 @@ Filter.prototype = {
},
is_search: function () {
- return this.has_operator('search');
+ return this.has_operator("search");
},
calc_can_mark_messages_read: function () {
const term_types = this.sorted_term_types();
- if (_.isEqual(term_types, ['stream', 'topic'])) {
+ if (_.isEqual(term_types, ["stream", "topic"])) {
return true;
}
- if (_.isEqual(term_types, ['pm-with'])) {
+ if (_.isEqual(term_types, ["pm-with"])) {
return true;
}
@@ -415,15 +415,15 @@ Filter.prototype = {
// that early-exits before the subsequent checks.
// (in which case, is_common_narrow would also need to be modified)
- if (_.isEqual(term_types, ['stream'])) {
+ if (_.isEqual(term_types, ["stream"])) {
return true;
}
- if (_.isEqual(term_types, ['is-private'])) {
+ if (_.isEqual(term_types, ["is-private"])) {
return true;
}
- if (_.isEqual(term_types, ['is-mentioned'])) {
+ if (_.isEqual(term_types, ["is-mentioned"])) {
return true;
}
@@ -432,7 +432,7 @@ Filter.prototype = {
return true;
}
- if (term_types.length === 1 && ['in-home', 'in-all'].includes(term_types[0])) {
+ if (term_types.length === 1 && ["in-home", "in-all"].includes(term_types[0])) {
return true;
}
@@ -469,10 +469,10 @@ Filter.prototype = {
// (which can_mark_messages_read_does not check as starred messages are always read)
const term_types = this.sorted_term_types();
- if (_.isEqual(term_types, ['is-starred'])) {
+ if (_.isEqual(term_types, ["is-starred"])) {
return true;
}
- if (_.isEqual(term_types, ['streams-public'])) {
+ if (_.isEqual(term_types, ["streams-public"])) {
return true;
}
return false;
@@ -489,12 +489,12 @@ Filter.prototype = {
const term_types = this.sorted_term_types();
// this comes first because it has 3 term_types but is not a "complex filter"
- if (_.isEqual(term_types, ['stream', 'topic', 'search'])) {
+ if (_.isEqual(term_types, ["stream", "topic", "search"])) {
// if stream does not exist, redirect to All
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"
@@ -502,29 +502,29 @@ Filter.prototype = {
return "#"; // redirect to All
}
- if (term_types[1] === 'search') {
+ if (term_types[1] === "search") {
switch (term_types[0]) {
- case 'stream':
+ case "stream":
// if stream does not exist, redirect to All
if (!this._sub) {
return "#";
}
- return '/#narrow/stream/' + stream_data.name_to_slug(this.operands('stream')[0]);
- case 'is-private':
- return '/#narrow/is/private';
- case 'is-starred':
- return '/#narrow/is/starred';
- case 'is-mentioned':
- return '/#narrow/is/mentioned';
- case 'streams-public':
- return '/#narrow/streams/public';
- case 'pm-with':
+ return "/#narrow/stream/" + stream_data.name_to_slug(this.operands("stream")[0]);
+ case "is-private":
+ return "/#narrow/is/private";
+ case "is-starred":
+ return "/#narrow/is/starred";
+ case "is-mentioned":
+ return "/#narrow/is/mentioned";
+ 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());
+ 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':
- return '/#narrow/sender/' + people.emails_to_slug(this.operands('sender')[0]);
+ case "sender":
+ return "/#narrow/sender/" + people.emails_to_slug(this.operands("sender")[0]);
}
}
@@ -535,62 +535,62 @@ Filter.prototype = {
// We have special icons for the simple narrows available for the via sidebars.
const term_types = this.sorted_term_types();
switch (term_types[0]) {
- case 'in-home':
- case 'in-all':
- return 'home';
- case 'stream':
+ case "in-home":
+ case "in-all":
+ return "home";
+ case "stream":
if (!this._sub) {
- return 'question-circle-o';
+ return "question-circle-o";
}
if (this._sub.invite_only) {
- return 'lock';
+ return "lock";
}
if (this._sub.is_web_public) {
- return 'globe';
+ return "globe";
}
- return 'hashtag';
- case 'is-private':
- return 'envelope';
- case 'is-starred':
- return 'star';
- case 'is-mentioned':
- return 'at';
- case 'pm-with':
- return 'envelope';
+ return "hashtag";
+ case "is-private":
+ return "envelope";
+ case "is-starred":
+ return "star";
+ case "is-mentioned":
+ return "at";
+ case "pm-with":
+ return "envelope";
}
},
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 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');
- case 'in-all':
- return i18n.t('All messages including muted streams');
- case 'streams-public':
- return i18n.t('Public stream messages in organization');
- case 'stream':
+ case "in-home":
+ return i18n.t("All messages");
+ case "in-all":
+ return i18n.t("All messages including muted streams");
+ case "streams-public":
+ return i18n.t("Public stream messages in organization");
+ case "stream":
if (!this._sub) {
- return i18n.t('Unknown stream');
+ return i18n.t("Unknown stream");
}
return this._sub.name;
- case 'is-starred':
- return i18n.t('Starred messages');
- case 'is-mentioned':
- return i18n.t('Mentions');
- case 'is-private':
- return i18n.t('Private messages');
- case 'pm-with': {
- const emails = this.operands('pm-with')[0].split(',');
+ case "is-starred":
+ return i18n.t("Starred messages");
+ case "is-mentioned":
+ return i18n.t("Mentions");
+ case "is-private":
+ return i18n.t("Private messages");
+ case "pm-with": {
+ const emails = this.operands("pm-with")[0].split(",");
const names = emails.map((email) => {
if (!people.get_by_email(email)) {
return email;
@@ -601,14 +601,14 @@ Filter.prototype = {
// We use join to handle the addition of a comma and space after every name
// and also to ensure that we return a string and not an array so that we
// can have the same return type as other cases.
- return names.join(', ');
+ return names.join(", ");
}
}
}
},
allow_use_first_unread_when_narrowing: function () {
- return this.can_mark_messages_read() || this.has_operator('is');
+ return this.can_mark_messages_read() || this.has_operator("is");
},
contains_only_private_messages: function () {
@@ -641,7 +641,7 @@ Filter.prototype = {
return false;
}
- if (this.has_operator('has') && is_local_echo) {
+ if (this.has_operator("has") && is_local_echo) {
// The has: operators can be applied locally for messages
// rendered by the backend; links, attachments, and images
// are not handled properly by the local echo markdown
@@ -649,8 +649,8 @@ 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;
}
@@ -665,13 +665,13 @@ Filter.prototype = {
},
_fix_redundant_is_private: function (terms) {
- const is_pm_with = (term) => Filter.term_type(term) === 'pm-with';
+ const is_pm_with = (term) => Filter.term_type(term) === "pm-with";
if (!terms.some(is_pm_with)) {
return terms;
}
- return terms.filter((term) => Filter.term_type(term) !== 'is-private');
+ return terms.filter((term) => Filter.term_type(term) !== "is-private");
},
_canonicalize_operators: function (operators_mixed_case) {
@@ -690,7 +690,7 @@ Filter.prototype = {
},
has_topic: function (stream_name, topic) {
- return this.has_operand('stream', stream_name) && this.has_operand('topic', topic);
+ return this.has_operand("stream", stream_name) && this.has_operand("topic", topic);
},
sorted_term_types: function () {
@@ -743,10 +743,10 @@ Filter.prototype = {
update_email: function (user_id, new_email) {
for (const term of this._operators) {
switch (term.operator) {
- case 'group-pm-with':
- case 'pm-with':
- case 'sender':
- case 'from':
+ case "group-pm-with":
+ case "pm-with":
+ case "sender":
+ case "from":
term.operand = people.update_email_in_reply_to(
term.operand,
user_id,
@@ -785,12 +785,12 @@ Filter.term_type = function (term) {
const operand = term.operand;
const negated = term.negated;
- let result = negated ? 'not-' : '';
+ let result = negated ? "not-" : "";
result += operator;
- if (['is', 'has', 'in', 'streams'].includes(operator)) {
- result += '-' + operand;
+ if (["is", "has", "in", "streams"].includes(operator)) {
+ result += "-" + operand;
}
return result;
@@ -798,15 +798,15 @@ Filter.term_type = function (term) {
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',
- 'search',
+ "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",
+ "search",
];
function level(term_type) {
@@ -831,65 +831,65 @@ Filter.sorted_term_types = function (term_types) {
Filter.operator_to_prefix = function (operator, negated) {
operator = Filter.canonicalize_operator(operator);
- if (operator === 'search') {
- return negated ? 'exclude' : 'search for';
+ if (operator === "search") {
+ return negated ? "exclude" : "search for";
}
- const verb = negated ? 'exclude ' : '';
+ const verb = negated ? "exclude " : "";
switch (operator) {
- case 'stream':
- return verb + 'stream';
- case 'streams':
- return verb + 'streams';
- case 'near':
- return verb + 'messages around';
+ case "stream":
+ return verb + "stream";
+ case "streams":
+ return verb + "streams";
+ case "near":
+ return verb + "messages around";
// Note: We hack around using this in "describe" below.
- case 'has':
- return verb + 'messages with one or more';
+ case "has":
+ return verb + "messages with one or more";
- case 'id':
- return verb + 'message ID';
+ case "id":
+ return verb + "message ID";
- case 'topic':
- return verb + 'topic';
+ case "topic":
+ return verb + "topic";
- case 'sender':
- return verb + 'sent by';
+ case "sender":
+ return verb + "sent by";
- case 'pm-with':
- return verb + 'private messages with';
+ case "pm-with":
+ return verb + "private messages with";
- case 'in':
- return verb + 'messages in';
+ case "in":
+ return verb + "messages in";
// Note: We hack around using this in "describe" below.
- case 'is':
- return verb + 'messages that are';
+ case "is":
+ return verb + "messages that are";
- case 'group-pm-with':
- return verb + 'group private messages including';
+ case "group-pm-with":
+ return verb + "group private messages including";
}
- return '';
+ return "";
};
function describe_is_operator(operator) {
- const verb = operator.negated ? 'exclude ' : '';
+ const verb = operator.negated ? "exclude " : "";
const operand = operator.operand;
- const operand_list = ['private', 'starred', 'alerted', 'unread'];
+ const operand_list = ["private", "starred", "alerted", "unread"];
if (operand_list.includes(operand)) {
- return verb + operand + ' messages';
- } else if (operand === 'mentioned') {
- return verb + '@-mentions';
+ return verb + operand + " messages";
+ } else if (operand === "mentioned") {
+ return verb + "@-mentions";
}
- return 'invalid ' + operand + ' operand for is operator';
+ return "invalid " + operand + " operand for is operator";
}
// Convert a list of operators to a human-readable description.
function describe_unescaped(operators) {
if (operators.length === 0) {
- return 'all messages';
+ return "all messages";
}
let parts = [];
@@ -899,10 +899,10 @@ function describe_unescaped(operators) {
return term.operator === expected && !term.negated;
};
- if (is(operators[0], 'stream') && is(operators[1], 'topic')) {
+ if (is(operators[0], "stream") && is(operators[1], "topic")) {
const stream = operators[0].operand;
const topic = operators[1].operand;
- const part = "stream " + stream + ' > ' + topic;
+ const part = "stream " + stream + " > " + topic;
parts = [part];
operators = operators.slice(2);
}
@@ -911,25 +911,25 @@ function describe_unescaped(operators) {
const more_parts = operators.map((elem) => {
const operand = elem.operand;
const canonicalized_operator = Filter.canonicalize_operator(elem.operator);
- if (canonicalized_operator === 'is') {
+ if (canonicalized_operator === "is") {
return describe_is_operator(elem);
}
- if (canonicalized_operator === 'has') {
+ if (canonicalized_operator === "has") {
// search_suggestion.get_suggestions takes care that this message will
// only be shown if the `has` operator is not at the last.
- 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';
+ return "invalid " + operand + " operand for has operator";
}
}
const prefix_for_operator = Filter.operator_to_prefix(canonicalized_operator,
elem.negated);
- if (prefix_for_operator !== '') {
- return prefix_for_operator + ' ' + operand;
+ if (prefix_for_operator !== "") {
+ return prefix_for_operator + " " + operand;
}
return "unknown operator";
});
- return parts.concat(more_parts).join(', ');
+ return parts.concat(more_parts).join(", ");
}
Filter.describe = function (operators) {
diff --git a/static/js/floating_recipient_bar.js b/static/js/floating_recipient_bar.js
index e5af1f90222..69d9c164abf 100644
--- a/static/js/floating_recipient_bar.js
+++ b/static/js/floating_recipient_bar.js
@@ -1,7 +1,7 @@
let is_floating_recipient_bar_showing = false;
function top_offset(elem) {
- return elem.offset().top - $('#tab_bar').safeOuterHeight();
+ return elem.offset().top - $("#tab_bar").safeOuterHeight();
}
exports.first_visible_message = function (bar) {
@@ -11,7 +11,7 @@ exports.first_visible_message = function (bar) {
// displayed, which will always be the first messages whose bottom
// overlaps the floating recipient bar's space (since you ).
- const messages = bar.children('.message_row');
+ const messages = bar.children(".message_row");
const frb_bottom = exports.frb_bottom();
const frb_top = frb_bottom - 25;
let result;
@@ -53,7 +53,7 @@ exports.first_visible_message = function (bar) {
// Important: This will break if we ever have things that are
// not message rows inside a recipient_row block.
- message = message.next('.message_row');
+ message = message.next(".message_row");
if (message.length > 0 && result) {
// Before returning a result, we check whether the next
// message's top is actually below the bottom of the
@@ -119,7 +119,7 @@ exports.relevant_recipient_bars = function () {
let first_elem = exports.candidate_recipient_bar();
if (!first_elem) {
- first_elem = $('.focused_table').find('.recipient_row').first();
+ first_elem = $(".focused_table").find(".recipient_row").first();
}
if (first_elem.length === 0) {
@@ -128,8 +128,8 @@ exports.relevant_recipient_bars = function () {
elems.push(first_elem);
- const max_offset = top_offset($('#compose'));
- let header_height = first_elem.find('.message_header').safeOuterHeight();
+ const max_offset = top_offset($("#compose"));
+ let header_height = first_elem.find(".message_header").safeOuterHeight();
// It's okay to overestimate header_height a bit, as we don't
// really need an FRB for a section that barely shows.
@@ -171,7 +171,7 @@ exports.relevant_recipient_bars = function () {
}
if (elems.length === 0) {
- blueslip.warn('Unexpected situation--maybe viewport height is very short.');
+ blueslip.warn("Unexpected situation--maybe viewport height is very short.");
return [];
}
@@ -183,14 +183,14 @@ exports.relevant_recipient_bars = function () {
date_html = exports.get_date(elem);
need_frb = top_offset(elem) < 0;
} else {
- date_html = elem.find('.recipient_row_date').html();
+ date_html = elem.find(".recipient_row_date").html();
need_frb = false;
}
const date_text = $(date_html).text();
// Add title here to facilitate troubleshooting.
- const title = elem.find('.message_label_clickable').last().attr('title');
+ const title = elem.find(".message_label_clickable").last().attr("title");
const item = {
elem: elem,
@@ -255,7 +255,7 @@ exports.candidate_recipient_bar = function () {
function show_floating_recipient_bar() {
if (!is_floating_recipient_bar_showing) {
- $("#floating_recipient_bar").css('visibility', 'visible');
+ $("#floating_recipient_bar").css("visibility", "visible");
is_floating_recipient_bar_showing = true;
}
}
@@ -280,31 +280,31 @@ function replace_floating_recipient_bar(source_info) {
header = source_recipient_bar.children(".message_header_private_message");
}
new_label.find(".message_header").replaceWith(header.clone());
- other_label.css('display', 'none');
- new_label.css('display', 'block');
+ other_label.css("display", "none");
+ new_label.css("display", "block");
new_label.attr("zid", rows.id(rows.first_message_in_group(source_recipient_bar)));
- new_label.toggleClass('message-fade', source_recipient_bar.hasClass('message-fade'));
+ new_label.toggleClass("message-fade", source_recipient_bar.hasClass("message-fade"));
old_source = source_recipient_bar;
}
- const rendered_date = source_info.date_html || '';
+ const rendered_date = source_info.date_html || "";
- $('#floating_recipient_bar').find('.recipient_row_date').html(rendered_date);
+ $("#floating_recipient_bar").find(".recipient_row_date").html(rendered_date);
show_floating_recipient_bar();
}
exports.hide = function () {
if (is_floating_recipient_bar_showing) {
- $("#floating_recipient_bar").css('visibility', 'hidden');
+ $("#floating_recipient_bar").css("visibility", "hidden");
is_floating_recipient_bar_showing = false;
}
};
exports.de_clutter_dates = function (items) {
for (const item of items) {
- item.elem.find('.recipient_row_date').toggle(item.show_date);
+ item.elem.find(".recipient_row_date").toggle(item.show_date);
}
};
diff --git a/static/js/gear_menu.js b/static/js/gear_menu.js
index a8cc808d0aa..b4f51ca7f82 100644
--- a/static/js/gear_menu.js
+++ b/static/js/gear_menu.js
@@ -75,7 +75,7 @@ the selector and then calls info_overlay.show.
const scroll_positions = new Map();
exports.update_org_settings_menu_item = function () {
- const item = $('.admin-menu-item').expectOne();
+ const item = $(".admin-menu-item").expectOne();
if (page_params.is_admin) {
item.find("span").text(i18n.t("Manage organization"));
} else {
@@ -86,15 +86,15 @@ exports.update_org_settings_menu_item = function () {
exports.initialize = function () {
exports.update_org_settings_menu_item();
- $('#gear-menu a[data-toggle="tab"]').on('show', (e) => {
+ $('#gear-menu a[data-toggle="tab"]').on("show", (e) => {
// Save the position of our old tab away, before we switch
- const old_tab = $(e.relatedTarget).attr('href');
+ const old_tab = $(e.relatedTarget).attr("href");
scroll_positions.set(old_tab, message_viewport.scrollTop());
});
- $('#gear-menu a[data-toggle="tab"]').on('shown', (e) => {
- const target_tab = $(e.target).attr('href');
+ $('#gear-menu a[data-toggle="tab"]').on("shown", (e) => {
+ const target_tab = $(e.target).attr("href");
// Hide all our error messages when switching tabs
- $('.alert').removeClass("show");
+ $(".alert").removeClass("show");
// Set the URL bar title to show the sub-page you're currently on.
let browser_url = target_tab;
@@ -106,7 +106,7 @@ exports.initialize = function () {
// After we show the new tab, restore its old scroll position
// (we apparently have to do this after setting the hash,
// because otherwise that action may scroll us somewhere.)
- if (target_tab === '#home') {
+ if (target_tab === "#home") {
if (scroll_positions.has(target_tab)) {
message_viewport.scrollTop(scroll_positions.get(target_tab));
} else {
diff --git a/static/js/hash_util.js b/static/js/hash_util.js
index 72a64db53bd..d67bde3dc48 100644
--- a/static/js/hash_util.js
+++ b/static/js/hash_util.js
@@ -7,12 +7,12 @@ exports.get_hash_section = function (hash) {
// given "#settings/your-account", returns "your-account"
// given '#streams/5/social", returns "5"
if (!hash) {
- return '';
+ return "";
}
const parts = hash.replace(/\/$/, "").split(/\//);
- return parts[1] || '';
+ return parts[1] || "";
};
// Some browsers zealously URI-decode the contents of
@@ -20,19 +20,19 @@ exports.get_hash_section = function (hash) {
// by replacing % with . (like MediaWiki).
exports.encodeHashComponent = function (str) {
return encodeURIComponent(str)
- .replace(/\./g, '%2E')
- .replace(/%/g, '.');
+ .replace(/\./g, "%2E")
+ .replace(/%/g, ".");
};
exports.encode_operand = function (operator, operand) {
- if (operator === 'group-pm-with' || operator === 'pm-with' || operator === 'sender') {
+ if (operator === "group-pm-with" || operator === "pm-with" || operator === "sender") {
const slug = people.emails_to_slug(operand);
if (slug) {
return slug;
}
}
- if (operator === 'stream') {
+ if (operator === "stream") {
return exports.encode_stream_name(operand);
}
@@ -63,7 +63,7 @@ exports.decodeHashComponent = function (str) {
// fail independent of our fault, so just tell the user
// that the url is invalid.
// TODO: Show possible valid urls to the user.
- return decodeURIComponent(str.replace(/\./g, '%'));
+ return decodeURIComponent(str.replace(/\./g, "%"));
} catch (e) {
ui_report.error(i18n.t("Invalid URL"), undefined, $("#home-error"), 2000);
return "";
@@ -71,7 +71,7 @@ exports.decodeHashComponent = function (str) {
};
exports.decode_operand = function (operator, operand) {
- if (operator === 'group-pm-with' || operator === 'pm-with' || operator === 'sender') {
+ if (operator === "group-pm-with" || operator === "pm-with" || operator === "sender") {
const emails = people.slug_to_emails(operand);
if (emails) {
return emails;
@@ -80,7 +80,7 @@ exports.decode_operand = function (operator, operand) {
operand = exports.decodeHashComponent(operand);
- if (operator === 'stream') {
+ if (operator === "stream") {
return stream_data.slug_to_name(operand);
}
@@ -100,19 +100,19 @@ exports.by_stream_topic_uri = function (stream_id, topic) {
// corresponding hash: the # component
// of the narrow URL
exports.operators_to_hash = function (operators) {
- let hash = '#';
+ let hash = "#";
if (operators !== undefined) {
- hash = '#narrow';
+ hash = "#narrow";
for (const elem of operators) {
// Support legacy tuples.
const operator = elem.operator;
const operand = elem.operand;
- const sign = elem.negated ? '-' : '';
- hash += '/' + sign + exports.encodeHashComponent(operator)
- + '/' + exports.encode_operand(operator, operand);
+ const sign = elem.negated ? "-" : "";
+ hash += "/" + sign + exports.encodeHashComponent(operator)
+ + "/" + exports.encode_operand(operator, operand);
}
}
@@ -121,7 +121,7 @@ exports.operators_to_hash = function (operators) {
exports.by_sender_uri = function (reply_to) {
return exports.operators_to_hash([
- {operator: 'sender', operand: reply_to},
+ {operator: "sender", operand: reply_to},
]);
};
@@ -135,13 +135,13 @@ exports.huddle_with_uri = function (user_ids_string) {
// that have already converted emails to a comma-delimited
// list of user_ids. We should be careful to keep this
// consistent with hash_util.decode_operand.
- return "#narrow/pm-with/" + user_ids_string + '-group';
+ return "#narrow/pm-with/" + user_ids_string + "-group";
};
exports.by_conversation_and_time_uri = function (message) {
const absolute_url = window.location.protocol + "//" +
window.location.host + "/" +
- window.location.pathname.split('/')[1];
+ window.location.pathname.split("/")[1];
const suffix = "/near/" + exports.encodeHashComponent(message.id);
@@ -162,7 +162,7 @@ exports.stream_edit_uri = function (sub) {
exports.search_public_streams_notice_url = function () {
// Computes the URL of the current narrow if streams:public were added.
const operators = narrow_state.filter().operators();
- const public_operator = {operator: 'streams', operand: 'public'};
+ const public_operator = {operator: "streams", operand: "public"};
return exports.operators_to_hash([public_operator].concat(operators));
};
@@ -174,7 +174,7 @@ exports.parse_narrow = function (hash) {
// but the user might write one.
let operator = exports.decodeHashComponent(hash[i]);
// Do not parse further if empty operator encountered.
- if (operator === '') {
+ if (operator === "") {
break;
}
@@ -185,7 +185,7 @@ exports.parse_narrow = function (hash) {
}
let negated = false;
- if (operator[0] === '-') {
+ if (operator[0] === "-") {
negated = true;
operator = operator.slice(1);
}
diff --git a/static/js/hashchange.js b/static/js/hashchange.js
index e546ffc89b5..07279ba1650 100644
--- a/static/js/hashchange.js
+++ b/static/js/hashchange.js
@@ -5,20 +5,20 @@ let changing_hash = false;
function get_full_url(hash) {
const location = window.location;
- if (hash === '' || hash.charAt(0) !== '#') {
- hash = '#' + hash;
+ if (hash === "" || hash.charAt(0) !== "#") {
+ hash = "#" + hash;
}
// IE returns pathname as undefined and missing the leading /
let pathname = location.pathname;
if (pathname === undefined) {
- pathname = '/';
- } else if (pathname === '' || pathname.charAt(0) !== '/') {
- pathname = '/' + pathname;
+ pathname = "/";
+ } else if (pathname === "" || pathname.charAt(0) !== "/") {
+ pathname = "/" + pathname;
}
// Build a full URL to not have same origin problems
- const url = location.protocol + '//' + location.host + pathname + hash;
+ const url = location.protocol + "//" + location.host + pathname + hash;
return url;
}
@@ -27,7 +27,7 @@ function set_hash(hash) {
const url = get_full_url(hash);
history.pushState(null, null, url);
} else {
- blueslip.warn('browser does not support pushState');
+ blueslip.warn("browser does not support pushState");
window.location.hash = hash;
}
}
@@ -83,16 +83,16 @@ function do_hashchange_normal(from_reload) {
if (operators === undefined) {
// If the narrow URL didn't parse, clear
// window.location.hash and send them to the home tab
- set_hash('');
+ set_hash("");
activate_home_tab();
return false;
}
const narrow_opts = {
change_hash: false, // already set
- trigger: 'hash change',
+ trigger: "hash change",
};
if (from_reload) {
- blueslip.debug('We are narrowing as part of a reload.');
+ blueslip.debug("We are narrowing as part of a reload.");
if (page_params.initial_narrow_pointer !== undefined) {
home_msg_list.pre_narrow_offset = page_params.initial_offset;
narrow_opts.then_select_id = page_params.initial_narrow_pointer;
@@ -122,7 +122,7 @@ function do_hashchange_normal(from_reload) {
case "#organization":
case "#settings":
case "#recent_topics":
- blueslip.error('overlay logic skipped for: ' + hash);
+ blueslip.error("overlay logic skipped for: " + hash);
break;
}
return false;
@@ -133,7 +133,7 @@ function do_hashchange_overlay(old_hash) {
const old_base = hash_util.get_hash_category(old_hash);
const section = hash_util.get_hash_section(window.location.hash);
- const coming_from_overlay = is_overlay_hash(old_hash || '#');
+ const coming_from_overlay = is_overlay_hash(old_hash || "#");
// Start by handling the specific case of going
// from something like streams/all to streams_subscribed.
@@ -142,26 +142,26 @@ function do_hashchange_overlay(old_hash) {
// the new overlay.
if (coming_from_overlay) {
if (base === old_base) {
- if (base === 'streams') {
+ if (base === "streams") {
subs.change_state(section);
return;
}
- if (base === 'settings') {
+ if (base === "settings") {
if (!section) {
// We may be on a really old browser or somebody
// hand-typed a hash.
- blueslip.warn('missing section for settings');
+ blueslip.warn("missing section for settings");
}
settings_panel_menu.normal_settings.activate_section_or_default(section);
return;
}
- if (base === 'organization') {
+ if (base === "organization") {
if (!section) {
// We may be on a really old browser or somebody
// hand-typed a hash.
- blueslip.warn('missing section for organization');
+ blueslip.warn("missing section for organization");
}
settings_panel_menu.org_settings.activate_section_or_default(section);
return;
@@ -197,12 +197,12 @@ function do_hashchange_overlay(old_hash) {
return;
}
- if (base === 'settings') {
+ if (base === "settings") {
settings.launch(section);
return;
}
- if (base === 'organization') {
+ if (base === "organization") {
admin.launch(section);
return;
}
@@ -212,7 +212,7 @@ function do_hashchange_overlay(old_hash) {
return;
}
- if (base === 'recent_topics') {
+ if (base === "recent_topics") {
recent_topics.launch();
return;
}
@@ -243,8 +243,8 @@ function hashchanged(from_reload, e) {
exports.update_browser_history = function (new_hash) {
const old_hash = window.location.hash;
- if (!new_hash.startsWith('#')) {
- blueslip.error('programming error: prefix hashes with #: ' + new_hash);
+ if (!new_hash.startsWith("#")) {
+ blueslip.error("programming error: prefix hashes with #: " + new_hash);
return;
}
@@ -253,7 +253,7 @@ exports.update_browser_history = function (new_hash) {
// probably harmless, and we just ignore it. But it could be a symptom
// of disorganized code that's prone to an infinite loop of repeatedly
// assigning the same hash.
- blueslip.info('ignoring probably-harmless call to update_browser_history: ' + new_hash);
+ blueslip.info("ignoring probably-harmless call to update_browser_history: " + new_hash);
return;
}
@@ -265,7 +265,7 @@ exports.update_browser_history = function (new_hash) {
exports.replace_hash = function (hash) {
if (!window.history.replaceState) {
// We may have strange behavior with the back button.
- blueslip.warn('browser does not support replaceState');
+ blueslip.warn("browser does not support replaceState");
return;
}
@@ -280,7 +280,7 @@ exports.go_to_location = function (hash) {
};
exports.initialize = function () {
- $(window).on('hashchange', (e) => {
+ $(window).on("hashchange", (e) => {
hashchanged(false, e.originalEvent);
});
hashchanged(true);
diff --git a/static/js/hotkey.js b/static/js/hotkey.js
index 3b6ac7f2e5e..35522db7a2a 100644
--- a/static/js/hotkey.js
+++ b/static/js/hotkey.js
@@ -1,15 +1,15 @@
function do_narrow_action(action) {
- action(current_msg_list.selected_id(), {trigger: 'hotkey'});
+ action(current_msg_list.selected_id(), {trigger: "hotkey"});
return true;
}
// For message actions and user profile menu.
const menu_dropdown_hotkeys = [
- 'down_arrow',
- 'up_arrow',
- 'vim_up',
- 'vim_down',
- 'enter',
+ "down_arrow",
+ "up_arrow",
+ "vim_up",
+ "vim_down",
+ "enter",
];
// Note that multiple keys can map to the same event_name, which
@@ -25,38 +25,38 @@ const menu_dropdown_hotkeys = [
const keydown_shift_mappings = {
// these can be triggered by shift + key only
- 9: {name: 'shift_tab', message_view_only: false}, // tab
- 32: {name: 'shift_spacebar', message_view_only: true}, // space bar
- 37: {name: 'left_arrow', message_view_only: false}, // left arrow
- 39: {name: 'right_arrow', message_view_only: false}, // right arrow
- 38: {name: 'up_arrow', message_view_only: false}, // up arrow
- 40: {name: 'down_arrow', message_view_only: false}, // down arrow
+ 9: {name: "shift_tab", message_view_only: false}, // tab
+ 32: {name: "shift_spacebar", message_view_only: true}, // space bar
+ 37: {name: "left_arrow", message_view_only: false}, // left arrow
+ 39: {name: "right_arrow", message_view_only: false}, // right arrow
+ 38: {name: "up_arrow", message_view_only: false}, // up arrow
+ 40: {name: "down_arrow", message_view_only: false}, // down arrow
};
const keydown_unshift_mappings = {
// these can be triggered by key only (without shift)
- 9: {name: 'tab', message_view_only: false}, // tab
- 27: {name: 'escape', message_view_only: false}, // escape
- 32: {name: 'spacebar', message_view_only: true}, // space bar
- 33: {name: 'page_up', message_view_only: true}, // page up
- 34: {name: 'page_down', message_view_only: true}, // page down
- 35: {name: 'end', message_view_only: true}, // end
- 36: {name: 'home', message_view_only: true}, // home
- 37: {name: 'left_arrow', message_view_only: false}, // left arrow
- 39: {name: 'right_arrow', message_view_only: false}, // right arrow
- 38: {name: 'up_arrow', message_view_only: false}, // up arrow
- 40: {name: 'down_arrow', message_view_only: false}, // down arrow
+ 9: {name: "tab", message_view_only: false}, // tab
+ 27: {name: "escape", message_view_only: false}, // escape
+ 32: {name: "spacebar", message_view_only: true}, // space bar
+ 33: {name: "page_up", message_view_only: true}, // page up
+ 34: {name: "page_down", message_view_only: true}, // page down
+ 35: {name: "end", message_view_only: true}, // end
+ 36: {name: "home", message_view_only: true}, // home
+ 37: {name: "left_arrow", message_view_only: false}, // left arrow
+ 39: {name: "right_arrow", message_view_only: false}, // right arrow
+ 38: {name: "up_arrow", message_view_only: false}, // up arrow
+ 40: {name: "down_arrow", message_view_only: false}, // down arrow
};
const keydown_ctrl_mappings = {
- 219: {name: 'escape', message_view_only: false}, // '['
+ 219: {name: "escape", message_view_only: false}, // '['
};
const keydown_cmd_or_ctrl_mappings = {
- 67: {name: 'copy_with_c', message_view_only: false}, // 'C'
- 75: {name: 'search_with_k', message_view_only: false}, // 'K'
- 83: {name: 'star_message', message_view_only: true}, // 's'
- 190: {name: 'narrow_to_compose_target', message_view_only: true}, // '.'
+ 67: {name: "copy_with_c", message_view_only: false}, // 'C'
+ 75: {name: "search_with_k", message_view_only: false}, // 'K'
+ 83: {name: "star_message", message_view_only: true}, // 's'
+ 190: {name: "narrow_to_compose_target", message_view_only: true}, // '.'
};
const keydown_either_mappings = {
@@ -71,48 +71,48 @@ const keydown_either_mappings = {
// For enter, there is some possibly that shift-enter is intended to
// have special behavior for folks that are used to shift-enter behavior
// in other apps, but that's also slightly dubious.
- 8: {name: 'backspace', message_view_only: true}, // backspace
- 13: {name: 'enter', message_view_only: false}, // enter
- 46: {name: 'delete', message_view_only: false}, // delete
+ 8: {name: "backspace", message_view_only: true}, // backspace
+ 13: {name: "enter", message_view_only: false}, // enter
+ 46: {name: "delete", message_view_only: false}, // delete
};
const keypress_mappings = {
- 42: {name: 'star_deprecated', message_view_only: true}, // '*'
- 43: {name: 'thumbs_up_emoji', message_view_only: true}, // '+'
- 45: {name: 'toggle_message_collapse', message_view_only: true}, // '-'
- 47: {name: 'search', message_view_only: false}, // '/'
- 58: {name: 'toggle_reactions_popover', message_view_only: true}, // ':'
- 62: {name: 'compose_quote_reply', message_view_only: true}, // '>'
- 63: {name: 'show_shortcuts', message_view_only: false}, // '?'
- 64: {name: 'compose_reply_with_mention', message_view_only: true}, // '@'
- 65: {name: 'stream_cycle_backward', message_view_only: true}, // 'A'
- 67: {name: 'C_deprecated', message_view_only: true}, // 'C'
- 68: {name: 'stream_cycle_forward', message_view_only: true}, // 'D'
- 71: {name: 'G_end', message_view_only: true}, // 'G'
- 74: {name: 'vim_page_down', message_view_only: true}, // 'J'
- 75: {name: 'vim_page_up', message_view_only: true}, // 'K'
- 77: {name: 'toggle_mute', message_view_only: true}, // 'M'
- 80: {name: 'narrow_private', message_view_only: true}, // 'P'
- 82: {name: 'respond_to_author', message_view_only: true}, // 'R'
- 83: {name: 'narrow_by_topic', message_view_only: true}, //'S'
- 86: {name: 'view_selected_stream', message_view_only: false}, //'V'
- 99: {name: 'compose', message_view_only: true}, // 'c'
- 100: {name: 'open_drafts', message_view_only: true}, // 'd'
- 101: {name: 'edit_message', message_view_only: true}, // 'e'
- 103: {name: 'gear_menu', message_view_only: true}, // 'g'
- 105: {name: 'message_actions', message_view_only: true}, // 'i'
- 106: {name: 'vim_down', message_view_only: true}, // 'j'
- 107: {name: 'vim_up', message_view_only: true}, // 'k'
- 110: {name: 'n_key', message_view_only: false}, // 'n'
- 112: {name: 'p_key', message_view_only: false}, // 'p'
- 113: {name: 'query_streams', message_view_only: true}, // 'q'
- 114: {name: 'reply_message', message_view_only: true}, // 'r'
- 115: {name: 'narrow_by_recipient', message_view_only: true}, // 's'
- 116: {name: 'open_recent_topics', message_view_only: true}, // 't'
- 117: {name: 'show_sender_info', message_view_only: true}, // 'u'
- 118: {name: 'show_lightbox', message_view_only: true}, // 'v'
- 119: {name: 'query_users', message_view_only: true}, // 'w'
- 120: {name: 'compose_private_message', message_view_only: true}, // 'x'
+ 42: {name: "star_deprecated", message_view_only: true}, // '*'
+ 43: {name: "thumbs_up_emoji", message_view_only: true}, // '+'
+ 45: {name: "toggle_message_collapse", message_view_only: true}, // '-'
+ 47: {name: "search", message_view_only: false}, // '/'
+ 58: {name: "toggle_reactions_popover", message_view_only: true}, // ':'
+ 62: {name: "compose_quote_reply", message_view_only: true}, // '>'
+ 63: {name: "show_shortcuts", message_view_only: false}, // '?'
+ 64: {name: "compose_reply_with_mention", message_view_only: true}, // '@'
+ 65: {name: "stream_cycle_backward", message_view_only: true}, // 'A'
+ 67: {name: "C_deprecated", message_view_only: true}, // 'C'
+ 68: {name: "stream_cycle_forward", message_view_only: true}, // 'D'
+ 71: {name: "G_end", message_view_only: true}, // 'G'
+ 74: {name: "vim_page_down", message_view_only: true}, // 'J'
+ 75: {name: "vim_page_up", message_view_only: true}, // 'K'
+ 77: {name: "toggle_mute", message_view_only: true}, // 'M'
+ 80: {name: "narrow_private", message_view_only: true}, // 'P'
+ 82: {name: "respond_to_author", message_view_only: true}, // 'R'
+ 83: {name: "narrow_by_topic", message_view_only: true}, //'S'
+ 86: {name: "view_selected_stream", message_view_only: false}, //'V'
+ 99: {name: "compose", message_view_only: true}, // 'c'
+ 100: {name: "open_drafts", message_view_only: true}, // 'd'
+ 101: {name: "edit_message", message_view_only: true}, // 'e'
+ 103: {name: "gear_menu", message_view_only: true}, // 'g'
+ 105: {name: "message_actions", message_view_only: true}, // 'i'
+ 106: {name: "vim_down", message_view_only: true}, // 'j'
+ 107: {name: "vim_up", message_view_only: true}, // 'k'
+ 110: {name: "n_key", message_view_only: false}, // 'n'
+ 112: {name: "p_key", message_view_only: false}, // 'p'
+ 113: {name: "query_streams", message_view_only: true}, // 'q'
+ 114: {name: "reply_message", message_view_only: true}, // 'r'
+ 115: {name: "narrow_by_recipient", message_view_only: true}, // 's'
+ 116: {name: "open_recent_topics", message_view_only: true}, // 't'
+ 117: {name: "show_sender_info", message_view_only: true}, // 'u'
+ 118: {name: "show_lightbox", message_view_only: true}, // 'v'
+ 119: {name: "query_users", message_view_only: true}, // 'w'
+ 120: {name: "compose_private_message", message_view_only: true}, // 'x'
};
exports.get_keydown_hotkey = function (e) {
@@ -224,7 +224,7 @@ exports.process_escape_key = function (e) {
if (compose_state.composing()) {
// Check for errors in compose box; close errors if they exist
- if ($("#compose-send-status").css('display') !== 'none') {
+ if ($("#compose-send-status").css("display") !== "none") {
$("#compose-send-status").hide();
return true;
}
@@ -234,11 +234,11 @@ exports.process_escape_key = function (e) {
return true;
}
- if ($('#searchbox').has(':focus')) {
+ if ($("#searchbox").has(":focus")) {
$("input:focus,textarea:focus").blur();
if (page_params.search_pills_enabled) {
- $('#searchbox .pill').blur();
- $('#searchbox #search_query').blur();
+ $("#searchbox .pill").blur();
+ $("#searchbox #search_query").blur();
} else {
tab_bar.exit_search();
}
@@ -281,12 +281,12 @@ exports.process_enter_key = function (e) {
}
if (hotspots.is_open()) {
- $(e.target).find('.hotspot.overlay.show .hotspot-confirm').click();
+ $(e.target).find(".hotspot.overlay.show .hotspot-confirm").click();
return false;
}
if (emoji_picker.reactions_popped()) {
- return emoji_picker.navigate('enter', e);
+ return emoji_picker.navigate("enter", e);
}
if (exports.in_content_editable_widget(e)) {
@@ -295,7 +295,7 @@ exports.process_enter_key = function (e) {
}
if (popovers.actions_popped()) {
- popovers.actions_menu_handle_keyboard('enter');
+ popovers.actions_menu_handle_keyboard("enter");
return true;
}
@@ -336,7 +336,7 @@ exports.process_enter_key = function (e) {
// cursor up and down, but Enter won't reply -- it'll just trigger
// the link on the sidebar! So you keep pressing enter over and
// over again. Until you click somewhere or press r.
- if ($('a:focus,button:focus').length > 0) {
+ if ($("a:focus,button:focus").length > 0) {
return false;
}
@@ -348,7 +348,7 @@ exports.process_enter_key = function (e) {
// If we got this far, then we're presumably in the message
// view, so in that case "enter" is the hotkey to respond to a message.
// Note that "r" has same effect, but that is handled in process_hotkey().
- compose_actions.respond_to_message({trigger: 'hotkey enter'});
+ compose_actions.respond_to_message({trigger: "hotkey enter"});
return true;
};
@@ -375,7 +375,7 @@ exports.process_tab_key = function () {
}
if (emoji_picker.reactions_popped()) {
- return emoji_picker.navigate('tab');
+ return emoji_picker.navigate("tab");
}
return false;
@@ -386,7 +386,7 @@ exports.process_shift_tab_key = function () {
// TODO: See if browsers like Safari can now handle tabbing correctly
// without our intervention.
- if ($('#compose-send-button').is(':focus')) {
+ if ($("#compose-send-button").is(":focus")) {
// Shift-Tab: go back to content textarea and restore
// cursor position.
ui.restore_compose_cursor();
@@ -409,7 +409,7 @@ exports.process_shift_tab_key = function () {
// Shift-tabbing from emoji catalog/search results takes you back to search textbox.
if (emoji_picker.reactions_popped()) {
- return emoji_picker.navigate('shift_tab');
+ return emoji_picker.navigate("shift_tab");
}
return false;
@@ -423,12 +423,12 @@ exports.process_hotkey = function (e, hotkey) {
// This block needs to be before the `tab` handler.
switch (event_name) {
- case 'up_arrow':
- case 'down_arrow':
- case 'left_arrow':
- case 'right_arrow':
- case 'tab':
- case 'shift_tab':
+ case "up_arrow":
+ case "down_arrow":
+ case "left_arrow":
+ case "right_arrow":
+ case "tab":
+ case "shift_tab":
if (overlays.recent_topics_open()) {
return recent_topics.change_focused_element(e, event_name);
}
@@ -436,23 +436,23 @@ exports.process_hotkey = function (e, hotkey) {
// We handle the most complex keys in their own functions.
switch (event_name) {
- case 'escape':
+ case "escape":
return exports.process_escape_key(e);
- case 'enter':
+ case "enter":
return exports.process_enter_key(e);
- case 'tab':
+ case "tab":
return exports.process_tab_key();
- case 'shift_tab':
+ case "shift_tab":
return exports.process_shift_tab_key();
}
// TODO: break out specific handlers for up_arrow,
// down_arrow, and backspace
switch (event_name) {
- case 'up_arrow':
- case 'down_arrow':
- case 'backspace':
- case 'delete':
+ case "up_arrow":
+ case "down_arrow":
+ case "backspace":
+ case "delete":
if (overlays.drafts_open()) {
drafts.drafts_handle_events(e, event_name);
return true;
@@ -463,20 +463,20 @@ exports.process_hotkey = function (e, hotkey) {
if (exports.processing_text()) {
return false;
}
- if (event_name === 'narrow_by_topic' && overlays.streams_open()) {
+ if (event_name === "narrow_by_topic" && overlays.streams_open()) {
subs.keyboard_sub();
return true;
}
- if (event_name === 'show_lightbox' && overlays.lightbox_open()) {
- overlays.close_overlay('lightbox');
+ if (event_name === "show_lightbox" && overlays.lightbox_open()) {
+ overlays.close_overlay("lightbox");
return true;
}
- if (event_name === 'open_drafts' && overlays.drafts_open()) {
- overlays.close_overlay('drafts');
+ if (event_name === "open_drafts" && overlays.drafts_open()) {
+ overlays.close_overlay("drafts");
return true;
}
- if (event_name === 'open_recent_topics' && overlays.recent_topics_open()) {
- overlays.close_overlay('recent_topics');
+ if (event_name === "open_recent_topics" && overlays.recent_topics_open()) {
+ overlays.close_overlay("recent_topics");
return true;
}
return false;
@@ -499,14 +499,14 @@ exports.process_hotkey = function (e, hotkey) {
}
if (overlays.info_overlay_open()) {
- if (event_name === 'show_shortcuts') {
+ if (event_name === "show_shortcuts") {
overlays.close_active();
return true;
}
return false;
}
- if ((event_name === 'up_arrow' || event_name === 'down_arrow') && overlays.streams_open()) {
+ if ((event_name === "up_arrow" || event_name === "down_arrow") && overlays.streams_open()) {
return subs.switch_rows(event_name);
}
@@ -545,14 +545,14 @@ exports.process_hotkey = function (e, hotkey) {
// The next two sections date back to 00445c84 and are Mac/Chrome-specific,
// and they should possibly be eliminated in favor of keeping standard
// browser behavior.
- if (event_name === 'backspace') {
- if ($('#compose-send-button').is(':focus')) {
+ if (event_name === "backspace") {
+ if ($("#compose-send-button").is(":focus")) {
// Ignore backspace; don't navigate back a page.
return true;
}
}
- if (event_name === 'narrow_to_compose_target') {
+ if (event_name === "narrow_to_compose_target") {
narrow.to_compose_target();
return true;
}
@@ -562,12 +562,12 @@ exports.process_hotkey = function (e, hotkey) {
// Note that there is special handling for enter/escape too, but
// we handle this in other functions.
- if (event_name === 'left_arrow' && compose_state.focus_in_empty_compose()) {
+ if (event_name === "left_arrow" && compose_state.focus_in_empty_compose()) {
message_edit.edit_last_sent_message();
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") {
@@ -588,7 +588,7 @@ exports.process_hotkey = function (e, hotkey) {
}
}
- if (event_name === 'left_arrow') {
+ if (event_name === "left_arrow") {
if (overlays.lightbox_open()) {
lightbox.prev();
return true;
@@ -601,7 +601,7 @@ exports.process_hotkey = function (e, hotkey) {
return true;
}
- if (event_name === 'right_arrow') {
+ if (event_name === "right_arrow") {
if (overlays.lightbox_open()) {
lightbox.next();
return true;
@@ -613,11 +613,11 @@ exports.process_hotkey = function (e, hotkey) {
// Prevent navigation in the background when the overlays are active.
if (overlays.is_active()) {
- if (event_name === 'view_selected_stream' && overlays.streams_open()) {
+ if (event_name === "view_selected_stream" && overlays.streams_open()) {
subs.view_stream();
return true;
}
- if (event_name === 'n_key' && overlays.streams_open() && page_params.can_create_streams) {
+ if (event_name === "n_key" && overlays.streams_open() && page_params.can_create_streams) {
subs.open_create_stream();
return true;
}
@@ -626,63 +626,63 @@ exports.process_hotkey = function (e, hotkey) {
// Shortcuts that don't require a message
switch (event_name) {
- case 'compose': // 'c': compose
- compose_actions.start('stream', {trigger: "compose_hotkey"});
+ case "compose": // 'c': compose
+ compose_actions.start("stream", {trigger: "compose_hotkey"});
return true;
- case 'compose_private_message':
- compose_actions.start('private', {trigger: "compose_hotkey"});
+ case "compose_private_message":
+ compose_actions.start("private", {trigger: "compose_hotkey"});
return true;
- case 'narrow_private':
+ case "narrow_private":
return do_narrow_action((target, opts) => {
- narrow.by('is', 'private', opts);
+ narrow.by("is", "private", opts);
});
- case 'query_streams':
+ case "query_streams":
stream_list.initiate_search();
return true;
- case 'query_users':
+ case "query_users":
activity.initiate_search();
return true;
- case 'search':
- case 'search_with_k':
+ case "search":
+ case "search_with_k":
search.initiate_search();
return true;
- case 'gear_menu':
+ case "gear_menu":
gear_menu.open();
return true;
- case 'show_shortcuts': // Show keyboard shortcuts page
+ case "show_shortcuts": // Show keyboard shortcuts page
info_overlay.maybe_show_keyboard_shortcuts();
return true;
- case 'stream_cycle_backward':
+ case "stream_cycle_backward":
narrow.stream_cycle_backward();
return true;
- case 'stream_cycle_forward':
+ case "stream_cycle_forward":
narrow.stream_cycle_forward();
return true;
- case 'n_key':
+ case "n_key":
narrow.narrow_to_next_topic();
return true;
- case 'p_key':
+ case "p_key":
narrow.narrow_to_next_pm_string();
return true;
- case 'open_drafts':
+ case "open_drafts":
drafts.launch();
return true;
- case 'reply_message': // 'r': respond to message
+ 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().
- compose_actions.respond_to_message({trigger: 'hotkey'});
+ compose_actions.respond_to_message({trigger: "hotkey"});
return true;
- case 'C_deprecated':
- ui.maybe_show_deprecation_notice('C');
+ case "C_deprecated":
+ ui.maybe_show_deprecation_notice("C");
return true;
- case 'star_deprecated':
- ui.maybe_show_deprecation_notice('*');
+ case "star_deprecated":
+ ui.maybe_show_deprecation_notice("*");
return true;
- case 'copy_with_c':
+ case "copy_with_c":
copy_and_paste.copy_handler();
return true;
- case 'open_recent_topics':
- hashchange.go_to_location('recent_topics');
+ case "open_recent_topics":
+ hashchange.go_to_location("recent_topics");
return true;
}
@@ -692,29 +692,29 @@ exports.process_hotkey = function (e, hotkey) {
// Navigation shortcuts
switch (event_name) {
- case 'down_arrow':
- case 'vim_down':
+ case "down_arrow":
+ case "vim_down":
navigate.down(true); // with_centering
return true;
- case 'up_arrow':
- case 'vim_up':
+ case "up_arrow":
+ case "vim_up":
navigate.up();
return true;
- case 'home':
+ case "home":
navigate.to_home();
return true;
- case 'end':
- case 'G_end':
+ case "end":
+ case "G_end":
navigate.to_end();
return true;
- case 'page_up':
- case 'vim_page_up':
- case 'shift_spacebar':
+ case "page_up":
+ case "vim_page_up":
+ case "shift_spacebar":
navigate.page_up();
return true;
- case 'page_down':
- case 'vim_page_down':
- case 'spacebar':
+ case "page_down":
+ case "vim_page_down":
+ case "spacebar":
navigate.page_down();
return true;
}
@@ -722,47 +722,47 @@ exports.process_hotkey = function (e, hotkey) {
const msg = current_msg_list.selected_message();
// Shortcuts that operate on a message
switch (event_name) {
- case 'message_actions':
+ case "message_actions":
return popovers.open_message_menu(msg);
- case 'star_message':
+ case "star_message":
message_flags.toggle_starred_and_update_server(msg);
return true;
- case 'narrow_by_recipient':
+ case "narrow_by_recipient":
return do_narrow_action(narrow.by_recipient);
- case 'narrow_by_topic':
+ case "narrow_by_topic":
return do_narrow_action(narrow.by_topic);
- case 'respond_to_author': // 'R': respond to author
- compose_actions.respond_to_message({reply_type: "personal", trigger: 'hotkey pm'});
+ case "respond_to_author": // 'R': respond to author
+ compose_actions.respond_to_message({reply_type: "personal", trigger: "hotkey pm"});
return true;
- case 'compose_reply_with_mention': // '@': respond to message with mention to author
- compose_actions.reply_with_mention({trigger: 'hotkey'});
+ case "compose_reply_with_mention": // '@': respond to message with mention to author
+ compose_actions.reply_with_mention({trigger: "hotkey"});
return true;
- case 'show_lightbox':
+ case "show_lightbox":
lightbox.show_from_selected_message();
return true;
- case 'show_sender_info':
+ case "show_sender_info":
popovers.show_sender_info();
return true;
- case 'toggle_reactions_popover': // ':': open reactions to message
+ 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
+ case "thumbs_up_emoji": { // '+': reacts with thumbs up emoji on selected message
// Use canonical name.
- const thumbs_up_emoji_code = '1f44d';
+ 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);
return true;
}
- case 'toggle_mute':
+ case "toggle_mute":
muting_ui.toggle_mute(msg);
return true;
- case 'toggle_message_collapse':
+ case "toggle_message_collapse":
condense.toggle_collapse(msg);
return true;
- case 'compose_quote_reply': // > : respond to selected message with quote
- compose_actions.quote_and_reply({trigger: 'hotkey'});
+ case "compose_quote_reply": // > : respond to selected message with quote
+ compose_actions.quote_and_reply({trigger: "hotkey"});
return true;
- case 'edit_message': {
+ case "edit_message": {
const row = current_msg_list.get_row(msg.id);
message_edit.start(row);
return true;
diff --git a/static/js/hotspots.js b/static/js/hotspots.js
index 05d2f21d12d..d48032df54b 100644
--- a/static/js/hotspots.js
+++ b/static/js/hotspots.js
@@ -1,52 +1,52 @@
-const render_hotspot_overlay = require('../templates/hotspot_overlay.hbs');
-const render_intro_reply_hotspot = require('../templates/intro_reply_hotspot.hbs');
+const render_hotspot_overlay = require("../templates/hotspot_overlay.hbs");
+const render_intro_reply_hotspot = require("../templates/intro_reply_hotspot.hbs");
// popover orientations
-const TOP = 'top';
-const LEFT = 'left';
-const RIGHT = 'right';
-const BOTTOM = 'bottom';
-const LEFT_BOTTOM = 'left_bottom';
-const VIEWPORT_CENTER = 'viewport_center';
+const TOP = "top";
+const LEFT = "left";
+const RIGHT = "right";
+const BOTTOM = "bottom";
+const LEFT_BOTTOM = "left_bottom";
+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',
+ element: ".selected_message .messagebox-content",
offset_x: 0.85,
offset_y: 0.7,
popover: BOTTOM,
}],
["intro_streams", {
- element: '#streams_header .sidebar-title',
+ element: "#streams_header .sidebar-title",
offset_x: 1.35,
offset_y: 0.39,
}],
["intro_topics", {
- element: '.topic-name',
+ element: ".topic-name",
offset_x: 0.8,
offset_y: 0.39,
}],
["intro_gear", {
- element: '#settings-dropdown',
+ element: "#settings-dropdown",
offset_x: -0.4,
offset_y: 1.2,
popover: LEFT_BOTTOM,
}],
["intro_compose", {
- element: '#left_bar_compose_stream_button_big',
+ element: "#left_bar_compose_stream_button_big",
offset_x: 0,
offset_y: 0,
}],
]);
// popover illustration url(s)
-const WHALE = '/static/images/hotspots/whale.svg';
+const WHALE = "/static/images/hotspots/whale.svg";
exports.post_hotspot_as_read = function (hotspot_name) {
channel.post({
- url: '/json/users/me/hotspots',
+ url: "/json/users/me/hotspots",
data: { hotspot: JSON.stringify(hotspot_name) },
error: function (err) {
blueslip.error(err.responseText);
@@ -56,11 +56,11 @@ exports.post_hotspot_as_read = function (hotspot_name) {
function place_icon(hotspot) {
const element = $(hotspot.location.element);
- const icon = $('#hotspot_' + hotspot.name + '_icon');
+ const icon = $("#hotspot_" + hotspot.name + "_icon");
- if (element.length === 0 || element.css('display') === 'none' ||
- !element.is(':visible') || element.is(':hidden')) {
- icon.css('display', 'none');
+ if (element.length === 0 || element.css("display") === "none" ||
+ !element.is(":visible") || element.is(":hidden")) {
+ icon.css("display", "none");
return false;
}
@@ -73,7 +73,7 @@ function place_icon(hotspot) {
top: client_rect.top + offset.top,
left: client_rect.left + offset.left,
};
- icon.css('display', 'block');
+ icon.css("display", "block");
icon.css(placement);
return true;
}
@@ -83,8 +83,8 @@ function place_popover(hotspot) {
return;
}
- const popover_width = $('#hotspot_' + hotspot.name + '_overlay .hotspot-popover').outerWidth();
- const popover_height = $('#hotspot_' + hotspot.name + '_overlay .hotspot-popover').outerHeight();
+ const popover_width = $("#hotspot_" + hotspot.name + "_overlay .hotspot-popover").outerWidth();
+ 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;
@@ -105,7 +105,7 @@ function place_popover(hotspot) {
top: -(popover_height + arrow_offset),
left: el_width / 2 - popover_width / 2,
};
- arrow_placement = 'bottom';
+ arrow_placement = "bottom";
break;
case LEFT:
@@ -113,7 +113,7 @@ function place_popover(hotspot) {
top: el_height / 2 - popover_height / 2,
left: -(popover_width + arrow_offset),
};
- arrow_placement = 'right';
+ arrow_placement = "right";
break;
case BOTTOM:
@@ -121,7 +121,7 @@ function place_popover(hotspot) {
top: el_height + arrow_offset,
left: el_width / 2 - popover_width / 2,
};
- arrow_placement = 'top';
+ arrow_placement = "top";
break;
case RIGHT:
@@ -129,7 +129,7 @@ function place_popover(hotspot) {
top: el_height / 2 - popover_height / 2,
left: el_width + arrow_offset,
};
- arrow_placement = 'left';
+ arrow_placement = "left";
break;
case LEFT_BOTTOM:
@@ -137,7 +137,7 @@ function place_popover(hotspot) {
top: 0,
left: -(popover_width + arrow_offset / 2),
};
- arrow_placement = '';
+ arrow_placement = "";
break;
case VIEWPORT_CENTER:
@@ -145,47 +145,47 @@ function place_popover(hotspot) {
top: el_height / 2,
left: el_width / 2,
};
- arrow_placement = '';
+ arrow_placement = "";
break;
default:
blueslip.error(
- 'Invalid popover placement value for hotspot \'' +
- hotspot.name + '\'',
+ "Invalid popover placement value for hotspot '" +
+ hotspot.name + "'",
);
break;
}
// position arrow
- arrow_placement = 'arrow-' + arrow_placement;
- $('#hotspot_' + hotspot.name + '_overlay .hotspot-popover')
- .removeClass('arrow-top arrow-left arrow-bottom arrow-right')
+ arrow_placement = "arrow-" + arrow_placement;
+ $("#hotspot_" + hotspot.name + "_overlay .hotspot-popover")
+ .removeClass("arrow-top arrow-left arrow-bottom arrow-right")
.addClass(arrow_placement);
// position popover
let popover_placement;
if (orientation === VIEWPORT_CENTER) {
popover_placement = {
- top: '45%',
- left: '50%',
- transform: 'translate(-50%, -50%)',
+ top: "45%",
+ left: "50%",
+ transform: "translate(-50%, -50%)",
};
} else {
const client_rect = $(hotspot.location.element).get(0).getBoundingClientRect();
popover_placement = {
top: client_rect.top + popover_offset.top,
left: client_rect.left + popover_offset.left,
- transform: '',
+ transform: "",
};
}
- $('#hotspot_' + hotspot.name + '_overlay .hotspot-popover')
+ $("#hotspot_" + hotspot.name + "_overlay .hotspot-popover")
.css(popover_placement);
}
function insert_hotspot_into_DOM(hotspot) {
if (hotspot.name === "intro_reply") {
- $('#bottom_whitespace').append(render_intro_reply_hotspot({}));
+ $("#bottom_whitespace").append(render_intro_reply_hotspot({}));
return;
}
@@ -201,17 +201,17 @@ function insert_hotspot_into_DOM(hotspot) {
'<span class="dot"></span>' +
'<span class="pulse"></span>' +
'<div class="bounce"><span class="bounce-icon">?</span></div>' +
- '</div>';
+ "</div>";
setTimeout(() => {
- $('body').prepend(hotspot_icon_HTML);
- $('body').prepend(hotspot_overlay_HTML);
+ $("body").prepend(hotspot_icon_HTML);
+ $("body").prepend(hotspot_overlay_HTML);
if (place_icon(hotspot)) {
place_popover(hotspot);
}
// reposition on any event that might update the UI
- ['resize', 'scroll', 'onkeydown', 'click'].forEach((event_name) => {
+ ["resize", "scroll", "onkeydown", "click"].forEach((event_name) => {
window.addEventListener(event_name, _.debounce(() => {
if (place_icon(hotspot)) {
place_popover(hotspot);
@@ -222,14 +222,14 @@ function insert_hotspot_into_DOM(hotspot) {
}
exports.is_open = function () {
- return $('.hotspot.overlay').hasClass('show');
+ return $(".hotspot.overlay").hasClass("show");
};
exports.close_hotspot_icon = function (elem) {
$(elem).animate({ opacity: 0 }, {
duration: 300,
done: function () {
- $(elem).css({ display: 'none' });
+ $(elem).css({ display: "none" });
}.bind(elem),
});
};
@@ -241,7 +241,7 @@ function close_read_hotspots(new_hotspots) {
);
for (const hotspot_name of unwanted_hotspots) {
- exports.close_hotspot_icon($('#hotspot_' + hotspot_name + '_icon'));
+ exports.close_hotspot_icon($("#hotspot_" + hotspot_name + "_icon"));
}
}
diff --git a/static/js/i18n.js b/static/js/i18n.js
index 5c90fc12ea5..e4099a6bb07 100644
--- a/static/js/i18n.js
+++ b/static/js/i18n.js
@@ -1,7 +1,7 @@
-import i18next from 'i18next';
+import i18next from "i18next";
i18next.init({
- lng: 'lang',
+ lng: "lang",
resources: {
lang: {
translation: page_params.translation_data,
diff --git a/static/js/info_overlay.js b/static/js/info_overlay.js
index b073c5dacab..080a0dd8bea 100644
--- a/static/js/info_overlay.js
+++ b/static/js/info_overlay.js
@@ -20,11 +20,11 @@ exports.set_up_toggler = function () {
exports.toggler = components.toggle(opts);
const elem = exports.toggler.get();
- elem.addClass('large allow-overflow');
+ elem.addClass("large allow-overflow");
const modals = opts.values.map((item) => {
const key = item.key; // e.g. message-formatting
- const modal = $('#' + key).find('.modal-body');
+ const modal = $("#" + key).find(".modal-body");
return modal;
});
@@ -54,7 +54,7 @@ exports.show = function (target) {
if (!overlay.hasClass("show")) {
overlays.open_overlay({
- name: 'informationalOverlays',
+ name: "informationalOverlays",
overlay: overlay,
on_close: function () {
hashchange.changehash("");
diff --git a/static/js/input_pill.js b/static/js/input_pill.js
index d5f94057753..8dfd64f0c4f 100644
--- a/static/js/input_pill.js
+++ b/static/js/input_pill.js
@@ -1,4 +1,4 @@
-const render_input_pill = require('../templates/input_pill.hbs');
+const render_input_pill = require("../templates/input_pill.hbs");
// See https://zulip.readthedocs.io/en/latest/subsystems/input-pills.html
exports.random_id = function () {
@@ -17,17 +17,17 @@ exports.create = function (opts) {
};
if (!opts.container) {
- blueslip.error('Pill needs container.');
+ blueslip.error("Pill needs container.");
return;
}
if (!opts.create_item_from_text) {
- blueslip.error('Pill needs create_item_from_text');
+ blueslip.error("Pill needs create_item_from_text");
return;
}
if (!opts.get_text_from_item) {
- blueslip.error('Pill needs get_text_from_item');
+ blueslip.error("Pill needs get_text_from_item");
return;
}
@@ -64,7 +64,7 @@ exports.create = function (opts) {
// in out widget that hasn't been turned into
// pills. We use it to decide things like
// whether we're ready to send typing indicators.
- return store.$input.text().trim() !== '';
+ return store.$input.text().trim() !== "";
},
create_item: function (text) {
@@ -89,7 +89,7 @@ exports.create = function (opts) {
const id = exports.random_id();
if (!item.display_value) {
- blueslip.error('no display_value returned');
+ blueslip.error("no display_value returned");
return;
}
@@ -330,7 +330,7 @@ exports.create = function (opts) {
e.preventDefault();
// get text representation of clipboard
- const text = (e.originalEvent || e).clipboardData.getData('text/plain');
+ const text = (e.originalEvent || e).clipboardData.getData("text/plain");
// insert text manually
document.execCommand("insertText", false, text);
diff --git a/static/js/invite.js b/static/js/invite.js
index ef1ec0d51d2..9bad326f660 100644
--- a/static/js/invite.js
+++ b/static/js/invite.js
@@ -1,29 +1,29 @@
const render_invitation_failed_error = require("../templates/invitation_failed_error.hbs");
-const render_invite_subscription = require('../templates/invite_subscription.hbs');
-const render_settings_dev_env_email_access = require('../templates/settings/dev_env_email_access.hbs');
+const render_invite_subscription = require("../templates/invite_subscription.hbs");
+const render_settings_dev_env_email_access = require("../templates/settings/dev_env_email_access.hbs");
-const autosize = require('autosize');
+const autosize = require("autosize");
function reset_error_messages() {
- $('#invite_status').hide().text('').removeClass(common.status_classes);
- $('#multiuse_invite_status').hide().text('').removeClass(common.status_classes);
+ $("#invite_status").hide().text("").removeClass(common.status_classes);
+ $("#multiuse_invite_status").hide().text("").removeClass(common.status_classes);
- $("#invitee_emails").closest('.control-group').removeClass('warning error');
+ $("#invitee_emails").closest(".control-group").removeClass("warning error");
if (page_params.development_environment) {
- $('#dev_env_msg').hide().text('').removeClass(common.status_classes);
+ $("#dev_env_msg").hide().text("").removeClass(common.status_classes);
}
}
function get_common_invitation_data() {
- const invite_as = parseInt($('#invite_as').val(), 10);
+ const invite_as = parseInt($("#invite_as").val(), 10);
const stream_ids = [];
$("#invite-stream-checkboxes input:checked").each(function () {
const stream_id = parseInt($(this).val(), 10);
stream_ids.push(stream_id);
});
const data = {
- csrfmiddlewaretoken: $('input[name="csrfmiddlewaretoken"]').attr('value'),
+ csrfmiddlewaretoken: $('input[name="csrfmiddlewaretoken"]').attr("value"),
invite_as: invite_as,
stream_ids: JSON.stringify(stream_ids),
};
@@ -37,14 +37,14 @@ function beforeSend() {
// aren't in the right domain, etc.)
//
// OR, you could just let the server do it. Probably my temptation.
- $('#submit-invitation').button('loading');
+ $("#submit-invitation").button("loading");
return true;
}
function submit_invitation_form() {
- const invite_status = $('#invite_status');
+ const invite_status = $("#invite_status");
const invitee_emails = $("#invitee_emails");
- const invitee_emails_group = invitee_emails.closest('.control-group');
+ const invitee_emails_group = invitee_emails.closest(".control-group");
const data = get_common_invitation_data();
data.invitee_emails = $("#invitee_emails").val();
@@ -53,13 +53,13 @@ function submit_invitation_form() {
data: data,
beforeSend: beforeSend,
success: function () {
- ui_report.success(i18n.t('User(s) invited successfully.'), invite_status);
- invitee_emails_group.removeClass('warning');
- invitee_emails.val('');
+ ui_report.success(i18n.t("User(s) invited successfully."), invite_status);
+ invitee_emails_group.removeClass("warning");
+ invitee_emails.val("");
if (page_params.development_environment) {
const rendered_email_msg = render_settings_dev_env_email_access();
- $('#dev_env_msg').html(rendered_email_msg).addClass('alert-info').show();
+ $("#dev_env_msg").html(rendered_email_msg).addClass("alert-info").show();
}
},
@@ -89,21 +89,21 @@ function submit_invitation_form() {
is_invitee_deactivated: is_invitee_deactivated,
});
ui_report.message(error_response, invite_status, "alert-warning");
- invitee_emails_group.addClass('warning');
+ invitee_emails_group.addClass("warning");
if (arr.sent_invitations) {
- invitee_emails.val(invitee_emails_errored.join('\n'));
+ invitee_emails.val(invitee_emails_errored.join("\n"));
}
}
},
complete: function () {
- $('#submit-invitation').button('reset');
+ $("#submit-invitation").button("reset");
},
});
}
function generate_multiuse_invite() {
- const invite_status = $('#multiuse_invite_status');
+ const invite_status = $("#multiuse_invite_status");
const data = get_common_invitation_data();
channel.post({
url: "/json/invites/multiuse",
@@ -117,7 +117,7 @@ function generate_multiuse_invite() {
ui_report.error("", xhr, invite_status);
},
complete: function () {
- $('#submit-invitation').button('reset');
+ $("#submit-invitation").button("reset");
},
});
}
@@ -138,7 +138,7 @@ function update_subscription_checkboxes() {
notifications_stream: stream_data.get_notifications_stream(),
};
const html = render_invite_subscription(data);
- $('#streams_to_add').html(html);
+ $("#streams_to_add").html(html);
}
function prepare_form_to_be_shown() {
@@ -147,13 +147,13 @@ function prepare_form_to_be_shown() {
}
exports.launch = function () {
- $('#submit-invitation').button();
+ $("#submit-invitation").button();
prepare_form_to_be_shown();
autosize($("#invitee_emails").focus());
overlays.open_overlay({
- name: 'invite',
- overlay: $('#invite-user'),
+ name: "invite",
+ overlay: $("#invite-user"),
on_close: function () {
hashchange.exit_overlay();
},
@@ -161,18 +161,18 @@ exports.launch = function () {
};
exports.initialize = function () {
- $(document).on('click', '.invite_check_all_button', (e) => {
- $('#streams_to_add :checkbox').prop('checked', true);
+ $(document).on("click", ".invite_check_all_button", (e) => {
+ $("#streams_to_add :checkbox").prop("checked", true);
e.preventDefault();
});
- $(document).on('click', '.invite_uncheck_all_button', (e) => {
- $('#streams_to_add :checkbox').prop('checked', false);
+ $(document).on("click", ".invite_uncheck_all_button", (e) => {
+ $("#streams_to_add :checkbox").prop("checked", false);
e.preventDefault();
});
$("#submit-invitation").on("click", () => {
- const is_generate_invite_link = $('#generate_multiuse_invite_radio').prop('checked');
+ const is_generate_invite_link = $("#generate_multiuse_invite_radio").prop("checked");
if (is_generate_invite_link) {
generate_multiuse_invite();
} else {
@@ -184,16 +184,16 @@ exports.initialize = function () {
$("#generate_multiuse_invite_radio").prop("checked", true);
$("#multiuse_radio_section").show();
$("#invite-method-choice").hide();
- $('#invitee_emails').prop('disabled', true);
- $('#submit-invitation').text(i18n.t('Generate invite link'));
- $('#submit-invitation').data('loading-text', i18n.t('Generating link...'));
+ $("#invitee_emails").prop("disabled", true);
+ $("#submit-invitation").text(i18n.t("Generate invite link"));
+ $("#submit-invitation").data("loading-text", i18n.t("Generating link..."));
reset_error_messages();
});
- $('#invite-user').on('change', '#generate_multiuse_invite_radio', () => {
- $('#invitee_emails').prop('disabled', false);
- $('#submit-invitation').text(i18n.t('Invite'));
- $('#submit-invitation').data('loading-text', i18n.t('Inviting...'));
+ $("#invite-user").on("change", "#generate_multiuse_invite_radio", () => {
+ $("#invitee_emails").prop("disabled", false);
+ $("#submit-invitation").text(i18n.t("Invite"));
+ $("#submit-invitation").data("loading-text", i18n.t("Inviting..."));
$("#multiuse_radio_section").hide();
$("#invite-method-choice").show();
reset_error_messages();
diff --git a/static/js/keydown_util.js b/static/js/keydown_util.js
index e1c1bc793a1..7244b75bada 100644
--- a/static/js/keydown_util.js
+++ b/static/js/keydown_util.js
@@ -3,11 +3,11 @@
*/
const keys = {
- 13: 'enter_key',
- 37: 'left_arrow',
- 38: 'up_arrow',
- 39: 'right_arrow',
- 40: 'down_arrow',
+ 13: "enter_key",
+ 37: "left_arrow",
+ 38: "up_arrow",
+ 39: "right_arrow",
+ 40: "down_arrow",
};
exports.handle = function (opts) {
diff --git a/static/js/lazy_set.js b/static/js/lazy_set.js
index c61aca18ee0..4b765f1dc3d 100644
--- a/static/js/lazy_set.js
+++ b/static/js/lazy_set.js
@@ -72,8 +72,8 @@ export class LazySet {
}
_clean(v) {
- if (typeof v !== 'number') {
- blueslip.error('not a number');
+ if (typeof v !== "number") {
+ blueslip.error("not a number");
return parseInt(v, 10);
}
return v;
diff --git a/static/js/lightbox.js b/static/js/lightbox.js
index b27b1a15e41..4e73c261c2e 100644
--- a/static/js/lightbox.js
+++ b/static/js/lightbox.js
@@ -126,7 +126,7 @@ exports.open = function ($image) {
}
overlays.open_overlay({
- name: 'lightbox',
+ name: "lightbox",
overlay: $("#lightbox_overlay"),
on_close: lightbox_close_overlay,
});
@@ -270,7 +270,7 @@ exports.initialize = function () {
$("#lightbox_overlay").on("click", ".image-list .image", function () {
const $image_list = $(this).parent();
- const $original_image = $(".message_row img[src='" + $(this).attr('data-src') + "']");
+ const $original_image = $(".message_row img[src='" + $(this).attr("data-src") + "']");
exports.open($original_image);
@@ -298,9 +298,9 @@ exports.initialize = function () {
$("#lightbox_overlay").on("click", ".center .arrow", function () {
const direction = $(this).attr("data-direction");
- if (direction === 'next') {
+ if (direction === "next") {
exports.next();
- } else if (direction === 'prev') {
+ } else if (direction === "prev") {
exports.prev();
}
});
diff --git a/static/js/lightbox_canvas.js b/static/js/lightbox_canvas.js
index 3f21ad1911c..e20710abf1a 100644
--- a/static/js/lightbox_canvas.js
+++ b/static/js/lightbox_canvas.js
@@ -32,9 +32,9 @@ window.onload = function () {
const funcs = {
setZoom: function (meta, zoom) {
// condition to handle zooming event by zoom hotkeys
- if (zoom === '+') {
+ if (zoom === "+") {
zoom = meta.zoom * 1.2;
- } else if (zoom === '-') {
+ } else if (zoom === "-") {
zoom = meta.zoom / 1.2;
}
// make sure the zoom is above 1 and below the maxZoom.
@@ -145,18 +145,18 @@ const funcs = {
// that the LightboxCanvas instance created in lightbox.js can be
// accessed from hotkey.js. Major code refactoring is required in lightbox.js
// to implement these keyboard shortcuts in hotkey.js
- document.addEventListener('keydown', (e) => {
+ document.addEventListener("keydown", (e) => {
if (!overlays.lightbox_open()) {
return;
}
- if (e.key === "Z" || e.key === '+') {
- funcs.setZoom(meta, '+');
+ if (e.key === "Z" || e.key === "+") {
+ funcs.setZoom(meta, "+");
funcs.displayImage(canvas, context, meta);
- } else if (e.key === "z" || e.key === '-') {
- funcs.setZoom(meta, '-');
+ } else if (e.key === "z" || e.key === "-") {
+ funcs.setZoom(meta, "-");
funcs.displayImage(canvas, context, meta);
- } else if (e.key === 'v') {
- overlays.close_overlay('lightbox');
+ } else if (e.key === "v") {
+ overlays.close_overlay("lightbox");
}
e.preventDefault();
e.stopPropagation();
diff --git a/static/js/list_cursor.js b/static/js/list_cursor.js
index 82e0907ab82..465ceab5066 100644
--- a/static/js/list_cursor.js
+++ b/static/js/list_cursor.js
@@ -12,7 +12,7 @@ const list_cursor = function (opts) {
;
if (!config_ok) {
- blueslip.error('Programming error');
+ blueslip.error("Programming error");
return;
}
@@ -84,7 +84,7 @@ const list_cursor = function (opts) {
self.go_to = function (key) {
if (key === undefined) {
- blueslip.error('Caller is not checking keys for list_cursor.go_to');
+ blueslip.error("Caller is not checking keys for list_cursor.go_to");
return;
}
if (key === self.curr_key) {
@@ -93,7 +93,7 @@ const list_cursor = function (opts) {
self.clear();
const row = self.get_row(key);
if (row === undefined) {
- blueslip.error('Cannot highlight key for list_cursor: ' + key);
+ blueslip.error("Cannot highlight key for list_cursor: " + key);
return;
}
self.curr_key = key;
diff --git a/static/js/list_render.js b/static/js/list_render.js
index 014b9323e1c..eda81d9b9b6 100644
--- a/static/js/list_render.js
+++ b/static/js/list_render.js
@@ -11,14 +11,14 @@ const DEFAULTS = {
// ----------------------------------------------------
exports.validate_opts = (opts) => {
- if (opts.html_selector && typeof opts.html_selector !== 'function') {
+ if (opts.html_selector && typeof opts.html_selector !== "function") {
// We have an html_selector, but it is not a function.
// This is a programming error.
- blueslip.error('html_selector should be a function.');
+ blueslip.error("html_selector should be a function.");
return false;
}
if (!opts.simplebar_container) {
- blueslip.error('simplebar_container is missing.');
+ blueslip.error("simplebar_container is missing.");
return false;
}
return true;
@@ -96,17 +96,17 @@ exports.valid_filter_opts = (opts) => {
return true;
}
if (opts.filter.predicate) {
- if (typeof opts.filter.predicate !== 'function') {
- blueslip.error('Filter predicate is not a function.');
+ if (typeof opts.filter.predicate !== "function") {
+ blueslip.error("Filter predicate is not a function.");
return false;
}
if (opts.filter.filterer) {
- blueslip.error('Filterer and predicate are mutually exclusive.');
+ blueslip.error("Filterer and predicate are mutually exclusive.");
return false;
}
} else {
- if (typeof opts.filter.filterer !== 'function') {
- blueslip.error('Filter filterer is not a function (or missing).');
+ if (typeof opts.filter.filterer !== "function") {
+ blueslip.error("Filter filterer is not a function (or missing).");
return false;
}
}
@@ -120,7 +120,7 @@ exports.valid_filter_opts = (opts) => {
// opts: An object of random preferences.
exports.create = function ($container, list, opts) {
if (!opts) {
- blueslip.error('Need opts to create widget.');
+ blueslip.error("Need opts to create widget.");
return;
}
@@ -145,15 +145,15 @@ exports.create = function ($container, list, opts) {
list: list,
filtered_list: list,
reverse_mode: false,
- filter_value: '',
+ filter_value: "",
};
if (!exports.valid_filter_opts(opts)) {
return;
}
- if (opts.get_item && typeof opts.get_item !== 'function') {
- blueslip.error('get_item should be a function');
+ if (opts.get_item && typeof opts.get_item !== "function") {
+ blueslip.error("get_item should be a function");
return;
}
@@ -190,13 +190,13 @@ exports.create = function ($container, list, opts) {
const slice = meta.filtered_list.slice(meta.offset, meta.offset + load_count);
- const finish = blueslip.start_timing('list_render ' + opts.name);
+ const finish = blueslip.start_timing("list_render " + opts.name);
let html = "";
for (const item of slice) {
const s = opts.modifier(item);
- if (typeof s !== 'string') {
- blueslip.error('List item is not a string: ' + s);
+ if (typeof s !== "string") {
+ blueslip.error("List item is not a string: " + s);
continue;
}
@@ -228,8 +228,8 @@ exports.create = function ($container, list, opts) {
item = opts.get_item(item);
}
const html = opts.modifier(item);
- if (typeof html !== 'string') {
- blueslip.error('List item is not a string: ' + html);
+ if (typeof html !== "string") {
+ blueslip.error("List item is not a string: " + html);
return;
}
@@ -272,20 +272,20 @@ exports.create = function ($container, list, opts) {
// on scroll of the nearest scrolling container, if it hits the bottom
// of the container then fetch a new block of items and render them.
- meta.scroll_container.on('scroll.list_widget_container', function () {
+ meta.scroll_container.on("scroll.list_widget_container", function () {
if (this.scrollHeight - (this.scrollTop + this.clientHeight) < 10) {
widget.render();
}
});
if (opts.parent_container) {
- opts.parent_container.on('click.list_widget_sort', "[data-sort]", function () {
+ opts.parent_container.on("click.list_widget_sort", "[data-sort]", function () {
exports.handle_sort($(this), widget);
});
}
if (opts.filter && opts.filter.element) {
- opts.filter.element.on('input.list_widget_filter', function () {
+ opts.filter.element.on("input.list_widget_filter", function () {
const value = this.value.toLocaleLowerCase();
widget.set_filter_value(value);
widget.hard_redraw();
@@ -294,14 +294,14 @@ exports.create = function ($container, list, opts) {
};
widget.clear_event_handlers = function () {
- meta.scroll_container.off('scroll.list_widget_container');
+ meta.scroll_container.off("scroll.list_widget_container");
if (opts.parent_container) {
- opts.parent_container.off('click.list_widget_sort', "[data-sort]");
+ opts.parent_container.off("click.list_widget_sort", "[data-sort]");
}
if (opts.filter && opts.filter.element) {
- opts.filter.element.off('input.list_widget_filter');
+ opts.filter.element.off("input.list_widget_filter");
}
};
diff --git a/static/js/loading.js b/static/js/loading.js
index 75927ae4d51..ad33ed5bf0e 100644
--- a/static/js/loading.js
+++ b/static/js/loading.js
@@ -9,14 +9,14 @@ exports.make_indicator = function (outer_container, opts) {
// width calculation, above, returns a result that's a few pixels
// too small. The container's div will be slightly too small,
// but that's probably OK for our purposes.
- outer_container.css({'white-space': 'nowrap'});
+ outer_container.css({"white-space": "nowrap"});
container.empty();
if (opts.abs_positioned !== undefined && opts.abs_positioned) {
// Create some additional containers to facilitate absolutely
// positioned spinners.
- const container_id = container.attr('id');
+ const container_id = container.attr("id");
let inner_container = $('<div id="' + container_id + '_box_container"></div>');
container.append(inner_container);
container = inner_container;
@@ -30,7 +30,7 @@ exports.make_indicator = function (outer_container, opts) {
container.append(spinner_elem);
let text_width = 0;
- if (opts.text !== undefined && opts.text !== '') {
+ if (opts.text !== undefined && opts.text !== "") {
const text_elem = $('<span class="loading_indicator_text"></span>');
text_elem.text(opts.text);
container.append(text_elem);
@@ -60,7 +60,7 @@ exports.destroy_indicator = function (container) {
}
container.removeData("spinner_obj");
container.empty();
- container.css({width: 0, height: 0, display: 'none'});
+ container.css({width: 0, height: 0, display: "none"});
};
diff --git a/static/js/local_message.js b/static/js/local_message.js
index ddc55449237..e1bbcb43cd4 100644
--- a/static/js/local_message.js
+++ b/static/js/local_message.js
@@ -22,7 +22,7 @@ exports.get_next_id_float = (function () {
return function () {
const local_id_increment = 0.01;
let latest = page_params.max_message_id;
- if (typeof message_list.all !== 'undefined' && message_list.all.last() !== undefined) {
+ if (typeof message_list.all !== "undefined" && message_list.all.last() !== undefined) {
latest = message_list.all.last().id;
}
latest = Math.max(0, latest);
diff --git a/static/js/markdown.js b/static/js/markdown.js
index af4179fa4ad..38b51fd108a 100644
--- a/static/js/markdown.js
+++ b/static/js/markdown.js
@@ -33,7 +33,7 @@ exports.translate_emoticons_to_names = (text) => {
let translated = text;
let replacement_text;
const terminal_symbols = ',.;?!()[] "\'\n\t'; // From composebox_typeahead
- const symbols_except_space = terminal_symbols.replace(' ', '');
+ const symbols_except_space = terminal_symbols.replace(" ", "");
const emoticon_replacer = function (match, g1, offset, str) {
const prev_char = str[offset - 1];
@@ -89,11 +89,11 @@ exports.apply_markdown = function (message) {
const options = {
userMentionHandler: function (mention, silently) {
- if (mention === 'all' || mention === 'everyone' || mention === 'stream') {
+ if (mention === "all" || mention === "everyone" || mention === "stream") {
message.mentioned = true;
return '<span class="user-mention" data-user-id="*">' +
- '@' + mention +
- '</span>';
+ "@" + mention +
+ "</span>";
}
let full_name;
@@ -149,7 +149,7 @@ exports.apply_markdown = function (message) {
message.mentioned = true;
message.mentioned_me_directly = true;
}
- let str = '';
+ let str = "";
if (silently) {
str += '<span class="user-mention silent" data-user-id="' + user_id + '">';
} else {
@@ -159,7 +159,7 @@ exports.apply_markdown = function (message) {
// If I mention "@aLiCe sMITH", I still want "Alice Smith" to
// show in the pill.
const actual_full_name = helpers.get_actual_name_from_user_id(user_id);
- return str + _.escape(actual_full_name) + '</span>';
+ return str + _.escape(actual_full_name) + "</span>";
},
groupMentionHandler: function (name) {
const group = helpers.get_user_group_from_name(name);
@@ -168,8 +168,8 @@ exports.apply_markdown = function (message) {
message.mentioned = true;
}
return '<span class="user-group-mention" data-user-group-id="' + group.id + '">' +
- '@' + _.escape(group.name) +
- '</span>';
+ "@" + _.escape(group.name) +
+ "</span>";
}
return;
},
@@ -178,7 +178,7 @@ exports.apply_markdown = function (message) {
const user_mention_re = /<span.*user-mention.*data-user-id="(\d+|\*)"[^>]*>@/gm;
quote = quote.replace(user_mention_re, (match) => {
match = match.replace(/"user-mention"/g, '"user-mention silent"');
- match = match.replace(/>@/g, '>');
+ match = match.replace(/>@/g, ">");
return match;
});
// In most cases, if you are being mentioned in the message you're quoting, you wouldn't
@@ -191,12 +191,12 @@ exports.apply_markdown = function (message) {
},
};
// Our python-markdown processor appends two \n\n to input
- message.content = marked(message.raw_content + '\n\n', options).trim();
+ message.content = marked(message.raw_content + "\n\n", options).trim();
message.is_me_message = exports.is_status_message(message.raw_content);
};
exports.add_topic_links = function (message) {
- if (message.type !== 'stream') {
+ if (message.type !== "stream") {
message.topic_links = [];
return;
}
@@ -233,14 +233,14 @@ exports.add_topic_links = function (message) {
};
exports.is_status_message = function (raw_content) {
- return raw_content.startsWith('/me ');
+ return raw_content.startsWith("/me ");
};
function make_emoji_span(codepoint, title, alt_text) {
return '<span aria-label="' + title + '"' +
' class="emoji emoji-' + codepoint + '"' +
' role="img" title="' + title + '">' + alt_text +
- '</span>';
+ "</span>";
}
function handleUnicodeEmoji(unicode_emoji) {
@@ -248,7 +248,7 @@ function handleUnicodeEmoji(unicode_emoji) {
const emoji_name = helpers.get_emoji_name(codepoint);
if (emoji_name) {
- const alt_text = ':' + emoji_name + ':';
+ const alt_text = ":" + emoji_name + ":";
const title = emoji_name.split("_").join(" ");
return make_emoji_span(codepoint, title, alt_text);
}
@@ -257,7 +257,7 @@ function handleUnicodeEmoji(unicode_emoji) {
}
function handleEmoji(emoji_name) {
- const alt_text = ':' + emoji_name + ':';
+ const alt_text = ":" + emoji_name + ":";
const title = emoji_name.split("_").join(" ");
// Zulip supports both standard/unicode emoji, served by a
@@ -309,7 +309,7 @@ function handleTimestamp(time) {
// Use html5 <time> tag for valid timestamps.
// render time without milliseconds.
- const escaped_isotime = _.escape(timeobject.toISOString().split('.')[0] + 'Z');
+ const escaped_isotime = _.escape(timeobject.toISOString().split(".")[0] + "Z");
return `<time datetime="${escaped_isotime}">${escaped_time}</time>`;
}
@@ -321,7 +321,7 @@ function handleStream(stream_name) {
const href = helpers.stream_hash(stream.stream_id);
return '<a class="stream" data-stream-id="' + stream.stream_id + '" ' +
'href="/' + href + '"' +
- '>' + '#' + _.escape(stream.name) + '</a>';
+ ">" + "#" + _.escape(stream.name) + "</a>";
}
function handleStreamTopic(stream_name, topic) {
@@ -330,9 +330,9 @@ function handleStreamTopic(stream_name, topic) {
return;
}
const href = helpers.stream_topic_hash(stream.stream_id, topic);
- const text = '#' + _.escape(stream.name) + ' > ' + _.escape(topic);
+ const text = "#" + _.escape(stream.name) + " > " + _.escape(topic);
return '<a class="stream-topic" data-stream-id="' + stream.stream_id + '" ' +
- 'href="/' + href + '"' + '>' + text + '</a>';
+ 'href="/' + href + '"' + ">" + text + "</a>";
}
function handleRealmFilter(pattern, matches) {
@@ -353,8 +353,8 @@ function handleTex(tex, fullmatch) {
try {
return katex.renderToString(tex);
} catch (ex) {
- if (ex.message.startsWith('KaTeX parse error')) { // TeX syntax error
- return '<span class="tex-error">' + _.escape(fullmatch) + '</span>';
+ if (ex.message.startsWith("KaTeX parse error")) { // TeX syntax error
+ return '<span class="tex-error">' + _.escape(fullmatch) + "</span>";
}
blueslip.error(ex);
}
@@ -369,9 +369,9 @@ function python_to_js_filter(pattern, url) {
while (match) {
const name = match[1];
// Replace named group with regular matching group
- pattern = pattern.replace('(?P<' + name + '>', '(');
+ pattern = pattern.replace("(?P<" + name + ">", "(");
// Replace named reference in url to numbered reference
- url = url.replace('%(' + name + ')s', '\\' + current_group);
+ url = url.replace("%(" + name + ")s", "\\" + current_group);
// Reset the RegExp state
named_group_re.lastIndex = 0;
@@ -380,7 +380,7 @@ function python_to_js_filter(pattern, url) {
current_group += 1;
}
// Convert any python in-regex flags to RegExp flags
- let js_flags = 'g';
+ let js_flags = "g";
const inline_flag_re = /\(\?([iLmsux]+)\)/;
match = inline_flag_re.exec(pattern);
@@ -413,7 +413,7 @@ function python_to_js_filter(pattern, url) {
// We have an error computing the generated regex syntax.
// We'll ignore this realm filter for now, but log this
// failure for debugging later.
- blueslip.error('python_to_js_filter: ' + ex.message);
+ blueslip.error("python_to_js_filter: " + ex.message);
}
return [final_regex, url];
}
@@ -454,7 +454,7 @@ exports.initialize = function (realm_filters, helper_config) {
// No <code> around our code blocks instead a codehilite <div> and disable
// class-specific highlighting.
- r.code = (code) => fenced_code.wrap_code(code) + '\n\n';
+ r.code = (code) => fenced_code.wrap_code(code) + "\n\n";
// Prohibit empty links for some reason.
const old_link = r.link;
@@ -462,7 +462,7 @@ exports.initialize = function (realm_filters, helper_config) {
// Put a newline after a <br> in the generated HTML to match markdown
r.br = function () {
- return '<br>\n';
+ return "<br>\n";
};
function preprocess_code_blocks(src) {
@@ -481,7 +481,7 @@ exports.initialize = function (realm_filters, helper_config) {
// Disable lheadings
// We only keep the # Heading format.
- disable_markdown_regex(marked.Lexer.rules.tables, 'lheading');
+ disable_markdown_regex(marked.Lexer.rules.tables, "lheading");
// Disable __strong__ (keeping **strong**)
marked.InlineLexer.rules.zulip.strong = /^\*\*([\s\S]+?)\*\*(?!\*)/;
@@ -495,7 +495,7 @@ exports.initialize = function (realm_filters, helper_config) {
marked.InlineLexer.rules.zulip.em = /^\*(?!\s+)((?:\*\*|[\s\S])+?)((?:[\S]))\*(?!\*)/;
// Disable autolink as (a) it is not used in our backend and (b) it interferes with @mentions
- disable_markdown_regex(marked.InlineLexer.rules.zulip, 'autolink');
+ disable_markdown_regex(marked.InlineLexer.rules.zulip, "autolink");
exports.update_realm_filter_rules(realm_filters);
diff --git a/static/js/message_edit.js b/static/js/message_edit.js
index 04daa9d6885..769c45842d1 100644
--- a/static/js/message_edit.js
+++ b/static/js/message_edit.js
@@ -1,5 +1,5 @@
-const render_message_edit_form = require('../templates/message_edit_form.hbs');
-const render_topic_edit_form = require('../templates/topic_edit_form.hbs');
+const render_message_edit_form = require("../templates/message_edit_form.hbs");
+const render_topic_edit_form = require("../templates/topic_edit_form.hbs");
const currently_editing_messages = new Map();
let currently_deleting_messages = [];
@@ -94,7 +94,7 @@ function get_editability(message, edit_limit_seconds_buffer) {
}
// time's up!
- if (message.type === 'stream') {
+ if (message.type === "stream") {
return editability_types.TOPIC_ONLY;
}
return editability_types.NO_LONGER;
@@ -149,19 +149,19 @@ exports.show_topic_edit_spinner = function (row) {
};
exports.end_if_focused_on_inline_topic_edit = function () {
- const focused_elem = $(".topic_edit_form").find(':focus');
+ const focused_elem = $(".topic_edit_form").find(":focus");
if (focused_elem.length === 1) {
focused_elem.blur();
- const recipient_row = focused_elem.closest('.recipient_row');
+ const recipient_row = focused_elem.closest(".recipient_row");
exports.end_inline_topic_edit(recipient_row);
}
};
exports.end_if_focused_on_message_row_edit = function () {
- const focused_elem = $(".message_edit").find(':focus');
+ const focused_elem = $(".message_edit").find(":focus");
if (focused_elem.length === 1) {
focused_elem.blur();
- const row = focused_elem.closest('.message_row');
+ const row = focused_elem.closest(".message_row");
exports.end_message_row_edit(row);
}
};
@@ -175,7 +175,7 @@ function handle_message_row_edit_keydown(e) {
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") {
+ 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
@@ -242,7 +242,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]
+ const content_top = row.find(".message_top_line")[0]
.getBoundingClientRect().top;
const message = current_msg_list.get(rows.id(row));
@@ -274,7 +274,7 @@ function edit_message(row, raw_content) {
.filter((s) => s.stream_id !== message.stream_id) : null;
const form = $(render_message_edit_form({
- is_stream: message.type === 'stream',
+ is_stream: message.type === "stream",
message_id: message.id,
is_editable: is_editable,
is_content_editable: editability === exports.editability_types.FULL,
@@ -298,16 +298,16 @@ function edit_message(row, raw_content) {
form.keydown(handle_message_row_edit_keydown);
- upload.feature_check($('#attach_files_' + rows.id(row)));
+ upload.feature_check($("#attach_files_" + rows.id(row)));
const message_edit_stream = row.find("#select_stream_id_" + message.id);
const stream_header_colorblock = row.find(".stream_header_colorblock");
- const message_edit_content = row.find('textarea.message_edit_content');
- const message_edit_topic = row.find('input.message_edit_topic');
- const message_edit_topic_propagate = row.find('select.message_edit_topic_propagate');
- const message_edit_breadcrumb_messages = row.find('div.message_edit_breadcrumb_messages');
- const message_edit_countdown_timer = row.find('.message_edit_countdown_timer');
- const copy_message = row.find('.copy_message');
+ const message_edit_content = row.find("textarea.message_edit_content");
+ const message_edit_topic = row.find("input.message_edit_topic");
+ const message_edit_topic_propagate = row.find("select.message_edit_topic_propagate");
+ const message_edit_breadcrumb_messages = row.find("div.message_edit_breadcrumb_messages");
+ const message_edit_countdown_timer = row.find(".message_edit_countdown_timer");
+ const copy_message = row.find(".copy_message");
ui_util.decorate_stream_bar(message.stream, stream_header_colorblock, false);
message_edit_stream.change(function () {
@@ -341,10 +341,10 @@ function edit_message(row, raw_content) {
}
composebox_typeahead.initialize_compose_typeahead(edit_id);
compose.handle_keyup(null, $(edit_id).expectOne());
- $(edit_id).on('keydown', function (event) {
+ $(edit_id).on("keydown", function (event) {
compose.handle_keydown(event, $(this).expectOne());
});
- $(edit_id).on('keyup', function (event) {
+ $(edit_id).on("keyup", function (event) {
compose.handle_keyup(event, $(this).expectOne());
});
}
@@ -352,10 +352,10 @@ function edit_message(row, raw_content) {
// Add tooltip
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({
+ row.find(".message-edit-timer-control-group").show();
+ row.find("#message_edit_tooltip").tooltip({
animation: false,
- placement: 'left',
+ placement: "left",
template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div>' +
'<div class="tooltip-inner message-edit-tooltip-inner"></div></div>',
});
@@ -376,7 +376,7 @@ function edit_message(row, raw_content) {
// I believe this needs to be defined outside the countdown_timer, since
// row just refers to something like the currently selected message, and
// can change out from under us
- const message_edit_save = row.find('button.message_edit_save');
+ const message_edit_save = row.find("button.message_edit_save");
// Do this right away, rather than waiting for the timer to do its first update,
// since otherwise there is a noticeable lag
message_edit_countdown_timer.text(timer_text(seconds_left));
@@ -385,7 +385,7 @@ function edit_message(row, raw_content) {
if (seconds_left <= 0) {
clearInterval(countdown_timer);
message_edit_content.prop("readonly", "readonly");
- if (message.type === 'stream') {
+ if (message.type === "stream") {
message_edit_topic.prop("readonly", "readonly");
message_edit_topic_propagate.hide();
message_edit_breadcrumb_messages.hide();
@@ -404,8 +404,8 @@ function edit_message(row, raw_content) {
if (!is_editable) {
row.find(".message_edit_close").focus();
- } else if (message.type === 'stream' && message.topic === compose.empty_topic_placeholder()) {
- message_edit_topic.val('');
+ } else if (message.type === "stream" && message.topic === compose.empty_topic_placeholder()) {
+ message_edit_topic.val("");
message_edit_topic.focus();
} else if (editability === editability_types.TOPIC_ONLY) {
row.find(".message_edit_topic").focus();
@@ -413,7 +413,7 @@ function edit_message(row, raw_content) {
message_edit_content.focus();
// Put cursor at end of input.
const contents = message_edit_content.val();
- message_edit_content.val('');
+ message_edit_content.val("");
message_edit_content.val(contents);
}
@@ -441,7 +441,7 @@ function edit_message(row, raw_content) {
set_propagate_selector_display();
});
- message_edit_stream.on('change', () => {
+ message_edit_stream.on("change", () => {
set_propagate_selector_display();
});
}
@@ -463,7 +463,7 @@ function start_edit_with_content(row, content, edit_box_open_callback) {
}
upload.setup_upload({
- mode: 'edit',
+ mode: "edit",
row: rows.id(row),
});
}
@@ -482,7 +482,7 @@ exports.start = function (row, edit_box_open_callback) {
const msg_list = current_msg_list;
channel.get({
- url: '/json/messages/' + message.id,
+ url: "/json/messages/" + message.id,
idempotent: true,
success: function (data) {
if (current_msg_list === msg_list) {
@@ -501,7 +501,7 @@ exports.start_topic_edit = function (recipient_row) {
const message = current_msg_list.get(msg_id);
let topic = message.topic;
if (topic === compose.empty_topic_placeholder()) {
- topic = '';
+ topic = "";
}
form.find(".inline_topic_edit").val(topic).select().focus();
};
@@ -577,7 +577,7 @@ exports.save_inline_topic_edit = function (row) {
};
channel.patch({
- url: '/json/messages/' + message.id,
+ url: "/json/messages/" + message.id,
data: request,
success: function () {
const spinner = row.find(".topic_edit_spinner");
@@ -589,7 +589,7 @@ exports.save_inline_topic_edit = function (row) {
if (msg_list === current_msg_list) {
message_id = rows.id_for_recipient_row(row);
const message = channel.xhr_error_message(i18n.t("Error saving edit"), xhr);
- row.find(".edit_error").text(message).css('display', 'inline-block');
+ row.find(".edit_error").text(message).css("display", "inline-block");
}
},
});
@@ -638,8 +638,8 @@ exports.save_message_row_edit = function (row) {
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 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;
@@ -703,7 +703,7 @@ exports.save_message_row_edit = function (row) {
}
channel.patch({
- url: '/json/messages/' + message.id,
+ url: "/json/messages/" + message.id,
data: request,
success: function () {
if (edit_locally_echoed) {
@@ -760,7 +760,7 @@ exports.edit_last_sent_message = function () {
}
if (!msg.id) {
- blueslip.error('Message has invalid id in edit_last_sent_message.');
+ blueslip.error("Message has invalid id in edit_last_sent_message.");
return;
}
@@ -773,7 +773,7 @@ exports.edit_last_sent_message = function () {
if (!msg_row) {
// This should never happen, since we got the message above
// from current_msg_list.
- blueslip.error('Could not find row for id ' + msg.id);
+ blueslip.error("Could not find row for id " + msg.id);
return;
}
@@ -782,32 +782,32 @@ exports.edit_last_sent_message = function () {
// Finally do the real work!
compose_actions.cancel();
exports.start(msg_row, () => {
- $('#message_edit_content').focus();
+ $("#message_edit_content").focus();
});
};
function hide_delete_btn_show_spinner(deleting) {
if (deleting) {
- $('do_delete_message_button').attr('disabled', 'disabled');
- $('#delete_message_modal > div.modal-footer > button').hide();
+ $("do_delete_message_button").attr("disabled", "disabled");
+ $("#delete_message_modal > div.modal-footer > button").hide();
const delete_spinner = $("#do_delete_message_spinner");
loading.make_indicator(delete_spinner, { abs_positioned: true });
} else {
loading.destroy_indicator($("#do_delete_message_spinner"));
- $("#do_delete_message_button").prop('disabled', false);
- $('#delete_message_modal > div.modal-footer > button').show();
+ $("#do_delete_message_button").prop("disabled", false);
+ $("#delete_message_modal > div.modal-footer > button").show();
}
}
exports.delete_message = function (msg_id) {
- $("#delete-message-error").html('');
- $('#delete_message_modal').modal("show");
+ $("#delete-message-error").html("");
+ $("#delete_message_modal").modal("show");
if (currently_deleting_messages.includes(msg_id)) {
hide_delete_btn_show_spinner(true);
} else {
hide_delete_btn_show_spinner(false);
}
- $('#do_delete_message_button').off().on('click', (e) => {
+ $("#do_delete_message_button").off().on("click", (e) => {
e.stopPropagation();
e.preventDefault();
currently_deleting_messages.push(msg_id);
@@ -815,7 +815,7 @@ exports.delete_message = function (msg_id) {
channel.del({
url: "/json/messages/" + msg_id,
success: function () {
- $('#delete_message_modal').modal("hide");
+ $("#delete_message_modal").modal("hide");
currently_deleting_messages = currently_deleting_messages.filter(
(id) => id !== msg_id,
);
@@ -841,7 +841,7 @@ exports.delete_topic = function (stream_id, topic_name) {
topic_name: topic_name,
},
success: function () {
- $('#delete_topic_modal').modal('hide');
+ $("#delete_topic_modal").modal("hide");
},
});
};
@@ -860,7 +860,7 @@ exports.move_topic_containing_message_to_stream =
send_notification_to_old_thread) {
const request = {
stream_id: new_stream_id,
- propagate_mode: 'change_all',
+ 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,
@@ -868,7 +868,7 @@ exports.move_topic_containing_message_to_stream =
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,
+ url: "/json/messages/" + message_id,
data: request,
success: function () {
// The main UI will update via receiving the event
diff --git a/static/js/message_edit_history.js b/static/js/message_edit_history.js
index b8ae0345606..636c32a1c13 100644
--- a/static/js/message_edit_history.js
+++ b/static/js/message_edit_history.js
@@ -1,4 +1,4 @@
-const render_message_edit_history = require('../templates/message_edit_history.hbs');
+const render_message_edit_history = require("../templates/message_edit_history.hbs");
exports.fetch_and_render_message_history = function (message) {
channel.get({
@@ -47,8 +47,8 @@ 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({
+ $("#message-history").attr("data-message-id", message.id);
+ $("#message-history").html(render_message_edit_history({
edited_messages: content_edit_history,
}));
},
@@ -60,8 +60,8 @@ exports.fetch_and_render_message_history = function (message) {
};
exports.show_history = function (message) {
- $('#message-history').html('');
- $('#message-edit-history').modal("show");
+ $("#message-history").html("");
+ $("#message-edit-history").modal("show");
exports.fetch_and_render_message_history(message);
};
diff --git a/static/js/message_events.js b/static/js/message_events.js
index d3dd225e1db..b3caa318f9f 100644
--- a/static/js/message_events.js
+++ b/static/js/message_events.js
@@ -9,7 +9,7 @@ function maybe_add_narrowed_messages(messages, msg_list) {
}
channel.get({
- url: '/json/messages/matches_narrow',
+ url: "/json/messages/matches_narrow",
data: {msg_ids: JSON.stringify(ids),
narrow: JSON.stringify(narrow_state.public_operators())},
timeout: 5000,
@@ -150,7 +150,7 @@ 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();
@@ -256,7 +256,7 @@ exports.update_messages = function update_messages(events) {
// The fix is likely somewhat involved, so punting for now.
const new_stream_name = stream_data.get_sub_by_id(new_stream_id).name;
new_filter = new_filter.filter_with_new_params({
- operator: 'stream',
+ operator: "stream",
operand: new_stream_name,
});
changed_narrow = true;
@@ -264,7 +264,7 @@ exports.update_messages = function update_messages(events) {
if (new_filter && topic_edited) {
new_filter = new_filter.filter_with_new_params({
- operator: 'topic',
+ operator: "topic",
operand: new_topic,
});
changed_narrow = true;
@@ -276,7 +276,7 @@ exports.update_messages = function update_messages(events) {
if (changed_narrow) {
const operators = new_filter.operators();
const opts = {
- trigger: 'stream/topic change',
+ trigger: "stream/topic change",
then_select_id: current_selected_id,
};
narrow.activate(operators, opts);
@@ -346,8 +346,8 @@ 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 46c918d10c6..8c13a80c8a5 100644
--- a/static/js/message_fetch.js
+++ b/static/js/message_fetch.js
@@ -16,7 +16,7 @@ const consts = {
function process_result(data, opts) {
let messages = data.messages;
- if (!$('#connection-error').hasClass('get-events-error')) {
+ if (!$("#connection-error").hasClass("get-events-error")) {
ui_report.hide_error($("#connection-error"));
}
@@ -123,8 +123,8 @@ function get_messages_success(data, opts) {
// or convert the emails string to user IDs directly into the Filter code
// because doing so breaks the app in various modules that expect emails string.
function handle_operators_supporting_id_based_api(data) {
- const operators_supporting_ids = ['pm-with'];
- const operators_supporting_id = ['sender', 'group-pm-with', 'stream'];
+ const operators_supporting_ids = ["pm-with"];
+ const operators_supporting_id = ["sender", "group-pm-with", "stream"];
if (data.narrow === undefined) {
return data;
@@ -137,7 +137,7 @@ function handle_operators_supporting_id_based_api(data) {
}
if (operators_supporting_id.includes(filter.operator)) {
- if (filter.operator === 'stream') {
+ if (filter.operator === "stream") {
const stream_id = stream_data.get_stream_id(filter.operand);
if (stream_id !== undefined) {
filter.operand = stream_id;
@@ -212,7 +212,7 @@ exports.load_messages = function (opts) {
data = handle_operators_supporting_id_based_api(data);
channel.get({
- url: '/json/messages',
+ url: "/json/messages",
data: data,
idempotent: true,
success: function (data) {
@@ -238,7 +238,7 @@ exports.load_messages = function (opts) {
}
// We might want to be more clever here
- $('#connection-error').addClass("show");
+ $("#connection-error").addClass("show");
setTimeout(() => {
exports.load_messages(opts);
}, consts.error_retry_time);
diff --git a/static/js/message_flags.js b/static/js/message_flags.js
index d1fb7bebf11..b2bceec5927 100644
--- a/static/js/message_flags.js
+++ b/static/js/message_flags.js
@@ -1,6 +1,6 @@
function send_flag_update(message, flag, op) {
channel.post({
- url: '/json/messages/flags',
+ url: "/json/messages/flags",
idempotent: true,
data: {
messages: JSON.stringify([message.id]),
@@ -30,11 +30,11 @@ exports.send_read = (function () {
// call finishes, they will be handled in the success callback.
channel.post({
- url: '/json/messages/flags',
+ url: "/json/messages/flags",
idempotent: true,
data: {messages: JSON.stringify(real_msg_ids_batch),
- op: 'add',
- flag: 'read'},
+ op: "add",
+ flag: "read"},
success: on_success,
});
}
@@ -62,11 +62,11 @@ exports.send_read = (function () {
}());
exports.save_collapsed = function (message) {
- send_flag_update(message, 'collapsed', 'add');
+ send_flag_update(message, "collapsed", "add");
};
exports.save_uncollapsed = function (message) {
- send_flag_update(message, 'collapsed', 'remove');
+ send_flag_update(message, "collapsed", "remove");
};
// This updates the state of the starred flag in local data
@@ -101,10 +101,10 @@ exports.toggle_starred_and_update_server = function (message) {
ui.update_starred_view(message.id, message.starred);
if (message.starred) {
- send_flag_update(message, 'starred', 'add');
+ send_flag_update(message, "starred", "add");
starred_messages.add([message.id]);
} else {
- send_flag_update(message, 'starred', 'remove');
+ send_flag_update(message, "starred", "remove");
starred_messages.remove([message.id]);
}
};
@@ -112,12 +112,12 @@ exports.toggle_starred_and_update_server = function (message) {
exports.unstar_all_messages = function () {
const starred_msg_ids = starred_messages.get_starred_msg_ids();
channel.post({
- url: '/json/messages/flags',
+ url: "/json/messages/flags",
idempotent: true,
data: {
messages: JSON.stringify(starred_msg_ids),
- flag: 'starred',
- op: 'remove',
+ flag: "starred",
+ op: "remove",
},
});
};
diff --git a/static/js/message_list.js b/static/js/message_list.js
index 5b370d3f06a..cd6c442c8e2 100644
--- a/static/js/message_list.js
+++ b/static/js/message_list.js
@@ -1,4 +1,4 @@
-const autosize = require('autosize');
+const autosize = require("autosize");
exports.narrowed = undefined;
exports.set_narrowed = function (value) {
@@ -199,7 +199,7 @@ exports.MessageList.prototype = {
this.view.maybe_rerender();
}
- $(document).trigger($.Event('message_selected.zulip', opts));
+ $(document).trigger($.Event("message_selected.zulip", opts));
},
reselect_selected_id: function MessageList_select_closest_id() {
@@ -321,28 +321,28 @@ exports.MessageList.prototype = {
show_edit_topic_on_recipient_row: function (recipient_row, form) {
recipient_row.find(".topic_edit_form").append(form);
- recipient_row.find('.on_hover_topic_edit').hide();
- recipient_row.find('.edit_content_button').hide();
+ recipient_row.find(".on_hover_topic_edit").hide();
+ recipient_row.find(".edit_content_button").hide();
recipient_row.find(".stream_topic").hide();
recipient_row.find(".topic_edit").show();
},
hide_edit_topic_on_recipient_row: function (recipient_row) {
recipient_row.find(".stream_topic").show();
- recipient_row.find('.on_hover_topic_edit').show();
- recipient_row.find('.edit_content_button').show();
+ recipient_row.find(".on_hover_topic_edit").show();
+ recipient_row.find(".edit_content_button").show();
recipient_row.find(".topic_edit_form").empty();
recipient_row.find(".topic_edit").hide();
},
show_message_as_read: function (message, options) {
const row = this.get_row(message.id);
- if (options.from === 'pointer' || options.from === "server") {
- row.find('.unread_marker').addClass('fast_fade');
+ if (options.from === "pointer" || options.from === "server") {
+ row.find(".unread_marker").addClass("fast_fade");
} else {
- row.find('.unread_marker').addClass('slow_fade');
+ row.find(".unread_marker").addClass("slow_fade");
}
- row.removeClass('unread');
+ row.removeClass("unread");
},
rerender: function MessageList_rerender() {
@@ -445,7 +445,7 @@ exports.all = new exports.MessageList({
// doing something. Be careful, though, if you try to capture
// mousemove, then you will have to contend with the autoscroll
// itself generating mousemove events.
-$(document).on('message_selected.zulip wheel', () => {
+$(document).on("message_selected.zulip wheel", () => {
message_viewport.stop_auto_scrolling();
});
diff --git a/static/js/message_list_data.js b/static/js/message_list_data.js
index 3fb86815777..6a2cc51af86 100644
--- a/static/js/message_list_data.js
+++ b/static/js/message_list_data.js
@@ -431,7 +431,7 @@ MessageListData.prototype = {
const item = items[potential_idx];
if (item === undefined) {
- blueslip.warn('Invalid potential_idx: ' + potential_idx);
+ blueslip.warn("Invalid potential_idx: " + potential_idx);
continue;
}
diff --git a/static/js/message_list_view.js b/static/js/message_list_view.js
index 17b46348acd..2451ce7320b 100644
--- a/static/js/message_list_view.js
+++ b/static/js/message_list_view.js
@@ -1,9 +1,9 @@
const util = require("./util");
-const rendered_markdown = require('./rendered_markdown');
-const render_bookend = require('../templates/bookend.hbs');
-const render_message_group = require('../templates/message_group.hbs');
-const render_recipient_row = require('../templates/recipient_row.hbs');
-const render_single_message = require('../templates/single_message.hbs');
+const rendered_markdown = require("./rendered_markdown");
+const render_bookend = require("../templates/bookend.hbs");
+const render_message_group = require("../templates/message_group.hbs");
+const render_recipient_row = require("../templates/recipient_row.hbs");
+const render_single_message = require("../templates/single_message.hbs");
function MessageListView(list, table_name, collapse_messages) {
this.list = list;
@@ -228,7 +228,7 @@ MessageListView.prototype = {
function start_group() {
return {
message_containers: [],
- message_group_id: _.uniqueId('message_group_'),
+ message_group_id: _.uniqueId("message_group_"),
};
}
@@ -393,7 +393,7 @@ MessageListView.prototype = {
let curr_msg_container;
let prev_msg_container;
- if (where === 'top') {
+ if (where === "top") {
first_group = _.last(new_message_groups);
second_group = _.first(this._message_groups);
} else {
@@ -419,7 +419,7 @@ MessageListView.prototype = {
clear_message_date_divider(curr_msg_container);
}
- if (where === 'top') {
+ if (where === "top") {
if (was_joined) {
// join_message_groups moved the old message to the end of the
// new group. We need to replace the old rendered message
@@ -466,7 +466,7 @@ MessageListView.prototype = {
_put_row: function (row) {
// row is a jQuery object wrapping one message row
- if (row.hasClass('message_row')) {
+ if (row.hasClass("message_row")) {
this._rows.set(rows.id(row), row);
}
},
@@ -476,7 +476,7 @@ MessageListView.prototype = {
if ($message_rows.constructor !== jQuery) {
// An assertion check that we're calling this properly
- blueslip.error('programming error--pass in jQuery objects');
+ blueslip.error("programming error--pass in jQuery objects");
}
const self = this;
@@ -497,10 +497,10 @@ MessageListView.prototype = {
// HTML and CSS.
if (row.length !== 1) {
- blueslip.error('programming error--expected single element');
+ blueslip.error("programming error--expected single element");
}
- const content = row.find('.message_content');
+ const content = row.find(".message_content");
rendered_markdown.update_elements(content);
@@ -614,14 +614,14 @@ MessageListView.prototype = {
table_name: self.table_name,
});
- dom_messages = rendered_groups.find('.message_row');
+ dom_messages = rendered_groups.find(".message_row");
new_dom_elements = new_dom_elements.concat(rendered_groups);
self._post_process(dom_messages);
// The date row will be included in the message groups or will be
// added in a rerenderd in the group below
- table.find('.recipient_row').first().prev('.date_row').remove();
+ table.find(".recipient_row").first().prev(".date_row").remove();
table.prepend(rendered_groups);
condense.condense_and_collapse(dom_messages);
}
@@ -631,9 +631,9 @@ MessageListView.prototype = {
save_scroll_position();
for (const message_group of message_actions.rerender_groups) {
- const old_message_group = $('#' + message_group.message_group_id);
+ const old_message_group = $("#" + message_group.message_group_id);
// Remove the top date_row, we'll re-add it after rendering
- old_message_group.prev('.date_row').remove();
+ old_message_group.prev(".date_row").remove();
rendered_groups = self._render_group({
message_groups: [message_group],
@@ -641,7 +641,7 @@ MessageListView.prototype = {
table_name: self.table_name,
});
- dom_messages = rendered_groups.find('.message_row');
+ dom_messages = rendered_groups.find(".message_row");
// Not adding to new_dom_elements it is only used for autoscroll
self._post_process(dom_messages);
@@ -669,9 +669,9 @@ MessageListView.prototype = {
// Insert new messages in to the last message group
if (message_actions.append_messages.length > 0) {
- last_message_row = table.find('.message_row').last().expectOne();
+ 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);
@@ -691,7 +691,7 @@ MessageListView.prototype = {
table_name: self.table_name,
});
- dom_messages = rendered_groups.find('.message_row');
+ dom_messages = rendered_groups.find(".message_row");
new_dom_elements = new_dom_elements.concat(rendered_groups);
self._post_process(dom_messages);
@@ -815,7 +815,7 @@ MessageListView.prototype = {
if (scroll_limit < 0) {
// This shouldn't happen, but if we're off by a pixel or
// something, we can deal with it, and just warn.
- blueslip.warn('Selected row appears too high on screen.');
+ blueslip.warn("Selected row appears too high on screen.");
scroll_limit = 0;
}
@@ -1000,7 +1000,7 @@ MessageListView.prototype = {
// 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_win_end), "bottom");
// If we could see the newly selected message, scroll the
// window such that the newly selected message is at the
@@ -1045,7 +1045,7 @@ MessageListView.prototype = {
}
const recipient_row = rows.get_message_recipient_row(first_row);
- const header = recipient_row.find('.message_header');
+ const header = recipient_row.find(".message_header");
const message_group_id = recipient_row.attr("id");
// Since there might be multiple dates within the message
@@ -1132,7 +1132,7 @@ MessageListView.prototype = {
if (cur_window_size < this._RENDER_WINDOW_SIZE) {
const slice_to_render = messages.slice(0, this._RENDER_WINDOW_SIZE - cur_window_size);
- render_info = this.render(slice_to_render, 'bottom', messages_are_new);
+ render_info = this.render(slice_to_render, "bottom", messages_are_new);
this._render_win_end += slice_to_render.length;
}
@@ -1158,7 +1158,7 @@ MessageListView.prototype = {
if (cur_window_size < this._RENDER_WINDOW_SIZE) {
const msgs_to_render_count = this._RENDER_WINDOW_SIZE - cur_window_size;
const slice_to_render = messages.slice(messages.length - msgs_to_render_count);
- this.render(slice_to_render, 'top', false);
+ this.render(slice_to_render, "top", false);
this._render_win_start -= slice_to_render.length;
}
@@ -1189,7 +1189,7 @@ MessageListView.prototype = {
},
clear_trailing_bookend: function () {
- const trailing_bookend = rows.get_table(this.table_name).find('.trailing_bookend');
+ const trailing_bookend = rows.get_table(this.table_name).find(".trailing_bookend");
trailing_bookend.remove();
},
@@ -1215,9 +1215,9 @@ MessageListView.prototype = {
const row = this._rows.get(old_id);
this._rows.delete(old_id);
- row.attr('zid', new_id);
- row.attr('id', this.table_name + new_id);
- row.removeClass('local');
+ row.attr("zid", new_id);
+ row.attr("id", this.table_name + new_id);
+ row.removeClass("local");
this._rows.set(new_id, row);
}
@@ -1235,9 +1235,9 @@ MessageListView.prototype = {
// 'p' tag is sliced off to get sender in the same line as the
// 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);
+ 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.include_sender = true;
} else {
message_container.status_message = false;
diff --git a/static/js/message_scroll.js b/static/js/message_scroll.js
index 287de82d9e5..d8298084045 100644
--- a/static/js/message_scroll.js
+++ b/static/js/message_scroll.js
@@ -12,7 +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'),
+ loading.make_indicator($("#loading_older_messages_indicator"),
{abs_positioned: true});
loading_older_messages_indicator_showing = true;
floating_recipient_bar.hide();
@@ -29,7 +29,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'),
+ loading.make_indicator($("#loading_newer_messages_indicator"),
{abs_positioned: true});
loading_newer_messages_indicator_showing = true;
floating_recipient_bar.hide();
@@ -114,7 +114,7 @@ exports.actively_scrolling = function () {
exports.scroll_finished = function () {
actively_scrolling = false;
- if (!$('#home').hasClass('active')) {
+ if (!$("#home").hasClass("active")) {
return;
}
@@ -159,7 +159,7 @@ exports.initialize = function () {
}, 50));
// Scroll handler that marks messages as read when you scroll past them.
- $(document).on('message_selected.zulip', (event) => {
+ $(document).on("message_selected.zulip", (event) => {
if (event.id === -1) {
return;
}
@@ -173,7 +173,7 @@ exports.initialize = function () {
messages = event.msg_list.message_range(event.previously_selected, event.id);
}
if (event.msg_list.can_mark_messages_read()) {
- unread_ops.notify_server_messages_read(messages, {from: 'pointer'});
+ unread_ops.notify_server_messages_read(messages, {from: "pointer"});
}
}
});
diff --git a/static/js/message_store.js b/static/js/message_store.js
index 8f909b28219..2493bc0eab5 100644
--- a/static/js/message_store.js
+++ b/static/js/message_store.js
@@ -22,12 +22,12 @@ exports.user_ids = function () {
exports.get = function get(message_id) {
if (message_id === undefined || message_id === null) {
- blueslip.error('message_store.get got bad value: ' + message_id);
+ blueslip.error("message_store.get got bad value: " + message_id);
return;
}
- if (typeof message_id !== 'number') {
- blueslip.error('message_store got non-number: ' + message_id);
+ if (typeof message_id !== "number") {
+ blueslip.error("message_store got non-number: " + message_id);
// Try to soldier on, assuming the caller treats message
// ids as strings.
@@ -46,8 +46,8 @@ exports.get_pm_emails = function (message) {
function email(user_id) {
const person = people.get_by_user_id(user_id);
if (!person) {
- blueslip.error('Unknown user id ' + user_id);
- return '?';
+ blueslip.error("Unknown user id " + user_id);
+ return "?";
}
return person.email;
}
@@ -55,7 +55,7 @@ exports.get_pm_emails = function (message) {
const user_ids = people.pm_with_user_ids(message);
const emails = user_ids.map(email).sort();
- return emails.join(', ');
+ return emails.join(", ");
};
exports.get_pm_full_names = function (message) {
@@ -63,8 +63,8 @@ exports.get_pm_full_names = function (message) {
function name(user_id) {
const person = people.get_by_user_id(user_id);
if (!person) {
- blueslip.error('Unknown user id ' + user_id);
- return '?';
+ blueslip.error("Unknown user id " + user_id);
+ return "?";
}
return person.full_name;
}
@@ -72,7 +72,7 @@ exports.get_pm_full_names = function (message) {
const user_ids = people.pm_with_user_ids(message);
const names = user_ids.map(name).sort();
- return names.join(', ');
+ return names.join(", ");
};
exports.process_message_for_recent_private_messages = function (message) {
@@ -95,13 +95,13 @@ exports.set_message_booleans = function (message) {
return flags.includes(flag_name);
}
- message.unread = !convert_flag('read');
- message.historical = convert_flag('historical');
- message.starred = convert_flag('starred');
- message.mentioned = convert_flag('mentioned') || convert_flag('wildcard_mentioned');
- message.mentioned_me_directly = convert_flag('mentioned');
- message.collapsed = convert_flag('collapsed');
- message.alerted = convert_flag('has_alert_word');
+ message.unread = !convert_flag("read");
+ message.historical = convert_flag("historical");
+ message.starred = convert_flag("starred");
+ message.mentioned = convert_flag("mentioned") || convert_flag("wildcard_mentioned");
+ message.mentioned_me_directly = convert_flag("mentioned");
+ message.collapsed = convert_flag("collapsed");
+ message.alerted = convert_flag("has_alert_word");
// Once we have set boolean flags here, the `flags` attribute is
// just a distraction, so we delete it. (All the downstream code
@@ -132,9 +132,9 @@ exports.update_booleans = function (message, flags) {
return flags.includes(flag_name);
}
- message.mentioned = convert_flag('mentioned') || convert_flag('wildcard_mentioned');
- message.mentioned_me_directly = convert_flag('mentioned');
- message.alerted = convert_flag('has_alert_word');
+ message.mentioned = convert_flag("mentioned") || convert_flag("wildcard_mentioned");
+ message.mentioned_me_directly = convert_flag("mentioned");
+ message.alerted = convert_flag("has_alert_word");
};
exports.add_message_metadata = function (message) {
@@ -164,7 +164,7 @@ exports.add_message_metadata = function (message) {
util.convert_message_topic(message);
switch (message.type) {
- case 'stream':
+ case "stream":
message.is_stream = true;
message.stream = message.display_recipient;
message.reply_to = message.sender_email;
@@ -179,7 +179,7 @@ exports.add_message_metadata = function (message) {
message_user_ids.add(message.sender_id);
break;
- case 'private':
+ case "private":
message.is_private = true;
message.reply_to = util.normalize_recipients(
exports.get_pm_emails(message));
diff --git a/static/js/message_util.js b/static/js/message_util.js
index deaf126675e..7192c252961 100644
--- a/static/js/message_util.js
+++ b/static/js/message_util.js
@@ -9,7 +9,7 @@ function add_messages(messages, msg_list, opts) {
return;
}
- loading.destroy_indicator($('#page_loading_indicator'));
+ loading.destroy_indicator($("#page_loading_indicator"));
const render_info = msg_list.add_messages(messages, opts);
@@ -17,15 +17,15 @@ function add_messages(messages, msg_list, opts) {
}
exports.message_has_link = function (message) {
- return $(message.content).find(`a`).length > 0;
+ return $(message.content).find("a").length > 0;
};
exports.message_has_image = function (message) {
- return $(message.content).find(`.message_inline_image`).length > 0;
+ return $(message.content).find(".message_inline_image").length > 0;
};
exports.message_has_attachment = function (message) {
- return $(message.content).find(`a[href^='/user_uploads']`).length > 0;
+ return $(message.content).find("a[href^='/user_uploads']").length > 0;
};
exports.add_old_messages = function (messages, msg_list) {
@@ -49,7 +49,7 @@ 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' &&
+ return message_list.all.all_messages().filter((x) => x.type === "stream" &&
x.stream_id === stream_id &&
x.topic.toLowerCase() === topic.toLowerCase());
};
diff --git a/static/js/message_viewport.js b/static/js/message_viewport.js
index fe6d6ccaa2b..74ec0a9c16e 100644
--- a/static/js/message_viewport.js
+++ b/static/js/message_viewport.js
@@ -41,7 +41,7 @@ exports.message_viewport_info = function () {
exports.at_bottom = function () {
const bottom = exports.scrollTop() + exports.height();
- const full_height = exports.message_pane.prop('scrollHeight');
+ const full_height = exports.message_pane.prop("scrollHeight");
// We only know within a pixel or two if we're
// exactly at the bottom, due to browser quirkiness,
@@ -262,8 +262,8 @@ function make_dimen_wrapper(dimen_name, dimen_func) {
};
}
-exports.height = make_dimen_wrapper('height', $(exports.message_pane).height);
-exports.width = make_dimen_wrapper('width', $(exports.message_pane).width);
+exports.height = make_dimen_wrapper("height", $(exports.message_pane).height);
+exports.width = make_dimen_wrapper("width", $(exports.message_pane).width);
exports.stop_auto_scrolling = function () {
if (in_stoppable_autoscroll) {
@@ -426,7 +426,7 @@ exports.initialize = function () {
bottom_of_feed.reset();
});
- $(document).on('compose_started compose_canceled compose_finished', () => {
+ $(document).on("compose_started compose_canceled compose_finished", () => {
bottom_of_feed.reset();
});
};
diff --git a/static/js/muting.js b/static/js/muting.js
index 7e060584299..cf5342bd5cd 100644
--- a/static/js/muting.js
+++ b/static/js/muting.js
@@ -1,4 +1,4 @@
-const FoldDict = require('./fold_dict').FoldDict;
+const FoldDict = require("./fold_dict").FoldDict;
const muted_topics = new Map();
@@ -60,7 +60,7 @@ exports.set_muted_topics = function (tuples) {
const stream_id = stream_data.get_stream_id(stream_name);
if (!stream_id) {
- blueslip.warn('Unknown stream in set_muted_topics: ' + stream_name);
+ blueslip.warn("Unknown stream in set_muted_topics: " + stream_name);
continue;
}
diff --git a/static/js/muting_ui.js b/static/js/muting_ui.js
index 9bfac827d39..7cc9f441fab 100644
--- a/static/js/muting_ui.js
+++ b/static/js/muting_ui.js
@@ -1,5 +1,5 @@
-const render_muted_topic_ui_row = require('../templates/muted_topic_ui_row.hbs');
-const render_topic_muted = require('../templates/topic_muted.hbs');
+const render_muted_topic_ui_row = require("../templates/muted_topic_ui_row.hbs");
+const render_topic_muted = require("../templates/topic_muted.hbs");
function timestamp_ms() {
return new Date().getTime();
@@ -29,11 +29,11 @@ exports.persist_mute = function (stream_id, topic_name) {
const data = {
stream_id: stream_id,
topic: topic_name,
- op: 'add',
+ op: "add",
};
last_topic_update = timestamp_ms();
channel.patch({
- url: '/json/users/me/subscriptions/muted_topics',
+ url: "/json/users/me/subscriptions/muted_topics",
idempotent: true,
data: data,
});
@@ -43,11 +43,11 @@ exports.persist_unmute = function (stream_id, topic_name) {
const data = {
stream_id: stream_id,
topic: topic_name,
- op: 'remove',
+ op: "remove",
};
last_topic_update = timestamp_ms();
channel.patch({
- url: '/json/users/me/subscriptions/muted_topics',
+ url: "/json/users/me/subscriptions/muted_topics",
idempotent: true,
data: data,
});
@@ -89,8 +89,8 @@ exports.set_up_muted_topics_ui = function () {
ui.reset_scrollbar(muted_topics_table.closest(".progressive-table-wrapper"));
},
},
- parent_container: $('#muted-topic-settings'),
- simplebar_container: $('#muted-topic-settings .progressive-table-wrapper'),
+ parent_container: $("#muted-topic-settings"),
+ simplebar_container: $("#muted-topic-settings .progressive-table-wrapper"),
});
};
@@ -137,7 +137,7 @@ exports.toggle_mute = function (message) {
if (muting.is_topic_muted(stream_id, topic)) {
exports.unmute(stream_id, topic);
- } else if (message.type === 'stream') {
+ } else if (message.type === "stream") {
exports.mute(stream_id, topic);
}
};
diff --git a/static/js/narrow.js b/static/js/narrow.js
index 96ff43e7a67..6b2c9aed9e7 100644
--- a/static/js/narrow.js
+++ b/static/js/narrow.js
@@ -5,7 +5,7 @@ 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',
+ url: "/json/report/narrow_times",
data: {initial_core: initial_core_time.toString(),
initial_free: initial_free_time.toString(),
network: network_time.toString()},
@@ -35,7 +35,7 @@ function report_unnarrow_time() {
const initial_free_time = unnarrow_times.initial_free_time - unnarrow_times.start_time;
channel.post({
- url: '/json/report/unnarrow_times',
+ url: "/json/report/unnarrow_times",
data: {initial_core: initial_core_time.toString(),
initial_free: initial_free_time.toString()},
});
@@ -84,7 +84,7 @@ function update_narrow_title(filter) {
exports.narrow_title = names + " and others";
}
} else {
- if (emails.includes(',')) {
+ if (emails.includes(",")) {
exports.narrow_title = "Invalid users";
} else {
exports.narrow_title = "Invalid user";
@@ -159,7 +159,7 @@ exports.activate = function (raw_operators, opts) {
then_select_id: -1,
then_select_offset: undefined,
change_hash: true,
- trigger: 'unknown',
+ trigger: "unknown",
...opts,
};
@@ -234,7 +234,7 @@ exports.activate = function (raw_operators, opts) {
const msg_list = new message_list.MessageList({
data: msg_data,
- table_name: 'zfilt',
+ table_name: "zfilt",
collapse_messages: !narrow_state.filter().is_search(),
});
@@ -247,7 +247,7 @@ exports.activate = function (raw_operators, opts) {
$("#zfilt").addClass("focused_table");
$("#zhome").removeClass("focused_table");
- ui_util.change_tab_to('#home');
+ ui_util.change_tab_to("#home");
message_list.set_narrowed(msg_list);
current_msg_list = message_list.narrowed;
@@ -307,7 +307,7 @@ exports.activate = function (raw_operators, opts) {
hashchange.save_narrow(operators);
}
- if (page_params.search_pills_enabled && opts.trigger !== 'search') {
+ if (page_params.search_pills_enabled && opts.trigger !== "search") {
search_pill_widget.widget.clear(true);
for (const operator of operators) {
@@ -406,7 +406,7 @@ exports.maybe_add_local_messages = function (opts) {
id_info.final_select_id = LARGER_THAN_MAX_MESSAGE_ID;
}
- if (unread_info.flavor === 'cannot_compute') {
+ if (unread_info.flavor === "cannot_compute") {
// Full-text search and potentially other future cases where
// we can't check which messages match on the frontend, so it
// doesn't matter what's in our cache, we must go to the server.
@@ -425,7 +425,7 @@ 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' &&
+ 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
@@ -555,7 +555,7 @@ 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},
+ {operator: "stream", operand: stream_name},
];
exports.activate(filter_expr, {});
};
@@ -609,8 +609,8 @@ exports.narrow_to_next_topic = function () {
}
const filter_expr = [
- {operator: 'stream', operand: next_narrow.stream},
- {operator: 'topic', operand: next_narrow.topic},
+ {operator: "stream", operand: next_narrow.stream},
+ {operator: "topic", operand: next_narrow.topic},
];
exports.activate(filter_expr, {});
@@ -631,7 +631,7 @@ exports.narrow_to_next_pm_string = function () {
const pm_with = people.user_ids_string_to_emails_string(next_pm);
const filter_expr = [
- {operator: 'pm-with', operand: pm_with},
+ {operator: "pm-with", operand: pm_with},
];
// force_close parameter is true to not auto open compose_box
@@ -652,7 +652,7 @@ exports.by = function (operator, operand, opts) {
exports.by_topic = function (target_id, opts) {
// don't use current_msg_list as it won't work for muted messages or for out-of-narrow links
const original = message_store.get(target_id);
- if (original.type !== 'stream') {
+ if (original.type !== "stream") {
// Only stream messages have topics, but the
// user wants us to narrow in some way.
exports.by_recipient(target_id, opts);
@@ -665,8 +665,8 @@ exports.by_topic = function (target_id, opts) {
unread_ops.notify_server_message_read(original);
const search_terms = [
- {operator: 'stream', operand: original.stream},
- {operator: 'topic', operand: original.topic},
+ {operator: "stream", operand: original.stream},
+ {operator: "topic", operand: original.topic},
];
opts = { then_select_id: target_id, ...opts };
exports.activate(search_terms, opts);
@@ -684,12 +684,12 @@ exports.by_recipient = function (target_id, opts) {
unread_ops.notify_server_message_read(message);
switch (message.type) {
- case 'private':
- exports.by('pm-with', message.reply_to, opts);
+ case "private":
+ exports.by("pm-with", message.reply_to, opts);
break;
- case 'stream':
- exports.by('stream', message.stream, opts);
+ case "stream":
+ exports.by("stream", message.stream, opts);
break;
}
};
@@ -701,10 +701,10 @@ exports.to_compose_target = function () {
}
const opts = {
- trigger: 'narrow_to_compose_target',
+ trigger: "narrow_to_compose_target",
};
- if (compose_state.get_message_type() === 'stream') {
+ if (compose_state.get_message_type() === "stream") {
const stream_name = compose_state.stream_name();
const stream_id = stream_data.get_stream_id(stream_name);
if (!stream_id) {
@@ -713,26 +713,26 @@ exports.to_compose_target = function () {
// If we are composing to a new topic, we narrow to the stream but
// grey-out the message view instead of narrowing to an empty view.
const topics = stream_topic_history.get_recent_topic_names(stream_id);
- const operators = [{operator: 'stream', operand: stream_name}];
+ const operators = [{operator: "stream", operand: stream_name}];
const topic = compose_state.topic();
if (topics.includes(topic)) {
- operators.push({operator: 'topic', operand: topic});
+ operators.push({operator: "topic", operand: topic});
}
exports.activate(operators, opts);
return;
}
- if (compose_state.get_message_type() === 'private') {
+ if (compose_state.get_message_type() === "private") {
const recipient_string = compose_state.private_message_recipient();
const emails = util.extract_pm_recipients(recipient_string);
const invalid = emails.filter((email) => !people.is_valid_email_for_compose(email));
// If there are no recipients or any recipient is
// invalid, narrow to all PMs.
if (emails.length === 0 || invalid.length > 0) {
- exports.by('is', 'private', opts);
+ exports.by("is", "private", opts);
return;
}
- exports.by('pm-with', util.normalize_recipients(recipient_string), opts);
+ exports.by("pm-with", util.normalize_recipients(recipient_string), opts);
}
};
@@ -793,9 +793,9 @@ exports.deactivate = function () {
exports.hide_empty_narrow_message();
- $("body").removeClass('narrowed_view');
- $("#zfilt").removeClass('focused_table');
- $("#zhome").addClass('focused_table');
+ $("body").removeClass("narrowed_view");
+ $("#zfilt").removeClass("focused_table");
+ $("#zhome").addClass("focused_table");
current_msg_list = home_msg_list;
condense.condense_and_collapse($("#zhome div.message_row"));
@@ -878,8 +878,8 @@ function show_search_query() {
// Add in stream:foo and topic:bar if present
if (current_filter.has_operator("stream") || current_filter.has_operator("topic")) {
let stream_topic_string = "";
- const stream = current_filter.operands('stream')[0];
- const topic = current_filter.operands('topic')[0];
+ const stream = current_filter.operands("stream")[0];
+ const topic = current_filter.operands("topic")[0];
if (stream) {
stream_topic_string = "stream: " + stream;
}
@@ -887,21 +887,21 @@ function show_search_query() {
stream_topic_string = stream_topic_string + " topic: " + topic;
}
- search_string_display.append(' ');
- search_string_display.append($('<span>').text(stream_topic_string));
+ search_string_display.append(" ");
+ search_string_display.append($("<span>").text(stream_topic_string));
}
for (const query_word of query_words) {
- search_string_display.append(' ');
+ search_string_display.append(" ");
// if query contains stop words, it is enclosed by a <del> tag
if (page_params.stop_words.includes(query_word)) {
// stop_words do not need sanitization so this is unnecessary but it is fail-safe.
- search_string_display.append($('<del>').text(query_word));
+ search_string_display.append($("<del>").text(query_word));
query_contains_stop_words = true;
} else {
// We use .text("...") to sanitize the user-given query_string.
- search_string_display.append($('<span>').text(query_word));
+ search_string_display.append($("<span>").text(query_word));
}
}
@@ -912,7 +912,7 @@ function show_search_query() {
}
function pick_empty_narrow_banner() {
- const default_banner = $('#empty_narrow_message');
+ const default_banner = $("#empty_narrow_message");
const current_filter = narrow_state.filter();
@@ -992,13 +992,13 @@ function pick_empty_narrow_banner() {
show_search_query();
return $("#empty_search_narrow_message");
} else if (first_operator === "pm-with") {
- if (!people.is_valid_bulk_emails_for_compose(first_operand.split(','))) {
- if (!first_operand.includes(',')) {
+ if (!people.is_valid_bulk_emails_for_compose(first_operand.split(","))) {
+ if (!first_operand.includes(",")) {
return $("#non_existing_user");
}
return $("#non_existing_users");
}
- if (!first_operand.includes(',')) {
+ if (!first_operand.includes(",")) {
// You have no private messages with this person
if (people.is_current_user(first_operand)) {
return $("#empty_narrow_self_private_message");
diff --git a/static/js/narrow_state.js b/static/js/narrow_state.js
index fe175a99795..32831b591c3 100644
--- a/static/js/narrow_state.js
+++ b/static/js/narrow_state.js
@@ -74,17 +74,17 @@ exports.set_compose_defaults = function () {
// Set the stream, topic, and/or PM recipient if they are
// uniquely specified in the narrow view.
- if (single.has('stream')) {
- opts.stream = stream_data.get_name(single.get('stream'));
+ if (single.has("stream")) {
+ opts.stream = stream_data.get_name(single.get("stream"));
}
- if (single.has('topic')) {
- opts.topic = single.get('topic');
+ if (single.has("topic")) {
+ opts.topic = single.get("topic");
}
- if (single.has('pm-with')) {
- const private_message_recipient = single.get('pm-with');
- if (people.is_valid_bulk_emails_for_compose(private_message_recipient.split(','))) {
+ if (single.has("pm-with")) {
+ const private_message_recipient = single.get("pm-with");
+ if (people.is_valid_bulk_emails_for_compose(private_message_recipient.split(","))) {
opts.private_message_recipient = private_message_recipient;
}
}
@@ -169,9 +169,9 @@ exports.pm_string = function () {
exports.get_first_unread_info = function () {
if (current_filter === undefined) {
// we don't yet support the all-messages view
- blueslip.error('unexpected call to get_first_unread_info');
+ blueslip.error("unexpected call to get_first_unread_info");
return {
- flavor: 'cannot_compute',
+ flavor: "cannot_compute",
};
}
@@ -181,7 +181,7 @@ exports.get_first_unread_info = function () {
// server to give us a definitive list of messages before
// deciding where we'll move the selection.
return {
- flavor: 'cannot_compute',
+ flavor: "cannot_compute",
};
}
@@ -190,7 +190,7 @@ exports.get_first_unread_info = function () {
if (unread_ids === undefined) {
// _possible_unread_message_ids() only works for certain narrows
return {
- flavor: 'cannot_compute',
+ flavor: "cannot_compute",
};
}
@@ -198,13 +198,13 @@ exports.get_first_unread_info = function () {
if (msg_id === undefined) {
return {
- flavor: 'not_found',
+ flavor: "not_found",
};
}
return {
- flavor: 'found',
+ flavor: "found",
msg_id: unread_ids[0],
};
};
@@ -225,7 +225,7 @@ exports._possible_unread_message_ids = function () {
let topic_name;
let pm_string;
- if (current_filter.can_bucket_by('stream', 'topic')) {
+ if (current_filter.can_bucket_by("stream", "topic")) {
stream_id = exports.stream_id();
if (stream_id === undefined) {
return [];
@@ -234,7 +234,7 @@ exports._possible_unread_message_ids = function () {
return unread.get_msg_ids_for_topic(stream_id, topic_name);
}
- if (current_filter.can_bucket_by('stream')) {
+ if (current_filter.can_bucket_by("stream")) {
stream_id = exports.stream_id();
if (stream_id === undefined) {
return [];
@@ -242,7 +242,7 @@ exports._possible_unread_message_ids = function () {
return unread.get_msg_ids_for_stream(stream_id);
}
- if (current_filter.can_bucket_by('pm-with')) {
+ if (current_filter.can_bucket_by("pm-with")) {
pm_string = exports.pm_string();
if (pm_string === undefined) {
return [];
@@ -250,19 +250,19 @@ exports._possible_unread_message_ids = function () {
return unread.get_msg_ids_for_person(pm_string);
}
- if (current_filter.can_bucket_by('is-private')) {
+ if (current_filter.can_bucket_by("is-private")) {
return unread.get_msg_ids_for_private();
}
- if (current_filter.can_bucket_by('is-mentioned')) {
+ if (current_filter.can_bucket_by("is-mentioned")) {
return unread.get_msg_ids_for_mentions();
}
- if (current_filter.can_bucket_by('is-starred')) {
+ if (current_filter.can_bucket_by("is-starred")) {
return unread.get_msg_ids_for_starred();
}
- if (current_filter.can_bucket_by('sender')) {
+ if (current_filter.can_bucket_by("sender")) {
// TODO: see #9352 to make this more efficient
return unread.get_all_msg_ids();
}
@@ -290,7 +290,7 @@ exports.narrowed_by_pm_reply = function () {
}
const operators = current_filter.operators();
return operators.length === 1 &&
- current_filter.has_operator('pm-with');
+ current_filter.has_operator("pm-with");
};
exports.narrowed_by_topic_reply = function () {
diff --git a/static/js/notifications.js b/static/js/notifications.js
index 13c6d08a917..16adf7359a7 100644
--- a/static/js/notifications.js
+++ b/static/js/notifications.js
@@ -1,5 +1,5 @@
-const render_compose_notification = require('../templates/compose_notification.hbs');
-const render_notification = require('../templates/notification.hbs');
+const render_compose_notification = require("../templates/compose_notification.hbs");
+const render_notification = require("../templates/notification.hbs");
const settings_config = require("./settings_config");
const notice_memory = new Map();
@@ -10,7 +10,7 @@ let window_has_focus = document.hasFocus && document.hasFocus();
let supports_sound;
-const unread_pms_favicon = '/static/images/favicon/favicon-pms.png?v=4';
+const unread_pms_favicon = "/static/images/favicon/favicon-pms.png?v=4";
let current_favicon;
let previous_favicon;
let flashing = false;
@@ -155,19 +155,19 @@ exports.redraw_title = function () {
// 'infinite'.
n = +new_message_count;
if (n > 99) {
- n = 'infinite';
+ n = "infinite";
}
- current_favicon = previous_favicon = '/static/images/favicon/favicon-' + n + '.png?v=4';
+ current_favicon = previous_favicon = "/static/images/favicon/favicon-" + n + ".png?v=4";
} else {
- current_favicon = previous_favicon = '/static/images/favicon.svg?v=4';
+ current_favicon = previous_favicon = "/static/images/favicon.svg?v=4";
}
favicon.set(current_favicon);
}
// Notify the current desktop app's UI about the new unread count.
if (window.electron_bridge !== undefined) {
- window.electron_bridge.send_event('total_unread_count', new_message_count);
+ window.electron_bridge.send_event("total_unread_count", new_message_count);
}
};
@@ -238,8 +238,8 @@ exports.notify_above_composebox = function (note, link_class, link_msg_id, link_
link_text: link_text,
}));
exports.clear_compose_notifications();
- $('#out-of-view-notification').append(notification_html);
- $('#out-of-view-notification').show();
+ $("#out-of-view-notification").append(notification_html);
+ $("#out-of-view-notification").show();
};
if (window.electron_bridge !== undefined) {
@@ -250,25 +250,25 @@ if (window.electron_bridge !== undefined) {
if (window.electron_bridge.set_send_notification_reply_message_supported !== undefined) {
window.electron_bridge.set_send_notification_reply_message_supported(true);
}
- window.electron_bridge.on_event('send_notification_reply_message', (message_id, reply) => {
+ window.electron_bridge.on_event("send_notification_reply_message", (message_id, reply) => {
const message = message_store.get(message_id);
const data = {
type: message.type,
content: reply,
- to: message.type === 'private' ? message.reply_to : message.stream,
+ to: message.type === "private" ? message.reply_to : message.stream,
topic: message.topic,
};
function success() {
- if (message.type === 'stream') {
- narrow.by_topic(message_id, {trigger: 'desktop_notification_reply'});
+ if (message.type === "stream") {
+ narrow.by_topic(message_id, {trigger: "desktop_notification_reply"});
} else {
- narrow.by_recipient(message_id, {trigger: 'desktop_notification_reply'});
+ narrow.by_recipient(message_id, {trigger: "desktop_notification_reply"});
}
}
function error(error) {
- window.electron_bridge.send_event('send_notification_reply_message_failed', {
+ window.electron_bridge.send_event("send_notification_reply_message_failed", {
data: data,
message_id: message_id,
error: error,
@@ -276,7 +276,7 @@ if (window.electron_bridge !== undefined) {
}
channel.post({
- url: '/json/messages',
+ url: "/json/messages",
data: data,
success: success,
error: error,
@@ -297,7 +297,7 @@ function process_notification(notification) {
let raw_operators = [];
const opts = {trigger: "notification click"};
// Convert the content to plain text, replacing emoji with their alt text
- content = $('<div/>').html(message.content);
+ content = $("<div/>").html(message.content);
ui.replace_emoji_with_text(content);
spoilers.hide_spoilers_in_notification(content);
content = content.text();
@@ -318,16 +318,16 @@ function process_notification(notification) {
// Remove the sender from the list of other recipients
other_recipients = other_recipients.replace(", " + message.sender_full_name, "");
other_recipients = other_recipients.replace(message.sender_full_name + ", ", "");
- notification_source = 'pm';
+ notification_source = "pm";
} else {
key = message.sender_full_name + " to " +
message.stream + " > " + topic;
if (message.mentioned) {
- notification_source = 'mention';
+ notification_source = "mention";
} else if (message.alerted) {
- notification_source = 'alert';
+ notification_source = "alert";
} else {
- notification_source = 'stream';
+ notification_source = "stream";
}
}
blueslip.debug("Desktop notification from source " + notification_source);
@@ -335,7 +335,7 @@ function process_notification(notification) {
if (content.length > 150) {
// Truncate content at a word boundary
for (i = 150; i > 0; i -= 1) {
- if (content[i] === ' ') {
+ if (content[i] === " ") {
break;
}
}
@@ -397,7 +397,7 @@ function process_notification(notification) {
notification_object.addEventListener("click", () => {
notification_object.close();
if (message.type !== "test-notification") {
- narrow.by_topic(message.id, {trigger: 'notification'});
+ narrow.by_topic(message.id, {trigger: "notification"});
}
window.focus();
});
@@ -649,7 +649,7 @@ 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;
}
@@ -660,7 +660,7 @@ exports.notify_local_mixes = function (messages, need_user_to_scroll) {
reason = i18n.t("Sent! Scroll down to view your message.");
exports.notify_above_composebox(reason, "", null, "");
setTimeout(() => {
- $('#out-of-view-notification').hide();
+ $("#out-of-view-notification").hide();
}, 3000);
}
@@ -695,9 +695,9 @@ exports.notify_messages_outside_current_search = function (messages) {
};
exports.clear_compose_notifications = function () {
- $('#out-of-view-notification').empty();
- $('#out-of-view-notification').stop(true, true);
- $('#out-of-view-notification').hide();
+ $("#out-of-view-notification").empty();
+ $("#out-of-view-notification").stop(true, true);
+ $("#out-of-view-notification").hide();
};
exports.reify_message_id = function (opts) {
@@ -706,31 +706,31 @@ exports.reify_message_id = function (opts) {
// If a message ID that we're currently storing (as a link) has changed,
// update that link as well
- for (const e of $('#out-of-view-notification a')) {
+ for (const e of $("#out-of-view-notification a")) {
const elem = $(e);
- const message_id = elem.data('message-id');
+ const message_id = elem.data("message-id");
if (message_id === old_id) {
- elem.data('message-id', new_id);
+ elem.data("message-id", new_id);
}
}
};
exports.register_click_handlers = function () {
- $('#out-of-view-notification').on('click', '.compose_notification_narrow_by_topic', (e) => {
- const message_id = $(e.currentTarget).data('message-id');
- narrow.by_topic(message_id, {trigger: 'compose_notification'});
+ $("#out-of-view-notification").on("click", ".compose_notification_narrow_by_topic", (e) => {
+ const message_id = $(e.currentTarget).data("message-id");
+ narrow.by_topic(message_id, {trigger: "compose_notification"});
e.stopPropagation();
e.preventDefault();
});
- $('#out-of-view-notification').on('click', '.compose_notification_scroll_to_message', (e) => {
- const message_id = $(e.currentTarget).data('message-id');
+ $("#out-of-view-notification").on("click", ".compose_notification_scroll_to_message", (e) => {
+ const message_id = $(e.currentTarget).data("message-id");
current_msg_list.select_id(message_id);
navigate.scroll_to_selected();
e.stopPropagation();
e.preventDefault();
});
- $('#out-of-view-notification').on('click', '.out-of-view-notification-close', (e) => {
+ $("#out-of-view-notification").on("click", ".out-of-view-notification-close", (e) => {
exports.clear_compose_notifications();
e.stopPropagation();
e.preventDefault();
diff --git a/static/js/overlays.js b/static/js/overlays.js
index f649cc33845..dc47a521f4c 100644
--- a/static/js/overlays.js
+++ b/static/js/overlays.js
@@ -17,27 +17,27 @@ exports.is_modal_open = function () {
};
exports.info_overlay_open = function () {
- return open_overlay_name === 'informationalOverlays';
+ return open_overlay_name === "informationalOverlays";
};
exports.settings_open = function () {
- return open_overlay_name === 'settings';
+ return open_overlay_name === "settings";
};
exports.streams_open = function () {
- return open_overlay_name === 'subscriptions';
+ return open_overlay_name === "subscriptions";
};
exports.lightbox_open = function () {
- return open_overlay_name === 'lightbox';
+ return open_overlay_name === "lightbox";
};
exports.drafts_open = function () {
- return open_overlay_name === 'drafts';
+ return open_overlay_name === "drafts";
};
exports.recent_topics_open = function () {
- return open_overlay_name === 'recent_topics';
+ return open_overlay_name === "recent_topics";
};
// To address bugs where mouse might apply to the streams/settings
@@ -48,14 +48,14 @@ exports.recent_topics_open = function () {
// This is kinda hacky; it only works for modals within overlays, and
// we need to make sure it gets re-enabled when the modal closes.
exports.disable_background_mouse_events = function () {
- $('.overlay.show').attr("style", "pointer-events: none");
+ $(".overlay.show").attr("style", "pointer-events: none");
};
// This removes only the inline-style of the element that
// was added in disable_background_mouse_events and
// enables the background mouse events.
exports.enable_background_mouse_events = function () {
- $('.overlay.show').attr("style", null);
+ $(".overlay.show").attr("style", null);
};
exports.active_modal = function () {
@@ -63,41 +63,41 @@ exports.active_modal = function () {
blueslip.error("Programming error — Called active_modal when there is no modal open");
return;
}
- return '#' + $(".modal.in").attr("id");
+ return "#" + $(".modal.in").attr("id");
};
exports.open_overlay = function (opts) {
popovers.hide_all();
if (!opts.name || !opts.overlay || !opts.on_close) {
- blueslip.error('Programming error in open_overlay');
+ blueslip.error("Programming error in open_overlay");
return;
}
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;
}
- blueslip.debug('open overlay: ' + opts.name);
+ blueslip.debug("open overlay: " + opts.name);
// Our overlays are kind of crufty...we have an HTML id
// attribute for them and then a data-overlay attribute for
// them. Make sure they match.
- if (opts.overlay.attr('data-overlay') !== opts.name) {
- blueslip.error('Bad overlay setup for ' + opts.name);
+ if (opts.overlay.attr("data-overlay") !== opts.name) {
+ blueslip.error("Bad overlay setup for " + opts.name);
return;
}
open_overlay_name = opts.name;
active_overlay = opts.overlay;
- opts.overlay.addClass('show');
+ opts.overlay.addClass("show");
opts.overlay.attr("aria-hidden", "false");
- $('.app').attr("aria-hidden", "true");
- $('.fixed-app').attr("aria-hidden", "true");
- $('.header').attr("aria-hidden", "true");
+ $(".app").attr("aria-hidden", "true");
+ $(".fixed-app").attr("aria-hidden", "true");
+ $(".header").attr("aria-hidden", "true");
close_handler = function () {
opts.on_close();
@@ -107,22 +107,22 @@ exports.open_overlay = function (opts) {
exports.open_modal = function (selector) {
if (selector === undefined) {
- blueslip.error('Undefined selector was passed into open_modal');
+ blueslip.error("Undefined selector was passed into open_modal");
return;
}
- if (selector[0] !== '#') {
- blueslip.error('Non-id-based selector passed in to open_modal: ' + selector);
+ if (selector[0] !== "#") {
+ blueslip.error("Non-id-based selector passed in to open_modal: " + selector);
return;
}
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;
}
- blueslip.debug('open modal: ' + selector);
+ blueslip.debug("open modal: " + selector);
const elem = $(selector).expectOne();
elem.modal("show").attr("aria-hidden", false);
@@ -140,18 +140,18 @@ exports.close_overlay = function (name) {
}
if (name === undefined) {
- blueslip.error('Undefined name was passed into close_overlay');
+ blueslip.error("Undefined name was passed into close_overlay");
return;
}
- blueslip.debug('close overlay: ' + name);
+ blueslip.debug("close overlay: " + name);
active_overlay.removeClass("show");
active_overlay.attr("aria-hidden", "true");
- $('.app').attr("aria-hidden", "false");
- $('.fixed-app').attr("aria-hidden", "false");
- $('.header').attr("aria-hidden", "false");
+ $(".app").attr("aria-hidden", "false");
+ $(".fixed-app").attr("aria-hidden", "false");
+ $(".header").attr("aria-hidden", "false");
if (!close_handler) {
blueslip.error("Overlay close handler for " + name + " not properly setup.");
@@ -163,7 +163,7 @@ exports.close_overlay = function (name) {
exports.close_active = function () {
if (!open_overlay_name) {
- blueslip.warn('close_active() called without checking is_active()');
+ blueslip.warn("close_active() called without checking is_active()");
return;
}
@@ -172,12 +172,12 @@ exports.close_active = function () {
exports.close_modal = function (selector) {
if (selector === undefined) {
- blueslip.error('Undefined selector was passed into close_modal');
+ blueslip.error("Undefined selector was passed into close_modal");
return;
}
if (!exports.is_modal_open()) {
- blueslip.warn('close_active_modal() called without checking is_modal_open()');
+ blueslip.warn("close_active_modal() called without checking is_modal_open()");
return;
}
@@ -187,7 +187,7 @@ exports.close_modal = function (selector) {
return;
}
- blueslip.debug('close modal: ' + selector);
+ blueslip.debug("close modal: " + selector);
const elem = $(selector).expectOne();
elem.modal("hide").attr("aria-hidden", true);
@@ -198,7 +198,7 @@ exports.close_modal = function (selector) {
exports.close_active_modal = function () {
if (!exports.is_modal_open()) {
- blueslip.warn('close_active_modal() called without checking is_modal_open()');
+ blueslip.warn("close_active_modal() called without checking is_modal_open()");
return;
}
@@ -212,7 +212,7 @@ exports.close_for_hash_change = function () {
exports.open_settings = function () {
exports.open_overlay({
- name: 'settings',
+ name: "settings",
overlay: $("#settings_overlay_container"),
on_close: function () {
hashchange.exit_overlay();
diff --git a/static/js/panels.js b/static/js/panels.js
index 446bb78e094..158d0592f0f 100644
--- a/static/js/panels.js
+++ b/static/js/panels.js
@@ -6,7 +6,7 @@ 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()
+ + $(".header").height()
+ parseInt($(".header").css("paddingBottom"), 10);
$("#floating_recipient_bar").css("top", frb_top + "px");
};
@@ -50,7 +50,7 @@ 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 === '' ||
+ if (page_params.realm_description === "" ||
page_params.realm_description.startsWith("Organization imported from")) {
$("[data-process='profile-incomplete']").show();
} else {
@@ -93,7 +93,7 @@ exports.initialize = function () {
$(".accept-bankruptcy").on("click", function (e) {
e.preventDefault();
$(this).closest(".alert").hide();
- $('.bankruptcy-loader').show();
+ $(".bankruptcy-loader").show();
setTimeout(unread_ops.mark_all_as_read, 1000);
resize_app();
});
diff --git a/static/js/people.js b/static/js/people.js
index 50319742ae6..7397547c46d 100644
--- a/static/js/people.js
+++ b/static/js/people.js
@@ -1,6 +1,6 @@
const util = require("./util");
require("unorm"); // String.prototype.normalize polyfill for IE11
-const FoldDict = require('./fold_dict').FoldDict;
+const FoldDict = require("./fold_dict").FoldDict;
const typeahead = require("../shared/js/typeahead");
const settings_data = require("./settings_data");
@@ -41,13 +41,13 @@ exports.init = function () {
exports.init();
function split_to_ints(lst) {
- return lst.split(',').map((s) => parseInt(s, 10));
+ 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);
+ blueslip.error("Unknown user_id in get_by_user_id: " + user_id);
return;
}
return people_by_user_id_dict.get(user_id);
@@ -62,8 +62,8 @@ 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,
);
}
@@ -87,7 +87,7 @@ exports.id_matches_email_operand = function (user_id, email) {
if (!person) {
// The user may type bad data into the search bar, so
// we don't complain too loud here.
- blueslip.debug('User email operand unknown: ' + email);
+ blueslip.debug("User email operand unknown: " + email);
return false;
}
@@ -114,13 +114,13 @@ exports.get_visible_email = function (user) {
exports.get_user_id = function (email) {
const person = exports.get_by_email(email);
if (person === undefined) {
- const error_msg = 'Unknown email for get_user_id: ' + email;
+ const error_msg = "Unknown email for get_user_id: " + email;
blueslip.error(error_msg);
return;
}
const user_id = person.user_id;
if (!user_id) {
- blueslip.error('No user_id found for ' + email);
+ blueslip.error("No user_id found for " + email);
return;
}
@@ -145,7 +145,7 @@ function sort_numerically(user_ids) {
}
exports.huddle_string = function (message) {
- if (message.type !== 'private') {
+ if (message.type !== "private") {
return;
}
@@ -165,7 +165,7 @@ exports.huddle_string = function (message) {
user_ids = sort_numerically(user_ids);
- return user_ids.join(',');
+ return user_ids.join(",");
};
exports.user_ids_string_to_emails_string = function (user_ids_string) {
@@ -177,7 +177,7 @@ exports.user_ids_string_to_emails_string = function (user_ids_string) {
});
if (!emails.every(Boolean)) {
- blueslip.warn('Unknown user ids: ' + user_ids_string);
+ blueslip.warn("Unknown user ids: " + user_ids_string);
return;
}
@@ -185,11 +185,11 @@ exports.user_ids_string_to_emails_string = function (user_ids_string) {
emails.sort();
- return emails.join(',');
+ return emails.join(",");
};
exports.user_ids_string_to_ids_array = function (user_ids_string) {
- const user_ids = user_ids_string.split(',');
+ const user_ids = user_ids_string.split(",");
const ids = user_ids.map((id) => Number(id));
return ids;
};
@@ -208,7 +208,7 @@ exports.reply_to_to_user_ids_string = function (emails_string) {
// This is basically emails_strings_to_user_ids_string
// without blueslip warnings, since it can be called with
// invalid data.
- const emails = emails_string.split(',');
+ const emails = emails_string.split(",");
let user_ids = emails.map((email) => {
const person = exports.get_by_email(email);
@@ -221,7 +221,7 @@ exports.reply_to_to_user_ids_string = function (emails_string) {
user_ids = sort_numerically(user_ids);
- return user_ids.join(',');
+ return user_ids.join(",");
};
exports.get_user_time_preferences = function (user_id) {
@@ -254,7 +254,7 @@ exports.get_user_type = function (user_id) {
};
exports.emails_strings_to_user_ids_string = function (emails_string) {
- const emails = emails_string.split(',');
+ const emails = emails_string.split(",");
return exports.email_list_to_user_ids_string(emails);
};
@@ -265,13 +265,13 @@ exports.email_list_to_user_ids_string = function (emails) {
});
if (!user_ids.every(Boolean)) {
- blueslip.warn('Unknown emails: ' + emails);
+ blueslip.warn("Unknown emails: " + emails);
return;
}
user_ids = sort_numerically(user_ids);
- return user_ids.join(',');
+ return user_ids.join(",");
};
exports.safe_full_names = function (user_ids) {
@@ -282,7 +282,7 @@ exports.safe_full_names = function (user_ids) {
names = names.filter(Boolean);
- return names.join(', ');
+ return names.join(", ");
};
exports.get_full_name = function (user_id) {
@@ -301,7 +301,7 @@ exports.get_recipients = function (user_ids_string) {
}
const names = other_ids.map(exports.get_full_name).sort();
- return names.join(', ');
+ return names.join(", ");
};
exports.pm_reply_user_string = function (message) {
@@ -311,7 +311,7 @@ exports.pm_reply_user_string = function (message) {
return;
}
- return user_ids.join(',');
+ return user_ids.join(",");
};
exports.pm_reply_to = function (message) {
@@ -324,15 +324,15 @@ exports.pm_reply_to = function (message) {
const emails = user_ids.map((user_id) => {
const person = people_by_user_id_dict.get(user_id);
if (!person) {
- blueslip.error('Unknown user id in message: ' + user_id);
- return '?';
+ blueslip.error("Unknown user id in message: " + user_id);
+ return "?";
}
return person.email;
});
emails.sort();
- const reply_to = emails.join(',');
+ const reply_to = emails.join(",");
return reply_to;
};
@@ -363,7 +363,7 @@ exports.concat_huddle = function (user_ids, user_id) {
how to encode huddles.
*/
const sorted_ids = sort_numerically([...user_ids, user_id]);
- return sorted_ids.join(',');
+ return sorted_ids.join(",");
};
exports.pm_lookup_key = function (user_ids_string) {
@@ -374,16 +374,16 @@ exports.pm_lookup_key = function (user_ids_string) {
*/
let user_ids = split_to_ints(user_ids_string);
user_ids = sorted_other_user_ids(user_ids);
- return user_ids.join(',');
+ return user_ids.join(",");
};
exports.all_user_ids_in_pm = function (message) {
- if (message.type !== 'private') {
+ if (message.type !== "private") {
return;
}
if (message.display_recipient.length === 0) {
- blueslip.error('Empty recipient list in message');
+ blueslip.error("Empty recipient list in message");
return;
}
@@ -394,12 +394,12 @@ exports.all_user_ids_in_pm = function (message) {
};
exports.pm_with_user_ids = function (message) {
- if (message.type !== 'private') {
+ if (message.type !== "private") {
return;
}
if (message.display_recipient.length === 0) {
- blueslip.error('Empty recipient list in message');
+ blueslip.error("Empty recipient list in message");
return;
}
@@ -409,12 +409,12 @@ exports.pm_with_user_ids = function (message) {
};
exports.group_pm_with_user_ids = function (message) {
- if (message.type !== 'private') {
+ if (message.type !== "private") {
return;
}
if (message.display_recipient.length === 0) {
- blueslip.error('Empty recipient list in message');
+ blueslip.error("Empty recipient list in message");
return;
}
@@ -439,12 +439,12 @@ exports.pm_perma_link = function (message) {
let suffix;
if (user_ids.length >= 3) {
- suffix = 'group';
+ suffix = "group";
} else {
- suffix = 'pm';
+ suffix = "pm";
}
- const slug = user_ids.join(',') + '-' + suffix;
+ const slug = user_ids.join(",") + "-" + suffix;
const uri = "#narrow/pm-with/" + slug;
return uri;
};
@@ -459,18 +459,18 @@ exports.pm_with_url = function (message) {
let suffix;
if (user_ids.length > 1) {
- suffix = 'group';
+ suffix = "group";
} else {
const person = exports.get_by_user_id(user_ids[0]);
if (person && person.email) {
- suffix = person.email.split('@')[0].toLowerCase();
+ suffix = person.email.split("@")[0].toLowerCase();
} else {
- blueslip.error('Unknown people in message');
- suffix = 'unk';
+ blueslip.error("Unknown people in message");
+ suffix = "unk";
}
}
- const slug = user_ids.join(',') + '-' + suffix;
+ const slug = user_ids.join(",") + "-" + suffix;
const uri = "#narrow/pm-with/" + slug;
return uri;
};
@@ -479,7 +479,7 @@ exports.update_email_in_reply_to = function (reply_to, user_id, new_email) {
// We try to replace an old email with a new email in a reply_to,
// but we try to avoid changing the reply_to if we don't have to,
// and we don't warn on any errors.
- let emails = reply_to.split(',');
+ let emails = reply_to.split(",");
const persons = emails.map((email) => people_dict.get(email.trim()));
@@ -500,11 +500,11 @@ exports.update_email_in_reply_to = function (reply_to, user_id, new_email) {
return person.email;
});
- return emails.join(',');
+ return emails.join(",");
};
exports.pm_with_operand_ids = function (operand) {
- let emails = operand.split(',');
+ let emails = operand.split(",");
emails = emails.map((email) => email.trim());
let persons = emails.map((email) => people_dict.get(email));
@@ -531,14 +531,14 @@ exports.emails_to_slug = function (emails_string) {
return;
}
- slug += '-';
+ slug += "-";
- const emails = emails_string.split(',');
+ const emails = emails_string.split(",");
if (emails.length === 1) {
- slug += emails[0].split('@')[0].toLowerCase();
+ slug += emails[0].split("@")[0].toLowerCase();
} else {
- slug += 'group';
+ slug += "group";
}
return slug;
@@ -574,12 +574,12 @@ exports.exclude_me_from_string = function (user_ids_string) {
// We either have a message to ourself, an empty
// slug, or a message to somebody else where we weren't
// part of the slug.
- return user_ids.join(',');
+ return user_ids.join(",");
}
user_ids = user_ids.filter((user_id) => !exports.is_my_user_id(user_id));
- return user_ids.join(',');
+ return user_ids.join(",");
};
exports.format_small_avatar_url = function (raw_url) {
@@ -605,7 +605,7 @@ exports.sender_is_guest = function (message) {
function gravatar_url_for_email(email) {
const hash = md5(email.toLowerCase());
- const avatar_url = 'https://secure.gravatar.com/avatar/' + hash + '?d=identicon';
+ const avatar_url = "https://secure.gravatar.com/avatar/" + hash + "?d=identicon";
const small_avatar_url = exports.format_small_avatar_url(avatar_url);
return small_avatar_url;
}
@@ -619,7 +619,7 @@ exports.small_avatar_url_for_person = function (person) {
return gravatar_url_for_email(person.email);
}
- return exports.format_small_avatar_url('/avatar/' + person.user_id);
+ return exports.format_small_avatar_url("/avatar/" + person.user_id);
};
exports.sender_info_with_small_avatar_urls_for_sender_ids = function (sender_ids) {
@@ -668,7 +668,7 @@ exports.small_avatar_url = function (message) {
// required to take advantage of the user_avatar_url_field_optional
// optimization, which saves a huge amount of network traffic on
// servers with 10,000s of user accounts.
- return exports.format_small_avatar_url('/avatar/' + person.user_id);
+ return exports.format_small_avatar_url("/avatar/" + person.user_id);
}
// For computing the user's email, we first trust the person
@@ -888,7 +888,7 @@ exports.build_termlet_matcher = function (termlet) {
// Only ignore diacritics if the query is plain ascii
full_name = typeahead.remove_diacritics(full_name);
}
- const names = full_name.toLowerCase().split(' ');
+ const names = full_name.toLowerCase().split(" ");
return names.some((name) => name.startsWith(termlet));
};
@@ -957,7 +957,7 @@ exports.get_actual_name_from_user_id = (user_id) => {
const person = people_by_user_id_dict.get(user_id);
if (!person) {
- blueslip.error('Unknown user_id: ' + user_id);
+ blueslip.error("Unknown user_id: " + user_id);
return;
}
@@ -1049,20 +1049,20 @@ exports.is_duplicate_full_name = function (full_name) {
};
exports.get_mention_syntax = function (full_name, user_id, silent) {
- let mention = '';
+ let mention = "";
if (silent) {
- mention += '@_**';
+ mention += "@_**";
} else {
- mention += '@**';
+ mention += "@**";
}
mention += full_name;
if (!user_id) {
- blueslip.warn('get_mention_syntax called without user_id.');
+ blueslip.warn("get_mention_syntax called without user_id.");
}
if (exports.is_duplicate_full_name(full_name) && user_id) {
- mention += '|' + user_id;
+ mention += "|" + user_id;
}
- mention += '**';
+ mention += "**";
return mention;
};
@@ -1081,7 +1081,7 @@ exports._add_user = function add(person) {
// with cross-realm bots, zephyr users, etc., deactivated
// users, where we are probably fine for now not to
// find them via user_id lookups.
- blueslip.warn('No user_id provided for ' + person.email);
+ blueslip.warn("No user_id provided for " + person.email);
}
exports.track_duplicate_full_name(person.full_name, person.user_id);
@@ -1122,7 +1122,7 @@ exports.report_late_add = function (user_id, email) {
// This function is extracted to make unit testing easier,
// plus we may fine-tune our reporting here for different
// types of realms.
- const msg = 'Added user late: user_id=' + user_id + ' email=' + email;
+ const msg = "Added user late: user_id=" + user_id + " email=" + email;
if (reload_state.is_in_progress()) {
blueslip.log(msg);
@@ -1135,13 +1135,13 @@ exports.extract_people_from_message = function (message) {
let involved_people;
switch (message.type) {
- case 'stream':
+ case "stream":
involved_people = [{full_name: message.sender_full_name,
user_id: message.sender_id,
email: message.sender_email}];
break;
- case 'private':
+ case "private":
involved_people = message.display_recipient;
break;
@@ -1174,7 +1174,7 @@ exports.extract_people_from_message = function (message) {
};
function safe_lower(s) {
- return (s || '').toLowerCase();
+ return (s || "").toLowerCase();
}
exports.matches_user_settings_search = function (person, value) {
@@ -1200,7 +1200,7 @@ exports.filter_for_user_settings_search = function (persons, query) {
};
exports.maybe_incr_recipient_count = function (message) {
- if (message.type !== 'private') {
+ if (message.type !== "private") {
return;
}
@@ -1287,8 +1287,8 @@ exports.is_my_user_id = function (user_id) {
return false;
}
- if (typeof user_id !== 'number') {
- blueslip.error('user_id is a string in my_user_id: ' + user_id);
+ if (typeof user_id !== "number") {
+ blueslip.error("user_id is a string in my_user_id: " + user_id);
user_id = parseInt(user_id, 10);
}
diff --git a/static/js/pm_conversations.js b/static/js/pm_conversations.js
index a4d8136fb50..2da978153b2 100644
--- a/static/js/pm_conversations.js
+++ b/static/js/pm_conversations.js
@@ -1,4 +1,4 @@
-const FoldDict = require('./fold_dict').FoldDict;
+const FoldDict = require("./fold_dict").FoldDict;
const partners = new Set();
@@ -25,7 +25,7 @@ exports.recent = (function () {
}
user_ids.sort((a, b) => a - b);
- const user_ids_string = user_ids.join(',');
+ const user_ids_string = user_ids.join(",");
let conversation = recent_message_ids.get(user_ids_string);
if (conversation === undefined) {
diff --git a/static/js/pm_list.js b/static/js/pm_list.js
index c1bd8281d8b..6552b0bd9c5 100644
--- a/static/js/pm_list.js
+++ b/static/js/pm_list.js
@@ -11,7 +11,7 @@ function get_filter_li() {
function update_count_in_dom(count_span, value_span, count) {
if (count === 0) {
count_span.hide();
- value_span.text('');
+ value_span.text("");
} else {
count_span.show();
value_span.text(count);
@@ -19,8 +19,8 @@ function update_count_in_dom(count_span, value_span, count) {
}
function set_count(count) {
- const count_span = get_filter_li().find('.count');
- const value_span = count_span.find('.value');
+ const count_span = get_filter_li().find(".count");
+ const value_span = count_span.find(".value");
update_count_in_dom(count_span, value_span, count);
}
@@ -42,7 +42,7 @@ exports.get_active_user_ids_string = function () {
return;
}
- const emails = filter.operands('pm-with')[0];
+ const emails = filter.operands("pm-with")[0];
if (!emails) {
return;
@@ -63,7 +63,7 @@ exports._get_convos = function () {
const num_unread = unread.num_unread_for_person(user_ids_string);
- const is_group = user_ids_string.includes(',');
+ const is_group = user_ids_string.includes(",");
const is_active = user_ids_string === active_user_ids_string;
@@ -71,7 +71,7 @@ exports._get_convos = function () {
let fraction_present;
if (is_group) {
- user_circle_class = 'user_circle_fraction';
+ user_circle_class = "user_circle_fraction";
fraction_present = buddy_data.huddle_fraction_present(user_ids_string);
} else {
const user_id = parseInt(user_ids_string, 10);
@@ -79,7 +79,7 @@ exports._get_convos = function () {
const recipient_user_obj = people.get_by_user_id(user_id);
if (recipient_user_obj.is_bot) {
- user_circle_class = 'user_circle_green';
+ user_circle_class = "user_circle_green";
}
}
@@ -101,7 +101,7 @@ exports._get_convos = function () {
};
exports._build_private_messages_list = function () {
- const finish = blueslip.start_timing('render pm list');
+ const finish = blueslip.start_timing("render pm list");
const convos = exports._get_convos();
const dom_ast = pm_list_dom.pm_ul(convos);
finish();
@@ -122,7 +122,7 @@ exports.update_private_messages = function () {
}
function find() {
- return container.find('ul');
+ return container.find("ul");
}
vdom.update(replace_content, find, new_dom, prior_dom);
@@ -137,7 +137,7 @@ exports.is_all_privates = function () {
return false;
}
- return filter.operands('is').includes("private");
+ return filter.operands("is").includes("private");
};
exports.expand = function () {
@@ -145,7 +145,7 @@ exports.expand = function () {
stream_popover.hide_topic_popover();
exports.update_private_messages();
if (exports.is_all_privates()) {
- $(".top_left_private_messages").addClass('active-filter');
+ $(".top_left_private_messages").addClass("active-filter");
}
};
diff --git a/static/js/pm_list_dom.js b/static/js/pm_list_dom.js
index 8a71493b7c1..918007922cb 100644
--- a/static/js/pm_list_dom.js
+++ b/static/js/pm_list_dom.js
@@ -1,4 +1,4 @@
-const render_pm_list_item = require('../templates/pm_list_item.hbs');
+const render_pm_list_item = require("../templates/pm_list_item.hbs");
exports.keyed_pm_li = (convo) => {
const render = () => render_pm_list_item(convo);
@@ -17,8 +17,8 @@ exports.keyed_pm_li = (convo) => {
exports.pm_ul = (convos) => {
const attrs = [
- ['class', 'expanded_private_messages'],
- ['data-name', 'private'],
+ ["class", "expanded_private_messages"],
+ ["data-name", "private"],
];
return vdom.ul({
attrs: attrs,
diff --git a/static/js/poll_widget.js b/static/js/poll_widget.js
index 6b35859d1d9..6561fcb0703 100644
--- a/static/js/poll_widget.js
+++ b/static/js/poll_widget.js
@@ -1,5 +1,5 @@
-const render_widgets_poll_widget = require('../templates/widgets/poll_widget.hbs');
-const render_widgets_poll_widget_results = require('../templates/widgets/poll_widget_results.hbs');
+const render_widgets_poll_widget = require("../templates/widgets/poll_widget.hbs");
+const render_widgets_poll_widget_results = require("../templates/widgets/poll_widget_results.hbs");
exports.poll_data_holder = function (is_my_poll, question, options) {
// This object just holds data for a poll, although it
@@ -68,7 +68,7 @@ exports.poll_data_holder = function (is_my_poll, question, options) {
new_option: {
outbound: function (option) {
const event = {
- type: 'new_option',
+ type: "new_option",
idx: my_idx,
option: option,
};
@@ -80,7 +80,7 @@ exports.poll_data_holder = function (is_my_poll, question, options) {
inbound: function (sender_id, data) {
const idx = data.idx;
- const key = sender_id + ',' + idx;
+ const key = sender_id + "," + idx;
const option = data.option;
const votes = new Map();
@@ -99,7 +99,7 @@ exports.poll_data_holder = function (is_my_poll, question, options) {
question: {
outbound: function (question) {
const event = {
- type: 'question',
+ type: "question",
question: question,
};
if (is_my_poll) {
@@ -124,7 +124,7 @@ exports.poll_data_holder = function (is_my_poll, question, options) {
}
const event = {
- type: 'vote',
+ type: "vote",
key: key,
vote: vote,
};
@@ -138,7 +138,7 @@ exports.poll_data_holder = function (is_my_poll, question, options) {
const option = key_to_option.get(key);
if (option === undefined) {
- blueslip.warn('unknown key for poll: ' + key);
+ blueslip.warn("unknown key for poll: " + key);
return;
}
@@ -167,7 +167,7 @@ exports.poll_data_holder = function (is_my_poll, question, options) {
// function to add all options added along with the /poll command
for (const [i, option] of options.entries()) {
- self.handle.new_option.inbound('canned', {
+ self.handle.new_option.inbound("canned", {
idx: i,
option: option,
});
@@ -180,10 +180,10 @@ exports.activate = function (opts) {
const elem = opts.elem;
const callback = opts.callback;
- let question = '';
+ let question = "";
let options = [];
if (opts.extra_data) {
- question = opts.extra_data.question || '';
+ question = opts.extra_data.question || "";
options = opts.extra_data.options || [];
}
@@ -191,39 +191,39 @@ exports.activate = function (opts) {
const poll_data = exports.poll_data_holder(is_my_poll, question, options);
function update_edit_controls() {
- const has_question = elem.find('input.poll-question').val().trim() !== '';
- elem.find('button.poll-question-check').toggle(has_question);
+ const has_question = elem.find("input.poll-question").val().trim() !== "";
+ elem.find("button.poll-question-check").toggle(has_question);
}
function render_question() {
const question = poll_data.get_question();
const input_mode = poll_data.get_input_mode();
const can_edit = is_my_poll && !input_mode;
- const has_question = question.trim() !== '';
+ const has_question = question.trim() !== "";
const can_vote = has_question;
const waiting = !is_my_poll && !has_question;
const author_help = is_my_poll && !has_question;
- elem.find('.poll-question-header').toggle(!input_mode);
- elem.find('.poll-question-header').text(question);
- elem.find('.poll-edit-question').toggle(can_edit);
+ elem.find(".poll-question-header").toggle(!input_mode);
+ elem.find(".poll-question-header").text(question);
+ elem.find(".poll-edit-question").toggle(can_edit);
update_edit_controls();
- elem.find('.poll-question-bar').toggle(input_mode);
- elem.find('.poll-option-bar').toggle(can_vote);
+ elem.find(".poll-question-bar").toggle(input_mode);
+ elem.find(".poll-option-bar").toggle(can_vote);
- elem.find('.poll-please-wait').toggle(waiting);
+ elem.find(".poll-please-wait").toggle(waiting);
- elem.find('.poll-author-help').toggle(author_help);
+ elem.find(".poll-author-help").toggle(author_help);
}
function start_editing() {
poll_data.set_input_mode();
const question = poll_data.get_question();
- elem.find('input.poll-question').val(question);
+ elem.find("input.poll-question").val(question);
render_question();
- elem.find('input.poll-question').focus();
+ elem.find("input.poll-question").focus();
}
function abort_edit() {
@@ -238,7 +238,7 @@ exports.activate = function (opts) {
// We should disable the button for blank questions,
// so this is just defensive code.
- if (new_question.trim() === '') {
+ if (new_question.trim() === "") {
new_question = old_question;
}
@@ -265,11 +265,11 @@ exports.activate = function (opts) {
return;
}
- if (option === '') {
+ if (option === "") {
return;
}
- poll_option_input.val('').focus();
+ poll_option_input.val("").focus();
const data = poll_data.handle.new_option.outbound(option);
callback(data);
@@ -284,12 +284,12 @@ exports.activate = function (opts) {
const html = render_widgets_poll_widget();
elem.html(html);
- elem.find('input.poll-question').on('keyup', (e) => {
+ elem.find("input.poll-question").on("keyup", (e) => {
e.stopPropagation();
update_edit_controls();
});
- elem.find('input.poll-question').on('keydown', (e) => {
+ elem.find("input.poll-question").on("keydown", (e) => {
e.stopPropagation();
if (e.keyCode === 13) {
@@ -303,27 +303,27 @@ exports.activate = function (opts) {
}
});
- elem.find('.poll-edit-question').on('click', (e) => {
+ elem.find(".poll-edit-question").on("click", (e) => {
e.stopPropagation();
start_editing();
});
- elem.find("button.poll-question-check").on('click', (e) => {
+ elem.find("button.poll-question-check").on("click", (e) => {
e.stopPropagation();
submit_question();
});
- elem.find("button.poll-question-remove").on('click', (e) => {
+ elem.find("button.poll-question-remove").on("click", (e) => {
e.stopPropagation();
abort_edit();
});
- elem.find("button.poll-option").on('click', (e) => {
+ elem.find("button.poll-option").on("click", (e) => {
e.stopPropagation();
submit_option();
});
- elem.find('input.poll-option').on('keydown', (e) => {
+ elem.find("input.poll-option").on("keydown", (e) => {
e.stopPropagation();
if (e.keyCode === 13) {
@@ -332,7 +332,7 @@ exports.activate = function (opts) {
}
if (e.keyCode === 27) {
- $('input.poll-option').val('');
+ $("input.poll-option").val("");
return;
}
});
@@ -343,11 +343,11 @@ exports.activate = function (opts) {
const widget_data = poll_data.get_widget_data();
const html = render_widgets_poll_widget_results(widget_data);
- elem.find('ul.poll-widget').html(html);
+ elem.find("ul.poll-widget").html(html);
- elem.find("button.poll-vote").off('click').on('click', (e) => {
+ elem.find("button.poll-vote").off("click").on("click", (e) => {
e.stopPropagation();
- const key = $(e.target).attr('data-key');
+ const key = $(e.target).attr("data-key");
submit_vote(key);
});
}
diff --git a/static/js/popovers.js b/static/js/popovers.js
index 4f86074637c..1feda2bb060 100644
--- a/static/js/popovers.js
+++ b/static/js/popovers.js
@@ -1,15 +1,15 @@
const util = require("./util");
const settings_data = require("./settings_data");
const confirmDatePlugin = require("flatpickr/dist/plugins/confirmDate/confirmDate.js");
-const render_actions_popover_content = require('../templates/actions_popover_content.hbs');
-const render_mobile_message_buttons_popover = require('../templates/mobile_message_buttons_popover.hbs');
-const render_mobile_message_buttons_popover_content = require('../templates/mobile_message_buttons_popover_content.hbs');
-const render_no_arrow_popover = require('../templates/no_arrow_popover.hbs');
-const render_remind_me_popover_content = require('../templates/remind_me_popover_content.hbs');
-const render_user_group_info_popover = require('../templates/user_group_info_popover.hbs');
-const render_user_group_info_popover_content = require('../templates/user_group_info_popover_content.hbs');
-const render_user_info_popover_content = require('../templates/user_info_popover_content.hbs');
-const render_user_info_popover_title = require('../templates/user_info_popover_title.hbs');
+const render_actions_popover_content = require("../templates/actions_popover_content.hbs");
+const render_mobile_message_buttons_popover = require("../templates/mobile_message_buttons_popover.hbs");
+const render_mobile_message_buttons_popover_content = require("../templates/mobile_message_buttons_popover_content.hbs");
+const render_no_arrow_popover = require("../templates/no_arrow_popover.hbs");
+const render_remind_me_popover_content = require("../templates/remind_me_popover_content.hbs");
+const render_user_group_info_popover = require("../templates/user_group_info_popover.hbs");
+const render_user_group_info_popover_content = require("../templates/user_group_info_popover_content.hbs");
+const render_user_info_popover_content = require("../templates/user_info_popover_content.hbs");
+const render_user_info_popover_title = require("../templates/user_info_popover_title.hbs");
const render_user_profile_modal = require("../templates/user_profile_modal.hbs");
let current_actions_popover_elem;
@@ -21,7 +21,7 @@ let userlist_placement = "right";
let list_of_popovers = [];
function elem_to_user_id(elem) {
- return parseInt(elem.attr('data-user-id'), 10);
+ return parseInt(elem.attr("data-user-id"), 10);
}
// this utilizes the proxy pattern to intercept all calls to $.fn.popover
@@ -47,18 +47,18 @@ function elem_to_user_id(elem) {
function copy_email_handler(e) {
const email_el = $(e.trigger.parentElement);
- const copy_icon = email_el.find('i');
+ const copy_icon = email_el.find("i");
// only change the parent element's text back to email
// and not overwrite the tooltip.
const email_textnode = email_el[0].childNodes[2];
- email_el.addClass('email_copied');
- email_textnode.nodeValue = i18n.t('Email copied');
+ email_el.addClass("email_copied");
+ email_textnode.nodeValue = i18n.t("Email copied");
setTimeout(() => {
- email_el.removeClass('email_copied');
- email_textnode.nodeValue = copy_icon.attr('data-clipboard-text');
+ email_el.removeClass("email_copied");
+ email_textnode.nodeValue = copy_icon.attr("data-clipboard-text");
}, 1500);
e.clearSelection();
}
@@ -69,10 +69,10 @@ function init_email_clipboard() {
who have names that would overflow past the right
edge of our user mention popup.
*/
- $('.user_popover_email').each(function () {
+ $(".user_popover_email").each(function () {
if (this.clientWidth < this.scrollWidth) {
const email_el = $(this);
- const copy_email_icon = email_el.find('i');
+ const copy_email_icon = email_el.find("i");
/*
For deactivated users, the copy-email icon will
@@ -81,9 +81,9 @@ function init_email_clipboard() {
users.
*/
if (copy_email_icon[0]) {
- copy_email_icon.removeClass('hide_copy_icon');
+ copy_email_icon.removeClass("hide_copy_icon");
const copy_email_clipboard = new ClipboardJS(copy_email_icon[0]);
- copy_email_clipboard.on('success', copy_email_handler);
+ copy_email_clipboard.on("success", copy_email_handler);
}
}
});
@@ -106,9 +106,9 @@ function calculate_info_popover_placement(size, elt) {
if (!(ypos + size / 2 < message_viewport.height() &&
ypos > size / 2)) {
if (ypos + size < message_viewport.height()) {
- return 'bottom';
+ return "bottom";
} else if (ypos > size) {
- return 'top';
+ return "top";
}
}
}
@@ -213,7 +213,7 @@ function render_user_info_popover(user, popover_element, is_sender_popover, priv
// TODO: Determine whether `fixed` should be applied
// unconditionally. Right now, we only do it for the user
// sidebar version of the popover.
- fixed: template_class === 'user_popover',
+ fixed: template_class === "user_popover",
placement: popover_placement,
template: render_no_arrow_popover({class: template_class}),
title: render_user_info_popover_title({
@@ -248,11 +248,11 @@ function show_user_info_popover(element, user, message) {
}
current_msg_list.select_id(message.id);
const elt = $(element);
- if (elt.data('popover') === undefined) {
+ if (elt.data("popover") === undefined) {
if (user === undefined) {
// This is never supposed to happen, not even for deactivated
// users, so we'll need to debug this error if it occurs.
- blueslip.error('Bad sender in message' + message.sender_id);
+ blueslip.error("Bad sender in message" + message.sender_id);
return;
}
@@ -303,7 +303,7 @@ exports.hide_user_profile = function () {
exports.show_user_profile = function (user) {
exports.hide_all();
- const dateFormat = moment.localeData().longDateFormat('LL');
+ const dateFormat = moment.localeData().longDateFormat("LL");
const field_types = page_params.custom_profile_field_types;
const profile_data = page_params.custom_profile_fields
.map((f) => get_custom_profile_field_data(user, f, field_types, dateFormat))
@@ -331,17 +331,17 @@ exports.show_user_profile = function (user) {
function get_user_info_popover_items() {
if (!current_message_info_popover_elem) {
- blueslip.error('Trying to get menu items when action popover is closed.');
+ blueslip.error("Trying to get menu items when action popover is closed.");
return;
}
- const popover_data = current_message_info_popover_elem.data('popover');
+ const popover_data = current_message_info_popover_elem.data("popover");
if (!popover_data) {
- blueslip.error('Cannot find popover data for actions menu.');
+ blueslip.error("Cannot find popover data for actions menu.");
return;
}
- return $('li:not(.divider):visible a', popover_data.$tip);
+ return $("li:not(.divider):visible a", popover_data.$tip);
}
function fetch_group_members(member_ids) {
@@ -381,7 +381,7 @@ function show_user_group_info_popover(element, group, message) {
}
current_msg_list.select_id(message.id);
const elt = $(element);
- if (elt.data('popover') === undefined) {
+ if (elt.data("popover") === undefined) {
const args = {
group_name: group.name,
group_description: group.description,
@@ -409,10 +409,10 @@ exports.toggle_actions_popover = function (element, id) {
return;
}
- $(element).closest('.message_row').toggleClass('has_popover has_actions_popover');
+ $(element).closest(".message_row").toggleClass("has_popover has_actions_popover");
current_msg_list.select_id(id);
const elt = $(element);
- if (elt.data('popover') === undefined) {
+ if (elt.data("popover") === undefined) {
const message = current_msg_list.get(id);
const editability = message_edit.get_editability(message);
let use_edit_icon;
@@ -454,14 +454,14 @@ exports.toggle_actions_popover = function (element, id) {
message.collapsed;
const should_display_edit_and_view_source =
- message.content !== '<p>(deleted)</p>' ||
+ 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 should_display_quote_and_reply = message.content !== "<p>(deleted)</p>";
const conversation_time_uri = hash_util.by_conversation_and_time_uri(message)
- .replace(/\(/g, '%28')
- .replace(/\)/g, '%29');
+ .replace(/\(/g, "%28")
+ .replace(/\)/g, "%29");
const should_display_delete_option = message_edit.get_deletability(message);
const args = {
@@ -488,7 +488,7 @@ exports.toggle_actions_popover = function (element, id) {
const ypos = elt.offset().top;
elt.popover({
// Popover height with 7 items in it is ~190 px
- placement: message_viewport.height() - ypos < 220 ? 'top' : 'bottom',
+ placement: message_viewport.height() - ypos < 220 ? "top" : "bottom",
title: "",
content: render_actions_popover_content(args),
html: true,
@@ -501,10 +501,10 @@ exports.toggle_actions_popover = function (element, id) {
exports.render_actions_remind_popover = function (element, id) {
exports.hide_all();
- $(element).closest('.message_row').toggleClass('has_popover has_actions_popover');
+ $(element).closest(".message_row").toggleClass("has_popover has_actions_popover");
current_msg_list.select_id(id);
const elt = $(element);
- if (elt.data('popover') === undefined) {
+ if (elt.data("popover") === undefined) {
const message = current_msg_list.get(id);
const args = {
message: message,
@@ -512,7 +512,7 @@ exports.render_actions_remind_popover = function (element, id) {
const ypos = elt.offset().top;
elt.popover({
// Popover height with 7 items in it is ~190 px
- placement: message_viewport.height() - ypos < 220 ? 'top' : 'bottom',
+ placement: message_viewport.height() - ypos < 220 ? "top" : "bottom",
title: "",
content: render_remind_me_popover_content(args),
html: true,
@@ -523,7 +523,7 @@ exports.render_actions_remind_popover = function (element, id) {
enableTime: true,
clickOpens: false,
defaultDate: moment().format(),
- minDate: 'today',
+ minDate: "today",
plugins: [new confirmDatePlugin({})], // eslint-disable-line new-cap, no-undef
});
current_actions_popover_elem = elt;
@@ -532,17 +532,17 @@ exports.render_actions_remind_popover = function (element, id) {
function get_action_menu_menu_items() {
if (!current_actions_popover_elem) {
- blueslip.error('Trying to get menu items when action popover is closed.');
+ blueslip.error("Trying to get menu items when action popover is closed.");
return;
}
- const popover_data = current_actions_popover_elem.data('popover');
+ const popover_data = current_actions_popover_elem.data("popover");
if (!popover_data) {
- blueslip.error('Cannot find popover data for actions menu.');
+ blueslip.error("Cannot find popover data for actions menu.");
return;
}
- return $('li:not(.divider):visible a', popover_data.$tip);
+ return $("li:not(.divider):visible a", popover_data.$tip);
}
function focus_first_popover_item(items) {
@@ -558,16 +558,16 @@ function popover_items_handle_keyboard(key, items) {
return;
}
- let index = items.index(items.filter(':focus'));
+ let index = items.index(items.filter(":focus"));
if (key === "enter" && index >= 0 && index < items.length) {
return items[index].click();
}
if (index === -1) {
index = 0;
- } else if ((key === 'down_arrow' || key === 'vim_down') && index < items.length - 1) {
+ } else if ((key === "down_arrow" || key === "vim_down") && index < items.length - 1) {
index += 1;
- } else if ((key === 'up_arrow' || key === 'vim_up') && index > 0) {
+ } else if ((key === "up_arrow" || key === "vim_up") && index > 0) {
index -= 1;
}
items.eq(index).focus();
@@ -607,7 +607,7 @@ exports.actions_popped = function () {
exports.hide_actions_popover = function () {
if (exports.actions_popped()) {
- $('.has_popover').removeClass('has_popover has_actions_popover');
+ $(".has_popover").removeClass("has_popover has_actions_popover");
current_actions_popover_elem.popover("destroy");
current_actions_popover_elem = undefined;
}
@@ -660,8 +660,8 @@ exports.hide_user_sidebar_popover = function () {
// this would confuse $.popover("destroy"), which looks at the .data() attached
// to a certain element. We thus save off the .data("popover") in the
// show_user_sidebar_popover and inject it here before calling destroy.
- $('#user_presences').data("popover", current_user_sidebar_popover);
- $('#user_presences').popover("destroy");
+ $("#user_presences").data("popover", current_user_sidebar_popover);
+ $("#user_presences").popover("destroy");
current_user_sidebar_user_id = undefined;
current_user_sidebar_popover = undefined;
}
@@ -681,7 +681,7 @@ exports.user_info_popover_handle_keyboard = function (key) {
exports.show_sender_info = function () {
const $message = $(".selected_message");
- const $sender = $message.find('.sender_info_hover');
+ const $sender = $message.find(".sender_info_hover");
const message = current_msg_list.get(rows.id($message));
const user = people.get_by_user_id(message.sender_id);
@@ -719,11 +719,11 @@ exports.register_click_handlers = function () {
});
$("#main_div").on("click", ".user-mention", function (e) {
- const id_string = $(this).attr('data-user-id');
+ const id_string = $(this).attr("data-user-id");
// We fallback to email to handle legacy markdown that was rendered
// before we cut over to using data-user-id
- const email = $(this).attr('data-user-email');
- if (id_string === '*' || email === '*') {
+ const email = $(this).attr("data-user-email");
+ if (id_string === "*" || email === "*") {
return;
}
const row = $(this).closest(".message_row");
@@ -740,43 +740,43 @@ exports.register_click_handlers = function () {
});
$("#main_div").on("click", ".user-group-mention", function (e) {
- const user_group_id = parseInt($(this).attr('data-user-group-id'), 10);
+ const user_group_id = parseInt($(this).attr("data-user-group-id"), 10);
const row = $(this).closest(".message_row");
e.stopPropagation();
const message = current_msg_list.get(rows.id(row));
const group = user_groups.get_user_group_from_id(user_group_id, true);
if (group === undefined) {
// This user group has likely been deleted.
- blueslip.info('Unable to find user group in message' + message.sender_id);
+ blueslip.info("Unable to find user group in message" + message.sender_id);
} else {
show_user_group_info_popover(this, group, message);
}
});
- $('body').on('click', '.info_popover_actions .narrow_to_private_messages', (e) => {
- const user_id = elem_to_user_id($(e.target).parents('ul'));
+ $("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;
exports.hide_message_info_popover();
- narrow.by('pm-with', email, {trigger: 'user sidebar popover'});
+ narrow.by("pm-with", email, {trigger: "user sidebar popover"});
e.stopPropagation();
e.preventDefault();
});
- $('body').on('click', '.info_popover_actions .narrow_to_messages_sent', (e) => {
- const user_id = elem_to_user_id($(e.target).parents('ul'));
+ $("body").on("click", ".info_popover_actions .narrow_to_messages_sent", (e) => {
+ const user_id = elem_to_user_id($(e.target).parents("ul"));
const email = people.get_by_user_id(user_id).email;
exports.hide_message_info_popover();
- narrow.by('sender', email, {trigger: 'user sidebar popover'});
+ narrow.by("sender", email, {trigger: "user sidebar popover"});
e.stopPropagation();
e.preventDefault();
});
- $('body').on('click', '.user_popover .mention_user', (e) => {
+ $("body").on("click", ".user_popover .mention_user", (e) => {
if (!compose_state.composing()) {
- compose_actions.start('stream', {trigger: 'sidebar user actions'});
+ compose_actions.start("stream", {trigger: "sidebar user actions"});
}
- const user_id = elem_to_user_id($(e.target).parents('ul'));
+ const user_id = elem_to_user_id($(e.target).parents("ul"));
const name = people.get_by_user_id(user_id).full_name;
const mention = people.get_mention_syntax(name, user_id);
compose_ui.insert_syntax_and_focus(mention);
@@ -786,11 +786,11 @@ exports.register_click_handlers = function () {
e.preventDefault();
});
- $('body').on('click', '.message-info-popover .mention_user', (e) => {
+ $("body").on("click", ".message-info-popover .mention_user", (e) => {
if (!compose_state.composing()) {
- compose_actions.respond_to_message({trigger: 'user sidebar popover'});
+ compose_actions.respond_to_message({trigger: "user sidebar popover"});
}
- const user_id = elem_to_user_id($(e.target).parents('ul'));
+ const user_id = elem_to_user_id($(e.target).parents("ul"));
const name = people.get_by_user_id(user_id).full_name;
const mention = people.get_mention_syntax(name, user_id);
compose_ui.insert_syntax_and_focus(mention);
@@ -799,57 +799,57 @@ exports.register_click_handlers = function () {
e.preventDefault();
});
- $('body').on('click', '.info_popover_actions .view_user_profile', (e) => {
- const user_id = elem_to_user_id($(e.target).parents('ul'));
+ $("body").on("click", ".info_popover_actions .view_user_profile", (e) => {
+ const user_id = elem_to_user_id($(e.target).parents("ul"));
const user = people.get_by_user_id(user_id);
exports.show_user_profile(user);
e.stopPropagation();
e.preventDefault();
});
- $('body').on('click', '.info_popover_actions .clear_status', (e) => {
+ $("body").on("click", ".info_popover_actions .clear_status", (e) => {
e.preventDefault();
- const me = elem_to_user_id($(e.target).parents('ul'));
+ const me = elem_to_user_id($(e.target).parents("ul"));
user_status.server_update({
user_id: me,
- status_text: '',
+ status_text: "",
success: function () {
- $('.info_popover_actions #status_message').html('');
+ $(".info_popover_actions #status_message").html("");
},
});
});
- $('body').on('click', '.bot-owner-name', (e) => {
- const user_id = parseInt($(e.target).attr('data-bot-owner-id'), 10);
+ $("body").on("click", ".bot-owner-name", (e) => {
+ const user_id = parseInt($(e.target).attr("data-bot-owner-id"), 10);
const user = people.get_by_user_id(user_id);
exports.show_user_profile(user);
});
- $('body').on('click', '#user-profile-modal #name #edit-button', () => {
+ $("body").on("click", "#user-profile-modal #name #edit-button", () => {
exports.hide_user_profile();
});
- $('body').on('click', '.compose_mobile_button', function (e) {
+ $("body").on("click", ".compose_mobile_button", function (e) {
show_mobile_message_buttons_popover(this);
e.stopPropagation();
e.preventDefault();
});
- $('body').on('click', '.set_away_status', (e) => {
+ $("body").on("click", ".set_away_status", (e) => {
exports.hide_all();
user_status.server_set_away();
e.stopPropagation();
e.preventDefault();
});
- $('body').on('click', '.revoke_away_status', (e) => {
+ $("body").on("click", ".revoke_away_status", (e) => {
exports.hide_all();
user_status.server_revoke_away();
e.stopPropagation();
e.preventDefault();
});
- $('body').on('click', '.update_status_text', (e) => {
+ $("body").on("click", ".update_status_text", (e) => {
exports.hide_all();
user_status_ui.open_overlay();
@@ -858,13 +858,13 @@ exports.register_click_handlers = function () {
e.preventDefault();
});
- $('#user_presences').on('click', '.user-list-sidebar-menu-icon', function (e) {
+ $("#user_presences").on("click", ".user-list-sidebar-menu-icon", function (e) {
e.stopPropagation();
// use email of currently selected user, rather than some elem comparison,
// as the presence list may be redrawn with new elements.
- const target = $(this).closest('li');
- const user_id = elem_to_user_id(target.find('a'));
+ const target = $(this).closest("li");
+ const user_id = elem_to_user_id(target.find("a"));
if (current_user_sidebar_user_id === user_id) {
// If the popover is already shown, clicking again should toggle it.
@@ -888,99 +888,99 @@ exports.register_click_handlers = function () {
"user_popover", popover_placement);
current_user_sidebar_user_id = user.user_id;
- current_user_sidebar_popover = target.data('popover');
+ current_user_sidebar_popover = target.data("popover");
});
- $('body').on("mouseenter", ".user_popover_email", function () {
- const tooltip_holder = $(this).find('div');
+ $("body").on("mouseenter", ".user_popover_email", function () {
+ const tooltip_holder = $(this).find("div");
if (this.offsetWidth < this.scrollWidth) {
- tooltip_holder.addClass('display-tooltip');
+ tooltip_holder.addClass("display-tooltip");
} else {
- tooltip_holder.removeClass('display-tooltip');
+ tooltip_holder.removeClass("display-tooltip");
}
});
- $('body').on('click', '.respond_button', (e) => {
+ $("body").on("click", ".respond_button", (e) => {
// Arguably, we should fetch the message ID to respond to from
// e.target, but that should always be the current selected
// message in the current message list (and
// compose_actions.respond_to_message doesn't take a message
// argument).
- compose_actions.quote_and_reply({trigger: 'popover respond'});
+ compose_actions.quote_and_reply({trigger: "popover respond"});
exports.hide_actions_popover();
e.stopPropagation();
e.preventDefault();
});
- $('body').on('click', '.reminder_button', (e) => {
- const message_id = $(e.currentTarget).data('message-id');
+ $("body").on("click", ".reminder_button", (e) => {
+ const message_id = $(e.currentTarget).data("message-id");
exports.render_actions_remind_popover($(".selected_message .actions_hover")[0], message_id);
e.stopPropagation();
e.preventDefault();
});
- $('body').on('click', '.remind.custom', (e) => {
+ $("body").on("click", ".remind.custom", (e) => {
$(e.currentTarget)[0]._flatpickr.toggle();
e.stopPropagation();
e.preventDefault();
});
function reminder_click_handler(datestr, e) {
- const message_id = $(".remind.custom").data('message-id');
+ const message_id = $(".remind.custom").data("message-id");
reminder.do_set_reminder_for_message(message_id, datestr);
exports.hide_all();
e.stopPropagation();
e.preventDefault();
}
- $('body').on('click', '.remind.in_20m', (e) => {
- const datestr = moment().add(20, 'm').format();
+ $("body").on("click", ".remind.in_20m", (e) => {
+ const datestr = moment().add(20, "m").format();
reminder_click_handler(datestr, e);
});
- $('body').on('click', '.remind.in_1h', (e) => {
- const datestr = moment().add(1, 'h').format();
+ $("body").on("click", ".remind.in_1h", (e) => {
+ const datestr = moment().add(1, "h").format();
reminder_click_handler(datestr, e);
});
- $('body').on('click', '.remind.in_3h', (e) => {
- const datestr = moment().add(3, 'h').format();
+ $("body").on("click", ".remind.in_3h", (e) => {
+ const datestr = moment().add(3, "h").format();
reminder_click_handler(datestr, e);
});
- $('body').on('click', '.remind.tomo', (e) => {
- const datestr = moment().add(1, 'd').hour(9).minute(0).seconds(0).format();
+ $("body").on("click", ".remind.tomo", (e) => {
+ const datestr = moment().add(1, "d").hour(9).minute(0).seconds(0).format();
reminder_click_handler(datestr, e);
});
- $('body').on('click', '.remind.nxtw', (e) => {
- const datestr = moment().add(1, 'w').day('monday').hour(9).minute(0).seconds(0).format();
+ $("body").on("click", ".remind.nxtw", (e) => {
+ const datestr = moment().add(1, "w").day("monday").hour(9).minute(0).seconds(0).format();
reminder_click_handler(datestr, e);
});
- $('body').on('click', '.flatpickr-calendar', (e) => {
+ $("body").on("click", ".flatpickr-calendar", (e) => {
e.stopPropagation();
e.preventDefault();
});
- $('body').on('click', '.flatpickr-confirm', (e) => {
+ $("body").on("click", ".flatpickr-confirm", (e) => {
const datestr = $(".remind.custom")[0].value;
reminder_click_handler(datestr, e);
});
- $('body').on('click', '.respond_personal_button, .compose_private_message', (e) => {
- const user_id = elem_to_user_id($(e.target).parents('ul'));
+ $("body").on("click", ".respond_personal_button, .compose_private_message", (e) => {
+ const user_id = elem_to_user_id($(e.target).parents("ul"));
const email = people.get_by_user_id(user_id).email;
- compose_actions.start('private', {
- trigger: 'popover send private',
+ compose_actions.start("private", {
+ trigger: "popover send private",
private_message_recipient: email});
exports.hide_all();
e.stopPropagation();
e.preventDefault();
});
- $('body').on('click', '.popover_toggle_collapse', (e) => {
- const message_id = $(e.currentTarget).data('message-id');
+ $("body").on("click", ".popover_toggle_collapse", (e) => {
+ const message_id = $(e.currentTarget).data("message-id");
const row = current_msg_list.get_row(message_id);
const message = current_msg_list.get(rows.id(row));
@@ -997,19 +997,19 @@ exports.register_click_handlers = function () {
e.stopPropagation();
e.preventDefault();
});
- $('body').on('click', '.popover_edit_message', (e) => {
- const message_id = $(e.currentTarget).data('message-id');
+ $("body").on("click", ".popover_edit_message", (e) => {
+ const message_id = $(e.currentTarget).data("message-id");
const row = current_msg_list.get_row(message_id);
exports.hide_actions_popover();
message_edit.start(row);
e.stopPropagation();
e.preventDefault();
});
- $('body').on('click', '.view_edit_history', (e) => {
- const message_id = $(e.currentTarget).data('message-id');
+ $("body").on("click", ".view_edit_history", (e) => {
+ const message_id = $(e.currentTarget).data("message-id");
const row = current_msg_list.get_row(message_id);
const message = current_msg_list.get(rows.id(row));
- const message_history_cancel_btn = $('#message-history-cancel');
+ const message_history_cancel_btn = $("#message-history-cancel");
exports.hide_actions_popover();
message_edit_history.show_history(message);
@@ -1018,9 +1018,9 @@ exports.register_click_handlers = function () {
e.preventDefault();
});
- $('body').on('click', '.popover_mute_topic', (e) => {
- const stream_id = parseInt($(e.currentTarget).attr('data-msg-stream-id'), 10);
- const topic = $(e.currentTarget).attr('data-msg-topic');
+ $("body").on("click", ".popover_mute_topic", (e) => {
+ const stream_id = parseInt($(e.currentTarget).attr("data-msg-stream-id"), 10);
+ const topic = $(e.currentTarget).attr("data-msg-topic");
exports.hide_actions_popover();
muting_ui.mute(stream_id, topic);
@@ -1028,9 +1028,9 @@ exports.register_click_handlers = function () {
e.preventDefault();
});
- $('body').on('click', '.popover_unmute_topic', (e) => {
- const stream_id = parseInt($(e.currentTarget).attr('data-msg-stream-id'), 10);
- const topic = $(e.currentTarget).attr('data-msg-topic');
+ $("body").on("click", ".popover_unmute_topic", (e) => {
+ const stream_id = parseInt($(e.currentTarget).attr("data-msg-stream-id"), 10);
+ const topic = $(e.currentTarget).attr("data-msg-topic");
exports.hide_actions_popover();
muting_ui.unmute(stream_id, topic);
@@ -1038,17 +1038,17 @@ exports.register_click_handlers = function () {
e.preventDefault();
});
- $('body').on('click', '.delete_message', (e) => {
- const message_id = $(e.currentTarget).data('message-id');
+ $("body").on("click", ".delete_message", (e) => {
+ const message_id = $(e.currentTarget).data("message-id");
exports.hide_actions_popover();
message_edit.delete_message(message_id);
e.stopPropagation();
e.preventDefault();
});
- new ClipboardJS('.copy_link');
+ new ClipboardJS(".copy_link");
- $('body').on('click', '.copy_link', function (e) {
+ $("body").on("click", ".copy_link", function (e) {
exports.hide_actions_popover();
const message_id = $(this).attr("data-message-id");
const row = $("[zid='" + message_id + "']");
@@ -1070,7 +1070,7 @@ exports.register_click_handlers = function () {
(function () {
let last_scroll = 0;
- $('.app').on('scroll', () => {
+ $(".app").on("scroll", () => {
if (suppress_scroll_hide) {
suppress_scroll_hide = false;
return;
@@ -1104,7 +1104,7 @@ exports.any_active = function () {
// userlist sidebars use the popover infrastructure, but doesn't work
// like a popover structurally).
exports.hide_all_except_sidebars = function () {
- $('.has_popover').removeClass('has_popover has_actions_popover has_emoji_popover');
+ $(".has_popover").removeClass("has_popover has_actions_popover has_emoji_popover");
exports.hide_actions_popover();
exports.hide_message_info_popover();
emoji_picker.hide_emoji_popover();
@@ -1154,27 +1154,27 @@ exports.compute_placement = function (elt, popover_height, popover_width,
distance_from_top + elt.height() / 2 > popover_height / 2;
// default to placing the popover in the center of the screen
- let placement = 'viewport_center';
+ let placement = "viewport_center";
// prioritize left/right over top/bottom
if (distance_from_top > popover_height && elt_will_fit_horizontally) {
- placement = 'top';
+ placement = "top";
}
if (distance_from_bottom > popover_height && elt_will_fit_horizontally) {
- placement = 'bottom';
+ placement = "bottom";
}
- if (prefer_vertical_positioning && placement !== 'viewport_center') {
+ if (prefer_vertical_positioning && placement !== "viewport_center") {
// If vertical positioning is preferred and the popover fits in
// either top or bottom position then return.
return placement;
}
if (distance_from_left > popover_width && elt_will_fit_vertically) {
- placement = 'left';
+ placement = "left";
}
if (distance_from_right > popover_width && elt_will_fit_vertically) {
- placement = 'right';
+ placement = "right";
}
return placement;
diff --git a/static/js/portico/dev-login.js b/static/js/portico/dev-login.js
index 3f60c6870cb..5e1891b92cc 100644
--- a/static/js/portico/dev-login.js
+++ b/static/js/portico/dev-login.js
@@ -7,8 +7,8 @@ $(() => {
preserved after user is logged in. See this:
https://stackoverflow.com/questions/5283395/url-hash-is-persisting-between-redirects */
$("input[name='direct_email']").each(function () {
- const new_formaction = $(this).attr('formaction') + '/' + window.location.hash;
- $(this).attr('formaction', new_formaction);
+ const new_formaction = $(this).attr("formaction") + "/" + window.location.hash;
+ $(this).attr("formaction", new_formaction);
});
}
}
diff --git a/static/js/portico/email_log.js b/static/js/portico/email_log.js
index d2c09074b8b..52551ba7039 100644
--- a/static/js/portico/email_log.js
+++ b/static/js/portico/email_log.js
@@ -1,8 +1,8 @@
$(() => {
// This code will be executed when the user visits /emails in
// development mode and email_log.html is rendered.
- $('#toggle').change(() => {
- if ($('.email-text').css('display') === 'none') {
+ $("#toggle").change(() => {
+ if ($(".email-text").css("display") === "none") {
$(".email-text").each(function () {
$(this).css("display", "block");
});
@@ -18,7 +18,7 @@ $(() => {
});
}
});
- $('input[type=radio][name=forward]').on('change', function () {
+ $("input[type=radio][name=forward]").on("change", function () {
if ($(this).val() === "enabled") {
$("#forward_address_sections").show();
} else {
@@ -26,8 +26,8 @@ $(() => {
}
});
$("#save_smptp_details").on("click", () => {
- const address = $('input[name=forward]:checked').val() === "enabled" ? $("#address").val() : "";
- const csrf_token = $('input[name="csrfmiddlewaretoken"]').attr('value');
+ 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};
channel.post({
diff --git a/static/js/portico/header.js b/static/js/portico/header.js
index c32703c03b7..b2570f9cebb 100644
--- a/static/js/portico/header.js
+++ b/static/js/portico/header.js
@@ -1,6 +1,6 @@
$(() => {
- $('.portico-header li.logout').on('click', () => {
- $('#logout_form').submit();
+ $(".portico-header li.logout").on("click", () => {
+ $("#logout_form").submit();
return false;
});
diff --git a/static/js/portico/help.js b/static/js/portico/help.js
index c324dd042c1..b08530fb82f 100644
--- a/static/js/portico/help.js
+++ b/static/js/portico/help.js
@@ -1,6 +1,6 @@
-import * as google_analytics from './google-analytics.js';
-import SimpleBar from 'simplebar';
-import {activate_correct_tab} from './tabbed-instructions.js';
+import * as google_analytics from "./google-analytics.js";
+import SimpleBar from "simplebar";
+import {activate_correct_tab} from "./tabbed-instructions.js";
function registerCodeSection($codeSection) {
const $li = $codeSection.find("ul.nav li");
@@ -18,7 +18,7 @@ function registerCodeSection($codeSection) {
}
function highlight_current_article() {
- $('.help .sidebar a').removeClass('highlighted');
+ $(".help .sidebar a").removeClass("highlighted");
const path = window.location.pathname;
if (!path) {
@@ -34,8 +34,8 @@ function highlight_current_article() {
article = $('.help .sidebar a[href="' + path + '"]');
}
// Highlight current article link and the heading of the same
- article.closest('ul').css('display', 'block');
- article.addClass('highlighted');
+ article.closest("ul").css("display", "block");
+ article.addClass("highlighted");
}
function render_code_sections() {
@@ -56,7 +56,7 @@ function render_code_sections() {
function scrollToHash(simplebar) {
const hash = window.location.hash;
const scrollbar = simplebar.getScrollElement();
- if (hash !== '' && $(hash).length > 0) {
+ if (hash !== "" && $(hash).length > 0) {
const position = $(hash).position().top - $(scrollbar.firstChild).position().top;
scrollbar.scrollTop = position;
} else {
@@ -104,7 +104,7 @@ $(".sidebar.slide h2").click((e) => {
if ($next.is("ul")) {
// Close other article's headings first
- $('.sidebar ul').not($next).hide();
+ $(".sidebar ul").not($next).hide();
// Toggle the heading
$next.slideToggle("fast", "swing");
}
@@ -112,8 +112,8 @@ $(".sidebar.slide h2").click((e) => {
$(".sidebar a").click(function (e) {
const path = $(this).attr("href");
- const path_dir = path.split('/')[1];
- const current_dir = window.location.pathname.split('/')[1];
+ const path_dir = path.split("/")[1];
+ const current_dir = window.location.pathname.split("/")[1];
// Do not block redirecting to external URLs
if (path_dir !== current_dir) {
@@ -133,15 +133,15 @@ $(".sidebar a").click(function (e) {
e.preventDefault();
});
-if (window.location.pathname === '/help/') {
+if (window.location.pathname === "/help/") {
// Expand the Guides user docs section in sidebar in the /help/ homepage.
- $('.help .sidebar h2#guides + ul').show();
+ $(".help .sidebar h2#guides + ul").show();
}
// Remove ID attributes from sidebar links so they don't conflict with index page anchor links
-$('.help .sidebar h1, .help .sidebar h2, .help .sidebar h3').removeAttr('id');
+$(".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 () {
+$(document).on("click", ".markdown .content h1, .markdown .content h2, .markdown .content h3", function () {
window.location.hash = $(this).attr("id");
scrollToHash(markdownSB);
});
@@ -167,4 +167,4 @@ window.addEventListener("popstate", () => {
update_page(html_map, path);
});
-$('body').addClass('noscroll');
+$("body").addClass("noscroll");
diff --git a/static/js/portico/integrations.js b/static/js/portico/integrations.js
index 182df3fecb9..f4fee4fc9d9 100644
--- a/static/js/portico/integrations.js
+++ b/static/js/portico/integrations.js
@@ -1,7 +1,7 @@
-import * as google_analytics from './google-analytics.js';
-import blueslip from './../blueslip';
+import * as google_analytics from "./google-analytics.js";
+import blueslip from "./../blueslip";
-import { path_parts } from './landing-page';
+import { path_parts } from "./landing-page";
// these constants are populated immediately with data from the DOM on page load
@@ -10,17 +10,17 @@ 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();
+ $(".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');
+ $(".integration-category").toArray().forEach((category) => {
+ const name = $(category).data("category");
const display_name = $(category).text().trim();
if (display_name && name) {
@@ -30,31 +30,31 @@ function load_data() {
}
const INITIAL_STATE = {
- category: 'all',
+ category: "all",
integration: null,
- query: '',
+ query: "",
};
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');
+ $integration_name.css("font-size", "1em");
if ($integration_name.height() > 30) {
- $integration_name.css('font-size', '.95em');
+ $integration_name.css("font-size", ".95em");
}
}
if ($integration_category.height() > 30) {
- $integration_category.css('font-size', '.8em');
+ $integration_category.css("font-size", ".8em");
if ($integration_category.height() > 30) {
- $integration_category.css('font-size', '.75em');
+ $integration_category.css("font-size", ".75em");
}
}
});
@@ -64,32 +64,32 @@ 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 = '/';
+ next_path = "/";
}
- window.history.pushState(state, '', next_path);
+ window.history.pushState(state, "", next_path);
google_analytics.config({page_path: next_path});
}
function update_categories() {
- $('.integration-lozenges').css('opacity', 0);
+ $(".integration-lozenges").css("opacity", 0);
- $('.integration-category').removeClass('selected');
- $('[data-category="' + state.category + '"]').addClass('selected');
+ $(".integration-category").removeClass("selected");
+ $('[data-category="' + state.category + '"]').addClass("selected");
- const $dropdown_label = $('.integration-categories-dropdown .dropdown-category-label');
+ const $dropdown_label = $(".integration-categories-dropdown .dropdown-category-label");
if (state.category === INITIAL_STATE.category) {
- $dropdown_label.text(i18n.t('Filter by category'));
+ $dropdown_label.text(i18n.t("Filter by category"));
} else {
$dropdown_label.text(CATEGORIES.get(state.category));
}
- $('.integration-lozenges').animate(
+ $(".integration-lozenges").animate(
{ opacity: 1 },
{ duration: 400 },
);
@@ -100,30 +100,30 @@ function update_categories() {
const update_integrations = _.debounce(() => {
const max_scrollY = window.scrollY;
- const integrations = $('.integration-lozenges').children().toArray();
+ const integrations = $(".integration-lozenges").children().toArray();
integrations.forEach((integration) => {
- const $integration = $(integration).find('.integration-lozenge');
- const $integration_category = $integration.find('.integration-category');
+ const $integration = $(integration).find(".integration-lozenge");
+ const $integration_category = $integration.find(".integration-category");
- if (state.category !== 'all') {
- $integration_category.css('display', 'none');
- $integration.addClass('without-category');
+ if (state.category !== "all") {
+ $integration_category.css("display", "none");
+ $integration.addClass("without-category");
} else {
- $integration_category.css('display', '');
- $integration.removeClass('without-category');
+ $integration_category.css("display", "");
+ $integration.removeClass("without-category");
}
- if (!$integration.hasClass('integration-create-your-own')) {
- const display_name = INTEGRATIONS.get($integration.data('name'));
+ if (!$integration.hasClass("integration-create-your-own")) {
+ const display_name = INTEGRATIONS.get($integration.data("name"));
const display =
common.phrase_match(state.query, display_name) &&
- ($integration.data('categories').includes(CATEGORIES.get(state.category)) ||
- state.category === 'all');
+ ($integration.data("categories").includes(CATEGORIES.get(state.category)) ||
+ state.category === "all");
if (display) {
- $integration.css('display', 'inline-block');
+ $integration.css("display", "inline-block");
} else {
- $integration.css('display', 'none');
+ $integration.css("display", "none");
}
}
@@ -135,16 +135,16 @@ const update_integrations = _.debounce(() => {
function hide_catalog_show_integration() {
const $lozenge_icon = $(".integration-lozenge.integration-" + state.integration).clone(false);
- $lozenge_icon.removeClass('legacy');
+ $lozenge_icon.removeClass("legacy");
- const categories = $('.integration-' + state.integration).data('categories')
+ const categories = $(".integration-" + state.integration).data("categories")
.slice(1, -1)
- .split(',')
+ .split(",")
.map((category) => category.trim().slice(1, -1));
function show_integration(doc) {
- $('#integration-instructions-group .name').text(INTEGRATIONS.get(state.integration));
- $('#integration-instructions-group .categories .integration-category').remove();
+ $("#integration-instructions-group .name").text(INTEGRATIONS.get(state.integration));
+ $("#integration-instructions-group .categories .integration-category").remove();
categories.forEach((category) => {
let link;
for (const [name, display_name] of CATEGORIES) {
@@ -152,31 +152,31 @@ function hide_catalog_show_integration() {
link = name;
}
}
- const category_el = $('<a></a>')
- .attr('href', '/integrations/' + link)
+ const category_el = $("<a></a>")
+ .attr("href", "/integrations/" + link)
.append('<h3 class="integration-category"></h3>');
- category_el.find('.integration-category')
- .attr('data-category', link)
+ category_el.find(".integration-category")
+ .attr("data-category", link)
.text(category);
- $('#integration-instructions-group .categories').append(category_el);
+ $("#integration-instructions-group .categories").append(category_el);
});
- $('#integration-instructions-group').css({
+ $("#integration-instructions-group").css({
opacity: 0,
- display: 'flex',
+ display: "flex",
});
- $('.integration-instructions').css('display', 'none');
- $('#' + state.integration + '.integration-instructions .help-content').html(doc);
- $('#integration-instruction-block .integration-lozenge').remove();
+ $(".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-instructions#' + state.integration).css('display', 'block');
+ .css("display", "flex");
+ $(".integration-instructions#" + state.integration).css("display", "block");
$("html, body").animate(
{ scrollTop: 0 },
{ duration: 200 },
);
- $('#integration-instructions-group').animate(
+ $("#integration-instructions-group").animate(
{ opacity: 1 },
{ duration: 300 },
);
@@ -185,8 +185,8 @@ function hide_catalog_show_integration() {
}
function hide_catalog(doc) {
- $(".integration-categories-dropdown").css('display', 'none');
- $(".integrations .catalog").addClass('hide');
+ $(".integration-categories-dropdown").css("display", "none");
+ $(".integrations .catalog").addClass("hide");
$(".extra, #integration-main-text, #integration-search").css("display", "none");
show_integration(doc);
@@ -194,8 +194,8 @@ function hide_catalog_show_integration() {
}
$.get({
- url: '/integrations/doc-html/' + state.integration,
- dataType: 'html',
+ url: "/integrations/doc-html/" + state.integration,
+ dataType: "html",
success: hide_catalog,
error: function (err) {
blueslip.error("Integration documentation for '" + state.integration + "' not found.", err);
@@ -210,16 +210,16 @@ function hide_integration_show_catalog() {
{ duration: 200 },
);
- $(".integration-categories-dropdown").css('display', '');
- $(".integrations .catalog").removeClass('hide');
+ $(".integration-categories-dropdown").css("display", "");
+ $(".integrations .catalog").removeClass("hide");
$(".extra, #integration-main-text, #integration-search").css("display", "block");
adjust_font_sizing();
}
function hide_integration() {
- $('#integration-instruction-block').css('display', 'none');
- $('#integration-instructions-group').css('display', 'none');
- $('.inner-content').css({ padding: '' });
+ $("#integration-instruction-block").css("display", "none");
+ $("#integration-instructions-group").css("display", "none");
+ $(".inner-content").css({ padding: "" });
$("#integration-instruction-block .integration-lozenge").remove();
show_catalog();
}
@@ -232,7 +232,7 @@ function get_state_from_path() {
result.query = state.query;
const parts = path_parts();
- if (parts[1] === 'doc' && INTEGRATIONS.get(parts[2])) {
+ if (parts[1] === "doc" && INTEGRATIONS.get(parts[2])) {
result.integration = parts[2];
} else if (CATEGORIES.has(parts[1])) {
result.category = parts[1];
@@ -269,28 +269,28 @@ function render(next_state) {
function dispatch(action, payload) {
switch (action) {
- case 'CHANGE_CATEGORY':
+ case "CHANGE_CATEGORY":
render(Object.assign({}, state, {
category: payload.category,
}));
update_path();
break;
- case 'SHOW_INTEGRATION':
+ case "SHOW_INTEGRATION":
render(Object.assign({}, state, {
integration: payload.integration,
}));
update_path();
break;
- case 'HIDE_INTEGRATION':
+ case "HIDE_INTEGRATION":
render(Object.assign({}, state, {
integration: null,
}));
update_path();
break;
- case 'SHOW_CATEGORY':
+ case "SHOW_CATEGORY":
render(Object.assign({}, state, {
integration: null,
category: payload.category,
@@ -298,70 +298,70 @@ function dispatch(action, payload) {
update_path();
break;
- case 'UPDATE_QUERY':
+ case "UPDATE_QUERY":
render(Object.assign({}, state, {
query: payload.query,
}));
break;
- case 'LOAD_PATH':
+ case "LOAD_PATH":
render(get_state_from_path());
google_analytics.config({page_path: window.location.pathname});
break;
default:
- blueslip.error('Invalid action dispatched on /integrations.');
+ blueslip.error("Invalid action dispatched on /integrations.");
break;
}
}
function toggle_categories_dropdown() {
- const $dropdown_list = $('.integration-categories-dropdown .dropdown-list');
+ const $dropdown_list = $(".integration-categories-dropdown .dropdown-list");
$dropdown_list.slideToggle(250);
}
function integration_events() {
$('#integration-search input[type="text"]').keypress((e) => {
- const integrations = $('.integration-lozenges').children().toArray();
- if (e.which === 13 && e.target.value !== '') {
+ const integrations = $(".integration-lozenges").children().toArray();
+ if (e.which === 13 && e.target.value !== "") {
for (let i = 0; i < integrations.length; i += 1) {
- const integration = $(integrations[i]).find('.integration-lozenge');
+ const integration = $(integrations[i]).find(".integration-lozenge");
- if ($(integration).css('display') !== 'none') {
- $(integration).closest('a')[0].click();
+ if ($(integration).css("display") !== "none") {
+ $(integration).closest("a")[0].click();
break;
}
}
}
});
- $('.integration-categories-dropdown .dropdown-toggle').click(() => {
+ $(".integration-categories-dropdown .dropdown-toggle").click(() => {
toggle_categories_dropdown();
});
- $('.integration-instruction-block').on('click', 'a .integration-category', (e) => {
- const category = $(e.target).data('category');
- dispatch('SHOW_CATEGORY', { category: category });
+ $(".integration-instruction-block").on("click", "a .integration-category", (e) => {
+ const category = $(e.target).data("category");
+ dispatch("SHOW_CATEGORY", { category: category });
return false;
});
- $('.integrations a .integration-category').on('click', (e) => {
- const category = $(e.target).data('category');
- dispatch('CHANGE_CATEGORY', { category: category });
+ $(".integrations a .integration-category").on("click", (e) => {
+ const category = $(e.target).data("category");
+ dispatch("CHANGE_CATEGORY", { category: category });
toggle_categories_dropdown();
return false;
});
- $('.integrations a .integration-lozenge').on('click', (e) => {
- if (!$(e.target).closest('.integration-lozenge').hasClass('integration-create-your-own')) {
- const integration = $(e.target).closest('.integration-lozenge').data('name');
- dispatch('SHOW_INTEGRATION', { integration: integration });
+ $(".integrations a .integration-lozenge").on("click", (e) => {
+ if (!$(e.target).closest(".integration-lozenge").hasClass("integration-create-your-own")) {
+ const integration = $(e.target).closest(".integration-lozenge").data("name");
+ dispatch("SHOW_INTEGRATION", { integration: integration });
return false;
}
});
- $('a#integration-list-link span, a#integration-list-link i').on('click', () => {
- dispatch('HIDE_INTEGRATION');
+ $("a#integration-list-link span, a#integration-list-link i").on("click", () => {
+ dispatch("HIDE_INTEGRATION");
return false;
});
@@ -369,25 +369,25 @@ function integration_events() {
// the input event.
$(".integrations .searchbar input[type='text']")
.focus()
- .on('input', (e) => {
- dispatch('UPDATE_QUERY', { query: e.target.value.toLowerCase() });
+ .on("input", (e) => {
+ dispatch("UPDATE_QUERY", { query: e.target.value.toLowerCase() });
});
$(window).scroll(() => {
if (document.body.scrollTop > 330) {
- $('.integration-categories-sidebar').addClass('sticky');
+ $(".integration-categories-sidebar").addClass("sticky");
} else {
- $('.integration-categories-sidebar').removeClass('sticky');
+ $(".integration-categories-sidebar").removeClass("sticky");
}
});
- $(window).on('resize', () => {
+ $(window).on("resize", () => {
adjust_font_sizing();
});
- $(window).on('popstate', () => {
- if (window.location.pathname.startsWith('/integrations')) {
- dispatch('LOAD_PATH');
+ $(window).on("popstate", () => {
+ if (window.location.pathname.startsWith("/integrations")) {
+ dispatch("LOAD_PATH");
} else {
window.location = window.location.href;
}
@@ -398,5 +398,5 @@ function integration_events() {
$(() => {
integration_events();
load_data();
- dispatch('LOAD_PATH');
+ dispatch("LOAD_PATH");
});
diff --git a/static/js/portico/integrations_dev_panel.js b/static/js/portico/integrations_dev_panel.js
index ac3ed44424e..591468d0f9d 100644
--- a/static/js/portico/integrations_dev_panel.js
+++ b/static/js/portico/integrations_dev_panel.js
@@ -13,9 +13,9 @@ 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(); },
+ 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 = ""; },
@@ -253,7 +253,7 @@ 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,7 +286,7 @@ 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);},
+ beforeSend: function (xhr) {xhr.setRequestHeader("X-CSRFToken", csrftoken);},
success: function (response) {set_results(response);},
error: handle_unsuccessful_response,
});
@@ -308,7 +308,7 @@ $(() => {
potential_default_bot.selected = true;
}
- $('#integration_name').change(function () {
+ $("#integration_name").change(function () {
clear_elements(["custom_http_headers", "fixture_body", "fixture_name", "results_notice"]);
const integration_name = $(this).children("option:selected").val();
get_fixtures(integration_name);
@@ -316,19 +316,19 @@ $(() => {
return;
});
- $('#fixture_name').change(function () {
+ $("#fixture_name").change(function () {
clear_elements(["fixture_body", "results_notice"]);
const fixture_name = $(this).children("option:selected").val();
load_fixture_body(fixture_name);
return;
});
- $('#send_fixture_button').click(() => {
+ $("#send_fixture_button").click(() => {
send_webhook_fixture_message();
return;
});
- $('#send_all_fixtures_button').click(() => {
+ $("#send_all_fixtures_button").click(() => {
clear_elements(["results_notice"]);
send_all_fixture_messages();
return;
diff --git a/static/js/portico/landing-page.js b/static/js/portico/landing-page.js
index 081a1da5885..012287c7b3b 100644
--- a/static/js/portico/landing-page.js
+++ b/static/js/portico/landing-page.js
@@ -1,9 +1,9 @@
-import * as google_analytics from './google-analytics.js';
-import { detect_user_os } from './tabbed-instructions.js';
-import render_tabs from './team.js';
+import * as google_analytics from "./google-analytics.js";
+import { detect_user_os } from "./tabbed-instructions.js";
+import render_tabs from "./team.js";
export function path_parts() {
- return window.location.pathname.split('/').filter((chunk) => chunk !== '');
+ return window.location.pathname.split("/").filter((chunk) => chunk !== "");
}
const hello_events = function () {
@@ -32,7 +32,7 @@ const apps_events = function () {
link: ELECTRON_APP_URL_WINDOWS,
show_instructions: true,
install_guide: "/help/desktop-app-install-guide",
- app_type: 'desktop',
+ app_type: "desktop",
},
mac: {
image: "/static/images/landing-page/macbook.png",
@@ -87,12 +87,12 @@ const apps_events = function () {
}
function get_path_from_version() {
- return '/apps/' + version;
+ return "/apps/" + version;
}
function update_path() {
const next_path = get_path_from_version();
- history.pushState(version, '', next_path);
+ history.pushState(version, "", next_path);
}
const update_page = function () {
@@ -121,7 +121,7 @@ const apps_events = function () {
$download_from_apple_app_store.toggle(version === "ios");
};
- $(window).on('popstate', () => {
+ $(window).on("popstate", () => {
version = get_version_from_path();
update_page();
$("body").animate({ scrollTop: 0 }, 200);
@@ -129,9 +129,9 @@ 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();
@@ -144,7 +144,7 @@ const apps_events = function () {
// init
version = get_version_from_path();
- history.replaceState(version, '', get_path_from_version());
+ history.replaceState(version, "", get_path_from_version());
update_page();
};
@@ -177,7 +177,7 @@ const events = function () {
apps_events();
}
- if (path_parts().includes('hello')) {
+ if (path_parts().includes("hello")) {
hello_events();
}
};
@@ -187,7 +187,7 @@ const events = function () {
const load = function () {
// Initiate the bootstrap carousel logic
- $('.carousel').carousel({
+ $(".carousel").carousel({
interval: false,
});
@@ -203,17 +203,17 @@ const load = function () {
const move_slide_forward = !is_button && !is_link && !is_last_slide;
if (move_slide_forward) {
- $(this).closest('.carousel').carousel('next');
+ $(this).closest(".carousel").carousel("next");
}
});
- $('.carousel').on('slid', function () {
+ $(".carousel").on("slid", function () {
const $this = $(this);
- $this.find('.visibility-control').show();
- if ($this.find('.carousel-inner .item').first().hasClass('active')) {
- $this.find('.left.visibility-control').hide();
- } else if ($this.find('.carousel-inner .item').last().hasClass('active')) {
- $this.find('.right.visibility-control').hide();
+ $this.find(".visibility-control").show();
+ if ($this.find(".carousel-inner .item").first().hasClass("active")) {
+ $this.find(".left.visibility-control").hide();
+ } else if ($this.find(".carousel-inner .item").last().hasClass("active")) {
+ $this.find(".right.visibility-control").hide();
}
});
@@ -228,7 +228,7 @@ if (document.readyState === "complete") {
}
$(() => {
- if (window.location.pathname === '/team/') {
+ if (window.location.pathname === "/team/") {
render_tabs();
}
});
@@ -237,6 +237,6 @@ $(() => {
// According to https://developer.mozilla.org/en-US/docs/DOM/window.onunload
// Using this event handler in your page prevents Firefox from caching the
// page in the in-memory bfcache (backward/forward cache).
-$(window).on('unload', () => {
- $(window).unbind('unload');
+$(window).on("unload", () => {
+ $(window).unbind("unload");
});
diff --git a/static/js/portico/signup.js b/static/js/portico/signup.js
index bfe93e42f4a..4b8a191a1c2 100644
--- a/static/js/portico/signup.js
+++ b/static/js/portico/signup.js
@@ -2,52 +2,52 @@ $(() => {
// NB: this file is included on multiple pages. In each context,
// some of the jQuery selectors below will return empty lists.
- const password_field = $('#id_password, #id_new_password1');
+ 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);
+ common.password_quality(password_field.val(), $("#pw_strength .bar"), password_field);
- password_field.on('input', function () {
+ password_field.on("input", function () {
// Update the password strength bar even if we aren't validating
// the field yet.
- common.password_quality($(this).val(), $('#pw_strength .bar'), $(this));
+ common.password_quality($(this).val(), $("#pw_strength .bar"), $(this));
});
}
function highlight(class_to_add) {
// Set a class on the enclosing control group.
return function (element) {
- $(element).closest('.control-group')
- .removeClass('success error')
+ $(element).closest(".control-group")
+ .removeClass("success error")
.addClass(class_to_add);
};
}
- $('#registration, #password_reset').validate({
+ $("#registration, #password_reset").validate({
rules: {
- password: 'password_strength',
- new_password1: 'password_strength',
+ password: "password_strength",
+ new_password1: "password_strength",
},
errorElement: "p",
errorPlacement: function (error, element) {
// NB: this is called at most once, when the error element
// is created.
- element.next('.help-inline.alert.alert-error').remove();
- if (element.next().is('label[for="' + element.attr('id') + '"]')) {
- error.insertAfter(element.next()).addClass('help-inline alert alert-error');
+ element.next(".help-inline.alert.alert-error").remove();
+ if (element.next().is('label[for="' + element.attr("id") + '"]')) {
+ error.insertAfter(element.next()).addClass("help-inline alert alert-error");
} else {
- error.insertAfter(element).addClass('help-inline alert alert-error');
+ error.insertAfter(element).addClass("help-inline alert alert-error");
}
},
- highlight: highlight('error'),
- unhighlight: highlight('success'),
+ highlight: highlight("error"),
+ unhighlight: highlight("success"),
});
if ($("#registration").length > 0) {
// Check if there is no input field with errors.
- if ($('.help-inline:not(:empty)').length === 0) {
+ if ($(".help-inline:not(:empty)").length === 0) {
// Find the first input field present in the form that is
// not hidden and disabled and store it in a variable.
const firstInputElement = $("input:not(:hidden, :disabled)").first();
@@ -55,15 +55,15 @@ $(() => {
common.autofocus(firstInputElement);
} 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);
}
// reset error message displays
- $('#id_team_subdomain_error_client').css('display', 'none');
- if ($('.team_subdomain_error_server').text() === '') {
- $('.team_subdomain_error_server').css('display', 'none');
+ $("#id_team_subdomain_error_client").css("display", "none");
+ if ($(".team_subdomain_error_server").text() === "") {
+ $(".team_subdomain_error_server").css("display", "none");
}
$("#timezone").val(moment.tz.guess());
@@ -73,7 +73,7 @@ $(() => {
// endpoint is visited i.e. accounts_send_confirm.html is rendered.
if ($("[data-page-id='accounts-send-confirm']").length > 0) {
$("#resend_email_link").click(() => {
- $('.resend_confirm').submit();
+ $(".resend_confirm").submit();
});
}
@@ -92,25 +92,25 @@ $(() => {
/* We append the location.hash to the formaction so that URL can be
preserved after user is logged in. See this:
https://stackoverflow.com/questions/5283395/url-hash-is-persisting-between-redirects */
- const email_formaction = $("#login_form").attr('action');
- $("#login_form").attr('action', email_formaction + '/' + window.location.hash);
- $(".social_login_form input[name='next']").attr('value', '/' + window.location.hash);
+ const email_formaction = $("#login_form").attr("action");
+ $("#login_form").attr("action", email_formaction + "/" + window.location.hash);
+ $(".social_login_form input[name='next']").attr("value", "/" + window.location.hash);
}
}
$("#send_confirm").validate({
errorElement: "div",
errorPlacement: function (error) {
- $('.email-frontend-error').empty();
+ $(".email-frontend-error").empty();
$("#send_confirm .alert.email-backend-error").remove();
error.appendTo(".email-frontend-error").addClass("text-error");
},
success: function () {
- $('#errors').empty();
+ $("#errors").empty();
},
});
- $(".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) {
@@ -131,7 +131,7 @@ $(() => {
errorClass: "text-error",
wrapper: "div",
submitHandler: function (form) {
- $("#login_form").find('.loader').css('display', 'inline-block');
+ $("#login_form").find(".loader").css("display", "inline-block");
$("#login_form").find("button .text").hide();
form.submit();
@@ -163,8 +163,8 @@ $(() => {
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');
- const full_name = $("#source_realm_select").find(":selected").attr('data-full-name');
+ const avatar_url = $("#source_realm_select").find(":selected").attr("data-avatar");
+ const full_name = $("#source_realm_select").find(":selected").attr("data-full-name");
$("#profile_full_name").text(full_name);
$("#id_full_name").val(full_name);
$("#profile_avatar").attr("src", avatar_url);
@@ -178,14 +178,14 @@ $(() => {
update_full_name_section();
let timer;
- $('#id_team_subdomain').on("keydown", () => {
- $('.team_subdomain_error_server').text('').css('display', 'none');
- $("#id_team_subdomain_error_client").css('display', 'none');
+ $("#id_team_subdomain").on("keydown", () => {
+ $(".team_subdomain_error_server").text("").css("display", "none");
+ $("#id_team_subdomain_error_client").css("display", "none");
clearTimeout(timer);
});
- $('#id_team_subdomain').on("keyup", () => {
+ $("#id_team_subdomain").on("keyup", () => {
clearTimeout(timer);
- timer = setTimeout(check_subdomain_avilable, 250, $('#id_team_subdomain').val());
+ timer = setTimeout(check_subdomain_avilable, 250, $("#id_team_subdomain").val());
});
// GitHub auth
diff --git a/static/js/portico/team.js b/static/js/portico/team.js
index 9a24b637ef2..5c83cbae328 100644
--- a/static/js/portico/team.js
+++ b/static/js/portico/team.js
@@ -2,8 +2,8 @@ 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 hidden_repos = ['zulip-android', 'zulip-ios-legacy'];
+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
// if a user leaves and then revisits the same tab.
@@ -21,14 +21,14 @@ function contrib_total_commits(contrib) {
// - Make tab header responsive.
// - Display full name instead of github username.
export default function render_tabs() {
- const template = _.template($('#contributors-template').html());
+ const template = _.template($("#contributors-template").html());
// Since the Github API limits the number of output to 100, we want to
// remove anyone in the total tab with less commits than the 100th
// contributor to the server repo. (See #7470)
const least_server_commits = _.chain(contributors_list)
- .filter('server')
- .sortBy('server')
+ .filter("server")
+ .sortBy("server")
.value()[0].server;
const total_tab_html = _.chain(contributors_list)
@@ -37,20 +37,20 @@ export default function render_tabs() {
avatar: c.avatar,
commits: contrib_total_commits(c),
}))
- .sortBy('commits')
+ .sortBy("commits")
.reverse()
.filter((c) => c.commits >= least_server_commits)
.map((c) => template(c))
.value()
- .join('');
+ .join("");
- $('#tab-total').html(total_tab_html);
+ $("#tab-total").html(total_tab_html);
for (const repo of repos) {
// Set as the loading template for now, and load when clicked.
- $('#tab-' + repo).html($('#loading-template').html());
+ $("#tab-" + repo).html($("#loading-template").html());
- $('#' + repo).click(() => {
+ $("#" + repo).click(() => {
if (!loaded_repos.includes(repo)) {
const html = _.chain(contributors_list)
.filter(repo)
@@ -62,9 +62,9 @@ export default function render_tabs() {
commits: c[repo],
}))
.value()
- .join('');
+ .join("");
- $('#tab-' + repo).html(html);
+ $("#tab-" + repo).html(html);
loaded_repos.push(repo);
}
diff --git a/static/js/presence.js b/static/js/presence.js
index d12fca95060..fcb9df1e2bb 100644
--- a/static/js/presence.js
+++ b/static/js/presence.js
@@ -74,20 +74,20 @@ exports.status_from_raw = function (raw) {
*/
if (age(active_timestamp) < OFFLINE_THRESHOLD_SECS) {
return {
- status: 'active',
+ status: "active",
last_active: last_active,
};
}
if (age(idle_timestamp) < OFFLINE_THRESHOLD_SECS) {
return {
- status: 'idle',
+ status: "idle",
last_active: last_active,
};
}
return {
- status: 'offline',
+ status: "offline",
last_active: last_active,
};
};
@@ -118,13 +118,13 @@ exports.update_info_from_event = function (user_id, info, server_timestamp) {
raw.server_timestamp = server_timestamp;
for (const rec of Object.values(info)) {
- if (rec.status === 'active') {
+ if (rec.status === "active") {
if (rec.timestamp > (raw.active_timestamp || 0)) {
raw.active_timestamp = rec.timestamp;
}
}
- if (rec.status === 'idle') {
+ if (rec.status === "idle") {
if (rec.timestamp > (raw.idle_timestamp || 0)) {
raw.idle_timestamp = rec.timestamp;
}
@@ -178,7 +178,7 @@ exports.set_info = function (presences, server_timestamp) {
if (!(server_events.suspect_offline || reload_state.is_in_progress())) {
// If we're online, and we get a user who we don't
// know about in the presence data, throw an error.
- blueslip.error('Unknown user ID in presence data: ' + user_id);
+ blueslip.error("Unknown user ID in presence data: " + user_id);
}
// Either way, we deal by skipping this user and
// continuing with processing everyone else.
diff --git a/static/js/reactions.js b/static/js/reactions.js
index 6d8f2a1d3ca..5d8de48e478 100644
--- a/static/js/reactions.js
+++ b/static/js/reactions.js
@@ -1,4 +1,4 @@
-const render_message_reaction = require('../templates/message_reaction.hbs');
+const render_message_reaction = require("../templates/message_reaction.hbs");
exports.view = {}; // function namespace
@@ -6,7 +6,7 @@ exports.get_local_reaction_id = function (reaction_info) {
return [
reaction_info.reaction_type,
reaction_info.emoji_code,
- ].join(',');
+ ].join(",");
};
exports.open_reactions_popover = function () {
@@ -29,7 +29,7 @@ exports.current_user_has_reacted_to_emoji = function (message, local_id) {
function get_message(message_id) {
const message = message_store.get(message_id);
if (!message) {
- blueslip.error('reactions: Bad message id: ' + message_id);
+ blueslip.error("reactions: Bad message id: " + message_id);
return;
}
@@ -55,7 +55,7 @@ function update_ui_and_send_reaction_ajax(message_id, reaction_info) {
message,
local_id,
);
- const operation = has_reacted ? 'remove' : 'add';
+ const operation = has_reacted ? "remove" : "add";
const reaction = create_reaction(message_id, reaction_info);
if (operation === "add") {
@@ -65,7 +65,7 @@ function update_ui_and_send_reaction_ajax(message_id, reaction_info) {
}
const args = {
- url: '/json/messages/' + message_id + '/reactions',
+ url: "/json/messages/" + message_id + "/reactions",
data: reaction_info,
success: function () {},
error: function (xhr) {
@@ -78,9 +78,9 @@ function update_ui_and_send_reaction_ajax(message_id, reaction_info) {
blueslip.warn(response);
},
};
- if (operation === 'add') {
+ if (operation === "add") {
channel.post(args);
- } else if (operation === 'remove') {
+ } else if (operation === "remove") {
channel.del(args);
}
}
@@ -96,19 +96,19 @@ exports.toggle_emoji_reaction = function (message_id, emoji_name) {
};
if (emoji.active_realm_emojis.has(emoji_name)) {
- if (emoji_name === 'zulip') {
- reaction_info.reaction_type = 'zulip_extra_emoji';
+ if (emoji_name === "zulip") {
+ reaction_info.reaction_type = "zulip_extra_emoji";
} else {
- reaction_info.reaction_type = 'realm_emoji';
+ reaction_info.reaction_type = "realm_emoji";
}
reaction_info.emoji_code = emoji.active_realm_emojis.get(emoji_name).id;
} else {
const codepoint = emoji.get_emoji_codepoint(emoji_name);
if (codepoint === undefined) {
- blueslip.warn('Bad emoji name: ' + emoji_name);
+ blueslip.warn("Bad emoji name: " + emoji_name);
return;
}
- reaction_info.reaction_type = 'unicode_emoji';
+ reaction_info.reaction_type = "unicode_emoji";
reaction_info.emoji_code = codepoint;
}
@@ -119,7 +119,7 @@ exports.process_reaction_click = function (message_id, local_id) {
const message = get_message(message_id);
if (!message) {
- blueslip.error('message_id for reaction click is unknown: ' + message_id);
+ blueslip.error("message_id for reaction click is unknown: " + message_id);
return;
}
@@ -127,8 +127,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;
}
@@ -143,7 +143,7 @@ exports.process_reaction_click = function (message_id, local_id) {
function full_name(user_id) {
if (user_id === page_params.user_id) {
- return 'You (click to remove)';
+ return "You (click to remove)";
}
return people.get_by_user_id(user_id).full_name;
}
@@ -155,12 +155,12 @@ function generate_title(emoji_name, user_ids) {
user_ids.splice(i, 1);
user_ids.unshift(page_params.user_id);
}
- const reacted_with_string = ' reacted with :' + emoji_name + ':';
+ const reacted_with_string = " reacted with :" + emoji_name + ":";
const user_names = user_ids.map(full_name);
if (user_names.length === 1) {
return user_names[0] + reacted_with_string;
}
- return _.initial(user_names).join(', ') + ' and ' + _.last(user_names) + reacted_with_string;
+ return _.initial(user_names).join(", ") + " and " + _.last(user_names) + reacted_with_string;
}
// Add a tooltip showing who reacted to a message.
@@ -176,8 +176,8 @@ exports.get_reaction_title_data = function (message_id, local_id) {
};
exports.get_reaction_section = function (message_id) {
- const message_element = $('.message_table').find("[zid='" + message_id + "']");
- const section = message_element.find('.message_reactions');
+ const message_element = $(".message_table").find("[zid='" + message_id + "']");
+ const section = message_element.find(".message_reactions");
return section;
};
@@ -189,12 +189,12 @@ exports.find_reaction = function (message_id, local_id) {
exports.get_add_reaction_button = function (message_id) {
const reaction_section = exports.get_reaction_section(message_id);
- const add_button = reaction_section.find('.reaction_button');
+ const add_button = reaction_section.find(".reaction_button");
return add_button;
};
exports.set_reaction_count = function (reaction, count) {
- const count_element = reaction.find('.message_reaction_count');
+ const count_element = reaction.find(".message_reaction_count");
count_element.text(count);
};
@@ -265,7 +265,7 @@ exports.view.update_existing_reaction = function (opts) {
exports.set_reaction_count(reaction, user_list.length);
const new_label = generate_title(emoji_name, user_list);
- reaction.attr('aria-label', new_label);
+ reaction.attr("aria-label", new_label);
if (user_id === page_params.user_id) {
reaction.addClass("reacted");
@@ -292,7 +292,7 @@ exports.view.insert_new_reaction = function (opts) {
const new_label = generate_title(emoji_name, user_list);
- if (opts.reaction_type !== 'unicode_emoji') {
+ if (opts.reaction_type !== "unicode_emoji") {
context.is_realm_emoji = true;
context.url = emoji.all_realm_emojis.get(emoji_code).emoji_url;
}
@@ -300,7 +300,7 @@ exports.view.insert_new_reaction = function (opts) {
context.count = 1;
context.label = new_label;
context.local_id = exports.get_local_reaction_id(opts);
- context.emoji_alt_code = page_params.emojiset === 'text';
+ context.emoji_alt_code = page_params.emojiset === "text";
if (opts.user_id === page_params.user_id) {
context.class = "message_reaction reacted";
@@ -381,7 +381,7 @@ exports.view.remove_reaction = function (opts) {
// "reacted" class.
const new_label = generate_title(emoji_name, user_list);
- reaction.attr('aria-label', new_label);
+ reaction.attr("aria-label", new_label);
// If the user is the current user, turn off the "reacted" class.
@@ -438,8 +438,8 @@ 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 +451,8 @@ 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;
}
@@ -495,9 +495,9 @@ exports.add_clean_reaction = function (opts) {
r.user_ids = opts.user_ids;
exports.update_user_fields(r);
- r.emoji_alt_code = page_params.emojiset === 'text';
+ r.emoji_alt_code = page_params.emojiset === "text";
- if (r.reaction_type !== 'unicode_emoji') {
+ if (r.reaction_type !== "unicode_emoji") {
r.is_realm_emoji = true;
r.url = emoji.all_realm_emojis.get(r.emoji_code).emoji_url;
}
diff --git a/static/js/realm_icon.js b/static/js/realm_icon.js
index 68d3858b00f..c2932c3c57e 100644
--- a/static/js/realm_icon.js
+++ b/static/js/realm_icon.js
@@ -1,21 +1,21 @@
exports.build_realm_icon_widget = function (upload_function) {
const get_file_input = function () {
- return $('#realm-icon-upload-widget .image_file_input').expectOne();
+ return $("#realm-icon-upload-widget .image_file_input").expectOne();
};
if (!page_params.is_admin) {
return;
}
- if (page_params.realm_icon_source === 'G') {
+ if (page_params.realm_icon_source === "G") {
$("#realm-icon-upload-widget .settings-page-delete-button").hide();
} else {
$("#realm-icon-upload-widget .settings-page-delete-button").show();
}
- $("#realm-icon-upload-widget .settings-page-delete-button").on('click', (e) => {
+ $("#realm-icon-upload-widget .settings-page-delete-button").on("click", (e) => {
e.preventDefault();
e.stopPropagation();
channel.del({
- url: '/json/realm/icon',
+ url: "/json/realm/icon",
});
});
@@ -30,14 +30,14 @@ exports.build_realm_icon_widget = function (upload_function) {
exports.rerender = function () {
$("#realm-icon-upload-widget .image-block").attr("src", page_params.realm_icon_url);
- if (page_params.realm_icon_source === 'U') {
+ if (page_params.realm_icon_source === "U") {
$("#realm-icon-upload-widget .settings-page-delete-button").show();
} else {
$("#realm-icon-upload-widget .settings-page-delete-button").hide();
// Need to clear input because of a small edge case
// where you try to upload the same image you just deleted.
const file_input = $("#realm-icon-upload-widget .image_file_input");
- file_input.val('');
+ file_input.val("");
}
};
diff --git a/static/js/realm_logo.js b/static/js/realm_logo.js
index 26210e1f364..71d17b94a5d 100644
--- a/static/js/realm_logo.js
+++ b/static/js/realm_logo.js
@@ -1,11 +1,11 @@
const settings_config = require("./settings_config");
exports.build_realm_logo_widget = function (upload_function, is_night) {
- let logo_section_id = '#realm-day-logo-upload-widget';
+ let logo_section_id = "#realm-day-logo-upload-widget";
let logo_source = page_params.realm_logo_source;
if (is_night) {
- logo_section_id = '#realm-night-logo-upload-widget';
+ logo_section_id = "#realm-night-logo-upload-widget";
logo_source = page_params.realm_night_logo_source;
}
@@ -22,18 +22,18 @@ exports.build_realm_logo_widget = function (upload_function, is_night) {
return;
}
- if (logo_source === 'D') {
+ if (logo_source === "D") {
delete_button_elem.hide();
} else {
delete_button_elem.show();
}
const data = {night: JSON.stringify(is_night)};
- delete_button_elem.on('click', (e) => {
+ delete_button_elem.on("click", (e) => {
e.preventDefault();
e.stopPropagation();
channel.del({
- url: '/json/realm/logo',
+ url: "/json/realm/logo",
data: data,
});
});
@@ -48,13 +48,13 @@ exports.build_realm_logo_widget = function (upload_function, is_night) {
};
function change_logo_delete_button(logo_source, logo_delete_button, file_input) {
- if (logo_source === 'U') {
+ if (logo_source === "U") {
logo_delete_button.show();
} else {
logo_delete_button.hide();
// Need to clear input because of a small edge case
// where you try to upload the same image you just deleted.
- file_input.val('');
+ file_input.val("");
}
}
@@ -63,8 +63,8 @@ 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
@@ -76,10 +76,10 @@ exports.rerender = function () {
}
if (page_params.color_scheme === settings_config.color_scheme_values.night.code &&
- page_params.realm_night_logo_source !== 'D' ||
+ 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)) {
+ 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);
diff --git a/static/js/recent_senders.js b/static/js/recent_senders.js
index 3bf0645b697..92a005481d1 100644
--- a/static/js/recent_senders.js
+++ b/static/js/recent_senders.js
@@ -1,4 +1,4 @@
-const FoldDict = require('./fold_dict').FoldDict;
+const FoldDict = require("./fold_dict").FoldDict;
// topic_senders[stream_id][topic_id][sender_id] = latest_message_id
const topic_senders = new Map();
diff --git a/static/js/recent_topics.js b/static/js/recent_topics.js
index 007199a3d33..edb7e21449c 100644
--- a/static/js/recent_topics.js
+++ b/static/js/recent_topics.js
@@ -1,6 +1,6 @@
-const render_recent_topics_body = require('../templates/recent_topics_table.hbs');
-const render_recent_topic_row = require('../templates/recent_topic_row.hbs');
-const render_recent_topics_filters = require('../templates/recent_topics_filters.hbs');
+const render_recent_topics_body = require("../templates/recent_topics_table.hbs");
+const render_recent_topic_row = require("../templates/recent_topic_row.hbs");
+const render_recent_topics_filters = require("../templates/recent_topics_filters.hbs");
const topics = new Map(); // Key is stream-id:topic.
let topics_widget;
// Sets the number of avatars to display.
@@ -46,8 +46,8 @@ function set_table_focus(row, col) {
return true;
}
- topic_rows.eq(row).find('.recent_topics_focusable').eq(col).children().focus();
- current_focus_elem = 'table';
+ topic_rows.eq(row).find(".recent_topics_focusable").eq(col).children().focus();
+ current_focus_elem = "table";
return true;
}
@@ -60,12 +60,12 @@ function revive_current_focus() {
return false;
}
- if (current_focus_elem === 'table') {
+ if (current_focus_elem === "table") {
set_table_focus(row_focus, col_focus);
return true;
}
- const filter_button = current_focus_elem.data('filter');
+ const filter_button = current_focus_elem.data("filter");
if (!filter_button) {
set_default_focus();
} else {
@@ -93,7 +93,7 @@ exports.process_messages = function (messages) {
};
exports.process_message = function (msg) {
- if (msg.type !== 'stream') {
+ if (msg.type !== "stream") {
return false;
}
// Initialize topic data
@@ -196,7 +196,7 @@ function format_topic(topic_data) {
muted: muted,
topic_muted: topic_muted,
participated: topic_data.participated,
- full_last_msg_date_time: full_datetime.date + ' ' + full_datetime.time,
+ full_last_msg_date_time: full_datetime.date + " " + full_datetime.time,
};
}
@@ -225,9 +225,9 @@ exports.topic_in_search_results = function (keyword, stream, topic) {
}
// Escape speacial characters from input.
// https://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
- keyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
- const text = (stream + ' ' + topic).toLowerCase().replace(/\s+/g, ' ');
- const search_words = keyword.toLowerCase().replace(/\s+/g, ' ').split(' ');
+ keyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
+ const text = (stream + " " + topic).toLowerCase().replace(/\s+/g, " ");
+ const search_words = keyword.toLowerCase().replace(/\s+/g, " ").split(" ");
return search_words.every((word) => {
if (text.search(word) !== -1) {
return true;
@@ -259,18 +259,18 @@ exports.filters_should_hide_topic = function (topic_data) {
return true;
}
- if (filters.has('unread')) {
+ if (filters.has("unread")) {
const unreadCount = unread.unread_topic_counter.get(msg.stream_id, msg.topic);
if (unreadCount === 0) {
return true;
}
}
- if (!topic_data.participated && filters.has('participated')) {
+ if (!topic_data.participated && filters.has("participated")) {
return true;
}
- if (!filters.has('include_muted')) {
+ if (!filters.has("include_muted")) {
const topic_muted = !!muting.is_topic_muted(msg.stream_id, msg.topic);
const stream_muted = stream_data.is_muted(msg.stream_id);
if (topic_muted || stream_muted) {
@@ -331,14 +331,14 @@ exports.set_filter = function (filter) {
// set `filters`.
// Get the button which was clicked.
- const filter_elem = $('#recent_topics_filter_buttons')
+ 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) {
+ if (filter === "all" && filters.size !== 0) {
filters = new Set();
// If the button was already selected, remove the filter.
- } else if (filter_elem.hasClass('btn-recent-selected')) {
+ } else if (filter_elem.hasClass("btn-recent-selected")) {
filters.delete(filter);
// If the button was not selected, we add the filter.
} else {
@@ -350,23 +350,23 @@ function show_selected_filters() {
// Add `btn-selected-filter` to the buttons to show
// which filters are applied.
if (filters.size === 0) {
- $('#recent_topics_filter_buttons')
+ $("#recent_topics_filter_buttons")
.find('[data-filter="all"]')
- .addClass('btn-recent-selected');
+ .addClass("btn-recent-selected");
} else {
for (const filter of filters) {
- $('#recent_topics_filter_buttons')
+ $("#recent_topics_filter_buttons")
.find('[data-filter="' + filter + '"]')
- .addClass('btn-recent-selected');
+ .addClass("btn-recent-selected");
}
}
}
exports.update_filters_view = function () {
const rendered_filters = render_recent_topics_filters({
- filter_participated: filters.has('participated'),
- filter_unread: filters.has('unread'),
- filter_muted: filters.has('include_muted'),
+ filter_participated: filters.has("participated"),
+ filter_unread: filters.has("unread"),
+ filter_muted: filters.has("include_muted"),
});
$("#recent_filters_group").html(rendered_filters);
show_selected_filters();
@@ -403,16 +403,16 @@ exports.complete_rerender = function () {
}
// Prepare header
const rendered_body = render_recent_topics_body({
- filter_participated: filters.has('participated'),
- filter_unread: filters.has('unread'),
- filter_muted: filters.has('include_muted'),
+ filter_participated: filters.has("participated"),
+ filter_unread: filters.has("unread"),
+ filter_muted: filters.has("include_muted"),
search_val: $("#recent_topics_search").val() || "",
});
- $('#recent_topics_table').html(rendered_body);
+ $("#recent_topics_table").html(rendered_body);
show_selected_filters();
// Show topics list
- const container = $('.recent_topics_table table tbody');
+ const container = $(".recent_topics_table table tbody");
container.empty();
const mapped_topic_values = Array.from(exports.get().values()).map((value) => value);
@@ -434,15 +434,15 @@ exports.complete_rerender = function () {
topic_sort: topic_sort,
},
html_selector: get_topic_row,
- simplebar_container: $('#recent_topics_table .table_fix_head'),
+ simplebar_container: $("#recent_topics_table .table_fix_head"),
});
revive_current_focus();
};
exports.launch = function () {
overlays.open_overlay({
- name: 'recent_topics',
- overlay: $('#recent_topics_overlay'),
+ name: "recent_topics",
+ overlay: $("#recent_topics_overlay"),
on_close: function () {
hashchange.exit_overlay();
},
@@ -451,7 +451,7 @@ exports.launch = function () {
};
function filter_buttons() {
- return $('#recent_filters_group').children();
+ return $("#recent_filters_group").children();
}
exports.change_focused_element = function (e, input_key) {
@@ -459,22 +459,22 @@ exports.change_focused_element = function (e, input_key) {
// returning true will cause the caller to do
// preventDefault/stopPropagation; false will let the browser
// handle the key.
- if (input_key === 'tab') {
- input_key = 'right_arrow';
- } else if (input_key === 'shift_tab') {
- input_key = 'left_arrow';
+ if (input_key === "tab") {
+ input_key = "right_arrow";
+ } else if (input_key === "shift_tab") {
+ input_key = "left_arrow";
}
const $elem = $(e.target);
- if ($("#recent_topics_table").find(':focus').length === 0) {
+ if ($("#recent_topics_table").find(":focus").length === 0) {
// This is a failsafe to return focus back to recent topics overlay,
// in case it loses focus due to some unknown reason.
set_default_focus();
return false;
}
- if (e.target.id === 'recent_topics_search') {
+ if (e.target.id === "recent_topics_search") {
// Since the search box a text area, we want the browser to handle
// Left/Right and selection within the widget; but if the user
// arrows off the edges, we should move focus to the adjacent widgets..
@@ -488,22 +488,22 @@ exports.change_focused_element = function (e, input_key) {
}
switch (input_key) {
- case 'left_arrow':
+ case "left_arrow":
if (start !== 0 || is_selected) {
return false;
}
current_focus_elem = filter_buttons().last();
break;
- case 'right_arrow':
+ case "right_arrow":
if (end !== text_length || is_selected) {
return false;
}
current_focus_elem = filter_buttons().first();
break;
- case 'down_arrow':
+ case "down_arrow":
set_table_focus(row_focus, col_focus);
return true;
- case 'click':
+ 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.
@@ -513,47 +513,47 @@ exports.change_focused_element = function (e, input_key) {
current_focus_elem = $("#recent_topics_search");
return true;
}
- } else if ($elem.hasClass('btn-recent-filters')) {
+ } else if ($elem.hasClass("btn-recent-filters")) {
switch (input_key) {
- case 'left_arrow':
+ case "left_arrow":
if (filter_buttons().first()[0] === $elem[0]) {
current_focus_elem = $("#recent_topics_search");
} else {
current_focus_elem = $elem.prev();
}
break;
- case 'right_arrow':
+ case "right_arrow":
if (filter_buttons().last()[0] === $elem[0]) {
current_focus_elem = $("#recent_topics_search");
} else {
current_focus_elem = $elem.next();
}
break;
- case 'down_arrow':
+ case "down_arrow":
set_table_focus(row_focus, col_focus);
return true;
}
- } else if (current_focus_elem === 'table') {
+ } else if (current_focus_elem === "table") {
// For arrowing around the table of topics, we implement left/right
// wraparound. Going off the top or the bottom takes one
// to the navigation at the top (see set_table_focus).
switch (input_key) {
- case 'left_arrow':
+ case "left_arrow":
col_focus -= 1;
if (col_focus < 0) {
col_focus = MAX_SELECTABLE_COLS - 1;
}
break;
- case 'right_arrow':
+ case "right_arrow":
col_focus += 1;
if (col_focus >= MAX_SELECTABLE_COLS) {
col_focus = 0;
}
break;
- case 'down_arrow':
+ case "down_arrow":
row_focus += 1;
break;
- case 'up_arrow':
+ case "up_arrow":
row_focus -= 1;
}
set_table_focus(row_focus, col_focus);
diff --git a/static/js/reload.js b/static/js/reload.js
index 9266a7be150..d44dc67ca25 100644
--- a/static/js/reload.js
+++ b/static/js/reload.js
@@ -22,11 +22,11 @@ function preserve_state(send_after_reload, save_pointer, save_narrow, save_compo
if (save_compose) {
const msg_type = compose_state.get_message_type();
- if (msg_type === 'stream') {
+ if (msg_type === "stream") {
url += "+msg_type=stream";
url += "+stream=" + encodeURIComponent(compose_state.stream_name());
url += "+topic=" + encodeURIComponent(compose_state.topic());
- } else if (msg_type === 'private') {
+ } else if (msg_type === "private") {
url += "+msg_type=private";
url += "+recipient=" + encodeURIComponent(compose_state.private_message_recipient());
}
@@ -64,14 +64,14 @@ function preserve_state(send_after_reload, save_pointer, save_narrow, save_compo
}
let oldhash = window.location.hash;
- if (oldhash.length !== 0 && oldhash[0] === '#') {
+ if (oldhash.length !== 0 && oldhash[0] === "#") {
oldhash = oldhash.slice(1);
}
url += "+oldhash=" + encodeURIComponent(oldhash);
const ls = localstorage();
// Delete all the previous preserved states.
- ls.removeRegex('reload:\\d+');
+ ls.removeRegex("reload:\\d+");
// To protect the browser against CSRF type attacks, the reload
// logic uses a random token (to distinct this browser from
@@ -92,7 +92,7 @@ function preserve_state(send_after_reload, save_pointer, save_narrow, save_compo
// done before the first call to get_events
exports.initialize = function () {
const location = window.location.toString();
- const hash_fragment = location.substring(location.indexOf('#') + 1);
+ const hash_fragment = location.substring(location.indexOf("#") + 1);
// hash_fragment should be e.g. `reload:12345123412312`
if (hash_fragment.search("reload:") !== 0) {
@@ -131,10 +131,10 @@ 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,7 +179,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',
+ blueslip.error("Failed to preserve state",
undefined, ex.stack);
}
}
@@ -190,7 +190,7 @@ function do_reload_app(send_after_reload, save_pointer, save_narrow, save_compos
// TODO: We need a better API for showing messages.
ui_report.message(message, $("#reloading-application"));
- blueslip.log('Starting server requested page reload');
+ blueslip.log("Starting server requested page reload");
reload_state.set_state_to_in_progress();
// Sometimes the window.location.reload that we attempt has no
@@ -199,7 +199,7 @@ function do_reload_app(send_after_reload, save_pointer, save_narrow, save_compos
// broken state and cause lots of confusing tracebacks. So, we
// set ourselves to try reloading a bit later, both periodically
// and when the user focuses the window.
- $(window).on('focus', () => {
+ $(window).on("focus", () => {
blueslip.log("Retrying on-focus page reload");
window.location.reload(true);
});
@@ -211,7 +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',
+ blueslip.error("Failed to cleanup before reloading",
undefined, ex.stack);
}
@@ -295,9 +295,9 @@ exports.initiate = function (options) {
idle_control.cancel();
idle_control = $(document).idle({idle: basic_idle_timeout,
onIdle: reload_from_idle});
- $(document).off('compose_canceled.zulip compose_finished.zulip',
+ $(document).off("compose_canceled.zulip compose_finished.zulip",
compose_done_handler);
- $(document).on('compose_started.zulip', compose_started_handler);
+ $(document).on("compose_started.zulip", compose_started_handler);
};
compose_started_handler = function () {
// If the user stops being idle and starts composing a
@@ -305,24 +305,24 @@ exports.initiate = function (options) {
idle_control.cancel();
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',
+ $(document).off("compose_started.zulip", compose_started_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',
+ $(document).on("compose_canceled.zulip compose_finished.zulip",
compose_done_handler);
} else {
idle_control = $(document).idle({idle: basic_idle_timeout,
onIdle: reload_from_idle});
- $(document).on('compose_started.zulip', compose_started_handler);
+ $(document).on("compose_started.zulip", compose_started_handler);
}
};
-window.addEventListener('beforeunload', () => {
+window.addEventListener("beforeunload", () => {
// When navigating away from the page do not try to reload.
// The polling get_events call will fail after we delete the event queue.
// When that happens we reload the page to correct the problem. If this
diff --git a/static/js/reminder.js b/static/js/reminder.js
index a401b9fe46f..1b38cf65419 100644
--- a/static/js/reminder.js
+++ b/static/js/reminder.js
@@ -1,14 +1,14 @@
const util = require("./util");
const deferred_message_types = {
scheduled: {
- delivery_type: 'send_later',
+ delivery_type: "send_later",
test: /^\/schedule/,
- slash_command: '/schedule',
+ slash_command: "/schedule",
},
reminders: {
- delivery_type: 'remind',
+ delivery_type: "remind",
test: /^\/remind/,
- slash_command: '/remind',
+ slash_command: "/remind",
},
};
@@ -41,9 +41,9 @@ exports.schedule_message = function (request) {
request = compose.create_message_object();
}
- const raw_message = request.content.split('\n');
+ const raw_message = request.content.split("\n");
const command_line = raw_message[0];
- const message = raw_message.slice(1).join('\n');
+ const message = raw_message.slice(1).join("\n");
const deferred_message_type = deferred_message_types.filter(
(props) => command_line.match(props.test) !== null,
@@ -52,16 +52,16 @@ 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'));
- } else if (deliver_at.trim() === '') {
- compose.compose_error(i18n.t('Please specify a date or time'), $('#compose-textarea'));
+ $("#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"));
+ } else if (deliver_at.trim() === "") {
+ compose.compose_error(i18n.t("Please specify a date or time"), $("#compose-textarea"));
} else {
- compose.compose_error(i18n.t('Your reminder note is empty!'), $('#compose-textarea'));
+ compose.compose_error(i18n.t("Your reminder note is empty!"), $("#compose-textarea"));
}
return;
}
@@ -72,18 +72,18 @@ exports.schedule_message = function (request) {
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-textarea").attr("disabled", false);
compose.clear_compose_box();
};
const error = function (response) {
- $("#compose-textarea").attr('disabled', false);
- compose.compose_error(response, $('#compose-textarea'));
+ $("#compose-textarea").attr("disabled", false);
+ compose.compose_error(response, $("#compose-textarea"));
};
/* We are adding a disable on compose under this block because we
want slash commands to be blocking in nature. */
- $("#compose-textarea").attr('disabled', true);
+ $("#compose-textarea").attr("disabled", true);
transmit.send_message(request, success, error);
};
@@ -105,7 +105,7 @@ exports.do_set_reminder_for_message = function (message_id, timestamp) {
if (!message.raw_content) {
const msg_list = current_msg_list;
channel.get({
- url: '/json/messages/' + message.id,
+ url: "/json/messages/" + message.id,
idempotent: true,
success: function (data) {
if (current_msg_list === msg_list) {
@@ -119,13 +119,13 @@ 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,
- stream: '',
+ stream: "",
};
- reminder_message.topic = '';
+ reminder_message.topic = "";
const recipient = page_params.email;
const emails = util.extract_pm_recipients(recipient);
diff --git a/static/js/rendered_markdown.js b/static/js/rendered_markdown.js
index ff5185de792..90be4676ad4 100644
--- a/static/js/rendered_markdown.js
+++ b/static/js/rendered_markdown.js
@@ -10,10 +10,10 @@
*/
function get_user_id_for_mention_button(elem) {
- const user_id_string = $(elem).attr('data-user-id');
+ const user_id_string = $(elem).attr("data-user-id");
// Handle legacy markdown that was rendered before we cut
// over to using data-user-id.
- const email = $(elem).attr('data-user-email');
+ const email = $(elem).attr("data-user-email");
if (user_id_string === "*" || email === "*") {
return "*";
@@ -35,7 +35,7 @@ function get_user_id_for_mention_button(elem) {
}
function get_user_group_id_for_mention_button(elem) {
- const user_group_id = $(elem).attr('data-user-group-id');
+ const user_group_id = $(elem).attr("data-user-group-id");
if (user_group_id) {
return parseInt(user_group_id, 10);
@@ -46,7 +46,7 @@ function get_user_group_id_for_mention_button(elem) {
// Helper function to update a mentioned user's name.
exports.set_name_in_mention_element = function (element, name) {
- if ($(element).hasClass('silent')) {
+ if ($(element).hasClass("silent")) {
$(element).text(name);
} else {
$(element).text("@" + name);
@@ -55,17 +55,17 @@ exports.set_name_in_mention_element = function (element, name) {
exports.update_elements = (content) => {
// Set the rtl class if the text has an rtl direction
- if (rtl.get_direction(content.text()) === 'rtl') {
- content.addClass('rtl');
+ if (rtl.get_direction(content.text()) === "rtl") {
+ content.addClass("rtl");
}
- content.find('.user-mention').each(function () {
+ content.find(".user-mention").each(function () {
const user_id = get_user_id_for_mention_button(this);
// We give special highlights to the mention buttons
// that refer to the current user.
if (user_id === "*" || people.is_my_user_id(user_id)) {
// Either a wildcard mention or us, so mark it.
- $(this).addClass('user-mention-me');
+ $(this).addClass("user-mention-me");
}
if (user_id && user_id !== "*" && !$(this).find(".highlight").length) {
// If it's a mention of a specific user, edit the
@@ -81,7 +81,7 @@ exports.update_elements = (content) => {
}
});
- content.find('.user-group-mention').each(function () {
+ content.find(".user-group-mention").each(function () {
const user_group_id = get_user_group_id_for_mention_button(this);
const user_group = user_groups.get_user_group_from_id(user_group_id, true);
if (user_group === undefined) {
@@ -95,7 +95,7 @@ exports.update_elements = (content) => {
const my_user_id = people.my_current_user_id();
// Mark user group you're a member of.
if (user_groups.is_member_of(user_group_id, my_user_id)) {
- $(this).addClass('user-mention-me');
+ $(this).addClass("user-mention-me");
}
if (user_group_id && !$(this).find(".highlight").length) {
@@ -105,8 +105,8 @@ exports.update_elements = (content) => {
}
});
- content.find('a.stream').each(function () {
- const stream_id = parseInt($(this).attr('data-stream-id'), 10);
+ content.find("a.stream").each(function () {
+ const stream_id = parseInt($(this).attr("data-stream-id"), 10);
if (stream_id && !$(this).find(".highlight").length) {
// Display the current name for stream if it is not
// being displayed in search highlight.
@@ -120,27 +120,27 @@ exports.update_elements = (content) => {
}
});
- content.find('a.stream-topic').each(function () {
- const stream_id = parseInt($(this).attr('data-stream-id'), 10);
+ content.find("a.stream-topic").each(function () {
+ const stream_id = parseInt($(this).attr("data-stream-id"), 10);
if (stream_id && !$(this).find(".highlight").length) {
// Display the current name for stream if it is not
// being displayed in search highlight.
const text = $(this).text();
- const topic = text.split('>', 2)[1];
+ const topic = text.split(">", 2)[1];
const stream_name = stream_data.maybe_get_stream_name(stream_id);
if (stream_name !== undefined) {
// If the stream has been deleted,
// stream_data.maybe_get_stream_name might return
// undefined. Otherwise, display the current stream name.
- $(this).text("#" + stream_name + ' > ' + topic);
+ $(this).text("#" + stream_name + " > " + topic);
}
}
});
- content.find('time').each(function () {
+ content.find("time").each(function () {
// Populate each timestamp span with mentioned time
// in user's local timezone.
- const time_str = $(this).attr('datetime');
+ const time_str = $(this).attr("datetime");
if (time_str === undefined) {
return;
}
@@ -155,24 +155,24 @@ exports.update_elements = (content) => {
const text = $(this).text();
const rendered_time = timerender.render_markdown_timestamp(timestamp, text);
$(this).text(rendered_time.text);
- $(this).attr('title', rendered_time.title);
+ $(this).attr("title", rendered_time.title);
} else {
// This shouldn't happen. If it does, we're very interested in debugging it.
blueslip.error(`Moment could not parse datetime supplied by backend: ${time_str}`);
}
});
- content.find('span.timestamp-error').each(function () {
- const time_str = $(this).text().replace('Invalid time format: ', '');
- const text = i18n.t('Invalid time format: __timestamp__', { timestamp: time_str });
+ content.find("span.timestamp-error").each(function () {
+ const time_str = $(this).text().replace("Invalid time format: ", "");
+ const text = i18n.t("Invalid time format: __timestamp__", { timestamp: time_str });
$(this).text(text);
});
- content.find('div.spoiler-header').each(function () {
+ content.find("div.spoiler-header").each(function () {
// If a spoiler block has no header content, it should have a default header.
// We do this client side to allow for i18n by the client.
if ($.trim($(this).html()).length === 0) {
- $(this).append(`<p>${i18n.t('Spoiler')}</p>`);
+ $(this).append(`<p>${i18n.t("Spoiler")}</p>`);
}
// Add the expand/collapse button to spoiler blocks
@@ -183,7 +183,7 @@ exports.update_elements = (content) => {
// Display emoji (including realm emoji) as text if
// page_params.emojiset is 'text'.
- if (page_params.emojiset === 'text') {
+ if (page_params.emojiset === "text") {
content.find(".emoji").replaceWith(function () {
const text = $(this).attr("title");
return ":" + text + ":";
diff --git a/static/js/resize.js b/static/js/resize.js
index ae6a747486e..a5968acb3bd 100644
--- a/static/js/resize.js
+++ b/static/js/resize.js
@@ -1,5 +1,5 @@
const util = require("./util");
-const autosize = require('autosize');
+const autosize = require("autosize");
let narrow_window = false;
@@ -76,8 +76,8 @@ function left_userlist_get_new_heights() {
// left sidebar
- const stream_filters = $('#stream_filters').expectOne();
- const buddy_list_wrapper = $('#buddy_list_wrapper').expectOne();
+ const stream_filters = $("#stream_filters").expectOne();
+ const buddy_list_wrapper = $("#buddy_list_wrapper").expectOne();
const stream_filters_real_height = stream_filters.prop("scrollHeight");
const user_list_real_height = ui.get_scroll_element(buddy_list_wrapper).prop("scrollHeight");
@@ -114,7 +114,7 @@ exports.watch_manual_resize = function (element) {
const box = document.querySelector(element);
if (!box) {
- blueslip.error('Bad selector in watch_manual_resize: ' + element);
+ blueslip.error("Bad selector in watch_manual_resize: " + element);
return;
}
@@ -159,7 +159,7 @@ exports.resize_bottom_whitespace = function (h) {
exports.resize_stream_filters_container = function (h) {
h = narrow_window ? left_userlist_get_new_heights() : get_new_heights();
exports.resize_bottom_whitespace(h);
- $("#stream-filters-container").css('max-height', h.stream_filters_max_height);
+ $("#stream-filters-container").css("max-height", h.stream_filters_max_height);
};
exports.resize_sidebars = function () {
@@ -170,7 +170,7 @@ exports.resize_sidebars = function () {
$("#top_navbar").removeClass("rightside-userlist");
- const right_items = $('.right-sidebar-items').expectOne();
+ const right_items = $(".right-sidebar-items").expectOne();
if (css_narrow_mode && !narrow_window) {
// move stuff to the left sidebar (skinny mode)
@@ -187,16 +187,16 @@ exports.resize_sidebars = function () {
popovers.set_userlist_placement("right");
sidebar = $("#right-sidebar").expectOne();
sidebar.append(right_items);
- $("#buddy_list_wrapper").css("margin", '');
- $("#userlist-toggle").css("display", '');
+ $("#buddy_list_wrapper").css("margin", "");
+ $("#userlist-toggle").css("display", "");
$("#invite-user-link").show();
}
}
const h = narrow_window ? left_userlist_get_new_heights() : get_new_heights();
- $("#buddy_list_wrapper").css('max-height', h.buddy_list_wrapper_max_height);
- $("#stream-filters-container").css('max-height', h.stream_filters_max_height);
+ $("#buddy_list_wrapper").css("max-height", h.buddy_list_wrapper_max_height);
+ $("#stream-filters-container").css("max-height", h.stream_filters_max_height);
return h;
};
diff --git a/static/js/rows.js b/static/js/rows.js
index 25b2b61d902..7aec1429ed9 100644
--- a/static/js/rows.js
+++ b/static/js/rows.js
@@ -5,40 +5,40 @@ exports.next_visible = function (message_row) {
if (message_row === undefined || message_row.length === 0) {
return $();
}
- const row = message_row.next('.selectable_row');
+ const row = message_row.next(".selectable_row");
if (row.length !== 0) {
return row;
}
const recipient_row = exports.get_message_recipient_row(message_row);
- const next_recipient_rows = $(recipient_row).nextAll('.recipient_row');
+ const next_recipient_rows = $(recipient_row).nextAll(".recipient_row");
if (next_recipient_rows.length === 0) {
return $();
}
- return $('.selectable_row', next_recipient_rows[0]).first();
+ return $(".selectable_row", next_recipient_rows[0]).first();
};
exports.prev_visible = function (message_row) {
if (message_row === undefined || message_row.length === 0) {
return $();
}
- const row = message_row.prev('.selectable_row');
+ const row = message_row.prev(".selectable_row");
if (row.length !== 0) {
return row;
}
const recipient_row = exports.get_message_recipient_row(message_row);
- const prev_recipient_rows = $(recipient_row).prevAll('.recipient_row');
+ const prev_recipient_rows = $(recipient_row).prevAll(".recipient_row");
if (prev_recipient_rows.length === 0) {
return $();
}
- return $('.selectable_row', prev_recipient_rows[0]).last();
+ return $(".selectable_row", prev_recipient_rows[0]).last();
};
exports.first_visible = function () {
- return $('.focused_table .selectable_row').first();
+ return $(".focused_table .selectable_row").first();
};
exports.last_visible = function () {
- return $('.focused_table .selectable_row').last();
+ return $(".focused_table .selectable_row").last();
};
exports.visible_range = function (start_id, end_id) {
@@ -66,12 +66,12 @@ exports.visible_range = function (start_id, end_id) {
};
exports.is_draft_row = function (row) {
- return row.find('.restore-draft').length >= 1;
+ return row.find(".restore-draft").length >= 1;
};
exports.id = function (message_row) {
if (exports.is_draft_row(message_row)) {
- blueslip.error('Drafts have no zid');
+ blueslip.error("Drafts have no zid");
return;
}
@@ -87,7 +87,7 @@ exports.id = function (message_row) {
blueslip.error("Caller should pass in a single row.");
}
- const zid = message_row.attr('zid');
+ const zid = message_row.attr("zid");
if (zid === undefined) {
blueslip.error("Calling code passed rows.id a row with no zid attr.");
@@ -97,15 +97,15 @@ exports.id = function (message_row) {
};
exports.local_echo_id = function (message_row) {
- const zid = message_row.attr('zid');
+ const zid = message_row.attr("zid");
if (zid === undefined) {
blueslip.error("Calling code passed rows.local_id a row with no zid attr.");
return;
}
- if (!zid.includes('.0')) {
- blueslip.error('Trying to get local_id from row that has reified message id: ' + zid);
+ if (!zid.includes(".0")) {
+ blueslip.error("Trying to get local_id from row that has reified message id: " + zid);
}
return zid;
@@ -121,7 +121,7 @@ exports.get_table = function (table_name) {
return $();
}
- return $('#' + table_name);
+ return $("#" + table_name);
};
exports.get_message_id = function (elem) {
@@ -141,19 +141,19 @@ exports.get_closest_group = function (element) {
};
exports.first_message_in_group = function (message_group) {
- return $('div.message_row', message_group).first();
+ return $("div.message_row", message_group).first();
};
exports.get_message_recipient_row = function (message_row) {
- return $(message_row).parent('.recipient_row').expectOne();
+ return $(message_row).parent(".recipient_row").expectOne();
};
exports.get_message_recipient_header = function (message_row) {
- return $(message_row).parent('.recipient_row').find('.message_header').expectOne();
+ return $(message_row).parent(".recipient_row").find(".message_header").expectOne();
};
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 03bb42901f0..dbbfe6d358c 100644
--- a/static/js/rtl.js
+++ b/static/js/rtl.js
@@ -58,7 +58,7 @@ const rl_ranges = convert_from_raw(digits, 2, 'fIfIf}f}g0g0g3g3g6g6g8g"g,g,g/g/g
*/
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]'));
+ 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.
@@ -67,20 +67,20 @@ const lr_ranges = convert_from_raw(digits, 2, '0$0}151u1<1<1|1|2222282u2w2!2#7Q7
*/
function get_bidi_class(ch) {
if (i_chars.includes(ch)) {
- return 'I'; // LRI, RLI, FSI
+ return "I"; // LRI, RLI, FSI
}
if (pdi_chars.includes(ch)) {
- return 'PDI';
+ return "PDI";
}
let i = util.lower_bound(rl_ranges, ch);
if (i < rl_ranges.length && (rl_ranges[i] === ch || i % 2 === 1)) {
- return 'R'; // R, AL
+ return "R"; // R, AL
}
i = util.lower_bound(lr_ranges, ch);
if (i < lr_ranges.length && (lr_ranges[i] === ch || i % 2 === 1)) {
- return 'L';
+ return "L";
}
- return 'Other';
+ return "Other";
}
/**
@@ -111,35 +111,35 @@ 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') {
+ } 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';
+ return "rtl";
}
- } else if (bidi_class === 'L') {
+ } else if (bidi_class === "L") {
if (isolations === 0) {
- return 'ltr';
+ return "ltr";
}
}
}
- return 'ltr';
+ return "ltr";
};
exports.set_rtl_class_for_textarea = function (textarea) {
// Set the rtl class if the text has an rtl direction, remove it otherwise
let text = textarea.val();
- if (text.startsWith('```quote')) {
+ if (text.startsWith("```quote")) {
text = text.substr(8);
}
- if (exports.get_direction(text) === 'rtl') {
- textarea.addClass('rtl');
+ if (exports.get_direction(text) === "rtl") {
+ textarea.addClass("rtl");
} else {
- textarea.removeClass('rtl');
+ textarea.removeClass("rtl");
}
};
diff --git a/static/js/schema.js b/static/js/schema.js
index 22053096200..aee875ad5f8 100644
--- a/static/js/schema.js
+++ b/static/js/schema.js
@@ -9,39 +9,39 @@ side validators in zerver/lib/validator.py.
exports.check_string = function (var_name, val) {
if (typeof val !== "string") {
- return var_name + ' is not a string';
+ return var_name + " is not a string";
}
};
exports.check_record = function (var_name, val, fields) {
if (typeof val !== "object") {
- return var_name + ' is not a record';
+ return var_name + " is not a record";
}
const field_results = Object.entries(fields).map(([field_name, f]) => {
if (val[field_name] === undefined) {
- return field_name + ' is missing';
+ return field_name + " is missing";
}
return f(field_name, val[field_name]);
});
- const msg = field_results.filter(Boolean).sort().join(', ');
+ const msg = field_results.filter(Boolean).sort().join(", ");
if (msg) {
- return 'in ' + var_name + ' ' + msg;
+ return "in " + var_name + " " + msg;
}
};
exports.check_array = function (var_name, val, checker) {
if (!Array.isArray(val)) {
- return var_name + ' is not an array';
+ return var_name + " is not an array";
}
for (const item of val) {
- const msg = checker('item', item);
+ const msg = checker("item", item);
if (msg) {
- return 'in ' + var_name + ' we found an item where ' + msg;
+ return "in " + var_name + " we found an item where " + msg;
}
}
};
diff --git a/static/js/scroll_bar.js b/static/js/scroll_bar.js
index 2b71baf40ef..2f1f29d0719 100644
--- a/static/js/scroll_bar.js
+++ b/static/js/scroll_bar.js
@@ -51,7 +51,7 @@ exports.initialize = function () {
$("#compose").css("left", "-" + sbWidth + "px");
$(".compose-content").css({left: sbWidth + "px",
"margin-right": 250 + sbWidth + "px"});
- $('#keyboard-icon').css({right: sbWidth + 35 + "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; } } " +
diff --git a/static/js/search.js b/static/js/search.js
index e6ab9da0abb..ed2ebb3434e 100644
--- a/static/js/search.js
+++ b/static/js/search.js
@@ -9,7 +9,7 @@ exports.narrow_or_search_for_term = function (search_string) {
// while using input tool
return search_query_box.val();
}
- ui_util.change_tab_to('#home');
+ ui_util.change_tab_to("#home");
let operators;
if (page_params.search_pills_enabled) {
@@ -22,7 +22,7 @@ exports.narrow_or_search_for_term = function (search_string) {
} else {
operators = Filter.parse(search_string);
}
- narrow.activate(operators, {trigger: 'search'});
+ narrow.activate(operators, {trigger: "search"});
// It's sort of annoying that this is not in a position to
// blur the search box, because it means that Esc won't
@@ -37,25 +37,25 @@ exports.narrow_or_search_for_term = function (search_string) {
};
function update_buttons_with_focus(focused) {
- const search_query_box = $('#search_query');
+ const search_query_box = $("#search_query");
// 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()) {
- $('.search_button').prop('disabled', false);
+ $(".search_button").prop("disabled", false);
}
}
exports.update_button_visibility = function () {
- update_buttons_with_focus($('#search_query').is(':focus'));
+ update_buttons_with_focus($("#search_query").is(":focus"));
};
exports.initialize = function () {
- const search_query_box = $('#search_query');
- const searchbox_form = $('#searchbox_form');
- const searchbox = $('#searchbox');
+ const search_query_box = $("#search_query");
+ const searchbox_form = $("#searchbox_form");
+ const searchbox = $("#searchbox");
// Data storage for the typeahead.
// This maps a search string to an object with a "description" field.
@@ -66,7 +66,7 @@ exports.initialize = function () {
search_query_box.typeahead({
source: function (query) {
- let base_query = '';
+ let base_query = "";
if (page_params.search_pills_enabled) {
base_query = search_pill.get_search_string_for_current_filter(
search_pill_widget.widget);
@@ -112,7 +112,7 @@ exports.initialize = function () {
on_escape: tab_bar.exit_search,
});
- searchbox_form.on('compositionend', () => {
+ searchbox_form.on("compositionend", () => {
// Set `is_using_input_method` to true if enter is pressed to exit
// the input tool popover and get the text in the search bar. Then
// we suppress searching triggered by this enter key by checking
@@ -155,8 +155,8 @@ exports.initialize = function () {
// but the code was moved here from elsewhere, and it would be
// more work to re-order everything and make them private.
- search_query_box.on('focus', exports.focus_search);
- search_query_box.on('blur', (e) => {
+ search_query_box.on("focus", exports.focus_search);
+ search_query_box.on("blur", (e) => {
// The search query box is a visual cue as to
// whether search or narrowing is active. If
// the user blurs the search box, then we should
@@ -173,7 +173,7 @@ exports.initialize = function () {
// really it would be OK if they did).
if (page_params.search_pills_enabled) {
- const pill_id = $(e.relatedTarget).closest(".pill").data('id');
+ const pill_id = $(e.relatedTarget).closest(".pill").data("id");
const search_pill = search_pill_widget.widget.getByID(pill_id);
if (search_pill) {
// The searchbox loses focus while the search
@@ -193,7 +193,7 @@ exports.initialize = function () {
// Uses jquery instead of pure css as the `:focus` event occurs on `#search_query`,
// while we want to add box-shadow to `#searchbox`. This could have been done
// with `:focus-within` CSS selector, but it is not supported in IE or Opera.
- searchbox.on('focusout', () => {
+ searchbox.on("focusout", () => {
tab_bar.close_search_bar_and_open_narrow_description();
searchbox.css({"box-shadow": "unset"});
});
@@ -207,18 +207,18 @@ exports.focus_search = function () {
exports.initiate_search = function () {
tab_bar.open_search_bar_and_close_narrow_description();
- $('#searchbox').css({"box-shadow": "inset 0px 0px 0px 2px hsl(204, 20%, 74%)"});
- $('#search_query').typeahead('lookup').select();
+ $("#searchbox").css({"box-shadow": "inset 0px 0px 0px 2px hsl(204, 20%, 74%)"});
+ $("#search_query").typeahead("lookup").select();
if (page_params.search_pills_enabled) {
- $('#search_query').focus();
- ui_util.place_caret_at_end($('#search_query')[0]);
+ $("#search_query").focus();
+ ui_util.place_caret_at_end($("#search_query")[0]);
}
};
exports.clear_search_form = function () {
- $('#search_query').val('');
- $('#search_query').blur();
- $('.search_button').prop('disabled', true);
+ $("#search_query").val("");
+ $("#search_query").blur();
+ $(".search_button").prop("disabled", true);
};
window.search = exports;
diff --git a/static/js/search_pill.js b/static/js/search_pill.js
index 69e059e7074..fa4fe2e6b2e 100644
--- a/static/js/search_pill.js
+++ b/static/js/search_pill.js
@@ -34,7 +34,7 @@ exports.append_search_string = function (search_string, pill_widget) {
exports.get_search_string_for_current_filter = function (pill_widget) {
const items = pill_widget.items();
const search_strings = items.map((item) => item.display_value);
- return search_strings.join(' ');
+ return search_strings.join(" ");
};
window.search_pill = exports;
diff --git a/static/js/search_pill_widget.js b/static/js/search_pill_widget.js
index 6cf01824677..cc5f8d6887d 100644
--- a/static/js/search_pill_widget.js
+++ b/static/js/search_pill_widget.js
@@ -2,12 +2,12 @@ exports.initialize = function () {
if (!page_params.search_pills_enabled) {
return;
}
- const container = $('#search_arrows');
+ const container = $("#search_arrows");
exports.widget = search_pill.create_pills(container);
exports.widget.onPillRemove(() => {
if (exports.widget.items().length === 0) {
- ui_util.change_tab_to('#home');
+ ui_util.change_tab_to("#home");
narrow.deactivate();
}
});
diff --git a/static/js/search_suggestion.js b/static/js/search_suggestion.js
index 194e8759cd3..3aae2db2f0e 100644
--- a/static/js/search_suggestion.js
+++ b/static/js/search_suggestion.js
@@ -21,7 +21,7 @@ function make_person_highlighter(query) {
function match_criteria(operators, criteria) {
const filter = new Filter(operators);
return criteria.some((cr) => {
- if (Object.prototype.hasOwnProperty.call(cr, 'operand')) {
+ if (Object.prototype.hasOwnProperty.call(cr, "operand")) {
return filter.has_operand(cr.operator, cr.operand);
}
return filter.has_operator(cr.operator);
@@ -77,12 +77,12 @@ function compare_by_huddle(huddle) {
}
function get_stream_suggestions(last, operators) {
- const valid = ['stream', 'search', ''];
+ const valid = ["stream", "search", ""];
const invalid = [
- {operator: 'stream'},
- {operator: 'streams'},
- {operator: 'is', operand: 'private'},
- {operator: 'pm-with'},
+ {operator: "stream"},
+ {operator: "streams"},
+ {operator: "is", operand: "private"},
+ {operator: "pm-with"},
];
if (!check_validity(last, operators, valid, invalid)) {
return [];
@@ -99,12 +99,12 @@ function get_stream_suggestions(last, operators) {
const hilite = typeahead_helper.highlight_with_escaping_and_regex;
const objs = streams.map((stream) => {
- const prefix = 'stream';
+ const prefix = "stream";
const highlighted_stream = hilite(regex, stream);
- const verb = last.negated ? 'exclude ' : '';
- const description = verb + prefix + ' ' + highlighted_stream;
+ const verb = last.negated ? "exclude " : "";
+ const description = verb + prefix + " " + highlighted_stream;
const term = {
- operator: 'stream',
+ operator: "stream",
operand: stream,
negated: last.negated,
};
@@ -116,7 +116,7 @@ function get_stream_suggestions(last, operators) {
}
function get_group_suggestions(last, operators) {
- if (!check_validity(last, operators, ['pm-with'], [{operator: 'stream'}])) {
+ if (!check_validity(last, operators, ["pm-with"], [{operator: "stream"}])) {
return [];
}
@@ -129,7 +129,7 @@ function get_group_suggestions(last, operators) {
// We only generate group suggestions when there's more than one part, and
// we only use the last part to generate suggestions.
- const last_comma_index = operand.lastIndexOf(',');
+ const last_comma_index = operand.lastIndexOf(",");
if (last_comma_index < 0) {
return [];
}
@@ -140,14 +140,14 @@ function get_group_suggestions(last, operators) {
// We don't suggest a person if their email is already present in the
// operand (not including the last part).
- const parts = all_but_last_part.split(',').concat(people.my_current_email());
+ const parts = all_but_last_part.split(",").concat(people.my_current_email());
const person_matcher = people.build_person_matcher(last_part);
let persons = people.filter_all_persons((person) => {
if (parts.includes(person.email)) {
return false;
}
- return last_part === '' || person_matcher(person);
+ return last_part === "" || person_matcher(person);
});
persons.sort(compare_by_huddle(parts));
@@ -155,21 +155,21 @@ function get_group_suggestions(last, operators) {
// Take top 15 persons, since they're ordered by pm_recipient_count.
persons = persons.slice(0, 15);
- const prefix = Filter.operator_to_prefix('pm-with', negated);
+ const prefix = Filter.operator_to_prefix("pm-with", negated);
const highlight_person = make_person_highlighter(last_part);
const suggestions = persons.map((person) => {
const term = {
- operator: 'pm-with',
- operand: all_but_last_part + ',' + person.email,
+ operator: "pm-with",
+ operand: all_but_last_part + "," + person.email,
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];
+ terms = [{operator: "is", operand: "private"}, term];
}
const search_string = Filter.unparse(terms);
return {description: description, search_string: search_string};
@@ -195,7 +195,7 @@ function make_people_getter(last) {
// This next block is designed to match the behavior of the
// `is:private` block in get_person_suggestions
if (last.operator === "is" && last.operand === "private") {
- query = '';
+ query = "";
} else {
query = last.operand;
}
@@ -216,17 +216,17 @@ function get_person_suggestions(people_getter, last, operators, autocomplete_ope
const query = last.operand;
// Be especially strict about the less common "from" operator.
- if (autocomplete_operator === 'from' && last.operator !== 'from') {
+ if (autocomplete_operator === "from" && last.operator !== "from") {
return [];
}
- const valid = ['search', autocomplete_operator];
+ const valid = ["search", autocomplete_operator];
let invalid;
- if (autocomplete_operator === 'pm-with') {
- invalid = [{operator: 'pm-with'}, {operator: 'stream'}];
+ if (autocomplete_operator === "pm-with") {
+ invalid = [{operator: "pm-with"}, {operator: "stream"}];
} else {
// If not pm-with, then this must either be 'sender' or 'from'
- invalid = [{operator: 'sender'}, {operator: 'from'}];
+ invalid = [{operator: "sender"}, {operator: "from"}];
}
if (!check_validity(last, operators, valid, invalid)) {
@@ -241,16 +241,16 @@ 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 description = prefix + " " + name;
const terms = [{
operator: autocomplete_operator,
operand: person.email,
negated: last.negated,
}];
- if (autocomplete_operator === 'pm-with' && 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
- terms.unshift({operator: 'is', operand: 'private'});
+ terms.unshift({operator: "is", operand: "private"});
}
const search_string = Filter.unparse(terms);
return {description: description, search_string: search_string};
@@ -263,24 +263,24 @@ function get_default_suggestion(operators) {
// Here we return the canonical suggestion for the query that the
// user typed. (The caller passes us the parsed query as "operators".)
if (operators.length === 0) {
- return {description: '', search_string: ''};
+ return {description: "", search_string: ""};
}
return format_as_suggestion(operators);
}
function get_topic_suggestions(last, operators) {
const invalid = [
- {operator: 'pm-with'},
- {operator: 'is', operand: 'private'},
- {operator: 'topic'},
+ {operator: "pm-with"},
+ {operator: "is", operand: "private"},
+ {operator: "topic"},
];
- if (!check_validity(last, operators, ['stream', 'topic', 'search'], invalid)) {
+ if (!check_validity(last, operators, ["stream", "topic", "search"], invalid)) {
return [];
}
const operator = Filter.canonicalize_operator(last.operator);
const operand = last.operand;
- const negated = operator === 'topic' && last.negated;
+ const negated = operator === "topic" && last.negated;
let stream;
let guess;
const filter = new Filter(operators);
@@ -302,19 +302,19 @@ function get_topic_suggestions(last, operators) {
// in terms of telling us whether they provided the operator,
// i.e. "foo" and "search:foo" both become [{operator: 'search', operand: 'foo'}].
switch (operator) {
- case 'stream':
- guess = '';
+ case "stream":
+ guess = "";
stream = operand;
suggest_operators.push(last);
break;
- case 'topic':
- case 'search':
+ case "topic":
+ case "search":
guess = operand;
- if (filter.has_operator('stream')) {
- stream = filter.operands('stream')[0];
+ if (filter.has_operator("stream")) {
+ stream = filter.operands("stream")[0];
} else {
stream = narrow_state.stream();
- suggest_operators.push({operator: 'stream', operand: stream});
+ suggest_operators.push({operator: "stream", operand: stream});
}
break;
}
@@ -339,7 +339,7 @@ function get_topic_suggestions(last, operators) {
// super huge, but still slice off enough topics to find matches.
topics = topics.slice(0, 300);
- if (guess !== '') {
+ if (guess !== "") {
topics = topics.filter((topic) => common.phrase_match(guess, topic));
}
@@ -352,7 +352,7 @@ function get_topic_suggestions(last, operators) {
topics.sort();
return topics.map((topic) => {
- const topic_term = {operator: 'topic', operand: topic, negated: negated};
+ const topic_term = {operator: "topic", operand: topic, negated: negated};
const operators = suggest_operators.concat([topic_term]);
return format_as_suggestion(operators);
});
@@ -378,13 +378,13 @@ function get_operator_subset_suggestions(operators) {
}
function get_special_filter_suggestions(last, operators, suggestions) {
- const is_search_operand_negated = last.operator === 'search' && last.operand[0] === '-';
+ const is_search_operand_negated = last.operator === "search" && last.operand[0] === "-";
// Negating suggestions on is_search_operand_negated is required for
// suggesting negated operators.
if (last.negated || is_search_operand_negated) {
suggestions = suggestions.map((suggestion) => ({
- search_string: '-' + suggestion.search_string,
- description: 'exclude ' + suggestion.description,
+ search_string: "-" + suggestion.search_string,
+ description: "exclude " + suggestion.description,
invalid: suggestion.invalid,
}));
}
@@ -394,14 +394,14 @@ function get_special_filter_suggestions(last, operators, suggestions) {
if (match_criteria(operators, s.invalid)) {
return false;
}
- if (last_string === '') {
+ if (last_string === "") {
return true;
}
// 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' &&
+ const show_operator_suggestions = last.operator === "search" &&
suggestion_operand.toLowerCase().startsWith(last_string);
return s.search_string.toLowerCase().startsWith(last_string) ||
show_operator_suggestions ||
@@ -409,8 +409,8 @@ function get_special_filter_suggestions(last, operators, suggestions) {
});
// Only show home if there's an empty bar
- if (operators.length === 0 && last_string === '') {
- suggestions.unshift({search_string: '', description: 'All messages'});
+ if (operators.length === 0 && last_string === "") {
+ suggestions.unshift({search_string: "", description: "All messages"});
}
return suggestions;
}
@@ -418,15 +418,15 @@ function get_special_filter_suggestions(last, operators, suggestions) {
function get_streams_filter_suggestions(last, operators) {
const suggestions = [
{
- search_string: 'streams:public',
- description: 'All public streams in organization',
+ search_string: "streams:public",
+ description: "All public streams in organization",
invalid: [
- {operator: 'is', operand: 'private'},
- {operator: 'stream'},
- {operator: 'group-pm-with'},
- {operator: 'pm-with'},
- {operator: 'in'},
- {operator: 'streams'},
+ {operator: "is", operand: "private"},
+ {operator: "stream"},
+ {operator: "group-pm-with"},
+ {operator: "pm-with"},
+ {operator: "in"},
+ {operator: "streams"},
],
},
@@ -436,42 +436,42 @@ function get_streams_filter_suggestions(last, operators) {
function get_is_filter_suggestions(last, operators) {
const suggestions = [
{
- search_string: 'is:private',
- description: 'private messages',
+ search_string: "is:private",
+ description: "private messages",
invalid: [
- {operator: 'is', operand: 'private'},
- {operator: 'stream'},
- {operator: 'pm-with'},
- {operator: 'in'},
+ {operator: "is", operand: "private"},
+ {operator: "stream"},
+ {operator: "pm-with"},
+ {operator: "in"},
],
},
{
- search_string: 'is:starred',
- description: 'starred messages',
+ search_string: "is:starred",
+ description: "starred messages",
invalid: [
- {operator: 'is', operand: 'starred'},
+ {operator: "is", operand: "starred"},
],
},
{
- search_string: 'is:mentioned',
- description: '@-mentions',
+ search_string: "is:mentioned",
+ description: "@-mentions",
invalid: [
- {operator: 'is', operand: 'mentioned'},
+ {operator: "is", operand: "mentioned"},
],
},
{
- search_string: 'is:alerted',
- description: 'alerted messages',
+ search_string: "is:alerted",
+ description: "alerted messages",
invalid: [
- {operator: 'is', operand: 'alerted'},
+ {operator: "is", operand: "alerted"},
],
},
{
- search_string: 'is:unread',
- description: 'unread messages',
+ search_string: "is:unread",
+ description: "unread messages",
invalid: [
- {operator: 'is', operand: 'unread'},
+ {operator: "is", operand: "unread"},
],
},
];
@@ -481,24 +481,24 @@ function get_is_filter_suggestions(last, operators) {
function get_has_filter_suggestions(last, operators) {
const suggestions = [
{
- search_string: 'has:link',
- description: 'messages with one or more link',
+ search_string: "has:link",
+ description: "messages with one or more link",
invalid: [
- {operator: 'has', operand: 'link'},
+ {operator: "has", operand: "link"},
],
},
{
- search_string: 'has:image',
- description: 'messages with one or more image',
+ search_string: "has:image",
+ description: "messages with one or more image",
invalid: [
- {operator: 'has', operand: 'image'},
+ {operator: "has", operand: "image"},
],
},
{
- search_string: 'has:attachment',
- description: 'messages with one or more attachment',
+ search_string: "has:attachment",
+ description: "messages with one or more attachment",
invalid: [
- {operator: 'has', operand: 'attachment'},
+ {operator: "has", operand: "attachment"},
],
},
];
@@ -508,27 +508,27 @@ function get_has_filter_suggestions(last, operators) {
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_symbol = negated ? '-' : '';
- const verb = negated ? 'exclude ' : '';
+ const negated = last.negated || last.operator === "search" && last.operand[0] === "-";
+ const negated_symbol = negated ? "-" : "";
+ const verb = negated ? "exclude " : "";
- const sender_query = negated_symbol + 'sender:' + people.my_current_email();
- const from_query = negated_symbol + 'from:' + people.my_current_email();
- const sender_me_query = negated_symbol + 'sender:me';
- const from_me_query = negated_symbol + 'from:me';
- const sent_string = negated_symbol + 'sent';
- const description = verb + 'sent by me';
+ const sender_query = negated_symbol + "sender:" + people.my_current_email();
+ const from_query = negated_symbol + "from:" + people.my_current_email();
+ const sender_me_query = negated_symbol + "sender:me";
+ const from_me_query = negated_symbol + "from:me";
+ const sent_string = negated_symbol + "sent";
+ const description = verb + "sent by me";
const invalid = [
- {operator: 'sender'},
- {operator: 'from'},
+ {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
@@ -553,7 +553,7 @@ function get_sent_by_me_suggestions(last, operators) {
}
function get_operator_suggestions(last) {
- if (!(last.operator === 'search')) {
+ if (!(last.operator === "search")) {
return [];
}
let last_operand = last.operand;
@@ -564,11 +564,11 @@ function get_operator_suggestions(last) {
last_operand = last_operand.slice(1);
}
- let choices = ['stream', 'topic', 'pm-with', 'sender', 'near', 'from', 'group-pm-with'];
+ let choices = ["stream", "topic", "pm-with", "sender", "near", "from", "group-pm-with"];
choices = choices.filter((choice) => common.phrase_match(last_operand, choice));
return choices.map((choice) => {
- const op = [{operator: choice, operand: '', negated: negated}];
+ const op = [{operator: choice, operand: "", negated: negated}];
return format_as_suggestion(op);
});
}
@@ -619,7 +619,7 @@ exports.get_search_result = function (base_query, query) {
all_operators = Filter.parse((base_query + " " + query).trim());
}
const search_operators = Filter.parse(query);
- let last = {operator: '', operand: '', negated: false};
+ let last = {operator: "", operand: "", negated: false};
if (search_operators.length > 0) {
last = search_operators.slice(-1)[0];
} else if (page_params.search_pills_enabled) {
@@ -632,7 +632,7 @@ exports.get_search_result = function (base_query, query) {
search_operators.push(last);
}
- const person_suggestion_ops = ['sender', 'pm-with', 'from', 'group-pm'];
+ const person_suggestion_ops = ["sender", "pm-with", "from", "group-pm"];
const search_operators_len = search_operators.length;
// Handle spaces in person name in new suggestions only. Checks if the last operator is 'search'
@@ -642,13 +642,13 @@ exports.get_search_result = function (base_query, query) {
// 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 &&
- last.operator === 'search' &&
+ last.operator === "search" &&
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 = {
operator: person_op.operator,
- operand: person_op.operand + ' ' + last.operand,
+ operand: person_op.operand + " " + last.operand,
negated: person_op.negated,
};
if (page_params.search_pills_enabled) {
@@ -667,7 +667,7 @@ exports.get_search_result = function (base_query, query) {
// `has` and `is` operators work only on predefined categories. Default suggestion
// is not displayed in that case. e.g. `messages with one or more abc` as
// a suggestion for `has:abc`does not make sense.
- if (last.operator !== '' && last.operator !== 'has' && last.operator !== 'is') {
+ if (last.operator !== "" && last.operator !== "has" && last.operator !== "is") {
suggestion = get_default_suggestion(search_operators);
attacher.push(suggestion);
}
@@ -686,10 +686,10 @@ exports.get_search_result = function (base_query, query) {
get_is_filter_suggestions,
get_sent_by_me_suggestions,
get_stream_suggestions,
- get_people('sender'),
- get_people('pm-with'),
- get_people('from'),
- get_people('group-pm-with'),
+ get_people("sender"),
+ get_people("pm-with"),
+ get_people("from"),
+ get_people("group-pm-with"),
get_group_suggestions,
get_topic_suggestions,
get_operator_suggestions,
diff --git a/static/js/sent_messages.js b/static/js/sent_messages.js
index 0b7177bf84d..ad39ffe2f22 100644
--- a/static/js/sent_messages.js
+++ b/static/js/sent_messages.js
@@ -7,7 +7,7 @@ exports.reset_id_state = function () {
exports.get_new_local_id = function () {
exports.next_local_id += 1;
const local_id = exports.next_local_id;
- return 'loc-' + local_id.toString();
+ return "loc-" + local_id.toString();
};
function report_send_time(send_time, receive_time,
@@ -23,7 +23,7 @@ function report_send_time(send_time, receive_time,
}
channel.post({
- url: '/json/report/send_times',
+ url: "/json/report/send_times",
data: data,
});
}
@@ -32,12 +32,12 @@ exports.start_tracking_message = function (opts) {
const local_id = opts.local_id;
if (!opts.local_id) {
- blueslip.error('You must supply a local_id');
+ blueslip.error("You must supply a local_id");
return;
}
if (exports.messages.has(local_id)) {
- blueslip.error('We are re-using a local_id');
+ blueslip.error("We are re-using a local_id");
return;
}
@@ -126,7 +126,7 @@ exports.get_message_state = function (local_id) {
const state = exports.messages.get(local_id);
if (!state) {
- blueslip.warn('Unknown local_id: ' + local_id);
+ blueslip.warn("Unknown local_id: " + local_id);
}
return state;
diff --git a/static/js/server_events.js b/static/js/server_events.js
index 74ff9b61aeb..071cf97e39c 100644
--- a/static/js/server_events.js
+++ b/static/js/server_events.js
@@ -22,7 +22,7 @@ function get_events_success(events) {
const clean_event = function clean_event(event) {
// Only log a whitelist of the event to remove private data
- return _.pick(event, 'id', 'type', 'op');
+ return _.pick(event, "id", "type", "op");
};
for (const event of events) {
@@ -30,7 +30,7 @@ function get_events_success(events) {
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',
+ blueslip.error("Failed to update last_event_id",
{event: clean_event(event)},
ex.stack);
}
@@ -52,7 +52,7 @@ function get_events_success(events) {
// rarely modified logic for non-normal events.
const dispatch_event = function dispatch_event(event) {
switch (event.type) {
- case 'message': {
+ case "message": {
const msg = event.message;
msg.flags = event.flags;
if (event.local_message_id) {
@@ -63,13 +63,13 @@ function get_events_success(events) {
break;
}
- case 'update_message':
+ case "update_message":
update_message_events.push(event);
break;
- case 'delete_message':
- case 'submessage':
- case 'update_message_flags':
+ case "delete_message":
+ case "submessage":
+ case "update_message_flags":
post_message_events.push(event);
break;
@@ -82,7 +82,7 @@ function get_events_success(events) {
try {
dispatch_event(event);
} catch (ex1) {
- blueslip.error('Failed to process an event\n' +
+ blueslip.error("Failed to process an event\n" +
blueslip.exception_msg(ex1),
{event: clean_event(event)},
ex1.stack);
@@ -93,7 +93,7 @@ function get_events_success(events) {
// Sort by ID, so that if we get multiple messages back from
// the server out-of-order, we'll still end up with our
// message lists in order.
- messages = _.sortBy(messages, 'id');
+ messages = _.sortBy(messages, "id");
try {
messages = echo.process_from_server(messages);
if (messages.length > 0) {
@@ -113,7 +113,7 @@ 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.error("Failed to insert new messages\n" +
blueslip.exception_msg(ex2),
undefined,
ex2.stack);
@@ -128,7 +128,7 @@ function get_events_success(events) {
try {
message_events.update_messages(update_message_events);
} catch (ex3) {
- blueslip.error('Failed to update messages\n' +
+ blueslip.error("Failed to update messages\n" +
blueslip.exception_msg(ex3),
undefined,
ex3.stack);
@@ -145,12 +145,12 @@ function get_events_success(events) {
function show_ui_connection_error() {
ui_report.show_error($("#connection-error"));
- $("#connection-error").addClass('get-events-error');
+ $("#connection-error").addClass("get-events-error");
}
function hide_ui_connection_error() {
ui_report.hide_error($("#connection-error"));
- $("#connection-error").removeClass('get-events-error');
+ $("#connection-error").removeClass("get-events-error");
}
function get_events(options) {
@@ -186,7 +186,7 @@ function get_events(options) {
get_events_timeout = undefined;
get_events_xhr = channel.get({
- url: '/json/events',
+ url: "/json/events",
data: get_events_params,
idempotent: true,
timeout: page_params.poll_timeout,
@@ -199,7 +199,7 @@ function get_events(options) {
get_events_success(data.events);
} catch (ex) {
- blueslip.error('Failed to handle get_events success\n' +
+ blueslip.error("Failed to handle get_events success\n" +
blueslip.exception_msg(ex),
undefined,
ex.stack);
@@ -212,7 +212,7 @@ function get_events(options) {
// 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') {
+ JSON.parse(xhr.responseText).code === "BAD_EVENT_QUEUE_ID") {
page_params.event_queue_expired = true;
reload.initiate({immediate: true,
save_pointer: false,
@@ -220,10 +220,10 @@ function get_events(options) {
save_compose: true});
}
- if (error_type === 'abort') {
+ if (error_type === "abort") {
// Don't restart if we explicitly aborted
return;
- } else if (error_type === 'timeout') {
+ } else if (error_type === "timeout") {
// Retry indefinitely on timeout.
get_events_failures = 0;
hide_ui_connection_error();
@@ -237,7 +237,7 @@ function get_events(options) {
hide_ui_connection_error();
}
} catch (ex) {
- blueslip.error('Failed to handle get_events error\n' +
+ blueslip.error("Failed to handle get_events error\n" +
blueslip.exception_msg(ex),
undefined,
ex.stack);
@@ -279,14 +279,14 @@ exports.check_for_unsuspend = function () {
watchdog_time = new_time;
// Our app's JS wasn't running, which probably means the machine was
// asleep.
- $(document).trigger($.Event('unsuspend'));
+ $(document).trigger($.Event("unsuspend"));
}
watchdog_time = new_time;
};
setInterval(exports.check_for_unsuspend, 5000);
exports.initialize = function () {
- $(document).on('unsuspend', () => {
+ $(document).on("unsuspend", () => {
// Immediately poll for new events on unsuspend
blueslip.log("Restarting get_events due to unsuspend");
get_events_failures = 0;
@@ -304,7 +304,7 @@ exports.cleanup_event_queue = function cleanup_event_queue() {
// Set expired because in a reload we may be called twice.
page_params.event_queue_expired = true;
channel.del({
- url: '/json/events',
+ url: "/json/events",
data: {queue_id: page_params.queue_id},
ignore_reload: true,
});
diff --git a/static/js/server_events_dispatch.js b/static/js/server_events_dispatch.js
index 779f4518e8c..77391a5e969 100644
--- a/static/js/server_events_dispatch.js
+++ b/static/js/server_events_dispatch.js
@@ -3,34 +3,34 @@ const settings_config = require("./settings_config");
exports.dispatch_normal_event = function dispatch_normal_event(event) {
const noop = function () {};
switch (event.type) {
- case 'alert_words':
+ case "alert_words":
alert_words.set_words(event.alert_words);
alert_words_ui.render_alert_words_ui();
break;
- case 'attachment':
+ case "attachment":
attachments_ui.update_attachments(event);
break;
- case 'custom_profile_fields':
+ case "custom_profile_fields":
page_params.custom_profile_fields = event.fields;
settings_profile_fields.populate_profile_fields(page_params.custom_profile_fields);
settings_account.add_custom_profile_fields_to_settings();
break;
- case 'default_streams':
+ case "default_streams":
stream_data.set_realm_default_streams(event.default_streams);
settings_streams.update_default_streams_table();
break;
- case 'delete_message': {
+ case "delete_message": {
const msg_ids = event.message_ids;
// message is passed to unread.get_unread_messages,
// which returns all the unread messages out of a given list.
// So double marking something as read would not occur
unread_ops.process_read_messages_event(msg_ids);
- if (event.message_type === 'stream') {
+ if (event.message_type === "stream") {
stream_topic_history.remove_messages({
stream_id: event.stream_id,
topic_name: event.topic,
@@ -43,7 +43,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
break;
}
- case 'has_zoom_token':
+ case "has_zoom_token":
page_params.has_zoom_token = event.value;
if (event.value) {
for (const callback of compose.zoom_token_callbacks.values()) {
@@ -53,28 +53,28 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
}
break;
- case 'hotspots':
+ case "hotspots":
hotspots.load_new(event.hotspots);
page_params.hotspots = page_params.hotspots ?
page_params.hotspots.concat(event.hotspots) :
event.hotspots;
break;
- case 'invites_changed':
- if ($('#admin-invites-list').length) {
+ case "invites_changed":
+ if ($("#admin-invites-list").length) {
settings_invites.set_up(false);
}
break;
- case 'muted_topics':
+ case "muted_topics":
muting_ui.handle_updates(event.muted_topics);
break;
- case 'presence':
+ case "presence":
activity.update_presence_info(event.user_id, event.presence, event.server_timestamp);
break;
- case 'restart': {
+ case "restart": {
const reload_options = {
save_pointer: true,
save_narrow: true,
@@ -88,15 +88,15 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
break;
}
- case 'reaction':
- if (event.op === 'add') {
+ case "reaction":
+ if (event.op === "add") {
reactions.add_reaction(event);
- } else if (event.op === 'remove') {
+ } else if (event.op === "remove") {
reactions.remove_reaction(event);
}
break;
- case 'realm': {
+ case "realm": {
const realm_settings = {
add_emoji_by_admins_only: settings_emoji.update_custom_emoji_ui,
allow_edit_history: noop,
@@ -136,27 +136,27 @@ 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)) {
- page_params['realm_' + event.property] = event.value;
+ 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') {
+ 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;
- } else if (event.property === 'invite_to_stream_policy') {
+ } 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;
}
- if (event.property === 'name' && window.electron_bridge !== undefined) {
- window.electron_bridge.send_event('realm_name', event.value);
+ if (event.property === "name" && window.electron_bridge !== undefined) {
+ window.electron_bridge.send_event("realm_name", event.value);
}
- } else if (event.op === 'update_dict' && event.property === 'default') {
+ } else if (event.op === "update_dict" && event.property === "default") {
for (const [key, value] of Object.entries(event.data)) {
- page_params['realm_' + key] = value;
- if (key === 'allow_message_editing') {
+ page_params["realm_" + key] = value;
+ if (key === "allow_message_editing") {
message_edit.update_message_topic_editing_pencil();
}
if (Object.prototype.hasOwnProperty.call(realm_settings, key)) {
@@ -166,24 +166,24 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
if (event.data.authentication_methods !== undefined) {
settings_org.populate_auth_methods(event.data.authentication_methods);
}
- } else if (event.op === 'update_dict' && event.property === 'icon') {
+ } else if (event.op === "update_dict" && event.property === "icon") {
page_params.realm_icon_url = event.data.icon_url;
page_params.realm_icon_source = event.data.icon_source;
realm_icon.rerender();
const electron_bridge = window.electron_bridge;
if (electron_bridge !== undefined) {
- electron_bridge.send_event('realm_icon_url', event.data.icon_url);
+ electron_bridge.send_event("realm_icon_url", event.data.icon_url);
}
- } else if (event.op === 'update_dict' && event.property === 'logo') {
+ } else if (event.op === "update_dict" && event.property === "logo") {
page_params.realm_logo_url = event.data.logo_url;
page_params.realm_logo_source = event.data.logo_source;
realm_logo.rerender();
- } else if (event.op === 'update_dict' && event.property === 'night_logo') {
+ } else if (event.op === "update_dict" && event.property === "night_logo") {
page_params.realm_night_logo_url = event.data.night_logo_url;
page_params.realm_night_logo_source = event.data.night_logo_source;
realm_logo.rerender();
- } else if (event.op === 'deactivated') {
+ } else if (event.op === "deactivated") {
window.location.href = "/accounts/deactivated/";
}
@@ -195,22 +195,22 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
break;
}
- case 'realm_bot':
- if (event.op === 'add') {
+ case "realm_bot":
+ if (event.op === "add") {
bot_data.add(event.bot);
- } else if (event.op === 'remove') {
+ } else if (event.op === "remove") {
bot_data.deactivate(event.bot.user_id);
event.bot.is_active = false;
- } else if (event.op === 'delete') {
+ } else if (event.op === "delete") {
blueslip.info("ignoring bot deletion for live UI update");
break;
- } else if (event.op === 'update') {
+ } else if (event.op === "update") {
bot_data.update(event.bot.user_id, event.bot);
}
settings_users.update_bot_data(event.bot.user_id);
break;
- case 'realm_emoji':
+ case "realm_emoji":
// Update `page_params.realm_emoji` so that settings page
// can display it properly when reopened without refresh.
page_params.realm_emoji = event.realm_emoji;
@@ -220,17 +220,17 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
composebox_typeahead.update_emoji_data();
break;
- case 'realm_filters':
+ case "realm_filters":
page_params.realm_filters = event.realm_filters;
markdown.update_realm_filter_rules(page_params.realm_filters);
settings_linkifiers.populate_filters(page_params.realm_filters);
break;
- case 'realm_domains': {
+ case "realm_domains": {
let i;
- if (event.op === 'add') {
+ if (event.op === "add") {
page_params.realm_domains.push(event.realm_domain);
- } else if (event.op === 'change') {
+ } else if (event.op === "change") {
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 =
@@ -238,7 +238,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
break;
}
}
- } else if (event.op === 'remove') {
+ } else if (event.op === "remove") {
for (i = 0; i < page_params.realm_domains.length; i += 1) {
if (page_params.realm_domains[i].domain === event.domain) {
page_params.realm_domains.splice(i, 1);
@@ -250,19 +250,19 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
break;
}
- case 'realm_user':
- if (event.op === 'add') {
+ case "realm_user":
+ if (event.op === "add") {
people.add_active_user(event.person);
- } else if (event.op === 'remove') {
+ } else if (event.op === "remove") {
people.deactivate(event.person);
stream_events.remove_deactivated_user_from_all_streams(event.person.user_id);
- } else if (event.op === 'update') {
+ } else if (event.op === "update") {
user_events.update_person(event.person);
}
break;
- case 'stream':
- if (event.op === 'update') {
+ 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,
@@ -273,7 +273,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
history_public_to_subscribers: event.history_public_to_subscribers,
});
settings_streams.update_default_streams_table();
- } else if (event.op === 'create') {
+ } else if (event.op === "create") {
stream_data.create_streams(event.streams);
for (const stream of event.streams) {
@@ -283,7 +283,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
subs.add_sub_to_table(sub);
}
}
- } else if (event.op === 'delete') {
+ } else if (event.op === "delete") {
for (const stream of event.streams) {
const was_subscribed = stream_data.get_sub_by_id(stream.stream_id).subscribed;
subs.remove_stream(stream.stream_id);
@@ -295,17 +295,17 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
stream_data.remove_default_stream(stream.stream_id);
if (page_params.realm_notifications_stream_id === stream.stream_id) {
page_params.realm_notifications_stream_id = -1;
- settings_org.sync_realm_settings('notifications_stream_id');
+ settings_org.sync_realm_settings("notifications_stream_id");
}
if (page_params.realm_signup_notifications_stream_id === stream.stream_id) {
page_params.realm_signup_notifications_stream_id = -1;
- settings_org.sync_realm_settings('signup_notifications_stream_id');
+ settings_org.sync_realm_settings("signup_notifications_stream_id");
}
}
}
break;
- case 'submessage': {
+ 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.
@@ -320,28 +320,28 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
break;
}
- case 'subscription':
- if (event.op === 'add') {
+ case "subscription":
+ if (event.op === "add") {
for (const rec of event.subscriptions) {
const sub = stream_data.get_sub_by_id(rec.stream_id);
if (sub) {
stream_data.update_stream_email_address(sub, rec.email_address);
stream_events.mark_subscribed(sub, rec.subscribers, rec.color);
} else {
- blueslip.error('Subscribing to unknown stream with ID ' + rec.stream_id);
+ blueslip.error("Subscribing to unknown stream with ID " + rec.stream_id);
}
}
- } else if (event.op === 'peer_add') {
+ } else if (event.op === "peer_add") {
function add_peer(stream_id, user_id) {
const sub = stream_data.get_sub_by_id(stream_id);
if (!sub) {
- blueslip.warn('Cannot find stream for peer_add: ' + stream_id);
+ blueslip.warn("Cannot find stream for peer_add: " + stream_id);
return;
}
if (!stream_data.add_subscriber(stream_id, user_id)) {
- blueslip.warn('Cannot process peer_add event');
+ blueslip.warn("Cannot process peer_add event");
return;
}
@@ -349,17 +349,17 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
compose_fade.update_faded_users();
}
add_peer(event.stream_id, event.user_id);
- } else if (event.op === 'peer_remove') {
+ } else if (event.op === "peer_remove") {
function remove_peer(stream_id, user_id) {
const sub = stream_data.get_sub_by_id(stream_id);
if (!sub) {
- blueslip.warn('Cannot find stream for peer_remove: ' + stream_id);
+ blueslip.warn("Cannot find stream for peer_remove: " + stream_id);
return;
}
if (!stream_data.remove_subscriber(sub.stream_id, user_id)) {
- blueslip.warn('Cannot process peer_remove event.');
+ blueslip.warn("Cannot process peer_remove event.");
return;
}
@@ -367,12 +367,12 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
compose_fade.update_faded_users();
}
remove_peer(event.stream_id, event.user_id);
- } else if (event.op === 'remove') {
+ } else if (event.op === "remove") {
for (const rec of event.subscriptions) {
const sub = stream_data.get_sub_by_id(rec.stream_id);
stream_events.mark_unsubscribed(sub);
}
- } else if (event.op === 'update') {
+ } else if (event.op === "update") {
stream_events.update_property(
event.stream_id,
event.property,
@@ -381,61 +381,61 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
}
break;
- case 'typing':
+ 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.
return;
}
- if (event.op === 'start') {
+ if (event.op === "start") {
typing_events.display_notification(event);
- } else if (event.op === 'stop') {
+ } else if (event.op === "stop") {
typing_events.hide_notification(event);
}
break;
- case 'update_display_settings': {
+ case "update_display_settings": {
const user_display_settings = [
- 'color_scheme',
- 'default_language',
- 'demote_inactive_streams',
- 'dense_mode',
- 'emojiset',
- 'fluid_layout_width',
- 'high_contrast_mode',
- 'left_side_userlist',
- 'timezone',
- 'twenty_four_hour_time',
- 'translate_emoticons',
- 'starred_message_counts',
+ "color_scheme",
+ "default_language",
+ "demote_inactive_streams",
+ "dense_mode",
+ "emojiset",
+ "fluid_layout_width",
+ "high_contrast_mode",
+ "left_side_userlist",
+ "timezone",
+ "twenty_four_hour_time",
+ "translate_emoticons",
+ "starred_message_counts",
];
if (user_display_settings.includes(event.setting_name)) {
page_params[event.setting_name] = event.setting;
}
- if (event.setting_name === 'default_language') {
+ if (event.setting_name === "default_language") {
// We additionally need to set the language name.
page_params.default_language_name = event.language_name;
}
- if (event.setting_name === 'twenty_four_hour_time') {
+ if (event.setting_name === "twenty_four_hour_time") {
// Rerender the whole message list UI
home_msg_list.rerender();
if (current_msg_list === message_list.narrowed) {
message_list.narrowed.rerender();
}
}
- if (event.setting_name === 'high_contrast_mode') {
+ if (event.setting_name === "high_contrast_mode") {
$("body").toggleClass("high-contrast");
}
- if (event.setting_name === 'demote_inactive_streams') {
+ if (event.setting_name === "demote_inactive_streams") {
stream_list.update_streams_sidebar();
stream_data.set_filter_out_inactives();
}
- if (event.setting_name === 'dense_mode') {
+ if (event.setting_name === "dense_mode") {
$("body").toggleClass("less_dense_mode");
$("body").toggleClass("more_dense_mode");
}
- if (event.setting_name === 'color_scheme') {
+ if (event.setting_name === "color_scheme") {
$("body").fadeOut(300);
setTimeout(() => {
if (event.setting === settings_config.color_scheme_values.night.code) {
@@ -451,24 +451,24 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
$("body").fadeIn(300);
}, 300);
}
- if (event.setting_name === 'starred_message_counts') {
+ if (event.setting_name === "starred_message_counts") {
starred_messages.rerender_ui();
}
- if (event.setting_name === 'fluid_layout_width') {
+ if (event.setting_name === "fluid_layout_width") {
scroll_bar.set_layout_width();
}
- if (event.setting_name === 'left_side_userlist') {
+ if (event.setting_name === "left_side_userlist") {
// TODO: Make this change the view immediately rather
// than requiring a reload or page resize.
}
- if (event.setting_name === 'default_language') {
+ 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.
}
- if (event.setting_name === 'emojiset') {
+ if (event.setting_name === "emojiset") {
settings_display.report_emojiset_change();
// Rerender the whole message list UI
@@ -481,7 +481,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
break;
}
- case 'update_global_notifications':
+ case "update_global_notifications":
notifications.handle_global_notification_updates(event.notification_name,
event.setting);
settings_notifications.update_page();
@@ -491,10 +491,10 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
// (E.g. update_stream_push_notifications).
break;
- case 'update_message_flags': {
+ case "update_message_flags": {
const new_value = event.operation === "add";
switch (event.flag) {
- case 'starred':
+ case "starred":
for (const message_id of event.messages) {
message_flags.update_starred_flag(message_id, new_value);
}
@@ -505,19 +505,19 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
starred_messages.remove(event.messages);
}
break;
- case 'read':
+ case "read":
unread_ops.process_read_messages_event(event.messages);
break;
}
break;
}
- case 'user_group':
- if (event.op === 'add') {
+ case "user_group":
+ if (event.op === "add") {
user_groups.add(event.group);
- } else if (event.op === 'add_members') {
+ } else if (event.op === "add_members") {
user_groups.add_members(event.group_id, event.user_ids);
- } else if (event.op === 'remove_members') {
+ } else if (event.op === "remove_members") {
user_groups.remove_members(event.group_id, event.user_ids);
} else if (event.op === "update") {
user_groups.update(event);
@@ -525,7 +525,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
settings_user_groups.reload();
break;
- case 'user_status':
+ case "user_status":
if (event.away !== undefined) {
if (event.away) {
activity.on_set_away(event.user_id);
@@ -542,7 +542,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
activity.redraw_user(event.user_id);
}
break;
- case 'realm_export':
+ case "realm_export":
settings_exports.populate_exports_table(event.exports);
break;
}
diff --git a/static/js/settings.js b/static/js/settings.js
index 2048e40f0f8..7eddf13669a 100644
--- a/static/js/settings.js
+++ b/static/js/settings.js
@@ -1,5 +1,5 @@
const settings_config = require("./settings_config");
-const render_settings_tab = require('../templates/settings_tab.hbs');
+const render_settings_tab = require("../templates/settings_tab.hbs");
$("body").ready(() => {
$("#settings_overlay_container").click((e) => {
@@ -51,8 +51,8 @@ exports.build_page = function () {
page_params: page_params,
enable_sound_select: page_params.enable_sounds ||
page_params.enable_stream_audible_notifications,
- zuliprc: 'zuliprc',
- botserverrc: 'botserverrc',
+ zuliprc: "zuliprc",
+ botserverrc: "botserverrc",
timezones: moment.tz.names(),
can_create_new_bots: settings_bots.can_create_new_bots(),
settings_label: exports.settings_label,
@@ -79,7 +79,7 @@ exports.launch = function (section) {
overlays.open_settings();
settings_panel_menu.normal_settings.activate_section_or_default(section);
- settings_toggle.highlight_toggle('settings');
+ settings_toggle.highlight_toggle("settings");
};
exports.set_settings_header = function (key) {
diff --git a/static/js/settings_account.js b/static/js/settings_account.js
index e96604c9f20..c377d0434d7 100644
--- a/static/js/settings_account.js
+++ b/static/js/settings_account.js
@@ -1,9 +1,9 @@
const render_settings_custom_user_profile_field = require("../templates/settings/custom_user_profile_field.hbs");
-const render_settings_dev_env_email_access = require('../templates/settings/dev_env_email_access.hbs');
-const render_settings_api_key_modal = require('../templates/settings/api_key_modal.hbs');
+const render_settings_dev_env_email_access = require("../templates/settings/dev_env_email_access.hbs");
+const render_settings_api_key_modal = require("../templates/settings/api_key_modal.hbs");
exports.update_email = function (new_email) {
- const email_input = $('#email_value');
+ const email_input = $("#email_value");
if (email_input) {
email_input.text(new_email);
@@ -47,50 +47,50 @@ exports.user_can_change_avatar = function () {
exports.update_name_change_display = function () {
if (!exports.user_can_change_name()) {
- $('#full_name').attr('disabled', 'disabled');
+ $("#full_name").attr("disabled", "disabled");
$(".change_name_tooltip").show();
} else {
- $('#full_name').attr('disabled', false);
+ $("#full_name").attr("disabled", false);
$(".change_name_tooltip").hide();
}
};
exports.update_email_change_display = function () {
if (page_params.realm_email_changes_disabled && !page_params.is_admin) {
- $('#change_email .button').attr('disabled', 'disabled');
+ $("#change_email .button").attr("disabled", "disabled");
$(".change_email_tooltip").show();
} else {
- $('#change_email .button').attr('disabled', false);
+ $("#change_email .button").attr("disabled", false);
$(".change_email_tooltip").hide();
}
};
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 .image_upload_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 .image_upload_button").attr("disabled", false);
+ $("#user-avatar-upload-widget .settings-page-delete-button .button").attr("disabled", false);
}
};
function display_avatar_upload_complete() {
- $('#user-avatar-upload-widget .upload-spinner-background').css({visibility: 'hidden'});
- $('#user-avatar-upload-widget .settings-page-upload-text').show();
- $('#user-avatar-upload-widget .settings-page-delete-button').show();
+ $("#user-avatar-upload-widget .upload-spinner-background").css({visibility: "hidden"});
+ $("#user-avatar-upload-widget .settings-page-upload-text").show();
+ $("#user-avatar-upload-widget .settings-page-delete-button").show();
}
function display_avatar_upload_started() {
$("#user-avatar-source").hide();
- $('#user-avatar-upload-widget .upload-spinner-background').css({visibility: 'visible'});
- $('#user-avatar-upload-widget .settings-page-upload-text').hide();
- $('#user-avatar-upload-widget .settings-page-delete-button').hide();
+ $("#user-avatar-upload-widget .upload-spinner-background").css({visibility: "visible"});
+ $("#user-avatar-upload-widget .settings-page-upload-text").hide();
+ $("#user-avatar-upload-widget .settings-page-delete-button").hide();
}
function settings_change_error(message, xhr) {
- ui_report.error(message, xhr, $('#account-settings-status').expectOne());
+ ui_report.error(message, xhr, $("#account-settings-status").expectOne());
}
function update_custom_profile_field(field, method) {
@@ -237,7 +237,7 @@ exports.initialize_custom_user_type_fields = function (element_id, user_id, is_e
}
if (is_editable) {
- const input = pill_container.children('.input');
+ const input = pill_container.children(".input");
if (set_handler_on_update) {
user_pill.set_up_typeahead_on_pills(input, pills, update_custom_user_field);
pills.onPillRemove(() => {
@@ -280,7 +280,7 @@ exports.set_up = function () {
const setup_api_key_modal = _.once(() => {
function request_api_key(data) {
channel.post({
- url: '/json/fetch_api_key',
+ url: "/json/fetch_api_key",
data: data,
success: function (data) {
$("#get_api_key_password").val("");
@@ -288,19 +288,19 @@ exports.set_up = function () {
// The display property on the error bar is set to important
// so instead of making display: none !important we just
// remove it.
- $('#api_key_status').remove();
+ $("#api_key_status").remove();
$("#password_confirmation").hide();
$("#show_api_key").show();
},
error: function (xhr) {
- ui_report.error(i18n.t("Error"), xhr, $('#api_key_status').expectOne());
+ ui_report.error(i18n.t("Error"), xhr, $("#api_key_status").expectOne());
$("#show_api_key").hide();
$("#api_key_modal").show();
},
});
}
- $('.account-settings-form').append(render_settings_api_key_modal());
+ $(".account-settings-form").append(render_settings_api_key_modal());
$("#api_key_value").text("");
$("#show_api_key").hide();
@@ -320,12 +320,12 @@ exports.set_up = function () {
$("#show_api_key").on("click", "button.regenerate_api_key", (e) => {
channel.post({
- url: '/json/users/me/api_key/regenerate',
+ url: "/json/users/me/api_key/regenerate",
success: function (data) {
- $('#api_key_value').text(data.api_key);
+ $("#api_key_value").text(data.api_key);
},
error: function (xhr) {
- $('#user_api_key_error').text(JSON.parse(xhr.responseText).msg).show();
+ $("#user_api_key_error").text(JSON.parse(xhr.responseText).msg).show();
},
});
e.preventDefault();
@@ -343,9 +343,9 @@ exports.set_up = function () {
});
});
- $('#api_key_button').click((e) => {
+ $("#api_key_button").click((e) => {
setup_api_key_modal();
- overlays.open_modal('#api_key_modal');
+ overlays.open_modal("#api_key_modal");
e.preventDefault();
e.stopPropagation();
});
@@ -353,69 +353,69 @@ exports.set_up = function () {
function clear_password_change() {
// Clear the password boxes so that passwords don't linger in the DOM
// for an XSS attacker to find.
- $('#old_password, #new_password').val('');
- common.password_quality('', $('#pw_strength .bar'), $('#new_password'));
+ $("#old_password, #new_password").val("");
+ common.password_quality("", $("#pw_strength .bar"), $("#new_password"));
}
clear_password_change();
- $("#change_full_name").on('click', (e) => {
+ $("#change_full_name").on("click", (e) => {
e.preventDefault();
e.stopPropagation();
if (exports.user_can_change_name()) {
- $('#change_full_name_modal').find("input[name='full_name']").val(page_params.full_name);
- overlays.open_modal('#change_full_name_modal');
+ $("#change_full_name_modal").find("input[name='full_name']").val(page_params.full_name);
+ overlays.open_modal("#change_full_name_modal");
}
});
- $('#change_password').on('click', (e) => {
+ $("#change_password").on("click", (e) => {
e.preventDefault();
e.stopPropagation();
- overlays.open_modal('#change_password_modal');
- $('#pw_change_controls').show();
+ overlays.open_modal("#change_password_modal");
+ $("#pw_change_controls").show();
if (page_params.realm_password_auth_enabled !== false) {
// zxcvbn.js is pretty big, and is only needed on password
// change, so load it asynchronously.
- require(['zxcvbn'], (zxcvbn) => {
+ require(["zxcvbn"], (zxcvbn) => {
window.zxcvbn = zxcvbn;
- $('#pw_strength .bar').removeClass("fade");
+ $("#pw_strength .bar").removeClass("fade");
});
}
});
- $('#change_password_modal').find('[data-dismiss=modal]').on('click', () => {
+ $("#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', () => {
+ $(".modal").find("[data-dismiss=modal]").on("click", () => {
// Enable mouse events for the background on closing modal
- $('.overlay.show').attr("style", null);
+ $(".overlay.show").attr("style", null);
});
- $('#change_password_button').on('click', (e) => {
+ $("#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(),
- new_password: $('#new_password').val(),
- confirm_password: $('#confirm_password').val(),
+ old_password: $("#old_password").val(),
+ new_password: $("#new_password").val(),
+ confirm_password: $("#confirm_password").val(),
};
- const new_pw_field = $('#new_password');
+ const new_pw_field = $("#new_password");
const new_pw = data.new_password;
- if (new_pw !== '') {
+ if (new_pw !== "") {
const password_ok = common.password_quality(new_pw, undefined, new_pw_field);
if (password_ok === undefined) {
// zxcvbn.js didn't load, for whatever reason.
settings_change_error(
- 'An internal error occurred; try reloading the page. ' +
- 'Sorry for the trouble!');
+ "An internal error occurred; try reloading the page. " +
+ "Sorry for the trouble!");
return;
} else if (!password_ok) {
- settings_change_error(i18n.t('New password is too weak'));
+ settings_change_error(i18n.t("New password is too weak"));
return;
}
}
@@ -426,23 +426,23 @@ 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();
});
- $('#new_password').on('input', () => {
- const field = $('#new_password');
- common.password_quality(field.val(), $('#pw_strength .bar'), field);
+ $("#new_password").on("input", () => {
+ const field = $("#new_password");
+ common.password_quality(field.val(), $("#pw_strength .bar"), field);
});
- $("#change_full_name_button").on('click', (e) => {
+ $("#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();
+ data.full_name = $(".full_name_change_container").find("input[name='full_name']").val();
const opts = {
success_continuation: function () {
@@ -450,16 +450,16 @@ 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) => {
+ $("#change_email_button").on("click", (e) => {
e.preventDefault();
e.stopPropagation();
- const change_email_error = $('#change_email_modal').find(".change_email_info").expectOne();
+ const change_email_error = $("#change_email_modal").find(".change_email_info").expectOne();
const data = {};
- data.email = $('.email_change_container').find("input[name='email']").val();
+ data.email = $(".email_change_container").find("input[name='email']").val();
const opts = {
success_continuation: function () {
@@ -467,27 +467,27 @@ exports.set_up = function () {
const email_msg = render_settings_dev_env_email_access();
ui_report.success(email_msg, $("#dev-account-settings-status").expectOne(), 4000);
}
- overlays.close_modal('#change_email_modal');
+ 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(
+ 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) => {
+ $("#change_email").on("click", (e) => {
e.preventDefault();
e.stopPropagation();
if (!page_params.realm_email_changes_disabled || page_params.is_admin) {
- overlays.open_modal('#change_email_modal');
- const email = $('#email_value').text().trim();
- $('.email_change_container').find("input[name='email']").val(email);
+ overlays.open_modal("#change_email_modal");
+ const email = $("#email_value").text().trim();
+ $(".email_change_container").find("input[name='email']").val(email);
}
});
- $("#user_deactivate_account_button").on('click', (e) => {
+ $("#user_deactivate_account_button").on("click", (e) => {
// This click event must not get propagated to parent container otherwise the modal
// will not show up because of a call to `close_active_modal` in `settings.js`.
e.preventDefault();
@@ -495,18 +495,18 @@ exports.set_up = function () {
$("#deactivate_self_modal").modal("show");
});
- $('#account-settings').on('click', '.custom_user_field .remove_date', (e) => {
+ $("#account-settings").on("click", ".custom_user_field .remove_date", (e) => {
e.preventDefault();
e.stopPropagation();
- const field = $(e.target).closest('.custom_user_field').expectOne();
+ const field = $(e.target).closest(".custom_user_field").expectOne();
const field_id = parseInt($(field).attr("data-field-id"), 10);
update_user_custom_profile_fields([field_id], channel.del);
});
- $('#account-settings').on('change', '.custom_user_field_value', function (e) {
+ $("#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);
@@ -516,8 +516,8 @@ exports.set_up = function () {
}
});
- $("#do_deactivate_self_button").on('click', () => {
- $("#do_deactivate_self_button .loader").css('display', 'inline-block');
+ $("#do_deactivate_self_button").on("click", () => {
+ $("#do_deactivate_self_button .loader").css("display", "inline-block");
$("#do_deactivate_self_button span").hide();
$("#do_deactivate_self_button object").on("load", function () {
const doc = this.getSVGDocument();
@@ -527,7 +527,7 @@ exports.set_up = function () {
setTimeout(() => {
channel.del({
- url: '/json/users/me',
+ url: "/json/users/me",
success: function () {
$("#deactivate_self_modal").modal("hide");
window.location.href = "/login/";
@@ -550,7 +550,7 @@ exports.set_up = function () {
}, 5000);
});
- $("#show_my_user_profile_modal").on('click', () => {
+ $("#show_my_user_profile_modal").on("click", () => {
overlays.close_overlay("settings");
const user = people.get_by_user_id(people.my_current_user_id());
setTimeout(() => {
@@ -560,7 +560,7 @@ exports.set_up = function () {
// If user opened the "preview profile" modal from user
// settings, then closing preview profile modal should
// send them back to the settings modal.
- $('body').one('hidden.bs.modal', '#user-profile-modal', (e) => {
+ $("body").one("hidden.bs.modal", "#user-profile-modal", (e) => {
e.preventDefault();
e.stopPropagation();
popovers.hide_user_profile();
@@ -577,13 +577,13 @@ exports.set_up = function () {
function upload_avatar(file_input) {
const form_data = new FormData();
- form_data.append('csrfmiddlewaretoken', csrf_token);
+ form_data.append("csrfmiddlewaretoken", csrf_token);
for (const [i, file] of Array.prototype.entries.call(file_input[0].files)) {
- form_data.append('file-' + i, file);
+ form_data.append("file-" + i, file);
}
display_avatar_upload_started();
channel.post({
- url: '/json/users/me/avatar',
+ url: "/json/users/me/avatar",
data: form_data,
cache: false,
processData: false,
@@ -596,7 +596,7 @@ exports.set_up = function () {
},
error: function (xhr) {
display_avatar_upload_complete();
- if (page_params.avatar_source === 'G') {
+ if (page_params.avatar_source === "G") {
$("#user-avatar-source").show();
}
const $error = $("#user-avatar-upload-widget .image_file_input_error");
diff --git a/static/js/settings_bots.js b/static/js/settings_bots.js
index 108e2577db3..1c7afc6ca9c 100644
--- a/static/js/settings_bots.js
+++ b/static/js/settings_bots.js
@@ -1,11 +1,11 @@
-const render_bot_avatar_row = require('../templates/bot_avatar_row.hbs');
-const render_edit_bot = require('../templates/edit_bot.hbs');
+const render_bot_avatar_row = require("../templates/bot_avatar_row.hbs");
+const render_edit_bot = require("../templates/edit_bot.hbs");
const render_settings_edit_embedded_bot_service = require("../templates/settings/edit_embedded_bot_service.hbs");
const render_settings_edit_outgoing_webhook_service = require("../templates/settings/edit_outgoing_webhook_service.hbs");
exports.hide_errors = function () {
- $('#bot_table_error').hide();
- $('.bot_error').hide();
+ $("#bot_table_error").hide();
+ $(".bot_error").hide();
};
const focus_tab = {
@@ -42,19 +42,19 @@ exports.get_bot_info_div = function (bot_id) {
exports.bot_error = function (bot_id, xhr) {
const bot_info = exports.get_bot_info_div(bot_id);
- const bot_error_div = bot_info.find('.bot_error');
+ const bot_error_div = bot_info.find(".bot_error");
bot_error_div.text(JSON.parse(xhr.responseText).msg);
bot_error_div.show();
- const bot_box = bot_info.closest('.bot-information-box');
+ const bot_box = bot_info.closest(".bot-information-box");
bot_box.scrollTop(bot_box[0].scrollHeight - bot_box[0].clientHeight);
};
function add_bot_row(info) {
const row = $(render_bot_avatar_row(info));
if (info.is_active) {
- $('#active_bots_list').append(row);
+ $("#active_bots_list").append(row);
} else {
- $('#inactive_bots_list').append(row);
+ $("#inactive_bots_list").append(row);
}
}
@@ -68,8 +68,8 @@ exports.type_id_to_string = function (type_id) {
};
exports.render_bots = function () {
- $('#active_bots_list').empty();
- $('#inactive_bots_list').empty();
+ $("#active_bots_list").empty();
+ $("#inactive_bots_list").empty();
const all_bots_for_current_user = bot_data.get_all_bots_for_current_user();
let user_owns_an_active_bot = false;
@@ -83,7 +83,7 @@ exports.render_bots = function () {
avatar_url: elem.avatar_url,
api_key: elem.api_key,
is_active: elem.is_active,
- zuliprc: 'zuliprc', // Most browsers do not allow filename starting with `.`
+ zuliprc: "zuliprc", // Most browsers do not allow filename starting with `.`
});
user_owns_an_active_bot = user_owns_an_active_bot || elem.is_active;
}
@@ -192,26 +192,26 @@ exports.update_bot_permissions_ui = function () {
exports.hide_errors();
$("#id_realm_bot_creation_policy").val(page_params.realm_bot_creation_policy);
if (!exports.can_create_new_bots()) {
- $('#create_bot_form').hide();
- $('.add-a-new-bot-tab').hide();
+ $("#create_bot_form").hide();
+ $(".add-a-new-bot-tab").hide();
focus_tab.active_bots_tab();
} else {
- $('#create_bot_form').show();
- $('.add-a-new-bot-tab').show();
+ $("#create_bot_form").show();
+ $(".add-a-new-bot-tab").show();
}
};
exports.set_up = function () {
- $('#payload_url_inputbox').hide();
- $('#create_payload_url').val('');
- $('#service_name_list').hide();
- $('#config_inputbox').hide();
- const selected_embedded_bot = 'converter';
- $('#select_service_name').val(selected_embedded_bot); // TODO: Use 'select a bot'.
- $('#config_inputbox').children().hide();
+ $("#payload_url_inputbox").hide();
+ $("#create_payload_url").val("");
+ $("#service_name_list").hide();
+ $("#config_inputbox").hide();
+ const selected_embedded_bot = "converter";
+ $("#select_service_name").val(selected_embedded_bot); // TODO: Use 'select a bot'.
+ $("#config_inputbox").children().hide();
$("[name*='" + selected_embedded_bot + "']").show();
- $('#download_botserverrc').click(function () {
+ $("#download_botserverrc").click(function () {
const OUTGOING_WEBHOOK_BOT_TYPE_INT = 3;
let content = "";
@@ -235,75 +235,75 @@ exports.set_up = function () {
const create_avatar_widget = avatar.build_bot_create_widget();
- const OUTGOING_WEBHOOK_BOT_TYPE = '3';
- const GENERIC_BOT_TYPE = '1';
- const EMBEDDED_BOT_TYPE = '4';
+ const OUTGOING_WEBHOOK_BOT_TYPE = "3";
+ const GENERIC_BOT_TYPE = "1";
+ const EMBEDDED_BOT_TYPE = "4";
- const GENERIC_INTERFACE = '1';
+ const GENERIC_INTERFACE = "1";
- $('#create_bot_form').validate({
- errorClass: 'text-error',
+ $("#create_bot_form").validate({
+ errorClass: "text-error",
success: function () {
exports.hide_errors();
},
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 payload_url = $('#create_payload_url').val();
- const interface_type = $('#create_interface_type').val();
- const service_name = $('#select_service_name :selected').val();
+ 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 payload_url = $("#create_payload_url").val();
+ const interface_type = $("#create_interface_type").val();
+ const service_name = $("#select_service_name :selected").val();
const formData = new FormData();
- const spinner = $('.create_bot_spinner');
+ const spinner = $(".create_bot_spinner");
- formData.append('csrfmiddlewaretoken', csrf_token);
- formData.append('bot_type', bot_type);
- formData.append('full_name', full_name);
- formData.append('short_name', short_name);
+ formData.append("csrfmiddlewaretoken", csrf_token);
+ formData.append("bot_type", bot_type);
+ formData.append("full_name", full_name);
+ formData.append("short_name", short_name);
// If the selected bot_type is Outgoing webhook
if (bot_type === OUTGOING_WEBHOOK_BOT_TYPE) {
- formData.append('payload_url', JSON.stringify(payload_url));
- formData.append('interface_type', interface_type);
+ formData.append("payload_url", JSON.stringify(payload_url));
+ formData.append("interface_type", interface_type);
} else if (bot_type === EMBEDDED_BOT_TYPE) {
- formData.append('service_name', service_name);
+ formData.append("service_name", service_name);
const config_data = {};
$("#config_inputbox [name*='" + service_name + "'] input").each(function () {
- config_data[$(this).attr('name')] = $(this).val();
+ config_data[$(this).attr("name")] = $(this).val();
});
- formData.append('config_data', JSON.stringify(config_data));
+ formData.append("config_data", JSON.stringify(config_data));
}
- for (const [i, file] of Array.prototype.entries.call($('#bot_avatar_file_input')[0].files)) {
- formData.append('file-' + i, file);
+ 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')});
+ loading.make_indicator(spinner, {text: i18n.t("Creating bot")});
channel.post({
- url: '/json/bots',
+ url: "/json/bots",
data: formData,
cache: false,
processData: false,
contentType: false,
success: function () {
exports.hide_errors();
- $('#create_bot_name').val('');
- $('#create_bot_short_name').val('');
- $('#create_payload_url').val('');
- $('#payload_url_inputbox').hide();
- $('#config_inputbox').hide();
+ $("#create_bot_name").val("");
+ $("#create_bot_short_name").val("");
+ $("#create_payload_url").val("");
+ $("#payload_url_inputbox").hide();
+ $("#config_inputbox").hide();
$("[name*='" + service_name + "'] input").each(function () {
- $(this).val('');
+ $(this).val("");
});
- $('#create_bot_type').val(GENERIC_BOT_TYPE);
- $('#select_service_name').val('converter'); // TODO: Later we can change this to hello bot or similar
- $('#service_name_list').hide();
- $('#create_bot_button').show();
- $('#create_interface_type').val(GENERIC_INTERFACE);
+ $("#create_bot_type").val(GENERIC_BOT_TYPE);
+ $("#select_service_name").val("converter"); // TODO: Later we can change this to hello bot or similar
+ $("#service_name_list").hide();
+ $("#create_bot_button").show();
+ $("#create_interface_type").val(GENERIC_INTERFACE);
create_avatar_widget.clear();
$("#bots_lists_navbar .add-a-new-bot-tab").removeClass("active");
$("#bots_lists_navbar .active-bots-tab").addClass("active");
},
error: function (xhr) {
- $('#bot_table_error').text(JSON.parse(xhr.responseText).msg).show();
+ $("#bot_table_error").text(JSON.parse(xhr.responseText).msg).show();
},
complete: function () {
loading.destroy_indicator(spinner);
@@ -313,40 +313,40 @@ exports.set_up = function () {
});
$("#create_bot_type").on("change", () => {
- const bot_type = $('#create_bot_type :selected').val();
+ const bot_type = $("#create_bot_type :selected").val();
// For "generic bot" or "incoming webhook" both these fields need not be displayed.
- $('#service_name_list').hide();
- $('#select_service_name').removeClass('required');
- $('#config_inputbox').hide();
+ $("#service_name_list").hide();
+ $("#select_service_name").removeClass("required");
+ $("#config_inputbox").hide();
- $('#payload_url_inputbox').hide();
- $('#create_payload_url').removeClass('required');
+ $("#payload_url_inputbox").hide();
+ $("#create_payload_url").removeClass("required");
if (bot_type === OUTGOING_WEBHOOK_BOT_TYPE) {
- $('#payload_url_inputbox').show();
- $('#create_payload_url').addClass('required');
+ $("#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');
- $("#select_service_name").trigger('change');
- $('#config_inputbox').show();
+ $("#service_name_list").show();
+ $("#select_service_name").addClass("required");
+ $("#select_service_name").trigger("change");
+ $("#config_inputbox").show();
}
});
$("#select_service_name").on("change", () => {
- $('#config_inputbox').children().hide();
- const selected_bot = $('#select_service_name :selected').val();
+ $("#config_inputbox").children().hide();
+ const selected_bot = $("#select_service_name :selected").val();
$("[name*='" + selected_bot + "']").show();
});
$("#active_bots_list").on("click", "button.delete_bot", (e) => {
- const bot_id = parseInt($(e.currentTarget).attr('data-user-id'), 10);
+ const bot_id = parseInt($(e.currentTarget).attr("data-user-id"), 10);
channel.del({
- url: '/json/bots/' + encodeURIComponent(bot_id),
+ 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);
@@ -355,10 +355,10 @@ exports.set_up = function () {
});
$("#inactive_bots_list").on("click", "button.reactivate_bot", (e) => {
- const user_id = parseInt($(e.currentTarget).attr('data-user-id'), 10);
+ const user_id = parseInt($(e.currentTarget).attr("data-user-id"), 10);
channel.post({
- url: '/json/users/' + encodeURIComponent(user_id) + "/reactivate",
+ url: "/json/users/" + encodeURIComponent(user_id) + "/reactivate",
error: function (xhr) {
exports.bot_error(user_id, xhr);
},
@@ -366,9 +366,9 @@ exports.set_up = function () {
});
$("#active_bots_list").on("click", "button.regenerate_bot_api_key", (e) => {
- const bot_id = parseInt($(e.currentTarget).attr('data-user-id'), 10);
+ const bot_id = parseInt($(e.currentTarget).attr("data-user-id"), 10);
channel.post({
- url: '/json/bots/' + encodeURIComponent(bot_id) + '/api_key/regenerate',
+ url: "/json/bots/" + encodeURIComponent(bot_id) + "/api_key/regenerate",
idempotent: true,
success: function (data) {
const row = $(e.currentTarget).closest("li");
@@ -387,9 +387,9 @@ exports.set_up = function () {
$("#active_bots_list").on("click", "button.open_edit_bot_form", (e) => {
e.preventDefault();
e.stopPropagation();
- overlays.open_modal('#edit_bot_modal');
- const li = $(e.currentTarget).closest('li');
- const bot_id = parseInt(li.find('.bot_info').attr('data-user-id'), 10);
+ overlays.open_modal("#edit_bot_modal");
+ const li = $(e.currentTarget).closest("li");
+ const bot_id = parseInt(li.find(".bot_info").attr("data-user-id"), 10);
const bot = bot_data.get(bot_id);
const user_ids = people.get_active_human_ids();
const users_list = user_ids.map((user_id) => ({
@@ -403,12 +403,12 @@ exports.set_up = function () {
users_list: users_list,
}));
const avatar_widget = avatar.build_bot_edit_widget($("#settings_page"));
- const form = $('#settings_page .edit_bot_form');
+ const form = $("#settings_page .edit_bot_form");
const image = li.find(".image");
- const errors = form.find('.bot_edit_errors');
+ const errors = form.find(".bot_edit_errors");
const opts = {
- widget_name: 'bot_owner',
+ widget_name: "bot_owner",
data: users_list,
default_text: i18n.t("No owner"),
value: bot.owner_id,
@@ -431,44 +431,44 @@ exports.set_up = function () {
avatar_widget.clear();
form.validate({
- errorClass: 'text-error',
+ errorClass: "text-error",
success: function () {
errors.hide();
},
submitHandler: function () {
- const bot_id = parseInt(form.attr('data-user-id'), 10);
- const type = form.attr('data-type');
+ const bot_id = parseInt(form.attr("data-user-id"), 10);
+ const type = form.attr("data-type");
- const full_name = form.find('.edit_bot_name').val();
+ const full_name = form.find(".edit_bot_name").val();
const bot_owner_id = owner_widget.value();
- const file_input = $(".edit_bot_form").find('.edit_bot_avatar_file_input');
- const spinner = form.find('.edit_bot_spinner');
- const edit_button = form.find('.edit_bot_button');
+ const file_input = $(".edit_bot_form").find(".edit_bot_avatar_file_input");
+ const spinner = form.find(".edit_bot_spinner");
+ const edit_button = form.find(".edit_bot_button");
const formData = new FormData();
- formData.append('csrfmiddlewaretoken', csrf_token);
- formData.append('full_name', full_name);
- formData.append('bot_owner_id', bot_owner_id);
+ formData.append("csrfmiddlewaretoken", csrf_token);
+ formData.append("full_name", full_name);
+ formData.append("bot_owner_id", bot_owner_id);
if (type === OUTGOING_WEBHOOK_BOT_TYPE) {
const service_payload_url = $("#edit_service_base_url").val();
const service_interface = $("#edit_service_interface :selected").val();
- formData.append('service_payload_url', JSON.stringify(service_payload_url));
- formData.append('service_interface', service_interface);
+ formData.append("service_payload_url", JSON.stringify(service_payload_url));
+ formData.append("service_interface", service_interface);
} else if (type === EMBEDDED_BOT_TYPE) {
const config_data = {};
$("#config_edit_inputbox input").each(function () {
- config_data[$(this).attr('name')] = $(this).val();
+ config_data[$(this).attr("name")] = $(this).val();
});
- formData.append('config_data', JSON.stringify(config_data));
+ formData.append("config_data", JSON.stringify(config_data));
}
for (const [i, file] of Array.prototype.entries.call(file_input[0].files)) {
- formData.append('file-' + i, file);
+ formData.append("file-" + i, file);
}
- loading.make_indicator(spinner, {text: 'Editing bot'});
+ loading.make_indicator(spinner, {text: "Editing bot"});
edit_button.hide();
channel.patch({
- url: '/json/bots/' + encodeURIComponent(bot_id),
+ url: "/json/bots/" + encodeURIComponent(bot_id),
data: formData,
cache: false,
processData: false,
@@ -484,15 +484,15 @@ 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');
+ overlays.close_modal("#edit_bot_modal");
},
error: function (xhr) {
loading.destroy_indicator(spinner);
edit_button.show();
errors.text(JSON.parse(xhr.responseText).msg).show();
- overlays.close_modal('#edit_bot_modal');
+ overlays.close_modal("#edit_bot_modal");
},
});
},
@@ -505,7 +505,7 @@ exports.set_up = function () {
$(this).attr("href", exports.generate_zuliprc_uri(bot_id));
});
- new ClipboardJS('#copy_zuliprc', {
+ new ClipboardJS("#copy_zuliprc", {
text: function (trigger) {
const bot_info = $(trigger).closest(".bot-information-box").find(".bot_info");
const bot_id = parseInt(bot_info.attr("data-user-id"), 10);
diff --git a/static/js/settings_display.js b/static/js/settings_display.js
index 84ecad6ccc0..85d5203008b 100644
--- a/static/js/settings_display.js
+++ b/static/js/settings_display.js
@@ -7,18 +7,18 @@ const meta = {
function change_display_setting(data, status_element, success_msg, sticky) {
const $status_el = $(status_element);
- const status_is_sticky = $status_el.data('is_sticky');
- const display_message = status_is_sticky ? $status_el.data('sticky_msg') : success_msg;
+ const status_is_sticky = $status_el.data("is_sticky");
+ const display_message = status_is_sticky ? $status_el.data("sticky_msg") : success_msg;
const opts = {
success_msg: display_message,
sticky: status_is_sticky || sticky,
};
if (sticky) {
- $status_el.data('is_sticky', true);
- $status_el.data('sticky_msg', success_msg);
+ $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 () {
@@ -36,14 +36,14 @@ exports.set_up = function () {
$(".emojiset_choice[value=" + page_params.emojiset + "]").prop("checked", true);
$("#default_language_modal [data-dismiss]").click(() => {
- overlays.close_modal('#default_language_modal');
+ overlays.close_modal("#default_language_modal");
});
const all_display_settings = settings_config.get_all_display_settings();
for (const setting of all_display_settings.settings.user_display_settings) {
$("#" + setting).change(function () {
const data = {};
- data[setting] = JSON.stringify($(this).prop('checked'));
+ data[setting] = JSON.stringify($(this).prop("checked"));
if (["left_side_userlist"].includes(setting)) {
change_display_setting(
@@ -59,49 +59,49 @@ exports.set_up = function () {
$("#default_language_modal .language").click((e) => {
e.preventDefault();
e.stopPropagation();
- overlays.close_modal('#default_language_modal');
+ overlays.close_modal("#default_language_modal");
const $link = $(e.target).closest("a[data-code]");
- const setting_value = $link.attr('data-code');
+ const setting_value = $link.attr("data-code");
const data = {default_language: JSON.stringify(setting_value)};
- const new_language = $link.attr('data-name');
- $('#default_language_name').text(new_language);
+ const new_language = $link.attr("data-name");
+ $("#default_language_name").text(new_language);
- change_display_setting(data, '#language-settings-status',
+ 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) => {
+ $("#default_language").on("click", (e) => {
e.preventDefault();
e.stopPropagation();
- overlays.open_modal('#default_language_modal');
+ overlays.open_modal("#default_language_modal");
});
- $('#demote_inactive_streams').change(function () {
+ $("#demote_inactive_streams").change(function () {
const data = {demote_inactive_streams: this.value};
- change_display_setting(data, '#display-settings-status');
+ change_display_setting(data, "#display-settings-status");
});
- $('#color_scheme').change(function () {
+ $("#color_scheme").change(function () {
const data = {color_scheme: this.value};
- change_display_setting(data, '#display-settings-status');
+ change_display_setting(data, "#display-settings-status");
});
- $('body').on('click', '.reload_link', () => {
+ $("body").on("click", ".reload_link", () => {
window.location.reload();
});
$("#twenty_four_hour_time").change(function () {
const data = {twenty_four_hour_time: this.value};
- change_display_setting(data, '#time-settings-status');
+ change_display_setting(data, "#time-settings-status");
});
$("#user_timezone").change(function () {
const data = {timezone: JSON.stringify(this.value)};
- change_display_setting(data, '#time-settings-status');
+ change_display_setting(data, "#time-settings-status");
});
$(".emojiset_choice").click(function () {
const data = {emojiset: JSON.stringify($(this).val())};
@@ -113,19 +113,19 @@ exports.set_up = function () {
loading.make_indicator(spinner, {text: settings_ui.strings.saving });
channel.patch({
- url: '/json/settings/display',
+ url: "/json/settings/display",
data: data,
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());
},
});
});
$("#translate_emoticons").change(function () {
const data = {translate_emoticons: JSON.stringify(this.checked)};
- change_display_setting(data, '#emoji-settings-status');
+ change_display_setting(data, "#emoji-settings-status");
});
};
@@ -143,16 +143,16 @@ exports.report_emojiset_change = async function () {
loading.destroy_indicator($("#emojiset_spinner"));
$("#emojiset_select").val(page_params.emojiset);
ui_report.success(i18n.t("Emojiset changed successfully!"),
- $('#emoji-settings-status').expectOne());
+ $("#emoji-settings-status").expectOne());
const spinner = $("#emoji-settings-status").expectOne();
settings_ui.display_checkmark(spinner);
}
};
exports.update_page = function () {
- $("#left_side_userlist").prop('checked', page_params.left_side_userlist);
+ $("#left_side_userlist").prop("checked", page_params.left_side_userlist);
$("#default_language_name").text(page_params.default_language_name);
- $("#translate_emoticons").prop('checked', page_params.translate_emoticons);
+ $("#translate_emoticons").prop("checked", page_params.translate_emoticons);
$("#twenty_four_hour_time").val(JSON.stringify(page_params.twenty_four_hour_time));
$("#color_scheme").val(JSON.stringify(page_params.color_scheme));
diff --git a/static/js/settings_emoji.js b/static/js/settings_emoji.js
index 1bfd9300003..ad64d05644a 100644
--- a/static/js/settings_emoji.js
+++ b/static/js/settings_emoji.js
@@ -1,4 +1,4 @@
-const render_admin_emoji_list = require('../templates/admin_emoji_list.hbs');
+const render_admin_emoji_list = require("../templates/admin_emoji_list.hbs");
const render_settings_emoji_settings_tip = require("../templates/settings/emoji_settings_tip.hbs");
const meta = {
@@ -36,13 +36,13 @@ exports.update_custom_emoji_ui = function () {
const rendered_tip = render_settings_emoji_settings_tip({
realm_add_emoji_by_admins_only: page_params.realm_add_emoji_by_admins_only,
});
- $('#emoji-settings').find('.emoji-settings-tip-container').html(rendered_tip);
+ $("#emoji-settings").find(".emoji-settings-tip-container").html(rendered_tip);
if (page_params.realm_add_emoji_by_admins_only && !page_params.is_admin) {
- $('.add-emoji-text').hide();
- $('.admin-emoji-form').hide();
+ $(".add-emoji-text").hide();
+ $(".admin-emoji-form").hide();
} else {
- $('.add-emoji-text').show();
- $('.admin-emoji-form').show();
+ $(".add-emoji-text").show();
+ $(".admin-emoji-form").show();
}
exports.populate_emoji(page_params.realm_emoji);
@@ -75,7 +75,7 @@ exports.populate_emoji = function (emoji_data) {
}
}
- const emoji_table = $('#admin_emoji_table').expectOne();
+ const emoji_table = $("#admin_emoji_table").expectOne();
list_render.create(emoji_table, Object.values(emoji_data), {
name: "emoji_list",
modifier: function (item) {
@@ -83,9 +83,9 @@ exports.populate_emoji = function (emoji_data) {
return render_admin_emoji_list({
emoji: {
name: item.name,
- display_name: item.name.replace(/_/g, ' '),
+ display_name: item.name.replace(/_/g, " "),
source_url: item.source_url,
- author: item.author || '',
+ author: item.author || "",
can_admin_emoji: can_admin_emoji(item),
},
});
@@ -105,24 +105,24 @@ exports.populate_emoji = function (emoji_data) {
sort_fields: {
author_full_name: sort_author_full_name,
},
- init_sort: ['alphabetic', 'name'],
- simplebar_container: $('#emoji-settings .progressive-table-wrapper'),
+ init_sort: ["alphabetic", "name"],
+ simplebar_container: $("#emoji-settings .progressive-table-wrapper"),
});
- loading.destroy_indicator($('#admin_page_emoji_loading_indicator'));
+ loading.destroy_indicator($("#admin_page_emoji_loading_indicator"));
};
exports.build_emoji_upload_widget = function () {
const get_file_input = function () {
- return $('#emoji_file_input');
+ return $("#emoji_file_input");
};
- const file_name_field = $('#emoji-file-name');
- const input_error = $('#emoji_file_input_error');
- const clear_button = $('#emoji_image_clear_button');
- const upload_button = $('#emoji_upload_button');
- const preview_text = $('#emoji_preview_text');
- const preview_image = $('#emoji_preview_image');
+ const file_name_field = $("#emoji-file-name");
+ const input_error = $("#emoji_file_input_error");
+ const clear_button = $("#emoji_image_clear_button");
+ const upload_button = $("#emoji_upload_button");
+ const preview_text = $("#emoji_preview_text");
+ const preview_image = $("#emoji_preview_image");
return upload_widget.build_widget(
get_file_input,
@@ -138,23 +138,23 @@ exports.build_emoji_upload_widget = function () {
exports.set_up = function () {
meta.loaded = true;
- loading.make_indicator($('#admin_page_emoji_loading_indicator'));
+ loading.make_indicator($("#admin_page_emoji_loading_indicator"));
// Populate emoji table
exports.populate_emoji(page_params.realm_emoji);
- $('.admin_emoji_table').on('click', '.delete', function (e) {
+ $(".admin_emoji_table").on("click", ".delete", function (e) {
e.preventDefault();
e.stopPropagation();
const btn = $(this);
channel.del({
- url: '/json/realm/emoji/' + encodeURIComponent(btn.attr('data-emoji-name')),
+ url: "/json/realm/emoji/" + encodeURIComponent(btn.attr("data-emoji-name")),
error: function (xhr) {
ui_report.generic_row_button_error(xhr, btn);
},
success: function () {
- const row = btn.parents('tr');
+ const row = btn.parents("tr");
row.remove();
},
});
@@ -162,11 +162,11 @@ exports.set_up = function () {
const emoji_widget = exports.build_emoji_upload_widget();
- $(".organization form.admin-emoji-form").off('submit').on('submit', function (e) {
+ $(".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_status = $("#admin-emoji-status");
+ $("#admin_emoji_submit").attr("disabled", true);
const emoji = {};
const formData = new FormData();
@@ -174,8 +174,8 @@ exports.set_up = function () {
emoji[obj.name] = obj.value;
}
- for (const [i, file] of Array.prototype.entries.call($('#emoji_file_input')[0].files)) {
- formData.append('file-' + i, file);
+ 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),
@@ -184,18 +184,18 @@ exports.set_up = function () {
processData: false,
contentType: false,
success: function () {
- $('#admin-emoji-status').hide();
+ $("#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');
+ $("#admin_emoji_submit").removeAttr("disabled");
emoji_widget.clear();
},
error: function (xhr) {
- $('#admin-emoji-status').hide();
+ $("#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');
+ $("#admin_emoji_submit").removeAttr("disabled");
},
});
});
diff --git a/static/js/settings_exports.js b/static/js/settings_exports.js
index 7f90a2f798b..30fcf5c9aa3 100644
--- a/static/js/settings_exports.js
+++ b/static/js/settings_exports.js
@@ -1,4 +1,4 @@
-const render_admin_export_list = require('../templates/admin_export_list.hbs');
+const render_admin_export_list = require("../templates/admin_export_list.hbs");
const meta = {
loaded: false,
@@ -24,7 +24,7 @@ exports.populate_exports_table = function (exports) {
return;
}
- const exports_table = $('#admin_exports_table').expectOne();
+ const exports_table = $("#admin_exports_table").expectOne();
list_render.create(exports_table, Object.values(exports), {
name: "admin_exports_list",
modifier: function (data) {
@@ -72,10 +72,10 @@ exports.populate_exports_table = function (exports) {
sort_fields: {
user: sort_user,
},
- simplebar_container: $('#data-exports .progressive-table-wrapper'),
+ simplebar_container: $("#data-exports .progressive-table-wrapper"),
});
- const spinner = $('.export_row .export_url_spinner');
+ const spinner = $(".export_row .export_url_spinner");
if (spinner.length) {
loading.make_indicator(spinner);
} else {
@@ -86,13 +86,13 @@ exports.populate_exports_table = function (exports) {
exports.set_up = function () {
meta.loaded = true;
- $("#export-data").on('click', (e) => {
+ $("#export-data").on("click", (e) => {
e.preventDefault();
e.stopPropagation();
- const export_status = $('#export_status');
+ const export_status = $("#export_status");
channel.post({
- url: '/json/export/realm',
+ url: "/json/export/realm",
success: function () {
ui_report.success(i18n.t("Export started. Check back in a few minutes."), export_status, 4000);
},
@@ -104,19 +104,19 @@ exports.set_up = function () {
// Do an initial population of the table
channel.get({
- url: '/json/export/realm',
+ url: "/json/export/realm",
success: function (data) {
exports.populate_exports_table(data.exports);
},
});
- $('.admin_exports_table').on('click', '.delete', function (e) {
+ $(".admin_exports_table").on("click", ".delete", function (e) {
e.preventDefault();
e.stopPropagation();
const btn = $(this);
channel.del({
- url: '/json/export/realm/' + encodeURIComponent(btn.attr('data-export-id')),
+ url: "/json/export/realm/" + encodeURIComponent(btn.attr("data-export-id")),
error: function (xhr) {
ui_report.generic_row_button_error(xhr, btn);
},
diff --git a/static/js/settings_invites.js b/static/js/settings_invites.js
index 7690b4853ab..e45ed62cd16 100644
--- a/static/js/settings_invites.js
+++ b/static/js/settings_invites.js
@@ -12,7 +12,7 @@ exports.reset = function () {
};
function failed_listing_invites(xhr) {
- loading.destroy_indicator($('#admin_page_invites_loading_indicator'));
+ loading.destroy_indicator($("#admin_page_invites_loading_indicator"));
ui_report.error(i18n.t("Error listing invites"), xhr, $("#invites-field-status"));
}
@@ -26,8 +26,8 @@ function sort_invitee(a, b) {
// multi-invite links don't have an email field,
// so we set them to empty strings to let them
// sort to the top
- const str1 = (a.email || '').toUpperCase();
- const str2 = (b.email || '').toUpperCase();
+ const str1 = (a.email || "").toUpperCase();
+ const str2 = (b.email || "").toUpperCase();
return util.strcmp(str1, str2);
}
@@ -42,7 +42,7 @@ function populate_invites(invites_data) {
const invites_table = $("#admin_invites_table").expectOne();
list_render.create(invites_table, invites_data.invites, {
- name: 'admin_invites_list',
+ name: "admin_invites_list",
modifier: function (item) {
item.invited_absolute_time = timerender.absolute_time(item.invited * 1000);
item.is_admin = page_params.is_admin;
@@ -68,10 +68,10 @@ function populate_invites(invites_data) {
sort_fields: {
invitee: sort_invitee,
},
- simplebar_container: $('#admin-invites-list .progressive-table-wrapper'),
+ simplebar_container: $("#admin-invites-list .progressive-table-wrapper"),
});
- loading.destroy_indicator($('#admin_page_invites_loading_indicator'));
+ loading.destroy_indicator($("#admin_page_invites_loading_indicator"));
}
function do_revoke_invite() {
@@ -82,14 +82,14 @@ function do_revoke_invite() {
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');
+ $("#home-error"), "alert-error");
}
$("#revoke_invite_modal").modal("hide");
revoke_button.prop("disabled", true).text(i18n.t("Working…"));
- let url = '/json/invites/' + meta.invite_id;
+ let url = "/json/invites/" + meta.invite_id;
if (modal_is_multiuse === "true") {
- url = '/json/invites/multiuse/' + meta.invite_id;
+ url = "/json/invites/multiuse/" + meta.invite_id;
}
channel.del({
url: url,
@@ -104,16 +104,16 @@ function do_revoke_invite() {
exports.set_up = function (initialize_event_handlers) {
meta.loaded = true;
- if (typeof initialize_event_handlers === 'undefined') {
+ if (typeof initialize_event_handlers === "undefined") {
initialize_event_handlers = true;
}
// create loading indicators
- loading.make_indicator($('#admin_page_invites_loading_indicator'));
+ loading.make_indicator($("#admin_page_invites_loading_indicator"));
// Populate invites table
channel.get({
- url: '/json/invites',
+ url: "/json/invites",
idempotent: true,
timeout: 10 * 1000,
success: function (data) {
@@ -135,8 +135,8 @@ exports.on_load_success = function (invites_data, initialize_event_handlers) {
e.preventDefault();
e.stopPropagation();
const row = $(e.target).closest(".invite_row");
- const email = row.find('.email').text();
- const referred_by = row.find('.referred_by').text();
+ const email = row.find(".email").text();
+ const referred_by = row.find(".referred_by").text();
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");
@@ -157,7 +157,7 @@ exports.on_load_success = function (invites_data, initialize_event_handlers) {
e.stopPropagation();
const row = $(e.target).closest(".invite_row");
- const email = row.find('.email').text();
+ const email = row.find(".email").text();
meta.current_resend_invite_user_modal_row = row;
meta.invite_id = $(e.currentTarget).attr("data-invite-id");
@@ -173,18 +173,18 @@ exports.on_load_success = function (invites_data, initialize_event_handlers) {
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');
+ $("#home-error"), "alert-error");
}
$("#resend_invite_modal").modal("hide");
resend_button.prop("disabled", true).text(i18n.t("Working…"));
channel.post({
- url: '/json/invites/' + meta.invite_id + "/resend",
+ url: "/json/invites/" + meta.invite_id + "/resend",
error: function (xhr) {
ui_report.generic_row_button_error(xhr, resend_button);
},
success: function (data) {
resend_button.text(i18n.t("Sent!"));
- resend_button.removeClass('resend btn-warning').addClass('sea-green');
+ resend_button.removeClass("resend btn-warning").addClass("sea-green");
data.timestamp = timerender.absolute_time(data.timestamp * 1000);
meta.current_resend_invite_user_modal_row.find(".invited_at").text(data.timestamp);
},
diff --git a/static/js/settings_linkifiers.js b/static/js/settings_linkifiers.js
index 48aee7a56bf..d1b0166a1c7 100644
--- a/static/js/settings_linkifiers.js
+++ b/static/js/settings_linkifiers.js
@@ -65,10 +65,10 @@ exports.populate_filters = function (filters_data) {
pattern: sort_pattern,
url: sort_url,
},
- simplebar_container: $('#filter-settings .progressive-table-wrapper'),
+ simplebar_container: $("#filter-settings .progressive-table-wrapper"),
});
- loading.destroy_indicator($('#admin_page_filters_loading_indicator'));
+ loading.destroy_indicator($("#admin_page_filters_loading_indicator"));
};
exports.set_up = function () {
@@ -80,35 +80,35 @@ exports.build_page = function () {
meta.loaded = true;
// create loading indicators
- loading.make_indicator($('#admin_page_filters_loading_indicator'));
+ loading.make_indicator($("#admin_page_filters_loading_indicator"));
// Populate filters table
exports.populate_filters(page_params.realm_filters);
- $('.admin_filters_table').on('click', '.delete', function (e) {
+ $(".admin_filters_table").on("click", ".delete", function (e) {
e.preventDefault();
e.stopPropagation();
const btn = $(this);
channel.del({
- url: '/json/realm/filters/' + encodeURIComponent(btn.attr('data-filter-id')),
+ url: "/json/realm/filters/" + encodeURIComponent(btn.attr("data-filter-id")),
error: function (xhr) {
ui_report.generic_row_button_error(xhr, btn);
},
success: function () {
- const row = btn.parents('tr');
+ const row = btn.parents("tr");
row.remove();
},
});
});
- $(".organization form.admin-filter-form").off('submit').on('submit', function (e) {
+ $(".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');
+ 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();
@@ -123,8 +123,8 @@ exports.build_page = function () {
url: "/json/realm/filters",
data: $(this).serialize(),
success: function (data) {
- $('#filter_pattern').val('');
- $('#filter_format_string').val('');
+ $("#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);
diff --git a/static/js/settings_muting.js b/static/js/settings_muting.js
index 4d1dcc12a34..96b7e65178b 100644
--- a/static/js/settings_muting.js
+++ b/static/js/settings_muting.js
@@ -2,7 +2,7 @@ exports.loaded = false;
exports.set_up = function () {
exports.loaded = true;
- $('body').on('click', '.settings-unmute-topic', function (e) {
+ $("body").on("click", ".settings-unmute-topic", function (e) {
const $row = $(this).closest("tr");
const stream_id = parseInt($row.attr("data-stream-id"), 10);
const topic = $row.attr("data-topic");
diff --git a/static/js/settings_notifications.js b/static/js/settings_notifications.js
index c7b3277de64..0a7e3b3a435 100644
--- a/static/js/settings_notifications.js
+++ b/static/js/settings_notifications.js
@@ -1,4 +1,4 @@
-const render_stream_specific_notification_row = require('../templates/settings/stream_specific_notification_row.hbs');
+const render_stream_specific_notification_row = require("../templates/settings/stream_specific_notification_row.hbs");
const settings_config = require("./settings_config");
exports.get_notifications_table_row_data = function (notify_settings) {
@@ -47,7 +47,7 @@ function rerender_ui() {
const unmatched_streams = stream_data.get_unmatched_streams_for_notification_settings();
- unmatched_streams_table.find('.stream-row').remove();
+ unmatched_streams_table.find(".stream-row").remove();
for (const stream of unmatched_streams) {
unmatched_streams_table.append(
@@ -70,7 +70,7 @@ 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() {
@@ -81,14 +81,14 @@ function update_desktop_icon_count_display() {
exports.set_enable_digest_emails_visibility = function () {
if (page_params.realm_digest_emails_enabled) {
- $('#enable_digest_emails_label').parent().show();
+ $("#enable_digest_emails_label").parent().show();
} else {
- $('#enable_digest_emails_label').parent().hide();
+ $("#enable_digest_emails_label").parent().hide();
}
};
exports.set_up = function () {
- $('#notification-settings').on('change', 'input, select', function (e) {
+ $("#notification-settings").on("change", "input, select", function (e) {
e.preventDefault();
e.stopPropagation();
const input_elem = $(e.currentTarget);
@@ -99,7 +99,7 @@ exports.set_up = function () {
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'));
+ input_elem.closest(".subsection-parent").find(".alert-notification"));
});
update_desktop_icon_count_display();
@@ -132,17 +132,17 @@ exports.set_up = function () {
exports.update_page = function () {
for (const setting of settings_config.all_notification_settings) {
- if (setting === 'enable_offline_push_notifications'
+ 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;
- } else if (setting === 'desktop_icon_count_display') {
+ } else if (setting === "desktop_icon_count_display") {
update_desktop_icon_count_display();
continue;
}
- $("#" + setting).prop('checked', page_params[setting]);
+ $("#" + setting).prop("checked", page_params[setting]);
}
rerender_ui();
};
diff --git a/static/js/settings_org.js b/static/js/settings_org.js
index 1e5ab811f43..a3137291611 100644
--- a/static/js/settings_org.js
+++ b/static/js/settings_org.js
@@ -1,5 +1,5 @@
const settings_config = require("./settings_config");
-const render_settings_admin_auth_methods_list = require('../templates/settings/admin_auth_methods_list.hbs');
+const render_settings_admin_auth_methods_list = require("../templates/settings/admin_auth_methods_list.hbs");
const render_settings_admin_realm_domains_list = require("../templates/settings/admin_realm_domains_list.hbs");
const pygments_data = require("../generated/pygments_data.json");
@@ -33,13 +33,13 @@ exports.maybe_disable_widgets = function () {
.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);
$(".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) {
@@ -87,15 +87,15 @@ exports.get_realm_time_limits_in_minutes = function (property) {
};
function get_property_value(property_name) {
- if (property_name === 'realm_message_content_edit_limit_minutes') {
- return exports.get_realm_time_limits_in_minutes('realm_message_content_edit_limit_seconds');
+ if (property_name === "realm_message_content_edit_limit_minutes") {
+ return exports.get_realm_time_limits_in_minutes("realm_message_content_edit_limit_seconds");
}
- if (property_name === 'realm_message_content_delete_limit_minutes') {
- return exports.get_realm_time_limits_in_minutes('realm_message_content_delete_limit_seconds');
+ if (property_name === "realm_message_content_delete_limit_minutes") {
+ return exports.get_realm_time_limits_in_minutes("realm_message_content_delete_limit_seconds");
}
- if (property_name === 'realm_waiting_period_setting') {
+ if (property_name === "realm_waiting_period_setting") {
if (page_params.realm_waiting_period_threshold === 0) {
return "none";
}
@@ -105,14 +105,14 @@ function get_property_value(property_name) {
return "custom_days";
}
- if (property_name === 'realm_add_emoji_by_admins_only') {
+ if (property_name === "realm_add_emoji_by_admins_only") {
if (page_params.realm_add_emoji_by_admins_only) {
return "by_admins_only";
}
return "by_anyone";
}
- if (property_name === 'realm_msg_edit_limit_setting') {
+ if (property_name === "realm_msg_edit_limit_setting") {
if (!page_params.realm_allow_message_editing) {
return "never";
}
@@ -124,14 +124,14 @@ function get_property_value(property_name) {
return "custom_limit";
}
- if (property_name === 'realm_message_retention_setting') {
+ if (property_name === "realm_message_retention_setting") {
if (page_params.realm_message_retention_days === settings_config.retain_message_forever) {
return "retain_forever";
}
return "retain_for_period";
}
- if (property_name === 'realm_msg_delete_limit_setting') {
+ if (property_name === "realm_msg_delete_limit_setting") {
if (!page_params.realm_allow_message_deleting) {
return "never";
}
@@ -143,7 +143,7 @@ function get_property_value(property_name) {
return "custom_limit";
}
- if (property_name === 'realm_org_join_restrictions') {
+ if (property_name === "realm_org_join_restrictions") {
if (page_params.realm_emails_restricted_to_domains) {
return "only_selected_domain";
}
@@ -153,7 +153,7 @@ function get_property_value(property_name) {
return "no_restriction";
}
- if (property_name === 'realm_user_invite_restriction') {
+ if (property_name === "realm_user_invite_restriction") {
if (!page_params.realm_invite_required) {
if (page_params.realm_invite_by_admins_only) {
return "no_invite_required_by_admins_only";
@@ -166,7 +166,7 @@ function get_property_value(property_name) {
return "by_anyone";
}
- if (property_name === 'realm_default_twenty_four_hour_time') {
+ if (property_name === "realm_default_twenty_four_hour_time") {
return JSON.stringify(page_params[property_name]);
}
@@ -174,23 +174,23 @@ function get_property_value(property_name) {
}
exports.extract_property_name = function (elem) {
- return elem.attr('id').split('-').join('_').replace("id_", "");
+ return elem.attr("id").split("-").join("_").replace("id_", "");
};
function get_subsection_property_elements(element) {
- const subsection = $(element).closest('.org-subsection-parent');
- return Array.from(subsection.find('.prop-element'));
+ const subsection = $(element).closest(".org-subsection-parent");
+ 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));
+ $("#id_" + property_name).val(get_property_value(property_name));
}
function change_element_block_display_property(elem_id, show_element) {
@@ -205,7 +205,7 @@ 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',
+ change_element_block_display_property("id_realm_waiting_period_threshold",
value === "custom_days");
}
@@ -217,7 +217,7 @@ 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',
+ 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);
@@ -226,35 +226,35 @@ function set_msg_edit_limit_dropdown() {
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',
+ 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',
+ 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('');
+ if (get_property_value("realm_message_retention_days") === settings_config.retain_message_forever) {
+ $("#id_realm_message_retention_days").val("");
}
}
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',
+ "message_content_in_email_notifications_label",
page_params.realm_message_content_allowed_in_email_notifications);
}
function set_digest_emails_weekday_visibility() {
- change_element_block_display_property('id_realm_digest_weekday',
+ change_element_block_display_property("id_realm_digest_weekday",
page_params.realm_digest_emails_enabled);
}
@@ -266,7 +266,7 @@ exports.populate_realm_domains = function (realm_domains) {
const domains_list = realm_domains.map(
(realm_domain) => realm_domain.allow_subdomains ? "*." + realm_domain.domain : realm_domain.domain,
);
- let domains = domains_list.join(', ');
+ let domains = domains_list.join(", ");
if (domains.length === 0) {
domains = i18n.t("None");
}
@@ -313,24 +313,24 @@ exports.populate_auth_methods = function (auth_methods) {
function update_dependent_subsettings(property_name) {
if (simple_dropdown_properties.includes(property_name)) {
set_property_dropdown_value(property_name);
- } else if (property_name === 'realm_waiting_period_threshold') {
+ } 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') {
+ } 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') {
+ } else if (property_name === "realm_org_join_restrictions") {
set_org_join_restrictions_dropdown();
- } else if (property_name === 'realm_message_content_allowed_in_email_notifications') {
+ } else if (property_name === "realm_message_content_allowed_in_email_notifications") {
set_message_content_in_email_notifications_visiblity();
- } else if (property_name === 'realm_digest_emails_enabled') {
+ } else if (property_name === "realm_digest_emails_enabled") {
settings_notifications.set_enable_digest_emails_visibility();
set_digest_emails_weekday_visibility();
}
@@ -341,18 +341,18 @@ function discard_property_element_changes(elem) {
const property_name = exports.extract_property_name(elem);
const property_value = get_property_value(property_name);
- if (property_name === 'realm_authentication_methods') {
+ if (property_name === "realm_authentication_methods") {
exports.populate_auth_methods(property_value);
- } else if (property_name === 'realm_notifications_stream_id') {
+ } else if (property_name === "realm_notifications_stream_id") {
exports.notifications_stream_widget.render(property_value);
- } else if (property_name === 'realm_signup_notifications_stream_id') {
+ } else if (property_name === "realm_signup_notifications_stream_id") {
exports.signup_notifications_stream_widget.render(property_value);
- } else if (property_name === 'realm_default_code_block_language') {
+ } else if (property_name === "realm_default_code_block_language") {
exports.default_code_language_widget.render(property_value);
} else if (property_value !== undefined) {
exports.set_input_element_value(elem, property_value);
} else {
- blueslip.error('Element refers to unknown property ' + property_name);
+ blueslip.error("Element refers to unknown property " + property_name);
}
update_dependent_subsettings(property_name);
@@ -364,28 +364,28 @@ exports.sync_realm_settings = function (property) {
}
const value = page_params[`realm_${property}`];
- if (property === 'notifications_stream_id') {
+ if (property === "notifications_stream_id") {
exports.notifications_stream_widget.render(value);
- } else if (property === 'signup_notifications_stream_id') {
+ } else if (property === "signup_notifications_stream_id") {
exports.signup_notifications_stream_widget.render(value);
- } else if (property === 'default_code_block_language') {
+ } else if (property === "default_code_block_language") {
exports.default_code_language_widget.render(value);
}
- if (property === 'message_content_edit_limit_seconds') {
- 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') {
- property = 'org_join_restrictions';
- } else if (property === 'message_content_delete_limit_seconds') {
- property = 'message_content_delete_limit_minutes';
- } else if (property === 'allow_message_deleting') {
- property = 'msg_delete_limit_setting';
- } else if (property === 'invite_required' || property === 'invite_by_admins_only') {
- property = 'user_invite_restriction';
- }
- const element = $('#id_realm_' + property);
+ if (property === "message_content_edit_limit_seconds") {
+ 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") {
+ property = "org_join_restrictions";
+ } else if (property === "message_content_delete_limit_seconds") {
+ property = "message_content_delete_limit_minutes";
+ } else if (property === "allow_message_deleting") {
+ property = "msg_delete_limit_setting";
+ } else if (property === "invite_required" || property === "invite_by_admins_only") {
+ property = "user_invite_restriction";
+ }
+ const element = $("#id_realm_" + property);
if (element.length) {
discard_property_element_changes(element);
}
@@ -395,7 +395,7 @@ exports.sync_realm_settings = function (property) {
exports.change_save_button_state = function ($element, state) {
function show_hide_element($element, show, fadeout_delay) {
if (show) {
- $element.removeClass('hide').addClass('.show').fadeIn(300);
+ $element.removeClass("hide").addClass(".show").fadeIn(300);
return;
}
setTimeout(() => {
@@ -403,11 +403,11 @@ exports.change_save_button_state = function ($element, state) {
}, fadeout_delay);
}
- const $saveBtn = $element.find('.save-button');
- const $textEl = $saveBtn.find('.icon-button-text');
+ const $saveBtn = $element.find(".save-button");
+ const $textEl = $saveBtn.find(".icon-button-text");
if (state !== "saving") {
- $saveBtn.removeClass('saving');
+ $saveBtn.removeClass("saving");
}
if (state === "discarded") {
@@ -423,7 +423,7 @@ exports.change_save_button_state = function ($element, state) {
data_status = "unsaved";
is_show = true;
- $element.find('.discard-button').show();
+ $element.find(".discard-button").show();
} else if (state === "saved") {
button_text = i18n.t("Save changes");
data_status = "";
@@ -433,13 +433,13 @@ exports.change_save_button_state = function ($element, state) {
data_status = "saving";
is_show = true;
- $element.find('.discard-button').hide();
- $saveBtn.addClass('saving');
+ $element.find(".discard-button").hide();
+ $saveBtn.addClass("saving");
} else if (state === "failed") {
button_text = i18n.t("Save changes");
data_status = "failed";
is_show = true;
- } else if (state === 'succeeded') {
+ } else if (state === "succeeded") {
button_text = i18n.t("Saved");
data_status = "saved";
is_show = false;
@@ -461,13 +461,13 @@ exports.get_input_element_value = function (input_elem, input_type) {
input_elem = $(input_elem);
input_type = get_input_type(input_elem, input_type);
if (input_type) {
- if (input_type === 'boolean') {
- return input_elem.prop('checked');
+ if (input_type === "boolean") {
+ return input_elem.prop("checked");
}
- if (input_type === 'string') {
+ if (input_type === "string") {
return input_elem.val().trim();
}
- if (input_type === 'number') {
+ if (input_type === "number") {
return parseInt(input_elem.val().trim(), 10);
}
}
@@ -477,10 +477,10 @@ exports.get_input_element_value = function (input_elem, input_type) {
exports.set_input_element_value = function (input_elem, value) {
const input_type = get_input_type(input_elem, typeof value);
if (input_type) {
- if (input_type === 'boolean') {
- return input_elem.prop('checked', value);
+ if (input_type === "boolean") {
+ return input_elem.prop("checked", value);
}
- if (input_type === 'string' || input_type === 'number') {
+ if (input_type === "string" || input_type === "number") {
return input_elem.val(value);
}
}
@@ -495,10 +495,10 @@ exports.set_up = function () {
function get_auth_method_table_data() {
const new_auth_methods = {};
- const auth_method_rows = $("#id_realm_authentication_methods").find('tr.method_row');
+ 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;
@@ -510,32 +510,32 @@ function check_property_changed(elem) {
let current_val = get_property_value(property_name);
let changed_val;
- if (property_name === 'realm_authentication_methods') {
+ if (property_name === "realm_authentication_methods") {
current_val = sort_object_by_key(current_val);
current_val = JSON.stringify(current_val);
changed_val = get_auth_method_table_data();
changed_val = JSON.stringify(changed_val);
- } else if (property_name === 'realm_notifications_stream_id') {
+ } else if (property_name === "realm_notifications_stream_id") {
changed_val = parseInt(exports.notifications_stream_widget.value(), 10);
- } else if (property_name === 'realm_signup_notifications_stream_id') {
+ } else if (property_name === "realm_signup_notifications_stream_id") {
changed_val = parseInt(exports.signup_notifications_stream_widget.value(), 10);
- } else if (property_name === 'realm_default_code_block_language') {
+ } else if (property_name === "realm_default_code_block_language") {
changed_val = exports.default_code_language_widget.value();
} else if (current_val !== undefined) {
changed_val = exports.get_input_element_value(elem, typeof current_val);
} else {
- blueslip.error('Element refers to unknown property ' + property_name);
+ blueslip.error("Element refers to unknown property " + property_name);
}
return current_val !== changed_val;
}
exports.save_discard_widget_status_handler = (subsection) => {
- subsection.find('.subsection-failed-status p').hide();
- subsection.find('.save-button').show();
+ subsection.find(".subsection-failed-status p").hide();
+ subsection.find(".save-button").show();
const properties_elements = get_subsection_property_elements(subsection);
const show_change_process_button = properties_elements.some(check_property_changed);
- const save_btn_controls = subsection.find('.subsection-header .save-button-controls');
+ const save_btn_controls = subsection.find(".subsection-header .save-button-controls");
const button_state = show_change_process_button ? "unsaved" : "discarded";
exports.change_save_button_state(save_btn_controls, button_state);
};
@@ -555,7 +555,7 @@ exports.init_dropdown_widgets = () => {
return item;
}),
on_update: () => {
- exports.save_discard_widget_status_handler($(`#org-notifications`));
+ exports.save_discard_widget_status_handler($("#org-notifications"));
},
default_text: i18n.t("Disabled"),
render_text: (x) => `#${x}`,
@@ -563,25 +563,25 @@ exports.init_dropdown_widgets = () => {
};
exports.notifications_stream_widget = dropdown_list_widget(
Object.assign({
- widget_name: 'realm_notifications_stream_id',
+ 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',
+ 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',
+ widget_name: "realm_default_code_block_language",
data: Object.keys(pygments_data.langs).map((x) => ({
name: x,
value: x,
})),
value: page_params.realm_default_code_block_language,
on_update: () => {
- exports.save_discard_widget_status_handler($(`#org-other-settings`));
+ exports.save_discard_widget_status_handler($("#org-other-settings"));
},
default_text: i18n.t("No language set"),
});
@@ -590,7 +590,7 @@ exports.init_dropdown_widgets = () => {
exports.build_page = function () {
meta.loaded = true;
- loading.make_indicator($('#admin_page_auth_methods_loading_indicator'));
+ loading.make_indicator($("#admin_page_auth_methods_loading_indicator"));
// Initialize all the dropdown list widgets.
exports.init_dropdown_widgets();
@@ -611,7 +611,7 @@ exports.build_page = function () {
set_message_content_in_email_notifications_visiblity();
set_digest_emails_weekday_visibility();
- $('.admin-realm-form').on('change input', 'input, select, textarea', (e) => {
+ $(".admin-realm-form").on("change input", "input, select, textarea", (e) => {
e.preventDefault();
e.stopPropagation();
@@ -629,22 +629,22 @@ exports.build_page = function () {
return false;
}
- const subsection = $(e.target).closest('.org-subsection-parent');
+ const subsection = $(e.target).closest(".org-subsection-parent");
exports.save_discard_widget_status_handler(subsection);
});
- $('.organization').on('click', '.subsection-header .subsection-changes-discard .button', (e) => {
+ $(".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');
+ 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');
- const save_btn_container = subsection_parent.find('.save-button-controls');
- const failed_alert_elem = subsection_parent.find('.subsection-failed-status p');
+ const subsection_parent = save_button.closest(".org-subsection-parent");
+ const save_btn_container = subsection_parent.find(".save-button-controls");
+ const failed_alert_elem = subsection_parent.find(".subsection-failed-status p");
exports.change_save_button_state(save_btn_container, "saving");
channel.patch({
url: "/json/realm",
@@ -668,12 +668,12 @@ exports.build_page = function () {
function get_complete_data_for_subsection(subsection) {
let data = {};
- if (subsection === 'msg_editing') {
+ if (subsection === "msg_editing") {
const edit_limit_setting_value = $("#id_realm_msg_edit_limit_setting").val();
- if (edit_limit_setting_value === 'never') {
+ 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'));
+ } 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"));
// Disable editing if the parsed time limit is 0 seconds
data.allow_message_editing = !!data.message_content_edit_limit_seconds;
} else {
@@ -684,10 +684,10 @@ exports.build_page = function () {
).seconds;
}
const delete_limit_setting_value = $("#id_realm_msg_delete_limit_setting").val();
- if (delete_limit_setting_value === 'never') {
+ 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'));
+ } 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"));
// Disable deleting if the parsed time limit is 0 seconds
data.allow_message_deleting = !!data.message_content_delete_limit_seconds;
} else {
@@ -697,23 +697,23 @@ exports.build_page = function () {
delete_limit_setting_value,
).seconds;
}
- } else if (subsection === 'notifications') {
+ } else if (subsection === "notifications") {
data.notifications_stream_id = JSON.stringify(
parseInt(exports.notifications_stream_widget.value(), 10));
data.signup_notifications_stream_id = JSON.stringify(
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 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')));
+ $("#id_realm_message_retention_days")));
}
- } else if (subsection === 'other_settings') {
+ } else if (subsection === "other_settings") {
const code_block_language_value = exports.default_code_language_widget.value();
data.default_code_block_language = JSON.stringify(code_block_language_value);
- } else if (subsection === 'other_permissions') {
+ } else if (subsection === "other_permissions") {
const add_emoji_permission = $("#id_realm_add_emoji_by_admins_only").val();
if (add_emoji_permission === "by_admins_only") {
@@ -721,8 +721,8 @@ exports.build_page = function () {
} else if (add_emoji_permission === "by_anyone") {
data.add_emoji_by_admins_only = false;
}
- } else if (subsection === 'org_join') {
- const org_join_restrictions = $('#id_realm_org_join_restrictions').val();
+ } else if (subsection === "org_join") {
+ const org_join_restrictions = $("#id_realm_org_join_restrictions").val();
if (org_join_restrictions === "only_selected_domain") {
data.emails_restricted_to_domains = true;
data.disallow_disposable_email_addresses = false;
@@ -734,14 +734,14 @@ exports.build_page = function () {
data.emails_restricted_to_domains = false;
}
- const user_invite_restriction = $('#id_realm_user_invite_restriction').val();
- if (user_invite_restriction === 'no_invite_required') {
+ const user_invite_restriction = $("#id_realm_user_invite_restriction").val();
+ if (user_invite_restriction === "no_invite_required") {
data.invite_required = false;
data.invite_by_admins_only = false;
- } else if (user_invite_restriction === 'no_invite_required_by_admins_only') {
+ } else if (user_invite_restriction === "no_invite_required_by_admins_only") {
data.invite_required = false;
data.invite_by_admins_only = true;
- } else if (user_invite_restriction === 'by_admins_only') {
+ } else if (user_invite_restriction === "by_admins_only") {
data.invite_required = true;
data.invite_by_admins_only = true;
} else {
@@ -757,11 +757,11 @@ exports.build_page = function () {
} else if (waiting_period_threshold === "custom_days") {
data.waiting_period_threshold = $("#id_realm_waiting_period_threshold").val();
}
- } else if (subsection === 'auth_settings') {
+ } else if (subsection === "auth_settings") {
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();
+ } else if (subsection === "user_defaults") {
+ 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;
@@ -776,7 +776,7 @@ exports.build_page = function () {
if (check_property_changed(input_elem)) {
const input_value = exports.get_input_element_value(input_elem);
if (input_value !== undefined) {
- const property_name = input_elem.attr('id').replace("id_realm_", "");
+ const property_name = input_elem.attr("id").replace("id_realm_", "");
data[property_name] = JSON.stringify(input_value);
}
}
@@ -789,9 +789,9 @@ exports.build_page = function () {
e.preventDefault();
e.stopPropagation();
const save_button = $(e.currentTarget);
- const subsection_id = save_button.attr('id').replace("org-submit-", "");
- const subsection = subsection_id.split('-').join('_');
- const subsection_elem = save_button.closest('.org-subsection-parent');
+ const subsection_id = save_button.attr("id").replace("org-submit-", "");
+ const subsection = subsection_id.split("-").join("_");
+ const subsection_elem = save_button.closest(".org-subsection-parent");
const data = {
...populate_data_for_request(subsection_elem),
@@ -804,41 +804,41 @@ 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) => {
const org_join_restrictions = e.target.value;
const node = $("#allowed_domains_label").parent();
- if (org_join_restrictions === 'only_selected_domain') {
+ if (org_join_restrictions === "only_selected_domain") {
node.show();
if (page_params.realm_domains.length === 0) {
- overlays.open_modal('#realm_domains_modal');
+ overlays.open_modal("#realm_domains_modal");
}
} else {
node.hide();
@@ -906,8 +906,8 @@ exports.build_page = function () {
e.stopPropagation();
const realm_domains_info = $(".realm_domains_info");
const domain = $(this).parents("tr").find(".domain").text();
- const allow_subdomains = $(this).prop('checked');
- const url = '/json/realm/domains/' + domain;
+ const allow_subdomains = $(this).prop("checked");
+ const url = "/json/realm/domains/" + domain;
const data = {
allow_subdomains: JSON.stringify(allow_subdomains),
};
@@ -933,7 +933,7 @@ exports.build_page = function () {
});
function realm_icon_logo_upload_complete(spinner, upload_text, delete_button) {
- spinner.css({visibility: 'hidden'});
+ spinner.css({visibility: "hidden"});
upload_text.show();
delete_button.show();
@@ -950,21 +950,21 @@ exports.build_page = function () {
let widget;
let url;
- form_data.append('csrfmiddlewaretoken', csrf_token);
+ form_data.append("csrfmiddlewaretoken", csrf_token);
for (const [i, file] of Array.prototype.entries.call(file_input[0].files)) {
- form_data.append('file-' + i, file);
+ form_data.append("file-" + i, file);
}
if (icon) {
- url = '/json/realm/icon';
- widget = '#realm-icon-upload-widget';
+ url = "/json/realm/icon";
+ widget = "#realm-icon-upload-widget";
} else {
if (night) {
- widget = '#realm-night-logo-upload-widget';
+ widget = "#realm-night-logo-upload-widget";
} else {
- widget = '#realm-day-logo-upload-widget';
+ widget = "#realm-day-logo-upload-widget";
}
- url = '/json/realm/logo';
- form_data.append('night', JSON.stringify(night));
+ url = "/json/realm/logo";
+ form_data.append("night", JSON.stringify(night));
}
const spinner = $(`${widget} .upload-spinner-background`).expectOne();
const upload_text = $(`${widget} .settings-page-upload-text`).expectOne();
@@ -995,23 +995,23 @@ exports.build_page = function () {
}
- $('#deactivate_realm_button').on('click', (e) => {
+ $("#deactivate_realm_button").on("click", (e) => {
if (!overlays.is_modal_open()) {
e.preventDefault();
e.stopPropagation();
- overlays.open_modal('#deactivate-realm-modal');
+ overlays.open_modal("#deactivate-realm-modal");
}
});
- $('#do_deactivate_realm_button').on('click', () => {
+ $("#do_deactivate_realm_button").on("click", () => {
if (overlays.is_modal_open()) {
- overlays.close_modal('#deactivate-realm-modal');
+ overlays.close_modal("#deactivate-realm-modal");
}
channel.post({
- url: '/json/realm/deactivate',
+ 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_panel_menu.js b/static/js/settings_panel_menu.js
index ed1933cb06e..e9f09a958e8 100644
--- a/static/js/settings_panel_menu.js
+++ b/static/js/settings_panel_menu.js
@@ -7,12 +7,12 @@ exports.mobile_deactivate_section = function () {
exports.make_menu = function (opts) {
const main_elem = opts.main_elem;
const hash_prefix = opts.hash_prefix;
- let curr_li = main_elem.children('li').eq(0);
+ let curr_li = main_elem.children("li").eq(0);
const self = {};
function two_column_mode() {
- return $('#settings_overlay_container').css('--single-column') === undefined;
+ return $("#settings_overlay_container").css("--single-column") === undefined;
}
self.show = function () {
@@ -30,7 +30,7 @@ exports.make_menu = function (opts) {
};
self.current_tab = function () {
- return curr_li.data('section');
+ return curr_li.data("section");
};
self.li_for_section = function (section) {
@@ -63,7 +63,7 @@ exports.make_menu = function (opts) {
self.enter_panel = function () {
const panel = self.get_panel();
- const sel = 'input:visible,button:visible,select:visible';
+ const sel = "input:visible,button:visible,select:visible";
const panel_elem = panel.find(sel).first();
panel_elem.focus();
@@ -90,14 +90,14 @@ exports.make_menu = function (opts) {
main_elem.children("li").removeClass("active");
curr_li.addClass("active");
- const settings_section_hash = '#' + hash_prefix + section;
+ const settings_section_hash = "#" + hash_prefix + section;
hashchange.update_browser_history(settings_section_hash);
$(".settings-section").removeClass("show");
settings_sections.load_settings_section(section);
- self.get_panel().addClass('show');
+ self.get_panel().addClass("show");
ui.reset_scrollbar($("#settings_content"));
@@ -109,14 +109,14 @@ exports.make_menu = function (opts) {
};
self.get_panel = function () {
- const section = curr_li.data('section');
+ const section = curr_li.data("section");
const sel = "[data-name='" + section + "']";
const panel = $(".settings-section" + sel);
return panel;
};
main_elem.on("click", "li[data-section]", function (e) {
- const section = $(this).attr('data-section');
+ const section = $(this).attr("data-section");
self.activate_section_or_default(section);
@@ -131,11 +131,11 @@ exports.make_menu = function (opts) {
exports.initialize = function () {
exports.normal_settings = exports.make_menu({
- main_elem: $('.normal-settings-list'),
+ main_elem: $(".normal-settings-list"),
hash_prefix: "settings/",
});
exports.org_settings = exports.make_menu({
- main_elem: $('.org-settings-list'),
+ main_elem: $(".org-settings-list"),
hash_prefix: "organization/",
});
};
diff --git a/static/js/settings_profile_fields.js b/static/js/settings_profile_fields.js
index 0306f359325..adb84950130 100644
--- a/static/js/settings_profile_fields.js
+++ b/static/js/settings_profile_fields.js
@@ -49,15 +49,15 @@ 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());
+ "/json/realm/profile_fields/" + encodeURIComponent($(this).attr("data-profile-field-id")),
+ {}, $("#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 () {
+ $(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()};
@@ -70,9 +70,9 @@ function read_choice_field_data_from_form(field_elem) {
function read_external_account_field_data(field_elem) {
const field_data = {};
- field_data.subtype = $(field_elem).find('select[name=external_acc_field_type]').val();
+ field_data.subtype = $(field_elem).find("select[name=external_acc_field_type]").val();
if (field_data.subtype === "custom") {
- field_data.url_pattern = $(field_elem).find('input[name=url_pattern]').val();
+ field_data.url_pattern = $(field_elem).find("input[name=url_pattern]").val();
}
return field_data;
}
@@ -121,7 +121,7 @@ function set_up_create_field_form() {
if (parseInt($("#profile_field_type").val(), 10) === field_types.EXTERNAL_ACCOUNT.id) {
field_elem.show();
- if ($("#profile_field_external_accounts_type").val() === 'custom') {
+ if ($("#profile_field_external_accounts_type").val() === "custom") {
field_url_pattern_elem.show();
$("#profile_field_name").val("").closest(".control-group").show();
$("#profile_field_hint").val("").closest(".control-group").show();
@@ -153,11 +153,11 @@ function create_profile_field(e) {
e.stopPropagation();
let field_data = {};
- const field_type = $('#profile_field_type').val();
+ const field_type = $("#profile_field_type").val();
const opts = {
success_continuation: clear_form_data,
};
- field_data = read_field_data_from_form(parseInt(field_type, 10), $('.new-profile-field-form'));
+ field_data = read_field_data_from_form(parseInt(field_type, 10), $(".new-profile-field-form"));
const form_data = {
name: $("#profile_field_name").val(),
@@ -167,7 +167,7 @@ function create_profile_field(e) {
};
settings_ui.do_settings_change(channel.post, "/json/realm/profile_fields", form_data,
- $('#admin-add-profile-field-status').expectOne(), opts);
+ $("#admin-add-profile-field-status").expectOne(), opts);
update_profile_fields_table_element();
}
@@ -220,21 +220,21 @@ exports.parse_field_choices_from_field_data = function (field_data) {
};
function set_up_external_account_field_edit_form(field_elem, url_pattern_val) {
- if (field_elem.form.find('select[name=external_acc_field_type]').val() === 'custom') {
- field_elem.form.find('input[name=url_pattern]').val(url_pattern_val);
- field_elem.form.find('.custom_external_account_detail').show();
- field_elem.form.find('input[name=name]').val("").closest(".control-group").show();
- field_elem.form.find('input[name=hint]').val("").closest(".control-group").show();
+ if (field_elem.form.find("select[name=external_acc_field_type]").val() === "custom") {
+ field_elem.form.find("input[name=url_pattern]").val(url_pattern_val);
+ field_elem.form.find(".custom_external_account_detail").show();
+ field_elem.form.find("input[name=name]").val("").closest(".control-group").show();
+ field_elem.form.find("input[name=hint]").val("").closest(".control-group").show();
} else {
- field_elem.form.find('input[name=name]').closest(".control-group").hide();
- field_elem.form.find('input[name=hint]').closest(".control-group").hide();
- field_elem.form.find('.custom_external_account_detail').hide();
+ field_elem.form.find("input[name=name]").closest(".control-group").hide();
+ field_elem.form.find("input[name=hint]").closest(".control-group").hide();
+ field_elem.form.find(".custom_external_account_detail").hide();
}
}
function set_up_choices_field_edit_form(profile_field, field_data) {
// Re-render field choices in edit form to load initial choice data
- const choice_list = profile_field.form.find('.edit_profile_field_choices_container');
+ const choice_list = profile_field.form.find(".edit_profile_field_choices_container");
choice_list.off();
choice_list.html("");
@@ -264,8 +264,8 @@ function open_edit_form(e) {
profile_field.form.show();
const field = get_profile_field(field_id);
// Set initial value in edit form
- profile_field.form.find('input[name=name]').val(field.name);
- profile_field.form.find('input[name=hint]').val(field.hint);
+ profile_field.form.find("input[name=name]").val(field.name);
+ profile_field.form.find("input[name=hint]").val(field.hint);
let field_data = {};
if (field.field_data) {
field_data = JSON.parse(field.field_data);
@@ -276,27 +276,27 @@ function open_edit_form(e) {
}
if (parseInt(field.type, 10) === field_types.EXTERNAL_ACCOUNT.id) {
- profile_field.form.find('select[name=external_acc_field_type]').val(field_data.subtype);
+ profile_field.form.find("select[name=external_acc_field_type]").val(field_data.subtype);
set_up_external_account_field_edit_form(profile_field, field_data.url_pattern);
}
- profile_field.form.find('.reset').on("click", () => {
+ profile_field.form.find(".reset").on("click", () => {
profile_field.form.hide();
profile_field.row.show();
});
- profile_field.form.find('.submit').on("click", () => {
+ profile_field.form.find(".submit").on("click", () => {
e.preventDefault();
e.stopPropagation();
- const profile_field_status = $('#admin-profile-field-status').expectOne();
+ const profile_field_status = $("#admin-profile-field-status").expectOne();
// For some reason jQuery's serialize() is not working with
// channel.patch even though it is supported by $.ajax.
const data = {};
- data.name = profile_field.form.find('input[name=name]').val();
- data.hint = profile_field.form.find('input[name=hint]').val();
+ 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));
@@ -306,8 +306,8 @@ function open_edit_form(e) {
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);
+ $(".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_form = get_profile_field_info(field_id);
set_up_external_account_field_edit_form(field_form, "");
});
@@ -319,12 +319,12 @@ exports.reset = function () {
function update_field_order() {
order = [];
- $('.profile-field-row').each(function () {
- order.push(parseInt($(this).attr('data-profile-field-id'), 10));
+ $(".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());
+ $("#admin-profile-field-status").expectOne());
}
exports.populate_profile_fields = function (profile_fields_data) {
@@ -381,11 +381,11 @@ exports.do_populate_profile_fields = function (profile_fields_data) {
}
update_profile_fields_table_element();
- loading.destroy_indicator($('#admin_page_profile_fields_loading_indicator'));
+ loading.destroy_indicator($("#admin_page_profile_fields_loading_indicator"));
};
function set_up_choices_field() {
- create_choice_row('#profile_field_choices');
+ create_choice_row("#profile_field_choices");
update_choice_delete_btn($("#profile_field_choices"), false);
if (page_params.is_admin) {
@@ -395,14 +395,14 @@ function set_up_choices_field() {
});
}
- const field_type = $('#profile_field_type').val();
+ const field_type = $("#profile_field_type").val();
if (parseInt(field_type, 10) !== field_types.CHOICE.id) {
// If 'Choice' type is already selected, show choice row.
$("#profile_field_choices_row").hide();
}
- $('#profile_field_type').on('change', (e) => {
+ $("#profile_field_type").on("change", (e) => {
const selected_field_id = parseInt($(e.target).val(), 10);
if (selected_field_id === field_types.CHOICE.id) {
$("#profile_field_choices_row").show();
@@ -416,7 +416,7 @@ function set_up_choices_field() {
}
function set_up_external_account_field() {
- $('#profile_field_type').on('change', () => {
+ $("#profile_field_type").on("change", () => {
set_up_create_field_form();
});
@@ -429,13 +429,13 @@ exports.get_external_account_link = function (field) {
const field_subtype = field.field_data.subtype;
let field_url_pattern;
- if (field_subtype === 'custom') {
+ 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;
}
- return field_url_pattern.replace('%(username)s', field.value);
+ return field_url_pattern.replace("%(username)s", field.value);
};
exports.set_up = function () {
@@ -445,12 +445,12 @@ exports.set_up = function () {
exports.build_page = function () {
// create loading indicators
- loading.make_indicator($('#admin_page_profile_fields_loading_indicator'));
+ loading.make_indicator($("#admin_page_profile_fields_loading_indicator"));
// Populate profile_fields table
exports.do_populate_profile_fields(page_params.custom_profile_fields);
meta.loaded = true;
- $('#admin_profile_fields_table').on('click', '.delete', delete_profile_field);
+ $("#admin_profile_fields_table").on("click", ".delete", delete_profile_field);
$("#profile-field-settings").on("click", "#add-custom-profile-field-btn", create_profile_field);
$("#admin_profile_fields_table").on("click", ".open-edit-form", open_edit_form);
set_up_choices_field();
diff --git a/static/js/settings_sections.js b/static/js/settings_sections.js
index 0fedea420b8..32f511b04aa 100644
--- a/static/js/settings_sections.js
+++ b/static/js/settings_sections.js
@@ -5,18 +5,18 @@ exports.get_group = function (section) {
// Sometimes several sections all share the same code.
switch (section) {
- case 'organization-profile':
- case 'organization-settings':
- case 'organization-permissions':
- case 'auth-methods':
- return 'org_misc';
+ case "organization-profile":
+ case "organization-settings":
+ case "organization-permissions":
+ case "auth-methods":
+ return "org_misc";
- case 'bot-list-admin':
- return 'org_bots';
+ case "bot-list-admin":
+ return "org_bots";
- case 'user-list-admin':
- case 'deactivated-users-admin':
- return 'org_users';
+ case "user-list-admin":
+ case "deactivated-users-admin":
+ return "org_users";
default:
return section;
@@ -25,32 +25,32 @@ exports.get_group = function (section) {
exports.initialize = function () {
// personal
- load_func_dict.set('your-account', settings_account.set_up);
- load_func_dict.set('display-settings', settings_display.set_up);
- load_func_dict.set('notifications', settings_notifications.set_up);
- load_func_dict.set('your-bots', settings_bots.set_up);
- load_func_dict.set('alert-words', alert_words_ui.set_up_alert_words);
- load_func_dict.set('uploaded-files', attachments_ui.set_up_attachments);
- load_func_dict.set('muted-topics', settings_muting.set_up);
+ load_func_dict.set("your-account", settings_account.set_up);
+ load_func_dict.set("display-settings", settings_display.set_up);
+ load_func_dict.set("notifications", settings_notifications.set_up);
+ load_func_dict.set("your-bots", settings_bots.set_up);
+ load_func_dict.set("alert-words", alert_words_ui.set_up_alert_words);
+ load_func_dict.set("uploaded-files", attachments_ui.set_up_attachments);
+ load_func_dict.set("muted-topics", settings_muting.set_up);
// org
- load_func_dict.set('org_misc', settings_org.set_up);
- load_func_dict.set('org_bots', settings_users.set_up_bots);
- load_func_dict.set('org_users', settings_users.set_up_humans);
- load_func_dict.set('emoji-settings', settings_emoji.set_up);
- load_func_dict.set('default-streams-list', settings_streams.set_up);
- load_func_dict.set('filter-settings', settings_linkifiers.set_up);
- load_func_dict.set('invites-list-admin', settings_invites.set_up);
- load_func_dict.set('user-groups-admin', settings_user_groups.set_up);
- load_func_dict.set('profile-field-settings', settings_profile_fields.set_up);
- load_func_dict.set('data-exports-admin', settings_exports.set_up);
+ load_func_dict.set("org_misc", settings_org.set_up);
+ load_func_dict.set("org_bots", settings_users.set_up_bots);
+ load_func_dict.set("org_users", settings_users.set_up_humans);
+ load_func_dict.set("emoji-settings", settings_emoji.set_up);
+ load_func_dict.set("default-streams-list", settings_streams.set_up);
+ load_func_dict.set("filter-settings", settings_linkifiers.set_up);
+ load_func_dict.set("invites-list-admin", settings_invites.set_up);
+ load_func_dict.set("user-groups-admin", settings_user_groups.set_up);
+ load_func_dict.set("profile-field-settings", settings_profile_fields.set_up);
+ load_func_dict.set("data-exports-admin", settings_exports.set_up);
};
exports.load_settings_section = function (section) {
const group = exports.get_group(section);
if (!load_func_dict.has(group)) {
- blueslip.error('Unknown section ' + section);
+ blueslip.error("Unknown section " + section);
return;
}
diff --git a/static/js/settings_streams.js b/static/js/settings_streams.js
index fc771b892bf..45f23dd7eef 100644
--- a/static/js/settings_streams.js
+++ b/static/js/settings_streams.js
@@ -41,11 +41,11 @@ exports.build_default_stream_table = function () {
},
},
parent_container: $("#admin-default-streams-list").expectOne(),
- init_sort: ['alphabetic', 'name'],
- simplebar_container: $('#admin-default-streams-list .progressive-table-wrapper'),
+ init_sort: ["alphabetic", "name"],
+ simplebar_container: $("#admin-default-streams-list .progressive-table-wrapper"),
});
- loading.destroy_indicator($('#admin_page_default_streams_loading_indicator'));
+ loading.destroy_indicator($("#admin_page_default_streams_loading_indicator"));
};
exports.update_default_streams_table = function () {
@@ -64,7 +64,7 @@ function make_stream_default(stream_id) {
default_stream_status.hide();
channel.post({
- url: '/json/default_streams',
+ url: "/json/default_streams",
data: data,
error: function (xhr) {
if (xhr.status.toString().charAt(0) === "4") {
@@ -99,7 +99,7 @@ exports.build_page = function () {
exports.update_default_streams_table();
- $('.create_default_stream').keypress((e) => {
+ $(".create_default_stream").keypress((e) => {
if (e.which === 13) {
e.preventDefault();
e.stopPropagation();
@@ -109,7 +109,7 @@ exports.build_page = function () {
}
});
- $('.create_default_stream').typeahead({
+ $(".create_default_stream").typeahead({
items: 5,
fixed: true,
source: function () {
diff --git a/static/js/settings_user_groups.js b/static/js/settings_user_groups.js
index 7e0293e3662..d81e97a4b82 100644
--- a/static/js/settings_user_groups.js
+++ b/static/js/settings_user_groups.js
@@ -1,5 +1,5 @@
-const render_admin_user_group_list = require('../templates/admin_user_group_list.hbs');
-const render_confirm_delete_user = require('../templates/confirm_delete_user.hbs');
+const render_admin_user_group_list = require("../templates/admin_user_group_list.hbs");
+const render_confirm_delete_user = require("../templates/confirm_delete_user.hbs");
const meta = {
loaded: false,
@@ -14,8 +14,8 @@ exports.reload = function () {
return;
}
- const user_groups_section = $('#user-groups').expectOne();
- user_groups_section.html('');
+ const user_groups_section = $("#user-groups").expectOne();
+ user_groups_section.html("");
exports.populate_user_groups();
};
@@ -38,7 +38,7 @@ exports.can_edit = function (group_id) {
};
exports.populate_user_groups = function () {
- const user_groups_section = $('#user-groups').expectOne();
+ const user_groups_section = $("#user-groups").expectOne();
const user_groups_array = user_groups.get_realm_user_groups();
for (const data of user_groups_array) {
@@ -66,20 +66,20 @@ exports.populate_user_groups = function () {
if (exports.can_edit(group_id)) {
return;
}
- userg.find('.name').attr('contenteditable', 'false');
- userg.find('.description').attr('contenteditable', 'false');
- userg.addClass('ntm');
- pill_container.find('.input').attr('contenteditable', 'false');
- pill_container.find('.input').css('display', 'none');
- pill_container.addClass('not-editable');
- pill_container.off('keydown', '.pill');
- pill_container.off('keydown', '.input');
- pill_container.off('click');
- pill_container.on('click', (e) => {
+ userg.find(".name").attr("contenteditable", "false");
+ userg.find(".description").attr("contenteditable", "false");
+ userg.addClass("ntm");
+ pill_container.find(".input").attr("contenteditable", "false");
+ pill_container.find(".input").css("display", "none");
+ pill_container.addClass("not-editable");
+ pill_container.off("keydown", ".pill");
+ pill_container.off("keydown", ".input");
+ pill_container.off("click");
+ 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,11 +89,11 @@ 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 user_group_status = $('#user-groups #' + data.id + ' .user-group-status');
+ 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')) {
+ if (user_group_status.is(":visible")) {
return false;
}
@@ -108,30 +108,30 @@ exports.populate_user_groups = function () {
if (!exports.can_edit(data.id)) {
return;
}
- const cancel_button = $('#user-groups #' + data.id + ' .save-status.btn-danger');
- const saved_button = $('#user-groups #' + data.id + ' .save-status.sea-green');
- const save_instructions = $('#user-groups #' + data.id + ' .save-instructions');
+ const cancel_button = $("#user-groups #" + data.id + " .save-status.btn-danger");
+ 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')) {
+ !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);
+ 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')) {
+ cancel_button.is(":visible")) {
cancel_button.fadeOut();
save_instructions.fadeOut();
}
}
function show_saved_button() {
- const cancel_button = $('#user-groups #' + data.id + ' .save-status.btn-danger');
- const saved_button = $('#user-groups #' + data.id + ' .save-status.sea-green');
- const save_instructions = $('#user-groups #' + data.id + ' .save-instructions');
- if (!saved_button.is(':visible')) {
+ const cancel_button = $("#user-groups #" + data.id + " .save-status.btn-danger");
+ const saved_button = $("#user-groups #" + data.id + " .save-status.sea-green");
+ const save_instructions = $("#user-groups #" + data.id + " .save-instructions");
+ 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);
}
}
@@ -146,7 +146,7 @@ exports.populate_user_groups = function () {
const added = _.difference(draft_group, original_group);
const removed = _.difference(original_group, draft_group);
channel.post({
- url: "/json/user_groups/" + data.id + '/members',
+ url: "/json/user_groups/" + data.id + "/members",
data: {
add: JSON.stringify(added),
delete: JSON.stringify(removed),
@@ -158,10 +158,10 @@ exports.populate_user_groups = function () {
}
function save_name_desc() {
- const user_group_status = $('#user-groups #' + data.id + ' .user-group-status');
+ 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;
@@ -182,8 +182,8 @@ exports.populate_user_groups = function () {
xhr.responseText = JSON.stringify({msg: errors});
ui_report.error(i18n.t("Failed"), xhr, user_group_status);
update_cancel_button();
- $('#user-groups #' + data.id + ' .name').text(group_data.name);
- $('#user-groups #' + data.id + ' .description').text(group_data.description);
+ $("#user-groups #" + data.id + " .name").text(group_data.name);
+ $("#user-groups #" + data.id + " .description").text(group_data.description);
},
});
}
@@ -196,7 +196,7 @@ exports.populate_user_groups = function () {
const blur_exceptions = _.without([".pill-container", ".name", ".description", ".input", ".delete"],
except_class);
- if ($(event.relatedTarget).closest('#user-groups #' + data.id).length) {
+ if ($(event.relatedTarget).closest("#user-groups #" + data.id).length) {
return blur_exceptions.some(
(class_name) => $(event.relatedTarget).closest(class_name).length,
);
@@ -212,8 +212,8 @@ 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;
}
@@ -221,25 +221,25 @@ exports.populate_user_groups = function () {
save_members();
}
- $('#user-groups #' + data.id).on('blur', '.input', (event) => {
- auto_save('.input', event);
+ $("#user-groups #" + data.id).on("blur", ".input", (event) => {
+ auto_save(".input", event);
});
- $('#user-groups #' + data.id).on('blur', '.name', (event) => {
- auto_save('.name', event);
+ $("#user-groups #" + data.id).on("blur", ".name", (event) => {
+ auto_save(".name", event);
});
- $('#user-groups #' + data.id).on('input', '.name', () => {
+ $("#user-groups #" + data.id).on("input", ".name", () => {
update_cancel_button();
});
- $('#user-groups #' + data.id).on('blur', '.description', (event) => {
- auto_save('.description', event);
+ $("#user-groups #" + data.id).on("blur", ".description", (event) => {
+ auto_save(".description", event);
});
- $('#user-groups #' + data.id).on('input', '.description', () => {
+ $("#user-groups #" + data.id).on("input", ".description", () => {
update_cancel_button();
});
- const input = pill_container.children('.input');
+ const input = pill_container.children(".input");
if (exports.can_edit(data.id)) {
user_pill.set_up_typeahead_on_pills(input, pills, update_cancel_button);
}
@@ -268,7 +268,7 @@ exports.set_up = function () {
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()]),
@@ -298,8 +298,8 @@ exports.set_up = function () {
});
});
- $('#user-groups').on('click', '.delete', function () {
- const group_id = parseInt($(this).parents('.user-group').attr('id'), 10);
+ $("#user-groups").on("click", ".delete", function () {
+ const group_id = parseInt($(this).parents(".user-group").attr("id"), 10);
if (!exports.can_edit(group_id)) {
return;
}
@@ -323,7 +323,7 @@ exports.set_up = function () {
}
// This is mostly important for styling concerns.
- const modal_parent = $('#settings_content');
+ const modal_parent = $("#settings_content");
const html_body = render_confirm_delete_user({
group_name: user_group.name,
@@ -331,14 +331,14 @@ exports.set_up = function () {
confirm_dialog.launch({
parent: modal_parent,
- html_heading: i18n.t('Delete user group'),
+ html_heading: i18n.t("Delete user group"),
html_body: html_body,
- html_yes_button: i18n.t('Delete'),
+ html_yes_button: i18n.t("Delete"),
on_click: delete_user_group,
});
});
- $('#user-groups').on('keypress', '.user-group h4 > span', (e) => {
+ $("#user-groups").on("keypress", ".user-group h4 > span", (e) => {
if (e.which === 13) {
e.preventDefault();
}
diff --git a/static/js/settings_users.js b/static/js/settings_users.js
index 023230729df..1f3ab98e8c8 100644
--- a/static/js/settings_users.js
+++ b/static/js/settings_users.js
@@ -1,8 +1,8 @@
const settings_data = require("./settings_data");
const settings_config = require("./settings_config");
const render_admin_user_list = require("../templates/admin_user_list.hbs");
-const render_admin_human_form = require('../templates/admin_human_form.hbs');
-const render_admin_bot_form = require('../templates/admin_bot_form.hbs');
+const render_admin_human_form = require("../templates/admin_human_form.hbs");
+const render_admin_bot_form = require("../templates/admin_bot_form.hbs");
const section = {
active: {},
@@ -20,8 +20,8 @@ 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) || '';
+ 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(),
@@ -30,7 +30,7 @@ function sort_email(a, b) {
function sort_bot_email(a, b) {
function email(bot) {
- return (bot.display_email || '').toLowerCase();
+ return (bot.display_email || "").toLowerCase();
}
return compare_a_b(email(a), email(b));
@@ -47,7 +47,7 @@ function sort_role(a, b) {
function sort_bot_owner(a, b) {
function owner_name(bot) {
- return (bot.bot_owner_full_name || '').toLowerCase();
+ return (bot.bot_owner_full_name || "").toLowerCase();
}
return compare_a_b(
@@ -76,23 +76,23 @@ function set_user_role_dropdown(person) {
} else if (person.is_guest) {
role_value = settings_config.user_role_values.guest.code;
}
- $('#user-role-select').val(role_value);
+ $("#user-role-select").val(role_value);
}
function update_view_on_deactivate(row) {
const button = row.find("button.deactivate");
const user_role = row.find(".user_role");
button.prop("disabled", false);
- row.find('button.open-user-form').hide();
- row.find('i.deactivated-user-icon').show();
+ row.find("button.open-user-form").hide();
+ row.find("i.deactivated-user-icon").show();
button.addClass("btn-warning reactivate");
button.removeClass("deactivate btn-danger");
button.html("<i class='fa fa-user-plus' aria-hidden='true'></i>");
- button.attr('title', 'Reactivate');
+ button.attr("title", "Reactivate");
row.addClass("deactivated_user");
if (user_role) {
- const user_id = row.data('user-id');
+ 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)));
}
@@ -102,15 +102,15 @@ function update_view_on_reactivate(row) {
const button = row.find("button.reactivate");
const user_role = row.find(".user_role");
row.find("button.open-user-form").show();
- row.find('i.deactivated-user-icon').hide();
+ row.find("i.deactivated-user-icon").hide();
button.addClass("btn-danger deactivate");
button.removeClass("btn-warning reactivate");
- button.attr('title', 'Deactivate');
+ button.attr("title", "Deactivate");
button.html('<i class="fa fa-user-plus" aria-hidden="true"></i>');
row.removeClass("deactivated_user");
if (user_role) {
- const user_id = row.data('user-id');
+ const user_id = row.data("user-id");
user_role.text(people.get_user_type(user_id));
}
}
@@ -118,11 +118,11 @@ function update_view_on_reactivate(row) {
function get_status_field() {
const current_tab = settings_panel_menu.org_settings.current_tab();
switch (current_tab) {
- case 'deactivated-users-admin':
+ case "deactivated-users-admin":
return $("#deactivated-user-field-status").expectOne();
- case 'user-list-admin':
+ case "user-list-admin":
return $("#user-field-status").expectOne();
- case 'bot-list-admin':
+ case "bot-list-admin":
return $("#bot-field-status").expectOne();
default:
blueslip.fatal("Invalid admin settings page");
@@ -130,10 +130,10 @@ function get_status_field() {
}
function failed_listing_users() {
- loading.destroy_indicator($('#subs_page_loading_indicator'));
+ loading.destroy_indicator($("#subs_page_loading_indicator"));
const status = get_status_field();
const user_id = people.my_current_user_id();
- blueslip.error('Error while listing users for user_id ' + user_id, status);
+ blueslip.error("Error while listing users for user_id " + user_id, status);
}
function populate_users() {
@@ -244,7 +244,7 @@ function human_info(person) {
let bot_list_widget;
section.bots.create_table = () => {
- loading.make_indicator($('#admin_page_bots_loading_indicator'), {text: 'Loading...'});
+ loading.make_indicator($("#admin_page_bots_loading_indicator"), {text: "Loading..."});
const $bots_table = $("#admin_bots_table");
$bots_table.hide();
const bot_user_ids = bot_data.all_user_ids();
@@ -266,15 +266,15 @@ section.bots.create_table = () => {
onupdate: reset_scrollbar($bots_table),
},
parent_container: $("#admin-bot-list").expectOne(),
- init_sort: ['alphabetic', 'full_name'],
+ init_sort: ["alphabetic", "full_name"],
sort_fields: {
email: sort_bot_email,
bot_owner: sort_bot_owner,
},
- simplebar_container: $('#admin-bot-list .progressive-table-wrapper'),
+ simplebar_container: $("#admin-bot-list .progressive-table-wrapper"),
});
- loading.destroy_indicator($('#admin_page_bots_loading_indicator'));
+ loading.destroy_indicator($("#admin_page_bots_loading_indicator"));
$bots_table.show();
};
@@ -293,16 +293,16 @@ section.active.create_table = (active_users) => {
onupdate: reset_scrollbar($users_table),
},
parent_container: $("#admin-user-list").expectOne(),
- init_sort: ['alphabetic', 'full_name'],
+ init_sort: ["alphabetic", "full_name"],
sort_fields: {
email: sort_email,
last_active: sort_last_active,
role: sort_role,
},
- simplebar_container: $('#admin-user-list .progressive-table-wrapper'),
+ simplebar_container: $("#admin-user-list .progressive-table-wrapper"),
});
- loading.destroy_indicator($('#admin_page_users_loading_indicator'));
+ loading.destroy_indicator($("#admin_page_users_loading_indicator"));
$("#admin_users_table").show();
};
@@ -321,15 +321,15 @@ section.deactivated.create_table = (deactivated_users) => {
onupdate: reset_scrollbar($deactivated_users_table),
},
parent_container: $("#admin-deactivated-users-list").expectOne(),
- init_sort: ['alphabetic', 'full_name'],
+ init_sort: ["alphabetic", "full_name"],
sort_fields: {
email: sort_email,
role: sort_role,
},
- simplebar_container: $('#admin-deactivated-users-list .progressive-table-wrapper'),
+ simplebar_container: $("#admin-deactivated-users-list .progressive-table-wrapper"),
});
- loading.destroy_indicator($('#admin_page_deactivated_users_loading_indicator'));
+ loading.destroy_indicator($("#admin_page_deactivated_users_loading_indicator"));
$("#admin_deactivated_users_table").show();
};
@@ -369,8 +369,8 @@ 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_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();
@@ -388,12 +388,12 @@ function open_human_form(person) {
disable_role_dropdown: person.is_owner && !page_params.is_owner,
});
const div = $(html);
- const modal_container = $('#user-info-form-modal-container');
+ const modal_container = $("#user-info-form-modal-container");
modal_container.empty().append(div);
- overlays.open_modal('#admin-human-form');
+ 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";
@@ -453,9 +453,9 @@ function open_bot_form(person) {
full_name: person.full_name,
});
const div = $(html);
- const modal_container = $('#user-info-form-modal-container');
+ const modal_container = $("#user-info-form-modal-container");
modal_container.empty().append(div);
- overlays.open_modal('#admin-bot-form');
+ overlays.open_modal("#admin-bot-form");
// NOTE: building `owner_dropdown` is quite expensive!
const owner_id = bot_data.get(person.user_id).owner_id;
@@ -466,7 +466,7 @@ function open_bot_form(person) {
value: user_id.toString(),
}));
const opts = {
- widget_name: 'edit_bot_owner',
+ widget_name: "edit_bot_owner",
data: users_list,
default_text: i18n.t("No owner"),
value: owner_id,
@@ -502,15 +502,15 @@ function confirm_deactivation(row, user_id, status_field) {
row_deactivate_button.text(i18n.t("Deactivate"));
},
};
- const url = '/json/users/' + encodeURIComponent(user_id);
+ const url = "/json/users/" + encodeURIComponent(user_id);
settings_ui.do_settings_change(channel.del, url, {}, status_field, opts);
}
modal_elem.modal("hide");
- modal_elem.off('click', '.do_deactivate_button');
+ modal_elem.off("click", ".do_deactivate_button");
set_fields();
- modal_elem.on('click', '.do_deactivate_button', handle_confirm);
+ modal_elem.on("click", ".do_deactivate_button", handle_confirm);
modal_elem.modal("show");
}
@@ -522,7 +522,7 @@ function handle_deactivation(tbody, status_field) {
e.stopPropagation();
const row = $(e.target).closest(".user_row");
- const user_id = row.data('user-id');
+ const user_id = row.data("user-id");
confirm_deactivation(row, user_id, status_field);
});
}
@@ -535,7 +535,7 @@ function handle_bot_deactivation(tbody, status_field) {
const button_elem = $(e.target);
const row = button_elem.closest(".user_row");
const bot_id = parseInt(row.attr("data-user-id"), 10);
- const url = '/json/bots/' + encodeURIComponent(bot_id);
+ const url = "/json/bots/" + encodeURIComponent(bot_id);
const opts = {
success_continuation: function () {
@@ -558,7 +558,7 @@ function handle_reactivation(tbody, status_field) {
const button_elem = $(e.target);
const row = button_elem.closest(".user_row");
const user_id = parseInt(row.attr("data-user-id"), 10);
- const url = '/json/users/' + encodeURIComponent(user_id) + "/reactivate";
+ const url = "/json/users/" + encodeURIComponent(user_id) + "/reactivate";
const data = {};
const opts = {
@@ -575,8 +575,8 @@ function handle_reactivation(tbody, status_field) {
}
function handle_bot_owner_profile(tbody) {
- tbody.on('click', '.user_row .view_user_profile', (e) => {
- const owner_id = parseInt($(e.target).attr('data-owner-id'), 10);
+ tbody.on("click", ".user_row .view_user_profile", (e) => {
+ const owner_id = parseInt($(e.target).attr("data-owner-id"), 10);
const owner = people.get_by_user_id(owner_id);
popovers.show_user_profile(owner);
e.stopPropagation();
@@ -599,11 +599,11 @@ function handle_human_form(tbody, status_field) {
const modal = ret.modal;
const fields_user_pills = ret.fields_user_pills;
- modal.find('.submit_human_change').on("click", (e) => {
+ modal.find(".submit_human_change").on("click", (e) => {
e.preventDefault();
e.stopPropagation();
- const role = parseInt(modal.find('#user-role-select').val().trim(), 10);
+ const role = parseInt(modal.find("#user-role-select").val().trim(), 10);
const full_name = modal.find("input[name='full_name']");
const profile_data = get_human_profile_data(fields_user_pills);
@@ -615,7 +615,7 @@ function handle_human_form(tbody, status_field) {
};
settings_ui.do_settings_change(channel.patch, url, data, status_field);
- overlays.close_modal('#admin-human-form');
+ overlays.close_modal("#admin-human-form");
});
});
}
@@ -633,7 +633,7 @@ function handle_bot_form(tbody, status_field) {
const {modal, owner_widget} = open_bot_form(bot);
- modal.find('.submit_bot_change').on("click", (e) => {
+ modal.find(".submit_bot_change").on("click", (e) => {
e.preventDefault();
e.stopPropagation();
@@ -650,14 +650,14 @@ function handle_bot_form(tbody, status_field) {
}
settings_ui.do_settings_change(channel.patch, url, data, status_field);
- overlays.close_modal('#admin-bot-form');
+ overlays.close_modal("#admin-bot-form");
});
});
}
section.active.handle_events = () => {
- const tbody = $('#admin_users_table').expectOne();
- const status_field = $('#user-field-status').expectOne();
+ const tbody = $("#admin_users_table").expectOne();
+ const status_field = $("#user-field-status").expectOne();
handle_deactivation(tbody, status_field);
handle_reactivation(tbody, status_field);
@@ -665,7 +665,7 @@ section.active.handle_events = () => {
};
section.deactivated.handle_events = () => {
- const tbody = $('#admin_deactivated_users_table').expectOne();
+ const tbody = $("#admin_deactivated_users_table").expectOne();
const status_field = $("#deactivated-user-field-status").expectOne();
handle_deactivation(tbody, status_field);
@@ -674,7 +674,7 @@ section.deactivated.handle_events = () => {
};
section.bots.handle_events = () => {
- const tbody = $('#admin_bots_table').expectOne();
+ const tbody = $("#admin_bots_table").expectOne();
const status_field = $("#bot-field-status").expectOne();
handle_bot_owner_profile(tbody);
diff --git a/static/js/setup.js b/static/js/setup.js
index 0dd6c94fc1e..2f33c2a252a 100644
--- a/static/js/setup.js
+++ b/static/js/setup.js
@@ -12,7 +12,7 @@ $(() => {
// 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
@@ -38,7 +38,7 @@ $(() => {
}
});
- if (typeof $ !== 'undefined') {
+ if (typeof $ !== "undefined") {
$.fn.expectOne = function () {
if (blueslip && this.length !== 1) {
blueslip.error("Expected one element in jQuery set, " + this.length + " found");
diff --git a/static/js/spoilers.js b/static/js/spoilers.js
index 1971fb29e70..c485a435dae 100644
--- a/static/js/spoilers.js
+++ b/static/js/spoilers.js
@@ -4,7 +4,7 @@ function collapse_spoiler(spoiler) {
// Set height to rendered height on next frame, then to zero on following
// frame to allow CSS transition animation to work
requestAnimationFrame(() => {
- spoiler.height(spoiler_height + 'px');
+ spoiler.height(spoiler_height + "px");
spoiler.removeClass("spoiler-content-open");
requestAnimationFrame(() => {
@@ -19,14 +19,14 @@ function expand_spoiler(spoiler) {
// of the content). CSS animations do not work with properties set to
// `auto`, so we get the actual height of the content here and temporarily
// put it explicitly on the element styling to allow the transition to work.
- const spoiler_height = spoiler.prop('scrollHeight');
+ const spoiler_height = spoiler.prop("scrollHeight");
spoiler.height(spoiler_height + "px");
// The `spoiler-content-open` class has CSS animations defined on it which
// will trigger on the frame after this class change.
spoiler.addClass("spoiler-content-open");
- spoiler.on('transitionend', () => {
- spoiler.off('transitionend');
+ spoiler.on("transitionend", () => {
+ spoiler.off("transitionend");
// When the CSS transition is over, reset the height to auto
// This keeps things working if, e.g., the viewport is resized
spoiler.height("");
@@ -34,29 +34,29 @@ function expand_spoiler(spoiler) {
}
exports.hide_spoilers_in_notification = (content) => {
- content.find('.spoiler-block').each((i, elem) => {
- $(elem).find('.spoiler-content').remove();
- let text = $(elem).find('.spoiler-header').text().trim();
+ content.find(".spoiler-block").each((i, elem) => {
+ $(elem).find(".spoiler-content").remove();
+ let text = $(elem).find(".spoiler-header").text().trim();
if (text.length > 0) {
text = `${text} `;
}
text = `${text}(…)`;
- $(elem).find('.spoiler-header').text(text);
+ $(elem).find(".spoiler-header").text(text);
});
return content;
};
exports.initialize = function () {
$("body").on("click", ".spoiler-header", function (e) {
- const button = $(this).children('.spoiler-button');
- const arrow = button.children('.spoiler-arrow');
+ const button = $(this).children(".spoiler-button");
+ const arrow = button.children(".spoiler-arrow");
const spoiler_content = $(this).siblings(".spoiler-content");
const target = $(e.target);
// Spoiler headers can contain markdown, including links. We
// return so that clicking such links will be be processed by
// the browser rather than opening the header.
- if (target.closest('a').length > 0) {
+ if (target.closest("a").length > 0) {
return;
}
diff --git a/static/js/stats/stats.js b/static/js/stats/stats.js
index ad26331bd57..44ef4923d9b 100644
--- a/static/js/stats/stats.js
+++ b/static/js/stats/stats.js
@@ -1,7 +1,7 @@
const font_14pt = {
- family: 'Source Sans Pro',
+ family: "Source Sans Pro",
size: 14,
- color: '#000000',
+ color: "#000000",
};
let last_full_update = Infinity;
@@ -31,18 +31,18 @@ function floor_to_local_week(date) {
function format_date(date, include_hour) {
const months = [
- i18n.t('January'),
- i18n.t('February'),
- i18n.t('March'),
- i18n.t('April'),
- i18n.t('May'),
- i18n.t('June'),
- i18n.t('July'),
- i18n.t('August'),
- i18n.t('September'),
- i18n.t('October'),
- i18n.t('November'),
- i18n.t('December'),
+ i18n.t("January"),
+ i18n.t("February"),
+ i18n.t("March"),
+ i18n.t("April"),
+ i18n.t("May"),
+ i18n.t("June"),
+ i18n.t("July"),
+ i18n.t("August"),
+ i18n.t("September"),
+ i18n.t("October"),
+ i18n.t("November"),
+ i18n.t("December"),
];
const month_str = months[date.getMonth()];
const year = date.getFullYear();
@@ -54,7 +54,7 @@ function format_date(date, include_hour) {
return month_str + " " + day + ", " + hour % 12 + ":00" + str;
}
- return month_str + ' ' + day + ', ' + year;
+ return month_str + " " + day + ", " + year;
}
function update_last_full_update(end_times) {
@@ -64,21 +64,21 @@ 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);
- $('#id_last_full_update').closest('.last-update').show();
+ $("#id_last_full_update").text(locale_time + " on " + locale_date);
+ $("#id_last_full_update").closest(".last-update").show();
}
$(() => {
$('span[data-toggle="tooltip"]').tooltip({
animation: false,
- placement: 'top',
- trigger: 'manual',
+ placement: "top",
+ trigger: "manual",
});
- $('#id_last_update_question_sign').hover(() => {
- $('span.last_update_tooltip').tooltip('toggle');
+ $("#id_last_update_question_sign").hover(() => {
+ $("span.last_update_tooltip").tooltip("toggle");
});
// Add configuration for any additional tooltips here.
});
@@ -92,36 +92,36 @@ function populate_messages_sent_over_time(data) {
// Helper functions
function make_traces(dates, values, type, date_formatter) {
const text = dates.map((date) => date_formatter(date));
- const common = { x: dates, type: type, hoverinfo: 'none', text: text };
+ const common = { x: dates, type: type, hoverinfo: "none", text: text };
return {
human: { // 5062a0
- name: i18n.t("Humans"), y: values.human, marker: {color: '#5f6ea0'},
+ name: i18n.t("Humans"), y: values.human, marker: {color: "#5f6ea0"},
...common,
},
bot: { // a09b5f bbb56e
- name: i18n.t("Bots"), y: values.bot, marker: {color: '#b7b867'},
+ 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,
},
};
}
const layout = {
- barmode: 'group',
+ barmode: "group",
width: 750,
height: 400,
margin: { l: 40, r: 0, b: 40, t: 0 },
xaxis: {
fixedrange: true,
- rangeslider: { bordercolor: '#D8D8D8', borderwidth: 1 },
- type: 'date',
+ rangeslider: { bordercolor: "#D8D8D8", borderwidth: 1 },
+ type: "date",
},
- yaxis: { fixedrange: true, rangemode: 'tozero' },
+ 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,
};
@@ -129,40 +129,40 @@ function populate_messages_sent_over_time(data) {
function make_rangeselector(x, y, button1, button2) {
return {x: x, y: y,
buttons: [
- {stepmode: 'backward', ...button1},
- {stepmode: 'backward', ...button2},
- {step: 'all', label: 'All time'}]};
+ {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,
- {count: 10, label: i18n.t('Last 10 days'), step: 'day'},
- {count: 30, label: i18n.t('Last 30 days'), step: 'day'});
+ {count: 10, label: i18n.t("Last 10 days"), step: "day"},
+ {count: 30, label: i18n.t("Last 30 days"), step: "day"});
const weekly_rangeselector = make_rangeselector(
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: 2, label: i18n.t("Last 2 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) => {
+ document.getElementById("id_messages_sent_over_time").on("plotly_hover", (data) => {
$("#hoverinfo").show();
- document.getElementById('hover_date').innerText =
+ document.getElementById("hover_date").innerText =
data.points[0].data.text[data.points[0].pointNumber];
const values = [null, null, null];
data.points.forEach((trace) => {
values[trace.curveNumber] = trace.y;
});
- const hover_text_ids = ['hover_me', 'hover_human', 'hover_bot'];
- const hover_value_ids = ['hover_me_value', 'hover_human_value', 'hover_bot_value'];
+ const hover_text_ids = ["hover_me", "hover_human", "hover_bot"];
+ const hover_value_ids = ["hover_me_value", "hover_human_value", "hover_bot_value"];
for (let i = 0; i < values.length; i += 1) {
if (values[i] !== null) {
- document.getElementById(hover_text_ids[i]).style.display = 'inline';
- document.getElementById(hover_value_ids[i]).style.display = 'inline';
+ document.getElementById(hover_text_ids[i]).style.display = "inline";
+ document.getElementById(hover_value_ids[i]).style.display = "inline";
document.getElementById(hover_value_ids[i]).innerText = values[i];
} else {
- document.getElementById(hover_text_ids[i]).style.display = 'none';
- document.getElementById(hover_value_ids[i]).style.display = 'none';
+ document.getElementById(hover_text_ids[i]).style.display = "none";
+ document.getElementById(hover_value_ids[i]).style.display = "none";
}
}
});
@@ -176,12 +176,12 @@ function populate_messages_sent_over_time(data) {
function aggregate_data(aggregation) {
let start;
let is_boundary;
- if (aggregation === 'day') {
+ if (aggregation === "day") {
start = floor_to_local_day(start_dates[0]);
is_boundary = function (date) {
return date.getHours() === 0;
};
- } else if (aggregation === 'week') {
+ } else if (aggregation === "week") {
start = floor_to_local_week(start_dates[0]);
is_boundary = function (date) {
return date.getHours() === 0 && date.getDay() === 0;
@@ -224,19 +224,19 @@ function populate_messages_sent_over_time(data) {
};
let values = {me: data.user.human, human: data.everyone.human, bot: data.everyone.bot};
- let info = aggregate_data('day');
+ let info = aggregate_data("day");
date_formatter = function (date) {
return format_date(date, false);
};
const last_day_is_partial = info.last_value_is_partial;
- const daily_traces = make_traces(info.dates, info.values, 'bar', date_formatter);
+ const daily_traces = make_traces(info.dates, info.values, "bar", date_formatter);
- info = aggregate_data('week');
+ info = aggregate_data("week");
date_formatter = function (date) {
return i18n.t("Week of __date__", {date: format_date(date, false)});
};
const last_week_is_partial = info.last_value_is_partial;
- const weekly_traces = make_traces(info.dates, info.values, 'bar', date_formatter);
+ 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),
@@ -244,7 +244,7 @@ function populate_messages_sent_over_time(data) {
date_formatter = function (date) {
return format_date(date, true);
};
- const cumulative_traces = make_traces(dates, values, 'scatter', date_formatter);
+ const cumulative_traces = make_traces(dates, values, "scatter", date_formatter);
// Functions to draw and interact with the plot
@@ -253,45 +253,45 @@ function populate_messages_sent_over_time(data) {
let clicked_cumulative = false;
function draw_or_update_plot(rangeselector, traces, last_value_is_partial, initial_draw) {
- $('#daily_button, #weekly_button, #cumulative_button').removeClass("selected");
- $('#id_messages_sent_over_time > div').removeClass("spinner");
+ $("#daily_button, #weekly_button, #cumulative_button").removeClass("selected");
+ $("#id_messages_sent_over_time > div").removeClass("spinner");
if (initial_draw) {
traces.human.visible = true;
- traces.bot.visible = 'legendonly';
- traces.me.visible = 'legendonly';
+ traces.bot.visible = "legendonly";
+ traces.me.visible = "legendonly";
} else {
- const plotDiv = document.getElementById('id_messages_sent_over_time');
+ const plotDiv = document.getElementById("id_messages_sent_over_time");
traces.me.visible = plotDiv.data[0].visible;
traces.human.visible = plotDiv.data[1].visible;
traces.bot.visible = plotDiv.data[2].visible;
}
layout.xaxis.rangeselector = rangeselector;
if (clicked_cumulative || initial_draw) {
- Plotly.newPlot('id_messages_sent_over_time',
+ 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]);
- Plotly.addTraces('id_messages_sent_over_time', [traces.me, traces.human, traces.bot]);
- Plotly.relayout('id_messages_sent_over_time', layout);
+ Plotly.deleteTraces("id_messages_sent_over_time", [0, 1, 2]);
+ Plotly.addTraces("id_messages_sent_over_time", [traces.me, traces.human, traces.bot]);
+ Plotly.relayout("id_messages_sent_over_time", layout);
}
- $('#id_messages_sent_over_time').attr('last_value_is_partial', last_value_is_partial);
+ $("#id_messages_sent_over_time").attr("last_value_is_partial", last_value_is_partial);
}
// Click handlers for aggregation buttons
- $('#daily_button').click(function () {
+ $("#daily_button").click(function () {
draw_or_update_plot(daily_rangeselector, daily_traces, last_day_is_partial, false);
$(this).addClass("selected");
clicked_cumulative = false;
});
- $('#weekly_button').click(function () {
+ $("#weekly_button").click(function () {
draw_or_update_plot(weekly_rangeselector, weekly_traces, last_week_is_partial, false);
$(this).addClass("selected");
clicked_cumulative = false;
});
- $('#cumulative_button').click(function () {
+ $("#cumulative_button").click(function () {
clicked_cumulative = false;
draw_or_update_plot(daily_rangeselector, cumulative_traces, false, false);
$(this).addClass("selected");
@@ -301,20 +301,20 @@ function populate_messages_sent_over_time(data) {
// Initial drawing of plot
if (weekly_traces.human.x.length < 12) {
draw_or_update_plot(daily_rangeselector, daily_traces, last_day_is_partial, true);
- $('#daily_button').addClass("selected");
+ $("#daily_button").addClass("selected");
} else {
draw_or_update_plot(weekly_rangeselector, weekly_traces, last_week_is_partial, true);
- $('#weekly_button').addClass("selected");
+ $("#weekly_button").addClass("selected");
}
}
function round_to_percentages(values, total) {
return values.map((x) => {
if (x === total) {
- return '100%';
+ return "100%";
}
if (x === 0) {
- return '0%';
+ return "0%";
}
const unrounded = x / total * 100;
@@ -326,7 +326,7 @@ function round_to_percentages(values, total) {
),
);
- return unrounded.toPrecision(precision) + '%';
+ return unrounded.toPrecision(precision) + "%";
});
}
@@ -403,27 +403,27 @@ 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 {
trace: {
x: plot_data.values,
y: plot_data.labels,
- type: 'bar',
- orientation: 'h',
+ type: "bar",
+ orientation: "h",
sort: false,
textinfo: "text",
hoverinfo: "none",
- marker: { color: '#537c5e' },
- font: { family: 'Source Sans Pro', size: 18, color: '#000000' },
+ marker: { color: "#537c5e" },
+ font: { family: "Source Sans Pro", size: 18, color: "#000000" },
},
trace_annotations: {
x: annotations.values,
y: annotations.labels,
- mode: 'text',
- type: 'scatter',
- textposition: 'middle right',
+ mode: "text",
+ type: "scatter",
+ textposition: "middle right",
text: annotations.text,
},
};
@@ -444,14 +444,14 @@ function populate_messages_sent_by_client(data) {
},
};
- let user_button = 'everyone';
+ let user_button = "everyone";
let time_button;
if (data.end_times.length >= 30) {
- time_button = 'month';
- $('#messages_by_client_last_month_button').addClass("selected");
+ time_button = "month";
+ $("#messages_by_client_last_month_button").addClass("selected");
} else {
- time_button = 'cumulative';
- $('#messages_by_client_cumulative_button').addClass("selected");
+ time_button = "cumulative";
+ $("#messages_by_client_cumulative_button").addClass("selected");
}
if (data.end_times.length < 365) {
@@ -465,11 +465,11 @@ function populate_messages_sent_by_client(data) {
}
function draw_plot() {
- $('#id_messages_sent_by_client > div').removeClass("spinner");
+ $("#id_messages_sent_by_client > div").removeClass("spinner");
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',
+ Plotly.newPlot("id_messages_sent_by_client",
[data_.trace, data_.trace_annotations],
layout,
{displayModeBar: false, staticPlot: true});
@@ -501,9 +501,9 @@ function populate_messages_sent_by_client(data) {
});
// handle links with @href started with '#' only
- $(document).on('click', 'a[href^="#"]', function (e) {
+ $(document).on("click", 'a[href^="#"]', function (e) {
// target element id
- const id = $(this).attr('href');
+ const id = $(this).attr("href");
// target element
const $id = $(id);
if ($id.length === 0) {
@@ -511,8 +511,8 @@ function populate_messages_sent_by_client(data) {
}
// prevent standard hash navigation (avoid blinking in IE)
e.preventDefault();
- const pos = $id.offset().top + $('.page-content')[0].scrollTop - 50;
- $('.page-content').animate({scrollTop: pos + "px"}, 500);
+ const pos = $id.offset().top + $(".page-content")[0].scrollTop - 50;
+ $(".page-content").animate({scrollTop: pos + "px"}, 500);
});
}
@@ -532,22 +532,22 @@ function populate_messages_sent_by_message_type(data) {
);
const labels = [];
for (let i = 0; i < plot_data.labels.length; i += 1) {
- labels.push(plot_data.labels[i] + ' (' + plot_data.percentages[i] + ')');
+ labels.push(plot_data.labels[i] + " (" + plot_data.percentages[i] + ")");
}
return {
trace: {
values: plot_data.values,
labels: labels,
- type: 'pie',
- direction: 'clockwise',
+ type: "pie",
+ direction: "clockwise",
rotation: -90,
sort: false,
textinfo: "text",
- text: plot_data.labels.map(() => ''),
+ text: plot_data.labels.map(() => ""),
hoverinfo: "label+value",
pull: 0.05,
marker: {
- colors: ['#68537c', '#be6d68', '#b3b348'],
+ colors: ["#68537c", "#be6d68", "#b3b348"],
},
},
total_str: "<b>Total messages:</b> " + plot_data.total.toString().
@@ -570,16 +570,16 @@ function populate_messages_sent_by_message_type(data) {
},
};
- let user_button = 'everyone';
+ let user_button = "everyone";
let time_button;
if (data.end_times.length >= 30) {
- time_button = 'month';
- $('#messages_by_type_last_month_button').addClass("selected");
+ time_button = "month";
+ $("#messages_by_type_last_month_button").addClass("selected");
} else {
- time_button = 'cumulative';
- $('#messages_by_type_cumulative_button').addClass("selected");
+ time_button = "cumulative";
+ $("#messages_by_type_cumulative_button").addClass("selected");
}
- const totaldiv = document.getElementById('pie_messages_sent_by_type_total');
+ const totaldiv = document.getElementById("pie_messages_sent_by_type_total");
if (data.end_times.length < 365) {
$("#pie_messages_sent_by_type button[data-time='year']").remove();
@@ -592,8 +592,8 @@ 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',
+ $("#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});
@@ -633,15 +633,15 @@ function populate_number_of_users(data) {
margin: { l: 40, r: 0, b: 65, t: 20 },
xaxis: {
fixedrange: true,
- rangeslider: { bordercolor: '#D8D8D8', borderwidth: 1 },
+ rangeslider: { bordercolor: "#D8D8D8", borderwidth: 1 },
rangeselector: {
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') },
+ { 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' },
+ yaxis: { fixedrange: true, rangemode: "tozero" },
font: font_14pt,
};
@@ -655,66 +655,66 @@ function populate_number_of_users(data) {
y: values,
type: type,
name: i18n.t("Active users"),
- hoverinfo: 'none',
+ hoverinfo: "none",
text: text,
visible: true,
};
}
function add_hover_handler() {
- document.getElementById('id_number_of_users').on('plotly_hover', (data) => {
+ document.getElementById("id_number_of_users").on("plotly_hover", (data) => {
$("#users_hover_info").show();
- document.getElementById('users_hover_date').innerText =
+ document.getElementById("users_hover_date").innerText =
data.points[0].data.text[data.points[0].pointNumber];
const values = [null, null, null];
data.points.forEach((trace) => {
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';
+ document.getElementById(hover_value_ids[i]).style.display = "inline";
document.getElementById(hover_value_ids[i]).innerText = values[i];
} else {
- document.getElementById(hover_value_ids[i]).style.display = 'none';
+ document.getElementById(hover_value_ids[i]).style.display = "none";
}
}
});
}
- const _1day_trace = make_traces(data.everyone._1day, 'bar');
- const _15day_trace = make_traces(data.everyone._15day, 'scatter');
- const all_time_trace = make_traces(data.everyone.all_time, 'scatter');
+ const _1day_trace = make_traces(data.everyone._1day, "bar");
+ const _15day_trace = make_traces(data.everyone._15day, "scatter");
+ const all_time_trace = make_traces(data.everyone.all_time, "scatter");
- $('#id_number_of_users > div').removeClass("spinner");
+ $("#id_number_of_users > div").removeClass("spinner");
// 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");
- Plotly.newPlot('id_number_of_users', [trace], layout, {displayModeBar: false});
+ $("#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();
}
- $('#1day_actives_button').click(function () {
+ $("#1day_actives_button").click(function () {
draw_or_update_plot(_1day_trace);
$(this).addClass("selected");
});
- $('#15day_actives_button').click(function () {
+ $("#15day_actives_button").click(function () {
draw_or_update_plot(_15day_trace);
$(this).addClass("selected");
});
- $('#all_time_actives_button').click(function () {
+ $("#all_time_actives_button").click(function () {
draw_or_update_plot(all_time_trace);
$(this).addClass("selected");
});
// Initial drawing of plot
draw_or_update_plot(all_time_trace, true);
- $('#all_time_actives_button').addClass("selected");
+ $("#all_time_actives_button").addClass("selected");
}
function populate_messages_read_over_time(data) {
@@ -726,32 +726,32 @@ function populate_messages_read_over_time(data) {
// Helper functions
function make_traces(dates, values, type, date_formatter) {
const text = dates.map((date) => date_formatter(date));
- const common = { x: dates, type: type, hoverinfo: 'none', text: text };
+ 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,
},
};
}
const layout = {
- barmode: 'group',
+ barmode: "group",
width: 750,
height: 400,
margin: { l: 40, r: 0, b: 40, t: 0 },
xaxis: {
fixedrange: true,
- rangeslider: { bordercolor: '#D8D8D8', borderwidth: 1 },
- type: 'date',
+ rangeslider: { bordercolor: "#D8D8D8", borderwidth: 1 },
+ type: "date",
},
- yaxis: { fixedrange: true, rangemode: 'tozero' },
+ 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,
};
@@ -759,40 +759,40 @@ function populate_messages_read_over_time(data) {
function make_rangeselector(x, y, button1, button2) {
return {x: x, y: y,
buttons: [
- {stepmode: 'backward', ...button1},
- {stepmode: 'backward', ...button2},
- {step: 'all', label: 'All time'}]};
+ {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,
- {count: 10, label: i18n.t('Last 10 days'), step: 'day'},
- {count: 30, label: i18n.t('Last 30 days'), step: 'day'});
+ {count: 10, label: i18n.t("Last 10 days"), step: "day"},
+ {count: 30, label: i18n.t("Last 30 days"), step: "day"});
const weekly_rangeselector = make_rangeselector(
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: 2, label: i18n.t("Last 2 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) => {
+ document.getElementById("id_messages_read_over_time").on("plotly_hover", (data) => {
$("#read_hover_info").show();
- document.getElementById('read_hover_date').innerText =
+ document.getElementById("read_hover_date").innerText =
data.points[0].data.text[data.points[0].pointNumber];
const values = [null, null];
data.points.forEach((trace) => {
values[trace.curveNumber] = trace.y;
});
- const read_hover_text_ids = ['read_hover_me', 'read_hover_everyone'];
- const read_hover_value_ids = ['read_hover_me_value', 'read_hover_everyone_value'];
+ const read_hover_text_ids = ["read_hover_me", "read_hover_everyone"];
+ const read_hover_value_ids = ["read_hover_me_value", "read_hover_everyone_value"];
for (let i = 0; i < values.length; i += 1) {
if (values[i] !== null) {
- document.getElementById(read_hover_text_ids[i]).style.display = 'inline';
- document.getElementById(read_hover_value_ids[i]).style.display = 'inline';
+ document.getElementById(read_hover_text_ids[i]).style.display = "inline";
+ document.getElementById(read_hover_value_ids[i]).style.display = "inline";
document.getElementById(read_hover_value_ids[i]).innerText = values[i];
} else {
- document.getElementById(read_hover_text_ids[i]).style.display = 'none';
- document.getElementById(read_hover_value_ids[i]).style.display = 'none';
+ document.getElementById(read_hover_text_ids[i]).style.display = "none";
+ document.getElementById(read_hover_value_ids[i]).style.display = "none";
}
}
});
@@ -806,12 +806,12 @@ function populate_messages_read_over_time(data) {
function aggregate_data(aggregation) {
let start;
let is_boundary;
- if (aggregation === 'day') {
+ if (aggregation === "day") {
start = floor_to_local_day(start_dates[0]);
is_boundary = function (date) {
return date.getHours() === 0;
};
- } else if (aggregation === 'week') {
+ } else if (aggregation === "week") {
start = floor_to_local_week(start_dates[0]);
is_boundary = function (date) {
return date.getHours() === 0 && date.getDay() === 0;
@@ -850,19 +850,19 @@ function populate_messages_read_over_time(data) {
};
let values = {me: data.user.read, everyone: data.everyone.read};
- let info = aggregate_data('day');
+ let info = aggregate_data("day");
date_formatter = function (date) {
return format_date(date, false);
};
const last_day_is_partial = info.last_value_is_partial;
- const daily_traces = make_traces(info.dates, info.values, 'bar', date_formatter);
+ const daily_traces = make_traces(info.dates, info.values, "bar", date_formatter);
- info = aggregate_data('week');
+ info = aggregate_data("week");
date_formatter = function (date) {
return i18n.t("Week of __date__", {date: format_date(date, false)});
};
const last_week_is_partial = info.last_value_is_partial;
- const weekly_traces = make_traces(info.dates, info.values, 'bar', date_formatter);
+ 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),
@@ -870,7 +870,7 @@ function populate_messages_read_over_time(data) {
date_formatter = function (date) {
return format_date(date, true);
};
- const cumulative_traces = make_traces(dates, values, 'scatter', date_formatter);
+ const cumulative_traces = make_traces(dates, values, "scatter", date_formatter);
// Functions to draw and interact with the plot
@@ -879,43 +879,43 @@ 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");
- $('#id_messages_read_over_time > div').removeClass("spinner");
+ $("#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;
- traces.me.visible = 'legendonly';
+ traces.me.visible = "legendonly";
} else {
- const plotDiv = document.getElementById('id_messages_read_over_time');
+ const plotDiv = document.getElementById("id_messages_read_over_time");
traces.me.visible = plotDiv.data[0].visible;
traces.everyone.visible = plotDiv.data[1].visible;
}
layout.xaxis.rangeselector = rangeselector;
if (clicked_cumulative || initial_draw) {
- Plotly.newPlot('id_messages_read_over_time',
+ 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]);
- Plotly.addTraces('id_messages_read_over_time', [traces.me, traces.everyone]);
- Plotly.relayout('id_messages_read_over_time', layout);
+ Plotly.deleteTraces("id_messages_read_over_time", [0, 1]);
+ Plotly.addTraces("id_messages_read_over_time", [traces.me, traces.everyone]);
+ Plotly.relayout("id_messages_read_over_time", layout);
}
- $('#id_messages_read_over_time').attr('last_value_is_partial', last_value_is_partial);
+ $("#id_messages_read_over_time").attr("last_value_is_partial", last_value_is_partial);
}
// Click handlers for aggregation buttons
- $('#read_daily_button').click(function () {
+ $("#read_daily_button").click(function () {
draw_or_update_plot(daily_rangeselector, daily_traces, last_day_is_partial, false);
$(this).addClass("selected");
clicked_cumulative = false;
});
- $('#read_weekly_button').click(function () {
+ $("#read_weekly_button").click(function () {
draw_or_update_plot(weekly_rangeselector, weekly_traces, last_week_is_partial, false);
$(this).addClass("selected");
clicked_cumulative = false;
});
- $('#read_cumulative_button').click(function () {
+ $("#read_cumulative_button").click(function () {
clicked_cumulative = false;
draw_or_update_plot(daily_rangeselector, cumulative_traces, false, false);
$(this).addClass("selected");
@@ -925,16 +925,16 @@ function populate_messages_read_over_time(data) {
// Initial drawing of plot
if (weekly_traces.everyone.x.length < 12) {
draw_or_update_plot(daily_rangeselector, daily_traces, last_day_is_partial, true);
- $('#read_daily_button').addClass("selected");
+ $("#read_daily_button").addClass("selected");
} else {
draw_or_update_plot(weekly_rangeselector, weekly_traces, last_week_is_partial, true);
- $('#read_weekly_button').addClass("selected");
+ $("#read_weekly_button").addClass("selected");
}
}
function get_chart_data(data, callback) {
$.get({
- url: '/json/analytics/chart_data' + page_params.data_url_suffix,
+ url: "/json/analytics/chart_data" + page_params.data_url_suffix,
data: data,
idempotent: true,
success: function (data) {
@@ -942,32 +942,32 @@ function get_chart_data(data, callback) {
update_last_full_update(data.end_times);
},
error: function (xhr) {
- $('#id_stats_errors').show().text(JSON.parse(xhr.responseText).msg);
+ $("#id_stats_errors").show().text(JSON.parse(xhr.responseText).msg);
},
});
}
get_chart_data(
- {chart_name: 'messages_sent_over_time', min_length: '10'},
+ {chart_name: "messages_sent_over_time", min_length: "10"},
populate_messages_sent_over_time,
);
get_chart_data(
- {chart_name: 'messages_sent_by_client', min_length: '10'},
+ {chart_name: "messages_sent_by_client", min_length: "10"},
populate_messages_sent_by_client,
);
get_chart_data(
- {chart_name: 'messages_sent_by_message_type', min_length: '10'},
+ {chart_name: "messages_sent_by_message_type", min_length: "10"},
populate_messages_sent_by_message_type,
);
get_chart_data(
- {chart_name: 'number_of_humans', min_length: '10'},
+ {chart_name: "number_of_humans", min_length: "10"},
populate_number_of_users,
);
get_chart_data(
- {chart_name: 'messages_read_over_time', min_length: '10'},
+ {chart_name: "messages_read_over_time", min_length: "10"},
populate_messages_read_over_time,
);
diff --git a/static/js/stream_color.js b/static/js/stream_color.js
index 976d9286971..189a739fc06 100644
--- a/static/js/stream_color.js
+++ b/static/js/stream_color.js
@@ -1,7 +1,7 @@
exports.default_color = "#c2c2c2";
// Classes which could be returned by get_color_class.
-exports.color_classes = 'dark_background';
+exports.color_classes = "dark_background";
function update_table_stream_color(table, stream_name, color) {
// This is ugly, but temporary, as the new design will make it
@@ -26,8 +26,8 @@ function update_table_stream_color(table, stream_name, color) {
}
function update_stream_sidebar_swatch_color(id, color) {
- $("#stream_sidebar_swatch_" + id).css('background-color', color);
- $("#stream_sidebar_privacy_swatch_" + id).css('color', color);
+ $("#stream_sidebar_swatch_" + id).css("background-color", color);
+ $("#stream_sidebar_privacy_swatch_" + id).css("color", color);
}
function update_historical_message_color(stream_name, color) {
@@ -38,10 +38,10 @@ function update_historical_message_color(stream_name, color) {
}
const stream_color_palette = [
- ['a47462', 'c2726a', 'e4523d', 'e7664d', 'ee7e4a', 'f4ae55'],
- ['76ce90', '53a063', '94c849', 'bfd56f', 'fae589', 'f5ce6e'],
- ['a6dcbf', 'addfe5', 'a6c7e5', '4f8de4', '95a5fd', 'b0a5fd'],
- ['c2c2c2', 'c8bebf', 'c6a8ad', 'e79ab5', 'bd86e5', '9987e1'],
+ ["a47462", "c2726a", "e4523d", "e7664d", "ee7e4a", "f4ae55"],
+ ["76ce90", "53a063", "94c849", "bfd56f", "fae589", "f5ce6e"],
+ ["a6dcbf", "addfe5", "a6c7e5", "4f8de4", "95a5fd", "b0a5fd"],
+ ["c2c2c2", "c8bebf", "c6a8ad", "e79ab5", "bd86e5", "9987e1"],
];
const subscriptions_table_colorpicker_options = {
@@ -64,7 +64,7 @@ exports.update_stream_color = function (sub, color, opts) {
sub.color = color;
const stream_id = sub.stream_id;
// The swatch in the subscription row header.
- $(".stream-row[data-stream-id='" + stream_id + "'] .icon").css('background-color', color);
+ $(".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);
@@ -77,7 +77,7 @@ exports.update_stream_color = function (sub, color, opts) {
};
function picker_do_change_color(color) {
- const stream_id = parseInt($(this).attr('stream_id'), 10);
+ const stream_id = parseInt($(this).attr("stream_id"), 10);
const hex_color = color.toHexString();
subs.set_color(stream_id, hex_color);
}
@@ -140,7 +140,7 @@ exports.get_color_class = _.memoize((color) => {
match = /^#([\da-fA-F])([\da-fA-F])([\da-fA-F])$/.exec(color);
if (!match) {
// Can't understand color.
- return '';
+ return "";
}
}
@@ -156,7 +156,7 @@ exports.get_color_class = _.memoize((color) => {
// Determine if we're past the midpoint between the
// dark and light label lightness.
- return lightness < lightness_threshold ? 'dark_background' : '';
+ return lightness < lightness_threshold ? "dark_background" : "";
});
window.stream_color = exports;
diff --git a/static/js/stream_create.js b/static/js/stream_create.js
index 441aa61b397..79c0e89d538 100644
--- a/static/js/stream_create.js
+++ b/static/js/stream_create.js
@@ -1,6 +1,6 @@
-const render_announce_stream_docs = require('../templates/announce_stream_docs.hbs');
-const render_new_stream_users = require('../templates/new_stream_users.hbs');
-const render_subscription_invites_warning_modal = require('../templates/subscription_invites_warning_modal.hbs');
+const render_announce_stream_docs = require("../templates/announce_stream_docs.hbs");
+const render_new_stream_users = require("../templates/new_stream_users.hbs");
+const render_subscription_invites_warning_modal = require("../templates/subscription_invites_warning_modal.hbs");
let created_stream;
@@ -102,27 +102,27 @@ 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();
+ $("#announce-new-stream").hide();
return;
}
// If the stream is invite only, disable the "Announce stream" option.
// Otherwise enable it.
- const announce_stream_checkbox = $('#announce-new-stream input');
- const announce_stream_label = $('#announce-new-stream');
+ const announce_stream_checkbox = $("#announce-new-stream input");
+ const announce_stream_label = $("#announce-new-stream");
let disable_it = false;
- const privacy_type = $('input:radio[name=privacy]:checked').val();
+ const privacy_type = $("input:radio[name=privacy]:checked").val();
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) {
disable_it = true;
- announce_stream_checkbox.prop('checked', false);
+ announce_stream_checkbox.prop("checked", false);
announce_stream_label.addClass("control-label-disabled");
}
- announce_stream_checkbox.prop('disabled', disable_it);
- $('#announce-new-stream').show();
+ announce_stream_checkbox.prop("disabled", disable_it);
+ $("#announce-new-stream").show();
}
function get_principals() {
@@ -141,21 +141,21 @@ function create_stream() {
// Even though we already check to make sure that while typing the user cannot enter
// 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')) {
+ if (description.includes("\n")) {
ui_report.message(i18n.t("The stream description cannot contain newline characters."),
- $(".stream_create_info"), 'alert-error');
+ $(".stream_create_info"), "alert-error");
return;
}
data.subscriptions = JSON.stringify([{name: stream_name, description: description}]);
let invite_only;
let history_public_to_subscribers;
- const privacy_setting = $('#stream_creation_form input[name=privacy]:checked').val();
+ const privacy_setting = $("#stream_creation_form input[name=privacy]:checked").val();
- if (privacy_setting === 'invite-only') {
+ if (privacy_setting === "invite-only") {
invite_only = true;
history_public_to_subscribers = false;
- } else if (privacy_setting === 'invite-only-public-history') {
+ } else if (privacy_setting === "invite-only-public-history") {
invite_only = true;
history_public_to_subscribers = true;
} else {
@@ -165,19 +165,19 @@ 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() &&
- $('#announce-new-stream input').prop('checked');
+ $("#announce-new-stream input").prop("checked");
data.announce = JSON.stringify(announce);
// TODO: We can eliminate the user_ids -> principals conversion
@@ -185,7 +185,7 @@ function create_stream() {
const user_ids = get_principals();
data.principals = JSON.stringify(user_ids);
- loading.make_indicator($('#stream_creating_indicator'), {text: i18n.t('Creating stream...')});
+ loading.make_indicator($("#stream_creating_indicator"), {text: i18n.t("Creating stream...")});
// Subscribe yourself and possible other people to a new stream.
return channel.post({
@@ -195,12 +195,12 @@ function create_stream() {
$("#create_stream_name").val("");
$("#create_stream_description").val("");
ui_report.success(i18n.t("Stream successfully created!"), $(".stream_create_info"));
- loading.destroy_indicator($('#stream_creating_indicator'));
+ loading.destroy_indicator($("#stream_creating_indicator"));
// The rest of the work is done via the subscribe event we will get
},
error: function (xhr) {
const msg = JSON.parse(xhr.responseText).msg;
- if (msg.includes('access')) {
+ if (msg.includes("access")) {
// If we can't access the stream, we can safely assume it's
// a duplicate stream that we are not invited to.
//
@@ -214,7 +214,7 @@ function create_stream() {
}
ui_report.error(i18n.t("Error creating stream"), xhr, $(".stream_create_info"));
- loading.destroy_indicator($('#stream_creating_indicator'));
+ loading.destroy_indicator($("#stream_creating_indicator"));
},
});
}
@@ -230,8 +230,8 @@ exports.new_stream_clicked = function (stream_name) {
$("#stream_settings_title, .subscriptions-container .settings, .nothing-selected").hide();
$("#stream-creation, #add_new_stream_title").show();
- if (stream_name !== '') {
- $('#create_stream_name').val(stream_name);
+ if (stream_name !== "") {
+ $("#create_stream_name").val(stream_name);
}
exports.show_new_stream_modal();
@@ -243,7 +243,7 @@ exports.new_stream_clicked = function (stream_name) {
// is clear is that this shouldn't be touched unless you're also changing
// the mobile @media query at 700px.
if (window.innerWidth > 700) {
- $('#create_stream_name').focus();
+ $("#create_stream_name").focus();
}
};
@@ -266,37 +266,37 @@ exports.show_new_stream_modal = function () {
is_admin: page_params.is_admin,
});
- const container = $('#people_to_add');
+ const container = $("#people_to_add");
container.html(html);
exports.create_handlers_for_users(container);
// Make the options default to the same each time:
// public, "announce stream" on.
- $('#make-invite-only input:radio[value=public]').prop('checked', true);
+ $("#make-invite-only input:radio[value=public]").prop("checked", true);
$("#stream_creation_form .stream-message-retention-days-input").hide();
$("#stream_creation_form select[name=stream_message_retention_setting]").val("realm_default");
if (stream_data.realm_has_notifications_stream()) {
- $('#announce-new-stream').show();
- $('#announce-new-stream input').prop('disabled', false);
- $('#announce-new-stream input').prop('checked', true);
+ $("#announce-new-stream").show();
+ $("#announce-new-stream input").prop("disabled", false);
+ $("#announce-new-stream input").prop("checked", true);
} else {
- $('#announce-new-stream').hide();
+ $("#announce-new-stream").hide();
}
clear_error_display();
- $("#stream-checkboxes label.checkbox").on('change', function (e) {
+ $("#stream-checkboxes label.checkbox").on("change", function (e) {
const elem = $(this);
- const stream_id = parseInt(elem.attr('data-stream-id'), 10);
- const checked = elem.find('input').prop('checked');
+ const stream_id = parseInt(elem.attr("data-stream-id"), 10);
+ const checked = elem.find("input").prop("checked");
const subscriber_ids = stream_data.get_sub_by_id(stream_id).subscribers;
- $('#user-checkboxes label.checkbox').each(function () {
+ $("#user-checkboxes label.checkbox").each(function () {
const user_elem = $(this);
- const user_id = parseInt(user_elem.attr('data-user-id'), 10);
+ const user_id = parseInt(user_elem.attr("data-user-id"), 10);
if (subscriber_ids.has(user_id)) {
- user_elem.find('input').prop('checked', checked);
+ user_elem.find("input").prop("checked", checked);
}
});
@@ -306,42 +306,42 @@ exports.show_new_stream_modal = function () {
exports.create_handlers_for_users = function (container) {
// container should be $('#people_to_add')...see caller to verify
- container.on('change', '#user-checkboxes input', update_announce_stream_state);
+ container.on("change", "#user-checkboxes input", update_announce_stream_state);
// 'Check all' and 'Uncheck all' visible users
- container.on('click', '.subs_set_all_users', (e) => {
- $('#user-checkboxes .checkbox').each((idx, li) => {
+ container.on("click", ".subs_set_all_users", (e) => {
+ $("#user-checkboxes .checkbox").each((idx, li) => {
if (li.style.display !== "none") {
- $(li.firstElementChild).prop('checked', true);
+ $(li.firstElementChild).prop("checked", true);
}
});
e.preventDefault();
update_announce_stream_state();
});
- container.on('click', '.subs_unset_all_users', (e) => {
- $('#user-checkboxes .checkbox').each((idx, li) => {
+ container.on("click", ".subs_unset_all_users", (e) => {
+ $("#user-checkboxes .checkbox").each((idx, li) => {
if (li.style.display !== "none") {
// The first checkbox is the one for ourself; this is the code path for:
// `stream_subscription_error.cant_create_stream_without_susbscribing`
if (idx === 0 && !page_params.is_admin) {
return;
}
- $(li.firstElementChild).prop('checked', false);
+ $(li.firstElementChild).prop("checked", false);
}
});
e.preventDefault();
update_announce_stream_state();
});
- container.on('click', '#copy-from-stream-expand-collapse', (e) => {
- $('#stream-checkboxes').toggle();
- $("#copy-from-stream-expand-collapse .toggle").toggleClass('fa-caret-right fa-caret-down');
+ container.on("click", "#copy-from-stream-expand-collapse", (e) => {
+ $("#stream-checkboxes").toggle();
+ $("#copy-from-stream-expand-collapse .toggle").toggleClass("fa-caret-right fa-caret-down");
e.preventDefault();
});
// Search People or Streams
- container.on('input', '.add-user-list-filter', (e) => {
+ container.on("input", ".add-user-list-filter", (e) => {
const user_list = $(".add-user-list-filter");
if (user_list === 0) {
return;
@@ -352,8 +352,8 @@ exports.create_handlers_for_users = function (container) {
(function filter_user_checkboxes() {
const user_labels = $("#user-checkboxes label.add-user-label");
- if (search_term === '') {
- user_labels.css({display: 'block'});
+ if (search_term === "") {
+ user_labels.css({display: "block"});
return;
}
@@ -369,7 +369,7 @@ exports.create_handlers_for_users = function (container) {
// implementation is merely sluggish.
user_labels.each(function () {
const elem = $(this);
- const user_id = parseInt(elem.attr('data-user-id'), 10);
+ const user_id = parseInt(elem.attr("data-user-id"), 10);
const user_checked = filtered_users.has(user_id);
const display = user_checked ? "block" : "none";
elem.css({display: display});
@@ -382,9 +382,9 @@ exports.create_handlers_for_users = function (container) {
exports.set_up_handlers = function () {
- const container = $('#stream-creation').expectOne();
+ const container = $("#stream-creation").expectOne();
- container.on('change', '#make-invite-only input', update_announce_stream_state);
+ container.on("change", "#make-invite-only input", update_announce_stream_state);
container.on("submit", "#stream_creation_form", (e) => {
e.preventDefault();
@@ -412,7 +412,7 @@ exports.set_up_handlers = function () {
stream_name: stream_name,
count: principals.length,
});
- $('#stream-creation').append(invites_warning_modal);
+ $("#stream-creation").append(invites_warning_modal);
} else {
create_stream();
}
@@ -443,13 +443,13 @@ exports.set_up_handlers = function () {
}),
html: true,
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.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");
e.stopPropagation();
});
container.on("mouseout", "#announce-stream-docs", (e) => {
- $("#announce-stream-docs").popover('hide');
+ $("#announce-stream-docs").popover("hide");
e.stopPropagation();
});
diff --git a/static/js/stream_data.js b/static/js/stream_data.js
index 8c53dca8641..66b5a0f2e86 100644
--- a/static/js/stream_data.js
+++ b/static/js/stream_data.js
@@ -1,6 +1,6 @@
const util = require("./util");
-const FoldDict = require('./fold_dict').FoldDict;
-const LazySet = require('./lazy_set').LazySet;
+const FoldDict = require("./fold_dict").FoldDict;
+const LazySet = require("./lazy_set").LazySet;
const settings_config = require("./settings_config");
const BinaryDict = function (pred) {
@@ -181,7 +181,7 @@ exports.unsubscribe_myself = function (sub) {
};
exports.add_sub = function (sub) {
- if (!Object.prototype.hasOwnProperty.call(sub, 'subscribers')) {
+ if (!Object.prototype.hasOwnProperty.call(sub, "subscribers")) {
sub.subscribers = new LazySet([]);
}
@@ -232,13 +232,13 @@ exports.get_sub_by_name = function (name) {
};
exports.id_to_slug = function (stream_id) {
- let name = exports.maybe_get_stream_name(stream_id) || 'unknown';
+ let name = exports.maybe_get_stream_name(stream_id) || "unknown";
// The name part of the URL doesn't really matter, so we try to
// make it pretty.
- name = name.replace(' ', '-');
+ name = name.replace(" ", "-");
- return stream_id + '-' + name;
+ return stream_id + "-" + name;
};
exports.name_to_slug = function (name) {
@@ -250,9 +250,9 @@ exports.name_to_slug = function (name) {
// The name part of the URL doesn't really matter, so we try to
// make it pretty.
- name = name.replace(' ', '-');
+ name = name.replace(" ", "-");
- return stream_id + '-' + name;
+ return stream_id + "-" + name;
};
exports.slug_to_name = function (slug) {
@@ -307,7 +307,7 @@ exports.slug_to_name = function (slug) {
exports.delete_sub = function (stream_id) {
const sub = subs_by_stream_id.get(stream_id);
if (!sub) {
- blueslip.warn('Failed to delete stream ' + stream_id);
+ blueslip.warn("Failed to delete stream " + stream_id);
return;
}
subs_by_stream_id.delete(stream_id);
@@ -440,7 +440,7 @@ exports.update_stream_email_address = function (sub, email) {
exports.get_subscriber_count = function (stream_id) {
const sub = exports.get_sub_by_id(stream_id);
if (sub === undefined) {
- blueslip.warn('We got a get_subscriber_count count call for a non-existent stream.');
+ blueslip.warn("We got a get_subscriber_count count call for a non-existent stream.");
return;
}
if (!sub.subscribers) {
@@ -470,7 +470,7 @@ exports.receives_notifications = function (stream_id, notification_name) {
if (sub[notification_name] !== null) {
return sub[notification_name];
}
- if (notification_name === 'wildcard_mentions_notify') {
+ if (notification_name === "wildcard_mentions_notify") {
return page_params[notification_name];
}
return page_params["enable_stream_" + notification_name];
@@ -498,7 +498,7 @@ exports.update_calculated_fields = function (sub) {
sub.can_add_subscribers = !page_params.is_guest && (!sub.invite_only || sub.subscribed);
sub.is_old_stream = sub.stream_weekly_traffic !== null;
if (sub.rendered_description !== undefined) {
- sub.rendered_description = sub.rendered_description.replace('<p>', '').replace('</p>', '');
+ sub.rendered_description = sub.rendered_description.replace("<p>", "").replace("</p>", "");
}
exports.update_subscribers_count(sub);
@@ -653,7 +653,7 @@ exports.set_subscribers = function (sub, user_ids) {
exports.add_subscriber = function (stream_id, user_id) {
const sub = exports.get_sub_by_id(stream_id);
- if (typeof sub === 'undefined') {
+ if (typeof sub === "undefined") {
blueslip.warn("We got an add_subscriber call for a non-existent stream.");
return false;
}
@@ -669,7 +669,7 @@ exports.add_subscriber = function (stream_id, user_id) {
exports.remove_subscriber = function (stream_id, user_id) {
const sub = exports.get_sub_by_id(stream_id);
- if (typeof sub === 'undefined') {
+ if (typeof sub === "undefined") {
blueslip.warn("We got a remove_subscriber call for a non-existent stream " + stream_id);
return false;
}
@@ -685,7 +685,7 @@ exports.remove_subscriber = function (stream_id, user_id) {
exports.is_user_subscribed = function (stream_id, user_id) {
const sub = exports.get_sub_by_id(stream_id);
- if (typeof sub === 'undefined' || !sub.can_access_subscribers) {
+ 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.");
@@ -747,8 +747,8 @@ exports.create_sub_from_server_data = function (attrs) {
push_notifications: page_params.enable_stream_push_notifications,
email_notifications: page_params.enable_stream_email_notifications,
wildcard_mentions_notify: page_params.wildcard_mentions_notify,
- description: '',
- rendered_description: '',
+ description: "",
+ rendered_description: "",
first_message_id: attrs.first_message_id,
...attrs,
};
@@ -775,7 +775,7 @@ 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);
@@ -831,7 +831,7 @@ exports.sort_for_stream_settings = function (stream_ids, order) {
function name(stream_id) {
const sub = exports.get_sub_by_id(stream_id);
if (!sub) {
- return '';
+ return "";
}
return sub.name.toLocaleLowerCase();
}
@@ -912,7 +912,7 @@ exports.get_notifications_stream = function () {
// We reach here when the notifications stream is a private
// stream the current user is not subscribed to.
}
- return '';
+ return "";
};
exports.initialize = function (params) {
diff --git a/static/js/stream_edit.js b/static/js/stream_edit.js
index b7de6f84ac6..02e1869d797 100644
--- a/static/js/stream_edit.js
+++ b/static/js/stream_edit.js
@@ -1,7 +1,7 @@
const util = require("./util");
const render_settings_deactivation_stream_modal = require("../templates/settings/deactivation_stream_modal.hbs");
-const render_stream_member_list_entry = require('../templates/stream_member_list_entry.hbs');
-const render_subscription_settings = require('../templates/subscription_settings.hbs');
+const render_stream_member_list_entry = require("../templates/stream_member_list_entry.hbs");
+const render_subscription_settings = require("../templates/subscription_settings.hbs");
const render_subscription_stream_privacy_modal = require("../templates/subscription_stream_privacy_modal.hbs");
const settings_data = require("./settings_data");
const settings_config = require("./settings_config");
@@ -24,9 +24,9 @@ function compare_by_name(a, b) {
exports.setup_subscriptions_tab_hash = function (tab_key_value) {
if (tab_key_value === "all-streams") {
- hashchange.update_browser_history('#streams/all');
+ hashchange.update_browser_history("#streams/all");
} else if (tab_key_value === "subscribed") {
- hashchange.update_browser_history('#streams/subscribed');
+ hashchange.update_browser_history("#streams/subscribed");
} else {
blueslip.debug("Unknown tab_key_value: " + tab_key_value);
}
@@ -86,9 +86,9 @@ exports.get_display_text_for_realm_message_retention_setting = function () {
function change_stream_message_retention_days_block_display_property(value) {
if (value === "retain_for_period") {
- $('.stream-message-retention-days-input').show();
+ $(".stream-message-retention-days-input").show();
} else {
- $('.stream-message-retention-days-input').hide();
+ $(".stream-message-retention-days-input").hide();
}
}
@@ -121,13 +121,13 @@ function get_stream_id(target) {
function get_sub_for_target(target) {
const stream_id = get_stream_id(target);
if (!stream_id) {
- blueslip.error('Cannot find stream id for target');
+ blueslip.error("Cannot find stream id for target");
return;
}
const sub = stream_data.get_sub_by_id(stream_id);
if (!sub) {
- blueslip.error('get_sub_for_target() failed id lookup: ' + stream_id);
+ blueslip.error("get_sub_for_target() failed id lookup: " + stream_id);
return;
}
return sub;
@@ -173,8 +173,8 @@ 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(
+ stream_settings.find("input.description").val(sub.description);
+ stream_settings.find(".stream-description-editable").html(
util.clean_user_content_links(sub.rendered_description),
);
};
@@ -192,15 +192,15 @@ exports.invite_user_to_stream = function (user_ids, sub, success, failure) {
};
function submit_add_subscriber_form(e) {
- const settings_row = $(e.target).closest('.subscription_settings');
+ const settings_row = $(e.target).closest(".subscription_settings");
const sub = get_sub_for_target(settings_row);
if (!sub) {
- blueslip.error('.subscriber_list_add form submit fails');
+ blueslip.error(".subscriber_list_add form submit fails");
return;
}
const user_ids = user_pill.get_user_ids(exports.pill_widget);
- const stream_subscription_info_elem = $('.stream_subscription_info').expectOne();
+ 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."))
@@ -215,7 +215,7 @@ function submit_add_subscriber_form(e) {
// The rest of the work is done via the subscription -> add event we will get
} else {
stream_subscription_info_elem.text(i18n.t("User already subscribed."));
- const already_subscribed_users = Object.keys(data.already_subscribed).join(', ');
+ 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}));
}
@@ -271,7 +271,7 @@ function show_subscription_settings(sub_row) {
const sub = stream_data.get_sub_by_id(stream_id);
const sub_settings = exports.settings_for_sub(sub);
- const colorpicker = sub_settings.find('.colorpicker');
+ const colorpicker = sub_settings.find(".colorpicker");
const color = stream_data.get_color(sub.name);
stream_color.set_colorpicker_color(colorpicker, color);
stream_ui_updates.update_add_subscriptions_elements(sub);
@@ -320,10 +320,10 @@ function show_subscription_settings(sub_row) {
}
},
},
- simplebar_container: $('.subscriber_list_container'),
+ simplebar_container: $(".subscriber_list_container"),
});
- user_pill.set_up_typeahead_on_pills(sub_settings.find('.input'),
+ user_pill.set_up_typeahead_on_pills(sub_settings.find(".input"),
exports.pill_widget,
() => {},
get_users_for_subscriber_typeahead);
@@ -372,7 +372,7 @@ exports.show_settings_for = function (node) {
stream_post_policy_values: stream_data.stream_post_policy_values,
message_retention_text: exports.get_retention_policy_text_for_subscription_type(sub),
});
- ui.get_content_element($('.subscriptions .right .settings')).html(html);
+ ui.get_content_element($(".subscriptions .right .settings")).html(html);
const sub_settings = exports.settings_for_sub(sub);
@@ -386,7 +386,7 @@ exports.show_settings_for = function (node) {
function stream_is_muted_clicked(e) {
const sub = get_sub_for_target(e.target);
if (!sub) {
- blueslip.error('stream_is_muted_clicked() fails');
+ blueslip.error("stream_is_muted_clicked() fails");
return;
}
@@ -407,28 +407,28 @@ function stream_is_muted_clicked(e) {
}
exports.stream_setting_clicked = function (e) {
- if (e.currentTarget.id === 'sub_is_muted_setting') {
+ if (e.currentTarget.id === "sub_is_muted_setting") {
return;
}
const sub = get_sub_for_target(e.target);
- let checkbox = $(e.currentTarget).find('.sub_setting_control');
+ let checkbox = $(e.currentTarget).find(".sub_setting_control");
let status_element = "#stream_change_property_status" + sub.stream_id;
// sub data is being changed from the notification settings page.
if (checkbox.length === 0) {
checkbox = $(e.currentTarget);
- status_element = checkbox.closest('.subsection-parent').find('.alert-notification');
+ status_element = checkbox.closest(".subsection-parent").find(".alert-notification");
}
- const setting = checkbox.attr('name');
+ const setting = checkbox.attr("name");
if (!sub) {
- blueslip.error('undefined sub in stream_setting_clicked()');
+ blueslip.error("undefined sub in stream_setting_clicked()");
return;
}
- if (checkbox.prop('disabled')) {
+ if (checkbox.prop("disabled")) {
return false;
}
if (exports.is_notification_setting(setting) && sub[setting] === null) {
- if (setting === 'wildcard_mentions_notify') {
+ if (setting === "wildcard_mentions_notify") {
sub[setting] = page_params[setting];
} else {
sub[setting] = page_params["enable_stream_" + setting];
@@ -438,7 +438,7 @@ exports.stream_setting_clicked = function (e) {
};
exports.bulk_set_stream_property = function (sub_data, status_element) {
- const url = '/json/users/me/subscriptions/properties';
+ const url = "/json/users/me/subscriptions/properties";
const data = {subscription_data: JSON.stringify(sub_data)};
if (!status_element) {
return channel.post({
@@ -462,16 +462,16 @@ function change_stream_privacy(e) {
const stream_id = $(e.target).data("stream-id");
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 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);
let invite_only;
let history_public_to_subscribers;
- if (privacy_setting === 'invite-only') {
+ if (privacy_setting === "invite-only") {
invite_only = true;
history_public_to_subscribers = false;
- } else if (privacy_setting === 'invite-only-public-history') {
+ } else if (privacy_setting === "invite-only-public-history") {
invite_only = true;
history_public_to_subscribers = true;
} else {
@@ -489,9 +489,9 @@ function change_stream_privacy(e) {
};
if (page_params.is_owner) {
- 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);
+ 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);
}
data.message_retention_days = JSON.stringify(message_retention_days);
}
@@ -500,7 +500,7 @@ function change_stream_privacy(e) {
url: "/json/streams/" + stream_id,
data: data,
success: function () {
- overlays.close_modal('#stream_privacy_modal');
+ overlays.close_modal("#stream_privacy_modal");
$("#stream_privacy_modal").remove();
// The rest will be done by update stream event we will get.
},
@@ -512,9 +512,9 @@ function change_stream_privacy(e) {
exports.change_stream_name = function (e) {
e.preventDefault();
- const sub_settings = $(e.target).closest('.subscription_settings');
+ const sub_settings = $(e.target).closest(".subscription_settings");
const stream_id = get_stream_id(e.target);
- const new_name_box = sub_settings.find('.stream-name-editable');
+ const new_name_box = sub_settings.find(".stream-name-editable");
const new_name = $.trim(new_name_box.text());
$(".stream_change_property_info").hide();
@@ -523,7 +523,7 @@ exports.change_stream_name = function (e) {
url: "/json/streams/" + stream_id,
data: {new_name: JSON.stringify(new_name)},
success: function () {
- new_name_box.val('');
+ new_name_box.val("");
ui_report.success(i18n.t("The stream has been renamed!"), $(".stream_change_property_info"));
},
error: function (xhr) {
@@ -534,10 +534,10 @@ exports.change_stream_name = function (e) {
};
exports.set_raw_description = function (target, destination) {
- const sub_settings = $(target).closest('.subscription_settings');
+ const sub_settings = $(target).closest(".subscription_settings");
const sub = get_sub_for_target(sub_settings);
if (!sub) {
- blueslip.error('set_raw_description() fails');
+ blueslip.error("set_raw_description() fails");
return;
}
destination.text(sub.description);
@@ -546,20 +546,20 @@ exports.set_raw_description = function (target, destination) {
exports.change_stream_description = function (e) {
e.preventDefault();
- const sub_settings = $(e.target).closest('.subscription_settings');
+ const sub_settings = $(e.target).closest(".subscription_settings");
const sub = get_sub_for_target(sub_settings);
if (!sub) {
- blueslip.error('change_stream_description() fails');
+ blueslip.error("change_stream_description() fails");
return;
}
const stream_id = sub.stream_id;
- const description = sub_settings.find('.stream-description-editable').text().trim();
+ const description = sub_settings.find(".stream-description-editable").text().trim();
$(".stream_change_property_info").hide();
channel.patch({
// Description might contain unsafe characters so we must encode it first.
- url: '/json/streams/' + stream_id,
+ url: "/json/streams/" + stream_id,
data: {
description: JSON.stringify(description),
},
@@ -569,7 +569,7 @@ exports.change_stream_description = function (e) {
$(".stream_change_property_info"));
},
error: function (xhr) {
- sub_settings.find('.stream-description-editable').html(
+ 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"));
@@ -579,7 +579,7 @@ exports.change_stream_description = function (e) {
exports.delete_stream = function (stream_id, alert_element, stream_row) {
channel.del({
- url: '/json/streams/' + stream_id,
+ url: "/json/streams/" + stream_id,
error: function (xhr) {
ui_report.error(i18n.t("Failed"), xhr, alert_element);
},
@@ -629,15 +629,15 @@ exports.initialize = function () {
$("#stream_privacy_modal").remove();
$("#subscriptions_table").append(change_privacy_modal);
set_stream_message_retention_setting_dropdown(stream);
- overlays.open_modal('#stream_privacy_modal');
+ overlays.open_modal("#stream_privacy_modal");
e.preventDefault();
e.stopPropagation();
});
- $("#subscriptions_table").on('click', '#change-stream-privacy-button',
+ $("#subscriptions_table").on("click", "#change-stream-privacy-button",
change_stream_privacy);
- $("#subscriptions_table").on('click', '.close-privacy-modal', (e) => {
+ $("#subscriptions_table").on("click", ".close-privacy-modal", (e) => {
// Re-enable background mouse events when we close the modal
// via the "x" in the corner. (The other modal-close code
// paths call `overlays.close_modal`, rather than using
@@ -677,14 +677,14 @@ exports.initialize = function () {
const list_entry = $(e.target).closest("tr");
const target_user_id = parseInt(list_entry.attr("data-subscriber-id"), 10);
- const settings_row = $(e.target).closest('.subscription_settings');
+ const settings_row = $(e.target).closest(".subscription_settings");
const sub = get_sub_for_target(settings_row);
if (!sub) {
- blueslip.error('.subscriber_list_remove form submit fails');
+ blueslip.error(".subscriber_list_remove form submit fails");
return;
}
- const stream_subscription_info_elem = $('.stream_subscription_info').expectOne();
+ const stream_subscription_info_elem = $(".stream_subscription_info").expectOne();
function removal_success(data) {
if (data.removed.length > 0) {
@@ -695,8 +695,8 @@ 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() {
@@ -731,7 +731,7 @@ 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);
@@ -741,15 +741,15 @@ exports.initialize = function () {
});
$("#deactivation_stream_modal").remove();
$("#subscriptions_table").append(deactivate_stream_modal);
- overlays.open_modal('#deactivation_stream_modal');
+ overlays.open_modal("#deactivation_stream_modal");
});
$("#subscriptions_table").on("click", "#do_deactivate_stream_button", (e) => {
const stream_id = $(e.target).data("stream-id");
- overlays.close_modal('#deactivation_stream_modal');
+ 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 96db6f31975..51ae135041e 100644
--- a/static/js/stream_events.js
+++ b/static/js/stream_events.js
@@ -19,43 +19,43 @@ exports.update_property = function (stream_id, property, value, other_values) {
}
switch (property) {
- case 'color':
+ case "color":
stream_color.update_stream_color(sub, value, {update_historical: true});
break;
- case 'in_home_view':
+ case "in_home_view":
stream_muting.update_is_muted(sub, !value);
break;
- case 'desktop_notifications':
- case 'audible_notifications':
- case 'push_notifications':
- case 'email_notifications':
- case 'wildcard_mentions_notify':
+ case "desktop_notifications":
+ case "audible_notifications":
+ case "push_notifications":
+ case "email_notifications":
+ case "wildcard_mentions_notify":
update_stream_setting(sub, value, property);
settings_notifications.update_page();
break;
- case 'name':
+ case "name":
subs.update_stream_name(sub, value);
break;
- case 'description':
+ case "description":
subs.update_stream_description(sub, value, other_values.rendered_description);
break;
- case 'email_address':
+ case "email_address":
sub.email_address = value;
break;
- case 'pin_to_top':
+ case "pin_to_top":
update_stream_setting(sub, value, property);
stream_list.refresh_pinned_or_unpinned_stream(sub);
break;
- case 'invite_only':
+ case "invite_only":
subs.update_stream_privacy(sub, {
invite_only: value,
history_public_to_subscribers: other_values.history_public_to_subscribers,
});
break;
- case 'stream_post_policy':
+ case "stream_post_policy":
subs.update_stream_post_policy(sub, value);
break;
- case 'message_retention_days':
+ case "message_retention_days":
subs.update_message_retention_setting(sub, value);
break;
default:
@@ -69,7 +69,7 @@ exports.update_property = function (stream_id, property, value, other_values) {
// but for now we just pass in the subscribers and color (things likely to be different).
exports.mark_subscribed = function (sub, subscribers, color) {
if (sub === undefined) {
- blueslip.error('Undefined sub passed to mark_subscribed');
+ blueslip.error("Undefined sub passed to mark_subscribed");
return;
}
diff --git a/static/js/stream_list.js b/static/js/stream_list.js
index ec9b1b32ec9..8ece8f32d78 100644
--- a/static/js/stream_list.js
+++ b/static/js/stream_list.js
@@ -1,18 +1,18 @@
-const render_stream_privacy = require('../templates/stream_privacy.hbs');
-const render_stream_sidebar_row = require('../templates/stream_sidebar_row.hbs');
+const render_stream_privacy = require("../templates/stream_privacy.hbs");
+const render_stream_sidebar_row = require("../templates/stream_sidebar_row.hbs");
let has_scrolled = false;
exports.update_count_in_dom = function (unread_count_elem, count) {
- const count_span = unread_count_elem.find('.count');
- const value_span = count_span.find('.value');
+ const count_span = unread_count_elem.find(".count");
+ const value_span = count_span.find(".value");
if (count === 0) {
count_span.hide();
if (count_span.parent().hasClass("subscription_block")) {
count_span.parent(".subscription_block").removeClass("stream-with-count");
}
- value_span.text('');
+ value_span.text("");
return;
}
@@ -102,7 +102,7 @@ exports.build_stream_list = function () {
return;
}
- const parent = $('#stream_filters');
+ const parent = $("#stream_filters");
const elems = [];
function add_sidebar_li(stream) {
@@ -147,12 +147,12 @@ exports.get_stream_li = function (stream_id) {
const li = row.get_li();
if (!li) {
- blueslip.error('Cannot find li for id ' + stream_id);
+ blueslip.error("Cannot find li for id " + stream_id);
return;
}
if (li.length > 1) {
- blueslip.error('stream_li has too many elements for ' + stream_id);
+ blueslip.error("stream_li has too many elements for " + stream_id);
return;
}
@@ -160,7 +160,7 @@ exports.get_stream_li = function (stream_id) {
};
function stream_id_for_elt(elt) {
- return parseInt(elt.attr('data-stream-id'), 10);
+ return parseInt(elt.attr("data-stream-id"), 10);
}
exports.zoom_in_topics = function (options) {
@@ -206,7 +206,7 @@ exports.zoom_out_topics = function () {
exports.set_in_home_view = function (stream_id, in_home) {
const li = exports.get_stream_li(stream_id);
if (!li) {
- blueslip.error('passed in bad stream id ' + stream_id);
+ blueslip.error("passed in bad stream id " + stream_id);
return;
}
@@ -240,9 +240,9 @@ function build_stream_sidebar_row(sub) {
self.update_whether_active = function () {
if (stream_data.is_active(sub) || sub.pin_to_top === true) {
- list_item.removeClass('inactive_stream');
+ list_item.removeClass("inactive_stream");
} else {
- list_item.addClass('inactive_stream');
+ list_item.addClass("inactive_stream");
}
};
@@ -268,7 +268,7 @@ function build_stream_sidebar_row(sub) {
exports.create_sidebar_row = function (sub) {
if (exports.stream_sidebar.has_row_for(sub.stream_id)) {
// already exists
- blueslip.warn('Dup try to build sidebar row for stream ' + sub.stream_id);
+ blueslip.warn("Dup try to build sidebar row for stream " + sub.stream_id);
return;
}
build_stream_sidebar_row(sub);
@@ -283,7 +283,7 @@ exports.redraw_stream_privacy = function (sub) {
return;
}
- const div = li.find('.stream-privacy');
+ const div = li.find(".stream-privacy");
const dark_background = stream_color.get_color_class(sub.color);
const args = {
@@ -300,14 +300,14 @@ function set_stream_unread_count(stream_id, count) {
if (!unread_count_elem) {
// This can happen for legitimate reasons, but we warn
// just in case.
- blueslip.warn('stream id no longer in sidebar: ' + stream_id);
+ blueslip.warn("stream id no longer in sidebar: " + stream_id);
return;
}
exports.update_count_in_dom(unread_count_elem, count);
}
exports.update_streams_sidebar = function () {
- const finish = blueslip.start_timing('build_stream_list');
+ const finish = blueslip.start_timing("build_stream_list");
exports.build_stream_list();
finish();
exports.stream_cursor.redraw();
@@ -346,7 +346,7 @@ exports.refresh_pinned_or_unpinned_stream = function (sub) {
if (sub.pin_to_top) {
const stream_li = exports.get_stream_li(sub.stream_id);
if (!stream_li) {
- blueslip.error('passed in bad stream id ' + sub.stream_id);
+ blueslip.error("passed in bad stream id " + sub.stream_id);
return;
}
exports.scroll_stream_into_view(stream_li);
@@ -359,7 +359,7 @@ exports.get_sidebar_stream_topic_info = function (filter) {
topic_selected: false,
};
- const op_stream = filter.operands('stream');
+ const op_stream = filter.operands("stream");
if (op_stream.length === 0) {
return result;
}
@@ -377,14 +377,14 @@ exports.get_sidebar_stream_topic_info = function (filter) {
result.stream_id = stream_id;
- const op_topic = filter.operands('topic');
+ const op_topic = filter.operands("topic");
result.topic_selected = op_topic.length === 1;
return result;
};
function deselect_stream_items() {
- $("ul#stream_filters li").removeClass('active-filter');
+ $("ul#stream_filters li").removeClass("active-filter");
}
exports.update_stream_sidebar_for_narrow = function (filter) {
@@ -407,13 +407,13 @@ exports.update_stream_sidebar_for_narrow = function (filter) {
// corresponding to that stream in our sidebar. This error
// stopped appearing from March 2018 until at least
// April 2020, so if it appears again, something regressed.
- blueslip.error('No stream_li for subscribed stream ' + stream_id);
+ blueslip.error("No stream_li for subscribed stream " + stream_id);
topic_zoom.clear_topics();
return;
}
if (!info.topic_selected) {
- stream_li.addClass('active-filter');
+ stream_li.addClass("active-filter");
}
if (stream_id !== topic_list.active_stream_id()) {
@@ -453,12 +453,12 @@ function keydown_enter_key() {
const sub = stream_data.get_sub_by_id(stream_id);
if (sub === undefined) {
- blueslip.error('Unknown stream_id for search/enter: ' + stream_id);
+ blueslip.error("Unknown stream_id for search/enter: " + stream_id);
return;
}
exports.clear_and_hide_search();
- narrow.by('stream', sub.name, {trigger: 'sidebar enter key'});
+ narrow.by("stream", sub.name, {trigger: "sidebar enter key"});
}
function actually_update_streams_for_search() {
@@ -479,14 +479,14 @@ exports.initialize = function () {
};
exports.set_event_handlers = function () {
- $('#stream_filters').on('click', 'li .subscription_block', (e) => {
+ $("#stream_filters").on("click", "li .subscription_block", (e) => {
if (e.metaKey || e.ctrlKey) {
return;
}
- const stream_id = stream_id_for_elt($(e.target).parents('li'));
+ const stream_id = stream_id_for_elt($(e.target).parents("li"));
const sub = stream_data.get_sub_by_id(stream_id);
popovers.hide_all();
- narrow.by('stream', sub.name, {trigger: 'sidebar'});
+ narrow.by("stream", sub.name, {trigger: "sidebar"});
exports.clear_and_hide_search();
@@ -494,22 +494,22 @@ exports.set_event_handlers = function () {
e.stopPropagation();
});
- $('#clear_search_stream_button').on('click', exports.clear_search);
+ $("#clear_search_stream_button").on("click", exports.clear_search);
$("#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 () {
+ ui.get_scroll_element($("#stream-filters-container")).on("scroll", function () {
has_scrolled = true;
// remove listener once user has scrolled
- $(this).off('scroll');
+ $(this).off("scroll");
});
exports.stream_cursor = list_cursor({
list: {
- scroll_container_sel: '#stream-filters-container',
+ scroll_container_sel: "#stream-filters-container",
find_li: function (opts) {
const stream_id = opts.key;
const li = exports.get_stream_li(stream_id);
@@ -519,10 +519,10 @@ exports.set_event_handlers = function () {
prev_key: stream_sort.prev_stream_id,
next_key: stream_sort.next_stream_id,
},
- highlight_class: 'highlighted_stream',
+ highlight_class: "highlighted_stream",
});
- const $search_input = $('.stream-list-filter').expectOne();
+ const $search_input = $(".stream-list-filter").expectOne();
keydown_util.handle({
elem: $search_input,
@@ -542,51 +542,51 @@ exports.set_event_handlers = function () {
},
});
- $search_input.on('click', focus_stream_filter);
- $search_input.on('focusout', exports.stream_cursor.clear);
- $search_input.on('input', update_streams_for_search);
+ $search_input.on("click", focus_stream_filter);
+ $search_input.on("focusout", exports.stream_cursor.clear);
+ $search_input.on("input", update_streams_for_search);
};
exports.searching = function () {
- return $('.stream-list-filter').expectOne().is(':focus');
+ return $(".stream-list-filter").expectOne().is(":focus");
};
exports.escape_search = function () {
- const filter = $('.stream-list-filter').expectOne();
- if (filter.val() === '') {
+ const filter = $(".stream-list-filter").expectOne();
+ if (filter.val() === "") {
exports.clear_and_hide_search();
return;
}
- filter.val('');
+ filter.val("");
update_streams_for_search();
};
exports.clear_search = function (e) {
e.stopPropagation();
- const filter = $('.stream-list-filter').expectOne();
- if (filter.val() === '') {
+ const filter = $(".stream-list-filter").expectOne();
+ if (filter.val() === "") {
exports.clear_and_hide_search();
return;
}
- filter.val('');
+ filter.val("");
filter.blur();
update_streams_for_search();
};
exports.show_search_section = function () {
- $('.stream_search_section').expectOne().removeClass('notdisplayed');
+ $(".stream_search_section").expectOne().removeClass("notdisplayed");
resize.resize_stream_filters_container();
};
exports.hide_search_section = function () {
- $('.stream_search_section').expectOne().addClass('notdisplayed');
+ $(".stream_search_section").expectOne().addClass("notdisplayed");
resize.resize_stream_filters_container();
};
exports.initiate_search = function () {
exports.show_search_section();
- const filter = $('.stream-list-filter').expectOne();
+ const filter = $(".stream-list-filter").expectOne();
if (!$(".app-main .column-left").hasClass("expanded")) {
popovers.hide_all();
@@ -598,9 +598,9 @@ exports.initiate_search = function () {
};
exports.clear_and_hide_search = function () {
- const filter = $('.stream-list-filter');
- if (filter.val() !== '') {
- filter.val('');
+ const filter = $(".stream-list-filter");
+ if (filter.val() !== "") {
+ filter.val("");
update_streams_for_search();
}
exports.stream_cursor.clear();
@@ -610,7 +610,7 @@ exports.clear_and_hide_search = function () {
};
exports.toggle_filter_displayed = function (e) {
- if ($('.stream_search_section.notdisplayed').length === 0) {
+ if ($(".stream_search_section.notdisplayed").length === 0) {
exports.clear_and_hide_search();
} else {
exports.initiate_search();
@@ -619,10 +619,10 @@ exports.toggle_filter_displayed = function (e) {
};
exports.scroll_stream_into_view = function (stream_li) {
- const container = $('#stream-filters-container');
+ const container = $("#stream-filters-container");
if (stream_li.length !== 1) {
- blueslip.error('Invalid stream_li was passed in');
+ blueslip.error("Invalid stream_li was passed in");
return;
}
@@ -653,7 +653,7 @@ exports.get_current_stream_li = function () {
if (!stream_li) {
// This code path shouldn't ever be reached.
- blueslip.warn('No active stream_li found for defined id ' + stream_id);
+ blueslip.warn("No active stream_li found for defined id " + stream_id);
return;
}
diff --git a/static/js/stream_muting.js b/static/js/stream_muting.js
index 3e3dc99fbc0..7d60fb929f4 100644
--- a/static/js/stream_muting.js
+++ b/static/js/stream_muting.js
@@ -47,7 +47,7 @@ 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");
- is_muted_checkbox.prop('checked', value);
+ is_muted_checkbox.prop("checked", value);
};
window.stream_muting = exports;
diff --git a/static/js/stream_popover.js b/static/js/stream_popover.js
index a1ffdf84d0f..2e1b4ef0cd3 100644
--- a/static/js/stream_popover.js
+++ b/static/js/stream_popover.js
@@ -1,8 +1,8 @@
-const render_all_messages_sidebar_actions = require('../templates/all_messages_sidebar_actions.hbs');
-const render_delete_topic_modal = require('../templates/delete_topic_modal.hbs');
-const render_starred_messages_sidebar_actions = require('../templates/starred_messages_sidebar_actions.hbs');
-const render_stream_sidebar_actions = require('../templates/stream_sidebar_actions.hbs');
-const render_topic_sidebar_actions = require('../templates/topic_sidebar_actions.hbs');
+const render_all_messages_sidebar_actions = require("../templates/all_messages_sidebar_actions.hbs");
+const render_delete_topic_modal = require("../templates/delete_topic_modal.hbs");
+const render_starred_messages_sidebar_actions = require("../templates/starred_messages_sidebar_actions.hbs");
+const render_stream_sidebar_actions = require("../templates/stream_sidebar_actions.hbs");
+const render_topic_sidebar_actions = require("../templates/topic_sidebar_actions.hbs");
const render_unstar_messages_modal = require("../templates/unstar_messages_modal.hbs");
const render_move_topic_to_stream = require("../templates/move_topic_to_stream.hbs");
@@ -14,10 +14,10 @@ let all_messages_sidebar_elem;
let starred_messages_sidebar_elem;
function elem_to_stream_id(elem) {
- const stream_id = parseInt(elem.attr('data-stream-id'), 10);
+ const stream_id = parseInt(elem.attr("data-stream-id"), 10);
if (stream_id === undefined) {
- blueslip.error('could not find stream id');
+ blueslip.error("could not find stream id");
}
return stream_id;
@@ -85,11 +85,11 @@ exports.hide_streamlist_sidebar = function () {
function stream_popover_sub(e) {
- const elem = $(e.currentTarget).parents('ul');
+ const elem = $(e.currentTarget).parents("ul");
const stream_id = elem_to_stream_id(elem);
const sub = stream_data.get_sub_by_id(stream_id);
if (!sub) {
- blueslip.error('Unknown stream: ' + stream_id);
+ blueslip.error("Unknown stream: " + stream_id);
return;
}
return sub;
@@ -102,12 +102,12 @@ function stream_popover_sub(e) {
function update_spectrum(popover, update_func) {
const initial_height = popover[0].offsetHeight;
- const colorpicker = popover.find('.colorpicker-container').find('.colorpicker');
+ const colorpicker = popover.find(".colorpicker-container").find(".colorpicker");
update_func(colorpicker);
const after_height = popover[0].offsetHeight;
const popover_root = popover.closest(".popover");
- const current_top_px = parseFloat(popover_root.css('top').replace('px', ''));
+ const current_top_px = parseFloat(popover_root.css("top").replace("px", ""));
const height_delta = after_height - initial_height;
let top = current_top_px - height_delta / 2;
@@ -122,7 +122,7 @@ function update_spectrum(popover, update_func) {
popover_root.find("div.arrow").hide();
}
- popover_root.css('top', top + "px");
+ popover_root.css("top", top + "px");
}
function build_stream_popover(opts) {
@@ -152,7 +152,7 @@ function build_stream_popover(opts) {
});
$(elt).popover("show");
- const popover = $('.streams_popover[data-stream-id=' + stream_id + ']');
+ const popover = $(".streams_popover[data-stream-id=" + stream_id + "]");
update_spectrum(popover, (colorpicker) => {
colorpicker.spectrum(stream_color.sidebar_popover_colorpicker_options);
@@ -175,7 +175,7 @@ function build_topic_popover(opts) {
const sub = stream_data.get_sub_by_id(stream_id);
if (!sub) {
- blueslip.error('cannot build topic popover for stream: ' + stream_id);
+ blueslip.error("cannot build topic popover for stream: " + stream_id);
return;
}
@@ -292,16 +292,16 @@ function build_move_topic_to_stream_popover(e, current_stream_id, topic_name) {
ui_util.decorate_stream_bar(stream_name, stream_header_colorblock, false);
});
- $('#move_topic_modal').modal('show');
+ $("#move_topic_modal").modal("show");
e.stopPropagation();
}
exports.register_click_handlers = function () {
- $('#stream_filters').on('click', '.stream-sidebar-menu-icon', (e) => {
+ $("#stream_filters").on("click", ".stream-sidebar-menu-icon", (e) => {
e.stopPropagation();
const elt = e.target;
- const stream_li = $(elt).parents('li');
+ const stream_li = $(elt).parents("li");
const stream_id = elem_to_stream_id(stream_li);
build_stream_popover({
@@ -310,13 +310,13 @@ exports.register_click_handlers = function () {
});
});
- $('#stream_filters').on('click', '.topic-sidebar-menu-icon', (e) => {
+ $("#stream_filters").on("click", ".topic-sidebar-menu-icon", (e) => {
e.stopPropagation();
- const elt = $(e.target).closest('.topic-sidebar-menu-icon').expectOne()[0];
- const stream_li = $(elt).closest('.narrow-filter').expectOne();
+ const elt = $(e.target).closest(".topic-sidebar-menu-icon").expectOne()[0];
+ const stream_li = $(elt).closest(".narrow-filter").expectOne();
const stream_id = elem_to_stream_id(stream_li);
- const topic_name = $(elt).closest('li').expectOne().attr('data-topic-name');
+ const topic_name = $(elt).closest("li").expectOne().attr("data-topic-name");
build_topic_popover({
elt: elt,
@@ -325,9 +325,9 @@ exports.register_click_handlers = function () {
});
});
- $('#global_filters').on('click', '.all-messages-sidebar-menu-icon', build_all_messages_popover);
+ $("#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();
@@ -335,7 +335,7 @@ exports.register_click_handlers = function () {
exports.register_stream_handlers = function () {
// Stream settings
- $('body').on('click', '.open_stream_settings', (e) => {
+ $("body").on("click", ".open_stream_settings", (e) => {
const sub = stream_popover_sub(e);
exports.hide_stream_popover();
@@ -344,7 +344,7 @@ exports.register_stream_handlers = function () {
});
// Pin/unpin
- $('body').on('click', '.pin_to_top', (e) => {
+ $("body").on("click", ".pin_to_top", (e) => {
const sub = stream_popover_sub(e);
exports.hide_stream_popover();
subs.toggle_pin_to_top_stream(sub);
@@ -352,7 +352,7 @@ exports.register_stream_handlers = function () {
});
// Mark all messages in stream as read
- $('body').on('click', '.mark_stream_as_read', (e) => {
+ $("body").on("click", ".mark_stream_as_read", (e) => {
const sub = stream_popover_sub(e);
exports.hide_stream_popover();
unread_ops.mark_stream_as_read(sub.stream_id);
@@ -360,14 +360,14 @@ exports.register_stream_handlers = function () {
});
// Mark all messages as read
- $('body').on('click', '#mark_all_messages_as_read', (e) => {
+ $("body").on("click", "#mark_all_messages_as_read", (e) => {
exports.hide_all_messages_popover();
unread_ops.mark_all_as_read();
e.stopPropagation();
});
// Unstar all messages
- $('body').on('click', '#unstar_all_messages', (e) => {
+ $("body").on("click", "#unstar_all_messages", (e) => {
exports.hide_starred_messages_popover();
e.preventDefault();
e.stopPropagation();
@@ -376,14 +376,14 @@ exports.register_stream_handlers = function () {
$("#unstar-messages-modal").modal("show");
});
- $('body').on('click', '#do_unstar_messages_button', (e) => {
+ $("body").on("click", "#do_unstar_messages_button", (e) => {
$("#unstar-messages-modal").modal("hide");
message_flags.unstar_all_messages();
e.stopPropagation();
});
// Toggle displaying starred message count
- $('body').on('click', '#toggle_display_starred_msg_count', (e) => {
+ $("body").on("click", "#toggle_display_starred_msg_count", (e) => {
exports.hide_starred_messages_popover();
e.preventDefault();
e.stopPropagation();
@@ -391,12 +391,12 @@ exports.register_stream_handlers = function () {
const data = {};
data.starred_message_counts = JSON.stringify(!starred_msg_counts);
channel.patch({
- url: '/json/settings/display',
+ url: "/json/settings/display",
data: data,
});
});
// Mute/unmute
- $('body').on('click', '.toggle_home', (e) => {
+ $("body").on("click", ".toggle_home", (e) => {
const sub = stream_popover_sub(e);
exports.hide_stream_popover();
subs.toggle_home(sub);
@@ -404,7 +404,7 @@ exports.register_stream_handlers = function () {
});
// Unsubscribe
- $('body').on("click", ".popover_sub_unsub_button", function (e) {
+ $("body").on("click", ".popover_sub_unsub_button", function (e) {
$(this).toggleClass("unsub");
$(this).closest(".popover").fadeOut(500).delay(500).remove();
@@ -415,9 +415,9 @@ exports.register_stream_handlers = function () {
});
// Choose a different color.
- $('body').on('click', '.choose_stream_color', (e) => {
- update_spectrum($(e.target).closest('.streams_popover'), (colorpicker) => {
- $('.colorpicker-container').show();
+ $("body").on("click", ".choose_stream_color", (e) => {
+ update_spectrum($(e.target).closest(".streams_popover"), (colorpicker) => {
+ $(".colorpicker-container").show();
colorpicker.spectrum("destroy");
colorpicker.spectrum(stream_color.sidebar_popover_colorpicker_options_full);
// In theory this should clean up the old color picker,
@@ -425,11 +425,11 @@ exports.register_stream_handlers = function () {
// doesn't fire until you click a button, but the buttons
// have been hidden. We work around this by just manually
// fixing it up here.
- colorpicker.parent().find('.sp-container').removeClass('sp-buttons-disabled');
+ colorpicker.parent().find(".sp-container").removeClass("sp-buttons-disabled");
$(e.target).hide();
});
- $('.streams_popover').on('click', 'a.sp-cancel', () => {
+ $(".streams_popover").on("click", "a.sp-cancel", () => {
exports.hide_stream_popover();
});
});
@@ -439,13 +439,13 @@ exports.register_stream_handlers = function () {
function topic_popover_sub(e) {
const stream_id = topic_popover_stream_id(e);
if (!stream_id) {
- blueslip.error('cannot find stream id');
+ blueslip.error("cannot find stream id");
return;
}
const sub = stream_data.get_sub_by_id(stream_id);
if (!sub) {
- blueslip.error('Unknown stream: ' + stream_id);
+ blueslip.error("Unknown stream: " + stream_id);
return;
}
return sub;
@@ -453,7 +453,7 @@ function topic_popover_sub(e) {
exports.register_topic_handlers = function () {
// Narrow to topic
- $('body').on('click', '.narrow_to_topic', (e) => {
+ $("body").on("click", ".narrow_to_topic", (e) => {
exports.hide_topic_popover();
const sub = topic_popover_sub(e);
@@ -461,101 +461,101 @@ exports.register_topic_handlers = function () {
return;
}
- const topic = $(e.currentTarget).attr('data-topic-name');
+ const topic = $(e.currentTarget).attr("data-topic-name");
const operators = [
- {operator: 'stream', operand: sub.name},
- {operator: 'topic', operand: topic},
+ {operator: "stream", operand: sub.name},
+ {operator: "topic", operand: topic},
];
- narrow.activate(operators, {trigger: 'sidebar'});
+ narrow.activate(operators, {trigger: "sidebar"});
e.stopPropagation();
});
// Mute the topic
- $('body').on('click', '.sidebar-popover-mute-topic', (e) => {
+ $("body").on("click", ".sidebar-popover-mute-topic", (e) => {
const stream_id = topic_popover_stream_id(e);
if (!stream_id) {
return;
}
- const topic = $(e.currentTarget).attr('data-topic-name');
+ const topic = $(e.currentTarget).attr("data-topic-name");
muting_ui.mute(stream_id, topic);
e.stopPropagation();
e.preventDefault();
});
// Unmute the topic
- $('body').on('click', '.sidebar-popover-unmute-topic', (e) => {
+ $("body").on("click", ".sidebar-popover-unmute-topic", (e) => {
const stream_id = topic_popover_stream_id(e);
if (!stream_id) {
return;
}
- const topic = $(e.currentTarget).attr('data-topic-name');
+ const topic = $(e.currentTarget).attr("data-topic-name");
muting_ui.unmute(stream_id, topic);
e.stopPropagation();
e.preventDefault();
});
// Mark all messages as read
- $('body').on('click', '.sidebar-popover-mark-topic-read', (e) => {
+ $("body").on("click", ".sidebar-popover-mark-topic-read", (e) => {
const stream_id = topic_popover_stream_id(e);
if (!stream_id) {
return;
}
- const topic = $(e.currentTarget).attr('data-topic-name');
+ const topic = $(e.currentTarget).attr("data-topic-name");
exports.hide_topic_popover();
unread_ops.mark_topic_as_read(stream_id, topic);
e.stopPropagation();
});
// Deleting all message in a topic
- $('body').on('click', '.sidebar-popover-delete-topic-messages', (e) => {
+ $("body").on("click", ".sidebar-popover-delete-topic-messages", (e) => {
const stream_id = topic_popover_stream_id(e);
if (!stream_id) {
return;
}
- const topic = $(e.currentTarget).attr('data-topic-name');
+ const topic = $(e.currentTarget).attr("data-topic-name");
const args = {
topic_name: topic,
};
exports.hide_topic_popover();
- $('#delete-topic-modal-holder').html(render_delete_topic_modal(args));
+ $("#delete-topic-modal-holder").html(render_delete_topic_modal(args));
- $('#do_delete_topic_button').on('click', () => {
+ $("#do_delete_topic_button").on("click", () => {
message_edit.delete_topic(stream_id, topic);
});
- $('#delete_topic_modal').modal('show');
+ $("#delete_topic_modal").modal("show");
e.stopPropagation();
});
- $('body').on('click', '.sidebar-popover-move-topic-messages', (e) => {
+ $("body").on("click", ".sidebar-popover-move-topic-messages", (e) => {
const topic_row = $(e.currentTarget);
- const stream_id = parseInt(topic_row.attr('data-stream-id'), 10);
- const topic_name = topic_row.attr('data-topic-name');
+ const stream_id = parseInt(topic_row.attr("data-stream-id"), 10);
+ const topic_name = topic_row.attr("data-topic-name");
build_move_topic_to_stream_popover(e, stream_id, topic_name);
e.stopPropagation();
e.preventDefault();
});
- $('body').on('click', '#topic_stream_edit_form_error .send-status-close', () => {
+ $("body").on("click", "#topic_stream_edit_form_error .send-status-close", () => {
$("#topic_stream_edit_form_error").hide();
});
- $('body').on('click', '#do_move_topic_button', (e) => {
+ $("body").on("click", "#do_move_topic_button", (e) => {
function show_error_msg(msg) {
$("#topic_stream_edit_form_error .error-msg").text(msg);
$("#topic_stream_edit_form_error").show();
}
- const params = $('#move_topic_form').serializeArray().reduce((obj, item) => {
+ const params = $("#move_topic_form").serializeArray().reduce((obj, item) => {
obj[item.name] = item.value;
return obj;
}, {});
@@ -564,8 +564,8 @@ exports.register_topic_handlers = function () {
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';
+ 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) &&
@@ -589,7 +589,7 @@ exports.register_topic_handlers = function () {
// cost for a rare operation, we just ask the server for the
// latest message ID in the topic.
const data = {
- anchor: 'newest',
+ anchor: "newest",
num_before: 1,
num_after: 0,
narrow: JSON.stringify(
@@ -599,7 +599,7 @@ exports.register_topic_handlers = function () {
};
channel.get({
- url: '/json/messages',
+ url: "/json/messages",
data: data,
idempotent: true,
success: function (data) {
@@ -616,7 +616,7 @@ exports.register_topic_handlers = function () {
message_id, select_stream_id, new_topic_name,
send_notification_to_new_thread,
send_notification_to_old_thread);
- $('#move_topic_modal').modal('hide');
+ $("#move_topic_modal").modal("hide");
}
},
error: function (xhr) {
diff --git a/static/js/stream_sort.js b/static/js/stream_sort.js
index 95983c9d2ce..9f254f2699e 100644
--- a/static/js/stream_sort.js
+++ b/static/js/stream_sort.js
@@ -11,7 +11,7 @@ exports.get_streams = function () {
};
function filter_streams_by_search(streams, search_term) {
- if (search_term === '') {
+ if (search_term === "") {
return streams;
}
diff --git a/static/js/stream_topic_history.js b/static/js/stream_topic_history.js
index fbcc43fff5b..faf99160d1d 100644
--- a/static/js/stream_topic_history.js
+++ b/static/js/stream_topic_history.js
@@ -1,4 +1,4 @@
-const FoldDict = require('./fold_dict').FoldDict;
+const FoldDict = require("./fold_dict").FoldDict;
const stream_dict = new Map(); // stream_id -> per_stream_history object
const fetched_stream_ids = new Set();
@@ -247,7 +247,7 @@ exports.get_server_history = function (stream_id, on_success) {
return;
}
- const url = '/json/users/me/' + stream_id + '/topics';
+ const url = "/json/users/me/" + stream_id + "/topics";
channel.get({
url: url,
diff --git a/static/js/stream_ui_updates.js b/static/js/stream_ui_updates.js
index 2899052447d..fa8cf7ad423 100644
--- a/static/js/stream_ui_updates.js
+++ b/static/js/stream_ui_updates.js
@@ -1,6 +1,6 @@
const render_subscription_count = require("../templates/subscription_count.hbs");
-const render_subscription_setting_icon = require('../templates/subscription_setting_icon.hbs');
-const render_subscription_type = require('../templates/subscription_type.hbs');
+const render_subscription_setting_icon = require("../templates/subscription_setting_icon.hbs");
+const render_subscription_type = require("../templates/subscription_type.hbs");
exports.update_check_button_for_sub = function (sub) {
const button = subs.check_button_for_sub(sub);
@@ -31,19 +31,19 @@ exports.initialize_disable_btn_hint_popover = function (btn_wrapper, popover_btn
animation: false,
});
- btn_wrapper.on('mouseover', (e) => {
- popover_btn.popover('show');
+ btn_wrapper.on("mouseover", (e) => {
+ popover_btn.popover("show");
e.stopPropagation();
});
- btn_wrapper.on('mouseout', (e) => {
- popover_btn.popover('hide');
+ btn_wrapper.on("mouseout", (e) => {
+ popover_btn.popover("hide");
e.stopPropagation();
});
};
exports.initialize_cant_subscribe_popover = function (sub) {
- const button_wrapper = stream_edit.settings_for_sub(sub).find('.sub_unsub_button_wrapper');
+ 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"));
@@ -58,7 +58,7 @@ exports.update_settings_button_for_sub = function (sub) {
}
if (sub.should_display_subscription_button) {
settings_button.prop("disabled", false);
- settings_button.popover('destroy');
+ settings_button.popover("destroy");
settings_button.css("pointer-events", "");
} else {
settings_button.attr("title", "");
@@ -78,9 +78,9 @@ exports.update_regular_sub_settings = function (sub) {
$settings.find(".email-address").text(sub.email_address);
$settings.find(".stream-email-box").show();
}
- $settings.find(".regular_subscription_settings").addClass('in');
+ $settings.find(".regular_subscription_settings").addClass("in");
} else {
- $settings.find(".regular_subscription_settings").removeClass('in');
+ $settings.find(".regular_subscription_settings").removeClass("in");
// Clear email address widget
$settings.find(".email-address").html("");
}
@@ -97,11 +97,11 @@ exports.update_change_stream_privacy_settings = function (sub) {
};
exports.update_notification_setting_checkbox = function (notification_name) {
- const stream_row = $('#subscriptions_table .stream-row.active');
+ const stream_row = $("#subscriptions_table .stream-row.active");
if (!stream_row.length) {
return;
}
- const stream_id = stream_row.data('stream-id');
+ const stream_id = stream_row.data("stream-id");
$(`#${notification_name}_${stream_id}`).prop("checked", stream_data.receives_notifications(
stream_id, notification_name));
};
@@ -128,10 +128,10 @@ exports.update_stream_privacy_type_icon = function (sub) {
const html = render_subscription_setting_icon(sub);
if (overlays.streams_open()) {
- sub_row.find('.icon').expectOne().replaceWith($(html));
+ sub_row.find(".icon").expectOne().replaceWith($(html));
}
if (stream_edit.is_sub_settings_active(sub)) {
- const large_icon = stream_settings.find('.large-icon').expectOne();
+ const large_icon = stream_settings.find(".large-icon").expectOne();
if (sub.invite_only) {
large_icon.removeClass("hash").addClass("lock")
.html("<i class='fa fa-lock' aria-hidden='true'></i>");
@@ -150,7 +150,7 @@ exports.update_stream_subscription_type_text = function (sub) {
};
const html = render_subscription_type(template_data);
if (stream_edit.is_sub_settings_active(sub)) {
- stream_settings.find('.subscription-type-text').expectOne().html(html);
+ stream_settings.find(".subscription-type-text").expectOne().html(html);
}
};
@@ -162,7 +162,7 @@ exports.update_subscribers_count = function (sub, just_subscribed) {
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) {
const rendered_sub_count = render_subscription_count(sub);
- stream_row.find('.subscriber-count').expectOne().html(rendered_sub_count);
+ stream_row.find(".subscriber-count").expectOne().html(rendered_sub_count);
} else {
stream_row.find(".subscriber-count-text").expectOne().text(sub.subscriber_count);
}
@@ -206,26 +206,26 @@ exports.update_add_subscriptions_elements = function (sub) {
if (page_params.is_guest) {
// For guest users, we just hide the add_subscribers feature.
- $('.add_subscribers_container').hide();
+ $(".add_subscribers_container").hide();
return;
}
// 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 input_element = $(".add_subscribers_container").find(".input").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) {
input_element.removeAttr("disabled");
button_element.removeAttr("disabled");
- button_element.css('pointer-events', "");
- $('.add_subscribers_container input').popover('destroy');
+ button_element.css("pointer-events", "");
+ $(".add_subscribers_container input").popover("destroy");
} else {
input_element.attr("disabled", "disabled");
button_element.attr("disabled", "disabled");
- exports.initialize_disable_btn_hint_popover($('.add_subscribers_container'), input_element, button_element,
+ 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/submessage.js b/static/js/submessage.js
index d905a9b7088..1ad0abff47e 100644
--- a/static/js/submessage.js
+++ b/static/js/submessage.js
@@ -27,7 +27,7 @@ exports.process_submessages = function (in_opts) {
try {
return exports.do_process_submessages(in_opts);
} catch (err) {
- blueslip.error('in process_submessages: ' + err.message);
+ blueslip.error("in process_submessages: " + err.message);
}
};
@@ -107,8 +107,8 @@ exports.handle_event = function (submsg) {
// Right now, our only use of submessages is widgets.
const msg_type = submsg.msg_type;
- if (msg_type !== 'widget') {
- blueslip.warn('unknown msg_type: ' + msg_type);
+ if (msg_type !== "widget") {
+ blueslip.warn("unknown msg_type: " + msg_type);
return;
}
@@ -117,7 +117,7 @@ exports.handle_event = function (submsg) {
try {
data = JSON.parse(submsg.content);
} catch (err) {
- blueslip.error('server sent us invalid json in handle_event: ' + submsg.content);
+ blueslip.error("server sent us invalid json in handle_event: " + submsg.content);
return;
}
@@ -130,7 +130,7 @@ exports.handle_event = function (submsg) {
exports.make_server_callback = function (message_id) {
return function (opts) {
- const url = '/json/submessage';
+ const url = "/json/submessage";
channel.post({
url: url,
diff --git a/static/js/subs.js b/static/js/subs.js
index a019db20791..aab54f80785 100644
--- a/static/js/subs.js
+++ b/static/js/subs.js
@@ -1,8 +1,8 @@
-const util = require('./util');
-const render_subscription = require('../templates/subscription.hbs');
-const render_subscription_settings = require('../templates/subscription_settings.hbs');
-const render_subscription_table_body = require('../templates/subscription_table_body.hbs');
-const render_subscriptions = require('../templates/subscriptions.hbs');
+const util = require("./util");
+const render_subscription = require("../templates/subscription.hbs");
+const render_subscription_settings = require("../templates/subscription_settings.hbs");
+const render_subscription_table_body = require("../templates/subscription_table_body.hbs");
+const render_subscriptions = require("../templates/subscriptions.hbs");
exports.show_subs_pane = {
nothing_selected: function () {
@@ -30,7 +30,7 @@ exports.settings_button_for_sub = function (sub) {
};
function get_row_data(row) {
- const row_id = parseInt(row.attr('data-stream-id'), 10);
+ const row_id = parseInt(row.attr("data-stream-id"), 10);
if (row_id) {
const row_object = stream_data.get_sub_by_id(row_id);
return {
@@ -41,9 +41,9 @@ function get_row_data(row) {
}
exports.get_active_data = function () {
- const active_row = $('div.stream-row.active');
- const valid_active_id = parseInt(active_row.attr('data-stream-id'), 10);
- const active_tab = $('.subscriptions-container').find('div.ind-tab.selected');
+ const active_row = $("div.stream-row.active");
+ const valid_active_id = parseInt(active_row.attr("data-stream-id"), 10);
+ const active_tab = $(".subscriptions-container").find("div.ind-tab.selected");
return {
row: active_row,
id: valid_active_id,
@@ -97,11 +97,11 @@ exports.active_stream = function () {
exports.toggle_home = function (sub, status_element) {
stream_muting.update_is_muted(sub, !sub.is_muted);
- stream_edit.set_stream_property(sub, 'is_muted', sub.is_muted, status_element);
+ stream_edit.set_stream_property(sub, "is_muted", sub.is_muted, status_element);
};
exports.toggle_pin_to_top_stream = function (sub) {
- stream_edit.set_stream_property(sub, 'pin_to_top', !sub.pin_to_top);
+ stream_edit.set_stream_property(sub, "pin_to_top", !sub.pin_to_top);
};
let subscribed_only = true;
@@ -146,7 +146,7 @@ exports.update_stream_name = function (sub, new_name) {
exports.update_stream_description = function (sub, description, rendered_description) {
sub.description = description;
- sub.rendered_description = rendered_description.replace('<p>', '').replace('</p>', '');
+ sub.rendered_description = rendered_description.replace("<p>", "").replace("</p>", "");
// Update stream row
const sub_row = exports.row_for_stream_id(sub.stream_id);
@@ -190,14 +190,14 @@ exports.update_message_retention_setting = function (sub, new_value) {
exports.set_color = function (stream_id, color) {
const sub = stream_data.get_sub_by_id(stream_id);
- stream_edit.set_stream_property(sub, 'color', color);
+ stream_edit.set_stream_property(sub, "color", color);
};
exports.rerender_subscriptions_settings = function (sub) {
// This rerendes the subscriber data for a given sub object
// where it might have already been rendered in the subscriptions UI.
if (typeof sub === "undefined") {
- blueslip.error('Undefined sub passed to function rerender_subscriptions_settings');
+ blueslip.error("Undefined sub passed to function rerender_subscriptions_settings");
return;
}
stream_data.update_subscribers_count(sub);
@@ -300,7 +300,7 @@ 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,
});
}
};
@@ -330,7 +330,7 @@ function triage_stream(query, sub) {
if (query.subscribed_only) {
// reject non-subscribed streams
if (!sub.subscribed) {
- return 'rejected';
+ return "rejected";
}
}
@@ -345,15 +345,15 @@ function triage_stream(query, sub) {
});
}
- if (match('name')) {
- return 'name_match';
+ if (match("name")) {
+ return "name_match";
}
- if (match('description')) {
- return 'desc_match';
+ if (match("description")) {
+ return "desc_match";
}
- return 'rejected';
+ return "rejected";
}
function get_stream_id_buckets(stream_ids, query) {
@@ -370,9 +370,9 @@ function get_stream_id_buckets(stream_ids, query) {
const sub = stream_data.get_sub_by_id(stream_id);
const match_status = triage_stream(query, sub);
- if (match_status === 'name_match') {
+ if (match_status === "name_match") {
buckets.name.push(stream_id);
- } else if (match_status === 'desc_match') {
+ } else if (match_status === "desc_match") {
buckets.desc.push(stream_id);
} else {
buckets.other.push(stream_id);
@@ -392,11 +392,11 @@ exports.populate_stream_settings_left_panel = function () {
subscriptions: sub_rows,
};
- const finish = blueslip.start_timing('render_subscriptions');
+ const finish = blueslip.start_timing("render_subscriptions");
const html = render_subscriptions(template_data);
finish();
- ui.get_content_element($('#subscriptions_table .streams-list')).html(html);
+ ui.get_content_element($("#subscriptions_table .streams-list")).html(html);
};
// query is now an object rather than a string.
@@ -405,7 +405,7 @@ exports.filter_table = function (query) {
exports.show_active_stream_in_left_panel();
function stream_id_for_row(row) {
- return parseInt($(row).attr('data-stream-id'), 10);
+ return parseInt($(row).attr("data-stream-id"), 10);
}
const widgets = new Map();
@@ -433,9 +433,9 @@ exports.filter_table = function (query) {
// Below code goes away if we don't do sort-DOM-in-place.
if (hidden_ids.has(stream_id)) {
- $(row).addClass('notdisplayed');
+ $(row).addClass("notdisplayed");
} else {
- $(row).removeClass('notdisplayed');
+ $(row).removeClass("notdisplayed");
}
widgets.set(stream_id, $(row).detach());
@@ -452,7 +452,7 @@ exports.filter_table = function (query) {
];
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();
@@ -570,7 +570,7 @@ exports.setup_page = function (callback) {
$("#subscriptions_table .search-container").prepend(toggler_elem);
}
if (page_params.is_guest) {
- exports.toggler.disable_tab('all-streams');
+ exports.toggler.disable_tab("all-streams");
}
// show the "Stream settings" header by default.
@@ -579,7 +579,7 @@ exports.setup_page = function (callback) {
function populate_and_fill() {
- $('#subscriptions_table').empty();
+ $("#subscriptions_table").empty();
const template_data = {
can_create_streams: page_params.can_create_streams,
@@ -597,7 +597,7 @@ exports.setup_page = function (callback) {
};
const rendered = render_subscription_table_body(template_data);
- $('#subscriptions_table').append(rendered);
+ $("#subscriptions_table").append(rendered);
exports.populate_stream_settings_left_panel();
initialize_components();
@@ -622,7 +622,7 @@ exports.setup_page = function (callback) {
populate_and_fill();
if (!should_list_all_streams()) {
- $('.create_stream_button').val(i18n.t("Subscribe"));
+ $(".create_stream_button").val(i18n.t("Subscribe"));
}
};
@@ -649,18 +649,18 @@ exports.change_state = function (section) {
if (!page_params.is_guest) {
exports.do_open_create_stream();
} else {
- exports.toggler.goto('subscribed');
+ exports.toggler.goto("subscribed");
}
return;
}
if (section === "all") {
- exports.toggler.goto('all-streams');
+ exports.toggler.goto("all-streams");
return;
}
if (section === "subscribed") {
- exports.toggler.goto('subscribed');
+ exports.toggler.goto("subscribed");
return;
}
@@ -671,21 +671,21 @@ exports.change_state = function (section) {
// So redirect guest users to 'subscribed' tab
// for any unsubscribed stream settings hash
if (page_params.is_guest && !stream_data.id_is_subscribed(stream_id)) {
- exports.toggler.goto('subscribed');
+ exports.toggler.goto("subscribed");
} else {
exports.switch_to_stream_row(stream_id);
}
return;
}
- blueslip.warn('invalid section for streams: ' + section);
- exports.toggler.goto('subscribed');
+ blueslip.warn("invalid section for streams: " + section);
+ exports.toggler.goto("subscribed");
};
exports.launch = function (section) {
exports.setup_page(() => {
overlays.open_overlay({
- name: 'subscriptions',
+ name: "subscriptions",
overlay: $("#subscription_overlay"),
on_close: function () {
hashchange.exit_overlay();
@@ -694,31 +694,31 @@ exports.launch = function (section) {
exports.change_state(section);
});
if (!exports.get_active_data().id) {
- $('#search_stream_name').focus();
+ $("#search_stream_name").focus();
}
};
exports.switch_rows = function (event) {
const active_data = exports.get_active_data();
let switch_row;
- if (window.location.hash === '#streams/new') {
+ if (window.location.hash === "#streams/new") {
// Prevent switching stream rows when creating a new stream
return false;
- } else if (!active_data.id || active_data.row.hasClass('notdisplayed')) {
- switch_row = $('div.stream-row:not(.notdisplayed)').first();
- if ($('#search_stream_name').is(":focus")) {
- $('#search_stream_name').blur();
+ } else if (!active_data.id || active_data.row.hasClass("notdisplayed")) {
+ switch_row = $("div.stream-row:not(.notdisplayed)").first();
+ if ($("#search_stream_name").is(":focus")) {
+ $("#search_stream_name").blur();
}
} else {
- if (event === 'up_arrow') {
- switch_row = active_data.row.prevAll().not('.notdisplayed').first();
- } else if (event === 'down_arrow') {
- switch_row = active_data.row.nextAll().not('.notdisplayed').first();
+ if (event === "up_arrow") {
+ switch_row = active_data.row.prevAll().not(".notdisplayed").first();
+ } else if (event === "down_arrow") {
+ switch_row = active_data.row.nextAll().not(".notdisplayed").first();
}
- if ($('#search_stream_name').is(":focus")) {
+ if ($("#search_stream_name").is(":focus")) {
// remove focus from Filter streams input instead of switching rows
// if Filter streams input is focused
- return $('#search_stream_name').blur();
+ return $("#search_stream_name").blur();
}
}
@@ -726,8 +726,8 @@ exports.switch_rows = function (event) {
if (row_data) {
const stream_id = row_data.id;
exports.switch_to_stream_row(stream_id);
- } else if (event === 'up_arrow' && !row_data) {
- $('#search_stream_name').focus();
+ } else if (event === "up_arrow" && !row_data) {
+ $("#search_stream_name").focus();
}
return true;
};
@@ -737,9 +737,9 @@ exports.keyboard_sub = function () {
const row_data = get_row_data(active_data.row);
if (row_data) {
exports.sub_or_unsub(row_data.object);
- if (row_data.object.subscribed && active_data.tab.text() === 'Subscribed') {
- active_data.row.addClass('notdisplayed');
- active_data.row.removeClass('active');
+ if (row_data.object.subscribed && active_data.tab.text() === "Subscribed") {
+ active_data.row.addClass("notdisplayed");
+ active_data.row.removeClass("active");
}
}
};
@@ -747,10 +747,10 @@ exports.keyboard_sub = function () {
exports.toggle_view = function (event) {
const active_data = exports.get_active_data();
- if (event === 'right_arrow' && active_data.tab.text() === 'Subscribed') {
- exports.toggler.goto('all-streams');
- } else if (event === 'left_arrow' && active_data.tab.text() === 'All streams') {
- exports.toggler.goto('subscribed');
+ if (event === "right_arrow" && active_data.tab.text() === "Subscribed") {
+ exports.toggler.goto("all-streams");
+ } else if (event === "left_arrow" && active_data.tab.text() === "All streams") {
+ exports.toggler.goto("subscribed");
}
};
@@ -758,7 +758,7 @@ 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);
}
};
@@ -766,7 +766,7 @@ exports.view_stream = function () {
/* For the given stream_row, remove the tick and replace by a spinner. */
function display_subscribe_toggle_spinner(stream_row) {
/* Prevent sending multiple requests by removing the button class. */
- $(stream_row).find('.check').removeClass("sub_unsub_button");
+ $(stream_row).find(".check").removeClass("sub_unsub_button");
/* Hide the tick. */
const tick = $(stream_row).find("svg");
@@ -781,7 +781,7 @@ function display_subscribe_toggle_spinner(stream_row) {
/* For the given stream_row, add the tick and delete the spinner. */
function hide_subscribe_toggle_spinner(stream_row) {
/* Re-enable the button to handle requests. */
- $(stream_row).find('.check').addClass("sub_unsub_button");
+ $(stream_row).find(".check").addClass("sub_unsub_button");
/* Show the tick. */
const tick = $(stream_row).find("svg");
@@ -874,7 +874,7 @@ exports.do_open_create_stream = function () {
exports.open_create_stream = function () {
exports.do_open_create_stream();
- hashchange.update_browser_history('#streams/new');
+ hashchange.update_browser_history("#streams/new");
};
diff --git a/static/js/tab_bar.js b/static/js/tab_bar.js
index 777705eceaf..9db02222413 100644
--- a/static/js/tab_bar.js
+++ b/static/js/tab_bar.js
@@ -1,5 +1,5 @@
-const render_tab_bar = require('../templates/tab_bar.hbs');
-const rendered_markdown = require('./rendered_markdown');
+const render_tab_bar = require("../templates/tab_bar.hbs");
+const rendered_markdown = require("./rendered_markdown");
function get_sub_count(current_stream) {
const sub_count = current_stream.subscriber_count;
@@ -10,7 +10,7 @@ function get_formatted_sub_count(current_stream) {
let sub_count = get_sub_count(current_stream);
if (sub_count >= 1000) {
// parseInt() is used to floor the value of division to an integer
- sub_count = parseInt(sub_count / 1000, 10) + 'k';
+ sub_count = parseInt(sub_count / 1000, 10) + "k";
}
return sub_count;
}
@@ -19,15 +19,15 @@ function make_tab_data(filter) {
const tab_data = {};
if (filter === undefined) {
return {
- title: i18n.t('All messages'),
- icon: 'home',
+ title: i18n.t("All messages"),
+ icon: "home",
};
}
tab_data.title = filter.get_title();
tab_data.icon = filter.get_icon();
- if (filter.has_operator('stream') && !filter._sub) {
- tab_data.sub_count = '0';
- tab_data.formatted_sub_count = '0';
+ if (filter.has_operator("stream") && !filter._sub) {
+ tab_data.sub_count = "0";
+ tab_data.formatted_sub_count = "0";
tab_data.rendered_narrow_description = i18n.t("This stream does not exist or is private.");
return tab_data;
}
@@ -50,7 +50,7 @@ function make_tab_data(filter) {
exports.colorize_tab_bar = function () {
const filter = narrow_state.filter();
if (filter === undefined || !filter._sub) {return;}
- $("#tab_bar .stream > .fa").css('color', filter._sub.color);
+ $("#tab_bar .stream > .fa").css("color", filter._sub.color);
};
function append_and_display_title_area(tab_bar_data) {
@@ -61,8 +61,8 @@ function append_and_display_title_area(tab_bar_data) {
if (tab_bar_data.stream_settings_link) {
exports.colorize_tab_bar();
}
- tab_bar_elem.removeClass('notdisplayed');
- const content = tab_bar_elem.find('span.rendered_markdown');
+ tab_bar_elem.removeClass("notdisplayed");
+ const content = tab_bar_elem.find("span.rendered_markdown");
if (content) {
// Update syntax like stream names, emojis, mentions, timestamps.
rendered_markdown.update_elements(content);
@@ -107,7 +107,7 @@ function build_tab_bar(filter) {
const tab_bar_data = make_tab_data(filter);
append_and_display_title_area(tab_bar_data);
bind_title_area_handlers();
- if (page_params.search_pills_enabled && $('#search_query').is(':focus')) {
+ if (page_params.search_pills_enabled && $("#search_query").is(":focus")) {
exports.open_search_bar_and_close_narrow_description();
} else {
exports.close_search_bar_and_open_narrow_description();
@@ -143,7 +143,7 @@ exports.initialize = function () {
exports.render_title_area();
// register searchbar click handler
- $('#search_exit').on("click", (e) => {
+ $("#search_exit").on("click", (e) => {
tab_bar.exit_search();
e.preventDefault();
e.stopPropagation();
diff --git a/static/js/templates.js b/static/js/templates.js
index a41f2b72fbe..02e6ec8d358 100644
--- a/static/js/templates.js
+++ b/static/js/templates.js
@@ -12,7 +12,7 @@ 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; },
@@ -52,7 +52,7 @@ Handlebars.registerHelper({
// Jinja2 templating engine, so we don't consider this important.
const t_cache = new Map();
-Handlebars.registerHelper('t', (i18n_key) => {
+Handlebars.registerHelper("t", (i18n_key) => {
// Marks a string for translation.
// Example usage:
// {{t "some English text"}}
@@ -67,7 +67,7 @@ Handlebars.registerHelper('t', (i18n_key) => {
return safe_result;
});
-Handlebars.registerHelper('tr', (context, options) => {
+Handlebars.registerHelper("tr", (context, options) => {
// Marks a block for translation.
// Example usage 1:
// {{#tr context}}
@@ -92,6 +92,6 @@ Handlebars.registerHelper(
(content) => new Handlebars.SafeString(util.clean_user_content_links(content)),
);
-Handlebars.registerHelper('numberFormat', (number) => number.toLocaleString());
+Handlebars.registerHelper("numberFormat", (number) => number.toLocaleString());
window.templates = exports;
diff --git a/static/js/tictactoe_widget.js b/static/js/tictactoe_widget.js
index 14ffad4bf62..eb0ec6f9eb3 100644
--- a/static/js/tictactoe_widget.js
+++ b/static/js/tictactoe_widget.js
@@ -1,4 +1,4 @@
-const render_widgets_tictactoe_widget = require('../templates/widgets/tictactoe_widget.hbs');
+const render_widgets_tictactoe_widget = require("../templates/widgets/tictactoe_widget.hbs");
const tictactoe_data_holder = function () {
const self = {};
@@ -56,7 +56,7 @@ const tictactoe_data_holder = function () {
[square(7), square(8), square(9)],
];
- const token = num_filled % 2 === 0 ? 'X' : 'O';
+ const token = num_filled % 2 === 0 ? "X" : "O";
let move_status = token + "'s turn";
if (game_over) {
@@ -75,7 +75,7 @@ const tictactoe_data_holder = function () {
square_click: {
outbound: function (idx) {
const event = {
- type: 'square_click',
+ type: "square_click",
idx: idx,
num_filled: num_filled,
};
@@ -86,11 +86,11 @@ const tictactoe_data_holder = function () {
const idx = data.idx;
if (data.num_filled !== num_filled) {
- blueslip.info('out of sync', data.num_filled);
+ blueslip.info("out of sync", data.num_filled);
return;
}
- const token = num_filled % 2 === 0 ? 'X' : 'O';
+ const token = num_filled % 2 === 0 ? "X" : "O";
if (square_values.has(idx)) {
return;
@@ -128,9 +128,9 @@ exports.activate = function (opts) {
const html = render_widgets_tictactoe_widget(widget_data);
elem.html(html);
- elem.find("button.tictactoe-square").on('click', (e) => {
+ elem.find("button.tictactoe-square").on("click", (e) => {
e.stopPropagation();
- const str_idx = $(e.target).attr('data-idx');
+ const str_idx = $(e.target).attr("data-idx");
const idx = parseInt(str_idx, 10);
const data = tictactoe_data.handle.square_click.outbound(idx);
diff --git a/static/js/timerender.js b/static/js/timerender.js
index c01b90de950..dfa50185b83 100644
--- a/static/js/timerender.js
+++ b/static/js/timerender.js
@@ -16,12 +16,12 @@ exports.render_now = function (time, today) {
const start_of_today = set_to_start_of_day(today || new XDate());
const start_of_other_day = set_to_start_of_day(time.clone());
- let time_str = '';
+ let time_str = "";
let needs_update = false;
// render formal time to be used as title attr tooltip
// "\xa0" is U+00A0 NO-BREAK SPACE.
// Can't use &nbsp; as that represents the literal string "&nbsp;".
- const formal_time_str = time.toString('dddd,\xa0MMMM\xa0d,\xa0yyyy');
+ const formal_time_str = time.toString("dddd,\xa0MMMM\xa0d,\xa0yyyy");
// How many days old is 'time'? 0 = today, 1 = yesterday, 7 = a
// week ago, -1 = tomorrow, etc.
@@ -60,7 +60,7 @@ exports.render_now = function (time, today) {
// Current date is passed as an argument for unit testing
exports.last_seen_status_from_date = function (last_active_date, current_date) {
- if (typeof current_date === 'undefined') {
+ if (typeof current_date === "undefined") {
current_date = new XDate();
}
@@ -132,7 +132,7 @@ function render_date_span(elem, rendered_time, rendered_time_above) {
return elem;
}
elem.append(rendered_time.time_str);
- return elem.attr('title', rendered_time.formal_time_str);
+ return elem.attr("title", rendered_time.formal_time_str);
}
// Given an XDate object 'time', return a DOM node that initially
@@ -148,7 +148,7 @@ exports.render_date = function (time, time_above, today) {
const className = "timerender" + next_timerender_id;
next_timerender_id += 1;
const rendered_time = exports.render_now(time, today);
- let node = $("<span />").attr('class', className);
+ let node = $("<span />").attr("class", className);
if (time_above !== undefined) {
const rendered_time_above = exports.render_now(time_above, today);
node = render_date_span(node, rendered_time, rendered_time_above);
@@ -166,8 +166,8 @@ exports.render_date = function (time, time_above, today) {
// Renders the timestamp returned by the <time:> markdown syntax.
exports.render_markdown_timestamp = function (time, text) {
- const hourformat = page_params.twenty_four_hour_time ? 'HH:mm' : 'h:mm A';
- const timestring = time.format('ddd, MMM D YYYY, ' + hourformat);
+ const hourformat = page_params.twenty_four_hour_time ? "HH:mm" : "h:mm A";
+ const timestring = time.format("ddd, MMM D YYYY, " + hourformat);
const titlestring = "This time is in your timezone. Original text was '" + text + "'.";
return {
text: timestring,
@@ -185,7 +185,7 @@ exports.update_timestamps = function () {
for (const entry of to_process) {
const className = entry.className;
- const elements = $('.' + className);
+ const elements = $("." + className);
// The element might not exist any more (because it
// was in the zfilt table, or because we added
// messages above it and re-collapsed).
@@ -241,9 +241,9 @@ exports.get_timestamp_for_flatpickr = (timestring) => {
exports.stringify_time = function (time) {
if (page_params.twenty_four_hour_time) {
- return time.toString('HH:mm');
+ return time.toString("HH:mm");
}
- return time.toString('h:mm TT');
+ return time.toString("h:mm TT");
};
// this is for rendering absolute time based off the preferences for twenty-four
@@ -275,7 +275,7 @@ exports.absolute_time = (function () {
};
return function (timestamp, today) {
- if (typeof today === 'undefined') {
+ if (typeof today === "undefined") {
today = new Date();
}
const date = new Date(timestamp);
@@ -299,7 +299,7 @@ exports.get_full_datetime = function (time) {
return {
date: time.toLocaleDateString(),
time: time.toLocaleTimeString() +
- ' (UTC' + (tz_offset < 0 ? '' : '+') + tz_offset + ')',
+ " (UTC" + (tz_offset < 0 ? "" : "+") + tz_offset + ")",
};
};
@@ -317,7 +317,7 @@ exports.set_full_datetime = function timerender_set_full_datetime(message, time_
message.full_date_str = full_datetime.date;
message.full_time_str = full_datetime.time;
- time_elem.attr('title', message.full_date_str + ' ' + message.full_time_str);
+ time_elem.attr("title", message.full_date_str + " " + message.full_time_str);
};
window.timerender = exports;
diff --git a/static/js/todo_widget.js b/static/js/todo_widget.js
index eeebc54a5d8..7e51db3fde8 100644
--- a/static/js/todo_widget.js
+++ b/static/js/todo_widget.js
@@ -1,5 +1,5 @@
-const render_widgets_todo_widget = require('../templates/widgets/todo_widget.hbs');
-const render_widgets_todo_widget_tasks = require('../templates/widgets/todo_widget_tasks.hbs');
+const render_widgets_todo_widget = require("../templates/widgets/todo_widget.hbs");
+const render_widgets_todo_widget_tasks = require("../templates/widgets/todo_widget_tasks.hbs");
exports.task_data_holder = function () {
const self = {};
@@ -53,7 +53,7 @@ exports.task_data_holder = function () {
new_task: {
outbound: function (task, desc) {
const event = {
- type: 'new_task',
+ type: "new_task",
key: get_new_index(),
task: task,
desc: desc,
@@ -92,7 +92,7 @@ exports.task_data_holder = function () {
strike: {
outbound: function (key) {
const event = {
- type: 'strike',
+ type: "strike",
key: key,
};
@@ -104,7 +104,7 @@ exports.task_data_holder = function () {
const item = task_map.get(key);
if (item === undefined) {
- blueslip.warn('Do we have legacy data? unknown key for tasks: ' + key);
+ blueslip.warn("Do we have legacy data? unknown key for tasks: " + key);
return;
}
@@ -133,22 +133,22 @@ exports.activate = function (opts) {
const html = render_widgets_todo_widget();
elem.html(html);
- elem.find("button.add-task").on('click', (e) => {
+ elem.find("button.add-task").on("click", (e) => {
e.stopPropagation();
- elem.find(".widget-error").text('');
+ elem.find(".widget-error").text("");
const task = elem.find("input.add-task").val().trim();
const desc = elem.find("input.add-desc").val().trim();
- if (task === '') {
+ if (task === "") {
return;
}
- elem.find(".add-task").val('').focus();
- elem.find(".add-desc").val('').focus();
+ elem.find(".add-task").val("").focus();
+ elem.find(".add-desc").val("").focus();
const task_exists = task_data.name_in_use(task);
if (task_exists) {
- elem.find(".widget-error").text(i18n.t('Task already exists'));
+ elem.find(".widget-error").text(i18n.t("Task already exists"));
return;
}
@@ -160,12 +160,12 @@ exports.activate = function (opts) {
function render_results() {
const widget_data = task_data.get_widget_data();
const html = render_widgets_todo_widget_tasks(widget_data);
- elem.find('ul.todo-widget').html(html);
- elem.find(".widget-error").text('');
+ elem.find("ul.todo-widget").html(html);
+ elem.find(".widget-error").text("");
- elem.find("button.task").on('click', (e) => {
+ elem.find("button.task").on("click", (e) => {
e.stopPropagation();
- const key = $(e.target).attr('data-key');
+ const key = $(e.target).attr("data-key");
const data = task_data.handle.strike.outbound(key);
callback(data);
diff --git a/static/js/top_left_corner.js b/static/js/top_left_corner.js
index c7abc5bdc59..86e52c88697 100644
--- a/static/js/top_left_corner.js
+++ b/static/js/top_left_corner.js
@@ -1,10 +1,10 @@
exports.update_count_in_dom = function (unread_count_elem, count) {
- const count_span = unread_count_elem.find('.count');
- const value_span = count_span.find('.value');
+ const count_span = unread_count_elem.find(".count");
+ const value_span = count_span.find(".value");
if (count === 0) {
count_span.hide();
- value_span.text('');
+ value_span.text("");
return;
}
@@ -13,7 +13,7 @@ exports.update_count_in_dom = function (unread_count_elem, count) {
};
exports.update_starred_count = function (count) {
- const starred_li = $('.top_left_starred_messages');
+ const starred_li = $(".top_left_starred_messages");
exports.update_count_in_dom(starred_li, count);
};
@@ -21,8 +21,8 @@ exports.update_dom_with_unread_counts = function (counts) {
// Note that "Private messages" counts are handled in pm_list.js.
// mentioned/home have simple integer counts
- const mentioned_li = $('.top_left_mentions');
- const home_li = $('.top_left_all_messages');
+ const mentioned_li = $(".top_left_mentions");
+ const home_li = $(".top_left_all_messages");
exports.update_count_in_dom(mentioned_li, counts.mentioned_message_count);
exports.update_count_in_dom(home_li, counts.home_unread_messages);
@@ -33,30 +33,30 @@ exports.update_dom_with_unread_counts = function (counts) {
function deselect_top_left_corner_items() {
function remove(elem) {
- elem.removeClass('active-filter active-sub-filter');
+ elem.removeClass("active-filter active-sub-filter");
}
- remove($('.top_left_all_messages'));
- remove($('.top_left_private_messages'));
- remove($('.top_left_starred_messages'));
- remove($('.top_left_mentions'));
+ remove($(".top_left_all_messages"));
+ remove($(".top_left_private_messages"));
+ remove($(".top_left_starred_messages"));
+ remove($(".top_left_mentions"));
}
function should_expand_pm_list(filter) {
- const op_is = filter.operands('is');
+ const op_is = filter.operands("is");
if (op_is.length >= 1 && op_is.includes("private")) {
return true;
}
- const op_pm = filter.operands('pm-with');
+ const op_pm = filter.operands("pm-with");
if (op_pm.length !== 1) {
return false;
}
const emails_strings = op_pm[0];
- const emails = emails_strings.split(',');
+ const emails = emails_strings.split(",");
const has_valid_emails = people.is_valid_bulk_emails_for_compose(emails);
@@ -71,23 +71,23 @@ exports.handle_narrow_activated = function (filter) {
let filter_li;
// TODO: handle confused filters like "in:all stream:foo"
- ops = filter.operands('in');
+ ops = filter.operands("in");
if (ops.length >= 1) {
filter_name = ops[0];
- if (filter_name === 'home') {
- filter_li = $('.top_left_all_messages');
- filter_li.addClass('active-filter');
+ if (filter_name === "home") {
+ filter_li = $(".top_left_all_messages");
+ filter_li.addClass("active-filter");
}
}
- ops = filter.operands('is');
+ ops = filter.operands("is");
if (ops.length >= 1) {
filter_name = ops[0];
- if (filter_name === 'starred') {
- filter_li = $('.top_left_starred_messages');
- filter_li.addClass('active-filter');
- } else if (filter_name === 'mentioned') {
- filter_li = $('.top_left_mentions');
- filter_li.addClass('active-filter');
+ if (filter_name === "starred") {
+ filter_li = $(".top_left_starred_messages");
+ filter_li.addClass("active-filter");
+ } else if (filter_name === "mentioned") {
+ filter_li = $(".top_left_mentions");
+ filter_li.addClass("active-filter");
}
}
@@ -102,8 +102,8 @@ exports.handle_narrow_deactivated = function () {
deselect_top_left_corner_items();
pm_list.close();
- const filter_li = $('.top_left_all_messages');
- filter_li.addClass('active-filter');
+ const filter_li = $(".top_left_all_messages");
+ filter_li.addClass("active-filter");
};
window.top_left_corner = exports;
diff --git a/static/js/topic_generator.js b/static/js/topic_generator.js
index 375f7878507..5293ea12162 100644
--- a/static/js/topic_generator.js
+++ b/static/js/topic_generator.js
@@ -50,7 +50,7 @@ exports.fchain = function (outer_gen, get_inner_gen) {
if (inner_gen === undefined) {
inner_gen = get_inner_gen(outer_val);
if (!inner_gen || !inner_gen.next) {
- blueslip.error('Invalid generator returned.');
+ blueslip.error("Invalid generator returned.");
return;
}
}
diff --git a/static/js/topic_list.js b/static/js/topic_list.js
index c9d0da0fbd2..4f6b1572607 100644
--- a/static/js/topic_list.js
+++ b/static/js/topic_list.js
@@ -1,7 +1,7 @@
-const render_more_topics = require('../templates/more_topics.hbs');
-const render_more_topics_spinner = require('../templates/more_topics_spinner.hbs');
-const render_topic_list_item = require('../templates/topic_list_item.hbs');
-const topic_list_data = require('./topic_list_data');
+const render_more_topics = require("../templates/more_topics.hbs");
+const render_more_topics_spinner = require("../templates/more_topics_spinner.hbs");
+const render_topic_list_item = require("../templates/topic_list_item.hbs");
+const topic_list_data = require("./topic_list_data");
/*
Track all active widgets with a Map.
@@ -43,7 +43,7 @@ exports.zoom_out = function () {
const stream_ids = Array.from(active_widgets.keys());
if (stream_ids.length !== 1) {
- blueslip.error('Unexpected number of topic lists to zoom out.');
+ blueslip.error("Unexpected number of topic lists to zoom out.");
return;
}
@@ -59,7 +59,7 @@ exports.keyed_topic_li = (convo) => {
const eq = (other) => _.isEqual(convo, other.convo);
- const key = 't:' + convo.topic_name;
+ const key = "t:" + convo.topic_name;
return {
key: key,
@@ -77,7 +77,7 @@ exports.more_li = (more_topics_unreads) => {
const eq = (other) => other.more_items &&
more_topics_unreads === other.more_topics_unreads;
- const key = 'more';
+ const key = "more";
return {
key: key,
@@ -93,7 +93,7 @@ exports.spinner_li = () => {
const eq = (other) => other.spinner;
- const key = 'more';
+ const key = "more";
return {
key: key,
@@ -120,7 +120,7 @@ exports.widget = function (parent_elem, my_stream_id) {
stream_topic_history.is_complete_for_stream_id(my_stream_id);
const attrs = [
- ['class', 'topic-list'],
+ ["class", "topic-list"],
];
const nodes = list_info.items.map(exports.keyed_topic_li);
@@ -148,7 +148,7 @@ exports.widget = function (parent_elem, my_stream_id) {
};
self.remove = function () {
- parent_elem.find('.topic-list').remove();
+ parent_elem.find(".topic-list").remove();
self.prior_dom = undefined;
};
@@ -161,7 +161,7 @@ exports.widget = function (parent_elem, my_stream_id) {
}
function find() {
- return parent_elem.find('.topic-list');
+ return parent_elem.find(".topic-list");
}
vdom.update(replace_content, find, new_dom, self.prior_dom);
@@ -215,7 +215,7 @@ exports.zoom_in = function () {
const stream_id = exports.active_stream_id();
if (!stream_id) {
- blueslip.error('Cannot find widget for topic history zooming.');
+ blueslip.error("Cannot find widget for topic history zooming.");
return;
}
@@ -223,12 +223,12 @@ exports.zoom_in = function () {
function on_success() {
if (!active_widgets.has(stream_id)) {
- blueslip.warn('User re-narrowed before topic history was returned.');
+ blueslip.warn("User re-narrowed before topic history was returned.");
return;
}
if (!zoomed) {
- blueslip.warn('User zoomed out before topic history was returned.');
+ blueslip.warn("User zoomed out before topic history was returned.");
// Note that we could attempt to re-draw the zoomed out topic list
// here, given that we have more history, but that might be more
// confusing than helpful to a user who is likely trying to browse
@@ -239,7 +239,7 @@ exports.zoom_in = function () {
active_widget.build();
}
- ui.get_scroll_element($('#stream-filters-container')).scrollTop(0);
+ ui.get_scroll_element($("#stream-filters-container")).scrollTop(0);
const spinner = true;
active_widget.build(spinner);
@@ -248,26 +248,26 @@ exports.zoom_in = function () {
};
exports.initialize = function () {
- $('#stream_filters').on('click', '.topic-box', (e) => {
+ $("#stream_filters").on("click", ".topic-box", (e) => {
if (e.metaKey || e.ctrlKey) {
return;
}
- if ($(e.target).closest('.show-more-topics').length > 0) {
+ if ($(e.target).closest(".show-more-topics").length > 0) {
return;
}
// In a more componentized world, we would delegate some
// of this stuff back up to our parents.
- const stream_row = $(e.target).parents('.narrow-filter');
- const stream_id = parseInt(stream_row.attr('data-stream-id'), 10);
+ const stream_row = $(e.target).parents(".narrow-filter");
+ const stream_id = parseInt(stream_row.attr("data-stream-id"), 10);
const sub = stream_data.get_sub_by_id(stream_id);
- const topic = $(e.target).parents('li').attr('data-topic-name');
+ const topic = $(e.target).parents("li").attr("data-topic-name");
narrow.activate([
- {operator: 'stream', operand: sub.name},
- {operator: 'topic', operand: topic}],
- {trigger: 'sidebar'});
+ {operator: "stream", operand: sub.name},
+ {operator: "topic", operand: topic}],
+ {trigger: "sidebar"});
e.preventDefault();
});
diff --git a/static/js/topic_zoom.js b/static/js/topic_zoom.js
index a46ce987f69..0217d0c60e1 100644
--- a/static/js/topic_zoom.js
+++ b/static/js/topic_zoom.js
@@ -47,14 +47,14 @@ exports.clear_topics = function () {
};
exports.initialize = function () {
- $('#stream_filters').on('click', '.show-more-topics', (e) => {
+ $("#stream_filters").on("click", ".show-more-topics", (e) => {
zoom_in();
e.preventDefault();
e.stopPropagation();
});
- $('.show-all-streams').on('click', (e) => {
+ $(".show-all-streams").on("click", (e) => {
exports.zoom_out();
e.preventDefault();
diff --git a/static/js/transmit.js b/static/js/transmit.js
index 72b44064f51..41764e68a97 100644
--- a/static/js/transmit.js
+++ b/static/js/transmit.js
@@ -1,6 +1,6 @@
exports.send_message = function (request, on_success, error) {
channel.post({
- url: '/json/messages',
+ url: "/json/messages",
data: request,
success: function success(data) {
// Call back to our callers to do things like closing the compose
@@ -11,7 +11,7 @@ exports.send_message = function (request, on_success, error) {
sent_messages.report_server_ack(request.local_id);
},
error: function (xhr, error_type) {
- if (error_type !== 'timeout' && reload_state.is_pending()) {
+ if (error_type !== "timeout" && reload_state.is_pending()) {
// The error might be due to the server changing
reload.initiate({immediate: true,
save_pointer: true,
@@ -66,14 +66,14 @@ exports.reply_message = function (opts) {
locally_echoed: locally_echoed,
});
- if (message.type === 'stream') {
+ if (message.type === "stream") {
const stream = message.stream;
const mention = people.get_mention_syntax(message.sender_full_name, message.sender_id);
- content = mention + ' ' + content;
+ content = mention + " " + content;
- reply.type = 'stream';
+ reply.type = "stream";
reply.to = stream;
reply.content = content;
reply.topic = message.topic;
@@ -82,18 +82,18 @@ exports.reply_message = function (opts) {
return;
}
- if (message.type === 'private') {
+ if (message.type === "private") {
const pm_recipient = people.pm_reply_to(message);
- reply.type = 'private';
- reply.to = JSON.stringify(pm_recipient.split(','));
+ reply.type = "private";
+ reply.to = JSON.stringify(pm_recipient.split(","));
reply.content = content;
exports.send_message(reply, success, error);
return;
}
- blueslip.error('unknown message type: ' + message.type);
+ blueslip.error("unknown message type: " + message.type);
};
window.transmit = exports;
diff --git a/static/js/tutorial.js b/static/js/tutorial.js
index daaf439f5ce..53356d7e2fc 100644
--- a/static/js/tutorial.js
+++ b/static/js/tutorial.js
@@ -1,6 +1,6 @@
function set_tutorial_status(status, callback) {
return channel.post({
- url: '/json/users/me/tutorial_status',
+ url: "/json/users/me/tutorial_status",
data: {status: JSON.stringify(status)},
success: callback,
});
@@ -9,7 +9,7 @@ function set_tutorial_status(status, callback) {
exports.initialize = function () {
if (page_params.needs_tutorial) {
set_tutorial_status("started");
- narrow.by('is', 'private', {trigger: 'sidebar'});
+ narrow.by("is", "private", {trigger: "sidebar"});
}
};
diff --git a/static/js/typeahead_helper.js b/static/js/typeahead_helper.js
index 518e00eef7d..acb33a12803 100644
--- a/static/js/typeahead_helper.js
+++ b/static/js/typeahead_helper.js
@@ -1,7 +1,7 @@
const util = require("./util");
const pygments_data = require("../generated/pygments_data.json");
const typeahead = require("../shared/js/typeahead");
-const render_typeahead_list_item = require('../templates/typeahead_list_item.hbs');
+const render_typeahead_list_item = require("../templates/typeahead_list_item.hbs");
const settings_data = require("./settings_data");
// Returns an array of private message recipients, removing empty elements.
@@ -14,8 +14,8 @@ exports.get_cleaned_pm_recipients = function (query_string) {
exports.build_highlight_regex = function (query) {
// the regex below is based on bootstrap code
- query = query.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
- const regex = new RegExp('(' + query + ')', 'ig');
+ query = query.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
+ const regex = new RegExp("(" + query + ")", "ig");
return regex;
};
@@ -47,7 +47,7 @@ exports.make_query_highlighter = function (query) {
return function (phrase) {
let result = "";
- const parts = phrase.split(' ');
+ const parts = phrase.split(" ");
for (i = 0; i < parts.length; i += 1) {
if (i > 0) {
result += " ";
diff --git a/static/js/typing.js b/static/js/typing.js
index 8145550ad69..db3f18ca674 100644
--- a/static/js/typing.js
+++ b/static/js/typing.js
@@ -8,7 +8,7 @@ const typing_status = require("../shared/js/typing_status");
function send_typing_notification_ajax(user_ids_array, operation) {
channel.post({
- url: '/json/typing',
+ url: "/json/typing",
data: {
to: JSON.stringify(user_ids_array),
op: operation,
@@ -58,7 +58,7 @@ exports.initialize = function () {
notify_server_stop: notify_server_stop,
};
- $(document).on('input', '#compose-textarea', () => {
+ $(document).on("input", "#compose-textarea", () => {
// If our previous state was no typing notification, send a
// start-typing notice immediately.
const new_recipient =
@@ -68,7 +68,7 @@ exports.initialize = function () {
// We send a stop-typing notification immediately when compose is
// closed/cancelled
- $(document).on('compose_canceled.zulip compose_finished.zulip', () => {
+ $(document).on("compose_canceled.zulip compose_finished.zulip", () => {
typing_status.update(worker, null);
});
};
diff --git a/static/js/typing_data.js b/static/js/typing_data.js
index 6834c77e0f8..0f739b3f2ef 100644
--- a/static/js/typing_data.js
+++ b/static/js/typing_data.js
@@ -10,7 +10,7 @@ function to_int(s) {
function get_key(group) {
const ids = util.sorted_ids(group);
- return ids.join(',');
+ return ids.join(",");
}
exports.add_typist = function (group, typist) {
diff --git a/static/js/typing_events.js b/static/js/typing_events.js
index 617dbb0fa97..a5ef1574d6f 100644
--- a/static/js/typing_events.js
+++ b/static/js/typing_events.js
@@ -1,4 +1,4 @@
-const render_typing_notifications = require('../templates/typing_notifications.hbs');
+const render_typing_notifications = require("../templates/typing_notifications.hbs");
// See docs/subsystems/typing-indicators.md for details on typing indicators.
@@ -22,7 +22,7 @@ function get_users_typing_for_narrow() {
}
const first_term = narrow_state.operators()[0];
- if (first_term.operator === 'pm-with') {
+ if (first_term.operator === "pm-with") {
// Get list of users typing in this conversation
const narrow_emails_string = first_term.operand;
// TODO: Create people.emails_strings_to_user_ids.
@@ -30,7 +30,7 @@ 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);
}
@@ -42,10 +42,10 @@ exports.render_notifications_for_narrow = function () {
const user_ids = get_users_typing_for_narrow();
const users_typing = user_ids.map(people.get_by_user_id);
if (users_typing.length === 0) {
- $('#typing_notifications').hide();
+ $("#typing_notifications").hide();
} else {
- $('#typing_notifications').html(render_typing_notifications({users: users_typing}));
- $('#typing_notifications').show();
+ $("#typing_notifications").html(render_typing_notifications({users: users_typing}));
+ $("#typing_notifications").show();
}
};
diff --git a/static/js/ui.js b/static/js/ui.js
index 24319bda410..9e4e2d793c3 100644
--- a/static/js/ui.js
+++ b/static/js/ui.js
@@ -25,7 +25,7 @@ exports.get_scroll_element = function (element_selector) {
const sb = SimpleBar.instances.get(element);
if (sb) {
return $(sb.getScrollElement());
- } else if ('simplebar' in element.dataset) {
+ } else if ("simplebar" in element.dataset) {
// The SimpleBar mutation observer hasn’t processed this element yet.
// Create the SimpleBar early in case we need to add event listeners.
return $(new SimpleBar(element).getScrollElement());
@@ -60,7 +60,7 @@ function update_message_in_all_views(message_id, callback) {
exports.show_error_for_unsupported_platform = function () {
// Check if the user is using old desktop app
- if (typeof bridge !== 'undefined') {
+ if (typeof bridge !== "undefined") {
// 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.
@@ -111,9 +111,9 @@ exports.update_starred_view = function (message_id, new_value) {
exports.show_message_failed = function (message_id, failed_msg) {
// Failed to send message, so display inline retry/cancel
update_message_in_all_views(message_id, (row) => {
- const failed_div = row.find('.message_failed');
- failed_div.toggleClass('notvisible', false);
- failed_div.find('.failed_text').attr('title', failed_msg);
+ const failed_div = row.find(".message_failed");
+ failed_div.toggleClass("notvisible", false);
+ failed_div.find(".failed_text").attr("title", failed_msg);
});
};
@@ -138,14 +138,14 @@ exports.remove_messages = function (message_ids) {
exports.show_failed_message_success = function (message_id) {
// Previously failed message succeeded
update_message_in_all_views(message_id, (row) => {
- row.find('.message_failed').toggleClass('notvisible', true);
+ row.find(".message_failed").toggleClass("notvisible", true);
});
};
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.',
+ + "to make this common shortcut easier to trigger.",
{ originalHotkey: originalHotkey, replacementHotkey: replacementHotkey },
);
};
@@ -154,9 +154,9 @@ let shown_deprecation_notices = [];
exports.maybe_show_deprecation_notice = function (key) {
let message;
const isCmdOrCtrl = common.has_mac_keyboard() ? "Cmd" : "Ctrl";
- if (key === 'C') {
- message = exports.get_hotkey_deprecation_notice('C', 'x');
- } else if (key === '*') {
+ if (key === "C") {
+ message = exports.get_hotkey_deprecation_notice("C", "x");
+ } else if (key === "*") {
message = exports.get_hotkey_deprecation_notice("*", isCmdOrCtrl + " + s");
} else {
blueslip.error("Unexpected deprecation notice for hotkey:", key);
@@ -166,7 +166,7 @@ exports.maybe_show_deprecation_notice = function (key) {
// Here we handle the tracking for showing deprecation notices,
// whether or not local storage is available.
if (localstorage.supported()) {
- const notices_from_storage = JSON.parse(localStorage.getItem('shown_deprecation_notices'));
+ const notices_from_storage = JSON.parse(localStorage.getItem("shown_deprecation_notices"));
if (notices_from_storage !== null) {
shown_deprecation_notices = notices_from_storage;
} else {
@@ -175,12 +175,12 @@ exports.maybe_show_deprecation_notice = function (key) {
}
if (!shown_deprecation_notices.includes(key)) {
- $('#deprecation-notice-modal').modal('show');
- $('#deprecation-notice-message').text(message);
- $('#close-deprecation-notice').focus();
+ $("#deprecation-notice-modal").modal("show");
+ $("#deprecation-notice-message").text(message);
+ $("#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));
}
}
};
@@ -190,7 +190,7 @@ exports.maybe_show_deprecation_notice = function (key) {
let saved_compose_cursor = 0;
exports.set_compose_textarea_handlers = function () {
- $('#compose-textarea').blur(function () {
+ $("#compose-textarea").blur(function () {
saved_compose_cursor = $(this).caret();
});
@@ -202,7 +202,7 @@ exports.set_compose_textarea_handlers = function () {
};
exports.restore_compose_cursor = function () {
- $('#compose-textarea')
+ $("#compose-textarea")
.focus()
.caret(saved_compose_cursor);
};
diff --git a/static/js/ui_init.js b/static/js/ui_init.js
index f26e6ab58a1..7c97fe1a382 100644
--- a/static/js/ui_init.js
+++ b/static/js/ui_init.js
@@ -1,5 +1,5 @@
const emojisets = require("./emojisets");
-const markdown_config = require('./markdown_config');
+const markdown_config = require("./markdown_config");
// This is where most of our initialization takes place.
// TODO: Organize it a lot better. In particular, move bigger
@@ -14,7 +14,7 @@ function message_unhover() {
if (current_message_hover === undefined) {
return;
}
- current_message_hover.find('span.edit_content').html("");
+ current_message_hover.find("span.edit_content").html("");
current_message_hover = undefined;
}
@@ -24,7 +24,7 @@ function message_hover(message_row) {
return;
}
// Don't allow on-hover editing for local-only messages
- if (message_row.hasClass('local')) {
+ if (message_row.hasClass("local")) {
return;
}
const message = current_msg_list.get(rows.id(message_row));
@@ -70,7 +70,7 @@ exports.initialize_kitchen_sink_stuff = function () {
message_viewport.set_last_movement_direction(delta);
}, 50);
- message_viewport.message_pane.on('wheel', (e) => {
+ message_viewport.message_pane.on("wheel", (e) => {
const delta = e.originalEvent.deltaY;
if (!overlays.is_active()) {
// In the message view, we use a throttled mousewheel handler.
@@ -87,7 +87,7 @@ exports.initialize_kitchen_sink_stuff = function () {
// propagation in all cases. Also, ignore the event if the
// element is already at the top or bottom. Otherwise we get a
// new scroll event on the parent (?).
- $('.modal-body, .scrolling_list, input, textarea').on('wheel', function (e) {
+ $(".modal-body, .scrolling_list, input, textarea").on("wheel", function (e) {
const self = ui.get_scroll_element($(this));
const scroll = self.scrollTop();
const delta = e.originalEvent.deltaY;
@@ -104,7 +104,7 @@ exports.initialize_kitchen_sink_stuff = function () {
});
// Ignore wheel events in the compose area which weren't already handled above.
- $('#compose').on('wheel', (e) => {
+ $("#compose").on("wheel", (e) => {
e.stopPropagation();
e.preventDefault();
});
@@ -186,19 +186,19 @@ exports.initialize_kitchen_sink_stuff = function () {
$(this).removeClass("active");
});
- $("#stream_message_recipient_stream").on('blur', function () {
+ $("#stream_message_recipient_stream").on("blur", function () {
ui_util.decorate_stream_bar(this.value, $("#stream-message .message_header_stream"), true);
});
- $(window).on('blur', () => {
- $(document.body).addClass('window_blurred');
+ $(window).on("blur", () => {
+ $(document.body).addClass("window_blurred");
});
- $(window).on('focus', () => {
- $(document.body).removeClass('window_blurred');
+ $(window).on("focus", () => {
+ $(document.body).removeClass("window_blurred");
});
- $(document).on('message_selected.zulip', (event) => {
+ $(document).on("message_selected.zulip", (event) => {
if (current_msg_list !== event.msg_list) {
return;
}
@@ -207,8 +207,8 @@ exports.initialize_kitchen_sink_stuff = function () {
return;
}
const row = event.msg_list.get_row(event.id);
- $('.selected_message').removeClass('selected_message');
- row.addClass('selected_message');
+ $(".selected_message").removeClass("selected_message");
+ row.addClass("selected_message");
if (event.then_scroll) {
if (row.length === 0) {
@@ -224,7 +224,7 @@ exports.initialize_kitchen_sink_stuff = function () {
selected_id_from_idx: messages[event.msg_list.selected_idx()].id,
msg_list_sorted: _.isEqual(
messages.map((message) => message.id),
- _.chain(current_msg_list.all_messages()).pluck('id').clone().value().sort(),
+ _.chain(current_msg_list.all_messages()).pluck("id").clone().value().sort(),
),
found_in_dom: row_from_dom.length,
});
@@ -249,16 +249,16 @@ exports.initialize_kitchen_sink_stuff = function () {
timerender.set_full_datetime(message, time_elem);
});
- $('#streams_header h4').tooltip({placement: 'right',
+ $("#streams_header h4").tooltip({placement: "right",
animation: false});
- $('#streams_header i[data-toggle="tooltip"]').tooltip({placement: 'left',
+ $('#streams_header i[data-toggle="tooltip"]').tooltip({placement: "left",
animation: false});
- $('#userlist-header #userlist-title').tooltip({placement: 'right',
+ $("#userlist-header #userlist-title").tooltip({placement: "right",
animation: false});
- $('#userlist-header #user_filter_icon').tooltip({placement: 'left',
+ $("#userlist-header #user_filter_icon").tooltip({placement: "left",
animation: false});
$('.message_failed i[data-toggle="tooltip"]').tooltip();
@@ -267,7 +267,7 @@ exports.initialize_kitchen_sink_stuff = function () {
// We disable animations here because they can cause the tooltip
// to change shape while fading away in weird way.
- $('#keyboard-icon').tooltip({animation: false});
+ $("#keyboard-icon").tooltip({animation: false});
$("body").on("mouseover", ".message_edit_content", function () {
$(this).closest(".message_row").find(".copy_message").show();
@@ -279,11 +279,11 @@ exports.initialize_kitchen_sink_stuff = function () {
$("body").on("mouseenter", ".copy_message", function () {
$(this).show();
- $(this).tooltip('show');
+ $(this).tooltip("show");
});
$("body").on("mouseleave", ".copy_message", function () {
- $(this).tooltip('hide');
+ $(this).tooltip("hide");
});
if (!page_params.realm_allow_message_editing) {
@@ -386,41 +386,41 @@ exports.initialize_everything = function () {
}
const alert_words_params = pop_fields(
- 'alert_words',
+ "alert_words",
);
const bot_params = pop_fields(
- 'realm_bots',
+ "realm_bots",
);
const people_params = pop_fields(
- 'realm_users',
- 'realm_non_active_users',
- 'cross_realm_bots',
+ "realm_users",
+ "realm_non_active_users",
+ "cross_realm_bots",
);
const pm_conversations_params = pop_fields(
- 'recent_private_conversations',
+ "recent_private_conversations",
);
const presence_params = pop_fields(
- 'presences',
- 'initial_servertime',
+ "presences",
+ "initial_servertime",
);
const stream_data_params = pop_fields(
- 'subscriptions',
- 'unsubscribed',
- 'never_subscribed',
- 'realm_default_streams',
+ "subscriptions",
+ "unsubscribed",
+ "never_subscribed",
+ "realm_default_streams",
);
const user_groups_params = pop_fields(
- 'realm_user_groups',
+ "realm_user_groups",
);
const user_status_params = pop_fields(
- 'user_status',
+ "user_status",
);
alert_words.initialize(alert_words_params);
@@ -489,7 +489,7 @@ exports.initialize_everything = function () {
};
$(() => {
- const finish = blueslip.start_timing('initialize_everything');
+ const finish = blueslip.start_timing("initialize_everything");
exports.initialize_everything();
finish();
});
diff --git a/static/js/ui_report.js b/static/js/ui_report.js
index 2af9af51f2e..4ada62569d1 100644
--- a/static/js/ui_report.js
+++ b/static/js/ui_report.js
@@ -6,7 +6,7 @@
exports.message = function (response, status_box, cls, remove_after) {
if (cls === undefined) {
- cls = 'alert';
+ cls = "alert";
}
// Note we use html() below, since we can rely on our callers escaping HTML
@@ -33,11 +33,11 @@ exports.error = function (response, xhr, status_box, remove_after) {
}
}
- exports.message(response, status_box, 'alert-error', remove_after);
+ exports.message(response, status_box, "alert-error", remove_after);
};
exports.success = function (response, status_box, remove_after) {
- exports.message(response, status_box, 'alert-success', remove_after);
+ exports.message(response, status_box, "alert-success", remove_after);
};
exports.generic_embed_error = function (error) {
diff --git a/static/js/ui_util.js b/static/js/ui_util.js
index 12bb553e9bf..34ae02f477f 100644
--- a/static/js/ui_util.js
+++ b/static/js/ui_util.js
@@ -2,7 +2,7 @@
// dependencies other than jQuery.
exports.change_tab_to = function (tabname) {
- $('#gear-menu a[href="' + tabname + '"]').tab('show');
+ $('#gear-menu a[href="' + tabname + '"]').tab("show");
};
// https://stackoverflow.com/questions/4233265/contenteditable-set-caret-at-the-end-of-the-text-cross-browser
@@ -54,7 +54,7 @@ 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 dd8e970bf53..96296e94d31 100644
--- a/static/js/unread.js
+++ b/static/js/unread.js
@@ -1,5 +1,5 @@
const util = require("./util");
-const FoldDict = require('./fold_dict').FoldDict;
+const FoldDict = require("./fold_dict").FoldDict;
// The unread module tracks the message IDs and locations of the
// user's unread messages. The tracking is initialized with
@@ -422,11 +422,11 @@ exports.process_loaded_messages = function (messages) {
unread_messages.add(message.id);
- if (message.type === 'private') {
+ if (message.type === "private") {
exports.unread_pm_counter.add(message);
}
- if (message.type === 'stream') {
+ if (message.type === "stream") {
exports.unread_topic_counter.add(
message.stream_id,
message.topic,
@@ -445,7 +445,7 @@ exports.update_message_for_mention = function (message) {
}
const is_unmuted_mention =
- message.type === 'stream' &&
+ message.type === "stream" &&
message.mentioned &&
!muting.is_topic_muted(message.stream_id, message.topic);
diff --git a/static/js/unread_ops.js b/static/js/unread_ops.js
index 2babfb3f465..1108bf3adfd 100644
--- a/static/js/unread_ops.js
+++ b/static/js/unread_ops.js
@@ -3,7 +3,7 @@ exports.mark_all_as_read = function () {
unread_ui.update_unread_counts();
channel.post({
- url: '/json/mark_all_as_read',
+ url: "/json/mark_all_as_read",
idempotent: true,
success: () => {
// After marking all messages as read, we reload the browser.
@@ -34,7 +34,7 @@ exports.process_read_messages_event = function (message_ids) {
actually read locally (and which we may not have even
loaded locally).
*/
- const options = {from: 'server'};
+ const options = {from: "server"};
message_ids = unread.get_unread_message_ids(message_ids);
if (message_ids.length === 0) {
@@ -107,7 +107,7 @@ exports.mark_current_list_as_read = function (options) {
exports.mark_stream_as_read = function (stream_id, cont) {
channel.post({
- url: '/json/mark_stream_as_read',
+ url: "/json/mark_stream_as_read",
idempotent: true,
data: {stream_id: stream_id},
success: cont,
@@ -116,7 +116,7 @@ exports.mark_stream_as_read = function (stream_id, cont) {
exports.mark_topic_as_read = function (stream_id, topic, cont) {
channel.post({
- url: '/json/mark_topic_as_read',
+ url: "/json/mark_topic_as_read",
idempotent: true,
data: {stream_id: stream_id, topic_name: topic},
success: cont,
diff --git a/static/js/unread_ui.js b/static/js/unread_ui.js
index ab575c497ad..5d693251b31 100644
--- a/static/js/unread_ui.js
+++ b/static/js/unread_ui.js
@@ -22,7 +22,7 @@ exports.animate_mention_changes = function (li, new_mention_count) {
exports.set_count_toggle_button = function (elem, count) {
if (count === 0) {
- if (elem.is(':animated')) {
+ if (elem.is(":animated")) {
return elem.stop(true, true).hide();
}
return elem.hide(500);
diff --git a/static/js/upload.js b/static/js/upload.js
index 70589938273..cf3b2b32d3e 100644
--- a/static/js/upload.js
+++ b/static/js/upload.js
@@ -1,6 +1,6 @@
-const Uppy = require('@uppy/core');
-const XHRUpload = require('@uppy/xhr-upload');
-const ProgressBar = require('@uppy/progress-bar');
+const Uppy = require("@uppy/core");
+const XHRUpload = require("@uppy/xhr-upload");
+const ProgressBar = require("@uppy/progress-bar");
exports.make_upload_absolute = function (uri) {
if (uri.startsWith(compose.uploads_path)) {
@@ -28,17 +28,17 @@ exports.get_item = function (key, config) {
if (config.mode === "compose") {
switch (key) {
case "textarea":
- return $('#compose-textarea');
+ return $("#compose-textarea");
case "send_button":
- return $('#compose-send-button');
+ return $("#compose-send-button");
case "send_status_identifier":
- return '#compose-send-status';
+ return "#compose-send-status";
case "send_status":
- return $('#compose-send-status');
+ return $("#compose-send-status");
case "send_status_close_button":
- return $('.compose-send-status-close');
+ return $(".compose-send-status-close");
case "send_status_message":
- return $('#compose-error-msg');
+ return $("#compose-error-msg");
case "file_input_identifier":
return "#file_input";
case "source":
@@ -54,19 +54,19 @@ exports.get_item = function (key, config) {
}
switch (key) {
case "textarea":
- return $('#message_edit_content_' + config.row);
+ 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;
+ return "#message-edit-send-status-" + config.row;
case "send_status":
- return $('#message-edit-send-status-' + config.row);
+ return $("#message-edit-send-status-" + config.row);
case "send_status_close_button":
- return $('#message-edit-send-status-' + config.row).find('.send-status-close');
+ return $("#message-edit-send-status-" + config.row).find(".send-status-close");
case "send_status_message":
- return $('#message-edit-send-status-' + config.row).find('.error-msg');
+ return $("#message-edit-send-status-" + config.row).find(".error-msg");
case "file_input_identifier":
- return '#message_edit_file_input_' + config.row;
+ return "#message_edit_file_input_" + config.row;
case "source":
return "message-edit-file-input";
case "drag_drop_container":
@@ -98,13 +98,13 @@ 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_message", config).html($("<p>").text(i18n.t("Uploading…")));
- exports.get_item("send_status_close_button", config).one('click', () => {
+ 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));
});
@@ -142,8 +142,8 @@ exports.setup_upload = function (config) {
},
locale: {
strings: {
- exceedsSize: i18n.t('This file exceeds maximum allowed size of'),
- failedToUpload: i18n.t('Failed to upload %{file}'),
+ exceedsSize: i18n.t("This file exceeds maximum allowed size of"),
+ failedToUpload: i18n.t("Failed to upload %{file}"),
},
},
});
@@ -152,14 +152,14 @@ exports.setup_upload = function (config) {
});
uppy.use(
XHRUpload, {
- endpoint: '/json/user_uploads',
+ endpoint: "/json/user_uploads",
formData: true,
- fieldName: 'file',
+ fieldName: "file",
// Number of concurrent uploads
limit: 5,
locale: {
strings: {
- timedOut: i18n.t('Upload stalled for %{seconds} seconds, aborting.'),
+ timedOut: i18n.t("Upload stalled for %{seconds} seconds, aborting."),
},
},
},
@@ -203,7 +203,7 @@ exports.setup_upload = function (config) {
exports.upload_files(uppy, config, files);
});
- uppy.on('upload-success', (file, response) => {
+ uppy.on("upload-success", (file, response) => {
const uri = response.body.uri;
if (uri === undefined) {
return;
@@ -211,7 +211,7 @@ exports.setup_upload = function (config) {
const split_uri = uri.split("/");
const filename = split_uri[split_uri.length - 1];
if (!compose_state.composing()) {
- compose_actions.start('stream');
+ compose_actions.start("stream");
}
const absolute_uri = exports.make_upload_absolute(uri);
const filename_uri = "[" + filename + "](" + absolute_uri + ")";
@@ -219,7 +219,7 @@ exports.setup_upload = function (config) {
compose_ui.autosize_textarea();
});
- uppy.on('complete', () => {
+ uppy.on("complete", () => {
let uploads_in_progress = false;
uppy.getFiles().forEach((file) => {
if (file.progress.uploadComplete) {
@@ -242,7 +242,7 @@ exports.setup_upload = function (config) {
}
});
- uppy.on('info-visible', () => {
+ uppy.on("info-visible", () => {
const info = uppy.getState().info;
if (info.type === "error" && info.message === "No Internet connection") {
// server_events already handles the case of no internet.
@@ -264,7 +264,7 @@ exports.setup_upload = function (config) {
}
});
- uppy.on('upload-error', (file, error, response) => {
+ uppy.on("upload-error", (file, error, response) => {
const message = response ? response.body.msg : null;
uppy.cancelAll();
exports.show_error_message(config, message);
@@ -272,7 +272,7 @@ exports.setup_upload = function (config) {
compose_ui.autosize_textarea();
});
- uppy.on('restriction-failed', (file) => {
+ uppy.on("restriction-failed", (file) => {
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 192223b3105..f7ece690f00 100644
--- a/static/js/upload_widget.js
+++ b/static/js/upload_widget.js
@@ -1,10 +1,10 @@
const default_max_file_size = 5;
const supported_types = [
- 'image/jpeg',
- 'image/png',
- 'image/gif',
- 'image/tiff',
+ "image/jpeg",
+ "image/png",
+ "image/gif",
+ "image/tiff",
];
function is_image_format(file) {
@@ -35,15 +35,15 @@ exports.build_widget = function (
upload_button.hide();
if (preview_text !== null) {
const image_blob = URL.createObjectURL(file);
- preview_image.attr('src', image_blob);
+ preview_image.attr("src", image_blob);
preview_text.show();
}
}
function clear() {
const control = get_file_input();
- control.val('');
- file_name_field.text('');
+ control.val("");
+ file_name_field.text("");
clear_button.hide();
upload_button.show();
if (preview_text !== null) {
@@ -53,12 +53,12 @@ exports.build_widget = function (
- clear_button.on('click', (e) => {
+ clear_button.on("click", (e) => {
clear();
e.preventDefault();
});
- upload_button.on('drop', (e) => {
+ upload_button.on("drop", (e) => {
const files = e.dataTransfer.files;
if (files === null || files === undefined || files.length === 0) {
return false;
@@ -68,41 +68,41 @@ exports.build_widget = function (
return false;
});
- get_file_input().attr('accept', supported_types.toString());
- get_file_input().on('change', (e) => {
+ get_file_input().attr("accept", supported_types.toString());
+ get_file_input().on("change", (e) => {
if (e.target.files.length === 0) {
input_error.hide();
} 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.', {
+ 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)) {
- input_error.text(i18n.t('File type is not supported.'));
+ input_error.text(i18n.t("File type is not supported."));
input_error.show();
clear();
} else {
accept(file);
}
} else {
- input_error.text(i18n.t('Please just upload one file.'));
+ input_error.text(i18n.t("Please just upload one file."));
}
});
- upload_button.on('click', (e) => {
- get_file_input().trigger('click');
+ upload_button.on("click", (e) => {
+ get_file_input().trigger("click");
e.preventDefault();
});
function close() {
clear();
- clear_button.off('click');
- upload_button.off('drop');
- get_file_input().off('change');
- upload_button.off('click');
+ clear_button.off("click");
+ upload_button.off("drop");
+ get_file_input().off("change");
+ upload_button.off("click");
}
return {
@@ -126,9 +126,9 @@ exports.build_direct_upload_widget = function (
function accept() {
input_error.hide();
const realm_logo_section = upload_button.closest(".avatar-icon-logo-settings");
- if (realm_logo_section.attr('id') === "realm-night-logo-upload-widget") {
+ if (realm_logo_section.attr("id") === "realm-night-logo-upload-widget") {
upload_function(get_file_input(), true, false);
- } else if (realm_logo_section.attr('id') === "realm-day-logo-upload-widget") {
+ } else if (realm_logo_section.attr("id") === "realm-day-logo-upload-widget") {
upload_function(get_file_input(), false, false);
} else {
upload_function(get_file_input(), null, true);
@@ -137,10 +137,10 @@ exports.build_direct_upload_widget = function (
function clear() {
const control = get_file_input();
- control.val('');
+ control.val("");
}
- upload_button.on('drop', (e) => {
+ upload_button.on("drop", (e) => {
const files = e.dataTransfer.files;
if (files === null || files === undefined || files.length === 0) {
return false;
@@ -150,32 +150,32 @@ exports.build_direct_upload_widget = function (
return false;
});
- get_file_input().attr('accept', supported_types.toString());
- get_file_input().on('change', (e) => {
+ get_file_input().attr("accept", supported_types.toString());
+ get_file_input().on("change", (e) => {
if (e.target.files.length === 0) {
input_error.hide();
} 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.', {
+ 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)) {
- input_error.text(i18n.t('File type is not supported.'));
+ input_error.text(i18n.t("File type is not supported."));
input_error.show();
clear();
} else {
accept();
}
} else {
- input_error.text(i18n.t('Please just upload one file.'));
+ input_error.text(i18n.t("Please just upload one file."));
}
});
- upload_button.on('click', (e) => {
- get_file_input().trigger('click');
+ upload_button.on("click", (e) => {
+ get_file_input().trigger("click");
e.preventDefault();
});
};
diff --git a/static/js/user_events.js b/static/js/user_events.js
index 44fdf4d9db6..bd5527c02ae 100644
--- a/static/js/user_events.js
+++ b/static/js/user_events.js
@@ -2,7 +2,7 @@
// server_events.js simple while breaking some circular
// dependencies that existed when this code was in people.js.
// (We should do bot updates here too.)
-const settings_config = require('./settings_config');
+const settings_config = require("./settings_config");
exports.update_person = function update(person) {
const person_obj = people.get_by_user_id(person.user_id);
@@ -11,7 +11,7 @@ exports.update_person = function update(person) {
return;
}
- if (Object.prototype.hasOwnProperty.call(person, 'new_email')) {
+ if (Object.prototype.hasOwnProperty.call(person, "new_email")) {
const user_id = person.user_id;
const new_email = person.new_email;
@@ -25,7 +25,7 @@ exports.update_person = function update(person) {
people.update_email(user_id, new_email);
}
- if (Object.prototype.hasOwnProperty.call(person, 'delivery_email')) {
+ if (Object.prototype.hasOwnProperty.call(person, "delivery_email")) {
const delivery_email = person.delivery_email;
if (people.is_my_user_id(person.user_id)) {
@@ -34,7 +34,7 @@ exports.update_person = function update(person) {
}
}
- if (Object.prototype.hasOwnProperty.call(person, 'full_name')) {
+ if (Object.prototype.hasOwnProperty.call(person, "full_name")) {
people.set_full_name(person_obj, person.full_name);
settings_users.update_user_data(person.user_id, person);
@@ -47,7 +47,7 @@ exports.update_person = function update(person) {
}
}
- if (Object.prototype.hasOwnProperty.call(person, 'role')) {
+ 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;
@@ -69,7 +69,7 @@ exports.update_person = function update(person) {
}
}
- if (Object.prototype.hasOwnProperty.call(person, 'avatar_url')) {
+ if (Object.prototype.hasOwnProperty.call(person, "avatar_url")) {
const url = person.avatar_url;
person_obj.avatar_url = url;
person_obj.avatar_version = person.avatar_version;
@@ -84,15 +84,15 @@ exports.update_person = function update(person) {
message_live_update.update_avatar(person_obj.user_id, person.avatar_url);
}
- if (Object.prototype.hasOwnProperty.call(person, 'custom_profile_field')) {
+ if (Object.prototype.hasOwnProperty.call(person, "custom_profile_field")) {
people.set_custom_profile_field_data(person.user_id, person.custom_profile_field);
}
- if (Object.prototype.hasOwnProperty.call(person, 'timezone')) {
+ if (Object.prototype.hasOwnProperty.call(person, "timezone")) {
person_obj.timezone = person.timezone;
}
- if (Object.prototype.hasOwnProperty.call(person, 'bot_owner_id')) {
+ if (Object.prototype.hasOwnProperty.call(person, "bot_owner_id")) {
person_obj.bot_owner_id = person.bot_owner_id;
}
};
diff --git a/static/js/user_groups.js b/static/js/user_groups.js
index f9b20b3b2ef..1f899f41868 100644
--- a/static/js/user_groups.js
+++ b/static/js/user_groups.js
@@ -1,4 +1,4 @@
-const FoldDict = require('./fold_dict').FoldDict;
+const FoldDict = require("./fold_dict").FoldDict;
let user_group_name_dict;
let user_group_by_id_dict;
@@ -28,7 +28,7 @@ exports.remove = function (user_group) {
exports.get_user_group_from_id = function (group_id, suppress_errors) {
if (!user_group_by_id_dict.has(group_id)) {
if (suppress_errors === undefined) {
- blueslip.error('Unknown group_id in get_user_group_from_id: ' + group_id);
+ blueslip.error("Unknown group_id in get_user_group_from_id: " + group_id);
}
return;
}
diff --git a/static/js/user_pill.js b/static/js/user_pill.js
index 26943d1725e..8ba6289484b 100644
--- a/static/js/user_pill.js
+++ b/static/js/user_pill.js
@@ -104,7 +104,7 @@ exports.append_user = function (user, pills) {
person: user,
});
} else {
- blueslip.warn('Undefined user in function append_user');
+ blueslip.warn("Undefined user in function append_user");
}
};
diff --git a/static/js/user_search.js b/static/js/user_search.js
index b95a97a3a2f..4fb9bfa22c0 100644
--- a/static/js/user_search.js
+++ b/static/js/user_search.js
@@ -5,8 +5,8 @@ const user_search = function (opts) {
const self = {};
- const $widget = $('#user_search_section').expectOne();
- const $input = $('.user-list-filter').expectOne();
+ const $widget = $("#user_search_section").expectOne();
+ const $input = $(".user-list-filter").expectOne();
self.input_field = function () {
return $input;
@@ -17,11 +17,11 @@ const user_search = function (opts) {
};
self.searching = function () {
- return $input.is(':focus');
+ return $input.is(":focus");
};
self.empty = function () {
- return self.text() === '';
+ return self.text() === "";
};
self.clear_search = function () {
@@ -30,7 +30,7 @@ const user_search = function (opts) {
return;
}
- $input.val('');
+ $input.val("");
$input.blur();
opts.reset_items();
};
@@ -41,12 +41,12 @@ const user_search = function (opts) {
return;
}
- $input.val('');
+ $input.val("");
opts.update_list();
};
self.hide_widget = function () {
- $widget.addClass('notdisplayed');
+ $widget.addClass("notdisplayed");
resize.resize_sidebars();
};
@@ -54,17 +54,17 @@ const user_search = function (opts) {
// Hide all the popovers but not userlist sidebar
// when the user wants to search.
popovers.hide_all_except_sidebars();
- $widget.removeClass('notdisplayed');
+ $widget.removeClass("notdisplayed");
resize.resize_sidebars();
};
self.widget_shown = function () {
- return $widget.hasClass('notdisplayed');
+ return $widget.hasClass("notdisplayed");
};
self.clear_and_hide_search = function () {
if (!self.empty()) {
- $input.val('');
+ $input.val("");
opts.update_list();
}
self.close_widget();
@@ -80,9 +80,9 @@ const user_search = function (opts) {
const column = $input.closest(".app-main [class^='column-']");
if (!column.hasClass("expanded")) {
popovers.hide_all();
- if (column.hasClass('column-left')) {
+ if (column.hasClass("column-left")) {
stream_popover.show_streamlist_sidebar();
- } else if (column.hasClass('column-right')) {
+ } else if (column.hasClass("column-right")) {
popovers.show_userlist_sidebar();
}
}
@@ -107,11 +107,11 @@ const user_search = function (opts) {
e.stopPropagation();
}
- $('#clear_search_people_button').on('click', self.clear_search);
- $('#userlist-header').on('click', self.toggle_filter_displayed);
+ $("#clear_search_people_button").on("click", self.clear_search);
+ $("#userlist-header").on("click", self.toggle_filter_displayed);
- $input.on('input', opts.update_list);
- $input.on('focus', on_focus);
+ $input.on("input", opts.update_list);
+ $input.on("focus", on_focus);
return self;
};
diff --git a/static/js/user_status.js b/static/js/user_status.js
index f231e1a2c60..9daa276e1cf 100644
--- a/static/js/user_status.js
+++ b/static/js/user_status.js
@@ -3,7 +3,7 @@ const user_info = new Map();
exports.server_update = function (opts) {
channel.post({
- url: '/json/users/me/status',
+ url: "/json/users/me/status",
data: {
away: opts.away,
status_text: opts.status_text,
@@ -26,15 +26,15 @@ exports.server_revoke_away = function () {
};
exports.set_away = function (user_id) {
- if (typeof user_id !== 'number') {
- blueslip.error('need ints for user_id');
+ if (typeof user_id !== "number") {
+ blueslip.error("need ints for user_id");
}
away_user_ids.add(user_id);
};
exports.revoke_away = function (user_id) {
- if (typeof user_id !== 'number') {
- blueslip.error('need ints for user_id');
+ if (typeof user_id !== "number") {
+ blueslip.error("need ints for user_id");
}
away_user_ids.delete(user_id);
};
diff --git a/static/js/user_status_ui.js b/static/js/user_status_ui.js
index e20071f7fab..1370f46eb21 100644
--- a/static/js/user_status_ui.js
+++ b/static/js/user_status_ui.js
@@ -1,15 +1,15 @@
exports.input_field = function () {
- return $('.user_status_overlay input.user_status');
+ return $(".user_status_overlay input.user_status");
};
exports.submit_button = function () {
- return $('.user_status_overlay .set_user_status');
+ return $(".user_status_overlay .set_user_status");
};
exports.open_overlay = function () {
const overlay = $(".user_status_overlay");
overlays.open_overlay({
- name: 'user_status_overlay',
+ name: "user_status_overlay",
overlay: overlay,
on_close: function () {},
});
@@ -23,16 +23,16 @@ exports.open_overlay = function () {
exports.toggle_clear_message_button();
const button = exports.submit_button();
- button.attr('disabled', true);
+ button.attr("disabled", true);
};
exports.close_overlay = function () {
- overlays.close_overlay('user_status_overlay');
+ overlays.close_overlay("user_status_overlay");
};
exports.submit_new_status = function () {
const user_id = people.my_current_user_id();
- let old_status_text = user_status.get_status_text(user_id) || '';
+ let old_status_text = user_status.get_status_text(user_id) || "";
old_status_text = old_status_text.trim();
const new_status_text = exports.input_field().val().trim();
@@ -51,51 +51,51 @@ exports.submit_new_status = function () {
exports.update_button = function () {
const user_id = people.my_current_user_id();
- let old_status_text = user_status.get_status_text(user_id) || '';
+ let old_status_text = user_status.get_status_text(user_id) || "";
old_status_text = old_status_text.trim();
const new_status_text = exports.input_field().val().trim();
const button = exports.submit_button();
if (old_status_text === new_status_text) {
- button.attr('disabled', true);
+ button.attr("disabled", true);
} else {
- button.attr('disabled', false);
+ button.attr("disabled", false);
}
};
exports.toggle_clear_message_button = function () {
- if (exports.input_field().val() !== '') {
- $('#clear_status_message_button').prop('disabled', false);
+ if (exports.input_field().val() !== "") {
+ $("#clear_status_message_button").prop("disabled", false);
} else {
- $('#clear_status_message_button').prop('disabled', true);
+ $("#clear_status_message_button").prop("disabled", true);
}
};
exports.clear_message = function () {
const field = exports.input_field();
- field.val('');
- $('#clear_status_message_button').prop('disabled', true);
+ field.val("");
+ $("#clear_status_message_button").prop("disabled", true);
};
exports.initialize = function () {
- $('body').on('click', '.user_status_overlay .set_user_status', () => {
+ $("body").on("click", ".user_status_overlay .set_user_status", () => {
exports.submit_new_status();
});
- $('body').on('keypress', '.user_status_overlay .user_status', (event) => {
- if (event.key === 'Enter') {
+ $("body").on("keypress", ".user_status_overlay .user_status", (event) => {
+ if (event.key === "Enter") {
event.preventDefault();
exports.submit_new_status();
}
});
- $('body').on('keyup', '.user_status_overlay input.user_status', () => {
+ $("body").on("keyup", ".user_status_overlay input.user_status", () => {
exports.update_button();
exports.toggle_clear_message_button();
});
- $('#clear_status_message_button').on('click', () => {
+ $("#clear_status_message_button").on("click", () => {
exports.clear_message();
exports.update_button();
});
diff --git a/static/js/util.js b/static/js/util.js
index 4e6f0eea39a..f4467118400 100644
--- a/static/js/util.js
+++ b/static/js/util.js
@@ -63,7 +63,7 @@ exports.same_stream_and_topic = function util_same_stream_and_topic(a, b) {
};
exports.is_pm_recipient = function (user_id, message) {
- const recipients = message.to_user_ids.split(',');
+ const recipients = message.to_user_ids.split(",");
return recipients.includes(user_id.toString());
};
@@ -80,12 +80,12 @@ exports.same_recipient = function util_same_recipient(a, b) {
}
switch (a.type) {
- case 'private':
+ case "private":
if (a.to_user_ids === undefined) {
return false;
}
return a.to_user_ids === b.to_user_ids;
- case 'stream':
+ case "stream":
return exports.same_stream_and_topic(a, b);
}
@@ -102,11 +102,11 @@ exports.normalize_recipients = function (recipients) {
// Converts a string listing emails of message recipients
// into a canonical formatting: emails sorted ASCIIbetically
// with exactly one comma and no spaces between each.
- recipients = recipients.split(',').map((s) => s.trim());
+ recipients = recipients.split(",").map((s) => s.trim());
recipients = recipients.map((s) => s.toLowerCase());
recipients = recipients.filter((s) => s.length > 0);
recipients.sort();
- return recipients.join(',');
+ return recipients.join(",");
};
// Avoid URI decode errors by removing characters from the end
@@ -125,7 +125,7 @@ exports.robust_uri_decode = function (str) {
end -= 1;
}
}
- return '';
+ return "";
};
// If we can, use a locale-aware sorter. However, if the browser
@@ -239,14 +239,14 @@ exports.get_match_topic = function (obj) {
exports.get_draft_topic = function (obj) {
// We will need to support subject for old drafts.
- return obj.topic || obj.subject || '';
+ return obj.topic || obj.subject || "";
};
exports.get_reload_topic = function (obj) {
// When we first upgrade to releases that have
// topic=foo in the code, the user's reload URL
// may still have subject=foo from the prior version.
- return obj.topic || obj.subject || '';
+ return obj.topic || obj.subject || "";
};
exports.get_edit_event_topic = function (obj) {
@@ -268,7 +268,7 @@ exports.get_edit_event_prev_topic = function (obj) {
};
exports.is_topic_synonym = function (operator) {
- return operator === 'subject';
+ return operator === "subject";
};
exports.convert_message_topic = function (message) {
diff --git a/static/js/vdom.js b/static/js/vdom.js
index 18e856edb70..7bf03bbf410 100644
--- a/static/js/vdom.js
+++ b/static/js/vdom.js
@@ -17,7 +17,7 @@ exports.eq_array = (a, b, eq) => {
};
exports.ul = (opts) => ({
- tag_name: 'ul',
+ tag_name: "ul",
opts: opts,
});
@@ -35,18 +35,18 @@ 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 + '>';
+ const start_tag = "<" + tag_name + attr_str + ">";
+ const end_tag = "</" + tag_name + ">";
if (opts.keyed_nodes === undefined) {
blueslip.error("We need keyed_nodes to render innards.");
return;
}
- const innards = opts.keyed_nodes.map((node) => node.render()).join('\n');
- return start_tag + '\n' + innards + '\n' + end_tag;
+ const innards = opts.keyed_nodes.map((node) => node.render()).join("\n");
+ return start_tag + "\n" + innards + "\n" + end_tag;
};
exports.update = (replace_content, find, new_dom, old_dom) => {
diff --git a/static/js/widgetize.js b/static/js/widgetize.js
index 637ed4fc0ee..f147f8deed7 100644
--- a/static/js/widgetize.js
+++ b/static/js/widgetize.js
@@ -9,7 +9,7 @@ const widget_contents = new Map();
exports.widget_contents = widget_contents;
function set_widget_in_message(row, widget_elem) {
- const content_holder = row.find('.message_content');
+ const content_holder = row.find(".message_content");
content_holder.empty().append(widget_elem);
}
@@ -24,18 +24,18 @@ exports.activate = function (in_opts) {
events.shift();
if (!widgets.has(widget_type)) {
- blueslip.warn('unknown widget_type', widget_type);
+ blueslip.warn("unknown widget_type", widget_type);
return;
}
const callback = function (data) {
post_to_server({
- msg_type: 'widget',
+ msg_type: "widget",
data: data,
});
};
- if (row.attr('id').startsWith('zhome') && narrow_state.active()) {
+ if (row.attr("id").startsWith("zhome") && narrow_state.active()) {
// Don't place widget in a home message row if we are narrowed
// to active state
return;
@@ -49,7 +49,7 @@ exports.activate = function (in_opts) {
// We depend on our widgets to use templates to build
// the HTML that will eventually go in this div.
- widget_elem = $('<div>').addClass('widget-content');
+ widget_elem = $("<div>").addClass("widget-content");
widgets.get(widget_type).activate({
elem: widget_elem,
diff --git a/static/js/zcommand.js b/static/js/zcommand.js
index 7bbb17fd0e3..76e1bb7cae5 100644
--- a/static/js/zcommand.js
+++ b/static/js/zcommand.js
@@ -24,7 +24,7 @@ exports.send = function (opts) {
};
channel.post({
- url: '/json/zcommand',
+ url: "/json/zcommand",
data: data,
success: function (data) {
if (on_success) {
@@ -32,7 +32,7 @@ exports.send = function (opts) {
}
},
error: function () {
- exports.tell_user('server did not respond');
+ exports.tell_user("server did not respond");
},
});
};
@@ -40,10 +40,10 @@ 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)
- .addClass('alert-error')
+ $("#compose-send-status").removeClass(common.status_classes)
+ .addClass("alert-error")
.stop(true).fadeTo(0, 1);
- $('#compose-error-msg').text(msg);
+ $("#compose-error-msg").text(msg);
};
exports.enter_day_mode = function () {
@@ -138,7 +138,7 @@ exports.process = function (message_content) {
const content = message_content.trim();
- if (content === '/ping') {
+ if (content === "/ping") {
const start_time = new Date();
exports.send({
@@ -154,30 +154,30 @@ exports.process = function (message_content) {
return true;
}
- const day_commands = ['/day', '/light'];
+ const day_commands = ["/day", "/light"];
if (day_commands.includes(content)) {
exports.enter_day_mode();
return true;
}
- const night_commands = ['/night', '/dark'];
+ const night_commands = ["/night", "/dark"];
if (night_commands.includes(content)) {
exports.enter_night_mode();
return true;
}
- if (content === '/fluid-width') {
+ if (content === "/fluid-width") {
exports.enter_fluid_mode();
return true;
}
- if (content === '/fixed-width') {
+ if (content === "/fixed-width") {
exports.enter_fixed_mode();
return true;
}
- if (content === '/settings') {
- hashchange.go_to_location('settings/your-account');
+ if (content === "/settings") {
+ hashchange.go_to_location("settings/your-account");
return true;
}
diff --git a/static/js/zform.js b/static/js/zform.js
index 9e78e128ed0..c29f71ce0c5 100644
--- a/static/js/zform.js
+++ b/static/js/zform.js
@@ -1,4 +1,4 @@
-const render_widgets_zform_choices = require('../templates/widgets/zform_choices.hbs');
+const render_widgets_zform_choices = require("../templates/widgets/zform_choices.hbs");
exports.validate_extra_data = function (data) {
function check(data) {
@@ -19,17 +19,17 @@ exports.validate_extra_data = function (data) {
);
}
- return schema.check_record('zform data', data, {
+ return schema.check_record("zform data", data, {
heading: schema.check_string,
choices: check_choices,
});
}
- if (data.type === 'choices') {
+ if (data.type === "choices") {
return check_choice_data(data);
}
- return 'unknown zform type: ' + data.type;
+ return "unknown zform type: " + data.type;
}
@@ -65,11 +65,11 @@ exports.activate = function (opts) {
const html = render_widgets_zform_choices(data);
const elem = $(html);
- elem.find('button').on('click', (e) => {
+ elem.find("button").on("click", (e) => {
e.stopPropagation();
// Grab our index from the markup.
- const idx = $(e.target).attr('data-idx');
+ const idx = $(e.target).attr("data-idx");
// Use the index from the markup to dereference our
// data structure.
@@ -87,7 +87,7 @@ exports.activate = function (opts) {
function render() {
let rendered_widget;
- if (data.type === 'choices') {
+ if (data.type === "choices") {
rendered_widget = make_choices(data);
outer_elem.html(rendered_widget);
}
@@ -95,7 +95,7 @@ exports.activate = function (opts) {
self.handle_events = function (events) {
if (events) {
- blueslip.info('unexpected');
+ blueslip.info("unexpected");
}
render();
};
diff --git a/static/js/zulip.js b/static/js/zulip.js
index 34c600d9f25..30632fa5abb 100644
--- a/static/js/zulip.js
+++ b/static/js/zulip.js
@@ -3,7 +3,7 @@
// modules). Please don't add things here.
const home_msg_list = new message_list.MessageList({
- table_name: 'zhome',
+ table_name: "zhome",
filter: new Filter([{operator: "in", operand: "home"}]),
muting_enabled: true,
});
diff --git a/static/shared/js/typeahead.js b/static/shared/js/typeahead.js
index dac446245c5..025aeccd6f6 100644
--- a/static/shared/js/typeahead.js
+++ b/static/shared/js/typeahead.js
@@ -20,12 +20,12 @@
prefix matches trumping "popularity".
*/
export const popular_emojis = [
- '1f44d', // +1
- '1f389', // tada
- '1f642', // slight_smile
- '2764', // heart
- '1f6e0', // working_on_it
- '1f419', // octopus
+ "1f44d", // +1
+ "1f389", // tada
+ "1f642", // slight_smile
+ "2764", // heart
+ "1f6e0", // working_on_it
+ "1f419", // octopus
];
const unicode_marks = /\p{M}/gu;
@@ -150,7 +150,7 @@ export function sort_emojis(objs, query) {
const lowerQuery = query.toLowerCase();
function decent_match(name) {
- const pieces = name.toLowerCase().split('_');
+ const pieces = name.toLowerCase().split("_");
return pieces.some((piece) => piece.startsWith(lowerQuery));
}
diff --git a/tools/check-openapi b/tools/check-openapi
index 3ac5f07f3a1..25abfd294da 100755
--- a/tools/check-openapi
+++ b/tools/check-openapi
@@ -1,9 +1,9 @@
#!/usr/bin/env node
-const fs = require('fs');
-const jsyaml = require('js-yaml');
-const SwaggerParser = require('swagger-parser');
-const ExampleValidator = require('openapi-examples-validator');
+const fs = require("fs");
+const jsyaml = require("js-yaml");
+const SwaggerParser = require("swagger-parser");
+const ExampleValidator = require("openapi-examples-validator");
(async () => {
// Iterate through the changed files, passed in the arguments.
@@ -12,7 +12,7 @@ const ExampleValidator = require('openapi-examples-validator');
for (const file of process.argv.slice(2)) {
try {
if (
- jsyaml.safeLoad(await fs.promises.readFile(file, 'utf8'), {
+ jsyaml.safeLoad(await fs.promises.readFile(file, "utf8"), {
filename: file,
}).openapi !== undefined
) {
diff --git a/tools/message-screenshot.js b/tools/message-screenshot.js
index 384d20d6c2c..96a47899bca 100644
--- a/tools/message-screenshot.js
+++ b/tools/message-screenshot.js
@@ -6,7 +6,7 @@ const host = "localhost:9991";
const options = {};
commander
- .arguments('<message_id> <image_path>')
+ .arguments("<message_id> <image_path>")
.action((messageId, imagePath) => {
options.messageId = messageId;
options.imagePath = imagePath;
@@ -15,7 +15,7 @@ commander
.parse(process.argv);
if (options.messageId === undefined) {
- console.error('no messageId specified!');
+ console.error("no messageId specified!");
process.exit(1);
}
@@ -23,10 +23,10 @@ if (options.messageId === undefined) {
async function run() {
const browser = await puppeteer.launch({
args: [
- '--window-size=1400,1024',
- '--no-sandbox', '--disable-setuid-sandbox',
+ "--window-size=1400,1024",
+ "--no-sandbox", "--disable-setuid-sandbox",
// Helps render fonts correctly on Ubuntu: https://github.com/puppeteer/puppeteer/issues/661
- '--font-render-hinting=none',
+ "--font-render-hinting=none",
],
defaultViewport: null,
headless: true,
@@ -35,13 +35,13 @@ async function run() {
const page = await browser.newPage();
// deviceScaleFactor:2 gives better quality screenshots (higher pixel density)
await page.setViewport({ width: 1280, height: 1024, deviceScaleFactor: 2 });
- await page.goto('http://' + host);
+ await page.goto("http://" + host);
// wait for Iago devlogin button and click on it.
await page.waitForSelector('[value="[email protected]"]');
// By waiting till DOMContentLoaded we're confirming that Iago is logged in.
await Promise.all([
- page.waitForNavigation({ waitUntil: 'domcontentloaded' }),
+ page.waitForNavigation({ waitUntil: "domcontentloaded" }),
page.click('[value="[email protected]"]'),
]);
@@ -54,7 +54,7 @@ async function run() {
await page.evaluate((sel) => $(sel).remove(), marker); // eslint-disable-line no-undef
await page.evaluate(() => navigate.up()); // eslint-disable-line no-undef
const messageBox = await page.$(messageSelector);
- const messageGroup = (await messageBox.$x('..'))[0];
+ const messageGroup = (await messageBox.$x(".."))[0];
// Compute screenshot area, with some padding around the message group
const clip = Object.assign({}, await messageGroup.boundingBox());
clip.y -= 5;
diff --git a/tools/webpack-helpers.ts b/tools/webpack-helpers.ts
index 52f9b015a89..69c4c211015 100644
--- a/tools/webpack-helpers.ts
+++ b/tools/webpack-helpers.ts
@@ -1,10 +1,10 @@
-import { RuleSetRule, RuleSetUseItem } from 'webpack';
-import { basename, resolve } from 'path';
+import { RuleSetRule, RuleSetUseItem } from "webpack";
+import { basename, resolve } from "path";
export const cacheLoader: RuleSetUseItem = {
- loader: 'cache-loader',
+ loader: "cache-loader",
options: {
- cacheDirectory: resolve(__dirname, '../var/webpack-cache'),
+ cacheDirectory: resolve(__dirname, "../var/webpack-cache"),
},
};
@@ -33,17 +33,17 @@ function getExposeLoaders(optionsArr: ExportLoaderOptions[]): RuleSetRule[] {
const useArr = [cacheLoader];
// If no name is provided, infer it
if (!loaderEntry.name) {
- name = basename(path, '.js');
- useArr.push({loader: 'expose-loader', options: name});
+ name = basename(path, ".js");
+ useArr.push({loader: "expose-loader", options: name});
} else {
// If name is an array
if (Array.isArray(loaderEntry.name)) {
for (const exposeName of loaderEntry.name) {
- useArr.push({loader: 'expose-loader', options: exposeName});
+ useArr.push({loader: "expose-loader", options: exposeName});
}
// If name is a string
} else {
- useArr.push({loader: 'expose-loader', options: loaderEntry.name});
+ useArr.push({loader: "expose-loader", options: loaderEntry.name});
}
}
exposeLoaders.push({
diff --git a/tools/webpack.config.ts b/tools/webpack.config.ts
index b10e84fa110..6f824eed751 100644
--- a/tools/webpack.config.ts
+++ b/tools/webpack.config.ts
@@ -1,17 +1,17 @@
-import { basename, resolve } from 'path';
-import { cacheLoader, getExposeLoaders } from './webpack-helpers';
-import BundleTracker from 'webpack4-bundle-tracker';
-import CleanCss from 'clean-css';
-import DebugRequirePlugin from './debug-require-webpack-plugin';
-import HtmlWebpackPlugin from 'html-webpack-plugin';
-import MiniCssExtractPlugin from 'mini-css-extract-plugin';
-import OptimizeCssAssetsPlugin from 'optimize-css-assets-webpack-plugin';
-import TerserPlugin from 'terser-webpack-plugin';
+import { basename, resolve } from "path";
+import { cacheLoader, getExposeLoaders } from "./webpack-helpers";
+import BundleTracker from "webpack4-bundle-tracker";
+import CleanCss from "clean-css";
+import DebugRequirePlugin from "./debug-require-webpack-plugin";
+import HtmlWebpackPlugin from "html-webpack-plugin";
+import MiniCssExtractPlugin from "mini-css-extract-plugin";
+import OptimizeCssAssetsPlugin from "optimize-css-assets-webpack-plugin";
+import TerserPlugin from "terser-webpack-plugin";
// The devServer member of webpack.Configuration is managed by the
// webpack-dev-server package. We are only importing the type here.
-import _webpackDevServer from 'webpack-dev-server';
-import assets from './webpack.assets.json';
-import webpack from 'webpack';
+import _webpackDevServer from "webpack-dev-server";
+import assets from "./webpack.assets.json";
+import webpack from "webpack";
export default (env?: string): webpack.Configuration[] => {
const production: boolean = env === "production";
@@ -28,16 +28,16 @@ export default (env?: string): webpack.Configuration[] => {
use: [
MiniCssExtractPlugin.loader,
{
- loader: 'css-loader',
+ loader: "css-loader",
options: {
url: false, // webfonts-loader generates public relative URLs
},
},
{
- loader: 'webfonts-loader',
+ loader: "webfonts-loader",
options: {
- fileName: production ? 'files/[fontname].[chunkhash].[ext]' : 'files/[fontname].[ext]',
- publicPath: '',
+ fileName: production ? "files/[fontname].[chunkhash].[ext]" : "files/[fontname].[ext]",
+ publicPath: "",
},
},
],
@@ -46,10 +46,10 @@ export default (env?: string): webpack.Configuration[] => {
{
test: /\.(js|ts)$/,
include: [
- resolve(__dirname, '../static/shared/js'),
- resolve(__dirname, '../static/js'),
+ resolve(__dirname, "../static/shared/js"),
+ resolve(__dirname, "../static/js"),
],
- use: [cacheLoader, 'babel-loader'],
+ use: [cacheLoader, "babel-loader"],
},
// Uses script-loader on minified files so we don't change global variables in them.
// Also has the effect of making processing these files fast
@@ -58,7 +58,7 @@ export default (env?: string): webpack.Configuration[] => {
{
// We dont want to match admin.js
test: /(\.min|min\.|zxcvbn)\.js/,
- use: [cacheLoader, 'script-loader'],
+ use: [cacheLoader, "script-loader"],
},
// regular css files
{
@@ -72,7 +72,7 @@ export default (env?: string): webpack.Configuration[] => {
},
cacheLoader,
{
- loader: 'css-loader',
+ loader: "css-loader",
options: {
sourceMap: true,
},
@@ -82,7 +82,7 @@ export default (env?: string): webpack.Configuration[] => {
// scss loader
{
test: /\.scss$/,
- include: resolve(__dirname, '../static/styles'),
+ include: resolve(__dirname, "../static/styles"),
use: [
{
loader: MiniCssExtractPlugin.loader,
@@ -92,14 +92,14 @@ export default (env?: string): webpack.Configuration[] => {
},
cacheLoader,
{
- loader: 'css-loader',
+ loader: "css-loader",
options: {
importLoaders: 1,
sourceMap: true,
},
},
{
- loader: 'postcss-loader',
+ loader: "postcss-loader",
options: {
sourceMap: true,
},
@@ -111,14 +111,14 @@ export default (env?: string): webpack.Configuration[] => {
use: [
cacheLoader,
{
- loader: 'handlebars-loader',
+ loader: "handlebars-loader",
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,
},
@@ -129,19 +129,19 @@ export default (env?: string): webpack.Configuration[] => {
{
test: /\.(woff(2)?|ttf|eot|svg|otf|png)$/,
use: [{
- loader: 'file-loader',
+ loader: "file-loader",
options: {
- name: production ? '[name].[hash].[ext]' : '[path][name].[ext]',
- outputPath: 'files/',
+ name: production ? "[name].[hash].[ext]" : "[path][name].[ext]",
+ outputPath: "files/",
},
}],
},
],
},
output: {
- path: resolve(__dirname, '../static/webpack-bundles'),
- filename: production ? '[name].[contenthash].js' : '[name].js',
- chunkFilename: production ? '[contenthash].js' : '[id].js',
+ path: resolve(__dirname, "../static/webpack-bundles"),
+ filename: production ? "[name].[contenthash].js" : "[name].js",
+ chunkFilename: production ? "[contenthash].js" : "[id].js",
},
resolve: {
extensions: [".ts", ".js"],
@@ -151,7 +151,7 @@ export default (env?: string): webpack.Configuration[] => {
// source mapped in error stack traces
// We prefer it over eval since eval has trouble setting
// breakpoints in chrome.
- devtool: production ? 'source-map' : 'cheap-module-source-map',
+ devtool: production ? "source-map" : "cheap-module-source-map",
optimization: {
minimizer: [
// Based on a comment in NMFR/optimize-css-assets-webpack-plugin#10.
@@ -200,8 +200,8 @@ export default (env?: string): webpack.Configuration[] => {
new DebugRequirePlugin(),
new BundleTracker({
filename: production
- ? 'webpack-stats-production.json'
- : 'var/webpack-stats-dev.json',
+ ? "webpack-stats-production.json"
+ : "var/webpack-stats-dev.json",
}),
...production
? []
@@ -236,18 +236,18 @@ export default (env?: string): webpack.Configuration[] => {
{ path: "../static/js/debug.js" },
{ path: "../static/js/blueslip.js" },
{ path: "../static/js/common.js" },
- { path: "jquery/dist/jquery.js", name: ['$', 'jQuery'] },
- { path: "underscore/underscore.js", name: '_' },
- { path: "handlebars/dist/cjs/handlebars.runtime.js", name: 'Handlebars' },
+ { path: "jquery/dist/jquery.js", name: ["$", "jQuery"] },
+ { path: "underscore/underscore.js", name: "_" },
+ { path: "handlebars/dist/cjs/handlebars.runtime.js", name: "Handlebars" },
{ path: "sortablejs/Sortable.js"},
- { path: "winchan/winchan.js", name: 'WinChan'},
+ { path: "winchan/winchan.js", name: "WinChan"},
];
config.module.rules.unshift(...getExposeLoaders(exposeOptions));
if (!production) {
// Out JS debugging tools
for (const paths of Object.values(assets)) {
- paths.push('./static/js/debug.js');
+ paths.push("./static/js/debug.js");
}
config.devServer = {
clientLogLevel: "error",
diff --git a/zerver/openapi/javascript_examples.js b/zerver/openapi/javascript_examples.js
index d8e938a3dcc..b18ecc74dbf 100644
--- a/zerver/openapi/javascript_examples.js
+++ b/zerver/openapi/javascript_examples.js
@@ -17,8 +17,8 @@ const ExamplesHandler = function () {
const name = count !== false ? `${example.name}_${count}` : example.name;
return {
name,
- endpoint: example.endpoint.split(':')[0],
- method: example.endpoint.split(':')[1],
+ endpoint: example.endpoint.split(":")[0],
+ method: example.endpoint.split(":")[1],
status_code: example.status_code.toString(),
result,
};
@@ -38,7 +38,7 @@ const ExamplesHandler = function () {
};
const main = async () => {
- const Zulip = require('zulip-js');
+ const Zulip = require("zulip-js");
const client = await Zulip(config);
await generate_validation_data(client, examples.send_message);
@@ -85,9 +85,9 @@ const {main, add_example} = ExamplesHandler();
const send_test_message = async (client) => {
const params = {
- to: 'Verona',
- type: 'stream',
- topic: 'Castle',
+ to: "Verona",
+ type: "stream",
+ topic: "Castle",
// Use some random text for easier debugging if needed. We don't
// depend on the content of these messages for the tests.
content: `Random test message ${Math.random()}`,
@@ -99,14 +99,14 @@ const send_test_message = async (client) => {
// Declare all the examples below.
-add_example('send_message', '/messages:post', 200, async (client) => {
+add_example("send_message", "/messages:post", 200, async (client) => {
// {code_example|start}
// Send a stream message
let params = {
- to: 'social',
- type: 'stream',
- topic: 'Castle',
- content: 'I come not, friends, to steal away your hearts.',
+ to: "social",
+ type: "stream",
+ topic: "Castle",
+ content: "I come not, friends, to steal away your hearts.",
};
const result_1 = await client.messages.send(params);
// {code_example|end}
@@ -116,37 +116,37 @@ add_example('send_message', '/messages:post', 200, async (client) => {
const user_id = 9;
params = {
to: [user_id],
- type: 'private',
- content: 'With mirth and laughter let old wrinkles come.',
+ type: "private",
+ content: "With mirth and laughter let old wrinkles come.",
};
const result_2 = await client.messages.send(params);
// {code_example|end}
return [result_1, result_2];
});
-add_example('create_user', '/users:post', 200, async (client) => {
+add_example("create_user", "/users:post", 200, async (client) => {
// {code_example|start}
const params = {
- email: '[email protected]',
- password: 'temp',
- full_name: 'New User',
+ email: "[email protected]",
+ password: "temp",
+ full_name: "New User",
};
return await client.users.create(params);
// {code_example|end}
});
-add_example('get_custom_emoji', '/realm/emoji:get', 200, async (client) => {
+add_example("get_custom_emoji", "/realm/emoji:get", 200, async (client) => {
// {code_example|start}
return await client.emojis.retrieve();
// {code_example|end}
});
-add_example('delete_queue', '/events:delete', 200, async (client) => {
+add_example("delete_queue", "/events:delete", 200, async (client) => {
// {code_example|start}
// Register a queue
const queueParams = {
- event_types: ['message'],
+ event_types: ["message"],
};
const res = await client.queues.register(queueParams);
@@ -159,14 +159,14 @@ add_example('delete_queue', '/events:delete', 200, async (client) => {
// {code_example|end}
});
-add_example('get_messages', '/messages:get', 200, async (client) => {
+add_example("get_messages", "/messages:get", 200, async (client) => {
// {code_example|start}
const readParams = {
- anchor: 'newest',
+ 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"
@@ -174,7 +174,7 @@ add_example('get_messages', '/messages:get', 200, async (client) => {
// {code_example|end}
});
-add_example('get_own_user', '/users/me:get', 200, async (client) => {
+add_example("get_own_user", "/users/me:get", 200, async (client) => {
// {code_example|start}
// Get the profile of the user/bot that requests this endpoint,
// which is `client` in this case:
@@ -182,28 +182,28 @@ add_example('get_own_user', '/users/me:get', 200, async (client) => {
// {code_example|end}
});
-add_example('get_stream_id', '/get_stream_id:get', 200, async (client) => {
+add_example("get_stream_id", "/get_stream_id:get", 200, async (client) => {
// {code_example|start}
// Get the ID of a given stream
- return await client.streams.getStreamId('Denmark');
+ return await client.streams.getStreamId("Denmark");
// {code_example|end}
});
-add_example('get_stream_topics', '/users/me/{stream_id}/topics:get', 200, async (client) => {
+add_example("get_stream_topics", "/users/me/{stream_id}/topics:get", 200, async (client) => {
// {code_example|start}
// Get all the topics in stream with ID 1
return client.streams.topics.retrieve({ stream_id: 1 });
// {code_example|end}
});
-add_example('get_subscriptions', '/users/me/subscriptions:get', 200, async (client) => {
+add_example("get_subscriptions", "/users/me/subscriptions:get", 200, async (client) => {
// {code_example|start}
// Get all streams that the user is subscribed to
return await client.streams.subscriptions.retrieve();
// {code_example|end}
});
-add_example('get_users', '/users:get', 200, async (client) => {
+add_example("get_users", "/users:get", 200, async (client) => {
// {code_example|start}
// Get all users in the realm
const result_1 = await client.users.retrieve();
@@ -216,35 +216,35 @@ add_example('get_users', '/users:get', 200, async (client) => {
return [result_1, result_2];
});
-add_example('register_queue', '/register:post', 200, async (client) => {
+add_example("register_queue", "/register:post", 200, async (client) => {
// {code_example|start}
// Register a queue
const params = {
- event_types: ['message'],
+ event_types: ["message"],
};
return await client.queues.register(params);
// {code_example|end}
});
-add_example('render_message', '/messages/render:post', 200, async (client) => {
+add_example("render_message", "/messages/render:post", 200, async (client) => {
// {code_example|start}
// Render a message
const params = {
- content: '**foo**',
+ content: "**foo**",
};
return await client.messages.render(params);
// {code_example|end}
});
-add_example('set_typing_status', '/typing:post', 200, async (client) => {
+add_example("set_typing_status", "/typing:post", 200, async (client) => {
// {code_example|start}
const user_id1 = 9;
const user_id2 = 10;
const typingParams = {
- op: 'start',
+ op: "start",
to: [user_id1, user_id2],
};
@@ -253,13 +253,13 @@ add_example('set_typing_status', '/typing:post', 200, async (client) => {
// {code_example|end}
});
-add_example('add_subscriptions', '/users/me/subscriptions:post', 200, async (client) => {
+add_example("add_subscriptions", "/users/me/subscriptions:post", 200, async (client) => {
// {code_example|start}
// Subscribe to the streams "Verona" and "Denmark"
const meParams = {
subscriptions: JSON.stringify([
- {name: 'Verona'},
- {name: 'Denmark'},
+ {name: "Verona"},
+ {name: "Denmark"},
]),
};
const result_1 = await client.users.me.subscriptions.add(meParams);
@@ -271,8 +271,8 @@ add_example('add_subscriptions', '/users/me/subscriptions:post', 200, async (cli
const user_id = 7;
const anotherUserParams = {
subscriptions: JSON.stringify([
- {name: 'Verona'},
- {name: 'Denmark'},
+ {name: "Verona"},
+ {name: "Denmark"},
]),
principals: JSON.stringify([user_id]),
};
@@ -281,11 +281,11 @@ add_example('add_subscriptions', '/users/me/subscriptions:post', 200, async (cli
return [result_1, result_2];
});
-add_example('remove_subscriptions', '/users/me/subscriptions:delete', 200, async (client) => {
+add_example("remove_subscriptions", "/users/me/subscriptions:delete", 200, async (client) => {
// {code_example|start}
// Unsubscribe from the stream "Denmark"
const meParams = {
- subscriptions: JSON.stringify(['Denmark']),
+ subscriptions: JSON.stringify(["Denmark"]),
};
const result_1 = await client.users.me.subscriptions.remove(meParams);
// {code_example|end}
@@ -294,7 +294,7 @@ add_example('remove_subscriptions', '/users/me/subscriptions:delete', 200, async
const user_id = 7;
// Unsubscribe Zoe from the stream "Denmark"
const zoeParams = {
- subscriptions: JSON.stringify(['Denmark']),
+ subscriptions: JSON.stringify(["Denmark"]),
principals: JSON.stringify([user_id]),
};
const result_2 = await client.users.me.subscriptions.remove(zoeParams);
@@ -302,7 +302,7 @@ add_example('remove_subscriptions', '/users/me/subscriptions:delete', 200, async
return [result_1, result_2];
});
-add_example('update_message_flags', '/messages/flags:post', 200, async (client) => {
+add_example("update_message_flags", "/messages/flags:post", 200, async (client) => {
// Send 3 messages to run this example on
const message_ids = [...Array(3)];
for (let i = 0; i < message_ids.length; i = i + 1) {
@@ -313,7 +313,7 @@ add_example('update_message_flags', '/messages/flags:post', 200, async (client)
// Add the "read" flag to the messages with IDs in "message_ids"
const addflag = {
messages: message_ids,
- flag: 'read',
+ flag: "read",
};
const result_1 = await client.messages.flags.add(addflag);
// {code_example|end}
@@ -322,19 +322,19 @@ add_example('update_message_flags', '/messages/flags:post', 200, async (client)
// Remove the "starred" flag from the messages with IDs in "message_ids"
const removeflag = {
messages: message_ids,
- flag: 'starred',
+ flag: "starred",
};
const result_2 = await client.messages.flags.remove(removeflag);
// {code_example|end}
return [result_1, result_2];
});
-add_example('update_message', '/messages/{message_id}:patch', 200, async (client) => {
+add_example("update_message", "/messages/{message_id}:patch", 200, async (client) => {
const request = {
- to: 'Denmark',
- type: 'stream',
- topic: 'Castle',
- content: 'I come not, friends, to steal away your hearts.',
+ to: "Denmark",
+ type: "stream",
+ topic: "Castle",
+ content: "I come not, friends, to steal away your hearts.",
};
const result = await client.messages.send(request);
const message_id = result.id;
@@ -343,17 +343,17 @@ add_example('update_message', '/messages/{message_id}:patch', 200, async (client
// Update a message with the given "message_id"
const params = {
message_id: message_id,
- content: 'New Content',
+ content: "New Content",
};
return await client.messages.update(params);
// {code_example|end}
});
-add_example('get_events', '/events:get', 200, async (client) => {
+add_example("get_events", "/events:get", 200, async (client) => {
// Register queue to receive messages for user.
const queueParams = {
- event_types: ['message'],
+ event_types: ["message"],
};
const res = await client.queues.register(queueParams);
const queue_id = res.queue_id;
@@ -372,7 +372,7 @@ add_example('get_events', '/events:get', 200, async (client) => {
// {code_example|end}
});
-add_example('get_streams', '/streams:get', 200, async (client) => {
+add_example("get_streams", "/streams:get", 200, async (client) => {
// {code_example|start}
// Get all streams that the user has access to
return await client.streams.retrieve();