Skip to content
Snippets Groups Projects
Commit d9608b6d authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Merge branch 'dd_area_choosers_altDesc_fix_and_start_of_name_collapsing_enhancement' into 'master'

DD Area Choosers: Fix for altName missing (reported by nelgin) and start of name collapsing enhancement (no empty names)

See merge request !524
parents a54caff6 6a3a946e
No related branches found
No related tags found
1 merge request!524DD Area Choosers: Fix for altName missing (reported by nelgin) and start of name collapsing enhancement (no empty names)
...@@ -74,6 +74,9 @@ ...@@ -74,6 +74,9 @@
* create multiple levels of categories * create multiple levels of categories
* 2025-03-17 Eric Oulashin Version 1.42 * 2025-03-17 Eric Oulashin Version 1.42
* Releasing this version * Releasing this version
* 2025-04-10 Eric Oulashin Version 1.42b
* Fix: altName wasn't added to items if name collapsing disabled.
* Also, start of name collapsing enhancement (no empty names).
*/ */
// TODO: Failing silently when 1st argument is true // TODO: Failing silently when 1st argument is true
...@@ -114,8 +117,8 @@ if (system.version_num < 31400) ...@@ -114,8 +117,8 @@ if (system.version_num < 31400)
} }
// Version & date variables // Version & date variables
var DD_FILE_AREA_CHOOSER_VERSION = "1.42"; var DD_FILE_AREA_CHOOSER_VERSION = "1.42b Beta";
var DD_FILE_AREA_CHOOSER_VER_DATE = "2025-03-17"; var DD_FILE_AREA_CHOOSER_VER_DATE = "2025-04-07";
// Keyboard input key codes // Keyboard input key codes
var CTRL_H = "\x08"; var CTRL_H = "\x08";
...@@ -2022,6 +2025,23 @@ function getFileDirHeirarchy(pCollapsing, pCollapsingSeparator) ...@@ -2022,6 +2025,23 @@ function getFileDirHeirarchy(pCollapsing, pCollapsingSeparator)
var fileDirHeirarchy = []; var fileDirHeirarchy = [];
if (pCollapsing) if (pCollapsing)
{ {
// First, check the library descriptions for strings before the separator character
var libsBeforeSeparator = {}; // Will be an object indexed by description with a count as the value
for (var libIdx = 0; libIdx < file_area.lib_list.length; ++libIdx)
{
var libDesc = skipsp(truncsp(file_area.lib_list[libIdx].description));
var sepIdx = file_area.lib_list[libIdx].description.indexOf(pCollapsingSeparator);
if (sepIdx > -1)
{
var libDescBeforeSep = file_area.lib_list[libIdx].description.substr(0, sepIdx);
if (libsBeforeSeparator.hasOwnProperty(libDescBeforeSep))
libsBeforeSeparator[libDescBeforeSep] += 1;
else
libsBeforeSeparator[libDescBeforeSep] = 1;
}
}
// Build the heirarchy
// For each library, go through each directory // For each library, go through each directory
for (var libIdx = 0; libIdx < file_area.lib_list.length; ++libIdx) for (var libIdx = 0; libIdx < file_area.lib_list.length; ++libIdx)
{ {
...@@ -2040,11 +2060,22 @@ function getFileDirHeirarchy(pCollapsing, pCollapsingSeparator) ...@@ -2040,11 +2060,22 @@ function getFileDirHeirarchy(pCollapsing, pCollapsingSeparator)
var libDesc = skipsp(truncsp(file_area.lib_list[libIdx].description)); var libDesc = skipsp(truncsp(file_area.lib_list[libIdx].description));
var dirDesc = skipsp(truncsp(file_area.lib_list[libIdx].dir_list[dirIdx].description)); var dirDesc = skipsp(truncsp(file_area.lib_list[libIdx].dir_list[dirIdx].description));
var libAndDirName = libDesc + ":" + dirDesc; var libAndDirName = libDesc + ":" + dirDesc;
var nameArray = libAndDirName.split(pCollapsingSeparator); var nameArray = removeEmptyStrsFromArray(libAndDirName.split(pCollapsingSeparator));
var arrayToSearch = fileDirHeirarchy; var arrayToSearch = fileDirHeirarchy;
for (var i = 0; i < nameArray.length; ++i) // If the library description has the separator character and the first element
{ // only appears once, then use the whole library name as one name
var name = skipsp(truncsp(nameArray[i])); var sepCountInLibDesc = countSubstrInStr(libDesc, pCollapsingSeparator);
var startIdx = 0;
if (sepCountInLibDesc > 0 && libsBeforeSeparator.hasOwnProperty(nameArray[0]) == 1)
startIdx += sepCountInLibDesc;
for (var i = startIdx; i < nameArray.length; ++i)
{
//var name = skipsp(truncsp(nameArray[i]));
var name = "";
if (startIdx > 0 && i == startIdx)
name = libDesc;
else
name = skipsp(truncsp(nameArray[i]));
// Look for this one in the heirarchy; if not found, add it. // Look for this one in the heirarchy; if not found, add it.
// Look for an entry in the array that matches the name and has its own "items" array // Look for an entry in the array that matches the name and has its own "items" array
var heirarchyIdx = -1; var heirarchyIdx = -1;
...@@ -2097,6 +2128,7 @@ function getFileDirHeirarchy(pCollapsing, pCollapsingSeparator) ...@@ -2097,6 +2128,7 @@ function getFileDirHeirarchy(pCollapsing, pCollapsingSeparator)
fileDirHeirarchy.push( fileDirHeirarchy.push(
{ {
name: file_area.lib_list[libIdx].description, name: file_area.lib_list[libIdx].description,
altName: file_area.lib_list[libIdx].name,
libIdx: libIdx, libIdx: libIdx,
items: [] items: []
}); });
...@@ -2106,6 +2138,7 @@ function getFileDirHeirarchy(pCollapsing, pCollapsingSeparator) ...@@ -2106,6 +2138,7 @@ function getFileDirHeirarchy(pCollapsing, pCollapsingSeparator)
fileDirHeirarchy[libIdxInHeirarchy].items.push( fileDirHeirarchy[libIdxInHeirarchy].items.push(
{ {
name: file_area.lib_list[libIdx].dir_list[dirIdx].description, name: file_area.lib_list[libIdx].dir_list[dirIdx].description,
altName: file_area.lib_list[libIdx].dir_list[dirIdx].name,
libIdx: libIdx, libIdx: libIdx,
dirObj: file_area.lib_list[libIdx].dir_list[dirIdx] dirObj: file_area.lib_list[libIdx].dir_list[dirIdx]
}); });
...@@ -2136,6 +2169,25 @@ function splitStrNoSpacesBeforeSeparator(pStr, pSep) ...@@ -2136,6 +2169,25 @@ function splitStrNoSpacesBeforeSeparator(pStr, pSep)
return strArray; return strArray;
} }
// Returns the number of times a substring apears in a string
//
// Parameters:
// pStr: The string to search
// pSubstr: The substring inside the string to count
//
// Return: The number of times the substring appears in the string
function countSubstrInStr(pStr, pSubstr)
{
var substrCount = 0;
var substrIdx = pStr.indexOf(pSubstr);
while (substrIdx > -1)
{
++substrCount;
substrIdx = pStr.indexOf(pSubstr, substrIdx+1);
}
return substrCount;
}
// Given a file lib/directory heirarchy object built by this module, this // Given a file lib/directory heirarchy object built by this module, this
// function returns whether it contains the user's currently selected file // function returns whether it contains the user's currently selected file
// directory. // directory.
...@@ -2196,3 +2248,16 @@ function maxNumItemsWidthInHeirarchy(pDirHeirarchyObj) ...@@ -2196,3 +2248,16 @@ function maxNumItemsWidthInHeirarchy(pDirHeirarchyObj)
} }
return maxNumItemsWidth; return maxNumItemsWidth;
} }
// Removes empty strings from an array - Given an array,
// makes a new array with only the non-empty strings and returns it.
function removeEmptyStrsFromArray(pArray)
{
var newArray = [];
for (var i = 0; i < pArray.length; ++i)
{
if (pArray[i].length > 0 && !/^\s+$/.test(pArray[i]))
newArray.push(pArray[i]);
}
return newArray;
}
\ No newline at end of file
...@@ -83,6 +83,9 @@ ...@@ -83,6 +83,9 @@
* 2025-04-04 Eric Oulashin Version 1.42a * 2025-04-04 Eric Oulashin Version 1.42a
* Fix for 'undefined' error (using the wrong object) when typing a sub-board * Fix for 'undefined' error (using the wrong object) when typing a sub-board
* number to choose it. Reported by Keyop. * number to choose it. Reported by Keyop.
* 2025-04-10 Eric Oulashin Version 1.42b
* Fix: altName wasn't added to items if name collapsing disabled.
* Also, start of name collapsing enhancement (no empty names).
*/ */
/* Command-line arguments: /* Command-line arguments:
...@@ -120,8 +123,8 @@ if (system.version_num < 31400) ...@@ -120,8 +123,8 @@ if (system.version_num < 31400)
} }
// Version & date variables // Version & date variables
var DD_MSG_AREA_CHOOSER_VERSION = "1.42a"; var DD_MSG_AREA_CHOOSER_VERSION = "1.42b Beta";
var DD_MSG_AREA_CHOOSER_VER_DATE = "2025-04-04"; var DD_MSG_AREA_CHOOSER_VER_DATE = "2025-04-07";
// Keyboard input key codes // Keyboard input key codes
var CTRL_H = "\x08"; var CTRL_H = "\x08";
...@@ -1281,7 +1284,8 @@ function DDMsgAreaChooser_CreateLightbarMenu(pMsgAreaHeirarchyObj, pHeirarchyLev ...@@ -1281,7 +1284,8 @@ function DDMsgAreaChooser_CreateLightbarMenu(pMsgAreaHeirarchyObj, pHeirarchyLev
{ {
var lastMsgPostTimestamp = getLatestMsgTime(this.msgAreaHeirarchyObj[pItemIdx].subObj.code); var lastMsgPostTimestamp = getLatestMsgTime(this.msgAreaHeirarchyObj[pItemIdx].subObj.code);
menuItemObj.text += format(this.areaChooser.subBoardListPrintfInfo[grpIdx].printfStr, pItemIdx+1, menuItemObj.text += format(this.areaChooser.subBoardListPrintfInfo[grpIdx].printfStr, pItemIdx+1,
this.msgAreaHeirarchyObj[pItemIdx].name.substr(0, this.areaChooser.subBoardNameLen), numItems, this.msgAreaHeirarchyObj[pItemIdx].name.substr(0, this.areaChooser.subBoardNameLen),
numItems,
strftime("%Y-%m-%d", lastMsgPostTimestamp), strftime("%Y-%m-%d", lastMsgPostTimestamp),
strftime("%H:%M:%S", lastMsgPostTimestamp)); strftime("%H:%M:%S", lastMsgPostTimestamp));
} }
...@@ -3081,6 +3085,22 @@ function getMsgSubHeirarchy(pCollapsing, pCollapsingSeparator) ...@@ -3081,6 +3085,22 @@ function getMsgSubHeirarchy(pCollapsing, pCollapsingSeparator)
var msgSubHeirarchy = []; var msgSubHeirarchy = [];
if (pCollapsing) if (pCollapsing)
{ {
// First, check the group descriptions for strings before the separator character
var grpsBeforeSeparator = {}; // Will be an object indexed by description with a count as the value
for (var grpIdx = 0; grpIdx < msg_area.grp_list.length; ++grpIdx)
{
var grpDesc = skipsp(truncsp(msg_area.grp_list[grpIdx].description));
var sepIdx = msg_area.grp_list[grpIdx].description.indexOf(pCollapsingSeparator);
if (sepIdx > -1)
{
var grpDescBeforeSep = msg_area.grp_list[grpIdx].description.substr(0, sepIdx);
if (grpsBeforeSeparator.hasOwnProperty(grpDescBeforeSep))
grpsBeforeSeparator[grpDescBeforeSep] += 1;
else
grpsBeforeSeparator[grpDescBeforeSep] = 1;
}
}
// For each message group, go through each sub-board // For each message group, go through each sub-board
for (var grpIdx = 0; grpIdx < msg_area.grp_list.length; ++grpIdx) for (var grpIdx = 0; grpIdx < msg_area.grp_list.length; ++grpIdx)
{ {
...@@ -3093,17 +3113,28 @@ function getMsgSubHeirarchy(pCollapsing, pCollapsingSeparator) ...@@ -3093,17 +3113,28 @@ function getMsgSubHeirarchy(pCollapsing, pCollapsingSeparator)
// areas where there are no spaces before or after the :, but that // areas where there are no spaces before or after the :, but that
// isn't how I did it before.. // isn't how I did it before..
/* /*
var libAndDirName = msg_area.grp_list[grpIdx].description + ":" + msg_area.grp_list[grpIdx].sub_list[subIdx].description; var grpAndSubname = msg_area.grp_list[grpIdx].description + ":" + msg_area.grp_list[grpIdx].sub_list[subIdx].description;
var nameArray = splitStrNoSpacesBeforeSeparator(libAndDirName, pCollapsingSeparator); var nameArray = splitStrNoSpacesBeforeSeparator(grpAndSubname, pCollapsingSeparator);
*/ */
var libDesc = skipsp(truncsp(msg_area.grp_list[grpIdx].description)); var grpDesc = skipsp(truncsp(msg_area.grp_list[grpIdx].description));
var dirDesc = skipsp(truncsp(msg_area.grp_list[grpIdx].sub_list[subIdx].description)); var subDesc = skipsp(truncsp(msg_area.grp_list[grpIdx].sub_list[subIdx].description));
var libAndDirName = libDesc + pCollapsingSeparator + dirDesc; var grpAndSubname = grpDesc + pCollapsingSeparator + subDesc;
var nameArray = libAndDirName.split(pCollapsingSeparator); var nameArray = removeEmptyStrsFromArray(grpAndSubname.split(pCollapsingSeparator));
var arrayToSearch = msgSubHeirarchy; var arrayToSearch = msgSubHeirarchy;
for (var i = 0; i < nameArray.length; ++i) // If the group description has the separator character and the first element
{ // only appears once, then use the whole group name as one name
var name = skipsp(truncsp(nameArray[i])); var sepCountInGrpDesc = countSubstrInStr(grpDesc, pCollapsingSeparator);
var startIdx = 0;
if (sepCountInGrpDesc > 0 && grpsBeforeSeparator.hasOwnProperty(nameArray[0]) == 1)
startIdx += sepCountInGrpDesc;
for (var i = startIdx; i < nameArray.length; ++i)
{
//var name = skipsp(truncsp(nameArray[i]));
var name = "";
if (startIdx > 0 && i == startIdx)
name = grpDesc;
else
name = skipsp(truncsp(nameArray[i]));
// Look for this one in the heirarchy; if not found, add it. // Look for this one in the heirarchy; if not found, add it.
// Look for an entry in the array that matches the name and has its own "items" array // Look for an entry in the array that matches the name and has its own "items" array
var heirarchyIdx = -1; var heirarchyIdx = -1;
...@@ -3156,6 +3187,7 @@ function getMsgSubHeirarchy(pCollapsing, pCollapsingSeparator) ...@@ -3156,6 +3187,7 @@ function getMsgSubHeirarchy(pCollapsing, pCollapsingSeparator)
msgSubHeirarchy.push( msgSubHeirarchy.push(
{ {
name: msg_area.grp_list[grpIdx].description, name: msg_area.grp_list[grpIdx].description,
altName: msg_area.grp_list[grpIdx].name,
grpIdx: grpIdx, grpIdx: grpIdx,
items: [] items: []
}); });
...@@ -3165,6 +3197,7 @@ function getMsgSubHeirarchy(pCollapsing, pCollapsingSeparator) ...@@ -3165,6 +3197,7 @@ function getMsgSubHeirarchy(pCollapsing, pCollapsingSeparator)
msgSubHeirarchy[libIdxInHeirarchy].items.push( msgSubHeirarchy[libIdxInHeirarchy].items.push(
{ {
name: msg_area.grp_list[grpIdx].sub_list[subIdx].description, name: msg_area.grp_list[grpIdx].sub_list[subIdx].description,
altName: msg_area.grp_list[grpIdx].sub_list[subIdx].name,
grpIdx: grpIdx, grpIdx: grpIdx,
subObj: msg_area.grp_list[grpIdx].sub_list[subIdx] subObj: msg_area.grp_list[grpIdx].sub_list[subIdx]
}); });
...@@ -3244,6 +3277,25 @@ function splitStrNoSpacesBeforeSeparator(pStr, pSep) ...@@ -3244,6 +3277,25 @@ function splitStrNoSpacesBeforeSeparator(pStr, pSep)
return strArray; return strArray;
} }
// Returns the number of times a substring apears in a string
//
// Parameters:
// pStr: The string to search
// pSubstr: The substring inside the string to count
//
// Return: The number of times the substring appears in the string
function countSubstrInStr(pStr, pSubstr)
{
var substrCount = 0;
var substrIdx = pStr.indexOf(pSubstr);
while (substrIdx > -1)
{
++substrCount;
substrIdx = pStr.indexOf(pSubstr, substrIdx+1);
}
return substrCount;
}
// Given a message group/sub-board heirarchy object built by this module, this // Given a message group/sub-board heirarchy object built by this module, this
// function returns whether it contains the user's currently selected message // function returns whether it contains the user's currently selected message
// sub-board. // sub-board.
...@@ -3277,3 +3329,16 @@ function msgAreaStructureHasCurrentUserSubBoard(pMsgSubHeirarchyObj) ...@@ -3277,3 +3329,16 @@ function msgAreaStructureHasCurrentUserSubBoard(pMsgSubHeirarchyObj)
} }
return currentUserSubBoardFound; return currentUserSubBoardFound;
} }
// Removes empty strings from an array - Given an array,
// makes a new array with only the non-empty strings and returns it.
function removeEmptyStrsFromArray(pArray)
{
var newArray = [];
for (var i = 0; i < pArray.length; ++i)
{
if (pArray[i].length > 0 && !/^\s+$/.test(pArray[i]))
newArray.push(pArray[i]);
}
return newArray;
}
\ No newline at end of file
Digital Distortion Area Choosers Digital Distortion Area Choosers
Version 1.42 Version 1.42b
Release date: 2025-03-17 Release date: 2025-04-10
by by
...@@ -160,26 +160,26 @@ do the following: ...@@ -160,26 +160,26 @@ do the following:
If you would like to set up these scripts as doors, the following is an example If you would like to set up these scripts as doors, the following is an example
setup of the message area chooser (assuming it is placed in sbbs/exec or setup of the message area chooser (assuming it is placed in sbbs/exec or
sbbs/mods): sbbs/mods):
+[¦][?]----------------------------------------------------+ +[¦][?]----------------------------------------------------+
¦ Message Area Chooser ¦ ¦ Message Area Chooser ¦
¦----------------------------------------------------------¦ ¦----------------------------------------------------------¦
¦ ¦Name Message Area Chooser ¦ ¦ ¦Name Message Area Chooser ¦
¦ ¦Internal Code MSGARCHO ¦ ¦ ¦Internal Code MSGARCHO ¦
¦ ¦Start-up Directory ¦ ¦ ¦Start-up Directory ¦
¦ ¦Command Line ?DDMsgAreaChooser.js ¦ ¦ ¦Command Line ?DDMsgAreaChooser.js ¦
¦ ¦Clean-up Command Line ¦ ¦ ¦Clean-up Command Line ¦
¦ ¦Execution Cost None ¦ ¦ ¦Execution Cost None ¦
¦ ¦Access Requirements ¦ ¦ ¦Access Requirements ¦
¦ ¦Execution Requirements ¦ ¦ ¦Execution Requirements ¦
¦ ¦Multiple Concurrent Users Yes ¦ ¦ ¦Multiple Concurrent Users Yes ¦
¦ ¦Intercept Standard I/O No ¦ ¦ ¦Intercept Standard I/O No ¦
¦ ¦Native (32-bit) Executable No ¦ ¦ ¦Native (32-bit) Executable No ¦
¦ ¦Use Shell to Execute No ¦ ¦ ¦Use Shell to Execute No ¦
¦ ¦Modify User Data No ¦ ¦ ¦Modify User Data No ¦
¦ ¦Execute on Event No ¦ ¦ ¦Execute on Event No ¦
¦ ¦Pause After Execution No ¦ ¦ ¦Pause After Execution No ¦
¦ ¦BBS Drop File Type None ¦ ¦ ¦BBS Drop File Type None ¦
¦ ¦Place Drop File In Node Directory ¦ ¦ ¦Place Drop File In Node Directory ¦
+----------------------------------------------------------+ +----------------------------------------------------------+
To run that from a JavaScript, include this line: To run that from a JavaScript, include this line:
bbs.exec_xtrn("MSGARCHO"); bbs.exec_xtrn("MSGARCHO");
......
...@@ -5,6 +5,10 @@ Revision History (change log) ...@@ -5,6 +5,10 @@ Revision History (change log)
============================= =============================
Version Date Description Version Date Description
------- ---- ----------- ------- ---- -----------
1.42b 2025-04-10 Fix: altName wasn't added to items if name collapsing
disabled.
Also, start of name collapsing enhancement (no empty
names).
1.42 2025-03-17 For both: Name collapsing now supports an arbitrary number 1.42 2025-03-17 For both: Name collapsing now supports an arbitrary number
of areas (depth) with an arbitrary number of separators of areas (depth) with an arbitrary number of separators
1.41 2024-03-13 File area chooser: Fix for the directory item counts 1.41 2024-03-13 File area chooser: Fix for the directory item counts
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment