Skip to content
Snippets Groups Projects
Commit a3a9115c authored by echicken's avatar echicken :chicken:
Browse files

Unbreak active_node_list setting.

Removed some unused stuff.
parent 64c382e3
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
......@@ -73,7 +73,7 @@ function scan() {
if (e.status != NODE_INUSE) {
return {
node: i + 1,
status: null,
status: locale.strings.sidebar_node_list.label_waiting_for_call,
action: null,
user: null,
connection: ''
......
......@@ -100,6 +100,7 @@ label_node_column = Node
label_send_telegram = Send a telegram
label_status_column = Status
label_status_web = browsing
label_waiting_for_call = Waiting for call
[sidebar_recent_visitors]
label_title = Recent Visitors
......
<h4><?xjs write(locale.strings.sidebar_node_list.label_title); ?></h4>
<div id="sbbs-nodelist"></div>
<?xjs if (settings.nodelist_ibbs) { ?>
<div id="sbbsimsg-nodelist"></div>
<?xjs } ?>
<script type="text/javascript">
......@@ -10,30 +7,6 @@
const nch = '<?xjs write(settings.active_node_list ? locale.strings.sidebar_node_list.label_connection_column : locale.strings.sidebar_node_list.label_node_column) ?>';
const nll = <?xjs write(system.node_list.length); ?>;
var niu = 0;
var ns = 0;
function _sb_list_node(e) {
if (e.action === null || e.user === null) return;
$('#sbbs-nodelist-table').append(
'<tr>' +
'<th scope="row">' +
(anl ? e.connection : (typeof e.node == 'number' ? e.node + 1 : e.connection)) +
'</th>' +
'<td id="nodelist-' + e.node + '">' +
(e.user == '' ? e.status : ('<strong>' + e.user + '</strong> ' + e.action)) +
'</td>' +
'</tr>'
);
if (e.user != '' && <?xjs write(user.alias != settings.guest); ?>) {
$('#nodelist-' + e.node).attr('title', '<?xjs write(locale.strings.sidebar_node_list.label_send_telegram); ?>');
$('#nodelist-' + e.node).css('cursor', 'pointer');
$('#nodelist-' + e.node).click(function () {
sendTelegram(e.user);
});
}
if (typeof e.node == 'number' && e.user != '') niu++;
ns++;
}
function _sb_nodelist(evt) {
const data = JSON.parse(evt.data);
......@@ -49,30 +22,29 @@
'</table>'
);
niu = 0;
ns = 0;
if (!anl) {
const nodes = Array(nll);
data.forEach(function (e) {
if (typeof e.node == 'number') {
nodes[e.node] = e;
} else {
nodes.push(e); // Web user
}
});
for (var n = 0; n < nodes.length; n++) {
if (!nodes[n]) {
_sb_list_node({ node: n, user: '', status :'Waiting for call' });
} else {
_sb_list_node(nodes[n], n);
}
var ns = data.reduce((a, c) => {
if (anl && (c.action === null || c.user === null)) return a;
$('#sbbs-nodelist-table').append(
'<tr>' +
'<th scope="row">' +
(anl ? c.connection : (typeof c.node == 'number' ? c.node : c.connection)) +
'</th>' +
`<td id="nodelist-${c.node}">` +
(c.user ? `<strong>${c.user}</strong> ${c.action}` : c.status) +
'</td>' +
'</tr>'
);
if (c.user && <?xjs write(user.alias != settings.guest); ?>) {
$(`#nodelist-${c.node}`).attr('title', '<?xjs write(locale.strings.sidebar_node_list.label_send_telegram); ?>');
$(`#nodelist-${c.node}`).css('cursor', 'pointer');
$(`#nodelist-${c.node}`).click(() => sendTelegram(c.user));
}
if (typeof c.node == 'number' && c.user != '') niu++;
return a + 1;
}, 0);
if (ns) {
$('#sbbs-nodelist').parent().removeClass('hidden');
} else {
data.forEach(_sb_list_node);
if (ns) {
$('#sbbs-nodelist').parent().removeClass('hidden');
$('#sbbs-nodelist').removeClass('hidden');
}
$('#sbbs-nodelist').removeClass('hidden');
}
// Spans with these classes are used in the 'system stats' sidebar module.
// Update the nodes in use / available counters there.
......@@ -82,68 +54,4 @@
registerEventListener('nodelist', _sb_nodelist);
<?xjs if (settings.nodelist_ibbs) { ?>
function _send_ibbs_telegram(sys, host, user) {
async function send_ibbs_tg(evt) {
if (typeof evt !== 'undefined') evt.preventDefault();
await v4_post('./api/sbbsimsg.ssjs', {
call: 'send_telegram',
username: user,
host: host,
message: $('#telegram').val()
});
$('#popUpModal').modal('hide');
};
$('#popUpModalTitle').html('Send a telegram to ' + user + '@' + sys);
$('#popUpModalBody').html(
'<form id="ibbs-telegram-form">'
+ '<input type="text" class="form-control" placeholder="My message" name="telegram" id="telegram">'
+ '<input type="submit" value="submit" class="hidden">'
+ '</form>'
);
$('#popUpModalActionButton').show();
$('#ibbs-telegram-form').submit(send_ibbs_tg);
$('#popUpModalActionButton').click(send_ibbs_tg);
$('#popUpModal').modal('show');
}
registerEventListener('sbbsimsg', function (e) {
const data = JSON.parse(e.data);
var users = 0;
$('#sbbsimsg-nodelist').addClass('hidden');
$('#sbbsimsg-nodelist').html('<h4>Other Systems</h4>');
Object.keys(data).forEach(function (e, i) {
if (!data[e].users.length) return;
const id = 'sbbsimsg-nodelist-' + i;
$('#sbbsimsg-nodelist').append(
'<table id="' + id + '" class="table table-condensed table-responsive table-striped">'
+ '<tr><td><strong>' + e + '</strong></td></tr>'
+ '</table>'
);
data[e].users.forEach(function (ee, ii) {
const nid = id + '-' + ii;
$('#' + id).append(
'<tr>'
+ '<td id="' + nid + '">'
+ '<strong>' + ee.name + '</strong> ' + ee.action
+ '</td>'
+'</tr>'
);
if (<?xjs write(user.alias != settings.guest); ?>) {
$('#' + nid).click(function () {
_send_ibbs_telegram(e, data[e].host, ee.name);
});
$('#' + nid).attr('title', '<?xjs write(locale.strings.sidebar_node_list.label_send_telegram); ?>');
$('#' + nid).css('cursor', 'pointer');
}
});
users += data[e].users.length;
});
if (users) {
$('#sbbsimsg-nodelist').removeClass('hidden');
$('#sbbs-nodelist').parent().removeClass('hidden');
}
});
<?xjs } ?>
</script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment