-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsqa.html
More file actions
1588 lines (1451 loc) · 42.2 KB
/
Copy pathsqa.html
File metadata and controls
1588 lines (1451 loc) · 42.2 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 lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>QChat</title>
<style>
:root {
--u: 1.8vw;
--c: #30f;
--c2: #90f;
--l41: #02d;
--l42: #0cf;
--l31: #050;
--l32: #8f8;
--l21: #f80;
--l22: #ff0;
--action: #205;
--action2: #2a006c;
--action3: #30a;
--grey: #555;
--grey-s: #5557;
--bg: #000;
--shadow: #0007;
--text: #fff;
--text-s: #fff5;
--text2: #ccc;
--fg: #141415;
--fg2: #1f1f20;
--fg3: #252526;
--border: #333;
--border2: #555;
--border-width: calc(.12 * var(--u));
--br: calc(1 * var(--u));
--chat-margin: calc(1 * var(--u));
}
body {
margin: 0;
background: var(--bg);
overflow: hidden;
}
* {
scrollbar-width: none;
}
*::-webkit-scrollbar {
display: none;
}
.btn {
--btn-h: var(--h);
--btn-s: var(--s);
--btn-l: var(--l);
--border: calc(.15 * var(--u));
box-sizing: border-box;
font-family: monospace;
font-size: calc(2 * var(--u));
color: var(--text);
background: hsl(var(--btn-h), calc(83% * var(--btn-s)), calc(57% * var(--btn-l)));
border: var(--border) solid hsl(var(--btn-h), calc(70% * var(--btn-s)), calc(48% * var(--btn-l)));
border-radius: var(--br);
box-shadow:
0 calc(var(--border)/2) calc(var(--border)/2) var(--border) hsla(var(--btn-h), calc(72% * var(--btn-s)), calc(30% * var(--btn-l)), 0.2),
inset 0 calc(-1 * var(--border)) var(--border) 0 hsl(var(--btn-h), calc(70% * var(--btn-s)), calc(48% * var(--btn-l))),
inset 0 0 0 var(--border) hsl(var(--btn-h), calc(92% * var(--btn-s)), calc(62% * var(--btn-l)));
transition: .2s;
}
.btn:hover {
--btn-l: calc(var(--l) * 1.05);
}
.btn:focus {
outline: none;
}
.btn::selection {
background: var(--c);
}
#top {
position: absolute;
top: 0;
left: 0;
height: calc(5 * var(--u));
display: flex;
align-items: center;
width: calc(100vw - var(--chat-margin) - calc(2 * var(--u)));
margin: 0 calc(2 * var(--u)) 0 var(--chat-margin);
gap: var(--chat-margin);
}
#top button {
position: relative;
background: transparent;
border: none;
width: calc(2.5 * var(--u));
height: calc(2.5 * var(--u));
}
#top button:focus {
outline: none;
}
#top button svg {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: calc(2.5 * var(--u));
height: calc(2.5 * var(--u));
stroke: var(--text);
}
#top .right {
margin-left: auto;
display: flex;
align-items: center;
gap: calc(1.2 * var(--chat-margin));
}
#top #channel {
user-select: none;
margin: 0;
font-family: monospace;
font-size: calc(2.5 * var(--u));
color: var(--grey);
}
#top p.mod {
user-select: none;
margin: 0;
font-family: monospace;
color: var(--text);
font-size: calc(2.5 * var(--u));
font-weight: 700;
}
.logo {
user-select: none;
margin: 0;
font-family: monospace;
color: var(--text);
font-size: calc(2.5 * var(--u));
}
.logo b {
font-weight: 700;
}
.logo .version {
color: var(--grey);
font-size: calc(2 * var(--u));
}
#info {
position: absolute;
bottom: calc(1 * var(--u));
width: calc(100vw - (1.2 * var(--u)) * 2);
margin: 0 calc(1.2 * var(--u));
display: flex;
justify-content: space-between;
align-items: center;
}
#info p {
margin: 0;
height: calc(2 * var(--u));
font-family: monospace;
font-size: calc(1.5 * var(--u));
color: var(--grey);
}
#info p::selection {
background: var(--grey-s);
}
#menu-wrapper {
pointer-events: none;
position: absolute;
top: 0;
left: -100vw;
width: 100vw;
height: 100vh;
z-index: 50;
display: grid;
grid-template-columns: auto calc(5 * var(--u));
transition: .5s;
}
#menu-wrapper #menu {
width: 100%;
height: 100%;
background: var(--bg);
box-shadow: 0 0 calc(5 * var(--u)) 0 var(--bg);
display: flex;
flex-direction: column;
align-items: center;
gap: calc(5 * var(--u));
overflow-y: scroll;
padding-bottom: calc(10 * var(--u));
box-sizing: border-box;
}
#menu-wrapper #menu .logo {
font-size: calc(3 * var(--u));
margin-top: calc(5 * var(--u));
text-align: center;
}
#menu-wrapper #menu div {
width: 100%;
height: max-content;
display: flex;
flex-direction: column;
align-items: center;
gap: calc(1 * var(--u));
}
#menu-wrapper #menu div[hidden] {
display: none;
}
#menu-wrapper #menu input[type="text"], #menu-wrapper #menu input[type="password"], #menu-wrapper #menu button {
width: 50%;
height: calc(5 * var(--u));
box-sizing: border-box;
font-family: monospace;
font-size: calc(2 * var(--u));
}
#menu-wrapper #menu input[type="text"]:focus, #menu-wrapper #menu input[type="password"]:focus, #menu-wrapper #menu button:focus {
outline: none;
border-color: var(--c);
}
#menu-wrapper #menu input[type="text"]::selection, #menu-wrapper #menu input[type="password"]::selection, #menu-wrapper #menu button::selection {
background: var(--c);
}
#menu-wrapper #menu input[type="text"], #menu-wrapper #menu input[type="password"] {
background: var(--fg);
border: var(--border-width) solid var(--border);
border-radius: var(--br);
font-family: monospace;
font-size: calc(2 * var(--u));
padding-left: calc(1.25 * var(--u));
color: var(--text);
}
#menu-wrapper #menu button {
background: var(--fg2);
border: var(--border-width) solid var(--border2);
border-radius: var(--br);
color: var(--text);
text-decoration: none;
}
#menu-wrapper #menu button:hover {
background: var(--fg3);
}
#menu-wrapper #menu h1, #menu-wrapper #menu h2, #menu-wrapper #menu p:not(.logo) {
width: 50%;
box-sizing: border-box;
font-family: monospace;
font-size: calc(2 * var(--u));
margin: 0;
text-align: center;
color: var(--text);
}
#menu-wrapper #menu h1::selection, #menu-wrapper #menu h2::selection, #menu-wrapper #menu p:not(.logo)::selection {
background: var(--text-s);
}
#menu-wrapper #menu .linkwrap {
width: 50%;
box-sizing: border-box;
}
#menu-wrapper #menu a {
width: min-content;
box-sizing: border-box;
font-family: monospace;
font-size: calc(1.5 * var(--u));
margin: 0;
text-decoration: underline;
cursor: pointer;
color: var(--grey);
}
#menu-wrapper #menu a::selection {
background: var(--grey-s);
}
#menu-wrapper #menu p:not(.logo) {
font-size: calc(1.5 * var(--u));
}
#menu-wrapper #menu #logout-section h2 {
margin: calc(1 * var(--u)) 0 calc(1.25 * var(--u)) 0;
}
#menu-wrapper #close-menu {
position: relative;
width: calc(5 * var(--u));
height: calc(5 * var(--u));
background: var(--bg);
border: none;
}
#menu-wrapper #close-menu:focus {
outline: none;
}
#menu-wrapper #close-menu svg {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: calc(2.5 * var(--u));
height: calc(2.5 * var(--u));
stroke: var(--text);
}
#menu-wrapper[data-active="1"] {
left: 0;
pointer-events: auto;
}
.lvl5 {
background: linear-gradient(to bottom, var(--c) 20%, var(--c2));
}
.lvl4 {
background: linear-gradient(to bottom, var(--l41) 20%, var(--l42));
}
.lvl3 {
background: linear-gradient(to bottom, var(--l31) 20%, var(--l32));
}
.lvl2 {
background: linear-gradient(to bottom, var(--l21) 20%, var(--l22));
}
.lvl5, .lvl4, .lvl3, .lvl2 {
background-clip: text;
-webkit-background-clip: text;
color: transparent !important;
-webkit-text-fill-color: transparent !important;
}
#chats {
position: absolute;
top: calc(5.5 * var(--u));
left: 50%;
transform: translateX(-50%);
width: calc(100vw - var(--chat-margin) * 2);
height: calc(100vh - (16.5 * var(--u)));
height: calc(100dvh - (16.5 * var(--u)));
padding-bottom: calc(1.25 * var(--u));
box-sizing: border-box;
overflow-x: hidden;
overflow-y: scroll;
display: flex;
flex-direction: column;
gap: calc(1.25 * var(--u));
}
#chats:focus {
outline: var(--border-width) solid var(--c);
}
.chat {
width: 100%;
height: min-content;
box-sizing: border-box;
background: var(--fg);
border: var(--border-width) solid var(--border);
border-radius: var(--br);
padding: 0 calc(.7 * var(--u)) calc(.5 * var(--u)) calc(.7 * var(--u));
}
.chat div {
display: flex;
align-items: center;
margin: 0;
margin-top: calc(.6 * var(--u));
gap: calc(.7 * var(--u));
}
.chat h1 {
font-family: monospace;
margin: 0;
font-size: calc(1.8 * var(--u));
font-weight: 700;
}
.chat h2 {
font-family: monospace;
margin: 0;
color: var(--grey);
font-size: calc(1.2 * var(--u));
font-weight: 700;
}
.chat h2::selection {
background: var(--grey-s);
}
.chat p {
margin: 0;
margin-top: calc(.7 * var(--u));
font-family: Arial;
font-size: calc(1.5 * var(--u));
font-weight: 500;
line-height: calc(2 * var(--u));
}
.chat h1, .chat p, .chat span {
color: var(--text);
}
.chat h1::selection, .chat p::selection, .chat span::selection {
background: var(--text-s);
}
.chat .mention {
padding: var(--border-width);
border: var(--border-width) solid var(--border);
border-radius: calc(var(--br) / 2);
}
.chat .mod {
margin: 0;
margin-left: auto;
gap: calc(.4 * var(--u));
display: none;
}
.chat:hover .mod {
display: flex;
}
.chat .mod[data-level="0"] .needsaccount {
display: none;
}
.chat .mod[data-ip="0"] .needsip {
display: none;
}
.chat .mod button {
position: relative;
background: transparent;
border: none;
width: calc(1.5 * var(--u));
height: calc(1.5 * var(--u));
padding: 0;
}
.chat .mod button:focus {
outline: none;
}
.chat .mod button svg {
position: absolute;
top: 0;
left: 0;
width: calc(1.5 * var(--u));
height: calc(1.5 * var(--u));
stroke: var(--text);
stroke-width: 2px;
}
.pending {
border-color: var(--border2);
}
#new {
display: flex;
align-items: center;
gap: calc(.4 * var(--u));
padding-left: calc(.7 * var(--u));
box-sizing: border-box;
background: var(--fg);
border: var(--border-width) solid var(--border);
border-radius: var(--br);
position: absolute;
bottom: calc(12.25 * var(--u));
right: calc(1 * var(--u));
box-shadow: 0 0 calc(1 * var(--u)) calc(-.5 * var(--u)) var(--bg);
transition: .2s;
z-index: 10;
}
#new p {
color: var(--text);
font-family: Arial;
margin: calc(.5 * var(--u)) 0;
font-size: calc(2 * var(--u));
}
#new svg {
width: calc(2 * var(--u));
height: calc(2 * var(--u));
}
#new svg path {
stroke: var(--text);
}
#new:hover {
background: var(--fg2);
border: var(--border-width) solid var(--border2);
transform: scale(1.03);
}
#new[hidden] {
display: none;
}
#error {
position: absolute;
top: calc(5 * var(--u));
left: 50%;
transform: translateX(-50%);
width: calc(100% - var(--chat-margin) * 2);
height: calc(100% - (16 * var(--u)));
box-sizing: border-box;
background: var(--fg);
border: var(--border-width) solid var(--border);
border-radius: var(--br);
z-index: 20;
}
#error p {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 80%;
text-align: center;
margin: 0;
font-size: calc(4 * var(--u));
color: var(--text);
font-family: monospace;
}
#chat-wrapper:has(#error:not([hidden]))::before, #chat-wrapper:has(#error:not([hidden]))::after {
height: calc(2 * var(--u));
background: var(--bg);
}
#bottom {
position: absolute;
bottom: 0;
left: 0;
width: 100vw;
height: calc(11 * var(--u));
background: var(--bg);
}
#top, #bottom {
z-index: 10;
box-shadow: 0 0 calc(1 * var(--u)) calc(.5 * var(--u)) var(--bg);
}
#msg-input {
position: absolute;
bottom: calc(4 * var(--u));
left: 50%;
transform: translateX(-50%);
width: calc(100vw - var(--chat-margin) * 2);
height: calc(7 * var(--u));
resize: none;
border-radius: calc(var(--br) * 2);
font-size: calc(2 * var(--u));
padding: calc(2.2 * var(--u)) calc(2 * var(--u));
box-sizing: border-box;
color: var(--text2);
background: var(--fg);
border: var(--border-width) solid var(--border);
transition: .4s;
}
#msg-input:focus {
outline: none;
border-color: var(--c);
}
#msg-input::selection {
background: var(--c);
color: var(--text);
}
.underlined {
color: var(--grey);
font-family: monospace;
font-weight: 500;
position: relative;
transition: .2s;
z-index: 2;
text-decoration: none;
}
.underline {
--widen: 0%;
--fix: 0%;
width: calc(100% + var(--widen));
transform: translateX(calc(-100% + var(--fix)));
height: 1px;
background: var(--grey);
position: absolute;
bottom: 0;
transition: .2s;
z-index: -1;
}
.underlined:hover {
color: var(--bg);
}
.underlined:hover .underline {
height: 100%;
}
.underlined::selection {
background: var(--text-s);
}
.template {
display: none;
}
#alert {
width: 100vw;
height: 100vh;
height: 100dvh;
position: absolute;
top: 0;
left: 0;
z-index: 100;
background: var(--shadow);
}
#alert #alert-box {
max-width: 80vw;
width: calc(50 * var(--u));
box-sizing: border-box;
padding: calc(2 * var(--u));
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: var(--fg);
border: var(--border-width) solid var(--border);
border-radius: calc(var(--br) * 2);
}
#alert #alert-box #alert-text {
margin: 0;
text-align: center;
font-size: calc(3 * var(--u));
font-weight: 500;
font-family: Arial;
color: var(--text);
}
#alert #alert-box #alert-input {
width: 100%;
margin-top: calc(2 * var(--u));
display: grid;
grid-template-columns: auto auto;
align-items: center;
gap: calc(1 * var(--u));
}
#alert #alert-box #alert-input p {
margin: 0;
font-size: calc(2 * var(--u));
font-weight: 500;
font-family: Arial;
color: #fff;
}
#alert #alert-box #alert-input[hidden] {
display: none;
}
#alert #alert-box input {
width: 100%;
height: calc(5 * var(--u));
box-sizing: border-box;
padding-left: calc(1.25 * var(--u));
background: var(--fg);
border: var(--border-width) solid var(--border);
border-radius: var(--br);
font-family: monospace;
font-size: calc(2 * var(--u));
color: #fff;
}
#alert #alert-box input:focus {
outline: none;
border-color: var(--c);
}
#alert #alert-box input::selection {
background: var(--c);
}
#alert #alert-box #alert-options {
display: flex;
width: 100%;
margin-top: calc(2 * var(--u));
gap: calc(.5 * var(--u));
align-items: center;
justify-content: center;
}
#alert #alert-box #alert-options button {
width: 100%;
height: calc(4 * var(--u));
--h: 0;
--s: 0;
--l: .4;
}
#alert #alert-box #alert-options button.action {
--h: 250;
--s: 1;
--l: 1;
}
.mod[hidden] {
display: none !important;
}
@media only screen and (min-aspect-ratio: 3/4) {
:root {
--u: 1.2vh;
}
}
@media only screen and (min-aspect-ratio: 1/1) {
#menu-wrapper {
left: -80vh;
grid-template-columns: calc(80vh - (5 * var(--u))) calc(5 * var(--u));
}
}
</style>
</head>
<body>
<div id="top">
<button onclick="burger(1)">
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g><path d="M4 6H20M4 12H20M4 18H20" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></g></svg>
</button>
<p class="logo"><b class="lvl5">Q</b>Chat <span class="version">v1.7.5</span></p>
<div class="right">
<p class="mod" hidden></p>
<p id="channel"></p>
</div>
</div>
<div id="menu-wrapper" data-active="0">
<div id="menu">
<p class="logo"><b class="lvl5">Q</b>Chat</p>
<div id="login-section">
<!-- <p>Enter display name:</p>
<input type="text" placeholder="Name" id="login-display" oninput="format(this)">
<p>OR</p> -->
<input type="text" placeholder="Username" id="login-user">
<input type="password" placeholder="Password" id="login-password">
<span class="linkwrap"><a onclick="forgotPassword()">Forgot Password</a></span>
<button onclick="login()">Log In</button>
<p>OR</p>
<button onclick="signup()">Sign Up</button>
</div>
<div id="logout-section" hidden>
<p>Signed in as:</p>
<h2 id="logged-in"></h2>
<button onclick="logout()">Logout</button>
<button onclick="editPassword()">Change Password</button>
</div>
<div id="mod-section" class="mod" hidden>
<p>Mod tools:</p>
<button onclick="modNuke()">Nuke Channel</button>
<button onclick="modClearTimeouts()">Clear Timeouts</button>
<button class="mod2" onclick="adminPanel()" hidden>Admin Panel</button>
</div>
<div id="settings-section">
<p>Settings:</p>
<button id="notif-toggle" onclick="toggleNotifications()">Notifications: Off</button>
<button class="mod" onclick="go('mods')" hidden>Mod Channel</button>
<button id="back" onclick="back()" hidden>Go Back</button>
</div>
</div>
<button id="close-menu" onclick="burger(0)">
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g><path d="M15 6L9 12L15 18" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></g></svg>
</button>
</div>
<div id="chats">
<div class="chat template">
<div>
<h1></h1>
<h2></h2>
<div class="mod" data-level="" data-ip="" hidden>
<button class="needsaccount mod2" onclick="modBan(this)" hidden>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g><path d="M18.364 18.364C19.9926 16.7353 21 14.4853 21 12C21 7.02944 16.9706 3 12 3C9.51472 3 7.26472 4.00736 5.63604 5.63604M18.364 18.364C16.7353 19.9926 14.4853 21 12 21C7.02944 21 3 16.9706 3 12C3 9.51472 4.00736 7.26472 5.63604 5.63604M18.364 18.364L5.63604 5.63604" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>
</button>
<button class="needsaccount" onclick="modTimeout(this, false)">
<svg style="transform: translateY(-3%)" viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g><path d="M12 14V11M12 6C7.85786 6 4.5 9.35786 4.5 13.5C4.5 17.6421 7.85786 21 12 21C16.1421 21 19.5 17.6421 19.5 13.5C19.5 11.5561 18.7605 9.78494 17.5474 8.4525M12 6C14.1982 6 16.1756 6.94572 17.5474 8.4525M12 6V3M19.5 6.5L17.5474 8.4525M12 3H9M12 3H15" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></g></svg>
</button>
<button class="needsip" onclick="modTimeout(this, true)">
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g><path fill="var(--text)" stroke="transparent" d="M1.33309 8.07433C0.92156 8.44266 0.886539 9.07485 1.25487 9.48638C1.62319 9.89791 2.25539 9.93293 2.66691 9.5646L1.33309 8.07433ZM21.3331 9.5646C21.7446 9.93293 22.3768 9.89791 22.7451 9.48638C23.1135 9.07485 23.0784 8.44266 22.6669 8.07433L21.3331 9.5646ZM12 19C11.4477 19 11 19.4477 11 20C11 20.5523 11.4477 21 12 21V19ZM12.01 21C12.5623 21 13.01 20.5523 13.01 20C13.01 19.4477 12.5623 19 12.01 19V21ZM14.6905 17.04C15.099 17.4116 15.7315 17.3817 16.1031 16.9732C16.4748 16.5646 16.4448 15.9322 16.0363 15.5605L14.6905 17.04ZM18.0539 13.3403C18.4624 13.7119 19.0949 13.682 19.4665 13.2734C19.8381 12.8649 19.8082 12.2324 19.3997 11.8608L18.0539 13.3403ZM7.96372 15.5605C7.55517 15.9322 7.52524 16.5646 7.89687 16.9732C8.2685 17.3817 8.90095 17.4116 9.3095 17.04L7.96372 15.5605ZM4.60034 11.8608C4.19179 12.2324 4.16185 12.8649 4.53348 13.2734C4.90511 13.682 5.53756 13.7119 5.94611 13.3403L4.60034 11.8608ZM10.5705 4.06305C10.0204 4.1118 9.61391 4.59729 9.66266 5.14741C9.71141 5.69754 10.1969 6.10399 10.747 6.05525L10.5705 4.06305ZM17.3393 10.3798C16.8567 10.1114 16.2478 10.285 15.9794 10.7677C15.711 11.2504 15.8847 11.8593 16.3673 12.1277L17.3393 10.3798ZM3.70711 2.29289C3.31658 1.90237 2.68342 1.90237 2.29289 2.29289C1.90237 2.68342 1.90237 3.31658 2.29289 3.70711L3.70711 2.29289ZM20.2929 21.7071C20.6834 22.0976 21.3166 22.0976 21.7071 21.7071C22.0976 21.3166 22.0976 20.6834 21.7071 20.2929L20.2929 21.7071ZM12 6C15.5863 6 18.8556 7.34716 21.3331 9.5646L22.6669 8.07433C19.8369 5.54138 16.0972 4 12 4V6ZM12 21H12.01V19H12V21ZM12 16C13.0367 16 13.9793 16.3931 14.6905 17.04L16.0363 15.5605C14.9713 14.5918 13.5536 14 12 14V16ZM9.3095 17.04C10.0207 16.3931 10.9633 16 12 16V14C10.4464 14 9.02872 14.5918 7.96372 15.5605L9.3095 17.04ZM10.747 6.05525C11.1596 6.01869 11.5775 6 12 6V4C11.5185 4 11.0417 4.0213 10.5705 4.06305L10.747 6.05525ZM16.3673 12.1277C16.9757 12.466 17.5412 12.874 18.0539 13.3403L19.3997 11.8608C18.7751 11.2927 18.0844 10.7941 17.3393 10.3798L16.3673 12.1277ZM2.29289 3.70711L5.46648 6.8807L6.8807 5.46648L3.70711 2.29289L2.29289 3.70711ZM2.66691 9.5646C3.81213 8.53961 5.12648 7.70074 6.56232 7.09494L5.78486 5.25224C4.14251 5.94517 2.64069 6.904 1.33309 8.07433L2.66691 9.5646ZM5.46648 6.8807L9.46042 10.8746L10.8746 9.46042L6.8807 5.46648L5.46648 6.8807ZM9.46042 10.8746L20.2929 21.7071L21.7071 20.2929L10.8746 9.46042L9.46042 10.8746ZM5.94611 13.3403C7.15939 12.2367 8.67355 11.4612 10.3496 11.1508L9.98543 9.18424C7.93271 9.5644 6.08108 10.5139 4.60034 11.8608L5.94611 13.3403Z"></path></g></svg>
</button>
<button onclick="modDelete(this)">
<svg style="transform: translateX(-3%)" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g><path d="M6 6L18 18M18 6L6 18" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></g></svg>
</button>
</div>
</div>
<p></p>
</div>
</div>
<button id="new" onclick="scrollBottom()" hidden>
<p>New</p>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g><path d="M12 6V18M12 18L7 13M12 18L17 13" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></g></svg>
</button>
<div id="error" hidden>
<p></p>
</div>
<dialog id="alert">
<div id="alert-box">
<p id="alert-text">Example</p>
<div id="alert-input" hidden></div>
<div id="alert-options">
<button class="btn" id="alert-cancel">CANCEL</button>
<button class="btn action" id="alert-ok">OK</button>
</div>
</div>
</dialog>
<div id="bottom">
<textarea id="msg-input" placeholder="Loading..."></textarea>
<div id="info">
<p id="domain">qchat.lol</p>
<p>Made by <span><a class="underlined" href="https://qwkdev.github.io/" target="_blank" aria-label="label">qwk<span class="underline" style="--widen: 5%; --fix: 1%;"></span></a></span></p>
</div>
</div>
<script>
const MAX_NAME_LENGTH = 16;
function safeText(text) {
return text.replace(/[^a-zA-Z0-9_-]/g, '').slice(0, MAX_NAME_LENGTH);
}
const CHANNEL = safeText(window.location.pathname.slice(1)) || 'main';
const SERVER = 'https://qchat.pythonanywhere.com';
// const SERVER = 'http://127.0.0.1:5000';
let session = {
auth: null,
user: null,
level: 0
}
function saveSession() {
if (session.auth) localStorage.setItem('token', session.auth);
else localStorage.removeItem('token');
if (session.user) localStorage.setItem('user', session.user);
else localStorage.removeItem('user');
}
const loginSection = document.getElementById('login-section');
const menuEle = {
// display: document.getElementById('login-display'),
user: document.getElementById('login-user'),
password: document.getElementById('login-password'),
loggedin: document.getElementById('logged-in')
}
const logoutSection = document.getElementById('logout-section');
function format(e) {
e.value = safeText(e.value);
}
function go(path='') {
window.location.href = '/' + (path ?? '') + `?from=${params.get('from') && path === CHANNEL ? params.get('from') : CHANNEL}`;
}
const params = new URLSearchParams(window.location.search);
function back() {
go(params.get('from'));
}
const backButton = document.getElementById('back');
backButton.hidden = !params.get('from');
const modLabel = document.querySelector('#top .right .mod');
function fixMenuSections() {
if (!session.user) {
loginSection.hidden = false;
logoutSection.hidden = true;
menuEle.user.value = '';
menuEle.password.value = '';
} else {
loginSection.hidden = true;
logoutSection.hidden = false;
menuEle.loggedin.innerText = parseUser(session.user, session.level);
menuEle.loggedin.className = `lvl${Number(session.level) || 0}`;
}
const modHidden = !session.user || session.level < 3;
const mod2Hidden = !session.user || session.level < 4;
if (!modHidden) {
modLabel.classList = `mod lvl${session.level}`;
if (session.level === 3) modLabel.innerText = 'MOD';
if (session.level === 4) modLabel.innerText = 'ADMIN';
if (session.level === 5) modLabel.innerText = 'DEV';
}
document.querySelectorAll('.mod').forEach(e => e.hidden = modHidden);
document.querySelectorAll('.mod2').forEach(e => e.hidden = mod2Hidden);
}
function editPassword() {
window.location.href = `/account/password/edit?from=${CHANNEL}`;
}
function forgotPassword() {
window.location.href = `/account/password/forgot?from=${CHANNEL}`;
}
function signup() {
window.location.href = `/signup?from=${CHANNEL}`;
}
function loginUser(data) {
session.auth = data.auth || null;
session.user = data.user || null;
session.level = data.level || 0;
saveSession();
menuEle.password.value = '';
fixMenuSections();
showError();
resetChat();
}
async function login() {
if (!menuEle.user.value || !menuEle.password.value) return;
await fetch(`${SERVER}/login`, {
method: 'POST',
// credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
user: menuEle.user.value.includes('@') ? menuEle.user.value : '@' + menuEle.user.value,
password: menuEle.password.value
})
})
.then(resp => resp.json())
.then(data => {
if (data.success === true) loginUser(data)
else showError('Client Error:', data.error);
})
.catch(e => showError('Network Error:', e));
}
async function logout() {
await fetch(`${SERVER}/logout`, {
method: 'POST',
// credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
auth: session.auth,
user: getUser()
})
})
.then(resp => resp.json())
.then(data => {
if (data.success !== true) showError('Client Error:', data.error);
session.user = null;
session.level = 0;
saveSession();
fixMenuSections();
})
.catch(e => showError('Network Error:', e));
}
function parseChannel(channel) {
if (
!channel.startsWith('~') &&
!channel.startsWith('^')
) {
return `#${channel}`;
} else return channel;
}
const channelName = parseChannel(CHANNEL);
document.getElementById('channel').innerText = channelName;
document.getElementById('domain').innerText += '/' + CHANNEL;
const msgInput = document.getElementById('msg-input');
msgInput.placeholder = `Message ${channelName}`;
const errorWall = document.getElementById('error');
const chat = document.getElementById('chats');
const chatTemplate = document.querySelector('.chat.template');
function scrollBottom(smooth=true) {
chat.scrollTo({ top: chat.scrollHeight, behavior: smooth ? 'smooth' : 'instant' });
}
async function resetChat() {
chat.querySelectorAll('.chat:not(.template)').forEach(e => e.remove());
await sync(false);
setTimeout(() => scrollBottom(false), 100);
}
function parseEpoch(epoch) {
if (epoch === 0) return '';
const date = new Date( epoch*1000 );
const now = new Date();
const isToday =
date.getDate() === now.getDate() &&
date.getMonth() === now.getMonth() &&
date.getFullYear() === now.getFullYear();
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
if (isToday) {
return `${hours}:${minutes}`;
} else {
const day = String(date.getDate()).padStart(2, '0');
const month = String(date.getMonth() + 1).padStart(2, '0');
return `${hours}:${minutes} ${day}/${month}`;
}
}
function parseUser(user, level) {
if (level === 0) return user;
// else if (level === 4) return `[${user}]`;
else return `@${user}`;
// switch (level) {
// case 0: return user;
// case 1: return `@${user}`;
// case 2: return `;${user}`;
// case 3: return `^${user}`;
// case 4: return `[${user}]`;
// default: return user;
// }
}
function getUser(force=false) {
const resp = session.user ? parseUser(session.user, session.level) : false