Commit 420a0797 authored by nightfox's avatar nightfox
Browse files

Version 1.26: Updated to use the absolute message number only on Synchronet >=...

Version 1.26: Updated to use the absolute message number only on Synchronet >= 3.16 from March 12, 2013 onward, since bbs.msg_number is valid only from that date forward.  For previous versions & builds of Synchronet, SlyEdit uses bbs.smb_curmsg, as before (although that can result in some incorrect message headers chosen for author initials in Scan For New Messages To You, resulting in incorrect initials used in message quoting).
parent 7c26f31b
......@@ -13,114 +13,21 @@
* 2009-08-22 Eric Oulashin Version 1.00
* Initial public release
* ....Removed some comments...
* 2012-12-21 Eric Oulashin Version 1.16
* Updated to look for the .cfg files first in
* the sbbs/ctrl directory, and if they're not
* found there, assume they're in the same
* directory as the .js files.
* 2012-12-23 Eric Oulashin Version 1.17 BETA
* Started working on updating the quoting style,
* to add the "To" user's initials or first 2
* letters of their username to the quote prefix.
* 2012-12-25 Eric Oulashin When reading quote lines, if a quote line
* contains only whitespace characters and/or >
* characters, it will make the line blank before
* adding it to gQuoteLines, to avoid weird
* issues when prefixing the quote lines.
* 2012-12-26 Eric Oulashin Version 1.17
* Updated printEditLine() to return the length of
* text actually written. Fixed a bug in
* displayMessageRectangle() that was causing some
* text lines not to be updated properly due to
* incorrectly calculating text lengths, etc.
* 2012-12-27 Eric Oulashin Version 1.17
* Bug fix: If the useQuoteLineInitials setting is
* enabled but the reWrapQuoteLines setting was
* disabled, it wasn't quoting lines; this has been
* fixed.
* Even though I had released v1.17 yesterday,
* it appeared that nobody had downloaded it yet,
* so I'm still calling this v1.17.
* 2012-12-27 Eric Oulashin Version 1.18 beta
* Bug fix: When wrapping text lines while prefixing
* the lines with initials, if wrapping a section
* resulted in adding more lines, it wasn't properly
* adding a > to the last line of the section to
* indicate one more level of quoting. This has
* been fixed.
* 2012-12-28 Eric Oulashin Version 1.18 beta 3
* Updated to use the new configuration setting
* gConfigSettings.indentQuoteLinesWithInitials
* to determine whether to prefix quote lines with
* a space if using author's initials in quote lines.
* 2012-12-30 Eric Oulashin Version 1.18 beta 4
* Updated so that when replying to a message
* in a public sub-board, it will use the
* message's "From" name, read from the message
* database, rather than the given "To" name,
* for the author's initials. That way, if a
* user changes the "To" name before replying to
* a message, the correct initials will be used.
* 2012-12-31 Eric Oulashin Version 1.18 (final)
* Releasing this version today, as testing has
* shown that it's working well and as intended.
* 2013-01-02 Eric Oulashin Version 1.19
* Fixed a bug where reading low-numbered messages
* in a sub-board would result in getting the
* incorrect original author name. Updated
* getFromNameForCurMsg() in SlyEdit_Misc.js
* to just use the sub-board code and message
* offset to get the header for the current
* message being read.
* 2013-01-13 Eric Oulashin Version 1.20 beta
* Started working on adding the ability to
* cross-post to different message areas.
* Started with the UI, selecting the message
* group.
* 2013-01-25 Eric Oulashin Have still been making small changes to support
* cross-posting.
* 2013-01-31 Eric Oulashin Version 1.20
* Cross-posting & other udpates appear to be
* working well and as expected, so releasing
* this version now.
* 2013-02-03 Eric Oulashin Version 1.21
* Bug fixes related to cross-posting:
* - Posting during newscan: The message telling
* which sub-board the message was posted in
* was incorrect if different from the user's
* current sub-board; this was fixed.
* - Now includes the user's signature when cross-posting
* 2013-02-08 Eric Oulashin Version 1.22
* Bug fix: When replying to a personal email
* or netmail, now uses the correct author's
* initials in quote lines.
* 2013-02-13 Eric Oulashin Version 1.23
* Bug fix: If the user doesn't have a current
* message sub-board (i.e., a new user applying
* for access), SlyEdit now uses the first sub-board
* that the user can post into. This avoids crashes
* due to JavaScript errors.
* 2013-02-17 Eric Oulashin Version 1.24
* Bug fix: If the user is posting a new message
* on a sub-board, SlyEdit now should have the
* correct sub-board info, even if the user is posting
* on a different sub-board than the one they're
* currently set for reading.
* Also, defaulted the option for indenting quote
* lines with initials to true.
* 2013-05-10 Eric Oulashin Version 1.25 beta
* Started working on more reliably getting the
* message headers to correctly get author
* initials in all cases when replying to messages.
* 2013-05-14 Eric OUlashin Version 1.25
* Updated to use bbs.msg_number instead of message
* indexes so that the correct message header (for
* retrieval of author initials) is correct in all
* cases, including when replying to messages during
* "Scan for messages to you":
* In SlyEdit_Misc.js, updated getCurMsgInfo() and
* getFromNameForCurMsg() to use the absolute message
* number (bbs.msg_number) rather than messages indexes.
* 2013-05-16 Eric Oulashin Version 1.26 beta
* Fix for getting author initials for quote lines:
* Updated to use bbs.msg_number only for Synchronet
* 3.16 builds starting on May 12, 2013 and to use
* bbs.smb_curmsg before that build date. May 12,
* 2013 was right after Digital Man put in his change
* to make bbs.msg_number work in JavaScript scripts,
* and it's accurate in all situations.
* 2013-05-17 Eric Oulashin Version 1.26
* Made another change to make sure the call
* to bbs.get_msg_header() in getFromNameForCurMsg()
* in SlyEdit_Misc.js had the correct first parameter
* to specify whether the message number is an
* offset. Released as version 1.26 after some
* testing.
*/
/* Command-line arguments:
......@@ -193,8 +100,8 @@ if (!console.term_supports(USER_ANSI))
}
// Constants
const EDITOR_VERSION = "1.25";
const EDITOR_VER_DATE = "2013-05-14";
const EDITOR_VERSION = "1.26";
const EDITOR_VER_DATE = "2013-05-17";
// Program variables
......
......@@ -86,6 +86,12 @@
* the correct message header in all cases, including
* when replying to messages during "Scan for messages
* to you".
* 2013-05-16 Eric Oulashin Added compileDateAtLeast2013_05_12(), which
* returns whether the Synchronet compile date is at
* least May 12, 2013. That was when Digital Man's
* change to make bbs.msg_number work when a script
* is running first went into the Synchronet daily
* builds.
*/
// Note: These variables are declared with "var" instead of "const" to avoid
......@@ -180,6 +186,11 @@ var CTRL_Y = "\x19";
var CTRL_Z = "\x1a";
var KEY_ESC = "\x1b";
// Store whether the Synchronet compile date is at least May 12, 2013
// (we'll need to know this multiple times, and I don't want to run the
// function more than once).
var gCompileDateAtLeast2013_05_12 = compileDateAtLeast2013_05_12();
///////////////////////////////////////////////////////////////////////////////////
// Object/class stuff
......@@ -1939,7 +1950,13 @@ function wrapQuoteLines(pUseAuthorInitials, pIndentQuoteLinesWithInitials)
// Returns an object containing the following properties:
// lastMsg: The last message in the sub-board (i.e., bbs.smb_last_msg)
// totalNumMsgs: The total number of messages in the sub-board (i.e., bbs.smb_total_msgs)
// curMsgNum: The absolute number of the current message being read (i.e., bbs.msg_number)
// curMsgNum: The number/index of the current message being read. Starting
// with Synchronet 3.16 on May 12, 2013, this is the absolute
// message number (bbs.msg_number). For Synchronet builds before
// May 12, 2013, this is bbs.smb_curmsg. Starting on May 12, 2013,
// bbs.msg_number is preferred because it works properly in all
// situations, whereas in earlier builds, bbs.msg_number was
// always given to JavaScript scripts as 0.
// subBoardCode: The current sub-board code (i.e., bbs.smb_sub_code)
// grpIndex: The message group index for the sub-board
//
......@@ -1947,7 +1964,7 @@ function wrapQuoteLines(pUseAuthorInitials, pIndentQuoteLinesWithInitials)
// DDML_SyncSMBInfo.txt in the node directory (written by the Digital
// Distortion Message Lister v1.31 and higher). If that file can't be read,
// the values will default to the values of bbs.smb_last_msg,
// bbs.smb_total_msgs, and bbs.msg_number.
// bbs.smb_total_msgs, and bbs.msg_number/bbs.smb_curmsg.
//
// Parameters:
// pMsgAreaName: The name of the message area being posted to
......@@ -1958,8 +1975,16 @@ function getCurMsgInfo(pMsgAreaName)
{
retObj.lastMsg = bbs.smb_last_msg;
retObj.totalNumMsgs = bbs.smb_total_msgs;
//retObj.curMsgNum = bbs.smb_curmsg; // OLD!
retObj.curMsgNum = bbs.msg_number; // New (2013-05-14)
// If the Synchronet version is at least 3.16 and the Synchronet compile
// date is at least May 12, 2013, then use bbs.msg_number. Otherwise,
// use bbs.smb_curmsg. bbs.msg_number is the absolute message number and
// is always accurate, but bbs.msg_number only works properly in the
// Synchronet 3.16 daily builds starting on May 12, 2013, which was right
// after Digital Man committed his fix to make bbs.msg_number work properly.
if ((system.version_num >= 3.16) && gCompileDateAtLeast2013_05_12)
retObj.curMsgNum = bbs.msg_number; // New (2013-05-14)
else
retObj.curMsgNum = bbs.smb_curmsg; // For older Synchronet builds
retObj.subBoardCode = bbs.smb_sub_code;
retObj.grpIndex = msg_area.sub[bbs.smb_sub_code].grp_index;
}
......@@ -2124,10 +2149,17 @@ function getFromNameForCurMsg(pMsgInfo)
if (msgBase != null)
{
msgBase.open();
// First parameter is false because we're not passing the message
// number by offset, we're passing the absolute message number
// (i.e., from bbs.msg_number) rather than the message offset.
var hdr = msgBase.get_msg_header(false, msgInfo.curMsgNum, true);
// The first parameter to msgBase.get_msg_header() is whether the message
// number is an offset. We only want to use offsets for Synchronet builds
// before May 12, 2013. On May 12, 2013, bbs.msg_number (the absolute
// message number/ID) was made to work for JavaScript scripts so it was
// no longer 0 all the time. Since bbs.msg_number always gets the
// correct message header in all cases, that's the preferred method, but
// we can only use that for Synchronet 3.16 and above from at least May
// 12, 2013.
//var msgNumAsOffset = !((system.version_num >= 3.16) && gCompileDateAtLeast2013_05_12);
var msgNumAsOffset = ((system.version_num < 3.16) || !gCompileDateAtLeast2013_05_12);
var hdr = msgBase.get_msg_header(msgNumAsOffset, msgInfo.curMsgNum, true);
if (hdr != null)
fromName = hdr.from;
msgBase.close();
......@@ -2320,6 +2352,68 @@ function getFirstPostableSubInfo()
return retObj;
}
// Returns whether the Synchronet compile date is at least May 12, 2013. That
// was when Digital Man's change to make bbs.msg_number work when a script is
// running first went into the Synchronet daily builds.
function compileDateAtLeast2013_05_12()
{
// system.compiled_when is in the following format:
// May 12 2013 05:02
var compileDateParts = system.compiled_when.split(" ");
if (compileDateParts.length < 4)
return false;
// Convert the month to a 1-based number
var compileMonth = 0;
if (/^Jan/.test(compileDateParts[0]))
compileMonth = 1;
else if (/^Feb/.test(compileDateParts[0]))
compileMonth = 2;
else if (/^Mar/.test(compileDateParts[0]))
compileMonth = 3;
else if (/^Apr/.test(compileDateParts[0]))
compileMonth = 4;
else if (/^May/.test(compileDateParts[0]))
compileMonth = 5;
else if (/^Jun/.test(compileDateParts[0]))
compileMonth = 6;
else if (/^Jul/.test(compileDateParts[0]))
compileMonth = 7;
else if (/^Aug/.test(compileDateParts[0]))
compileMonth = 8;
else if (/^Sep/.test(compileDateParts[0]))
compileMonth = 9;
else if (/^Oct/.test(compileDateParts[0]))
compileMonth = 10;
else if (/^Nov/.test(compileDateParts[0]))
compileMonth = 11;
else if (/^Dec/.test(compileDateParts[0]))
compileMonth = 12;
// Get the compileDay and compileYear as numeric variables
var compileDay = +compileDateParts[1];
var compileYear = +compileDateParts[2];
// Determine if the compile date is at least 2013-05-12
var compileDateIsAtLeastMin = true;
if (compileYear > 2013)
compileDateIsAtLeastMin = true;
else if (compileYear < 2013)
compileDateIsAtLeastMin = false;
else // compileYear is 2013
{
if (compileMonth > 5)
compileDateIsAtLeastMin = true
else if (compileMonth < 5)
compileDateIsAtLeastMin = false;
else // compileMonth is 5
compileDateIsAtLeastMin = (compileDay >= 12);
}
return compileDateIsAtLeastMin;
}
// This function displays debug text at a given location on the screen, then
// moves the cursor back to a given location.
//
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment