Skip to content
Snippets Groups Projects
Commit 59a048b5 authored by Michael Long's avatar Michael Long
Browse files

enhancements to external menu mod

-gamemenu functionality
-add commands to any menu item
-built-in commands for common functions (feedback, etc.)
-use mod for displaying section menus (toggled with modopts)
-better input handling
-use require instead of load (more efficient)
-fix tabs in source
-fix bug with multicolumn display
parent 55271814
No related branches found
No related tags found
No related merge requests found
/**
* Custom External Program Menu Library for Custom External Program Menus
* by Michael Long mlong innerrealmbbs.us
*
* This provides common functionality for retrieving menus used by
*
* This provides common functionality for retrieving menus used by
* the loadable module xtrnmenu.js and by the web interface
* 099-xtrnmenu-games.xjs
*/
"use strict";
load("sbbsdefs.js", "K_NONE");
require("sbbsdefs.js", "K_NONE");
/* text.dat entries */
require("text.js", "XtrnProgLstFmt");
var MENU_LOADED = true;
function ExternalMenus() {
this.options = {};
this.xtrn_custommenu_options = {};
this.menuconfig = {};
this.getOptions();
this.getMenuConfig();
}
......@@ -31,7 +33,7 @@ ExternalMenus.prototype.getMenuConfig = function() {
config_src = config_file.read();
config_file.close();
}
if (typeof config_src !== "undefined") {
this.menuconfig = JSON.parse(config_src.toString());
}
......@@ -41,7 +43,7 @@ ExternalMenus.prototype.getOptions = function(menutype, menuid) {
if (typeof menutype === "undefined") {
menutype = 'custommenu';
}
// Get xtrn_sec options from modopts.ini [xtrn_sec]
if ((this.options = load({}, "modopts.js", "xtrn_sec")) == null) {
this.options = { multicolumn: true, sort: false };
......@@ -61,28 +63,19 @@ ExternalMenus.prototype.getOptions = function(menutype, menuid) {
if (this.options.multicolumn_fmt === undefined)
this.options.multicolumn_fmt = system.text(XtrnProgLstFmt);
if (this.options.singlecolumn_fmt === undefined)
this.options.singlecolumn_fmt = "\x01h\x01c%3u \xb3 \x01n\x01c%s\x01h ";
if (this.options.singlecolumn_margin == undefined)
this.options.singlecolumn_margin = 7;
if (typeof bbs !== "undefined") {
if (this.options.singlecolumn_height == undefined)
this.options.singlecolumn_height = console.screen_rows - this.options.singlecolumn_margin;
// override and turn off multicolumn if terminal width is less than 80
if (console.screen_columns < 80)
options.multicolumn = false;
}
if (this.options.restricted_user_msg === undefined)
this.options.restricted_user_msg = system.text(R_ExternalPrograms);
if (this.options.no_programs_msg === undefined)
if (this.options.no_programs_msg === undefined)
this.options.no_programs_msg = system.text(NoXtrnPrograms);
if (this.options.header_fmt === undefined)
this.options.header_fmt = system.text(XtrnProgLstHdr);
......@@ -92,7 +85,7 @@ ExternalMenus.prototype.getOptions = function(menutype, menuid) {
if (this.options.underline === undefined)
this.options.underline = system.text(XtrnProgLstUnderline);
if (this.options.which === undefined)
if (this.options.which === undefined)
this.options.which = system.text(WhichXtrnProg);
if (this.options.clear_screen === undefined)
......@@ -107,6 +100,10 @@ ExternalMenus.prototype.getOptions = function(menutype, menuid) {
if (this.options.section_which === undefined)
this.options.section_which = "\r\n\x01-\x01gWhich, \x01w\x01h~Q\x01n\x01guit or [1]: \x01h"
if (typeof (this.options.use_xtrn_sec) == "undefined") {
this.options.use_xtrn_sec = false;
}
// if its a custom menu, then override with custommenu_options
if (menutype == 'custommenu') {
if (typeof this.xtrn_custommenu_options.multicolumn_fmt !== "undefined") {
......@@ -123,7 +120,7 @@ ExternalMenus.prototype.getOptions = function(menutype, menuid) {
this.options.singlecolumn_fmt = "\x01h\x01c%3s \xb3 \x01n\x01c%s\x01h ";
}
this.options.header_fmt = (typeof this.xtrn_custommenu_options.header_fmt !== "undefined")
this.options.header_fmt = (typeof this.xtrn_custommenu_options.header_fmt !== "undefined")
? this.xtrn_custommenu_options.header_fmt : this.options.header_fmt;
this.options.titles = (typeof this.xtrn_custommenu_options.titles !== "undefined")
......@@ -153,11 +150,18 @@ ExternalMenus.prototype.getOptions = function(menutype, menuid) {
if (typeof bbs !== "undefined") {
this.options.singlecolumn_height = (typeof this.xtrn_custommenu_options.singlecolumn_height !== "undefined")
? this.xtrn_custommenu_options.singlecolumn_height : this.options.singlecolumn_height;
if (this.options.singlecolumn_height == undefined)
this.options.singlecolumn_height = console.screen_rows - this.options.singlecolumn_margin;
// override and turn off multicolumn if terminal width is less than 80
if (console.screen_columns < 80)
options.multicolumn = false;
}
// no need to override restricted_user_msg or no_programs_msg - these
// will be the same for both types of menus
// Allow overriding on a per-menu basis
var menuoptions = load({}, "modopts.js", "xtrnmenu:" + menuid);
if ((typeof menuid !== "undefined") && (menuoptions != null)) {
......@@ -166,9 +170,9 @@ ExternalMenus.prototype.getOptions = function(menutype, menuid) {
}
}
}
// these options only apply to terminals/consoles
// the intention is to obtain all the mod_opts options for xtrn_sec, and
// override if a custom menu global setting is set
......@@ -176,11 +180,11 @@ ExternalMenus.prototype.getOptions = function(menutype, menuid) {
if (this.options.custom_menu_not_found_msg === undefined) {
this.options.custom_menu_not_found_msg = "Menu %MENUID% not found";
}
if (this.options.custom_menu_program_not_found_msg === undefined) {
this.options.custom_menu_program_not_found_msg = "Program %PROGRAMID% not found";
}
return this.options;
}
......@@ -194,7 +198,7 @@ ExternalMenus.prototype.getMenu = function(menuid) {
}
var menu;
if ((typeof this.menuconfig !== "undefined") && (typeof this.menuconfig.menus !== "undefined")) {
this.menuconfig.menus.some(function (indmenu) {
if (indmenu.id.toLowerCase() == menuid) {
......@@ -202,10 +206,10 @@ ExternalMenus.prototype.getMenu = function(menuid) {
}
});
}
if (!menu && (menuid == "main")) {
// no custom menus defined, make one to mimic old behavior
var menuitems = [];
var i;
......@@ -221,7 +225,7 @@ ExternalMenus.prototype.getMenu = function(menuid) {
i++;
}
});
menu = {
"id": "main",
"title": "Main Menu",
......@@ -238,19 +242,19 @@ ExternalMenus.prototype.getSectionMenu = function(menuid) {
if ((typeof menuid === "undefined") || !menuid) {
return false;
}
var menuitems = [];
var menu, title;
xtrn_area.sec_list.some(function (sec) {
if (sec.code.toLowerCase() == menuid.toLowerCase()) {
title = sec.name;
if (!sec.can_access || sec.prog_list.length < 1) {
return false;
}
var i = 1;
sec.prog_list.some(function (prog) {
menuitems.push({
......@@ -263,7 +267,7 @@ ExternalMenus.prototype.getSectionMenu = function(menuid) {
});
i++;
});
if (menuitems.length > 0) {
menu = {
'id': menuid,
......@@ -281,13 +285,13 @@ ExternalMenus.prototype.getSectionMenu = function(menuid) {
// Sort the menu items according to options
ExternalMenus.prototype.getSortedItems = function(menuobj) {
var sort_type;
if ((typeof menuobj.sort_type !== "undefined") && menuobj.sort_type) {
sort_type = menuobj.sort_type; // "name" or "key"
} else {
sort_type = this.options.sort; // bool
}
// first, build a new menu with only options they have access to
var menuitemsfiltered = [];
for (i in menuobj.items) {
......@@ -301,7 +305,7 @@ ExternalMenus.prototype.getSortedItems = function(menuobj) {
}
}
break;
case 'xtrnprog':
for (j in xtrn_area.sec_list) {
for (var k in xtrn_area.sec_list[j].prog_list) {
......@@ -313,7 +317,7 @@ ExternalMenus.prototype.getSortedItems = function(menuobj) {
}
}
break;
case 'custommenu':
default:
if ((typeof menuobj.items[i].access_string === "undefined") || !menuobj.items[i].access_string) {
......@@ -328,7 +332,7 @@ ExternalMenus.prototype.getSortedItems = function(menuobj) {
break;
}
}
// if no custom input keys are specified for an input, then assign a numeric input
// this would mimic the built-in external section menu functionality
// but this is only assigned on sort_type key because if the sort type is for
......@@ -340,10 +344,10 @@ ExternalMenus.prototype.getSortedItems = function(menuobj) {
if (menuitemsfiltered[i].input > sortind) {
sortind = menuitemsfiltered[i].input;
}
}
}
}
sortind++;
if (sort_type == "key") {
for (i in menuitemsfiltered) {
if (!menuitemsfiltered[i].input) {
......@@ -352,7 +356,7 @@ ExternalMenus.prototype.getSortedItems = function(menuobj) {
}
}
}
if (sort_type) {
switch (sort_type) {
case "key":
......@@ -365,7 +369,7 @@ ExternalMenus.prototype.getSortedItems = function(menuobj) {
break;
}
}
// if this is a sort by title and the key is empty, it will be assigned the next available number
// this is to support auto-generated inputs like is done on the built-in section menus
// however, to keep the numeric keys in order, the numbers could not be pre-assigned like it done
......@@ -376,7 +380,7 @@ ExternalMenus.prototype.getSortedItems = function(menuobj) {
sortind++;
}
}
return menuitemsfiltered;
}
......
......@@ -5,11 +5,11 @@
*
* This is the loadable module that displays the custom external menus
* in terminal server (telnet/rlogin/ssh)
*
*
* To jump to a specific menu, pass the ID as an argument
*
*
* To set options, add to modopts.ini [xtrnmenu]
*
*
* See instructions at http://wiki.synchro.net/module:xtrnmenu
*/
......@@ -17,7 +17,7 @@
require("sbbsdefs.js", "K_NONE");
load("xtrnmenulib.js");
require("xtrnmenulib.js", "MENU_LOADED");
var options, xsec = -1;
......@@ -25,38 +25,88 @@ var options, xsec = -1;
var ExternalMenus = new ExternalMenus();
const menuconfig = ExternalMenus.menuconfig;
{
var i,j;
for(i in argv) {
for(j in xtrn_area.sec_list) {
if(argv[i].toLowerCase()==xtrn_area.sec_list[j].code)
xsec=j;
var i,j;
if ((argv[0] == 'command') && (typeof argv[1] != "undefined")) {
docommand(argv[1]);
} else if (argv[0] == 'gamesrv') {
external_section_menu_custom('gamesrv');
} else {
for (i in argv) {
for (j in xtrn_area.sec_list) {
if (argv[i].toLowerCase() == xtrn_area.sec_list[j].code)
xsec = j;
}
}
}
if (xsec > -1) {
// if its the id of a standard section menu, send it to the
// stock menu
js.exec("xtrn_sec.js", {}, xsec);
} else if (typeof argv[0] !== "undefined") {
// if its not a section menu, assume it is a custom menu
external_section_menu_custom(argv[0]);
} else {
// main custom menu
external_section_menu_custom();
if (xsec > -1) {
// if its the id of a standard section menu
if (options.use_xtrn_sec) {
// stock menu
js.exec("xtrn_sec.js", {}, xsec);
} else {
external_section_menu_custom(xsec);
}
} else if (typeof argv[0] !== "undefined") {
// if its not a section menu, assume it is a custom menu
external_section_menu_custom(argv[0]);
} else {
// main custom menu
external_section_menu_custom();
}
}
// Runs custom commands, for gamesrv
function docommand(command)
{
switch (command) {
case 'checkmail':
var lmsg = user.stats.mail_wait;
if (lmsg > 0) {
console.putmsg('\r\n\x01gYou have \x01c' + parseInt(lmsg) + ' \x01gMessages waiting');
} else {
console.putmsg('\r\n\x01gNo New Messages');
}
mswait(1500);
console.clear();
break;
case 'feedback':
var subject;
console.putmsg('\r\n\x01\gPlease choose \x01wYes \x01gto forward to netmail!\r\n\r\n');
bbs.email(1, subject = "Game Server Feedback\r\n");
console.putmsg('Thank you for your Feedback, @SYSOP@ will get back to you ASAP!\r\n\r\n');
break;
case 'prefs':
bbs.user_config();
break;
case 'sysop':
require("str_cmds.js", "str_cmds");
console.putmsg("\r\n\x01gCommand: ");
var commandstr;
commandstr = console.getstr();
str_cmds(commandstr);
break;
default:
doerror("Unknown command " + command);
break;
}
}
// Renders the top-level external menu
function external_section_menu_custom(menuid)
{
var i, menucheck, menuobj, item_multicolumn_fmt, item_singlecolumn_fmt,
cost, multicolumn, menuitemsfiltered = [];
cost, multicolumn, menuitemsfiltered = [];
var validkeys = []; // valid chars on menu selection
var keymax = 0; // max integer allowed on menu selection
var gamesrv = menuid == "gamesrv" ? true : false;
if (gamesrv) {
menuid = undefined;
}
var options = ExternalMenus.getOptions('custommenu', menuid);
menuobj = ExternalMenus.getMenu(menuid);
// Allow overriding auto-format on a per-menu basis
......@@ -67,8 +117,11 @@ function external_section_menu_custom(menuid)
console.aborted = false;
if (typeof menuobj === "undefined") {
doerror(options.custom_menu_not_found_msg.replace('%MENUID%', menuid));
break;
menuobj = ExternalMenus.getSectionMenu(menuid);
if (typeof menuobj === "undefined") {
doerror(options.custom_menu_not_found_msg.replace('%MENUID%', menuid));
break;
}
}
if (options.clear_screen) {
......@@ -85,25 +138,22 @@ function external_section_menu_custom(menuid)
break;
}
var keyin;
system.node_list[bbs.node_num-1].aux = 0; /* aux is 0, only if at menu */
bbs.node_action = NODE_XTRN;
bbs.node_sync();
menuitemsfiltered = ExternalMenus.getSortedItems(menuobj);
menuitemsfiltered = ExternalMenus.getSortedItems(menuobj);
if (!bbs.menu("xtrnmenu_head_" + menuid, P_NOERROR) && !bbs.menu("xtrnmenu_head", P_NOERROR)) {
bbs.menu("xtrn_head", P_NOERROR);
}
}
// if file exists text/menu/xtrnmenu_(menuid).[rip|ans|mon|msg|asc],
// then display that, otherwise dynamiic
if (!bbs.menu("xtrnmenu_" + menuid, P_NOERROR)) {
if (!bbs.menu("xtrnmenu_" + menuid, P_NOERROR)) {
// if no custom menu file in text/menu, create a dynamic one
multicolumn = options.multicolumn && menuitemsfiltered.length > options.singlecolumn_height;
printf(options.header_fmt, menuobj.title);
if(options.titles.trimRight() != '')
write(options.titles);
......@@ -122,7 +172,7 @@ function external_section_menu_custom(menuid)
write(options.underline);
}
console.crlf();
// n is the number of items for the 1st column
var n;
if (multicolumn) {
......@@ -130,18 +180,18 @@ function external_section_menu_custom(menuid)
} else {
n = menuitemsfiltered.length;
}
// j is the index for each menu item on 2nd column
// j is the index for each menu item on 2nd column
var j = n; // start j at the first item for 2nd column
for (i = 0; i < n && !console.aborted; i++) {
cost = "";
if (menuitemsfiltered[i].type == "xtrnprog") {
// if its an external program, get the cost
cost = xtrn_area.prog[menuitemsfiltered[i].target.toLowerCase()].cost;
}
console.add_hotspot(menuitemsfiltered[i].input.toString());
cost = "";
if (menuitemsfiltered[i].type == "xtrnprog") {
// if its an external program, get the cost
cost = xtrn_area.prog[menuitemsfiltered[i].target.toLowerCase()].cost;
}
console.add_hotspot(menuitemsfiltered[i].input.toString());
validkeys.push(menuitemsfiltered[i].input.toString());
var intCheck = Number(menuitemsfiltered[i].input);
if (!intCheck.isNaN) {
......@@ -151,7 +201,7 @@ function external_section_menu_custom(menuid)
}
// allow overriding format on a per-item basis
// great for featuring a specific game
// great for featuring a specific game
var checkkey = menuitemsfiltered[i].target + '-multicolumn_fmt';
checkkey = checkkey.toLowerCase();
item_multicolumn_fmt = (typeof options[checkkey] !== "undefined") ?
......@@ -159,13 +209,13 @@ function external_section_menu_custom(menuid)
checkkey = menuitemsfiltered[i].target + '-singlecolumn_fmt'
checkkey = checkkey.toLowerCase();
item_singlecolumn_fmt = (typeof options[checkkey] !== "undefined") ?
item_singlecolumn_fmt = (typeof options[checkkey] !== "undefined") ?
options[checkkey] : options.singlecolumn_fmt;
printf(multicolumn ? item_multicolumn_fmt : item_singlecolumn_fmt,
menuitemsfiltered[i].input.toString().toUpperCase(),
menuitemsfiltered[i].title,
cost
menuitemsfiltered[i].input.toString().toUpperCase(),
menuitemsfiltered[i].title,
cost
);
if (multicolumn) {
......@@ -189,12 +239,12 @@ function external_section_menu_custom(menuid)
checkkey = menuitemsfiltered[j].target + '-singlecolumn_fmt'
checkkey = checkkey.toLowerCase();
write(options.multicolumn_separator);
write(options.multicolumn_separator);
console.add_hotspot(menuitemsfiltered[j].input.toString());
printf(item_multicolumn_fmt,
menuitemsfiltered[j].input.toString().toUpperCase(),
menuitemsfiltered[j].input.toString().toUpperCase(),
menuitemsfiltered[j].title,
cost
cost
);
} else {
write(options.multicolumn_separator);
......@@ -204,6 +254,12 @@ function external_section_menu_custom(menuid)
console.crlf();
}
if (gamesrv) {
if (!bbs.menu("xtrn_gamesrv_tail_" + menuid, P_NOERROR)) {
bbs.menu("xtrn_gamesrv_tail", P_NOERROR);
}
}
if (!bbs.menu("xtrnmenu_tail_" + menuid, P_NOERROR) && !bbs.menu("xtrnmenu_tail", P_NOERROR)) {
bbs.menu("xtrn_tail", P_NOERROR);
}
......@@ -213,16 +269,56 @@ function external_section_menu_custom(menuid)
}
validkeys.push('q');
keyin = console.getkeys(validkeys, keymax, K_NONE);
var keyin, keyin2;
var maxkeylen = 0;
var maxfirstkey = 0;
var morekeys = [];
var k;
for (k in validkeys) {
if (validkeys[k].length > maxkeylen) {
maxkeylen = validkeys[k].length;
}
if (validkeys[k].length > 1) {
morekeys.push(validkeys[k].toString().toLowerCase().substring(0,1));
}
}
// get first key
keyin = console.getkey();
keyin = keyin.toString().toLowerCase();
// The logic below is to make it not require enter for as
// many items as possible
// if max keys is 2 and they entered something that might have
// a second digit/char, then get the key
if (maxkeylen == 2) {
if (morekeys.indexOf(keyin) !== -1) {
write(keyin);
keyin2 = console.getkey(); // either the second digit or enter
if ((keyin2 != "\r") && (keyin2 != "\n") && (keyin2 != "\r\n")) {
keyin = keyin + keyin2.toLowerCase();
}
}
} else if (maxkeylen > 2) {
// there there are more than 99 items, then just use getkeys
// for the rest
write(keyin);
keyin2 = console.getkeys(validkeys, keymax);
keyin = keyin + keyin2.toLowerCase();
}
if (keyin) {
// q for quit
if (keyin == "q") {
console.clear();
break;
if (keyin == 'q') {
if (gamesrv && ('menuid' == 'main')) {
bbs.logoff();
} else {
console.clear();
return;
}
}
menuitemsfiltered.some(function (menuitemfiltered) {
var menutarget = menuitemfiltered.target.toLowerCase();
var menuinput = menuitemfiltered.input.toString().toLowerCase();
......@@ -235,8 +331,11 @@ function external_section_menu_custom(menuid)
return true;
// external program section
case 'xtrnmenu':
js.exec("xtrn_sec.js", {}, menutarget);
//js.exec(js.exec_dir + 'xtrn_sec.js ' + menutarget)
if (options.use_xtrn_sec) {
js.exec("xtrn_sec.js", {}, menutarget);
} else {
external_section_menu_custom(menutarget);
}
return true;
// external program
case 'xtrnprog':
......@@ -248,6 +347,9 @@ function external_section_menu_custom(menuid)
doerror(options.custom_menu_program_not_found_msg.replace('%PROGRAMID%', menutarget));
}
break;
case 'command':
bbs.exec(menutarget);
return true;
} //switch
} // if menu item matched keyin
}); // foreach menu item
......
......@@ -97,7 +97,7 @@ var editMenu = function(menuid) {
displayoptions.push(format("%23s: %s", "Edit Items", "[...]"));
displayoptionids.push("items");
selection = uifc.list(WIN_ORG|WIN_MID|WIN_ACT|WIN_ESC, 0, 0, 0, last, last,
menu.title + ": Options", displayoptions);
......@@ -170,7 +170,7 @@ var editItems = function(menuid) {
// cur bar top left width
var ctxm = new uifc.list.CTX(0, 0, 0, 0, 0);
if (typeof menuid === "undefined") {
uifc.msg("Menu could not be found");
return;
......@@ -182,12 +182,12 @@ var editItems = function(menuid) {
}
}
}
if ((typeof menu.items == "undefined") || (menu.items.length == 0)) {
// no items, prompt them to make one
editItem(menu.id, 0);
}
uifc.help_text = word_wrap("This menu allows editing the various items in this menu.\r\n\r\n"
+ "If you leave input key blank, it will use an auto-generated number at display time.\r\n\r\n"
......@@ -223,7 +223,7 @@ var editItems = function(menuid) {
items,
ctxm
);
if (selection == -1) {
// esc key
break;
......@@ -305,10 +305,10 @@ var editItems = function(menuid) {
for (i in menu.items) {
menuitems2.push(menu.items[i]);
// paste copied item after selected item
if (i == itemids[selection]) {
menuitems2.push(copyitem);
if (i == itemids[selection]) {
menuitems2.push(copyitem);
ctxm.cur = i-1;
}
}
}
menu.items = menuitems2;
}
......@@ -383,7 +383,7 @@ var editItem = function(menuid, itemindex) {
("target" in item ? item.target : "")));
displayoptionids.push("target");
if (item.type == "custommenu") {
if ((item.type == "custommenu") || (item.type == "command")) {
displayoptions.push(format("%23s: %s", "access_string",
("access_string" in item ? item.access_string : "(default)")));
displayoptionids.push("access_string");
......@@ -412,7 +412,7 @@ var editItem = function(menuid, itemindex) {
}
switch (displayoptionids[selection]) {
case 'input':
uifc.help_text = word_wrap("The input key to access this item. Can be anything except Q. Leave blank to auto-generate a number.");
selection2 = uifc.input(WIN_MID, "Input Key", item.input, 3, K_EDIT);
......@@ -478,7 +478,7 @@ var editItem = function(menuid, itemindex) {
}
item.access_string = selection2;
break;
}
last = Math.max(selection, 0);
}
......@@ -490,7 +490,8 @@ function present_select_targettype(item)
"This is the type of target this item points to.\r\n\r\n"
+ "custommenu is a custom menu defined in this tool.\r\n\r\n"
+ "xtrnmenu is a standard Syncrhonet External Section Menu (refer to the scfg tool).\r\n\r\n"
+ "xtrnprog is a direct link to an external program (refer to the scfg tool)");
+ "xtrnprog is a direct link to an external program (refer to the scfg tool)"
+ "command is a synchronet command line. See http://wiki.synchro.net/config:cmdline");
var targetypectx = uifc.list.CTX(0, 0, 0, 0, 0);
if (typeof item.type !== "undefined") {
......@@ -507,10 +508,14 @@ function present_select_targettype(item)
targetypectx.cur = 2;
targetypectx.bar = 2;
break;
case 'command':
targetypectx.cur = 3;
targetypectx.bar = 3;
break;
}
}
switch (uifc.list(WIN_ORG | WIN_MID | WIN_SAV,
"Target Type", ["custommenu", "xtrnmenu", "xtrnprog"], targetypectx)) {
"Target Type", ["custommenu", "xtrnmenu", "xtrnprog", "command"], targetypectx)) {
case 0:
item.type = "custommenu";
break;
......@@ -520,13 +525,16 @@ function present_select_targettype(item)
case 2:
item.type = "xtrnprog";
break;
case 3:
item.type = "command";
break;
default:
// includes escape key
break;
}
// convienence... enter target selection
present_select_target(item)
present_select_target(item)
}
function present_select_target(item)
......@@ -538,9 +546,9 @@ function present_select_target(item)
var custommenuitems = [];
var custommenuitemsids = [];
var custommenunames = [];
var selection2;
switch (item.type) {
case "custommenu":
// present list of custom menus
......@@ -582,7 +590,7 @@ function present_select_target(item)
seclist.push({ code: xtrn_area.sec_list[i].code, name: xtrn_area.sec_list[i].name});
};
seclist.sort(sort_by_code);
for (i in seclist) {
custommenuitems.push(format("%23s: %s", seclist[i].code, seclist[i].name));
custommenuitemsids.push(seclist[i].code);
......@@ -655,6 +663,15 @@ function present_select_target(item)
}
break;
command:
selection2 = uifc.input(WIN_ORG | WIN_MID, "Command", item.target, 63, K_EDIT);
if ((selection2 < 0) || (selection2 == null)) {
// escape key
break;
}
item.target = selection2;
break;
default:
selection2 = uifc.input(WIN_ORG | WIN_MID, "Target", item.target, 50, K_EDIT);
if ((selection2 < 0) || (selection2 == null)) {
......@@ -664,7 +681,7 @@ function present_select_target(item)
item.target = selection2;
break;
}
}
}
function sort_by_name(a, b)
......@@ -708,14 +725,14 @@ try {
}
}
config_file.close();
if (typeof menuconfig.menus === "undefined") {
menuconfig.menus = [];
}
uifc.init("Enhanced External Program Menus Configurator");
uifc.lightbar_color = 120;
uifc.background_color = 21;
uifc.background_color = 21;
uifc.frame_color = 15;
js.on_exit("if (uifc.initialized) uifc.bail()");
......@@ -745,9 +762,9 @@ try {
menus.push(menuconfig.menus[m].id);
menuTitles.push(format("%20s: %s", menuconfig.menus[m].id, menuconfig.menus[m].title));
}
menuTitles.push(format("%20s %s", '', "[Save Config Without Exit]"));
// WIN_ORG = original menu, destroy valid screen area
// WIN_MID = place window in middle of screen
// WIN_XTR = add extra line at end for inserting at end
......
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