Skip to content
Snippets Groups Projects
Commit 2ad2c929 authored by rickparrish's avatar rickparrish
Browse files

Call the existing node_status method instead of re-inventing the wheel.

Add options to node_status to allow excluding information webv4 already displays.
Truncate whitespace in extended_status to remove the trailing 0x00 bytes
parent a199e8b3
No related branches found
No related tags found
1 merge request!329Update node action display on web
Pipeline #4693 passed
...@@ -138,7 +138,7 @@ function extended_status(num) ...@@ -138,7 +138,7 @@ function extended_status(num)
f.position = num * 128; f.position = num * 128;
var str = f.read(128); var str = f.read(128);
f.close(); f.close();
return str; return truncsp(str);
} }
// Returns a string describing the node status, suitable for printing on a single line // Returns a string describing the node status, suitable for printing on a single line
...@@ -148,11 +148,13 @@ function extended_status(num) ...@@ -148,11 +148,13 @@ function extended_status(num)
// options values supported/used: // options values supported/used:
// .include_age // .include_age
// .include_gender // .include_gender
// .exclude_username
// .username_prefix // .username_prefix
// .status_prefix // .status_prefix
// .age_prefix // .age_prefix
// .gender_prefix // .gender_prefix
// .gender_separator // .gender_separator
// .exclude_connection
// .connection_prefix // .connection_prefix
// .errors_prefix // .errors_prefix
function node_status(node, is_sysop, options, num) function node_status(node, is_sysop, options, num)
...@@ -174,12 +176,14 @@ function node_status(node, is_sysop, options, num) ...@@ -174,12 +176,14 @@ function node_status(node, is_sysop, options, num)
} }
var user = new User(node.useron); var user = new User(node.useron);
if (!options.exclude_username) {
if(options.username_prefix) if(options.username_prefix)
output += options.username_prefix; output += options.username_prefix;
if(js.global.bbs && (misc&NODE_ANON) && !is_sysop) if(js.global.bbs && (misc&NODE_ANON) && !is_sysop)
output += bbs.text(UNKNOWN_USER); output += bbs.text(UNKNOWN_USER);
else else
output += user.alias; output += user.alias;
}
if(options.status_prefix) if(options.status_prefix)
output += options.status_prefix; output += options.status_prefix;
output += user_age_and_gender(user, options); output += user_age_and_gender(user, options);
...@@ -201,9 +205,11 @@ function node_status(node, is_sysop, options, num) ...@@ -201,9 +205,11 @@ function node_status(node, is_sysop, options, num)
output += format(NodeAction[node.action], node.aux); output += format(NodeAction[node.action], node.aux);
break; break;
} }
if (!options.exclude_connection) {
if(options.connection_prefix) if(options.connection_prefix)
output += options.connection_prefix; output += options.connection_prefix;
output += node_connection_desc(node); output += node_connection_desc(node);
}
break; break;
} }
case NODE_LOGON: case NODE_LOGON:
......
...@@ -82,18 +82,11 @@ function scan() { ...@@ -82,18 +82,11 @@ function scan() {
}; };
} else { } else {
usr.number = e.useron; usr.number = e.useron;
if(e.action == NODE_BXFR) {
actionstr = format(extended_status(i));
} else if(e.action==NODE_XTRN && e.aux && xtrn_area.prog[usr.curxtrn]) {
actionstr = format("running %s",xtrn_area.prog[usr.curxtrn].name);
} else {
actionstr = format(NodeAction[e.action], e.aux, e.extaux);
}
return { return {
node: i + 1, node: i + 1,
status: format(NodeStatus[e.status], e.aux, e.extaux), status: format(NodeStatus[e.status], e.aux, e.extaux),
action: actionstr, action: node_status(e, user.is_sysop, {exclude_username: true, exclude_connection: true}, i),
user: (e.misc & NODE_ANON) && !user.is_sysop ? "Anonymous" : usr.alias, user: (e.misc & NODE_ANON) && !user.is_sysop ? "Anonymous" : usr.alias,
connection : NodeConnectionProper[e.connection] ? NodeConnectionProper[e.connection] : (e.connection + ' bps') connection : NodeConnectionProper[e.connection] ? NodeConnectionProper[e.connection] : (e.connection + ' bps')
}; };
......
...@@ -40,17 +40,10 @@ if ((http_request.method === 'GET' || http_request.method === 'POST') && http_re ...@@ -40,17 +40,10 @@ if ((http_request.method === 'GET' || http_request.method === 'POST') && http_re
reply = system.node_list.reduce(function (a, c, i) { reply = system.node_list.reduce(function (a, c, i) {
if (c.status !== 3) return a; if (c.status !== 3) return a;
usr.number = c.useron; usr.number = c.useron;
if(c.action == NODE_BXFR) {
actionstr = format(extended_status(i));
} else if(c.action==NODE_XTRN && c.aux && xtrn_area.prog[usr.curxtrn]) {
actionstr = format("running %s",xtrn_area.prog[usr.curxtrn].name);
} else {
actionstr = format(NodeAction[c.action], c.aux, c.extaux);
}
a.push({ a.push({
node: i, node: i,
status: format(NodeStatus[c.status], c.aux, c.extaux), status: format(NodeStatus[c.status], c.aux, c.extaux),
action: actionstr, action: node_status(c, user.is_sysop, {exclude_username: true, exclude_connection: true}, i),
user: usr.alias, user: usr.alias,
connection: usr.connection connection: usr.connection
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment