Skip to content

Commit fd3e3ac

Browse files
committed
chore: minor code and style fixes
1 parent ff491ce commit fd3e3ac

File tree

1 file changed

+12
-7
lines changed
  • status/root/www/luci-static/resources/view/xray

1 file changed

+12
-7
lines changed

status/root/www/luci-static/resources/view/xray/status.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function get_inbound_uci_description(config, key) {
6969
}
7070
const uci_key = key.slice(-9);
7171
const uci_item = uci.get(config, uci_key);
72-
if (uci_item == null) {
72+
if (uci_item === null) {
7373
return key;
7474
}
7575
switch (uci_item[".type"]) {
@@ -96,7 +96,7 @@ function get_outbound_uci_description(config, key) {
9696
}
9797
const uci_key = key.slice(-9);
9898
const uci_item = uci.get(config, uci_key);
99-
if (uci_item == null) {
99+
if (uci_item === null) {
100100
return "direct";
101101
}
102102
switch (uci_item[".type"]) {
@@ -120,7 +120,7 @@ function outbound_first_tag_format(tag_split, first_uci_description) {
120120
let result = [tag_split[0]];
121121

122122
const first_tag = tag_split[0].split(":");
123-
if (first_tag.length == 1) {
123+
if (first_tag.length === 1) {
124124
return result;
125125
}
126126

@@ -200,9 +200,9 @@ function outbound_middle_tag_format(tag_split, first_uci_description, current_ta
200200
}
201201

202202
function outbound_last_tag_format(first_uci_description, last_tag, last_uci_description) {
203-
if (last_tag[0] == "tcp_outbound") {
203+
if (last_tag[0] === "tcp_outbound") {
204204
return shared.badge(`{ tcp: <strong>${first_uci_description}</strong> }`);
205-
} else if (last_tag[0] == "udp_outbound") {
205+
} else if (last_tag[0] === "udp_outbound") {
206206
return shared.badge(`{ udp: <strong>${first_uci_description}</strong> }`);
207207
}
208208
return shared.badge(`{ ${last_tag[0]}: <strong>${last_uci_description}</strong> }`, last_tag[1]);
@@ -216,7 +216,7 @@ function get_outbound_description(config, tag) {
216216
for (let i = 1; i < tag_split.length; i++) {
217217
const current_tag = tag_split[i].split(":");
218218
const current_uci_description = get_outbound_uci_description(config, current_tag[1]);
219-
if (i == tag_split.length - 1) {
219+
if (i === tag_split.length - 1) {
220220
result.push(" ", outbound_last_tag_format(first_uci_description, current_tag, current_uci_description));
221221
} else {
222222
result.push(" ", outbound_middle_tag_format(tag_split, first_uci_description, current_tag, current_uci_description));
@@ -247,7 +247,12 @@ function observatory(vars, config) {
247247
}
248248
return _("<i>unreachable</i>");
249249
}(v)),
250-
E('td', { 'class': 'td' }, '%d'.format(greater_than_zero(now_timestamp - v[1]["last_seen_time"])) + _('s ago')),
250+
E('td', { 'class': 'td' }, function (c) {
251+
if (c[1]["last_seen_time"] === undefined) {
252+
return _("<i>never</i>");
253+
}
254+
return '%d'.format(greater_than_zero(now_timestamp - c[1]["last_seen_time"])) + _('s ago');
255+
}(v)),
251256
E('td', { 'class': 'td' }, '%d'.format(greater_than_zero(now_timestamp - v[1]["last_try_time"])) + _('s ago')),
252257
]))
253258
])

0 commit comments

Comments
 (0)