-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlbshell.js
2616 lines (2533 loc) · 80.7 KB
/
lbshell.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// lbshell.js
// Lightbar Command Shell for Synchronet Version 4.00a+
// $Id: lbshell.js,v 1.131 2020/04/29 05:40:38 deuce Exp $
// @format.tab-size 4, @format.use-tabs true
//##############################################################################
//#
//# Tips:
//#
//# Tabstops should be set to 4 to view/edit this file
//# If your editor does not support control characters,
//# use \1 for Ctrl-A codes
//#
//################################# Begins Here #################################
/* Adjustable settings */
const LBShell_Attr=0x07; /* light-grey on black */
const MessageWindow_Attr=7;
const MessageTimeout=50; /* 100ths of a second */
load("sbbsdefs.js");
load("nodedefs.js");
load("lightbar.js");
load("graphic.js");
bbs.command_str=''; // Clear STR (Contains the EXEC for default.js)
load("text.js");
load("str_cmds.js");
var str;
var size=file_size(system.text_dir+"lbshell_bg.bin");
size/=2; // Divide by two for attr/char pairs
size/=80; // Divide by 80 cols. Size should now be height (assuming int)
var BackGround=new Graphic(80,size,LBShell_Attr,' ');
var bg_filename=system.text_dir+"lbshell_bg.bin";
var bg_names;
bg_names=directory(system.text_dir+"/backgrounds/*.bin");
if(bg_names.length>0) {
bg_filename=bg_names[random(bg_names.length)];
}
var use_bg=BackGround.load(bg_filename);
var MessageWindow=new Graphic(80,console.screen_rows,MessageWindow_Attr,' ');
var bars80="\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4";
var spaces80=" ";
var msg_rows=0;
var msg_timeouts=new Array();
var menus_displayed=new Array();
var lastmessage_time=0;
var lastmessage_type=0;
var orig_passthru=console.ctrlkey_passthru;
var hangup_now=false;
/*
* TODO: This mangles the ANSI sequence so it will pass through inkey()
* properly... inkey re-inserts ESC back into the stream using ungetkey()
* which changes the order of if the string, putting sequence arguments
* at the end.
*/
function mangle_mouse_seq(seq)
{
var len = seq.length;
return '' + seq[0] + seq[len - 1] + seq.substr(1,len - 2);
}
function handle_a_ctrlkey(key)
{
var i;
var pause=false;
switch(key) {
case ctrl('O'): /* CTRL-O - Pause */
break;
case ctrl('U'): /* CTRL-U User List */
case ctrl('T'): /* CTRL-T Time Info */
case ctrl('K'): /* CTRL-K Control Key Menu */
pause=true;
case ctrl('P'): /* Ctrl-P Messages */
stop_mouse();
clear_screen();
console.handle_ctrlkey(key);
if(pause)
console.pause();
draw_main(true);
for(i=0; i<menus_displayed.length; i++)
menus_displayed[i].draw();
start_mouse();
break;
}
}
function get_message()
{
var rows=0;
/* Update node action */
if(bbs.node_action != system.node_list[bbs.node_num-1].action)
system.node_list[bbs.node_num-1].action = bbs.node_action;
/* Check for messages */
if(system.node_list[bbs.node_num-1].misc & NODE_MSGW)
rows+=MessageWindow.putmsg(1,MessageWindow.height,system.get_telegram(user.number),MessageWindow_Attr,true);
if(system.node_list[bbs.node_num-1].misc & NODE_NMSG)
rows+=MessageWindow.putmsg(1,MessageWindow.height,system.get_node_message(bbs.node_num),MessageWindow_Attr,true);
/* Fix up node status */
if(system.node_list[bbs.node_num-1].status==NODE_WFC) {
log("NODE STATUS FIXUP");
system.node_list[bbs.node_num-1].status=NODE_INUSE;
}
/* Check if user data has changed */
if((system.node_list[bbs.node_num-1].misc & NODE_UDAT) && bbs.compare_ars("REST NOT G")) {
user.cached=false;
system.node_list[bbs.node_num-1].misc &= ~NODE_UDAT;
}
/* Interrupted? */
if(system.node_list[bbs.node_num-1].misc & NODE_INTR) {
rows+=MessageWindow.putmsg(1,MessageWindow.height,bbs.text(NodeLocked),MessageWindow_Attr,true);
log("Interrupted");
hangup_now=true;
}
/* Sysop Chat? */
if(system.node_list[bbs.node_num-1].misc & NODE_LCHAT) {
menu_opt(function() {
bbs.private_chat(true);
bbs.nodesync();
});
}
/* Time left warning? */
if((bbs.time_left/60)<(5-console.timeleft_warning) && !bbs.compare_ars("SYSOP")) {
console.timeleft_warning=5-(bbs.time_left/60);
rows+=MessageWindow.putmsg(1,MessageWindow.height,format(bbs.text(OnlyXminutesLeft),bbs.time_left/60+1,(bbs.time_left/60)?"s":""),MessageWindow_Attr,true);
}
if(bbs.time_left==0) {
/* Call get_time_left() to handle the hangup and such */
stop_mouse();
clear_screen();
bbs.get_time_left();
bbs.hangup();
}
/* New day? */
// if(!(system.status & SS_NEWDAY))
// bbs.nodesync();
return(rows);
}
function message_callback()
{
var rows;
var display=false;
var i;
var old_rows=msg_rows;
rows=get_message();
if(rows>0) {
display=true;
/*
* ToDo: This currently assumes that the
* current menu is the only one protruding into the message window
* This would not be correct with (for example) 20 external areas
* and 20 externals in one area
*/
/* Create new timeout object. */
if(rows > console.screen_rows-1)
rows=console.screen_rows-1;
var timeout=new Object;
timeout.ticks=0;
timeout.rows=rows;
msg_timeouts.push(timeout);
msg_rows+=rows;
if(msg_rows > console.screen_rows-1) {
/* Find and remove older messages that have scrolled off the top (or at least partially). */
for(i=0; i<msg_timeouts.length; i++) {
timeout=msg_timeouts.shift();
msg_rows -= timeout.rows;
if(msg_rows < console.screen_rows-1)
break;
}
}
console.beep();
}
/* Increment the ticks and expire as necessary */
for(i=0; i<msg_timeouts.length; i++) {
msg_timeouts[i].ticks++;
if(msg_timeouts[i].ticks>=MessageTimeout) {
msg_rows -= msg_timeouts[i].rows;
i--;
msg_timeouts.shift();
display=true;
}
}
if(display) {
var display_rows=old_rows;
if(msg_rows>old_rows)
display_rows=msg_rows;
// Is this lightbar inside of the message window?
if(this.ypos+this.items.length-1 /* Last Used Row */ > console.screen_rows-display_rows /* Row above top row of message window */) {
/* Draw to left of lightbar */
if(this.xpos>1)
cleararea(1,console.screen_rows-display_rows+1,this.xpos-1,display_rows,false);
/* Draw below lightbar */
i=this.ypos+this.items[0].length;
if(i<=console.screen_rows)
cleararea(this.xpos,i,this.items[0].length,console.screen_rows-i+1,true);
/* Draw to right of lightbar */
i=this.xpos+this.items[0].length;
if(i<=console.screen_columns)
cleararea(i,console.screen_rows-display_rows+1,console.screen_columns-i+1,display_rows,true);
}
else
/* We can draw the whole thing. */
cleararea(1,console.screen_rows-display_rows+1,console.screen_columns,display_rows);
}
if(hangup_now)
bbs.hangup();
}
function format_opt(str, width, expand)
{
var opt=str;
if(expand) {
var cleaned=opt;
cleaned=cleaned.replace(/\|/g,'');
opt+=spaces80.substr(0,width-cleaned.length-2);
opt+=' >';
}
return(opt);
}
function ShellLB() {
Lightbar.call(this);
}
ShellLB.prototype = new Lightbar;
// Extend the Lightbar prototype...
ShellLB.prototype.erase=function() {
cleararea(this.xpos,this.ypos,this.items[0].text.length,this.items.length,true);
};
ShellLB.prototype.lpadding="\xb3";
ShellLB.prototype.rpadding="\xb3";
ShellLB.prototype.timeout=100;
ShellLB.prototype.callback = message_callback;
ShellLB.prototype.hotkeys = KEY_LEFT+KEY_RIGHT+"\b\x7f\x1b"+ctrl('O')+ctrl('U')+ctrl('T')+ctrl('K')+ctrl('P');
ShellLB.prototype.mouse_miss_key = '\b';
ShellLB.prototype.mouse_enabled = true;
function Mainbar()
{
this.items=new Array();
this.direction=1;
this.xpos=2;
this.ypos=1;
this.hotkeys=KEY_DOWN+";"+ctrl('O')+ctrl('U')+ctrl('T')+ctrl('K')+ctrl('P');
this.mouse_miss_key = undefined;
this.add("|File","F",undefined,undefined,undefined,bbs.compare_ars("REST T"));
this.add("|Messages","M");
this.add("|Email","E",undefined,undefined,undefined,bbs.compare_ars("REST SE"));
this.add("|Chat","C",undefined,undefined,undefined,bbs.compare_ars("REST C"));
this.add("|Settings","S");
this.add("E|xternals","x",undefined,undefined,undefined,bbs.compare_ars("REST X"));
this.add("|View","V");
this.add("|Goodbye","G");
this.add("Commands",";");
this.lpadding="";
this.rpadding="";
}
Mainbar.prototype=ShellLB.prototype;
function top_bar(width)
{
return("\xda"+bars80.substr(0,width)+"\xbf");
}
function bottom_bar(width)
{
return("\xc0"+bars80.substr(0,width)+"\xd9");
}
function format_opt(str, width, expand)
{
var opt=str;
if(expand) {
var cleaned=opt;
cleaned=cleaned.replace(/\|/g,'');
opt+=spaces80.substr(0,width-cleaned.length-2);
opt+=' >';
}
return(opt);
}
function Filemenu()
{
this.items=new Array();
// Width of longest line with no dynamic variables
var width=0;
var scantime=system.datestr(bbs.new_file_time);
// Expand for scan time line.
if(width < 27+scantime.length)
width=27+scantime.length;
if(width < 11+file_area.lib_list[bbs.curlib].dir_list[bbs.curdir].name.length)
width=11+file_area.lib_list[bbs.curlib].dir_list[bbs.curdir].name.length;
this.xpos=1;
this.ypos=2;
this.full_width = width+2;
this.add(top_bar(width),undefined,undefined,"","");
this.add(
format_opt("|Change Directory",width,false)
,"C",width
);
this.add(
format_opt("|List Dir ("+file_area.lib_list[bbs.curlib].dir_list[bbs.curdir].name+")",width,false)
,"L",width
);
this.add(
format_opt("Scan for |New Files since "+scantime,width,true)
,"N",width
);
this.add(
format_opt("Search for |Filenames",width,true)
,"F",width
);
this.add(
format_opt("Search for |Text in Descriptions",width,true)
,"T",width
);
this.add(
format_opt("|Download file(s)",width,true)
,"D",width,undefined,undefined
,bbs.compare_ars("REST D")
|| (!file_area.lib_list[bbs.curlib].dir_list[bbs.curdir].can_download)
);
this.add(
format_opt("|Upload file(s)",width,true)
,"U",width,undefined,undefined
,bbs.compare_ars("REST U")
|| ((!file_area.lib_list[bbs.curlib].dir_list[bbs.curdir].can_upload)
&& file_area.upload_dir==undefined)
);
this.add(
format_opt("|Remove/Edit Files",width,false)
,"R",width
);
this.add(
format_opt("View/Edit |Batch Queue",width,false)
,"B",width,undefined,undefined
// Disabled if you can't upload or download.
// Disabled if no upload dir and no batch queue
,(bbs.compare_ars("REST U AND REST D"))
|| (bbs.batch_upload_total <= 0
&& bbs.batch_dnload_total <= 0
&& file_area.upload_dir==undefined
)
);
this.add(
format_opt("|View",width,true)
,"V",width
);
this.add(
format_opt("|Settings",width,true)
,"S",width
);
this.add(bottom_bar(width),undefined,undefined,"","");
}
Filemenu.prototype=ShellLB.prototype;
function Filedirmenu(x, y, changenewscan)
{
this.items=new Array();
var width=changenewscan?20:0;
if(width<10+file_area.lib_list[bbs.curlib].name.length)
width=10+file_area.lib_list[bbs.curlib].name.length;
if(width<12+file_area.lib_list[bbs.curlib].dir_list[bbs.curdir].name.length)
width=12+file_area.lib_list[bbs.curlib].dir_list[bbs.curdir].name.length;
this.xpos=x;
this.ypos=y;
this.add(top_bar(width),undefined,undefined,"","");
this.add("|All File Areas","A",width);
this.add("|Library ("+file_area.lib_list[bbs.curlib].name+")","L",width);
this.add("|Directory ("+file_area.lib_list[bbs.curlib].dir_list[bbs.curdir].name+")","D",width);
if(changenewscan)
this.add("Change |New Scan Date","N",width);
this.add(bottom_bar(width),undefined,undefined,"","");
}
Filedirmenu.prototype=ShellLB.prototype;
function Fileinfo()
{
this.items=new Array();
this.xpos=22;
this.ypos=4;
this.add("\xda\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xbf",undefined,undefined,"","");
this.add("File |Transfer Policy","T",32);
this.add("Information on |Directory","D",32);
this.add("|Users With Access to Dir","U",32);
this.add("|Your File Transfer Statistics","Y",32);
this.add("\xc0\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xd9",undefined,undefined,"","");
}
Fileinfo.prototype=ShellLB.prototype;
function Settingsmenu()
{
var width=18;
this.items=new Array();
this.xpos=30;
this.ypos=2;
this.add(top_bar(width),undefined,undefined,"","");
this.add("|User Configuration","U",width);
this.add("Minute |Bank","B",width);
this.add(bottom_bar(width),undefined,undefined,"","");
}
Settingsmenu.prototype=ShellLB.prototype;
function Emailmenu()
{
var width=24;
this.items=new Array();
this.xpos=17;
this.ypos=2;
this.add(top_bar(width),undefined,undefined,"","");
this.add(format_opt("|Send Mail",width,true),"S",width);
this.add("|Read Inbox","R",width);
this.add("Read Sent |Messages","M",width,undefined,undefined,bbs.compare_ars("REST K"));
this.add(bottom_bar(width),undefined,undefined,"","");
}
Emailmenu.prototype=ShellLB.prototype;
function Messagemenu()
{
var width=31;
if(width<8+msg_area.grp_list[bbs.curgrp].sub_list[bbs.cursub].name.length)
width=8+msg_area.grp_list[bbs.curgrp].sub_list[bbs.cursub].name.length
this.items=new Array();
this.xpos=7;
this.ypos=2;
this.add(top_bar(width),undefined,undefined,"","");
this.add("|Change Sub","C",width);
this.add("|Read "+msg_area.grp_list[bbs.curgrp].sub_list[bbs.cursub].name,"R",width);
this.add(
format_opt("Scan For |New Messages",width,true)
,"N",width
);
this.add(
format_opt("Scan For Messages To |You",width,true)
,"Y",width
);
this.add(
format_opt("Search For |Text in Messages",width,true)
,"T",width
);
this.add("|Post In "+msg_area.grp_list[bbs.curgrp].sub_list[bbs.cursub].name,"P",width,undefined,undefined,bbs.compare_ars("REST P"));
if(bbs.compare_ars("REST N") && (msg_area.grp_list[bbs.curgrp].sub_list[bbs.crusub] & (SUB_QNET|SUB_PNET|SUB_FIDO)))
this.items[6].disabed=true;
this.add("Read/Post |Auto-Message","A",width);
this.add("|QWK Packet Transfer Menu","Q",width);
this.add("|View Information on Sub","V",width);
this.add(bottom_bar(width),undefined,undefined,"","");
}
Messagemenu.prototype=ShellLB.prototype;
function Chatmenu()
{
var width=27;
this.items=new Array();
this.xpos=24;
this.ypos=2;
this.add(top_bar(width),undefined,undefined,"","");
this.add("|Multinode Chat","M",width);
this.add("|Private Node to Node Chat","P",width);
this.add("|Chat With The SysOp","C",width);
this.add("|Talk With The System Guru","T",width);
this.add("|Finger A Remote User/System","F",width);
this.add("I|RC Chat","R",width);
this.add("InterBBS |Instant Messages","I",width);
this.add(format_opt("|Settings",width,true),"S",width);
this.add(bottom_bar(width),undefined,undefined,"","");
}
Chatmenu.prototype=ShellLB.prototype;
// Generate menus of available xtrn sections.
function Xtrnsecs()
{
var hotkeys="1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*():;<>";
this.items=new Array();
this.xpos=40;
this.ypos=2;
var xtrnsecwidth=0;
var j;
for(j=0; j<xtrn_area.sec_list.length && j<console.screen_rows-2; j++) {
if(xtrn_area.sec_list[j].name.length > xtrnsecwidth)
xtrnsecwidth=xtrn_area.sec_list[j].name.length;
}
xtrnsecwidth += 4;
if(xtrnsecwidth>37)
xtrnsecwidth=37;
this.add("\xda"+bars80.substr(0,xtrnsecwidth)+"\xbf",undefined,undefined,"","");
for(j=0; j<xtrn_area.sec_list.length; j++)
this.add("< |"+hotkeys.substr(j,1)+" "+xtrn_area.sec_list[j].name,j.toString(),xtrnsecwidth);
this.add("\xc0"+bars80.substr(0,xtrnsecwidth)+"\xd9",undefined,undefined,"","");
}
Xtrnsecs.prototype=ShellLB.prototype;
function Xtrnsec(sec)
{
var hotkeys="1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*():;<>";
this.items=new Array();
var j=0;
xtrnsecprogwidth=0;
// Figure out the correct width
for(j=0; j<xtrn_area.sec_list[sec].prog_list.length && j < (console.screen_rows-2); j++) {
if(xtrn_area.sec_list[sec].prog_list[j].name.length > xtrnsecprogwidth)
xtrnsecprogwidth=xtrn_area.sec_list[sec].prog_list[j].name.length;
}
xtrnsecprogwidth+=2;
if(xtrnsecprogwidth>37)
xtrnsecprogwidth=37;
if(xtrn_area.sec_list[sec].prog_list.length+3+sec <= console.screen_rows)
this.ypos=sec+2;
else
this.ypos=console.screen_rows-j-1;
this.xpos=40-xtrnsecprogwidth-2;
this.add("\xda"+bars80.substr(0,xtrnsecprogwidth)+"\xbf",undefined,undefined,"","");
for(j=0; j<xtrn_area.sec_list[sec].prog_list.length && j<console.screen_rows-3; j++)
this.add("|"+hotkeys.substr(j,1)+" "+xtrn_area.sec_list[sec].prog_list[j].name,j.toString(),xtrnsecprogwidth);
this.add("\xc0"+bars80.substr(0,xtrnsecprogwidth)+"\xd9",undefined,undefined,"","");
}
Xtrnsec.prototype=ShellLB.prototype;
function Infomenu()
{
this.items=new Array();
this.xpos=51;
this.ypos=2;
this.add("\xda\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xbf",undefined,undefined,"","");
this.add("System |Information","I",25);
this.add("Synchronet |Version Info","V",25);
this.add("Info on |Sub-Board","S",25);
this.add("|Your Statistics","Y",25);
this.add("< |User Lists","U",25);
this.add("|Text Files","T",25);
this.add("\xc0\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xd9",undefined,undefined,"","");
}
Infomenu.prototype=ShellLB.prototype;
function Userlists()
{
this.items=new Array();
this.xpos=37;
this.ypos=6;
this.add("\xda\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xbf",undefined,undefined,"","");
this.add("|Logons Today","L",12);
this.add("|Sub-Board","S",12);
this.add("|All","A",12);
this.add("\xc0\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xd9",undefined,undefined,"","");
}
Userlists.prototype=ShellLB.prototype;
var mainbar=new Mainbar;
draw_main(true);
var next_key='';
start_mouse();
while(bbs.online) {
var done=0;
var key=next_key;
var extra_select=false;
next_key='';
bbs.node_action=NODE_MAIN;
if(key=='')
key=mainbar.getval()
else
mainbar.draw();
extra_select=false;
if(key==KEY_DOWN) {
key=mainbar.items[mainbar.current].retval;
extra_select=true;
}
switch(key) {
case ctrl('O'): /* CTRL-O - Pause */
case ctrl('U'): /* CTRL-U User List */
case ctrl('T'): /* CTRL-T Time Info */
case ctrl('K'): /* CTRL-K Control Key Menu */
case ctrl('P'): /* Ctrl-P Messages */
handle_a_ctrlkey(key);
break;
case ';':
stop_mouse();
mainbar.current=8;
mainbar.draw();
console.gotoxy(1,2);
console.attributes=9;
console.write("Command (? For Help): ");
console.attributes=7;
if(!console.aborted) {
var str=console.getstr("",40,K_EDIT);
clear_screen();
if(str=='?') {
if(!bbs.compare_ars("SYSOP"))
str='HELP';
}
if(str=='?') {
bbs.menu("sysmain");
console.pause();
bbs.menu("sysxfer");
}
else {
var oldshell=user.command_shell;
str_cmds(str);
/* Still using this shell? */
if(user.command_shell != oldshell)
exit(0);
}
console.pause();
draw_main(true);
}
else
cleararea(1,2,console.screen_columns,1,true);
start_mouse();
break;
case 'F':
show_filemenu();
break;
case 'S':
show_settingsmenu();
break;
case 'E':
show_emailmenu();
break;
case 'M':
show_messagemenu();
break;
case 'C':
show_chatmenu();
break;
case 'x':
var curr_xtrnsec=0;
var x_sec;
var x_prog;
done=false;
var xtrnsec=new Xtrnsecs;
menus_displayed.push(xtrnsec);
while(!done && bbs.online) {
x_sec=xtrnsec.getval();
if(x_sec==KEY_LEFT)
x_sec=(xtrnsec.current-1).toString();
if(x_sec==KEY_RIGHT) {
main_right();
break;
}
if(x_sec=='\b' || x_sec=='\x7f' || x_sec=='\x1b') {
if (xtrnsec.mouse_miss_str !== undefined) {
console.ungetstr(mangle_mouse_seq(xtrnsec.mouse_miss_str));
delete xtrnsec.mouse_miss_str;
}
break;
}
if(x_sec==ctrl('O')
|| x_sec==ctrl('U')
|| x_sec==ctrl('T')
|| x_sec==ctrl('K')
|| x_sec==ctrl('P')) {
handle_a_ctrlkey(x_sec);
continue;
}
curr_xtrnsec=parseInt(x_sec);
var this_xtrnsec=new Xtrnsec(curr_xtrnsec);
menus_displayed.push(this_xtrnsec);
while(bbs.online) {
x_prog=this_xtrnsec.getval();
if(x_prog==KEY_LEFT) {
this_xtrnsec.erase();
xtrnsec.erase();
main_left();
done=1;
break;
}
if(x_prog==KEY_RIGHT || x_prog=='\b' || x_prog=='\x7f' || x_prog=='\x1b') {
this_xtrnsec.erase();
if (this_xtrnsec.mouse_miss_str !== undefined) {
console.ungetstr(mangle_mouse_seq(this_xtrnsec.mouse_miss_str));
delete this_xtrnsec.mouse_miss_str;
}
break;
}
if(x_prog==ctrl('O')
|| x_prog==ctrl('U')
|| x_prog==ctrl('T')
|| x_prog==ctrl('K')
|| x_prog==ctrl('P')) {
handle_a_ctrlkey(x_prog);
continue;
}
stop_mouse();
clear_screen();
if(file_exists("../xtrn/doorscan/doorscan.js")) {
try {
load("../xtrn/doorscan/doorscan.js","run",xtrn_area.sec_list[curr_xtrnsec].prog_list[parseInt(x_prog)].code);
}
catch(e) {
console.writeln("DOORSCAN ERROR: "+e);
log("Error running "+xtrn_area.sec_list[curr_xtrnsec].prog_list[parseInt(x_prog)].code+" "+e);
}
}
else {
bbs.exec_xtrn(xtrn_area.sec_list[curr_xtrnsec].prog_list[parseInt(x_prog)].number);
}
start_mouse();
draw_main(true);
xtrnsec.draw();
}
menus_displayed.pop();
}
menus_displayed.pop();
xtrnsec.erase();
break;
case 'V':
var infomenu=new Infomenu;
menus_displayed.push(infomenu);
infoloop: while(bbs.online) {
key=infomenu.getval();
switch(key) {
case ctrl('O'): /* CTRL-O - Pause */
case ctrl('U'): /* CTRL-U User List */
case ctrl('T'): /* CTRL-T Time Info */
case ctrl('K'): /* CTRL-K Control Key Menu */
case ctrl('P'): /* Ctrl-P Messages */
handle_a_ctrlkey(key);
break;
case 'I':
menu_opt(function() {
bbs.sys_info();
console.pause();
});
break;
case 'V':
menu_opt(function() {
bbs.ver();
console.pause();
});
break;
case 'S':
menu_opt(function() {
bbs.sub_info();
console.pause();
});
break;
case 'Y':
menu_opt(function() {
bbs.user_info();
console.pause();
});
break;
case KEY_LEFT:
if(infomenu.items[infomenu.current].retval!='U') {
main_left();
done=1;
break infoloop;
}
// Fall-through
case 'U':
var userlists=new Userlists;
menus_displayed.push(userlists);
userlistloop: while(bbs.online) {
key=userlists.getval();
switch(key) {
case ctrl('O'): /* CTRL-O - Pause */
case ctrl('U'): /* CTRL-U User List */
case ctrl('T'): /* CTRL-T Time Info */
case ctrl('K'): /* CTRL-K Control Key Menu */
case ctrl('P'): /* Ctrl-P Messages */
handle_a_ctrlkey(key);
break;
case KEY_LEFT:
userlists.erase();
main_left();
break infoloop;
case KEY_RIGHT:
case '\b':
if (userlists.mouse_miss_str !== undefined) {
console.ungetstr(mangle_mouse_seq(userlists.mouse_miss_str));
delete userlists.mouse_miss_str;
}
case '\x7f':
case '\x1b':
userlists.erase();
break userlistloop;
case 'L':
menu_opt(function() {
bbs.list_logons();
console.pause();
});
break;
case 'S':
menu_opt(function() {
bbs.list_users(UL_SUB);
console.pause();
});
break;
case 'A':
menu_opt(function() {
bbs.list_users(UL_ALL);
console.pause();
});
break;
}
}
menus_displayed.pop();
break;
case 'T':
menu_opt(function() {
bbs.text_sec();
});
break infoloop;
case KEY_RIGHT:
main_right();
done=1;
break infoloop;
case '\b':
if (infomenu.mouse_miss_str !== undefined) {
console.ungetstr(mangle_mouse_seq(infomenu.mouse_miss_str));
delete infomenu.mouse_miss_str;
}
case '\x7f':
case '\x1b':
break infoloop;
}
}
menus_displayed.pop();
infomenu.erase();
break;
case 'G': // Goodbye
if(!extra_select) {
stop_mouse();
console.clear(LIGHTGRAY);
bbs.logoff(/* prompt? */false);
draw_main(true);
}
}
}
function todo_getfiles(lib, dir)
{
var path=format("%s%s.ixb", file_area.lib_list[lib].dir_list[dir].data_dir, file_area.lib_list[lib].dir_list[dir].code);
return(file_size(path)/22); /* F_IXBSIZE */
}
function start_mouse()
{
console.write("\x1b[?1006;9h");
}
function stop_mouse()
{
console.write("\x1b[?9l");
}
function clear_screen()
{
/*
* Called whenever a command needs to exit the menu for user interaction.
*
* If you'd like a header before non-menu stuff, this is the place to put
* it.
*/
console.attributes=7;
console.line_counter=0;
console.clear();
/* We are going to a line-mode thing... re-enable CTRL keys. */
console.ctrlkey_passthru=orig_passthru;
}
function draw_main(topline)
{
/*
* Called to re-display the main menu.
* topline is false when the top line doesn't need redrawing.
*/
/* Disable CTRL keys that we "know" how to handle. */
console.ctrlkey_passthru="+KOPTU";
console.aborted=false;
if(topline) {
console.line_counter=0;
console.clear();
cleararea(1,1,console.screen_columns,console.screen_rows,true);
}
else
cleararea(1,2,console.screen_columns,console.screen_rows,true);
}
function menu_opt(func)
{
stop_mouse();
clear_screen();
func();
draw_main(true);
for(i=0; i<menus_displayed.length; i++)
menus_displayed[i].draw();
start_mouse();
}
function main_right()
{
do {
mainbar.current++;
if(mainbar.current==mainbar.items.length)
mainbar.current=0;
} while(mainbar.items[mainbar.current].disabled || mainbar.items[mainbar.current].retval==undefined)
next_key=mainbar.items[mainbar.current].retval;
if(next_key=='G' || next_key==';')
next_key='';
}
function main_left()
{
do {
if(mainbar.current==0)
mainbar.current=mainbar.items.length;
mainbar.current--;
} while(mainbar.items[mainbar.current].disabled || mainbar.items[mainbar.current].retval==undefined)
next_key=mainbar.items[mainbar.current].retval;
if(next_key=='G' || next_key==';')
next_key='';
}
/*
* Displays and handles the file menu
*/
function show_filemenu()
{
var cur=1;
var nd=false;
bbs.node_action=NODE_XFER;
while(bbs.online) {
var filemenu=new Filemenu();
var ret;
var i;
var j;
filemenu.nodraw=nd;
filemenu.current=cur;
menus_displayed.push(filemenu);
ret=filemenu.getval();
if(ret==KEY_RIGHT) {
if(filemenu.items[filemenu.current].text.substr(-2,2)==' >')
ret=filemenu.items[filemenu.current].retval;
}
file: switch(ret) {
case ctrl('O'): /* CTRL-O - Pause */
case ctrl('U'): /* CTRL-U User List */
case ctrl('T'): /* CTRL-T Time Info */
case ctrl('K'): /* CTRL-K Control Key Menu */
case ctrl('P'): /* Ctrl-P Messages */
handle_a_ctrlkey(ret);
break;
case KEY_LEFT:
filemenu.erase();
main_left();
menus_displayed.pop();
return;
case '\b':
if (filemenu.mouse_miss_str !== undefined) {
console.ungetstr(mangle_mouse_seq(filemenu.mouse_miss_str));
delete filemenu.mouse_miss_str;
}
case '\x7f':
case '\x1b':
filemenu.erase();
menus_displayed.pop();
return;
case KEY_RIGHT:
filemenu.erase();
main_right();
menus_displayed.pop();
return;
case 'C':
menu_opt(function() {
changedir: do {
if(!file_area.lib_list.length)
break changedir;
while(bbs.online) {
var orig_lib=bbs.curlib;
i=0;
j=0;
if(file_area.lib_list.length>1) {
if(file_exists(system.text_dir+"menu/libs.*"))