Newer
Older
}

nightfox
committed
var allowChgSubBoard = (typeof(pAllowChgSubBoard) == "boolean" ? pAllowChgSubBoard : true);

nightfox
committed
// This function will be used for displaying the help line at
// the bottom of the screen.
function DisplayHelpLine(pHelpLineText)
{
console.gotoxy(1, console.screen_rows);
console.print(pHelpLineText);
console.cleartoeol("\1n");
}

nightfox
committed
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
// Clear the screen and write the header at the top
console.clear("\1n");
this.WriteMsgListScreenTopHeader();
DisplayHelpLine(this.msgListLightbarModeHelpLine);
// If the lightbar message list index & cursor position variables haven't been
// set yet, then set them.
if ((this.lightbarListTopMsgIdx == -1) || (this.lightbarListSelectedMsgIdx == -1) ||
(this.lightbarListCurPos == null))
{
this.SetUpLightbarMsgListVars();
}
// List a screenful of message headers
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
var lastPage = this.ListScreenfulOfMessages(this.lightbarListTopMsgIdx, this.lightbarMsgListNumLines);
// Move the cursor to where it needs to be
console.gotoxy(this.lightbarListCurPos);
// User input loop
var bottomMsgIndex = 0;
var userInput = "";
var msgHeader = null;
var continueOn = true;
while (continueOn)
{
bbs.command_str = ""; // To prevent weirdness
retObj.selectedMsgOffset = -1;
// Calculate the message number (0-based) of the message
// appearing on the bottom of the screen.
if (this.reverseListOrder)
{

nightfox
committed
bottomMsgIndex = this.lightbarListTopMsgIdx - this.lightbarMsgListNumLines + 1;
if (bottomMsgIndex < 0)
bottomMsgIndex = 0;
}
else
{

nightfox
committed
var totalNumMessages = this.NumMessages();
bottomMsgIndex = this.lightbarListTopMsgIdx + this.lightbarMsgListNumLines - 1;
if (bottomMsgIndex >= totalNumMessages)
bottomMsgIndex = totalNumMessages - 1;
}

nightfox
committed
// Write the current message information with highlighting colors
msgHeader = this.GetMsgHdrByIdx(this.lightbarListSelectedMsgIdx);
this.PrintMessageInfo(msgHeader, true, this.lightbarListSelectedMsgIdx+1);
console.gotoxy(this.lightbarListCurPos); // Make sure the cursor is still in the right place

nightfox
committed
// Get a key from the user (upper-case) and take appropriate action.
userInput = getKeyWithESCChars(K_UPPER|K_NOCRLF|K_NOECHO|K_NOSPIN);
retObj.lastUserInput = userInput;
// Q: Quit
if (userInput == "Q")
{
// Quit
continueOn = false;
break;
}
// ?: Show help
else if (userInput == "?")
{
// Display help
console.clear("\1n");
this.DisplayMsgListHelp(allowChgSubBoard, true);

nightfox
committed
// Re-draw the message list on the screen
console.clear("\1n");
this.WriteMsgListScreenTopHeader();
DisplayHelpLine(this.msgListLightbarModeHelpLine);
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
lastPage = this.ListScreenfulOfMessages(this.lightbarListTopMsgIdx, this.lightbarMsgListNumLines);
console.gotoxy(this.lightbarListCurPos); // Put the cursor back where it should be
}
// Up arrow: Highlight the previous message
else if (userInput == KEY_UP)
{
// Make sure this.lightbarListSelectedMsgIdx is within bounds before moving down.
if (this.reverseListOrder)

nightfox
committed
{
if (this.lightbarListSelectedMsgIdx >= this.NumMessages() - 1)
continue;
}
else
{
if (this.lightbarListSelectedMsgIdx <= 0)
continue;
}

nightfox
committed
// Print the current message information with regular colors
this.PrintMessageInfo(msgHeader, false, this.lightbarListSelectedMsgIdx+1);
if (this.reverseListOrder)

nightfox
committed
++this.lightbarListSelectedMsgIdx;
else
--this.lightbarListSelectedMsgIdx;

nightfox
committed
// If the current screen row is above the first line allowed, then
// move the cursor up one row.
if (this.lightbarListCurPos.y > this.lightbarMsgListStartScreenRow)
{
console.gotoxy(1, this.lightbarListCurPos.y-1);
this.lightbarListCurPos.x = 1;
--this.lightbarListCurPos.y;
}
else
{
// Go onto the previous page, with the cursor highlighting
// the last message on the page.
if (this.reverseListOrder)

nightfox
committed
this.lightbarListTopMsgIdx = this.lightbarListSelectedMsgIdx + this.lightbarMsgListNumLines - 1;
else
this.lightbarListTopMsgIdx = this.lightbarListSelectedMsgIdx - this.lightbarMsgListNumLines + 1;

nightfox
committed
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
lastPage = this.ListScreenfulOfMessages(this.lightbarListTopMsgIdx, this.lightbarMsgListNumLines);
console.gotoxy(1, this.lightbarMsgListStartScreenRow+this.lightbarMsgListNumLines-1);
this.lightbarListCurPos.x = 1;
this.lightbarListCurPos.y = this.lightbarMsgListStartScreenRow+this.lightbarMsgListNumLines-1;
}
}
// Down arrow: Highlight the next message
else if (userInput == KEY_DOWN)
{
// Make sure this.lightbarListSelectedMsgIdx is within bounds before moving down.
if (this.reverseListOrder)

nightfox
committed
{
if (this.lightbarListSelectedMsgIdx <= 0)
continue;
}
else
{
if (this.lightbarListSelectedMsgIdx >= this.NumMessages() - 1)
continue;
}

nightfox
committed
// Print the current message information with regular colors
this.PrintMessageInfo(msgHeader, false, this.lightbarListSelectedMsgIdx+1);
if (this.reverseListOrder)

nightfox
committed
--this.lightbarListSelectedMsgIdx;
else
++this.lightbarListSelectedMsgIdx;

nightfox
committed
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
// If the current screen row is below the last line allowed, then
// move the cursor down one row.
if (this.lightbarListCurPos.y < this.lightbarMsgListStartScreenRow+this.lightbarMsgListNumLines-1)
{
console.gotoxy(1, this.lightbarListCurPos.y+1);
this.lightbarListCurPos.x = 1;
++this.lightbarListCurPos.y;
}
else
{
// Go onto the next page, with the cursor highlighting
// the first message on the page.
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
this.lightbarListTopMsgIdx = this.lightbarListSelectedMsgIdx;
lastPage = this.ListScreenfulOfMessages(this.lightbarListTopMsgIdx, this.lightbarMsgListNumLines);
// If we were on the last page, then clear the screen from
// the current line to the end of the screen.
if (lastPage)
{
this.lightbarListCurPos = console.getxy();
clearToEOS(this.lightbarListCurPos.y);
// Make sure the help line is still there
DisplayHelpLine(this.msgListLightbarModeHelpLine);
}

nightfox
committed
// Move the cursor to the top of the list
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
this.lightbarListCurPos.x = 1;
this.lightbarListCurPos.y = this.lightbarMsgListStartScreenRow;
}
}
// HOME key: Go to the first message on the screen
else if (userInput == KEY_HOME)
{
// Print the current message information with regular colors
this.PrintMessageInfo(msgHeader, false, this.lightbarListSelectedMsgIdx+1);
// Go to the first message of the current page
if (this.reverseListOrder)

nightfox
committed
this.lightbarListSelectedMsgIdx += (this.lightbarListCurPos.y - this.lightbarMsgListStartScreenRow);
else
this.lightbarListSelectedMsgIdx -= (this.lightbarListCurPos.y - this.lightbarMsgListStartScreenRow);
// Move the cursor to the first message line
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
this.lightbarListCurPos.x = 1;
this.lightbarListCurPos.y = this.lightbarMsgListStartScreenRow;
}
// END key: Go to the last message on the screen
else if (userInput == KEY_END)
{
// Print the current message information with regular colors
this.PrintMessageInfo(msgHeader, false, this.lightbarListSelectedMsgIdx+1);
// Update the selected message #
this.lightbarListSelectedMsgIdx = bottomMsgIndex;
// Go to the last message of the current page
if (this.reverseListOrder)

nightfox
committed
this.lightbarListCurPos.y = this.lightbarMsgListStartScreenRow + this.lightbarListTopMsgIdx - bottomMsgIndex;
else
this.lightbarListCurPos.y = this.lightbarMsgListStartScreenRow + bottomMsgIndex - this.lightbarListTopMsgIdx;
console.gotoxy(this.lightbarListCurPos);
}
// Enter key: Select a message to read
else if (userInput == KEY_ENTER)
{
var originalCurpos = console.getxy();

nightfox
committed
// Allow the user to read the current message.
var readMsg = true;
if (this.promptToReadMessage)
{
// Confirm with the user whether to read the message.
var sReadMsgConfirmText = this.colors["readMsgConfirmColor"]
+ "Read message "
+ this.colors["readMsgConfirmNumberColor"]
+ +(msgHeader.offset+1)
+ this.colors["readMsgConfirmColor"]
+ ": Are you sure";
console.gotoxy(1, console.screen_rows);
console.print("\1n");
console.clearline();
readMsg = console.yesno(sReadMsgConfirmText);
}
var repliedToMessage = false;
if (readMsg)
{
// If there is a search specified and the search result objects are
// set up for the current sub-board, then the selected message offset
// should be the search result array index. Otherwise (if not
// searching), the message offset should be the actual message offset
// in the message base.
if (this.SearchingAndResultObjsDefinedForCurSub())
retObj.selectedMsgOffset = this.lightbarListSelectedMsgIdx;
else
retObj.selectedMsgOffset = msgHeader.offset;

nightfox
committed
if (pReturnOnMsgSelect)
return retObj;
else
{
this.readAMessage = true;
console.clear("\1n");
var readRetObj = null;
if (this.SearchingAndResultObjsDefinedForCurSub())
readRetObj = this.ReadMessage(this.lightbarListSelectedMsgIdx);

nightfox
committed
else
readRetObj = this.ReadMessage(msgHeader.offset);

nightfox
committed
repliedToMessage = readRetObj.userReplied;
}
}
else
this.deniedReadingMessage = true;

nightfox
committed
// Ask the user if they want to continue reading messages
if (this.promptToContinueListingMessages)
{
continueOn = console.yesno(this.colors["afterReadMsg_ListMorePromptColor"] +
"Continue listing messages");
}
// If the user chose to continue reading messages, then refresh
// the screen. Even if the user chooses not to read the message,
// the screen needs to be re-drawn so it appears properly.
if (continueOn)
{
console.clear("\1n");
this.WriteMsgListScreenTopHeader();
DisplayHelpLine(this.msgListLightbarModeHelpLine);
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
// If we're dispaying in reverse order and the user replied
// to the message, then we'll have to re-arrange the screen
// a bit to make way for the new message that will appear
// in the list.
if (this.reverseListOrder && repliedToMessage)

nightfox
committed
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
{
// Make way for the new message, which will appear at the
// top.
++this.lightbarListTopMsgIdx;
// If the cursor is below the bottommost line displaying
// messages, then advance the cursor down one position.
// Otherwise, increment this.lightbarListSelectedMsgIdx (since a new message
// will appear at the top, the previous selected message
// will be pushed to the next page).
if (this.lightbarListCurPos.y < console.screen_rows - 1)
{
++originalCurpos.y;
++this.lightbarListCurPos.y;
}
else
++this.lightbarListSelectedMsgIdx;
}
lastPage = this.ListScreenfulOfMessages(this.lightbarListTopMsgIdx, this.lightbarMsgListNumLines);
console.gotoxy(originalCurpos); // Put the cursor back where it should be
}
}
// PageDown: Next page
else if (userInput == KEY_PAGE_DOWN)
{
// Next page
if (!lastPage)
{
if (this.reverseListOrder)

nightfox
committed
this.lightbarListTopMsgIdx -= this.lightbarMsgListNumLines;
else
this.lightbarListTopMsgIdx += this.lightbarMsgListNumLines;
this.lightbarListSelectedMsgIdx = this.lightbarListTopMsgIdx;
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
this.lightbarListCurPos.x = 1;
this.lightbarListCurPos.y = this.lightbarMsgListStartScreenRow;
lastPage = this.ListScreenfulOfMessages(this.lightbarListTopMsgIdx, this.lightbarMsgListNumLines);
// If we were on the last page, then clear the screen from
// the current line to the end of the screen.
if (lastPage)
{
this.lightbarListCurPos = console.getxy();
clearToEOS(this.lightbarListCurPos.y);
// Make sure the help line is still there
DisplayHelpLine(this.msgListLightbarModeHelpLine);
}

nightfox
committed
// Move the cursor back to the first message info line
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
this.lightbarListCurPos.x = 1;
this.lightbarListCurPos.y = this.lightbarMsgListStartScreenRow;
}
else {
// The user is on the last page - Go to the last message on the page.
if (this.lightbarListSelectedMsgIdx != bottomMsgIndex)
{
// Print the current message information with regular colors
this.PrintMessageInfo(msgHeader, false, this.lightbarListSelectedMsgIdx+1);
// Update the selected message #
this.lightbarListSelectedMsgIdx = bottomMsgIndex;
this.lightbarListCurPos.x = 1;
if (this.reverseListOrder)
this.lightbarListCurPos.y = this.lightbarMsgListStartScreenRow + this.lightbarListTopMsgIdx - bottomMsgIndex;
else
this.lightbarListCurPos.y = this.lightbarMsgListStartScreenRow + bottomMsgIndex - this.lightbarListTopMsgIdx;
console.gotoxy(this.lightbarListCurPos);
}
}

nightfox
committed
}
// PageUp: Previous page
else if (userInput == KEY_PAGE_UP)
{
var canGoToPrevious = false;
if (this.reverseListOrder)

nightfox
committed
canGoToPrevious = (this.lightbarListTopMsgIdx < this.NumMessages() - 1);
else
canGoToPrevious = (this.lightbarListTopMsgIdx > 0);
if (canGoToPrevious)

nightfox
committed
{
if (this.reverseListOrder)

nightfox
committed
this.lightbarListTopMsgIdx += this.lightbarMsgListNumLines;
else
this.lightbarListTopMsgIdx -= this.lightbarMsgListNumLines;
this.lightbarListSelectedMsgIdx = this.lightbarListTopMsgIdx;
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
lastPage = this.ListScreenfulOfMessages(this.lightbarListTopMsgIdx, this.lightbarMsgListNumLines);
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
this.lightbarListCurPos.x = 1;
this.lightbarListCurPos.y = this.lightbarMsgListStartScreenRow;
}
else
{
// The user is on the first page - Go to the first message on the page.
if (this.lightbarListSelectedMsgIdx != 0)
{
// Print the current message information with regular colors
this.PrintMessageInfo(msgHeader, false, this.lightbarListSelectedMsgIdx+1);
// Go to the first message of the current page
if (this.reverseListOrder)
this.lightbarListSelectedMsgIdx += (this.lightbarListCurPos.y - this.lightbarMsgListStartScreenRow);
else
this.lightbarListSelectedMsgIdx -= (this.lightbarListCurPos.y - this.lightbarMsgListStartScreenRow);
// Move the cursor to the first message line
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
this.lightbarListCurPos.x = 1;
this.lightbarListCurPos.y = this.lightbarMsgListStartScreenRow;
}
}

nightfox
committed
}
// F: First page
else if (userInput == "F")
{
var canGoToFirst = false;
if (this.reverseListOrder)

nightfox
committed
canGoToFirst = (this.lightbarListTopMsgIdx < this.NumMessages() - 1);
else
canGoToFirst = (this.lightbarListTopMsgIdx > 0);
if (canGoToFirst)
{
if (this.reverseListOrder)

nightfox
committed
this.lightbarListTopMsgIdx = this.NumMessages() - 1;
else
this.lightbarListTopMsgIdx = 0;
this.lightbarListSelectedMsgIdx = this.lightbarListTopMsgIdx;
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
lastPage = this.ListScreenfulOfMessages(this.lightbarListTopMsgIdx, this.lightbarMsgListNumLines);
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
this.lightbarListCurPos.x = 1;
this.lightbarListCurPos.y = this.lightbarMsgListStartScreenRow;
}
}
// L: Last page
else if (userInput == "L")
{
if (!lastPage)
{
// Set the top message index. If this.lightbarListTopMsgIdx is beyond the last
// message in the sub-board, then move back a full page of messages.
if (this.reverseListOrder)

nightfox
committed
{
this.lightbarListTopMsgIdx = (this.NumMessages() % this.lightbarMsgListNumLines) - 1;
// If this.lightbarListTopMsgIdx is now invalid (below 0), then adjust it
// to properly display the last page of messages.
if (this.lightbarListTopMsgIdx < 0)
this.lightbarListTopMsgIdx = this.lightbarMsgListNumLines - 1;
}
else
{
var totalNumMessages = this.NumMessages();
this.lightbarListTopMsgIdx = totalNumMessages - (totalNumMessages % this.lightbarMsgListNumLines);
if (this.lightbarListTopMsgIdx >= totalNumMessages)
this.lightbarListTopMsgIdx = totalNumMessages - this.lightbarMsgListNumLines;
}

nightfox
committed
this.lightbarListSelectedMsgIdx = this.lightbarListTopMsgIdx;
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
lastPage = this.ListScreenfulOfMessages(this.lightbarListTopMsgIdx, this.lightbarMsgListNumLines);
// If we were on the last page, then clear the screen from
// the current line to the end of the screen.
if (lastPage)
{
this.lightbarListCurPos = console.getxy();
clearToEOS(this.lightbarListCurPos.y);
// Make sure the help line is still there
DisplayHelpLine(this.msgListLightbarModeHelpLine);
}

nightfox
committed
// Move the cursor back to the first message info line
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
this.lightbarListCurPos.x = 1;
this.lightbarListCurPos.y = this.lightbarMsgListStartScreenRow;
}
}
// Numeric digit: The start of a number of a message to read
else if (userInput.match(/[0-9]/))
{
var originalCurpos = console.getxy();

nightfox
committed
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
// Put the user's input back in the input buffer to
// be used for getting the rest of the message number.
console.ungetstr(userInput);
// Move the cursor to the bottom of the screen and
// prompt the user for the message number.
console.gotoxy(1, console.screen_rows);
userInput = this.PromptForMsgNum({ x: 1, y: console.screen_rows }, this.text.readMsgNumPromptText, true, ERROR_PAUSE_WAIT_MS, false);
if (userInput > 0)
{
// Confirm with the user whether to read the message
var readMsg = true;
if (this.promptToReadMessage)
{
var sReadMsgConfirmText = this.colors["readMsgConfirmColor"]
+ "Read message "
+ this.colors["readMsgConfirmNumberColor"]
+ userInput + this.colors["readMsgConfirmColor"]
+ ": Are you sure";
readMsg = console.yesno(sReadMsgConfirmText);
}
if (readMsg)
{
// Update the message list screen variables
this.CalcMsgListScreenIdxVarsFromMsgNum(+userInput);
// Let the user read the message
retObj.selectedMsgOffset = userInput - 1;

nightfox
committed
if (pReturnOnMsgSelect)
return retObj;
else
{
this.readAMessage = true;
if (this.SearchingAndResultObjsDefinedForCurSub())
this.ReadMessage(this.lightbarListSelectedMsgIdx);

nightfox
committed
else
this.ReadMessage(userInput-1);

nightfox
committed
}
}
else
this.deniedReadingMessage = true;

nightfox
committed
// Prompt the user whether or not to continue listing
// messages.
if (this.promptToContinueListingMessages)
{
continueOn = console.yesno(this.colors["afterReadMsg_ListMorePromptColor"] +
"Continue listing messages");
}
}

nightfox
committed
// If the user chose to continue listing messages, then re-draw
// the screen.
if (continueOn)
{
console.clear("\1n");
this.WriteMsgListScreenTopHeader();
DisplayHelpLine(this.msgListLightbarModeHelpLine);
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
lastPage = this.ListScreenfulOfMessages(this.lightbarListTopMsgIdx, this.lightbarMsgListNumLines);
console.gotoxy(originalCurpos); // Put the cursor back where it should be
}
}
// DEL key: Delete a message
else if (userInput == KEY_DEL)
{
if (this.CanDelete() || this.CanDeleteLastMsg())
{
var originalCurpos = console.getxy();

nightfox
committed
console.gotoxy(1, console.screen_rows);
console.print("\1n");
console.clearline();
// The DeleteMessage() methdo will prompt the user for confirmation
// to delete the message and then delete it if confirmed.
this.DeleteMessage(this.lightbarListSelectedMsgIdx, { x: 1, y: console.screen_rows});

nightfox
committed
// Refresh the screen
console.clear("\1n");
this.WriteMsgListScreenTopHeader();
DisplayHelpLine(this.msgListLightbarModeHelpLine);
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
lastPage = this.ListScreenfulOfMessages(this.lightbarListTopMsgIdx, this.lightbarMsgListNumLines);
console.gotoxy(originalCurpos); // Put the cursor back where it should be
}
}
// E: Edit a message
else if (userInput == "E")
{
if (this.CanEdit())
{
var originalCurpos = console.getxy();

nightfox
committed
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
// Ask the user if they really want to edit the message
console.gotoxy(1, console.screen_rows);
console.print("\1n");
console.clearline();
// Let the user edit the message
//var returnObj = this.EditExistingMsg(msgHeader.offset);
var returnObj = this.EditExistingMsg(this.lightbarListSelectedMsgIdx);
// Refresh the screen
console.clear("\1n");
this.WriteMsgListScreenTopHeader();
DisplayHelpLine(this.msgListLightbarModeHelpLine);
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
lastPage = this.ListScreenfulOfMessages(this.lightbarListTopMsgIdx, this.lightbarMsgListNumLines);
console.gotoxy(originalCurpos); // Put the cursor back where it should be
}
}
// G: Go to a specific message by # (highlight or place that message on the top)
else if (userInput == "G")
{
var originalCurpos = console.getxy();
// Move the cursor to the bottom of the screen and
// prompt the user for a message number.
console.gotoxy(1, console.screen_rows);
userInput = this.PromptForMsgNum({ x: 1, y: console.screen_rows }, "\n" + this.text.goToMsgNumPromptText, true, ERROR_PAUSE_WAIT_MS, false);
if (userInput > 0)
{
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
// Make sure the message number is for a valid message (i.e., it
// could be an invalid message number if there is a search, where
// not all message numbers are consecutive).
if (this.GetMsgHdrByMsgNum(userInput) != null)
{
// If the message is on the current page, then just go to and
// highlight it. Otherwise, set the user's selected message on the
// top of the page. We also have to make sure that this.lightbarListCurPos.y and
// originalCurpos.y are set correctly. Also, account for search
// results if there are any (we'll need to have the correct array
// index for the search results).
var chosenMsgIndex = userInput - 1;
if ((chosenMsgIndex <= bottomMsgIndex) && (chosenMsgIndex >= this.lightbarListTopMsgIdx))
{
this.lightbarListSelectedMsgIdx = chosenMsgIndex;
originalCurpos.y = this.lightbarListCurPos.y = this.lightbarListSelectedMsgIdx - this.lightbarListTopMsgIdx + this.lightbarMsgListStartScreenRow;
}
else
{
this.lightbarListTopMsgIdx = this.lightbarListSelectedMsgIdx = chosenMsgIndex;
originalCurpos.y = this.lightbarListCurPos.y = this.lightbarMsgListStartScreenRow;
}
}
else
{
// The user entered an invalid message number
console.print("\1n" + this.text.invalidMsgNumText.replace("%d", userInput) + "\1n");
console.inkey(K_NONE, ERROR_PAUSE_WAIT_MS);
}

nightfox
committed
}

nightfox
committed
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
// Clear & re-draw the screen, to fix any possible alignment problems
// caused by newline output after the user inputs their choice.
console.clear("\1n");
this.WriteMsgListScreenTopHeader();
DisplayHelpLine(this.msgListLightbarModeHelpLine);
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
lastPage = this.ListScreenfulOfMessages(this.lightbarListTopMsgIdx, this.lightbarMsgListNumLines);
console.gotoxy(originalCurpos); // Put the cursor back where it should be
}
// C: Change to another message area (sub-board)
else if (userInput == "C")
{
if (allowChgSubBoard && (this.subBoardCode != "mail"))
{
// Store the current sub-board code so we can see if it changed
var oldSubCode = bbs.cursub_code;
// Let the user choose another message area. If they chose
// a different message area, then set up the message base
// object accordingly.
this.SelectMsgArea();
if (bbs.cursub_code != oldSubCode)
{
var chgSubRetval = this.ChangeSubBoard(bbs.cursub_code);
continueOn = chgSubRetval.succeeded;
}
// Update the lightbar list variables and refresh the screen
if (continueOn)
{
this.SetUpLightbarMsgListVars();
console.clear("\1n");
this.WriteMsgListScreenTopHeader();
DisplayHelpLine(this.msgListLightbarModeHelpLine);
// List a screenful of message headers
console.gotoxy(1, this.lightbarMsgListStartScreenRow);
var lastPage = this.ListScreenfulOfMessages(this.lightbarListTopMsgIdx, this.lightbarMsgListNumLines);
// Move the cursor to where it needs to be
console.gotoxy(this.lightbarListCurPos);
}
}
}
}

nightfox
committed
return retObj;
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
}
// For the DigDistMsgListerClass: Prints a line of information about
// a message.
//
// Parameters:
// pMsgHeader: The message header object, returned by MsgBase.get_msg_header().
// pHighlight: Optional boolean - Whether or not to highlight the line or
// use the standard colors.
// pMsgNum: Optional - A number to use for the message instead of the number/offset
// in the message header
function DigDistMsgReader_PrintMessageInfo(pMsgHeader, pHighlight, pMsgNum)
{
// pMsgHeader must be a valid object.
if (typeof(pMsgHeader) == "undefined")
return;
if (pMsgHeader == null)
return;
var highlight = false;
if (typeof(pHighlight) != "undefined")
highlight = pHighlight;
// Determine if the message has been deleted.
var msgDeleted = ((pMsgHeader.attr & MSG_DELETE) == MSG_DELETE);
// Get the message's import date & time as strings. If
// this.msgList_displayMessageDateImported is true, use the message import date.
// Otherwise, use the message written date.
var sDate;
var sTime;
if (this.msgList_displayMessageDateImported)
{
sDate = strftime("%Y-%m-%d", pMsgHeader.when_imported_time);
sTime = strftime("%H:%M:%S", pMsgHeader.when_imported_time);
}
else
{
sDate = strftime("%Y-%m-%d", pMsgHeader.when_written_time);
sTime = strftime("%H:%M:%S", pMsgHeader.when_written_time);
}
// Write the message header information.
// Note: The message header has the following fields:
// 'number': The message number
// 'offset': The message offset
// 'to': Who the message is directed to (string)
// 'from' Who wrote the message (string)
// 'subject': The message subject (string)
// 'date': The date - Full text (string)
// To access one of these, use brackets; i.e., msgHeader['to']
var msgNum = (typeof(pMsgNum) == "number" ? pMsgNum : pMsgHeader.offset+1);
if (highlight)
{
printf(this.sMsgInfoFormatHighlightStr,
msgNum,
(msgDeleted ? "\1r\1i*\1n\1h" + this.colors["msgListHighlightBkgColor"] : " "),
pMsgHeader.from.substr(0, this.FROM_LEN),
pMsgHeader.to.substr(0, this.TO_LEN),
pMsgHeader.subject.substr(0, this.SUBJ_LEN),
sDate, sTime);
}
else
{
// Determine whether to use the normal, "to-user", or "from-user" format string.
// The differences are the colors. Then, output the message information line.
var toNameUpper = pMsgHeader.to.toUpperCase();
var msgToUser = ((toNameUpper == user.alias.toUpperCase()) || (toNameUpper == user.name.toUpperCase()) || (toNameUpper == user.handle.toUpperCase()));
var fromNameUpper = pMsgHeader.from.toUpperCase();
var msgIsFromUser = ((fromNameUpper == user.alias.toUpperCase()) || (fromNameUpper == user.name.toUpperCase()) || (fromNameUpper == user.handle.toUpperCase()));
printf((msgToUser ? this.sMsgInfoToUserFormatStr :
(msgIsFromUser ? this.sMsgInfoFromUserFormatStr :
this.sMsgInfoFormatStr)),
msgNum,
(msgDeleted ? "\1r\1i*\1n" : " "),
pMsgHeader.from.substr(0, this.FROM_LEN),
pMsgHeader.to.substr(0, this.TO_LEN),
pMsgHeader.subject.substr(0, this.SUBJ_LEN),
sDate, sTime);
}
console.cleartoeol("\1"); // To clear away any extra text that may have been entered by the user
}
// For the traditional interface of DigDistMsgListerClass: Prompts the user to
// continue or read a message (by number).
//
// Parameters:
// pStart: Whether or not we're on the first page (true or false)
// pEnd: Whether or not we're at the last page (true or false)
// pReturnOnMsgSelect: Optional - A boolean to specify whether or not
// to return when a message is selected to read.

nightfox
committed
// pAllowChgSubBoard: Optional - A boolean to specify whether or not to allow
// changing to another sub-board. Defaults to true.
//
// Return value: An object with the following properties:
// continueOn: Boolean, whether or not the user wants to continue
// listing the messages
// userInput: The user's input
// selectedMsgOffset: The offset of the message selected to read,
// if one was selected. If a message was not
// selected, this will be -1.

nightfox
committed
function DigDistMsgReader_PromptContinueOrReadMsg(pStart, pEnd, pReturnOnMsgSelect, pAllowChgSubBoard)
{

nightfox
committed
// Create the return object and set some initial default values
var retObj = new Object();
retObj.continueOn = true;
retObj.userInput = "";
retObj.selectedMsgOffset = -1;
var allowChgSubBoard = (typeof(pAllowChgSubBoard) == "boolean" ? pAllowChgSubBoard : true);
var continueOn = true;
// Prompt the user whether or not to continue or to read a message
// (by message number). Make use of the different prompt texts,
// depending whether we're at the beginning, in the middle, or at
// the end of the message list.
var userInput = "";
var allowedKeys = "?G"; // ? = help, G = Go to message #

nightfox
committed
if (allowChgSubBoard)
allowedKeys += "C"; // Change to another message area
if (this.CanDelete() || this.CanDeleteLastMsg())

nightfox
committed
allowedKeys += "D"; // Delete
if (this.CanEdit())
allowedKeys += "E"; // Edit
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
if (pStart && pEnd)
{
// This is the only page.
console.print(this.msgListOnlyOnePageContinuePrompt);
// Get input from the user. Allow only Q (quit).
allowedKeys += "Q";
}
else if (pStart)
{
// We're on the first page.
console.print(this.sStartContinuePrompt);
// Get input from the user. Allow only L (last), N (next), or Q (quit).
allowedKeys += "LNQ";
}
else if (pEnd)
{
// We're on the last page.
console.print(this.sEndContinuePrompt);
// Get input from the user. Allow only F (first), P (previous), or Q (quit).
allowedKeys += "FPQ";
}
else
{
// We're neither on the first nor last page. Allow F (first), L (last),
// N (next), P (previous), or Q (quit).
console.print(this.sContinuePrompt);
allowedKeys += "FLNPQ";
}
// Get the user's input. Allow the keys in allowedKeys or a number from 1
// to the highest message number.
userInput = console.getkeys(allowedKeys, this.HighestMessageNum()).toString();
if (userInput == "Q")
continueOn = false;
// If the user has typed all numbers, then read that message.
if ((userInput != "") && /^[0-9]+$/.test(userInput))
{
// If the user entered a valid message number, then let the user read the message.
// The message number might be invalid if there are search results that
// have non-continuous message numbers.
if (this.IsValidMessageNum(userInput))
{
// Confirm with the user whether to read the message
var readMsg = true;
if (this.promptToReadMessage)
{
var sReadMsgConfirmText = this.colors["readMsgConfirmColor"]

nightfox
committed
+ "Read message "
+ this.colors["readMsgConfirmNumberColor"]
+ userInput + this.colors["readMsgConfirmColor"]
+ ": Are you sure";
readMsg = console.yesno(sReadMsgConfirmText);
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
}
if (readMsg)
{
// Update the message list screen variables
this.CalcMsgListScreenIdxVarsFromMsgNum(+userInput);
// Let the user read the message
if (pReturnOnMsgSelect)
{
// Fill a return object with the required values, and return it.
retObj.continueOn = continueOn;
retObj.userInput = userInput;
retObj.selectedMsgOffset = userInput-1;
return retObj;
}
else
{
this.readAMessage = true;
this.ReadMessage(userInput-1);
}
}
else
this.deniedReadingMessage = true;
// Prompt the user whether or not to continue listing
// messages.
if (this.promptToContinueListingMessages)
{
continueOn = console.yesno(this.colors["afterReadMsg_ListMorePromptColor"] +

nightfox
committed
"Continue listing messages");
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
}
}
else
{
// The user entered an invalid message number.
console.print("\1n\1h\1w" + userInput + " \1y is not a valid message number.\1n");
console.crlf();
console.pause();
continueOn = true;
}
}
// Make sure color highlighting is turned off
console.print("\1n");
// Fill the return object with the required values, and return it.
retObj.continueOn = continueOn;
retObj.userInput = userInput;
return retObj;
}
// For the DigDistMsgReader Class: Given a message number of a message in the
// current message area, shows the message to the user and allows the user to
// respond.
//
// Parameters:
// pOffset: The offset of the message to be read
//
// Return value: And object with the following properties:
// offsetValid: Boolean - Whether or not the passed-in offset was valid
// userReplied: Boolean - Whether or not the user replied to the message.
// msgbaseReOpened: Boolean - Whether or not the messagebase is open after
// the user replied to the message. Will be true if
// the user didn't reply to the message.
function DigDistMsgReader_ReadMessage(pOffset)
{
var retObj = new Object();
retObj.offsetValid = true;
retObj.userReplied = false;
retObj.msgbaseReOpened = true;
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
// Get the message header
var msgHeader = this.GetMsgHdrByMsgNum(pOffset+1);
if (msgHeader == null)
{
console.print("\1n" + this.text.invalidMsgNumText.replace("%d", +(pOffset+1)) + "\1n");
console.inkey(K_NONE, ERROR_PAUSE_WAIT_MS);
retObj.offsetValid = false;
return retObj;
}
// Show the message header.
this.DisplaySyncMsgHeader(msgHeader);
// Show the message body. Make sure the text is word-wrapped
// so that it looks good.
var msgText = this.msgbase.get_msg_body(true, msgHeader.offset);
var msgTextWrapped = word_wrap(msgText, console.screen_columns-1);
console.print("\1n" + this.colors["msgBodyColor"]);
console.putmsg(msgTextWrapped, P_NOATCODES);
// Hack: If the "from" name in the header is blank (as it might be sometimes), then
// set it to "All". This prevents Synchronet from crashing, and it will also default
// the "to" name in the user's reply to "All".
if (msgHeader["from"] == "")
msgHeader["from"] = "All";
// Mark the message as read, if it was written to the current
// user.
var msgToUpper = msgHeader["to"].toUpperCase();
if ((msgToUpper == user.alias.toUpperCase()) || (msgToUpper == user.name.toUpperCase()))
{
msgHeader.attr = (msgHeader.attr | MSG_READ);
var wroteHeader = this.msgbase.put_msg_header(true, msgHeader.offset, msgHeader);
}
// If not reading personal email, then update the scan & last read message pointers.
if (this.subBoardCode != "mail") // && !this.SearchTypePopulatesSearchResults()
{
if (msgHeader.number > msg_area.sub[this.subBoardCode].scan_ptr)
msg_area.sub[this.subBoardCode].scan_ptr = msgHeader.number;
msg_area.sub[this.subBoardCode].last_read = msgHeader.number;
}
// Allow the user to reply to the message, either publicly or privately.
console.print("\1n\1cEnd of message. \1hR\1b)\1n\1ceply\1h\1b, " +
"\1cP\1b)\1n\1crivate reply\1h\1b, \1cENTER\1b/\1cN\1b)\1n\1co reply\1h\1g: \1n\1c");
var userKey = console.getkeys("RPN").toString();
var privateReply = (userKey == "P");
if ((userKey == "R") || privateReply)
{
var replyRetObj = this.ReplyToMsg(msgHeader, msgText, privateReply, pOffset);
retObj.userReplied = replyRetObj.postSucceeded;
retObj.msgbaseReOpened = replyRetObj.msgbaseReOpened;
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
}
return retObj;
}
// For the DigDistMsgReader Class: Given a message number of a message in the
// current message area, shows the message to the user and allows the user to
// respond. This is an enhanced version that allows scrolling up & down the
// message with the up & down arrow keys, and the left & right arrow keys will
// return from the function to allow calling code to navigate back & forth
// through the message sub-board.
//
// Parameters:
// pOffset: The offset of the message to be read
// pAllowChgArea: Optional boolean - Whether or not to allow changing the
// message area
//
// Return value: And object with the following properties:
// offsetValid: Boolean - Whether or not the passed-in offset was valid
// msgDeleted: Boolean - Whether or not the message is marked as deleted
// (not deleted by the user in the reader)
// userReplied: Boolean - Whether or not the user replied to the message.
// lastKeypress: The last keypress from the user - For navigation purposes
// newMsgOffset: The offset of another message to read, if the user
// input another message number. If the user did not
// input another message number, this will be -1.
// nextAction: The next action for the caller to take. This will be
// one of the values specified by the ACTION_* constants.
// This defaults to ACTION_NONE on error.
// refreshEnhancedRdrHelpLine: Boolean - Whether or not to refresh the
// enhanced reader help line on the screen
// (for instance, if switched to the traditional
// non-scrolling interface to read the message)
function DigDistMsgReader_ReadMessageEnhanced(pOffset, pAllowChgArea)
{
var retObj = new Object();
retObj.offsetValid = true;
retObj.msgDeleted = false;
retObj.userReplied = false;
retObj.lastKeypress = "";
retObj.newMsgOffset = -1;
retObj.nextAction = ACTION_NONE;
retObj.refreshEnhancedRdrHelpLine = false;