Skip to content

Commit 10fb7ed

Browse files
committed
Fixed #172 and #173
2 parents 734be47 + b6efc98 commit 10fb7ed

7 files changed

Lines changed: 488 additions & 304 deletions

File tree

ddoc2.js

Lines changed: 73 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* contributing/refactoring also by: @Ntwitch (github.com)
77
* started: 18aug14
88
* alpha phase: 25oct14
9-
* beta phase: 10mar14
9+
* beta phase:
1010
* finished:
1111
*
1212
* a slightly more organized attempt to emulate the DOC shell from
@@ -28,7 +28,7 @@ load("/sbbs/exec/load/nodedefs.js");
2828
//pseudo-globals
2929
const excuse = "\n\nThe rothe strikes! You die!. . .\n\n",
3030
debugOnly = false, topebaseno = 6,
31-
alwaysLogout = false, std_logging = true;
31+
alwaysLogout = false, std_logging = true, maxMsgs = 500;
3232

3333
//a few easier hooks for the ctrl-a codes
3434
const ctrl_a = "\1";
@@ -46,14 +46,15 @@ var stillAlive = true; //ask for advice on the 'right' way to do this
4646
userSettings = null; roomSettings = { }; zappedRooms = null;
4747

4848
/*
49-
* obviously, with all of the other places that we've got debugging
50-
* referenced, we need to go around and make them dependent upon this,
51-
* even before we start introducing granularity into the whole mixture
49+
* summary:
50+
* Top level object for globals and primary program control flow/menu
5251
*/
53-
5452
docIface = {
5553
//top level menu
56-
//menu properties
54+
/*
55+
* summary:
56+
* Top-level menu contained within a string
57+
*/
5758
menu : green + high_intensity +
5859
//$ctrl_a + "g" + "\n" + "<A>\tSysop commands\n" +
5960
"\n\n<B>\tChange eXpress beeps\n<b>\tRead forum backward\n" +
@@ -75,6 +76,10 @@ docIface = {
7576
"number\n<->\tread last n messages\n<%>\ttoggle guideflag " +
7677
"status\n<@>\taidelist\n<\">\tquote Xes to Sysop\n" +
7778
"<$>\tchange debugging settings\n\n",
79+
/*
80+
* summary:
81+
* Save text prompt
82+
*/
7883
sprompt : high_intensity + yellow + "<A>" + green + "bort " +
7984
yellow + "<C>" + green + "ontinue " + yellow + "<P>" +
8085
green + "rint " + yellow + "<S>" + green + "ave " + yellow +
@@ -91,8 +96,6 @@ docIface = {
9196
* the exception message
9297
* setnum:
9398
* exception number
94-
* toString():
95-
* Used for returning a concise message on the exception
9699
*/
97100
dDocException : function(setname, setmsg, setnum) {
98101
this.name = setname;
@@ -118,25 +121,15 @@ docIface = {
118121
}
119122
bbs.node_action = nodeAction;
120123
system.node_list[bbs.node_num - 1].action = bbs.node_action;
121-
122-
/* for (var ouah = 0; ouah < maxnodes; ouah++) {
123-
if (userSettings.debug.misc) {
124-
console.putmsg(red + high_intensity + ouah + " ");
125-
}
126-
if (system.node_list[ouah].useron == user.number) {
127-
if (userSettings.debug.misc) {
128-
console.putmsg(yellow + "Hit! Trying to set status\n");
129-
}
130-
system.node_list[ouah].action = nodeAction;
131-
break;
132-
}
133-
} */
134124
},
135125
/*
136126
* summary:
137-
* Just a wrapper for console.getkey() at this point. I honestly can't
138-
* remember why I did this now; leaving it in case I remember
139-
* returns:
127+
* Just a wrapper for console.getkey() at this point. This is utilized for
128+
* any prompting situation where we want to be able to make sure that we're
129+
* going to receive any X messages (or telegrams/messages or other inter-
130+
* node communication) while the prompt is waiting for something from the
131+
* user
132+
* return:
140133
* Unmodified return value from console.getkey()
141134
*/
142135
getChoice : function() {
@@ -157,7 +150,10 @@ docIface = {
157150
* String value
158151
* key:
159152
* Character value
160-
* returns: nonzero on error
153+
*
154+
* NOTE: This might be broken in some areas; as I was doing the documentation
155+
* pass I decided to change this one to throw an exception on error and
156+
* ditch the return codes since it was so rudimentary
161157
*/
162158
log_str_n_char : function(str, key) {
163159
try {
@@ -166,14 +162,17 @@ docIface = {
166162
} catch (e) {
167163
system.log("TTBBS Error " + e.description +
168164
" when trying to save str+key to log");
169-
return -1;
165+
throw new dDocException("log_str_n_char() Error", e.message, 1);
170166
}
171167

172-
return 0;
168+
//return 0;
173169
},
174170
/*
175171
* summary:
176172
* Simply displays the docIface top level property 'menu'
173+
* NOTE:
174+
* See the commented out area where things need to be fixed in order to
175+
* implement pausing (I think that's what it was working with, anyway)
177176
*/
178177
doMainMenu : function() {
179178
bbs.log_key("?");
@@ -199,7 +198,6 @@ docIface = {
199198

200199
//console.putmsg(this.menu);
201200
},
202-
203201
//sub-objects
204202
nav : {
205203
/*
@@ -209,7 +207,7 @@ docIface = {
209207
* room:
210208
* The msg_area.grp_list[].sub_list[] element of the room to jump
211209
* to
212-
* returns:
210+
* return:
213211
* String of the human-readable sub name.
214212
*/
215213
setSub : function(room) {
@@ -231,7 +229,7 @@ docIface = {
231229
* Scans through known rooms (not zapped) starting from
232230
* the current room and looks for new messages. If new messages
233231
* are found, call setSub to point the user at the room.
234-
* returns:
232+
* return:
235233
* sub-board object if new messages were found
236234
* null if no new messages were found
237235
*/
@@ -377,6 +375,9 @@ docIface = {
377375
* summary:
378376
* Mark all messages as read in the current room and
379377
* call findNew() to change to the next room with unread messages
378+
* NOTE:
379+
* skip() should _NOT_ mark all messages in the current room as
380+
* read; it should just skip to the next room in the list
380381
*/
381382
skip: function () {
382383
// mark all messages as read in current room
@@ -398,10 +399,9 @@ docIface = {
398399
* sub-boards
399400
* srchStr:
400401
* Substring to search for
401-
* returns:
402-
* The object for the sub-board if a match, null if rList
403-
* doesn't come back decently, -1 if no match is found
404-
* within a valid list
402+
* return:
403+
* The object for the sub-board if a match, exceptions are thrown
404+
* on appropriate error conditions
405405
*/
406406
chk4Room : function (srchStr) {
407407
var rList = docIface.util.getRoomList(true);
@@ -425,6 +425,7 @@ docIface = {
425425
throw new dDocException("chk4Room() exception", "No match", 2);
426426
}
427427
},
428+
//sub-object
428429
util : {
429430
// --++==**properties**==++--
430431
preSubBoard : null,
@@ -438,10 +439,13 @@ docIface = {
438439
* not being confined is expanded. Also, this may be
439440
* useful in the future for listKnown() and other routines
440441
* in dmbase.js that are recreating the wheel a bit
441-
* returns:
442+
* return:
442443
* As I redundantly and out-of-proper-orderly mentioned
443444
* above, it returns an array of sub-board objects
444-
* If running non-confined, returns null
445+
* If running non-confined, returns null. When this feature is
446+
* finally ready to be implemented, it might be necessary to return
447+
* some sort of JSON or list of arrays in order to handle the
448+
* deeper data structure than we're currently utilizing
445449
*/
446450
getRoomList : function(/*in the future, group here too*/) {
447451
//var debugging = true;
@@ -455,7 +459,7 @@ docIface = {
455459
}
456460
return msg_area.grp_list[topebaseno].sub_list;
457461
} else {
458-
return null;
462+
return null; //ereh
459463
}
460464
},
461465
/*
@@ -477,21 +481,9 @@ docIface = {
477481
console.putmsg(red + e.toString() + "\n");
478482
}
479483

480-
//load room settings
484+
//load room settings -- WHAT THE FUCK IS GOING ON WITH THE NESTED TRY/
485+
//CATCH BULLSHIT HERE? Vestigial horror no doubt; fix this
481486
try {
482-
/*if (userSettings.debug.file_io) {
483-
console.putmsg(cyan + "Looking for room info file: " +
484-
roomData.fileIO.roomRecFilename + "\n"); //why no workee? 8o|
485-
} //this should be "/sbbs/data/user/docrooms", but more than that
486-
//it should be working correctly from w/in proper references WTF
487-
488-
for each(var area in msg_area.grp_list[topebaseno].code) {
489-
roomSettings[area] = roomData.fileIO.snagRoomInfoBlob(
490-
"/sbbs/data/user/docrooms",
491-
//roomData.fileIO.roomRecFilename,
492-
area);
493-
}*/
494-
495487
try {
496488
roomData.fileIO.snagRoomInfoBlob();
497489
} catch (e) {
@@ -586,7 +578,11 @@ docIface = {
586578
* ddoc, in order to restore functionality to where it was
587579
* left off for somebody that may be jumping between
588580
* shells, or the like. As mentioned above; this may be
589-
* out of scope and needing a better solution.
581+
* out of scope and needing a better solution. For some reason
582+
* this also refuses to work properly when not called from the
583+
* lowest-level primary menu; not sure what's up with that, Digital
584+
* Man just referred me to logout.c or something and I couldn't
585+
* make heads or tails of it just yet
590586
*/
591587
quitDdoc : function() {
592588
bbs.log_str(user.alias + " is leaving dDOC shell");
@@ -617,14 +613,17 @@ docIface = {
617613
"again soon!\n\nPeace out!\n");
618614

619615
bbs.logout();
620-
return;
621616
},
622617
/*
623618
* summary:
624619
* Searches the correct file in /sbbs/user for the proper
625620
* block of information regarding the current sub/room and
626621
* displays that information with proper DOC-ish heading
627622
* information.
623+
* NOTE:
624+
* I believe this is completely vestigial at this point; need to
625+
* run through and verify before removing it. This should all be
626+
* handled from within dperroom's code right now, though.
628627
*/
629628
dispRoomInfo : function() {
630629
bbs.log_key("I");
@@ -691,17 +690,15 @@ if (!debugOnly) {
691690

692691
console.putmsg("\n" + dprompt);
693692
uchoice = docIface.getChoice();
694-
//poor aliasing
695-
if (uchoice == ' ') {
696-
uchoice = 'n';
697-
}
698693

699694
switch (uchoice) {
700695
//top menu
701696
case '?':
702697
docIface.doMainMenu();
703698
break;
704699
//message base entry commands
700+
case ' ':
701+
uchoice = 'n';
705702
case 'b':
706703
case 'e':
707704
case 'E':
@@ -819,6 +816,24 @@ if (!debugOnly) {
819816
roomData.tieIns.zapRoom(bbs.cursub);
820817
}
821818
break;
819+
case '0':
820+
case '1':
821+
case '2':
822+
case '3':
823+
case '4':
824+
case '5':
825+
case '6':
826+
case '7':
827+
case '8':
828+
case '9': //we're going to read message by number here
829+
//there will, of course, have to be some error checking for
830+
//trying to hit out of bounds messages if dispMsg() doesn't
831+
//already have it
832+
console.putmsg(green + high_intensity + "Go to message #> ");
833+
console.ungetstr(uchoice); //put it back on the input stack
834+
msg_base.dispMsg(new MsgBase(bbs.cursub_code),
835+
console.getnum(maxMsgs), false);
836+
break;
822837
case '$': //change debugging flags for this user
823838
var dropOut = false;
824839
var un;

0 commit comments

Comments
 (0)