Newer
Older
/* This is a script that lets the user choose a message area,
* with either a lightbar or traditional user interface.
*
* Date Author Description
* ... Trimmed comments ...
* 2019-08-22 Eric Oulashin Version 1.18
* Added message area searching.
* Also, improved the time to display sub-boards
* with the latest message date & time.
* 2019-08-24 Eric Oulashin Version 1.19
* Fixed a bug with 'Next' search when returning from
* sub-board choosing.
* 2020-04-19 Eric Oulashin Version 1.20
* For lightbar mode, it now uses DDLightbarMenu
* instead of using internal lightbar code.
Eric Oulashin
committed
* 2020-11-01 Eric Oulashin Version 1.21 Beta
* Working on sub-board collapsing
* 2022-01-15 Eric Oulashin Version 1.21
* Finished sub-board collapsing (finally) and releasing
* this version.
* 2022-02-12 Eric Oulashin Version 1.22
* Updated the version to match the file area chooser
Eric Oulashin
committed
* 2022-03-18 Eric Oulashin Version 1.23
* For sub-board collapsing, if there's only one sub-group,
* then it won't be collapsed.
* Also fixed an issue: Using Q to quit out of the 2nd level
* (sub-board/sub-group) for lightbar mode no longer quits
* out of the chooser altogether.
* 2022-05-17 Eric Oulashin Version 1.24
* Fix for search error reporting (probably due to
* mistaken copy & paste in an earlier commit)
Eric Oulashin
committed
* 2022-06-06 Eric Oulashin Version 1.25
* Fix for miscolored digit(s) in # messages column in
* the sub-board list when using the lightbar menu
* 2022-06-11 Eric Oulashin Version 1.26
* Updated to try to prevent the error "this.subBoardListPrintfInfo[pGrpIdx] is undefined"
* in CreateLightbarSubBoardMenu()
*/
Eric Oulashin
committed
// TODO: In the area list, the 10,000ths digit (for # posts) is in a different color)
Eric Oulashin
committed
// TODO: Passing "false" as the first command-line argument no longer works.
// That should allow choosing a sub-board within the user's current message
// group.
/* Command-line arguments:
1 (argv[0]): Boolean - Whether or not to choose a message group first (default). If
false, the user will only be able to choose a different sub-board within
their current message group.
2 (argv[1]): Boolean - Whether or not to run the area chooser (if false,
then this file will just provide the DDMsgAreaChooser class).
*/
Eric Oulashin
committed
if (typeof(require) === "function")
{
require("sbbsdefs.js", "K_NOCRLF");
require("dd_lightbar_menu.js", "DDLightbarMenu");
}
else
{
load("sbbsdefs.js");
load("dd_lightbar_menu.js");
}
// This script requires Synchronet version 3.14 or higher.
// Exit if the Synchronet version is below the minimum.
if (system.version_num < 31400)
{
var message = "\1n\1h\1y\1i* Warning:\1n\1h\1w Digital Distortion Message Area Chooser "
+ "requires version \1g3.14\1w or\r\n"
+ "higher of Synchronet. This BBS is using version \1g" + system.version
+ "\1w. Please notify the sysop.";
console.crlf();
console.print(message);
console.crlf();
console.pause();
exit();
}
// Version & date variables
Eric Oulashin
committed
var DD_MSG_AREA_CHOOSER_VERSION = "1.25";
var DD_MSG_AREA_CHOOSER_VER_DATE = "2022-06-06";
// Keyboard input key codes
var CTRL_H = "\x08";
var CTRL_M = "\x0d";
var KEY_ENTER = CTRL_M;
var BACKSPACE = CTRL_H;
var CTRL_F = "\x06";
var KEY_ESC = ascii(27);
// PageUp & PageDown keys - Synchronet 3.17 as of about December 18, 2017
// use CTRL-P and CTRL-N for PageUp and PageDown, respectively. sbbsdefs.js
// defines them as KEY_PAGEUP and KEY_PAGEDN; I've used slightly different names
// in this script so that this script will work with Synchronet systems before
// and after the update containing those key definitions.
var KEY_PAGE_UP = "\x10"; // Ctrl-P
var KEY_PAGE_DOWN = "\x0e"; // Ctrl-N
// Ensure KEY_PAGE_UP and KEY_PAGE_DOWN are set to what's defined in sbbs.js
// for KEY_PAGEUP and KEY_PAGEDN in case they change
if (typeof(KEY_PAGEUP) === "string")
KEY_PAGE_UP = KEY_PAGEUP;
if (typeof(KEY_PAGEDN) === "string")
KEY_PAGE_DOWN = KEY_PAGEDN;
// Key codes for display
var UP_ARROW = ascii(24);
var DOWN_ARROW = ascii(25);
// Misc. defines
var ERROR_WAIT_MS = 1500;
var SEARCH_TIMEOUT_MS = 10000;
// Determine the script's startup directory.
// This code is a trick that was created by Deuce, suggested by Rob Swindell
// as a way to detect which directory the script was executed in. I've
// shortened the code a little.
var gStartupPath = '.';
try { throw dig.dist(dist); } catch(e) { gStartupPath = e.fileName; }
gStartupPath = backslash(gStartupPath.replace(/[\/\\][^\/\\]*$/,''));
// gIsSysop stores whether or not the user is a sysop.
var gIsSysop = user.compare_ars("SYSOP"); // Whether or not the user is a sysop
// 1st command-line argument: Whether or not to choose a message group first (if
// false, then only choose a sub-board within the user's current group). This
// can be true or false.
Eric Oulashin
committed
var gChooseMsgGrpOnStartup = true;
if (typeof(argv[0]) == "boolean")
Eric Oulashin
committed
gChooseMsgGrpOnStartup = argv[0];
else if (typeof(argv[0]) == "string")
Eric Oulashin
committed
gChooseMsgGrpOnStartup = (argv[0].toLowerCase() == "true");
Eric Oulashin
committed
// When using the number of messages in a sub-board, whether or not to count the
// number of readable messages (which can be slow). If false, will just look at the number
// of all messages in the sub-board.
var gUseNumReadableMessagesForMsgCount = false;
// 2nd command-line argument: Determine whether or not to execute the message listing
// code (true/false)
var executeThisScript = true;
if (typeof(argv[1]) == "boolean")
executeThisScript = argv[1];
else if (typeof(argv[1]) == "string")
executeThisScript = (argv[1].toLowerCase() == "true");
// If executeThisScript is true, then create a DDMsgAreaChooser object and use
// it to let the user choose a message area.
if (executeThisScript)
{
var msgAreaChooser = new DDMsgAreaChooser();
Eric Oulashin
committed
// If we are to let the user choose a sub-board within
// their current group (and not choose a message group
// first), then we need to capture the chosen sub-board
// here just in case, and change the user's message area
// here. Otherwise, if choosing the message group first,
// SelectMsgArea() will change the user's sub-board.
var msgGroupIdx = (gChooseMsgGrpOnStartup ? 0/*null*/ : bbs.curgrp);
var chosenIdx = msgAreaChooser.SelectMsgArea(gChooseMsgGrpOnStartup, msgGroupIdx);
if (!gChooseMsgGrpOnStartup && (typeof(chosenIdx) === "number"))
bbs.cursub_code = msg_area.grp_list[bbs.curgrp].sub_list[chosenIdx].code;
}
// End of script execution
///////////////////////////////////////////////////////////////////////////////////
// DDMsgAreaChooser class stuff
function DDMsgAreaChooser()
{
// this.colors will be an associative array of colors (indexed by their
// usage) used for the message group/sub-board lists.
// Colors for the file & message area lists
this.colors = {
areaNum: "\1n\1w\1h",
desc: "\1n\1c",
numItems: "\1b\1h",
header: "\1n\1y\1h",
subBoardHeader: "\1n\1g",
areaMark: "\1g\1h",
latestDate: "\1n\1g",
latestTime: "\1n\1m",
// Highlighted colors (for lightbar mode)
bkgHighlight: "\1" + "4", // Blue background
areaNumHighlight: "\1w\1h",
descHighlight: "\1c",
dateHighlight: "\1w\1h",
timeHighlight: "\1w\1h",
numItemsHighlight: "\1w\1h",
// Lightbar help line colors
lightbarHelpLineBkg: "\1" + "7",
lightbarHelpLineGeneral: "\1b",
lightbarHelpLineHotkey: "\1r",
lightbarHelpLineParen: "\1m"
};
// showImportDates is a boolean to specify whether or not to display the
// message import dates. If false, the message written dates will be
// displayed instead.
this.showImportDates = true;
Loading
Loading full blame...