Newer
Older
20001
20002
20003
20004
20005
20006
20007
20008
20009
20010
20011
20012
20013
20014
20015
20016
20017
20018
20019
20020
20021
20022
20023
20024
20025
20026
20027
20028
20029
20030
20031
20032
20033
20034
20035
20036
20037
20038
20039
20040
20041
20042
20043
20044
20045
20046
20047
20048
20049
20050
20051
20052
20053
20054
20055
20056
20057
20058
20059
20060
20061
20062
20063
20064
20065
20066
20067
20068
20069
20070
20071
20072
20073
20074
20075
20076
20077
20078
20079
20080
20081
20082
20083
20084
topIdx = endIdx;
}
} while (continueOn);
return retObj;
}
// Finds the page number of a message group or sub-board, given some text to
// search for.
//
// Parameters:
// pText: The text to search for in the items
// pNumItemsPerPage: The number of items per page
// pSubBoard: Boolean - If true, search the sub-board list for the given group index.
// If false, search the group list.
// pStartItemIdx: The item index to start at
// pGrpIdx: The index of the group to search in (only for doing a sub-board search)
//
// Return value: An object containing the following properties:
// pageNum: The page number of the item (1-based; will be 0 if not found)
// pageTopIdx: The index of the top item on the page (or -1 if not found)
// itemIdx: The index of the item (or -1 if not found)
function getMsgAreaPageNumFromSearch(pText, pNumItemsPerPage, pSubBoard, pStartItemIdx, pGrpIdx)
{
var retObj = {
pageNum: 0,
pageTopIdx: -1,
itemIdx: -1
};
// Sanity checking
if ((typeof(pText) != "string") || (typeof(pNumItemsPerPage) != "number") || (typeof(pSubBoard) != "boolean"))
return retObj;
// Convert the text to uppercase for case-insensitive searching
var srchText = pText.toUpperCase();
if (pSubBoard)
{
if ((typeof(pGrpIdx) == "number") && (pGrpIdx >= 0) && (pGrpIdx < msg_area.grp_list.length))
{
// Go through the sub-board list of the given group and
// search for text in the descriptions
for (var i = pStartItemIdx; i < msg_area.grp_list[pGrpIdx].sub_list.length; ++i)
{
if ((msg_area.grp_list[pGrpIdx].sub_list[i].description.toUpperCase().indexOf(srchText) > -1) ||
(msg_area.grp_list[pGrpIdx].sub_list[i].name.toUpperCase().indexOf(srchText) > -1))
{
retObj.itemIdx = i;
// Figure out the page number and top index for the page
var pageObj = calcPageNumAndTopPageIdx(i, pNumItemsPerPage);
if ((pageObj.pageNum > 0) && (pageObj.pageTopIdx > -1))
{
retObj.pageNum = pageObj.pageNum;
retObj.pageTopIdx = pageObj.pageTopIdx;
}
break;
}
}
}
}
else
{
// Go through the message group list and look for a match
for (var i = pStartItemIdx; i < msg_area.grp_list.length; ++i)
{
if ((msg_area.grp_list[i].name.toUpperCase().indexOf(srchText) > -1) ||
(msg_area.grp_list[i].description.toUpperCase().indexOf(srchText) > -1))
{
retObj.itemIdx = i;
// Figure out the page number and top index for the page
var pageObj = calcPageNumAndTopPageIdx(i, pNumItemsPerPage);
if ((pageObj.pageNum > 0) && (pageObj.pageTopIdx > -1))
{
retObj.pageNum = pageObj.pageNum;
retObj.pageTopIdx = pageObj.pageTopIdx;
}
break;
}
}
}
return retObj;
}
// For debugging: Writes some text on the screen at a given location with a given pause.
//
// Parameters:
// pX: The column number on the screen at which to write the message
// pY: The row number on the screen at which to write the message
// pText: The text to write
// pPauseMS: The pause time, in milliseconds
// pClearLineAttrib: Optional - The color/attribute to clear the line with.
// If not specified or null is specified, defaults to normal attribute.
// pClearLineAfter: Whether or not to clear the line again after the message is dispayed and
// the pause occurred. This is optional.
function writeWithPause(pX, pY, pText, pPauseMS, pClearLineAttrib, pClearLineAfter)
{
var clearLineAttrib = "\1n";
if ((pClearLineAttrib != null) && (typeof(pClearLineAttrib) == "string"))
clearLineAttrib = pClearLineAttrib;
console.gotoxy(pX, pY);
console.cleartoeol(clearLineAttrib);
console.print(pText);
if (pPauseMS > 0)
mswait(pPauseMS);
if (pClearLineAfter)
{
console.gotoxy(pX, pY);
console.cleartoeol(clearLineAttrib);
}