From c1ba0f6b367f10e2ab53202eeb27698847e530e9 Mon Sep 17 00:00:00 2001 From: Rob Swindell <rob@synchro.net> Date: Tue, 24 Nov 2020 15:32:05 -0800 Subject: [PATCH] Refactor commit 25360110a6f (customizable xtrn program section menu) Use the text.dat strings that corresponded with the previous behavior (used by console.uselect()). The defaults include new-lines, so removed some hard-coded console.crlf() calls that were added. If you have a custom section_header_fmt, you'll likely need to add a \r\n to it. Allow the "External Program Section" title string to be customized (separately from section_header_fmt, e.g. for localization). Save/use the current section. Mouse-enable the program section list. --- exec/xtrn_sec.js | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/exec/xtrn_sec.js b/exec/xtrn_sec.js index 0c5ea66cd8..95aa262d8b 100644 --- a/exec/xtrn_sec.js +++ b/exec/xtrn_sec.js @@ -74,14 +74,16 @@ if(options.clear_screen === undefined) options.clear_screen = true; if (options.section_fmt === undefined) - options.section_fmt = "\x01y\x01g%3d:\x01n\x01g %s" + options.section_fmt = bbs.text(SelectItemFmt); if (options.section_header_fmt === undefined) - options.section_header_fmt = "\x01-\x01gSelect \x01hExternal Program Section\x01-\x01g:" + options.section_header_fmt = bbs.text(SelectItemHdr); if(options.section_which === undefined) - options.section_which = "\r\n\x01-\x01gWhich, \x01w\x01h~Q\x01n\x01guit or [1]: \x01h" + options.section_which = bbs.text(SelectItemWhich); +if(options.section_header_title === undefined) + options.section_header_title = "External Program Section"; function sort_by_name(a, b) { @@ -197,6 +199,7 @@ function external_program_menu(xsec) function external_section_menu() { var i,j; + var xsec=0; while(bbs.online) { @@ -211,7 +214,6 @@ function external_section_menu() break; } - var xsec=0; var sec_list=xtrn_area.sec_list.slice(); /* sec_list is a possibly-sorted copy of xtrn_area.sect_list */ system.node_list[bbs.node_num-1].aux=0; /* aux is 0, only if at menu */ @@ -232,25 +234,20 @@ function external_section_menu() if(options.sort) sec_list.sort(sort_by_name); - printf(options.section_header_fmt); - console.crlf(); - console.crlf(); + printf(options.section_header_fmt, options.section_header_title); - for (i in sec_list) { - printf(options.section_fmt, parseInt(i) + 1, sec_list[i].name); - console.crlf(); + for (i = 0; i < sec_list.length; i++) { + console.add_hotspot(i+1); + printf(options.section_fmt, i + 1, sec_list[i].name); } bbs.node_sync(); - console.mnemonics(options.section_which); - - xsec = console.getnum(sec_list.length); - xsec--; // match array index + console.mnemonics(format(options.section_which, xsec + 1)); - if(xsec == -1) - xsec = 0; // default option - else if(xsec == -2) + xsec = console.getnum(sec_list.length, xsec + 1); + if(xsec < 1) break; + xsec--; } external_program_menu(sec_list[xsec].index); -- GitLab