Skip to content
Snippets Groups Projects
Commit 0dae7271 authored by Eric Oulashin's avatar Eric Oulashin
Browse files

Added exec/load/user_settings.js, currently with a function to prompt the user...

Added exec/load/user_settings.js, currently with a function to prompt the user for a preferred download protocol. Used by DDMsgReader, and user_settings.js can use it too.
parent 2621a035
No related branches found
No related tags found
1 merge request!465DDMsgReader: Sorting of sub-boards when changing to another sub-board (for nelgin). Toggleable behavior to only show sub-boards with new messages in the indexed-mode newscan (for kdi4hw). Internal: Updated for bbs.msg_number and bbs.smb_curmsg being write
Pipeline #6928 passed
// This is a library of functions to allow the user to change their settings.
//
// *** NOTE - This will only work on Synchronet v3.20 or above!
"use strict";
require("gettext.js", "gettext");
// Prompts the user for their preferred download protocol & auto-hangup setting
//
// Parameters:
// pUserObj: Optional - A User object representing the current user
// pFileCfg: Optional - A cfglib object with file.ini loaded
function prompt_user_for_download_protocol(pUserObj, pFileCfg)
{
var thisuser;
if (typeof(pUserObj) === "object" && pUserObj.hasOwnProperty("download_protocol"))
thisuser = pUserObj;
else
thisuser = new User(user.number);
var file_cfg;
if (typeof(pFileCfg) === "object" && pFileCfg.hasOwnProperty("protocol"))
file_cfg = pFileCfg;
else
{
var cfglib = load({}, "cfglib.js");
file_cfg = cfglib.read("file.ini");
}
var c = 0;
var keylist = 'Q';
console.newline();
console.print(gettext("Choose a default file transfer protocol (or [ENTER] for None):"));
console.newline(2);
for (var code in file_cfg.protocol)
{
if (!thisuser.compare_ars(file_cfg.protocol[code].ars) || file_cfg.protocol[code].dlcmd.length === 0)
continue;
console.putmsg(format(bbs.text(bbs.text.TransferProtLstFmt), String(file_cfg.protocol[code].key), file_cfg.protocol[code].name));
keylist += String(file_cfg.protocol[code].key);
if (c % 2 === 1)
console.newline();
++c;
}
console.mnemonics(bbs.text(bbs.text.ProtocolOrQuit));
var kp = console.getkeys(keylist);
if (kp !== 'Q' && !console.aborted)
{
thisuser.download_protocol = kp;
if (kp && console.yesno(bbs.text(bbs.text.HangUpAfterXferQ)))
thisuser.settings |= USER_AUTOHANG;
else
thisuser.settings &= ~USER_AUTOHANG;
}
}
this;
......@@ -28,7 +28,7 @@ console.clear();
require("sbbsdefs.js", 'BBS_OPT_AUTO_LOGON');
require("userdefs.js", 'USER_SPIN');
require("nodedefs.js", 'NODE_DFLT');
require("gettext.js", 'gettext');
require("user_settings_lib.js", 'prompt_user_for_download_protocol'); // Includes gettext.js
var termdesc = load("termdesc.js");
function get_lang_count()
......@@ -529,34 +529,7 @@ while(bbs.online && !js.terminated) {
thisuser.settings ^= USER_ASK_SSCAN;
break;
case 'Z':
var c = 0;
var keylist = 'Q';
console.newline();
console.print(gettext("Choose a default file transfer protocol (or [ENTER] for None):"));
console.newline(2);
for (var code in file_cfg.protocol) {
if (!thisuser.compare_ars(file_cfg.protocol[code].ars)
|| file_cfg.protocol[code].dlcmd.length === 0)
continue;
if (c%2===1)
console.newline();
console.putmsg(format(bbs.text(bbs.text.TransferProtLstFmt)
,String(file_cfg.protocol[code].key)
,file_cfg.protocol[code].name));
keylist += String(file_cfg.protocol[code].key);
c++;
}
console.newline();
console.mnemonics(bbs.text(bbs.text.ProtocolOrQuit));
var kp = console.getkeys(keylist);
if (kp === 'Q' || console.aborted)
break;
thisuser.download_protocol = kp;
if (kp && console.yesno(bbs.text(bbs.text.HangUpAfterXferQ)))
thisuser.settings |= USER_AUTOHANG;
else
thisuser.settings &= ~USER_AUTOHANG;
prompt_user_for_download_protocol(thisuser, file_cfg);
break;
case 'Q':
case '\r':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment