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
// Find start & end indexes of a @MSG_TO* @-code, i.e.,
// @MSG_TO, @MSG_TO_NAME, @MSG_TO_EXT, @MSG_TO_NET
var toCodeStartIdx = pStr.indexOf("@MSG_TO");
if (toCodeStartIdx < 0)
return pStr;
// Insert the color in the right position and return the line
return pStr.substr(0, toCodeStartIdx) + "\1n" + pToUserColor + pStr.substr(toCodeStartIdx) + "\1n";
/*
// Insert the color in the right position, and
// put a \1n right after the end of the @-code
var str = "";
var toCodeEndIdx = pStr.indexOf("@", toCodeStartIdx+1);
if (toCodeEndIdx >= 0)
{
str = pStr.substr(0, toCodeStartIdx) + "\1n" + pToUserColor + pStr.substr(toCodeStartIdx, toCodeEndIdx-toCodeStartIdx+1)
+ "\1n" + pStr.substr(toCodeEndIdx);
}
else
str = pStr.substr(0, toCodeStartIdx) + "\1n" + pToUserColor + pStr.substr(toCodeStartIdx) + "\1n";
return str;
*/
}
// Returns whether a string has any Synchronet attribute codes
//
// Parameters:
// pStr: the string to check
//
// Return value: Boolean - Whether or not the string has any Synchronet attribute codes
function hasSyncAttrCodes(pStr)
{
return (pStr.search(/\1[krgybmcwhifn\-_01234567]/i) > -1);
}
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
// Gets the value of the user's current scan_ptr in a sub-board, or if it's
// 0xffffffff, returns the message number of the last readable message in
// the sub-board (this is the message number, not the index).
//
// Parameters:
// pSubCode: A sub-board internal code
//
// Return value: The user's scan_ptr value or the message number of the
// last readable message in the sub-board
function GetScanPtrOrLastMsgNum(pSubCode)
{
var msgNumToReturn = 0;
// If pMsgNum is 4294967295 (0xffffffff, or ~0), that is a special value
// for the user's scan_ptr meaning it should point to the latest message
// in the messagebase.
if (msg_area.sub[pSubCode].scan_ptr != 0xffffffff)
msgNumToReturn = msg_area.sub[pSubCode].scan_ptr;
else
{
var msgbase = new MsgBase(pSubCode);
if (msgbase.open())
{
var numMsgs = msgbase.total_msgs;
for (var msgIdx = numMsgs - 1; msgIdx >= 0; --msgIdx)
{
var msgHdr = msgbase.get_msg_header(true, msgIdx);
if ((msgHdr != null) && ((msgHdr.attr & MSG_DELETE) == 0))
{
msgNumToReturn = msgHdr.number;
break;
}
}
msgbase.close();
}
}
return msgNumToReturn;
}
20076
20077
20078
20079
20080
20081
20082
20083
20084
20085
20086
20087
20088
20089
20090
20091
20092
20093
20094
20095
20096
20097
20098
20099
20100
20101
20102
20103
20104
20105
20106
20107
20108
20109
20110
20111
20112
20113
20114
20115
20116
20117
20118
20119
20120
20121
20122
20123
20124
20125
20126
20127
20128
20129
20130
20131
20132
20133
20134
20135
20136
20137
20138
20139
20140
20141
20142
20143
20144
20145
20146
20147
20148
20149
20150
20151
20152
20153
20154
20155
20156
20157
20158
20159
20160
20161
20162
20163
20164
20165
20166
20167
20168
20169
20170
20171
20172
20173
20174
20175
20176
20177
20178
20179
20180
20181
20182
20183
20184
20185
20186
20187
20188
20189
20190
20191
20192
20193
20194
20195
20196
20197
20198
20199
20200
20201
20202
20203
20204
20205
20206
20207
20208
20209
20210
20211
20212
20213
20214
20215
20216
20217
20218
20219
20220
// Returns whether a message header has one of the attachment flags
// enabled (for Synchtonet 3.17 or newer).
//
// Parameters:
// pMsgHdr: A message header (returned from MsgBase.get_msg_header())
//
// Return value: Boolean - Whether or not the message has one of the attachment flags
function msgHdrHasAttachmentFlag(pMsgHdr)
{
if (typeof(pMsgHdr) !== "object" || typeof(pMsgHdr.auxattr) === "undefined")
return false;
var attachmentFlag = false;
if (typeof(MSG_FILEATTACH) !== "undefined" && typeof(MSG_MIMEATTACH) !== "undefined")
attachmentFlag = (pMsgHdr.auxattr & (MSG_FILEATTACH|MSG_MIMEATTACH)) > 0;
return attachmentFlag;
}
// Allows the user to download a message and its attachments, using the newer
// Synchronet interface (the function bbs.download_msg_attachments() must exist).
//
// Parameters:
// pMsgHdr: The message header
// pSubCode: The sub-board code that the message is in
function allowUserToDownloadMessage_NewInterface(pMsgHdr, pSubCode)
{
if (typeof(bbs.download_msg_attachments) !== "function")
return;
if (typeof(pSubCode) !== "string")
return;
if (typeof(pMsgHdr) !== "object" || typeof(pMsgHdr.number) == "undefined")
return;
var msgBase = new MsgBase(pSubCode);
if (msgBase.open())
{
// bbs.download_msg_attachments() requires a message header returned
// by MsgBase.get_msg_header()
var msgHdrForDownloading = msgBase.get_msg_header(false, pMsgHdr.number, false);
// Allow the user to download the message
if (!console.noyes("Download message", P_NOCRLF))
{
if (!download_msg(msgHdrForDownloading, msgBase, console.yesno("Plain-text only")))
console.print("\1n\r\nFailed\r\n");
}
// Allow the user to download the attachments
console.creturn();
bbs.download_msg_attachments(msgHdrForDownloading);
msgBase.close();
delete msgBase; // Free some memory?
}
}
// From msglist.js - Prompts the user if they want to download the message text
function download_msg(msg, msgbase, plain_text)
{
var fname = system.temp_dir + "msg_" + msg.number + ".txt";
var f = new File(fname);
if(!f.open("wb"))
return false;
var text = msgbase.get_msg_body(msg
,/* strip ctrl-a */false
,/* dot-stuffing */false
,/* tails */true
,plain_text);
f.write(msg.get_rfc822_header(/* force_update: */false, /* unfold: */false
,/* default_content_type */!plain_text));
f.writeln(text);
f.close();
return bbs.send_file(fname);
}
////////// Message list sort functions
// For sorting message headers by date & time
//
// Parameters:
// msgHdrA: The first message header
// msgHdrB: The second message header
//
// Return value: -1, 0, or 1, depending on whether header A comes before,
// is equal to, or comes after header B
function sortMessageHdrsByDateTime(msgHdrA, msgHdrB)
{
// Return -1, 0, or 1, depending on whether msgHdrA's date & time comes
// before, is equal to, or comes after msgHdrB's date & time
// Convert when_written_time to local time before comparing the times
var localWrittenTimeA = msgWrittenTimeToLocalBBSTime(msgHdrA);
var localWrittenTimeB = msgWrittenTimeToLocalBBSTime(msgHdrB);
var yearA = +strftime("%Y", localWrittenTimeA);
var monthA = +strftime("%m", localWrittenTimeA);
var dayA = +strftime("%d", localWrittenTimeA);
var hourA = +strftime("%H", localWrittenTimeA);
var minuteA = +strftime("%M", localWrittenTimeA);
var secondA = +strftime("%S", localWrittenTimeA);
var yearB = +strftime("%Y", localWrittenTimeB);
var monthB = +strftime("%m", localWrittenTimeB);
var dayB = +strftime("%d", localWrittenTimeB);
var hourB = +strftime("%H", localWrittenTimeB);
var minuteB = +strftime("%M", localWrittenTimeB);
var secondB = +strftime("%S", localWrittenTimeB);
if (yearA < yearB)
return -1;
else if (yearA > yearB)
return 1;
else
{
if (monthA < monthB)
return -1;
else if (monthA > monthB)
return 1;
else
{
if (dayA < dayB)
return -1;
else if (dayA > dayB)
return 1;
else
{
if (hourA < hourB)
return -1;
else if (hourA > hourB)
return 1;
else
{
if (minuteA < minuteB)
return -1;
else if (minuteA > minuteB)
return 1;
else
{
if (secondA < secondB)
return -1;
else if (secondA > secondB)
return 1;
else
return 0;
}
}
}
}
}
}
Eric Oulashin
committed
20221
20222
20223
20224
20225
20226
20227
20228
20229
20230
20231
20232
20233
20234
20235
20236
20237
20238
20239
20240
20241
20242
20243
20244
20245
20246
20247
20248
// Returns an array of internal sub-board codes to scan for a given scan scope.
//
// Parameters:
// pScanScopeChar: A string specifying "A" for all sub-boards, "G" for current
// message group sub-boards, or "S" for the current sub-board
//
// Return value: An array of internal sub-board codes for sub-boards to scan
function getSubBoardsToScanArray(pScanScopeChar)
{
var subBoardsToScan = [];
if (pScanScopeChar == "A") // All sub-board scan
{
for (var grpIndex = 0; grpIndex < msg_area.grp_list.length; ++grpIndex)
{
for (var subIndex = 0; subIndex < msg_area.grp_list[grpIndex].sub_list.length; ++subIndex)
subBoardsToScan.push(msg_area.grp_list[grpIndex].sub_list[subIndex].code);
}
}
else if (pScanScopeChar == "G") // Group scan
{
for (var subIndex = 0; subIndex < msg_area.grp_list[bbs.curgrp].sub_list.length; ++subIndex)
subBoardsToScan.push(msg_area.grp_list[bbs.curgrp].sub_list[subIndex].code);
}
else if (pScanScopeChar == "S") // Current sub-board scan
subBoardsToScan.push(bbs.cursub_code);
return subBoardsToScan;
}
// 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);
}