From d7f0dc537d9840d2bd1e7bc867ba4185066d7417 Mon Sep 17 00:00:00 2001 From: Eric Oulashin <eric.oulashin@gmail.com> Date: Sun, 22 Dec 2024 18:17:12 -0800 Subject: [PATCH 1/3] DDMsgReader: When doing an indexed newscan, display the progress percentage when doing the newscan. Should fix issue #846 (reported by Keyop) --- xtrn/DDMsgReader/DDMsgReader.js | 54 ++++++++++++++++++++++++++- xtrn/DDMsgReader/ddmr_cfg.js | 4 +- xtrn/DDMsgReader/readme.txt | 4 +- xtrn/DDMsgReader/revision_history.txt | 2 + 4 files changed, 58 insertions(+), 6 deletions(-) diff --git a/xtrn/DDMsgReader/DDMsgReader.js b/xtrn/DDMsgReader/DDMsgReader.js index 6ff4f6c506..9028567dc3 100644 --- a/xtrn/DDMsgReader/DDMsgReader.js +++ b/xtrn/DDMsgReader/DDMsgReader.js @@ -208,6 +208,9 @@ * 2024-12-18 Eric Oulashin Version 1.96h * When reading messages with the scrolling interface, pay attention * to user input timeout via a check of the last user input. + * 2024-12-22 Eric Oulashin Version 1.96i + * When doing an indexed newscan, display the progress percentage + * when doing the newscan */ "use strict"; @@ -315,8 +318,8 @@ var hexdump = load('hexdump_lib.js'); // Reader version information -var READER_VERSION = "1.96h"; -var READER_DATE = "2024-12-18"; +var READER_VERSION = "1.96i"; +var READER_DATE = "2024-12-22"; // Keyboard key codes for displaying on the screen var UP_ARROW = ascii(24); @@ -16777,14 +16780,30 @@ function DigDistMsgReader_IndexedModeChooseSubBoard(pClearScreen, pDrawMenu, pDi } else DigDistMsgReader_IndexedModeChooseSubBoard.selectedItemIdx = this.indexedModeMenu.selectedItemIdx; + // New + //console.print("\x01n\r\nScanning...\x01;"); // Temporary + // 1 2 3 + // 123456789012345678901234567890 + // Progress: 100% + //var numBlocks = console.screen_columns - 15; + //var numBlocksPerPercent = 100.0 / numBlocks; + // End New // Ensure the menu is clear, and (re-)populate the menu with sub-board information w/ # of new messages in each, etc. // Also, build an array of sub-board codes for each menu item. + // Also, display loading percentage while this is happening. this.indexedModeMenu.RemoveAllItems(); setIndexedSubBoardMenuSelectedItemIdx(this.indexedModeMenu, 0); if (newScanOnly && this.userSettings.indexedModeMenuSnapToFirstWithNew) DigDistMsgReader_IndexedModeChooseSubBoard.selectedItemIdx = 0; var numSubBoards = 0; var totalNewMsgs = 0; + console.attributes = "N"; + console.crlf(); + printf("Loading: %0.2f% ", 0.0); + // The total number of sub-boards we'll scan - For displaying the progress percentage + if (typeof(DigDistMsgReader_IndexedModeChooseSubBoard.totalNumSubBoards) !== "number") + DigDistMsgReader_IndexedModeChooseSubBoard.totalNumSubBoards = countSubBoardsForScanning(scanScope, newScanOnly); + // Load the menu for (var grpIdx = 0; grpIdx < msg_area.grp_list.length; ++grpIdx) { // If scanning the user's current group or sub-board and this is the wrong group, then skip this group. @@ -16806,6 +16825,11 @@ function DigDistMsgReader_IndexedModeChooseSubBoard(pClearScreen, pDrawMenu, pDi ++numSubBoards; + // Calculate & display progress percentage (every other sub-board) + var progressPercentage = numSubBoards / DigDistMsgReader_IndexedModeChooseSubBoard.totalNumSubBoards * 100.0; + if (numSubBoards % 2 == 0) + printf("\rLoading: %0.2f% ", progressPercentage); + var itemInfo = this.GetIndexedModeSubBoardMenuItemTextAndInfo(msg_area.grp_list[grpIdx].sub_list[subIdx].code); // If configured to only show sub-boards with new messages and this sub-board // does'nt have any new messages, then skip it @@ -25717,6 +25741,32 @@ function countOccurrencesInStr(pStr, pSubstr) return count; } +// Counts the number of sub-boards that would be scanned for the user, +// considering their sub-board access, for a particular scan scope +function countSubBoardsForScanning(pScanScope, pNewScanOnly) +{ + var numSubBoards = 0; + for (var grpIdx = 0; grpIdx < msg_area.grp_list.length; ++grpIdx) + { + // If scanning the user's current group or sub-board and this is the wrong group, then skip this group. + if ((pScanScope == SCAN_SCOPE_GROUP || pScanScope == SCAN_SCOPE_SUB_BOARD) && bbs.curgrp != grpIdx) + continue; + for (var subIdx = 0; subIdx < msg_area.grp_list[grpIdx].sub_list.length; ++subIdx) + { + // Skip sub-boards that the user can't read or doesn't have configured for newscans + if (!msg_area.grp_list[grpIdx].sub_list[subIdx].can_read) + continue; + if (pNewScanOnly && !Boolean(msg_area.grp_list[grpIdx].sub_list[subIdx].scan_cfg & SCAN_CFG_NEW)) + continue; + // If scanning the user's current sub-board and this is the wrong sub-board, then + // skip this sub-board (the other groups should have been skipped in the outer loop). + if (pScanScope == SCAN_SCOPE_SUB_BOARD && bbs.cursub != subIdx) + continue; + ++numSubBoards; + } + } + return numSubBoards; +} /////////////////////////////////////////////////////////////////////////////////// diff --git a/xtrn/DDMsgReader/ddmr_cfg.js b/xtrn/DDMsgReader/ddmr_cfg.js index 3ccc3fce7a..159cdc15f2 100644 --- a/xtrn/DDMsgReader/ddmr_cfg.js +++ b/xtrn/DDMsgReader/ddmr_cfg.js @@ -5,7 +5,7 @@ // If you have DDMsgReader in a directory other than xtrn/DDMsgReader, then the changes to // DDMsgReader.cfg will be saved in that directory (assuming you're running ddmr_cfg.js from // that same directory). -// Currently for DDMsgReader 1.96h. +// Currently for DDMsgReader 1.96i. // // If you're running DDMsgReader from xtrn/DDMsgReader (the standard location) and you want // to save the configuration file there (rather than sbbs/mods), you can use one of the @@ -18,7 +18,7 @@ require("sbbsdefs.js", "P_NONE"); require("uifcdefs.js", "UIFC_INMSG"); -if (!uifc.init("DigDist. Message Reader 1.96h Configurator")) +if (!uifc.init("DigDist. Message Reader 1.96i Configurator")) { print("Failed to initialize uifc"); exit(1); diff --git a/xtrn/DDMsgReader/readme.txt b/xtrn/DDMsgReader/readme.txt index 479b183c4f..fd9db90bbd 100644 --- a/xtrn/DDMsgReader/readme.txt +++ b/xtrn/DDMsgReader/readme.txt @@ -1,6 +1,6 @@ Digital Distortion Message Reader - Version 1.96h - Release date: 2024-12-18 + Version 1.96i + Release date: 2024-12-22 by diff --git a/xtrn/DDMsgReader/revision_history.txt b/xtrn/DDMsgReader/revision_history.txt index db6bf11a1e..775e859a91 100644 --- a/xtrn/DDMsgReader/revision_history.txt +++ b/xtrn/DDMsgReader/revision_history.txt @@ -5,6 +5,8 @@ Revision History (change log) ============================= Version Date Description ------- ---- ----------- +1.96i 2024-12-22 When doing an indexed newscan, display the progress + percentage when doing the newscan 1.96h 2024-12-18 Bug fix: When reading messages with the scrolling interface, it now exits from user input timeout as it should. -- GitLab From f2368de6f8fe9febcb427e8b40fddabe3d4a4145 Mon Sep 17 00:00:00 2001 From: Eric Oulashin <eric.oulashin@gmail.com> Date: Sun, 22 Dec 2024 18:23:36 -0800 Subject: [PATCH 2/3] DDMsgReader: 100% progress update & conditinally setting line_counter to 0 for indexed newscan --- xtrn/DDMsgReader/DDMsgReader.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xtrn/DDMsgReader/DDMsgReader.js b/xtrn/DDMsgReader/DDMsgReader.js index 9028567dc3..dd2207dcc6 100644 --- a/xtrn/DDMsgReader/DDMsgReader.js +++ b/xtrn/DDMsgReader/DDMsgReader.js @@ -16866,6 +16866,10 @@ function DigDistMsgReader_IndexedModeChooseSubBoard(pClearScreen, pDrawMenu, pDi totalNewMsgs += itemInfo.numNewMsgs; } } + // For end of progress reporting + printf("\rLoading: 100.0% \r\n"); + if (totalNewMsgs > 0) + console.line_counter = 0; // To prevent a pause before the index mode sub-board menu comes up // If there are no items on the menu, then show a message and return if (this.indexedModeMenu.NumItems() == 0) { -- GitLab From 16abca569cf2a3be92094fe589b8c88f2bbd0214 Mon Sep 17 00:00:00 2001 From: Eric Oulashin <eric.oulashin@gmail.com> Date: Mon, 23 Dec 2024 10:03:16 -0800 Subject: [PATCH 3/3] DDMsgReader: Display loading dots when counting sub-boards during indexed mode newscan --- xtrn/DDMsgReader/DDMsgReader.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/xtrn/DDMsgReader/DDMsgReader.js b/xtrn/DDMsgReader/DDMsgReader.js index dd2207dcc6..9a7db9cf07 100644 --- a/xtrn/DDMsgReader/DDMsgReader.js +++ b/xtrn/DDMsgReader/DDMsgReader.js @@ -16716,6 +16716,12 @@ function DigDistMsgReader_IndexedModeChooseSubBoard(pClearScreen, pDrawMenu, pDi var scanScope = (isValidScanScopeVal(pScanScope) ? pScanScope : SCAN_SCOPE_ALL); var newScanOnly = (typeof(pNewscanOnly) === "boolean" ? pNewscanOnly : false); + // Display an initial loading text, since the following may take some time + // for BBSes with many sub-boards + console.attributes = "N"; + console.crlf(); + console.print("Loading..."); + // Note: DDlightbarMenu supports non-ANSI terminals with a more traditional UI // of listing the items and letting the user choose one by typing its number. // If we are to use the traditional interface, the menu will be in numbered mode, @@ -16780,14 +16786,6 @@ function DigDistMsgReader_IndexedModeChooseSubBoard(pClearScreen, pDrawMenu, pDi } else DigDistMsgReader_IndexedModeChooseSubBoard.selectedItemIdx = this.indexedModeMenu.selectedItemIdx; - // New - //console.print("\x01n\r\nScanning...\x01;"); // Temporary - // 1 2 3 - // 123456789012345678901234567890 - // Progress: 100% - //var numBlocks = console.screen_columns - 15; - //var numBlocksPerPercent = 100.0 / numBlocks; - // End New // Ensure the menu is clear, and (re-)populate the menu with sub-board information w/ # of new messages in each, etc. // Also, build an array of sub-board codes for each menu item. // Also, display loading percentage while this is happening. @@ -16797,12 +16795,9 @@ function DigDistMsgReader_IndexedModeChooseSubBoard(pClearScreen, pDrawMenu, pDi DigDistMsgReader_IndexedModeChooseSubBoard.selectedItemIdx = 0; var numSubBoards = 0; var totalNewMsgs = 0; - console.attributes = "N"; - console.crlf(); - printf("Loading: %0.2f% ", 0.0); // The total number of sub-boards we'll scan - For displaying the progress percentage if (typeof(DigDistMsgReader_IndexedModeChooseSubBoard.totalNumSubBoards) !== "number") - DigDistMsgReader_IndexedModeChooseSubBoard.totalNumSubBoards = countSubBoardsForScanning(scanScope, newScanOnly); + DigDistMsgReader_IndexedModeChooseSubBoard.totalNumSubBoards = countSubBoardsForScanning(scanScope, newScanOnly, true); // Load the menu for (var grpIdx = 0; grpIdx < msg_area.grp_list.length; ++grpIdx) { @@ -25747,8 +25742,9 @@ function countOccurrencesInStr(pStr, pSubstr) // Counts the number of sub-boards that would be scanned for the user, // considering their sub-board access, for a particular scan scope -function countSubBoardsForScanning(pScanScope, pNewScanOnly) +function countSubBoardsForScanning(pScanScope, pNewScanOnly, pDisplayStatusDots) { + var displayStatusDots = (typeof(pDisplayStatusDots) === "boolean" ? pDisplayStatusDots : false); var numSubBoards = 0; for (var grpIdx = 0; grpIdx < msg_area.grp_list.length; ++grpIdx) { @@ -25767,6 +25763,9 @@ function countSubBoardsForScanning(pScanScope, pNewScanOnly) if (pScanScope == SCAN_SCOPE_SUB_BOARD && bbs.cursub != subIdx) continue; ++numSubBoards; + // If we are to display status dots, then display a dot for every 4 sub-boards + if (displayStatusDots && numSubBoards % 4 == 0) + console.print("."); } } return numSubBoards; -- GitLab