aboutsummaryrefslogtreecommitdiff
path: root/html/display.html
blob: b9cf7188d3e557dd6ad55553c926d5919805e60c (plain)
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
<html>

<head>
    <!--<script src="https://raw.githubusercontent.com/a-weeb-programmer/libcute/main/src/libcute.h"></script> lol-->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <script rel="preconnect" src="./src/jssh.js" crossorigin></script>
    <script rel="preconnect" src="./src/window-utils.js" crossorigin></script>
    <link href="https://fonts.googleapis.com/css2?family=Flow+Circular&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">
    <style>
        @font-face {
            font-family: f98;
            src: url(src/98.ttf);
        }

        * {
            margin: 0;
            font-family: f98;
            font-size: 15px;
            scrollbar-width: none;
        }

        .window {
            width: 56%;
            max-width: inherit;
            height: 30%;
            max-height: inherit;
            background-color: #c3c3c3;
            position: absolute;
        }

        .head-border {
            width: calc(100%);
            background: linear-gradient(90deg, rgba(1, 0, 129, 1) 0%, rgba(0, 128, 128, 1) 100%);
            height: 25px;
            position: absolute;
            top: 0;
            left: 0;
            cursor: grab;
        }

        .close-button {
            width: calc(25px - 7px);
            background-color: #c3c3c3;
            height: calc(100% - 7px);
            position: absolute;
            top: 3.5px;
            right: 3.5px;
            cursor: initial;

        }

        #root {
            position: relative;
            background-color: cornsilk;
            background-image: url("src/img/wallpaper.jpg");
            background-repeat: no-repeat;
            background-origin: content-box;
            background-attachment: fixed;
            background-position: center center;
            -webkit-background-size: cover;
            -moz-background-size: cover;
            -o-background-size: cover;
            background-size: cover;
            width: 90%;
            height: 90%;
            margin-left: 5%;
            margin-top: 2.5%;
            margin-bottom: 2.5%;
            overflow: hidden;

        }

        .resize-n {
            position: absolute;
            top: -1px;
            width: 100%;
            height: 7px;
            background-color: rgba(0, 0, 0, 0);
            cursor: ns-resize;
        }

        .resize-s {
            position: absolute;
            bottom: -1px;
            width: 100%;
            height: 7px;
            background-color: rgba(0, 0, 0, 0);
            cursor: ns-resize;
        }

        table {
            display: table;
        }

        table tr {
            display: table-cell;
        }

        table tr td {
            display: block;
        }

        .resize-e {
            position: absolute;
            right: -3px;
            width: 7px;
            height: 100%;
            background-color: rgba(0, 0, 0, 0);
            cursor: ew-resize;
        }

        .resize-w {
            position: absolute;
            left: -3px;
            width: 7px;
            height: 100%;
            background-color: rgba(0, 0, 0, 0);
            cursor: ew-resize;

        }

        .resize-ne {
            position: absolute;
            right: -3px;
            top: -3px;
            width: 15px;
            height: 15px;
            background-color: rgba(255, 0, 0, 0);
            cursor: ne-resize;

        }

        .resize-es {
            position: absolute;
            right: -3px;
            bottom: -3px;
            width: 15px;
            height: 15px;
            background-color: rgba(255, 0, 0, 0);
            cursor: se-resize;

        }

        .resize-sw {
            position: absolute;
            left: -3px;
            bottom: -3px;
            width: 15px;
            height: 15px;
            background-color: rgba(255, 0, 0, 0);
            cursor: sw-resize;

        }

        .resize-nw {
            position: absolute;
            left: -3px;
            top: -3px;
            width: 15px;
            height: 15px;
            background-color: rgba(255, 0, 0, 0);
            cursor: nw-resize;

        }


        ::-webkit-scrollbar {
            display: none;
        }

        .scrollbar {
            width: 10px;
            height: calc(100% - 25px);
            background-color: #aaaaaa;
            position: absolute;
            bottom: 0;
            right: 0;
        }

        .scrollbar-point {
            width: 100%;
            max-height: 100%;
            background-color: #999999;
            position: absolute;
            top: 0;
            outline: 2px outset;
            outline-offset: -2px;
            cursor: grab;
        }

        #bar {
            width: 100%;
            height: 30px;
            background-color: #c3c3c3;
            position: absolute;
            bottom: 0;
            display: inline-block;
            left: 0;
        }

        .bar-item {
            height: 80%;
            background-color: #c3c3c3;
            width: fit-content;
            padding-left: 20px;
            padding-right: 20px;
            border-style: outset;
            cursor: grab;
            user-select: none;
            display: block;
            position: absolute;
            top: 0;
        }

        #bar-items {
            height: 100%;
            width: 100%;
            position: relative;
            display: block;
        }

        #bar-children {
            position: relative;
            width: 100%;
            height: 100%;
            display: flex;

        }

        #bar-menu {
            display: flex;
            position: relative;
            height: calc(100% - 5px);
            font-size: large;
            padding: 3px;
            user-select: none;
            padding-left: 10px;
            padding-right: 10px;
            outline: 2px outset;
            outline-offset: -2px;
            cursor: pointer;


        }

        #bar-menu-root {
            padding-top: 2px;
            height: 280px;
            width: 180px;
            background-color: #c7c7c7;
            position: absolute;
            border-style: outset;
            bottom: 30px;
            display: none;
        }

        .bar-menu-item {
            padding-left: 5px;
            width: 100%;
            height: 25px;
            display: flex;
            font-size: 14px;
            font-weight: bold;
            padding-top: 1px;
            user-select: none;
        }

        .bar-menu-image {
            height: 18px;
            padding-left: 5px;
            padding-right: 5px;
        }

        .bar-menu-text {
            position: absolute;
            left: 35px;
            padding-top: 2px;
        }

        .bar-menu-separator {
            width: calc(100% - 20px);
            height: 3px;
            margin-bottom: 5px;
            background-color: #a1a1a1;
            border-style: none none solid none;
            border-color: #dddddd;
            border-width: 2px;
            left: 10px;
            position: relative;
        }

        .bar-menu-more {
            width: 0;
            height: 0;
            border-top: 5px solid transparent;
            border-left: 7px solid #000000;
            border-bottom: 5px solid transparent;
            position: absolute;
            right: 5px;
            margin-top: 6px;

        }

        .bar-menu-more-root {
            display: none;
            width: 120px;
            height: fit-content;
            border-style: outset outset outset none;
            right: -123px;
            position: absolute;
            padding-top: 3px;
            background-color: #c7c7c7;
            overflow: hidden;
        }

        .fd-bottom {
            width: 100%;
            height: 26px;
            background-color: #b1b1b1;
            position: absolute;
            bottom: 0;
            overflow: hidden;
            white-space: nowrap;
        }

        textarea {
            resize: none;
            background-color: rgba(0, 0, 0, 0);
            border: none;
            outline: none;
            overflow: scroll;
            -webkit-box-shadow: none;
            -moz-box-shadow: none;
            box-shadow: none;
        }

        input {
            background-color: rgba(0, 0, 0, 0);
            text-shadow: 0 0 10px white;
            border: none;
            color: inherit;
        }

        input {
            border: 0;
            outline: 0;
        }

        input:focus {
            outline: none !important;
        }

        input:hover {
            cursor: text;
        }

        button {
            border-radius: 0px;
            background-color: #c1c1c1;
        }
    </style>
    <script>
        function compare(a, b) {
            if (a.left < b.left) {
                return -1;
            }
            if (a.left > b.left) {
                return 1;
            }
            return 1;
        }
        let bar_items_left = []
        function load_bar() {
            document.getElementById("bar-menu").onclick = ((ev) => {
                if (document.getElementById("bar-menu-root").style.display == "block")
                    document.getElementById("bar-menu-root").style.display = "none"
                else
                    document.getElementById("bar-menu-root").style.display = "block"
            })
            let items = document.getElementById("bar-menu-root").children
            for (let item = 0; item != items.length; item++) {
                //console.log(items.item(item))
                if (items.item(item).className == "bar-menu-item") {
                    let i_c = items.item(item).children
                    for (let i = 0; i != i_c.length; i++) {
                        let id = i_c.item(i)
                        if (id.className == "bar-menu-more-root") {

                            let t_s = new jssh(fs, '/', document.getElementsByClassName('window').length, 'null', 'null')
                            let dd = (t_s.set_wd(items.item(item).getAttribute("dir")))
                            if (dd[0] == undefined) { //item is null
                                id.innerHTML = '';
                                items.item(item).onmouseover = null
                                break
                                //! TODO: don't show bar if dir is empty or null
                            }
                            /*
                            <div class="bar-menu-item" id="bar-menu-favorites"><img class="bar-menu-image"
                                src="./src/img/notepad.png">
                            <div class="bar-menu-text">Notepad--</div>
                        </div>
                            */
                            id.innerHTML = ''
                            let ins = ""
                            for (let ite = 0; ite != dd.length; ite++) {
                                if (dd[ite].dir == false) {
                                    let icon = ""
                                    ins += `<div class="bar-menu-item" onclick="shortcut('${items.item(item).getAttribute("dir") + dd[ite].name}');close_menu();" id="bar-menu-${dd[ite].name}">`
                                    //if (dd[ite].icon)
                                    //icon = `<img class="bar-menu-image" src="${dd[ite].icon}">`
                                    //else {

                                    for (let l of dd[ite].content.split("\n")) {
                                        if (l.split(" ")[0] == "meta") {
                                            let tem = l.split(" ")
                                            tem.splice(0, 1);
                                            tem = tem.join(" ")
                                            //console.log(tem)
                                            tem = tem.split(",")
                                            //console.log(tem)
                                            for (let tw of tem) {
                                                if (tw.trim().split(" ")[0] == "icon") {
                                                    icon = `<img class="bar-menu-image" src="${tw.trim().split(" ")[1]}">`
                                                }
                                            }
                                            /*if (l.split(" ")[1] == "icon") {
                                                icon = `<img class="bar-menu-image" src="${l.split(" ")[2]}">`
                                            }*/

                                        }
                                    }
                                    ins += icon
                                    //}
                                    ins += `<div class="bar-menu-text">${dd[ite].name}</div></div>`


                                    //console.log(id.children.item(ite))
                                }
                            }
                            id.innerHTML = ins;
                            items.item(item).onmouseover = ((ev) => {
                                id.style.display = "block"
                                items.item(item).onmouseout = ((ev) => {
                                    id.style.display = "none"
                                })
                            })
                            break;
                        }
                    }
                }
            }
            let bar = document.getElementById("bar-items")
            let windows = document.getElementsByClassName("window")
            let put = ""
            let last_left = 0;
            let temp = []
            bar.innerHTML = ""
            for (let i = 0; i != windows.length; i++) {
                bar.innerHTML += "<div style='left:" + last_left + ";' id='" + windows.item(i).id + "-bar' class='bar-item'>" + windows.item(i).getAttribute("window-name") + "</div>"
                temp.push({ left: last_left, id: windows.item(i).id, width: bar.children.item(bar.children.length - 1).clientWidth + 5 })
                last_left += bar.children.item(bar.children.length - 1).clientWidth + 5


            }
            bar_items_left = temp;
            //bar.innerHTML = put;
            for (let i = 0; i != bar.children.length; i++) {
                let elemy = bar.children.item(i)
                for (let ii = 0; ii != windows.length; ii++) {
                    if (windows.item(ii).id + "-bar" == elemy.id) {
                        //let px = 0, py = 0;

                        elemy.onmousedown = ((ev) => {
                            for (let iii = 0; iii != windows.length; iii++) {
                                windows.item(iii).style.zIndex = 0;
                                bar.children.item(iii).style.zIndex = 0;
                            }
                            document.body.style.cursor = "grabbing"
                            windows.item(ii).style.zIndex = 1
                            bar.children.item(ii).style.zIndex = 1;
                            document.onmouseup = ((ev) => {
                                document.onmousemove = null
                                document.body.style.cursor = ''
                                temp = [];
                                for (let iii = 0; iii != bar.children.length; iii++) {
                                    temp.push({ left: bar.children.item(iii).offsetLeft, id: bar.children.item(iii).id, width: bar.children.item(iii).clientWidth + 5 })
                                }
                                temp = temp.sort(compare)
                                bar_items_left = []
                                let len = 0
                                for (let item in temp) {
                                    for (let iii = 0; iii != bar.children.length; iii++) {
                                        if (bar.children.item(iii).id == temp[item].id) {
                                            bar.children.item(iii).style.left = len
                                            bar_items_left.push({ left: len, id: bar.children.item(iii).id, width: bar.children.item(iii).clientWidth + 5 })
                                            len += temp[item].width

                                        }
                                    }

                                }

                            })
                            let px = 0;
                            document.onmousemove = ((evm) => {
                                if ((elemy.parentElement.clientWidth * (evm.clientX / elemy.parentElement.clientWidth) - (elemy.parentElement.offsetLeft + document.getElementById("root").offsetLeft + (elemy.clientWidth / 2))) > 0) {
                                    if ((elemy.parentElement.clientWidth * (evm.clientX / elemy.parentElement.clientWidth) - (elemy.parentElement.offsetLeft + document.getElementById("root").offsetLeft - (elemy.clientWidth / 2))) < elemy.parentElement.clientWidth - 5) {
                                        elemy.style.left = (elemy.parentElement.clientWidth * (evm.clientX / elemy.parentElement.clientWidth) - (elemy.parentElement.offsetLeft + document.getElementById("root").offsetLeft + (elemy.clientWidth / 2)))
                                    } else {
                                        elemy.style.left = elemy.parentElement.clientWidth - elemy.clientWidth - 5
                                    }
                                } else {
                                    elemy.style.left = 0;
                                }
                                //console.log((px - evm.clientX), px, evm.clientX, m)

                            })
                        })
                    }
                }
            }
        }
        let minx = 150;
        let miny = 150;
        function window_create(uid, name, content, options = {}) {
            let promise = new Promise((res, rej) => {
                let lines = content.split("</br>").length
                let a = ''
                let size = (options.width != undefined && options.height != undefined) ? ("width:" + options.width + "px;height:" + options.height + "px;") : ("width:" + Math.max(document.body.clientWidth * .36, minx) + "px;height:" + Math.max(miny, document.body.clientHeight * .30) + "px;");
                let pos = (options.left != undefined && options.top != undefined) ? ("left:" + options.left + "px;top:" + options.top + "px;") : ("left:0px;top:0px;");
                a += "<div id='" + uid + "-root' class='window' style=\"" + size + pos + "position:absolute;\" window-name='" + name + "'>"
                //console.log(document.getElementById(uid).attributes["window-name"].value)
                a += "<div id='" + uid + "-head' class='head-border' window-name='" + name + "'> <div style='color:fdffff'>" + name + "</div>"
                a += "<div id='" + uid + "-close' class='close-button' window-name='" + name + "'>" + `<svg draggable="false" xmlns="http://www.w3.org/2000/svg" style="position:absolute;left:-3px;top:0px;" xmlns:xlink="http://www.w3.org/1999/xlink" width="23px" height="20px" viewBox="0 0 23 20" version="1.1">
<g id="surface1">
<path style=" stroke:none;fill-rule:evenodd;fill:rgb(2.745098%,3.137255%,2.745098%);fill-opacity:1;" d="M 8.476562 6.042969 C 9.042969 6.042969 9.613281 6.042969 10.179688 6.042969 C 10.179688 6.332031 10.179688 6.625 10.179688 6.914062 C 10.464844 6.914062 10.746094 6.914062 11.03125 6.914062 C 11.03125 7.203125 11.03125 7.492188 11.03125 7.78125 C 11.597656 7.78125 12.167969 7.78125 12.734375 7.78125 C 12.734375 7.492188 12.734375 7.203125 12.734375 6.914062 C 13.019531 6.914062 13.304688 6.914062 13.585938 6.914062 C 13.585938 6.625 13.585938 6.332031 13.585938 6.042969 C 14.15625 6.042969 14.722656 6.042969 15.289062 6.042969 C 15.289062 6.332031 15.289062 6.625 15.289062 6.914062 C 15.007812 6.914062 14.722656 6.914062 14.4375 6.914062 C 14.4375 7.203125 14.4375 7.492188 14.4375 7.78125 C 14.15625 7.78125 13.871094 7.78125 13.585938 7.78125 C 13.585938 8.074219 13.585938 8.363281 13.585938 8.652344 C 13.304688 8.652344 13.019531 8.652344 12.734375 8.652344 C 12.734375 8.941406 12.734375 9.230469 12.734375 9.523438 C 13.019531 9.523438 13.304688 9.523438 13.585938 9.523438 C 13.585938 9.8125 13.585938 10.101562 13.585938 10.390625 C 13.871094 10.390625 14.15625 10.390625 14.4375 10.390625 C 14.4375 10.679688 14.4375 10.972656 14.4375 11.261719 C 14.722656 11.261719 15.007812 11.261719 15.289062 11.261719 C 15.289062 11.550781 15.289062 11.839844 15.289062 12.128906 C 14.722656 12.128906 14.15625 12.128906 13.585938 12.128906 C 13.585938 11.839844 13.585938 11.550781 13.585938 11.261719 C 13.304688 11.261719 13.019531 11.261719 12.734375 11.261719 C 12.734375 10.972656 12.734375 10.679688 12.734375 10.390625 C 12.167969 10.390625 11.597656 10.390625 11.03125 10.390625 C 11.03125 10.679688 11.03125 10.972656 11.03125 11.261719 C 10.746094 11.261719 10.464844 11.261719 10.179688 11.261719 C 10.179688 11.550781 10.179688 11.839844 10.179688 12.128906 C 9.613281 12.128906 9.042969 12.128906 8.476562 12.128906 C 8.476562 11.839844 8.476562 11.550781 8.476562 11.261719 C 8.761719 11.261719 9.042969 11.261719 9.328125 11.261719 C 9.328125 10.972656 9.328125 10.679688 9.328125 10.390625 C 9.613281 10.390625 9.894531 10.390625 10.179688 10.390625 C 10.179688 10.101562 10.179688 9.8125 10.179688 9.523438 C 10.464844 9.523438 10.746094 9.523438 11.03125 9.523438 C 11.03125 9.230469 11.03125 8.941406 11.03125 8.652344 C 10.746094 8.652344 10.464844 8.652344 10.179688 8.652344 C 10.179688 8.363281 10.179688 8.074219 10.179688 7.78125 C 9.894531 7.78125 9.613281 7.78125 9.328125 7.78125 C 9.328125 7.492188 9.328125 7.203125 9.328125 6.914062 C 9.042969 6.914062 8.761719 6.914062 8.476562 6.914062 C 8.476562 6.625 8.476562 6.332031 8.476562 6.042969 Z M 8.476562 6.042969 "/>
</g>
</svg></div></div>`
                if (options.resize != false && options.resize != "false") {
                    a += "<div id='" + uid + "-resize-n' class='resize-n'></div>"
                    a += "<div id='" + uid + "-resize-s' class='resize-s'></div>"
                    a += "<div id='" + uid + "-resize-e' class='resize-e'></div>"
                    a += "<div id='" + uid + "-resize-w' class='resize-w'></div>"
                }
                a += "<div style='height:25px;'></div>"
                a += "<div id='" + uid + "-content-root' class='content-root' style='overflow:scroll;height:calc(100% - 26px);width:100%'>"

                a += "<div id='" + uid + "-content-content' class='content-content'>" + content + "</div>"
                if (options.scroll != false && options.scroll != "false") {
                    a += "<div id='" + uid + "-content-scrollbar' class='scrollbar'><div id='" + uid + "-content-scrollbar-point' class='scrollbar-point'></div>"
                    a += "</div>"
                }
                a += "</div>"
                if (options.resize != false && options.resize != "false") {
                    a += "<div id='" + uid + "-resize-ne' class='resize-ne'></div>"
                    a += "<div id='" + uid + "-resize-nw' class='resize-nw'></div>"
                    a += "<div id='" + uid + "-resize-sw' class='resize-sw'></div>"
                    a += "<div id='" + uid + "-resize-es' class='resize-es'></div>"
                }
                document.getElementById("root").innerHTML += a
                //console.log(document.getElementById(uid + "-content-root").clientHeight / (document.getElementById(uid + "-content-content").clientHeight / document.getElementById(uid + "-content-root").clientHeight))

                //console.log(document.getElementById(uid + "-content-scrollbar-point"))
                refresh_windows()
                res()
            })
            return promise
        }
        function refresh_windows() {
            load_bar()
            let elems = document.getElementsByClassName("window")
            for (let i = 0; i != elems.length; i++) {
                let uid = elems.item(i).id.split("-")[0]
                try {
                    document.getElementById(uid + "-content-scrollbar-point").style.height = (document.getElementById(uid + "-content-root").clientHeight / (document.getElementById(uid + "-content-content").clientHeight / document.getElementById(uid + "-content-root").clientHeight)) + "px"

                    if (document.getElementById(uid + "-content-scrollbar-point").clientHeight >= document.getElementById(uid + "-content-root").clientHeight) {
                        document.getElementById(uid + "-content-scrollbar").style.display = 'none'
                    }
                    else {
                        if (document.getElementById(uid + "-content-scrollbar").style.display == 'none') {
                            document.getElementById(uid + "-content-scrollbar").style.display = 'block'
                            if (document.getElementById(uid + "-content-scrollbar-point").clientHeight >= document.getElementById(uid + "-content-root").clientHeight) {
                                document.getElementById(uid + "-content-scrollbar").style.display = 'none'
                            }
                        }
                    }
                } catch (e) { }
                //let elem = elems.item(i).children[0]
                let elec = elems.item(i).children
                let elem
                //console.log(elec)
                for (let ii = 0; ii != elec.length; ii++) {
                    if (elec.item(ii).className == 'head-border') {
                        elem = elec.item(ii)
                        for (let iii = 0; iii != elem.children.length; iii++) {
                            if (elem.children.item(iii).className == "close-button") {
                                //console.log(elem.children.item(iii))
                                let ii = elems.item(i)
                                elem.children.item(iii).onmousedown = ((ev) => {
                                    //console.log(elems.item(i))
                                    //onkill.apply(this)
                                    delete procs[elem.id.split("-")[0]]
                                    ii.remove()
                                    load_bar()
                                })
                                break
                            }
                        }
                        break
                    }
                }
                let elep = elems.item(i)
                let px = 0, py = 0;

                if (elem.className == 'head-border') {
                    elemhb = elem
                    elem.onmousedown = ((ev) => {

                        for (let i = 0; i != elems.length; i++) {
                            elems.item(i).style.zIndex = 0;
                        }
                        elep.style.zIndex = 1
                        document.body.style.cursor = 'grabbing'
                        elemhb.style.cursor = 'grabbing'
                        px = ev.clientX
                        py = ev.clientY
                        document.body.style.userSelect = "none"
                        document.onmouseup = ((evu) => {
                            document.body.style.userSelect = "unset"
                            document.onmousemove = null
                            document.onmouseup = null
                            document.body.style.cursor = ''
                            elemhb.style.cursor = 'grab'
                        })
                        document.onmousemove = ((evm) => {
                            //console.log(elem.id)
                            elep.style.left = (elep.offsetLeft - (px - evm.clientX)) + "px"
                            elep.style.top = (elep.offsetTop - (py - evm.clientY)) + "px"
                            px = (evm.clientX)
                            py = (evm.clientY)
                        })
                    })
                }


                ['resize-s', 'resize-n', 'resize-e', 'resize-w', 'resize-ne', 'resize-nw', 'resize-sw', 'resize-es'].forEach((sel) => {
                    for (let ii = 0; ii != elec.length; ii++) {
                        if (elec.item(ii).className == sel) {
                            elem = elec.item(ii)
                            break
                        }
                    }
                    if (elem.className == sel) {
                        elem.onmousedown = ((ev) => {
                            px = ev.clientX
                            py = ev.clientY
                            if (sel == 'resize-s' || sel == 'resize-n')
                                document.body.style.cursor = 'ns-resize'
                            else if (sel == 'resize-e' || sel == 'resize-w')
                                document.body.style.cursor = 'ew-resize'
                            else if (sel == 'resize-ne')
                                document.body.style.cursor = 'ne-resize'
                            else if (sel == 'resize-nw')
                                document.body.style.cursor = 'nw-resize'
                            else if (sel == 'resize-sw')
                                document.body.style.cursor = 'sw-resize'
                            else if (sel == 'resize-es')
                                document.body.style.cursor = 'se-resize'
                            document.body.style.userSelect = "none"
                            document.onmouseup = ((evu) => {
                                document.body.style.userSelect = "unset"
                                document.onmousemove = null
                                document.onmouseup = null
                                document.body.style.cursor = ''

                            })
                            document.onmousemove = ((evm) => {
                                if (sel == 'resize-s' || sel == 'resize-es' || sel == 'resize-sw')
                                    if ((parseInt(elep.style.height.replace("px", "")) + (evm.clientY - py)) > miny) {
                                        elep.style.height = (parseInt(elep.style.height.replace("px", "")) + (evm.clientY - py)) + "px"
                                    } if (sel == 'resize-n' || sel == 'resize-nw' || sel == 'resize-ne') {
                                        if ((parseInt(elep.style.height.replace("px", "")) - (evm.clientY - py)) > miny) {
                                            elep.style.top = (elep.offsetTop - (py - evm.clientY)) + "px"
                                            elep.style.height = (parseInt(elep.style.height.replace("px", "")) - (evm.clientY - py)) + "px"
                                            //console.log(elem.parentElement.parentElement.parentElement)

                                            //document.getElementById(uid + "-content-scrollbar-point").style.height = (document.getElementById(uid + "-content-root").clientHeight / (document.getElementById(uid + "-content-content").clientHeight / document.getElementById(uid + "-content-root").clientHeight)) + "px"
                                        }
                                    }
                                if (sel == 'resize-e' || sel == 'resize-es' || sel == 'resize-ne')
                                    if ((parseInt(elep.style.width.replace("px", "")) + (evm.clientX - px)) > minx) {
                                        elep.style.width = (parseInt(elep.style.width.replace("px", "")) + (evm.clientX - px)) + "px"
                                    } if (sel == 'resize-w' || sel == 'resize-nw' || sel == 'resize-sw') {
                                        //console.log((parseInt(elep.style.width.replace("px", "")) - (evm.clientX - px)))
                                        if ((parseInt(elep.style.width.replace("px", "")) - (evm.clientX - px)) > minx) {
                                            elep.style.left = (elep.offsetLeft - (px - evm.clientX)) + "px"
                                            elep.style.width = (parseInt(elep.style.width.replace("px", "")) - (evm.clientX - px)) + "px"
                                        }
                                    }
                                //
                                //if (sel == 'resize-s' || sel == 'resize-n' || ) {
                                for (let iii = 0; iii != elem.parentElement.parentElement.parentElement.children.length; iii++) {
                                    //console.log(elem.parentElement.parentElement.parentElement.children.item(iii).className)
                                    if (elem.parentElement.parentElement.parentElement.children.item(iii).className == "content-root") {

                                        for (let iiii = 0; iiii != elem.parentElement.parentElement.parentElement.children.item(iii).children.length; iiii++) {
                                            if (elem.parentElement.parentElement.parentElement.children.item(iii).children.item(iiii).className == "scrollbar") {
                                                for (let iiiii = 0; iiiii != elem.parentElement.parentElement.parentElement.children.item(iii).children.item(iiii).children.length; iii++) {
                                                    if (elem.parentElement.parentElement.parentElement.children.item(iii).children.item(iiii).children.item(iiiii).className == "scrollbar-point") {
                                                        for (let iiiiii = 0; iiiiii != elem.parentElement.parentElement.parentElement.children.item(iii).children.length; iiiiii++) {

                                                            if (elem.parentElement.parentElement.parentElement.children.item(iii).children.item(iiiiii).className == "content-content") {

                                                                if (elem.parentElement.parentElement.parentElement.children.item(iii).clientHeight / (elem.parentElement.parentElement.parentElement.children.item(iii).children.item(iiiiii).clientHeight / elem.parentElement.parentElement.parentElement.children.item(iii).clientHeight) < elem.parentElement.parentElement.parentElement.children.item(iii).clientHeight) {
                                                                    elem.parentElement.parentElement.parentElement.children.item(iii).children.item(iiii).style.display = "block"
                                                                    elem.parentElement.parentElement.parentElement.children.item(iii).children.item(iiii).children.item(iiiii).style.height = (elem.parentElement.parentElement.parentElement.children.item(iii).clientHeight / (elem.parentElement.parentElement.parentElement.children.item(iii).children.item(iiiiii).clientHeight / elem.parentElement.parentElement.parentElement.children.item(iii).clientHeight))
                                                                    if (elem.parentElement.parentElement.parentElement.children.item(iii).children.item(iiii).children.item(iiiii).offsetTop > elem.parentElement.parentElement.parentElement.children.item(iii).children.item(iiii).clientHeight - elem.parentElement.parentElement.parentElement.children.item(iii).children.item(iiii).children.item(iiiii).clientHeight) {
                                                                        elem.parentElement.parentElement.parentElement.children.item(iii).children.item(iiii).children.item(iiiii).style.top = elem.parentElement.parentElement.parentElement.children.item(iii).children.item(iiii).clientHeight - elem.parentElement.parentElement.parentElement.children.item(iii).children.item(iiii).children.item(iiiii).clientHeight
                                                                    }
                                                                    //elem.parentElement.parentElement.parentElement.children.item(iii).children.item(iiii).children.item(iiiii).style.top = Math.min(elem.parentElement.parentElement.parentElement.children.item(iii).children.item(iiii).children.item(iiiii).style.top, elem.parentElement.parentElement.parentElement.children.item(iii).clientHeight)
                                                                } else {
                                                                    elem.parentElement.parentElement.parentElement.children.item(iii).children.item(iiii).style.display = "none"
                                                                }
                                                                break
                                                            }
                                                        }

                                                        break
                                                    }
                                                }
                                                break
                                            }
                                        }
                                        break
                                    }
                                }
                                //}
                                py = (evm.clientY)
                                px = (evm.clientX)

                            })
                        })
                    }
                })
                let temp
                let scrolling = false
                for (let ii = 0; ii != elec.length; ii++) {

                    if (elec.item(ii).className == 'content-root') {
                        //console.log(elec.item(ii).className)
                        temp = elec.item(ii).children
                        for (let iii = 0; iii != temp.length; iii++) {
                            //console.log(temp.item(iii).className)
                            if (temp.item(iii).className == 'scrollbar') {
                                temp = temp.item(iii).children
                                for (let iiii = 0; iiii != temp.length; iiii++) {
                                    //console.log(temp.item(iiii).className)
                                    if (temp.item(iiii).className == 'scrollbar-point') {
                                        elem = temp.item(iiii)

                                        for (let iiiii = 0; iiiii != elec.item(ii).children.length; iiiii++) {

                                            if (elec.item(ii).children.item(iiiii).className == 'content-content') {
                                                //console.log(elec.item(ii).children.item(iiiii), "hi")
                                                con = elec.item(ii).children.item(iiiii)
                                                elec.item(ii).onscroll = ((ev) => {
                                                    if (!scrolling) {
                                                        let aaaa = (elec.item(ii).clientHeight - elem.clientHeight)
                                                        let scro = (elec.item(ii).scrollTop / (elec.item(ii).scrollHeight - elec.item(ii).clientHeight))
                                                        //console.log(aaaa, (elec.item(ii).scrollHeight - elec.item(ii).clientTop))
                                                        elem.style.top = scro * aaaa
                                                    }
                                                })
                                                elem.onmousedown = ((ev) => {
                                                    let thi = elec.item(ii).children.item(iiiii)
                                                    let eel = temp.item(iiii)
                                                    document.body.style.cursor = 'grabbing'
                                                    eel.style.cursor = 'grabbing'
                                                    py = ev.clientY
                                                    document.body.style.userSelect = "none"
                                                    document.onmouseup = ((evu) => {
                                                        document.body.style.userSelect = "unset"
                                                        document.onmousemove = null
                                                        document.onmouseup = null
                                                        document.body.style.cursor = ''
                                                        eel.style.cursor = 'grab'
                                                        scrolling = false
                                                    })
                                                    document.onmousemove = ((evm) => {
                                                        scrolling = true
                                                        let z = (eel.offsetTop - (py - evm.clientY))
                                                        //let b = (elem.clientHeight - elem.offsetTop - (py - evm.clientY))
                                                        //console.log(elem.clientHeight/2 - elem.offsetTop - (py - evm.clientY))
                                                        //console.log(z, elem.parentElement.clientHeight - elem.clientHeight)
                                                        if (z >= 0 && z < eel.parentElement.clientHeight - eel.clientHeight) {
                                                            eel.style.top = z
                                                            thi.parentElement.scrollTop = ((z / (eel.parentElement.clientHeight - eel.clientHeight)) * (thi.scrollHeight - eel.parentElement.clientHeight + 24))
                                                        } else {
                                                            if (z < elem.parentElement.clientHeight - elem.clientHeight) {
                                                                elem.style.top = 0
                                                            } else {
                                                                elem.style.top = elem.parentElement.clientHeight - elem.clientHeight
                                                            }
                                                        }
                                                        py = (evm.clientY)
                                                    })
                                                })
                                                break
                                            }
                                        }

                                        break
                                    }
                                }
                                break
                            }
                        }
                        break
                    }
                }
                px = 0, py = 0;

                if (elem.className == 'scrollbar-point') {


                }



            }



        }
        function auto_resize(i) {

            i.style.height = (i.value.split("\n").length + 1) * 25
            refresh_windows()
        }
        let procs = {}
        function exe_com(a) {
            let exe;
            let id = a.parentElement.id.split("-")[0]

            let a_c = a.children;
            for (let i = 0; i != a_c.length; i++) {
                if (a_c.item(i).id == id + "-line") {
                    let inp = a_c.item(i).id
                    let a_p_c = a.parentElement.children
                    for (let ii = 0; ii != a_p_c.length; ii++) {
                        if (a_p_c.item(ii).id == id + "-history") {
                            let his = a_p_c.item(ii).id
                            if (procs[id] == undefined)
                                procs[id] = new jssh(fs, "/", id, inp, his, window_create)
                            procs[id].ex()
                            refresh_windows()
                            a.parentElement.parentElement.scrollTop = a.parentElement.parentElement.scrollHeight
                            break
                        }
                    }
                    break
                }
            }
        }
        function req(url) {
            let prom = new Promise((resolve, reject) => {
                var xhr = new XMLHttpRequest();
                xhr.open('GET', url, true);
                xhr.responseType = 'json';
                xhr.onload = function () {
                    resolve(xhr.response);
                };
                xhr.send();
            })
            return prom;
        }
        let fs = []
        function shortcut(i, shell = new jssh(fs, '/', document.getElementsByClassName('window').length, 'null', 'null', window_create)) {
            shell.ex_file(i)
        }
        function close_menu() {
            let items = document.getElementsByClassName("bar-menu-item")
            for (let item = 0; item != items.length; item++) {
                let i_c = items.item(item).children
                for (let i = 0; i != i_c.length; i++) {
                    let id = i_c.item(i)
                    if (id.className == "bar-menu-more-root") {
                        id.style.display = "none"
                    }
                }
            }
            document.getElementById("bar-menu-root").style.display = "none"

            load_bar()
        }



        async function main() {
            fs = await req('src/fs.json')
            fd = await util.fd({ path: '/', filetype: '*' })
            console.log(fd)
            document.getElementById("bar-menu").onclick = ((ev) => {
                if (document.getElementById("bar-menu-root").style.display == "block")
                    document.getElementById("bar-menu-root").style.display = "none"
                else
                    document.getElementById("bar-menu-root").style.display = "block"
            })
            load_bar()
        }

    </script>
