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

Show domain & date information in top bar when domain tree expanded.

parent 6325bf45
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
......@@ -160,7 +160,7 @@ function populate_zone_tree(filename, tree, settings) {
});
}
function populate_domain_tree(filename, domain, tree, settings) {
function populate_domain_tree(filename, domain, tree, settings, frame) {
try {
const nodelist = new NodeList(filename);
} catch (err) {
......@@ -169,6 +169,7 @@ function populate_domain_tree(filename, domain, tree, settings) {
}
const domain_tree = tree.addTree(domain);
const idx = tree.items.length - 1;
var sframe;
domain_tree.onOpen = function () {
populate_zone_tree(filename, domain_tree, settings);
if (settings.auto_close_domain) {
......@@ -179,24 +180,30 @@ function populate_domain_tree(filename, domain, tree, settings) {
}
});
}
if (nodelist.domain && nodelist.date) {
sframe = new Frame(frame.x, frame.y + 1, frame.width, 1, frame.attr, frame);
sframe.open();
sframe.putmsg(nodelist.domain + ' nodelist for ' + nodelist.date);
}
tree.refresh();
}
domain_tree.onClose = function () {
domain_tree.items = [];
if (sframe instanceof Frame) sframe.delete();
}
}
function populate_tree(tree, settings) {
function populate_tree(tree, settings, frame) {
const ftn_domains = new FTNDomains();
Object.keys(ftn_domains.nodeListFN).forEach(function (e) {
if (!file_exists(ftn_domains.nodeListFN[e])) return;
const dn = settings['domain_' + e] || e;
populate_domain_tree(ftn_domains.nodeListFN[e], dn, tree, settings);
populate_domain_tree(ftn_domains.nodeListFN[e], dn, tree, settings, frame);
});
Object.keys(settings).forEach(function (e) {
if (e.search(/^nodelist_/) > -1 && file_exists(settings[e])) {
const dn = e.replace(/^nodelist_/, '');
populate_domain_tree(settings[e], dn, tree, settings);
populate_domain_tree(settings[e], dn, tree, settings, frame);
}
});
tree.items.sort(function (a, b) {
......@@ -206,13 +213,11 @@ function populate_tree(tree, settings) {
}
function search(frame, settings) {
const sframe = new Frame(frame.x, frame.y + 4, frame.width, 3, BG_BLUE|WHITE, frame);
sframe.putmsg('Search by address, system name, sysop, or location:');
sframe.gotoxy(1, 3);
sframe.putmsg("Type a query and wait for results, don't hit enter.");
sframe.open();
const typeahead = new Typeahead({
x: 1,
y: sframe.y + 1,
......@@ -240,11 +245,8 @@ function search(frame, settings) {
node: e,
text: format(
'%-15s%-' + w + 's %-' + w + 's %-' + w + 's',
e.addr,
e.name.substr(0, w),
e.location.substr(0, w),
e.sysop.substr(0, w)
)
e.addr, e.name.substr(0, w), e.location.substr(0, w), e.sysop.substr(0, w)
),
});
return true;
}
......@@ -254,9 +256,8 @@ function search(frame, settings) {
});
return ret;
}
]
],
});
var user_input;
while (typeof user_input == 'boolean' || typeof user_input == 'undefined') {
user_input = typeahead.inkey(console.inkey(K_NONE));
......@@ -269,7 +270,6 @@ function search(frame, settings) {
}
typeahead.close();
sframe.close();
if (typeof user_input == 'object') {
node_info_popup(user_input.node, frame, settings);
}
......@@ -277,17 +277,11 @@ function search(frame, settings) {
}
function main() {
const ca = console.attributes;
const bss = bbs.sys_status;
bbs.sys_status|=SS_MOFF;
const frame = new Frame(
1, 1, console.screen_columns, console.screen_rows, BG_BLUE|WHITE
);
const tree_frame = new Frame(
frame.x, frame.y + 2, frame.width, frame.height - 4, BG_BLACK, frame
);
const frame = new Frame(1, 1, console.screen_columns, console.screen_rows, BG_BLUE|WHITE);
const tree_frame = new Frame(frame.x, frame.y + 2, frame.width, frame.height - 4, BG_BLACK, frame);
const tree = new Tree(tree_frame);
tree.colors.lfg = WHITE;
tree.colors.lbg = BG_CYAN;
......@@ -295,7 +289,6 @@ function main() {
tree.colors.kfg = WHITE;
tree.colors.xfg = LIGHTCYAN;
const scrollbar = new ScrollBar(tree, { autohide: true });
// Valid settings:
// auto_close_domain t/f
// auto_close_zone t/f
......@@ -311,18 +304,15 @@ function main() {
if (typeof settings[e] == 'undefined') settings[e] = defaults[e];
});
settings.frame = frame;
frame.putmsg('Nodelist Browser');
frame.gotoxy(1, frame.height);
frame.putmsg('\1h\1cS\1h\1wearch \1h\1cQ\1h\1wuit');
populate_tree(tree, settings);
populate_tree(tree, settings, frame);
console.clear(LIGHTGRAY);
frame.open();
tree.open();
frame.cycle();
scrollbar.cycle();
var user_input;
while ((user_input = console.getkey(K_NOSPIN).toLowerCase()) != 'q') {
if (user_input == 's') {
......@@ -331,16 +321,11 @@ function main() {
tree.getcmd(user_input);
scrollbar.cycle();
}
if (frame.cycle()) {
console.gotoxy(console.screen_columns, console.screen_rows);
}
yield();
if (frame.cycle()) console.gotoxy(console.screen_columns, console.screen_rows);
}
frame.close();
bbs.sys_status = bss;
console.clear(ca);
}
main();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment