Newer
Older
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
// If the user chose a sub-board, then set bbs.curgrp and
// bbs.cursub, and don't continue the input loop anymore.
if (retObj.subBoardChosen)
{
// Set the current group & sub-board
bbs.curgrp = msgGroupIndex;
bbs.cursub = retObj.subBoardIndex;
continueChoosingMsgArea = false;
}
else
{
// A sub-board was not chosen, so we'll have to re-draw
// the header and list of message groups.
console.gotoxy(1, 1);
this.WriteGrpListHdrLine(numPages, pageNum);
this.ListScreenfulOfMsgGrps(topMsgGrpIndex, listStartRow, listEndRow,
false, true);
}
}
else
{
// The user didn't make a selection. So, we need to refresh
// the screen due to everything being moved up one line.
this.WriteChgMsgAreaKeysHelpLine();
console.gotoxy(1, 1);
this.WriteGrpListHdrLine(numPages, pageNum);
this.ListScreenfulOfMsgGrps(topMsgGrpIndex, listStartRow, listEndRow,
false, true);
}
}
break;
}
}
// If the user chose a different message group & sub-board, then reset the
// lister index & cursor variables, as well as this.subBoardCode, etc.
if ((bbs.curgrp != oldGrp) || (bbs.cursub != oldSub))
{
this.tradListTopMsgIdx = -1;
this.lightbarListTopMsgIdx = -1;
this.lightbarListSelectedMsgIdx = -1;
this.lightbarListCurPos = null;
this.setSubBoardCode(msg_area.grp_list[bbs.curgrp].sub_list[bbs.cursub].code);
// Re-create the msgbase object for the new sub-board. Don't open it yet,
// as that is done in the read/list methods.
if (this.msgbase != null)
{
if (this.msgbase.is_open)
this.msgbase.close();
this.msgbase = null;
}
this.msgbase = new MsgBase(this.subBoardCode);
}
}
// For the DigDistMsgReader class: Lets the user choose a sub-board within a
// message group, with a lightbar interface. Does not set bbs.cursub.
//
// Parameters:
// pGrpIndex: The index of the message group to choose from. This is
// optional; if not specified, bbs.curgrp will be used.
// pMarkIndex: An index of a message group to display the "current" mark
// next to. This is optional; if left off, this will default to
// the current sub-board.
//
// Return value: An object containing the following values:
// subBoardChosen: Boolean - Whether or not a sub-board was chosen.
// subBoardIndex: Numeric - The sub-board that was chosen (if any).
// Will be -1 if none chosen.
function DigDistMsgReader_SelectSubBoard_Lightbar(pGrpIndex, pMarkIndex)
{
// Create the return object.
var retObj = new Object();
retObj.subBoardChosen = false;
retObj.subBoardIndex = -1;
var grpIndex = 0;
if (typeof(pGrpIndex) == "number")
grpIndex = pGrpIndex;
else
grpIndex = msg_area.sub[this.subBoardCode].grp_index;
// Older:
/*
else if ((bbs.curgrp != null) && (typeof(bbs.curgrp) == "number"))
grpIndex = bbs.curgrp;
*/
// Double-check grpIndex
if (grpIndex < 0)
grpIndex = 0;
else if (grpIndex >= msg_area.grp_list.length)
grpIndex = msg_area.grp_list.length - 1;
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
var markIndex = 0;
if ((pMarkIndex != null) && (typeof(pMarkIndex) == "number"))
markIndex = pMarkIndex;
else
markIndex = msg_area.sub[this.subBoardCode].index;
// Older:
/*
else if ((bbs.cursub != null) && (typeof(bbs.cursub) == "number") &&
(bbs.curgrp == pGrpIndex))
{
markIndex = bbs.cursub;
}
*/
// Double-check markIndex
if (markIndex < 0)
markIndex = 0;
else if (markIndex >= msg_area.grp_list[grpIndex].sub_list.length)
markIndex = msg_area.grp_list[grpIndex].sub_list.length - 1;
// Ensure that the sub-board printf information is created for
// this message group.
this.BuildSubBoardPrintfInfoForGrp(grpIndex);
// If there are no sub-boards in the given message group, then show
// an error and return.
if (msg_area.grp_list[grpIndex].sub_list.length == 0)
{
console.clear("\1n");
console.print("\1y\1hThere are no sub-boards in the chosen group.\r\n\1p");
return retObj;
}
// Returns the index of the bottommost sub-board that can be displayed on
// the screen.
//
// Parameters:
// pTopSubIndex: The index of the topmost sub-board displayed on screen
// pNumItemsPerPage: The number of items per page
function getBottommostSubIndex(pTopSubIndex, pNumItemsPerPage)
{
var bottomGrpIndex = topSubIndex + pNumItemsPerPage - 1;
// If bottomGrpIndex is beyond the last index, then adjust it.
if (bottomGrpIndex >= msg_area.grp_list[grpIndex].sub_list.length)
bottomGrpIndex = msg_area.grp_list[grpIndex].sub_list.length - 1;
return bottomGrpIndex;
}
// Figure out the index of the user's currently-selected sub-board.
var selectedSubIndex = 0;
if (msg_area.sub[this.subBoardCode].grp_index == pGrpIndex)
selectedSubIndex = msg_area.sub[this.subBoardCode].index;
/*
var selectedSubIndex = 0;
if ((bbs.cursub != null) && (typeof(bbs.cursub) == "number"))
{
if ((bbs.curgrp != null) && (typeof(bbs.curgrp) == "number") &&
(bbs.curgrp == pGrpIndex))
{
selectedSubIndex = bbs.cursub;
}
}
*/
// listStartRow is the row on the screen where the list will start
var listStartRow = 3 + this.areaChangeHdrLines.length;
var listEndRow = console.screen_rows - 1; // Row on screen where list will end
var topSubIndex = 0; // The index of the message group at the top of the list
// Figure out the index of the last message group to appear on the screen.
var numItemsPerPage = listEndRow - listStartRow + 1;
var bottomSubIndex = getBottommostSubIndex(topSubIndex, numItemsPerPage);
// Figure out how many pages are needed to list all the sub-boards.
var numPages = Math.ceil(msg_area.grp_list[grpIndex].sub_list.length / numItemsPerPage);
// Figure out the top index for the last page.
var topIndexForLastPage = (numItemsPerPage * numPages) - numItemsPerPage;
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
// If the highlighted row is beyond the current screen, then
// go to the appropriate page.
if (selectedSubIndex > bottomSubIndex)
{
var nextPageTopIndex = 0;
while (selectedSubIndex > bottomSubIndex)
{
nextPageTopIndex = topSubIndex + numItemsPerPage;
if (nextPageTopIndex < msg_area.grp_list[grpIndex].sub_list.length)
{
// Adjust topSubIndex and bottomSubIndex, and
// refresh the list on the screen.
topSubIndex = nextPageTopIndex;
bottomSubIndex = getBottommostSubIndex(topSubIndex, numItemsPerPage);
}
else
break;
}
// If we didn't find the correct page for some reason, then set the
// variables to display page 1 and select the first message group.
var foundCorrectPage =
((topSubIndex < msg_area.grp_list[grpIndex].sub_list.length) &&
(selectedSubIndex >= topSubIndex) && (selectedSubIndex <= bottomSubIndex));
if (!foundCorrectPage)
{
topSubIndex = 0;
bottomSubIndex = getBottommostSubIndex(topSubIndex, numItemsPerPage);
selectedSubIndex = 0;
}
}
// Clear the screen, write the header line, help line and group list header,
// and output a screenful of message sub-boards.
console.clear("\1n");
this.DisplayAreaChgHdr(1);
if (this.areaChangeHdrLines.length > 0)
console.crlf();
var pageNum = calcPageNum(topSubIndex, numItemsPerPage);
this.WriteSubBrdListHdr1Line(grpIndex, numPages, pageNum);
this.WriteChgMsgAreaKeysHelpLine();
var curpos = new Object();
curpos.x = 1;
curpos.y = 2 + this.areaChangeHdrLines.length;
console.gotoxy(curpos);
printf(this.subBoardListHdrPrintfStr, "Sub #", "Name", "# Posts", "Latest date & time");
this.ListScreenfulOfSubBrds(grpIndex, topSubIndex, listStartRow, listEndRow, false, false);
// Start of the input loop.
var highlightScrenRow = 0; // The row on the screen for the highlighted group
var userInput = ""; // Will store a keypress from the user
var continueChoosingSubBrd = true;
while (continueChoosingSubBrd)
{
// Highlight the currently-selected message group
highlightScrenRow = listStartRow + (selectedSubIndex - topSubIndex);
curpos.y = highlightScrenRow;
if ((highlightScrenRow > 0) && (highlightScrenRow < console.screen_rows))
{
console.gotoxy(1, highlightScrenRow);
this.WriteMsgSubBoardLine(grpIndex, selectedSubIndex, true);
}
// Get a key from the user (upper-case) and take action based upon it.
//userInput = console.getkey(K_UPPER | K_NOCRLF);
userInput = getKeyWithESCChars(K_UPPER | K_NOCRLF);
switch (userInput)
{
case KEY_UP: // Move up one message group in the list
if (selectedSubIndex > 0)
{
// If the previous group index is on the previous page, then
// display the previous page.
var previousSubIndex = selectedSubIndex - 1;
if (previousSubIndex < topSubIndex)
{
// Adjust topSubIndex and bottomSubIndex, and
// refresh the list on the screen.
topSubIndex -= numItemsPerPage;
bottomSubIndex = getBottommostSubIndex(topSubIndex, numItemsPerPage);
pageNum = calcPageNum(topSubIndex, numItemsPerPage);
this.UpdateMsgAreaPageNumInHeader(pageNum, numPages, false, false);
this.ListScreenfulOfSubBrds(grpIndex, topSubIndex, listStartRow, listEndRow, false, true);
}
else
{
// Display the current line un-highlighted.
console.gotoxy(1, curpos.y);
this.WriteMsgSubBoardLine(grpIndex, selectedSubIndex, false);
}
selectedSubIndex = previousSubIndex;
}
break;
case KEY_DOWN: // Move down one message group in the list
if (selectedSubIndex < msg_area.grp_list[grpIndex].sub_list.length - 1)
{
// If the next group index is on the next page, then display
// the next page.
var nextGrpIndex = selectedSubIndex + 1;
if (nextGrpIndex > bottomSubIndex)
{
// Adjust topSubIndex and bottomSubIndex, and
// refresh the list on the screen.
topSubIndex += numItemsPerPage;
bottomSubIndex = getBottommostSubIndex(topSubIndex, numItemsPerPage);
pageNum = calcPageNum(topSubIndex, numItemsPerPage);
this.UpdateMsgAreaPageNumInHeader(pageNum, numPages, false, false);
this.ListScreenfulOfSubBrds(grpIndex, topSubIndex, listStartRow, listEndRow, false, true);
}
else
{
// Display the current line un-highlighted.
console.gotoxy(1, curpos.y);
this.WriteMsgSubBoardLine(grpIndex, selectedSubIndex, false);
}
selectedSubIndex = nextGrpIndex;
}
break;
case KEY_HOME: // Go to the top message group on the screen
if (selectedSubIndex > topSubIndex)
{
// Display the current line un-highlighted, then adjust
// selectedSubIndex.
console.gotoxy(1, curpos.y);
this.WriteMsgSubBoardLine(grpIndex, selectedSubIndex, false);
selectedSubIndex = topSubIndex;
// Note: curpos.y is set at the start of the while loop.
}
break;
case KEY_END: // Go to the bottom message group on the screen
if (selectedSubIndex < bottomSubIndex)
{
// Display the current line un-highlighted, then adjust
// selectedSubIndex.
console.gotoxy(1, curpos.y);
this.WriteMsgSubBoardLine(grpIndex, selectedSubIndex, false);
selectedSubIndex = bottomSubIndex;
// Note: curpos.y is set at the start of the while loop.
}
break;
case KEY_ENTER: // Select the currently-highlighted sub-board
// Validate the sub-board choice. If a search is specified, the
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
// validator function will search for messages in the selected
// sub-board and will return true if there are messages to read
// there or false if not. If there is no search specified,
// the validator function will return a 'true' value.
var msgAreaValidRetval = this.ValidateMsgAreaChoice(grpIndex, selectedSubIndex, curpos);
if (msgAreaValidRetval.msgAreaGood)
{
continueChoosingSubBrd = false;
retObj.subBoardChosen = true;
retObj.subBoardIndex = selectedSubIndex;
}
else
{
// Output the error that was returned by the validator function
console.gotoxy(1, curpos.y);
console.cleartoeol("\1n");
console.print("\1h\1y" + msgAreaValidRetval.errorMsg);
mswait(ERROR_PAUSE_WAIT_MS);
console.print("\1n");
continueChoosingSubBrd = true;
retObj.subBoardChosen = false;
retObj.subBoardIndex = -1;
}
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
break;
case KEY_PAGE_DOWN: // Go to the next page
case 'N':
var nextPageTopIndex = topSubIndex + numItemsPerPage;
if (nextPageTopIndex < msg_area.grp_list[grpIndex].sub_list.length)
{
// Adjust topSubIndex and bottomSubIndex, and
// refresh the list on the screen.
topSubIndex = nextPageTopIndex;
pageNum = calcPageNum(topSubIndex, numItemsPerPage);
bottomSubIndex = getBottommostSubIndex(topSubIndex, numItemsPerPage);
this.UpdateMsgAreaPageNumInHeader(pageNum, numPages, false, false);
this.ListScreenfulOfSubBrds(grpIndex, topSubIndex, listStartRow, listEndRow, false, true);
selectedSubIndex = topSubIndex;
}
break;
case KEY_PAGE_UP: // Go to the previous page
case 'P':
var prevPageTopIndex = topSubIndex - numItemsPerPage;
if (prevPageTopIndex >= 0)
{
// Adjust topSubIndex and bottomSubIndex, and
// refresh the list on the screen.
topSubIndex = prevPageTopIndex;
pageNum = calcPageNum(topSubIndex, numItemsPerPage);
bottomSubIndex = getBottommostSubIndex(topSubIndex, numItemsPerPage);
this.UpdateMsgAreaPageNumInHeader(pageNum, numPages, false, false);
this.ListScreenfulOfSubBrds(grpIndex, topSubIndex, listStartRow, listEndRow, false, true);
selectedSubIndex = topSubIndex;
}
break;
case 'F': // Go to the first page
if (topSubIndex > 0)
{
topSubIndex = 0;
pageNum = calcPageNum(topSubIndex, numItemsPerPage);
bottomSubIndex = getBottommostSubIndex(topSubIndex, numItemsPerPage);
this.UpdateMsgAreaPageNumInHeader(pageNum, numPages, false, false);
this.ListScreenfulOfSubBrds(grpIndex, topSubIndex, listStartRow, listEndRow, false, true);
selectedSubIndex = 0;
}
break;
case 'L': // Go to the last page
if (topSubIndex < topIndexForLastPage)
{
topSubIndex = topIndexForLastPage;
pageNum = calcPageNum(topSubIndex, numItemsPerPage);
bottomSubIndex = getBottommostSubIndex(topSubIndex, numItemsPerPage);
this.UpdateMsgAreaPageNumInHeader(pageNum, numPages, false, false);
this.ListScreenfulOfSubBrds(grpIndex, topSubIndex, listStartRow, listEndRow, false, true);
selectedSubIndex = topIndexForLastPage;
}
break;
case 'Q': // Quit
continueChoosingSubBrd = false;
break;
case '?': // Show help
this.ShowChooseMsgAreaHelpScreen(true, true);
console.pause();
// Refresh the screen
this.DisplayAreaChgHdr(1);
//if (this.areaChangeHdrLines.length > 0)
// console.crlf();
console.gotoxy(1, 1+this.areaChangeHdrLines.length);
this.WriteSubBrdListHdr1Line(grpIndex, numPages, pageNum);
console.cleartoeol("\1n");
this.WriteChgMsgAreaKeysHelpLine();
console.gotoxy(1, 2+this.areaChangeHdrLines.length);
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
printf(this.subBoardListHdrPrintfStr, "Sub #", "Name", "# Posts", "Latest date & time");
this.ListScreenfulOfSubBrds(grpIndex, topSubIndex, listStartRow, listEndRow, false, true);
break;
default:
// If the user entered a numeric digit, then treat it as
// the start of the message sub-board number.
if (userInput.match(/[0-9]/))
{
var originalCurpos = curpos;
// 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);
console.clearline("\1n");
console.print("\1cSub-board #: \1h");
userInput = console.getnum(msg_area.grp_list[grpIndex].sub_list.length);
// If the user made a selection, then set it in the
// return object and don't continue the input loop.
if (userInput > 0)
{
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
// Validate the sub-board choice. If a search is specified, the
// validator function will search for messages in the selected
// sub-board and will return true if there are messages to read
// there or false if not. If there is no search specified,
// the validator function will return a 'true' value.
var msgAreaValidRetval = this.ValidateMsgAreaChoice(grpIndex, selectedSubIndex, curpos);
if (msgAreaValidRetval.msgAreaGood)
{
continueChoosingSubBrd = false;
retObj.subBoardChosen = true;
retObj.subBoardIndex = userInput - 1;
}
else
{
// Output the error that was returned by the validator function
console.print("\1n\1y\1h" + msgAreaValidRetval.errorMsg);
mswait(ERROR_PAUSE_WAIT_MS);
// Set our loop variables so that we continue the sub-board
// choosing loop.
continueChoosingSubBrd = true;
retObj.subBoardChosen = false;
retObj.subBoardIndex = -1;
// Since the message area selection failed, we need to
// re-draw the screen due to everything being moved up one
// line.
console.gotoxy(1, 1);
this.DisplayAreaChgHdr(1);
if (this.areaChangeHdrLines.length > 0)
console.crlf();
this.WriteSubBrdListHdr1Line(grpIndex, numPages, pageNum);
console.cleartoeol("\1n");
this.WriteChgMsgAreaKeysHelpLine();
console.gotoxy(1, 2);
printf(this.subBoardListHdrPrintfStr, "Sub #", "Name", "# Posts", "Latest date & time");
this.ListScreenfulOfSubBrds(grpIndex, topSubIndex, listStartRow, listEndRow, false, true);
}
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
}
else
{
// The user didn't enter a selection. Now we need to re-draw
// the screen due to everything being moved up one line.
console.gotoxy(1, 1);
this.DisplayAreaChgHdr(1);
if (this.areaChangeHdrLines.length > 0)
console.crlf();
this.WriteSubBrdListHdr1Line(grpIndex, numPages, pageNum);
console.cleartoeol("\1n");
this.WriteChgMsgAreaKeysHelpLine();
console.gotoxy(1, 2);
printf(this.subBoardListHdrPrintfStr, "Sub #", "Name", "# Posts", "Latest date & time");
this.ListScreenfulOfSubBrds(grpIndex, topSubIndex, listStartRow, listEndRow, false, true);
}
}
break;
}
}
}
// For the DigDistMsgReader class: Lets the user choose a message group and
// sub-board via numeric input, using a traditional user interface.
function DigDistMsgReader_SelectMsgArea_Traditional()
{
// If there are no message groups, then don't let the user
// choose one.
if (msg_area.grp_list.length == 0)
{
console.clear("\1n");
console.print("\1y\1hThere are no message groups.\r\n\1p");
return;
}
// Make a backup of the current message group & sub-board indexes so
// that later we can tell if the user chose something different.
var oldGrp = msg_area.sub[this.subBoardCode].grp_index;
var oldSub = msg_area.sub[this.subBoardCode].index;
// Older:
/*
var oldGrp = bbs.curgrp;
var oldSub = bbs.cursub;
*/
// Show the message groups & sub-boards and let the user choose one.
var selectedGrp = 0; // The user's selected message group
var selectedSubBoard = 0; // The user's selected sub-board
var continueChoosingMsgGroup = true;
while (continueChoosingMsgGroup)
{
// Clear the BBS command string to make sure there are no extra
// commands in there that could cause weird things to happen.
bbs.command_str = "";
console.clear("\1n");
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
this.ListMsgGrps();
console.crlf();
console.print("\1n\1b\1hþ \1n\1cWhich, \1hQ\1n\1cuit, or [\1h" +
+(msg_area.sub[this.subBoardCode].grp_index+1) + "\1n\1c]: \1h");
// Older:
/*
console.print("\1n\1b\1hþ \1n\1cWhich, \1hQ\1n\1cuit, or [\1h" +
+(bbs.curgrp+1) + "\1n\1c]: \1h");
*/
// Accept Q (quit) or a file library number
selectedGrp = console.getkeys("Q", msg_area.grp_list.length);
// If the user just pressed enter (selectedGrp would be blank),
// default to the current group.
if (selectedGrp.toString() == "")
selectedGrp = msg_area.sub[this.subBoardCode].grp_index + 1;
// Older:
/*
if (selectedGrp.toString() == "")
selectedGrp = bbs.curgrp + 1;
*/
if (selectedGrp.toString() == "Q")
continueChoosingMsgGroup = false;
else
{
// If the user specified a message group number, then
// set it and let the user choose a sub-board within
// the group.
if (selectedGrp > 0)
{
// Set the default sub-board #: The current sub-board, or if the
// user chose a different group, then this should be set
// to the first sub-board.
var defaultSubBoard = msg_area.sub[this.subBoardCode].index + 1;
if (selectedGrp-1 != msg_area.sub[this.subBoardCode].grp_index)
defaultSubBoard = 1;
// Older:
/*
var defaultSubBoard = bbs.cursub + 1;
if (selectedGrp-1 != bbs.curgrp)
defaultSubBoard = 1;
*/
var continueChoosingSubBoard = true;
while (continueChoosingSubBoard)
{
console.clear("\1n");
this.ListSubBoardsInMsgGroup(selectedGrp-1, defaultSubBoard-1);
console.crlf();
console.print("\1n\1b\1hþ \1n\1cWhich, \1hQ\1n\1cuit, or [\1h" +
defaultSubBoard + "\1n\1c]: \1h");
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
// Accept Q (quit) or a sub-board number
selectedSubBoard = console.getkeys("Q", msg_area.grp_list[selectedGrp - 1].sub_list.length);
// If the user just pressed enter (selectedSubBoard would be blank),
// default the selected directory.
if (selectedSubBoard.toString() == "")
selectedSubBoard = defaultSubBoard;
// If the user chose to quit out of the sub-board list, then
// return to the message group list.
if (selectedSubBoard.toString() == "Q")
continueChoosingSubBoard = false;
// If the user chose a message sub-board, then validate the user's
// sub-board choice; if that succeeds, then change the user's
// sub-board to that and quit out of the chooser loops.
else if (selectedSubBoard > 0)
{
// Validate the sub-board choice. If a search is specified, the
// validator function will search for messages in the selected
// sub-board and will return true if there are messages to read
// there or false if not. If there is no search specified,
// the validator function will return a 'true' value.
var selectedGrpIdx = selectedGrp - 1;
var selectedSubIdx = selectedSubBoard - 1;
var msgAreaValidRetval = this.ValidateMsgAreaChoice(selectedGrpIdx, selectedSubIdx);
if (msgAreaValidRetval.msgAreaGood)
{
bbs.curgrp = selectedGrpIdx;
bbs.cursub = selectedSubIdx;
continueChoosingSubBoard = false;
continueChoosingMsgGroup = false;
}
else
{
// Output the error returned by the validator function
console.print("\1n\1h\1y" + msgAreaValidRetval.errorMsg);
mswait(ERROR_PAUSE_WAIT_MS);
// Set our loop variables to continue allowing the user to
// choose a message sub-board
continueChoosingSubBoard = true;
continueChoosingMsgGroup = true;
}
}
}
}
}
}
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
// If the user chose a different message group & sub-board, then reset the
// lister index & cursor variables, as well as this.subBoardCode, etc.
//msg_area.sub[this.subBoardCode].grp_index
if ((bbs.curgrp != oldGrp) || (bbs.cursub != oldSub))
{
this.tradListTopMsgIdx = -1;
this.lightbarListTopMsgIdx = -1;
this.lightbarListSelectedMsgIdx = -1;
this.lightbarListCurPos = null;
this.setSubBoardCode(msg_area.grp_list[bbs.curgrp].sub_list[bbs.cursub].code);
// Re-create the msgbase object for the new sub-board. Don't open it yet,
// as that is done in the read/list methods.
if (this.msgbase != null)
{
if (this.msgbase.is_open)
this.msgbase.close();
this.msgbase = null;
}
this.msgbase = new MsgBase(this.subBoardCode);
}
}
// For the DigDistMsgReader class: Lists all message groups (for the traditional
// user interface).
function DigDistMsgReader_ListMsgGrps_Traditional()
{
// Print the header
this.WriteGrpListHdrLine();
console.print("\1n");
// List the message groups
for (var i = 0; i < msg_area.grp_list.length; ++i)
{
console.crlf();
this.WriteMsgGroupLine(i, false);
}
}
// For the DigDistMsgReader class: Lists the sub-boards in a message group,
// for the traditional user interface.
//
// Parameters:
// pGrpIndex: The index of the message group (0-based)
// pMarkIndex: An index of a message group to highlight. This
// is optional; if left off, this will default to
// the current sub-board.
// pSortType: Optional - A string describing how to sort the list (if desired):
// "none": Default behavior - Sort by sub-board #
// "dateAsc": Sort by date, ascending
// "dateDesc": Sort by date, descending
// "description": Sort by description
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
function DigDistMsgReader_ListSubBoardsInMsgGroup_Traditional(pGrpIndex, pMarkIndex, pSortType)
{
// Default to the current message group & sub-board if pGrpIndex
// and pMarkIndex aren't specified.
var grpIndex = bbs.curgrp;
if ((pGrpIndex != null) && (typeof(pGrpIndex) == "number"))
grpIndex = pGrpIndex;
var highlightIndex = bbs.cursub;
if ((pMarkIndex != null) && (typeof(pMarkIndex) == "number"))
highlightIndex = pMarkIndex;
// Make sure grpIndex and highlightIndex are valid (they might not be for
// brand-new users).
if ((grpIndex == null) || (typeof(grpIndex) == "undefined"))
grpIndex = 0;
if ((highlightIndex == null) || (typeof(highlightIndex) == "undefined"))
highlightIndex = 0;
// Ensure that the sub-board printf information is created for
// this message group.
this.BuildSubBoardPrintfInfoForGrp(grpIndex);
// Print the headers
this.WriteSubBrdListHdr1Line(grpIndex);
console.crlf();
printf(this.subBoardListHdrPrintfStr, "Sub #", "Name", "# Posts", "Latest date & time");
console.print("\1n");
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
// List each sub-board in the message group.
var subBoardArray = null; // For sorting, if desired
var newestDate = new Object(); // For storing the date of the newest post in a sub-board
var msgBase = null; // For opening the sub-boards with a MsgBase object
var msgHeader = null; // For getting the date & time of the newest post in a sub-board
var subBoardNum = 0; // 0-based sub-board number (because the array index is the number as a str)
// If a sort type is specified, then add the sub-board information to
// subBoardArray so that it can be sorted.
if ((typeof(pSortType) == "string") && (pSortType != "") && (pSortType != "none"))
{
subBoardArray = new Array();
var subBoardInfo = null;
for (var arrSubBoardNum in msg_area.grp_list[grpIndex].sub_list)
{
// Open the current sub-board with the msgBase object.
msgBase = new MsgBase(msg_area.grp_list[grpIndex].sub_list[arrSubBoardNum].code);
if (msgBase.open())
{
subBoardInfo = new MsgSubBoardInfo();
subBoardInfo.subBoardNum = +(arrSubBoardNum);
subBoardInfo.description = msg_area.grp_list[grpIndex].sub_list[arrSubBoardNum].description;
subBoardInfo.numPosts = msgBase.total_msgs;
// Get the date & time when the last message was imported.
if (msgBase.total_msgs > 0)
{
msgHeader = msgBase.get_msg_header(true, msgBase.total_msgs-1, true);
if (this.msgAreaList_lastImportedMsg_showImportTime)
subBoardInfo.newestPostDate = msgHeader.when_imported_time
else
{
//subBoardInfo.newestPostDate = msgHeader.when_written_time;
var msgWrittenLocalTime = msgWrittenTimeToLocalBBSTime(msgHeader);
if (msgWrittenLocalTime != -1)
subBoardInfo.newestPostDate = msgWrittenTimeToLocalBBSTime(msgHeader);
else
subBoardInfo.newestPostDate = msgHeader.when_written_time;
}
}
}
msgBase.close();
subBoardArray.push(subBoardInfo);
}
// Free some memory?
delete msgBase;
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
// Possibly sort the sub-board list.
if (pSortType == "dateAsc")
{
subBoardArray.sort(function(pA, pB)
{
// Return -1, 0, or 1, depending on whether pA's date comes
// before, is equal to, or comes after pB's date.
var returnValue = 0;
if (pA.newestPostDate < pB.newestPostDate)
returnValue = -1;
else if (pA.newestPostDate > pB.newestPostDate)
returnValue = 1;
return returnValue;
});
}
else if (pSortType == "dateDesc")
{
subBoardArray.sort(function(pA, pB)
{
// Return -1, 0, or 1, depending on whether pA's date comes
// after, is equal to, or comes before pB's date.
var returnValue = 0;
if (pA.newestPostDate > pB.newestPostDate)
returnValue = -1;
else if (pA.newestPostDate < pB.newestPostDate)
returnValue = 1;
return returnValue;
});
}
else if (pSortType == "description")
{
// Binary safe string comparison
//
// version: 909.322
// discuss at: http://phpjs.org/functions/strcmp // + original by: Waldo Malqui Silva
// + input by: Steve Hilder
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + revised by: gorthaur
// * example 1: strcmp( 'waldo', 'owald' ); // * returns 1: 1
// * example 2: strcmp( 'owald', 'waldo' );
// * returns 2: -1
subBoardArray.sort(function(pA, pB)
{
return ((pA.description == pB.description) ? 0 : ((pA.description > pB.description) ? 1 : -1));
});
}
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
// Display the sub-board list.
for (var i = 0; i < subBoardArray.length; ++i)
{
console.crlf();
console.print((subBoardArray[i].subBoardNum == highlightIndex) ? "\1n" +
this.colors.areaChooserMsgAreaMarkColor + "*" : " ");
printf(this.subBoardListPrintfInfo[grpIndex].printfStr, +(subBoardArray[i].subBoardNum+1),
subBoardArray[i].description.substr(0, this.subBoardNameLen),
subBoardArray[i].numPosts, strftime("%Y-%m-%d", subBoardArray[i].newestPostDate),
strftime("%H:%M:%S", subBoardArray[i].newestPostDate));
}
}
// If no sort type is specified, then output the sub-board information in
// order of sub-board number.
else
{
for (var arrSubBoardNum in msg_area.grp_list[grpIndex].sub_list)
{
// Open the current sub-board with the msgBase object.
msgBase = new MsgBase(msg_area.grp_list[grpIndex].sub_list[arrSubBoardNum].code);
if (msgBase.open())
{
// Get the date & time when the last message was imported.
if (msgBase.total_msgs > 0)
{
msgHeader = msgBase.get_msg_header(true, msgBase.total_msgs-1, true);
// Construct the date & time strings of the latest post
if (this.msgAreaList_lastImportedMsg_showImportTime)
{
newestDate.date = strftime("%Y-%m-%d", msgHeader.when_imported_time);
newestDate.time = strftime("%H:%M:%S", msgHeader.when_imported_time);
}
else
{
//newestDate.date = strftime("%Y-%m-%d", msgHeader.when_written_time);
//newestDate.time = strftime("%H:%M:%S", msgHeader.when_written_time);
var msgWrittenLocalTime = msgWrittenTimeToLocalBBSTime(msgHeader);
if (msgWrittenLocalTime != -1)
{
newestDate.date = strftime("%Y-%m-%d", msgWrittenLocalTime);
newestDate.time = strftime("%H:%M:%S", msgWrittenLocalTime);
}
else
{
newestDate.date = strftime("%Y-%m-%d", msgHeader.when_written_time);
newestDate.time = strftime("%H:%M:%S", msgHeader.when_written_time);
}
}
}
else
newestDate.date = newestDate.time = "";
// Print the sub-board information
subBoardNum = +(arrSubBoardNum);
console.crlf();
console.print((subBoardNum == highlightIndex) ? "\1n" +
this.colors.areaChooserMsgAreaMarkColor + "*" : " ");
printf(this.subBoardListPrintfInfo[grpIndex].printfStr, +(subBoardNum+1),
msg_area.grp_list[grpIndex].sub_list[arrSubBoardNum].description.substr(0, this.subBoardListPrintfInfo[grpIndex].nameLen),
msgBase.total_msgs, newestDate.date, newestDate.time);
msgBase.close();
}
// Free some memory?
delete msgBase;
}
}
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
}
//////////////////////////////////////////////
// Message group list stuff (lightbar mode) //
//////////////////////////////////////////////
// Displays a screenful of message groups, for the lightbar interface.
//
// Parameters:
// pStartIndex: The message group index to start at (0-based)
// pStartScreenRow: The row on the screen to start at (1-based)
// pEndScreenRow: The row on the screen to end at (1-based)
// pClearScreenFirst: Boolean - Whether or not to clear the screen first
// pBlankToEndRow: Boolean - Whether or not to write blank lines to the end
// screen row if there aren't enough message groups to fill
// the screen.
function DigDistMsgReader_listScreenfulOfMsgGrps(pStartIndex, pStartScreenRow,
pEndScreenRow, pClearScreenFirst,
pBlankToEndRow)
{
// Check the parameters; If they're bad, then just return.
if ((typeof(pStartIndex) != "number") ||
(typeof(pStartScreenRow) != "number") ||
(typeof(pEndScreenRow) != "number"))
{
return;
}
if ((pStartIndex < 0) || (pStartIndex >= msg_area.grp_list.length))
return;
if ((pStartScreenRow < 1) || (pStartScreenRow > console.screen_rows))
return;
if ((pEndScreenRow < 1) || (pEndScreenRow > console.screen_rows))
return;
// If pStartScreenRow is greather than pEndScreenRow, then swap them.
if (pStartScreenRow > pEndScreenRow)
{
var temp = pStartScreenRow;
pStartScreenRow = pEndScreenRow;
pEndScreenRow = temp;
}
// Calculate the ending index to use for the message groups array.
var endIndex = pStartIndex + (pEndScreenRow-pStartScreenRow);
if (endIndex >= msg_area.grp_list.length)
endIndex = msg_area.grp_list.length - 1;
var onePastEndIndex = endIndex + 1;
// Clear the screen, go to the specified screen row, and display the message
// group information.
if (pClearScreenFirst)
console.clear("\1n");
console.gotoxy(1, pStartScreenRow);
var grpIndex = pStartIndex;
for (; grpIndex < onePastEndIndex; ++grpIndex)
{
this.WriteMsgGroupLine(grpIndex, false);
if (grpIndex < endIndex)
console.crlf();
}
// If pBlankToEndRow is true and we're not at the end row yet, then
// write blank lines to the end row.
if (pBlankToEndRow)
{
var screenRow = pStartScreenRow + (endIndex - pStartIndex) + 1;
if (screenRow <= pEndScreenRow)
{
for (; screenRow <= pEndScreenRow; ++screenRow)
{
console.gotoxy(1, screenRow);
console.clearline("\1n");
}
}
}
}
// For the DigDistMsgReader class - Writes a message group information line.
//
// Parameters:
// pGrpIndex: The index of the message group to write (assumed to be valid)
// pHighlight: Boolean - Whether or not to write the line highlighted.
function DigDistMsgReader_writeMsgGroupLine(pGrpIndex, pHighlight)
{
// TODO: If pHighlight is true, that causes the screen to be cleared
// and the line is written on the first row of the console.
console.print("\1n");
// Write the highlight background color if pHighlight is true.
if (pHighlight)
console.print(this.colors.areaChooserMsgAreaBkgHighlightColor);
// Write the message group information line
console.print(((typeof(bbs.curgrp) == "number") && (pGrpIndex == msg_area.sub[this.subBoardCode].grp_index)) ? this.colors.areaChooserMsgAreaMarkColor + "*" : " ");
printf((pHighlight ? this.msgGrpListHilightPrintfStr : this.msgGrpListPrintfStr),
+(pGrpIndex+1),
msg_area.grp_list[pGrpIndex].description.substr(0, this.msgGrpDescLen),
msg_area.grp_list[pGrpIndex].sub_list.length);
console.cleartoeol("\1n");
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
}
//////////////////////////////////////////////////
// Message sub-board list stuff (lightbar mode) //
//////////////////////////////////////////////////
// Updates the page number text in the group list header line on the screen.
//
// Parameters:
// pPageNum: The page number
// pNumPages: The total number of pages
// pGroup: Boolean - Whether or not this is for the group header. If so,
// then this will go to the right location for the group page text
// and use this.colors.areaChooserMsgAreaHeaderColor for the text.
// Otherwise, this will go to the right place for the sub-board page
// text and use the sub-board header color.
// pRestoreCurPos: Optional - Boolean - If true, then move the cursor back
// to the position where it was before this function was called
function DigDistMsgReader_updateMsgAreaPageNumInHeader(pPageNum, pNumPages, pGroup, pRestoreCurPos)
{
var originalCurPos = null;
if (pRestoreCurPos)
originalCurPos = console.getxy();
if (pGroup)
{
console.print("\1n" + this.colors.areaChooserMsgAreaHeaderColor + pPageNum + " of " +
pNumPages + ") ");
}
else
{
console.print("\1n" + this.colors.areaChooserSubBoardHeaderColor + pPageNum + " of " +
pNumPages + ") ");
}
if (pRestoreCurPos)
console.gotoxy(originalCurPos);