diff --git a/xtrn/ddfilelister/ddfilelister.cfg b/xtrn/ddfilelister/ddfilelister.cfg index 76d0aa70cacd6230e6581a21d67912ee6d63ff09..90c0a6760ce49fab59433446960bcbbf28891fbe 100644 --- a/xtrn/ddfilelister/ddfilelister.cfg +++ b/xtrn/ddfilelister/ddfilelister.cfg @@ -31,5 +31,9 @@ blankNFilesListedStrIfLoadableModule=true ; information for files displayUserAvatars=true +; If a file's description is unavailable, whether or not to use the +; filename in the list instead +useFilenameIfNoDescription=true + ; The name of the color theme configuration file themeFilename=defaultTheme.cfg diff --git a/xtrn/ddfilelister/ddfilelister.js b/xtrn/ddfilelister/ddfilelister.js index 66a69635a985d80f52b93b675e01549958167fcf..07f8531ec5b676fde21e6ab458fa7a4912e18288 100644 --- a/xtrn/ddfilelister/ddfilelister.js +++ b/xtrn/ddfilelister/ddfilelister.js @@ -149,6 +149,9 @@ * exist in the metadata before accessing them * 2024-12-08 Eric Oulashin Version 2.25c * Check whether 'desc' is a string in file metadata before trying to use it + * 2024-12-27 Eric Oulashin Version 2.26 + * New configuration setting: useFilenameIfNoDescription - If a + * file's description is empty, show its filename in the list instead */ "use strict"; @@ -190,8 +193,8 @@ var gAvatar = load({}, "avatar_lib.js"); // Version information -var LISTER_VERSION = "2.25c"; -var LISTER_DATE = "2024-12-08"; +var LISTER_VERSION = "2.26"; +var LISTER_DATE = "2024-12-27"; /////////////////////////////////////////////////////////////////////////////// @@ -335,6 +338,10 @@ var gTraditionalUseSyncStock = false; // file information var gDispayUserAvatars = true; +// If a file's description is unavailable, whether or not to use the +// filename instead +var gUseFilenameIfNoDescription = true; + /////////////////////////////////////////////////////////////////////////////// // Script execution code @@ -3398,6 +3405,10 @@ function createFileListMenu(pQuitKeys) var desc = (typeof(gFileList[pIdx].desc) === "string" ? gFileList[pIdx].desc : ""); // Remove/replace any cursor movement codes in the description, which can corrupt the display desc = removeOrReplaceSyncCursorMovementChars(desc, false); + // If there is no description and the option to use the filename is enabled, then use the + // filename. + if (gUseFilenameIfNoDescription && (desc == "" || /^\s+$/.test(desc))) + desc = gFileList[pIdx].name; var fileSizeStr = file_size_str(gFileList[pIdx].size, null, FILE_SIZE_PRECISION); menuItemObj.text = format(this.fileFormatStr, filename, @@ -4153,6 +4164,11 @@ function readConfigFile() themeFilename = js.exec_dir + settingsObj[prop]; } } + else if (propUpper == "USEFILENAMEIFNODESCRIPTION") + { + if (typeof(settingsObj[prop]) === "boolean") + gUseFilenameIfNoDescription = settingsObj[prop]; + } } } else @@ -5171,7 +5187,12 @@ function displayFileExtDescOnMainScreen(pFileIdx, pStartScreenRow, pEndScreenRow lastScreenRow = pEndScreenRow; // Remove/replace any cursor movement characters, as they can corrupt the display fileDesc = removeOrReplaceSyncCursorMovementChars(fileDesc); + // If there is no description and the option to use the filename is enabled, then use the + // filename. + if (gUseFilenameIfNoDescription && (fileDesc == "" || /^\s+$/.test(fileDesc))) + fileDesc = lfexpand(word_wrap(fileMetadata.name + "\r\n(No description)", maxDescLen, null, false)); var fileDescArray = fileDesc.split("\r\n"); + //if (user.is_sysop) console.print("\x01nfileDescArray is array: " + Array.isArray(fileDescArray) + " \x01p"); // Temporary console.attributes = "N"; // screenRowNum is to keep track of the row on the screen where the // description line would be placed, in case the start row is after that diff --git a/xtrn/ddfilelister/readme.txt b/xtrn/ddfilelister/readme.txt index bfe7d33fcc5afb44ae6929b35f6ee08658424fb9..d1792e3ad330adfebabf5b231865c3cb290a5aa5 100644 --- a/xtrn/ddfilelister/readme.txt +++ b/xtrn/ddfilelister/readme.txt @@ -250,6 +250,11 @@ displayUserAvatars Whether or not to display uploader avatars in extended information for files. Valid values are true and false. +useFilenameIfNoDescription If a file's description is unavailable, + whether or not to use the filename in the + list instead. Valid values are true and + false. + themeFilename The name of the configuration file to use for colors & string settings diff --git a/xtrn/ddfilelister/revision_history.txt b/xtrn/ddfilelister/revision_history.txt index 942b25010c7ba32acbe5b4ad9276a98337cf8618..75df87000f30e9e829e19058c2e9e103e36a0ea8 100644 --- a/xtrn/ddfilelister/revision_history.txt +++ b/xtrn/ddfilelister/revision_history.txt @@ -5,6 +5,9 @@ Revision History (change log) ============================= Version Date Description ------- ---- ----------- +2.26 2024-12-27 New configuration setting: useFilenameIfNoDescription - + If a file's description is empty, show its filename in the + list instead 2.25c 2024-12-08 Bug fix for trying to use 'desc' in file metadata and not checking whether it's defined. 2.25b 2024-11-24 When editing file information, check whether cost and