From fd3e3ac4a0d32d828e39a235e024673c6ac057cb Mon Sep 17 00:00:00 2001 From: yichya QC Date: Fri, 26 Jul 2024 17:32:53 +0800 Subject: [PATCH] chore: minor code and style fixes --- .../luci-static/resources/view/xray/status.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/status/root/www/luci-static/resources/view/xray/status.js b/status/root/www/luci-static/resources/view/xray/status.js index 362c03a8..03da4792 100644 --- a/status/root/www/luci-static/resources/view/xray/status.js +++ b/status/root/www/luci-static/resources/view/xray/status.js @@ -69,7 +69,7 @@ function get_inbound_uci_description(config, key) { } const uci_key = key.slice(-9); const uci_item = uci.get(config, uci_key); - if (uci_item == null) { + if (uci_item === null) { return key; } switch (uci_item[".type"]) { @@ -96,7 +96,7 @@ function get_outbound_uci_description(config, key) { } const uci_key = key.slice(-9); const uci_item = uci.get(config, uci_key); - if (uci_item == null) { + if (uci_item === null) { return "direct"; } switch (uci_item[".type"]) { @@ -120,7 +120,7 @@ function outbound_first_tag_format(tag_split, first_uci_description) { let result = [tag_split[0]]; const first_tag = tag_split[0].split(":"); - if (first_tag.length == 1) { + if (first_tag.length === 1) { return result; } @@ -200,9 +200,9 @@ function outbound_middle_tag_format(tag_split, first_uci_description, current_ta } function outbound_last_tag_format(first_uci_description, last_tag, last_uci_description) { - if (last_tag[0] == "tcp_outbound") { + if (last_tag[0] === "tcp_outbound") { return shared.badge(`{ tcp: ${first_uci_description} }`); - } else if (last_tag[0] == "udp_outbound") { + } else if (last_tag[0] === "udp_outbound") { return shared.badge(`{ udp: ${first_uci_description} }`); } return shared.badge(`{ ${last_tag[0]}: ${last_uci_description} }`, last_tag[1]); @@ -216,7 +216,7 @@ function get_outbound_description(config, tag) { for (let i = 1; i < tag_split.length; i++) { const current_tag = tag_split[i].split(":"); const current_uci_description = get_outbound_uci_description(config, current_tag[1]); - if (i == tag_split.length - 1) { + if (i === tag_split.length - 1) { result.push(" ", outbound_last_tag_format(first_uci_description, current_tag, current_uci_description)); } else { result.push(" ", outbound_middle_tag_format(tag_split, first_uci_description, current_tag, current_uci_description)); @@ -247,7 +247,12 @@ function observatory(vars, config) { } return _("unreachable"); }(v)), - E('td', { 'class': 'td' }, '%d'.format(greater_than_zero(now_timestamp - v[1]["last_seen_time"])) + _('s ago')), + E('td', { 'class': 'td' }, function (c) { + if (c[1]["last_seen_time"] === undefined) { + return _("never"); + } + return '%d'.format(greater_than_zero(now_timestamp - c[1]["last_seen_time"])) + _('s ago'); + }(v)), E('td', { 'class': 'td' }, '%d'.format(greater_than_zero(now_timestamp - v[1]["last_try_time"])) + _('s ago')), ])) ])