pinokiod 1.3.28 → 1.3.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/kernel/api/fs/index.js +74 -3
- package/kernel/bin/conda.js +33 -6
- package/kernel/index.js +11 -2
- package/kernel/shell.js +5 -10
- package/kernel/shells.js +7 -0
- package/package.json +2 -2
- package/server/index.js +167 -53
- package/server/public/Socket.js +0 -1
- package/server/public/style.css +2 -4
- package/server/views/browser-experimental.ejs +440 -271
- package/server/views/browser.ejs +0 -3
- package/server/views/fullscreen_editor.ejs +3 -0
- package/server/views/index.ejs +1 -1
- package/server/views/partials/menu.ejs +3 -3
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
<link href="/style.css" rel="stylesheet"/>
|
|
13
13
|
<script src="/hotkeys.min.js"></script>
|
|
14
14
|
<script src="/sweetalert2.js"></script>
|
|
15
|
+
<script src="/nav.js"></script>
|
|
15
16
|
<script src="/opener.js"></script>
|
|
16
17
|
<script src="/report.js"></script>
|
|
17
18
|
<script src="/normalize.js"></script>
|
|
@@ -30,7 +31,9 @@
|
|
|
30
31
|
display: none;
|
|
31
32
|
height: 40px;
|
|
32
33
|
object-fit: contain;
|
|
34
|
+
/*
|
|
33
35
|
border-radius: 20px
|
|
36
|
+
*/
|
|
34
37
|
}
|
|
35
38
|
#menu.margin {
|
|
36
39
|
padding: 15px;
|
|
@@ -47,6 +50,7 @@ html, body {
|
|
|
47
50
|
margin: 0;
|
|
48
51
|
}
|
|
49
52
|
body {
|
|
53
|
+
display: flex;
|
|
50
54
|
}
|
|
51
55
|
.menu {
|
|
52
56
|
overflow: auto;
|
|
@@ -58,6 +62,7 @@ body.dark .m {
|
|
|
58
62
|
border-top: 1px solid rgba(0,0,0,0.04);
|
|
59
63
|
}
|
|
60
64
|
.container {
|
|
65
|
+
position: relative;
|
|
61
66
|
display: flex;
|
|
62
67
|
flex-direction: column;
|
|
63
68
|
flex-grow: 1;
|
|
@@ -200,17 +205,18 @@ body.dark .app-info > * {
|
|
|
200
205
|
display: flex;
|
|
201
206
|
*/
|
|
202
207
|
display: grid;
|
|
203
|
-
grid-template-columns: repeat(
|
|
208
|
+
grid-template-columns: repeat(4, 1fr);
|
|
204
209
|
}
|
|
205
210
|
.footer > * {
|
|
206
|
-
padding:
|
|
211
|
+
padding: 10px !important;
|
|
207
212
|
display: block;
|
|
208
213
|
box-sizing: border-box;
|
|
209
|
-
font-size:
|
|
214
|
+
font-size: 12px !important;
|
|
210
215
|
text-align: center;
|
|
211
216
|
}
|
|
212
217
|
.footer i {
|
|
213
218
|
margin: 0 !important;
|
|
219
|
+
padding: 5px;
|
|
214
220
|
}
|
|
215
221
|
.footer a {
|
|
216
222
|
font-size: 14px;
|
|
@@ -329,10 +335,18 @@ body.dark nav {
|
|
|
329
335
|
/*
|
|
330
336
|
border-bottom: 1px solid rgba(255,255,255,0.04);
|
|
331
337
|
*/
|
|
332
|
-
border-
|
|
338
|
+
border-top: 1px solid rgba(255,255,255,0.04);
|
|
339
|
+
}
|
|
340
|
+
.container:hover nav {
|
|
341
|
+
display: block;
|
|
333
342
|
}
|
|
334
343
|
nav {
|
|
344
|
+
display: none;
|
|
335
345
|
background: white;
|
|
346
|
+
position: absolute;
|
|
347
|
+
bottom: 0;
|
|
348
|
+
left: 0;
|
|
349
|
+
right: 0;
|
|
336
350
|
/*
|
|
337
351
|
padding: 5px;
|
|
338
352
|
*/
|
|
@@ -342,7 +356,7 @@ nav {
|
|
|
342
356
|
/*
|
|
343
357
|
border-bottom: 1px solid rgba(0,0,0,0.04);
|
|
344
358
|
*/
|
|
345
|
-
border-
|
|
359
|
+
border-top: 1px solid rgba(0,0,0,0.04);
|
|
346
360
|
box-sizing: border-box;
|
|
347
361
|
}
|
|
348
362
|
body.dark nav .btn2 {
|
|
@@ -439,6 +453,13 @@ body.dark .loader-container {
|
|
|
439
453
|
#menu-mobile {
|
|
440
454
|
display: none;
|
|
441
455
|
}
|
|
456
|
+
.tabmenu .label {
|
|
457
|
+
padding: 10px;
|
|
458
|
+
border-bottom: 1px solid rgba(255,255,255,0.04);
|
|
459
|
+
text-transform: uppercase;
|
|
460
|
+
font-size: 12px;
|
|
461
|
+
font-weight: bold;
|
|
462
|
+
}
|
|
442
463
|
@media only screen and (max-width: 480px) {
|
|
443
464
|
nav .btn2 {
|
|
444
465
|
width: auto !important;
|
|
@@ -483,17 +504,15 @@ body.dark .loader-container {
|
|
|
483
504
|
</style>
|
|
484
505
|
</head>
|
|
485
506
|
<body class='<%=theme%>' data-platform="<%=platform%>">
|
|
486
|
-
<
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
<
|
|
490
|
-
|
|
491
|
-
<
|
|
492
|
-
<
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
</nav>
|
|
496
|
-
<main>
|
|
507
|
+
<aside class='active'>
|
|
508
|
+
<!--
|
|
509
|
+
<div class='footer'>
|
|
510
|
+
<button class='btn header-item' id='clone-tab'><i class='fa-regular fa-copy'></i></button>
|
|
511
|
+
<a class='btn header-item' id='open-browser' target="_blank" href="" features="browser"><i class="fa-solid fa-square-arrow-up-right"></i></a>
|
|
512
|
+
<button class='btn header-item' id='reload'><i class="fa-solid fa-rotate-right"></i></button>
|
|
513
|
+
<div id='new-tab' class='btn header-item'><i class="fa-solid fa-plus"></i></div>
|
|
514
|
+
</div>
|
|
515
|
+
-->
|
|
497
516
|
<div class='header-top header-item'>
|
|
498
517
|
<div class='app-info'>
|
|
499
518
|
<% if (config.icon) { %>
|
|
@@ -527,13 +546,74 @@ body.dark .loader-container {
|
|
|
527
546
|
</a>
|
|
528
547
|
<%})%>
|
|
529
548
|
</div>
|
|
549
|
+
<div class='flexible'></div>
|
|
550
|
+
<!--
|
|
551
|
+
<div class='tabmenu'>
|
|
552
|
+
<div id='new-tab' class='btn header-item'><div class='tab'><i class="fa-solid fa-plus"></i> New</div></div>
|
|
553
|
+
<button class='btn header-item' id='clone-tab'><div class='tab'><i class='fa-regular fa-copy'></i> Clone</div></button>
|
|
554
|
+
<a class='btn header-item' id='open-browser' target="_blank" href="" features="browser"><div class='tab'><i class="fa-solid fa-square-arrow-up-right"></i> Popout</div></a>
|
|
555
|
+
<button class='btn header-item' id='reload'><div class='tab'><i class="fa-solid fa-rotate-right"></i> Refresh</div></button>
|
|
556
|
+
</div>
|
|
557
|
+
-->
|
|
558
|
+
<div class='grid-btns'>
|
|
559
|
+
<a class='btn2' href="/?mode=help"><div><i class="fa-regular fa-face-smile"></i></div><div>help</div></a>
|
|
560
|
+
<a class='btn2' href="/?mode=settings"><div><i class="fa-solid fa-gear"></i></div><div>config</div></a>
|
|
561
|
+
<a class='btn2' href="/"><div><i class="fa-solid fa-house"></i></div><div>home</div></a>
|
|
562
|
+
<button class='btn2' id='new-window' title='open a new window'><div><i class="fa-solid fa-plus"></i></div><div> window</div></button>
|
|
563
|
+
</div>
|
|
530
564
|
<!--
|
|
531
|
-
<div
|
|
532
|
-
<i class="fa-solid fa-
|
|
565
|
+
<div class='grid-btns'>
|
|
566
|
+
<a class='btn2' href="/?mode=explore" id='explore'><div><i class="fa-solid fa-globe"></i></div><div>Discover</div></a>
|
|
567
|
+
<a class='btn2' id='report'><div><i class="fa-solid fa-bug"></i></div><div>Report Bug</div></a>
|
|
568
|
+
<a class='btn2' href='https://discord.gg/TQdNwadtE4' target="_blank"><div><i class="fa-brands fa-discord"></i></div><div>Discord</div></a>
|
|
569
|
+
<a class='btn2' href='https://twitter.com/cocktailpeanut' target="_blank"><div><i class="fa-brands fa-twitter"></i></div><div>Twitter</div></a>
|
|
533
570
|
</div>
|
|
534
571
|
-->
|
|
535
|
-
|
|
536
|
-
|
|
572
|
+
</aside>
|
|
573
|
+
<div class='container'>
|
|
574
|
+
<nav>
|
|
575
|
+
<div class='bar'>
|
|
576
|
+
<button class='btn2' id='menu-mobile'><i class="fa-solid fa-bars"></i></button>
|
|
577
|
+
<button class='btn2' id='menu'>
|
|
578
|
+
<img src="<%=rawpath%>/<%=config.icon%>?raw=true"/>
|
|
579
|
+
<i class="fa-solid fa-arrow-right-to-bracket fa-rotate-180"></i>
|
|
580
|
+
</button>
|
|
581
|
+
<% if (agent === "electron") { %>
|
|
582
|
+
<button class='btn2' id='back'><i class="fa-solid fa-chevron-left"></i></button>
|
|
583
|
+
<button class='btn2' id='forward'><i class="fa-solid fa-chevron-right"></i></button>
|
|
584
|
+
<% } %>
|
|
585
|
+
<button class='btn2' id='clone-tab'><i class='fa-regular fa-copy'></i> Clone</button>
|
|
586
|
+
<a class='btn2' id='open-browser' target="_blank" href="" features="browser"><i class="fa-solid fa-square-arrow-up-right"></i> Popout</a>
|
|
587
|
+
<button class='btn2' id='reload'><i class="fa-solid fa-rotate-right"></i> Refresh</button>
|
|
588
|
+
<div id='new-tab' class='btn2'><i class="fa-solid fa-plus"></i> New</div>
|
|
589
|
+
<!--
|
|
590
|
+
<button class='btn2 logo' id='reload'><i class="fa-solid fa-rotate-right"></i></button>
|
|
591
|
+
-->
|
|
592
|
+
<input type='url' id='location' readonly>
|
|
593
|
+
<!--
|
|
594
|
+
<div id='location'></div>
|
|
595
|
+
-->
|
|
596
|
+
</div>
|
|
597
|
+
<!--
|
|
598
|
+
<div class='flexible'></div>
|
|
599
|
+
<a class='btn2' href="/?mode=explore"><div><i class="fa-solid fa-globe"></i></div><div>Discover</div></a>
|
|
600
|
+
<a class='btn2' id='report'><div><i class="fa-solid fa-bug"></i></div><div>Report Bug</div></a>
|
|
601
|
+
<a class='btn2' href='https://discord.gg/TQdNwadtE4' target="_blank"><div><i class="fa-brands fa-discord"></i></div><div>Discord</div></a>
|
|
602
|
+
<a class='btn2' href='https://twitter.com/cocktailpeanut' target="_blank"><div><i class="fa-brands fa-twitter"></i></div><div>Twitter</div></a>
|
|
603
|
+
-->
|
|
604
|
+
</nav>
|
|
605
|
+
<main class='browserview'>
|
|
606
|
+
<% if (false) { %>
|
|
607
|
+
<% if (config.menu) { %>
|
|
608
|
+
<% config.menu.forEach((item) => { %>
|
|
609
|
+
<% if (item.btn && item.src) { %>
|
|
610
|
+
<iframe name='<%=item.src%>' class='hidden'></iframe>
|
|
611
|
+
<% } %>
|
|
612
|
+
<% }) %>
|
|
613
|
+
<% } %>
|
|
614
|
+
<% } %>
|
|
615
|
+
</main>
|
|
616
|
+
</div>
|
|
537
617
|
<script>
|
|
538
618
|
let loaded = {}
|
|
539
619
|
let cursorIndex = 0;
|
|
@@ -587,47 +667,94 @@ const renderCursor = () => {
|
|
|
587
667
|
console.log({ cursorIndex, target })
|
|
588
668
|
target.classList.add("cursor")
|
|
589
669
|
}
|
|
670
|
+
const nav = (type) => {
|
|
671
|
+
let targetFrame = document.querySelector("iframe:not(.hidden)")
|
|
672
|
+
if (type === "back") {
|
|
673
|
+
// targetFrame.contentWindow.history.back()
|
|
674
|
+
targetFrame.contentWindow.postMessage({
|
|
675
|
+
action: "back"
|
|
676
|
+
}, "*")
|
|
677
|
+
} else if (type === "forward") {
|
|
678
|
+
// targetFrame.contentWindow.history.forward()
|
|
679
|
+
targetFrame.contentWindow.postMessage({
|
|
680
|
+
action: "forward"
|
|
681
|
+
}, "*")
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
// if (location.hash && location.hash.length > 0) {
|
|
687
|
+
//// let id = getTarget(location.hash.slice(1))
|
|
688
|
+
//// let target = document.querySelector("aside [target='" + id + "']")
|
|
689
|
+
// let id = location.hash.slice(1)
|
|
690
|
+
// let type = id[0]
|
|
691
|
+
// let index = id.slice(1)
|
|
692
|
+
// let target = document.querySelector(`aside .${type} [data-index='${index}']`)
|
|
693
|
+
// let targetFrame = document.querySelector(`iframe[name='${target.target}']`)
|
|
694
|
+
// console.log({ target, targetFrame })
|
|
695
|
+
// if (type === "back") {
|
|
696
|
+
// targetFrame.contentWindow.history.back()
|
|
697
|
+
// } else if (type === "forward") {
|
|
698
|
+
// targetFrame.contentWindow.history.forward()
|
|
699
|
+
// }
|
|
700
|
+
// /*
|
|
701
|
+
// targetFrame.contentWindow.postMessage({
|
|
702
|
+
// action: type
|
|
703
|
+
// }, "*")
|
|
704
|
+
// */
|
|
705
|
+
// }
|
|
706
|
+
}
|
|
590
707
|
const renderSelection = (e, force) => {
|
|
591
708
|
console.log("# 1")
|
|
592
|
-
if
|
|
709
|
+
// if the menu has a default item, or if the url specifies a selection
|
|
710
|
+
let selection = document.querySelector("[data-default]")
|
|
711
|
+
if (selection || location.hash && location.hash.length > 0) {
|
|
593
712
|
console.log("# 2")
|
|
594
|
-
// document.querySelector(".bar").classList.remove("hidden")
|
|
595
|
-
//let id = getTarget(location.hash.slice(1))
|
|
596
|
-
let id = location.hash.slice(1)
|
|
597
713
|
|
|
598
714
|
|
|
599
|
-
let
|
|
600
|
-
if (
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
let
|
|
604
|
-
let index = id.slice(1)
|
|
605
|
-
console.log({ type, index })
|
|
606
|
-
selector = `aside .${type} [data-index='${index}']`
|
|
607
|
-
}
|
|
715
|
+
let target
|
|
716
|
+
if (location.hash && location.hash.length > 0) {
|
|
717
|
+
// document.querySelector(".bar").classList.remove("hidden")
|
|
718
|
+
//let id = getTarget(location.hash.slice(1))
|
|
719
|
+
let id = location.hash.slice(1)
|
|
608
720
|
|
|
609
721
|
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
722
|
+
let selector
|
|
723
|
+
if (id.startsWith("@")) {
|
|
724
|
+
selector = `aside [target='${id.slice(1)}']`
|
|
725
|
+
} else {
|
|
726
|
+
let type = id[0]
|
|
727
|
+
let index = id.slice(1)
|
|
728
|
+
console.log({ type, index })
|
|
729
|
+
selector = `aside .${type} [data-index='${index}']`
|
|
730
|
+
}
|
|
614
731
|
|
|
615
732
|
|
|
733
|
+
// select the selected link
|
|
734
|
+
// document.querySelectorAll(".frame-link").forEach((el) => {
|
|
735
|
+
// el.classList.remove("selected")
|
|
736
|
+
// })
|
|
616
737
|
|
|
617
|
-
// const target = document.querySelector(`[target='${id}']`)
|
|
618
738
|
|
|
619
739
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
if (e
|
|
624
|
-
|
|
740
|
+
// const target = document.querySelector(`[target='${id}']`)
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
if (e) {
|
|
744
|
+
// If the renderSelection is triggered by an event, look for the frame-link that's triggering the event
|
|
745
|
+
if (e.target.classList.contains("frame-link")) {
|
|
746
|
+
target = e.target
|
|
747
|
+
} else {
|
|
748
|
+
target = e.target.closest(".frame-link")
|
|
749
|
+
}
|
|
625
750
|
} else {
|
|
626
|
-
target
|
|
751
|
+
// if not triggered by an event, look for the target from the location hash
|
|
752
|
+
target = document.querySelector(selector)
|
|
627
753
|
}
|
|
628
754
|
} else {
|
|
629
|
-
|
|
630
|
-
|
|
755
|
+
if (selection) {
|
|
756
|
+
target = selection
|
|
757
|
+
}
|
|
631
758
|
}
|
|
632
759
|
|
|
633
760
|
|
|
@@ -644,11 +771,11 @@ const renderSelection = (e, force) => {
|
|
|
644
771
|
// maximize container
|
|
645
772
|
// minimize aside
|
|
646
773
|
|
|
647
|
-
|
|
648
|
-
|
|
774
|
+
document.querySelector(".container").classList.add("active")
|
|
775
|
+
document.querySelector("aside").classList.remove("active")
|
|
649
776
|
} else {
|
|
650
|
-
|
|
651
|
-
|
|
777
|
+
document.querySelector(".container").classList.remove("active")
|
|
778
|
+
document.querySelector("aside").classList.add("active")
|
|
652
779
|
}
|
|
653
780
|
|
|
654
781
|
if (target) {
|
|
@@ -659,8 +786,8 @@ const renderSelection = (e, force) => {
|
|
|
659
786
|
let url = target.href
|
|
660
787
|
console.log("> url", url)
|
|
661
788
|
document.querySelector("#open-browser").href = url
|
|
662
|
-
|
|
663
|
-
|
|
789
|
+
document.querySelector("#clone-tab").setAttribute("data-href", url)
|
|
790
|
+
document.querySelector("#location").value = url
|
|
664
791
|
|
|
665
792
|
|
|
666
793
|
// select the selected target element (tab)
|
|
@@ -679,14 +806,18 @@ const renderSelection = (e, force) => {
|
|
|
679
806
|
// 2. if it's soft (".s")
|
|
680
807
|
// find using the name attribute
|
|
681
808
|
let targetFrame;
|
|
809
|
+
console.log("> A")
|
|
682
810
|
if (target.closest(".h")) {
|
|
811
|
+
console.log("> B")
|
|
683
812
|
let hardFrames = document.querySelectorAll(".browserview iframe[name^='@']")
|
|
684
|
-
let port = new URL(target.href).port
|
|
813
|
+
let port = new URL(target.href).port || 80
|
|
685
814
|
for(let frame of hardFrames) {
|
|
815
|
+
console.log("> C")
|
|
686
816
|
console.log({ src: frame.src, href: target.href, target: target.target })
|
|
687
817
|
// Types of links in the tab
|
|
688
|
-
if (String(port) === "
|
|
689
|
-
|
|
818
|
+
if (String(port) === "<%=port%>") {
|
|
819
|
+
console.log("> D")
|
|
820
|
+
// 1. running from <%=port%> => find a frame whose base URL matches the tab's base URL
|
|
690
821
|
// Pinokio links
|
|
691
822
|
let targetPath = new URL(target.href).pathname
|
|
692
823
|
let framePath = new URL(frame.src).pathname
|
|
@@ -699,6 +830,7 @@ const renderSelection = (e, force) => {
|
|
|
699
830
|
}
|
|
700
831
|
} else {
|
|
701
832
|
// 2. rest => find the frame whose src exactly matches the tab's url
|
|
833
|
+
console.log("> E")
|
|
702
834
|
if (target.href === frame.src) {
|
|
703
835
|
frame.name = target.target
|
|
704
836
|
targetFrame = frame
|
|
@@ -712,6 +844,7 @@ const renderSelection = (e, force) => {
|
|
|
712
844
|
} else if (target.closest(".n")) {
|
|
713
845
|
targetFrame = document.querySelector(`iframe[name='${target.target}']`)
|
|
714
846
|
}
|
|
847
|
+
console.log("targetFrame", targetFrame)
|
|
715
848
|
|
|
716
849
|
|
|
717
850
|
/*
|
|
@@ -738,6 +871,7 @@ const renderSelection = (e, force) => {
|
|
|
738
871
|
*/
|
|
739
872
|
|
|
740
873
|
if (targetFrame) {
|
|
874
|
+
console.log("> F")
|
|
741
875
|
targetFrame.classList.remove("hidden")
|
|
742
876
|
let mode = target.getAttribute("data-mode")
|
|
743
877
|
if (mode === "refresh") {
|
|
@@ -883,50 +1017,73 @@ const renderSelection = (e, force) => {
|
|
|
883
1017
|
}
|
|
884
1018
|
} else {
|
|
885
1019
|
console.log("# 14")
|
|
886
|
-
|
|
887
|
-
|
|
1020
|
+
document.querySelector(".container").classList.remove("active")
|
|
1021
|
+
document.querySelector("aside").classList.add("active")
|
|
1022
|
+
|
|
888
1023
|
}
|
|
889
1024
|
}
|
|
890
1025
|
console.log("loaded before", loaded)
|
|
891
1026
|
renderSelection()
|
|
892
1027
|
//renderCursor()
|
|
893
1028
|
console.log("loaded after", loaded)
|
|
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
|
-
|
|
1029
|
+
//Reporter()
|
|
1030
|
+
document.querySelector("#reload").addEventListener("click", (e) => {
|
|
1031
|
+
/*
|
|
1032
|
+
// get selected
|
|
1033
|
+
let target = document.querySelector(".selected").target
|
|
1034
|
+
location.hash = target
|
|
1035
|
+
// force refresh
|
|
1036
|
+
renderSelection(null, true)
|
|
1037
|
+
*/
|
|
1038
|
+
let frame = document.querySelector("iframe:not(.hidden)")
|
|
1039
|
+
frame.src = frame.src
|
|
1040
|
+
// frame.contentWindow.location.reload();
|
|
1041
|
+
})
|
|
1042
|
+
<% if (agent === "electron") { %>
|
|
1043
|
+
document.querySelector("#back").addEventListener("click", (e) => {
|
|
1044
|
+
nav("back")
|
|
1045
|
+
})
|
|
1046
|
+
document.querySelector("#forward").addEventListener("click", (e) => {
|
|
1047
|
+
nav("forward")
|
|
1048
|
+
})
|
|
1049
|
+
<% } %>
|
|
1050
|
+
|
|
1051
|
+
document.querySelector("#new-tab").addEventListener("click", async (e) => {
|
|
1052
|
+
const u = prompt("url")
|
|
1053
|
+
|
|
1054
|
+
if (u) {
|
|
1055
|
+
let url
|
|
1056
|
+
if (/^[ ]*http:/i.test(u)) {
|
|
1057
|
+
url = u
|
|
1058
|
+
} else if (/^[ ]*https:/i.test(u)) {
|
|
1059
|
+
url = u
|
|
1060
|
+
} else {
|
|
1061
|
+
let o = {}
|
|
1062
|
+
if (/^[0-9.:]/.test(u)) {
|
|
1063
|
+
o.forceHttp = true
|
|
1064
|
+
} else if (/^localhost/.test(u)) {
|
|
1065
|
+
o.forceHttp = true
|
|
1066
|
+
} else {
|
|
1067
|
+
o.forceHttps = true
|
|
1068
|
+
}
|
|
1069
|
+
url = normalizeURL(u, o)
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
if (url && url.trim().length > 0) {
|
|
1073
|
+
console.log("url", url)
|
|
1074
|
+
const { tab, frame } = await addTab(url)
|
|
1075
|
+
tab.click()
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
})
|
|
1079
|
+
document.querySelector("#clone-tab").addEventListener("click", async (e) => {
|
|
1080
|
+
const url = document.querySelector("#clone-tab").getAttribute("data-href")
|
|
1081
|
+
if (url && url.trim().length > 0) {
|
|
1082
|
+
console.log("url", url)
|
|
1083
|
+
const { tab, frame } = await addTab(url)
|
|
1084
|
+
tab.click()
|
|
1085
|
+
}
|
|
1086
|
+
})
|
|
930
1087
|
|
|
931
1088
|
const syncTabs = async () => {
|
|
932
1089
|
let tabs = []
|
|
@@ -949,39 +1106,39 @@ const syncTabs = async () => {
|
|
|
949
1106
|
})
|
|
950
1107
|
})
|
|
951
1108
|
}
|
|
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
|
-
|
|
1109
|
+
const addTab = async (url) => {
|
|
1110
|
+
let item = document.createElement("a")
|
|
1111
|
+
//let id = "ts" + Date.now()
|
|
1112
|
+
let index = document.querySelectorAll("aside .s .frame-link").length
|
|
1113
|
+
|
|
1114
|
+
let id = "s" + index
|
|
1115
|
+
// let id = url
|
|
1116
|
+
item.target = id
|
|
1117
|
+
item.href = url
|
|
1118
|
+
item.setAttribute("data-index", index)
|
|
1119
|
+
item.className = "btn header-item frame-link"
|
|
1120
|
+
item.innerHTML = `<div class='tab'><i class="fa-solid fa-link"></i><div class='display'>${url}</div><div class='flexible'></div><button class='btn2 del'><i class="fa-solid fa-xmark"></i></button></div>`
|
|
1121
|
+
|
|
1122
|
+
document.querySelector(".temp-menu").appendChild(item)
|
|
1123
|
+
|
|
1124
|
+
let frame = document.createElement("iframe")
|
|
1125
|
+
frame.name = id
|
|
1126
|
+
frame.src = item.href
|
|
1127
|
+
frame.setAttribute(
|
|
1128
|
+
"allow",
|
|
1129
|
+
"clipboard-read *; clipboard-write *; accelerometer *; ambient-light-sensor *; autoplay *; battery *; camera *; display-capture *; gamepad *; geolocation *; gyroscope *; hid *; identity-credentials-get *; microphone *; midi *; otp-credentials *; serial *;"
|
|
1130
|
+
)
|
|
1131
|
+
document.querySelector("main").appendChild(frame)
|
|
1132
|
+
|
|
1133
|
+
await syncTabs()
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+
return {
|
|
1137
|
+
tab: item,
|
|
1138
|
+
frame
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
}
|
|
985
1142
|
|
|
986
1143
|
|
|
987
1144
|
|
|
@@ -1043,124 +1200,124 @@ document.querySelector("#delete").addEventListener("click", async (e) => {
|
|
|
1043
1200
|
} else {
|
|
1044
1201
|
}
|
|
1045
1202
|
})
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1203
|
+
document.querySelector("aside").addEventListener("click", async (e) => {
|
|
1204
|
+
let target
|
|
1205
|
+
|
|
1206
|
+
|
|
1207
|
+
// delete
|
|
1208
|
+
if (e.target.classList.contains("del")) {
|
|
1209
|
+
target = e.target
|
|
1210
|
+
} else {
|
|
1211
|
+
target = e.target.closest(".del")
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
if (target) {
|
|
1215
|
+
e.preventDefault()
|
|
1216
|
+
e.stopPropagation()
|
|
1217
|
+
// Delete
|
|
1218
|
+
// delete link
|
|
1219
|
+
let el = target.closest(".frame-link")
|
|
1220
|
+
console.log("target", el.target)
|
|
1221
|
+
let iframe = document.querySelector("iframe[name='" + el.target + "']")
|
|
1222
|
+
console.log("iframe", iframe)
|
|
1223
|
+
if (iframe) {
|
|
1224
|
+
// delete iframe
|
|
1225
|
+
iframe.remove()
|
|
1226
|
+
}
|
|
1227
|
+
el.remove()
|
|
1228
|
+
// update tabs
|
|
1229
|
+
await syncTabs()
|
|
1230
|
+
|
|
1231
|
+
} else {
|
|
1232
|
+
// Select
|
|
1233
|
+
if (e.target.classList.contains("frame-link")) {
|
|
1234
|
+
target = e.target
|
|
1235
|
+
} else {
|
|
1236
|
+
target = e.target.closest(".frame-link")
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
|
|
1240
|
+
|
|
1241
|
+
if (target) {
|
|
1242
|
+
|
|
1243
|
+
// if data-confirm exists, ask for confirmation
|
|
1244
|
+
// if not, then just go forward
|
|
1245
|
+
let confirmText = target.getAttribute("data-confirm")
|
|
1246
|
+
if (confirmText && confirmText.length > 0) {
|
|
1247
|
+
const confirmed = confirm(confirmText)
|
|
1248
|
+
console.log('confirmed', confirmed)
|
|
1249
|
+
if (!confirmed) {
|
|
1250
|
+
e.preventDefault()
|
|
1251
|
+
e.stopPropagation()
|
|
1252
|
+
return
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
if (target.getAttribute("data-action")) {
|
|
1257
|
+
let actionStr = target.getAttribute("data-action")
|
|
1258
|
+
let action = JSON.parse(actionStr)
|
|
1259
|
+
console.log("action", action)
|
|
1260
|
+
if (action.method === "stop" && action.uri) {
|
|
1261
|
+
let socket = new Socket()
|
|
1262
|
+
socket.run({
|
|
1263
|
+
method: "kernel.api.stop",
|
|
1264
|
+
params: {
|
|
1265
|
+
uri: action.uri//"~" + location.pathname
|
|
1266
|
+
}
|
|
1267
|
+
}, (packet) => {
|
|
1268
|
+
console.log("packet", packet)
|
|
1269
|
+
if (packet.type === "result") {
|
|
1270
|
+
socket.close()
|
|
1271
|
+
// location.href = location.href
|
|
1272
|
+
}
|
|
1273
|
+
})
|
|
1274
|
+
}
|
|
1275
|
+
} else if (target.target === "_blank") {
|
|
1276
|
+
// nothing
|
|
1277
|
+
} else {
|
|
1278
|
+
if (target.classList.contains("reveal")) {
|
|
1279
|
+
// nested menu
|
|
1280
|
+
target.closest(".nested-menu").querySelector(".submenu").classList.toggle("hidden")
|
|
1281
|
+
e.preventDefault()
|
|
1282
|
+
e.stopPropagation()
|
|
1283
|
+
} else {
|
|
1284
|
+
//location.hash = target.target
|
|
1285
|
+
|
|
1286
|
+
|
|
1287
|
+
// let id = getTarget(target.getAttribute("href"))
|
|
1288
|
+
// console.log("ID", id, target.href)
|
|
1289
|
+
// location.hash = id
|
|
1290
|
+
|
|
1291
|
+
//location.hash = target.getAttribute("href")
|
|
1292
|
+
|
|
1293
|
+
if (target.closest(".h")) {
|
|
1294
|
+
location.hash = target.target
|
|
1295
|
+
} else {
|
|
1296
|
+
let index = target.getAttribute("data-index")
|
|
1297
|
+
let type = target.closest(".m").getAttribute("data-type")
|
|
1298
|
+
|
|
1299
|
+
|
|
1300
|
+
location.hash = type + index
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
document.querySelectorAll(".frame-link").forEach((el) => {
|
|
1304
|
+
el.classList.remove("selected")
|
|
1305
|
+
})
|
|
1306
|
+
target.classList.add("selected")
|
|
1307
|
+
|
|
1308
|
+
renderSelection(e)
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
|
|
1313
|
+
|
|
1314
|
+
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
|
|
1319
|
+
|
|
1320
|
+
})
|
|
1164
1321
|
const refresh = async () => {
|
|
1165
1322
|
console.log("REFRESH")
|
|
1166
1323
|
await new Promise((resolve, reject) => {
|
|
@@ -1176,37 +1333,49 @@ const refresh = async () => {
|
|
|
1176
1333
|
renderSelection()
|
|
1177
1334
|
}
|
|
1178
1335
|
window.addEventListener('message', (event) => {
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
} else {
|
|
1203
|
-
|
|
1336
|
+
|
|
1337
|
+
// only process the event it's coming from pinokio
|
|
1338
|
+
console.log("EVENT", event)
|
|
1339
|
+
let origin = event.origin
|
|
1340
|
+
if (origin) {
|
|
1341
|
+
let port = new URL(origin).port || 80
|
|
1342
|
+
console.log("port", port)
|
|
1343
|
+
if (String(port) === "<%=port%>") {
|
|
1344
|
+
console.log("Message received from the child: ", event); // Message received from child
|
|
1345
|
+
if (event.data) {
|
|
1346
|
+
if (event.data.action) {
|
|
1347
|
+
if (event.data.action.type === "newtab") {
|
|
1348
|
+
console.log("create tab", event.data.action.url)
|
|
1349
|
+
addTab(event.data.action.url)
|
|
1350
|
+
} else if (event.data.action.type === "title") {
|
|
1351
|
+
console.log("title", event.data)
|
|
1352
|
+
} else if (event.data.action.type === "location") {
|
|
1353
|
+
let url = event.data.action.url
|
|
1354
|
+
console.log({ action: event.data.action })
|
|
1355
|
+
document.querySelector("#open-browser").href = url
|
|
1356
|
+
//document.querySelector("#location").innerHTML = url
|
|
1357
|
+
document.querySelector("#location").value = url
|
|
1358
|
+
}
|
|
1359
|
+
} else if (event.data.type) {
|
|
1360
|
+
let asideHidden = (window.getComputedStyle(document.querySelector("aside")).display === "none")
|
|
1361
|
+
console.log("asideHidden", asideHidden)
|
|
1362
|
+
if (!asideHidden) {
|
|
1363
|
+
// refresh only if aside
|
|
1364
|
+
|
|
1365
|
+
if (event.data.type === 'disconnect') {
|
|
1366
|
+
refresh()
|
|
1367
|
+
} else {
|
|
1368
|
+
refresh()
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1204
1371
|
}
|
|
1372
|
+
} else {
|
|
1373
|
+
refresh()
|
|
1205
1374
|
}
|
|
1206
1375
|
}
|
|
1207
|
-
} else {
|
|
1208
|
-
refresh()
|
|
1209
1376
|
}
|
|
1377
|
+
|
|
1378
|
+
|
|
1210
1379
|
});
|
|
1211
1380
|
/*
|
|
1212
1381
|
document.addEventListener("keydown", (e) => {
|