-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.html
More file actions
2164 lines (2034 loc) · 114 KB
/
Copy pathindex.html
File metadata and controls
2164 lines (2034 loc) · 114 KB
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset='UTF-8' name='viewport' content='width=device-width, height=device-height, initial-scale=1.0, user-scalable=0'>
<title>Web-IRC</title>
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="style.css">
<script src="DragDropTouch.js"></script>
<script src="Qtv5.js"></script>
<script src="ircclient.js"></script>
<script src="WebIRC-dialogs.js"></script>
<script src="WebIRC-subwindows.js"></script>
<script>
const fontAvailable = new Set();
const fontCheck = new Set([
'Arial',
'Arial Black',
'Bahnschrift',
'Calibri',
'Cambria',
'Cambria Math',
'Candara',
'Comic Sans MS',
'Consolas',
'Constantia',
'Corbel',
'Courier New',
'Ebrima',
'Franklin Gothic Medium',
'Gabriola',
'Gadugi',
'Georgia',
'HoloLens MDL2 Assets',
'Impact',
'Ink Free',
'Javanese Text',
'Leelawadee UI',
'Lucida Console',
'Lucida Sans Unicode',
'Malgun Gothic',
'Marlett',
'Microsoft Himalaya',
'Microsoft JhengHei',
'Microsoft New Tai Lue',
'Microsoft PhagsPa',
'Microsoft Sans Serif',
'Microsoft Tai Le',
'Microsoft YaHei',
'Microsoft Yi Baiti',
'MingLiU-ExtB',
'Mongolian Baiti',
'MS Gothic',
'MV Boli',
'Myanmar Text',
'Nirmala UI',
'Palatino Linotype',
'Segoe MDL2 Assets',
'Segoe Print',
'Segoe Script',
'Segoe UI',
'Segoe UI Historic',
'Segoe UI Emoji',
'Segoe UI Symbol',
'SimSun',
'Sitka',
'Sylfaen',
'Symbol',
'Tahoma',
'Times New Roman',
'Trebuchet MS',
'Verdana',
'Webdings',
'Wingdings',
'Yu Gothic',
'American Typewriter',
'Andale Mono',
'Arial',
'Arial Black',
'Arial Narrow',
'Arial Rounded MT Bold',
'Arial Unicode MS',
'Avenir',
'Avenir Next',
'Avenir Next Condensed',
'Baskerville',
'Big Caslon',
'Bodoni 72',
'Bodoni 72 Oldstyle',
'Bodoni 72 Smallcaps',
'Bradley Hand',
'Brush Script MT',
'Chalkboard',
'Chalkboard SE',
'Chalkduster',
'Charter',
'Cochin',
'Comic Sans MS',
'Copperplate',
'Courier',
'Courier New',
'Didot',
'DIN Alternate',
'DIN Condensed',
'Futura',
'Geneva',
'Georgia',
'Gill Sans',
'Helvetica',
'Helvetica Neue',
'Herculanum',
'Hoefler Text',
'Impact',
'Lucida Grande',
'Luminari',
'Marker Felt',
'Menlo',
'Microsoft Sans Serif',
'Monaco',
'Noteworthy',
'Optima',
'Palatino',
'Papyrus',
'Phosphate',
'Rockwell',
'Savoye LET',
'SignPainter',
'Skia',
'Snell Roundhand',
'Tahoma',
'Times',
'Times New Roman',
'Trattatello',
'Trebuchet MS',
'Verdana',
'Zapfino',
'Abadi MT Condensed Light',
'Agency FB',
'Algerian',
'Almanac MT',
'Amazone BT',
'Architecture',
'Arial',
'Arial Black',
'Arial Narrow',
'Avant Garde Book BT',
'Avant Garde Book Oblique BT',
'Avant Garde Medium BT',
'Avant Garde Medium Oblique BT',
'Bank Gothic Medium BT',
'Baskerville Old Face',
'Bauhaus 93',
'Beesknees ITC',
'Bell MT',
'Benguiat Bk BT',
'Benguiat Book BT',
'Berlin Sans FB',
'Bernard MT Condensed',
'Bernhard Fashion BT',
'Blackadder ITC',
'Book Antiqua',
'Bookman ITC Demi BT',
'Bookman ITC Light BT',
'Bookman Old Style',
'Bradley Hand ITC',
'Broadway',
'Brush Script BT',
'Californian FB',
'Calisto MT',
'Castellar',
'Centaur',
'Century Gothic',
'Century Schoolbook',
'Century Schoolbook BT',
'Chiller',
'Colonna MT',
'Comic Sans MS',
'Common Bullets',
'Compacta',
'Compacta BT',
'Cooper Black',
'Cooper Black BT',
'Cooper Black Outline BT',
'Cooper Medium BT',
'Copperplate Goth Bd BT Normal',
'Copperplate Gothic Light',
'Courier New',
'Curlz MT',
'Dauphin',
'Dom Casual BT',
'True Type Font List',
'Edwardian Script ITC',
'Elephant',
'English 157 BT',
'Engravers MT',
'Eras Demi ITC',
'Eras Light ITC',
'Eras Medium ITC',
'Eras Ultra ITC',
'Felix Titling',
'Footlight MT Light',
'Forte',
'Franklin Gothic Book',
'Franklin Gothic Demi',
'Franklin Gothic Demi Cond',
'Franklin Gothic Heavy',
'Franklin Gothic Medium',
'Franklin Gothic Medium Cond',
'Freestyle Script',
'French Script',
'Furura Extra Black BT',
'Futura Extra Black Condensed BT',
'Futura Heavy BT',
'Futura Light BT',
'Futura Light Condensed BT',
'Furuta Medium BT',
'Futura Medium Condensed BT',
'Galliard BT',
'Garamond',
'Garamond MT',
'Georgia',
'Gigi',
'Gill Sans MT',
'Gill Sans MT Condensed',
'Gloucester MT Extra Condensed',
'Goudy Handtooled BT',
'Goudy Old Style',
'Goudy Old Style BT',
'Goudy Stout',
'Haettenschweiler',
'Harrington',
'High Tower Text',
'Hobo BT',
'Holidays MT',
'Humanist 521 BT',
'Impact',
'Imprint MT Shadow',
'Informal Roman',
'Jokerman',
'Juice ITC',
'Kids',
'Kristen ITC',
'Kunstler Script',
'Letter Gothic MT',
'Letter Gothic MT Oblique',
'Lucida Bright',
'Lucida Bright Demibold',
'Lucida Console',
'Lucida Fax Demibold',
'Lucida Fax Regular',
'Lucida Sans Demibold Roman',
'Lucida Sans Regular',
'Lucida Sans Typewriter Oblique',
'Lucida Sans Typewriter Regular',
'Lucida Sans Unicode',
'Lydian BT',
'Lydian Cursive BT',
'Maiandra GD',
'Marlett',
'Matisse ITC',
'Matura MT Script Capitals',
'Mini Pics Art Jam',
'Mini Pics Classic',
'Mini Pics Lil Critters',
'Mini Pics Lil Edibles',
'Mini Pics Lil Events',
'Mini Pics Lil Stuff',
'Mini Pics Lil Vehicles',
'Mini Pics Red Rock',
'Mistral',
'Modern No. 20',
'Monotype Corsiva',
'Monotype Sorts',
'Monotype Sorts 2',
'MS Outlook',
'MT Extra',
'News Gothic MT',
'Niagara Engraved',
'Niagara Solid',
'OCR A Extended',
'OCR A BT',
'OCR B 10 Pitch BT',
'Old English Text MT',
'Onyx',
'PT Barnum BT',
'Palace Script MT',
'Papyrus',
'Parchment',
'Park Avenue BT',
'Pepita MT',
'Perpetua',
'Perpetua Titling MT Light',
'Playbill',
'Poor Richard',
'President',
'Pristina',
'Ravie',
'Rockwell',
'Rockwell Condensed',
'Seagull Heavy BT',
'Seagull Light BT',
'Seagul Medium BT',
'Showcard Gothic',
'Snap ITC',
'Souvenir Demi BT',
'Souvenir Light BT',
'Stencil',
'Swiss 721 Black Bt',
'Swiss 721 Black Condensed Bt',
'Swiss 721 Black Extended BT',
'Swiss 721 Extended BT',
'Swiss 721 Heavy BT',
'Swiss 721 Light BT',
'Swiss 721 Light Condensed BT',
'Swiss 721 Light Extended BT',
'Swiss 721 Medium BT',
'Symbol',
'Symbol Proportional BT',
'Tahoma',
'Technical',
'Tempus Sans ITC',
'Times New Roman',
'Trebuchet MS',
'Tw Cen MT',
'Tw Cen MT Condensed',
'Tw Cen MT Condensed Medium',
'Vacation MT',
'Verdana',
'Verdana Ref',
'Viner Hand ITC',
'Vladimir Script',
'Webdings',
'Westminster',
'Wide Latin',
'Wingdings',
'Wingdings 2',
'Wingdings 3',
'Zapf Calligraphic 801 BT',
'Zapf Chancery Medium BT',
'Zapf Dingbats BT',
'Zapf Humanist 601 BT',
].sort());
function AscTime(date,format) {
let DayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] , MonthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
let Second = date.getSeconds(), Minute = date.getMinutes(), Hour = date.getHours(), Day = date.getDay(), Month = date.getMonth(), Year = date.getFullYear(), OffsetHrs = date.getTimezoneOffset() / -60, OffsetMns = (Math.abs(OffsetHrs) % 1 * 60).toString().padStart(2,0);
OffsetHrs = parseInt(OffsetHrs);
return format.replace(/(yy(?:yy)?|m{1,4}|d{1,4}|z{1,3}|HH?|hh?|nn?|ss?|TT?|tt?)/g, function(m,i) {
let chr = i.substr(0,1);
if (chr == "y") { return Year.toString().substr((i.length <= 2 ? 2 : 0)); }
else if (chr == "m") { return (i.length < 3 ? (Month + 1).toString().padStart(i.length,0) : (i.length < 4 ? MonthNames[Month].substring(0,i.length) : MonthNames[Month])); }
else if (chr == "d") { return (i.length < 3 ? date.getDate().toString().padStart(i.length,0) : (i.length < 4 ? DayNames[Day].substring(0,i.length) : DayNames[Day])); }
else if (chr == "H") { return (i.length == 2 ? Hour.toString().padStart(2,0) : Hour); }
else if (chr == "h") { return (Hour < 12 ? (i.length == 2 ? Hour.toString().padStart(2,0) : Hour) : (i.length == 2 ? (Hour - 12).toString().padStart(2,0) : (Hour - 12))); }
else if (chr == "n") { return (i.length == 2 ? Minute.toString().padStart(2,0) : Minute); }
else if (chr == "s") { return (i.length == 2 ? Second.toString().padStart(2,0) : Second); }
else if (chr == "T") { return (Hour < 12 ? "AM" : "PM").substr(0,i.length); }
else if (chr == "t") { return (Hour < 12 ? "am" : "pm").substr(0,i.length); }
else if (chr == "z") { return (OffsetHrs < 0 ? '-' : '+') + (i.length < 3 ? (i.length == 1 ? Math.abs(OffsetHrs) : Math.abs(OffsetHrs).toString().padStart(2,0) + OffsetMns) : Math.abs(OffsetHrs).toString().padStart(2,0) + OffsetMns + " GMT"); }
}).replace(/(1?\d)oo/g,function(m,i) { return i + ([0,'st','nd','rd'][i]||'th'); });
}
function AsyncEmbed(id) {
var elem = document.getElementById(id);
if (elem) {
var url = elem.innerText;
return new Promise((res, rej) => {
if (/\.(?:bmp|cgm|g3|gif|ief|jpe?g?|png|btif|svgz?|tiff?|psd|djvu?|dwg|dxf|fbs|fpx|fst|mmr|rlc|mdi|npx|wbmp|xif|ras|cmx|ico|pcx|pic|pct|pnm|pbm|pgm|ppm|rgb|xbm|xpm|xwd)(?:\?.*)?$/i.test(url)) {
var img = document.createElement('img');
img.addEventListener('load',() => { res({type: 'image', data: img, src: url}); });
img.addEventListener('error',() => { res({type: 'text', src: url}); });
img.src = url;
}
else if (/\.(?:asf|au|snd|midi?|kar|rmi|mpga|mp?[2-4](?:a|v)?|eol|lvp|ecelp(?:4800|7470|9600)|wav|aiff?c?|m3u|wax|wma|ram?|rmp|3g(?:p|2)|h26(?:1|3|4)|jpg(?:m|v)|jpm|mjp?2|mpe?g?|m[1-2]v|qt|mov|fvt|mxu|m4u|viv|fli|asx|wm(?:v|x)?|wvx|avi|movie)(?:\?.*)?$/i.test(url)) {
var video = QuickElement('video',{controls: true, style: "text-indent: 0; max-width: 400px; max-height: 227px;"})
video.preload='metadata';
video.onloadedmetadata = (evt) => {
if (video.videoHeight && video.videoWidth) { res({type: 'video', data: video, src: url}); }
else { video.src = null; res({type: 'audio', data: QuickElement('audio',{src: url, controls: true, style: "text-indent: 0; max-width: 400px; max-height: 227px;"}) , src: url}); }
};
video.src = url;
}
else { res({type: 'text', src: url}); }
});
}
}
//SHA-1 (x) SHA-256 (ok) SHA-384 (ok) SHA-512 (ok)
async function shaEnc(method,source) {
const sourceBytes = new TextEncoder().encode(source);
const digest = await crypto.subtle.digest("SHA-" + method, sourceBytes);
const resultBytes = [...new Uint8Array(digest)];
return resultBytes.map(x => x.toString(16).padStart(2, '0')).join("");
}
class WebIRC extends QMainWindow {
constructor() {
super(null,Qt.WindowType.Window);
/*-------------------------------------------------------------------------------------------------
Build Configuration Object
-------------------------------------------------------------------------------------------------*/
this._Config = {
'dockarea': {
//Immovable: 'Menubar': "",
'Toolbar': Qt.ToolBarArea.TopToolBarArea,
'Treebar': Qt.DockWidgetArea.LeftDockWidgetArea,
'Switchbar': Qt.ToolBarArea.BottomToolBarArea,
'ChanMonitor': Qt.DockWidgetArea.BottomDockWidgetArea,
'NoticeMonitor': Qt.DockWidgetArea.TopDockWidgetArea,
'PrivateMonitor': Qt.DockWidgetArea.BottomDockWidgetArea,
'ServerMonitor': Qt.DockWidgetArea.TopDockWidgetArea,
'HighlightMonitor': Qt.DockWidgetArea.BottomDockWidgetArea,
//Immovable: 'Statusbar': "",
'ChanToolbar': Qt.ToolBarArea.TopToolBarArea,
'QueryToolbar': Qt.ToolBarArea.TopToolBarArea,
},
'states': {
'Menubar': true,
'Toolbar': true,
'Treebar': true,
'Switchbar': true,
'ChanMonitor': false,
'NoticeMonitor': false,
'PrivateMonitor': false,
'ServerMonitor': false,
'HighlightMonitor': false,
'Statusbar': true,
'ChanToolbar': true,
'QueryToolbar': true,
},
'palette': new Array("#FFFFFF","#000000","#00009D","#009300","#FF0000","#7F0000","#9C009C","#FC7F00","#FFFF00","#00FC00","#009393","#00FFFF","#0000FC","#FF00FF","#7F7F7F","#D2D2D2","#470000","#472100","#474700","#324700","#004700","#00472C","#004747","#002747","#000047","#2E0047","#470047","#47002A","#740000","#743A00","#747400","#517400","#007400","#007449","#007474","#004074","#000074","#4B0074","#740074","#740045","#B50000","#B56300","#B5B500","#7DB500","#00B500","#00B571","#00B5B5","#0063B5","#0000B5","#7500B5","#B500B5","#B5006B","#FF0000","#FF8C00","#FFFF00","#B2FF00","#00FF00","#00FFA0","#00FFFF","#008CFF","#0000FF","#A500FF","#FF00FF","#FF0098","#FF5959","#FFB459","#FFFF71","#CFFF60","#6FFF6F","#65FFC9","#6DFFFF","#59B4FF","#5959FF","#C459FF","#FF66FF","#FF59BC","#FF9C9C","#FFD39C","#FFFF9C","#E2FF9C","#9CFF9C","#9CFFDB","#9CFFFF","#9CD3FF","#9C9CFF","#DC9CFF","#FF9CFF","#FF94D3","#000000","#131313","#282828","#363636","#4D4D4D","#656565","#818181","#9F9F9F","#BCBCBC","#E2E2E2","#FFFFFF","inherit"),
'colors': {
'action':7,
'ctcp':4,
'highlight':4,
'info':3,
'invite':3,
'join':10,
'kick':4,
'mode':4,
'nick':10,
'normal':'inherit',
'notice':7,
'own':'inherit',
'part':10,
'topic':3,
'quit':72,
'treebar':'inherit',
'treebartext':'inherit',
'mdi':'inherit',
'viewport':'inherit',
'listbox':'inherit',
'listboxtext':'inherit',
'editbox':'inherit',
'editboxtext':'inherit',
//Treebar/Switchbar text color on events
'barevent': 47,
'barhighlight': 9,
'barmessage': 4,
},
'options': {
//Connect
'MNick': "",
'ANick': "",
//Options
'QuitMessage': "Web-IRC v1.0 Beta https://chat.swiftirc.net/",
'ConnectOnStartup': false,
'ReconnectOnDisconnect': true,
'ShowQuickConnectOnStartup': true,
'UseInvisibleMode': true,
//IRC
'PrefixMessages': true,
'StartQueriesMinimized': false,
'WhoisOnQueryOpen': false,
'KeepChannelsOpen': true,
'AutoJoinOnInvite': false,
'RejoinWhenKicked': true,
'RejoinOnConnect': true,
'ShortChannelEvents': true,
'ShowUserAddress': true,
'SendIRCv3Typing': true,
'TimestampEvents': true,
'TimestampFormat': "[HH:nn]",
'StripControlCodes': false,
'SplitLongMessages': true,
//Sounds
'EnableSounds': false,
'BeepOnChannelMsg': false,
'BeepOnQueryMsg': false,
//Mouse
'StatusDoubleClick': "/lusers",
'QueryDoubleClick': "/whois",
'ChannelDoubleClick': "/channel",
'NicklistDoubleClick': "/query",
//Display
'ShowNetworkInTitle': true,
'ShowNicknameInTitle': false,
'ShowNicknameInTree': true,
'EmbedMediaUrls': true,
'WindowBuffer': 500,
//Notifications
'EnableNotifications': false,
'TipChanMessage': true,
'TipChanNotice': false,
'TipChanCTCP': false,
'TipChanJoinPart': false,
'TipChanKick': false,
'TipChanMode': false,
'TipChanTopic': false,
'TipChanNickname': false,
'TipChanQuit': false,
'TipPrivateMessage': true,
'TipPrivateNotice': true,
'TipPrivateCTCP': false,
'TipOtherConnect': true,
'TipOtherInvite': false,
'TipDuration': 10000,
//Other
'ConfirmCloseStatusStillConnected': true,
'ConfirmLargePastes': false,
},
'servers': {
'SwiftIRC': 'wss://fiery.swiftirc.net:4443',
'Libera.Chat': 'wss://web.libera.chat/webirc/websocket/',
'Unreal': 'wss://irc.unrealircd.org',
'Ergo': 'wss://irc.ergo.chat/webirc',
'Ergo Test': 'wss://testnet.ergo.chat/webirc',
'HybridIRC': 'wss://nexus.hybridirc.com:7002',
'WRNet': 'wss://irc.wrestlingnewssource.com:8000',
'PirateIRC': 'wss://webchat.pirateirc.net/webirc',
'fleenode.chat': 'wss://irc.fleenode.chat:8000',
'DigitalIRC': 'wss://irc-websocket.digitalirc.org:8443',
'LibertaCasa': 'wss://liberta.casa/webirc',
//'Getgle': 'wss://getgle.org:8097',
//'BugzbunnyNET': 'wss://irc.bugzbunny.net:8000',
//'null-net': 'wss://irc.null-net.net:8000',
},
}
this._MergeConfig();
this._Sessions = { };
this._hasFocus = true;
this.Aliases = { };
/*-------------------------------------------------------------------------------------------------
Build UI Components
-------------------------------------------------------------------------------------------------*/
this.setWindowTitle("Web-IRC"); //for giggles just incase we setwindowflags to give back titlehint...
this.mFile = new QMenu('File');
this.fNew = new QAction('images/addserver.ico','New Server Window',this.mFile).connect('triggered',this,() => { this._NewSession(this._Config.options.MNick,'',['text.ircv3.net']); });
new QAction('','',this.mFile).setSeparator();
this.fOptions = new QAction('images/options.ico','Options',this.mFile).connect('triggered',this,this._ToggleConfigGeneral);
new QAction('','',this.mFile).setSeparator();
this.fQuickConnect = new QAction('images/connect.png','Quick Connect',this.mFile).connect('triggered',this,this._ToggleQuickConnect);
new QAction('','',this.mFile).setSeparator();
this.fConnect = new QAction('images/connect.ico','Connect',this.mFile);//.connect('triggered',this,this._ToggleConfigGeneral);
this.fDisconnect = new QAction('images/disconnect.ico','Disconnect',this.mFile).setEnabled(false);//.connect('triggered',this,this._ToggleConfigGeneral);
this._MenuBar.addMenu(this.mFile);
this.mView = new QMenu('View');
this.vFull = new QAction('','Fullscreen',this.mView).connect('triggered',this,this._ToggleFullscreen);
new QAction('','',this.mView).setSeparator();
this.vMenu = new QAction('','Menubar',this.mView).setCheckable(true).setChecked(this._Config.states.Menubar).connect('toggled',this,this._ToggleMenubar);
this.vTool = new QAction('','Toolbar',this.mView).setCheckable(true).setChecked(this._Config.states.Toolbar).connect('toggled',this,this._ToggleToolbar);
this.vTree = new QAction('','Treebar',this.mView).setCheckable(true).setChecked(this._Config.states.Treebar).connect('toggled',this,this._ToggleTreebar);
this.vSwitch = new QAction('','Switchbar',this.mView).setCheckable(true).setChecked(this._Config.states.Switchbar).connect('toggled',this,this._ToggleSwitch);
this.vStatus = new QAction('','Statusbar',this.mView).setCheckable(true).setChecked(this._Config.states.Statusbar).connect('toggled',this,this._ToggleStatus);
new QAction('','',this.mView).setSeparator();
this.vMPToggle = new QAction('','Toggle All Monitor Panels',this.mView).connect('triggered',this,this._ToggleAll);
new QAction('','',this.mView).setSeparator();
this.vChan = new QAction('','Channel Messages',this.mView).setCheckable(true).setChecked(this._Config.states.ChanMonitor).connect('toggled',this,this._ToggleChan);
this.vHighlight = new QAction('','Highlights',this.mView).setCheckable(true).setChecked(this._Config.states.HighlightMonitor).connect('toggled',this,this._ToggleHighlight);
this.vNotice = new QAction('','Notices',this.mView).setCheckable(true).setChecked(this._Config.states.NoticeMonitor).connect('toggled',this,this._ToggleNotice);
this.vQuery = new QAction('','Private Messages',this.mView).setCheckable(true).setChecked(this._Config.states.PrivateMonitor).connect('toggled',this,this._ToggleQuery);
this.vServer = new QAction('','Server Messages',this.mView).setCheckable(true).setChecked(this._Config.states.ServerMonitor).connect('toggled',this,this._ToggleServer);
this._MenuBar.addMenu(this.mView);
this.mHelp = new QMenu('Help');
this.hHelp = new QAction('','Help Doc',this.mHelp).setCheckable(true).setChecked(false).connect('toggled',this,this._ToggleHelp);
this.hAbout = new QAction('','About',this.mHelp).connect('triggered',this,this._ToggleAbout);
new QAction('','',this.mHelp).setSeparator();
this.hGithub = new QAction('','Visit Github',this.mHelp).connect('triggered',this,() => { window.open('https://github.com/SwiftIRC/Web-IRC','_blank'); });
this._MenuBar.addMenu(this.mHelp);
this.MDI = new QMdiArea(this);
this.MDI._CurrentWindowState = Qt.WindowState.WindowMaximized;
this._StatusBar.style.display = (this._Config.states.Statusbar == true ? '' : 'none');
this.SwitchBar = new QToolBar().setVisible(this._Config.states.Switchbar);
this.SwitchBar.style.overflow = "hidden";
this.SwitchBar._CentralWidget.style.overflow = "hidden";
this.addToolBar(this._Config.dockarea.Switchbar,this.SwitchBar);
this.MDI.style.background = this._Color('mdi');
this.TreeDock = new QDockWidget('Treebar').setAllowedAreas(Qt.DockWidgetArea.RightDockWidgetArea | Qt.DockWidgetArea.LeftDockWidgetArea).setBaseSize(150,null).setResizable(true);
this.HelpDock = new QDockWidget('Help').setAllowedAreas(Qt.DockWidgetArea.RightDockWidgetArea | Qt.DockWidgetArea.LeftDockWidgetArea).setBaseSize(300,200).setResizable(true).setVisible(false);
this.HelpDialog = new QDialog().setBaseSize(270,240).setWindowTitle('About Web-IRC').setWindowFlag(Qt.WindowType.WindowMinMaxButtonsHint,false).hide();
this.GeneralDialog = new ConfigGeneral(this).setBaseSize(420,290).setWindowTitle('Web-IRC Preferences').hide();
this.ColorsDialog = new ConfigColors(this).setBaseSize(420,298).setWindowTitle('Web-IRC Colors').hide();
this.QuickConnect = new QuickConnect(this).setBaseSize(300,230).setWindowTitle('Quick Connect').hide();
this.QuickConnect._ShowStartup.checked = this._Config.options.ShowQuickConnectOnStartup;
this.QuickConnect._MNick.value = this._Config.options.MNick;
this.QuickConnect._ANick.value = this._Config.options.ANick;
this.QuickConnect.addEventListener('childEvent', (e) => {
if (e.detail.QEvent == Qt.QEvent.Close) {
this._Config.options.ShowQuickConnectOnStartup = this.QuickConnect._ShowStartup.checked;
this._Config.options.MNick = this.QuickConnect._MNick.value;
this._Config.options.ANick = this.QuickConnect._ANick.value;
this._SaveConfig();
}
});
this.SelectFont = new FontSelect(this,fontAvailable).setBaseSize(300,230).setWindowTitle('Select Font').hide();
//this.TabTest = new TabTest(this).setBaseSize(300,230).setWindowTitle('Testing Tabs').showCentered();
setTimeout(() => {
this.HelpDialog.setCentralWidget(document.getElementById('helpabout'));
document.getElementById('helpabout').style.display = "";
this.HelpDock.setCentralWidget(document.getElementById('helpdoc'));
document.getElementById('helpdoc').style.display = "";
});
this.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea,this.HelpDock);
this.Treebar = new QTreeWidget();
this.Treebar.style.background = this._Color('treebar');
this.Treebar.style.color = this._Color('treebartext');
this.TreeDock.setCentralWidget(this.Treebar);
this.TreeDock.setVisible(this._Config.states.Treebar);
this.addDockWidget(this._Config.dockarea.Treebar,this.TreeDock);
this.MonitorChan = new QDockWidget('Channel Messages').setFeature(Qt.DockWidgetFeature.AllowTabs,true).setMinimumSize(75,75).setBaseSize(75,75).setVisible(this._Config.states.ChanMonitor).setResizable(true);
this.MonitorChanViewPort = QuickElement('div',{'class': 'viewport', style: "display: flex; flex-direction: column; background: inherit; flex: auto; text-indent: -1em; padding: 0 0 0 1.2em; word-wrap: break-word; white-space: pre-wrap; overflow-y: scroll;"});
this.MonitorChan.setCentralWidget(this.MonitorChanViewPort);
this.MonitorHighlight = new QDockWidget('Highlights').setFeature(Qt.DockWidgetFeature.AllowTabs,true).setMinimumSize(75,75).setBaseSize(75,75).setVisible(this._Config.states.HighlightMonitor).setResizable(true);
this.MonitorHighlightViewPort = QuickElement('div',{'class': 'viewport', style: "display: flex; flex-direction: column; background: inherit; flex: auto; text-indent: -1em; padding: 0 0 0 1.2em; word-wrap: break-word; white-space: pre-wrap; overflow-y: scroll;"});
this.MonitorHighlight.setCentralWidget(this.MonitorHighlightViewPort);
this.MonitorNotice = new QDockWidget('Notices').setFeature(Qt.DockWidgetFeature.AllowTabs,true).setMinimumSize(75,75).setBaseSize(75,75).setVisible(this._Config.states.NoticeMonitor).setResizable(true);
this.MonitorNoticeViewPort = QuickElement('div',{'class': 'viewport', style: "display: flex; flex-direction: column; background: inherit; flex: auto; text-indent: -1em; padding: 0 0 0 1.2em; word-wrap: break-word; white-space: pre-wrap; overflow-y: scroll;"});
this.MonitorNotice.setCentralWidget(this.MonitorNoticeViewPort);
this.MonitorQuery = new QDockWidget('Private Messages').setFeature(Qt.DockWidgetFeature.AllowTabs,true).setMinimumSize(75,75).setBaseSize(75,75).setVisible(this._Config.states.PrivateMonitor).setResizable(true);
this.MonitorQueryViewPort = QuickElement('div',{'class': 'viewport', style: "display: flex; flex-direction: column; background: inherit; flex: auto; text-indent: -1em; padding: 0 0 0 1.2em; word-wrap: break-word; white-space: pre-wrap; overflow-y: scroll;"});
this.MonitorQuery.setCentralWidget(this.MonitorQueryViewPort);
this.MonitorServer = new QDockWidget('Server Messages').setFeature(Qt.DockWidgetFeature.AllowTabs,true).setMinimumSize(75,75).setBaseSize(75,75).setVisible(this._Config.states.ServerMonitor).setResizable(true);
this.MonitorServerViewPort = QuickElement('div',{'class': 'viewport', style: "display: flex; flex-direction: column; background: inherit; flex: auto; text-indent: -1em; padding: 0 0 0 1.2em; word-wrap: break-word; white-space: pre-wrap; overflow-y: scroll; "});
this.MonitorServer.setCentralWidget(this.MonitorServerViewPort);
this.MonitorChanViewPort.style.background = this.MonitorHighlightViewPort.style.background = this.MonitorNoticeViewPort.style.background = this.MonitorQueryViewPort.style.background = this.MonitorServerViewPort.style.background = this._Color('viewport');
//Setup event listeners for closing the dockwidget (x)
this.TreeDock.addEventListener('childEvent', (e) => { if (e.detail.QEvent == Qt.QEvent.Close) { this._ToggleTreebar({detail: { checked:false } }); } });
this.MonitorChan.addEventListener('childEvent', (e) => { if (e.detail.QEvent == Qt.QEvent.Close) { this._ToggleChan({detail: { checked:false } }); } });
this.MonitorHighlight.addEventListener('childEvent', (e) => { if (e.detail.QEvent == Qt.QEvent.Close) { this._ToggleHighlight({detail: { checked:false } }); } });
this.MonitorQuery.addEventListener('childEvent', (e) => { if (e.detail.QEvent == Qt.QEvent.Close) { this._ToggleQuery({detail: { checked:false } }); } });
this.MonitorServer.addEventListener('childEvent', (e) => { if (e.detail.QEvent == Qt.QEvent.Close) { this._ToggleServer({detail: { checked:false } }); } });
this.MonitorNotice.addEventListener('childEvent', (e) => { if (e.detail.QEvent == Qt.QEvent.Close) { this._ToggleNotice({detail: { checked:false } }); } });
this.addDockWidget(this._Config.dockarea.ChanMonitor,this.MonitorChan);
this.addDockWidget(this._Config.dockarea.HighlightMonitor,this.MonitorHighlight);
this.addDockWidget(this._Config.dockarea.PrivateMonitor,this.MonitorQuery);
this.addDockWidget(this._Config.dockarea.ServerMonitor,this.MonitorServer);
this.addDockWidget(this._Config.dockarea.NoticeMonitor,this.MonitorNotice);
this.Toolbar = new QToolBar();
//Need a placeholder (so we can change this one based on active subwindow)
this.ConnectToggle = new QAction('images/connect.ico').setToolTip('Connect').connect('triggered',this,() => { this._ToggleConnection(); });
this.Toolbar.addAction(this.ConnectToggle);
this.Toolbar.addAction(new QAction('','').setSeparator());
this.Toolbar.addAction(new QAction('images/options.ico').setToolTip('Options').connect('triggered',this,this._ToggleConfigGeneral));
this.Toolbar.addAction(new QAction('images/colors.ico').setToolTip('Colors').connect('triggered',this,this._ToggleConfigColors));
this.Toolbar.addAction(new QAction('','').setSeparator());
this.Toolbar.addAction(new QAction('images/monitor.ico').setToolTip('Toggle Monitor Panels').connect('triggered',this,this._ToggleAll));
this.Toolbar.addAction(new QAction('','').setSeparator());
this.Toolbar.addAction(new QAction('images/font.png').setToolTip('Set Monitor Panels Font').connect('triggered',this,this._ToggleFont));
this.Toolbar.addAction(new QAction('','').setSeparator());
this.Toolbar.addAction(new QAction('images/leftarrow.png').setToolTip('Previous Subwindow').connect('triggered',this,() => this.MDI.activatePreviousSubWindow() ));
this.Toolbar.addAction(new QAction('images/rightarrow.png').setToolTip('Next Subwindow').connect('triggered',this,() => this.MDI.activateNextSubWindow() ));
this.Toolbar.addAction(new QAction('','').setSeparator());
this.Toolbar.addAction(new QAction('images/tile_cascade.png').setToolTip('Cascade Subwindows').connect('triggered',this,() => this.MDI.activatePreviousSubWindow() ));
this.Toolbar.addAction(new QAction('images/tile.png').setToolTip('Tile Subwindows').connect('triggered',this,() => this.MDI.activateNextSubWindow() ));
this.Toolbar.addAction(new QAction('','').setSeparator());
this.Toolbar.addAction(new QAction('images/question.png').setToolTip('About WebIRC').connect('triggered',this,() => this._ToggleAbout() ));
this.addToolBar(this._Config.dockarea.Toolbar,this.Toolbar);
this.TreeDock.addEventListener('visibilityChanged',(e) => { this.vTree.setChecked(e.detail.visible); });
this.HelpDock.addEventListener('visibilityChanged',(e) => { this.hHelp.setChecked(e.detail.visible); });
this.MonitorChan.addEventListener('visibilityChanged',(e) => { this.vChan.setChecked(e.detail.visible); });
this.MonitorHighlight.addEventListener('visibilityChanged',(e) => { this.vHighlight.setChecked(e.detail.visible); });
this.MonitorNotice.addEventListener('visibilityChanged',(e) => { this.vNotice.setChecked(e.detail.visible); });
this.MonitorQuery.addEventListener('visibilityChanged',(e) => { this.vQuery.setChecked(e.detail.visible); });
this.MonitorServer.addEventListener('visibilityChanged',(e) => { this.vServer.setChecked(e.detail.visible); });
//this.MDI.addEventListener('subWindowActivated',(e) => { this._ToggleConnection(true); });
this.MDI.addEventListener('childEvent',(e) => {
this.MDI.Children().forEach((child) => { if (e.detail.QEvent == Qt.QEvent.Resize && child.hasOwnProperty('ViewPort') && child.ViewPort._isEnd == true) { child.ViewPort.scrollTop = child.ViewPort.scrollHeight; } })
this._ToggleConnection(true);
});
this._NewSession(this._Config.options.MNick,'',['text.ircv3.net']);
if (this._Config.options.ShowQuickConnectOnStartup) {
setTimeout(() => { this._ToggleQuickConnect(); });
}
//For Tooltips (Notifications) see if we have browser tab/window focus
window.addEventListener('blur', (e) => { this._hasFocus = false; });
window.addEventListener('focus', (e) => { this._hasFocus = true; });
var params = new Proxy(new URLSearchParams(window.location.search), { get: (searchParams, prop) => searchParams.get(prop), });
if (params.perform) { this._processInputLine(this._Sessions["1"].Windows['status window'],params.perform); }
}
_InternalBeep() {
//if (this._Config['options']['irc'].ebeeps) {
var context = new(window.AudioContext || window.webkitAudioContext)();
var square_wave = context.createOscillator();
var envelope = context.createGain();
var volume = context.createGain();
var destination = context.destination;
var t0 = context.currentTime;
square_wave.type = "square";
square_wave.frequency.value = 440 * 4;
square_wave.detune.value = 0;
envelope.gain.value = 0.0;
volume.gain.value = 0.05;
square_wave.connect(envelope).connect(volume).connect(destination);
// Envelope
var t1, v = 0.5;
envelope.gain.setValueAtTime(0.0, t1 = t0);
envelope.gain.linearRampToValueAtTime(1.0, t1 = t0 + v * 0.01);
envelope.gain.linearRampToValueAtTime(0.1, t1 = t0 + v * 0.09);
envelope.gain.linearRampToValueAtTime(0.0, t1 = t0 + v * 0.50);
square_wave.addEventListener('ended',() => {
square_wave.disconnect(envelope);
envelope.disconnect(volume);
volume.disconnect(context.destination);
});
//square_wave.onended = on_ended;
square_wave.start();
square_wave.stop(t1);
//}
}
_SaveConfig() {
window.localStorage.setItem('Web-IRC.Config',JSON.stringify(this._Config));
if (this.Treebar) {
this.Treebar.style.background = this._Color('treebar');
this.Treebar.style.color = this._Color('treebartext');
this.MDI.style.background = this._Color('mdi');
this.MonitorChanViewPort.style.background = this.MonitorHighlightViewPort.style.background = this.MonitorNoticeViewPort.style.background = this.MonitorQueryViewPort.style.background = this.MonitorServerViewPort.style.background = this._Color('viewport');
this.MDI.Children().forEach((child) => {
if (child.hasOwnProperty('ViewPort')) { child.ViewPort.style.background = this._Color('viewport'); }
if (child.hasOwnProperty('EditBox')) { child.EditBox.style.background = this._Color('editbox'); child.EditBox.style.color = this._Color('editboxtext'); }
if (child.hasOwnProperty('List')) { child.List.style.background = this._Color('listbox'); child.List.style.color = this._Color('listboxtext'); }
});
}
}
_MergeConfig() {
let stored = JSON.parse(window.localStorage.getItem('Web-IRC.Config'));
if (stored) {
if (stored.hasOwnProperty('palette')) { this._Config.palette = stored.palette; }
if (stored.hasOwnProperty('colors')) { Object.keys(stored.colors).forEach((target) => { this._Config.colors[target] = stored.colors[target]; }); }
if (stored.hasOwnProperty('dockarea')) { Object.keys(stored.dockarea).forEach((target) => { this._Config.dockarea[target] = stored.dockarea[target]; }); }
if (stored.hasOwnProperty('states')) { Object.keys(stored.states).forEach((target) => { this._Config.states[target] = stored.states[target]; }); }
if (stored.hasOwnProperty('options')) { Object.keys(stored.options).forEach((target) => { this._Config.options[target] = stored.options[target]; }); }
if (stored.hasOwnProperty('servers')) { Object.keys(stored.servers).forEach((target) => { this._Config.servers[target] = stored.servers[target]; }); }
}
this._SaveConfig();
}
_ToggleQuickJoin() {
let channels = prompt("Enter channels seperated by comma:", "");
if (channels == null || channels == "") { }
else {
if (this.MDI.activeSubWindow() && this.MDI.activeSubWindow()._Cid) {
this._processInputLine(this.MDI.activeSubWindow(),"/join " + channels);
}
}
}
_ToggleConnection(bool) {
if (this.MDI.activeSubWindow() && this.MDI.activeSubWindow()._Cid) {
if (this._Sessions[this.MDI.activeSubWindow()._Cid].Windows.hasOwnProperty('status window')) { this._Sessions[this.MDI.activeSubWindow()._Cid].Windows['status window']._SortTree(); }
var Client = this._Sessions[this.MDI.activeSubWindow()._Cid].Client;
if (bool) {
if (Client.hasOwnProperty('Socket') && Client.Socket.readyState < 3) { this.ConnectToggle.setIcon('images/disconnect.ico').setToolTip('Disconnect'); }
else { this.ConnectToggle.setIcon('images/connect.ico').setToolTip('Connect'); }
}
else if (Client) {
if (Client.hasOwnProperty('Socket') && Client.Socket.readyState < 3) {
this.ConnectToggle.setIcon('images/connect.ico').setToolTip('Connect');
Client.WSClose();
}
else {
if (!Client.hasOwnProperty('Socket') && Client.WSServerURI && Client.WSServerPROTO) {
this.ConnectToggle.setIcon('images/disconnect.ico').setToolTip('Disconnect');
Client.WSConnect(Client.Me,Client.WSServerURI,Client.WSServerPROTO,true);
}
else { this._ToggleQuickConnect(); }
}
}
}
else { this.ConnectToggle.setIcon('images/connect.ico').setToolTip('Connect'); }
}
_ToggleHelp(e) { this.HelpDock.setVisible(e.detail.checked); }
_ToggleAbout() {
this.HelpDialog.showCentered();
}
_ToggleConfigGeneral() {
this.GeneralDialog._Init();
this.GeneralDialog.showCentered();
}
_ToggleConfigColors() {
this.ColorsDialog._InitList();
this.ColorsDialog.showCentered();
}
_ToggleQuickConnect() {
this.QuickConnect._Init();
if (this.MDI.activeSubWindow() && this.MDI.activeSubWindow()._Cid) {
this.QuickConnect._MNick.setAttribute('placeholder',this._Sessions[this.MDI.activeSubWindow()._Cid].Client.Me);
}
this.QuickConnect.showCentered();
}
_ToggleSelectFont() {
this.SelectFont._Init();
this.SelectFont.showCentered();
}
_ToggleAll() {
if (this.vChan.isChecked() && this.vHighlight.isChecked() && this.vNotice.isChecked() && this.vQuery.isChecked() && this.vServer.isChecked()) { var Invert = true; }
if (!this.vChan.isChecked() || Invert) { this.vChan.toggle(); }
if (!this.vHighlight.isChecked() || Invert) { this.vHighlight.toggle(); }
if (!this.vNotice.isChecked() || Invert) { this.vNotice.toggle(); }
if (!this.vQuery.isChecked() || Invert) { this.vQuery.toggle(); }
if (!this.vServer.isChecked() || Invert) { this.vServer.toggle(); }
[this.MonitorChanViewPort,this.MonitorHighlightViewPort,this.MonitorNoticeViewPort,this.MonitorQueryViewPort,this.MonitorServerViewPort].forEach((target) => { target.scrollTop = target.scrollHeight; });
}
_ToggleFullscreen() {
if (document.fullscreenElement == null) { document.documentElement.requestFullscreen(); }
else { document.exitFullscreen(); }
}
_ToggleChan(e) { this.MonitorChan.setVisible(e.detail.checked); this._Config.states.ChanMonitor = e.detail.checked; this._SaveConfig(); }
_ToggleHighlight(e) { this.MonitorHighlight.setVisible(e.detail.checked); this._Config.states.HighlightMonitor = e.detail.checked; this._SaveConfig(); }
_ToggleMenubar(e) { this.menuBar().style.display = (e.detail.checked == true ? '' : 'none'); this._Config.states.Menubar = e.detail.checked; this._SaveConfig(); }
_ToggleNotice(e) { this.MonitorNotice.setVisible(e.detail.checked); this._Config.states.NoticeMonitor = e.detail.checked; this._SaveConfig(); }
_ToggleQuery(e) { this.MonitorQuery.setVisible(e.detail.checked); this._Config.states.PrivateMonitor = e.detail.checked; this._SaveConfig(); }
_ToggleServer(e) { this.MonitorServer.setVisible(e.detail.checked); this._Config.states.ServerMonitor = e.detail.checked; this._SaveConfig(); }
_ToggleStatus(e) { this._StatusBar.style.display = (e.detail.checked == true ? '' : 'none'); this._Config.states.Statusbar = e.detail.checked; this._SaveConfig(); }
_ToggleSwitch(e) { this.SwitchBar.setVisible(e.detail.checked); this._Config.states.Switchbar = e.detail.checked; this._SaveConfig(); }
_ToggleToolbar(e) { this.Toolbar.setVisible(e.detail.checked); this._Config.states.Toolbar = e.detail.checked; this._SaveConfig(); }
_ToggleTreebar(e) { this.TreeDock.setVisible(e.detail.checked); this._Config.states.Treebar = e.detail.checked; this._SaveConfig(); }
_Color(type,bool) { return (isNaN(this._Config['colors'][type]) ? this._Config['colors'][type] : (bool ? this._Config['colors'][type] : this._Config['palette'][this._Config['colors'][type]])); }
_NewSession(Nick,Server,Protocol,AutoJoin) {
var x = 1;
Object.keys(this._Sessions).forEach((target) => { if ("" + x + "" == target) { x++; } });
this._Sessions[x] = {
Client: new IRCClient(x,Nick,Server),
Windows: { "status window": new CustomWindow(this.MDI,{root:this,type:'status',cid:x,target:'status window',title:'Status: Not Connected'}) }
};
this._Sessions[x].Client.addListener('action',this,this.onAction);
this._Sessions[x].Client.addListener('connect',this,this.onConnect);
this._Sessions[x].Client.addListener('ctcp',this,this.onCtcp);
this._Sessions[x].Client.addListener('ctcpreply',this,this.onCtcpReply);
this._Sessions[x].Client.addListener('disconnect',this,this.onDisconnect);
this._Sessions[x].Client.addListener('error',this,this.onError);
this._Sessions[x].Client.addListener('invite',this,this.onInvite);
this._Sessions[x].Client.addListener('join',this,this.onJoin);
this._Sessions[x].Client.addListener('kick',this,this.onKick);
this._Sessions[x].Client.addListener('logon',this,this.onLogon);
this._Sessions[x].Client.addListener('mode',this,this.onMode);
this._Sessions[x].Client.addListener('nick',this,this.onNick);
this._Sessions[x].Client.addListener('notice',this,this.onNotice);
this._Sessions[x].Client.addListener('part',this,this.onPart);
this._Sessions[x].Client.addListener('ping',this,this.onPing);
this._Sessions[x].Client.addListener('pong',this,this.onPong);
this._Sessions[x].Client.addListener('privmsg',this,this.onPrivmsg);
this._Sessions[x].Client.addListener('tagmsg',this,this.onTagmsg);
this._Sessions[x].Client.addListener('quit',this,this.onQuit);
this._Sessions[x].Client.addListener('raw',this,this.onRaw);
this._Sessions[x].Client.addListener('smode',this,this.onSmode);
this._Sessions[x].Client.addListener('snotice',this,this.onSnotice);
this._Sessions[x].Client.addListener('topic',this,this.onTopic);
this._Sessions[x].Client.addListener('umode',this,this.onUmode);
this._Sessions[x].Client.addListener('debugrawdata',this,this.onDebug);
this._Sessions[x].Client.addListener('chancentral',this,this.onChanCentral);
if (AutoJoin) { this._Sessions[x].TempAutoJoin = AutoJoin; }
if (/^wss?:\/\//i.test(Server)) { this._Sessions[x].Client.WSConnect(this._Sessions[x].Client.Me,Server,Protocol); }
this._updateStatus();
//this._ShowNotification('favicon.ico','Web-IRC','Welcome to Web-IRC!',2000);
}
_NewSubWindow(x,wtype,wtarget,width,height) {
if (this._Sessions.hasOwnProperty(x)) {
if (!this._Sessions[x].Windows.hasOwnProperty(wtarget.toLowerCase())) {
if (wtype == 'status window') { this.SwitchBar.addAction(new QAction().setSeparator()); }
this._Sessions[x].Windows[wtarget.toLowerCase()] = new CustomWindow(this.MDI,{root:this,owner:this._Sessions[x].Windows['status window'],type:wtype,cid:x,target:wtarget});
}
else { this.MDI.setActiveSubWindow(this._Sessions[x].Windows[wtarget.toLowerCase()]); }
this._Sessions[x].Windows['status window']._SortTree();
}
if (width && height) { this._Sessions[x].Windows[wtarget.toLowerCase()].setBaseSize(width,height); }
return this._Sessions[x].Windows[wtarget.toLowerCase()];
}
_CloseSession(cid) {
if (this._Sessions.hasOwnProperty(cid)) {
var Client = this._Sessions[cid].Client , windows = Object.keys(this._Sessions[cid].Windows) , close = true;
if (windows.length > 1 || (Client.hasOwnProperty('Socket') && Client.Socket.readyState < 3)) { if (this._Config.options.ConfirmCloseStatusStillConnected) { var close = window.confirm("Are you sure you wish to close this session and all subsequent windows?"); } }
if (close) {
if (this._Sessions[cid].hasOwnProperty('Windows')) {
windows.reduceRight((_, key) => {
if (this._Sessions[cid].Windows[key].TreeItem.parentNode) { this._Sessions[cid].Windows[key].TreeItem.parentNode.removeChild(this._Sessions[cid].Windows[key].TreeItem); }
if (this._Sessions[cid].Windows[key].parentNode) { this._Sessions[cid].Windows[key].parentNode.removeChild(this._Sessions[cid].Windows[key]); }
if (this._Sessions[cid].Windows[key].TreeItem._SwitchItem.parentNode) { this._Sessions[cid].Windows[key].TreeItem._SwitchItem.parentNode.removeChild(this._Sessions[cid].Windows[key].TreeItem._SwitchItem); }
if (this._Sessions[cid].Windows[key]._Type == 'status') { clearInterval(this._Sessions[cid].Windows[key].OnlineTimer); }
delete this._Sessions[cid].Windows[key];
}, null);
}
this._SendData(this._Sessions[cid].Client,"QUIT :" + this._Config.options.QuitMessage);
this._Sessions[cid].Client.WSClose();
delete this._Sessions[cid];
}
}
}
_CloseSubWindow(cid,target) {
if (this._Sessions.hasOwnProperty(cid)) {
if (this._Sessions[cid].hasOwnProperty('Windows')) {
Object.keys(this._Sessions[cid].Windows).reduceRight((_, key) => {
if (this._Sessions[cid].Windows[key] == target) {
if (this._Sessions[cid].Windows[key].TreeItem.parentNode) { this._Sessions[cid].Windows[key].TreeItem.parentNode.removeChild(this._Sessions[cid].Windows[key].TreeItem); }
if (this._Sessions[cid].Windows[key].TreeItem._SwitchItem.parentNode) { this._Sessions[cid].Windows[key].TreeItem._SwitchItem.parentNode.removeChild(this._Sessions[cid].Windows[key].TreeItem._SwitchItem); }
if (this._Sessions[cid].Windows[key].parentNode) { this._Sessions[cid].Windows[key].parentNode.removeChild(this._Sessions[cid].Windows[key]); }
delete this._Sessions[cid].Windows[key];
}
}, null);
}
}
}
_updateStatus() {
var active = this.MDI.activeSubWindow();
if (active && active.hasOwnProperty('_Cid')) {
var Client = this._Sessions[active._Cid].Client;
if (Client.Socket && Client.Socket.readyState == 1) { this._StatusBar.innerText = Client.Me + " [+" + Client.UMode + "] on " + Client.Server + (Client.Latency != "" && !isNaN(Client.Latency) ? " Latency: " + Client.Latency + " ms" : ""); }
else { this._StatusBar.innerText = Client.Me + " (Not Connected)"; }
}
}
async _ShowNotification(icon,title,body,N) {
var granted = false;
if (Notification.permission === 'granted') { granted = true; }
else if (Notification.permission !== 'denied') {
var permission = await Notification.requestPermission();
granted = permission === 'granted' ? true : false;
}
if (granted) {
var notification = new Notification(title,{'icon': icon, 'body': body});
setTimeout(() => { notification.close(); },(N || 5000));
}
}
_stringify(IRCv3) {
var ret = [];
Object.keys(IRCv3).forEach((key) => {
if (key != 'clientonly') {
ret.push(key + "=" + IRCv3[key].replace(/([\x3B\x5C \r\n])/g,(m) => {
if (m == "\x3B") { return "\x5C:"; }
if (m == "\x5C") { return "\x5C\x5C"; }
if (m == " ") { return "\x5Cs"; }
if (m == "\r") { return "\x5Cr"; }
if (m == "\n") { return "\x5Cn"; }
}));
}
});
if (IRCv3.hasOwnProperty('clientonly')) {
Object.keys(IRCv3.clientonly).forEach((key) => {
ret.push("+" + key + "=" + IRCv3.clientonly[key].replace(/([\x3B\x5C \r\n])/g,(m) => {
if (m == "\x3B") { return "\x5C:"; }
if (m == "\x5C") { return "\x5C\x5C"; }
if (m == " ") { return "\x5Cs"; }
if (m == "\r") { return "\x5Cr"; }
if (m == "\n") { return "\x5Cn"; }
}));
});
}
return "@" + ret.join(";") + " ";
}