pinokiod 1.3.28 → 1.3.29
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 +438 -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,92 @@ 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
|
-
|
|
715
|
+
let target
|
|
716
|
+
if (selection) {
|
|
717
|
+
target = selection
|
|
602
718
|
} else {
|
|
603
|
-
|
|
604
|
-
let
|
|
605
|
-
|
|
606
|
-
selector = `aside .${type} [data-index='${index}']`
|
|
607
|
-
}
|
|
719
|
+
// document.querySelector(".bar").classList.remove("hidden")
|
|
720
|
+
//let id = getTarget(location.hash.slice(1))
|
|
721
|
+
let id = location.hash.slice(1)
|
|
608
722
|
|
|
609
723
|
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
724
|
+
let selector
|
|
725
|
+
if (id.startsWith("@")) {
|
|
726
|
+
selector = `aside [target='${id.slice(1)}']`
|
|
727
|
+
} else {
|
|
728
|
+
let type = id[0]
|
|
729
|
+
let index = id.slice(1)
|
|
730
|
+
console.log({ type, index })
|
|
731
|
+
selector = `aside .${type} [data-index='${index}']`
|
|
732
|
+
}
|
|
614
733
|
|
|
615
734
|
|
|
735
|
+
// select the selected link
|
|
736
|
+
// document.querySelectorAll(".frame-link").forEach((el) => {
|
|
737
|
+
// el.classList.remove("selected")
|
|
738
|
+
// })
|
|
616
739
|
|
|
617
|
-
// const target = document.querySelector(`[target='${id}']`)
|
|
618
740
|
|
|
619
741
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
if (e
|
|
624
|
-
|
|
742
|
+
// const target = document.querySelector(`[target='${id}']`)
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
if (e) {
|
|
746
|
+
// If the renderSelection is triggered by an event, look for the frame-link that's triggering the event
|
|
747
|
+
if (e.target.classList.contains("frame-link")) {
|
|
748
|
+
target = e.target
|
|
749
|
+
} else {
|
|
750
|
+
target = e.target.closest(".frame-link")
|
|
751
|
+
}
|
|
625
752
|
} else {
|
|
626
|
-
target
|
|
753
|
+
// if not triggered by an event, look for the target from the location hash
|
|
754
|
+
target = document.querySelector(selector)
|
|
627
755
|
}
|
|
628
|
-
} else {
|
|
629
|
-
// if not triggered by an event, look for the target from the location hash
|
|
630
|
-
target = document.querySelector(selector)
|
|
631
756
|
}
|
|
632
757
|
|
|
633
758
|
|
|
@@ -644,11 +769,11 @@ const renderSelection = (e, force) => {
|
|
|
644
769
|
// maximize container
|
|
645
770
|
// minimize aside
|
|
646
771
|
|
|
647
|
-
|
|
648
|
-
|
|
772
|
+
document.querySelector(".container").classList.add("active")
|
|
773
|
+
document.querySelector("aside").classList.remove("active")
|
|
649
774
|
} else {
|
|
650
|
-
|
|
651
|
-
|
|
775
|
+
document.querySelector(".container").classList.remove("active")
|
|
776
|
+
document.querySelector("aside").classList.add("active")
|
|
652
777
|
}
|
|
653
778
|
|
|
654
779
|
if (target) {
|
|
@@ -659,8 +784,8 @@ const renderSelection = (e, force) => {
|
|
|
659
784
|
let url = target.href
|
|
660
785
|
console.log("> url", url)
|
|
661
786
|
document.querySelector("#open-browser").href = url
|
|
662
|
-
|
|
663
|
-
|
|
787
|
+
document.querySelector("#clone-tab").setAttribute("data-href", url)
|
|
788
|
+
document.querySelector("#location").value = url
|
|
664
789
|
|
|
665
790
|
|
|
666
791
|
// select the selected target element (tab)
|
|
@@ -679,14 +804,18 @@ const renderSelection = (e, force) => {
|
|
|
679
804
|
// 2. if it's soft (".s")
|
|
680
805
|
// find using the name attribute
|
|
681
806
|
let targetFrame;
|
|
807
|
+
console.log("> A")
|
|
682
808
|
if (target.closest(".h")) {
|
|
809
|
+
console.log("> B")
|
|
683
810
|
let hardFrames = document.querySelectorAll(".browserview iframe[name^='@']")
|
|
684
|
-
let port = new URL(target.href).port
|
|
811
|
+
let port = new URL(target.href).port || 80
|
|
685
812
|
for(let frame of hardFrames) {
|
|
813
|
+
console.log("> C")
|
|
686
814
|
console.log({ src: frame.src, href: target.href, target: target.target })
|
|
687
815
|
// Types of links in the tab
|
|
688
|
-
if (String(port) === "
|
|
689
|
-
|
|
816
|
+
if (String(port) === "<%=port%>") {
|
|
817
|
+
console.log("> D")
|
|
818
|
+
// 1. running from <%=port%> => find a frame whose base URL matches the tab's base URL
|
|
690
819
|
// Pinokio links
|
|
691
820
|
let targetPath = new URL(target.href).pathname
|
|
692
821
|
let framePath = new URL(frame.src).pathname
|
|
@@ -699,6 +828,7 @@ const renderSelection = (e, force) => {
|
|
|
699
828
|
}
|
|
700
829
|
} else {
|
|
701
830
|
// 2. rest => find the frame whose src exactly matches the tab's url
|
|
831
|
+
console.log("> E")
|
|
702
832
|
if (target.href === frame.src) {
|
|
703
833
|
frame.name = target.target
|
|
704
834
|
targetFrame = frame
|
|
@@ -712,6 +842,7 @@ const renderSelection = (e, force) => {
|
|
|
712
842
|
} else if (target.closest(".n")) {
|
|
713
843
|
targetFrame = document.querySelector(`iframe[name='${target.target}']`)
|
|
714
844
|
}
|
|
845
|
+
console.log("targetFrame", targetFrame)
|
|
715
846
|
|
|
716
847
|
|
|
717
848
|
/*
|
|
@@ -738,6 +869,7 @@ const renderSelection = (e, force) => {
|
|
|
738
869
|
*/
|
|
739
870
|
|
|
740
871
|
if (targetFrame) {
|
|
872
|
+
console.log("> F")
|
|
741
873
|
targetFrame.classList.remove("hidden")
|
|
742
874
|
let mode = target.getAttribute("data-mode")
|
|
743
875
|
if (mode === "refresh") {
|
|
@@ -883,50 +1015,73 @@ const renderSelection = (e, force) => {
|
|
|
883
1015
|
}
|
|
884
1016
|
} else {
|
|
885
1017
|
console.log("# 14")
|
|
886
|
-
|
|
887
|
-
|
|
1018
|
+
document.querySelector(".container").classList.remove("active")
|
|
1019
|
+
document.querySelector("aside").classList.add("active")
|
|
1020
|
+
|
|
888
1021
|
}
|
|
889
1022
|
}
|
|
890
1023
|
console.log("loaded before", loaded)
|
|
891
1024
|
renderSelection()
|
|
892
1025
|
//renderCursor()
|
|
893
1026
|
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
|
-
|
|
1027
|
+
//Reporter()
|
|
1028
|
+
document.querySelector("#reload").addEventListener("click", (e) => {
|
|
1029
|
+
/*
|
|
1030
|
+
// get selected
|
|
1031
|
+
let target = document.querySelector(".selected").target
|
|
1032
|
+
location.hash = target
|
|
1033
|
+
// force refresh
|
|
1034
|
+
renderSelection(null, true)
|
|
1035
|
+
*/
|
|
1036
|
+
let frame = document.querySelector("iframe:not(.hidden)")
|
|
1037
|
+
frame.src = frame.src
|
|
1038
|
+
// frame.contentWindow.location.reload();
|
|
1039
|
+
})
|
|
1040
|
+
<% if (agent === "electron") { %>
|
|
1041
|
+
document.querySelector("#back").addEventListener("click", (e) => {
|
|
1042
|
+
nav("back")
|
|
1043
|
+
})
|
|
1044
|
+
document.querySelector("#forward").addEventListener("click", (e) => {
|
|
1045
|
+
nav("forward")
|
|
1046
|
+
})
|
|
1047
|
+
<% } %>
|
|
1048
|
+
|
|
1049
|
+
document.querySelector("#new-tab").addEventListener("click", async (e) => {
|
|
1050
|
+
const u = prompt("url")
|
|
1051
|
+
|
|
1052
|
+
if (u) {
|
|
1053
|
+
let url
|
|
1054
|
+
if (/^[ ]*http:/i.test(u)) {
|
|
1055
|
+
url = u
|
|
1056
|
+
} else if (/^[ ]*https:/i.test(u)) {
|
|
1057
|
+
url = u
|
|
1058
|
+
} else {
|
|
1059
|
+
let o = {}
|
|
1060
|
+
if (/^[0-9.:]/.test(u)) {
|
|
1061
|
+
o.forceHttp = true
|
|
1062
|
+
} else if (/^localhost/.test(u)) {
|
|
1063
|
+
o.forceHttp = true
|
|
1064
|
+
} else {
|
|
1065
|
+
o.forceHttps = true
|
|
1066
|
+
}
|
|
1067
|
+
url = normalizeURL(u, o)
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
if (url && url.trim().length > 0) {
|
|
1071
|
+
console.log("url", url)
|
|
1072
|
+
const { tab, frame } = await addTab(url)
|
|
1073
|
+
tab.click()
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
})
|
|
1077
|
+
document.querySelector("#clone-tab").addEventListener("click", async (e) => {
|
|
1078
|
+
const url = document.querySelector("#clone-tab").getAttribute("data-href")
|
|
1079
|
+
if (url && url.trim().length > 0) {
|
|
1080
|
+
console.log("url", url)
|
|
1081
|
+
const { tab, frame } = await addTab(url)
|
|
1082
|
+
tab.click()
|
|
1083
|
+
}
|
|
1084
|
+
})
|
|
930
1085
|
|
|
931
1086
|
const syncTabs = async () => {
|
|
932
1087
|
let tabs = []
|
|
@@ -949,39 +1104,39 @@ const syncTabs = async () => {
|
|
|
949
1104
|
})
|
|
950
1105
|
})
|
|
951
1106
|
}
|
|
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
|
-
|
|
1107
|
+
const addTab = async (url) => {
|
|
1108
|
+
let item = document.createElement("a")
|
|
1109
|
+
//let id = "ts" + Date.now()
|
|
1110
|
+
let index = document.querySelectorAll("aside .s .frame-link").length
|
|
1111
|
+
|
|
1112
|
+
let id = "s" + index
|
|
1113
|
+
// let id = url
|
|
1114
|
+
item.target = id
|
|
1115
|
+
item.href = url
|
|
1116
|
+
item.setAttribute("data-index", index)
|
|
1117
|
+
item.className = "btn header-item frame-link"
|
|
1118
|
+
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>`
|
|
1119
|
+
|
|
1120
|
+
document.querySelector(".temp-menu").appendChild(item)
|
|
1121
|
+
|
|
1122
|
+
let frame = document.createElement("iframe")
|
|
1123
|
+
frame.name = id
|
|
1124
|
+
frame.src = item.href
|
|
1125
|
+
frame.setAttribute(
|
|
1126
|
+
"allow",
|
|
1127
|
+
"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 *;"
|
|
1128
|
+
)
|
|
1129
|
+
document.querySelector("main").appendChild(frame)
|
|
1130
|
+
|
|
1131
|
+
await syncTabs()
|
|
1132
|
+
|
|
1133
|
+
|
|
1134
|
+
return {
|
|
1135
|
+
tab: item,
|
|
1136
|
+
frame
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
}
|
|
985
1140
|
|
|
986
1141
|
|
|
987
1142
|
|
|
@@ -1043,124 +1198,124 @@ document.querySelector("#delete").addEventListener("click", async (e) => {
|
|
|
1043
1198
|
} else {
|
|
1044
1199
|
}
|
|
1045
1200
|
})
|
|
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
|
-
|
|
1201
|
+
document.querySelector("aside").addEventListener("click", async (e) => {
|
|
1202
|
+
let target
|
|
1203
|
+
|
|
1204
|
+
|
|
1205
|
+
// delete
|
|
1206
|
+
if (e.target.classList.contains("del")) {
|
|
1207
|
+
target = e.target
|
|
1208
|
+
} else {
|
|
1209
|
+
target = e.target.closest(".del")
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
if (target) {
|
|
1213
|
+
e.preventDefault()
|
|
1214
|
+
e.stopPropagation()
|
|
1215
|
+
// Delete
|
|
1216
|
+
// delete link
|
|
1217
|
+
let el = target.closest(".frame-link")
|
|
1218
|
+
console.log("target", el.target)
|
|
1219
|
+
let iframe = document.querySelector("iframe[name='" + el.target + "']")
|
|
1220
|
+
console.log("iframe", iframe)
|
|
1221
|
+
if (iframe) {
|
|
1222
|
+
// delete iframe
|
|
1223
|
+
iframe.remove()
|
|
1224
|
+
}
|
|
1225
|
+
el.remove()
|
|
1226
|
+
// update tabs
|
|
1227
|
+
await syncTabs()
|
|
1228
|
+
|
|
1229
|
+
} else {
|
|
1230
|
+
// Select
|
|
1231
|
+
if (e.target.classList.contains("frame-link")) {
|
|
1232
|
+
target = e.target
|
|
1233
|
+
} else {
|
|
1234
|
+
target = e.target.closest(".frame-link")
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
|
|
1238
|
+
|
|
1239
|
+
if (target) {
|
|
1240
|
+
|
|
1241
|
+
// if data-confirm exists, ask for confirmation
|
|
1242
|
+
// if not, then just go forward
|
|
1243
|
+
let confirmText = target.getAttribute("data-confirm")
|
|
1244
|
+
if (confirmText && confirmText.length > 0) {
|
|
1245
|
+
const confirmed = confirm(confirmText)
|
|
1246
|
+
console.log('confirmed', confirmed)
|
|
1247
|
+
if (!confirmed) {
|
|
1248
|
+
e.preventDefault()
|
|
1249
|
+
e.stopPropagation()
|
|
1250
|
+
return
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
if (target.getAttribute("data-action")) {
|
|
1255
|
+
let actionStr = target.getAttribute("data-action")
|
|
1256
|
+
let action = JSON.parse(actionStr)
|
|
1257
|
+
console.log("action", action)
|
|
1258
|
+
if (action.method === "stop" && action.uri) {
|
|
1259
|
+
let socket = new Socket()
|
|
1260
|
+
socket.run({
|
|
1261
|
+
method: "kernel.api.stop",
|
|
1262
|
+
params: {
|
|
1263
|
+
uri: action.uri//"~" + location.pathname
|
|
1264
|
+
}
|
|
1265
|
+
}, (packet) => {
|
|
1266
|
+
console.log("packet", packet)
|
|
1267
|
+
if (packet.type === "result") {
|
|
1268
|
+
socket.close()
|
|
1269
|
+
// location.href = location.href
|
|
1270
|
+
}
|
|
1271
|
+
})
|
|
1272
|
+
}
|
|
1273
|
+
} else if (target.target === "_blank") {
|
|
1274
|
+
// nothing
|
|
1275
|
+
} else {
|
|
1276
|
+
if (target.classList.contains("reveal")) {
|
|
1277
|
+
// nested menu
|
|
1278
|
+
target.closest(".nested-menu").querySelector(".submenu").classList.toggle("hidden")
|
|
1279
|
+
e.preventDefault()
|
|
1280
|
+
e.stopPropagation()
|
|
1281
|
+
} else {
|
|
1282
|
+
//location.hash = target.target
|
|
1283
|
+
|
|
1284
|
+
|
|
1285
|
+
// let id = getTarget(target.getAttribute("href"))
|
|
1286
|
+
// console.log("ID", id, target.href)
|
|
1287
|
+
// location.hash = id
|
|
1288
|
+
|
|
1289
|
+
//location.hash = target.getAttribute("href")
|
|
1290
|
+
|
|
1291
|
+
if (target.closest(".h")) {
|
|
1292
|
+
location.hash = target.target
|
|
1293
|
+
} else {
|
|
1294
|
+
let index = target.getAttribute("data-index")
|
|
1295
|
+
let type = target.closest(".m").getAttribute("data-type")
|
|
1296
|
+
|
|
1297
|
+
|
|
1298
|
+
location.hash = type + index
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
document.querySelectorAll(".frame-link").forEach((el) => {
|
|
1302
|
+
el.classList.remove("selected")
|
|
1303
|
+
})
|
|
1304
|
+
target.classList.add("selected")
|
|
1305
|
+
|
|
1306
|
+
renderSelection(e)
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
|
|
1311
|
+
|
|
1312
|
+
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
|
|
1317
|
+
|
|
1318
|
+
})
|
|
1164
1319
|
const refresh = async () => {
|
|
1165
1320
|
console.log("REFRESH")
|
|
1166
1321
|
await new Promise((resolve, reject) => {
|
|
@@ -1176,37 +1331,49 @@ const refresh = async () => {
|
|
|
1176
1331
|
renderSelection()
|
|
1177
1332
|
}
|
|
1178
1333
|
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
|
-
|
|
1334
|
+
|
|
1335
|
+
// only process the event it's coming from pinokio
|
|
1336
|
+
console.log("EVENT", event)
|
|
1337
|
+
let origin = event.origin
|
|
1338
|
+
if (origin) {
|
|
1339
|
+
let port = new URL(origin).port || 80
|
|
1340
|
+
console.log("port", port)
|
|
1341
|
+
if (String(port) === "<%=port%>") {
|
|
1342
|
+
console.log("Message received from the child: ", event); // Message received from child
|
|
1343
|
+
if (event.data) {
|
|
1344
|
+
if (event.data.action) {
|
|
1345
|
+
if (event.data.action.type === "newtab") {
|
|
1346
|
+
console.log("create tab", event.data.action.url)
|
|
1347
|
+
addTab(event.data.action.url)
|
|
1348
|
+
} else if (event.data.action.type === "title") {
|
|
1349
|
+
console.log("title", event.data)
|
|
1350
|
+
} else if (event.data.action.type === "location") {
|
|
1351
|
+
let url = event.data.action.url
|
|
1352
|
+
console.log({ action: event.data.action })
|
|
1353
|
+
document.querySelector("#open-browser").href = url
|
|
1354
|
+
//document.querySelector("#location").innerHTML = url
|
|
1355
|
+
document.querySelector("#location").value = url
|
|
1356
|
+
}
|
|
1357
|
+
} else if (event.data.type) {
|
|
1358
|
+
let asideHidden = (window.getComputedStyle(document.querySelector("aside")).display === "none")
|
|
1359
|
+
console.log("asideHidden", asideHidden)
|
|
1360
|
+
if (!asideHidden) {
|
|
1361
|
+
// refresh only if aside
|
|
1362
|
+
|
|
1363
|
+
if (event.data.type === 'disconnect') {
|
|
1364
|
+
refresh()
|
|
1365
|
+
} else {
|
|
1366
|
+
refresh()
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1204
1369
|
}
|
|
1370
|
+
} else {
|
|
1371
|
+
refresh()
|
|
1205
1372
|
}
|
|
1206
1373
|
}
|
|
1207
|
-
} else {
|
|
1208
|
-
refresh()
|
|
1209
1374
|
}
|
|
1375
|
+
|
|
1376
|
+
|
|
1210
1377
|
});
|
|
1211
1378
|
/*
|
|
1212
1379
|
document.addEventListener("keydown", (e) => {
|