js: Fix no-jquery/no-parse-html-literal.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2022-03-16 16:31:13 -07:00 committed by Tim Abbott
parent e32ec3f7eb
commit 6aec27e646
20 changed files with 69 additions and 73 deletions

View File

@ -73,6 +73,7 @@
"no-implied-eval": "error", "no-implied-eval": "error",
"no-inner-declarations": "off", "no-inner-declarations": "off",
"no-iterator": "error", "no-iterator": "error",
"no-jquery/no-parse-html-literal": "error",
"no-label-var": "error", "no-label-var": "error",
"no-labels": "error", "no-labels": "error",
"no-loop-func": "error", "no-loop-func": "error",

View File

@ -121,11 +121,10 @@ mock_jquery((sel, attributes) => {
} }
switch (sel) { switch (sel) {
case "<div class='tab-switcher'></div>":
return env.switcher;
case "<div class='tab-switcher stream_sorter_toggle'></div>":
return env.switcher;
case "<div>": { case "<div>": {
if (attributes.class === "tab-switcher") {
return env.switcher;
}
const tab_id = attributes["data-tab-id"]; const tab_id = attributes["data-tab-id"];
assert.deepEqual( assert.deepEqual(
attributes, attributes,

View File

@ -736,7 +736,7 @@ test_ui("warn_if_mentioning_unsubscribed_user", ({override, override_rewire, moc
} }
// Simulate that the row was added to the DOM. // Simulate that the row was added to the DOM.
const $warning_row = $("<warning row>"); const $warning_row = $("<warning-row-stub>");
let looked_for_existing; let looked_for_existing;
$warning_row.data = (field) => { $warning_row.data = (field) => {

View File

@ -120,7 +120,7 @@ test("draft_model add", ({override}) => {
const ls = localstorage(); const ls = localstorage();
assert.equal(ls.get("draft"), undefined); assert.equal(ls.get("draft"), undefined);
const $unread_count = $('<span class="unread_count"></span>'); const $unread_count = $("<unread-count-stub>");
$(".top_left_drafts").set_find_results(".unread_count", $unread_count); $(".top_left_drafts").set_find_results(".unread_count", $unread_count);
override(Date, "now", () => 1); override(Date, "now", () => 1);
@ -136,7 +136,7 @@ test("draft_model edit", () => {
assert.equal(ls.get("draft"), undefined); assert.equal(ls.get("draft"), undefined);
let id; let id;
const $unread_count = $('<span class="unread_count"></span>'); const $unread_count = $("<unread-count-stub>");
$(".top_left_drafts").set_find_results(".unread_count", $unread_count); $(".top_left_drafts").set_find_results(".unread_count", $unread_count);
with_overrides(({override}) => { with_overrides(({override}) => {
@ -161,7 +161,7 @@ test("draft_model delete", ({override}) => {
const ls = localstorage(); const ls = localstorage();
assert.equal(ls.get("draft"), undefined); assert.equal(ls.get("draft"), undefined);
const $unread_count = $('<span class="unread_count"></span>'); const $unread_count = $("<unread-count-stub>");
$(".top_left_drafts").set_find_results(".unread_count", $unread_count); $(".top_left_drafts").set_find_results(".unread_count", $unread_count);
override(Date, "now", () => 1); override(Date, "now", () => 1);
@ -212,7 +212,7 @@ test("initialize", ({override_rewire}) => {
assert.ok(called); assert.ok(called);
}; };
const $unread_count = $('<span class="unread_count"></span>'); const $unread_count = $("<unread-count-stub>");
$(".top_left_drafts").set_find_results(".unread_count", $unread_count); $(".top_left_drafts").set_find_results(".unread_count", $unread_count);
drafts.initialize(); drafts.initialize();
@ -239,7 +239,7 @@ test("remove_old_drafts", () => {
ls.set("drafts", data); ls.set("drafts", data);
assert.deepEqual(draft_model.get(), data); assert.deepEqual(draft_model.get(), data);
const $unread_count = $('<span class="unread_count"></span>'); const $unread_count = $("<unread-count-stub>");
$(".top_left_drafts").set_find_results(".unread_count", $unread_count); $(".top_left_drafts").set_find_results(".unread_count", $unread_count);
drafts.remove_old_drafts(); drafts.remove_old_drafts();
@ -313,7 +313,7 @@ test("delete_all_drafts", () => {
ls.set("drafts", data); ls.set("drafts", data);
assert.deepEqual(draft_model.get(), data); assert.deepEqual(draft_model.get(), data);
const $unread_count = $('<span class="unread_count"></span>'); const $unread_count = $("<unread-count-stub>");
$(".top_left_drafts").set_find_results(".unread_count", $unread_count); $(".top_left_drafts").set_find_results(".unread_count", $unread_count);
drafts.delete_all_drafts(); drafts.delete_all_drafts();
@ -451,7 +451,7 @@ test("format_drafts", ({override_rewire, mock_template}) => {
expected[0].stream_name = "stream-rename"; expected[0].stream_name = "stream-rename";
const $unread_count = $('<span class="unread_count"></span>'); const $unread_count = $("<unread-count-stub>");
$(".top_left_drafts").set_find_results(".unread_count", $unread_count); $(".top_left_drafts").set_find_results(".unread_count", $unread_count);
drafts.launch(); drafts.launch();

View File

@ -449,7 +449,6 @@ run_test("show_empty_narrow_message_with_search", ({mock_template}) => {
}); });
run_test("hide_empty_narrow_message", () => { run_test("hide_empty_narrow_message", () => {
$(".empty_feed_notice_main").html("<div class='empty_feed_notice'>Nothing here</div>");
narrow_banner.hide_empty_narrow_message(); narrow_banner.hide_empty_narrow_message();
assert.equal($(".empty_feed_notice").text(), "never-been-set"); assert.equal($(".empty_feed_notice").text(), "never-been-set");
}); });

View File

@ -624,11 +624,11 @@ test("view.insert_new_reaction (me w/unicode emoji)", ({override_rewire, mock_te
reaction_type: opts.reaction_type, reaction_type: opts.reaction_type,
is_realm_emoji: false, is_realm_emoji: false,
}); });
return "<new reaction html>"; return "<new-reaction-stub>";
}); });
let insert_called; let insert_called;
$("<new reaction html>").insertBefore = (element) => { $("<new-reaction-stub>").insertBefore = (element) => {
assert.equal(element, "reaction-button-stub"); assert.equal(element, "reaction-button-stub");
insert_called = true; insert_called = true;
}; };
@ -673,11 +673,11 @@ test("view.insert_new_reaction (them w/zulip emoji)", ({override_rewire, mock_te
still_url: undefined, still_url: undefined,
reaction_type: opts.reaction_type, reaction_type: opts.reaction_type,
}); });
return "<new reaction html>"; return "<new-reaction-stub>";
}); });
let insert_called; let insert_called;
$("<new reaction html>").insertBefore = (element) => { $("<new-reaction-stub>").insertBefore = (element) => {
assert.equal(element, "reaction-button-stub"); assert.equal(element, "reaction-button-stub");
insert_called = true; insert_called = true;
}; };

View File

@ -131,7 +131,7 @@ function createSaveButtons(subsection) {
const $stub_save_button_text = $(".save-discard-widget-button-text"); const $stub_save_button_text = $(".save-discard-widget-button-text");
$stub_save_button_header.set_find_results( $stub_save_button_header.set_find_results(
".subsection-failed-status p", ".subsection-failed-status p",
$("<failed status element>"), $("<failed-status-stub>"),
); );
$stub_save_button.closest = () => $stub_save_button_header; $stub_save_button.closest = () => $stub_save_button_header;
$save_button_controls.set_find_results(".save-button", $stub_save_button); $save_button_controls.set_find_results(".save-button", $stub_save_button);

View File

@ -50,14 +50,14 @@ function create_devel_sidebar_row({mock_template}) {
const $devel_count = $.create("devel-count"); const $devel_count = $.create("devel-count");
const $subscription_block = $.create("devel-block"); const $subscription_block = $.create("devel-block");
const $sidebar_row = $("<devel sidebar row>"); const $sidebar_row = $("<devel-sidebar-row-stub>");
$sidebar_row.set_find_results(".subscription_block", $subscription_block); $sidebar_row.set_find_results(".subscription_block", $subscription_block);
$subscription_block.set_find_results(".unread_count", $devel_count); $subscription_block.set_find_results(".unread_count", $devel_count);
mock_template("stream_sidebar_row.hbs", false, (data) => { mock_template("stream_sidebar_row.hbs", false, (data) => {
assert.equal(data.uri, "#narrow/stream/100-devel"); assert.equal(data.uri, "#narrow/stream/100-devel");
return "<devel sidebar row>"; return "<devel-sidebar-row-stub>";
}); });
num_unread_for_stream = 42; num_unread_for_stream = 42;
@ -69,14 +69,14 @@ function create_social_sidebar_row({mock_template}) {
const $social_count = $.create("social-count"); const $social_count = $.create("social-count");
const $subscription_block = $.create("social-block"); const $subscription_block = $.create("social-block");
const $sidebar_row = $("<social sidebar row>"); const $sidebar_row = $("<social-sidebar-row-stub>");
$sidebar_row.set_find_results(".subscription_block", $subscription_block); $sidebar_row.set_find_results(".subscription_block", $subscription_block);
$subscription_block.set_find_results(".unread_count", $social_count); $subscription_block.set_find_results(".unread_count", $social_count);
mock_template("stream_sidebar_row.hbs", false, (data) => { mock_template("stream_sidebar_row.hbs", false, (data) => {
assert.equal(data.uri, "#narrow/stream/200-social"); assert.equal(data.uri, "#narrow/stream/200-social");
return "<social sidebar row>"; return "<social-sidebar-row-stub>";
}); });
num_unread_for_stream = 99; num_unread_for_stream = 99;
@ -105,8 +105,8 @@ test_ui("create_sidebar_row", ({override_rewire, mock_template}) => {
create_social_sidebar_row({mock_template}); create_social_sidebar_row({mock_template});
const split = '<hr class="stream-split">'; const split = '<hr class="stream-split">';
const $devel_sidebar = $("<devel sidebar row>"); const $devel_sidebar = $("<devel-sidebar-row-stub>");
const $social_sidebar = $("<social sidebar row>"); const $social_sidebar = $("<social-sidebar-row-stub>");
let appended_elems; let appended_elems;
$("#stream_filters").append = (elems) => { $("#stream_filters").append = (elems) => {
@ -130,7 +130,7 @@ test_ui("create_sidebar_row", ({override_rewire, mock_template}) => {
assert.deepEqual(appended_elems, expected_elems); assert.deepEqual(appended_elems, expected_elems);
const $social_li = $("<social sidebar row>"); const $social_li = $("<social-sidebar-row-stub>");
const stream_id = social.stream_id; const stream_id = social.stream_id;
$social_li.length = 0; $social_li.length = 0;
@ -183,7 +183,7 @@ test_ui("pinned_streams_never_inactive", ({override_rewire, mock_template}) => {
create_social_sidebar_row({mock_template}); create_social_sidebar_row({mock_template});
// non-pinned streams can be made inactive // non-pinned streams can be made inactive
const $social_sidebar = $("<social sidebar row>"); const $social_sidebar = $("<social-sidebar-row-stub>");
let stream_id = social.stream_id; let stream_id = social.stream_id;
let row = stream_list.stream_sidebar.get_row(stream_id); let row = stream_list.stream_sidebar.get_row(stream_id);
override_rewire(stream_data, "is_active", () => false); override_rewire(stream_data, "is_active", () => false);
@ -200,7 +200,7 @@ test_ui("pinned_streams_never_inactive", ({override_rewire, mock_template}) => {
assert.ok($social_sidebar.hasClass("inactive_stream")); assert.ok($social_sidebar.hasClass("inactive_stream"));
// pinned streams can never be made inactive // pinned streams can never be made inactive
const $devel_sidebar = $("<devel sidebar row>"); const $devel_sidebar = $("<devel-sidebar-row-stub>");
stream_id = devel.stream_id; stream_id = devel.stream_id;
row = stream_list.stream_sidebar.get_row(stream_id); row = stream_list.stream_sidebar.get_row(stream_id);
override_rewire(stream_data, "is_active", () => false); override_rewire(stream_data, "is_active", () => false);
@ -217,7 +217,7 @@ function add_row(sub) {
const row = { const row = {
update_whether_active() {}, update_whether_active() {},
get_li() { get_li() {
const html = "<" + sub.name + " sidebar row html>"; const html = "<" + sub.name + "-sidebar-row-stub>";
const $obj = $(html); const $obj = $(html);
$obj.length = 1; // bypass blueslip error $obj.length = 1; // bypass blueslip error
@ -372,7 +372,7 @@ test_ui("narrowing", ({override_rewire}) => {
topic_list.get_stream_li = noop; topic_list.get_stream_li = noop;
override_rewire(scroll_util, "scroll_element_into_container", noop); override_rewire(scroll_util, "scroll_element_into_container", noop);
assert.ok(!$("<devel sidebar row html>").hasClass("active-filter")); assert.ok(!$("<devel-sidebar-row-stub>").hasClass("active-filter"));
stream_list.set_event_handlers(); stream_list.set_event_handlers();
@ -380,7 +380,7 @@ test_ui("narrowing", ({override_rewire}) => {
filter = new Filter([{operator: "stream", operand: "devel"}]); filter = new Filter([{operator: "stream", operand: "devel"}]);
stream_list.handle_narrow_activated(filter); stream_list.handle_narrow_activated(filter);
assert.ok($("<devel sidebar row html>").hasClass("active-filter")); assert.ok($("<devel-sidebar-row-stub>").hasClass("active-filter"));
filter = new Filter([ filter = new Filter([
{operator: "stream", operand: "cars"}, {operator: "stream", operand: "cars"},
@ -388,12 +388,12 @@ test_ui("narrowing", ({override_rewire}) => {
]); ]);
stream_list.handle_narrow_activated(filter); stream_list.handle_narrow_activated(filter);
assert.ok(!$("ul.filters li").hasClass("active-filter")); assert.ok(!$("ul.filters li").hasClass("active-filter"));
assert.ok(!$("<cars sidebar row html>").hasClass("active-filter")); // false because of topic assert.ok(!$("<cars-sidebar-row-stub>").hasClass("active-filter")); // false because of topic
filter = new Filter([{operator: "stream", operand: "cars"}]); filter = new Filter([{operator: "stream", operand: "cars"}]);
stream_list.handle_narrow_activated(filter); stream_list.handle_narrow_activated(filter);
assert.ok(!$("ul.filters li").hasClass("active-filter")); assert.ok(!$("ul.filters li").hasClass("active-filter"));
assert.ok($("<cars sidebar row html>").hasClass("active-filter")); assert.ok($("<cars-sidebar-row-stub>").hasClass("active-filter"));
let removed_classes; let removed_classes;
$("ul#stream_filters li").removeClass = (classes) => { $("ul#stream_filters li").removeClass = (classes) => {
@ -450,14 +450,14 @@ test_ui("sort_streams", ({override_rewire}) => {
const split = '<hr class="stream-split">'; const split = '<hr class="stream-split">';
const expected_elems = [ const expected_elems = [
$("<devel sidebar row html>"), $("<devel-sidebar-row-stub>"),
$("<Rome sidebar row html>"), $("<Rome-sidebar-row-stub>"),
$("<test sidebar row html>"), $("<test-sidebar-row-stub>"),
split, split,
$("<announce sidebar row html>"), $("<announce-sidebar-row-stub>"),
$("<Denmark sidebar row html>"), $("<Denmark-sidebar-row-stub>"),
split, split,
$("<cars sidebar row html>"), $("<cars-sidebar-row-stub>"),
]; ];
assert.deepEqual(appended_elems, expected_elems); assert.deepEqual(appended_elems, expected_elems);
@ -529,11 +529,11 @@ test_ui("separators_only_pinned_and_dormant", ({override_rewire}) => {
const split = '<hr class="stream-split">'; const split = '<hr class="stream-split">';
const expected_elems = [ const expected_elems = [
// pinned // pinned
$("<devel sidebar row html>"), $("<devel-sidebar-row-stub>"),
$("<Rome sidebar row html>"), $("<Rome-sidebar-row-stub>"),
split, split,
// dormant // dormant
$("<Denmark sidebar row html>"), $("<Denmark-sidebar-row-stub>"),
]; ];
assert.deepEqual(appended_elems, expected_elems); assert.deepEqual(appended_elems, expected_elems);
@ -573,8 +573,8 @@ test_ui("separators_only_pinned", () => {
const expected_elems = [ const expected_elems = [
// pinned // pinned
$("<devel sidebar row html>"), $("<devel-sidebar-row-stub>"),
$("<Rome sidebar row html>"), $("<Rome-sidebar-row-stub>"),
// no separator at the end as no stream follows // no separator at the end as no stream follows
]; ];

View File

@ -210,7 +210,7 @@ run_test("render_date_renders_time_html", () => {
const expected_html = $t({defaultMessage: "Today"}); const expected_html = $t({defaultMessage: "Today"});
const attrs = {}; const attrs = {};
const $span_stub = $("<span />"); const $span_stub = $("<span>");
$span_stub.attr = (name, val) => { $span_stub.attr = (name, val) => {
attrs[name] = val; attrs[name] = val;
@ -234,7 +234,7 @@ run_test("render_date_renders_time_above_html", () => {
const message_time = today; const message_time = today;
const message_time_above = add(today, {days: -1}); const message_time_above = add(today, {days: -1});
const $span_stub = $("<span />"); const $span_stub = $("<span>");
let appended_val; let appended_val;
$span_stub.append = (...val) => { $span_stub.append = (...val) => {
@ -243,10 +243,10 @@ run_test("render_date_renders_time_above_html", () => {
}; };
const expected = [ const expected = [
'<i class="date-direction fa fa-caret-up"></i>', $("<i>"),
$t({defaultMessage: "Yesterday"}), $t({defaultMessage: "Yesterday"}),
'<hr class="date-line">', $("<hr>"),
'<i class="date-direction fa fa-caret-down"></i>', $("<i>"),
$t({defaultMessage: "Today"}), $t({defaultMessage: "Today"}),
]; ];

View File

@ -59,7 +59,7 @@ run_test("basics", () => {
assert.equal($widget.attr("data-department-name"), "hr"); assert.equal($widget.attr("data-department-name"), "hr");
assert.equal($widget.data("department-name"), "hr"); assert.equal($widget.data("department-name"), "hr");
$widget.html("<b>hello</b>"); $widget.html("<b>hello</b>"); // eslint-disable-line no-jquery/no-parse-html-literal
assert.equal($widget.html(), "<b>hello</b>"); assert.equal($widget.html(), "<b>hello</b>");
$widget.prop("title", "My widget"); $widget.prop("title", "My widget");
@ -84,7 +84,7 @@ run_test("finding_related_objects", () => {
// But you can set up your tests to simulate DOM relationships. // But you can set up your tests to simulate DOM relationships.
// //
// We will use set_find_results(), which is a special zjquery helper. // We will use set_find_results(), which is a special zjquery helper.
const $emoji = $('<div class="emoji">'); const $emoji = $("<emoji-stub>");
$("#my-message").set_find_results(".emoji", $emoji); $("#my-message").set_find_results(".emoji", $emoji);
// And then calling the function produces the desired effect: // And then calling the function produces the desired effect:

View File

@ -102,7 +102,7 @@ export async function display_stacktrace(error: string, stack: string): Promise<
}), }),
); );
const $alert = $("<div class='stacktrace'>").html( const $alert = $("<div>", {class: "stacktrace"}).html(
render_blueslip_stacktrace({error, stackframes}), render_blueslip_stacktrace({error, stackframes}),
); );
$(".alert-box").append($alert); $(".alert-box").append($alert);

View File

@ -32,7 +32,7 @@ export function toggle(opts: {
child_wants_focus?: boolean; child_wants_focus?: boolean;
selected?: number; selected?: number;
}): Toggle { }): Toggle {
const $component = $("<div class='tab-switcher'></div>"); const $component = $("<div>", {class: "tab-switcher"});
if (opts.html_class) { if (opts.html_class) {
// add a check inside passed arguments in case some extra // add a check inside passed arguments in case some extra
// classes need to be added for correct alignment or other purposes // classes need to be added for correct alignment or other purposes

View File

@ -10,7 +10,7 @@ function is_numeric_key(key) {
} }
export function show_flatpickr(element, callback, default_timestamp, options = {}) { export function show_flatpickr(element, callback, default_timestamp, options = {}) {
const $flatpickr_input = $("<input id='#timestamp_flatpickr'>"); const $flatpickr_input = $("<input>", {id: "#timestamp_flatpickr"});
const instance = $flatpickr_input.flatpickr({ const instance = $flatpickr_input.flatpickr({
mode: "single", mode: "single",

View File

@ -183,7 +183,7 @@ export function render_lightbox_list_images(preview_source) {
const src = img.getAttribute("src"); const src = img.getAttribute("src");
const className = preview_source === src ? "image selected" : "image"; const className = preview_source === src ? "image selected" : "image";
const $node = $("<div></div>", { const $node = $("<div>", {
class: className, class: className,
"data-src": src, "data-src": src,
}).css({backgroundImage: "url(" + src + ")"}); }).css({backgroundImage: "url(" + src + ")"});
@ -244,7 +244,7 @@ function display_video(payload) {
break; break;
} }
const $iframe = $("<iframe></iframe>"); const $iframe = $("<iframe>");
$iframe.attr( $iframe.attr(
"sandbox", "sandbox",
"allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts", "allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts",

View File

@ -29,13 +29,13 @@ export function make_indicator(
$container = $inner_container; $container = $inner_container;
} }
const $spinner_elem = $('<div class="loading_indicator_spinner" aria-hidden="true"></div>'); const $spinner_elem = $("<div>", {class: "loading_indicator_spinner", ["aria-hidden"]: "true"});
$spinner_elem.html(render_loader({container_id: $outer_container.attr("id")})); $spinner_elem.html(render_loader({container_id: $outer_container.attr("id")}));
$container.append($spinner_elem); $container.append($spinner_elem);
let text_width = 0; let text_width = 0;
if (text !== undefined) { if (text !== undefined) {
const $text_elem = $('<span class="loading_indicator_text"></span>'); const $text_elem = $("<span>", {class: "loading_indicator_text"});
$text_elem.text(text); $text_elem.text(text);
$container.append($text_elem); $container.append($text_elem);
// See note, below // See note, below

View File

@ -237,7 +237,7 @@ export function process_notification(notification) {
let msg_count = 1; let msg_count = 1;
let notification_source; let notification_source;
// Convert the content to plain text, replacing emoji with their alt text // Convert the content to plain text, replacing emoji with their alt text
const $content = $("<div/>").html(message.content); const $content = $("<div>").html(message.content);
ui.replace_emoji_with_text($content); ui.replace_emoji_with_text($content);
spoilers.hide_spoilers_in_notification($content); spoilers.hide_spoilers_in_notification($content);
content = $content.text(); content = $content.text();

View File

@ -156,10 +156,9 @@ function hide_catalog_show_integration() {
link = name; link = name;
} }
} }
const $category_el = $("<a></a>") const $category_el = $("<a>", {href: "/integrations/" + link}).append(
.attr("href", "/integrations/" + link) $("<h3>", {class: "integration-category", ["data-category"]: link}).text(category),
.append('<h3 class="integration-category"></h3>'); );
$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({

View File

@ -97,7 +97,7 @@ export function update_view_on_deactivate(user_id) {
$row.find("i.deactivated-user-icon").show(); $row.find("i.deactivated-user-icon").show();
$button.addClass("btn-warning reactivate"); $button.addClass("btn-warning reactivate");
$button.removeClass("deactivate btn-danger"); $button.removeClass("deactivate btn-danger");
$button.html("<i class='fa fa-user-plus' aria-hidden='true'></i>"); $button.empty().append($("<i>", {class: "fa fa-user-plus", ["aria-hidden"]: "true"}));
$button.attr("title", "Reactivate"); $button.attr("title", "Reactivate");
$row.addClass("deactivated_user"); $row.addClass("deactivated_user");
@ -117,7 +117,7 @@ function update_view_on_reactivate($row) {
$button.addClass("btn-danger deactivate"); $button.addClass("btn-danger deactivate");
$button.removeClass("btn-warning reactivate"); $button.removeClass("btn-warning reactivate");
$button.attr("title", "Deactivate"); $button.attr("title", "Deactivate");
$button.html('<i class="fa fa-user-times" aria-hidden="true"></i>'); $button.empty().append($("<i>", {class: "fa fa-user-times", ["aria-hidden"]: "true"}));
$row.removeClass("deactivated_user"); $row.removeClass("deactivated_user");
if ($user_role) { if ($user_role) {

View File

@ -183,10 +183,10 @@ function render_date_span(
$elem.text(""); $elem.text("");
if (rendered_time_above !== undefined) { if (rendered_time_above !== undefined) {
$elem.append( $elem.append(
'<i class="date-direction fa fa-caret-up"></i>', $("<i>").addClass(["date-direction", "fa", "fa-caret-up"]),
_.escape(rendered_time_above.time_str), _.escape(rendered_time_above.time_str),
'<hr class="date-line">', $("<hr>").addClass("date-line"),
'<i class="date-direction fa fa-caret-down"></i>', $("<i>").addClass(["date-direction", "fa", "fa-caret-down"]),
_.escape(rendered_time.time_str), _.escape(rendered_time.time_str),
); );
return $elem; return $elem;
@ -208,7 +208,7 @@ export function render_date(time: Date, time_above: Date | undefined, today: Dat
const className = `timerender${next_timerender_id}`; const className = `timerender${next_timerender_id}`;
next_timerender_id += 1; next_timerender_id += 1;
const rendered_time = render_now(time, today); const rendered_time = render_now(time, today);
let $node = $("<span />").attr("class", className); let $node = $("<span>").attr("class", className);
if (time_above !== undefined) { if (time_above !== undefined) {
const rendered_time_above = render_now(time_above, today); const rendered_time_above = render_now(time_above, today);
$node = render_date_span($node, rendered_time, rendered_time_above); $node = render_date_span($node, rendered_time, rendered_time_above);

View File

@ -65,12 +65,10 @@ export function success(response_html: string, $status_box: JQuery, remove_after
} }
export function generic_embed_error(error_html: string): void { export function generic_embed_error(error_html: string): void {
const $alert = $("<div class='alert home-error-bar'></div>"); const $alert = $("<div>", {class: "alert home-error-bar show"});
const exit_html = "<div class='exit'></div>"; const $exit = $("<div>", {class: "exit"});
$(".alert-box").append( $(".alert-box").append($alert.append($exit, $("<div>", {class: "content"}).html(error_html)));
$alert.html(exit_html + "<div class='content'>" + error_html + "</div>").addClass("show"),
);
} }
export function generic_row_button_error(xhr: JQuery.jqXHR, $btn: JQuery): void { export function generic_row_button_error(xhr: JQuery.jqXHR, $btn: JQuery): void {