</head>

<body onload="main()">
    <div id="root">
        <div id="bar">
            <div id="bar-children">
                <div id="bar-menu"><img src="./src/img/windows.png">
                    <pre> </pre>Start

                </div>
                <div id="bar-items">
                </div>


            </div>
        </div>
        <div id="bar-menu-root">
            <div class="bar-menu-item" id="bar-menu-windows-update"><img class="bar-menu-image"
                    src="./src/img/update.png">
                <div class="bar-menu-text">Windows Update</div>

            </div>
            <div class="bar-menu-separator"></div>
            <div class="bar-menu-item" id="bar-menu-programs" dir="/apps/"><img class="bar-menu-image"
                    src="./src/img/programs.png">
                <div class="bar-menu-text">Programs</div>
                <div class="bar-menu-more"></div>
                <div class="bar-menu-more-root">
                    <!--
                    <div class="bar-menu-item" id="bar-menu-favorites" shortcut-path=""><img class="bar-menu-image"
                            src="./src/img/notepad.png">
                        <div class="bar-menu-text">Notepad</div>
                    </div>
                    <div class="bar-menu-item" id="bar-menu-favorites"><img class="bar-menu-image"
                            src="./src/img/notepad.png">
                        <div class="bar-menu-text">Notepad--</div>
                    </div>-->
                </div>
            </div>
            <div class="bar-menu-item" id="bar-menu-favorites" dir="/fav/"><img class="bar-menu-image"
                    src="./src/img/favorites.png">
                <div class="bar-menu-text">Favorites</div>
                <div class="bar-menu-more"></div>
                <div class="bar-menu-more-root"></div>
            </div>
            <div class="bar-menu-item" id="bar-menu-docs" dir="/docs/"><img class="bar-menu-image"
                    src="./src/img/docs.png">
                <div class="bar-menu-text">Documents</div>
                <div class="bar-menu-more"></div>
                <div class="bar-menu-more-root"></div>
            </div>
            <div class="bar-menu-item" id="bar-menu-settings" dir="/settings/"><img class="bar-menu-image"
                    style="height:27px;padding-left:2px" src="./src/img/settings.png">
                <div class="bar-menu-text">Settings</div>
                <div class="bar-menu-more"></div>
                <div class="bar-menu-more-root"></div>
            </div>
            <div class="bar-menu-item" id="bar-menu-find" dir="/find/"><img class="bar-menu-image"
                    style="height:27px;padding-left:2px" src="./src/img/find.png">
                <div class="bar-menu-text">Find</div>
                <div class="bar-menu-more"></div>
                <div class="bar-menu-more-root"></div>
            </div>
            <div class="bar-menu-item" id="bar-menu-help"><img class="bar-menu-image" src="./src/img/help.png">
                <div class="bar-menu-text">Help</div>
            </div>
            <div class="bar-menu-item" id="bar-menu-run"><img class="bar-menu-image" src="./src/img/run.png">
                <div class="bar-menu-text">Run</div>
            </div>
            <div class="bar-menu-separator"></div>
            <div class="bar-menu-item" id="bar-menu-help"><img class="bar-menu-image" style="height:24px"
                    src="./src/img/log-off.png">
                <div class="bar-menu-text">Log Off...</div>
            </div>
            <div class="bar-menu-item" id="bar-menu-run"><img class="bar-menu-image" style="height:24px"
                    src="./src/img/shut-down.png">
                <div class="bar-menu-text">Shut Down...</div>
            </div>
        </div>
    </div>
</body>

</html>